Repository navigation
fix(javascript): preserve loader authority for exact suffixes - #9477
Conversation
…58-loader-origin-fix # Conflicts: # src/application/javascript/JavaScriptArtifactGraphBuilder.ts
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ece1cfbec7
ℹ️ 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".
|
Follow-up on the outside-diff finding: the reported child-property behavior was already fixed by 8c3af19. On the current branch, real reference-source imports after require.call.extra, require.apply.extra, and require.resolve.extra writes all resolve internally. The final guard also protects a distinct case: deleting it falsely resolves a directly replaced box.load() alias as internal. It therefore remains in place. Test-only commit 1c1485f adds these positive cases and direct/deferred alias-replacement controls. The 32-test reference-source boundary run, targeted formatting check, and diff check passed. The reported example passed before this test-only follow-up; the deletion negative control failed as described. No production redesign was needed. |
main renamed the Electron loader-authority handling in morluto#9477, so the merge only needed the summary count to keep both sides: main's proven-finding filters for the seven existing fact families plus this branch's dynamic_code family. The domain fixture now parses as CommonJS because a .js fixture resolves as ESM and every require keeps only candidate loader authority, which hid the cache path from the unit test while the real .cjs boundary test already passed.
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]>
…mplates (#9538) * fix(electron): trace IPC channels and bridge keys spelled as exact templates 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]> * test(electron): declare CommonJS in the exact-template CLI fixture Since #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]> * refactor(electron): read switch case literals through the exact-literal owner * fix(electron): keep non-finite numeric switch cases as selection predicates --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: morluto <[email protected]>
Summary
Fixes #8973; relates to #9446. An uppercase
.MJSfilename does not establish Node's lowercase.mjsloader, but REA could infer a module or a CommonJS wrapper from the filename. Preserve unknown-host loader observations as candidates instead of reporting proven, resolved dependencies. Apply package and preload loader context only to exact lowercase.jsand.tssuffixes as appropriate; uppercase spellings keep candidate dependencies. Case-variant suffixes also keep runtime mode unknown when the source combines ESM syntax and a possible CommonJS request; both syntax observations remain available. The same rule applies to dotfiles such as.MJS, whose suffix is not returned bypath.extname. Reference-source classification uses the same JavaScript syntax admission for suffix-only dotfiles, retaining their language and candidate relationships.This change continues ShuaixinHuang's #9428 and retains its original commits and authorship. It also addresses three review findings: aliases retain conditional loader authority, writes to child properties do not by themselves replace the parent callable, and TypeScript-wrapped
call/applyinvocations still check callable mutation.Scope and evidence
The existing static JavaScript analysis owns loader mode, provenance and invocation effects; CLI and MCP consume those facts. The change does not add target execution. Candidate references and graph Evidence carry uncertainty instead of claiming a proven loader. No operation names or input schemas change.
The three review examples failed against #9428's
fc98a0653chead and pass through both CLI and stdio MCP with this follow-up. Shadowed and reassigned alias controls also pass. A related consecutive-method case also failed because receiver-escape tracking treated a later effect as preceding a proven native resolver. The ambient-effect owner now uses source-order proof while keeping repeated, deferred, and otherwise uncertain execution conservative. Both dependencies are retained through CLI and stdio MCP; prior opaque calls and repeated function execution remain unknown. A nested-alias follow-up also checks callable mutation after selecting the loader value: replacingbox.load.callno longer invents a dependency, while writes to a child property remain valid. Conditional constructor calls now retain literal requests through direct and aliased loaders; shadowed and replaced constructors stay local. Reference-source import also retains constructor requests, normalizes TypeScript-wrapped callees, and follows nested loader aliases using the selected callable path. Unknown-host resolution stays unknown; replaced or shadowed loaders are rejected. Both consumers use the same selected-callable mutation rule. Shared graph projections keep conditional built-in node markers, relation resolution and Evidence together across configuration, request, resource, timer and child-process operations; operation-specific properties remain local. Graph acceptance checks require the expected relations and their candidate or proven Evidence.TypeScript-wrapped unknown-host
require.resolvecalls retain their resolver operation in the shared call fact, with deferred mutation checks using the normalized callee. Mixed ESM and unknown-loader alternatives for the same built-in now retain the operation as conditional. The shared identity and receiver checks consider equivalent origins and their mutations; different modules and CommonJSdefaultslots remain distinct. Nested receivers such asselected.promises.readFileuse the same origin and mutation rules, including replacement of the selected object or method.Validation performed
npm run test:focused -- tests/boundary/filesystem/referenceSourceLoaderConstructors.test.ts tests/boundary/filesystem/referenceSourceImport.test.ts tests/boundary/filesystem/referenceSourceShadowedRequire.test.ts tests/acceptance/applications/javascriptPackageSuffixCase.test.ts— 34 tests passed, including reference-source and CLI/stdio MCP workflows; the reorganized constructor boundary assertions were rerun separately. The publicimport-reference-sourceCLI and the constructor boundary test also passed together for suffix-only dotfiles. A Node 24.22.1 control successfully ran the CommonJS-package.MJSmixed-syntax fixture; the module-package control failed atrequire.npm run test:focused -- tests/acceptance/applications/javascriptConditionalBuiltinEffects.test.tspassed through CLI and stdio MCP.npm run test:focused -- tests/acceptance/applications/unboundRequires.test.tspassed all 11 tests, including CLI and stdio MCP.npm run test:focused -- tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts— 10 passed against the built worker with Node 24.22.1. Restoring the old fixture filenames reproduced all three CI failures; the fixtures now declare CommonJS with.cjsbecause the selected inventory has no package manifest establishing a.jsloader. The native-loader source suite passed 14 tests, including the ESM control.npm run format:checkpassed after formatting the files reported by CI.npm run check:fast— typecheck and lint passed.Maintainer follow-up
Candidate Electron windows were being treated as proof that their preloads execute with CommonJS authority. The preload context owner now requires a proven window; candidate evidence remains candidate, with a positive proven-window control retained. Filename handling now uses the shared Node extension interpretation instead of suffix matching: extensionless dotfiles named .mjs/.cjs/.js/.ts/.json/.node cannot establish a loader without route evidence. Existing normal-extension, shadowed/replaced resolver, and wrapped receiver controls remain covered.
At d389477, the new negative controls failed before repair and pass afterward. The final checks passed 135 domain tests and 25 built CLI/MCP/reference-source/Electron boundary tests, plus uncached check:fast and full format:check. Node 24.22.1 probes confirm that suffix-only names differ by load route; no real Electron application qualification was performed. Current-head CI and Greptile review remain required before merge.
Fixed in 2540713. The helper previously converted an absent source module into undefined/empty facts, allowing negative assertions to pass without preload evidence. Every helper caller requires a source module, so sourceRequireFacts now fails explicitly if that module is absent. The regression also requires a BrowserWindow with loader_authority: "candidate" and checks that the preload module format is "unknown" before checking the unresolved dependency. Removing preload.js from the fixture made this test fail with the missing-source-module error; after restoring it, all 12 acceptance tests passed. Full format:check and uncached check:fast also passed. No further cleanup for this finding remains; current-head CI and automated review are still required before merge.
Follow-up on the outside-diff finding: the reported child-property behavior was already fixed by 8c3af19. On the current branch, real reference-source imports after require.call.extra, require.apply.extra, and require.resolve.extra writes all resolve internally. The final guard also protects a distinct case: deleting it falsely resolves a directly replaced box.load() alias as internal. It therefore remains in place. Test-only commit 1c1485f adds these positive cases and direct/deferred alias-replacement controls. The 32-test reference-source boundary run, targeted formatting check, and diff check passed. The reported example passed before this test-only follow-up; the deletion negative control failed as described. No production redesign was needed.
Author readiness
Human owner: