Repository navigation
fix(electron): trace IPC channels and bridge keys spelled as exact templates - #9538
Conversation
…mplates Electron call-path tracing started only at calls whose first argument was a quoted string literal, and its symbolic evaluator had no case for template literals. A template without substitutions, such as `app:template`, therefore stayed dynamic in the trace while the syntax pass already reads it as a literal channel through readExactJavaScriptLiteral. Wrapper registrations on such channels were missing, direct handlers and contextBridge exposures keyed that way got no call paths, and exact template switch cases lost their selection condition. The seed check, the evaluator and the switch-case label check now read exact strings through readExactJavaScriptLiteral. Templates with substitutions stay dynamic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
[Medium impact] The PR appears safe to merge; no blocking issue remains. SummaryThe PR makes Electron tracing treat exact templates like quoted strings for channels, bridge keys, and switch labels.
Reviews (5) · Last reviewed commit: "fix(electron): keep non-finite numeric s..." · Reviewed by Greptile |
Codex Review Summary: ❌ FailedThis 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. |
Since morluto#9477, main counts an Electron finding as proven only in modules declared CommonJS. The exact-template fixture used .js files without a package.json, so after merging main the wrapper registrations stayed unpaired (paired_renderer_transmissions 0) and the wrapper's own call changed to inferred. The change under test still works: with .cjs files the original expectations hold. Name the fixture files .cjs, like the neighbouring fixtures in this file. Validation: npx vitest run tests/boundary/cli/electronWrappedCallPaths.test.ts - Tests 27 passed (27) on the built merged tree; npm run test:local on electronWrappedCallPaths.test.ts and javascriptSymbolicBindings.test.ts - Tests 326 passed (326). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Electron call-path tracing starts only at calls whose first argument is an
exact string, then evaluates channels and
contextBridgekeys symbolically.Both steps recognized a string only as a
StringLiteralnode, so a templatewithout substitutions, such as
`app:template`, stayed dynamic there. Thesyntax pass already reads that spelling as a literal channel
(
electronStaticValueusesreadExactJavaScriptLiteral), and thereconstruction guide states that direct string literals and cooked templates
without substitutions use the same normalization boundary. On this trigger,
electron.ipchas noapp:templateregistration:With this change the trace reads exact strings through
readExactJavaScriptLiteral, so the second call registersapp:templatetheway the first registers
app:quoted. Templates with substitutions staydynamic.
No issue is linked: the trigger is self-contained, and the failure and the fix
are both shown below.
Problem and expected behavior
Violated invariant: an exact string has one meaning whatever its spelling. On
base (
c78c8aed4), an exact template had these effects:registration is missing, and the wrapper's own unresolved site does not get
invocation_channels: "literal", so renderer sends and invokes beside itstay ambiguous instead of pairing.
ipcMain.on(`app:copy`, handler)orcontextBridge.exposeInMainWorld(`desktop`, api)gets no call paths. Thechannel or key itself is already reported by the syntax pass.
contextBridgehelper invoked asexpose(`one`)besideexpose("two")reports only thetwoAPI: the traced quoted call replacesthe site's own observation, and the template call is lost.
case `win32`:label loses its selection condition, as a dynamic caseexpression does.
Source:
seedinelectronWrappedCallPaths.tscheckedt.isStringLiteral(node.arguments[0]).JavaScriptSymbolicBindings#evaluatehad no
TemplateLiteralcase and returnedunsupported TemplateLiteral.switchCaseContextadmitted only string, numeric, boolean, null and BigIntliteral case tests. #8120 describes the seed rule: seeds start only at calls
whose first argument is a string literal. #4511 is a precedent for reading
exact templates without substitutions as exact strings in another producer.
Change and scope
electronWrappedCallPaths.ts:seedstarts a trace whenexactStringArgumentreads an exact string first argument throughreadExactJavaScriptLiteral. That reader also looks through type-onlywrappers, which
evaluatealready removes, soregister("app:typed" as const, fn)now starts a trace too (tested).switchCaseContextaccepts an exact template case label. Its predicate textis the source label, for example
((process.platform) === (`win32`)).javascriptSymbolicBindings.ts:#evaluatereturns the cooked string of anexact template through
readExactJavaScriptLiteral. A template withsubstitutions still returns
unsupported TemplateLiteral. The other literalbranches are unchanged: sending them through the same reader would also
change non-finite and signed numeric literals, which is outside this fix.
ipcMain.handle(PING, fn), at sitesthat no literal-started trace reaches. feat(javascript): fold constant values and recover Electron boundaries through wrappers #2094 covers constant folding.
Object.definePropertywrites inJavaScriptSymbolicBindingsstill indexonly quoted keys. A template key there changes module export tables and
belongs in a separate change.
lets an exact template through the same seed check inside a larger
contextBridgechange, but does not change#evaluate, so a wrapper'stemplate channel stays unresolved there. feat(javascript): fold constant values and recover Electron boundaries through wrappers #2094 reads exact literals in
#evaluateinside a broader constant-folding change. Whichever lands secondhas a small textual conflict at the seed check.
and literal switch cases, and states that direct string literals and cooked
templates without substitutions use the same normalization boundary.
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".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Scope decision: not applicable; this is a fix within the existing static
analysis boundary.
Contract and boundary impact
readExactJavaScriptLiteralinjavascriptAstValues.tsowns exact-literal reading. The call-path trace inelectronWrappedCallPaths.ts(seed check and switch labels) and itsevaluator
JavaScriptSymbolicBindings, whose only consumer is that trace,now use it instead of testing for
StringLiteral. Affected outputs:electron.ipc,electron.call_paths,electron.context_bridge_apis, andthe application graph's IPC channel, handler, call-path and pairing facts
built from them. No superseded path remains.
templates, existing fields gain the facts that quoted strings already
produce:
wrapper-substitutionIPC findings, call paths, resolved bridgeexposures,
invocation_channels: "literal"when every wrapper invocation isexact, and renderer transmissions that pair.
carry the same
inferredevidence as their quoted-string equivalents. Eachsite's
observedsyntax observation is unchanged.docs/public/product-catalog.json), package, or installation impact: 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
Evidence is executed unless marked source-derived.
Tests added or updated:
src/domain/javascript/electronWrappedCallPaths.test.ts: wrapper channelsspelled quoted, as an exact template and as
"app:typed" as consteachsubstitute. When another invocation passes a template with a substitution,
that call stays dynamic and the wrapper's site keeps no
invocation_channels(negative case). Call paths start from a directhandler channel and a
contextBridgekey spelled as exact templates. AcontextBridgehelper invoked with an exact template key resolves beside aquoted key. An exact template
casekeeps its selection condition.tests/boundary/cli/electronWrappedCallPaths.test.ts: through the publicCLI, a wrapper registration on an exact template channel and a
template-keyed
contextBridgeexposure give theapp:templatemainchannel, both bridge call paths, and 2 paired renderer invokes with none
ambiguous.
Base reproduction or other evidence: with the new tests and the base source,
all 6 new module tests fail (
Tests 6 failed | 194 passed (200)), and thenew CLI test fails against a base build. Abridged:
User-visible CLI/MCP output (if applicable): the fixture below, analyzed with
rea analyze-javascript-application <dir> --format jsonafternpm run build:cachedon base and on this branch. Rows are graph nodesselected with the
jqfilter below, thensort -u; the last line of eachblock is from
summary.ipc.Fixture and jq filter
package.json:{"name":"ipc-templates","version":"1.0.0","main":"main.js"}main.js:preload.js:Remaining proof gaps:
case. The rest of
tests/boundary/cli/electronWrappedCallPaths.test.tsranonly on the merged tree (27 passed); the other boundary suites were not run.
bundles spell channels as exact templates was not measured.
argument is an exact template or a type-wrapped string, which is the work
the trace already does for the quoted spelling of the same source; the
existing visit budget still bounds it.
For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.
Boundary regressions covered: raw identity and normalization. Spellings that
normalize to one exact string give the same facts, and a template with a
substitution stays dynamic instead of becoming a guessed value. No resource
ownership or lifecycle stage changes, so no lifecycle regression applies.
For evidence-bearing changes:
Validation performed
Run on macOS arm64 with Node 24.22.2 (
.nvmrcpins 24.22.1) and dependenciesinstalled from the unchanged lockfile.
npm run test:local -- src/domain/javascript/electronWrappedCallPaths.test.ts src/domain/javascript/javascriptSymbolicBindings.test.ts—
Test Files 2 passed (2),Tests 289 passed (289).electronWrappedCallPaths.test.tswith the twochanged source files restored to base —
Tests 6 failed | 194 passed (200);the 6 failures are the new tests.
npm run test:local --on the neighbouring Electron suiteselectronBundledRequireIdentity,javascriptStaticCoverage,JavaScriptSemanticGraphElectronProjection,electronStaticAnalysisScopedIpc,electronStaticAnalysisIdentityandelectronCallPathBlockPrefixes—Test Files 6 passed (6),Tests 163 passed (163).npm run build:cached, thennode scripts/run-exact-tests.mjs run tests/boundary/cli/electronWrappedCallPaths.test.ts -t "exact template"(the runner
test:focuseduses) —Tests 1 passed | 24 skipped (25).With a build of the base source:
Tests 1 failed | 24 skipped (25).— output as shown.
npm run check:fast— passed (typecheck and lint).npx oxfmt --checkon the four changed files — formatted.origin/main(cdc4541ef) into this branch, on the merged tree:npm run test:local -- src/domain/javascript/electronWrappedCallPaths.test.ts src/domain/javascript/javascriptSymbolicBindings.test.ts—
Test Files 2 passed (2),Tests 326 passed (326);npm run test:focused -- tests/boundary/cli/electronWrappedCallPaths.test.tsbuilt the artifacts, then
npx vitest run tests/boundary/cli/electronWrappedCallPaths.test.ts—Tests 27 passed (27);npm run check:fast— passed. Since fix(javascript): preserve loader authority for exact suffixes #9477, mainproves an Electron finding only in modules declared CommonJS, so the
exact-template fixture now names its files
.cjs; the expectations areunchanged.
npm run check,npm run check:pr, the full test suite, the otherCLI/MCP boundary suites, and
npm run docs:checkandnpm run verify:test-discovery(no docs or test files added).Compatibility, safety, and release
the facts that the quoted spelling already produces.
JavaScript analysis only.
executed, and no file, process or network effect is added.
Author readiness
Human owner: @pedrocormann
Before merge
type(scope): outcome.🤖 Generated with Claude Code