feat(#546,#550): defines-first tier0 candidates + call-graph distance ranking#608
Merged
Merged
Conversation
…-graph distance Two ranking changes attacking the same failure: structurally-relevant files losing to mention-dense lexical hits. Tier 0 candidate selection (#546): files were ordered by raw hit count with a max_results/5 per-file cap, so five mention-dense test files consumed the whole budget — 'codedb search indexFile' did not surface src/explore.zig or src/index.zig anywhere in 200 results. Files that define a symbol named by the query (outline scan, fast-load safe) now class above other code, which classes above docs. The defining files rank first; the reranker's +5 def-line bonus then works with real candidates. Call-graph distance (#550): undirected BFS (callers and callees) from every graph node whose name equals a query term, min hop distance per file, folded in as a >=1 multiplier (x1.5 at the definition, halving per hop) in both searchContentRanked and rerankAndFinalize. Gated so NL-only queries never pay: the graph builds only when a raw token exactly names a known symbol; identifier-shaped queries ensure the deferred (#564) symbol index pre-lock, mirroring the lazy word-index rebuild. CODEDB_NO_GRAPH_DISTANCE kills the signal; CODEDB_NO_CENTRALITY kills both graph signals. Benchmark (engram codedb-report, 30 git-derived queries): rescues 'indexFile' -> src/explore.zig from not-a-candidate to #2; misses drop 6/30 to 5/30. Aggregate MRR 0.42 vs 0.42 baseline (one test-file gold slips one place — the defines class deliberately prefers impl files over the test files this repo's fix-with-failing-test history uses as gold). codedb now outranks engram's structural reranker (0.42 vs 0.29), inverting the gap #546 was filed on. Suite: 811/811. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 11, 2026
search: structurally-relevant files rank below lexical hits (engram benchmark MRR 0.36 vs 0.58)
#546
Closed
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
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.
First structural slice of the ranking lane (#546 / #550). Does not close #550 (git co-change still to come); #546 is closed manually with this PR's evidence.
1. Defines-first Tier 0 candidate selection (the #546 starvation fix)
Tier 0 ordered candidate files by raw hit count with a
max_results/5per-file cap — five mention-dense test files ate the entire budget. Concretely, on the current index,codedb search indexFilereturned neither src/explore.zig nor src/index.zig anywhere in 200 results; the defining files were structurally invisible no matter what the reranker did.Files that define a symbol named by the query (case-insensitive outline scan — works on snapshot fast-load where symbol_index is deferred) now class above other code files, which class above docs. After:
src/index.zig(4indexFiledefinitions) leads,src/explore.zig:906 pub fn indexFile(...)right behind.2. Query-specific call-graph distance (#550 signal 1)
Undirected BFS — callers and callees — from every call-graph node whose name equals a query term; each reached file's min hop distance becomes a ≥1 multiplier (×1.5 at the definition, halving per hop, ×1.0 unreached) in both
searchContentRankedandrerankAndFinalize. Never a filter, mirroringcentralityBoost.Cost discipline:
CODEDB_NO_GRAPH_DISTANCEdisables the signal;CODEDB_NO_CENTRALITYdisables both graph signals (ensureCallGraph would repopulate call_centrality).Benchmark evidence (engram codedb-report, 30 git-derived queries, A/B against a clean release-tip binary)
indexFile→ src/explore.zigThe ~2% aggregate dip is one test-file gold slipping a place: this repo's git gold is test-heavy (every fix ships a failing test) and the defines class deliberately prefers implementation files — the behavior an agent wants. #546's own evidence rows are either already fixed by prior slices (navigation/searchContent/retrieval #1, daemon #3) or stale gold (src/explore.zig no longer lexically contains "correctness"/"validation"/"prefilter" — no lexical ranker can surface it; that's the #550 co-change signal's job). The MRR gap #546 was filed on (engram 0.58 vs codedb 0.36) is now inverted (codedb 0.42 vs engram 0.29–0.32).
Tests
issue-550: call-graph distance ranks structurally-near files above equal-lexical noise— pins the undirected walk (helper file is reached via the reverse edge only).🤖 Generated with Claude Code