Skip to content

fix(javascript): preserve exact static CommonJS export keys - #1600

Closed
N0zoM1z0 wants to merge 6 commits into
mainfrom
fix/javascript-export-keys-integration-1369
Closed

N0zoM1z0 wants to merge 6 commits into
mainfrom
fix/javascript-export-keys-integration-1369

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Preserve exact static CommonJS export keys. Quoted, dotted and empty keys retain their source identity; computed identifiers remain unknown instead of becoming invented export names. Helper handling recognizes member .d calls and exact Object.defineProperty, keeps this.d, and avoids scanning export arguments for unrelated callees.

This integrates the contribution from #1369 with the independently reviewed helper follow-up. The original contributor history and source branch are retained. Main now also contains the previously encountered formatting and maintenance/capture repairs.

Independent verification against main 11e3fae6: 126 affected tests across ten files and all eight static/documentation/architecture/discovery checks passed. Fresh compiled public CLI/pinned-SDK MCP runs cover an 833-byte eleven-module export fixture, a 296-byte helper control and a 113-byte this.d control. Exact export expectations, complete same-version CLI/MCP normalized-result and Evidence-ID parity, unchanged input bytes and subsequent ping all passed. An irrelevant-call probe confirms zero argument-path segment reads, compared with sixteen in the original candidate; this is a structural count, not a throughput or billed-token measurement. Native JavaScript controls confirm standalone d creates no exports and the owned this.d helper creates self.

No real Hopper/Ghidra or Electron runtime verification was performed for this static JavaScript change. Windows/provider behavior is covered only to the extent established by the linked CI; final-head CI is still running.

CI refresh at 1e034a80 changes no tracked source bytes. The independently compiled combination with main c1217e71 passes 17 focused export/helper tests, all eight checks, and all three public CLI/pinned-SDK MCP export controls plus the irrelevant-call structural probe. This includes the current snapshot cleanup and merged runtime ownership fix. The earlier 126-test validation remains tied to its stated revision. Original contributor and source history remain intact.

CI refresh at 9d4dce12 reruns the unchanged source tree against current main c12a532b, which now contains the shared cleanup-boundary corrections. Earlier local and real-target measurements remain tied to their stated revisions; this empty refresh makes no new runtime-verification claim.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto

morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Superseded by 5485483f7. Static CommonJS collection now preserves quoted, dotted, numeric and empty property identities as segments, omits unresolved computed names, distinguishes nested writes from literal dotted keys, and handles object-literal prototype setters correctly. Helper recognition retains member .d calls including this.d, exact Object.defineProperty, and ignores unrelated/standalone calls.

Verified with 5 producer tests, 15 compiled application acceptance tests including Node runtime oracles and public CLI/MCP Evidence parity, four additional compiled helper controls, and typecheck/lint. This is static JavaScript verification; no native provider or Electron-runtime claim.

@morluto morluto closed this Oct 11, 2026
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I reran my 29-form export check on 5485483 and on main (a11fbc0). Fixed: 6 of the 14 forms where c916850 differed from Node. Still differs from Node: 8 forms, 5 of them computed keys that now give no name instead of a wrong name.

Results

For each form, Node says what Object.keys(require(file)) returns. Then I ask REA's collector, and the analyze-javascript-application CLI on a webpack-style bundle. Both REA paths agreed on every row.

The columns are:

Below are the forms that changed or still differ. A tick means REA equals Node. The other 15 forms match Node in every column. Fix and main gave the same answer on all 29 forms.

form Node parent PR fix and main
exports.a = {}; exports.a.b = 1 ["a"] ["a","a.b"] ["a","a.b"] ["a"] ✓
module["exports.value"] = 1 [] ["value"] [] ✓ [] ✓
module.exports = { "": 1 } [""] [] [""] ✓ [""] ✓
Object.defineProperty(exports, "", {value:1, enumerable:true}) [""] [] [""] ✓ [""] ✓
exports = { rebound: 1 } [] ["rebound"] ["rebound"] [] ✓
exports = 5 [] ["default"] ["default"] [] ✓
exports["a" + "b"] = 1 ["ab"] [""] [] []
const k = "z"; exports[k] = 1 ["z"] ["k"] [] []
exports[tpl] = 1 ["tpl"] [""] [] []
var key = process.argv.length > 0 ? 'dyn' : 'x'; exports[key] = 1 ["dyn"] ["key"] [] []
module.exports = { [key]: 1 } ["dyn"] ["key"] [] []
Object[method](exports, "value", {...}) ["value"] [] [] []
module.exports = function(){} [] ["default"] ["default"] ["default"]
n.d(exports, {ready: ()=>1, 'x-y': ()=>2}) [] ["ready","x-y"] ["ready","x-y"] ["ready","x-y"]

Forms that match Node, out of 29: parent 15, PR 18, fix 21, main 21. The collector file has not changed between fix and main. Fix matches Node on 3 forms the PR did not: the nested write, exports = {rebound: 1} and exports = 5. Fix loses none of the PR's matches.

Two rows differ from Node by a REA convention. The CLI test in 5485483 expects "default" for module.exports = function realDefault() {}. In my fixture n.d does nothing, so Node sees no exports. REA reads the call as a bundler helper.

Real files: I took 130 CommonJS entry files from the repo's own node_modules. Parent, PR and main give the same names for all 130, and 27 match Node exactly in each. So the fix changed nothing there. It shows no regression, but it does not test the fix either.

Tests on main, 3 runs each, all passed. The member path depth test has 5 tests. The CLI acceptance test has 15 tests. One of them is new, for exact keys. The whole src/domain/javascript folder passed once, with 770 tests.

Not run

  • macOS and Windows.
  • Node 22 and Node 26.
  • A real minified webpack bundle.
  • npm run test:fast, npm run check and the other integration projects on main.
  • Whether three rows with fixed keys should stay empty: "a" + "b", const k and the template string. The commit message says the fix drops computed keys it cannot resolve. I did not read the code for intent.

Thanks, N0zoM1z0, for the PR and the forms it covered. Thanks, morluto, for the fix in 5485483.

All 29 forms
form Node parent PR fix main
exports["a-b"] = 1 ["a-b"] ["a-b"] ✓ ["a-b"] ✓ ["a-b"] ✓ ["a-b"] ✓
module.exports['x.y'] = 1 ["x.y"] ["x.y"] ✓ ["x.y"] ✓ ["x.y"] ✓ ["x.y"] ✓
exports.a = {}; exports.a.b = 1 ["a"] ["a","a.b"] ["a","a.b"] ["a"] ✓ ["a"] ✓
exports["a.b"] = 1 ["a.b"] ["a.b"] ✓ ["a.b"] ✓ ["a.b"] ✓ ["a.b"] ✓
exports[0] = 1 ["0"] ["0"] ✓ ["0"] ✓ ["0"] ✓ ["0"] ✓
exports["7"] = 1 ["7"] ["7"] ✓ ["7"] ✓ ["7"] ✓ ["7"] ✓
exports[0x10] = 1 ["16"] ["16"] ✓ ["16"] ✓ ["16"] ✓ ["16"] ✓
module.exports = {0: 1} ["0"] ["0"] ✓ ["0"] ✓ ["0"] ✓ ["0"] ✓
exports["\u00e9\u{1F600}"] = 1 ["é😀"] ["é😀"] ✓ ["é😀"] ✓ ["é😀"] ✓ ["é😀"] ✓
exports["\x41"] = 1 ["A"] ["A"] ✓ ["A"] ✓ ["A"] ✓ ["A"] ✓
exports["a" + "b"] = 1 ["ab"] [""] [] [] []
const k = "z"; exports[k] = 1 ["z"] ["k"] [] [] []
exports[tpl] = 1 ["tpl"] [""] [] [] []
var key = process.argv.length > 0 ? 'dyn' : 'x'; exports[key] = 1 ["dyn"] ["key"] [] [] []
module.exports = { [key]: 1 } ["dyn"] ["key"] [] [] []
module.exports = { ["d"]: 1 } ["d"] ["d"] ✓ ["d"] ✓ ["d"] ✓ ["d"] ✓
module["exports.value"] = 1 [] ["value"] [] ✓ [] ✓ [] ✓
module["exports"]["ready"] = 1 ["ready"] ["ready"] ✓ ["ready"] ✓ ["ready"] ✓ ["ready"] ✓
exports[""] = 1 [""] [""] ✓ [""] ✓ [""] ✓ [""] ✓
module.exports = { "": 1 } [""] [] [""] ✓ [""] ✓ [""] ✓
Object.defineProperty(exports, "k", {value:1, enumerable:true}) ["k"] ["k"] ✓ ["k"] ✓ ["k"] ✓ ["k"] ✓
Object.defineProperty(module.exports, "g", {get(){return 1}, enumerable:true}) ["g"] ["g"] ✓ ["g"] ✓ ["g"] ✓ ["g"] ✓
Object.defineProperty(exports, "", {value:1, enumerable:true}) [""] [] [""] ✓ [""] ✓ [""] ✓
Object[method](exports, "value", {...}) ["value"] [] [] [] []
exports = { rebound: 1 } [] ["rebound"] ["rebound"] [] ✓ [] ✓
exports = 5 [] ["default"] ["default"] [] ✓ [] ✓
module.exports = {a:1,"b-c":2,["d"]:3,4:5} ["4","a","b-c","d"] ["4","a","b-c","d"] ✓ ["4","a","b-c","d"] ✓ ["4","a","b-c","d"] ✓ ["4","a","b-c","d"] ✓
module.exports = function(){} [] ["default"] ["default"] ["default"] ["default"]
n.d(exports, {ready: ()=>1, 'x-y': ()=>2}) [] ["ready","x-y"] ["ready","x-y"] ["ready","x-y"] ["ready","x-y"]
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0
  • Parent: c916850
  • Fix: 5485483
  • Main: a11fbc0
  • PR head: 9d4dce1

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks, @N0zoM1z0, for pinning down the distinction between literal dotted export names and nested member writes. Main now keeps those CommonJS key identities separate and leaves unresolved computed names unknown (main).

@morluto morluto added the area: evidence Evidence, artifacts, and reconstruction label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants