Repository navigation
feat(lynx): mount a resident program by name, and fold a proved-scalar text hole (#246 E1 + B2) - #269
Merged
Merged
Conversation
Adds the addressing half of E1: a plan can carry a cross-realm name, a `mount-program-run` command names one instead of carrying a descriptor, and both realms resolve it against a registry their own chunk populated. - `UniversalProgramAddress` on `UniversalPlan`, taken as `universalPlan`'s third argument so the background chunk changes by exactly the addressing. - Realm-local wire registry in the universal core, populated by the producer in the background and by the main-thread chunk on the other side. - `mount-program-run` in the command union, emitted by the producer when the plan is addressed and the renderer claims `addressedProgramRuns`. - Protocol validation for the new op, sharing the descriptor run's checks and refusing an address this realm cannot resolve. - Compiler emits the address plus a build-time digest over the derived wire surface, from both compiles, gated on a `programAddressing` build. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
The applier, the validator and the capability negotiation for `mount-program-run`, plus the resident descriptor it resolves against. An addressed run re-enters the same applier a descriptor run takes, with the program resolved instead of carried, so the tree, the ids, the events and adoption are identical by construction rather than by a second implementation kept in step. What the naming buys is not the wire bytes. `prepareTemplateProgram` and `assertTemplateProgram` both memoize on program object identity, so a descriptor that crosses the realm boundary misses both memos on every mount while a resident program is walked and validated once for the chunk's life. The main-thread compile therefore emits the derived wire into its program object, and the registry deep-freezes it once at registration, because neither memo will store a program it cannot prove immutable. The two realms resolve differently and the module graph says so. A background asks the universal core for the program its own producer lowered for that exact command — keying the sender by address would be wrong, since `prepareUniversalTemplateProgram` memoizes per encoder and two roots hold two objects for one address. The main thread asks its own residency. `protocol.ts` is in both graphs, so it takes the resolver as a parameter rather than importing either; `program-registry.ts` holds no runtime import from the core, keeping the main-thread graph's zero package dependencies intact. The main thread advertises `addressedProgramRuns` from residency rather than from the protocol rung it speaks: understanding the op is free, holding programs to resolve against needs the main-thread chunk of a two-layer build. An isolated `thread: 'main-thread'` graph registers nothing, says so, and keeps descriptor mounts. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
…t build (#246 E1, part 3) Completes E1 with B2 and the build-time drift gate the addressing needs. B2 rides #250's fold rather than adding wire vocabulary, per the §6.4 ruling that a scalar text slot is a binding `{ valueIndex, name: 'text' }` on a `text` host and therefore absent ABI work rather than deferred work. `{expr as string}` as the lone child of a text-absorbing host now folds onto that host as a `['text', slot]` binding, the carrier is never painted, and the slot keeps the existing `p:text` kind. The proof is read off the authored JSX, not the plan node: `compile.js` strips every TS-only wrapper before printing, so by codegen the cast is gone. The compiled child is checked too, so a hole that folded to static text or to a nested plan is not this. A lying cast cannot paint a wrong tree — `text` on a `text` host takes the carrier's semantics in all three appliers, each rendering a non-string as empty rather than coercing it. The drift gate lands in the Rspack loader, which is where one build sees both compiles of a module. Each compile reports the addresses it emitted with the digest of the wire surface it derived them from; a disagreement per `(module, index)` fails the build naming the module, rather than shipping a positional address that would mount a plausible wrong tree. The module id is package-relative, computed from the path alone, and deliberately not the compiler's canonical module id: that one is project-relative and falls back to the absolute path outside the project root, which would put a build machine's filesystem layout into a shipped chunk and disagree between a monorepo build and a consumer's build of the same source. A module with no package-relative name declines addressing in both compiles alike and keeps descriptor mounts. `programAddressing` is on by default for an rspeedy application build that configures a backend, and refused for an isolated thread graph. Both layers inherit the backend when it is on, because the background decides eligibility by running the same derivation as a pure oracle. The backend signature is bumped and its digest repinned, since the derivation's design-spec header changed: its stated blocker — that a plan the compiler produced cannot say a hole is text — is what B2 removes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
…g under B2
`lynx-main-thread-program-first-screen.test.ts` exists to catch a program
that numbers its own nodes first and its ranges' members afterwards, and
its fixture's own doc says how: an event before the first range and one
after it, with each range holding a member that takes an ID of its own.
B2 folds `{expr as string}` onto its `<text>`, which removed both ranges
and left the file comparing a shape it was not built to test.
So the fixtures ask for the holes they need. A bare hole is still a hole
for the reason it always was — it can evaluate to an array or a component
— and every pinned number is restored exactly, rather than repinned
against a fixture that lost its point. `HOSTING_CARD` now differs from
`CARD` only by the annotation that lets a caller pass a component, since
the hole it used to open is already open.
The folded form gets its own cell instead of being lost: the same card
with both holes cast, asserting the two encodings agree about the smaller
host count, the shifted listener IDs and the envelope, and that both
paint the value onto the `<text>` with no child under it. Counting hosts
alone cannot tell a fold from a hole the compiler dropped.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Sep 1, 2026
A module evaluated twice mints a fresh plan object each time, so the identity check refused exactly the ordinary re-evaluation the tolerance existed for and crashed it with the two-programs TypeError. Same is now structural over the wire — the surface the address digest already covers — keeping the first registration so memoization survives; a genuinely different program is still refused. Also derives a main-thread program once per root per compile instead of twice (digest + emission). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Huxpro
marked this pull request as ready for review
September 2, 2026 07:53
This was referenced Sep 2, 2026
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
Implements #246 E1 in full —
mount-program-run, the addressing that makes itpossible, and the build gate that makes it safe — plus B2, the scalar text slot,
as the same ABI change. Per the owner directive
(#246 issuecomment-5485057342); every §6 ruling is taken as given and none is
re-opened here.
§3 says E1 is three parts, and it is:
1 — a key.
UniversalPlangains an optionalUniversalProgramAddress,passed as
universalPlan's third argument. The wire carries only the positional(module id, plan index)of §6.1's A half. The module id is package-relativewith posix separators and no leading
./(§6.2), computed from the path alone byOctaneBundlerCompiler#_programModuleId, so a monorepo build and a consumer'sbuild of the same shipped source name it identically. Deliberately not the
compiler's existing canonical module id: that one is project-relative and falls
back to the absolute path for a file outside the project root, which would put a
build machine's filesystem layout into a shipped chunk.
2 — a registry.
packages/lynx/src/core/program-registry.ts, main-threadonly, populated by the main-thread chunk as it evaluates.
mount-program-runresolves against it and re-enters the same applier
mount-template-runtakes,with the program resolved instead of carried — so the tree, the ids, the
listeners and adoption are identical by construction rather than by a second
implementation kept in step.
The two realms resolve differently, and the module graph says so. The background
asks the universal core for the program its own producer lowered for that exact
command, keyed by command object: keying the sender by address would be wrong,
because
prepareUniversalTemplateProgrammemoizes per encoder and two roots holdtwo objects for one address.
protocol.tsis in both graphs, so it takes theresolver as a parameter rather than importing either, and
program-registry.tsholds no runtime import from the core — the main-thread graph's
packages: []invariant is intact.
3 — a drift gate. Both compiles emit a structural digest over exactly the
derived wire surface (§6.1's B half), and
crossCheckProgramAddressesin theRspack loader compares them per
(module, index)across the build's two layers.A disagreement is a build error naming the module. This is the part §3 calls the
worst failure shape in the codebase: a positional address that binds to the wrong
program paints a plausible wrong tree, and nothing at runtime would notice.
An isolated
thread: 'main-thread'graph refuses the option outright (§6.3), atthe configuration rather than at a mount that finds nothing, and its diagnostic
names the two-layer build.
What the naming buys
Not the wire bytes.
prepareTemplateProgramandassertTemplateProgramboth keyon program object identity, so a descriptor that crosses the realm boundary misses
both memos on every mount, while a resident program is walked and validated once
for the chunk's life. That is why the main-thread compile emits the derived wire
into its program object and the registry deep-freezes it at registration: neither
memo will store a program it cannot prove immutable.
B2
§6.4 ruled that a scalar text slot is absent ABI work, not deferred ABI work —
"a binding
{ valueIndex, name: 'text' }on atexthost … no new opcode, no newfield, no arity change, and no receiver dispatch". So B2 lands as an extension of
#250's fold rather than as a new
UniversalSlotKindmember:{expr as string}asthe lone child of a text-absorbing host folds onto that host as a
['text', slot]binding, the carrier is never painted, and the slot's kind is the existing
'p:text'.The proof is read off the authored JSX, not the plan node, because
compile.jsstrips every TS-only wrapper before printing — by codegen the cast is gone. The
compiled child is checked too, so the two views must agree before anything folds.
A lying cast cannot paint a wrong tree, and the receiver for that was already
built by #250:
attributeValueinhost-props.ts, the dense route inhost-driver.ts, and the compiled create inemit-main-thread-program.tseachrender a non-string as empty rather than coercing it — which is what the carrier
this replaces did.
Changes
octane:UniversalProgramAddresson the plan and asuniversalPlan's thirdargument; the realm-local wire registry;
mount-program-runin the commandunion and in protocol validation; the compiler emits the address and digest
from both compiles under
programAddressing, and reports every address itemitted so an integration can cross-check them; the B2 fold; package-relative
_programModuleId.@octanejs/lynx:core/program-registry.ts; the addressed-run branch in theapplier;
addressedProgramRunscapability negotiation; the design-spec headerin
derive-main-thread-program.tsrewritten, since its stated blocker ("a planthe compiler produced cannot say it") is what B2 removes.
@octanejs/rspack-plugin: theprogramAddressingoption through normalization,cache identity and layer selection — whole-build, deliberately not
specializable — and the loader's cross-compile digest check.
@octanejs/rspeedy-plugin:programAddressing, on by default for anapplication build that configures a main-thread program backend, refused for an
isolated thread graph. Both layers inherit the backend when it is on, because
the background decides eligibility by running the same derivation as a pure
oracle.
#238's two tests, converted per §5
They are on
new-lynxalready (1bd0af124), which is what makes the conversionpart of this diff rather than a precondition for it.
§5 required the byte-identity gate be replaced, not deleted. The two tests
become
naming a resident program from the background (#246 E1):gives both sides the same identifier, and only when the build assigns one—both chunks carry the same digest, only the main-thread chunk carries the wire,
and a build with no module id emits no address at all.
changes the background chunk by exactly the addressing, and nothing else—strip the address literal from the addressed background chunk and it is the
plain one.
The wider #163 background byte-identity gate is untouched, because it is
differential over the backend switch rather than absolute; B2 shifts both arms
equally.
One fixture the fold would have quietly gutted
lynx-main-thread-program-first-screen.test.tsexists to catch a program thatnumbers its own nodes first and its ranges' members afterwards, and its fixture's
doc says how: an event before the first range and one after it, each range
holding a member that takes an ID of its own. Both of its holes were casts, so B2
folded them and left the file comparing a shape it was not built to test. The
fixtures now ask for the holes they need — a bare hole is still a hole, because
it can evaluate to an array or a component — and every pinned number is restored
exactly rather than repinned. The folded form gets its own cell instead of being
lost.
Spec-silent choices, noted rather than asked about
programAddressingdefaults on for an rspeedy application build thatconfigures a backend, and only there. There is a program to address and both
layers of that one build emit the digest that proves they agree.
falsekeepsdescriptor mounts, which is what an A/B and the byte-identity pins need.
residentUniversalProgramCount() > 0, following the first-screen precedent of negotiating at mount rather thanper command. Consequence recorded under Risk.
owns it, or it sits outside its package root — in both compiles alike, since
both ask the same question of the same path. It keeps descriptor mounts rather
than getting an id two builds could disagree about.
the derived wire. It is a build-time artifact compared inside one build, never
shipped as a resolution key, so collision resistance is not load-bearing; §6.1
explicitly keeps it off the wire.
textbinding is appended after the host's other bindings, so the slottable gains
p:textat its natural position and no existing slot renumbers.Validation
pnpm test— three failures, all pre-existing (below)pnpm typecheckpnpm format:fileson every changed pathpnpm sync(no generated changes)packages/lynx/tests/addressed-program-run.test.ts(new, 6),packages/octane/tests/lynx-main-thread-program-first-screen.test.ts(74),packages/octane/tests/compiler/lynx-main-thread-program.test.ts(15),packages/octane/tests/lynx-target-templates.test.ts(14),packages/rspack-plugin-octane/tests/main-thread-program-build.test.ts(5),packages/lynx/tests/background-deferred-list.test.ts(5),packages/lynx/tests/main-thread-backend-signature.test.ts(2),packages/rspeedy-plugin-octane/tests/plugin.test.tsThe three failures, and why they are not this diff's — each was re-run on
origin/new-lynxatc124594c7in the same container and failed identicallythere, and none of the three imports anything the diff touches:
drei›should match previous onesuspense-hydration›restores focused input and its selected text after a keyed DOM reordernative-demo›escalates cleanup for a detached descendant after its leader exitsscripts/run-lynx-explorer-demo.mjsEvery load-bearing new assertion was falsified before being trusted, per
octane-core-extend. DisablingcrossCheckProgramAddressesturns the drift testred while the build otherwise succeeds and ships the mismatched address.
Making
_programModuleIdreturnnullturns the addressing test red while thedrift test's build stops failing — the decline path behaving correctly. Disabling
the scalar-text fold turns the new first-screen cell red on both arms.
No performance number is claimed here. Per the directive the web lane is a
development mirror, the absence of a V8 win is expected, and the device round
makes the performance and regression verdict against the finished implementation.
Risk / follow-ups
whose module has not yet evaluated would leave the count at zero at negotiation
time; the background then keeps descriptor mounts for the whole root rather
than failing per command. Sound but conservative, and moot in practice because
application builds set
splitChunks: false. A per-module negotiation is thefollow-up if a build ever splits the main-thread chunk.
both compiles. A different integration that drives the compiler directly gets
the addresses on the compile result and must run its own check; the option
defaults off there.
claude/octane-issue-66-phase-a-7wz97z;this repo's
create-a-prrequires afeat/-prefixed topic branch so the labelbot can read the type from it. The topic branch is used, and the deviation is
flagged here rather than resolved unilaterally.
Does this change the sequence?
No. E2 → E3 → E1 stands and this is E1, built to the directive. It closes
Cause B: B1 is in this diff, and B2 turned out to be absent ABI work rather than
deferred work, exactly as §6.4 ruled. E3's remaining blocker — unfreezing a run's
values— is receiver-local and neither waits on nor is helped by anything here.Nothing in this PR spends the #163 byte-identity promise beyond the addressing
itself, which §5 authorized and whose replacement gate ships with it.
Provenance
agent-authored)Generated by Claude Code