Skip to content

feat: trust pure renders in Strong mode - #866

Merged
trueadm merged 14 commits into
mainfrom
codex/use-strong-pure-renders
Aug 27, 2026
Merged

trueadm merged 14 commits into
mainfrom
codex/use-strong-pure-renders

Conversation

@trueadm

@trueadm trueadm commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Treat "use strong" as an author assertion that user-authored render operations are pure projections of immutable snapshots and witnessed inputs.
  • Remove Strong-mode hook-name, callee-shape, callback, and whole-module alias fallbacks so local, computed, call-produced, constructor, tagged-template, callback-bearing, and use*-shaped ordinary calls can participate in production region memoization.
  • Keep compatibility mode conservative, replace the old fallback fixtures with deterministic seven-shape performance/semantic guards, and document the contract across the core, website, bundler, type, LLM, and changeset surfaces.

This finishes the purity-contract follow-up to #862. Hidden ref contents, state getters, mutable globals, live stores, clocks/randomness, mutations, or hook state behind a stable user call now violate the Strong assertion instead of silently forcing compatibility behavior. Bounded diagnostics still reject violations they can prove.

Validation

  • pnpm sync
  • pnpm format:check
  • pnpm typecheck
  • Explicit changed-file pnpm typecheck:files ...
  • 792 targeted Octane development/production/compiler/registration tests
  • 36 website search, docs snapshot, and built MCP-handler tests
  • node benchmarks/bench.mjs --ratios template-call-memo (13/13 applicable guards pass)
  • Full root Vitest reached 26,182/26,185 passing tests with three resource-concurrent bundling failures; all three pass in isolation (6/6 compiler-registration variants and 7/7 built MCP-handler tests). Current-head CI is the authoritative sharded gate.

Performance evidence

  • Strong stable/reorder work for all seven added call shapes: 0 calls.
  • Insert/changed-row work: exactly 7 calls per new or replaced row.
  • Captured-argument changes: exactly 18 × 7 = 126 calls.
  • Compatibility behavior remains conservative (3,584 stable and 126 reorder calls in the fixed workload).
  • The implementation removes the whole-module Strong hook-alias graph; it adds no runtime helper or allocation.

Risk

  • This deliberately changes the contract for Strong modules. Code that reads unwitnessed live data behind a stable user call can now become stale; the migration is to keep that consumer in compatibility mode or pass a real reactive snapshot into a Strong component.
  • Development, HMR, profiling, server, hydration, retry, and aborted-work evaluation counts remain non-contractual.

Provenance

  • An agent produced this diff (agent-authored)

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


Note

High Risk
Strong production memoization now trusts author purity across all call shapes; code that hid live refs, getters, or stores behind stable calls can render stale output without falling back to compatibility behavior.

Overview
Strong mode is reframed as an author assertion that user-authored render work is a pure function of immutable snapshots and witnessed inputs (callable, receiver, and arguments), not a narrow fast path for static member calls.

The production memoizer stops using use* naming, callback guards, and hook-alias graphs to block Strong regions. Instead it lexically distinguishes real hook setup (built-in import provenance, optional calls, same-module custom hooks, cycles, and reassignment conservatism) from ordinary calls—including hook-shaped helpers, computed/call-produced callees, new, tagged templates, and callbacks—so those shapes can memoize when inputs are unchanged. Compatibility mode stays conservative on member calls. Memo miss tests at component and list boundaries move to Object.is, with a carve-out so certified keyed selected === row.id keeps strict equality.

Diagnostics add OCTANE_STRONG_RETAINED_ROW_MUTATION for writes from a keyed @for body to outer bindings. Docs, plugin types, TanStack Table boundary guidance, and the template-call-memo benchmark (seven-shape AssumedPureRows fixture + ratio guards) document and lock the contract. Tests and fixtures are reshaped around the new semantics (including removal of cases that expected Strong to keep ref/context reads live behind stable calls).

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

@trueadm
trueadm marked this pull request as ready for review August 26, 2026 19:18
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Aug 26, 2026

@domgan-oai domgan-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would not merge the current implementation yet. I found five reproducible regressions below, using the current head f748ff3 and exact base d5175ca. These involve pure immutable inputs or supported setup hooks, not the deliberately unsupported hidden-ref/live-accessor cases.

Direction

The opt-in pure-projection contract is defensible, and the benchmark demonstrates a real reduction in evaluated work. The problem is applying that assertion more broadly than the existing dependency and lifecycle machinery supports. Purity cannot substitute for complete receiver/callee dependencies, valid dependency expressions, or hook/context/effect semantics.

I would keep the ordinary pure-call optimization, but retain semantic boundaries around actual setup hooks and leave unsupported expression shapes on the existing path until their dependency handling is complete. The same-module component proof currently analyzes setup and render output together, so the documented promise that actual hooks retain their setup behavior is not yet enforced.

Verification and missing coverage

  • The existing for, auto-memo, automemo-render-calls, and compiler strong-mode suites pass: 828 tests through a focused production configuration.
  • The new input-replacement/chained-expression probes pass 18/18 on the base; 8 fail on this head (five stale values and three mount errors). All nine autoMemo: false controls pass.
  • Custom-hook context and Suspense layout-effect probes pass all four Strong/compatibility controls on the base. On this head, both Strong cases fail and both compatibility controls pass.
  • The aliased built-in keyed-row probe passes Strong on the base and fails Strong on this head. Its compatibility failure already exists on the base, so that part is not attributed to this PR.
  • All 13 applicable benchmark ratio guards pass. With the same new fixture on both commits, stable call work falls from 3,584 to 0, while changed-argument work remains 126. Eight additional server-to-dev/prod hydration checks pass.

The new benchmark exercises keyed rows, but misses the newly admitted component-prop boundaries, replacement of callable/receiver identities, context changes through setup hooks, and Suspense effect reconnection. Add those semantic cases to the regular runtime suite and keep operation-count assertions in the benchmark. The benchmark workflow is weekly/manual, so green ordinary PR CI does not cover the seven-shape guards.

Local verification used Node 26.4.0 and the repository's existing fixture/runtime harness. The configured npm registry denied part of installation; the missing TSRX source was taken from the official @tsrx/[email protected] release commit tsrx-org/tsrx@7cb01278, with the checked-in patch applied. The base tests explicitly alias Octane exports to base source, avoiding accidental use of the head compiler through shared dependency links. I did not rerun the full monorepo suite; current-head CI is green.

No earlier review comments were present. This is a comment-only review; no approval is submitted, and the PR does not have the codex-approvable label.

Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
@trueadm

trueadm commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all five review findings in 8447074: chained member results no longer emit property tokens as dependencies; guards include callable and receiver identity; compiler-proven built-ins and transitive same-module setup hooks retain lifecycle semantics without a use-name heuristic; Suspense reveals reconnect cached-child layout effects; and aliased built-ins block keyed-row setup skipping. Validation: 1,056 focused compiler/runtime tests, 158 Strong mount/hydration tests, 43 docs/search tests, full repository typecheck, repository-wide formatting, pnpm sync, and template-call-memo ratio guards all pass.

Comment thread packages/octane/src/compiler/compile.js Resolved

@domgan-oai domgan-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revalidated 8447074. All five original reproduction cases are fixed, including the compatibility-mode hook-alias case that previously failed on the base. The unchanged original probe suite now passes 26/26, and the new permanent tests cover those failures.

The direction is improved: retaining actual setup operations separately from ordinary projections is the right boundary. I found two remaining holes in the new hook proof, plus an existing equality weakness exposed by the newly memoized constructor path; details are inline. I would address those before calling the broadened contract safe.

