Repository navigation
Inline hook-memo tier: de-callback useMemo/useCallback + parallel-use creations, memoize use()-fed promise chains - #208
Merged
Merged
Conversation
… creations, memoize use()-fed promise chains Production client compiles lower the hook memo tier from runtime-callback form to inline caches (docs/decallback-memo.md): - Authored/auto-generated `const x = useMemo/useCallback(fn, deps)` declarations become inline regions over a per-body flat cell array (`__s.slots._k$N`): zero allocations on a dependency hit, Object.is compares, closures only on a miss, labeled-break early returns, immediate publish so promise identity survives suspend-replay and a throwing factory keeps the previous entry. - Pass A parallel-use creations lower to an arity-specialized puTake0..4/puPub/puMiss runtime ABI that preserves every warm-plan semantic (Symbol-slot hooks-map entries, adoption, episode stamping, activeMemoMatch dedup) while eliminating the per-render arrow + deps-array allocations; fully-lowered modules carry no dead _$useMemo import. - New Pass A′ (client AND SSR pipelines): local const promise chains that transitively feed a use() argument are memoized at their declarations, so the natural `const p = fetchUser(id); const t = p.then(…); use(t)` shape no longer refetches per replay or re-render, and the chain head joins the __warm prefetch plan. Member deps rooted at body-locals coarsen to the local's identity (`p.then` is Promise.prototype.then — identical across promises — and would pin a derived chain stale forever). Dev/HMR/profile, server, universal units, and ineligible shapes keep the runtime forms; `inlineHookMemo: false` is a diagnostic escape hatch. Behavioral equivalence is proven by running the new inline-hook-memo / use-chain-memo suites under both vitest projects (runtime path vs inline path, identical expectations); the chain tests fail 8/8 with Pass A′ disabled. Full suite 12,006 tests green; memo-wall improves 1-4%; codegen-size +2% gz(min) (inline-region expansion); bundle-size and async-composition/waterfall ratio guards pass. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…y consts Bugbot finding on #208: collectUseArgumentRoots resolved each use() argument's free identifiers against an empty bound set while walking into nested functions and directive arms, so a shadowing inner binding (a @for item, a nested arrow param/local) seeded its NAME and an unrelated same-named body const could be wrongly memoized — freezing a creation the component expects to re-run every render. The seed scan is now scope-aware: names bound by any scope the candidate collector cannot reach are bound out before seeding — nested function params + internal declarations, loop bindings (including JSXForExpression item/index, scoping key + body but not the iterable or @empty arm), catch params, and every block's declarations inside the render tree (arm consts are never setup candidates). JSX reached at a setup value position flips into render-tree binding rules. Over-binding is the safe direction: a dropped seed leaves that chain unmemoized — exactly today's behavior. Pinned behaviorally (ShadowedLoopHost: a @for arm's use(item.promise) must not stop the body's `const item = build()` recreating per render) and probed in both directions (an outer const use()d from inside an arm still seeds). Full suite 12,010 tests green. Co-Authored-By: Claude Fable 5 <[email protected]>
…README, website docs, llms.txt) The user-observable half of the inline hook-memo tier deserves public documentation: promises created during render — including local .then chains feeding use() — are now a SUPPORTED authoring pattern (no cache() wrapper, stable across re-renders and suspense replays, refetching exactly when inputs change), and production useMemo/ useCallback compile to allocation-free inline caches. - website/differences-from-react: extends the parallel-use section with the chain example, the dependency-keying story, and the React / React Compiler contrast. - README "At a glance": inline-cache note on the hook-API bullet plus a "Promises in render are safe" bullet. - llms.txt: agent-facing directives — don't add cache(), don't hoist fetches to effects, don't hand-restructure waterfalls; plus the transparent inline-cache note under dependency-taking hooks. Website tests (mdx compile + e2e) and the react-parity audit pass. Co-Authored-By: Claude Fable 5 <[email protected]>
…ainting Two Bugbot findings on #208: - collectCandidates/rewriteStatements only entered IfStatement alternates that were blocks, so chain consts in `else if` arms were never memoized (recreating every render and replay — the hole the pass exists to close). Both walkers now recurse IfStatement alternates with the guard chain extended (!outerTest, innerTest), matching the lowering pass's existing else-if handling. - Tainting is name-based, and setup-level if/block declarations are legitimate candidates, so `use(x)` against an inner `const x` also tainted an unrelated outer `const x` — freezing a creation that must recreate per render (the same failure mode as the @for shadowing fix, through setup scopes). Any name declared more than once in the walked setup region, or colliding with a component param, is now excluded from tainting and memoization entirely: which binding a seed means is unknowable by name, and exclusion is never staler than today's recreate-per-render behavior. Shadowed names don't cascade taint either; a downstream unique-named link still memoizes, coarsening its dep to the in-scope local's identity. Behaviorally pinned: BranchChainHost (else-if chain fetches once across the suspend replay) and SetupShadowHost (a setup-block shadow must not stop the outer `const item = build()` recreating). Full suite 12,014 tests green. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 06ca22d. Configure here.
mrdiyorbek-juraev
added a commit
to mrdiyorbek-juraev/octane
that referenced
this pull request
Jul 21, 2026
Brings in 5 upstream commits: the safe inline-script content contract (octanejs#215), the tanstack.com shell port (octanejs#214), the TSRX directive arm output docs (octanejs#213), the inline hook-memo tier (octanejs#208), and the website menu / scroll-spy work (octanejs#209). Upstream added three bindings (tanstack-router-ssr-query, tanstack-hotkeys, tanstack-pacer), taking the table to 39. Six conflicts, all resolved as unions so neither side lost content: - website/src/content/bindings.json — @octanejs/cmdk listed alongside upstream's three new bindings; the "UI and interaction" description keeps command menus and gains keyboard shortcuts and event pacing. - website/public/llms.txt — same union in prose form. - docs/bindings-status.md, docs/packages.md, docs/binding-parity-gaps.md and the evals user-apps-v1 manifest are generated, so they were taken from upstream and regenerated (39 bindings, 48 publishable packages, 0 parity pins, 19 eval tasks). packages/cmdk is byte-identical to its pre-merge state; upstream's compiler changes do not perturb it. Verified: 32/32 cmdk and cmdk-ssr tests including both differential parity checks against [email protected], tsrx-tsc and tsgo clean, prettier clean, and all five freshness gates current. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This branch was previously deployed
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.

What
Production client compiles lower the hook memo tier from runtime-callback form to inline caches, and a new taint pass closes the use()-fed promise-chain hole. Design doc:
docs/decallback-memo.md.1. Authored/auto-generated
useMemo/useCallback→ inline cell regions.const x = useMemo(fn, deps)declarations in proven render-scope bodies compile to inline regions over a per-body flat cell array (__s.slots._k$N— a named expando, so the slots array keeps its packed elements kind). Zero allocations on a dependency hit (no factory closure, no deps array, no hooks-map lookup),Object.iscompares (React NaN/±0 parity), closures allocated only on a miss, block bodies inlined with labeled-break early returns, explicit-nulldeps evaluated inline with no cache. Cells publish immediately (unlike autoMemo's transactional cache), value-before-deps, so promise identity survives suspend-replay and a throwing factory leaves the previous entry fully usable.2. Parallel-
use()creations → closure-freepuTake/puPubABI. Pass A creations keep their Symbol-slotscope.hooksentries — warm adoption,activeMemoMatchdedup, and episode stamping are preserved exactly — but the per-render arrow + deps-array allocations are gone (arity-specializedpuTake0..4, deps array built only on cold branches).__warmplans keep their closure form (suspension-only). Fully-lowered modules carry no dead_$useMemoimport.3. Pass A′ — use()-fed const chain memoization (client AND SSR). The natural authoring shape
previously memoized nothing (trivial identifier argument): every render and every suspend-replay re-ran
fetchUser— the replay leniency drops the fresh promise but the duplicate request already fired — and the chain was invisible to__warm. A taint pre-pass marks local consts transitively feeding anyuse()argument and memoizes each creation-bearing taintedconstat its declaration with the same slot-keyed machinery as Pass A. Each link keys on its real inputs (userPromise→[fetchUser, id], warmable;thumbnailPromise→[userPromise]).Dev/HMR/profile, server, universal units, custom-hook-context bodies, and ineligible shapes keep the runtime forms.
inlineHookMemo: falseis a diagnostic escape hatch (likeautoMemo: false).Review findings that shaped the implementation
.thenmember-dep trap: the one-level member-path dep policy would give a derived chain depuserPromise.then—Promise.prototype.then, identical across every promise — pinning it permanently stale when its upstream changes. Member deps rooted at any body-local binding now coarsen to the local's identity; params keep precise paths (props.id). Behaviorally pinned via a reassigned-letupstream fixture._$useMemoimport registration is an explicit per-pipeline flag; universal stays eager and on runtime forms.Validation
octane-prodproject (the inline branch's coverage) and SSR/hydration/differential suites.pnpm typecheck,pnpm format:checkclean.fetchUserand onethumbnail()call across mount + both replay waves). The chain tests fail 8/8 with Pass A′ disabled.Residual risk / follow-ups
letchains (unsound to taint — covered by a test proving they're never staler than today) and arm-scoped consts.puMemowrapping + coarsened deps); no SSR behavioral rig exists for it yet beyond the existing ssr-parallel-use suites.fetchUserfrom deps; we conservatively keep them).🤖 Generated with Claude Code
Note
High Risk
Large compiler/runtime changes to hooks, Suspense memoization, and warm-plan behavior; subtle stale-data risk around dependency coarsening and suspend-replay is mitigated by dual-project tests but SSR chain behavior is mostly codegen-pinned.
Overview
Production client compiles add an inline hook-memo tier (
docs/decallback-memo.md): eligibleuseMemo/useCallbackdeclarations become flat_k$Ncell regions on__s.slots(dependency hits avoid factory closures, deps arrays, and hook-map lookups), while parallel-use()Pass A sites lower topuTake0–4/puPubso Symbol slots stay warm-visible without per-render memo closures. Dev/HMR/profile, server, universal units, and declined shapes keep runtime hooks;inlineHookMemo: falsebisects the new path.Pass A′ runs before parallel Pass A on client and SSR: a taint pass memoizes setup
constcreations that feeduse()(including.thenchains), with member deps on body locals coarsened to promise identity so derived links do not pin onPromise.prototype.then. Chain heads join__warm; shadowed/param-colliding names are excluded. Parallel Pass B gains betterelse if/ bracelessuse()arm handling.New
puMiss/puTake*/puPubruntime ABI mirrorsuseMemowarm semantics on cache hits. Docs, README, and agent rules document promise-in-render and inline memo behavior; behavioral tests run under bothoctaneandoctane-prod.Reviewed by Cursor Bugbot for commit 788145d. Bugbot is set up for automated code reviews on this repo. Configure here.