Repository navigation
Conversation
…4439) A Rust `use` targets the bare, case-folded name it imports. That reached the declaration only when a type annotation in the corpus had left a sourceless node under the same id for the stub rewire to remap. Otherwise the edge dangled, and since 0.9.63 build mints the target as an external stub that ties with the real declaration in `affected` and `explain`. The `use` edge now carries the name as written, and the rewire is lent a sourceless node for each imported name that has none. The lent nodes are not kept, so an import with no unique declaration dangles exactly as before. Standard-library paths are left out. An incremental build re-extracts only the changed files, so the rewire also takes the unchanged ones as candidates; without that it resolved less than a full build. Bumps the AST cache schema: cached edges lack the name.
|
Thanks for the pull request, @bercedev. 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.
Code graph out of date: Health delta baseline: last indexed commit 6996bcd, 3 commit(s) behind this PR's base. Impact and hotspot numbers below may be wrong.
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
Fixes Rust use imports so they resolve to their corpus declaration whenever the imported name is declared exactly once, instead of only when a type annotation left a sourceless node to rewire. Each import edge is tagged with _rust_use_name (skipped for std/core/alloc), and extract lends _rewire_unique_stub_nodes a temporary stub per name, plus unchanged nodes on incremental builds; the stubs are discarded afterwards, so ambiguous or undeclared imports still dangle. Bumps _AST_CACHE_SCHEMA to 16, so cached ASTs are re-extracted.
Worth a look
- Imports from external (non-std) crates are rewired onto same-named local declarations —
graphify/extractors/rust.py:724· 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 — 3456 functions depend on the 458 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
walk()— 1 callers, 13 callees
Verification — 3456 functions in the blast radius were not formally verified this run (proofs are advisory here).
Health delta baseline: last indexed commit 6996bcd, 3 commit(s) behind this PR's base.
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: 3213 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
214 of 418 test file(s) selected (51%) via static blast radius.
tests/test_affected_overrides.py— impacttests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_blade_extractor.py— impacttests/test_build.py— impacttests/test_builtin_global_type_refs.py— impacttests/test_c_include_resolution.py— impacttests/test_cache.py— impacttests/test_cache_stale_import_target.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_cobol_extractor.py— impacttests/test_cpp_method_declarations.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cpp_template_type_params.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_language_call_resolution.py— impacttests/test_cross_repo_external_call_guards.py— impacttests/test_cross_repo_member_calls.py— impacttests/test_csharp_call_site_generic_args.py— impacttests/test_csharp_enum_members.py— impacttests/test_csharp_field_generic_args.py— impacttests/test_csharp_foreach_loop_variable.py— impacttests/test_csharp_generic_callsites.py— impacttests/test_csharp_interface_dispatch.py— impacttests/test_csharp_member_calls.py— impacttests/test_csharp_member_chain_calls.py— impacttests/test_csharp_member_nodes.py— impacttests/test_csharp_object_creation.py— impacttests/test_csharp_partial_classes.py— impacttests/test_csharp_tuple_type_refs.py— impacttests/test_csharp_type_resolution.py— impacttests/test_csharp_underscore_collisions.py— impacttests/test_csharp_var_call_return_type.py— impacttests/test_csharp_verbatim_interpolation.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_duplicate_annotation_edges.py— impacttests/test_ejs_extractor.py— impacttests/test_elixir_defdelegate.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_keyword_def_calls.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_erlang_extractor.py— impacttests/test_extract.py— impact- … and 164 more
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 extract (not a proof).
The verifier ran both versions of extract 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 extract\_rust (not a proof).
The verifier ran both versions of extract\_rust 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 more finding(s) on lines outside this diff (see the check run).
The review bot is right that `use serde::Serialize;` should not land on a local `Serialize`. Leaving out std/core/alloc was not enough: any other crate has the same problem. A `use` is now resolved only when its path starts at `crate`, `self` or `super`.
|
Thanks for taking this on, the by-name rewire is a clean, low-risk way to fix the case in #4439, and the second commit (only landing I ran this branch (
A four-file repro that shows 1 and 3 side by side is in the issue comment linked above (cross-crate The approach I took for those cases is in https://github.com/liam-mcelhaney122/graphify/tree/fix/rust-use-path-resolution. The edge carries the path as written ( If you'd rather fold any of this into this PR, or want me to split it differently, let me know. |
|
Thanks for running it against a real workspace, those numbers are really useful. I'd like to keep this one narrow so it stays easy to review, so please go ahead with the follow-up as you planned. Your module-tree and manifest resolution is the right place for cross-crate paths, re-exports and globs. Happy to rebase onto 17 if yours lands first. |
Eight community PRs: Windows MCP-stdio hang (#4441), Rust use->declaration (#4443), JS/TS file-scope callback param shadowing (#4457), sibling-file-id symbol retention (#4452), TS class-field receiver scoping (#4297), Ollama /api/chat num_ctx (#4414), cluster label retention on majority overlap (#4451), and an ingest symlink test fix (#4442). AST cache schema bumped to 16. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in 0.9.91 as ef1d256 + 5faa05c (cherry-picked with your authorship preserved, so it shows on your contributions). Thanks @bercedev! Released to PyPI: https://pypi.org/project/graphifyy/0.9.91/ |
What does this PR do?
Fixes #4439.
A Rust
useadds animports_fromedge whose target is the bare, case-folded name it imports (invoiceforuse crate::model::Invoice;). That only reached the declaration when a type annotation somewhere had left a sourceless node under the same id for_rewire_unique_stub_nodesto remap. When the type is only constructed or called, the edge dangled, and since 0.9.63 build mints the target as an external stub that ties with the real declaration, sographify affected Invoiceandgraphify explain Invoicestop resolving.What changes:
useedge carries the imported name as written (_rust_use_name, stripped before output like the other_rust_use_*markers), because the id has already folded its case and the rewire matches case-sensitively.crate,selforsuperis resolved.use serde::Serialize;oruse std::fs::File;names another crate's item, never the corpus's ownSerializeorFile(second commit, after the review bot's finding).resolution_context_nodesas candidates. Without that,watchresolved less than a full build andtest_incremental_builds_match_full_buildscaught it.I first tried emitting the stub from the extractor. That changed other passes (in-file call resolution bound to it, and the colliding-id pass renamed existing stubs), so the node only exists for the duration of the rewire.
Type of change
Verification & Invariants
Invariant: the only thing that moves is the target of a Rust
imports_fromedge whose name has exactly one declaration.I checked that on a real corpus, the RustDesk source tree (289
.rsfiles), comparingextract()output before and after:Limitations:
usepath says which one is meant (test_a_use_of_a_name_declared_twice_stays_unresolved).Configthroughcrate::, ause other_crate::Config;elsewhere follows it. On RustDesk about 38 of the 489 edges come from a path that is not rooted atcrate/self/super, mostlyhbb_common::andscrap::, which are workspace crates there. An annotation naming the type does the same today.use hbb_common::Foo;only lands when something else already resolved that name.tests/test_rust_use_trees.pypinned the bare target (parse,render) and now expect the declaration id. That is the behaviour change this PR is about, but it does edit tests that were written on purpose, so please look at those.resolution_context_nodeschange is on a path every language shares. The full suite passes; I have no incremental corpus for other languages to compare.How was this tested?
Linux, Python from the repo's
uv.lock.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.Note: I used Claude Code while working on this fix. I reviewed and ran all of it myself.