Repository navigation
fix(js): retain lazy CommonJS require dependencies - #2749
rajanpanth 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 extraction logic in graphify/extractors/engine.py to detect CommonJS require() imports that appear inside function bodies (not just at the module top level) and attribute those import edges to the enclosing callable rather than dropping them. It renames the file_nid parameter to importer_nid in _require_imports_js to reflect that the import source may now be a function rather than a file, and adds a call to this helper during the function-body walk in _extract_generic. A new test (test_extract_js_function_scoped_require_emits_import_edge) is added to exercise the lazy/function-scoped require path, asserting the resulting import edge is sourced from the enclosing function. The many other changed symbols in the diff summary appear to be incidental (e.g., line-number-shifted rationale/test identifiers) rather than direct edits.
No blocking issues surfaced. 4 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 897 functions depend on the 534 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
walk_calls()— 1 callers, 16 callees - worse:
_require_imports_js()— 3 callers, 5 callees
Verification — 897 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: 838 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify \_extract\_generic.
The verifier did not have enough to check \_extract\_generic, 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: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set
Could not verify: Could not verify \_require\_imports\_js.
The verifier did not have enough to check \_require\_imports\_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)
· 1 grounded finding(s) anchored inline below; 1 more finding(s) on lines outside this diff (see the check run).
| return None | ||
|
|
||
| def _require_imports_js(node, source: bytes, file_nid: str, stem: str, edges: list, str_path: str) -> bool: | ||
| def _require_imports_js(node, source: bytes, importer_nid: str, stem: str, edges: list, str_path: str) -> bool: |
There was a problem hiding this comment.
_require_imports_js()
high coupling complexity (Ca·Ce = 15).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
Landed in v0.9.44, just published to PyPI. I cherry-picked this onto |
Summary
equire()\ declarations while traversing JavaScript and TypeScript function bodies
Fixes #2700.
Validation