Validation:

  • 839 relevant compiler/runtime tests pass.
  • 24 additional ordinary expression checks pass, covering receiver replacement, callbacks, computed methods/tags, spread arguments, and optional/conditional evaluation.
  • 8 server-to-dev/prod hydration probes and all 13 applicable benchmark guards pass; benchmark counts and output sizes are unchanged from the original PR head.
  • The new hook edge-case matrix passes 12/12 on the exact base d5175ca, but fails two Strong cases on this head. Compatibility and source-local controls pass.
  • The signed-zero constructor case passes on the base and with memoization disabled, but fails here. The arithmetic control already fails on the base: the underlying !== weakness predates this repair, so I am not attributing its introduction to the new dependency walker.

Base runs explicitly resolve Octane exports to base source. I used the same focused harness and dependencies as the original review, not a full local monorepo run. At the last check there were no failing CI checks; the React parity aggregate and Bugbot Autofix were still running.

Submitting a comment-only follow-up, not approval. The original examples are addressed, but the remaining findings below need attention; codex-approvable is still absent.

Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
cursoragent and others added 2 commits August 26, 2026 20:56
The setup-hook veto in containsRenderCall, autoMemoBuiltinHookName, and
the recursive walk in autoMemoCallExecutesSetupHook only matched
CallExpression nodes. Since the enclosing branch already handles
OptionalCallExpression, an optional hook call like useContext?.(Theme)
bypassed the veto and was admitted by plainCalleeIsMemoizable as a pure
projection under Strong mode. This could cause keyed rows and child
caches to skip context, state, and effect setup.

Extend the type checks in all three locations to also match
OptionalCallExpression. For autoMemoBuiltinHookName, also accept
OptionalCallExpression in the callee-name branch since these nodes lack
the _octaneUnboundCallee annotation from hook-deps analysis.

@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: Optional hook aliases skip setup detection
    • Extended hook-deps.js to annotate OptionalCallExpression nodes with _octaneImportedHook/_octaneUnboundCallee/_octaneHookRuntimeImportedHook provenance, and extended containsAutoMemoContextRead to check both CallExpression and OptionalCallExpression, so aliased optional hook calls are now correctly identified as setup hooks.

Create PR

Or push these changes by commenting:

@cursor push 2bd751b1be
Preview (2bd751b1be)
diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -4178,7 +4178,10 @@
 		) {
 			return;
 		}
