Skip to content

Commit 81a12d8

Browse files
ryansolidclaude
andauthored
fix(signals): latest() opens no transaction for its verdict; its reader watches the seam (#4365) (#4393)
* fix(signals): latest() of a memo born in a lane throws NotReady instead of undefined (#4362, #4363, #4376) A memo whose compute reads latest(s) is re-asked as the write's verdict lane work, so it becomes a lane derivation. While its first pass is in flight, nothing is in the lane, and laneValueOf/display fell back to the committed value, which an uninitialized node does not have: - latest(m)/isPending(m) served undefined and probed it pending (#4363); - the lane's end committed that undefined as the node's answer and cleared STATUS_UNINITIALIZED with the flight still up, which tripped the flush loop guard for [latest(m), isPending(m)] (#4362); - in hydration, m2 = fetchC(1 + latest(m1)) asked fetchC(NaN) instead of adopting the streamed answer (#4376). laneValueOf/display now return NOT_PENDING for such a node, so every read throws NotReady (A7; A19 exc. 1) and the lane's end leaves the node in flight. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): latest(a) beside b() computes one pass on the frame's world (#4365) A memo or render effect that reads `latest(a)` beside `b()` computed a torn pass on a batched write. The `latest()` read of a's staging opened the flush's transaction for its verdict (verdict.ts `provisionalVerdict`). The plain `b()` read after it then took that transaction for a hold (`stagedScreen`): it served b's committed value and made the reader a stale reader of the transaction. Nothing held the flush, so that torn pass was one of the flush's frames. Through a memo, a render effect ran `[2,1]` before `[2,2]`. A throw from the pass stuck, because the landing skips errored readers. A pass seated in the verdict lane only by its own `latest()` read (REACTIVE_PROVISIONAL) now reads a staging as the frame does: it leaves the lane and is recorded in `stagedReaders`. If the frame commits, the pass was the frame's one pass. If the flush parks, the lane seam re-derives it on the committed world as display-ahead work. A reader whose own stale pass threw now re-derives at the landing. `stagedScreen` moves into lanes.ts behind a hook, so the core floor does not carry it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): keep a verdict reader's lane routing and own-error recovery (async-gen #119, #1238) - verdictValue: read the lane value before routing the reader into the verdict lane, so a node born in the lane with nothing in it yet is read as any uninitialized node (NotReady) without moving its reader (#1238). - reruns: a stale reader whose error is its own (thrown by its pass over the committed value it was served) re-derives at the landing; only an error from an errored source is skipped (#3945). With #4363 no longer committing `undefined`, async-gen case 119 reached this stuck error. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * chore: re-measure sizes over next @ 40cde2c, record async-gen improvements - scripts/size: ledger lines for `signals: + isPending/latest`, the compiled live page and live + router (+46/+46/+47 B minified over next); this PR's store-app line re-measured (97,019 B). - async-gen baseline: 15 recorded failures no longer reproduce (10 undefined-value, 4 final-screen, 1 unhandled-rejection). - RULES-INDEX regenerated; changeset notes the error recovery. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): re-derive a self-errored stale reader at the lane's end, not in reruns The verdict reader's own error from a served committed value (async-gen #119) now re-derives from `dissolveLane` (lane engine only) instead of a widened `reruns` condition, so the floors pay nothing (0 B; the lane scenarios +20 B over the previous form). `reruns` is next's again. Ledger re-measured; async-gen baseline unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): latest() opens no transaction for its verdict; its reader watches the seam (#4365) Rework #4365 to the ruled shape (R5): in provisionalVerdict, latest() no longer calls joinFuture(null). Like a probe read before anything has joined, it goes through watchVerdict. Its pass is the frame's. If the flush parks, it re-derives once in the verdict lane: it is marked unanswered, so the seam does not take the transaction it joined as its answer. A flush that has already joined a transaction (Vl1), and reads outside a flush (Vl3), are unchanged. This drops the stagedScreen variant (REACTIVE_PROVISIONAL, the stagedScreen hook move and the laneSeams change). It also drops this branch's `reruns` change: #4383 handles a self-errored stale reader in lanes.ts dissolveLane, and that branch merges next. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals, web): re-pin the keyed Show over latest() to two mounts at a park (R-5, #4365) Under design ruling R-5, latest() opens no transaction for its verdict. The keyed condition's first pass is the frame's, and Show mounts A there. The parked flush re-runs the latest() reader once in the verdict lane, and Show mounts A again. The lane's mount is the one shown (the early fallback, still asserted); the held frame's mount is discarded at the lane's reveal. mounts goes [1,2,2] -> [1,3,3] for the static and callback forms over latest(count). The committed-key and `on` rows are unchanged. This re-pin waits on Ryan's ruling. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): the lane's end re-derives a render effect's own stale error too The re-enqueue of a self-errored stale reader at the lane's end sat inside the non-effect branch, so a render effect whose display-ahead pass threw over a held write's screen value kept its error after the landing (found by the #4365 thread). It now applies to both. Byte-neutral (0 B minified in every scenario); floors 0 B. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals, web): note why the keyed Show over latest() mounts 3 at a park (D-2, A10) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): an async memo over a verdict memo asks each question once A memo that reads a verdict memo is a verdict reader (F-6, #4050), and propagateStatus re-derived every verdict reader when its source went pending. Re-derived, an async one was served the committed value it had already derived from (A10) and asked that question again; that flight held the verdict lane, and the source's held landing re-ran it as lane work onto the same committed value, a third ask. Only the landing's re-derive asked the new question. Now an async memo that is a verdict reader only by reading a verdict memo (it opened no isPending/latest window of its own: REACTIVE_WINDOW, set per pass by markVerdictReader) drops CONFIG_VERDICT when that memo goes pending and takes the plain pending mark: it is pending through the flight (F-9) and the hold's work until it lands, reading plainly (D-25, #3884), and asks once at the landing. Sync readers re-derive as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals): with #4383, isPending of the unresolved m1 holds its Loading, so the unheld latest case asks like the held one Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * docs(signals): regenerate RULES-INDEX Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): a latest() reader's frame flight is adopted at the landing, not asked again (#4365) Under R5 a latest() reader's first pass is the frame's: an async one asks the frame's question there. When the flush parks, the seam re-derives it in the verdict lane (F-6: the display-ahead view's own async), and that re-derive superseded the frame's flight. The transaction's landing then re-ran the reader as a stale reader and asked the frame's question a second time on the same input. The seam now parks the frame pass's flight (`_parked`) when it re-derives an async unanswered reader outside a lane, and the landing's `reruns` adopts it (`adoptFlight`: registered as if the re-derive had returned it, through a promise of its own so the frame pass's listener cannot land it twice) instead of re-running the reader. That happens whether the flight landed before the transaction or is still in the air. Any later pass drops the parked flight. Asks for m0 = ask(1 + latest(s) + s()) and m1 = ask(1 + m0()) after setS(2): m0:5, m0:4, m1:5, m0:5, m1:6 become m0:5, m0:4, m1:5, m1:6 (F-9: a re-ask of the same question is no new question). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(web): #4375 hydration pins the asks over latest(s) under R5's adopted frame flight Over `latest(s)` the write asks m0's frame question first (R5), the verdict lane's intermediate next, and the landing adopts the frame's flight: `m0:5, m0:4, m1:5, m1:6`, each question asked once. The control keeps its `m0:5, m1:6` tail. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): an async memo with no verdict window of its own takes no verdict role #4397 review: with two verdict sources (`m1 = ask(1 + m0() + m0b())` over `m0 = ask(1 + latest(s) + s())` and `m0b = ask(10 * (latest(t) + t()))`), the grouped `[isPending(m1), m1()]` reader asked `m1:5` a second time on stale inputs after both sources landed. m1 lost CONFIG_VERDICT when its first source went pending, but a pass that threw NotReady at that source's read picked it back up (F-6, `read`). The settle walk then re-ran m1 as a verdict reader, and the committed values a hold had moved past were served to it (A10). The demotion is now per pass, in `recompute`. An async memo (new CONFIG_ASYNC: its last answering pass registered a flight) whose pass opened no isPending/latest window of its own (REACTIVE_WINDOW) does not become a verdict reader by reading a verdict memo. It waits on its sources like any derivation (F-9), reads them plainly (D-25), and asks each question once. The side-effecting clear in `propagateStatus` is gone, since that path no longer sees such a memo as a verdict reader. Pinned: two verdict memos into one async memo, grouped and split, with no question asked twice and equal final screens. A `test.fails` pin records that the grouped shape still skips the t lane's m1:15/m1:16 asks that split makes: whether a later write merges into an open transaction or opens its own lane depends on grouping (#4398). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): two latest() readers under one async memo ask each question once - A latest() reader whose frame lands at the seam that would re-derive it in the verdict lane keeps its flight: the pass was the landing's (it asked the frame question twice in one flush). The check moves from core's `_update` into lanes.ts `laneSeams`. - Verdict-lane work that read a staging re-derives on the committed world only while the transaction holding the staging stays parked: judged on the flush's transaction, not the lane's parent, and not when the pass's own render effect is all that keeps it parked (`heldBy`). The re-derive asked a question already asked and showed it over inputs the landing replaced. - The landing's adopt of a parked frame flight is a lane hook (`laneAdoptHook`): scheduler.ts no longer imports `adoptFlight`. - #4398's grouped/split pin passes here: grouped and split ask the same questions with latest()'s pass the frame's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): a grouped reader over a held write shows the lane's answer A reader that groups isPending with the value over a held write (`[isPending(m1), m1()]`) never showed m1's lane answer, though a plain value reader did. Two things kept it out: - A pass served a held node's committed value (frameRead, a stale reader of the hold) still kept the node's propagated pending sources, so when it went pending on another source it never woke when that source settled. frameRead now drops what the served node propagated onto it (A15): the landing re-derives it. - A lane's reveal (reruns on a lane) cleared REACTIVE_FRAME_READ, the mark the held transaction's landing needed to re-run the reader. Only the transaction's own reruns clear it now. CONFIG_ASYNC is worked out once, at the end of each pass, from the pass's `_inFlight` (registered a flight: async; answered sync: not; pending or errored without a flight: the last answer's), so a plain sync recompute does no extra work and handleAsync no longer touches it. refresh(m0) mid-hold now shows the lane's answer for the refreshed question in every reader shape. Pins for the held write, an equal landing, and refresh after and mid-hold cover the value, pair and split readers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals): name frameRead in the held-shapes pin comment Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * chore(size): re-record this PR's four sizes over next @ 7ebd4a3 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): a latest() reader's lane answer reaches the screen whatever the grouping Three review cases on R5, decided from F-6 (display-ahead readers show the held change now, beside the held screen, in their own lane; the lane reveals at its own landing, ahead of the parent's) and D-22/D-23: - An isPending(m0) effect beside `v${m0()}`, with an unrelated async keeping the flush parked: the verdict lane revealed at the write, before R5's lane pass of m0 joined it, so m0's reader read m0 outside the shown lane and waited for the unrelated async. The verdict lane a re-derived latest() reader joins no longer reveals at that seam (laneSeams). - An async memo over latest(s) held only by its own flight: the lane asked m1:120 and its parent landed at the same seam, adopting the frame flight before the lane's reader re-ran, so only v220 showed. A parent whose lane reveals with readers to re-derive now lands a round later (`revealing`), so they show the lane's answer first: v120, then v220, inline and with latest(s) extracted into a memo (F-6; Ryan, 2026-10-29, after #4284). - A sync latest() memo's `[isPending(m0), m0()]` reader under an unrelated hold showed the frame pass's `true,12` before the lane's `false,22`: the same early reveal. It now shows `false,22` directly, as next does (D-22: the pass re-derives once as a verdict reader; D-23). `heldBy` now counts a lane under `t` that only `r`'s own flight keeps blocked: with the parent landing a round later, a lane pass's flight was the only thing parking it, and the seam re-derived the pass and asked its question again. Size: adoptFlight folds into adoptParked (-16 B) and adopts through `parked.then()` (-4 B). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * docs(signals): changeset for the latest() lane-answer fixes Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): an async memo over a verdict memo stays a verdict reader (D-25) Review of #4397: the strict rule (an async memo with no `latest`/`isPending` window of its own took no verdict role at all) overrode D-25 ("one that reads a verdict reader's value is ... a verdict reader itself"; "a memo computes under its own posture"). It caused two regressions against next: 1. Memo-extracted `latest()` (`v = createMemo(() => latest(s))`, `m1` async over `v()` and `s()`): m1's pass at the write read the transaction's staging and asked m1:220, the lane re-derived it (m1:120), and the landing asked m1:220 again. It now asks m1:120 then m1:220, once each, as the inline form does (D-22, F-9 exc. 2), showing v120 then v220 (F-6). 2. A reader disposed and remounted while the lane answer was in flight: `[isPending(m1), m1()]` in one effect showed true,4 -> true,5 -> false,6 while `m1()` alone and split showed 4 -> 6. All shapes now show the screen, then the landing (F-6: grouped holds like a lone read; D-26). The strict rule is gone. In its place, D-25's "a node whose fetch a hold is waiting on is that hold's work" (#3884), kept by the verdict engine (verdict.ts `holdWork`, behind `holdWorkHook`, like `observeFlightHook`): - A verdict source going pending does not re-derive an async memo with no window of its own: none of its reads changed, and re-derived it was served the committed value it had already derived from and asked that question again (A10). It waits on the source like any derivation (F-9). Except when its own flight is up outside a lane on a new question of the source's: that re-run supersedes a flight asked of a value the source has moved past (a `refresh()` re-ask is the same question). - A held re-run of such a memo reads plainly, as a pending one already did (#3884): the write that re-ran it is its hold's. - Its async posture (CONFIG_ASYNC) is kept at each pass end in verdict.ts, not computed in core. Kept from the PR, as review asked: the frame read's drop of a served flight's pending (A15; now in lanes.ts `laneServed`, behind a hook, run only for lane work and verdict readers, with no closure), and `reruns` leaving the stale-reader mark to the transaction at a lane's reveal. Pins (tests/verdict-memo-flight-no-reask.test.ts): the memo-extracted and inline forms ask m1:120, m1:220 once and show v110, v120, v220 in every reader shape (D-22, D-25, F-6); a reader remounted mid-flight shows the screen, then the landing, grouped as alone or split (F-6, D-26). Both fail on the previous head. Size: the floors are +14 B minified over next (was +126). The verdict scenarios carry the rule: + isPending/latest +339 B. Ledger lines and the frozen live-server-components floor are re-recorded to the measured sizes (Size-Exception: floor-caps.json 115,423 -> 115,646 B minified, measured 38,197 B brotli; the maintainer relaxed the size rule for this fix). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals): pin the remount shapes on what holds whatever the timing CI ran the "remounted mid-flight, then a write" pin slower than local runs: the landing's `m1:6` was asked before the remount in the grouped run and after the write in the lone run, so comparing one shape's asks against another's compared two timings, not two shapes. Run at a later remount locally, every shape asks `m1:6` alike, and none diverges. The pin now states what holds at any timing, per shape: no question asked twice (F-9), the lane's `m1:5` never shown to a reader mounted mid-hold (D-26), and the grouped `[isPending(m1), m1()]` ending on the landing like the lone read (F-6). The no-write case still fails on the strict rule's head, where the grouped remount showed `true,5`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals): land the extracted pin's flights by hand, not by timer CI's coverage run (slower than a plain run) let m1's 10 ms lane flight land before the pin's 2 ms sleep ended, so the later write came after the landing and the run asked m1:220 where the pin expects m1:125. The pin compared two timings, not two behaviours. m1's flights now land only when the test lands them, so the later write always comes while the write's flights are up. The pin's expectations are unchanged (D-25, D-22, F-6, F-9), and it still fails on ee0b535's source in all three reader shapes (the m1:220, m1:120, m1:220 triple ask). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): only an async memo with no window of its own is hold work (D-25) Review of #4397: REACTIVE_WINDOW was wiped at the pass tail, and both of holdWork's consumers (the pass head and propagateStatus) run between passes, so `own` was CONFIG_ASYNC alone. The rule hit every async verdict memo, including one that calls latest()/isPending() itself, and changed screens against next on the canonical F-6 shape: an async memo over `${isPending(m0)}:${latest(m0)}` never showed the lane's true:2, and one over latest(m0) read through [isPending(m1), m1()] skipped l1 and showed true,l1. CONFIG_ASYNC is now set at the pass end, while the pass's REACTIVE_WINDOW is still up, only for a pass that registered a flight and opened no window; a pass that opened one clears it. A memo that asks is a verdict reader whoever dirties it (D-25, ruled 2026-10-28), unchanged from next. The held re-run arm applies only to memos that never asked; removing it reasks m1:5/m1:104/m1:15 in five pins, so it stays, documented against D-25. Pins: the two own-window shapes, as next shows them (D-25, F-6). The pin file takes the hand-landed flights from the split prepared for review, so no pin races a timer. Ledger re-records dropped: the size ledger is re-recorded once on next after the batch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * perf(signals): keep D-25's async posture off recompute's hot path CONFIG_ASYNC is now set where a flight registers (handleAsync) and cleared by a verdict window (markVerdictReader) or a sync answer, instead of a holdWork call at every pass's end. The pass-head check is inline. holdWork only answers propagateStatus. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): R5 with #4397 asks each question once Merging #4397 into #4393 asked three questions twice: - An async memo over `latest()` of a flight (the own-window pins) took R5's frame pass and then a verdict-lane pass that asked the same question again. `latest` of a flight serves the committed value in either world (D-22), so the seam has nothing to decide. The reader joins the verdict lane at once, as a plain read of a flight makes it (`observeFlight`). `latest` of a staging stays the seam's (#4365). - An async memo over a `latest()` memo (D-22 extracted): R5 parked only the reader's own flight. The memo's frame flight was superseded by its lane pass, and the landing asked `m1:220` again. The seam now parks the frame flights of a sync reader's async readers held by the frame, and the landing adopts them as it does inline (F-9). The remount and extracted pins take R5's order: the frame's question comes first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): a verdict effect's staged read before the frame's transaction re-derives once if the flush parks (D-22) In R5, latest() opens no transaction. A render effect that is a verdict reader (`v:${s()} a:${A()} l:${latest(s)}`) read s's staging before the frame had a transaction, so it stayed the frame's pass. Its held run then showed `l:0` until the landing. stagedRead now also lists such an effect for the seam, which re-derives it once as a verdict reader when the flush parks, as D-22 and D-25 require: it shows `v:0 a:0 l:1`. This is limited to effects. A memo is not a leaf, and with async memos the re-run asked its question again. With every memo, the async-gen case e1-3289-1831 ended on [ROOT-E]. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals): pin #4393's beside shape as it.fails for the reader-seat carve (F-6, D-26) With #4397 merged, m1 is a verdict reader between its flights (D-25) and m0's lane pass re-derives it into the s lane early, so the t transaction lands while m1:1122 is in flight. Telling that pass apart as the hold's work needs a per-pass check; it goes to the carve. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * test(signals): land twoVerdicts' flights by hand The grouped-vs-split ask order raced its 10 ms flights against a 12 ms sleep on a slow runner (m0b:20 before m1:5). The t write now comes after the s write's first flights land, while m1's question is up. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * perf(signals): keep R5's parked flight off the floors The recompute clear runs only with the lane engine, and ext() no longer seeds the field, so builds without lanes drop both (-39 B minified on every floor). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 --------- Co-authored-by: Claude <[email protected]>
1 parent 9baaba3 commit 81a12d8

15 files changed

Lines changed: 908 additions & 104 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
A memo or render effect reading `latest(a)` beside `b()` no longer computes a torn pass on a batched write (#4365). The `latest()` read of a's staging opened a transaction for the flush, and the plain `b()` read after it took that transaction for a hold, so it paired a's new value with b's old one. Nothing held the flush, so that pass was shown: a render effect behind a memo ran `[2,1]` before `[2,2]`, and a throw from the pass stuck at the error boundary. `latest()` no longer opens a transaction. Its reader's pass belongs to the frame, and if the flush parks it runs once more in the verdict lane, ahead of the hold.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
An async memo that reads `latest()` no longer asks the frame's question twice when its flush parks. Its first pass belongs to the frame and asks that frame's question. When the flush parks, the memo re-derives in the verdict lane for the display-ahead view, and that re-derive used to discard the frame's flight, so the transaction's landing asked the same question again. The landing now adopts the frame's flight, whether it has already landed or is still in flight.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Two `latest()` async readers under one async memo, with the second input written while the first one's flush is parked, ask each question once. A `latest()` reader whose frame lands at the seam no longer re-derives in the verdict lane, so its frame question isn't asked a second time. A verdict-lane pass that read a staging re-derives only while the transaction holding that staging stays parked, judged on that transaction rather than the lane's parent and not counting the pass's own render effect. Before, the memo asked a question twice and could show a value derived from the input's old answer next to its new one.
6+
7+
A `latest()` reader's lane answer now reaches the screen whatever the grouping. An `isPending()` effect beside the reader no longer makes it wait for an unrelated hold, and an async memo over `latest()` that only its own flight holds shows the lane's answer before the final one. A `[isPending(m), m()]` reader of a sync `latest()` memo no longer shows a pending pair with the old value before the lane's.

‎packages/signals/docs/RULES-INDEX.md‎

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

‎packages/signals/src/core/core.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
399399
)
400400
el._config &= ~CONFIG_VERDICT;
401401
if (el._x !== null) {
402+
// The seam's re-derive runs with the parked flight still current; any
403+
// later pass asks its own question (`_parked`; only the lane engine
404+
// parks one).
405+
const p = laneStageHook && el._x._parked;
406+
if (p && p !== el._x._inFlight) el._x._parked = undefined;
402407
el._x._inFlight = null;
403408
// Supersede is where an iterator flight dies (#3122): close it now.
404409
// Idempotent with the cleanup-channel close.
@@ -2195,7 +2200,14 @@ export function serve(el: Signal<any> | Computed<any>, c: Computed<any> | null):
21952200
export function stagedRead(c: Computed<any>, el?: Signal<any> | Computed<any>): void {
21962201
if (!((el as Computed<any> | undefined)?._statusFlags! & STATUS_UNINITIALIZED)) {
21972202
c._flags |= REACTIVE_STAGED_READ;
2198-
if (laneSeamsHook && passLane !== null) stagedReaders.push(c);
2203+
// A verdict reader's too when it is an effect, before the frame has a
2204+
// transaction (after, `stagedScreen` serves it the screen): the staging
2205+
// is the frame's read, and the pass re-derives once as a verdict reader
2206+
// if the flush parks (D-22; D-25: the probe decides the posture in either
2207+
// read order). A memo's is the frame's derivation either way: a memo is
2208+
// not a leaf (`frameRead`).
2209+
if (laneSeamsHook && (passLane !== null || ((c as any)._type && c._config & CONFIG_VERDICT)))
2210+
stagedReaders.push(c);
21992211
}
22002212
}
22012213

‎packages/signals/src/core/lanes.ts‎

Lines changed: 121 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,14 @@ import {
6060
} from "./constants.js";
6161
import { attrHooks } from "./attribution-hooks.js";
6262
import { bornInto, creatorReads, ext, stagedRead, tracking } from "./core.js";
63-
import { NotReadyError } from "./error.js";
64-
import { removePendingSource } from "./async.js";
63+
import { NotReadyError, type StatusError } from "./error.js";
64+
import {
65+
handleAsync,
66+
isThenable,
67+
notifyStatus,
68+
releaseFlightTeardown,
69+
removePendingSource
70+
} from "./async.js";
6571
import { laneValueOf } from "./truth.js";
6672
import { enqueueSub } from "./heap.js";
6773
import {
@@ -576,6 +582,18 @@ function dissolveLane(l: Transaction, into: Transaction | null, except?: Signal<
576582
n._config |= CONFIG_INPUTS_PUBLISHED;
577583
if (shown !== NOT_PENDING && (!n._equals || !n._equals(shown, n._value))) insertSubs(n);
578584
}
585+
// A stale reader's own error — its pass (a memo's or a render
586+
// effect's) threw over the committed value of what the parent held
587+
// (A10), served as the screen — is no answer of the world landing now:
588+
// it re-derives on it (A15; D-39, the landing is the new answer). The
589+
// landing's `reruns` skips an errored reader: its error is an errored
590+
// source's (#3945).
591+
if (
592+
(n as Computed<any>)._flags & REACTIVE_FRAME_READ &&
593+
(n as Computed<any>)._statusFlags & STATUS_ERROR &&
594+
(x._error as StatusError).source === n
595+
)
596+
enqueueSub(n as Computed<any>);
579597
} else if (guess) {
580598
// A guess of a dissolving lane: its truth — a landing held beneath it,
581599
// else the value it covered — is the parent's to land, and its readers
@@ -784,7 +802,7 @@ function laneSeam(l: Transaction, leaked: boolean): void {
784802
}
785803
l._held = false;
786804
l._shown = true;
787-
reruns(l);
805+
if (reruns(l)) revealing.push(resolveTx(l._parent!));
788806
for (let i = 0; i < l._nodes.length; i++) {
789807
const n = l._nodes[i] as Computed<any>;
790808
if (n._flags & LEFT_SHOWN) {
@@ -850,8 +868,14 @@ function endLanes(u: Transaction): void {
850868
function lanesBlocked(t: Transaction): boolean {
851869
return (t._lane && linkBlocked(t)) || nestedBlocked(t);
852870
}
871+
/** Parents whose lane revealed this seam with readers to re-derive there
872+
* (`laneSeam`): the lane shows ahead of its parent (F-6), so the parent lands
873+
* a round later — after those readers have shown the lane's answer — even
874+
* when nothing else holds it (#4393). */
875+
const revealing: Transaction[] = [];
853876
/** The lanes under `t` (its own; a link group's are each other's). */
854877
function nestedBlocked(t: Transaction): boolean {
878+
if (revealing.indexOf(t) !== -1) return true;
855879
for (let i = 0; i < lanes.length; i++) {
856880
const l = lanes[i];
857881
if (resolveTx(l._parent!) !== t) continue;
@@ -950,12 +974,37 @@ const applyGuessesAt = (parent: Transaction | null): void => {
950974
judged = lanes.length;
951975
if (pendingGuesses.length !== 0) applyGuesses(parent);
952976
};
977+
/** `t` is parked by `r`'s pass alone: each node keeping it — `t`'s own, or
978+
* a lane's under it — is `r` itself (its flight, in the verdict lane) or a
979+
* render effect pending on `r` only: the frame observing the lane work that
980+
* read its staging. Anything else (an open action, a guess's flight,
981+
* another flight) holds it on its own. */
982+
function heldBy(t: Transaction, r: Computed<any>): boolean {
983+
if (t._open !== 0 || (t._lane && linkBlocked(t))) return false;
984+
for (let k = -1, u = t; u; u = lanes[++k])
985+
if (u === t || resolveTx(u._parent!) === t) {
986+
if (u !== t && guessFlights(u)) return false;
987+
for (let i = 0; i < u._nodes.length; i++) {
988+
const n = u._nodes[i] as Computed<any>;
989+
if (
990+
n === r ||
991+
!(n._statusFlags & STATUS_PENDING) ||
992+
(n._x!._transaction !== null && txOf(n) !== u)
993+
)
994+
continue;
995+
const s = n._x!._pendingSources;
996+
if ((n as any)._type !== EFFECT_RENDER || s?.size !== 1 || !s.has(r)) return false;
997+
}
998+
}
999+
return true;
1000+
}
9531001
const laneSeams = (t: Transaction | null): void => {
9541002
// Passes that read a write the parked frame holds as the screen
9551003
// (`stagedReaders`: lane work, a verdict reader before the verdict): they
9561004
// re-derive on the committed world next round (and register as stale
9571005
// readers of the transaction there); a lane's runs wait that round — a
9581006
// lane sees the screen plus its own guesses.
1007+
if (revealing.length) revealing.length = 0;
9591008
const leaked: Transaction[] = [];
9601009
if (t !== null)
9611010
for (let i = 0; i < stagedReaders.length; i++) {
@@ -970,23 +1019,29 @@ const laneSeams = (t: Transaction | null): void => {
9701019
// lane answered for itself: it re-derives at the holder's landing, not
9711020
// now (one run — #3322, #3540). Other verdict-lane work re-derives only
9721021
// if the frame stays parked: a transaction landing at this seam makes
973-
// what it read the screen (one run). A reader a transaction holds that
974-
// read none of its stagings (a verdict reader that probed only a
975-
// flight, held as the frame's pending observer or its staged
976-
// derivation) has nothing to re-derive: its re-run re-enters that
977-
// transaction and parks it again, every round — it runs at the
978-
// landing (#4349). One that read a staging re-derives only if its
979-
// frame stays parked: landing at this seam, what it read is the screen
980-
// (one run, D-22). Not one born into that frame (a held pass's child,
981-
// ruling A): it has no screen, its reads are the transaction's either
982-
// way — it runs again at the landing, not now.
1022+
// what it read the screen (one run). The frame is the transaction that
1023+
// holds what it read (`t`, this flush's — not always the lane's parent:
1024+
// a landing that reached a frame held elsewhere joined that one). Nor
1025+
// when only this pass keeps it parked (`heldBy`): the frame lands with
1026+
// the pass's answer, so what the pass read is the screen when anything
1027+
// shows it — re-derived on the committed world, it would ask a question
1028+
// already asked, over inputs the landing replaces. A reader a
1029+
// transaction holds that read none of its stagings (a verdict reader
1030+
// that probed only a flight, held as the frame's pending observer or
1031+
// its staged derivation) has nothing to re-derive: its re-run
1032+
// re-enters that transaction and parks it again, every round — it
1033+
// runs at the landing (#4349). One that read a staging re-derives only
1034+
// if its frame stays parked: landing at this seam, what it read is the
1035+
// screen (one run, D-22). Not one born into that frame (a held pass's
1036+
// child, ruling A): it has no screen, its reads are the transaction's
1037+
// either way — it runs again at the landing, not now.
9831038
if (
9841039
r._flags & REACTIVE_DISPOSED ||
9851040
(l?._lane
9861041
? l._parent?._verdict === l &&
9871042
(r._config & CONFIG_VERDICT
9881043
? !(r._flags & REACTIVE_PROBE_UNANSWERED)
989-
: !blocked(l._parent))
1044+
: !blocked(t!) || heldBy(t!, r))
9901045
: l &&
9911046
!(
9921047
r._flags & REACTIVE_PROBE_UNANSWERED ||
@@ -1001,6 +1056,38 @@ const laneSeams = (t: Transaction | null): void => {
10011056
// again — every round (#4014). A computed is already seated by its
10021057
// override, and a written guess's own pass stays the frame's.
10031058
if (l?._lane && (r as any)._type) r._flags |= REACTIVE_LANE_DIRTY;
1059+
// R5 for an async reader: its frame pass asked the frame's question
1060+
// (F-6's lane gets its own pass now). That flight is the frame's
1061+
// answer: the landing adopts it rather than asking it again (F-9: a
1062+
// re-ask of the same question is no new question; `reruns`). A frame
1063+
// landing at this seam has nothing to re-derive: the pass was the
1064+
// landing's, its flight the screen's answer. Sync or async, the
1065+
// reader's lane pass is still to come: the verdict lane it joins does
1066+
// not reveal this seam (F-6: the lane's readers show its answer
1067+
// together, D-23: atomic with the value) — revealed now, it showed a
1068+
// verdict beside the frame pass's value, before the pass that answers
1069+
// for the lane, and a reader of the re-derived memo read it outside
1070+
// the shown lane and waited for the frame (#4393).
1071+
else if (!l?._lane && r._flags & REACTIVE_PROBE_UNANSWERED) {
1072+
if (isThenable(r._x?._inFlight)) {
1073+
if (!blocked(t!)) continue;
1074+
r._x!._parked = r._x!._inFlight;
1075+
} else if (blocked(t!))
1076+
// A sync reader's lane pass re-derives the async memos over it (a
1077+
// memo over a verdict memo is a verdict reader, D-25 #4050; D-22:
1078+
// `latest()` extracted into a memo reads as inline). The flight
1079+
// each asked over its frame staging, up and held by `t`, is the
1080+
// frame's answer too: the landing adopts it (F-9).
1081+
for (let s = r._subs, n; s; s = s._nextSub)
1082+
if (
1083+
isThenable((n = s._sub)._x?._inFlight) &&
1084+
n._x!._pendingSources?.has(n) &&
1085+
n._config & CONFIG_HELD &&
1086+
txOf(n) === t
1087+
)
1088+
n._x!._parked = n._x!._inFlight;
1089+
if (t?._verdict && leaked.indexOf(t._verdict) === -1) leaked.push(t._verdict);
1090+
}
10041091
enqueueSub(r);
10051092
if (l?._lane && leaked.indexOf(l) === -1) leaked.push(l);
10061093
}
@@ -1019,6 +1106,25 @@ const laneSeams = (t: Transaction | null): void => {
10191106
enqueueSub(r);
10201107
}
10211108
};
1109+
/** The landing's re-derive of a reader whose frame flight the seam parked
1110+
* (R5): the flight asked the question the landing would — adopted, it is
1111+
* asked once (F-9). Not over a pass already queued: that one asks anew.
1112+
* Registered as if this pass had returned it — the node pending on it, its
1113+
* landing the answer — through a promise of its own: the frame pass's
1114+
* registration still listens to the flight, and must not land it a second
1115+
* time. */
1116+
const adoptParked = (r: Computed<any>): boolean => {
1117+
const parked = r._x?._parked;
1118+
if (!parked || r._flags & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP)) return false;
1119+
r._x!._parked = undefined;
1120+
releaseFlightTeardown(r);
1121+
try {
1122+
handleAsync(r, parked.then());
1123+
} catch {}
1124+
r._x!._blocked = true;
1125+
notifyStatus(r, STATUS_PENDING, new NotReadyError(r));
1126+
return true;
1127+
};
10221128
/** A15: lane work or a verdict reader was served `el`'s committed value
10231129
* (core.ts `frameRead`), so its pass does not wait on `el`'s flight: what
10241130
* `el`'s pending propagated onto it before the pass (its origins, `el`
@@ -1042,6 +1148,7 @@ installLaneHooks(
10421148
() => lanes.length !== 0 && laneCorrections(),
10431149
endLanes,
10441150
lanesBlocked,
1151+
adoptParked,
10451152
laneServed
10461153
);
10471154
if (__OBSERVE__)

‎packages/signals/src/core/scheduler.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ export let laneSeamsHook: ((t: Transaction | null) => void) | null = null;
8080
export let laneCorrectionsHook: (() => boolean) | null = null;
8181
export let endLanesHook: ((u: Transaction) => void) | null = null;
8282
export let lanesBlockedHook: ((t: Transaction) => boolean) | null = null;
83+
/** R5 (lanes.ts `laneSeams` parks a frame flight): the landing's re-derive
84+
* of a reader adopts the flight instead (true: adopted, nothing to queue). */
85+
export let laneAdoptHook: ((r: Computed<any>) => boolean) | null = null;
8386
/** core.ts `frameRead` served lane work or a verdict reader a held node's
8487
* committed value (lanes.ts `laneServed`). */
8588
export let laneServedHook: ((c: Computed<any>, el: Signal<any> | Computed<any>) => void) | null =
@@ -101,6 +104,7 @@ export function installLaneHooks(
101104
corrections: NonNullable<typeof laneCorrectionsHook>,
102105
end: NonNullable<typeof endLanesHook>,
103106
blocked: NonNullable<typeof lanesBlockedHook>,
107+
adopt: NonNullable<typeof laneAdoptHook>,
104108
served: NonNullable<typeof laneServedHook>
105109
): void {
106110
laneReadHook = read;
@@ -112,6 +116,7 @@ export function installLaneHooks(
112116
laneCorrectionsHook = corrections;
113117
endLanesHook = end;
114118
lanesBlockedHook = blocked;
119+
laneAdoptHook = adopt;
115120
laneServedHook = served;
116121
}
117122
// Boundaries (boundaries.ts): the display consumers between an observer
@@ -1217,7 +1222,9 @@ export function reruns(u: Transaction): unknown {
12171222
// frame being replaced — void too (#3404).
12181223
for (let c = r._firstChild; c !== null; c = c._nextSibling)
12191224
if ((c as any)._type) (c as any)._modified = false;
1220-
enqueueSub(r);
1225+
// A frame flight the seam parked (lanes.ts `laneSeams`, R5) asked the
1226+
// question this landing would: adopted, it is asked once (F-9).
1227+
if (!laneAdoptHook?.(r)) enqueueSub(r);
12211228
}
12221229
}
12231230
u._reruns.length = 0;

‎packages/signals/src/core/types.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ export interface NodeExtension {
123123
* it, `isPending` reads a staged answer as a change over it, and a
124124
* recovery equal to the last good value is still a new answer. */
125125
_shownError: unknown;
126+
/** R5: the frame pass's flight of a `latest()`/`isPending()` reader the
127+
* seam re-derived in the verdict lane (lanes.ts `laneSeams`) — the
128+
* frame's answer to the question it asked, which the transaction's
129+
* landing adopts instead of asking it again (lanes.ts `adoptParked`, F-9). Cleared
130+
* by any later pass. */
131+
_parked?: PromiseLike<any>;
126132
}
127133

128134
export interface RawSignal<T> {

0 commit comments

Comments
 (0)