feat: replace LSP enrichment with SCIP integration#39
Merged
mehrdadpfg merged 2 commits intomainfrom Mar 13, 2026
Merged
Conversation
…lity)
Replace the LSP-based enrichment pipeline with compiler-grade SCIP
(Source Code Intelligence Protocol) for precise cross-reference edges.
Key changes:
- Add SCIP reader, graph builder, and orchestrator modules
- Multi-layer edge fusion: ast-grep (0.10) + SCIP (0.15) with additive confidence
- Intra-class edge collapsing for Class/Trait/Interface/Enum parents
- Tier 3 node folding (fields, type_params, enum_variants → parent metadata)
- SCIP cache at ~/.codemem/scip-cache/{namespace}/ with save-after-success
- Stale SCIP node cleanup on re-index with orphan doc memory deletion
- Edge fusion deduplication: fuse_edges returns superseded ast-grep IDs
- persist_graph_only fast path for --skip-embed
- Remove 6 heavy MCP tools (enrich_codebase, analyze_codebase, etc.)
- Remove LSP modules and tests, add SCIP tests
- Backfill 8 ADRs from git history
- Remove examples/ directory (assets/ is canonical)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the entire LSP-based enrichment pipeline with compiler-grade SCIP (Source Code Intelligence Protocol) for precise, language-agnostic cross-reference edges.
Why SCIP over LSP?
LSP enrichment had fundamental limitations:
textDocument/definitionSCIP indexes are produced by compiler-frontend indexers (rust-analyzer, scip-typescript, scip-python, scip-java, etc.) and contain every definition and reference in a single protobuf file — the same data Sourcegraph uses for code navigation.
What changed
New: SCIP pipeline (
codemem-engine/src/index/scip/)mod.rs(reader).scipprotobuf →ScipDefinition,ScipReference,ScipExternalstructs. Handles symbol string parsing, kind inference, range extraction, definition extent inferencegraph_builder.rsorchestrate.rs~/.codemem/scip-cache/{namespace}/Multi-layer edge fusion
ast-grep (pattern-based, confidence 0.10) and SCIP (compiler-grade, confidence 0.15) edges are fused:
(src, dst, relationship)triple, confidences sum (0.25) and the ast-grep edge is supersededfuse_edges()returns superseded ast-grep edge IDs for removal from storageNode tiering & collapsing
method_a CALLS method_bwithin the sameimplblock becomes metadata on the class node)New relationship types
Added
TypeDefinition,Reads,Writes, andOverridestoRelationshipTypewith configurable edge weights inGraphConfig.Stale node cleanup
On re-index, SCIP nodes from previously-seen files that no longer appear in the new SCIP index are removed, along with their orphan
scip-doc:*memories.persist_graph_onlyfast pathNew engine method for
--skip-embedworkflows: persists graph nodes and edges without embedding or cross-repo linking. Useful for rapid iteration during development.Removed: LSP pipeline
index/lsp/(mod.rs, pyright.rs, tsserver.rs) — 898 linespersistence/lsp.rs— 445 linesRemoved: 6 heavy MCP tools
Removed tools that performed long-running analysis inside the MCP server (blocking the assistant):
enrich_codebase,analyze_codebase,enrich_git_historyenrich_security,enrich_performanceindex_codebase(moved to CLI-only viacodemem analyze)Tool count: 32 → 26. These operations now run exclusively through the CLI where progress can be displayed and timeouts aren't a concern.
New: 8 backfilled ADRs (
docs/adr/)Architecture Decision Records covering major design decisions from project history:
Housekeeping
examples/directory (assets/is the canonical location for agent/skill definitions)scipanddirsdependencies to codemem-engineTest plan
cargo clippy --workspace --all-targets -- -D warningscleancargo fmt --all -- --checkcleanscip_reader_tests.rs— 181 lines)scip_graph_builder_tests.rs— 850 lines)scip_orchestrate_tests.rs— 206 lines)fuse_edgesreturns superseded ast-grep IDspersist_graph_onlyskips embeddings🤖 Generated with Claude Code