Repository navigation
Conversation
A node id whose tokens also match another node's label was refused as ambiguous, with a message recommending the very id that was supplied. Give an id the same precedence _resolve_single_node already gives it for explain, so it resolves outright and only a genuine label tie is refused. Fixes #5361
|
Thanks for the pull request, @Arav-Arun. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · 0d4cb97bf659
Note
Merge confidence: 5/5 · Nothing blocking · 2 possible issues to check · 🟠 High impact
2 possible issues not confirmed
Path endpoint resolution now returns an exact graph node ID before checking label and path matches.
Full summary
Path endpoint resolution now returns an exact graph node ID before checking label and path matches. The tests cover that precedence in the CLI and MCP tool while preserving refusals for ambiguous labels.
No confirmed issues. We found 2 possible issues we couldn't confirm; see below.
Not confirmed (2 possible issues)
Leads worth a look; we didn't double-check these. They don't change the score.
Not confirmed · The MCP shortest_path test forces directed and multigraph flags that the sibling test does not, so it may load a different graph shape than Inspect source
Detailed review · not confirmed
The new MCP test rebuilds the graph with directed and multigraph set to True. The earlier MCP test in the same file loads the raw JSON as-is. If the decoy fixture's JSON sets those flags differently, this test exercises a graph the real loader never produces.
Line 610 builds the graph with json_graph.node_link_graph(raw, edges="links"), while line 673 merges in directed and multigraph overrides. The two tests therefore construct graphs differently, and only one of them matches the fixture as written.
-
The
_write_nodesoutput and the serve loader's graph construction were not visible, so it is unknown whether the flags already match the override. -
Found by the per-file sweep; not double-checked.
Not confirmed · The ambiguity test's docstring describes a decoy node that this test never builds, so it misstates what is covered. Inspect source
Detailed review · not confirmed
The docstring of test_path_still_refuses_genuinely_ambiguous_label says the decoy's label still names one node, but that test's graph has no decoy. The text describes a different test.
The graph at lines 651-657 contains only a_prepare, b_prepare and finish, and the test queries prepare() and finish directly. No node with the label demo src alpha prepare exists in that test, so the docstring's reference to the decoy's label is wrong.
-
The rest of the test body was not visible, so the exact assertions beyond line 666 were not checked.
-
Reference checks do not establish safe deletion for dynamic or external consumers.
-
Found by the per-file sweep; not double-checked.
Code graph and static checks · 913 functions depend on this change
Impact & health
Impact — 913 functions depend on the 280 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
main()— 129 callers, 3 callees - worse:
_shortest_path_text()— 28 callers, 7 callees
Formal checks — 913 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 779 function(s) in the blast radius were not formally verified this run
Test selection
28 of 607 test file(s) selected (5%) via static blast radius.
tests/test_4874_jvm_resolution.py— impacttests/test_affected_cli.py— impacttests/test_affected_path_file_node.py— impacttests/test_affected_seed_reference_forms.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_confidence_score_output.py— impacttests/test_edge_also_seen.py— impacttests/test_explain_same_file_tie.py— impacttests/test_extract.py— impacttests/test_file_label_disambiguation.py— impacttests/test_graph_context_cache_reload.py— impacttests/test_markdown_sections.py— impacttests/test_mcp_graph_view_cache.py— impacttests/test_path_cli.py— impact, changed-testtests/test_path_confidence.py— impacttests/test_path_type_member.py— impacttests/test_query_induced_edges.py— impacttests/test_query_mcp_direction.py— impacttests/test_query_names_its_graph.py— impacttests/test_query_seed_order.py— impacttests/test_query_seeds.py— impacttests/test_query_source_first.py— impacttests/test_serve.py— impacttests/test_serve_http.py— impacttests/test_terraform.py— impacttests/test_truncation_full_answer.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Every flagged function
main()ingraphify/__main__.py:808· 129 callers, 3 callees: 129 callers depend on it (afferent coupling)_shortest_path_text()ingraphify/serve.py:2739· 28 callers, 7 callees: fans out to 7 callees (efferent coupling); 28 callers depend on it (afferent coupling)
|
I reproduced #5361 independently and reached the same fix, so here's some extra verification for this approach:
I'm closing my duplicate #5373 in favour of this one. |
…batch Fold the Rust (#5380), C# (#5376) and PHP (#5362) AST-output changes into the unreleased _AST_CACHE_SCHEMA = 51 entry (alongside the GHSA-g6c9-j4vm-mwq4 bash change already there), so cached Rust/C#/PHP extractions re-run on the next build. Document the #5229 Python import-binding limitation (plain-module re-exports are left unresolved rather than chased) in ARCHITECTURE.md, and add the 0.9.115 changelog entries for the batch. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.115 via an authorship-preserving cherry-pick, so your commit keeps its credit. The exact-id-before-tier-matching fix (and the MCP |
What does this PR do?
Fixes #5361.
An endpoint that is an exact node id was refused as ambiguous when another node's label tokenized to the same words. The refusal recommended retrying with the full node id, which is what had just been supplied. Give an id the same precedence
_resolve_single_nodealready gives it forexplain(#5343): if the query is a node key, it resolves outright, and only a genuine label tie is refused.Reproduction
On 0.9.113, with the fixture from the issue:
exits 3 with
Ambiguous: 'demo::src_alpha_prepare' matches 2 nodes in different files.With this change it prints the one-hop routeprepare() --calls [EXTRACTED]--> finish()and exits 0.Why the tier match could not do it
_search_tokens("demo::src_alpha_prepare")and the decoy label"demo src alpha prepare"split into the same words, so_find_node_tiersput both nodes in the exact tier across two files, and_tier_refusalfired. The id is a unique graph key, so no other interpretation of the query can name a different node: resolving it outright cannot guess.A case-mismatched id (
DEMO::SRC_...) still goes through the tiers, the same limitation_resolve_single_node'slabel in Ghas.Type of change
How has this been tested?
tests/test_path_cli.py:shortest_pathtool shares the resolver and gets the same id precedencetests/test_path_cli.py30/30, and the resolver-adjacent suites (test_serve.py,test_path_confidence.py,test_path_type_member.py,test_affected_path_file_node.py) 265/265.