Repository navigation
fix(javascript): attribute call-path unknowns only where the walk can reach Electron - #4915
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no new blocking issue was found. SummaryThis PR keeps unrelated unresolved reads from making non-Electron files appear incomplete. The latest change preserves warnings when returned timer values may carry changed members.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Walk every module] --> B[Collect paths and unresolved reads]
B --> C{Could the walk reach Electron?}
C -->|Yes or unknown| D[Keep coverage warnings]
C -->|No| E[Drop unrelated warnings]
F[Returned ambient value] --> G[Check changed members]
G --> C
Reviews (25) · Last reviewed commit: "fix(javascript): retain uncertainty for ..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d40f4f7b3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Both findings were right, and I checked them against main first:
Counts: new test file 5 passed (3 failed before the fix), CLI coverage test 1 passed, src/domain/javascript 2282 passed, src/application/javascript 335 passed, the javascript-applications and Electron boundary and acceptance set 347 passed, |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a99090fcc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0a99090 to
7c9596b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c9596bdec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a93119cb73
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7161c5ef9e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
7161c5e to
9c0b6cf
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c0b6cf547
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
TL;DR: I checked all 12 open bot threads against 9c0b6cf. Four still reproduce. Three make a file read "complete" where the base said "partial". They are a this receiver, a this.r(...) receiver and a changed holder object. The fourth keeps a plain file "partial" because it returns the string "electron". The other eight do not reproduce with my fixtures.
Edit: I retested on head 58f6759. Three of the four findings below are fixed there. New results are here.
I ran fixtures and the two test files this PR touches. I did not run real apps.
Findings and verdicts
I tested head 9c0b6cf. The base is 22ddd82. "Reproduces" means a short source string I wrote gives the wrong answer. The wrong answer is "complete" with no IPC finding, although the source registers IPC. Results were the same on Node 22.23.1, 24.18.0 and 26.11.1.
| Thread | Sev | Verdict | What I saw |
|---|---|---|---|
| Receiver loaders lose warnings | P1 | Reproduces | load.call(require)("electron") with var load = function(){ return this; } is "complete", 0 IPC. The base said "partial" |
| Mutated bindings in the loader-free proof | P1 | Reproduces | holder.load = require then var load = () => holder.load(name) is "complete", 0 IPC. The base said "partial" |
this as an unresolved loader source |
P1 | Reproduces | load.call({r: require}) with return this.r(name) is "complete", 0 IPC. The base said "partial" |
| Returned Electron strings as loader evidence | P2 | Reproduces | var format = () => "electron" read by run(), with no Electron import, is "partial". The base said "partial" too, so this is not new |
The first three share one cause. The loader-free proof accepts a this receiver and ignores writes to an object member. A returned require then looks harmless. In the fourth, a probe with "other" instead of "electron" is "complete", so the string itself is the trigger.
The 8 threads that do not reproduce
| Thread | Sev | Verdict | What I saw |
|---|---|---|---|
| Filter the gate by reference kind | P2 | Does not reproduce | A worker URL and a service-worker URL that name electron, plus a hoisted read: "complete" |
| Late-initialized require aliases | P1 | Does not reproduce | var load = require; after the call: "partial" with the unknown limitation |
| Transitive late loader aliases | P1 | Does not reproduce | Alias through base, through const req, through pick() and through window.require: all "partial" |
| Cache loader scans | P2 | Does not reproduce | The scan is now charged to the budget. 100 to 2,000 reads of a 2,000-entry initializer ran in 26 to 81 ms |
| Resolve aliases before declaring function initializers loader-free | P1 | Does not reproduce | name => req(name) and (req = require) => req: "partial" |
| Bound recursion on alias chains | P2 | Does not reproduce | Chains of 5,000 and 15,000 links: no crash, "partial" |
| Forwarded parameters | P1 | Does not reproduce | load(require) with var load = req => req(name): "partial" |
| Initializer-expression recursion | P2 | Does not reproduce | A 5,000-term a + b + ... initializer: no crash, "partial" |
On the cache thread: a call-position read skips the cache and spends budget. With 500 or more calls of a 2,000-entry object, the budget runs out and the file is "partial". That fails safe. The base was "partial" for every such file, since it had no gate.
On the last thread: 8,000 or more terms make the whole analysis fail with a parse error. That happens with no hoisted read at all, and also on the base. It is not from this PR.
Five of these threads have a reply from the author. I tested the code shapes named in each reply on the head. The replies name four commits. None of them is in the head's history. The head has commits with the same titles.
Test results, the 2 test files this PR touches:
| Node | Result |
|---|---|
| 22.23.1 | 23 passed |
| 24.18.0 | 23 passed |
| 26.11.1 | 23 passed |
The goal of the PR holds. The react-dom shape (a hoisted read of "function" === typeof setTimeout ? setTimeout : void 0) is "complete" on the head and "partial" on the base. The new test file has no this, .call or holder-object case. Those would catch the three regressions.
Not run
- Real apps and live Electron or browser captures. Every result comes from short source strings I wrote.
- Main (d3627b1). It has no change to the files this PR touches, but I did not build it.
- Other test files for the changed sources, the full suite, typecheck and lint. Only the two files this PR touches ran.
- Other shapes of the eight threads that did not reproduce. I tried the forms in the table only.
- The author's own numbers (0.152 s against 0.135 s for 1,000 reads). I did not rerun them. My timings are single runs on a shared box.
Thanks, mertkayacs, for the work on this.
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: 22.23.1, 24.18.0, 26.11.1
- Head / base: 9c0b6cf / 22ddd82 (main was d3627b1)
- Other: the box was shared with other test jobs, so timings are rough. For the base comparison I swapped the four changed source files for their base versions in a scratch copy, then put the head versions back.
Commands
npm ci --ignore-scripts; npm run prepare; npm run build:cached; npm run test:prepare (Node 24, tree at 9c0b6cf547)
npm run test:focused -- src/domain/javascript/electronWrappedCallPaths.unknown_scope.test.ts tests/boundary/cli/javascriptApplicationCoverage.test.ts (once each on Node 24, 22, 26)
npm run test:focused -- tests/boundary/ev4915/probe.test.ts (my probe file, once each on Node 24, 22, 26)
npm run test:focused -- tests/boundary/ev4915/probe2.test.ts (my second probe file, once each on Node 24, 22, 26)
Neither touched test file mentions doctor; I checked with grep first.
Each probe calls analyzeJavaScriptStaticSource(source) and records parse_status, whether the limitations say unknowns remain, and the IPC count.
Sources for the four that reproduce:
// 1
function register(){ load.call(require)("electron").ipcMain.on("ping", () => {}); }
var load = function(){ return this; };
register();
// 2
const name = "electron"; const holder = {}; holder.load = require;
function register(){ load().ipcMain.on("x", () => {}); }
var load = () => holder.load(name);
register();
// 3
const name = "electron";
function register(){ load.call({r: require}).ipcMain.on("x", () => {}); }
var load = function(){ return this.r(name); };
register();
// 4
function run(){ format("x"); }
var format = () => "electron";
run();🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
|
@CassieFox23 I verified all four against 9c0b6cf.
Pushed c6bc7bc. The compiled focused tests pass 26/26, the JavaScript domain and application tests pass 2765/2765, and typecheck, lint, and format are green. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6bc7bce46
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
I verified all four findings against c6bc7bc. Each reproduced and was valid, and I fixed them in 77900ac.
The regression file passes 31/31. The full suite ran 19,667 tests: 19,465 passed, 173 skipped, and 29 failed in unrelated process and host-environment cases. Sixteen of the 18 non-zip failing files passed in isolation with 239 tests passing. The full-run failures remaining in the two process files reproduced on untouched base 22ddd82, as did all three missing-zip failures. Typecheck, lint with 0 errors, format, Python tests, docs, duplication, and TODO checks pass. |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77900ac5f5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
I verified all six findings against 77900ac. Two were new false-complete cases, fixed in 58f6759:
The timer shim, alias reassignment, and sequence-wrapped callee fixtures remain conservative Validation: regression file 33/33, JavaScript domain and application tests 2773/2773, compiled Electron and application boundary tests 28/28, and |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58f67590da
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
TL;DR: At 58f6759, three of my four earlier findings are fixed. The fourth, a false "partial", is unchanged. Two new false "complete" shapes still reproduce. One puts the loader on the Array or String prototype. The other reads a prototype inside a late function.
Edit (2 Nov): I retested at e36ddc6. Most of this is fixed now. Results are here.
I ran short source strings and the PR's two test files only. I did not run real apps. Thanks, mertkayacs, for the fast fixes.
My earlier findings
"Old" is my review at 9c0b6cf. "New" is 58f6759. Node 22.23.1, 24.18.0 and 26.11.1 gave the same result on every probe.
| Finding | Old | New |
|---|---|---|
| Receiver loaders lose warnings | complete, 0 IPC | Fixed. load.call(require)("electron") is "partial" |
| Mutated bindings | complete, 0 IPC | Fixed. holder.load = require is "partial" |
this as a loader source |
complete, 0 IPC | Fixed. load.call({r: require}) is "partial" |
| Returned Electron strings | partial | Still "partial". The base says "partial" too. The author left it out on purpose |
"Complete, 0 IPC" means the file reads "complete" but the IPC registration is missing. The base said "partial" for all three.
Open bot threads that reproduce at 58f6759
| Thread | Sev | Result | What I saw |
|---|---|---|---|
| Loader writes on every literal prototype | P1 | Reproduces | Array.prototype.load = require; var load = [].load is "complete", 0 IPC. String.prototype.load with "".load does the same. The base said "partial". Function.prototype stays "partial". Node loads a module through all three, and through Function.prototype as well |
| Prototype reads in late function bodies | P1 | Reproduces | Object.prototype.load = require and var load = () => ({}).load(name) is "complete", 0 IPC. The base said "partial". Without the prototype write it is correctly "complete" |
| Alias writes exhaust memory | P1 | Reproduces | One object, M aliases, M writes. At M = 8,000 (260 KB of source) the test worker hit Node's default heap limit and aborted. It was not the box's RAM. The base used 297 MB at M = 8,000. At head M = 2,000 used 440 MB; the base used 180 MB. I did not run the 10,000 case |
| Member-mutation indexing | P2 | Reproduces, small | A plain bundle of 60,000 objects took 16.0 s and 16.8 s at head, and 11.8 s and 12.2 s at the base. About 35% more time and 30% more memory. The 15,000-link alias chain also took twice as long: 12.3 s at head, 6.2 s at the base |
| Timer shims (Greptile, P1), alias reassignment (Codex, P2), sequence-wrapped callees (Codex, P2) | P1, P2 | Reproduce | Each gives a false "partial" on a file with no Electron. clearTimeout and queueMicrotask shims, let alias = base; alias = {}, and (0, format)("x"). The author said these edges are acknowledged. They are precision only |
The first two share one cause. The prototype check covers Object but not other literal prototypes. It also skips reads inside a late function.
Repros for the first two:
// 1
const name = "electron"; Array.prototype.load = require;
function register(){ load(name).ipcMain.on("x", () => {}); }
var load = [].load; register();
// 2
const name = "electron"; Object.prototype.load = require;
function register(){ load().ipcMain.on("x", () => {}); }
var load = () => ({}).load(name); register();The other open bot threads (6 fixed, 7 not real, 1 not run)
"Earlier" is 9c0b6cf where I tested it, and 77900ac where noted.
| Thread | Sev | Result at 58f6759 |
|---|---|---|
| Ambient loader aliases | P1 | Fixed. var load = __non_webpack_require__ is "partial". It was "complete" at 9c0b6cf |
| Member writes across object aliases | P1 | Fixed. alias.load = require is "partial" |
| Invocation through conditional aliases | P2 | Fixed for conditional and logical forms. I did not test the sequence form |
import.meta vs dynamic import |
P2 | Fixed. import.meta.url is "complete". import(m) as a loader stays "partial" |
| Mutations through call parameters | P1 | Fixed in 58f6759. install(holder) is "partial". It was "complete", 0 IPC at 77900ac |
| Inherited literal members | P1 | Fixed in 58f6759 for Object.prototype with ({}).load. It was "complete", 0 IPC at 77900ac |
| Filter the gate by reference kind | P2 | Does not reproduce. Worker and service-worker URLs that name electron: "complete" |
| Late-initialized require aliases | P1 | Does not reproduce. var load = require; after the call: "partial" |
| Transitive late loader aliases | P1 | Does not reproduce for three shapes (base, const req, pick()): IPC found. A fourth, var load = window.require, is "complete" with 0 IPC. It is the same at the base, so it is not from this PR. My first review said "partial" for it, and I cannot explain the difference |
| Resolve aliases before loader-free | P1 | Does not reproduce. name => req(name) and (req = require) => req: "partial" |
| Bound recursion on alias chains | P2 | No crash. Chains of 5,000 and 15,000 links are "partial". They took 1.2 s and 12.3 s at head, and 0.7 s and 6.2 s at the base and at 77900ac. Single runs |
| Forwarded parameters | P1 | Does not reproduce. load(require) and arguments[0](name): "partial" |
| Initializer-expression recursion | P2 | No crash, but a 5,000-term sum makes the whole analysis "failed". That is the same at the base, so it is not from this PR |
| Cache loader scans | P2 | Not run this time |
Tests
The PR's two test files pass on all three Nodes: 34 tests on 22.23.1, 24.18.0 and 26.11.1. The author's regression file has 33 of them. It has no Array.prototype, String.prototype or late-function prototype case.
Not run
- Real apps, live Electron or browser captures. Every result comes from a short source string I wrote.
- Main (3fca2e0). It changes two of the files this PR touches. I did not build it, so I do not know if it changes any result here.
- The cache-scan timings.
- The 10,000 alias case.
- The sequence case of the alias thread.
- Other test files for the changed sources, the full suite, typecheck and lint. The author's own numbers (2,773 domain and application tests,
check:fast) were not rerun. - Other shapes of the threads that did not reproduce. I tried the forms in the tables only.
- Timings are single runs on Node 24 (the plain bundle ran twice). The box was shared with other test jobs.
Test setup
- Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
- CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
- RAM: 32 GB DDR4-3600
- Node: 22.23.1, 24.18.0, 26.11.1
- Head / base: 58f6759 / 22ddd82 (main was 3fca2e0)
- Other: the box was shared with other test jobs, so timings are rough. To say what changed at which commit, I swapped
src/domain/javascriptfor the base, 9c0b6cf and 77900ac versions in a scratch copy, ran the same probes, then put the head files back and checked them withdiff -r.
Commands
git archive 58f67590d into a fresh folder
npm ci --ignore-scripts; npm run build:cached; npm run test:prepare (Node 24)
npm run test:focused -- src/domain/javascript/electronWrappedCallPaths.unknown_scope.test.ts tests/boundary/cli/javascriptApplicationCoverage.test.ts (Node 22, 24, 26)
npm run test:focused -- tests/boundary/ev4915/probe.test.ts (my 39 probe cases; Node 22, 24, 26; the same file at the base, 9c0b6cf54 and 77900ac5f on Node 24)
npm run test:focused -- tests/boundary/ev4915/perf.test.ts (alias-write scaling and a plain bundle; Node 24; sizes 4,000 and 8,000 under systemd-run with an 8 GB memory cap)
node -e 'Array.prototype.load = require; console.log(typeof [].load("path").join)' (prints function)
Neither touched test file mentions doctor; I checked with grep first.
Each probe calls analyzeJavaScriptStaticSource(source) and records parse_status, whether the limitations say unknowns remain, and the IPC count. The "wrong answer" for the first two rows is "complete" with 0 IPC although the source registers IPC.
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
A function-local binding was accepted by scope alone, so a destructuring
projection such as `const { r } = {}` inside a late initializer never met
the inherited-member check that a top-level projection goes through. Route
projected locals through the binding proof; locals with inline initializers
keep the scope shortcut, since the walk already visits their expressions.
…meta uncertain
The loader-free proof inspected member expressions inside a late function
but not what its caller does with the result. With `Object.prototype.load =
require`, `var load = () => ({})` and `load().load("electron")` reach the
loader through a member selected after the call, and a bare `import.meta`
returned after `import.meta.load = ...` does the same. Check each result
expression: a literal fails when its prototype chain gained members, a bare
`import.meta` when any of its members changed, and a result of unknown shape
when either happened. Promise and generator results inherit from
Object.prototype as well. `SemanticPropertyPathCoverage.touches` answers
whether any retained write or escape sits below a prefix.
`alias = replacement` with `const replacement = {}` selected an identifier
initializer, so the later `alias.other = 1` stayed a shared write on the
original alias group and the resolver treated `base` as overwritten,
dropping its bridge call path. Resolve the identifier to its binding and
accept it when that binding only ever received one fresh allocation.
Bindings that can hold the original object keep the shared write.
morluto#11319 replaced the wrapper-visit counter with a Budget, so the loader proof charge no longer compiled on current main. Spend it through the shared helper, which records the same limit.
The 8,000 by 8,000 alias bound spent its time in the ambient write index, which walks every store to an object for each member write. That cost is the same on main and is not what the bound covers. Reach the same 64 million alias and write pairs with 32,000 aliases and 2,000 writes, which runs in about 2.5 seconds instead of 8.5 on the same host. Drop the 30 second overrides on both alias bounds too. They halved the hosted CI deadline the source project gives them, and the testing guide asks tests to leave deadlines to the project.
Main now guards reads of the effect indexes outside javascriptSemanticEffectLog.ts. The loader proof read them directly in 15 places. Route those reads through the log: the existing ambientPathMayHaveChanged and bindingHasMemberWrites queries, plus three timeless queries for a path or any member below it, an ambient binding write, and an escape at a site other than the call being proved. The answers are unchanged.
1a492a1 to
3ef3331
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 775c437434
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (this.#scopeContains(binding.scopeId, functionScopeId) && | ||
| binding.initializers.every( | ||
| ({ projection }) => projection.length === 0, | ||
| )) || |
There was a problem hiding this comment.
Preserve loader uncertainty for copied parameter bindings
In a CommonJS file, const name="electron"; function register(){ load(require).ipcMain.on("x",()=>{}); } var load=function(r=undefined){ var r; return r(name); }; register(); is incorrectly accepted as loader-free here. The non-simple parameter list gives the body’s var r a separate binding, which copyParameterToBody initializes from the parameter through initializer.entryBody. Because this binding is a local variable with an empty projection, the short-circuit accepts its references without consulting argument safety, even though the argument is require. No module-load reference is recorded, so the new gate can discard the late-read unknown and omit the registration under complete coverage. Honor the parsed parameter-copy initializer instead of accepting it solely by local scope.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| loaderFree = semanticCallableResultExpressions(node).every( | ||
| ({ node: result }) => | ||
| this.#chargeLoaderProof() && this.#isLoaderFreeResult(node, result), |
There was a problem hiding this comment.
Validate implicit promise and iterator results
In CommonJS, Object.prototype.load=require; function register(){ load().load("electron").ipcMain.on("x",()=>{}); } var load=async()=>{}; register(); obtains the loader through the returned promise’s prototype. Unlike the earlier explicit-return regression (async () => null), an empty async body—and an empty generator—produces no entries in semanticCallableResultExpressions, so this every returns true without executing #isLoaderFreeResult’s async/generator check. Consequently, unresolvedLoader stays false and the gate can discard the sole late-read unknown, reporting complete coverage without the registration. Check the invocation-result kind independently of whether any explicit return or yield exists.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
Summary
Fixes #4893.
Since 6.5.0,
analyze-javascript-applicationreportsparse_status: "partial"for ordinary production bundles that parse cleanly, and the application graph coverage follows it topartialwith no named limit. The file-level unknown comes from the Electron wrapped-call-path expansion: it evaluates calls in every module, including modules that never import or require Electron, and any read the symbolic resolver cannot settle counts as an unknown finding for the whole file. Since b8fab74 the resolver treats a read that precedes its initializer in source order as unresolved. Every hoisted function that reads a module-levelvarinitialized later (the timer shims inreact-dom-client.production.js, for example) now trips it, so a module with no Electron surface at all is reported as partially understood.This change keeps the expansion running on every module, so no finding is lost, and attributes the unknowns it meets to the file only where the walk could have reached Electron, as judged by the same resolver: a proven Electron callee root in the identity index, a resolver value that reached an Electron module, a require whose module name stayed unresolved, an exhausted budget, or a static import or require that names Electron or leaves its module name unresolved. Where none of that happened the walk could not have hidden a path, so its unresolved reads describe no fact the analysis could have found. Modules that reach Electron keep the current behavior, including the unknown findings their dynamic values produce.
Problem and expected behavior
Smallest trigger, a module without any Electron reference:
Observed on main (2fb5e20):
parse_status: "partial",parse_error_count: 0, limitation "One or more static keys, expressions, or Electron boundary values were dynamic and remain unknown.", graph coveragepartialwithomitted_count: nullandlimits: [].Expected:
parse_status: "complete"and complete graph coverage. The unknown is attributed by a walk that can only ever emit Electron call paths. Every emitted path starts at an Electron exposure or IPC registration (entryKindis only set bybridgeand the IPC registration branches), and every Electron value the resolver can reach starts at a require or import of the Electron module (arequire("electron")literal, the Electron identity index, or a bundler namespace that resolves to one). Without such a reference the walk cannot hide a finding, so reporting its unresolved reads as unknown findings violates the rule in AGENTS.md that unknowns describe facts the analysis could not establish, and the coverage contract indocs/javascript-application-graph.md("Graph coverage describes the analyzed artifact scope and resource limits").Change and scope
src/domain/javascript/javascriptSymbolicBindings.ts: the resolver recordsreachedElectronwhen an evaluated require names an Electron module andunresolvedRequirewhen a require's module name could not be resolved. These are the only places the resolver produces an Electron module value or gives up on one, so the gate is derived from the resolution the walk itself performs.src/domain/javascript/electronWrappedCallPaths.ts:collectElectronWrappedCallPathscounts the unknowns it meets locally and adds them to the file'sunknownFindingsonly when the walk could have reached Electron (identity bindings, the two resolver flags, an exhausted budget, or a module reference that names Electron or leaves its name unresolved). Paths, bridge findings and IPC registrations are produced exactly as before.src/domain/javascript/javascriptElectronMemberWrites.ts:referencesElectronModule(references)is the predicatefinalizeStaticAnalysisalready used inline for the Electron identity limitation, now shared and restricted to module reference kinds (static-import,dynamic-import,require); a worker or service-worker script namedelectronis a script, not a module.referencesUnresolvedModuleis its unresolved-name companion for the gate.require(name)), a require alias (const load = require; load("electron")), bundler namespaces or the identity index keep their bridge findings, IPC registrations and call paths; regression tests pin these paths and the worker-URL distinction.src/domain/javascript/javascriptSymbolicBindings.ts: when a read precedes its initializer, a resolver-backed proof drops the loader uncertainty only after establishing that the initializer cannot expose a module loader. The proof follows safe single-definition aliases and function calls, derives ordinary and rest parameter safety from the actual call arguments, treats unproven parameters, catch bindings andargumentsas loader-bearing, memoizes called functions by parameter-safety signature, and fails closed when either binding recursion or AST recursion reaches depth 128.javascriptSymbolicBindings.ts,javascriptSemanticPropertyPaths.ts): projected locals inside a late initializer go through the same binding proof as top-level projections; a late function's result keeps the loader uncertainty when a built-in prototype gained members or animport.metamember was written or escaped (SemanticPropertyPathCoverage.touchesanswers whether anything was retained below a prefix); and an alias reassigned to a binding that holds a fresh allocation (const replacement = {}) no longer shares the original object's writes.Not included: the semantics of
parse_statusfor Electron modules with dynamic values, and theomitted_count: nullnote in the issue. Both are existing, tested behavior and out of scope here.Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Contract and boundary impact
collectElectronWrappedCallPaths, which runs after the static traversal of one source. The static reference facts it reads are produced by that traversal.parse_statusiscompletewhen the parser completed and the file'slimitationsno longer carry the dynamic-unknown line; graph coverage and per-observation coverage follow. Modules with an Electron reference report exactly what they did before.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/domain/javascript/electronWrappedCallPaths.unknown_scope.test.ts: 25 cases cover non-Electron hoisted reads, real and unresolved Electron reachability, worker URLs, aliased and late-initialized loaders, default parameters, closed-over loaders, receiver-derived loaders, changed holder objects, invocation parameters, rest parameters, catch bindings,arguments, safe wrappers, a 15,000-binding alias chain, and a 15,000-term nested initializer.tests/boundary/cli/javascriptApplicationCoverage.test.ts: the built public CLI reports complete file and graph coverage for the minimal non-Electron trigger.expected 'partial' to be 'complete'(domain test atparse_status, CLI test at the file observation'sparse_status). The Electron-reference case passes on base and after the fix. The three later tests were written against the first version of this change (a skip gated on literal Electron references) and failed there: the resolved-name and alias modules lost their bridge, IPC and call-path findings, and the worker-URL module stayedpartial; they pass with the resolver-derived attribution. InstrumentingJavaScriptSymbolicBindingsonreact-dom-client.production.js(react-dom 19.2.0 from npm) showed every unresolved read came fromscheduleTimeout,cancelTimeout,scheduleMicrotask,listeneranddiscreteReplayableEventsreads inside hoisted functions, each initialized later in the file, evaluated by the isolated-world probe and by seeded walks of a module with no Electron reference. With the fix the domain analysis of that file returnsparse_status: "complete",parse_error_count: 0, 3 references, and only the "parsed as data" limitation.react-dom-client.production.jsreports the file observationparse_statusaspartialon main andcompletewith this change. Graph coverage on that file stayspartialhere for a different, named reason: the semantic pass reports "Owned JavaScript worker exhausted its heap", with both the default heap and--max-heap-mb 5120, so the coverage carries the heap and timeout limits. The reporter's run did not hit that constraint; the CLI test above shows the coverage change on a module the semantic pass completes.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/domain/javascript/electronWrappedCallPaths.unknown_scope.test.ts tests/boundary/cli/javascriptApplicationCoverage.test.tsonc6bc7bce4: 2 files passed, 26 tests passed.src/domain/javascriptandsrc/application/javascripttests vianpm run test:local -- <exact test paths>onc6bc7bce4: 105 files passed, 2,765 tests passed.npm run check:fastonc6bc7bce4: dependency check, typecheck, and lint passed.npm run format:checkonc6bc7bce4: all 4,055 matched files passed.3ef333163, rebased on main2910fc0b1) on Node 24:npm run check:fastpassed, including architecture guards across 2,811 source files. The rebase moved the symbolic-binding reads behind three newjavascriptSemanticEffectLog.tsqueries so main's effect-index guard holds without a baseline change.npm run test:local -- src/application/javascript/JavaScriptWrappedCallPathCancellation.test.ts src/domain/javascript/electronWrappedCallPaths.unknown_scope.test.ts src/domain/javascript/javascriptSymbolicBindings.test.ts src/domain/javascript/javascriptSemanticPropertyPaths.test.ts: 4 files passed, 213 tests passed.npm run test:local -- src/domain/javascript/*.test.ts: 195 files passed, 6,236 tests passed;npm run test:focused -- tests/boundary/cli/javascriptApplicationCoverage.test.ts tests/boundary/mcp/agentKnownAnswerMcp.test.ts: 2 files passed, 11 tests passed.npm run verify:advertised-schemaspassed with no summary change (v8, Go RE2 and Python engines; re2 C++ and Rust not installed locally). Not run locally: the full suite,npm run check:pr,lint:typed, Node 22 and 26.Compatibility, safety, and release
partialon non-Electron bundles as a completeness signal getcompletewhen the parse completed and no limit fired.The review follow-up at
775c437434keeps possible own-member writes visible when a timer is returned directly or through an alias or sequence. All three cases lost coverage warnings before the fix. Ordinary scheduler calls still report complete. All 211 focused parser, CLI, and stdio MCP tests andcheck:fastpassed.Author readiness
Human owner: @mertkayacs
Before merge
type(scope): outcome.