Repository navigation
Conversation
…x-runtime-literal-percent
…x-runtime-literal-percent # Conflicts: # tests/boundary/filesystem/ghidraProfileArtifactOwnership.test.ts
…h-ownership-resubmit
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
| while ( | ||
| remaining.length > 1 && | ||
| (remaining[0] === "posix" || remaining[0] === "win32") | ||
| ) { | ||
| selected = `path/${remaining[0]}`; | ||
| remaining = remaining.slice(1); |
There was a problem hiding this comment.
The new path identities lose writes across names that share the same object. On POSIX, require("node:path") and require("node:path/posix") are identical. After changed.resolve = first => first through the first name, a read through the second checks a different write bucket. A preload such as p.resolve(runtimePath, __dirname, "decoy.cjs") is then reported as decoy.cjs, although the replacement returns runtimePath.
Parent-slot writes have the same gap: replacing changed.posix is stored under path, while a separate default import reading path.posix.resolve checks path/posix. Preserve shared-object writes and parent-slot writes before proving the selected helper native.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptSemanticRequireOrigin.ts
Line: 1453-1458
Comment:
**Changed helpers select decoys**
The new path identities lose writes across names that share the same object. On POSIX, `require("node:path")` and `require("node:path/posix")` are identical. After `changed.resolve = first => first` through the first name, a read through the second checks a different write bucket. A preload such as `p.resolve(runtimePath, __dirname, "decoy.cjs")` is then reported as `decoy.cjs`, although the replacement returns `runtimePath`.
Parent-slot writes have the same gap: replacing `changed.posix` is stored under `path`, while a separate default import reading `path.posix.resolve` checks `path/posix`. Preserve shared-object writes and parent-slot writes before proving the selected helper native.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| for (const name of fields.definite) | ||
| if (!overwritten.has(name)) | ||
| exported.push({ | ||
| exportedName: name, | ||
| value, | ||
| projection: [name], | ||
| ownEnumerable: true, |
There was a problem hiding this comment.
Object.assign can invoke a target setter without storing the source value. For Object.defineProperty(exports, "change", {set(value){}, enumerable:true}); Object.assign(exports, {change:app.setAppPath});, the setter discards the function and exports.change remains undefined.
This loop still publishes app.setAppPath. The helper therefore adds app_path_changes, and an importing entrypoint loses its valid loadFile("index.html") link. Check the target's selected property and descriptor too, rather than treating every selected source field as the resulting export.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptCommonJsExportReceivers.ts
Line: 299-305
Comment:
**`Object.assign` invents setters**
`Object.assign` can invoke a target setter without storing the source value. For `Object.defineProperty(exports, "change", {set(value){}, enumerable:true}); Object.assign(exports, {change:app.setAppPath});`, the setter discards the function and `exports.change` remains `undefined`.
This loop still publishes `app.setAppPath`. The helper therefore adds `app_path_changes`, and an importing entrypoint loses its valid `loadFile("index.html")` link. Check the target's selected property and descriptor too, rather than treating every selected source field as the resulting export.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Follow-up for the older outside-diff “Typed writes lose module loads” finding in #4941 (comment): fixed in Before: the typed/untyped native/local source controls were 2 failed / 2 passed, and the independent compiled CLI/MCP controls on The previous hosted Linux run also passed all 16 jadx controls, including the original Java readiness cancellation test. Its one portable-test failure was an unbound |
CassieFox23
left a comment
There was a problem hiding this comment.
TL;DR: At 35e2cad, my four earlier findings and the four bot findings I reproduced last time are all fixed. The six threads the author closed since then also hold. The two bot threads still open both reproduce, and one test still fails on Node 22 because of Node 22 itself.
This PR merged after my run, at the same head I tested. I'm posting this as a record. The two open threads below now apply to main.
I ran fixtures and named test files only. I did not run real apps. Thanks, ShuaixinHuang, for the quick fixes.
My earlier findings
"Old" is my result at the head named in the first column. "Now" is my result at 35e2cad. Node 22.23.1, 24.18.0 and 26.11.1 gave the same result on every probe below.
| # | Finding | Old | Now |
|---|---|---|---|
| 5 | Bound module.require (c4ec17d, my review) |
Reproduced | Fixed. bind, .call, .apply, Reflect.apply and a captured-then-bound alias all give unavailable. |
| 6 | Windows-relative package main (c4ec17d) | Reproduced | Fixed. sub\main.cjs gives unavailable. |
| 14 | Module gaps across archive containers (c4ec17d) | Reproduced | Fixed. require(process.env.X) inside app.asar gives unavailable. |
| 16 | app.setAppPath (c4ec17d) |
Reproduced | Fixed. A direct call and a returned alias both give unavailable. |
| - | packageImportAliases.test.ts on Node 22 (c4ec17d) |
1 failed | Still fails on Node 22 only. The same test fails with ERR_INVALID_MODULE_SPECIFIER. A tiny package with only the imports key #/x fails the same way on plain Node 22.23.1 with no rea code. It passes on Node 24.18.0 and 26.11.1. |
| - | Valid preload links disappear (my newer review, 01cd14e) | Reproduced: no preload role | Fixed. With var __dirname; the preload resolves to a/preload.cjs, the same as without the var. |
| - | Prove dirname anchors (01cd14e) | Reproduced: a/decoy.cjs |
Fixed. helper.dirname(__filename) and helper.dirname(import.meta.url) no longer give a/decoy.cjs. No preload link is drawn. A real path.dirname(__filename) still gives a/decoy.cjs. |
| - | Retain require.main.require (01cd14e) |
Reproduced: b/index.html |
Fixed. The renderer is unavailable. |
| - | Exported setAppPath delegate (01cd14e) |
Reproduced: a/index.html |
Fixed. change.call(app, lib) gives unavailable. |
The four author replies on these last four threads say "Fixed in eb553d5". I tested the behaviour, not the replies.
Bot threads the author closed since my last review
All of these are resolved with an author reply ("Fixed in" 93969ba or 31d6970). I tested one fixture each, in the shape the thread describes.
| Thread | Result at 35e2cad |
|---|---|
Retain process.mainModule require calls |
Holds. process.mainModule.require(...) gives unavailable. |
Track setters exported with Object.assign |
Holds. change.call(app, lib) gives unavailable. |
| Exported app keeps stale paths | Holds. A caller that sets the app path gives unavailable. One side effect, see below. |
| Changed helpers select decoys | Holds for two default imports of node:path (no decoy). The newer open thread shows a gap that remains. |
| Overwritten setters hide valid pages | Holds. With {change(){}} as the later source, the renderer resolves to a/index.html. With the setter as the later source, it is unavailable. |
| Typed writes lose module loads | Holds. (box.make as any) = () => module in main.ts gives unavailable, the same as the untyped form. A typed local store gives b/index.html, as it should. I built the fixture from the new test in 35e2cad, because I did not fetch the original finding text. |
One side effect shows on the "exported app" thread. Take a helper that exports the native app. An entrypoint imports it but never calls setAppPath. That now also gives unavailable. The correct page is a/index.html. This is cautious, not a wrong link. The same happens for a setter module imported without a call.
Open bot threads at 35e2cad
Both are from 12:40 AM UTC today. Both reproduce.
| Thread | Sev | Result | What I saw |
|---|---|---|---|
| Changed helpers select decoys | P1 | Reproduces | const changed = require("node:path"); const p = require("node:path/posix"); changed.resolve = first => first;, then p.resolve(BASE, __dirname, "decoy.cjs"): the preload resolves to a/decoy.cjs. Plain Node returns BASE, because require("node:path") === require("node:path/posix") is true. The parent-slot half, changed.posix = {resolve: first => first} then path.posix.resolve(...), does the same. Both halves fail in CommonJS and in ESM. The control with no replacement correctly gives a/decoy.cjs. |
Object.assign invents setters |
P1 | Reproduces | Object.defineProperty(exports, "change", {set(value){}, enumerable: true}); Object.assign(exports, {change: app.setAppPath});. Plain Node leaves exports.change as undefined. An entrypoint that only imports this module, then loads index.html, gets unavailable. The correct page is a/index.html. A setter module without the defineProperty gives unavailable too, so the descriptor is not what decides it. The case is still a missing valid link. |
Tests
On Node 24.18.0 I ran 31 test files, 903 tests: all passed. They are the files the PR touched since my last review (19 of 22 still exist) plus the 12 from my last round. On Node 22.23.1 the same files give 902 of 903; the one failure is the Node 22 test above. I ran packageImportAliases.test.ts on Node 26.11.1 (13 passed), and no other test file there. The test count is not comparable with the 571 from last round, because the set of files is different. The tests pass while my two open-thread fixtures fail, so the tests do not cover those shapes.
Not run
- Real apps, live Electron or browser captures. Every result comes from fixture folders I wrote and the graph builder.
- The original text of the "Typed writes lose module loads" finding. I used the shape from the PR's own new test.
- How the fixed threads behaved before their fix commits. That includes "Typed writes lose module loads". I did not build 31d6970 or 93969ba.
- The factory choices thread.
- The other resolved threads I did not name above.
- N6 (alias stall) at depths other than 18 levels; 18 levels took about 1 second on all three Node versions.
- Other shapes of the two open threads.
- Windows hosts. The Windows path rows are path-syntax checks on Linux.
Test setup
Commands
git archive 35e2cad5b into a fresh folder
npm ci --ignore-scripts; npm run build:cached; npm run test:prepare (Node 24)
npm run test:focused -- <probe files> (Node 22, 24 and 26)
npm run test:focused -- <31 test files> (Node 24; Node 22 for the same files)
node -p 'require("node:path")===require("node:path/posix")' (true on Node 22, 24, 26)
node -e 'const e={};Object.defineProperty(e,"change",{set(v){},enumerable:true});Object.assign(e,{change:1});console.log(e.change)' (undefined on Node 22, 24, 26)
Fixture for the first open thread (CommonJS):
a/package.json {"main":"main.cjs"}
a/main.cjs const {BrowserWindow}=require("electron"); const changed=require("node:path"); const p=require("node:path/posix"); changed.resolve=first=>first; new BrowserWindow({webPreferences:{preload:p.resolve(process.env.BASE, __dirname, "decoy.cjs")}});
a/decoy.cjs (empty)
Expected: no preload resolved to a/decoy.cjs. Seen: resolved, a/decoy.cjs.
Fixture for the second open thread:
a/package.json {"main":"main.cjs"}
a/setter.cjs const {app}=require("electron"); Object.defineProperty(exports,"change",{set(value){},enumerable:true}); Object.assign(exports,{change:app.setAppPath});
a/main.cjs require("./setter.cjs"); require("./win.cjs");
a/win.cjs const {BrowserWindow}=require("electron"); new BrowserWindow().loadFile("index.html");
a/index.html, a/lib/index.html, index.html
Expected: renderer resolved, a/index.html. Seen: unavailable.
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
main's morluto#5224 and morluto#4941 rewrote the snapshot, capture-progress, ZIP and runtime-observation tests that this branch's shared test-hardening commits patched. Take main's version of those files so the branch diff is only the HAR entry-scoping fix (12c6316). Co-Authored-By: Claude Opus 5.5 <[email protected]>
main's morluto#5224 and morluto#4941 rewrote the snapshot, capture-progress, ZIP and runtime-observation tests that this branch's shared test-hardening commits patched. Take main's version of those files so the branch diff is only the ARM32 Mach-O slice fix (1ccb40d). Co-Authored-By: Claude Opus 5.5 <[email protected]>
main's morluto#5224 and morluto#4941 rewrote the snapshot, capture-progress, ZIP and runtime-observation tests that this branch's shared test-hardening commits patched. Take main's version of those files so the branch diff is only the Webpack loader-alias changes (bdd57b4, 641f662, 3a0fd8a). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem and outcome
Electron renderer/preload paths require the original filename bytes and a proven application owner. The shared JavaScript analysis now retains unsupported loads, competing owners and possible app-path mutations as explicit uncertainty instead of resolving them to a decoy. This replaces #4327.
The current fixes use the existing source and export owners:
Synced upstream main at
833136507dd79d959340b09862a53af344e4f1b3. Its process UID/exit-scope/lifecycle implementation and recorded-crash trace policy replace the superseded local observer. The upstream canonical base64 schema replaces the separate schema translator; MCP metadata/intersection controls remain. Process production and recorded-crash verification match that upstream base. Its readiness fork-association fix (#5316) also applies.Executed validation
Current revision:
35e2cad5bdbbf90f15adb5c814297b25e36f4c79, Windows x64, Node 24.18.0/npm 11.16.0.31d6970b, with 78 unrelated cases excluded by the name filter.pathidentifier. The fixture now supplies actual CommonJS native-path and Electron bindings and checks the same exactpreload%20?#.cjsresult through full static analysis. The filtered test failed before and passes after on Windows (1 executed, 26 excluded). The current hosted Linux run passes all 27 tests in this file; shard 1 passes 1,935 tests with zero failures.npm run check: six tasks passed, 2,277 resolved module boundaries, 1,594 architecture guards, zero lint errors. Build, MCP catalog and diff checks passed. Test discovery registered all 1,766 files exactly once.31d6970bto this committed source (83 input hashes; artifact48cf3aee8d13290c4bdb603071d894b6268aa8aefdef2fff056a414d9ed38baf; workloaddf41bf234b49076137628cd8f858807acc8fde439ca5996078cd669f9e7b5af9). Before/after wall times were 134.852/210.824 ms and 70.360/149.873 ms; CPU 187/265 ms and 140/94 ms; whole-child high-water RSS 84,532/85,048 KiB and 90,892/89,576 KiB. Mixed results under uncontrolled desktop load establish neither a speedup nor a definite regression. Imports/bundling and complete CLI/native process-family costs are excluded.Current-head hosted Linux executes all 16 jadx controls successfully (12.453 s), including cancellation of an in-flight Java readiness probe and joining cancelled Java until its owned child exits. These are actual Linux passes, independent of the 16 POSIX-only local skips. Earlier validation on the immediately preceding
31d6970brevision also passed 148 compiled public/Node/schema controls across nine files; that historical count is not added to the current-head totals.Current-head hosted status: SUCCESS on this exact revision: https://github.com/morluto/rea/actions/runs/39350036839. All five portable test shards and CI required passed: 10,251 tests passed, zero failed, 162 existing skips; 1,025 test files passed. Source tests, static checks, build, docs, real JavaScript recovery, Apple artifact E2E, Windows package/capability checks and all three native package baselines passed. Independently scheduled sigrok/tshark checks also passed. Scope-excluded lanes remain skipped and are not counted as passes. PR readiness is SUCCESS (https://github.com/morluto/rea/actions/runs/39350091288). GitHub reports mergeable=true and mergeable_state=clean against upstream 8331365..
The four reviewed inline threads were replied to with evidence and resolved at
31d6970b. The typed-store follow-up also addresses the older outside-diff finding in #4941 (comment).No analyzed target or real Electron application is executed by the public analysis fixtures. Authored Node oracle fixtures establish only the native semantics they exercise. Real provider execution, complete CLI process-family costs and token usage remain unmeasured unless explicitly reported above. Prepared with AI assistance; the original human initial-readiness declaration is preserved.
Author readiness
Human owner: @ShuaixinHuang
The human owner explicitly confirmed review, evidence, responsibility and initial readiness for this PR on 2026-10-18.