Repository navigation
Description
Found by an adversarial audit of the #58 L0–L3 equivalence claims, against the #65 stack head 2fe14465f. Counterexample to the #65 claim that applyLynxFirstScreenDirect "leaves container state indistinguishable from prepareLynxHostBatch + apply".
Root cause
The staged applier validates host placement before mutating; the direct applier runs no equivalent check. Given the same rendered first-screen tree:
DIRECT: {"outcome":"accepted(true)","instances":2}
STAGED: {"outcome":"threw: Octane Lynx host: #text host 2 may only be placed
directly under a text host.","instances":0}
One paints the tree, the other refuses it. The refusal is what keeps an invalid tree away from the engine, so an applier that skips it is not substitutable for one that performs it — the direct path is the less safe of the two.
This sits entirely on the plan encoding (a children binding makes the template ineligible), so it is an applier-level divergence independent of #63.
Reachability, and a second gap it exposes
The renderer already guards the idiomatic form, but an explicit children prop bypasses that guard. Both executed:
| source | compile result |
|---|---|
<view class="page">{props.t as string}</view> |
rejected: renderer "lynx" does not allow authored primitive text under <view> |
<view class="page" children={props.t} /> |
compiles clean, no diagnostic |
validationAttributeName skips children in the attribute check at packages/octane/src/compiler/compile-universal.js:1817, so the explicit-prop spelling escapes the very rule the direct spelling trips. The renderer then materializes the string into a #text host under the view, and renderPlanNode picks it up through const dynamicChildren = props.children at packages/lynx/src/main-renderer.ts:801.
So there are two things to fix here, and they are independent:
applyLynxFirstScreenDirectperforms no host-placement validation (packages/lynx/src/core/host-driver.ts:2900).- The compiler's text-under-
<view>rule is bypassable viachildren={...}.
Reproduction
Committed as a red test on claude/octane-issue-58-adversarial-audit (5d000b30e):
packages/lynx/tests/first-screen-applier-acceptance.test.ts
AssertionError: expected 'painted' to be 'refused: Octane Lynx host: #text host 2 may only be placed directly under a text host.'
Consumer impact
Since #65 made the direct path the default for every non-native-list first screen (packages/lynx/src/main-thread.ts, installLynxMainThread), a tree that the staged path would have refused now reaches the Element PAPI on every launch. Whether the native engine tolerates a raw-text child under a view is exactly the question the staged validation existed to avoid asking.
Notes for the fix
The committed test asserts only that the two appliers agree, so either direction passes: give the direct path the same placement validation, or establish that the check is unnecessary and drop it from the staged path. It does not pin which.
What else was checked on this surface, and held
To be clear about scope, these were attacked and did not break:
- Teardown fault handling — faults injected at
setEvent,remove,setAttribute,flush,insertBeforeduring disposal produce byte-identicalLynxHostCleanupResult(complete,errors,remainingRoots) and identicalcontainer.disposedon both appliers. The retry contract (disposed:falseplus populatederrors) works as documented. - Flush obligation — exactly one flush on a mid-walk fault on both paths.
- Ordered PAPI call journals differ (direct 46 calls, staged 48; direct interleaves
insertBeforeduring the walk and skipssetEventSET/REMOVE pairs on hidden subtrees) but terminal container state is identical. Assessed as not a defect —.rulesync/rules/testing.mdlists exact internal call order as a non-contract, and feat(lynx): direct-emission first screen with unchanged adoption capture (issue-58 L3) #65's claim is about container state, which holds.
Verification performed
Reproduced independently of the finding agents; the compile-reachability contrast above was executed directly. Three separate finder agents independently reported the direct path skipping staged-path validation, which is what prompted this check. Adversarial refuter panel had not adjudicated at time of filing.
Activity
Huxpro commentedon Aug 18, 2026
Second mechanism for the same defect: shared
main-thread:refacross a visible and a hidden hostA dedicated adoption lens found an independent way the direct applier paints a tree the staged applier refuses. Same root-cause class as the
#textplacement case above — the direct path lacks state/validation the staged path has — but a different mechanism, and this one is confirmed not pre-existing.The two appliers derive
visiblefrom different sourcesconst visible = parentVisible && node.visibility !== 'hidden'(packages/lynx/src/core/host-driver.ts:2951), then passesvisible && state.hasMainThreadPropsasapplyProps'interactiveargument (:2996). A host inside a hidden<Activity>therefore never installs itsmain-thread:ref.operation.visible, snapshotted fromrecord.visibleat create time (:4418,visible: true).So for a
main-thread:refshared by a visible host and a hidden<Activity>host, the two paths disagree on whether the second registration happens.Observed
Throw originates at
packages/lynx/src/core/host-driver.ts:1795.Authored-reachable
useMainThreadRef()returns one descriptor with a stable_wvid(packages/lynx/src/renderer.ts:52-96), so this is ordinary code:In production
packages/lynx/src/main-thread.ts:1906always tries the direct applier first, so such a page paints. It then adopts only while the background commit matches byte-for-byte; the same throw fires for a plain background-only mount of the identical tree, and on the repair path after a direct paint.Attribution
Checked in a
git worktreeat base6079a6804:git show 6079a6804:packages/lynx/src/core/host-driver.ts | grep applyLynxFirstScreenDirectreturns nothing — the direct applier does not exist on base, so only one applier existed and it refused this tree. The staged-side refusal itself is pre-existing (byte-identical on base), but the divergence is introduced by this stack, which is what makes it a CLAIM 2 counterexample rather than a latent bug.Bearing on the fix
This strengthens the case that the fix belongs on the direct side. Two independent mechanisms now show the direct applier accepting trees the staged applier rejects —
#textplacement above, and main-thread ref lifetime here — which suggests the gap is systematic rather than a single missing check.Generated by Claude Code
Huxpro commentedon Aug 18, 2026
Panel result: not refuted by either refuter, and both attacks broadened it
Two independent refuters attacked this on the fixture-validity axis. Neither could kill it, and both made it stronger.
It is a crash on a real page, not only an acceptance asymmetry
The issue above frames this as "direct paints, staged refuses" — a divergence. A refuter showed the production consequence: add a native
<list>to the same page andapplyLynxFirstScreenDirectdeclines viafirstScreenTreeHasList, sopackages/lynx/src/main-thread.ts:1906falls through toprepareLynxHostBatch(...).apply()— which throws.So on any page combining a native
<list>with achildren={string}prop on a non-text host, the first screen throws rather than merely differing. The<list>is not exotic — declining lists is the one documented fallback the direct applier has.The compiler really does guard the idiomatic forms
A refuter set out to show the fixture was an exotic backdoor and it backfired — the guard is real, which is what makes
children={...}an escape hatch rather than an equivalent spelling:Both rejected under both targets. Only the explicit
childrenprop slips past, becausevalidationAttributeNameskipschildren.Not a typing artifact
An independent sweep compiled five authored sources through the real compiler and fed identical
result.nodes/result.batchto both appliers head to head. With fully typed props — noany—<view class="page" children={props.label} />still gives DIRECT paints / STAGED throws. The divergence does not depend on loose typing.Panel tally
Two verdicts on this candidate: both not refuted, both reproduced byte-identically from a clean tree, both attacking fixture validity and failing.
Combined with the
main-thread:refmechanism in the previous comment, that is now three distinct routes by which the direct applier accepts or paints what the staged applier refuses — which is the argument for treating the missing validation on the direct path as systematic rather than as three separate patches.Generated by Claude Code
Huxpro commentedon Aug 18, 2026
Two more mechanisms from a registry-backed worklet lens — and the staged path is implicated in one of them
A lens that finally built a registry-backed container (
createLynxHostContainer(papi, { root, worklets })withcreateLynxMainThreadWorkletRegistry()) reached themain-thread:surface that defeated two earlier attempts. Both findings below are verified not pre-existing — the direct applier does not exist at base6079a6804, and the staged path there is byte-identical (271 insertions(+), 0 deletions).Mechanism 3 — the staged path over-refuses because its
visibleflag is staleThis one inverts the usual direction, so it is worth stating carefully.
A first-screen batch emits every
visibility/hidden command last (packages/lynx/src/main-renderer.ts:1117-1125). The stagedcreateoperation capturesvisible: record.visibleat staging time (host-driver.ts:4418), so a host that the same batch will hide is still staged asvisible: true. The apply loop then gates main-thread installation on that stale flag (:5330-5332).The direct applier computes final visibility structurally during the walk (
:2951,:2996), so it gets the right answer.So for a page binding one
useMainThreadRefto a visible element and to an element inside a hidden<Activity>, the direct path is arguably correct and the staged path is wrong. It renders fine today and hard-fails the moment a native<list>forces the staged fallback.That matters for the fix: the answer here is not simply "add the staged path's checks to the direct path". Mechanism 3 needs the staged path's stale-visibility bug fixed too, or adding its check to the direct path would propagate a false refusal.
Mechanism 4 — both refuse, but with different messages, phases, and PAPI footprints
Two visible hosts sharing one
main-thread:ref::4794-4807): "main-thread ref X is assigned to hosts A and B", zero PAPI calls.installMainThreadRefreaches the second host mid-walk (:1789-1796): "main-thread ref X is already mounted". Before failing it allocates three engine elements, attaches one, publishes the ref into the worklet registry, and calls flush.Both reject the tree, so the end state agrees — but against a real Element PAPI the engine observes a partial page and a flush for a tree that was never valid, which the staged path never produces.
Where this leaves the issue
Four distinct mechanisms now, plus a fifth filed separately (#84 — the direct applier skips
assertNoMainThreadEventCollisionentirely, silently dropping the main-thread handler):#textunder a non-text hostmain-thread:refshared visible + hiddenvisibleon the staged create opmain-thread:ref, two visible hostsassertNoMainThreadEventCollisionon the direct pathThe pattern is that the direct applier has no prepare stage at all, so every batch-level invariant the staged path checks up front is either missed or discovered mid-mutation. That is one structural fix, not five patches — and mechanism 3 shows the prepare-stage checks themselves need auditing before they are copied over.
Generated by Claude Code
Huxpro commentedon Aug 18, 2026
Correction: mechanism 1 is refuted as a consumer-visible defect
A refuter ran the full production stack —
installLynxMainThread({firstScreen:true})+firstScreenRoot.render(...)+createLynxRoot().render(...)+markFirstScreenSyncReady()over@lynx-js/testing-environment— across five configurations. I only ever tested at the applier boundary, hand-feedingresult.nodes/result.batchto the two appliers. The end-to-end result contradicts this issue's central consumer claim.<list>— my "paints fine today" case<list>childrenprop (explicitraw-textunderview)#textOCTANE_LYNX_FIRST_SCREEN_MISMATCHThere is no configuration in which the direct applier's extra leniency changes a consumer outcome. Every path ends in the same
hostError, or the node is repaired away with a published diagnostic.Three specific things I got wrong:
<list>is present" — false. It dies either way; config B kills the app with no list at all.children-prop escape hatch isn't load-bearing — config D reaches the same divergence with an explicitraw-texthost, so thevalidationAttributeNamegap is a side detail, not the root cause.<view children={string}/>is an already-fatal authoring violation on this branch and every branch before it;docs/lynx-native-renderer-plan.md:408states the compiler must reject text underview, andcompile-universal.js:1789does so for authored text.The committed red test's oracle is disputed
packages/lynx/tests/first-screen-applier-acceptance.test.ts(5d000b30e) asserts the two appliers accept the same trees. The refuter argues, reasonably, that both places declaring the contract scope it to container state and named downstream observers — not to acceptance sets — so pinning acceptance parity may itself violate.rulesync/rules/testing.md's rule against pinning non-contracts. I am leaving the test in place because it documents a real mechanical divergence, but the owner should decide whether acceptance parity is a contract worth pinning. If it isn't, that test should be dropped.What survives
This refutation is specific to mechanism 1. It does not generalise, and two mechanisms are untouched by it:
main-thread:refshared across a visible and a hidden<Activity>host): the adoption round reported verdictadopt— the illegal tree survives adoption rather than being caught by it, which is exactly what mechanism 1 fails to do.assertNoMainThreadEventCollisionon the direct path): the symptom is a silently dead main-thread handler, which adoption has no reason to repair.Mechanism 3 (stale
visibleon the staged create op) also stands and is a staged-path bug regardless.So CLAIM 2 remains falsified — but on mechanisms 2, 3, and 5, not on the
#textplacement case this issue is titled around. The title now overstates the finding; treat #84 and mechanism 2 as the load-bearing evidence.Panel tally
Three verdicts on this candidate: two not-refuted (both attacking fixture validity at the applier boundary), one refuted by going end-to-end past that boundary. The refutation is better-evidenced than the confirmations, because it tested the thing that actually matters.
Generated by Claude Code
Huxpro commentedon Aug 18, 2026
Correction: mechanism 2 is also refuted — the direct applier is correct there, and the staged path was already broken
A refuter attacked mechanism 2 (
main-thread:refshared across a visible and a hidden<Activity>host) and killed it as a stack-caused defect. I have read the argument and it holds.The only thing that actually goes wrong in that composition —
main-thread ref "scene:shared" is already mountedthrown out ofprepareLynxHostBatch— is entirely pre-existing. Executed against base6079a6804in a worktree: byte-identical throw, byte-identical empty<page#1>, byte-identical unowned ref, same order-dependence (hidden-first passes on base too). Base'smain-renderer.tsalready appends everyvisibilitycommand last, and base'sinstallMainThreadRefalready carries therecord.visible-gated tolerance. Root cause, trigger and symptom all predate the stack.What the stack added is a second applier that handles the composition correctly:
applyLynxFirstScreenDirectderives visibility structurally during the walk (:2951) and passesvisible && state.hasMainThreadPropsasinteractive(:2996), so the hidden host never installs the ref and it lands on the visible owner — the semantics the finding itself argued for.My headline consequence did not survive execution either. I claimed the direct-painted page "adopts cleanly, but the first background divergence tears down the first screen and throws mid-repaint, leaving the page empty and the root faulted." Measured against what base does on every mount of this composition, the terminal states are byte-identical JSON. There is no state HEAD reaches here that base does not already reach unconditionally and immediately — while HEAD's steady state (direct paint → exact-match adopt → ordinary update commit) runs with
error: nulland the correct tree, where base is dead on arrival.HEAD ≥ base at every observable point, and strictly better in the common path.
Where that leaves this issue
Both mechanisms this issue was filed on are now refuted as stack defects:
#textunder a non-text hostmain-thread:refvisible + hiddenvisibleon the staged create opassertNoMainThreadEventCollisionon the direct pathSo the honest position is:
Treat #84 as the actionable item and this issue as documentation of the surface. I would not fix mechanisms 1–4 by making the direct path match the staged path — that would propagate staged bugs into a correct applier. The structural read still stands (the direct applier has no prepare stage, so batch-level invariants are missed or found mid-mutation), but the fix is to audit those invariants first, not to copy them.
If the maintainers prefer, this issue could reasonably be closed in favour of #84, with mechanisms 3 and 4 split out as their own staged-path cleanups.
Panel tally
Mechanism 1: 2 not-refuted, 1 refuted (the refutation went end-to-end past the applier boundary and was better-evidenced). Mechanism 2: 2 not-refuted, 1 refuted (the refutation established base-parity, which the confirmations did not test).
In both cases the refuting verdict tested something the confirming verdicts did not. That is the panel working as intended, and it is why the two mechanisms this issue is titled around should not be the ones anyone acts on.
Generated by Claude Code
Huxpro commentedon Aug 18, 2026
Correction to the structural read: some staged-path checks are transport checks the direct path structurally cannot need
My earlier comment said the direct applier "has no prepare stage, so every batch-level invariant the staged path checks up front is either missed or discovered mid-mutation," and framed that as one structural fix. A refuter working an adjacent candidate disproved the general form of that claim by execution, and the distinction matters for anyone acting on this issue.
The two appliers agree across the whole invalid-
main-thread:value spaceA sweep over empty
_wkltId, missing_wkltId, main-local_owltactivation, string, number, array, and unregistered worklet id produced an identical error class and identical message on both appliers in every case. They share the prop validator.A genuinely tagged callable (
bindThreadFunction('main-thread','scene.tsrx:tap',...)) is accepted by both, unwrapped by both to{"_wkltId":"scene.tsrx:tap","_c":{"values":[]}}, with byte-identical PAPI journals and physical trees. The direct path does perform the unwrap —planLynxHostPropPatch→decodeMainThreadWorklet(packages/lynx/src/core/host-props.ts:304-316) →unwrapThreadFunctionDescriptor, a thin wrapper over the samegetThreadFunctionDescriptorthatclonePropsuses (core/worklets.ts:1394-1413).The one divergence is structural, not a missing check
It exists for exactly one input class — a raw, untagged JavaScript function — and the reason is architectural:
That is not the direct path skipping validation. It is the staged path running an extra, earlier check that only the staged path needs.
What this changes for the fix
Do not port
cloneProps-family checks onto the direct path. They are transport invariants, not tree invariants, and adding them would impose an encoding constraint on a path that performs no encoding — cost with no correctness gain.The distinction to apply when auditing the prepare stage:
So the structural read narrows: the direct applier is missing tree-invariant checks, of which #84 is the confirmed instance. It is not missing the transport checks, and it should not acquire them.
Net effect on this issue
Combined with the earlier refutations of mechanisms 1 and 2, CLAIM 2's acceptance surface comes out substantially healthier than this issue's title suggests: the two appliers agree on the entire invalid-value space, produce byte-identical journals for valid tagged worklets, and diverge only where the staged path carries transport concerns the direct path does not have — plus the single genuine tree-invariant gap in #84.
This reinforces the earlier recommendation: act on #84; treat this issue as documentation of the surface.
Generated by Claude Code