Skip to content

fix(javascript): attribute call-path unknowns only where the walk can reach Electron - #4915

Merged
morluto merged 43 commits into
morluto:mainfrom
mertkayacs:fix/javascript-electron-call-paths-reference
Nov 19, 2026
Merged

morluto merged 43 commits into
morluto:mainfrom
mertkayacs:fix/javascript-electron-call-paths-reference

Conversation

@mertkayacs

@mertkayacs mertkayacs commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4893.

Since 6.5.0, analyze-javascript-application reports parse_status: "partial" for ordinary production bundles that parse cleanly, and the application graph coverage follows it to partial with 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-level var initialized later (the timer shims in react-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:

function schedule(callback) {
  return scheduleTimeout(callback, 0);
}
var scheduleTimeout = "function" === typeof setTimeout ? setTimeout : void 0;
module.exports = { schedule };

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 coverage partial with omitted_count: null and limits: [].

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 (entryKind is only set by bridge and the IPC registration branches), and every Electron value the resolver can reach starts at a require or import of the Electron module (a require("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 in docs/javascript-application-graph.md ("Graph coverage describes the analyzed artifact scope and resource limits").

Change and scope

  • src/domain/javascript/javascriptSymbolicBindings.ts: the resolver records reachedElectron when an evaluated require names an Electron module and unresolvedRequire when 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: collectElectronWrappedCallPaths counts the unknowns it meets locally and adds them to the file's unknownFindings only 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 predicate finalizeStaticAnalysis already 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 named electron is a script, not a module. referencesUnresolvedModule is its unresolved-name companion for the gate.
  • Modules that reach Electron through a variable module name (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 and arguments as loader-bearing, memoizes called functions by parameter-safety signature, and fails closed when either binding recursion or AST recursion reaches depth 128.
  • Review follow-ups in the same proof (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 an import.meta member was written or escaped (SemanticPropertyPathCoverage.touches answers 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_status for Electron modules with dynamic values, and the omitted_count: null note 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

  • Semantic owner and earliest changed stage: domain static analysis, collectElectronWrappedCallPaths, which runs after the static traversal of one source. The static reference facts it reads are produced by that traversal.
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. For modules without an Electron reference, parse_status is complete when the parser completed and the file's limitations no longer carry the dynamic-unknown line; graph coverage and per-observation coverage follow. Modules with an Electron reference report exactly what they did before.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: the file-level unknown is only dropped where no Electron path could exist; retained unknowns keep their current text and placement.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; 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.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • 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.
  • Base reproduction or other evidence (executed): on 2fb5e20 with only the first test commit applied, the hoisted-read test and the CLI test fail with expected 'partial' to be 'complete' (domain test at parse_status, CLI test at the file observation's parse_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 stayed partial; they pass with the resolver-derived attribution. Instrumenting JavaScriptSymbolicBindings on react-dom-client.production.js (react-dom 19.2.0 from npm) showed every unresolved read came from scheduleTimeout, cancelTimeout, scheduleMicrotask, listener and discreteReplayableEvents reads 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 returns parse_status: "complete", parse_error_count: 0, 3 references, and only the "parsed as data" limitation.
  • User-visible CLI/MCP output (if applicable): on this host the built CLI on a directory holding react-dom-client.production.js reports the file observation parse_status as partial on main and complete with this change. Graph coverage on that file stays partial here 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.
  • Remaining proof gaps: no end-to-end complete-coverage run on the reporter's exact file on this host, for the heap reason above. No real Electron runtime execution is claimed.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/domain/javascript/electronWrappedCallPaths.unknown_scope.test.ts tests/boundary/cli/javascriptApplicationCoverage.test.ts on c6bc7bce4: 2 files passed, 26 tests passed.
  • All src/domain/javascript and src/application/javascript tests via npm run test:local -- <exact test paths> on c6bc7bce4: 105 files passed, 2,765 tests passed.
  • npm run check:fast on c6bc7bce4: dependency check, typecheck, and lint passed.
  • npm run format:check on c6bc7bce4: all 4,055 matched files passed.
  • Historical base and intermediate failure results remain recorded in the evidence section above.
  • Current head (3ef333163, rebased on main 2910fc0b1) on Node 24: npm run check:fast passed, including architecture guards across 2,811 source files. The rebase moved the symbolic-binding reads behind three new javascriptSemanticEffectLog.ts queries so main's effect-index guard holds without a baseline change.
  • Current head: 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.
  • Current head: 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.
  • Current head: the alias write bound test now uses 32,000 aliases and 2,000 writes (the same 64 million pairs) and runs in about 2.5 s. It also drops the explicit 30 s timeouts on both alias bounds, which halved the deadline hosted CI gives source tests. Main's ambient write index costs quadratic time for member writes to one object (about 8.6 s for 8,000 writes on main too), which this bound does not exercise.
  • Current head: npm run verify:advertised-schemas passed 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

  • Breaking changes or migration steps: none. Consumers that treated partial on non-Electron bundles as a completeness signal get complete when the parse completed and no limit fired.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no provider involved. Linux x64, Node 24.18.0.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; the walk still runs everywhere, only the attribution of its unresolved reads changes.

The review follow-up at 775c437434 keeps 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 and check:fast passed.

Author readiness

Human owner: @mertkayacs

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T05:37:03.468702Z 775c437 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

This 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.

  • Unrelated unresolved reads no longer make JavaScript files partial.
  • The resolver checks later values before calling an earlier read unknown.
  • Writes through a fresh replacement no longer blur the original object.

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
Loading

Reviews (25) · Last reviewed commit: "fix(javascript): retain uncertainty for ..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@mertkayacs mertkayacs changed the title fix(javascript): expand Electron call paths only with an Electron reference fix(javascript): attribute call-path unknowns only where the walk can reach Electron Oct 18, 2026
@mertkayacs

Copy link
Copy Markdown
Contributor Author

Both findings were right, and I checked them against main first: require(name) with const name = "electron" and const load = require; load("electron") lost their bridge finding, IPC registration and call path on the previous head, and new Worker(new URL("electron", import.meta.url)) with the hoisted read stayed partial. Two follow-up commits, and the PR title and body now describe the new shape.

  • The early skip is gone: the walk runs on every module, so no finding can disappear. Unknowns met on the walk are counted locally and attributed to the file only where the walk could have reached Electron, decided by the resolver itself: JavaScriptSymbolicBindings now records reachedElectron at the one site that turns a require into an Electron module value and unresolvedRequire at the site that gives up on a require's name. Identity bindings, an exhausted budget and the static reference predicates remain as conservative backstops for requires the walk never evaluates.
  • referencesElectronModule is restricted to module reference kinds (static-import, dynamic-import, require), so a worker or service-worker URL named electron no longer counts; referencesUnresolvedModule covers require(<non-literal>). One visible consequence: a worker script named electron no longer adds the Electron identity limitation in finalizeStaticAnalysis, which I believe is correct.
  • Regression tests for both reviewer examples and the worker URL case; the react-dom file still analyzes as complete.

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, check:fast passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@mertkayacs
mertkayacs force-pushed the fix/javascript-electron-call-paths-reference branch from 0a99090 to 7c9596b Compare October 18, 2026 07:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@mertkayacs
mertkayacs force-pushed the fix/javascript-electron-call-paths-reference branch from 7161c5e to 9c0b6cf Compare October 18, 2026 22:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@CassieFox23 CassieFox23 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) 🦊

@mertkayacs

Copy link
Copy Markdown
Contributor Author

@CassieFox23 I verified all four against 9c0b6cf.

  • load.call(require) returning this: valid. The loader-free proof ignored ThisExpression; it now treats the receiver as unproven. The exact fixture now stays partial in a regression test.
  • holder.load = require: valid. The proof inspected only the holder initializer and ignored indexed member writes. It now rejects bindings present in the write or mutation indexes. The exact fixture now stays partial in a regression test.
  • this.r(name): valid for the same receiver root cause. Its separate exact fixture now stays partial in a regression test.
  • Returning the string "electron": valid false partial, but pre-existing on base 22ddd82, where every late unresolved read was attributed unconditionally. A correct fix needs use-sensitive analysis of whether the returned string can feed a module loader, so I left it out of this PR instead of broadening the change.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@mertkayacs

Copy link
Copy Markdown
Contributor Author

I verified all four findings against c6bc7bc. Each reproduced and was valid, and I fixed them in 77900ac.

  • Unbound ambient identifiers now fail the loader-free proof closed unless explicitly known inert. The regression covers non_webpack_require.
  • Member writes are indexed across holder binding aliases. The regression covers alias.load = require followed by holder.load(...).
  • Conditional and logical arms, plus the final sequence value, now retain the caller invocation and parameter proof context. One table regression covers all three forms.
  • import.meta by itself is no longer loader evidence. Dynamic import remains loader evidence, and the regression covers import.meta.url.

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.

@greptile-apps

greptile-apps Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@mertkayacs

Copy link
Copy Markdown
Contributor Author

I verified all six findings against 77900ac. Two were new false-complete cases, fixed in 58f6759:

  • Mutation through a called parameter now reaches the existing alias-aware mutation and escape facts before the loader-free proof runs. The exact install(holder) fixture now stays partial in a regression test.
  • Literal-member loader proof now consumes the existing prototype-uncertainty fact while preserving known own properties. The exact Object.prototype.load = require fixture now stays partial in a regression test.

The timer shim, alias reassignment, and sequence-wrapped callee fixtures remain conservative partial results, so unresolved cases fail closed and do not create false-complete coverage. The alias-write allocation report is an adversarial resource case rather than a false-complete result. I acknowledge these remaining precision and resource edges, and I think human review is the right next step rather than broadening this PR again.

Validation: regression file 33/33, JavaScript domain and application tests 2773/2773, compiled Electron and application boundary tests 28/28, and check:fast passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@CassieFox23 CassieFox23 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/javascript for the base, 9c0b6cf and 77900ac versions in a scratch copy, ran the same probes, then put the head files back and checked them with diff -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.
@mertkayacs
mertkayacs force-pushed the fix/javascript-electron-call-paths-reference branch from 1a492a1 to 3ef3331 Compare November 16, 2026 01:30
@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 enabled auto-merge (squash) November 19, 2026 05:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1347 to +1350
(this.#scopeContains(binding.scopeId, functionScopeId) &&
binding.initializers.every(
({ projection }) => projection.length === 0,
)) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +1263 to +1265
loaderFree = semanticCallableResultExpressions(node).every(
({ node: result }) =>
this.#chargeLoaderProof() && this.#isLoaderFreeResult(node, result),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@morluto
morluto merged commit cad3209 into morluto:main Nov 19, 2026
42 checks passed
@morluto morluto added bug Something isn't working provider: electron Analysis provider / engine: electron area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: electron Analysis provider / engine: electron

Projects

None yet

3 participants