Skip to content

fix(octane): keep a signal-capable only-child text hole's last primitive - #1643

Merged
trueadm merged 1 commit into
mainfrom
fix/only-child-text-token
Oct 3, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/only-child-text-token

Conversation

@trueadm

@trueadm trueadm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The weekly root-transactions guard equal_reads (target text-compiled, reference text-compiled-work, maxRatio 0) breaches on main. Compiled text bindings make 128 live nodeValue reads across 128 unchanged updates, and the guard allows none. The breach went unnoticed because benchmarks/root-transactions/contracts.mjs crashed from 2026-09-15 until the weekly triage re-anchored it.

Cause. git bisect run over contracts.mjs <checkout> --reads-only, starting from the guard's origin 3c1cc55 (#1079, where it measured 0), names 5ead1ff (#1069, async signals and streaming SSR).

The same path also changed behaviour. An unchanged value overwrote an outside edit to the text. React leaves the DOM alone when the props are equal, and so did Octane before #1069.

Changes

bindSignalChild's only-child path now keeps the last written primitive as its token, as #1591 does for marker-bounded holes.

  • Unchanged primitive. Returns before any DOM read. dangerouslySetInnerHTMLOwnsChild still runs first, so raw HTML and children stay mutually exclusive.
  • Changed primitive, or a switch to a signal handle. The token's Text node is the host's first child, so it is recovered from there and rewritten in place.
  • When a primitive becomes the token. Only when that first-child position is proven:
    • by the previous token;
    • by a client mount's empty template (no DOM read);
    • otherwise by one firstChild comparison, because hydration can keep unclaimed server content ahead of the Text node it appends. Main updates that node correctly in this case; an earlier draft of this fix did not, and the new mismatch tests pin it.
    • A staged ViewTransition render keeps the Text token.

Cost per update:

Update main this PR before #1069
unchanged 1 nodeValue read 0 0
changed 1 nodeValue read + write 1 firstChild read + write write

A mount costs no extra DOM read. Hydration costs one firstChild comparison per hole.

Validation

  • node benchmarks/root-transactions/contracts.mjs, with the weekly triage's re-anchored harness applied locally (uncommitted; it is not part of this PR):
    • main: App 128/128;
    • this PR: App changed 128 / equal 0, DescriptorApp 128/128 (its guard allows 1×);
    • every rollback contract still holds, and the script exits 0.
  • New tests in packages/octane/tests/hydration/direct-signal-bindings.test.ts:
    • Unchanged value leaves the DOM alone. An outside edit survives an unchanged value; a changed value rewrites the same Text node with a single characterData mutation. The test also walks true, an element, a signal handle and back, checking a single child at every step. It fails on main (expected '1' to be 'edited').
    • Hydrated hole keeps its server Text node across equal, changed and number values.
    • Hydration mismatch (three variants). After hydrating over <b>x</b>, a comment, and <b>x</b>tail, updates write the appended client Text node and keep the server nodes. All three fail with a hydration-blind publication guard.
    • Raw HTML still throws beside an unchanged child. It fails if the fast path skips dangerouslySetInnerHTMLOwnsChild.
    • Recovering the Text node from null instead of firstChild fails two of the new tests.
  • vitest --project octane: direct-signal-bindings, mismatch-sibling-hole and mismatch-structural pass (552 tests). The new tests also pass in --project octane-prod.
  • pnpm typecheck:files and pnpm format:files:check on the changed files.
  • CI byte budgets (run-minimal.mjs --budgets root-static-local root-chained-jsx hooks-state prop-attributes context) pass, and the signal-free fixtures are byte-identical. In an esbuild bundle that reaches bindSignalChild (bindSignalChild plus createRoot), the change costs +194 raw / +29 gzip / +3 brotli.
  • The PR bench (run 37107779544) agrees with the size estimate.
    • Every bundle that reaches bindSignalChild grows by +194–196 raw, +45–76 gzip, and −34 to +86 brotli: root-static, the octane-jsx app, and the Base UI, Radix and Apollo binding bundles.
    • That is the fast path, the Text-node lookup and the publication check. Inspecting the minified output found nothing further to trim without dropping a guard.
    • All 20 timed js-framework operations are within noise.
    • The 37 other application values and 84 other reachability values are unchanged.
  • Not run locally: the full pnpm test, pnpm typecheck and pnpm format:check, which are left to CI.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches core bindSignalChild DOM update paths for a common JSX pattern, including hydration edge cases, though behavior is narrowed and heavily regression-tested.

Overview
Signal-capable only-child text holes (e.g. <p>{props.value}</p> via bindSignalChild) no longer use the Text node as their binding token. They now keep the last written primitive, matching marker-bounded compiled text holes.

Unchanged primitives return early after a raw-value check (still running dangerouslySetInnerHTMLOwnsChild), so there is no nodeValue read on equal updates and outside DOM edits are not clobbered. Changed values still rewrite the same Text node, with token adoption rules for client mount, hydration when server nodes sit ahead of the adopted text, and staged ViewTransition renders.

Adds hydration/direct-signal tests for unchanged-value no-ops, server Text node identity, mismatch append cases, and raw HTML rejection beside an unchanged child.

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

Since #1069 a `{props.value}` hole that is its host's only child compiles to
bindSignalChild, because the value can carry a signal handle. The binding kept
the Text node as its token, so every render went through updateTextValue,
which reads nodeValue to compare. 128 unchanged updates now made 128 live
nodeValue reads where the compiled childTextHoleUpdate path made none. An
unchanged value also overwrote an outside edit to the text.

The only-child path now keeps the last written primitive as its token, like
#1591 did for marker-bounded holes. An unchanged primitive returns before any
DOM read; raw HTML still claims the host first. The token's Text node is the
host's first child. A changed primitive or a switch to a signal handle
recovers it from there. A primitive becomes the token only where that
position is proven:
- by the previous token;
- by a client mount's empty template;
- otherwise by one comparison, because hydration can keep unclaimed server
  content ahead of the node it adopted.
A staged ViewTransition render keeps the Text token.

Restores root-transactions equal_reads text-compiled to 0 (guard maxRatio 0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 3, 2026
@trueadm
trueadm marked this pull request as ready for review October 3, 2026 07:52
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 8 value(s) increased
  • 🔴 bundle-reachability: 19 value(s) increased

Compares 11a9da935 with f6ba5d95c on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 3.49 3.45 −1.1% ±6% ⚪ within noise
octane-tsrx replace 6.75 6.64 −1.6% ±9% ⚪ within noise
octane-tsrx add 3.49 3.48 −0.3% ±7% ⚪ within noise
octane-tsrx update 0.34 0.37 +8.8% ±44% ⚪ within noise
octane-tsrx select 0.12 0.15 +25.0% ±123% ⚪ within noise
octane-tsrx swap 0.31 0.36 +16.1% ±48% ⚪ within noise
octane-tsrx remove 0.29 0.27 −6.9% ±47% ⚪ within noise
octane-tsrx runlots 32.05 33.45 +4.4% ±22% ⚪ within noise
octane-tsrx select_lots 0.21 0.17 −19.0% ±49% ⚪ within noise
octane-tsrx clear 33.14 33.20 +0.2% ±14% ⚪ within noise
octane-jsx run 3.76 3.71 −1.3% ±7% ⚪ within noise
octane-jsx replace 7.08 6.72 −5.1% ±10% ⚪ within noise
octane-jsx add 3.27 3.31 +1.2% ±7% ⚪ within noise
octane-jsx update 0.53 0.53 −0.0% ±49% ⚪ within noise
octane-jsx select 0.32 0.34 +6.3% ±34% ⚪ within noise
octane-jsx swap 0.59 0.64 +8.5% ±22% ⚪ within noise
octane-jsx remove 0.45 0.50 +11.1% ±28% ⚪ within noise
octane-jsx runlots 29.45 30.40 +3.2% ±9% ⚪ within noise
octane-jsx select_lots 2.50 2.28 −8.8% ±36% ⚪ within noise
octane-jsx clear 33.45 33.01 −1.3% ±24% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-jsx js_raw 226,680 226,876 +196 (+0.1%) 🔴
octane-jsx js_gzip 72,367 72,419 +52 (+0.1%) 🔴
octane-jsx js_brotli 62,726 62,741 +15 (+0.0%) 🔴
octane-jsx app_gzip 2,935 2,936 +1 (+0.0%) 🔴
octane-jsx app_brotli 2,497 2,503 +6 (+0.2%) 🔴
octane-jsx fw_raw 218,221 218,417 +196 (+0.1%) 🔴
octane-jsx fw_gzip 69,432 69,483 +51 (+0.1%) 🔴
octane-jsx fw_brotli 60,229 60,238 +9 (+0.0%) 🔴

37 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
root-static raw 203,008 203,204 +196 (+0.1%) 🔴
root-static gzip 64,558 64,621 +63 (+0.1%) 🔴
root-static brotli 55,969 56,012 +43 (+0.1%) 🔴
binding-base-ui-vite raw 213,239 213,435 +196 (+0.1%) 🔴
binding-base-ui-vite gzip 68,137 68,210 +73 (+0.1%) 🔴
binding-base-ui-vite brotli 59,057 59,119 +62 (+0.1%) 🔴
binding-base-ui-esbuild raw 211,196 211,390 +194 (+0.1%) 🔴
binding-base-ui-esbuild gzip 68,119 68,181 +62 (+0.1%) 🔴
binding-base-ui-esbuild brotli 59,070 59,074 +4 (+0.0%) 🔴
binding-radix-vite raw 215,169 215,365 +196 (+0.1%) 🔴
binding-radix-vite gzip 68,709 68,778 +69 (+0.1%) 🔴
binding-radix-vite brotli 59,589 59,668 +79 (+0.1%) 🔴
binding-radix-esbuild raw 213,086 213,280 +194 (+0.1%) 🔴
binding-radix-esbuild gzip 68,708 68,753 +45 (+0.1%) 🔴
binding-radix-esbuild brotli 59,547 59,633 +86 (+0.1%) 🔴
binding-apollo-client-vite raw 358,254 358,450 +196 (+0.1%) 🔴
binding-apollo-client-vite gzip 112,253 112,322 +69 (+0.1%) 🔴
binding-apollo-client-vite brotli 97,970 97,936 −34 (−0.0%) 🟢
binding-apollo-client-esbuild raw 361,203 361,397 +194 (+0.1%) 🔴
binding-apollo-client-esbuild gzip 114,460 114,536 +76 (+0.1%) 🔴
binding-apollo-client-esbuild brotli 99,732 99,698 −34 (−0.0%) 🟢

84 other measured values are unchanged.

trueadm added a commit that referenced this pull request Oct 3, 2026
The waived guards now have owner PRs: ssr-final-replay try_closures (#1644),
root-transactions equal_reads (#1643) and codegen-size gzip compiled/source
(#1645). #1645 rebaselines the same codegen-size entry, so this branch no
longer edits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit ed188d7 into main Oct 3, 2026
55 checks passed
@trueadm
trueadm deleted the fix/only-child-text-token branch October 3, 2026 10:21
trueadm added a commit that referenced this pull request Oct 3, 2026
…nd re-judge them (#1646)

* ci(bench): triage the weekly ratio-guard breaches so new ones show

The weekly Bench job (`bench.mjs --quick --ratios`) was red with 81 ratio
breaches, 4 suites that wrote no numbers and 4 harness gate failures, so a new
breach was invisible. Every item is now a fix or a rebaseline.

- Harness drift, fixed. Each harness had stopped producing numbers when runtime
  source it anchors on changed:
  - ssr-final-replay: a second suspended loop since 2026-09-29.
  - root-transactions/contracts: staged-DOM text and attribute journaling since
    2026-09-15.
  - signal-dom-bindings: a second native style Block allocation site since
    2026-09-23.
  - codegen-size: the server runtime's lazy streamed-signals chunk since
    2026-09-16.
  - recursive-context: counted a pure-call annotation and trailing newlines as
    output growth.
- Rebaselined, with numbers in each note: five cross-framework bundle-size
  ratios and the workerd script-size ratio. The absolute app and server-render
  budgets are now the ratchet. Lynx's no-worklet byte caps from 2026-08-17 are
  reset to measured + 32, with the background program pinned exactly.
- Fix pending, with dated waivers that expire 2026-10-24, each with an owner
  task:
  - three exact counters the revived harnesses exposed (one extra closure per
    ssrTry, 128 live text reads per 128 unchanged compiled updates, compiled
    output at 1.295x its source);
  - Lynx create ratios and the re-entrant transport gate;
  - superlinear hydrate boundary preparation;
  - Octane Three versus R3F size and frame dispatch;
  - two timing regressions near the timer floor;
  - ten quick-mode timing guards whose samples are noise-bound;
  - the scoped descriptor shape change.
- bench.mjs supports a guard `waiver` ({ reason, expires }). A waived breach
  prints and does not fail, and fails again once the date passes.
  HARNESS_FAILURE_ALLOWLIST now also covers a suite whose harness writes no
  numbers.

The budget breaches (57) clear when the budget reset lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): pair and lengthen the timing samples behind waived ratio guards

Twelve timing guards breached in weekly quick runs without a verdict. Their
samples sat near Chromium's 100 µs clock or under two-sample noise, and each
target ran its whole block minutes after the other side of its guard.

- benchmarks/lib/paired.mjs: rotating per-round visit order and a ~20 ms
  sample calibration shared by the harnesses below.
- js-framework-reorder, memo-wall, svg-dashboard, spa-navigation: every
  target's page stays open in one browser and each sample round visits all
  targets; short ops repeat until a sample takes about 20 ms (clicks,
  hook invocations, op batches, and summed navigation legs).
- activity caught-reveal: a sample reveals several independent hidden roots
  in one window, with the small case revealing eight times as many roots so
  both cases do equal work; the cases alternate per round.
- ssr-workerd: an untimed priming spawn per target, then paired cold-spawn
  rounds; quick mode runs six rounds instead of two.
- bench.yml: a `suites` dispatch input to run selected suites.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): collect garbage before every timed spa-navigation leg

The untimed return leg mounts a whole route, and its collection landed
inside the next timed teardown: nav_teardown samples ran at 17-45% rme.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): re-judge the twelve waived timing guards with paired samples

Two quick CI runs of the paired, ~20 ms harness and same-runner A/B runs
against the commits that set each guard decided every waiver:

- Passing, waiver removed: activity reports, ssr-workerd
  cold_spawn_to_first_byte, svg-dashboard pan_zoom, memo-wall
  parent_rerender_equal_A and octane-jsx mount, spa-navigation
  nav_teardown and nav_mount (no Octane change since #674 on one runner).
- Rebaselined: svg-dashboard icon_swap 1.2 -> 1.6, because #983's esbuild
  minification made React 15% faster while Octane stayed flat.
- Confirmed Octane regressions, waiver kept and pointed at the fix:
  js-framework-reorder rotateb (1.41x per click since #639), memo-wall
  one_change_B (1.5x) and ctx_through_wall_B (1.44x), and svg-dashboard
  tooltip_swarm (1.31x since #635).
- The rotateb note claimed React moves every survivor; it moves one. A new
  rotatef guard covers the LIS-vs-lastPlacedIndex differentiator (0.043x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): rebaseline spa-navigation nav_mount to its CI baseline

The 1.2 ceiling came from a local 0.94x reading. On CI runners #674 itself
measures 1.15x and head 1.09-1.16x, so the ceiling left 3% of quick-mode
headroom; 1.35 keeps a margin while still catching per-node mount growth.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): drop the three weekly waivers that now have fix PRs

The waived guards now have owner PRs: ssr-final-replay try_closures (#1644),
root-transactions equal_reads (#1643) and codegen-size gzip compiled/source
(#1645). #1645 rebaselines the same codegen-size entry, so this branch no
longer edits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave lynx-render to its owner fix

The lynx-render transport gate failure and the create_1k/create_10k ratio
breaches both trace to #885's JSON-encoded transport and now have an owner
fix. Its branch re-notes those two guards, so this branch drops their waivers
and the suite's allowlist entry instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): keep harness failures unwaivable and leave descriptor shapes to their owner

Waiving a suite that throws before it writes numbers would hide any crash in
that suite, not only the known shape change, and skip all of its guards. The
scoped-descriptor-shapes defect has an owner fix in progress. That fix re-pins
the harness's expected keys, so narrowing the waiver here would edit the same
assertion. HARNESS_FAILURE_ALLOWLIST is empty again, and a thrown suite failure
always fails the job. Dated waivers remain only on individual ratio guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave the Three guards to their owner fixes

three-renderer frame_1k_subscribers and the two three-bundle-size ratios have
owner PRs (#1651, #1652) that re-note and ratchet those entries, so this branch
drops their waivers instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): point the four kept timing waivers at their attributed fixes

rotateb and ctx_through_wall_B clear with #1655 and #1656; one_change_B's
per-row remainder and tooltip_swarm's scoped-descriptor accessor reads each
have their own fix task.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(benchmarks): point parent_rerender_equal_A's note at its per-commit journal fix

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
…1641)

* ci(bench): triage the weekly ratio-guard breaches so new ones show

The weekly Bench job (`bench.mjs --quick --ratios`) was red with 81 ratio
breaches, 4 suites that wrote no numbers and 4 harness gate failures, so a new
breach was invisible. Every item is now a fix or a rebaseline.

- Harness drift, fixed. Each harness had stopped producing numbers when runtime
  source it anchors on changed:
  - ssr-final-replay: a second suspended loop since 2026-09-29.
  - root-transactions/contracts: staged-DOM text and attribute journaling since
    2026-09-15.
  - signal-dom-bindings: a second native style Block allocation site since
    2026-09-23.
  - codegen-size: the server runtime's lazy streamed-signals chunk since
    2026-09-16.
  - recursive-context: counted a pure-call annotation and trailing newlines as
    output growth.
- Rebaselined, with numbers in each note: five cross-framework bundle-size
  ratios and the workerd script-size ratio. The absolute app and server-render
  budgets are now the ratchet. Lynx's no-worklet byte caps from 2026-08-17 are
  reset to measured + 32, with the background program pinned exactly.
- Fix pending, with dated waivers that expire 2026-10-24, each with an owner
  task:
  - three exact counters the revived harnesses exposed (one extra closure per
    ssrTry, 128 live text reads per 128 unchanged compiled updates, compiled
    output at 1.295x its source);
  - Lynx create ratios and the re-entrant transport gate;
  - superlinear hydrate boundary preparation;
  - Octane Three versus R3F size and frame dispatch;
  - two timing regressions near the timer floor;
  - ten quick-mode timing guards whose samples are noise-bound;
  - the scoped descriptor shape change.
- bench.mjs supports a guard `waiver` ({ reason, expires }). A waived breach
  prints and does not fail, and fails again once the date passes.
  HARNESS_FAILURE_ALLOWLIST now also covers a suite whose harness writes no
  numbers.

The budget breaches (57) clear when the budget reset lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): drop the three weekly waivers that now have fix PRs

The waived guards now have owner PRs: ssr-final-replay try_closures (#1644),
root-transactions equal_reads (#1643) and codegen-size gzip compiled/source
(#1645). #1645 rebaselines the same codegen-size entry, so this branch no
longer edits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave lynx-render to its owner fix

The lynx-render transport gate failure and the create_1k/create_10k ratio
breaches both trace to #885's JSON-encoded transport and now have an owner
fix. Its branch re-notes those two guards, so this branch drops their waivers
and the suite's allowlist entry instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): keep harness failures unwaivable and leave descriptor shapes to their owner

Waiving a suite that throws before it writes numbers would hide any crash in
that suite, not only the known shape change, and skip all of its guards. The
scoped-descriptor-shapes defect has an owner fix in progress. That fix re-pins
the harness's expected keys, so narrowing the waiver here would edit the same
assertion. HARNESS_FAILURE_ALLOWLIST is empty again, and a thrown suite failure
always fails the job. Dated waivers remain only on individual ratio guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci(bench): leave the Three guards to their owner fixes

three-renderer frame_1k_subscribers and the two three-bundle-size ratios have
owner PRs (#1651, #1652) that re-note and ratchet those entries, so this branch
drops their waivers instead of editing the same entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant