Repository navigation
refactor(octane): move universal hook cells into the owner kernel - #1714
Merged
Merged
Conversation
Phase 2, slice 1 of #1055. The dedicated Lynx runtime will bind the same hook cells as the universal core, so their shapes and pure helpers move to packages/octane/src/owner-kernel/hooks.ts, the first module of the host-neutral owner kernel: - the state, linked-state, reducer, memo, ref, id, effect, and effect-event cell types; - the update-queue types; - depsEqual, isThenable, trackUniversalThenable, runEffectCreate, runEffectCleanup, and deactivateEffectEventCells. The kernel is stateless and imports nothing. Owner- and batch-shaped dependencies are type parameters, and universal-core re-aliases them under their existing names, so every call site is unchanged. Nothing that reads the current attempt, an owner record, or a scheduler moves here; those slices need a services interface. LinkedStatePrevious and LinkedStateOptions stay exported from the core, where Lynx imports them. The octane/internal/owner-kernel subpath waits for its first consumer outside this package. universal-hook-dependencies.test.ts pins what the moved helpers guarantee through public hooks: Object.is dependency equality, effects receiving their dependency values as arguments (the hoisted-callback ABI), and one cleanup per create. The Lynx inventory attributes the kernel to the universal runtime. Refs #1055 Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 4, 2026 15:54
Contributor
Benchmark report🟢 No budget breaches, 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)
50 other measured values are unchanged. Public-import reachability bundles (bytes)No changes across 105 measured values. |
This was referenced Oct 4, 2026
trueadm
added a commit
that referenced
this pull request
Oct 4, 2026
#1714 moved the universal hook cells into the owner kernel, which adds 8 raw bytes to the background program. run.mjs pins that size exactly, so the weekly lynx-bundle-size suite failed at 288,398 against the 288,390 that #1710 set. Budget value and comment only; the main-thread caps are unchanged. 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
This is Phase 2, slice 1 of #1055 (plan, §3.2 and §7; decision 3 in §10). It starts the host-neutral owner kernel. The universal core binds it today, and the dedicated Lynx runtime will bind the same hook cells later, so hook semantics have one source of truth instead of a second copy. The refactor is behavior-neutral.
What moves.
packages/octane/src/owner-kernel/hooks.tsis new. It is stateless, imports nothing, and has no renderer or host dependency.StateHook,LinkedStateHook,ReducerHook,MemoHook,RefHook(shared byuseRefanduseLazyRef),IdHook,EffectEventCell,EffectEventHook, andEffectHook<Owner>;UniversalHookUpdateQueue<Batch>andAppliedUniversalHookUpdates<Batch>;EffectPhaseandUniversalTrackedThenable.depsEqual,isThenable,trackUniversalThenable,runEffectCreate,runEffectCleanup, anddeactivateEffectEventCells. Each was copied from main verbatim.How the core binds it.
universal-core.tsimports the kernel and re-aliases its generic types under their existing names, such astype EffectHook = KernelEffectHook<UniversalOwnerRecord>. Every one of the existing call sites is unchanged. The core adds noexport *, so no kernel name reachesoctane/universal.What stays in the core. It stays until a services interface exists in later slices:
enqueueUniversalHookUpdate,applyUniversalHookUpdateQueue,collectEffectEventCells, and the owned effect runners;PARKED_UNIVERSAL_LINKED_DRAFTS,EMPTY_UNIVERSAL_TRANSITION_BATCHES, and the slot stack;LinkedStatePreviousandLinkedStateOptions, because@octanejs/lynximports them from the core.The
octane/internal/owner-kernelsubpath waits for its first importer outside this package, so this PR publishes no new surface.Prior art. The fork
Huxpro/octane:new-lynxhas a similar slice (universal-kernel.ts). It is out of date on main: itstrackUniversalThenablewould overwrite a foreign thenable status such as router-core's'resolved', whichuniversal-settled-wakeable.test.tspins. That is why everything here was copied from main rather than from the fork.Refs #1055
Tests
packages/octane/tests/universal-hook-dependencies.test.tspins, through public universal hooks, what the moved helpers guarantee. No existing universal test covered these:useMemorecomputes only on anObject.ischange.NaNstays equal,+0→−0recomputes, a length change recomputes, andnulldeps recompute every render.Each test was seen to fail against a deliberately broken kernel:
===instead ofObject.is, effects called without arguments, and a dropped cleanup.Bundle evidence
node benchmarks/bench.mjs --ratios three-bundle-size lynx-bundle-size, base77504c160cagainst this change, same machine:k,O), which shifts a few later names to two characters.backgroundRawpin: ci(bench): reset the Lynx main-thread caps and background pin for #1700 #1710 re-pins it at 288,390. These +8 bytes need their own budget-only re-pin after both PRs land, and I'll open it.Validation
vitest run --project octane --project octane-prod packages/octane/tests/universal-hook-dependencies.test.ts: 6 passed.pnpm typecheck:filesonuniversal-core.ts,owner-kernel/hooks.ts, and the new test.pnpm format:files:checkon every changed file, andpnpm sync.pnpm format:check,pnpm typecheck, andpnpm testwere not run locally.Risk / follow-ups
dist/anddist/nodeeach get their own copy of the module, which is safe because the module holds no state.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Behavior-neutral refactor: verbatim extraction of stateless types and pure functions with new tests; no auth, scheduling, or public API changes beyond internal module layout.
Overview
Starts the host-neutral owner kernel (#1055) by moving shared hook cell types, update-queue shapes, and six pure helpers (
depsEqual,isThenable,trackUniversalThenable, effect create/cleanup, effect-event deactivation) into newpackages/octane/src/owner-kernel/hooks.ts.universal-core.tsdrops the inlined copies and binds the kernel via type aliases (e.g.EffectHook = KernelEffectHook<UniversalOwnerRecord>); scheduling, owner reads, and linked-state parking stay in the core unchanged.Adds
universal-hook-dependencies.test.tsto lock memoObject.isdeps, effect callbacks receiving dep values as arguments, and one cleanup per create. Lynx bundle inventory attributesowner-kernel/modules touniversal-runtimelikeuniversal-core.Reviewed by Cursor Bugbot for commit 4124ca0. Bugbot is set up for automated code reviews on this repo. Configure here.