Skip to content

fix(query): reach the not-indexed marker on the not_found path - #885

Merged
tirth8205 merged 1 commit into
mainfrom
fix/not-found-confidence-reachability
Aug 19, 2026
Merged

fix(query): reach the not-indexed marker on the not_found path#885
tirth8205 merged 1 commit into
mainfrom
fix/not-found-confidence-reachability

Conversation

@tirth8205

Copy link
Copy Markdown
Owner

Follow-up to #884, found by smoke-testing the merged feature against this repository's own graph rather than trusting the tests.

The gap

query_graph returns early at query.py:375 with status: "not_found" for every pattern except consumers_of and file_summary. An unresolved target therefore never reached the empty-result path where #884 attaches the marker. The feature's most valuable case, telling an agent that a zero means "I never indexed this", was unreachable for 14 of the 16 query patterns in production. The original test did not catch it because it exercised file_summary, one of the two patterns that skip that branch.

The fix

Attach the marker to the not_found response, and check for an empty or stale graph before declaring a target simply unindexed. Priority now matches what semantic_search_nodes already did: empty graph, then stale graph, then genuinely not indexed.

A stale graph explains the miss and has a remedy, so it outranks wording that reads like a permanent parser limitation.

Verified against a real stale graph

This repository's checked-in graph was built on 2026-05-16 at commit 52cf3bc, with HEAD at 455a85a. Querying a function that plainly exists in the source:

Before:

status: not_found, confidence: (absent)

After #884 alone:

target not indexed: no node matching 'attach_context_savings', so this 0 is not evidence that none exist

After this change:

graph is stale: no node matching 'attach_context_savings'; the graph predates HEAD, so run `code-review-graph update` first

The first is silent, the second blames the parser, the third names the actual cause and the fix.

Tests

9 new tests: the marker is present on not_found across five patterns (the reachability regression), stale beats not-indexed, current graph still says not-indexed, empty graph says build, and a resolved target with results still carries no marker so the token guarantee holds on this path too.

Full suite 2768 passed, 5 skipped, 2 xpassed in a clean checkout. ruff and mypy clean.

query_graph returns early with status not_found for every pattern except
consumers_of and file_summary, so an unresolved target never reached the
empty-result path where the confidence marker is attached. The marker was
only observable through file_summary, which is what the original test used.

Attach it to the not_found response too, and check for an empty or stale
graph before declaring a target simply unindexed. A stale graph explains
the miss and has a remedy, so it outranks wording that reads like a
permanent parser limitation. Verified against this repository's own graph,
built three months and many commits behind HEAD: callers_of on a function
that plainly exists now says the graph predates HEAD and to update it,
where before it said the symbol was not indexed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012fHfGDiZedoxjpKzanHri3
@github-actions

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.75 (HIGH) — 8 changed function(s)/class(es), 0 affected flow(s), 1 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.75 high code_review_graph/tools/query.py::query_graph code_review_graph/tools/query.py:249 yes
0.35 low code_review_graph/uncertainty.py::unresolved_stale_note code_review_graph/uncertainty.py:248 no
0.35 low code_review_graph/uncertainty.py::empty_query_confidence code_review_graph/uncertainty.py:343 yes
0.05 low tests/test_uncertainty.py::test_not_found_response_carries_a_marker tests/test_uncertainty.py:485 (test)
0.05 low tests/test_uncertainty.py::test_unresolved_target_on_a_stale_graph_says_stale_not_unindexed tests/test_uncertainty.py:496 (test)
0.05 low tests/test_uncertainty.py::test_unresolved_target_on_a_current_graph_says_not_indexed tests/test_uncertainty.py:516 (test)
0.05 low tests/test_uncertainty.py::test_unresolved_target_on_an_empty_graph_says_build tests/test_uncertainty.py:531 (test)
0.05 low tests/test_uncertainty.py::test_resolved_target_with_results_still_has_no_marker tests/test_uncertainty.py:546 (test)

Test gaps

  • code_review_graph/uncertainty.py::unresolved_stale_note (code_review_graph/uncertainty.py:248)

Token savings: this graph-backed report used ~17,804 fewer tokens (~91%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant