Skip to content

feat(lynx): put the block core on the real transport seam - #106

Merged
Huxpro merged 4 commits into
new-lynxfrom
feat/lynx-block-root
Aug 20, 2026
Merged

Huxpro merged 4 commits into
new-lynxfrom
feat/lynx-block-root

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 20, 2026

Copy link
Copy Markdown
Owner

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:

  1. core/block-root.ts — the commit and event half of a background root.
    It owns a LynxBlockCore, turns one flush into one transported commit
    through the same createLynxBackgroundTransport that src/root.ts builds,
    and routes an inbound native delivery back to the handler its mount bound.
    selfCheckLynxBackgroundOutboundMessage runs inside transport.prepareBatch,
    so a frame that would fault a real page now faults in a test instead.

  2. 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).

  3. tests/block-core-differential.test.ts — the two cores painting the same
    page. 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 createLynxBackgroundTransport against the same fake main
thread and replay the accepted commits through prepareLynxHostBatch; the only
difference 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@10k reconciles 10,042 blueprints and emits one host command. So:

  • both cores send exactly one command for a scoped change on a 200-row list;
  • where they differ is the mount, where the Block core's is one
    mount-template-run for 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

  • The transport root id space is not shared. universal-core.ts allocates
    from a module-private NEXT_TRANSPORT_ROOT it does not export, so a second
    core cannot mint a non-colliding identity. createLynxBlockRoot takes the id
    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.

Changes

  • packages/lynx/src/core/block-root.ts — new.
  • packages/lynx/src/core/block-core.ts — 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 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 the
    wire, extracted once two suites needed it. protocol.test.ts keeps its own
    richer harness; this one stays small so a failure points at the core.
  • packages/lynx/tests/_fixtures/fake-element-papi.ts — withoutAllocatorIdentity
    moves here beside shape(), now that two suites normalize the same way.

Validation

  • pnpm format:check — via pnpm format:files over every changed path
  • pnpm typecheck:files — every changed path, clean
  • pnpm test — result in a follow-up comment
  • targeted tests: vitest run --project lynx — 32 files / 423 tests, all
    passing
    . The diff touches packages/lynx only.
  • negative check: the differential comparison was made to fail by changing
    one static prop on the block side, so it is not passing vacuously.

Risk / follow-ups

  • No changeset. packages/lynx does not export ./core/*, so both new
    modules are internal and no published behavior changes. block-root.ts is
    reachable from neither src/root.ts nor src/main-thread.ts, so the source
    graph runtime-compatibility.test.ts pins is untouched.
  • No flag on CreateLynxRootOptions, and that is the honest state.
    LynxRoot.render(component, props) is the only entry point a flag could
    redirect, 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
    createLynxRoot or by createLynxBlockRoot, never by a build flag.
  • Still no milliseconds. Lynx specialized background core: the Block model over the wire (#58 L2 body, post-attribution direction) #103 §5's U2 asks for the U0 harness re-run on the
    real slice; that needs the core driving the benchmark app's background, and it
    is the next piece. U0's two open gates — updateStorm@10k sitting on the wrong
    side, and select@10k recovering less than its count predicts — stand exactly
    where U0 left them.

Provenance

  • An agent produced this diff (agent-authored)

Generated by Claude Code

Huxpro and others added 2 commits August 20, 2026 05:32
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

Huxpro commented Aug 20, 2026

Copy link
Copy Markdown
Owner Author

pnpm test — full run, complete. This is the result promised by the unticked pnpm test box in the body.

Result: Test Files 12 failed | 2184 passed (2196), Tests 6 failed | 20954 passed | 75 skipped (21035), 1 unhandled error. Start 06:09:53, duration 3888 s. Ran on a clean tree at 781e4fca3, the tip of this stack, so it covers this PR's head (af3349627) plus the branch above it.

No lynx project failure — the project this stack changes.

All 12 failures were re-run individually on an idle host and A/B'd against the stack's merge-base 5d6172478 (unmodified new-lynx). Two are pre-existing at the merge-base (octane-events-browser suspense-hydration selection restore; rspeedy-plugin native-demo, already documented in #66 §2.3); the rest are container-speed timeouts or an outbound-network fetch. Nothing is attributable to this stack, which touches only packages/lynx/** plus the lynx compiler target.

Full per-failure table and method: #105 (comment)


Generated by Claude Code

Huxpro and others added 2 commits August 20, 2026 17:25
…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
@Huxpro
Huxpro changed the base branch from feat/lynx-block-core to new-lynx August 20, 2026 17:56
@Huxpro
Huxpro marked this pull request as ready for review August 20, 2026 17:56
@Huxpro
Huxpro merged commit 5116432 into new-lynx Aug 20, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant