Skip to content

fix(javascript): preserve intrinsic invocation read identity - #2465

Closed
aznikline wants to merge 36 commits into
morluto:mainfrom
aznikline:split/intrinsic-boundaries
Closed

aznikline wants to merge 36 commits into
morluto:mainfrom
aznikline:split/intrinsic-boundaries

Conversation

@aznikline

@aznikline aznikline commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Preserve intrinsic-invocation identity across aliased member reads, bound
callables, and destructured writes. Identifier-aliased reads of intrinsic
invocation members (e.g. const change = Object.defineProperty.call; change(...)) were left effect-free after #1912's receiver tracking: the
member path resolved but derived no callable. This change keeps such calls'
effects unknown (opaque) — argument expressions still evaluate — rather
than effect-free or a confirmed write.

Semantics, verified against a real engine (Node v26): a bare alias
invocation throws TypeError, but its argument expressions still evaluate.

Covers, on top of the shared captured-member identity model:

  • identifier-aliased .call/.apply/.bind reads resolved conservatively
  • bound invocation members with explicit receivers; alias initializers such
    as invoke = change.call resolve the captured member's canonical
    Function.prototype.<member> identity for both reads and writes
  • call-site re-reads of outer invocation members (invoke.call,
    invoke.apply) validated against writes at the callee's evaluation
    offset; nested Function.prototype.<member>.<member> reads checked at
    canonical depth
  • unknown bound-argument lists stay unknown instead of merging into an
    empty prefix
  • evaluation-order writes: destructuring RHS before pattern, per-leaf
    effect timing, sequence-expression callee tails
  • destructured write targets resolve object identity at the enclosing
    write site (statement context) while each leaf keeps its own effect
    timing; for-in sites positioned like for-of; transparent wrappers
    (as casts, assertions) defer a default target's write until after the
    default runs
  • captured-member aliases are followed transitively (copy = invoke,
    (0, change.call) sequence tails) and only canonicalize when the owner
    is a provable callable whose own slot was unwritten at capture —
    "recognized but replaced" resolves opaque, never effect-free or a
    confirmed write
  • captured members resolve as direct Reflect.apply targets
    (Reflect.apply(invoke, change, [...]))
  • merged upstream origin(root, kind, writeSite) signature and [null]
    unknown-child member-mutation encoding

Test plan

  • electronIntrinsicCapture.test.ts: 78/78 — semantic-contrast cases
    including alias writes to captured members, replaced outer-member
    reads, argument-side effects, sequence callees/tails, copied aliases,
    owner-slot replacement (opaque), bare calls of replaced captured
    members (opaque), destructured call/apply/bind captures
    (incl. slot checks at destructuring time), nested captured owners,
    explicit-receiver member calls, direct Reflect.apply targets, and
    wrapped destructuring defaults
  • javascriptSemanticAmbientWrites.test.ts: 10/10 — destructured
    writes through reassigned vs still-global aliases (Worker specifier)
  • src/domain/javascript suite: 71 files, 1778/1778
  • check:fast green; oxfmt --check clean on touched files
  • Required CI lanes on f3765f117 (run 38679888243): CI required +
    Portable tests pass; newer heads pending
  • Provisioned CI lane: check:pr full suite

Notes

  • No "proven regression" claim: base behavior retained no effect for
    aliased calls, keeping downstream intrinsic identity and producing
    unsound findings; the base/head contrast is recorded in the research
    notes (not part of this diff).

Generated with Devin

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

morluto and others added 2 commits October 13, 2026 09:57
Identifier-aliased invocation member reads like
`const change = Object.defineProperty.call; change(...)` invoke
Function.prototype.call without a callable receiver and throw TypeError
at runtime. Assert the resolver keeps them opaque (conservative unknown),
never a confirmed write, while resolvable callables still resolve known
and argument-side effects remain recorded.
aznikline added a commit to aznikline/rea that referenced this pull request Oct 13, 2026
…terface semantics

Verifier: history_mode=none zero-byte inputs are a valid "no records"
state (not corrupt); packaged-input existence no longer counts as hash
coverage; cancelled runs recorded but ineligible; missing window
endpoints produce OBSERVED_PARTIAL + ineligibility instead of a crash;
ready_epoch_s required when readiness is claimed.

Regression: F18–F22 fixtures for the five focused-review cases (27/27);
T8–T10 run the real runner->extract->verify chain for R0 empty-history
negative, R1 positive, R2 repeat, and cancelled runs (10/10).

Ledger: PR morluto#2465 exists upstream (Draft, approval-blocked); tart pull
resolved — image digest pinned; VM precheck pass (SSH, macOS 15.7.7).
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the outstanding explicit-receiver bug is fixed.

Summary

Preserves captured invocation-member identity across aliases, bound functions, reads, and writes.

  • Captured invocation aliases keep their callable identity.
  • Destructured writes now follow JavaScript's evaluation order.
  • Two boundary tests keep the same checks with tidier formatting.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Captured invocation member] --> B{Explicit receiver supplied?}
  B -->|Yes| C[Select the receiver as callable]
  B -->|No| D[Use existing member rules]
  C --> E[Shift call or apply arguments]
  E --> F[Check selected callable again]
  F --> G{Callable understood?}
  G -->|Yes| H[Record its effects]
  G -->|No| I[Do not claim an intrinsic write]
Loading

Reviews (28) · Last reviewed commit: "fix(javascript): prefer the explicit rec..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review October 13, 2026 11:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-17T03:54:30.767987Z 3e18226 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d5e11efcd

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c75efc034

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: facc35478f

ℹ️ 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".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1, thread 2, thread 3, thread 4

Handled in facc354. The invocation owner preserves receiver loss while peeling comma expressions, so detached call/apply values stay opaque. intrinsicReadChanged follows stable aliases and sequence values through separate invocation-member and base-capture checks. Call-effect offsets now use node.end, preserving findings evaluated in arguments before the opaque invocation takes effect. Added targeted receiver, aliased-capture and converted-window argument regressions.

Source inspection and git diff --check completed. Tests, builds, typechecking, lint, and real-provider verification were skipped at the user's explicit request.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

This finding is already addressed in the current branch. The write owner retains replace-value, mutate-object and opaque as distinct effects; invocation-member reads test immediate object mutation as well as exact slot replacement. Object.assign(define,{call:replacement}) therefore invalidates the captured function's later .call read, while replacing Object.defineProperty alone preserves an already captured function. The existing focused source regression covers this example. The final follow-up also preserves that distinction while fixing destructuring evaluation order. Validation: inspected producing boundaries and affected consumers; targeted source formatting and git diff --check completed. Tests, typechecks, lint, builds, provider runs and CI reruns were not executed, per the user's explicit instruction. No directly related cleanup is deferred.

  1. thread 1, thread 2

Root cause: whole-assignment end effects and source offsets place every destructuring write after all defaults, even though JavaScript writes each leaf before evaluating later defaults and computed keys. The identity-write owner now traverses destructuring RHS before targets, retains each leaf at its completed assignment point (after its own default), and shares those evaluation boundaries with intrinsic-read/dependency validation. Ordinary assignments remain exit effects. Shared AST child expansion is retained through an explicit field-order override; the superseded aggregate pattern-write path is removed. Authored source regressions cover array/object defaults, bound invocation members, computed keys, for-of patterns, and RHS-before-write preservation. Both related PR branches receive the same structural fix. The evaluation index adds bounded per-AST-node bookkeeping; its performance costs have not been measured. Validation: inspected producing boundaries and affected consumers; targeted source formatting and git diff --check completed. Tests, typechecks, lint, builds, provider runs and CI reruns were not executed, per the user's explicit instruction. No directly related cleanup is deferred.

  1. thread 1

Root cause: the path-undefined bound-alias fallback reconstructed a member receiver after a sequence had erased it. That branch now checks the explicit receiver state before following the bound function. Receiverless bound .call/.apply remains opaque, with no invented known defineProperty write. Added focused normalization regressions for both bound members; the parallel invocation branch retains its existing detached-call semantics. Validation: inspected producing boundaries and affected consumers; targeted source formatting and git diff --check completed. Tests, typechecks, lint, builds, provider runs and CI reruns were not executed, per the user's explicit instruction. No directly related cleanup is deferred.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef8eb3ab19

ℹ️ 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".

@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e1253bede9

ℹ️ 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".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Fixed publicly in e1253be. The member-resolution fallback proved only that an explicit receiver existed, then discarded it and reconstructed callee.object as the callable. It now continues from the outer explicit receiver, preserving the same generic Function.prototype.call/apply semantics as the intrinsic-path branch. The bound owner is used only when no explicit receiver was supplied. Regressions cover detached call and apply with noop as the receiver and preserve valid Electron findings. Source inspection covered the producing boundary and affected consumers; prior live history is preserved and git diff --check passed. Tests, builds, lint, typechecks, provider workloads and CI reruns were not run at the explicit user request. No directly related source cleanup remains.

dakjdakd and others added 2 commits October 14, 2026 00:57
* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <[email protected]>
aznikline added a commit to aznikline/rea that referenced this pull request Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2bf3a74e8c

ℹ️ 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".

Comment on lines +600 to +603
if (capturedOwner !== undefined && capturedOwner.replaced !== true)
ownerPath = intrinsicInvocationMemberPath(capturedOwner.key);
}
if (ownerPath === undefined) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Propagate replaced state through nested member captures

Fresh evidence beyond the fixed direct invoke.call case is an extra stable alias: with change.call = {call: poison}; const invoke = change.call; const outer = invoke.call; outer(), the recursive lookup returns {replaced: true}, but this condition discards it and the next guard returns undefined. The collector therefore records neither the call nor an opaque intrinsic effect even though outer() runs poison; if poison mutates Object.create before a Rolldown conversion, the helper remains trusted and a spurious BrowserWindow finding can be emitted. Propagate the replaced result (or another opaque marker) instead.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in efd68b4. The recursive owner proof now propagates the replaced marker: when capturedInvocationMember(owner) returns {replaced: true}, the outer capture returns {replaced: true, path: capturedOwner.path} instead of falling through to undefined. outer = invoke.call; outer() — where invoke stored the {call: poison} replacement — now classifies outer() as opaque at [i,O,defineProperty,call] with an ["intrinsic"] effect retained, instead of recording nothing. Regression: "propagates replaced state through a nested captured owner" (fails on 2bf3a74 — invocation unresolved, no effect). 64/64 capture, 1764/1764 JS domain, check:fast green.

When a captured member's owner is itself a replaced captured member,
the recursive owner proof discarded the marker and returned undefined —
`outer = invoke.call; outer()` then recorded neither a known call nor
an opaque effect even though the stored replacement executes. Propagate
the replaced result so the call classifies opaque at the owner path.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
aznikline added a commit to aznikline/rea that referenced this pull request Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efd68b4a36

ℹ️ 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".

Comment on lines 403 to +404
if (!terminal && members.length !== 1) return undefined;
bindReads.push(captured?.capturedAt ?? current.callee);
bindReads.push(current.callee);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Carry captured invocation values through direct bind

When a captured invocation member is itself bound—for example const change = Object.defineProperty.bind(null, Object, "create"); const invoke = change.call; const changed = invoke.bind(change, null); changed({value: customCreate})—this direct-.bind branch keeps the raw invoke target, and resolveBoundIntrinsic later follows it to the member-expression initializer and returns undefined. At runtime this binds Function.prototype.call, so the final call reaches the bound defineProperty and replaces Object.create; because no intrinsic write is retained, the Rolldown helper can remain trusted and emit a spurious BrowserWindow finding. Fresh evidence beyond the fixed captured-.bind alias case is the inverse operation of binding a captured .call value; canonicalize that target before continuing.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c8048a1.

Reproduced on efd68b4: invoke.bind(change, null) reached resolveBoundIntrinsic, hit the !isCallExpression(current) early return, and produced no invocation at all — the subsequent Object.create write was dropped and a spurious BrowserWindow finding surfaced.

