Repository navigation
fix(js): stabilize unresolved local import targets - #2645
rohit-jsfreaky wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
This PR modifies the JavaScript/TypeScript import resolution logic in graphify/extract.py. When a static ES import resolves to a path that doesn't correspond to an actual file, the change now falls back to a stable ref-based target ID and clears the resolved path, rather than using the attempted path. A new test in tests/test_js_import_resolution.py covers the case of an unresolved relative import and asserts the expected ref target ID. The reviewer should note the change touches only the static ES import branch, and the diff header lists many other symbols in scope though the actual code change is localized to the _import_js function and the added test.
No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1424 functions depend on the 275 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
extract()— 433 callers, 41 callees (high)_rebuild_code()— 94 callers, 51 callees (high)extract_xaml()— 19 callers, 17 callees (high)dispatch_command()— 2 callers, 117 callees (high)extract_js()— 75 callers, 3 callees (high)_get_extractor()— 26 callers, 6 callees (high)run_pipeline()— 8 callers, 13 callees (high)collect_files()— 17 callers, 6 callees (high)- …and 2 more
Verification — 1424 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: 1284 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify \_import\_js.
The verifier did not have enough to check \_import\_js, 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: not verifiable: all 200 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)
|
Shipped in v0.9.41 ( |
Fixes #2457.
Summary
When a static JS/TS import points to a local module that is absent from the scan,
_resolve_js_import_pathreturns the attempted path._import_jsthen treated that path as resolved and generated absolute-path-derived IDs, causing graph churn between checkouts.This change treats a non-existent static import target as unresolved:
ref_<specifier>file-levelimports_fromtarget;importsedge for a file that does not exist.Tests
import { getFoo } from "./generated/api"wheregenerated/apiis absent. The regression asserts the stable reference target and no fabricated symbol edge.uv run pytest tests/test_js_import_resolution.py tests/test_ts_import_require.py tests/test_phantom_external_import.py tests/test_extract.py::test_extract_js_destructured_require_named_symbols tests/test_extract.py::test_extract_js_member_require_emits_property_symbol -q— 74 passed.uv run ruff check graphify/extract.py tests/test_js_import_resolution.py— passed.uv run pytest tests/ -q— 4,271 passed, 20 skipped. The 20 failures match the existing Windows/platform-sensitive baseline and do not exercise this static import path.