Skip to content

fix(serve): resolve qualified Python names like pkg.mod.func (#4366) - #4367

Closed
Mpasha17 wants to merge 2 commits into
Graphify-Labs:v8from
Mpasha17:fix/4366-qualified-symbol-lookup
Closed

Mpasha17 wants to merge 2 commits into
Graphify-Labs:v8from
Mpasha17:fix/4366-qualified-symbol-lookup

Conversation

@Mpasha17

@Mpasha17 Mpasha17 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Asking for miden_preflight.cli.main (or miden_preflight.engine.scan) found nothing, even though main()/scan() resolve fine. The dotted name tokenizes to miden_preflight cli main, which matches no label. The issue's graphify_node / resolved: semantic output comes from a wrapper outside this repo. Upstream get_node/get_neighbors/explain already fail closed with "No node matching…", so the wrong match itself doesn't come from here. Still, the qualified name should resolve.

What changed (graphify/serve.py): in _find_node_tiers, a dotted Python symbol (pkg.mod.func, pkg.mod.func(), or the pkg.mod:func entry-point form) is now mapped onto the existing path::symbol lookup. It checks pkg/mod.py and then pkg/mod/__init__.py, suffix-matched, so src/ layouts work. It's skipped when the raw query already exactly matches a node label, and when nothing matches it falls through to the old tiers. _tier_refusal treats a dotted hit as a symbol tier and not a file query, so a function plus a same-named method in that module come back as Ambiguous (for get_node/explain and path alike) instead of one of them being picked.

Testing

  • Live, on chapaevv123/miden-preflight @ d939705 after graphify update .: miden_preflight.cli.main and miden_preflight.cli:main now resolve to src/miden_preflight/cli.py main() L26, and miden_preflight.engine.scan resolves to engine.py scan() L158. Before, all three gave "No node matching". main() itself is still ambiguous because role_model.py also defines one, same as before.
  • Added two tests in tests/test_serve.py. Both fail on v8 and pass here.
  • ruff is clean. Full suite on 3.10/3.12/3.13/3.14: the only failures are the 16 that already fail on v8 (9 test_dm_*, 7 test_security safe_fetch/validate_url).

Not covered: pkg.mod.Class.method. Use path::.method() or the node id for that.

Fixes #4366

AI disclosure: written with help from Grok Bot. I reviewed the change and ran the tests myself.

…bs#4366)

pkg.mod.func, pkg.mod.func() and the pkg.mod:func entry-point form now
map onto the path::symbol lookup (pkg/mod.py or pkg/mod/__init__.py,
suffix-matched so src/ layouts work). A function and same-named method
in that module are refused as a tie instead of picking one.

Co-Authored-By: Grok Bot <[email protected]>
@Mpasha17
Mpasha17 requested a review from safishamsi as a code owner October 12, 2026 14:22
@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 12, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @Mpasha17. 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.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) (2 sampled, not proven).

Formal verification. PR-changed functions: 2/2 verified (0 proven, 2 may-equivalent, 0 distinguished) · 0 not verified.


Graphify review — findings

Adds dotted Python symbol resolution to node lookup: pkg.mod.func, pkg.mod.func() and the pkg.mod:func entry-point form map onto the path::symbol lookup against pkg/mod.py or pkg/mod/__init__.py, suffix-matched so src/ layouts resolve. This kicks in only when no node label matches the string literally, and a miss falls through to the ordinary tiers. In _resolve_single_node, several hits from one dotted symbol (say a function and a same-named method in the same module) are refused as ambiguous instead of being treated as a file query that picks the first member.

Worth a look

  • Dotted-symbol same-file tie refused only in _resolve_single_node, not in the other _tier_refusal callers — graphify/serve.py:1704 · 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 — 698 functions depend on the 377 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: _load_graph() — 23 callers, 3 callees
  • worse: _query_terms() — 20 callers, 3 callees
  • worse: _resolve_single_node() — 10 callers, 3 callees
  • worse: _find_node_tiers() — 4 callers, 6 callees

Verification — 698 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: 498 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

13 of 376 test file(s) selected (3%) via static blast radius.

  • tests/test_benchmark.py — impact
  • tests/test_benchmark_raw_graph.py — impact
  • tests/test_explain_same_file_tie.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_mcp_graph_view_cache.py — impact
  • tests/test_path_cli.py — impact
  • tests/test_query_induced_edges.py — impact
  • tests/test_query_mcp_direction.py — impact
  • tests/test_query_names_its_graph.py — impact
  • tests/test_serve.py — impact, changed-test
  • tests/test_serve_http.py — impact
  • tests/test_terraform.py — impact
  • tests/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.

Formal verification

No difference found (not proven): No behavior difference found in \_find\_node\_tiers (not a proof).

The verifier ran both versions of \_find\_node\_tiers on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in \_resolve\_single\_node (not a proof).

The verifier ran both versions of \_resolve\_single\_node on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

· 1 grounded finding(s) anchored inline below; 3 more finding(s) on lines outside this diff (see the check run).

Comment thread graphify/serve.py Resolved
…raphify-Labs#4366)

Moves the check out of _resolve_single_node so the path endpoint
(CLI path / MCP shortest_path) refuses pkg.mod.run the same way
get_node and explain do, instead of taking the first hit.

Co-Authored-By: Grok Bot <[email protected]>
@Mpasha17

Copy link
Copy Markdown
Contributor Author

Good catch, checked it live: path/shortest_path went through _resolve_path_endpoint, which calls _tier_refusal with file_query=True, so pkg.mod.run quietly took the function while get_node/explain called it ambiguous. Not a regression (v8's path gave the same answer via scoring) but it was inconsistent. Moved the check into _tier_refusal itself (77f4734) so every caller refuses that tie the same way, plus a test for the path endpoint. On the coupling note: the extra callee is a small helper that hands off to the existing path:: lookup. Inlining it would just make _find_node_tiers longer, so I'm leaving it.

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.88, just released to PyPI as graphifyy 0.9.88. Landed via an authorship-preserving cherry-pick (your commit keeps your name and counts on your contributor graph), which is why GitHub marks this closed rather than merged. Thanks @Mpasha17!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: graphify_node silently resolves qualified Python symbols to unrelated semantic matches

2 participants