feat: graph-augmented search (index_graph, search_graph, graph_neighbors, hybrid_search)#47
Merged
Conversation
PairReviewer
approved these changes
Jun 8, 2026
PairReviewer
left a comment
Collaborator
There was a problem hiding this comment.
This PR introduces a graph-augmented search layer to VecGrep, blending semantic vector search with structural code relationships via a tree-sitter-based knowledge graph. The implementation is robust, with comprehensive error handling, input validation, and thorough testing. No bugs, security issues, or architectural violations were found; dependencies are correctly pinned and all new features are well-documented. The code is production-ready and can be merged as is.
Note
Review metadata for this run is included below.
Recent review info
Verdict: APPROVE
Inline comments: 0
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Pull Request
Type of Change
Description
Integrates a graphify-inspired knowledge graph alongside VecGrep's existing vector search, giving AI assistants both semantic similarity and structural code relationships in one plugin.
Vector search is strong for behavioural queries ("find code that does X") but blind to structure ("what calls this function?", "what does this class inherit?"). This PR adds a pure tree-sitter graph layer — no LLM required — and exposes it via 4 new MCP tools.
Token usage benchmarks (measured on VecGrep itself):
search_code(top_k=8)hybrid_search(top_k=8)search_graph(limit=8)Latency (median, 5 runs):
search_graphhybrid_searchsearch_codeRelated Issues / PRs
Closes #46
Changes Made
src/vecgrep/graph.py—GraphStoreclass: tree-sitter AST extraction,build(),search(),neighbors(),chunk_graph_scores(), JSON persistence via networkxsrc/vecgrep/server.py:index_graph(path, force)— builds the knowledge graph (496 nodes, 1251 edges on VecGrep itself)search_graph(query, path, limit)— keyword search over node labels, ~47 tokens avg, ~3msgraph_neighbors(node_id, path, depth)— callers/callees/imports/contains/inherits up to N hopshybrid_search(query, path, top_k, alpha)— blendsalpha * vector_score + (1-alpha) * graph_scorenetworkx>=3.2to core depstree-sitter==0.21.3— compatible withtree-sitter-languages 1.10.x(0.22+ broke the API)tests/test_graph.py— 23 tests covering extraction, search, neighbors, scores, disk reloadtests/conftest.py— preloadvecgrep.graphbeforetest_chunker_ast.pypatchessys.modulesCHANGELOG.md— Unreleased sectionREADME.md— Benchmarks section, graph tools docs, no emojisTesting
tests/test_graph.py, all passManual test results:
index_graph— built graph of VecGrep: 496 nodes, 1251 edges, 35 filessearch_graph("VectorStore")— exact match, score 1.00, degree 39graph_neighbors("VectorStore", depth=1)— 18 callers, 18 methods, correct parent classhybrid_search("VectorStore search method")— fixed wrong vector result (CHANGELOG.md -> store.py), graph_score 1.00Checklist
ruffpasses)Screenshots
index_graphoutput:search_graph("VectorStore")output:hybrid_searchresult quality fix: