Repository navigation
feat(compiler): reject element descriptor APIs and single-item @for in Strong mode - #2055
Merged
Merged
Conversation
…s modules Strong modules outside the .tsx/.jsx dialect now report OCTANE_STRONG_ELEMENT_API for createElement, cloneElement, isValidElement, Children, and descriptorChildren from octane (named imports, namespace member access, and namespace destructuring), and for jsx/jsxs/jsxDEV/Fragment from Octane's JSX runtime entries. Descriptors render through the generic descriptor renderer instead of compiled templates. Type-only imports stay valid, and Strong .tsx keeps them. The namespace checks share one helper with OCTANE_STRONG_COMPAT_IMPORT. The Strong useMemo/useCallback plain-module fixtures now take their markup from a non-Strong view module. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 14, 2026 14:38
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
View logs |
octane-website | 91813bd | Oct 14 2026, 03:28 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
View logs |
octane-website-mcp | 91813bd | Oct 14 2026, 03:28 PM |
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 93 measured values. Public-import reachability bundles (bytes)No changes across 120 measured values. |
Strong .tsrx modules now report OCTANE_STRONG_SINGLE_ITEM_FOR for an @for whose iterable is a one-item array literal, whatever its binding pattern or key, and for a const holding one when no other identifier in the module spells its name. Multi-item literals, spreads, and holes stay valid. The replacement is React's keyed remount: <Fragment key={value}> or a key on the only element or component. suspense-superseded-arm.tsrx compiles with strong: true and its keyed @for case covers row replacement (#1698), so it now iterates a real one-row list instead of a literal. The tsrx-authoring rule names the new code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fragment-sibling-slots.test.ts compiles its fixture with strong: true, and ForRow covers sibling slots at a @for row's fragment root. Its `const rows = ['row']` alias now trips OCTANE_STRONG_SINGLE_ITEM_FOR, so the row comes from a helper instead of a single-item literal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 8 tasks
7 of 8 tasks
trueadm
added a commit
that referenced
this pull request
Oct 14, 2026
…note The element API changeset from #2055 is unreleased and ships with this change, which makes Strong .tsx modules a compile error. Its ".tsx may keep these APIs" wording no longer holds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 14, 2026
* feat(compiler): reject element descriptor APIs in Strong .tsrx and .ts modules Strong modules outside the .tsx/.jsx dialect now report OCTANE_STRONG_ELEMENT_API for createElement, cloneElement, isValidElement, Children, and descriptorChildren from octane (named imports, namespace member access, and namespace destructuring), and for jsx/jsxs/jsxDEV/Fragment from Octane's JSX runtime entries. Descriptors render through the generic descriptor renderer instead of compiled templates. Type-only imports stay valid, and Strong .tsx keeps them. The namespace checks share one helper with OCTANE_STRONG_COMPAT_IMPORT. The Strong useMemo/useCallback plain-module fixtures now take their markup from a non-Strong view module. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(compiler): reject single-item @for loops in Strong mode Strong .tsrx modules now report OCTANE_STRONG_SINGLE_ITEM_FOR for an @for whose iterable is a one-item array literal, whatever its binding pattern or key, and for a const holding one when no other identifier in the module spells its name. Multi-item literals, spreads, and holes stay valid. The replacement is React's keyed remount: <Fragment key={value}> or a key on the only element or component. suspense-superseded-arm.tsrx compiles with strong: true and its keyed @for case covers row replacement (#1698), so it now iterates a real one-row list instead of a literal. The tsrx-authoring rule names the new code. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(octane): keep the Strong fragment-sibling @for row a real list fragment-sibling-slots.test.ts compiles its fixture with strong: true, and ForRow covers sibling slots at a @for row's fragment root. Its `const rows = ['row']` alias now trips OCTANE_STRONG_SINGLE_ITEM_FOR, so the row comes from a helper instead of a single-item literal. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(compiler): reject Strong .tsx and .jsx modules Strong mode renders through compiled templates, but JSX in a .tsx or .jsx module lowers to element descriptors. A .tsx/.jsx module that "use strong" or the application compiler.strong policy reaches now reports OCTANE_STRONG_TSX_MODULE in client, server, and editor compilation. The rest of the analysis still runs, so collectDiagnostics and `octane analyze --strong-preview` list the module's other findings. With no Strong .tsx left, OCTANE_STRONG_ELEMENT_API applies to every Strong module, and the createElement raw-HTML check it now subsumes is removed. Migration recipes, the MCP server recipes and skills, the Strong docs and website guide, and the Strong compiler tests move to .tsrx. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changeset): drop the Strong .tsx exemption from the element API note The element API changeset from #2055 is unreleased and ships with this change, which makes Strong .tsx modules a compile error. Its ".tsx may keep these APIs" wording no longer holds. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: move the remaining Strong .tsx probes to .tsrx direct-signal-bindings ran its Strong matrix over .tsx too, and strong-hook-cache compiled its returned-JSX Strong case as .tsx; both now report OCTANE_STRONG_TSX_MODULE. The .tsx compatibility cells stay, and the returned-JSX Strong form now runs as a .tsrx module. The MCP explain test expects the tsrx recipe fences. 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 15, 2026
Brings in #2047-#2051 (Strong literal stabilisation), #2054 (checked compiled boundaries and a compiled router entry), #2055/#2057 (Strong rejects descriptor APIs and .tsx/.jsx), #2056/#2060/#2061 (CLI Strong reports), #2062 (Strong in the website and devtools), #2065 (no browser-translation DOM accommodations) and Version Packages. Conflicts, resolved so main's behaviour lands on the redesign's commit model: - runtime.ts, #2065: setText keeps main's legacy host-only convention and the redesign's hydration writeText. The translator recovery is gone from renderText/commitText, setRenderText/commitSetText, commitHole, childTextHoleUpdate, recordHole and bindSignalChild; removeOnlyChildText still removes a committed Text at commit. resetOnlyChildHost and PENDING_HOST_TEXTS (which served only the host-only text writes) are deleted. - compile.js, #2065: text updates call setRenderText(_txt, v), commit functions setText(_txt, v), and commitHole takes no host. - runtime.server.ts, #2054: a compiled-only frame checks its output; ordinary frames keep the redesign's returned-value normalization. - codes.json: main's 344-346 (CompiledContext, CompiledOutlet) keep their numbers; the redesign's codes move to 347 (server boundary error), 348 (hydration protocol skew) and 349 (frontier rehome). Generated tables and CLI data are regenerated; docs/ssr.md names #348. Adaptations: - compiled-boundaries.test.ts: the server runs no error boundary (React's model), so an invalid CompiledOutlet under a catch-only @Try fails renderToString with the CompiledOutlet error; the client still shows the catch arm. - scripts/render-writers.mjs drops resetOnlyChildHost. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OCTANE_STRONG_ELEMENT_APIfor modules outside the.tsx/.jsxdialect (.tsrx,.ts, and other plain modules). It fires oncreateElement,cloneElement,isValidElement,Children, ordescriptorChildrenfromoctane/octane/server, whether reached as a named import, a namespace member (Octane.createElement,Octane['Children']), or namespace destructuring. It also fires onjsx,jsxs,jsxDEV, orFragmentimported fromoctane/jsx-runtime,octane/jsx-dev-runtime, or theiroctane/strong/*variants.import type { ElementDescriptor },import { type Children }) stay legal. Shadowed namespaces and look-alike names from other modules stay legal too. Strong.tsxand.jsxare exempt because theirreturn <jsx>lowers to descriptors by design.OCTANE_STRONG_SINGLE_ITEM_FORfor an@forover a one-item array literal, such as@for (const item of [source]; key item), whatever the binding pattern (const item,const { a, b }) or key (header, constant, or row-rootkey={…}). It also fires for aconstholding a one-item literal (const one = [value]) when no other identifier in the module spells that name. Literals with two or more items, spreads, and holes stay valid.Why
OCTANE_STRONG_ELEMENT_APIis step 1 of the plan to keep Strong template modules off the generic descriptor renderer, which makes their performance predictable. It follows the existingOCTANE_STRONG_MAP_JSXandOCTANE_STRONG_COMPAT_IMPORTbans. On its own the check removes no bytes, becausechildSlotstill reaches the descriptor renderer statically. The runtime driver gate waits for Runtime vision: render computes, commit writes — one compiled commit model #2043/perf(octane): render computes, commit writes — runtime size redesign (#2043) #2044.OCTANE_STRONG_SINGLE_ITEM_FOR: agents use a one-row@forto bind a value or to force a remount..rulesync/rules/tsrx-authoring.mdalready forbids this, and the error enforces it. The replacement is React's keyed remount:<Fragment key={value}>…</Fragment>or akeyon the only element or component. To render one value, render it directly.Changes
packages/octane/src/compiler/strong-template-policy.js:namespaceAccesshelper withOCTANE_STRONG_COMPAT_IMPORTinstead of three copies of that check.@fordirectly. It records single-itemconstids and identifier iterables as it goes, and one walk infinish()drops any name that another identifier spells, so an alias that is read, mutated, or shadowed elsewhere is never flagged. That walk runs only when the module has both a single-itemconstand an@forover an identifier.packages/octane/src/compiler/strong-diagnostics.js: two catalog entries intemplates.OCTANE_STRONG_ELEMENT_APIsits next toOCTANE_STRONG_COMPAT_IMPORT, andOCTANE_STRONG_SINGLE_ITEM_FORnext toOCTANE_STRONG_INDEX_KEY.pnpm syncregenerateddocs/strong-compiler-checks.md, the website Strong-mode reference (anchors#octane-strong-element-apiand#octane-strong-single-item-for),llms.txt, the MCP server JSON, and the CLI data.icon={Plus}), or a() => @{ … }render function. The compiler marks<tsrx>blocks as legacy, so the message does not suggest them..rulesync/rules/tsrx-authoring.mdnamesOCTANE_STRONG_SINGLE_ITEM_FORin its existing "do not use a single-item@for" sentence. The generated copies come frompnpm rules:generate.packages/octane/tests/strong-manual-memo.test.ts: the Strong.tsrxfixtures importedcreateElementwithout using it, and the Strong plain-.tsfixtures built their markup with it. The plain fixtures now importparagraphandbuttonsfrom a non-Strong./viewruntime module through the loader's existingruntimeModulesoption, and their assertions are unchanged.packages/octane/tests/_fixtures/suspense-superseded-arm.tsrxis the only single-item-loop fixture compiled withstrong: true, fromsuspense-preserves-dom.test.ts. Itskeyed @for rowcase covers replacing a keyed@forrow beside a suspended arm (Keyed child disappears after a pending update is superseded #1698), which is row machinery rather than a remount trick. It now iterates a real one-row list from aselectionRows()helper, so it keeps testing the same@forpath in Strong dev and prod.packages/octane/tests/_fixtures/fragment-sibling-slots.tsrx:fragment-sibling-slots.test.tscompiles it withstrong: true, and itsForRowcase covers sibling slots at a@forrow's fragment root. Itsconst rows = ['row']alias tripped the new check in CI, so the row now comes from aoneRow()helper. I found it by Strong-compiling all 3,231.tsrxfiles in the repo: the only otherOCTANE_STRONG_SINGLE_ITEM_FORhits are in fixtures no test compiles with Strong on. The other single-item loops (descriptor-children-shadowing,ssr-invalid-nesting,ssr-suspense,markerless-arm-retry,stale-leading-component-range) are not compiled with Strong on, since no vitest project enables Strong globally, so they are unchanged.@forliterals all have three items.octaneminor, covering both codes.Validation
--project octane):strong-template-policy.test.ts(72 passed),strong-diagnostics-catalog.test.ts, andsuspense-preserves-dom.test.tsall pass. I also ran every test file that combines Strong with element APIs:auto-memo,bundler-compiler,compiler-vite-options,native-reads,strong-html,volar,hydration/signal-instance-identity,layout-snapshot,private-context,signals-dom-bindings, andstrong-manual-memo.OCTANE_STRONG_ELEMENT_APItests cover client and servercompile,slotHooks(.ts), and Volar editor diagnostics, plus the.tsx/.jsxexemption, type-only imports, shadowed namespaces,Fragmentfromoctane, andcreateElementfrom another module. Four mutations each turn them red: dropping the.tsxexemption (7 failures), dropping the type-only skip (1), dropping the namespace check (2), and dropping the JSX-runtime check (2).OCTANE_STRONG_SINGLE_ITEM_FORtests cover client and servercompileand Volar diagnostics. The rejected cases are a literal keyed by its item, a literal with a constant key, a literal with a row-root key, a local alias, and a module alias. The allowed cases are several items, a spread, an alias that grows, and a shadowed alias. Four mutations each turn them red: dropping the literal check (3 failures), dropping alias following (2), dropping the other-reference drop (2), and counting spreads (1). The pre-changesuspense-superseded-arm.tsrxfails to compile under Strong at line 43.pnpm typecheck:fileson the changed test files and fixturepnpm format:files:checkon every changed file (llms.txthas no Prettier parser)pnpm sync; the tree was clean after each commitpnpm format:check,pnpm typecheck,pnpm test: not run locally under the machine-load rule. CI covers them.perf-review:node scripts/perf-review-scan.mjsandnode scripts/perf-review-scan.mjs packages/octane/src/compiler/found 0 candidates. Both changes are compile-time Strong diagnostics: no runtime source, no compiled-output change, and no new runtime import. The added compile cost, in Strong modules only, is one specifier loop per import, one set lookup per namespace member, one array check per@for, and at most one AST walk per module.concise-code: authored src +93 −29 instrong-template-policy.jsplus +18 in the catalog; runtime +0 −0. The other src lines are generated JSON. No new files except the changeset, and no new exports. Alternatives considered:strong-mode.jspredeclareStatements. That adds a binding shape for a pattern that cannot run, since those entries are types-only, so I rejected it.createLexicalAnalysisscopes. That was about 15 more lines; the name match can never flag a list that isn't single-item, and only misses an alias whose name is reused elsewhere in the module, so I rejected it.Risk / follow-ups
.js/.mjsStrong modules are checked like.ts. Only the JSX dialect (.tsx/.jsx) is exempt, matching where descriptors are the intended lowering.import * as R from 'octane/jsx-runtime'; R.jsx(…)) is not flagged. Those entries are types-only, so such code cannot bundle anyway.OCTANE_STRONG_SINGLE_ITEM_FORdoes not follow a one-row list produced by a function call (rows(value)), alet, or an alias whose name appears anywhere else in the module. Those misses are deliberate, so the check never flags a real list..tsrxto compiled renderables (step 2), and gatingchildSlot's descriptor path behind a creator-installed driver (step 3, after Runtime vision: render computes, commit writes — one compiled commit model #2043/perf(octane): render computes, commit writes — runtime size redesign (#2043) #2044).Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Adds Strong compile errors that can break builds for
.tsrx/plain Strong modules using descriptor APIs or one-item@forremount tricks; no runtime change for code that already compiles.Overview
Strong mode gains two new compile-time errors (minor
octanerelease), with catalog/docs/rules synced and tests/fixtures updated so existing Strong suites keep passing.OCTANE_STRONG_ELEMENT_APIapplies to Strong modules that are not.tsx/.jsx(e.g..tsrx, plain.ts). It rejects imports or namespace use of descriptor builders/inspectors fromoctane(createElement,cloneElement,isValidElement,Children,descriptorChildren) and ofjsx/jsxs/jsxDEV/Fragmentfrom Octane JSX runtime entrypoints. Type-only imports, shadowed names, and Strong.tsx/.jsxstay allowed.OCTANE_STRONG_SINGLE_ITEM_FORflags@forover a one-element array literal (or a module-uniqueconstone-item alias only used as a loop iterable)—patterns often used for keyed remounts instead of<Fragment key={…}>or direct rendering.Implementation lives in
strong-template-policy.js(sharednamespaceAccess,@for/ alias analysis infinish()). Valid programs still compile to the same output; only new diagnostics and doc/generated JSON churn.Reviewed by Cursor Bugbot for commit 91813bd. Bugbot is set up for automated code reviews on this repo. Configure here.