feat(index): tree-sitter AST extraction + schema v3 edges table#356
Merged
Conversation
Phase 2 of knowledge graph implementation. ## tree-sitter AST extraction (feature-gated) - Add ast.rs module with tree-sitter-based AST parsing for Rust, Go, Python, TypeScript - Cursor-based DFS traversal (tree-sitter 0.26 has no descendants()) - Kind-based child lookup (grammars lack named fields like name) - TypeScript export_statement unwrapping for exported declarations - Go const/var declaration support via const_spec/var_spec traversal - Wire extract_symbols() and extract_calls() to try tree-sitter first, fall back to regex for unsupported languages - Add extract_edges() for richer edge types (IMPORTS, IMPLEMENTS, INHERITS, CHILD_OF) - 10 new tests covering all 4 language extractors ## Schema v3 — edges table - Add edges table: source to target with typed relationship (CALLS, IMPORTS, IMPLEMENTS, INHERITS, CHILD_OF) - Migrate existing call_graph data into edges with kind=CALLS - Populate edges table during indexing when tree-sitter feature enabled - Add KgEdge, store_kg_edges(), clear_kg_edges_for_file() to graph.rs - 2 new schema migration tests ## Feature flag - All tree-sitter code behind --features tree-sitter - Default build has zero tree-sitter overhead - 4 language grammars statically linked (~454KB release binary) Test results: - Default: 705 pass, 0 fail - With tree-sitter: 714 pass, 0 fail (+9 new tests) - Clippy: 0 warnings both modes
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.
Phase 2 — Knowledge Graph: tree-sitter + edges table
What
--features tree-sitter)edgestable with typed relationships (CALLS, IMPORTS, IMPLEMENTS, INHERITS, CHILD_OF)edgestable when tree-sitter is enabledWhy
edgestable is a richer superset ofcall_graphfor future graph queriesChanges
Cargo.tomlsrc/index/ast.rssrc/index/extract.rssrc/index/schema.rssrc/index/graph.rssrc/index/mod.rsTest results
--features tree-sitter: 714 pass, 0 fail (+9 new)Key technical decisions
descendants()method, uses cursor-based DFSfind_child_by_kind()helpercall_graphtable preserved,edgesis additive