fix(javascript): resolve Electron paths held in definite constants

A preload, utilityProcess.fork module path, serviceName or loadFile path
written inline as path.join(__dirname, "preload.js") resolves, but the same
expression stored in a const first stays dynamic, because staticPathFact
returned undefined for every identifier. The ESM idiom
const __dirname = path.dirname(fileURLToPath(import.meta.url)) left
path.join(__dirname, ...) unresolved for the same reason.

The path intrinsic query now also returns the initializer of a single,
unreassigned, unprojected const whose initializer the shared lexical index
proves has run at the read (the proof constant BrowserWindow options use).
staticPathFact and the filesystem-context check recurse into that
initializer, so a source-directory base survives, and the source-directory
and source-file identity proofs follow const aliases. Each constant is
substituted at most once per evaluated expression, which keeps work and
spelling bounded by the source text.

let and var bindings, reassigned, destructured or shadowed constants, reads
that may run before initialization and URL objects stay unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pedrocormannandClaude Opus 5.5 committed 2026-11-08 22:44:13 -03:00
1 parent c78c8aed40
commit 7d7180515d
5 files changed
+527 -17

No files matched your search

@@ -533,6 +533,16 @@ covers direct BrowserWindow instances, stable local aliases, and their
`webContents`; other receiver-producing APIs remain unmodeled. Complete AST
traversal does not imply complete API-model coverage.
Path values and source-directory or source-file anchors held in a single
`const`, such as `const preload = path.join(__dirname, "preload.js")` or
`const __dirname = path.dirname(fileURLToPath(import.meta.url))`, stand for
their initializers when the shared lexical index proves that the initializer
runs before every evaluation of the read. The timing rules described below for
constant options apply. Each constant is read at most once per path
expression, so repeated reads such as `const twice = once + once` stay
unknown. `let` and `var` bindings, reassigned or destructured constants, reads
that may run before initialization, and `URL` objects keep their expressions.
Artifact bytes and AST syntax are observations. Entrypoint resolution, imports,
loads, calls, and persistence relationships are static inferences and explicitly
say that syntax does not prove runtime execution. A malformed or unavailable