Skip to content

Extend Strong mode: read-side snapshot checks, silent-degradation escape hatches, and dev runtime enforcement #1027

Closed

Description

@trueadm

Summary

Track follow-up work that extends Strong mode so it closes the escape hatches agents and LLMs reach for most often. Originally assessed against main @ 621147d01 on 2026-09-10; progress below was verified against upstream main @ 8a4a2e087 on 2026-09-21 using merged PRs and the current compiler, regression tests, docs, scaffold, editor, and eval sources.

Progress as of 2026-09-21

All compiler diagnostic categories in A and B have landed. Twelve checklist entries are complete; the manual-memo prerequisite and the blanket list/index-key proposal have narrower implementations and remain marked partial below. Section C remains open, with docs/MCP updates landed but the website diagnostic catalog incomplete.

  • Ref reads: #1029 (merged 2026-09-10).
  • State getter calls: #1031 (merged 2026-09-10).
  • Mutable module-state reads: #1033 (merged 2026-09-10).
  • Ambient browser/global reads: #1036 (merged 2026-09-10).
  • Remaining compiler checks, trustHTML / TrustedHTML, dependency hints, and eligible hook-input caching: #1083 (merged 2026-09-14).
  • Follow-up analyzer scoping repair: #1040 (merged 2026-09-10).

Where Strong stands now. It is an opt-in, compiler-enforced render-snapshot contract with read-side checks as well as write-side checks. Errors are source-located in compiler/editor analysis. Equivalent explicit dependency arrays intentionally produce nonfatal redundancy hints. These are bounded static checks: supported aliases and known callbacks are followed, but opaque imported behavior, arbitrary mutable containers, and all asynchronous data flow are not proven. Strong still has no runtime phase guard or projection verification mode, and create-octane still does not enable it by default.

Accepted codegen change. #1083 intentionally changes emitted code for eligible Strong const object/array/callback hook inputs and normalizes proven built-in aliases and unshadowed undefined dependency placeholders. The original blanket requirement that valid Strong modules emit identical code is superseded by that landed contract. Compatibility behavior remains unchanged. See the shipped eligibility, migration, and type-checking contract.

Why this matters for agents. Render output must depend on immutable snapshots rather than live ref contents, scheduled state, mutable module state, or ambient browser values. Enforcement diagnostics are errors under Strong so an agent sees them through failed checks. Runtime coverage, structured fixes, defaults, and measured agent outcomes remain separate work in C.

A. Close the read side of the snapshot contract

  • Ref reads during render (OCTANE_STRONG_RENDER_REF_READ). Landed in #1029. Provable useRef.current reads during render are errors, including supported aliases and synchronous helpers. Passing ref identities as ref={ref} props and reading them in events, effects, cleanup, or deferred callbacks remains legal.
  • State getter called during render (OCTANE_STRONG_RENDER_STATE_GETTER_CALL). Landed in #1031. Calls to the third tuple member of useState, useReducer, or useLinkedState during render are errors, including supported tuple aliases. Render from the first tuple member; getter reads remain valid in deferred work.
  • Mutable module bindings read during render (OCTANE_STRONG_RENDER_MODULE_STATE_READ). Landed in #1033. Render reads of provably reassigned module-scope let/var bindings are errors. Use state, context, a subscribed snapshot, or an immutable prop instead. Unreassigned bindings and shadowed locals remain legal.
  • Ambient globals read during render (OCTANE_STRONG_RENDER_AMBIENT_READ). Landed in #1036. Known browser handles and nonstandard globalThis property reads during render are errors, including supported aliases and typeof guards. Shadowed names, standard language builtins, scalar snapshots captured at module initialization, and lazy state/reducer initializers remain legal. Lazy initialization still needs SSR-safe initial output; use useSyncExternalStore with a server snapshot for changing browser state.
  • Effects that fetch and set state (OCTANE_STRONG_EFFECT_DATA_FETCH). Landed in #1083. Known fetch-to-state effect continuations without returned cleanup are errors. Use use() or a query binding for render data, or return cleanup for external synchronization. Returning cleanup does not prove that stale results are actually cancelled or ignored.
  • Effect chains (OCTANE_STRONG_EFFECT_CHAIN). Landed in #1083. An effect reading state written by another effect's own execution or promise continuation in the same component is an error. External subscription/timer callbacks remain event-driven updates; nested component owners have separate effect graphs.
  • Unlinked prop state (OCTANE_STRONG_UNLINKED_PROP_STATE). Landed in #1083. Eager prop-derived useState and two-argument useReducer initializers are errors. Use useLinkedState(source, reconcile) to follow the source, or a lazy state initializer / explicit third reducer initializer for deliberate initial capture. The check does not generally propagate component prop intent through helper or custom-hook arguments.

B. Remove silent-degradation escape hatches

  • Explicit dependency arrays (OCTANE_STRONG_EXPLICIT_DEPENDENCIES). Landed in #1083. A built-in hook dependency argument that differs from inference, or cannot be proven equivalent, is an error. Equivalent arrays preserve authored behavior and produce labeled, nonfatal hints in compiler, editor, bundler, and CLI output. Effect Events remain excluded; unshadowed undefined receives inferred tracking. Callback-observable argument order and duplicates are respected.
  • null dependencies (OCTANE_STRONG_UNTRACKED_EFFECT). Landed in #1083. Known built-in dependency hooks reject null under Strong; omit the argument for inferred tracking. Compatibility mode retains run-every-render behavior.
  • Manual useMemo / useCallback — partial against the original prerequisite (OCTANE_STRONG_MANUAL_MEMO). The diagnostic and eligible hook-input caching landed in #1083: both hooks are errors, and eligible const object/array/callback inputs gain stable identities until inferred inputs change. The landed cache pass deliberately excludes arbitrary calls, constructors, tagged templates, spreads, opaque imported custom-hook inputs, unknown helper escapes, and unsupported nested/manual-slot cases. The original requirement to cover every identity shape previously requiring manual memoization is therefore not established. Reconcile that prerequisite with the shipped bounded eligibility contract, or retain it as further caching work.
  • .map returning JSX, and index keys — partial against the original blanket proposal (OCTANE_STRONG_MAP_JSX, OCTANE_STRONG_INDEX_KEY). #1083 rejects JSX-returning .map() in .tsrx and position-derived @for keys, while allowing item-ID lookups such as items[index].id. Standard keyed .tsx/.jsx mapping intentionally remains valid, and a general map-callback-index key check did not land. Reconcile the original cross-dialect requirement with this accepted .tsrx policy, or track broader index-key enforcement separately.
  • Suppression props (OCTANE_STRONG_SUPPRESSION_PROP). Landed in #1083. DOM intrinsic suppressHydrationWarning and suppressNativeChangeWarning props, including statically visible spreads, are errors. Native text OCTANE_NATIVE_TEXT_ONCHANGE is promoted to an error in Strong; use onInput for per-edit changes. Component props and native checkbox/radio/select onChange semantics remain valid. Dynamic spreads/input types may still require the existing development diagnostic.
  • dangerouslySetInnerHTML requires a branded value (OCTANE_STRONG_UNTRUSTED_HTML). Landed in #1083 through public trustHTML / TrustedHTML, compiler rejection of visibly raw DOM values, and nominal Strong JSX types. Strong .tsrx selects those types automatically; plain .tsx needs jsxImportSource: "octane/strong" or its pragma. Imported/dynamic values require typechecking as well as compilation. trustHTML marks an explicit trust decision; it does not sanitize HTML.
  • Imperative compatibility exports (OCTANE_STRONG_COMPAT_IMPORT). Landed in #1083. Value imports and known namespace accesses for flushSync, unstable_batchedUpdates, and StrictMode from Octane are errors, including supported aliases and the octane/server entrypoint. Use normal Octane scheduling and component semantics.

C. Enforcement, fix-its, defaults, and measurement

  • Dev-only runtime phase guard for Strong components. docs/strict-state-plan.md proposed it and it did not ship, so Strong is purely static and the docs admit unknown call shapes do not fall back. Have the compiler stamp Strong components (a static marker on the component body, in the same spirit as $$singleRoot), and have the dev runtime throw on a state update, ref.current write, or getter call while a Strong render or synchronous effect setup is on the stack. Throwing fails the agent's test run, where a static check only sees code the analyzer understands. Must be zero-cost in production and must not add work to non-Strong components; follow .rulesync/rules/core-engineering.md for hot-path evidence.
  • Strong verification mode. Octane rejects StrictMode double-invoke as a React feature, but a dev-only, opt-in mode that re-evaluates eligible Strong projections and asserts Object.is-equal results is a different thing: it verifies the purity assertion that production memoization trusts, and catches the live-accessor-behind-stable-inputs case the docs currently handle with prose. Scope, cost, and the reporting channel need a design note before implementation.
  • Structured fix-its on every Strong diagnostic. Human-readable suggestions and compiler/editor diagnostics are present, but the source-range/replacement edit contract and Volar code actions have not landed. Give every existing and new Strong code at least one suggestion with a source range and replacement text, surface it through Volar as a code action, and document the shape so agents can apply it verbatim. The error message is the documentation the agent actually reads.
  • Default-on in create-octane. The scaffold does not mention Strong today. Containment is already solved because dependencies stay in compatibility mode unless they opt in, so the blast radius of a default is the application's own source. Enable compiler.strong in generated octane.config.ts and in the website's getting-started path once section A and B items have landed and the eval family below is green.
  • Eval coverage in @octanejs/evals. Add Strong tasks to datasets/train/user-apps-v1 (or a new family) that target each new diagnostic's failure mode, so every code is checked against the behavior it claims to prevent. Behavioral claims about agent outcomes are not accepted without measurement in this repo.
  • Docs and catalog — partial. Strong sections in docs/tsrx-basics.md and docs/differences-from-react.md, the new docs/strong-compiler-checks.md reference, and MCP react-divergences.md guidance landed with #1029, #1031, #1033, #1036, and #1083. The website build-tools guide includes the read-side checks, but its error catalog still covers numeric runtime errors rather than OCTANE_STRONG_* diagnostics, and website/public/llms.txt still lists the older write-side set. Finish the Strong diagnostic catalog and bring the website/LLM reference into parity with the newly landed checks.

