Skip to content

Commit 2ba10bd

Browse files
ryansolidclaude
andauthored
fix(signals): a memo waiting on a held flight is the hold's work at its landing (#4408, #4399) (#4510)
* fix(signals): a memo waiting on a held flight is the hold's work at its landing (#4408, #4399) #4408 (F-6 amended 2026-10-28, D-26): `latest(m2)` showed `c1101` while `m1:1122` of the same lane was in flight. `m1` (an async memo over a verdict memo, no window of its own) was waiting on `m0`'s flight as the hold's work (verdict.ts `holdWork`), but kept CONFIG_VERDICT, so `m0`'s verdict-lane re-derive at the park re-derived it into the s lane early; the lane was unshown when `m1:22` landed and nothing held the frame `m0b:1100` landed into. `holdWork` now drops the verdict posture at the wait: the memo is the hold's work until a pass of it reads a verdict again (D-25: re-run by the write its hold holds, it reads plainly). The recompute head could not tell: the landing settles the node before the pass, and a lane's node is not held. #4399 (F-9, D-25): two actions, each holding a verdict memo's write, asked `m1:15` twice. `m1`'s pass over `m0b`'s landing re-entered its hold at its head, then read `m0` (A's verdict lane) first and was moved into that lane, where its read of its own hold's landing was the screen (D-26), so it asked `m1:15` again. In `enterLane`, a pass that re-entered the hold holding its node at its head stays that hold's work when the verdict lane is another hold's, as it already did when it read its hold's staging first (D-25: either read order). Its own hold's verdict lane is its display-ahead read and it still enters that one (#4050). Both decisions sit at the event (the wait's start in `propagateStatus`, a verdict-lane read in `enterLane`), behind `holdWorkHook` and the lane engine: nothing in recompute's hot path, 0 B in bundles without them. The pins in latest-two-readers-one-ask-4393 (beside) and latest-first-one-pass-4402 (#4399 split/value) flip from it.fails to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * refactor(signals): enterLane's guard resolves the hold once (#4408, #4399) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(signals): a committed memo keeps its posture over a pending verdict read (#4408 after #4504; D-25) After #4504, `m2 = m0b() + 1` (m0b a verdict memo) re-ran at the t landing while m0b was pending, threw, and got no posture (#4504: a pending read hands on none). Its next run, at m0b:1100's landing into the frame that m1:22's landing opened, was plain: it staged 1101 there, and `latest(m2)` showed it through that frame's verdict lane while m1:1122 was in flight (c1101 before v1122). #4504's rule rests on D-25's "the hold's own work ... reads plainly". It now applies only to such a pass: one born in the hold's world (uninitialized, D-27) or one over a staged pass of its own. A memo with a committed value and nothing staged is no hold's work. Its posture is what it reads, and it lasts "until one completes having asked nothing" (D-25, ruled 2026-10-28); a pass that threw on a pending read did not complete. The line stays behind observeFlightHook. holdWork returns from the wait branch instead of keeping a local (-10 B minified). 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 730c9ef commit 2ba10bd

6 files changed

Lines changed: 89 additions & 35 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
An async memo over two verdict memos asks each question once, and a lane's readers show its answer together (#4408, #4399; F-6, F-9, D-25, D-26).
6+
7+
- An async memo with no verdict window of its own that waits on a source's flight as the hold's work (`holdWork`) drops its verdict posture at the wait, so the source's verdict-lane re-derive does not move it into that lane early, and the pass the landing runs reads plainly. Before, `latest(m2)` showed `c1101` while `m1:1122` of the same lane was still in flight.
8+
- A held memo's pass that re-entered its hold at its head stays that hold's work when it reads another hold's verdict lane, in either read order. Before, moved into the other lane, it read its own hold's landing as the screen and asked `m1:15` a second time.
9+
- A memo with a committed value and no pass staged keeps the verdict posture it reads when a pass of it reads that verdict memo while it is pending (#4408 after #4504; D-25). #4504's rule — a pending read hands on no posture — stays for the hold's own work: a pass born in the hold's world, or one over a staged pass of its own. Before, `m2 = m0b() + 1` lost its posture at such a read, re-ran plainly into the frame `m0b`'s answer landed in, and `latest(m2)` showed `c1101` before `v1122`.

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,17 +2103,31 @@ export function read<T>(el: Signal<T> | Computed<T>): T {
21032103
// verdict now. Not an effect: a render effect is a frame reader
21042104
// already, and a user effect's posture is its own reads'.
21052105
// A read of a pending node hands on no posture to a pass that is
2106-
// not a verdict reader already (#4504): such a read throws — it read
2107-
// no value, and a node whose flight is up is the hold's work, not a
2108-
// verdict reader (D-25, #3884). Stamped, the pass's next run — the
2109-
// hold's re-run at the landing of a memo whose plain mount read
2110-
// held its reader (D-2, D-27) — was served the screen beside the
2111-
// answer its reader waited for (F-2, D-22). A verdict reader keeps
2112-
// the posture it is served the screen with (`observeFlight`).
2113-
// (A verdict memo exists only with the verdict engine installed.)
2106+
// the hold's own work and not a verdict reader already (#4504):
2107+
// such a read throws — it read no value, and a node whose flight is
2108+
// up is the hold's work, not a verdict reader (D-25, #3884). The
2109+
// hold's own work is a pass born in its world (uninitialized, D-27)
2110+
// or one over a pass of its own still staged for the commit.
2111+
// Stamped, its next run — the hold's re-run at the landing of a
2112+
// memo whose plain mount read held its reader (D-2, D-27) — was
2113+
// served the screen beside the answer its reader waited for (F-2,
2114+
// D-22). A memo with a committed value and none staged is no hold's
2115+
// work, and its posture lasts until a pass completes having read no
2116+
// verdict reader (D-25, ruled 2026-10-28) — a pass that threw on a
2117+
// pending read did not complete. Unstamped, `latest(m2)` over a
2118+
// verdict memo showed its re-run's staging ahead of the lane that
2119+
// staging lands with (#4408). A
2120+
// verdict reader keeps the posture it is served the screen with
2121+
// (`observeFlight`). (A verdict memo exists only with the verdict
2122+
// engine installed.)
21142123
if (observeFlightHook && !(c as any)._type)
21152124
(c as Computed<any>)._flags |=
2116-
owner._config & CONFIG_VERDICT & (owner._statusFlags & STATUS_PENDING ? c._config : -1);
2125+
owner._config &
2126+
CONFIG_VERDICT &
2127+
(owner._statusFlags & STATUS_PENDING &&
2128+
(c._config & CONFIG_STAGED || (c as Computed<any>)._statusFlags & STATUS_UNINITIALIZED)
2129+
? c._config
2130+
: -1);
21172131
}
21182132
}
21192133
if (__TEST__)

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
import {
3333
CONFIG_AUTHORITATIVE,
3434
CONFIG_CHILDREN_FORBIDDEN,
35+
CONFIG_FRAME,
3536
CONFIG_GUESS,
3637
CONFIG_HELD,
3738
CONFIG_HELD_FRAME,
3839
CONFIG_INPUTS_PUBLISHED,
40+
CONFIG_LAGS,
3941
CONFIG_OVERRIDE,
4042
CONFIG_SLOT_NODE,
4143
CONFIG_STAGED,
@@ -290,11 +292,27 @@ export function enterLane(l: Transaction, c: Computed<any>): void {
290292
// on any later run (CONFIG_HELD_FRAME, `bornInto`): born in the hold's
291293
// world, it is the hold's own work and its run is the frame's, at the
292294
// landing (D-25, D-27) — as `route` keeps it for the inline `latest()`.
295+
// Nor by a pass that re-entered the hold holding its node at its head
296+
// (core.ts `recompute`: held, with no verdict posture — an async memo's
297+
// was dropped there — not a frame, not lagging, not a lane's node), when
298+
// `l` is another hold's verdict lane: re-run by the write its hold
299+
// holds, the pass is that hold's work and reads plainly in either read
300+
// order (D-25), as it does reading its hold's staging before `l`'s
301+
// value. Moved into `l`, it read its own hold's landing as the screen
302+
// (D-26) and asked a question already asked (#4399: `m1:15` again, over
303+
// `m0b`'s committed value beside the landing of its next question). Its
304+
// own hold's verdict lane is its display-ahead read: it enters that one
305+
// (D-25, #4050).
306+
let hold: Transaction;
293307
if (
294308
!(
295309
verdict &&
296310
(creatorReads(c, (c as any)._type || f) ||
297-
(c._config & CONFIG_HELD_FRAME && bornInto(c, resolveTx(l._parent!))))
311+
((hold = resolveTx(l._parent!)),
312+
(c._config &
313+
(CONFIG_HELD | CONFIG_VERDICT | CONFIG_FRAME | CONFIG_LAGS | CONFIG_OVERRIDE)) ===
314+
CONFIG_HELD && txOf(c) !== hold) ||
315+
(c._config & CONFIG_HELD_FRAME && bornInto(c, hold!)))
298316
)
299317
) {
300318
setPassLane(l);

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,19 +630,32 @@ function verdictValue(el: Signal<any> | Computed<any>, c: Computed<any> | null):
630630
* no value, so its re-run re-asked the question it was answering. Unless
631631
* its own flight is up outside a lane on a new question of the source's:
632632
* its re-run supersedes a flight asked of a value the source has moved past
633-
* (re-asked by a `refresh()`, the source's question is the same one). */
633+
* (re-asked by a `refresh()`, the source's question is the same one).
634+
*
635+
* Waiting, it is the hold's work until a pass of it reads a verdict again,
636+
* so the verdict posture drops here, at the wait (the pass's own reads
637+
* stamp it again, `read`). Kept, the source's next pending — its verdict
638+
* lane's re-derive at the park (#4393) — re-derived the waiting memo as a
639+
* verdict reader into that lane while the hold's flight it waits on was
640+
* still up, and the pass the landing runs, its hold re-running it, read as
641+
* a verdict reader: the head that drops the posture for such a pass sees
642+
* neither pending (the landing settles the node first) nor held (a lane's
643+
* node). #4408: `m1` entered the s lane early, the lane was unshown when
644+
* `m1:22` landed, nothing held the frame `m0b:1100` landed into, and the
645+
* lane's reader `latest(m2)` showed `c1101` while `m1:1122` was in flight. */
634646
function holdWork(n: Computed<any>, source: Computed<any>): unknown {
635647
// CONFIG_ASYNC records an async memo with no window of its own: its last
636648
// answering pass registered a flight (`handleAsync`) and called neither
637649
// `latest` nor `isPending`. A window (`markVerdictReader`), a sync answer or
638650
// an error clears it; a pass left pending keeps the last answer's.
639-
const own = n._config & CONFIG_ASYNC;
640-
return (
641-
own &&
651+
// Waiting drops the posture; the result stays truthy (CONFIG_ASYNC is kept).
652+
if (
653+
n._config & CONFIG_ASYNC &&
642654
(!(n._statusFlags & STATUS_PENDING) ||
643655
n._x!._transaction?._lane ||
644656
source._flags & REACTIVE_REASK)
645-
);
657+
)
658+
return (n._config &= ~CONFIG_VERDICT);
646659
}
647660

648661
// Installed at module evaluation — present exactly when something imports

‎packages/signals/tests/latest-first-one-pass-4402.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
// Pins for what #4393 (R5, D-22) fixed beyond #4365, and one row it leaves
2-
// for the reader-seat carve.
1+
// Pins for what #4393 (R5, D-22) fixed beyond #4365, and #4399.
32
//
43
// - #4402: a pass that reads `latest(s)` before `s()` computes once per
54
// plain write, as `[s(), latest(s)]` does (D-22: one pass; it re-derives
65
// only if the flush parks).
76
// - #4398: `[isPending(m1), m1()]` in one effect, split across two, or
87
// `m1()` alone show the same values when the write changes during the hold
98
// (D-26, F-6: a grouped read holds as a lone read; #4284).
10-
// - #4399 (it.fails, carve row): two actions, each holding a verdict
11-
// memo's write, ask `m1:15` twice: once in A's verdict lane, once in B's
12-
// transaction over the same inputs (F-9).
9+
// - #4399: two actions, each holding a verdict memo's write, ask `m1:15`
10+
// once: in A's verdict lane. `m1`'s pass over `m0b`'s landing is the
11+
// hold's work (D-25: re-run by the write its hold holds, it reads plainly
12+
// in either read order) and stays out of A's lane; moved into it, it read
13+
// the landing as the screen and asked `m1:15` again (F-9).
1314
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1415
import {
1516
action,
@@ -129,14 +130,13 @@ describe("#4398: grouping isPending(m1) with m1() shows the same values", () =>
129130
});
130131

131132
describe("#4399: two actions, each holding a verdict memo's write", () => {
132-
// F-9: a re-ask of the same question is no new question. A row for the
133-
// reader-seat carve: telling B's pass apart from A's lane pass over the
134-
// same inputs needs a per-pass check.
133+
// F-9: a re-ask of the same question is no new question. D-25: `m1`'s
134+
// pass over `m0b`'s landing is its hold's work, not A's verdict lane's
135+
// (lanes.ts `holdsPass`).
135136
const once = async (reader: Reader) => {
136137
const { asks, values } = await run(reader, "two-actions");
137138
expect(new Set(asks).size, asks.join(" ")).toBe(asks.length);
138139
expect(values.at(-1)).toBe("26");
139140
};
140-
it("each question asked once (pair)", () => once("pair"));
141-
it.fails.each(["split", "value"] as const)("each question asked once (%s)", once);
141+
it.each(["pair", "split", "value"] as const)("each question asked once (%s)", once);
142142
});

‎packages/signals/tests/latest-two-readers-one-ask-4393.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ describe("#4393: two latest() readers under one async memo, t written during the
130130
};
131131
it("m1's lane pass is not re-derived over a staging that lands with it (value)", () =>
132132
notReDerived("value"));
133-
// F-6 (amended 2026-10-28: the parent waits for the lane's flights) and
134-
// D-26. Fails with #4397 merged (#4393 alone passed): #4397 makes `m1` a
135-
// verdict reader between its flights (D-25), so m0's lane pass re-derives
136-
// it into the s lane early; the lane is unshown when `m1:22` lands, nothing
137-
// holds the t transaction, and `c1101` shows while `m1:1122` is in flight.
138-
// A row for the reader-seat carve: telling "its hold re-runs it" (D-25)
139-
// apart at that landing needs a per-pass check.
140-
it.fails("m1's lane pass is not re-derived over a staging that lands with it (beside)", () =>
141-
notReDerived("beside")
142-
);
133+
// #4408 — F-6 (amended 2026-10-28: the parent waits for the lane's
134+
// flights) and D-26: the lane's readers show its answer together, so
135+
// `c1101` never shows before `v1122`. `m1` waits on `m0`'s flight as the
136+
// hold's work (D-25, verdict.ts `holdWork`): it is not re-derived into the
137+
// s lane early, the lane shows, and `m1:22`'s landing holds the frame
138+
// `m0b:1100` lands into. Re-derived early (#4397's verdict reader between
139+
// its flights), the lane was unshown when `m1:22` landed, nothing held
140+
// that frame, and `c1101` showed while `m1:1122` was in flight.
141+
it("m1's lane pass is not re-derived over a staging that lands with it (beside, #4408)", () =>
142+
notReDerived("beside"));
143143

144144
// Its lane's own render effect shows m1 (pair): the staging's transaction
145145
// lands at the very seam, so the pass read the screen (one run).

0 commit comments

Comments
 (0)