Repository navigation
feat(lynx): mount a worklet keyed list through one template run - #122
Merged
Merged
Conversation
U4a taught a template run to carry a `main-thread:` prop. The shipping path still could not take that road: a 1,000-row list with one `main-thread:bindtap` mounted in 6,002 commands where the same list without it mounted in 3. It now mounts in 3 at either scale. Three refusals stood in the way, each answered where it lives. The compiler disqualified a keyed row from a template program if any attribute was `main-thread:`-namespaced, so the list lost its program before the core saw it. A worklet and a main-thread ref are produced by the setup body and bound per instance, which is exactly what a program slot is, so a bound one is now eligible. A literal one is still refused — the same answer the core's program derivation gives a static main-thread prop. The core refused a namespaced binding when compiling a collapsed program, and refused a non-scalar in any slot. A slot whose binding names a renderer-namespaced prop may now carry a value the core forwards without interpreting, and the renderer's driver validates it. Every other slot stays scalar-only, so the same object in a plain slot still declines the program. A function is refused outright: it is what the encoder exists to replace, so one surviving means the renderer declined to encode. `UniversalHostTemplateProgramOpaqueValue` becomes `object` rather than a record of unknown fields. A renderer's descriptor is a declared interface, which TypeScript gives no implicit index signature, so the record form made this escape hatch unusable by the renderers it exists for — its first consumer could only reach it through a double cast. The core reads no field there; what the value must not be is enforced at runtime, where the core can enforce it. Lifting the refusals alone would ship a worklet with no bound execution: the Lynx driver retained background closures on the create path only, so a worklet mounted through a run would paint and be uncallable. It now retains the ones a run carries, the same step `create` already took, and records ownership per host rather than per command — one run installs callbacks on many hosts, and each host's later `update` replaces its own while its `destroy` releases them, so removing one row cannot take another row's handler down with it. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Aug 21, 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 U4b, stacked on #121. U4a taught a Lynx template run to carry a
main-thread:prop; this makes the shipping path actually take that road, sothe 6,002 in §1 becomes 3.
The measurement that opened U4 (real compiler, real transport, template runs
negotiated, keyed list of
view.row > text.col > #text):main-thread:bindtapThe "before" column is §1's; the "now" column is measured in this PR, through
the same real compiler and real transport, at 10 rows and at 1,000.
Three refusals stood between the two rows, and each was answered where it lives:
attribute was
main-thread:-namespaced, so the list lost its program beforethe core ever saw it. A worklet and a main-thread ref are produced by the
setup body and bound per instance — which is exactly what a program slot is —
so a bound one is now eligible. A literal one is still refused, the same
answer the core's program derivation gives a static main-thread prop.
main-thread:binding when compiling a collapsedtemplate program, and refused a non-scalar value in any slot. A slot whose
binding names a renderer-namespaced prop may now carry a value the core
forwards without interpreting; every other slot is scalar-only exactly as
before, so the same object in a plain slot still declines the program.
create/updatepath,so a worklet mounted through a run shipped with no
_execIdand could notcall back. That was not in U4a's design record, which scoped U4b as "lift the
refusals"; the correction is recorded on Lynx specialized background core: the Block model over the wire (#58 L2 body, post-attribution direction) #103.
Changes
octanecompilerisTemplateProgramForHost: resolves attribute names throughhostAttributeName, which is namespace-aware, and admits amain-thread:attribute whose value is a per-instance expression the same predicate already
accepts for every other binding. The only change in emitted output is the
run-eligible flag on
universalFor.octaneuniversal-core.ts:compiledCollapsedTemplateProgramkeeps anamespaced binding eligible;
prepareCollapsedTemplateValueschecks anamespaced source for what it must not be rather than for being a scalar and
validates the encoded result through a slot-scoped predicate. A function is
still refused outright: it is what the encoder exists to replace, so one
surviving means the renderer declined to encode.
octaneUniversalHostTemplateProgramOpaqueValueis nowobjectrather thana record of unknown fields. A renderer's descriptor is a declared interface,
and TypeScript gives an interface no implicit index signature, so the record
form made this escape hatch unusable by the renderers it exists for — the
first consumer could only reach it through a double cast. The core reads no
field here; what the value must not be is enforced at runtime, where the core
can enforce it.
@octanejs/lynxclient-driver.ts:prepareLynxClientWorkletBatchretainsthe worklets a run carries, the same step
createalready took, and deriveswhich slots those are once per program (cached with the program, like the
three other places that derive the same fact inside a walk they already do).
Ownership is recorded per host —
firstId + instance * hostCount + node—rather than per command, because one run installs callbacks on many hosts and
each is replaced or destroyed on its own.
@octanejs/lynxroot.ts: the accepted-worklet ledger takes that per-hostshape.
create/update/recreateassign one host, a run assigns the hostsit named, and
destroyreleases one — all through a singleassignhelper,so the three cannot drift.
Validation
pnpm format:check(repo-wide, clean)pnpm typecheck(repo-wide, clean)pnpm test— 5 failed / 21,056 passed / 8 skipped; none of them this diff's--project lynx453 passed,--project octane6,797 passedEvery failing file in the full run was attributed individually:
dropzoneprobes/hydration,octanebrowser suspense-hydration(focus/selection after a keyed reorder),
dreibrowser upstream-e2e (WebGL),and
rspeedy-pluginnative-demoper Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §2.3;octanereact-hosted/web3-island (2 passed),
ariapackage-boundary (6 passed), andmarkdownconformance/public-types (1 passed, 2.16s against a 5s deadline).All three are fixed-deadline hooks or imports that compile or bundle, and the
run they failed in took 3,519s wall.
Red-first, per changed source file, against the new
packages/lynx/tests/worklet-template-runs.test.ts:universal-core.tsclient-driver.ts_execIdroot.tscompile-universal.jsis attributed by the new case inuniversal-renderer.test.ts: reverted, the bound row is no longerprogram-eligible.
New tests:
packages/lynx/tests/worklet-template-runs.test.ts(2) — the shipping pathend to end:
createLynxRootover the real transport onto the official ElementPAPI. One run mounts the whole list with exactly one
create(the page) at 10and at 1,000 rows, and each row's captured background function is callable
while its hosts live and refused once they are destroyed.
packages/octane/tests/universal-renderer.test.ts(1) — a keyed row thatbinds a
main-thread:prop stays program-eligible; a literal one does not.packages/octane/tests/universal-host-sdk.test.ts(1) — sibling to theexisting "falls back for refs, native-list hosts, and main-thread-owned
props": a renderer-namespaced binding carries an opaque value through a run,
and the identical value in a plain slot still declines the program.
The compiler and core changes are shared, so they reach the main-thread
first screen as well as the background root:
createLynxHostDrivernegotiatestemplateProgramRunstoo.first-screen-direct.test.tsalready renders a keyedlist whose rows bind
main-thread:bindtapthrough that applier, and it is greenon this branch; the applier's own handling of a main-thread prop on a program is
U4a's work, tested directly in
host-driver.test.ts.The component in the Lynx test is written the way the compiler writes one — a
module-level plan with per-instance bindings and a run-eligible
universalFor—because the lynx suite compiles
.tsrxwithout selecting a thread layer, so a'main thread'directive cannot be authored in a fixture there. The compilerhalf is proven on the
octaneside instead, which is where a compiler test canchoose its own options.
Risk / follow-ups
bindThreadFunctionreturns a freshtagged function every render, and the core's prop diff falls back to identity
for a function, so every surviving worklet-bearing row takes an
updateonevery render — measured here: removing one row from a three-row list emits two
updates carrying the full prop bag. A plain row emits none. U4a already fixed
this inside the Block core with a structural compare; the universal path needs
a renderer-owned equality hook to do the same, which is a designed core-API
addition rather than something to bolt onto this diff. Recorded on Lynx specialized background core: the Block model over the wire (#58 L2 body, post-attribution direction) #103 as the
next unit; the new test asserts the survivors stay callable through whichever
execution the current frame carries, so it does not pin the re-send itself.
main-thread:refis deliberately not retained by the run path, matchingcreate: a ref cell holds no background closure and so has no executionlifetime. One ref bound on every row of a keyed list is still one cell claiming
N hosts, which 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