fix(graph): restore linear-scan fallback in find_ending_with#557
fix(graph): restore linear-scan fallback in find_ending_with#557ChetanyaRathi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the find_ending_with method in codebase_rag/graph_updater.py to ensure that if a suffix is not found in _simple_name_lookup, the method correctly falls back to scanning all entries instead of returning an empty list. A new unit test has been added in codebase_rag/tests/test_trie_optimization.py to verify this fallback behavior. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR fixes
Confidence Score: 5/5The change is narrowly scoped to restoring the intended fallback path and is covered by focused regression tests. The updated conditional preserves the optimized lookup-hit behavior while allowing misses to use the existing full registry scan, and the tests cover the affected branches.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(graph): restore linear-scan fallback..." | Re-trigger Greptile |
|
T-Rex pricing update — T-Rex was free through June 2026. Effective July 1, 2026, T-Rex adds 2 credits on top of the standard 1-credit review (3 total). T-Rex settings |
|
The failing CI checks all error within ~2s, which looks like a shared setup |
|
Non-blocking: since |
|
Traced this in graph_updater.py. The divergence isn't a parser mutating the I've updated the root-cause note to reflect that. I verified the fallback |
Summary
Fixes a bug where
FunctionRegistryTrie.find_ending_with()silently dropped call-resolution results when_simple_name_lookupwas populated but did not contain the searched suffix.The method returned an empty result in that case instead of falling through to the linear scan over
_entries, so any qualified name ending in.<suffix>was lost. This affects repos where a function is registered in the trie but its simple name is not indexed in_simple_name_lookup(generated names, IIFE patterns, some JS/TS module edge cases).Root cause
find_ending_withhas two paths: a fast path over_simple_name_lookupand alinear scan over
_entries._simple_name_lookupis optional — it is passed inat construction and defaults to
None(graph_updater.py:64-65), and whenpresent it is kept in sync by
insertitself (graph_updater.py:117-118). So thetwo failure-free cases are: lookup is
None(scan runs) and lookup is presentand complete (fast path hits).
The pre-fix bug surfaced only in a third state — a lookup that is present but
does not contain the queried suffix. In that case the old code returned
[]instead of falling back to the
_entriesscan. The fix restores the fallback soa present-but-incomplete lookup degrades to the scan rather than dropping the
result.
Note: because
insertmaintains a present lookup, this incomplete-lookup stateis not produced by
insertalone; it requires the lookup to be populated by aseparate path. I verified the fallback behavior directly via the added unit
test, but I have not identified that construction path in the current tree, so
I'm treating the axios impact figure as reported in #513 rather than one I
traced.
Impact
14 CALLS relationships were silently dropped on the axios repo (JavaScript). Any repo whose functions are registered in the trie without their simple names being indexed in
_simple_name_lookupwas affected.How it was found
Surfaced by expanding the benchmark suite from 2 repos (requests, tree-sitter) to 10 repos across the supported languages — the original two never exercised the failing path, but axios did.
Test plan
Added a regression test (
test_find_ending_with_falls_back_when_suffix_missing_from_lookup) covering all three branches:_simple_name_lookup is None, lookup present and containing the suffix, and lookup present but missing the suffix (the bug state). Verified it fails on the pre-fix code and passes with the fix. Fulltest_trie_optimization.pysuite passes.Fixes #513