Repository navigation
Refuse an ambiguous name in graphify query - #4517
shivampal46011 wants to merge 1 commit into
Conversation
query guessed a node when the same name existed in several files, and an ambiguous --seed still exited 0. explain and path already refuse that lookup. query now returns the same candidate list and exits 3, and a --seed that matches nothing exits 4.
|
Thanks for the pull request, @shivampal46011. 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. |
|
Thanks @shivampal46011! One small thing: our changelog and release notes are built from PR titles, so we use the conventional-commits format, for example: Prefixes we use: |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 2 changed function(s) (1 not verified).
Formal verification. 1 change(s) alter behavior, breaking input(s) attached. PR-changed functions: 1/2 verified (0 proven, 0 may-equivalent, 1 distinguished) · 1 not verified (1 vacuous).
Behavior changes: \_query\_graph\_text changes behavior, here is the input that shows it.
The verifier found a concrete input on which \_query\_graph\_text behaves differently before and after the change. If that change is intended, ship it; if not, this is your bug.
Guarantee: This difference was REPRODUCED, the verifier actually ran both versions on that input and saw them disagree. It is real, not an artifact.
Evidence: On input \{"G":"\(lambda \_g: \(\_g\.add\_nodes\_from\(\[\(1, \{\}\), \(2, \{\}\), \(3, \{\}\)\]\), \_g\.add\_edges\_from\(\[\(1, 2, \{\}\), \(1, 3, \{\}\), \(2, 3, \{\}\)\]\), \_g\)\[\-1\]\)\(\_\_import\_\_\('networkx'\)\.Graph\(\)\)","question":"' x '"\}, the old code produced 'No matching nodes found\.' but the new code produces raises AttributeError. Paste that input straight into a regression test.
Not verified on this run: dispatch\_command (vacuous: never exercised).
Graphify review — findings
Makes graphify query refuse ambiguous input the way explain and path already do. A question that names one symbol shared by nodes in different files, or an ambiguous --seed, now prints the ambiguity message and exits with EXIT_AMBIGUOUS instead of guessing a node. Sentences that aren't a node name still fall through to keyword scoring, and a --seed that matches nothing keeps EXIT_NOT_FOUND. In _query_graph_text, the refusal is only returned when no seed resolves, so with several seeds an ambiguous one can be skipped while the others still run the query.
Worth a look
- Ambiguous seed silently dropped when another seed resolves —
graphify/serve.py:1442· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 778 functions depend on the 254 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_query_graph_text()— 48 callers, 7 callees
Verification — 778 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: 735 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
45 of 432 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_benchmark_real_query.py— impacttests/test_cli_export.py— impacttests/test_cloud_cta.py— impacttests/test_codebuddy.py— impacttests/test_compact_graph_json.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— impacttests/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_lookup_exit_codes.py— impact, changed-testtests/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_query_seed_order.py— impacttests/test_query_seeds.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_truncation_full_answer.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.
Formal verification
Behavior changes: \_query\_graph\_text changes behavior, here is the input that shows it.
The verifier found a concrete input on which \_query\_graph\_text behaves differently before and after the change. If that change is intended, ship it; if not, this is your bug.
Guarantee: This difference was REPRODUCED, the verifier actually ran both versions on that input and saw them disagree. It is real, not an artifact.
Evidence: On input \{"G":"\(lambda \_g: \(\_g\.add\_nodes\_from\(\[\(1, \{\}\), \(2, \{\}\), \(3, \{\}\)\]\), \_g\.add\_edges\_from\(\[\(1, 2, \{\}\), \(1, 3, \{\}\), \(2, 3, \{\}\)\]\), \_g\)\[\-1\]\)\(\_\_import\_\_\('networkx'\)\.Graph\(\)\)","question":"' x '"\}, the old code produced 'No matching nodes found\.' but the new code produces raises AttributeError. Paste that input straight into a regression test.
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
· 1 more finding(s) on lines outside this diff (see the check run).
…#4517) The ambiguous-name refusal added in #4517 routed through _resolve_single_node, whose winning tier can be a prefix or substring match, so a bare search keyword that merely substring-matched several labels was wrongly refused: `query "client"` returned EXIT 3 because it is a substring of `AlphaClient`/`BetaClient`. That narrowed query's keyword-search semantics. Adds _query_name_refusal, which refuses only when the term EXACTLY names several nodes (the source_exact/exact tiers) -- #4511's `.nonce()` case -- and otherwise falls through to scoring. The `query` and `--seed` paths use it; explain/path/ get_node keep _resolve_single_node, whose prefix/substring tiers are correct for a direct node lookup. Adds a regression test that a substring keyword still searches. Co-Authored-By: shivampal46011 <[email protected]> Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in 0.9.93, cherry-picked to preserve your authorship. |
What does this PR do?
Fixes #4511.
graphify explainandgraphify pathrefuse a name that matches several nodes and exit 3.graphify queryscored the question and silently picked one node, so exit code 0 could mean either a real answer or a guess. An ambiguous--seedprinted a refusal and still exited 0.querynow uses the same uniqueness check asexplain:--seedexits 3--seedthat matches nothing exits 4This change was written with AI assistance.
Type of change
Verification & Invariants
The lookup contract is: a name that matches several nodes is refused with the candidates listed, and the exit code tells a script which outcome it got (
0answer,3ambiguous,4no match). Keyword scoring of a real question is unchanged.A multi-word question is not treated as a node name, so it still searches by keywords even when one of its words is a common symbol.
How was this tested?
29 passed.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.