Repository navigation
feat(lynx): direct-emission first screen with unchanged adoption capture (issue-58 L3) - #65
Conversation
Huxpro
left a comment
There was a problem hiding this comment.
Reviewed the direct applier against the staged path and the adoption contract. The equivalences that matter hold: listener ids are minted once in renderLynxFirstScreen and the applier consumes the batch's own event commands, so token encoding inputs are identical by construction; events-on-hidden converges with the staged install-then-remove; the end state satisfies captureLynxFirstTree's invariants clause-by-clause; and the native-list decline happens before any PAPI mutation and covers exactly the trees adoption already skips. The differential suite (deep-equal adoption snapshots, event journals, and physical trees, with a red-green check) is the right shape of evidence.
Independently verified on this head: the full lynx project green (26 files / 342 tests), a production BENCH_AUTOROWS build of the lynx-table app producing both bundles, and the web smoke passing at 10k rows through this direct path — so the stack is sound to rebuild benchmark entries against.
Two inline findings, both about the exported applyLynxFirstScreenDirect rather than the integrated flow: the fault path skips the staged applier's lifetime-invalidation/flush-journal steps (no test covers a mid-walk throw), and the applier skips the envelope validation the staged path performs. Neither blocks the measurement claims; the fault-path one is the one I'd fix before this merges.
Generated by Claude Code
09e0cd5 to
4924e40
Compare
…ure (issue-58 L3) renderFirstScreenNow now applies the rendered record tree straight to the Element PAPI (applyLynxFirstScreenDirect): no command staging, cloned record maps, or operation replay, while the container state stays indistinguishable from the staged path so captureLynxFirstTree, background adoption, mismatch repair, and buffered-event replay are untouched. Listener ids stay single-sourced in the renderer's batch; native-list trees keep the staged path. Equivalence pinned by a differential snapshot/journal/physical-tree test alongside the existing first-screen and adoption suites. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
…alidation Per review: a mid-walk PAPI fault now mirrors the staged applier — the flush obligation survives (cleanupNeedsFlush journaled on flush failure) and directly installed main-thread worklets are invalidated through the shared invalidateMainThreadLifetimesAfterFault before rethrow. The exported applier also validates the batch envelope (renderer id, positive safe version) before touching PAPI. Fault-injection and envelope tests added. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
5dc3c52 to
2fe1446
Compare
Counterexample to the #65 claim that `applyLynxFirstScreenDirect` leaves the container indistinguishable from `prepareLynxHostBatch` + `apply`. RED on this stack head. The staged applier validates host placement before mutating: a `#text` host under a non-text parent is refused with "#text host N may only be placed directly under a text host." The direct applier runs no equivalent check, so it paints the same tree — 2 instances against the staged path's 0. 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. Reachable from authored `.tsrx`: the renderer rejects `<view>{text}</view>` at compile time ("does not allow authored primitive text under <view>"), but an explicit `children` prop is skipped by that attribute check and compiles clean, after which the renderer materializes the string into a `#text` host under the view. This sits entirely on the plan encoding — a `children` binding makes the template ineligible — so it is an applier-level divergence independent of #63. Asserts only that the two appliers agree, so either repair passes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015bSFKJDuqGJALcNAEiycA4
Summary
Stacked on the L2 spike PR (#64); first slice of #62 (L3 of the #58 roadmap). The synchronous first screen now lands on the Element PAPI through direct emission instead of the staged command pipeline:
host-driver.tsgainsapplyLynxFirstScreenDirect(container, nodes, batch): one walk over the rendered record tree doingcreateElement→ props (planLynxHostPropPatch+applyProps, unchanged for correctness) → selector install → event-token journal (installNativeEvent, ids read from the batch's event commands so the deterministic 1,000,000-seed assignment stays single-sourced in the renderer) → child-first append — no command staging, no cloned record/generation maps, no operation replay, noactiveNodesindirection. The container'sLynxHostStateafterward is indistinguishable from the staged path, socaptureLynxFirstTree, background adoption, mismatch repair, capability handoff, and buffered-event replay are untouched.falseand keep the staged path (they are also the trees adoption declines today). Any failure faults the container exactly like the staged apply.main-renderer.tsexposes the id-assigned record tree onLynxFirstScreenRenderResult.nodes; the batch remains the wire/adoption product.main-thread.tsrenderFirstScreenNowtries the direct path first and falls back for declined trees.Why (measured, in-product)
The L0 evidence located the first-screen cost in the interpret → record graph → command batch → prepare → generic apply pipeline. #63 removed the interpreter for eligible templates; this PR removes the staging/apply half in the real stack. Same-window mount-create FCP@10k, fresh page per sample, AB/BA, n=5 (
benchmarks/lynx-table/prototype/results/fcp-10000-l3.md):The remaining gap to the floor is owned by the still-built command batch and record graph, background-thread boot, capture-side validation, and the engine floor — the next L3 slices, tracked in #62.
Validation
packages/lynx/tests/first-screen-direct.test.ts: differential equivalence — direct and staged appliers produce deep-equal adoption snapshots, event-token journals, and physical PAPI trees for a fixture with keyed rows, events, and a hidden Activity subtree; red-green verified by deliberately dropping the hidden-attribute write. Also pins the native-list fallback.pnpm typecheck:fileson the touched packages clean.pnpm test(full repo run beyond the projects above not executed in-session); native-engine gates (Explorer/Android/iOS) unchanged and still open per the roadmap.Risk / follow-ups
captureLynxFirstTreestill re-plans host prop patches for main-thread-prop validation; ahasMainThreadPropsfast exit is a follow-up flagged in the exploration notes.Provenance
agent-authored)Generated by Claude Code