Skip to content

Commit d6b4715

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

4 files changed

Lines changed: 53 additions & 10 deletions

File tree

‎.changeset/optimistic-second-log-guess-4666.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@solidjs/signals": patch
33
---
44

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).
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`. 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`.
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/src/core/lanes.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export function enterLane(l: Transaction, c: Computed<any>): void {
284284
const f = (c._flags |= REACTIVE_LANE_READ),
285285
p = passLane;
286286
if (p === null) {
287-
const verdict = l._parent!._verdict === l;
287+
const verdict = isVerdict(l);
288288
// A verdict lane's value (a memo of `latest` / `isPending`, F-6) read by
289289
// a derivation that already read the frame's staging or joined its
290290
// hold, or by any pass a pass that did is creating: the verdict read
@@ -335,6 +335,10 @@ export function enterLane(l: Transaction, c: Computed<any>): void {
335335
setPassLane(l);
336336
}
337337
}
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+
}
338342
/** Is `l` nested under `a` (an ancestor lane)? */
339343
function under(l: Transaction, a: Transaction): boolean {
340344
for (let t = l._parent; t !== null && t._lane; t = t._parent) if (t === a) return true;
@@ -760,13 +764,21 @@ export function laneRead(c: Computed<any> | null, el: Signal<any> | Computed<any
760764
// the leaf into another lane (no link): it reads that lane as from the
761765
// frame's seat (#4284).
762766
const p = passLane;
763-
const seated = p?._parent!._verdict === p;
767+
const seated = isVerdict(p);
764768
if (seated && (never || p !== l)) setPassLane(null);
765769
if (passLane === null || !sameLane(passLane, l)) {
766770
// (A lane that has never shown: the screen is the committed value.)
767771
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.
768779
if (
769780
!guess &&
781+
(!l._shown || isVerdict(l)) &&
770782
el._pendingValue !== NOT_PENDING &&
771783
c._config & CONFIG_HELD &&
772784
flushTransaction !== null &&
@@ -793,7 +805,7 @@ export function laneRead(c: Computed<any> | null, el: Signal<any> | Computed<any
793805
}
794806
// A verdict reader reads ahead of the seam's verdict: re-derived on the
795807
// screen if the lane holds (#4284).
796-
if (c._config & CONFIG_VERDICT && l._parent!._verdict !== l) entered.push(c);
808+
if (c._config & CONFIG_VERDICT && !isVerdict(l)) entered.push(c);
797809
}
798810
}
799811
enterLane(l, c);
@@ -1133,7 +1145,7 @@ const laneSeams = (t: Transaction | null): void => {
11331145
if (
11341146
r._flags & REACTIVE_DISPOSED ||
11351147
(l?._lane
1136-
? (l._parent?._verdict === l &&
1148+
? (isVerdict(l) &&
11371149
(r._config & CONFIG_VERDICT
11381150
? !(r._flags & REACTIVE_PROBE_UNANSWERED)
11391151
: !blocked(t!) || heldBy(t!, r))) ||
@@ -1191,8 +1203,7 @@ const laneSeams = (t: Transaction | null): void => {
11911203
// a pass routed into it — the park seam's zombie verdict readers re-run
11921204
// as its work so that this seam reveals them (#3444).
11931205
for (let k = lanes.length - 1; k >= 0; k--)
1194-
if (k < judged || lanes[k]._parent?._verdict === lanes[k])
1195-
laneSeam(lanes[k], leaked.indexOf(lanes[k]) !== -1);
1206+
if (k < judged || isVerdict(lanes[k])) laneSeam(lanes[k], leaked.indexOf(lanes[k]) !== -1);
11961207
// A verdict reader that entered a lane this seam held: its run waits with
11971208
// the lane, and the verdict beside it would freeze — it re-derives next
11981209
// round from the frame's seat, a stale reader of the lane (#4284).

‎packages/signals/tests/optimistic-second-log-guess-4666.test.ts‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const tick = async () => {
3434

3535
type Read = "serverFirst" | "guessFirst" | "viaMemo";
3636

37-
function run(sameLog = false, read: Read = "serverFirst") {
37+
function run(sameLog = false, read: Read = "serverFirst", ids = [1, 3]) {
3838
const asks: { key: string; res: (v: any) => void; rej: (e: any) => void }[] = [];
3939
const ask = (key: string) => new Promise<any>((res, rej) => asks.push({ key, res, rej }));
4040
const settle = async (key: string, fail = false) => {
@@ -44,7 +44,7 @@ function run(sameLog = false, read: Read = "serverFirst") {
4444
fail ? a.rej(new Error("no")) : a.res({});
4545
await tick();
4646
};
47-
let serverRows: Row[] = [{ id: 1 }, { id: 3 }];
47+
let serverRows: Row[] = ids.map(id => ({ id }));
4848
const frames: string[] = [];
4949
let assign!: (id: number) => any;
5050
let close!: (id: number) => any;
@@ -181,6 +181,38 @@ describe("#4666: a guess into a second log beside another action's refresh", ()
181181
expect(t.screen, "every refresh landed").toBe("#1(-) #5(-)");
182182
});
183183

184+
// The second log already carries a guess from a third action, and that
185+
// guess's lane has shown. The overlay, held by assign's refresh, is seated
186+
// in that lane, which is judged in the same seam and holds once on the
187+
// overlay's stale pending. Its pass then stages the lane's next reveal. The
188+
// render effect read that staging as its frame's, so its run waited with
189+
// the frame and #3 stayed shown. A guess shows at once (F-11), beside the
190+
// screen's list (D-26), whatever order the overlay reads in (D-28).
191+
for (const read of ["serverFirst", "guessFirst", "viaMemo"] as const)
192+
it(`second log, ${read}: a guess into a log whose lane has shown`, async () => {
193+
const t = run(false, read, [1, 2, 3, 4]);
194+
flush();
195+
await tick();
196+
await t.settle("fetch");
197+
expect(t.screen).toBe("#1(-) #2(-) #3(-) #4(-)");
198+
t.close(4);
199+
await tick();
200+
expect(t.screen, "close #4 guessed").toBe("#1(-) #2(-) #3(-)");
201+
t.assign(3);
202+
await tick();
203+
expect(t.screen, "assign #3 guessed").toBe("#1(-) #2(-) #3(guest)");
204+
await t.settle("assign:3");
205+
expect(t.screen, "assign accepted, refresh in flight").toBe("#1(-) #2(-) #3(guest)");
206+
t.close(3);
207+
await tick();
208+
expect(t.screen, "close #3 guessed").toBe("#1(-) #2(-)");
209+
await t.settle("close:4");
210+
await t.settle("close:3");
211+
expect(t.screen, "both closes accepted").toBe("#1(-) #2(-)");
212+
while (t.asks.some(a => a.key === "fetch")) await t.settle("fetch");
213+
expect(t.screen, "every refresh landed").toBe("#1(-) #2(-)");
214+
});
215+
184216
it("second log: a rejected close reverts only its own guess", async () => {
185217
const t = await start();
186218
t.assign(3);

0 commit comments

Comments
 (0)