Skip to content

Commit 81bae30

Browse files
committed
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
1 parent b656418 commit 81bae30

8 files changed

Lines changed: 275 additions & 24 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).

‎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); `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×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 … |
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×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: 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: 0 additions & 2 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
}
@@ -982,7 +981,6 @@ function laneWrite<T>(el: Signal<T> | Computed<T>, v: T): T {
982981
if (l._shown) el._pendingValue = v;
983982
else el._x!._lane = v;
984983
if ((el as any)._fn !== undefined) (el as Computed<T>)._time = clock;
985-
insertSubs(el);
986984
laneDirty(el, l);
987985
}
988986
schedule();

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,12 +1408,13 @@ export function insertSubs(node: Signal<any> | Computed<any>): void {
14081408
if (__OBSERVE__ && fanOut >= GRAPH_SIZE_WARN_AT) noteFanOut(node, fanOut);
14091409
}
14101410

1411-
/** Lane work re-staged (lanes.ts; `recompute`): the lane's members among
1412-
* its subscribers re-derive as the lane's work (REACTIVE_LANE_DIRTY), their
1413-
* runs held with it — not as stale readers republishing the committed view
1414-
* (#3460). After `insertSubs`. A render effect on no lane is marked too:
1415-
* inert for its pass (`recompute` seats a lane only from its own `_x`), it
1416-
* is a live write if the effect becomes a zombie later this flush — an
1411+
/** Lane work re-staged (lanes.ts; `recompute`): the node's subscribers are
1412+
* notified (`insertSubs`), and the lane's members among them re-derive as
1413+
* the lane's work (REACTIVE_LANE_DIRTY), their runs held with it — not as
1414+
* stale readers republishing the committed view (#3460). `l` is a lane, so
1415+
* it has a parent. A render effect on no lane is marked too: inert for its
1416+
* pass (`recompute` seats a lane only from its own `_x`), it is a live
1417+
* write if the effect becomes a zombie later this flush — an
14171418
* on-screen reader whose removal an adopted write stages follows the lane
14181419
* (the lane-membership ruling, 2026-10-05; `_update`).
14191420
*
@@ -1425,24 +1426,33 @@ export function insertSubs(node: Signal<any> | Computed<any>): void {
14251426
* seat: its pass starts from the frame's, as the inline effect's does, and
14261427
* `laneRead` re-derives it on the screen if that lane holds (`entered`). */
14271428
export function laneDirty(node: Signal<any> | Computed<any>, l: Transaction): void {
1429+
insertSubs(node);
14281430
for (let s = node._subs; s !== null; s = s._nextSub) {
14291431
const c = s._sub;
14301432
let t = c._x?._transaction;
1431-
// A reader the parent holds pending on its re-ask (a correction's
1433+
// A reader a hold has pending on its re-ask (a correction's
14321434
// re-derivation waiting on a refresh) re-derives from the guess as the
14331435
// lane's work, seated there before its pass: lane work reads the
1434-
// parent's flight as the screen (D-26, D-37), whether it reads the
1436+
// hold's flight as the screen (D-26, D-37), whether it reads the
14351437
// flight before the guess or after (D-28), and whether it reads the
14361438
// guess itself or a derivation of it — this walk runs at every lane
14371439
// node's change. Seated at the guess read, the earlier read threw the
1438-
// pass back into the hold (#4629).
1440+
// pass back into the hold (#4629). The hold is the lane's parent's (the
1441+
// same slot, D-33), or any hold whose flights the reader waits on are all
1442+
// `refresh()` re-asks (`_reask`; with none, its own flight): a re-ask
1443+
// asks no new question and holds nothing new (D-34 ¶3), so a guess into
1444+
// another log shows beside it at once (F-11, #4666). A reader pending on
1445+
// another hold's new question stays with that hold (#4577: seated, it
1446+
// would ask its question over the screen's input). One seated in another
1447+
// lane this flush moves; its pass reads that lane's guess and links the
1448+
// two (`enterLane`, A15), and `dissolveLane` skips a node it lost.
14391449
if (
14401450
t &&
1441-
l._parent &&
14421451
!(c as any)._type &&
14431452
(c._config & (CONFIG_HELD | CONFIG_OVERRIDE)) === CONFIG_HELD &&
14441453
(c._statusFlags & (STATUS_PENDING | STATUS_UNINITIALIZED)) === STATUS_PENDING &&
1445-
resolveTx(t) === resolveTx(l._parent)
1454+
(resolveTx(t) === resolveTx(l._parent!) ||
1455+
[...(c._x!._pendingSources ?? [c])].every(p => p._x!._reask))
14461456
)
14471457
list(c, (t = l));
14481458
if ((c as any)._type === EFFECT_RENDER && node._config & CONFIG_VERDICT)

‎packages/signals/src/store/optimistic.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,7 @@ function laneSet(node: Signal<any>, value: unknown, lane: ReturnType<typeof txOf
533533
list(node, lane);
534534
} else if (x._lane === value) return;
535535
x._lane = value;
536-
if (node._subs !== null) {
537-
insertSubs(node);
538-
laneDirty(node, lane);
539-
}
536+
if (node._subs !== null) laneDirty(node, lane);
540537
}
541538

542539
/** D-34 for a per-key guess (#4329): the derive's draft wrote new objects

0 commit comments

Comments
 (0)