Skip to content

feat(compiler): close Strong render determinism gaps - #1489

Merged
trueadm merged 8 commits into
mainfrom
claude/dreamy-wiles-d5c5da
Oct 1, 2026
Merged

trueadm merged 8 commits into
mainfrom
claude/dreamy-wiles-d5c5da

Conversation

@trueadm

@trueadm trueadm commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes three gaps in Strong mode's render determinism checks (issue #1027). Each pattern below used to compile in Strong mode and now fails as an error. Compatibility mode is unchanged.

  • Array-method callbacks run as render. Callbacks passed to map, filter, forEach, reduce, reduceRight, flatMap, some, every, find, findIndex, findLast, findLastIndex, sort, toSorted, and the mapping function of Array.from were treated as deferred. Every render rule now applies inside them, for example items.map(i => <li key={Math.random()}>…) and items.forEach(setSelected).

  • crypto.randomUUID() and crypto.getRandomValues() join OCTANE_STRONG_RENDER_IMPURE_CALL, with a message that names useId(). Any impure call that computes a key= or an @for key gets a message that names a stable item ID instead.

  • New OCTANE_STRONG_RENDER_LOCALE_FORMAT covers:

    • toLocaleString, toLocaleDateString, and toLocaleTimeString without both a locale and a visible timeZone;
    • toString and toTimeString on a provable Date;
    • an Intl service constructed without a locale (DateTimeFormat also needs a timeZone);
    • a module-level formatter built that way and used during render.

    It reports only when the receiver is provably a Date built with new Date(...), or the constructor is an unshadowed Intl.*.

Why

A probe on main @ 85cb387 found that .map callbacks were not checked as render, that crypto calls were missing from the impure-call list, and that locale-dependent formatting compiled cleanly. Locale-dependent formatting is a hydration mismatch in any SSR app.

Changes

  • packages/octane/src/compiler/strong-render-policy.js: new module containing all of this analysis.
  • strong-mode.js gains only hook points (about 45 lines), to keep merge conflicts small with the parallel Strong sessions that also edit it.
  • New packages/octane/tests/compiler/strong-render-determinism.test.ts. It covers aliases, shadowed globals, optional chains, computed members, .tsrx (including @for rows and @for key headers), plain .ts custom hooks, Volar parity, every compile mode, and pinned unchanged output.
  • strong-mode.test.ts had a test from fix: memoize snapshot method calls in Strong mode #862 that pinned crypto.randomUUID() in render as legal. It now pins the new error, plus legal non-random crypto use.
  • Docs: a "Render determinism" table in docs/strong-compiler-checks.md, plus tsrx-basics.md, differences-from-react.md, llms.txt, and build-tools.mdx. Changeset added.

Deliberately not reported, because the bug can't be proven:

  • local getters such as getHours(), and toDateString(): both are time-zone independent on dates built from local parts;
  • a Date passed as a prop;
  • options objects the compiler cannot see.

Validation

  • pnpm format:files:check on the diff
  • pnpm typecheck (full run passed on the combined local work), plus pnpm typecheck:files on this diff
  • pnpm test: a full local run with a 12 GB heap passed 82,876 tests with 2 failures. Both pass in isolation: one is a load-sensitive browser timeout, the other a pristine upstream Base UI test. The machine was running other sessions at load average ~40, and with the default heap the root Vitest process ran out of memory. CI is the authority here.
  • Targeted: all strong-* compiler suites plus volar.test.ts, 1,262 tests passing.
  • Breaking each rule on purpose (array callbacks, crypto, key message, locale, time zone, module formatter, Date shadowing) turns at least one test red.
  • Compiled 3,479 real .tsx/.tsrx files in the repo under Strong and diffed against main. Every new render diagnostic is a true positive: Math.random/Date.now inside map callbacks, toLocaleDateString() in TanStack.com components, and crypto.randomUUID() passed to a useRef initializer.
  • Throughput, measured together with the companion DOM checks: the Strong analyzer alone is +4.8% on that corpus, about +1% of a whole Strong compile. The paired benchmarks/strong-compiler-checks audit stays within noise (median ratios 0.95–1.03). Compatibility-mode compiles skip the analyzer entirely.