D. Close the nearest workaround for each rule

A probe on 2026-09-30 compiled 65 common agent patterns with "use strong" against main @ 85cb387fe. Strong rejected 12 of them. Most of the rest were one-line rewrites of patterns Strong already rejects. An agent that hits a Strong error makes the smallest edit that silences it, for example useEffect(() => { startTransition(() => setX(v)); }), or returning () => {} to satisfy the fetch check. So each diagnostic should ship with its nearest workarounds also rejected, and each new rule's fixtures should include the likely rewrite. Status below was checked on 2026-10-01.

Effects

State

Render and DOM

Tooling

  • Strong repair eval family in @octanejs/evals. Landed in feat(evals): add the Strong mode repair task family #1493. This partially addresses "Eval coverage" in C.
    • An agent receives failing code and its Strong error. The run is graded on whether the fix compiles and whether the bug is actually gone.
    • Rewrites that compile but keep the bug become compiler fixtures. This is how the next round of workarounds should be found.
  • Strong coverage ratchet (OCTANE_STRONG_COVERAGE_REGRESSION, OCTANE_STRONG_COVERAGE_STALE). feat(cli): fail CI when a module stops compiling under Strong mode #1515.
    • The cheapest way around Strong is leaving it: deleting "use strong", turning compiler.strong off, or moving code into another package.
    • octane analyze --strong-baseline init records today's non-Strong modules in a checked-in octane-strong-baseline.json. While it exists, every octane analyze run fails on a module that is neither Strong nor listed, and on a listed name that is now Strong or gone.
    • --strong-baseline update only removes names, so a new exception is always a reviewed edit to the file.
    • Which modules are Strong is decided by the compiler's new strongModuleStatus, the same decision transform makes.
    • Also fixes octane analyze ignoring compiler.strong from octane.config.ts.
    • Limitation: a bundler plugin's inline strong option is not visible to the CLI.

Deliberately not pursued

  • Rejecting use(fetch(...)). The compiler memoizes use() creations per call site, so this is valid Octane.
  • Rules keyed on names such as onChange or subscribe. Naming heuristics stay a non-goal.
  • General lint such as empty catch blocks or @ts-ignore. These belong in a linter, not the framework contract.
  • Treating requestAnimationFrame deferral as synchronous. The enter-animation pattern is legitimate.

Non-goals

  • Do not reintroduce Rules of Hooks or naming heuristics. The docs are explicit that use* spelling is not a purity oracle; that is what keeps Strong honest.
  • Enforcement diagnostics are errors under Strong. Equivalent explicit dependency arrays intentionally produce nonfatal redundancy hints, as landed in feat: complete remaining Strong compiler checks #1083.
  • Do not change compatibility-mode behavior. Every item is gated on "use strong" or compiler.strong.
  • Strong opt-in may change generated code for the landed caching and dependency-normalization contract. Preserve compatibility semantics, and require identity/invalidation evidence for new caches. Diagnostic-only fixtures should continue to pin unchanged client/server output.

Evidence required per PR

  • Positive and negative fixtures in strong-mode.test.ts, including shadowed names, aliases, namespace imports, optional chains, and plain .ts/.tsx custom-hook modules, matching the existing test matrix.
  • Volar diagnostics parity with source-located errors.
  • Compatibility behavior preserved; unchanged client/server output for diagnostic-only fixtures, with separate behavior and byte-cost evidence for intentional Strong caching/codegen changes.
  • Compiler throughput check for the analyzer additions; section C runtime work also needs the standard render/mount benchmark evidence.

Activity

  1. added
    enhancement
    agent-authored
    on Sep 10, 2026
  2. domgan-oai commented on Sep 21, 2026

    @domgan-oai
    Contributor

    Updated the issue body and checklist against upstream main @ 8a4a2e087 (2026-09-21).

    Landed PRs: #1029, #1031, #1033, #1036, and #1083, plus the analyzer scoping follow-up #1040.

    Twelve entries are now checked off. All A/B diagnostic categories have landed, with two entries kept partial against the original broader requirements: universal manual-memo replacement coverage and cross-dialect map/index-key enforcement. Docs and MCP guidance have also landed; the website Strong diagnostic catalog and LLM reference remain partial.

    The five outstanding C items are runtime phase enforcement, projection verification, structured fix-its/Volar actions, default-on scaffolding, and Strong eval coverage. The body also now records #1083's intentional Strong caching/codegen changes instead of the original blanket output-parity assumption.

    This update was prepared and posted by Codex at Dominic's request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authoreddxenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions