Skip to content

fix(compiler): preserve map observations for source-visible proxies - #3051

Merged
domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:fix/compiler-map-receiver-proof
Nov 18, 2026
Merged

domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:fix/compiler-map-receiver-proof

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The compiler's keyed map eligibility check adds observable prototype and descriptor traps when the receiver is a Proxy. Keep an explicit new Proxy(...) receiver, or a local const bound to that construction, on the authored map callback path in both client and SSR. Reuse lexical scope analysis so a shadowed constructor continues to follow the ordinary list path.

Refs #2567. Proxies received through props, state, imports, or other external values remain unresolved. Browser JavaScript cannot distinguish them from ordinary arrays without observable operations, and sending all dynamic receivers through the authored callback conflicts with existing mount/coercion ordering and materially regresses mapped-list performance. A block-bodied JSX callback remains an escape for those receivers.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • Targeted compiler, list, and diagnostics suites: 413 tests passed, including client/SSR native trap comparisons and a shadowed-constructor binding/coercion control.
  • Scoped Prettier, git diff --check, pnpm sync.
  • Public compiler comparison against the base: ordinary dynamic list output is byte-for-byte identical (2,452 bytes; SHA-256 prefix 5e0c376602c4). Explicit Proxy output changes from 2,566 to 1,094 bytes and uses the authored callback path.
  • Current-head CI: all 31 checks passed on bc5031f1f, including the benchmark report.

Perf review: #3051 (a632714..bc5031f)

Scan: git diff d69609368..HEAD -- packages/octane/src/compiler/compile.js | node scripts/perf-review-scan.mjs --diff - --json packages/octane/src/compiler/ → 0 candidates. The change runs during compilation, caches the source-token check, and builds the lexical Proxy binding index at most once for a module containing Proxy. Ordinary dynamic-list code generation, runtime imports, per-row work, DOM insertion, shapes, and scheduling remain unchanged. Source-visible Proxy lists deliberately allocate authored callback descriptors for correctness; no performance claim is made for that exceptional path.

Severity Location Dimension Finding Required evidence Provided?
none compiler map lowering compiler output and runtime work No remaining must-fix finding for this narrowed scope. Identical ordinary-list output, focused behavior tests, current-head CI Output and local tests passed; CI passed; benchmark reports no byte growth, added work or paired timing change beyond ±3%.
  • concise-code: compiler source +51/−0, client runtime +0/−0, regression tests +79/−0, one patch changeset; no new runtime modules, exports, fields, or public API. The source proof extends the existing lowering owner and reuses lexical analysis.

Risk / follow-ups

Live main currently contains a known codemod regression from the stale-head merge of #3052. Base integration is held for repair #3066; CI on this PR's current head does not validate that broken-main combination.

This is a partial fix and does not close #2567. Source classification assumes the realm's unshadowed global Proxy is the standard intrinsic; replacing that global remains outside this proof. The unknown external-receiver tradeoff needs an explicit framework semantics decision rather than a reflective Proxy heuristic.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · Host com-79386


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Touches JSX list lowering in the compiler with nuanced Proxy/source classification; behavior change is scoped to explicit Proxy receivers but could affect compiled output size and map semantics for those cases.

Overview
The compiler now skips keyed JSX .map → @for fusion when the list receiver is a source-visible Proxy—either new Proxy(...) in place or a local const bound to that construction—so eligibility checks don’t run reflective guards that would observe Proxy traps before native .map.

Classification reuses module lexical analysis (isProxyConstruction / isSourceProxyMapReceiver): only the realm’s global Proxy counts; shadowed constructors and unrelated values keep the ordinary fused list path.

Tests compare client/SSR Probe vs Control trap sequences for inline and aliased Proxy receivers, plus a control that ordinary list fusion still runs with a shadowed Proxy and sparse arrays. Patch changeset for Octane.

Reviewed by Cursor Bugbot for commit bc5031f. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Nov 18, 2026
@trueadm
trueadm marked this pull request as ready for review November 18, 2026 20:53
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares a63271401, the merge commit's first parent with fbccfeb4e on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.008 2.967 ±0.0% −10.8% … +5.8% ⚪ within noise
octane-tsrx replace 5.775 5.925 +0.9% −5.9% … +7.3% ⚪ within noise
octane-tsrx add 2.267 2.275 −0.0% −4.4% … +2.2% ⚪ within noise
octane-tsrx update 0.094 0.093 −0.9% −3.4% … +1.6% ⚪ within noise
octane-tsrx select 0.006 0.006 +1.6% −3.0% … +12.3% ⚪ within noise
octane-tsrx swap 0.021 0.022 −0.2% −4.1% … +6.7% ⚪ within noise
octane-tsrx remove 0.019 0.018 −0.1% −3.9% … +12.7% ⚪ within noise
octane-tsrx runlots 27.892 28.283 −5.4% −10.0% … +0.0% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 −1.2% −8.3% … +3.8% ⚪ within noise
octane-tsrx clear 53.242 54.483 +2.4% −3.7% … +6.0% ⚪ within noise
octane-jsx run 3.875 4.025 −0.0% −5.3% … +4.9% ⚪ within noise
octane-jsx replace 8.208 8.208 +4.1% −3.5% … +13.2% ⚪ within noise
octane-jsx add 3.600 3.525 ±0.0% −6.3% … +4.9% ⚪ within noise
octane-jsx update 0.177 0.172 −3.0% −4.7% … +1.5% ⚪ within noise
octane-jsx select 0.100 0.097 −2.9% −10.3% … +3.1% ⚪ within noise
octane-jsx swap 0.159 0.158 +3.8% −11.0% … +7.9% ⚪ within noise
octane-jsx remove 0.135 0.143 −0.3% −3.9% … +11.4% ⚪ within noise
octane-jsx runlots 32.025 31.425 +6.6% −0.3% … +12.0% ⚪ within noise
octane-jsx select_lots 0.979 0.976 +5.2% +2.2% … +9.6% ⚪ within noise
octane-jsx clear 49.017 48.867 −1.4% −3.4% … +2.9% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 111 measured values.

Public-import reachability bundles (bytes)

No changes across 141 measured values.

@domgan-oai domgan-oai changed the title fix(compiler): preserve authored map receiver observations fix(compiler): preserve map observations for source-visible proxies Nov 18, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 0826d7b. Configure here.

Comment thread packages/octane/src/compiler/compile.js Resolved
@domgan-oai
domgan-oai merged commit 857b26e into octanejs:main Nov 18, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler JSX map eligibility invokes Proxy traps that native map never uses

1 participant