Risk / follow-ups

  • Array methods are matched by name on unknown receivers, as the brief specified. A lazy .map on a non-array would now be checked as render.
  • Companion PRs: DOM write checks, own-markup queries, and the Strong repair eval family.
  • The octane analyze --strict coverage ratchet is awaiting a design decision.

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
Strong mode becomes stricter for common patterns (map callbacks, crypto IDs, date formatting), which can break existing "use strong" modules until fixed; runtime behavior and compatibility mode are unchanged.

Overview
Strong mode now enforces three additional render-determinism rules; compatibility mode and emitted code are unchanged.

Callbacks passed to synchronous array methods (map, filter, forEach, reduce, sort, Array.from, and related APIs) are analyzed as render, so impure calls, state updates, and ref reads inside those callbacks are rejected the same as in the component body.

crypto.randomUUID() and crypto.getRandomValues() are treated as OCTANE_STRONG_RENDER_IMPURE_CALL, with diagnostics that point to useId() for element IDs and stable item IDs for list keys when the impure expression feeds a key or @for key.

A new OCTANE_STRONG_RENDER_LOCALE_FORMAT diagnostic flags locale- or time-zone-dependent formatting during render on provable Date values and implicit-locale Intl construction (including module-level formatters used from render). Implementation lives in new strong-render-policy.js, wired from strong-mode.js via focused hook points.

Docs and a large strong-render-determinism.test.ts suite document and lock in the behavior.

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

Strong mode treated callbacks passed to known synchronous array methods as
deferred, so `items.map(i => <li key={Math.random()} />)` and random children
inside `.map` compiled. Those callbacks now run in the caller's phase, so every
render rule applies inside them (impure calls, ref reads, state updates).

`crypto.randomUUID()` and `crypto.getRandomValues()` join
OCTANE_STRONG_RENDER_IMPURE_CALL with a message that names `useId()`, and an
impure call that computes a `key` or `@for` key gets a message that names a
stable item ID.

New OCTANE_STRONG_RENDER_LOCALE_FORMAT rejects locale- and time-zone-dependent
formatting during render when the receiver is provably a Date or the
constructor is an Intl service, including module-level formatters used in
render.

The analysis lives in strong-render-policy.js; strong-mode.js only gains hook
points. Diagnostics only: compatibility mode and emitted code are unchanged.

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

# Conflicts:
#	docs/differences-from-react.md
#	docs/strong-compiler-checks.md
#	packages/octane/src/compiler/strong-mode.js
trueadm added a commit that referenced this pull request Oct 1, 2026
Brings in #1497 (Strong state values, updaters, and write-only state) and
resolves the same conflicts as #1489 in strong-mode.js and the Strong docs,
keeping the DOM ownership and query additions from #1491 and #1492.

The workaround ledger records that #1497 now rejects five workarounds that
previously compiled and kept the bug: both force-update click tallies,
setN(n + 1) after await, mutate-then-set, and the mutating updater
(27 → 22 compiler gaps). Prompts, references, and the recorded alternative are
unchanged.

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

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

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Spread first arg false positive
    • Added a guard (args[0]?.type !== 'SpreadElement') before the missingTimeZone(args[1]) check in both intlService and call, so a leading spread — which could supply both locale and options — fails open instead of being falsely reported as missing a timeZone.

Create PR

Or push these changes by commenting:

@cursor push 88296b923a
Preview (88296b923a)
diff --git a/packages/octane/src/compiler/strong-render-policy.js b/packages/octane/src/compiler/strong-render-policy.js
--- a/packages/octane/src/compiler/strong-render-policy.js
+++ b/packages/octane/src/compiler/strong-render-policy.js
@@ -139,7 +139,9 @@
 			name,
 			implicit:
 				missingValue(args[0], scope) ||
-				(name === 'DateTimeFormat' && missingTimeZone(args[1], scope)),
+				(name === 'DateTimeFormat' &&
+					args[0]?.type !== 'SpreadElement' &&
+					missingTimeZone(args[1], scope)),
 		};
 	}
 
@@ -253,7 +255,11 @@
 			const locale = DATE_LOCALE_METHODS.has(name);
 			if ((!locale && !DATE_ZONE_METHODS.has(name)) || !isDate(member.object, scope)) return;
 			const args = node.arguments ?? [];
-			if (locale && (missingValue(args[0], scope) || missingTimeZone(args[1], scope))) {
+			if (
+				locale &&
+				(missingValue(args[0], scope) ||
+					(args[0]?.type !== 'SpreadElement' && missingTimeZone(args[1], scope)))
+			) {
 				report(
 					STRONG_RENDER_LOCALE_FORMAT,
 					member,

diff --git a/packages/octane/tests/compiler/strong-render-determinism.test.ts b/packages/octane/tests/compiler/strong-render-determinism.test.ts
--- a/packages/octane/tests/compiler/strong-render-determinism.test.ts
+++ b/packages/octane/tests/compiler/strong-render-determinism.test.ts
@@ -307,6 +307,8 @@
       {new Date(t).toISOString()}{new Date(t).toUTCString()}{new Date(t).getTime()}
       {new Date(2024, 0, 1).toDateString()}
       {new Intl.DateTimeFormat(locale, { timeZone, month: 'long' }).format(t)}
+      {new Intl.DateTimeFormat(...options).format(t)}
+      {new Date(t).toLocaleString(...options)}
       {utc.format(t)}{count.format(n)}{date.toLocaleString()}{n.toLocaleString()}
       {label}{clicked}
     </button>

You can send follow-ups to the cloud agent here.

A spread in the locale or options position, such as `toLocaleString(...args)`
or `new Intl.DateTimeFormat(...args)`, can supply both the locale and the
options. OCTANE_STRONG_RENDER_LOCALE_FORMAT treated the following position as
absent and reported a missing time zone it could not prove. A spread in either
of the first two positions now leaves the call unreported, like other options
the compiler cannot see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 1, 2026 12:03
…5c5da

# Conflicts:
#	packages/octane/src/compiler/strong-mode.js
…5c5da

# Conflicts:
#	packages/octane/src/compiler/strong-mode.js

@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 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Local aliases skip module formatter checks
    • Replaced the resolveScope === moduleScope gate with a moduleLevel flag set on the value object when first recorded at module scope, so local aliases inherit the flag through the same object reference and are correctly reported during render.
  • ✅ Fixed: Locale checks misfire in state updaters
    • Added early return in pureDiagnostic for OCTANE_STRONG_RENDER_LOCALE_FORMAT (returning false) and a corresponding check in report() to suppress the diagnostic entirely in updaters/reducers, since locale/timezone are stable across replays on the same runtime.

Create PR

Or push these changes by commenting:

@cursor push 2290cc3f2a
Preview (2290cc3f2a)
diff --git a/packages/octane/src/compiler/strong-mode.js b/packages/octane/src/compiler/strong-mode.js
--- a/packages/octane/src/compiler/strong-mode.js
+++ b/packages/octane/src/compiler/strong-mode.js
@@ -1636,6 +1636,7 @@
 	function report(code, node, message, suggestions = []) {
 		if (insidePureCallback) {
 			const pure = statePolicy.pureDiagnostic(code);
+			if (pure === false) return;
 			if (pure !== null) {
 				code = pure.code;
 				message = pure.message;

diff --git a/packages/octane/src/compiler/strong-render-policy.js b/packages/octane/src/compiler/strong-render-policy.js
--- a/packages/octane/src/compiler/strong-render-policy.js
+++ b/packages/octane/src/compiler/strong-render-policy.js
@@ -172,6 +172,8 @@
 				recorded++;
 				if (scope === moduleScope && value.kind === 'intl' && value.implicit) moduleFormatters++;
 			}
+			if (scope === moduleScope && value.kind === 'intl' && value.implicit)
+				value.moduleLevel = true;
 			names.set(id.name, value);
 		}
 	}
@@ -248,11 +250,7 @@
 			}
 			if (moduleFormatters !== 0) {
 				const alias = aliasValue(member.object, scope);
-				if (
-					alias?.kind === 'intl' &&
-					alias.implicit &&
-					resolveScope(scope, unwrap(member.object).name) === moduleScope
-				) {
+				if (alias?.kind === 'intl' && alias.implicit && alias.moduleLevel) {
 					reportIntl(member, alias, true);
 					return;
 				}

diff --git a/packages/octane/src/compiler/strong-state.js b/packages/octane/src/compiler/strong-state.js
--- a/packages/octane/src/compiler/strong-state.js
+++ b/packages/octane/src/compiler/strong-state.js
@@ -220,6 +220,7 @@
 
 		/** The Strong diagnostic that replaces a render diagnostic inside an updater or reducer. */
 		pureDiagnostic(code) {
+			if (code === 'OCTANE_STRONG_RENDER_LOCALE_FORMAT') return false;
 			if (code === 'OCTANE_STRONG_RENDER_SNAPSHOT_MUTATION') {
 				return { code: STRONG_SNAPSHOT_MUTATION, message: UPDATER_MUTATION_MESSAGE };
 			}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit ca328ef. Configure here.

trueadm and others added 2 commits October 1, 2026 19:32
…aters

A module-level Intl formatter without a locale or time zone, rebound to a local
const and used during render, went unreported: the use site required the name
to resolve at module scope. Formatter records now remember whether they were
built at module scope, and aliases carry that through.

Updaters and reducers are visited as render code since #1497, so
OCTANE_STRONG_RENDER_LOCALE_FORMAT fired inside them with a hydration message.
They run on the client after an event and a replay formats the same way, so the
locale check is skipped there; randomness inside them still reports as
OCTANE_STRONG_IMPURE_UPDATER.

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

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No size increases and no timing regressions outside noise.

Compares f1516140c with ddd6c87fd 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 moving the same way. 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.39 3.41 +0.6% ±6% ⚪ within noise
octane-tsrx replace 6.58 6.51 −1.1% ±7% ⚪ within noise
octane-tsrx add 3.21 3.19 −0.6% ±11% ⚪ within noise
octane-tsrx update 0.33 0.34 +3.0% ±38% ⚪ within noise
octane-tsrx select 0.12 0.15 +25.0% ±69% ⚪ within noise
octane-tsrx swap 0.30 0.27 −10.0% ±61% ⚪ within noise
octane-tsrx remove 0.32 0.36 +12.5% ±53% ⚪ within noise
octane-tsrx runlots 29.10 27.79 −4.5% ±10% ⚪ within noise
octane-tsrx select_lots 0.29 0.21 −27.6% ±79% ⚪ within noise
octane-tsrx clear 40.20 38.46 −4.3% ±6% ⚪ within noise
octane-jsx run 3.37 3.35 −0.6% ±11% ⚪ within noise
octane-jsx replace 6.27 6.16 −1.8% ±9% ⚪ within noise
octane-jsx add 2.99 3.00 +0.3% ±9% ⚪ within noise
octane-jsx update 0.50 0.46 −8.0% ±27% ⚪ within noise
octane-jsx select 0.32 0.33 +3.1% ±35% ⚪ within noise
octane-jsx swap 0.55 0.53 −3.6% ±25% ⚪ within noise
octane-jsx remove 0.52 0.52 −0.0% ±33% ⚪ within noise
octane-jsx runlots 26.08 26.58 +1.9% ±5% ⚪ within noise
octane-jsx select_lots 2.55 2.51 −1.6% ±17% ⚪ within noise
octane-jsx clear 40.31 40.87 +1.4% ±6% ⚪ within noise

Application bundle size (bytes)

No changes across 45 measured values.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

CI job durations

  • 🟡 8 job(s) slower than every recent main run: heavy integration (package builds, eval corpus, runtime loaders, Astro), heavy integration (browser - chromium), React parity shard (1/4), test shard (Node 24, 4/4), example apps (3/3), validate publishable packages, test shard (Node 24, 2/4), typecheck checks

Compares the CI run for 4d698ac73 (run) with the last 5 successful main push runs. A job is only slower or faster outside the whole main range, by at least 10% and 15s.

job main median main range this PR Δ
wall clock (first job start to last job end) 17m 05s 12m 35s–23m 15s 24m 21s +7m 16s (+43%) 🟡 slower
total job time 184m 21s 144m 08s–242m 49s 241m 20s +56m 59s (+31%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 5m 28s 4m 36s–16m 52s 23m 47s +18m 19s (+335%) 🟡 slower
heavy integration (browser - chromium) 12m 52s 11m 12s–19m 08s 23m 37s +10m 45s (+84%) 🟡 slower
React parity shard (1/4) 14m 25s 10m 05s–18m 11s 20m 02s +5m 37s (+39%) 🟡 slower
test shard (Node 24, 4/4) 12m 54s 10m 24s–16m 16s 18m 16s +5m 22s (+42%) 🟡 slower
example apps (3/3) 3m 49s 3m 34s–5m 33s 8m 58s +5m 09s (+135%) 🟡 slower
validate publishable packages 4m 32s 3m 45s–5m 20s 8m 21s +3m 49s (+84%) 🟡 slower
test shard (Node 24, 2/4) 13m 32s 10m 24s–15m 53s 16m 06s +2m 34s (+19%) 🟡 slower
typecheck checks 9m 23s 7m 20s–11m 01s 11m 37s +2m 14s (+24%) 🟡 slower
All 26 timed jobs
job main median main range this PR Δ
heavy integration (package builds, eval corpus, runtime loaders, Astro) 5m 28s 4m 36s–16m 52s 23m 47s +18m 19s (+335%) 🟡 slower
heavy integration (browser - chromium) 12m 52s 11m 12s–19m 08s 23m 37s +10m 45s (+84%) 🟡 slower
React parity shard (1/4) 14m 25s 10m 05s–18m 11s 20m 02s +5m 37s (+39%) 🟡 slower
test shard (Node 24, 4/4) 12m 54s 10m 24s–16m 16s 18m 16s +5m 22s (+42%) 🟡 slower
example apps (3/3) 3m 49s 3m 34s–5m 33s 8m 58s +5m 09s (+135%) 🟡 slower
example apps (1/3) 3m 36s 3m 07s–9m 27s 8m 38s +5m 02s (+140%) ⚪ within noise
validate publishable packages 4m 32s 3m 45s–5m 20s 8m 21s +3m 49s (+84%) 🟡 slower
React parity shard (2/4) 10m 50s 9m 32s–19m 40s 13m 43s +2m 53s (+27%) ⚪ within noise
test shard (Node 24, 2/4) 13m 32s 10m 24s–15m 53s 16m 06s +2m 34s (+19%) 🟡 slower
typecheck checks 9m 23s 7m 20s–11m 01s 11m 37s +2m 14s (+24%) 🟡 slower
test shard (Node 24, 1/4) 14m 01s 11m 10s–17m 32s 16m 09s +2m 08s (+15%) ⚪ within noise
example apps (2/3) 4m 15s 3m 26s–9m 58s 6m 10s +1m 55s (+45%) ⚪ within noise
React parity shard (4/4) 13m 38s 11m 39s–22m 17s 15m 31s +1m 53s (+14%) ⚪ within noise
React parity shard (3/4) 13m 10s 10m 59s–18m 01s 14m 33s +1m 23s (+11%) ⚪ within noise
test shard (Node 24, 3/4) 11m 56s 9m 44s–15m 12s 12m 44s +48s (+7%) ⚪ within noise
Three compatibility 3m 28s 2m 51s–4m 23s 4m 01s +33s (+16%) ⚪ within noise
Lynx compatibility 2m 00s 1m 34s–2m 55s 2m 14s +14s (+12%) ⚪ within noise
classify changeset release 16s 14s–21s 18s +2s (+13%) ⚪ within noise
React parity checks 15s 14s–16s 16s +1s (+7%) ⚪ within noise
CI provenance 4s 3s–4s 5s +1s (+25%) ⚪ within noise
examples 4s 4s–4s 4s ±0s (±0%) ⚪ within noise
typecheck 4s 3s–4s 4s ±0s (±0%) ⚪ within noise
lint 4s 4s–5s 3s −1s (−25%) ⚪ within noise
test (24) 4s 3s–5s 3s −1s (−25%) ⚪ within noise
lint checks 8m 49s 7m 43s–12m 27s 8m 43s −6s (−1%) ⚪ within noise
website integration suite 7m 24s 5m 45s–11m 41s 7m 17s −7s (−2%) ⚪ within noise

…5c5da

# Conflicts:
#	packages/octane/src/compiler/strong-mode.js
@trueadm
trueadm merged commit 0339abc into main Oct 1, 2026
30 checks passed
@trueadm
trueadm deleted the claude/dreamy-wiles-d5c5da branch October 1, 2026 20:11
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 feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant