fix(query): five defects that returned wrong answers without erroring - #1577
Merged
Merged
Conversation
Each of these produced a plausible-looking result rather than a failure, which is the class an agent cannot detect and will act on. get_repository_stats inflated every per-repo count (#1529) The per-repository branch counted CONTAINS *paths*, not nodes. The writer creates File->CONTAINS->Function, Class->CONTAINS->Function and Function->CONTAINS->Function, so every method is reached 2+ times. On a live single-repo database this reported 2202 functions against 1551 real Function nodes, while the tool's own global branch reported 1551 — two branches of one tool disagreeing by 42%. The module counter already used count(DISTINCT m); the file, function and class counters now do too. find_callers misattributed callers across same-named functions (#1530) target_file_path was hoisted to the envelope from the first row and stripped from the rest, on the assumption it is constant. Without `context`, who_calls_function matches Function {name} across every file, so rows legitimately carry different targets and every caller was reported as calling whichever definition sorted first. Now hoisted only when the rows agree; otherwise the field stays per-row and the envelope carries a note naming the ambiguity. graph_name silently discarded for dead_code and find_complexity (#1531) Both inner methods default graph_name to None and re-assign the shared _active_graph, so omitting it at the dispatch site redirected the query to the default graph. On FalkorDB — the default, multi-graph backend — that returns results for the wrong repository with no error. count(*) after OPTIONAL MATCH, and a phantom collect() entry (#1533) An unmatched OPTIONAL MATCH still emits one null row, so count(*) meant injection_count was never 0 and every Spring bean reported at least one injector; now counts the bound relationship. Separately, a map literal is non-null even when every field inside is null, so collect() kept an all-null entry for a datasource with no key patterns; now collects the node and projects afterwards. add_code_to_graph advertised an argument it ignored (#1558) graph_name is in the tool schema but the handler never read it, so an agent could index into "service-a", be told it succeeded, and find nothing there. Honouring it needs a per-job writer threaded through the pipeline (GraphBuilder binds its GraphWriter to the default driver at construction), so this refuses explicitly instead. Full support stays open on #1558. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ |
Contributor
🔍 PR Code Graph Analysisfix(query): five defects that returned wrong answers without erroring (#1577) 📊 Interactive VisualizationView the blast radius graph: PR Reviewer Dashboard 📦 ArtifactsThe graph JSON has been uploaded as a build artifact: Generated by CodeGraphContext using FalkorDB Lite |
This was referenced Aug 5, 2026
Shashankss1205
added a commit
that referenced
this pull request
Aug 8, 2026
Ten PRs since 0.5.6 — mostly parser correctness, all with regression tests. Parsers - Ruby nested classes no longer delete their parent; method parameters extracted at all (#1523, #1527, #1581) - C/C++ functions returning a pointer or reference are extracted, and registered in pre_scan so they resolve as call targets (#1524, #1582) - C# fields and locals parsed, restoring receiver-type inference for `var x = new T(); x.M();` (#1525, #1584) - JavaScript destructured, array and rest parameters extracted, recording the binding names rather than a placeholder (#1527, #1591) Queries and analysis - Five defects that returned wrong answers without erroring: inflated repository stats, misattributed callers, discarded graph_name, count(*) after OPTIONAL MATCH, an ignored tool argument (#1577) - Dead-code detection made correct and self-consistent, including the JS module-level false positive (#600, #1559, #1578) Indexing - add_package_to_graph on a flat module no longer indexes the whole virtualenv (#1528, #1586) - SCIP job progress no longer exceeds 100% (#1535, #1583) Docs and tests - Database Options table columns realigned (#1590) - MCP tool definition contract validation (#1580) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #1529, #1530, #1531, #1558, and items 1–2 of #1533.
Full suite: 1101 passed, 19 skipped, no failures.
These are grouped because they share a failure mode: each returned a plausible-looking wrong answer instead of an error, which is the class an agent cannot detect and will act on.
CONTAINSpaths, not nodesfind_callershoisted row 0'starget_file_pathand stripped the restgraph_namenot forwarded tofind_dead_code/find_most_complex_functionscount(*)afterOPTIONAL MATCH;collect()of a map literalinjection_countnever 0; a phantom all-nullkey_patternsentryadd_code_to_graphadvertisedgraph_nameand ignored itNotes on two of them
#1530 keeps the payload-slimming that motivated the original code. The path is still hoisted when every row agrees — the common case, when
contextpinned one definition. It only stays per-row when the rows genuinely disagree, and then the envelope carries a note:#1558 is not fully fixed and the issue stays open. Honouring
graph_namefor indexing needs a per-jobGraphWriterthreaded through the pipeline —GraphBuilderbinds its writer to the default driver at construction (graph_builder.py:57). That is a real change with real risk to the core path, so this PR makes the tool refuse explicitly rather than write to the default graph and report success. Failing loudly beats misleading silently; the proper fix remains tracked.Tests
tests/unit/tools/test_query_correctness_batch.py— 8 tests. Verified they catch the bugs by reverting the source changes: 7 of 8 fail, the 8th being the hoist-when-rows-agree case, which is correct both before and after.One thing the tests caught while I wrote them: my first assertion for #1529 was too broad and flagged the global branch (
MATCH (f:File) RETURN count(f)), which has noCONTAINStraversal and is correct as-is. The assertion now targets the traversal shape specifically.🤖 Generated with Claude Code