Repository navigation
Conversation
After Graphify-Labs#4634 stopped minting a module-scope node for `const X = require('./m')`, `class A extends X` lost its inherits edge entirely. Record whole-module require bindings and `module.exports = Name` as symbol import/export facts so heritage resolves to the required class, matching ESM default imports. Fixes Graphify-Labs#4688 Co-Authored-By: Grok Bot
|
Thanks for the pull request, @Mpasha17. 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.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 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 not verified).
Formal verification. PR-changed functions: 0/2 verified (0 proven, 0 may-equivalent, 0 distinguished) · 2 not verified (1 vacuous, 1 unsupported).
Not verified on this run: \_collect\_js\_symbol\_resolution\_facts (unsupported), \_js\_module\_specifier (vacuous: never exercised).
Graphify review — findings
Restores class A extends X inheritance edges for const X = require('./m'), which broke when #4634 stopped minting a module-scope node for the require binding. Whole-module const/let/var requires and TS import X = require("./m") are now recorded as default imports, so heritage resolves through the same alias path as ESM import X from './m'; destructured and require('./m').y forms are deliberately left to the structural imports edges so the EXTRACTED confidence path doesn't regress. Adds CommonJS export facts for module.exports = Name, exports.Foo = ..., and module.exports = { ... }, with the whole-module form also exposed under its own local name. The export-side parsing is the loosest part: it decides which local name and key a require resolves to, and it treats bare exports = X and chained assignments as default exports. Makes _js_module_specifier dig into import_require_clause so TS import x = require(...) yields its module string instead of None.
Worth a look
- Bare
exports = Xwrongly recorded as a CommonJS default export —graphify/extractors/resolution.py:2304· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
- Chained
module.exports = exports = Fooexports the wrong local name —graphify/extractors/resolution.py:2270· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 3140 functions depend on the 190 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1008 callers, 60 callees - worse:
_collect_js_symbol_resolution_facts()— 3 callers, 30 callees
Verification — 3140 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: 1255 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
34 of 444 test file(s) selected (8%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_ejs_extractor.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_extract.py— impacttests/test_forwarding_review_findings.py— impacttests/test_import_extension_resolution.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_js_extends_require_4688.py— impact, changed-testtests/test_js_member_collisions.py— impacttests/test_js_walk_order.py— impacttests/test_language_override_imports.py— impacttests/test_languages.py— impacttests/test_loose_sibling_import_resolution.py— impacttests/test_multilang.py— impacttests/test_package_json_subpath_imports.py— impacttests/test_pascal.py— impacttests/test_pascal_resolution.py— impacttests/test_phantom_external_import.py— impacttests/test_pr10_resolution_overrides.py— impacttests/test_python_import_resolution.py— impacttests/test_python_parse_memoization.py— impacttests/test_rationale.py— impacttests/test_resolve_memoization.py— impacttests/test_source_key_memoization.py— impacttests/test_src_layout_import_resolution.py— impacttests/test_svelte_extraction.py— impacttests/test_ts_new_expression_calls.py— impacttests/test_typescript_module_extensions.py— impacttests/test_unmapped_at_alias_resolution.py— impacttests/test_vue_extraction.py— impacttests/test_walk_python_tree_iterative.py— impact
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
Could not verify: Could not verify \_collect\_js\_symbol\_resolution\_facts.
The verifier did not have enough to check \_collect\_js\_symbol\_resolution\_facts, 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: no capturable inputs from the test suite; property tier: parameter `facts` is annotated `_SymbolResolutionFacts` — outside the synthesizable primitive/collection set
Could not verify: Could not verify \_js\_module\_specifier.
The verifier did not have enough to check \_js\_module\_specifier, 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: no capturable inputs from the test suite; property tier: not verifiable: all 225 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)
· 2 more finding(s) on lines outside this diff (see the check run).
Bare `exports = X` only rebinds the local exports binding in CommonJS and must not mint a default export. Chained `module.exports = exports = Foo` must export Foo, not the intermediate name `exports`. Co-Authored-By: Grok Bot
|
Thanks for the review — I checked both with live
Couldn't find the 2 out-of-diff findings. The Graphify check run has 0 annotations and its output only lists these 2, so if you can point me to them I'll take a look. |
|
Landed in 0.9.102 (published to PyPI), cherry-picked with your authorship preserved. Follow-up: rewrote test_external_require_new_matches_esm_no_calls_edge, which asserted an ESM-parity (no-edge) that no longer holds on the current tree for external requires - a pre-existing CJS/ESM asymmetry outside this PR's intra-project ./ require fix. Fixes #4688. Thanks @Mpasha17. |
Fixes #4688.
What was wrong
#4634 stopped creating a module-scope node for
const X = require('./m')sonew X()could reach the required class. That fixed the shadowing half of #4621, butclass A extends Xwent through the same missing binding and ended up with noinheritsedge at all (webpackAssetGenerator extends Generatoris the real-world case).What changed
In the JS/TS symbol-resolution facts pass:
const/let/var X = require('./m')(and TSimport X = require('./m')) as a default import alias, same shape as ESMimport X from './m'.module.exports = Name/exports.X = …as export facts so that alias can resolve to the class in the required file.Follow-up after review: only
module.exports = …mints a default export (bareexports = Xis ignored), and chained assignments walk to the final RHS somodule.exports = exports = FooexportsFoo.Destructured /
require('./m').yforms are left alone — they already have structuralimportsedges, and minting symbol-import facts for them regresses the EXTRACTED call path.External
require('pkg')Checked against ESM:
import X from 'some-plugin'also has nocalls/inheritsedge today, onlyimports_fromto aref_…id. Restoring a local stub would undo #4634. So unresolved package requires stay without a use edge, matching ESM / #4634.Tests
tests/test_js_extends_require_4688.py(10 cases: local require extends, let/var/ts, ESM control,import = require, renamed require,newno-regression, external CJS vs ESM, bareexports =ignored, chainedmodule.exports = exports = Foo).v8: same pre-existing failures on both trees, no new ones.Generator.js/AssetGenerator.jsunder/workspace/e2e-4688— before: noA inherits, noAssetGenerator inherits; after: both land onGeneratorin the required file.Limitations
const { X } = require('./m')/require('./m').Xextends is not covered here (structural imports already exist; whole-module was the JS/TS: after #4634,class A extends Xwithconst X = require('./m')gets noinheritsedge at all #4688 gap).calls/inheritsedge (same as ESM after fix(extract): a require binding does not shadow the required class #4634).Written with help from Grok Bot; I reviewed and tested it.