resolveBoundIntrinsic now consults capturedInvocationMember when a bind chain (gated on argumentGroups.length > 0, so bare aliases are untouched) bottoms out on a non-call value. An intact capture returns {kind:"known", path:[i,F,p,call], receiver, arguments} so the chain continues into the bound defineProperty; a replaced capture returns opaque with the captured slot path. Regression test carries a captured member value through a direct bind fails on the previous implementation and passes now (66/66 capture tests, 1766/1766 JS-domain tests).

owner = peelValueSequence(next.object);
at = next;
} else {
if (initializer.projection.length !== 1) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Follow multi-segment destructured member captures

When an invocation member is destructured through more than one static property—for example const {call: {call: invoke}} = change for a bound change—this guard drops the binding solely because its projection is ["call", "call"]. Both runtime reads yield Function.prototype.call, so invoke.call(change, null, {value: customCreate}) reaches the bound defineProperty and replaces Object.create; analysis instead retains no write and can trust a poisoned Rolldown helper, producing a spurious BrowserWindow finding. Fresh evidence beyond the fixed one-key destructuring case is this two-key static projection; walk it through captured-owner identity rather than rejecting it.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c8048a1.

Reproduced on efd68b4: const {call: {call: invoke}} = change was rejected by the projection.length !== 1 guard, so invoke.call(change, null, {value: customCreate}) lost its Object.create write.

Destructured captures now accept projections whose every segment is call/apply/bind — each read lands on a Function.prototype member whose own invocation members resolve to the same canonical members, so the final segment names the captured member. projectedCaptureAt walks nested object patterns level by level (matching the binding's own name for duplicate keys), and the destructuring-offset slot check covers every projection level: [ownerPath,call] and [i,F,p,call,call]-style nested slots. Regression test follows a multi-segment destructured member capture fails on the previous implementation and passes now (66/66, 1766/1766).

…ctions

A bound captured member carries the canonical member's value —
`changed = invoke.bind(change, …)` where `invoke = change.call` binds
Function.prototype.call itself. resolveBoundIntrinsic now consults
capturedInvocationMember when a bind chain reaches a non-call value,
returning the canonical member path with the accumulated receiver;
replaced captures stay opaque.

Destructured captures accept multi-segment invocation-member
projections — `{call: {call: invoke}}` reads Function.prototype.call
through Function.prototype.call. projectedCaptureAt walks nested
object patterns one level at a time and every projection level's slot
is checked for replacement at the destructuring offset.
aznikline added a commit to aznikline/rea that referenced this pull request Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8048a1ec2

ℹ️ 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".

Comment on lines +233 to +234
if (t.isAssignmentExpression(node) && isPattern(node.left))
return ["right", "left"];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Unwrap the whole pattern before applying evaluation order

Fresh evidence beyond the fixed wrapped-leaf case is a transparent wrapper around the entire LHS, such as ([change.call, ignored = change.call({value: customCreate})] as any) = [replacement, undefined]. Here isPattern(node.left) is false for the TSAsExpression, so the collector neither switches to RHS-before-pattern traversal nor registers per-leaf effects and instead retains both writes only when the whole assignment exits. If replacement is Object.defineProperty.bind(null, Object, "create"), runtime installs it before evaluating the later default and replaces Object.create, while analysis still classifies the default against the old change.call; a following Rolldown conversion remains trusted and can emit a spurious BrowserWindow finding. Unwrap the target in every pattern-ordering/leaf gate, not only nested AssignmentPattern.left.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 79af132.

Reproduced on 8fbb88e — added the exact case to the existing destructuring it.each: ([change.call, ignored = change.call(null,metadata,"x",{value:1})] as any) = [replacement, undefined] failed (windows emitted) before the fix and passes now.

Root cause: every pattern gate keyed on the raw node.left/target, so a TSAsExpression wrapper fell through both the RHS-before-pattern childKeys ordering and the per-leaf registration — leaf effects were retained only at the assignment's exit, making the RHS-installed replacement look later than the default's change.call write. All four isPattern gates now unwrap the target first: childKeys (assignment + AssignmentPattern.left, already unwrapped), the enter-time leaf registration, the for…of loop guard, and the exit-time retainTargets gate (rewritten to unwrap once and reuse the value).

// binding back to the owner's initializer and miss writes between
// them. Check the slot at the destructuring offset directly.
const scope = opaqueMutationPath(at).join(".");
const offset = evaluationOffset(at);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Track capture time separately for every projected property

Fresh evidence beyond the fixed one-level destructuring timestamp is a nested projection such as const {call: {missing: x = (change.call = noop), call: invoke}} = change: the outer change.call value is captured before the default overwrites that owner slot, so the later inner read still obtains Function.prototype.call. This code compares every projected slot against the single final-leaf offset, causing the intervening write to look as though it preceded the outer capture and making invoke.call(...) opaque. When change is a bound defineProperty targeting fresh metadata, runtime mutates only that metadata, but the opaque classification invalidates all intrinsics and suppresses a valid BrowserWindow finding; retain an evaluation point for each projection level.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed in 8fbb88e — this report was generated against c8048a1, before that commit landed.

The implementation now tracks one timing node per projection level (projectedCaptureAts): an intermediate level uses its property's key node, which exits before the value subtree runs defaults, so const {call: {missing: x = (change.call = noop), call: invoke}} = change checks the outer [ownerPath,call] slot at the outer read's offset — before the inner default's write. Two related bugs were fixed in the same commit: the intermediate canonical slot [i,F,p,proj[i-1]] is now checked at each level, and the resolver no longer re-checks [bound.path,method] on virtual-member iterations (the synthetic owner substitution is not a real slot read). The regression test times each projected level at its own property read is your exact example — it fails on c8048a1 and passes on 8fbb88e (69/69 capture, 1769/1769 JS-domain).

The captured-member bind fallback skipped the recorded `.bind` read
checks — `invoke.bind = replacement` could hide that `invoke.bind(…)`
produces the replacement, not bound Function.prototype.call. Run the
same bindReads check against the canonical member's bind slot before
returning the captured bound value.

Destructured multi-segment captures now check the inherited canonical
member slot at every level — `{call: {apply: invoke}}` verifies
[i,F,p,call] as well as [i,F,p,call,apply] and [i,F,p,apply] — and each
level is timed at its own property read (the property key exits before
the value subtree's defaults), so a write inside an inner default no
longer marks an earlier outer read replaced.

The resolver no longer re-checks the substituted owner's member slot on
virtual-member iterations: `invoke.call(…)` models the stored member
applied to the owner, it does not re-read `owner.call`, so a write
between capture and call is irrelevant.
aznikline added a commit to aznikline/rea that referenced this pull request Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8fbb88eb22

ℹ️ 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".

// captured member is itself provable — `outer = invoke.call` reads the
// member from the function `invoke` already stores.
let ownerPath = intrinsicPath(owner) ?? boundIntrinsic(owner)?.path;
if (ownerPath === undefined && depth < 4) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve uncertainty past the captured-owner depth cap

With six nested stable reads (a = change.call through f = e.call), this fixed depth cap stops before proving f, so f.call(change, null, descriptor) is classified as having no retained effect rather than known or opaque. At runtime every alias is Function.prototype.call, and the final call reaches the bound Object.defineProperty and can replace Object.create; before a Rolldown conversion, the missed write leaves the helper trusted and can emit a spurious BrowserWindow finding. Fresh evidence beyond the earlier one-level nested-owner case is this first chain beyond the hard cap; use the binding cycle guard without a fixed depth, or return opaque when the bound is exhausted.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 79af132.

Reproduced on 8fbb88e: the depth < 4 cap stopped the recursive owner proof at the fifth captured owner, so f.call(change, null, descriptor) in the six-alias chain resolved undefined — neither known nor opaque — and the Object.create write was dropped.

The fixed depth is gone: capturedInvocationMember now threads the same binding-visited set through recursion, so the chain a…f resolves fully while a cyclic owner chain (a = b.call; b = a.call) still terminates at the cycle guard. Regression test follows a captured-member owner chain without a depth cap fails on the previous implementation and passes now (71/71 capture, 1771/1771 JS-domain, check:fast + knip green).

…epth cap

A transparent wrapper around a whole destructuring LHS
(`([change.call, …] as any) = [replacement]`) defeated every
pattern-ordering gate — the collector retained leaf effects only at the
assignment's exit, so a RHS-installed replacement appeared to postdate
defaults it actually precedes. isPattern checks now unwrap the target
in the childKeys ordering, the per-leaf registration, the for-of loop
guard, and the exit-time retain gate.

Nested captured-owner resolution no longer stops at a fixed depth of
four — `f = e.call` on the sixth alias could not be proven and the
final call lost its effect entirely. The binding-visited set is now
shared across recursion, which also terminates cyclic owner chains.
aznikline added a commit to aznikline/rea that referenced this pull request Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79af1328f4

ℹ️ 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".

idOf(callee),
receiver === undefined ? -1 : idOf(receiver),
explicitReceiver ? 1 : 0,
arguments_ === undefined ? -1 : arguments_.length,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Distinguish equal-length arguments in cycle detection

When a captured apply alias re-enters with a different argument list of the same length, this key treats the states as identical. For example, const change = Object.defineProperty.bind(null, Object, "create"); const invoke = change.apply; invoke.apply(invoke, [invoke, [change, [null, [{value: customCreate}]]]]) reaches the virtual change.apply state first with receiver invoke and arguments beginning with invoke, then again with the same receiver and two arguments beginning with change; Node v24 ultimately replaces Object.create, but the second state is rejected and the collector records neither a known nor opaque effect, so a subsequent Rolldown helper remains trusted and can emit a spurious BrowserWindow finding. Fresh evidence beyond the earlier re-entry case is that the receiver and arity are unchanged while the argument identities differ, so include the argument identities in the cycle key (or keep the collision opaque).

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ac857c8 — the cycle key now includes argument node identities (arguments_.map(idOf).join(",")) instead of arity alone, so equal-length re-entries through different argument nodes can no longer collide.

One honest correction to the reported mechanism: I instrumented the resolver on your exact example — the re-entered change.apply states arrive with different receiver nodes (each apply expansion consumes a distinct argument node), so the arity-only key did not actually collide on this input and the write was already retained. Argument identities are in the key regardless per your direction; the regression re-enters a captured member with different argument identities pins the intended outcome (known Object.defineProperty + retained ["intrinsic","Object","create"]).

Comment on lines +640 to +643
projected.some(
(segment) =>
segment !== "call" && segment !== "apply" && segment !== "bind",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve container segments before member projections

A destructured capture is discarded whenever its projection contains a literal container segment, even when that segment is exactly recoverable. With const change = Object.defineProperty.bind(null, Object, "create"); const [{call: invoke}] = [change]; invoke.call(change, null, {value: customCreate}), the projection is [0, "call"], so this guard rejects it although Node v24 invokes the bound defineProperty and replaces Object.create; no intrinsic write is retained and a later Rolldown conversion can produce a spurious BrowserWindow finding. Fresh evidence beyond the earlier multi-member destructuring case is the leading literal array index rather than another invocation member; resolve exact array/object container projections before validating the remaining call/apply/bind path.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ac857c8 — leading literal container segments now resolve into the RHS before the member suffix is validated.

capturedInvocationMember descends containerElement for non-member segments ([{call: invoke}] = [change] reads element 0 of the array literal, then .call on it); every remaining projected segment must still be call/apply/bind, and interleaved members-then-containers are still rejected. projectedCaptureAts now descends ArrayPattern element positions so each member level keeps its own read-offset timing.

Regression resolves a member capture through a literal container segment failed on 79af132 and now passes (known Object.defineProperty + retained ["intrinsic","Object","create"]).

… projections

- Captured-member owner chains now descend on an explicit work stack so
  flat files with thousands of `aN = aN-1.call` aliases cannot exhaust
  the call stack; the shared binding-visited set still terminates
  cycles and per-level slot checks are preserved.
- Invocation cycle detection keys on argument node identities, not
  arity alone, so equal-length re-entries through apply chains cannot
  collide.
- Destructured captures resolve leading literal container segments
  into the RHS (`[{call: invoke}] = [change]`) before validating the
  invocation-member suffix; projectedCaptureAts descends ArrayPattern
  element positions for per-level timing.
aznikline added a commit to aznikline/rea that referenced this pull request Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac857c881c

ℹ️ 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".

Comment on lines +151 to 153
const virtual = virtualMember;
virtualMember = undefined;
let path = intrinsicPath(callee);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Process virtual members before accepting owner paths

When memberRead recovers an alias only through a literal-container projection and its owner already has an intrinsic path, these lines clear the virtual call/apply/bind marker before the direct-path branch can process it. For const [{call: invoke}] = [Object.defineProperty]; const metadata = {}; Reflect.apply(invoke, Object.defineProperty, [null, metadata, "x", {value: 1}]), runtime only defines metadata.x, but resolution returns Object.defineProperty with the leading null still in arguments; write collection consequently records an opaque intrinsic mutation and can invalidate a later Rolldown helper, hiding a valid BrowserWindow finding. Handle the virtual member before accepting intrinsicPath(callee).

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8da8ab2 — a pending virtual member is now consumed before intrinsicPath(callee) is accepted.

When a captured member substitutes an intrinsic owner (invoke = Object.defineProperty.call), virtual is processed first: call/apply shift receiver = arguments[0] and slice the argument list (via invocationArguments), then resolution continues so the owner's own intrinsicReadChanged check still runs; bind returns a Function.prototype.bind bound value with explicitReceiver target selection, matching the direct-member branch.

On your example the call now resolves as Object.defineProperty(metadata, "x", {value: 1}) — regression applies a captured virtual member before an owner intrinsic path fails on ac857c8 and now passes. This also covers the pre-existing direct-initializer form const invoke = Object.defineProperty.call, which hit the same path.

return element === null || element === undefined ? undefined : element;
}
if (t.isObjectExpression(node))
for (const property of node.properties)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Select the effective object-literal property

When a destructured capture crosses an inline object literal with duplicate static keys, this source-order loop returns the first property even though the last matching data property is the runtime value. With const {slot:{call:invoke}} = {slot: change, slot: {call: noop}} for a bound Object.defineProperty change, invoke.call(change, null, descriptor) invokes only noop, while the analysis resolves invoke from the shadowed first slot and records a nonexistent Object.create replacement; before a Rolldown helper capture, that false write suppresses a valid BrowserWindow finding. Select the last effective property rather than the first shadowed one.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8da8ab2 — same root cause as the adjacent comment; containerElement selects the effective last entry.

{slot: change, slot: {call: noop}} now resolves invoke from the second slot value ({call: noop} — an unprovable owner), so the capture is rejected and no Object.create write is fabricated. A later spread or method definition likewise resets the effective value to unknown; an earlier spread before the last matching literal is correctly overridden and still resolves.

Covered by reads the effective last value for duplicate literal keys (fails on ac857c8, passes now) plus the spread-order case.

…bers

- containerElement selects the effective last literal slot: duplicate
  keys, trailing spreads, and unmodelable method values now hide the
  owner instead of returning the shadowed first match; array spreads
  at or before the target index also bail.
- A pending virtual call/apply/bind member is consumed before the
  callee's intrinsic path is accepted, so [{call: invoke}] =
  [Object.defineProperty] invokes ODP with a shifted receiver and
  sliced arguments instead of returning ODP with the raw list.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

aznikline added a commit to aznikline/rea that referenced this pull request Oct 17, 2026
…ic owner

When a pending virtual call/apply member sits on an intrinsic owner,
the explicit receiver is the callable - Reflect.apply(invoke, noop,
args) invokes noop, never Object.defineProperty. Only the no-explicit-
receiver path keeps the owner as the callable.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I read the 18 new commits on 3e18226 and ran nothing. My earlier results are for f3765f1 and do not carry over, because the code and tests changed a lot. GitHub's CI is red on this head, and the PR now conflicts with main.

My earlier result, on f3765f1 Now, on 3e18226 What I read
The PR's 5 test files pass on Node 24 and 26 (271 tests) needs a run The 18 new commits change 7 files: 1,520 lines added, 115 removed. Most changed lines are in electronIntrinsicCapture.test.ts (701), javascriptModuleInterop.ts (448) and javascriptIntrinsicInvocation.ts (352). GitHub's CI log shows the same 5 files passing, but on a merge with a 17 Oct main, so its counts (310 tests together) do not compare with my 271.
Main did not hold the PR's changes still true for the new test and the new code The PR's new test file is still not on main. The function capturedInvocationMember, which the PR adds, matches nothing in src on main.
On main, 23 of the PR's tests fail and 14 of 19 small Electron files get the wrong answer needs a run 83 main commits have changed the PR's overlapping files since the PR's base. Those main numbers are old.
On the PR head, 19 of 19 small files right needs a run The 18 new commits change the code those files exercise. I did not re-run them.
No conflict with main b7dcf78 conflicts now See the next paragraph.

Conflict with main. GitHub says this PR conflicts with main aba487e. 10 of the PR's 13 files changed on main since the PR's base 4135c91. A text merge of those 10 files gives 9 conflicts: 3 each in javascriptElectronMemberWrites.ts, javascriptIntrinsicInvocation.ts and javascriptModuleInterop.ts. The other 7 merge clean. This is a text check, not a build.

CI. CI required and Portable tests failed on 3e18226. Test shard (3/5) has one failing test, joins whole provider resolution before shutdown and gates the next admission in ghidraProfileArtifactOwnership.test.ts. This PR does not change that file. Test shard (5/5) was cancelled, so it has no result. The PR body says both lanes passed on f3765f1 and newer heads were pending. The run merged this head into a main from 17 Oct.

Bot threads. 7 Codex threads are unresolved and not outdated. The author has replied to each, saying the fix is in a named commit or is unchanged. Nobody has resolved them. The PR has 57 threads in all.

Still not run

  • Nothing was built or run this time. This is a read of the diffs and of GitHub's check list.
  • The 5 test files, the 19 small Electron files and the main comparison, all on 3e18226.
  • The PR body's ASAR example. The body I read today has no ASAR text, so I cannot say what it was.
  • Real Electron apps. Node 22, Windows and macOS.
  • The full check suite and the CI lanes that were skipped.
  • Speed cost. The body reports no timing, and I did not measure it.
  • This head merged onto today's main. The text merge above is the only check.

Thanks, Mason, for the 18 follow-up commits and for the replies on the bot threads.

What I read
  • The 18 commits are listed by git log f3765f117..3e18226dc. None is a merge. The first and the last are these:

    Commit Subject
    1a866d4 (first) alias writes to captured invocation members
    3e18226 (last) explicit receiver over a captured intrinsic owner
  • Test counts in GitHub's job logs for this head, on a merge with main cc2e18a: electronIntrinsicCapture.test.ts 78, electronModuleInterop.test.ts 202, electronModuleInteropCli.test.ts 2, fridaLifecycleMcp.test.ts 26, toolInputAdmission.test.ts 2. All passed. javascriptSemanticAmbientWrites.test.ts (10) passed too. The 78 matches the PR body's "78/78".

  • Since f3765f1 the PR also touches javascriptSemanticAmbientWrites.test.ts and javascriptSemanticMutationInitializers.ts. It now changes 13 files, 36 commits, 2,403 lines added and 150 removed.

  • The 3 files with conflicts changed on main in only 3 commits since the PR's base.

Test setup

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for this fix! The intrinsic invocation read identity changes were already integrated into main in commit 04672f2b917d7ae3d71424a6abbcc2da0f24fa0b (fix(javascript): preserve builtin identity and share alias traversal), which explicitly includes #2465 along with src/domain/javascript/javascriptIntrinsicInvocation.ts and src/domain/javascript/javascriptIntrinsicInvocation.test.ts. Closing this PR as already landed.

@morluto morluto closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants