Skip to content

fix(js): stabilize unresolved local import targets - #2645

Closed
rohit-jsfreaky wants to merge 1 commit into
Graphify-Labs:v8from
rohit-jsfreaky:fix/stable-unresolved-js-imports
Closed

rohit-jsfreaky wants to merge 1 commit into
Graphify-Labs:v8from
rohit-jsfreaky:fix/stable-unresolved-js-imports

Conversation

@rohit-jsfreaky

Copy link
Copy Markdown
Contributor

Fixes #2457.

Summary

When a static JS/TS import points to a local module that is absent from the scan, _resolve_js_import_path returns the attempted path. _import_js then 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:

  • emits the stable ref_<specifier> file-level imports_from target;
  • avoids emitting a named-symbol imports edge for a file that does not exist.

Tests

  • Added coverage for import { getFoo } from "./generated/api" where generated/api is 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.

@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.

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)

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.41 (graphifyy==0.9.41 on PyPI) (#2457). Credited in the release notes. Thanks @rohit-jsfreaky!

@safishamsi safishamsi closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

imports to a file absent from the scan (e.g. gitignored codegen) emit abs-path slug endpoints (residual of #2262)

2 participants