Repository navigation
fix(solidity): resolve ../ imports to the real file - #4985
rohit-jsfreaky wants to merge 1 commit into
Conversation
A Solidity import was joined to the importer's folder without normalising it, so `import "../utils/Errors.sol"` from contracts/proxy/ pointed at a dangling contracts/proxy/utils/errors.sol stub whose id kept the checkout's absolute path. Normalise the joined path like the other extractors do (os.path.normpath). OpenZeppelin Contracts v5.4.0: 87 -> 681 of 681 Solidity imports_from edges reach a real file; no node ids carry the checkout path any more. Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @rohit-jsfreaky. 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; formal verification proved 0 of 1 changed function(s) (1 sampled, not proven).
Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.
Graphify review — findings
Fixes Solidity relative imports such as import "../x/Y.sol" so they resolve to the real file, instead of a dangling stub that kept the importer's own folder. The Solidity extractor also gets related edits to inherited-call and type-reference resolution, with tests covering enum values, free-function using sets and contract members and calls. Bumps _AST_CACHE_SCHEMA to 37, so cached Solidity extractions re-run once on the next build.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 3035 functions depend on the 126 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1116 callers, 66 callees
Verification — 3035 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: 1538 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
501 of 501 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_4874_jvm_resolution.py— full-run-safetytests/test_4909_reference_binding_scale.py— full-run-safetytests/test_affected_cli.py— full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— full-run-safetytests/test_affected_path_file_node.py— full-run-safetytests/test_affected_seed_reference_forms.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_alias_folding.py— full-run-safetytests/test_analyze.py— full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— full-run-safetytests/test_astro_import_ids.py— full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_backend_opt_in.py— full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_benchmark_real_query.py— full-run-safetytests/test_binary_media_words.py— impact, full-run-safetytests/test_blade_extractor.py— full-run-safetytests/test_build.py— full-run-safetytests/test_build_located_semantic_identity.py— full-run-safetytests/test_build_merge_dedup_scope.py— full-run-safetytests/test_build_merge_hyperedges_and_prune.py— full-run-safetytests/test_build_merge_shrink_guard.py— full-run-safetytests/test_builtin_global_type_refs.py— full-run-safetytests/test_c_include_resolution.py— full-run-safetytests/test_cache.py— impact, full-run-safetytests/test_cache_long_paths.py— impact, full-run-safetytests/test_cache_stale_import_target.py— impact, full-run-safetytests/test_cache_windows_case_4925.py— impact, full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— full-run-safetytests/test_case_only_decl_ids_4904.py— full-run-safetytests/test_case_sensitive_resolution.py— full-run-safetytests/test_charmap_encoding.py— impact, full-run-safetytests/test_chunking.py— impact, full-run-safetytests/test_cjs_module_extension.py— full-run-safetytests/test_claude_cli_backend.py— full-run-safety- … and 451 more
changed code file(s) with no mapped test (
graphify/extractors/solidity.py) — a coverage gap or a missing link — running the full suite rather than only the selected tests
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\_solidity (not a proof).
The verifier ran both versions of extract\_solidity 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).
|
Shipped in 0.9.102 (published to PyPI), with your authorship preserved. Fixes #4984. Thanks @rohit-jsfreaky. |
Closes #4984
What does this PR do?
While checking Solidity calls on OpenZeppelin I saw most imports going nowhere. The extractor joined the import path to the file's folder without normalising it, so
import "../utils/Errors.sol"incontracts/proxy/Clones.solpointed atcontracts/proxy/utils/errors.sol, a stub that does not exist, and that stub's id even kept my checkout's absolute path.The fix is one line:
Path(os.path.normpath(path.parent / relative)), which is what the other extractors inextract.pyalready do. I added a regression test and bumped the AST cache schema (36 to 37) because Solidity output changes.On OpenZeppelin Contracts v5.4.0 (319 files):
I also compared call links against the solc 0.8.28 AST before and after: same, inherited, super and modifier counts are identical, so nothing that worked before changed.
Not covered: remapped imports like
@openzeppelin/contracts/...need the project's remappings, so I left them out.Type of change
Verification & Invariants
Invariant: a Solidity
imports_fromedge targets the file the import names, using the same normalised path the file node is built from, so ids stay relative to the scan root../x.soland http(s) imports behave as before.How was this tested?
I did not run the full suite locally (low RAM on my laptop); CI runs it here.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (Not needed: no skill fragments changed.)