Repository navigation
fix(serve): resolve an exact node id path endpoint before ranking (#5361) - #5373
Deepjyoti-Sarmah wants to merge 2 commits into
Conversation
|
Thanks for the pull request, @Deepjyoti-Sarmah. 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. |
|
Duplicate of #5367. |
There was a problem hiding this comment.
Graphify code review 
Review completed · f545ab5cf6e2
Tip
Merge confidence: 5/5 · Looks safe to merge · 🟠 High impact
No issues reported
Path endpoint resolution now returns a graph node immediately when the query exactly matches its ID, before considering label matches or ambiguity.
Full summary
Path endpoint resolution now returns a graph node immediately when the query exactly matches its ID, before considering label matches or ambiguity. The CLI and shortest-path tool both use this resolver.
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)
What does this PR do?
Fixes #5361. If you pass
graphify path(or theshortest_pathMCP tool) an exact node id, it now resolves to that node. Before, another node whose label tokenizes to the same words made the endpoint ambiguous. The refusal then told the caller to retry with the full node id, which they had already passed.The issue's fixture, on v8
b582ad40:With this PR it prints
Shortest path (1 hops):andprepare() --calls [EXTRACTED]--> finish().Why they tie:
_find_node_tiersputs both nodes in theexacttier.Two
exacthits in different files are refused by_tier_refusal. #5343 fixed the same case forexplain/get_node/get_neighborsby checkingif label in Gbefore ranking in_resolve_single_node._resolve_path_endpointis the sibling resolver and was missed. This PR adds the same two-line check there:The other fix I considered was moving the check into
_find_node_tiers, so every caller gets it. That also passed every test I ran. I didn't use it because it changes keywordquery/--seedranking as well, which this issue doesn't ask for. The narrow version uses the same rule #5343 already uses.Type of change
Verification & Invariants
Invariant: a string that is a node's id names exactly that node. Only queries that are not a node id go through ranking and the ambiguity checks.
Merge Danger
Door: two-way. Reverting
f545ab5crestores v8's behaviour. No cache or schema change.Blast Radius: small.
pathendpoints that are literally a node id. Those used to be refused whenever another node's label normalized to the same id, and now they resolve.path::symbol, file-path and scored endpoints take the same route as before.Limitations
query in G), as in MCP get_neighbors can resolve an exact node ID to a different file node #5343. An id typed in a different case still goes through ranking.How was this tested?
There are three new tests in
tests/test_path_cli.py, on the issue's fixture plus a secondprepare()ingamma.py:b582ad40f545ab5cFull suite, with v8 and this branch run at the same time in the same venv:
b582ad40f545ab5cruff check graphify/serve.py tests/test_path_cli.py-> All checks passed!Not tested: Windows.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched.)