Repository navigation
feat(lynx): carry main-thread props on a template run - #121
Merged
Merged
Conversation
A keyed list with a `main-thread:` handler lost its template program and fell back to a create per host — one worklet prop anywhere on the row cost the whole list, and the excess grew with the list while the plain path stayed at one command at any scale. A template-run or template-range per-instance value may now be a renderer-namespaced descriptor, and only when the program binds that slot to a `main-thread:` prop name. Everywhere else values stay scalar. The scalar rule this appears to bend is a rule about update frames: a structured value would have to be walked to be checked, which is the recursive cost the delta format exists to delete. A mount payload is walked once per instance either way, so accepting the descriptor here costs the same validation the `create` command already pays, minus the commands. Naming the slots in the program is what keeps header-only validation sound — the shape is decided once when the program is prepared and cached with it, so a slot bound to `class` that arrives carrying an object is still the error it always was. Installation goes through the existing prop-patch planner, so activation lifetime, ref-owner uniqueness and fault invalidation are the paths that already existed. Two refusals move earlier, to program-prepare time, since a program states both statically: a main-thread binding on raw text, and a main-thread event on a channel the program's own event sites already own. Template mounts also stop hardcoding `interactive: false`. Worklet lifetime is owned by connectivity, not insertion order, and a template mount inserts its own root — so the answer is the parent's, computed once per run. The block core compares a worklet slot structurally rather than by identity: the compiler rebuilds the descriptor every render, so an identity-only compare would re-send an unchanged handler forever. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Aug 20, 2026
Merged
Huxpro
marked this pull request as ready for review
August 21, 2026 21:03
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
#103 U4a. A Lynx template run can now carry
main-thread:props, so the Blockcore can express a worklet: a keyed list with a handler mounts in one
mount-template-runinstead of losing its template program and falling back toa create per host.
The measurement that opened U4 (posted on #103, real compiler, real transport,
template runs negotiated, keyed list of
view.row > text.col > #text):main-thread:bindtap, no capturesmain-thread:bindtapcapturing the rowmain-thread:refOne main-thread prop anywhere on a keyed row costs the whole list its template
program, and the excess grows with the list. This lands the half of that the
Block core owns; the compiler and universal-core refusals that make the
shipping path pay 6,002 are U4b, stacked next.
The change, in one sentence: a template-run or template-range per-instance
value may be a renderer-namespaced descriptor, and only when the program binds
that slot to a
main-thread:prop name. Everywhere else values stay scalar andevery existing check stays exactly as it was.
The scalar rule it appears to bend is a rule about update frames — a
structured value would have to be walked to be checked, which is the recursive
cost the delta format exists to delete. A mount payload is walked once per
instance either way: accepting the descriptor here costs the same
assertLynxWorkletValuethecreatecommand pays today, minus 6,000 commands.v2
SETstays scalar-only, and the update path needed no protocol change at allbecause
updatealready accepts main-thread props.Naming the slots in the program is what keeps header-only validation sound: the
shape is decided once when the program is prepared and cached with it, so a slot
bound to
classthat arrives carrying an object is still the error it alwayswas, reported in the same words.
Changes
octane:UniversalHostTemplateProgramValueadmits a renderer-namespacedopaque value. The core forwards it without interpreting it and the renderer's
driver validates it; the core's own program derivation still produces scalars
only, which is why
isUniversalHostTemplateProgramValueis unchanged.@octanejs/lynxprotocol.ts: the validated program records which slots amain-thread:binding owns. A non-scalar on such a slot is walked byassertWireValue— the same validator acreatecommand's main-thread propgoes through — and a non-scalar anywhere else fails as before. Binding a
main-thread:prop on raw text is refused.@octanejs/lynxhost-driver.ts:prepareTemplateProgramcomputes the sameslot mask, refuses a main-thread binding on raw text, and refuses a program
that binds a main-thread event on a channel its own event sites already own —
both statically visible, so both are reported once per program rather than
once per instance. The instance loop installs through the existing
planLynxHostPropPatch/installMainThreadEvent/installMainThreadRef,so activation lifetime, ref-owner uniqueness, and fault invalidation are the
paths that already existed. A run that installs main-thread props sets
hasMainThreadPropsand takes the ordinary per-host acknowledgement.@octanejs/lynxhost-driver.tsalso stops hardcodinginteractive: falsefor template mounts. Worklet lifetime is owned by connectivity, not insertion
order: a detached subtree installs nothing and
insertactivates it later. Atemplate mount inserts its own root, so the answer is the parent's, and it is
computed once per run rather than once per row.
@octanejs/lynxblock-core.ts:compileLynxBlockTemplatemarks the workletslots and refuses one on raw text, and
write()compares a worklet slotstructurally instead of by identity —
bindThreadFunctionreturns a freshtagged function every render, so an identity-only compare would re-send an
unchanged handler forever. The structural compare runs only for marked slots;
an ordinary slot still costs one
Object.is. It reusessameLynxMainThreadPropValue, extracted from the decode-then-compare theprop-patch planner already does, so the two paths cannot disagree about what
"changed" means.
Validation
pnpm format:check(repo-wide, clean)pnpm typecheckpnpm testpackages/lynx/tests/block-core.test.ts(7 new),packages/lynx/tests/block-core-differential.test.ts(3 new),packages/lynx/tests/protocol.test.ts(the changed contract),--project lynx451 passedRed-first: with the source changes stashed, 6 of the 7 new
block-coretests,all 3 new differential tests, and the changed protocol case fail. The seventh —
"refuses an object in a slot the template did not bind to a main-thread prop" —
passes both ways on purpose: that refusal pre-exists, and the test is what proves
the new permission is per-slot rather than a blanket one.
protocol.test.tspinned the removed refusal (/ordinary host-prop name/for amain-thread:binding). It now pins what replaced it:refstill fails with thesame words, a descriptor is accepted in the slot the program bound to
main-thread:bindtap, the same descriptor in the slot bound tovaluestillfails as a non-scalar, and a
main-thread:binding on the#textnode isrefused.
The differential tests are the U2b rig extended by one prop kind: the same page
with a worklet row, driven through the universal core and the Block core over
the same wire and the same applier, leaves the same tree, the same event sites,
and the same live handler on every row — same worklet id, same captures, in the
same order, with a distinct activation each.
pnpm testran on the tree before the protocol-test fix and ended 5 failed /21,050 passed. One was mine — the
protocol.test.tscase above — and it isfixed;
--project lynxis 451 passed since. The other four were checkedindividually by stashing the whole diff and re-running on the clean base:
dropzoneprobes/hydration,octanebrowser suspense-hydration (focus/selection after a keyed reorder),dreibrowser upstream-e2e (WebGL), andrspeedy-pluginnative-demoperExecution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §2.3;
octanereact-hosted/web3-island and
ariapackage-boundary, both fixed-deadline hooksthat build bundles.
Risk / follow-ups
6,002 becomes 3, with that count committed as a test. Stacked on this.
reply-shape optimization rather than a gate on the run, and keeping a
conservative rule conservative costs nothing the measurement above counted.
main-thread:refbound on every row of a keyed list is one cell claiming Nhosts. That is still an error the user meets at mount, now covered by a test.
Whether it should become a compile diagnostic is question 2 on Lynx specialized background core: the Block model over the wire (#58 L2 body, post-attribution direction) #103.
Provenance
agent-authored)Generated by Claude Code