-		if (node.type === 'CallExpression' && node.callee?.type === 'Identifier') {
+		if (
+			(node.type === 'CallExpression' || node.type === 'OptionalCallExpression') &&
+			node.callee?.type === 'Identifier'
+		) {
 			const name =
 				node._octaneImportedHook ??
 				node._octaneHookRuntimeImportedHook ??

diff --git a/packages/octane/src/compiler/hook-deps.js b/packages/octane/src/compiler/hook-deps.js
--- a/packages/octane/src/compiler/hook-deps.js
+++ b/packages/octane/src/compiler/hook-deps.js
@@ -605,6 +605,21 @@
 			if (trustedConfig && node.arguments.length === trustedConfig.deps) {
 				candidates.push({ call: node, scope, name: trustedName, config: trustedConfig });
 			}
+		} else if (node.type === 'OptionalCallExpression') {
+			const octaneImportedName = canonicalOctaneHookName(node, scope);
+			const callee = unwrapValue(node.callee);
+			const unboundCallee =
+				callee?.type === 'Identifier' && resolveBinding(scope, callee.name) === null;
+			const hookRuntimeImportedName = canonicalHookName(node, scope, true);
+			if (octaneImportedName !== null || unboundCallee || hookRuntimeImportedName !== null) {
+				const props = {};
+				if (octaneImportedName !== null) props._octaneImportedHook = octaneImportedName;
+				if (unboundCallee) props._octaneUnboundCallee = true;
+				if (octaneImportedName === null && hookRuntimeImportedName !== null) {
+					props._octaneHookRuntimeImportedHook = hookRuntimeImportedName;
+				}
+				callAnnotations.set(node, props);
+			}
 		}
 
 		if (node.type?.startsWith('TS') && !TS_VALUE_WRAPPERS.has(node.type)) return;

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

Comment thread packages/octane/src/compiler/compile.js Resolved
…nto codex/use-strong-pure-renders

# Conflicts:
#	packages/octane/src/compiler/compile.js
@trueadm

trueadm commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up review feedback is addressed in b48309b/cc5ca4861: setup-hook reachability is now an order-independent lexical fixed point, shadowed assignments no longer demote the real module hook, memo guards use SameValue semantics for signed zero, and optional direct/aliased built-ins retain lifecycle behavior without a name-only Rules-of-Hooks heuristic. The existing project-wide configuration is also documented explicitly: Vite/Rsbuild read compiler.strong from octane.config.ts, while standalone Rspack uses new OctaneRspackPlugin({ strong: true }); direct plugin options override shared config. Final-head validation: 1,173 focused compiler/runtime/plugin/docs tests, full monorepo typecheck, repository-wide formatting, pnpm sync, and all 13 template-call-memo ratio guards pass.

@trueadm

trueadm commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

CI follow-up: Node 24 shard 3 exposed that the initial SameValue change was too broad for keyed selection, whose authored comparison intentionally treats 0 and -0 as equal. Commit 44e1d29 scopes Object.is to component-projection inputs (preserving the reviewed constructor fix) and keeps strict equality for keyed list/selection guards. The exact failed CI test now passes in both dev/prod projects; the final focused matrix is 1,205 tests, all 13 ratio guards pass, and benchmark output returns to 4408 compiled / 47576 gzip bytes.

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

Autofix Details

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

  • ✅ Fixed: Missing scope treats hooks as pure
    • Changed three sites (autoMemoBuiltinHookName identifier path, autoMemoSetupHookFunctions call-graph edges, and autoMemoCallExecutesSetupHook) to fall back to lexical.rootScope when nodeScopes has no entry, matching the existing conservative fallback already used by the namespace/member path.
  • ✅ Fixed: Namespace optional hooks skip TS peels
    • Applied unwrapTsExpr to callee.object and callee.property in the namespace optional-call branch so parenthesized or assertion-wrapped receivers like (Octane as any).useContext?.() are correctly identified as hook calls.

Create PR

Or push these changes by commenting:

@cursor push c26522ca16
Preview (c26522ca16)
diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -4229,8 +4229,9 @@
 	ctx.activityLexical ??= lexical;
 	const callee = unwrapTsExpr(call.callee);
 	if (callee?.type === 'Identifier') {
-		const scope = lexical.nodeScopes.get(callee) ?? lexical.nodeScopes.get(call);
-		const binding = scope === undefined ? null : lexical.resolveBinding(scope, callee.name);
+		const scope =
+			lexical.nodeScopes.get(callee) ?? lexical.nodeScopes.get(call) ?? lexical.rootScope;
+		const binding = lexical.resolveBinding(scope, callee.name);
 		const importedName = ctx.octaneImportLocals?.get(callee.name);
 		if (
 			importedName !== undefined &&
@@ -4242,21 +4243,19 @@
 		if (binding === null && AUTO_MEMO_SETUP_HOOK_NAMES.has(callee.name)) return callee.name;
 		return null;
 	}
-	if (
-		(callee?.type === 'MemberExpression' || callee?.type === 'OptionalMemberExpression') &&
-		callee.object?.type === 'Identifier'
-	) {
-		const property = callee.computed ? callee.property?.value : callee.property?.name;
+	if (callee?.type === 'MemberExpression' || callee?.type === 'OptionalMemberExpression') {
+		const object = unwrapTsExpr(callee.object);
+		if (object?.type !== 'Identifier') return null;
+		const prop = unwrapTsExpr(callee.property);
+		const property = callee.computed ? prop?.value : prop?.name;
 		if (
 			typeof property === 'string' &&
 			AUTO_MEMO_SETUP_HOOK_NAMES.has(property) &&
-			ctx.octaneImportNamespaces?.has(callee.object.name)
+			ctx.octaneImportNamespaces?.has(object.name)
 		) {
 			const scope =
-				lexical.nodeScopes.get(callee.object) ??
-				lexical.nodeScopes.get(callee) ??
-				lexical.rootScope;
-			if (lexical.resolveBinding(scope, callee.object.name)?.scope === lexical.rootScope) {
+				lexical.nodeScopes.get(object) ?? lexical.nodeScopes.get(callee) ?? lexical.rootScope;
+			if (lexical.resolveBinding(scope, object.name)?.scope === lexical.rootScope) {
 				return property;
 			}
 		}
@@ -4380,11 +4379,9 @@
 				} else {
 					const callee = unwrapTsExpr(node.callee);
 					if (callee?.type === 'Identifier' && declarations.has(callee.name)) {
-						const scope = lexical.nodeScopes.get(callee) ?? lexical.nodeScopes.get(node);
-						if (
-							scope !== undefined &&
-							lexical.resolveBinding(scope, callee.name)?.scope === lexical.rootScope
-						) {
+						const scope =
+							lexical.nodeScopes.get(callee) ?? lexical.nodeScopes.get(node) ?? lexical.rootScope;
+						if (lexical.resolveBinding(scope, callee.name)?.scope === lexical.rootScope) {
 							outgoing.add(callee.name);
 						}
 					}
@@ -4440,8 +4437,8 @@
 	// the same name. The summary graph uses this same binding resolution for its
 	// transitive edges, so cycles reach a fixed point independent of source order.
 	const lexical = ctx.autoMemoHookLexical;
-	const scope = lexical.nodeScopes.get(callee) ?? lexical.nodeScopes.get(call);
-	const binding = scope === undefined ? null : lexical.resolveBinding(scope, name);
+	const scope = lexical.nodeScopes.get(callee) ?? lexical.nodeScopes.get(call) ?? lexical.rootScope;
+	const binding = lexical.resolveBinding(scope, name);
 	return binding?.scope === lexical.rootScope;
 }

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

Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
@trueadm

trueadm commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Latest Bugbot feedback is addressed in a215fe2: missing lexical scope now fails closed to module-root setup classification at every hook checkpoint, and optional namespace recovery peels TypeScript wrappers on both receiver and property. Permanent production/dev regressions cover an optional same-module custom-hook chain, an aliased optional useContext call, and a TypeScript-wrapped namespace/computed-property call. The focused matrix remains 1,205/1,205 with all 13 performance guards passing.

@domgan-oai domgan-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revalidated the current head a215fe2a7c93d213245de1444f1f147d574db157. The earlier reproduction cases are fixed, including cyclic/shadowed hook reachability and the direct constructor signed-zero case, but I still would not merge this head: two isolated cases show incomplete fixes, detailed inline.

  • Optional computed namespace hook: when tested alone in a keyed row, (Hooks as any)['useContext' as string]?.(Theme) still freezes a context update. The new permanent fixture groups this with a recognized direct hook, which keeps the entire row live and masks the failure.
  • Signed-zero input through a list: component guards now distinguish 0 and -0, but an ordinary enclosing list cache still drops that change before the row or child component can run. No authored selection comparison is involved.

Verification

  • 917/917 tests pass across the four existing focused compiler/runtime suites plus all five earlier review probe files, including server-to-dev/prod hydration.
  • 20 additional isolated probes: 16 pass, 4 fail on this head. The failures are two namespace-key forms and two list-row forms. All four failing cases pass on exact pre-PR base d5175ca; current compatibility or autoMemo:false controls also pass. The full base probe run has one unrelated, pre-existing compatibility failure for an optional named-import alias, which is fixed on the current head and is not a new finding.
  • 13/13 applicable template-call-memo benchmark guards pass; measured operation counts, output sizes, and semantic traces match 8447074. That benchmark does not cover these two isolated failures or establish component-guard latency.
  • Current-head CI is green: 28 successful checks and one skipped optional check. The CI workflow reports a215fe2 as its head.

The remaining work is to handle the parser's optional CallExpression form and to preserve numeric projection dependencies through every enclosing cache, while keeping specialized selection semantics separate. Please retain independent regression cases so one safe sibling cannot mask another form.

Two P2 inline findings are included. This is a comment-only review; approval is withheld because these regressions remain. The PR also does not have the codex-approvable label.

Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
@trueadm

trueadm commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Latest review feedback is addressed in 2bcc38a. Optional imported-hook recovery now covers both optional-call AST encodings, and whole-list projection guards use SameValue while preserving strict equality only for the certified keyed-selection operand. The isolated reproductions failed on the reviewed production head before the fix; permanent coverage includes namespace-only optional context rows, child and inline signed-zero list projections, mixed selection/non-selection comparator policy, and the existing selection-only no-reread case. Validation: 1,162 focused compiler/list/hydration tests, 26,223 full tests with an 8 GB Node heap (the first default-heap run exhausted its 4 GB coordinator limit without an assertion failure), full monorepo typecheck, repository-wide formatting, pnpm sync, 17 docs tests, and all 13 template-call-memo ratio guards pass. Benchmark counters are unchanged; Strong output moves from 4,408 to 4,447 minified bytes and 47,576 to 47,585 gzip bytes.

@trueadm
trueadm marked this pull request as draft August 26, 2026 22:45
@trueadm
trueadm marked this pull request as ready for review August 26, 2026 22:45
@trueadm trueadm closed this Aug 26, 2026
@trueadm trueadm reopened this Aug 26, 2026
@vercel

vercel Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
octane-website Skipped Skipped Aug 26, 2026 10:49pm
octane-website-mcp Skipped Skipped Aug 26, 2026 10:49pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp August 26, 2026 22:49 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website August 26, 2026 22:49 Inactive
@trueadm trueadm closed this Aug 26, 2026
@trueadm trueadm reopened this Aug 26, 2026

Copy link
Copy Markdown
Contributor

Additional design context from the #846 discussion, reviewed against ea49abae4f690a5acc2bc041fa352d4a31c24de8.

I think the central concern supports the compatibility/Strong split already described in the latest docs; it does not require reversing that direction. The useful follow-up is to make the boundaries more explicit:

  1. Keep Octane's contract separate from React Compiler heuristics. The docs already disclaim matching every React Compiler optimization. Retain that distinction: compatibility deliberately keeps certain live reads executing, while Strong asserts that witnessed snapshots determine the result. React's incompatible-library guidance explicitly identifies interior-mutability hazards. A particular .map() transform happening to work is not evidence that a stable method or receiver is safe to cache.

  2. Bound the compatibility promise. Keeping a member call live helps only when its containing render scope actually executes; it creates no subscription and does not make a stable live object safe across arbitrary explicit or Strong memoization boundaries. Add a concrete migration example: a subscribed compatibility consumer reads the changing sorting/selection value, then passes that value into a separate Strong component which renders from it. Merely passing the same header/row, shallow-copying an object containing the same live methods, or forcing a render while ignoring the selected value is not a snapshot contract.

  3. Define local mutation versus mutation across @for boundaries. React permits mutation of fresh render-local data. Building a fresh array in an ordinary JS loop before it escapes is different from retained row bodies incrementing a shared outer i. Document whether the latter is unsupported or requires defined conservative execution; it cannot simply be assumed to be an independently reusable projection. Classify both examples explicitly and cover observable results/diagnostics, rather than treating all local mutation as impure or relying on row evaluation order.

  4. Make the integration evidence versioned and boundary-specific. The historical rationale concerns Table v8, while this repository's binding is pinned to Table v9.0.0-beta.58. TanStack's current compiler guide distinguishes its reactive adapter value from stable core table/row/header objects. Extend existing integration scenarios to cover inline .map, @for, and extracted consumers, with a changing selected snapshot crossing the Strong boundary. Keep unsupported stable-live-object usage as a documented negative example, not an expected Strong compatibility guarantee. Assert sorting/selection output and promised identity; keep call counts in benchmarks.

I have not reproduced the discussion's specific enableJsxOutlining or useDebugValue(header) effects. Those should remain version/options-specific observations until a pinned compiler/package reproduction confirms them, rather than becoming the rationale for Octane's contract. The examples concern TanStack Table, not evidence of a TanStack Query defect.

This is additional contract/documentation/test feedback, not a new correctness revalidation of the latest fixes.

@trueadm

trueadm commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the additional contract feedback in 6f6f5bb (with current main merged in c7742c6 and its generated parity inventory synchronized in 7a8ab83):

  1. The docs now keep Octane's compatibility/Strong contract explicitly separate from React Compiler lint classifications, JSX outlining, debug hooks, and React memo directives.
  2. The compatibility promise is bounded to execution of the containing subscribed scope. The docs and pinned Table fixture show the supported bridge: compatibility owns table.Subscribe, selects an immutable boolean/sort value, and passes that value into a separate Strong component. Passing the same live row/header, a shallow copy with the same methods, or an unrelated forced render is documented as unsupported.
  3. Fresh setup-local mutation and scratch owned by one row remain valid. Strong now reports OCTANE_STRONG_RETAINED_ROW_MUTATION for statically provable cross-row writes (scalar/member/destructuring updates, captured helpers, and known array mutators); compatibility still compiles them but makes no row-order promise. Coverage spans directive/project opt-in, client/server, dev/prod, and Volar diagnostics.
  4. The integration evidence is pinned to @tanstack/[email protected]. Development and explicit production compilation cover inline .map, keyed @for, and an extracted subscribed consumer, asserting selection/sorting output and surviving DOM identity. Strong children receive immutable snapshots, not stable live table-core objects.

The new diagnostic reproduction failed before the compiler change, and a deliberately broken snapshot handoff failed both development and production integration cases before restoration. Current validation: 1,129 focused compiler/list/hydration/TanStack/docs tests pass; full monorepo typecheck, repository formatting, pnpm sync, and all 13 template-call-memo guards pass with unchanged benchmark counters and sizes. The first full local run passed all 2,410 files / 26,230 assertions but exited on an unrelated late jsdom animation-frame teardown error from Redux Toolkit; that isolated file then passed 5 consecutive reruns. A clean full-suite rerun and current-head GitHub CI are in progress, and I will keep this PR at the final head until CI is green.

@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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Const custom hooks become projections
    • Extended autoMemoModuleFunctionDeclarations to collect VariableDeclaration statements with ArrowFunctionExpression/FunctionExpression initializers, so const/let-declared hooks are now tracked in the Strong setup-hook dependency graph and their calls correctly prevent caching.

Create PR

Or push these changes by commenting:

@cursor push 9fa49630b2
Preview (9fa49630b2)
diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -4280,6 +4280,16 @@
 		if (declaration?.type === 'FunctionDeclaration' && declaration.id?.type === 'Identifier') {
 			declarations.set(declaration.id.name, declaration);
 		}
+		if (declaration?.type === 'VariableDeclaration') {
+			for (const declarator of declaration.declarations) {
+				if (declarator.id?.type === 'Identifier') {
+					const init = unwrapTsExpr(declarator.init);
+					if (init?.type === 'ArrowFunctionExpression' || init?.type === 'FunctionExpression') {
+						declarations.set(declarator.id.name, init);
+					}
+				}
+			}
+		}
 	}
 	ctx.autoMemoModuleFunctionDeclarations = declarations;
 	return declarations;

diff --git a/packages/octane/tests/_fixtures/for-strong.tsrx b/packages/octane/tests/_fixtures/for-strong.tsrx
--- a/packages/octane/tests/_fixtures/for-strong.tsrx
+++ b/packages/octane/tests/_fixtures/for-strong.tsrx
@@ -264,6 +264,24 @@
 	</div>
 }
 
+const useConstTheme = (context: typeof StrongTheme): string => useContext(context);
+
+export function StrongConstHookContextRows() @{
+	const [theme, setTheme] = useState('first');
+	const [items] = useState([{ id: 1 }, { id: 2 }]);
+	<div>
+		<button id="strong-const-hook-context-update" onClick={() => setTheme('second')}>
+			update
+		</button>
+		<StrongTheme.Provider value={theme}>
+			@for (const item of items.slice(); key item.id) {
+				const value = useConstTheme(StrongTheme);
+				<span class="strong-const-hook-context-row">{value as string}</span>
+			}
+		</StrongTheme.Provider>
+	</div>
+}
+
 function useShadowedTheme(context: typeof StrongTheme): string {
 	return useContext(context);
 }

diff --git a/packages/octane/tests/for.test.ts b/packages/octane/tests/for.test.ts
--- a/packages/octane/tests/for.test.ts
+++ b/packages/octane/tests/for.test.ts
@@ -48,6 +48,7 @@
 	CapturedSnapshotList,
 	StrongAliasedContextRows,
 	StrongCallableDependencies,
+	StrongConstHookContextRows,
 	StrongConstructedResultProp,
 	StrongCustomHookContext,
 	StrongCyclicContextReaders,
@@ -687,6 +688,20 @@
 		r.unmount();
 	});
 
+	it('tracks const-declared function-expression hooks as setup-bearing in keyed rows', () => {
+		const r = mount(StrongConstHookContextRows);
+		expect(r.findAll('.strong-const-hook-context-row').map((row) => row.textContent)).toEqual([
+			'first',
+			'first',
+		]);
+		r.click('#strong-const-hook-context-update');
+		expect(r.findAll('.strong-const-hook-context-row').map((row) => row.textContent)).toEqual([
+			'second',
+			'second',
+		]);
+		r.unmount();
+	});
+
 	it('uses SameValue semantics for newly cached constructor inputs', () => {
 		const Projector = class {
 			result: string;

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

Reviewed by Cursor Bugbot for commit 7a8ab83. Configure here.

Comment thread packages/octane/src/compiler/compile.js Resolved
@blacksmith-sh

This comment has been minimized.

@trueadm

trueadm commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Final-head follow-up: CI is green on 563ce46df8dad98cab7e453c4c853e83745bd843 — 28 checks succeeded, the optional [code]smith check skipped, and there are no pending/failed checks or unresolved review threads.

The latest Bugbot finding was valid despite being auto-resolved. A Strong keyed-row reproduction using a module arrow binding that called a later function-expression binding and reached useContext stayed stale before the fix. Commit 563ce46 adds top-level function-valued bindings to the lexical transitive setup-hook fixed point; the permanent production regression now updates both retained rows. I also replied directly on the Bugbot thread with the reproduction and validation.

Final validation includes 1,102 focused compiler/list/hydration tests, full monorepo typecheck, repository formatting, docs tests, pnpm sync, and all 13 template-call-memo guards with unchanged counters and output sizes. The final local full run passed 2,415/2,416 files and 26,269/26,270 tests; its sole failure was an unrelated 5-second HMR timing timeout, and that exact production HMR case passed three consecutive isolated reruns. The immediately preceding merged-head full run was clean at 2,416 files / 26,268 tests.

@trueadm
trueadm merged commit 42256eb into main Aug 27, 2026
30 checks passed
@trueadm
trueadm deleted the codex/use-strong-pure-renders branch August 27, 2026 07:14
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.

3 participants