Repository navigation
fix(javascript): preserve uncertainty after references escape to calls - #1292
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71cbf17e40
ℹ️ 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".
Keep rest exclusions, object overwrite ordering, and array spread offsets when tracking escaped references. Preserve conservative origins for accessors and uncertain iteration, and deduplicate deferred reference paths. Integrate current main while preserving alias assignment ordering.
Use the canonical Unicode ordering implementation after upstream export cleanup. Reuse source-analysis fixture setup for the public CLI regressions. Integrate the latest main branch.
Include the upstream translated README correction so documentation facts remain consistent.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…rsal Resolve aliases at their use or capture point, discard replaced rest/default origins, and preserve primitive snapshots before later calls. Retain saved and restored references while deduplicating conditional copied-slot selections to avoid exponential traversal. Integrate upstream main and add source regressions plus a public CLI/stdio MCP comparison verified against executed fixtures. Validation: 1,164 affected tests passed (1 skipped), 70 CLI/MCP and boundary tests passed, and npm run check:ci passed. Independent review found no remaining blockers.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d400632da9
ℹ️ 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".
|
TL;DR: I checked this on Linux, and it fixes the case it targets. On 6.2.0 and on current main, a helper that adds a field still shows up as a definite "added" change. On this branch the same comparison comes back partial, with no definite changes. The five changed test files pass: 237 tests. For a before and after, I used two v1/v2 fixture pairs. Each build made its own Evidence. Then
One small note. On the branch, both return variants come back as unpaired unknowns at path Not run: the full suite, and my fixtures over MCP. GitHub says the branch merges cleanly, though it's 40 commits behind main. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
TL;DR: Follow-up to my last comment. The full suite is clean, apart from one failure the base already has. But over MCP I hit a regression. After one partial comparison, the next comparison in the same session fails with Full suite. My fixtures over MCP. Over stdio, I analyzed each v1/v2 pair, then ran The regression. It shows up with two different pairs in one session:
The error says "Evidence state changed before the update completed. Refresh the current state and try again." It needs the first comparison to be partial. My third pair has an unresolved package import, so it comes back partial, with 2 unknowns, on every build. I compared it first, then pair A. That works on 6.2.0, main and the base, and fails on this branch. Comparing the same pair twice works. Analyzing all four folders up front doesn't help. Inline and retained inputs both fail. I didn't trace the cause. This PR adds a docs line about partial comparisons recording an unknown in the MCP session. That may be related. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: A correction to my last comment, sorry. The This ran over stdio MCP. In one session I analyzed two different v1/v2 pairs. Each imports a package that isn't there. So each comparison comes back partial, with 2 unknowns. Then I ran
In my last comment, the second pair was A. On main and the base, A comes back complete, so that second call worked. That's what made it look new. So the bug predates this PR, and it likely needs its own issue. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Reviewed d400632. No blocking issue found in the reviewed escape/capture logic. The change keeps explicit writes and possible call escapes separate, invalidates referenced children rather than replacing the containing slot, preserves shallow-copy exclusions/rest selections, and bounds repeated reference traversal. The point-local capture exception is constrained to a demonstrable same-body ordering, while outer/persistent origins still receive their own effects; that distinction is essential to avoid publishing a pre-mutation primitive from a later activation. The CLI/filesystem/MCP regressions and the incomplete-comparison coverage handling are appropriate, and CI is green at this head. Recommended merge sequencing: land #1351 first, then rerun both its exported-binding cases and this PRs reference-lifetime/escape cases against the combined tree. The two PRs touch the same semantic collection/state mechanisms, so individual green CI is not evidence for every combined interaction. Review scope: static review of the changed semantic owners and supplied regression evidence. I did not independently rerun the complete matrix or real binary/browser providers, and I am not making a performance claim. |
Preserve iterative escape/reference propagation and extended initializer types alongside lexical module-link bindings, conditional initializer tracking, and function-body entry origins. Validation: 337 focused tests including CLI/MCP capture-lifetime and exported-binding regressions, typecheck/lint, architecture guards, and formatting.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3701e03f9
ℹ️ 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".
| slot?.presence === "present" && | ||
| (slot.value.status === "literal" || | ||
| slot.value.status === "union" || | ||
| slot.value.status === "object" || | ||
| slot.value.status === "array") |
There was a problem hiding this comment.
Evaluate fallback guards at destructuring time
When a definitely present object-valued source is escaped through the selected binding, that escape changes the slot's value to unknown before referenceSourcesInactive runs, so this status whitelist incorrectly treats the fallback as reachable. For const fallback={value:"TOKEN"}; const source={child:{}}; const {child: copy=fallback}=source; mutate(copy); return fallback.value, the fallback is never selected at runtime, but the analysis escapes it and reports its value as unknown; preserve the guard value from the destructuring point instead of consulting the mutation-completed state.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
| const statement = parents.get(node); | ||
| return t.isExpressionStatement(statement) && statement.expression === node | ||
| ? statementPosition(statement, parents) |
There was a problem hiding this comment.
Track calls nested in later statements
When an escape call is wrapped in a variable initializer, await, or another expression, its immediate parent is not an expression statement and directMutationPosition loses its ordering entirely. Thus const source={value:1}; const snapshot=source.value; const ignored=mutate(source); return snapshot reports snapshot as unknown even though the primitive was copied before the call; locate the containing unconditional statement so later nested calls can be excluded from earlier captures.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
| !t.isObjectExpression(initializer.node) && | ||
| !t.isArrayExpression(initializer.node) && | ||
| !t.isIdentifier(initializer.node) && | ||
| !t.isMemberExpression(initializer.node) && | ||
| !t.isOptionalMemberExpression(initializer.node) |
There was a problem hiding this comment.
Unwrap transparent syntax before classifying capture origins
This classification examines the raw initializer node, so transparent TypeScript/Flow wrappers prevent an otherwise supported object or alias origin from preserving an earlier primitive. For const source=({value:1} as {value:number}); const snapshot=source.value; mutate(source); return snapshot, the TSAsExpression fails these checks and the analysis reports the snapshot as unknown; classify unwrapJavaScriptExpression(initializer.node).node instead.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
| sourcePosition !== null && | ||
| capturePosition !== null && | ||
| sourcePosition.body === capturePosition.body && | ||
| sourcePosition.index < capturePosition.index |
There was a problem hiding this comment.
Preserve declarator ordering when capturing primitives
Using only the enclosing statement index makes sequential declarators appear simultaneous. In const source={value:1}, snapshot=source.value; mutate(source); return snapshot, JavaScript initializes source before evaluating snapshot, but both positions have the same index, so semanticBindingPrecedesCapture rejects the capture and the later escape turns the copied primitive unknown; retain declarator or source-offset ordering within a declaration.
AGENTS.md reference: AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
|
TL;DR: Thanks for merging both, morluto. I ran the combined check you asked for on main, and it's clean. Both PRs' cases still come out right together. And the session bug from my earlier comments is fixed now. Commit This is main at Full suite. After Both PRs' cases, through the CLI:
Each matches what its own branch gave. Over stdio MCP, two different partial pairs now work back to back in one session. Replaying the first pair works too. Published 6.2.0 still fails the second call with Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
morluto#1292) * fix(javascript): preserve uncertainty after references escape to calls * fix(javascript): track iterator root escapes and preserve static captures * fix(javascript): scope comparison unknowns to their evidence * fix(javascript): track parameter origins at function body entry --------- Co-authored-by: morluto <[email protected]>
Object and array return shapes could remain literal after a helper, method, constructor, or tagged template could mutate a shared reference. Export comparisons could then report definite changes from incomplete evidence.
Preserve call-site uncertainty across aliases, awaited arguments, logical assignments, destructuring defaults, and genuinely shared children. Rest copies exclude consumed keys and known array prefixes. Spread copies respect later explicit overwrites and known array offsets. Accessors and uncertain or custom iteration remain conservative, including observed shared array-prototype changes.
Keep copied primitive slots and unrelated source values known. Deduplicate reference traversal, preserve current-main alias assignment ordering, and record a session unknown when partial comparisons produce no differing projections.
Tested:
npm run test:changed -- --base origin/main: 1,074 tests passed across 66 files; 1 skipped.npm run test:focused -- tests/acceptance/applications/applicationWorkflowCli.test.ts tests/boundary/filesystem/javascriptExportShapeComparison.test.ts tests/boundary/mcp/applicationExportShapeMcp.test.ts: 69 tests passed across 3 files.npm run check:ciandnpm run docs:check.fe9c7c75: all 22 CI jobs and Real JavaScript recovery passed. Full suite: 6,144 tests passed; 89 skipped. Includes coverage/timing, build, documentation, static checks, Windows/Linux/macOS package checks, and real Apple artifact CLI/MCP E2E.Not tested: real Hopper, Ghidra, or IDA provider execution.