Skip to content

Commit ab5b5cb

Browse files
ryansolidclaude
andauthored
fix(signals): a guess into a second optimistic log shows beside another action's refresh (#4666) (#4669)
* fix(signals): a guess into a second optimistic log shows beside another action's refresh (#4666) laneDirty seats a held pending reader in the lane before its pass, so lane work reads the hold's flight as the screen (D-26, D-37) in either read order (D-28). It only did so when the reader's hold was the lane's own parent, which is true when the second guess goes into the same slot (D-33 entangles the actions, #4637). A guess into a different createOptimistic opens a lane under its own action, so the overlay held by the first action's refresh(server) was not seated: its pass ran as that hold's work, threw on the pending list and stayed hidden until every refresh landed. The seat now also takes a reader whose every pending flight is a refresh() re-ask (_reask; with none, its own flight). A re-ask asks no new question and holds nothing new (D-34 para 3), so the guess shows at once (F-11). A reader pending on another hold's new question stays with that hold (#4577). laneDirty now runs insertSubs itself (every call site did so first), and drops the l._parent check (l is always a lane, which always has a parent). That pays for the new arm: 0 B on the core floors. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * fix(signals): a guess into a log whose lane has shown is not held by another action's refresh (#4666) Residual shape the #4666 fuzz found: rows 1-4; close(4), assign(3), land assign:3, then close(3), and #3 stayed shown until every refresh landed. close(3)'s guess goes into close(4)'s lane, which has already shown. The overlay, held by assign's refresh, is seated there by laneDirty, but the lane is judged in the same seam with the overlay's stale pending, so it holds once. The overlay's lane pass then writes the lane's staging for its next reveal (`_pendingValue`, the lane has shown). The render effect, held by the frame the flush joined, read that through laneRead's frame-staging branch as if it were its frame's staging: its run waited with the parked frame, and the reveal never re-ran it. On a shown guess lane, `_pendingValue` is the lane's staging, so a held leaf reads it as the screen and re-derives at the reveal, or enters the lane (F-11, D-26). A verdict lane keeps the branch: there the staging is the frame's (#4275, S-39). The lane-is-a-verdict-lane test is now one helper (isVerdict) in lanes.ts, shared by its six sites, which pays for the new condition. 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 1445197 commit ab5b5cb

8 files changed

Lines changed: 324 additions & 30 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+
An optimistic guess into a second `createOptimistic` log shows at once while another action's `refresh()` is in flight over the list both read (#4666). A reader held by that action's hold is seated in the new guess's lane when every flight it waits on is a re-ask (D-34 ¶3, F-11); one pending on a new question stays held (#4577). The same holds when that log already carries another action's guess whose lane has shown: a render effect reading the overlay now re-runs at that lane's reveal instead of waiting with the refresh's hold.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ What is rendered from a display-ahead read reveals together with it: an async me
216216

217217
A held display-ahead world ("a lane") is a hold seen from the outside. A render effect _off_ it that reads what it is revealing — mounted mid-hold, or re-run by an unrelated sync write — shows the committed value (what is on screen), publishes now, entangles nothing, and re-derives at the release: `Late: 0` at the mount, `Details: 1 | Late: 1 | Value: 1` at the release. `latest()` is not special here: a `createOptimistic` source behaves the same. A reader whose removal is staged in a live hold is still on screen and keeps holding the lane while visible; `latest()` read in such a branch peers through to the proposal. A direct leaf reading a lane's derivation shows the lane's revealed value and re-derives at the reveal (control and content never disagree); a derivation between (a memo, a boundary's tree) carries the future and is born held with its mount (D-2). The same holds for a render effect that reads an optimistic value before its lane is judged: if the lane holds on a derivation's flight, the effect shows the committed value and `latest()` of the guess shows the guess beside it, whether the two reads share one render effect or not — `1 x1 / 5`, then `5 x5 / 5` at the landing (#4284). **Inside the lane, "sees the parent's landings" is about computing, not showing (clarified 2026-10-28):** a lane derivation that reads a value the parent holds joins that hold (D-1) — it computes now, so async downstream of it starts without waiting for the commit, and its result shows at the commit as the hold's work. What lane work _displays_ is the screen plus the lane's own values: its guesses, or what its `latest()` reads asked for. A plain read in lane work of a node the parent holds and the lane does not show ahead is the screen's value, in a verdict lane as in an optimistic one (F-6: "a plain read beside it is a read"); `[s(), L()]` with `L = createMemo(() => latest(s))` shows `v:0 l:1`, as the inline `[s(), latest(s)]` does. A15 #3460's sentence is the computing half.
218218

219-
**Collapses:** [A15](./SPEC-ASYNC-SEMANTICS.md#a15-transition-entanglement-is-graph-driven-lanes-settle-as-one-reveal) lanes corollary (#3460, #3463, #3479, #3662, #3698), #3444, the fuzzer-finding F8 ruling (2026-10-05, #3806), the adopted-staging ruling. **Status:** standing; fuzzer finding F5b ("a stale reader of a held re-guess shows the revealed guess") pinned `it.fails`. Grouping: `tests/lane-render-effect-grouping-4284.test.ts`. Fixed 2026-11-02 (#4629, #4633, #4637): a second action's guess into a slot whose earlier action's `refresh()` is in flight shows now, beside the screen's value of the re-asked node (the plain read in lane work above), whatever order the pass reads them in (D-28); `tests/projection-second-guess-4629.test.ts`, `tests/optimistic-second-guess-reask-4629.test.ts`.
219+
**Collapses:** [A15](./SPEC-ASYNC-SEMANTICS.md#a15-transition-entanglement-is-graph-driven-lanes-settle-as-one-reveal) lanes corollary (#3460, #3463, #3479, #3662, #3698), #3444, the fuzzer-finding F8 ruling (2026-10-05, #3806), the adopted-staging ruling. **Status:** standing; fuzzer finding F5b ("a stale reader of a held re-guess shows the revealed guess") pinned `it.fails`. Grouping: `tests/lane-render-effect-grouping-4284.test.ts`. Fixed 2026-11-02 (#4629, #4633, #4637): a second action's guess into a slot whose earlier action's `refresh()` is in flight shows now, beside the screen's value of the re-asked node (the plain read in lane work above), whatever order the pass reads them in (D-28); `tests/projection-second-guess-4629.test.ts`, `tests/optimistic-second-guess-reask-4629.test.ts`. Fixed 2026-11-03 (#4666): the same with the second guess written into a different `createOptimistic` log — a reader held by another action's hold shows the guess at once when every flight it waits on is a `refresh()` re-ask (D-34 ¶3: it holds nothing new), and a reader pending on that hold's new question stays held (#4577); also into a log whose lane has already shown, where a held leaf reads that lane's staging as the screen and re-derives at its reveal, not as its frame's staging; `tests/optimistic-second-log-guess-4666.test.ts`.
220220

221221
### D-27. A verdict reader's mount is a mainline mount
222222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
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×17 seat.ts×1 verdict.ts×5 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-probe-committed-4648.test.ts×2 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×18 seat.ts×1 verdict.ts×5 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-probe-committed-4648.test.ts×2 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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -977,11 +977,9 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
977977

978978
// insertSubs only walks _subs (no scheduling of its own), so a
979979
// subscriber-less node has nothing to notify.
980-
if (el._subs !== null) {
981-
insertSubs(el);
982-
// Lane work re-staged: the lane's members re-derive as its work.
983-
if (lane !== null) laneDirty(el, lane);
984-
}
980+
// Lane work re-staged: the lane's members re-derive as its work
981+
// (`laneDirty` notifies them first).
982+
if (el._subs !== null) lane !== null ? laneDirty(el, lane) : insertSubs(el);
985983
} else if (el._height != oldHeight) {
986984
for (let s = el._subs; s !== null; s = s._nextSub) insertIntoHeapHeight(s._sub, dirtyQueue);
987985
}

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ function applyGuesses(parent: Transaction | null): void {
266266
// The lane's members re-derive as its work (REACTIVE_LANE_DIRTY): a
267267
// blocked lane's re-guess does not re-run its render effects as stale
268268
// readers republishing the committed view (#3460).
269-
insertSubs(n);
270269
laneDirty(n, txOf(n));
271270
}
272271
}
@@ -285,7 +284,7 @@ export function enterLane(l: Transaction, c: Computed<any>): void {
285284
const f = (c._flags |= REACTIVE_LANE_READ),
286285
p = passLane;
287286
if (p === null) {
288-
const verdict = l._parent!._verdict === l;
287+
const verdict = isVerdict(l);
289288
// A verdict lane's value (a memo of `latest` / `isPending`, F-6) read by
290289
// a derivation that already read the frame's staging or joined its
291290
// hold, or by any pass a pass that did is creating: the verdict read
@@ -336,6 +335,10 @@ export function enterLane(l: Transaction, c: Computed<any>): void {
336335
setPassLane(l);
337336
}
338337
}
338+
/** Is `l` a verdict lane (its parent's `_verdict`)? False for none. */
339+
function isVerdict(l: Transaction | null | undefined): boolean {
340+
return l?._parent?._verdict === l;
341+
}
339342
/** Is `l` nested under `a` (an ancestor lane)? */
340343
function under(l: Transaction, a: Transaction): boolean {
341344
for (let t = l._parent; t !== null && t._lane; t = t._parent) if (t === a) return true;
@@ -761,13 +764,21 @@ export function laneRead(c: Computed<any> | null, el: Signal<any> | Computed<any
761764
// the leaf into another lane (no link): it reads that lane as from the
762765
// frame's seat (#4284).
763766
const p = passLane;
764-
const seated = p?._parent!._verdict === p;
767+
const seated = isVerdict(p);
765768
if (seated && (never || p !== l)) setPassLane(null);
766769
if (passLane === null || !sameLane(passLane, l)) {
767770
// (A lane that has never shown: the screen is the committed value.)
768771
if (never && l._shown) return NOT_PENDING;
772+
// A held leaf reads its frame's staging. Not a shown guess lane's:
773+
// there `_pendingValue` is the lane's staging for its next reveal
774+
// (`laneWrite`, `laneStage`), not the frame's — read as the frame's, the leaf's run
775+
// waited with the frame and the reveal never re-ran it; a guess into a
776+
// log whose lane has shown stayed hidden behind another action's
777+
// refresh (F-11, D-26, #4666). It reads the screen and re-derives at
778+
// the reveal (below), or enters the lane.
769779
if (
770780
!guess &&
781+
(!l._shown || isVerdict(l)) &&
771782
el._pendingValue !== NOT_PENDING &&
772783
c._config & CONFIG_HELD &&
773784
flushTransaction !== null &&
@@ -794,7 +805,7 @@ export function laneRead(c: Computed<any> | null, el: Signal<any> | Computed<any
794805
}
795806
// A verdict reader reads ahead of the seam's verdict: re-derived on the
796807
// screen if the lane holds (#4284).
797-
if (c._config & CONFIG_VERDICT && l._parent!._verdict !== l) entered.push(c);
808+
if (c._config & CONFIG_VERDICT && !isVerdict(l)) entered.push(c);
798809
}
799810
}
800811
enterLane(l, c);
@@ -982,7 +993,6 @@ function laneWrite<T>(el: Signal<T> | Computed<T>, v: T): T {
982993
if (l._shown) el._pendingValue = v;
983994
else el._x!._lane = v;
984995
if ((el as any)._fn !== undefined) (el as Computed<T>)._time = clock;
985-
insertSubs(el);
986996
laneDirty(el, l);
987997
}
988998
schedule();
@@ -1135,7 +1145,7 @@ const laneSeams = (t: Transaction | null): void => {
11351145
if (
11361146
r._flags & REACTIVE_DISPOSED ||
11371147
(l?._lane
1138-
? (l._parent?._verdict === l &&
1148+
? (isVerdict(l) &&
11391149
(r._config & CONFIG_VERDICT
11401150
? !(r._flags & REACTIVE_PROBE_UNANSWERED)
11411151
: !blocked(t!) || heldBy(t!, r))) ||
@@ -1193,8 +1203,7 @@ const laneSeams = (t: Transaction | null): void => {
11931203
// a pass routed into it — the park seam's zombie verdict readers re-run
11941204
// as its work so that this seam reveals them (#3444).
11951205
for (let k = lanes.length - 1; k >= 0; k--)
1196-
if (k < judged || lanes[k]._parent?._verdict === lanes[k])
1197-
laneSeam(lanes[k], leaked.indexOf(lanes[k]) !== -1);
1206+
if (k < judged || isVerdict(lanes[k])) laneSeam(lanes[k], leaked.indexOf(lanes[k]) !== -1);
11981207
// A verdict reader that entered a lane this seam held: its run waits with
11991208
// the lane, and the verdict beside it would freeze — it re-derives next
12001209
// round from the frame's seat, a stale reader of the lane (#4284).

0 commit comments

Comments
 (0)