Repository navigation
fix(javascript): resolve module-level Electron options in functions - #8852
ShuaixinHuang wants to merge 29 commits into
Conversation
Codex Review SummaryThis 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. |
[High impact] The reviewed changes appear safe to merge; both numbered findings are addressed. SummaryThis PR resolves initialized module-level Electron options inside functions while keeping uncertain early activation dynamic. The latest changes address both numbered review findings:
No new actionable issue or security flaw was identified in the reviewed changes. No tests or target applications were executed during this review. Supersession could not be checked because GitHub access was unavailable. Reviews (3) · Last reviewed commit: "fix(javascript): retain projected receiv..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5099a450a3
ℹ️ 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".
| const [receiver, key] = invocation.arguments ?? []; | ||
| if (!t.isExpression(receiver)) continue; |
There was a problem hiding this comment.
Preserve reflected reads when apply arguments are unresolved
In a classic script, const args = [globalThis, 'createWindow']; Reflect.get.apply(Reflect, args)(); can activate the hoisted function before its captured options const initializes. The invocation owner identifies Reflect.get but leaves its arguments unresolved because arrayArguments only expands literal array syntax. This continue drops the read entirely, allowing a later bare call to establish an apparently safe initialization bound and produce definite Electron preferences despite the early TDZ. Retain an unknown receiver/property read when a recognized intrinsic has unresolved arguments.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| t.isIdentifier(node, { name: "Reflect" }) || | ||
| t.isStringLiteral(node, { value: "Reflect" }) | ||
| ) | ||
| mayReferenceReflect = true; |
There was a problem hiding this comment.
Recognize template-literal Reflect roots in the indexing gate
A classic script that accesses Reflect only as globalThis[`Reflect`].get(globalThis, 'createWindow')() never sets this flag: the property name is a template literal, not an identifier or string literal. The shared static-property parser and intrinsic resolver already recognize this syntax, but readInterop is never created, so an activation before the captured options const disappears from the timing inventory. A later ordinary call can then make those options appear definitely initialized. Use the shared static-key interpretation when deciding whether this indexing pass can be skipped.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| if (t.isArrayExpression(node)) fact.owners.add("Array"); | ||
| else if (t.isFunction(node)) fact.owners.add("Function"); |
There was a problem hiding this comment.
Include object and string prototypes in receiver isolation
In classic-script mode, globalReceiver also classifies ordinary object and string literals as isolated, but only arrays and functions receive prototype provenance here. For example, Object.setPrototypeOf(String.prototype, globalThis); ''.createWindow(); before the captured preferences const activates the hoisted function and hits its TDZ. Although the String prototype mutation is indexed, the property read is discarded as unrelated, allowing a later bare call to establish definite preferences. Ordinary objects have the same gap with Object.assign(Object.prototype, globalThis). Track the applicable prototype owners or retain uncertainty for these receivers.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| state.implicitPropertyReads.set( | ||
| node, | ||
| semanticPatternPropertyReadSources( | ||
| parent.handler.param, | ||
| { node: node.argument, projection: [] }, |
There was a problem hiding this comment.
Retain unresolved sources for catch-pattern property reads
Recording catch reads only for lexically matched throws misses a classic-script activation such as function fail() { throw globalThis; } try { fail(); } catch ({ createWindow: start }) { start(); } before the captured preferences const. The throw inventory stops at the function boundary, and ordinary property-read collection does not handle catch clauses, so this handler contributes no read. A later bare createWindow() can consequently establish definite initialization despite the earlier TDZ. Retain an unresolved source for catch patterns whose thrown value is not proven, rather than treating the missing source as no property access.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
This comment has been minimized.
This comment has been minimized.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Superseded by #8893 at the author's request; no code change.
Review follow-up: projected receivers and method-fact reuse
A destructured binding now requires an unprojected initializer before its container can prove an own method. This retains possible early activation through a selected global receiver instead of confusing it with a same-named method on the container. Effective own-method facts are produced once per object within the timing index, and only queried for module-function names; ordered overrides and unknown spreads keep their existing conservative semantics.
The reviewed early-call case failed against the preceding producer while its VM early/late controls established the timing difference. Final verification: 213 tests passed in four files, including actual compiled CLI/stdio MCP with 34 early/late source fixtures per surface; check:fast passed (2 tasks, 29.669 s), formatter/diff checks passed. At 64/128 reads, bypassing the new cache caused 10,008/36,376 key visits and both operation-count regressions failed; fixed runs satisfy bounds 2,080/4,128 including other analysis passes. These are operation counts, not end-to-end speed or memory measurements. Comments 4466635940 and 4466635953 are addressed in code; no review thread has been replied to or resolved. Current HEAD needs its own CI result. Full remote integration tree has not been rerun locally.
Review follow-up: global activation reads
Classic scripts now retain possible early
createWindowactivation through Object/String prototype changes, top-levelthis.Array, static templateReflectkeys, unresolvedReflect.get.applyarguments, and catch destructuring after a call that can propagate an exception. Ordered object members preserve a proven own method, so unrelated receiver reads do not activate the global function.Validation: six reviewed cases were reproduced with VM early/late controls; 144/144 focused source tests, 46/46 compiled CLI/stdio MCP acceptance tests (including the expanded 28-file scenario matrix), typecheck and lint passed. Repository formatting and diff checks passed. Complete remote integrated-tree validation requires this commit's CI. Synthetic JavaScript and local adapters do not constitute a real Electron/provider/platform run.
Current follow-up: reflected invocation facts
The previously unprocessed P1/P2 findings 4462183847 and 4462231321 were independently reproduced: four additional VM early/late cases failed while 127 original cases passed. Implicit reflected reads now normalize call/optional-call candidates through the existing intrinsic invocation owner, including namespace/method aliases and bound argument forms, before retaining receiver/property selection. A cheap Reflect-root presence gate avoids invoking this owner for programs without a candidate origin. The previous direct-global callee spelling filter is removed.
Current follow-up validation: 230 tests passed across five files, including parser, intrinsic invocation, import-cycle guard, 133 option-analysis cases and 46 actual compiled CLI/stdio MCP acceptance cases. The expanded two-surface regression checks fourteen source fixtures per surface, including optional/namespace-alias/method-alias/bound Reflect.get forms. Shadowed Reflect controls retain definite settings. Four red cases are covered by VM early-TDZ/late-success controls. check:fast passed both tasks in 51.083 s; three build tasks passed (cached outputs verified to contain the current producer); formatter, diff check and post-hook source-byte checks passed.
Three files were applied to the current remote source with exact-context patches, preserving existing upstream content. The integrated remote whole tree requires the new HEAD's own hosted CI; local whole-tree integration validation is not claimed. Existing human Author declarations remain unchanged; no review reply or resolve was performed.
Latest follow-up: receiver prototype provenance and unresolved parameters
The two new P2 findings (4462231337 / 4462231347) were independently reproduced: four new VM early/late cases produced 4 failures with 122 original cases passing. Receiver identity now carries Array/Function prototype provenance along its existing initializer DAG, so alias reads use the same owner-specific effect timing as direct literals. Parameter destructuring retains an unresolved caller-supplied source instead of dropping property reads; a default cannot exclude supplied values. This deliberately remains dynamic without interprocedural argument/activation proof.
Validation for the current follow-up: 250 tests passed across seven files, including the real compiled CLI and stdio MCP acceptance file (46 tests, two newly added surface cases each checking six fixture sources), semantic-cycle guard, parser, invocation/iteration and original isolation controls. check:fast passed both tasks in 49.785 s; build passed three tasks (two cached); explicit repository formatter check and diff check passed. No existing assertions were weakened; the new unresolved-parameter cases retain VM early-TDZ/late-success evidence while correctly expecting conservative static uncertainty in both positions.
Four files were applied with exact-context patches to the published remote source, preserving existing content; the integrated remote whole tree was not independently rerun locally. The new HEAD requires its own complete hosted CI. Ordinary push retains the existing human Author declarations. No review reply or resolve was performed.
Implicit reads and bounded prototype indexing
Record Reflect.get property reads and retained throw/catch pattern projections at the shared definition boundary. Module initialization timing and member-effect analysis consume the same state-owned read facts. Bare static constructor writes no longer count as inherited prototype changes; actual prototype mutation retains uncertainty. Reject structurally impossible builtin-owner paths before shared identity matching, preventing repeated deep-chain scans that failed Source/Portable source-map tests.
Validation: five new VM-backed controls initially failed (5 failed / 114 passed). Final 300/300 tests across five complete files pass, including all 100 source-map fetcher tests, 44 real compiled CLI/stdio MCP tests, import-cycle assertions and shadowed/unrelated Reflect/catch controls. The unchanged 12,000-member source-map regression failed locally before the bounded owner gate and passes afterward. check:fast 2/2 passed; formatting/diff checks passed and seven committed local files remain byte-exact after hooks. Static-write controls are tested in the new implicit-read workflows; actual prototype mutations keep their conservative protection. No assertion, timeout or resource limit was weakened. Exact-context patch preserves remote integrated content, but the complete integrated remote tree was not locally rerun and requires fresh current-head CI. Synthetic JavaScript with local adapters is not a real Electron/provider/platform validation. Node24.22.1/existing npm10.9.3, no dependency installation.
Outer activation and prototype correction
Computed definition keys and class heritage retain their surrounding lexical-this owner; field values, static blocks and ordinary method/function bodies remain isolated. Tagged intrinsic invocations retain possible global activation. Array/function literal isolation now consults owner-specific prototype-effect bounds shared across reads; unrelated and later prototype effects retain their controls. Immutable statement indices are built once per owning body, including distinct functions.
Validation: four new early/late VM regressions initially failed (4 failed / 106 passed); final 238/238 tests pass across six complete files, including 40 real compiled CLI/stdio MCP cases, source-context controls, the unchanged import-cycle assertion and existing long-alias controls. The new distinct-function operation-count regression fails against the prior producer with 129 body indexOf calls, then passes an at-most-one bound while preserving 128 semantic results. This is an operation count, not a completed-workflow speed or memory measurement. check:fast 2/2 (62.206s); all 13 local files remain byte-exact after normal commit hooks. Exact-context application preserves upstream remote content and passes repository formatting. The complete integrated remote tree was not rerun locally; this new head requires its own hosted CI. Synthetic/inert JavaScript and local adapters do not establish real Electron or Linux/macOS behavior. Node 24.22.1 / existing npm 10.9.3; no dependency installation.
Effect-free receiver correction
When the completed receiver summary has no effects, preserve its ordinary-object identity without requiring a function/loop read position. Ordering is consulted only when an effect exists. This prevents unrelated deferred, repeating and aliased property reads from hiding proven Electron settings.
Validation: three new VM-backed controls failed before the fix; 171/171 tests across four files pass, including unchanged early-call protections, operation-count controls, cycle assertion and actual compiled CLI/stdio MCP fixtures with unrelated function/loop reads. check:fast 2/2 (36.243s); all three local files byte-exact after hooks. Exact-context patch preserves upstream contents; the complete integrated remote tree requires fresh hosted CI.
Aliased receiver and lexical-this correction
Propagate source-owned receiver effects through initializer aliases using one per-binding timing summary. Keep allocation identity separate from effect timing and retain uncertainty for cycles, deferred effects and ambiguous same-statement bounds. The shared source-context owner recognizes a possible classic-script top-level lexical this; modules, CommonJS wrappers and non-lexical function/class owners stay isolated.
Validation: three VM-backed early/late regressions failed before the fix. 293/293 tests across ten files now pass, including actual compiled CLI/stdio MCP aliases/computed constructors, unrelated-object controls, source parser, cycle and long-alias cases. check:fast 2/2 (30.512s); seven local files byte-exact after hooks. The 64/128 read-before-distinct-write regression counted 8192/32768 effect visits before, and passes bounds of 128/256 after. These are operation-count controls, not complete-workflow speed or memory measurements. Exact-context application preserved upstream remote contents and passed repository formatting; the complete integrated remote tree requires new hosted CI.
Constructor and receiver-effect timing correction
Normalize bound constructors and Reflect.construct through the shared intrinsic invocation owner. Receiver allocation identity stays cached separately from source-owned read-time effects; recompute module read bounds after the member-effect inventory completes. This retains early TDZ uncertainty for post-allocation Object.assign/setPrototypeOf while preserving unrelated own-method and nested-literal controls.
Validation: baseline four VM-backed early/late regressions failed; 252/252 tests across nine files now pass, including actual compiled CLI/stdio MCP cases, cycle check, identity and long-alias controls. check:fast 2/2 (31.93s), all eight local files byte-exact after hooks. Exact-context patch preserves integrated upstream contents; the complete remote integrated tree still needs fresh hosted CI.
Runtime-read and import-cycle correction
Pure copied-reference paths now have a separate owner, removing the Source/Portable test import cycle. Shared static property selection preserves unrelated nested receiver identity; erased TypeScript reads no longer activate module functions.
Validation: 231/231 tests across eight files including unchanged cycle checks and compiled CLI/stdio MCP; check:fast 2/2 (22.329s). All nine local files byte-exact after hooks. Two integrated upstream files preserve their remote contents with import-only migration. The full integrated remote tree was not locally rerun; fresh hosted CI is required.
Problem and outcome
Keep module-level Electron const options uncertain when a hoisted function can be read or activated before initialization. Use parser-owned runtime context, lexical direct-eval facts and conservative global-code bounds rather than Babel syntax alone.
Pattern property reads now come from the existing
semanticPropertyReadSourcesowner, covering declarations, assignment destructuring and for-of patterns. The specialized declarator-only decoder is removed. Nested/iteration projections without a disjointness proof retain possible activation rather than proving global isolation. Ordinary unrelated receiver controls remain.Immutable enclosing-function positions are cached with the existing parent-map facts. The shared source-read index, incremental opaque effects and per-binding receiver summaries remain; distinct initializer identities are preserved.
Validation and limits
check:fast: 2/2 passed in 56.193s.5b8594a6c806d0fd7dc9386f38f3ea7ba47d7f5c; new hosted CI pending. Previous complete green runs cover earlier heads only. Human declarations remain intact, and no target Electron application execution is claimed.Earlier validation records and scope limits
Runtime-context and lexical-eval corrections
Use the parser-owned runtime context for hoisted-function global activation: erased TypeScript imports do not establish module isolation. Include the already indexed, scope-owned direct-eval sites in initialization timing even in ESM/CommonJS; indirect eval and Function construction retain their separate global-visibility rules.
Receiver summaries now share a representative by binding identity while keeping initializer-expression identities separate. Repeated member reads reuse the same initializer summary instead of expanding the binding again.
Validation: previous producer fails both new P1 regressions (2 failed / 114 passed); the fixed final selection passes 217 tests in seven complete files, including compiled CLI/stdio MCP TypeScript and ESM fixtures, lexical early/late controls and prior identity/alias/opaque-effect cases. Independent Node ESM controls throw ReferenceError before initialization and return 1 after initialization.
check:fastpasses 2/2 in 29.693s.The owned diagnostic for 64/128/256 receiver reads recorded 4160/16512/65792 initializer visits before and 65/129/257 after. This establishes removed repeated expansion; one warm in-process sample per size does not establish general end-to-end speed or memory improvement. Logs include wall time, CPU and cumulative process peak RSS. No probe instrumentation is committed.
Current head:
1016f6c9d433727e1cc3b2ef8dba1461458958bb; new hosted CI pending. All four changed files match the checked local bytes after hooks. Upstream's existing call-site presence assertion is preserved. Other checkout files remain from earlier integration, so complete current-tree validation still requires hosted CI. The ESM positive public control omits opaque eval because eval may mutate the options object even after initialization; the dedicated lexical-binding regression separately checks early versus late direct-eval ordering.Problem and outcome
Keep hoisted Electron option reads uncertain when classic-script global code may activate the function before its captured const is initialized. The shared opaque-global observer now recognizes Function construction as well as eval through the existing global identity and intrinsic call owner, including
new, aliases, call/apply and bound calls. Local shadowed constructors retain definite options.Constructed code may escape, so construction supplies a conservative possible-activation bound. This does not assert that merely creating a function executed it; unused constructed functions can therefore retain uncertainty. No source strings or target Electron programs are executed by the analyzer.
The source timing index remains shared and incremental. Internal discovery facts now name global code rather than eval alone; call positions and retained effect facts include constructor nodes.
Validation and limits
npm run check:fast: 2/2 passed in 43.954s. Precommit preserved all six checked files byte-for-byte.13f5340e8bfe199766d6af982ff4342520a11626. New hosted CI is pending; the previous head's full CI success does not cover this push.Earlier evidence and verification limits
Problem and outcome
Hoisted Electron functions could treat module-level const options as initialized despite an earlier possible classic-script activation. Preserve uncertainty for early global aliases, destructuring, logical assignment, prototype/spread receivers and indirect eval; retain concrete values where initialization is actually ordered.
The shared initializer owner builds the source-read index once. It records possible call positions during that walk, then consumes newly observed opaque global calls incrementally. This keeps callee-resolution prewarming from freezing incomplete timing facts and avoids rebuilding the entire source index after each eval. Existing per-node receiver facts, unrelated-object controls and function-boundary rules remain.
Validation and limits
npm run check:fastpassed 2/2 in 62.068s.e4cf01fa4a9ccfa766c5ad9427be4fd0c40f60c3; new hosted CI pending. Existing human declarations are preserved. No target Electron application was executed, and no new real-platform/provider coverage is claimed.Earlier validation records and execution limits
Current CI integration — 2026-11-03
Current head:
e2e3576f238df648d9fd714b1425d0769a9be153. The first cache-fix run failed only the formatting gate: Static checks identifies the upstreamwebsite/wrangler.tomlwatch-directory array. The same exact blob (7c64886b3005bda755a580e36eb058d3f84d7755) exists on maind496d803a4f50dc82248db0630042894c1136d00. Integrated that main normally, preserving its GitHub-computed merge tree, then applied only the formatter's array wrapping. TOML parsing before/after produces identical values; the exact affected file fails formatting before and passes afterward. #7716 already contains the same incidental gate correction, so no duplicate standalone PR was opened.The 126 tests and check:fast below cover the local cache correction before upstream integration. The full integrated tree has not been rerun locally; its new hosted CI is pending. No runtime/configuration values or test expectations were weakened.
Activation-cache lifetime correction — 2026-11-03
Callee resolution could populate module-function timing before the ambient observer had recorded a later indirect eval. That stale cache then incorrectly treated an early classic-script function call as occurring after const initialization. Cache entries now include the append-only opaque-global-site count and are rebuilt when that producing index grows; unchanged effect prefixes still reuse the shared timing facts.
Reproduction against the previous published producer: 1 failed / 77 passed, including a VM-backed early-throw / late-success control. Fixed validation: 126 passed in four complete files, including compiled CLI and stdio MCP coverage of this cache-prewarming case;
npm run check:fastpassed 2/2 in 31.009s. Existing unrelated-object, late-call and 6000-alias controls remain. No performance improvement or new real Electron runtime claim. Current head:c347f9ad462f812a128a514dc35954b370c3d10d; its new hosted CI is pending. Precommit only wrapped a condition; remote tree exactly matches the committed local tree.Projected and opaque activation correction — 2026-11-03
Retain classic-script function reads through global destructuring, logical assignment, prototype/spread receivers and opaque global eval. Reuse the shared write-read and opaque-effects facts. Receiver aliases now use an iterative per-node postorder cache: each initializer retains its own answer, cycles stay uncertain, and shared alias prefixes are reused.
Previous production fails all five new VM-backed cases (5 failed / 72 passed). Fixed focused validation passes 123 tests in four complete files, including compiled CLI/stdio MCP; final option grouping passes 77 tests. The 6000-alias control now reads every intermediate receiver. check:fast passes 2/2 in 36.912s. Precommit removed one blank line only; production and assertions remain the tested bytes. No measured performance speedup is claimed. Fresh hosted CI is required for this HEAD.
Receiver identity follow-up — 2026-11-02
An alias with both an ordinary object and the global object as possible origins previously cached its combined answer on the ordinary object's initializer. A later unrelated method call then incorrectly made safely initialized Electron preferences dynamic. Cache the combined answer only on the queried receiver. Unknown computed global properties now share one earliest-read/uncertainty fact, applied to module functions once after the source scan, removing the repeated function scan per access.
The strengthened unrelated-object runtime control passes while the previous production code fails its static assertion (1 failed / 71 passed). Fixed four-file focused validation: 118 passed, including compiled CLI and stdio MCP; all 3 prerequisite tasks pass.
check:fast: 2/2 passed, 45.104s. No measured performance speedup is claimed. This new HEAD requires fresh hosted CI.Latest conservative activation correction
The previous correction still missed classic-script receiver projections, computed global keys and uncertain with-scope binding ownership. The shared first-activation owner now keeps these possible reads in its timing bound instead of treating unsupported identity as absence. Aliases use an iterative visited-node worklist with conservative cached may-alias results, so alias depth does not become JavaScript recursion depth. Callback statement lookup stops at intervening functions, including hoisted default-parameter callbacks. Existing unrelated object and shadowed-local controls remain.
Executed evidence: replacing only the production owner with the previous committed version causes 5 failures / 67 passes in the expanded option file; restoring the final owner yields 118 passing tests across options, initializer ordering, call resolution and actual compiled CLI/stdio MCP, plus 277 passing sibling binding/loader/fingerprint tests. check:fast passed 2/2 in 41.573s; diff check passed. A 6000-link flat alias fixture passes; it also passed on the previous version on this host, so stack exhaustion is source-supported rather than reproduced. No target source was executed by static analysis. Real Electron/platform coverage remains limited as recorded below.
Current HEAD:
507b50a97ca70bab1e25bbb3c201aff1097c522c. Hosted code CI for this new head is pending; previous green checks below belong to previous heads. Human declarations are preserved. No review thread was replied to or resolved.Supersedes #8634 at the author's explicit request to resubmit all current PRs. Same published branch and HEAD 4cd804c. Original discussion and historical validation remain at #8634. This new PR requires its own hosted CI and new human declarations for this PR ID.
Current review correction
Current HEAD:
4cd804cbcc17dc76f02c27f327f577d2fc7b3665.Reproduced the global-object-alias early-call case and the unrelated same-named parameter case (3 new cases failed on the prior head). The shared initializer timing owner now consumes existing lexical binding state: identifier reads match the actual function binding, and classic-script global receivers follow binding-owned initializer aliases with a cycle guard. All production callers now pass their existing analysis state rather than only its parent map; low-level parent-map-only tests retain their API. No target source is executed by analysis. Validation: 112 passed across initializer, call-resolution, Electron options and compiled CLI/stdio MCP files, plus 277 sibling binding/loader/fingerprint cases; check:fast 2/2 passed (43.349s). The VM controls confirm the early alias call reaches the temporal dead zone while the late control succeeds. These are synthetic source/VM and actual compiled CLI/MCP checks, not a real Electron application run.
The new HEAD requires its own hosted CI; earlier green runs below belong to earlier commits. Existing human declarations remain in force. The original replacement description and its execution points follow as historical context.
Supersedes #8495 at the author's explicit request to resubmit all current PRs. Same published branch and HEAD
9611e5cbe8d0d3639f87df529d2989e69a63d1f2. Original discussion and historical validation remain at #8495. This new PR requires its own hosted CI and a new human declaration for this PR ID; prior review declarations are historical.Supersedes #8250 at the author's explicit request to resubmit the existing PRs. This replacement reuses the identical published head
cc2bb1242a5611527bfb99935bc7dbcf85e902f7and full three-file patch. Prior discussion and historical verification remain at #8250 (earlier #8087). No code changes or new local test runs were made for this resubmission. This new PR requires its own hosted CI. The owner has specifically confirmed review of this replacement PR's final diff, evidence, limitations and unresolved P1, accepted full responsibility, and approved it for initial maintainer review. The P1 remains a before-merge blocker.Outstanding review follow-up — addressed in the current published revision
The known P1 review finding was addressed in the current head. In a classic script, an early
globalThis.createWindow()followed by a later bare call can make module-constant initialization appear definite even though the early activation encounters the temporal dead zone. The previously reported 115-test verification below does not establish that this additional case is fixed.A separate local draft follow-up has 67 focused tests and three build tasks passing, plus
check:fast; expanded verification and commit/push are not complete. That draft is not part of this PR's published commit or diff, and those draft results are not claimed as a fix in this revision. The prior finding is covered by the current-head regression; hosted CI and maintainer review still apply; the original review is preserved rather than marked resolved.Supersedes #8087 at the author's request. This replacement reuses verified head cc2bb12 and preserves the original discussion and validation record at #8087. Historical revision-specific validation below remains at its stated execution points. This new PR must pass its own hosted CI.
Problem and resulting behavior
Fixes #7227. Electron static analysis loses module-level immutable
webPreferencesread inside a later activation. Retain those settings when initialization precedes the function's module-level uses, while preserving uncertainty when a hoisted function can run earlier.For example, this source must remain dynamic rather than report a proven
nodeIntegration: true:Moving the call after the const initializer yields
object-literalwith the literal setting, including when the function declaration appears before the initializer.Owning change and scope
Initialization coverage stays in
javascriptSemanticMutationInitializers.ts; Electron consumers use that fact without reinterpreting declaration order. A hoisted declaration's position does not prove activation timing. The owner indexes module-level function references once per immutable module body and treats earlier aliases, indirect activations, live exports and unproven timing conservatively. This is a bounded reference-order check, not a general call graph or runtime execution proof.The existing ancestry cache also retains the enclosing function, avoiding repeated walks from deep reads. Initialization coverage remains separate from cross-function capture ordering: the latter stays unresolved so named child-process argv shapes retain their existing uncertainty. No public schema, provider, execution authority, deadline, resource ceiling or assertion was weakened.
Validation at the current follow-up
Windows, Node 24.22.1 / npm 11.16.0:
fb2532ad61ceb4cce7d233131fc1edd4305925ff, with the new source regressions: 4 failed / 47 passed. Three cases expose early direct, aliased and forwarding calls; the fourth exposes a late-call positive control.9bafc838629358fb8ebc0ce86abefa5c82c8a0ab: 112/112 passed across six complete files: Electron options 51, existing scope-depth/resource controls 14, binding initializers 13, argument shapes 30, existing child-process compiled CLI/stdio MCP 2, and new Electron initialization compiled CLI/stdio MCP 2. Three build prerequisite tasks passed.The earlier head's independent hosted CI passed, but it did not cover this hoisted-declaration review case. The new head requires its own hosted CI; an earlier green run does not validate it. Local checks use synthetic JavaScript through production static analysis and real local compiled CLI/stdio MCP. No real Electron application or Linux/macOS execution is claimed.
Loop ownership review follow-up
Commit
cc2bb1242a5611527bfb99935bc7dbcf85e902f7keeps enclosing-function identity in its own immutable ancestry cache. Loop ordering remains uncertain; entering a loop no longer erases which function owns the read. This retains initialized module-level Electron settings inside for-of, for and while loops while keeping early calls dynamic. No downstream reinterpretation or call graph expansion was added.On exact preceding head
9bafc838, the three new loop source cases fail while the existing 51 pass. With the correction, six complete files pass 115/115 (Electron 54, scope-depth 14, initializers 13, shapes 30, existing child-process CLI/MCP 2, Electron initialization CLI/MCP 2). The public adapter cases include both early and late calls inside loops and outside loops, with source provenance. All three committed files match the tested bytes exactly after normal precommit hooks. Three build tasks passed; normal prepush typecheck/lint passed 2/2, 46.166 seconds. No assertions or resource controls were relaxed.The earlier
9bafc838own hosted workflow41009833080completed successfully; the newcc2bb124head requires independent hosted validation. Validation uses synthetic inert JavaScript and real local compiled CLI/stdio MCP on Windows, Node 24.22.1 / npm 11.16.0; no real Electron application or Linux/macOS run is claimed.Author readiness
Human owner: @ShuaixinHuang
Before merge
type(scope): outcome.Current-head P1 correction
Commit
9611e5cbe8d0d3639f87df529d2989e69a63d1f2covers the classic-script global activation case. Focused domain and CLI/stdio MCP validation passed 67/67 tests;check:fastpassed 2/2. The local regression covers early and lateglobalThis/window/self/thisactivations without expanding call-graph or authority semantics.This replacement preserves the prior PR discussion and validation history at #8331. It reuses the verified published head and requires its own hosted CI.
Supersedes #8749.