Repository navigation
feat(lynx): put the block core on the real transport seam - #106
Conversation
The U2 slice proved what the specialized core emits and what it costs. It could not prove the wire would take it: every frame went to a fixture that was written to agree with the core. `core/block-root.ts` is the commit and event half of a background root. It owns a `LynxBlockCore`, turns one flush into one transported commit through the same `createLynxBackgroundTransport` `src/root.ts` builds, and routes an inbound native delivery back to the handler its mount bound. It is not `LynxRoot`: there is no `render(component, props)`, because there are no hook cells yet and therefore no program for a component to be. `selfCheckLynxBackgroundOutboundMessage` runs inside `transport.prepareBatch`, so a frame that would fault a real page now faults in a test instead. `LynxBlock` gains `firstListenerId`. The listener run is dense the way the host run is, so a block's own base is its row offset into the run's base — which is what lets a delivery be routed to the block that owns it without shipping a listener table across the wire. Two findings the slice produced, both recorded rather than worked around: - The transport root id space belongs to `universal-core.ts`'s module-private `NEXT_TRANSPORT_ROOT`, which it does not export, so a second core cannot mint a non-colliding identity. The id arrives as an option; minting from a second private counter would collide silently the first time both cores ran in one page. - A `mount-template-run` is one command outbound and `nodes.length * count` handle deltas inbound: the client container derives a transition per node per instance and refuses an acknowledgement that omits one. The compact acknowledgement is what makes the return leg proportional too, and the block core's frames qualify for it. Both halves are asserted. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
U1 §7 named this as the reason coexistence is per-root rather than per-build: the same logical state driven through the universal core and through the Block core, over the same transport and the same applier, must leave the same physical tree. Sharing the applier is what makes the comparison mean anything — fork it and byte-equality proves nothing about the core. Four states are compared: first mount, a scoped selection change, a keyed reorder, and an insert-and-remove in one reconcile. Both columns run `createLynxBackgroundTransport` against the same fake main thread and replay the accepted commits through `prepareLynxHostBatch`. Only the host ids inside a nodes-ref selector and the numeric half of an event token are normalized: the two cores are different allocators and never had to agree about a number. Perturbing one static prop on the block side fails all four, so the oracle bites. Two tests state what the wire already agrees about, so the slice cannot be read as claiming more than it shows. #102 attributed the update-path debt to the background drain, not the wire — `select@10k` reconciles 10,042 blueprints and emits ONE host command. Both cores send exactly one command for a scoped change on a 200-row list. Where they differ is the mount: the Block core's is one command for the whole dense run. The wire harness moves to `tests/_fixtures/fake-lynx-wire.ts` now that two suites drive it, and the allocator-identity normalizer moves to the PAPI fixture beside `shape()`. The ledger learns the create/insert vocabulary the universal core emits when main advertises no template capability. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
|
Result: No All 12 failures were re-run individually on an idle host and A/B'd against the stack's merge-base Full per-failure table and method: #105 (comment) Generated by Claude Code |
…ipline to the block root Review follow-ups on the transport seam: dispatchTransportEvent skipped the version check universal-core performs, so a delivery stamped against a superseded batch ran against post-commit state; and a throwing handler aborted the loop, dropping the remaining pre-validated deliveries — the partially-dispatched valid batch the pre-validation comment forbids. Events now refuse a version mismatch, and every delivery runs with errors aggregated, both pinned red-green in block-root.test.ts. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Summary
Issue #103 U2b. The U2 slice (#105) proved what the specialized core emits and
what it costs. It could not prove the wire would take it: every frame went to a
fixture written to agree with the core. This is that proof, plus the first
comparison between the two cores.
Stacked on #105 (U2) → #104 (U0) → #102 → #101 → #100 → #97.
Three things land:
core/block-root.ts— the commit and event half of a background root.It owns a
LynxBlockCore, turns one flush into one transported committhrough the same
createLynxBackgroundTransportthatsrc/root.tsbuilds,and routes an inbound native delivery back to the handler its mount bound.
selfCheckLynxBackgroundOutboundMessageruns insidetransport.prepareBatch,so a frame that would fault a real page now faults in a test instead.
tests/block-root.test.ts— 12 tests over that seam: commit round trip,scoped update, the empty flush that sends nothing, inbound event routing by
derived listener id, and the refusals (unknown listener, priority mismatch,
foreign root, released listener).
tests/block-core-differential.test.ts— the two cores painting the samepage. U1 §7 named this as the reason coexistence is per-root: the same
logical state through the universal core and through the Block core, over the
same transport and the same applier, must leave the same physical tree.
Why the differential test shares the applier
Fork the applier and byte-equality of the tree proves nothing about the core.
Both columns run
createLynxBackgroundTransportagainst the same fake mainthread and replay the accepted commits through
prepareLynxHostBatch; the onlydifference between them is which background core built the frames.
Four states are compared: first mount, a scoped selection change, a keyed
reorder, and an insert-and-remove in one reconcile. Only two things are
normalized — the host ids inside a nodes-ref selector, and the numeric half of a
native event token — because the two cores are different allocators and never
had to agree about a number. Root and generation survive, so a replaced
instance still fails the comparison.
The oracle bites: perturbing one static prop on the block side fails all four.
What the slice deliberately does not claim
Two tests exist to keep the result readable rather than to make it look better.
#102 attributed the update-path debt to the background drain, not the wire —
select@10kreconciles 10,042 blueprints and emits one host command. So:mount-template-runfor the whole dense run.A claim that this makes the wire cheaper on an update would be wrong, and the
test says so.
Two findings, recorded rather than worked around
universal-core.tsallocatesfrom a module-private
NEXT_TRANSPORT_ROOTit does not export, so a secondcore cannot mint a non-colliding identity.
createLynxBlockRoottakes the idas an option; minting from a second private counter would collide silently the
first time both cores ran in one page.
mount-template-runis one command outbound andnodes.length * counthandle deltas inbound. The client container derives a transition per node per
instance and refuses an acknowledgement that omits one. The compact
acknowledgement is what makes the return leg proportional too, and the Block
core's frames qualify for it — both halves are asserted.
Changes
packages/lynx/src/core/block-root.ts— new.packages/lynx/src/core/block-core.ts—LynxBlockgainsfirstListenerId.The listener run is dense the way the host run is, so a block's own base is its
row offset into the run's base, which is what lets a delivery reach the block
that owns it without shipping a listener table across the wire.
packages/lynx/tests/block-root.test.ts— new, 12 tests.packages/lynx/tests/block-core-differential.test.ts— new, 6 tests.packages/lynx/tests/_fixtures/fake-lynx-wire.ts— new. The main side of thewire, extracted once two suites needed it.
protocol.test.tskeeps its ownricher harness; this one stays small so a failure points at the core.
packages/lynx/tests/_fixtures/fake-element-papi.ts—withoutAllocatorIdentitymoves here beside
shape(), now that two suites normalize the same way.Validation
pnpm format:check— viapnpm format:filesover every changed pathpnpm typecheck:files— every changed path, cleanpnpm test— result in a follow-up commentvitest run --project lynx— 32 files / 423 tests, allpassing. The diff touches
packages/lynxonly.one static prop on the block side, so it is not passing vacuously.
Risk / follow-ups
packages/lynxdoes not export./core/*, so both newmodules are internal and no published behavior changes.
block-root.tsisreachable from neither
src/root.tsnorsrc/main-thread.ts, so the sourcegraph
runtime-compatibility.test.tspins is untouched.CreateLynxRootOptions, and that is the honest state.LynxRoot.render(component, props)is the only entry point a flag couldredirect, and the Block core has no component program to run — no hook cells,
no compiler output. A flag today would be a switch with nothing behind it. The
opt-in that does exist is already per-root: a root is constructed by
createLynxRootor bycreateLynxBlockRoot, never by a build flag.real slice; that needs the core driving the benchmark app's background, and it
is the next piece. U0's two open gates —
updateStorm@10ksitting on the wrongside, and
select@10krecovering less than its count predicts — stand exactlywhere U0 left them.
Provenance
agent-authored)Generated by Claude Code