Skip to content

Commit 061b013

Browse files
ryansolidclaude
andauthored
fix(signals): a latest() read of a flight does not hold a Loading on switch (#4661) (#4663)
* fix(signals): a latest() read of a flight does not hold a Loading on switch (#4661) A memo whose last run read `latest(() => list())` is still the hold's verdict reader on its next run (D-25). Its read of the switch's own staging (`f`) is the screen's, and that stale-reader mark (REACTIVE_FRAME_READ) made `blockedBy` count it as a frame reader of `list`'s new flight too — a flight it read only inside `latest()`, ahead of it (F-6). The switch was held and the `on` fallback never showed. At the seam, a verdict reader that read a flight of the frame only ahead of it this pass (and no flight plainly: `observeFlight`, `frameRead`) drops the mark and its rerun on the frame's landing: it holds nothing, keeps its committed value (maintainer, 2026-11-03: "intentional tearing"), and the flight's own landing re-derives it. Engine only (lanes.ts, verdict.ts). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * perf(signals): track #4661's read-ahead readers with one list, no WeakMap The seam drops the stale-reader mark of a verdict reader whose pass read a flight inside latest() before any plain flight read routed it (F-6). A plain read of a flight first routes the pass (REACTIVE_LANE_READ), so the read-ahead push is skipped and the reader still holds (A10, A15); later plain reads in a routed pass are the lane's and mark nothing. That replaces the pass-generation tuples, the plain-read WeakMap and the laneServed hook. A new variant pins the plain-read-first hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * fix(signals): a memo's plain read of a flight after its latest() window still holds (#4661) A window read routes the pass into the verdict lane, and `read` then served a later plain read of a flight as lane work: committed, no frame read. So `latest(len) + len()` did not hold where `len() + latest(len)` did, and with the #4661 seam sweep the f-read variant lost its hold too (A10, A15: read order never changes what holds). `read` now asks `observeFlight` for any verdict reader first (the same tokens, reordered: no core bytes). `observeFlight` serves a routed render effect as before (lane work, D-26) and has a memo observe the flight; that plain read takes the reader off the seam's read-ahead list. New variants pin the window-first order with and without the read of f. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE --------- Co-authored-by: Claude <[email protected]>
1 parent 227a01d commit 061b013

7 files changed

Lines changed: 371 additions & 9 deletions

File tree

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 whose last run read `latest(x)` no longer holds a `<Loading on>` switch while `x`'s new flight is up: its read of the switch's own write is the screen's, and a flight it reads only inside `latest()` is one it reads ahead of (F-6). The fallback shows at once; the memo keeps its committed value until the flight lands (#4661).

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
5454
| A7 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:167` | seat.ts×1 truth.ts×1 verdict.ts×1 | fuzz-findings-l2.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×2 spec-async-semantics.test.ts×2 visibility-oracle-store.states.ts×1 visibility-oracle.states.ts×1 visibility-oracle.test.ts×1 | [ruled, amended in place] Resolved async never reads `[false, undefined]` — After an async memo resolves, `[isPending(x), latest(x)]` is `[false, resolvedValue]` — never `[false, undefined]`. **Amende… |
5555
| A8 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:175` | — | create-deferred-3710.test.ts×1 createMemo.test.ts×1 visibility-oracle-store.states.ts×1 visibility-oracle.states.ts×2 | [ruled, amended in place 2026-07-07] `isPending(() => latest(x))` follows `x`'s own async only — verdicts are per-channel — (**re-ruled 2026-07-07c** — was "tracks the transition the same as `isPendin… |
5656
| A9 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:183` | async.ts×1 projection.ts×1 target.ts×1 | spec-async-semantics.test.ts×3 visibility-oracle-store.states.ts×4 visibility-oracle-store.test.ts×1 | [ruled, amended in place 2026-07-07] Store leaves behind a firewall report the firewall's new-question refetch — `isPending` on a store leaf behind a firewall reports the firewall's refetch like any a… |
57-
| A10 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:191` | async.ts×1 core.ts×3 lanes.ts×1 scheduler.ts×1 seat.ts×1 verdict.ts×4 | boundary-not-born-held-3540.test.ts×1 createMemo.test.ts×1 error-staged-recovery.test.ts×1 fuzz-findings-l2.test.ts×1 ispending-memo-unstamped-hold-3457.test.ts×2 latest-isPending-consistency.test.ts×3 latest-uninitialized-over-latest-4362.test.ts×1 verdict-contract.test.ts×2 verdict-memo-flight-no-reask.test.ts×1 | [ruled] `[isPending(x), x()]` is atomic within one scope — `[isPending(x), x()]` read in one scope is atomic: a reader that observed the fresh value must not see `pending === true` for it. |
57+
| A10 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:191` | async.ts×1 core.ts×4 lanes.ts×2 scheduler.ts×1 seat.ts×1 verdict.ts×5 | boundary-not-born-held-3540.test.ts×1 createMemo.test.ts×1 error-staged-recovery.test.ts×1 fuzz-findings-l2.test.ts×1 ispending-memo-unstamped-hold-3457.test.ts×2 latest-isPending-consistency.test.ts×3 latest-stale-branch-hold-4661.test.ts×3 latest-uninitialized-over-latest-4362.test.ts×1 verdict-contract.test.ts×2 verdict-memo-flight-no-reask.test.ts×1 | [ruled] `[isPending(x), x()]` is atomic within one scope — `[isPending(x), x()]` read in one scope is atomic: a reader that observed the fresh value must not see `pending === true` for it. |
5858
| A11 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:103` | — | latest-isPending-consistency.test.ts×1 loading-fallback-in-flush-3540.test.ts×2 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×1 | [ruled] Sync derivations of held sources are visible through `latest()`/`isPending()` — Sync derivations of transition-held sources are visible through `latest()`/`isPending()` (held sync recompute is… |
5959
| A12 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:199` | — | createOptimistic.test.ts×2 spec-async-semantics.test.ts×1 | [ruled, amended in place] Resting optimistic nodes report pending like a plain memo — A resting optimistic node reports pending via exactly the causes a plain async memo does (A19) — a reverting optim… |
6060
| A13 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:207` | — | spec-async-semantics.test.ts×7 | [ruled 2026-07-06 (promoted from B1)] Resting optimistic ≡ plain async memo at every checkpoint — (was B1) A resting optimistic node (no active override) is observationally identical to a plain async … |
6161
| A14 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:215` | — | spec-async-semantics.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B2)] Companion nodes get child lanes that do not merge with the owner — (was B2) `isPending`/`latest` companion nodes get child lanes that do not mer… |
62-
| A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:251` | async.ts×2 constants.ts×1 core.ts×4 effect.ts×1 lanes.ts×6 scheduler.ts×16 seat.ts×1 verdict.ts×4 store.ts×1 | async-chain-supersession.test.ts×1 boundary-output-frame-reader.test.ts×1 create-deferred-3710.test.ts×2 first-observer-stale-reader.test.ts×1 fuzz-findings-l2.test.ts×17 held-restore.test.ts×1 hold-recovers-landing-reruns-4469.test.ts×1 l2-contract.test.ts×7 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 lane-pass-stamped-effect-3662.test.ts×1 latest-memo-inline-parity.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×1 loading-fallback-in-flush-3540.test.ts×4 mount-over-foreign-hold-3761.test.ts×2 optimistic-lane-seam-loop-4643.test.ts×1 overlapping-flights.test.ts×3 posture-born-held-and-observation.test.ts×4 posture-store-parity.test.ts×2 reveal-carve-out.test.ts×2 shared-effect-no-entangle.test.ts×1 show-stale-child-in-action-4137.test.ts×1 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 tick-scoped-pass-transaction.test.ts×1 tracked-effect-staged-dep-4606-4607.test.ts×1 treeshake.test.ts×4 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-held-branch-4544.test.ts×1 verdict-shortcut-pending-source-liveness.test.ts×1 visibility-oracle-store.states.ts×6 visibility-oracle.states.ts×7 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B3)] Transition entanglement is graph-driven; lanes settle as one reveal — (was B3) Transition entanglement is graph-driven: writes whose async work … |
62+
| A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:251` | async.ts×2 constants.ts×1 core.ts×4 effect.ts×1 lanes.ts×6 scheduler.ts×16 seat.ts×1 verdict.ts×4 store.ts×1 | async-chain-supersession.test.ts×1 boundary-output-frame-reader.test.ts×1 create-deferred-3710.test.ts×2 first-observer-stale-reader.test.ts×1 fuzz-findings-l2.test.ts×17 held-restore.test.ts×1 hold-recovers-landing-reruns-4469.test.ts×1 l2-contract.test.ts×7 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 lane-pass-stamped-effect-3662.test.ts×1 latest-memo-inline-parity.test.ts×1 latest-stale-branch-hold-4661.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×1 loading-fallback-in-flush-3540.test.ts×4 mount-over-foreign-hold-3761.test.ts×2 optimistic-lane-seam-loop-4643.test.ts×1 overlapping-flights.test.ts×3 posture-born-held-and-observation.test.ts×4 posture-store-parity.test.ts×2 reveal-carve-out.test.ts×2 shared-effect-no-entangle.test.ts×1 show-stale-child-in-action-4137.test.ts×1 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 tick-scoped-pass-transaction.test.ts×1 tracked-effect-staged-dep-4606-4607.test.ts×1 treeshake.test.ts×4 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-held-branch-4544.test.ts×1 verdict-shortcut-pending-source-liveness.test.ts×1 visibility-oracle-store.states.ts×6 visibility-oracle.states.ts×7 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B3)] Transition entanglement is graph-driven; lanes settle as one reveal — (was B3) Transition entanglement is graph-driven: writes whose async work … |
6363
| A16 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:223` | scheduler.ts×1 | caught-reactive-read-diagnostic.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×2 spec-async-semantics.test.ts×1 strict-read-pending-store.test.ts×2 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×2 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B5)] `isPending` never throws in untracked contexts — (was B5) `isPending` never throws in untracked contexts — thunks that throw real errors or read… |
6464
| A17 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:71` | async.ts×3 constants.ts×1 lanes.ts×7 scheduler.ts×2 seat.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×2 store.ts×3 | create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×6 lane-uninitialized-landing-3648.test.ts×5 optimistic-over-held-row-3796.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×2 optimistic-undefined-override.test.ts×1 posture-store-parity.test.ts×1 refresh-await.test.ts×1 reveal-gating-contract.test.ts×3 spec-async-semantics.test.ts×10 createOptimisticStore.test.ts×2 kanban-a17-fixture.test.ts×3 optimistic-list-mutation-matrix.test.ts×1 optimistic-maparray-index-frame-f1.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 treeshake.test.ts×1 until.test.ts×1 visibility-oracle-store.states.ts×24 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×20 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from C4)] An active override is the displayed value until its transaction commits, and the graph's value until its own source answers — **Statement (curre… |
6565
| A18 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:81` | action.ts×1 async.ts×2 core.ts×3 lanes.ts×8 scheduler.ts×2 types.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×1 projection.ts×1 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×3 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-outside-view.test.ts×1 lane-uninitialized-landing-3648.test.ts×5 optimistic-move-duplicate-3548.test.ts×2 optimistic-read-lane-not-transaction-3698.test.ts×4 posture-store-parity.test.ts×5 spec-async-semantics.test.ts×5 flight-owned-transaction.test.ts×1 lane-authority-twins.test.ts×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 unchanged-presence-no-hold-3743.test.ts×2 superseded-before-first-commit.test.ts×4 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×17 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from B4)] An override lives exactly as long as its own transaction; a newer truth from the source supersedes it in the graph immediately, on screen at com… |

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,12 +2343,18 @@ export function read<T>(el: Signal<T> | Computed<T>): T {
23432343
!(el._config & CONFIG_OVERRIDE) &&
23442344
!(owner._statusFlags & STATUS_UNINITIALIZED)
23452345
) {
2346-
// A reader with no committed value yet sees the flight pending: a
2346+
// A verdict reader first, in a lane or not: a memo's plain read of a
2347+
// flight observes it whether or not a window read routed the pass first
2348+
// (A10; `observeFlight` serves a routed render effect as lane work, D-26,
2349+
// #4661). A reader with no committed value yet sees the flight pending: a
23472350
// boundary a lane mounts shows its fallback (A29's boundary exemption).
2348-
if (passLane !== null && !((c as Computed<any> | null)?._statusFlags! & STATUS_UNINITIALIZED))
2349-
committed = true;
2350-
else if (c !== null && c._config & CONFIG_VERDICT)
2351+
if (c !== null && c._config & CONFIG_VERDICT)
23512352
committed = observeFlightHook!(c as Computed<any>, owner);
2353+
else if (
2354+
passLane !== null &&
2355+
!((c as Computed<any> | null)?._statusFlags! & STATUS_UNINITIALIZED)
2356+
)
2357+
committed = true;
23522358
}
23532359
if (owner._statusFlags & STATUS_PENDING && !committed) {
23542360
// A reader landing on a pending node throws; an untracked read of an

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,18 @@ const laneSeams = (t: Transaction | null): void => {
10761076
// readers of the transaction there); a lane's runs wait that round — a
10771077
// lane sees the screen plus its own guesses.
10781078
if (revealing.length) revealing.length = 0;
1079+
// #4661 (F-6): a verdict reader whose pass read a flight of the frame
1080+
// ahead of it (`latest`, verdict.ts `pendingVerdict`) before any plain
1081+
// read of one is no frame reader of it, though its stale read of the
1082+
// frame's staging (A10, `stagedScreen`) marked it one
1083+
// (REACTIVE_FRAME_READ, which `blockedBy` counts): the mark comes off and
1084+
// the reader holds nothing. It keeps what it read — the committed value
1085+
// ("It should read the committed value, we can't reveal early outside of
1086+
// latest. This is intentional tearing.", maintainer, 2026-11-03) — and the
1087+
// flight's own landing re-derives it, not the frame's.
1088+
for (const c of ahead.splice(0))
1089+
c._flags & REACTIVE_FRAME_READ &&
1090+
((c._flags ^= REACTIVE_FRAME_READ), t?._reruns.splice(t._reruns.indexOf(c) >>> 0, 1));
10791091
const leaked: Transaction[] = [];
10801092
if (t !== null)
10811093
for (let i = 0; i < stagedReaders.length; i++) {
@@ -1226,6 +1238,9 @@ const laneServed = (c: Computed<any>, el: Signal<any> | Computed<any>): void =>
12261238
if (from && c._x?._pendingSources)
12271239
for (const s of from) if (removePendingSource(c, s)) settlePendingSource(c, s);
12281240
};
1241+
/** This flush's verdict readers that read a flight ahead of the frame
1242+
* (#4661, the seam). */
1243+
export const ahead: Computed<any>[] = [];
12291244
/** Render effects that read a verdict and entered a lane before its seam (#4284). */
12301245
const entered: Computed<any>[] = [];
12311246
installLaneHooks(

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import { settlePendingSource } from "./async.js";
6767
import { forgetThrownRead, warnStrictReadUntracked } from "./dev.js";
6868
import { NotReadyError } from "./error.js";
6969
import { link } from "./graph.js";
70-
import { display, laneValueOf, verdictLane } from "./lanes.js";
70+
import { ahead, display, laneValueOf, verdictLane } from "./lanes.js";
7171
import { deleteFromHeap, enqueueSub } from "./heap.js";
7272
import {
7373
blocked,
@@ -154,6 +154,10 @@ function route(c: Computed<any>, t: Transaction): void {
154154
* transaction (`bornInto`, #4010): it has no screen — it waits on the flight
155155
* with the rest of its frame. */
156156
function observeFlight(c: Computed<any>, el: Computed<any>): boolean {
157+
// A render effect routed into a verdict lane reads the screen as lane
158+
// work (D-26). A memo still observes the flight: a plain read after its
159+
// window is the frame's read, as one before it is (A10, F-6, #4661).
160+
if (passLane && (c as any)._type && !(c._statusFlags & STATUS_UNINITIALIZED)) return true;
157161
if (el._config & CONFIG_INPUTS_PUBLISHED || (el._config & CONFIG_HELD && bornInto(c, txOf(el))))
158162
return false;
159163
// A derived store's derive whose store has no reader (`fam.live` empty:
@@ -162,6 +166,7 @@ function observeFlight(c: Computed<any>, el: Computed<any>): boolean {
162166
if (globalQueue._running && (c as any)._fam?.live.size !== 0) {
163167
joinFuture(null);
164168
if (!(el._config & CONFIG_HELD)) queuePendingNode(el);
169+
ahead.splice(ahead.indexOf(c) >>> 0, 1);
165170
verdictRead(c, flushTransaction!, true);
166171
}
167172
return true;
@@ -284,10 +289,15 @@ function pendingVerdict(c: Computed<any> | null, el: Computed<any>): void {
284289
// seam, where a re-run would open it again, every flush (F-6, D-23).
285290
// (The mark is the transaction's own — `Transaction.latest` — so
286291
// nothing outlives its landing.)
287-
if (!probing)
292+
// Read ahead of, by a pass no plain read of a flight routed yet
293+
// (`observeFlight`): no frame read of it (F-6, #4661; lanes.ts
294+
// `laneSeams`). Once routed, the pass's later plain reads are the
295+
// lane's and mark nothing.
296+
if (!probing) {
297+
c._flags & REACTIVE_LANE_READ || ahead.push(c);
288298
flushTransaction ||
289299
(joinFuture(null), ((flushTransaction as Transaction | null)!.latest = 1));
290-
else if (flushTransaction?.latest) return route(c, flushTransaction);
300+
} else if (flushTransaction?.latest) return route(c, flushTransaction);
291301
provisionalVerdict(c, false); // decided above
292302
}
293303
}

0 commit comments

Comments
 (0)