Skip to content

fix: memoize snapshot method calls in Strong mode - #862

Merged
domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-846-template-call-memoization
Aug 26, 2026
Merged

domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-846-template-call-memoization

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Allow statically named receiver methods to participate in production DOM memoization when a module opts into Strong mode's immutable snapshot and pure render contract. Keep compatibility, development, profiling, server, and universal paths conservative.
  • Retain fallbacks for visible hooks, live refs and state getters, callback hazards, and opaque globals. Add bounded Strong diagnostics for detectable state snapshot mutations and nondeterministic render calls.
  • Add list, callback, ref, hook, calculation, and hydration regression cases; deterministic method-call benchmark controls; documentation; and an Octane patch changeset.

Addresses #846. The reported remove callback captures the entire current list, so replacing that list must still refresh surviving rows' handlers. This change does not promise that every original row body can be skipped in that example.

Validation

Intentionally opened as an unvalidated draft, as requested. This is not ready to merge.

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • Targeted for.test.ts and compiler/strong-mode.test.ts suites in the applicable development and production projects
  • node benchmarks/bench.mjs --ratios template-call-memo
  • Complete pnpm sync

Dependency installation was blocked by the configured registry's security policy for @tsrx/[email protected] and @tsrx/[email protected]. Test and typecheck attempts did not reach execution; the benchmark could not start with the incomplete dependency tree. No test, typecheck, formatting, benchmark, or CI success is claimed.

The required sync was attempted without triggering another dependency download. It reached cli:data and stopped because prettier was unavailable. The generators that ran produced no additional Git diff.

Earlier static checks passed: node --check on the two modified compiler JavaScript files and the benchmark runners, plus git diff --check. These establish syntax and whitespace only, not behavioral correctness or performance.

Risk / follow-ups

  • Install approved dependencies, complete sync and formatting, run the relevant correctness suites and baseline/candidate benchmarks, and obtain green current-head CI before marking ready.
  • Strong mode's method purity and immutable snapshot contract is an opt-in assertion; diagnostics do not prove whole-program purity.
  • Conservative name-based alias handling and retained state tuple fallbacks may decline otherwise safe optimizations.
  • No measured performance improvement is claimed. The new regression cases and benchmark guards remain unexecuted.

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

Medium Risk
Changes production memoization semantics for Strong modules and expand compiler purity rules; incorrect alias or capture analysis could cause stale UI, though compatibility mode and conservative fallbacks limit blast radius.

Overview
Strong mode now treats opted-in modules as an immutable render-snapshot contract: production client builds can memoize statically named receiver calls (e.g. row.read(suffix)) and reuse keyed list rows when inputs and captures are unchanged. Compatibility mode still treats member calls as live and does not apply this fast path.

The compiler adds bounded Strong diagnostics for provable state-snapshot mutations (OCTANE_STRONG_RENDER_SNAPSHOT_MUTATION) and direct clock/random reads during render (OCTANE_STRONG_RENDER_IMPURE_CALL), with hook/ref/callback guards so hooks, refs, opaque globals, and callback arguments stay conservative. Docs clarify that keys preserve DOM identity, console.log in rows does not block Strong reuse, and handlers that close over the parent list still force survivor updates.

A new template-call-memo benchmark (runner manifest, ratio baselines, MCP exposure) counts receiver invocations for Strong vs compatibility. Regression coverage spans list/capture/ref/hook scenarios, expanded strong-mode compiler tests, and Apollo useQuery rejecting Strong when it mutates snapshots.

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

@domgan-oai
domgan-oai marked this pull request as ready for review August 26, 2026 16:43
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Aug 26, 2026
fix: make PR 862 CI-ready and clarify Strong mode
@domgan-oai
domgan-oai merged commit 4a4996e into octanejs:main Aug 26, 2026
26 of 29 checks passed
@trueadm trueadm mentioned this pull request Aug 26, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants