Repository navigation
Conversation
explain and the get_node / get_neighbors MCP tools refused a name only when its winning match tier spanned several source files. Within one file (two classes each defining .send(), or per-file import stubs that carry no source file) the tie was broken by graph iteration order and one node was presented as the answer. path already refused that case with the node ids. Route all of them through one _tier_refusal helper, so explain, get_node, get_neighbors and the path endpoints refuse the same lookups. A plain file path keeps resolving to its file node. Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @alexwrite. 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.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; no formal proof of the changed code.
Graphify review — findings
Makes explain, get_node and get_neighbors refuse a label whose winning match tier holds several nodes in the same file (or several sourceless stubs), instead of returning whichever one graph iteration order puts first. All three now go through _resolve_single_node, which shares a new _tier_refusal check with the path endpoints, so every lookup refuses the same names. A plain file-path query still resolves to the file node, a node ID still picks one twin, and explain exits 1 on ambiguity and 0 on no match.
No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 692 functions depend on the 218 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
main()— 104 callers, 3 callees - worse:
_find_node_tiers()— 4 callers, 5 callees
Verification — 692 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 631 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
38 of 368 test file(s) selected (10%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_cloud_cta.py— impacttests/test_codebuddy.py— impacttests/test_dedup_shrink_refuses_force_write.py— impacttests/test_devin.py— impacttests/test_explain_cli.py— impacttests/test_explain_same_file_tie.py— impact, changed-testtests/test_extract_cli.py— impacttests/test_file_label_disambiguation.py— impacttests/test_global_add_tag_inference.py— impacttests/test_god_nodes_cli.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_hook_guard_token_match.py— impacttests/test_hook_out_of_project_paths.py— impacttests/test_hook_strict.py— impacttests/test_incomplete_build_guard.py— impacttests/test_install.py— impacttests/test_install_references.py— impacttests/test_mcp_graph_view_cache.py— impacttests/test_merge_chunks_validation.py— impacttests/test_multigraph_diagnostics.py— impacttests/test_no_dedup_flag.py— impacttests/test_opencode_plugin_refresh.py— impacttests/test_partial_cache.py— impacttests/test_path_cli.py— impacttests/test_query_cli.py— impacttests/test_query_induced_edges.py— impacttests/test_query_mcp_direction.py— impacttests/test_query_names_its_graph.py— impacttests/test_serve.py— impacttests/test_serve_http.py— impacttests/test_skill_auto_refresh.py— impacttests/test_stale_prune.py— impacttests/test_terraform.py— impacttests/test_unverified_semantic_shrink.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.
· 2 more finding(s) on lines outside this diff (see the check run).
The wording of a refusal among sourceless stubs depends on how stubs are grouped (one shared empty source, or one rival each), which is not what this test is about. Co-Authored-By: Claude <[email protected]>
Landed from PR #4320 (squashed, authorship preserved).
|
Landed in 0.9.86 (now on PyPI) via an authorship-preserving cherry-pick, so your commit authorship is retained. Thank you, @alexwrite! |
What does this PR do?
explainand the MCPget_node/get_neighborstools refuse a name only when its winning match tier spans several source files. When several nodes of one file carry the name, the tie is broken by graph iteration order and one node is printed as the answer, with nothing saying a choice was made.pathalready refuses that case (#3913, #3935) and lists the node ids.Two shapes seen on real graphs:
WebSocketRequestHandler.vmsg()andWebSocketServer.vmsg()in one Python file).explain ".vmsg()"printed one of them.source_file, so every stub ofEntityManagerInterfacecounts as the same "file".explain "EntityManagerInterface"printed the stub of one test file, with that stub's degree.Measured on three real PHP/JS/Python graphs (4.8k to 36.5k nodes), on 1,500 node labels drawn at random from each: 4, 12 and 22 labels resolved this way, silently.
Change. One helper,
_tier_refusal, now decides whether the winning tier names a single node._resolve_single_node(explain,get_node,get_neighbors) and_resolve_path_endpoint(path,shortest_path) both call it, so the four lookups refuse the same names with the same messages. A plain file path keeps its exception: its tier is the file node followed by its members, which is precedence, not a tie.The
explainCLI now resolves through_resolve_single_nodeinstead of its own copy of the cross-file check. Exit codes are unchanged here (a refusal still exits 1, a miss still exits 0); distinct exit codes are a separate PR.Type of change
Verification & Invariants
Invariant: a lookup by name answers with a node only when the name designates exactly one node; otherwise it lists the candidates and their ids. The answer never depends on node order in graph.json.
Persisted state: none. Read-only commands.
How was this tested?
Linux only; no filesystem, path or process code is touched.
Limitations
Node:line shows which node it is. Only a tie is refused.find_node_ambiguityis kept as is (public name) but is no longer called byexplain.