Skip to content

Commit 2a0d3c7

Browse files
committed
fix(signals): a pass born inside a staged reader stays the frame's on a verdict memo read
After #4390 the E9 memo shape showed an empty screen. A nested <Show>'s condition memo is created inside a pass that read the action's staging; it read the verdict memo with no staged read of its own, so enterLane moved it into the verdict lane (inline, markVerdictReader's creator walk keeps it in the frame). Its branch then became lane work; the fresh <Loading> staged its fallback, the seam's fold-back redrew it outside the hold, and #4390's re-derive published the errored tree's undefined committed value. enterLane now checks the creator chain the same way, through a shared creatorReads helper (core.ts) that markVerdictReader also uses. Golfed so the live server-components floor stays under its recorded 115,217 B (115,213 B). Ledger re-recorded over next @ 1b32ff2. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent edf04c5 commit 2a0d3c7

5 files changed

Lines changed: 49 additions & 47 deletions

File tree

‎.changeset/verdict-memo-after-staged-read.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-
A memo of a verdict (`createMemo(() => latest(s))` or `createMemo(() => isPending(s))`) no longer shows a held change early. Before, a pass that read an action's staged write and then read that memo moved into the verdict lane, and the lane showed what the pass had read while the action was still open. For example, `<Errored>` showed the branch that the action's write recovers in place of its error, and `[s(), L()]` in one render effect showed `v:1 l:1`. Now a derivation in that position belongs to the frame, as it does when it calls `latest()` inline, so its result appears when the action lands. A render effect in that position re-derives on the committed world when the flush parks, so it shows `v:0 l:1`, the same as the inline `[s(), latest(s)]` (D-26). The async-app generator found this through its E9 pair (seed 3289).
5+
A memo of a verdict (`createMemo(() => latest(s))` or `createMemo(() => isPending(s))`) no longer shows a held change early. Before, a pass that read an action's staged write and then read that memo moved into the verdict lane, and the lane showed what the pass had read while the action was still open. For example, `<Errored>` showed the branch that the action's write recovers in place of its error, and `[s(), L()]` in one render effect showed `v:1 l:1`. Now a derivation in that position belongs to the frame, as it does when it calls `latest()` inline, so its result appears when the action lands. The same holds for a pass created inside such a pass, such as the condition of a `<Show>` nested in a branch that read the staging; before, that case could leave the screen empty. A render effect in that position re-derives on the committed world when the flush parks, so it shows `v:0 l:1`, the same as the inline `[s(), latest(s)]` (D-26). The async-app generator found this through its E9 pair (seed 3289).

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,16 @@ export function creatorPass(owner: Owner | null): Computed<any> | null {
12361236
: (owner as Computed<any> | null);
12371237
}
12381238

1239+
/** What `born` and the passes still running around `p` read — its
1240+
* creator's, theirs — of the future or a staging (REACTIVE_JOINED |
1241+
* REACTIVE_STAGED_READ): a pass created by one that did has no screen; its
1242+
* branch exists only in that world (#4341). */
1243+
export function creatorReads(p: Computed<any> | null, born: number): number {
1244+
return (p = creatorPass(p!._parent))?._flags! & REACTIVE_RECOMPUTING_DEPS
1245+
? creatorReads(p, born | p!._flags)
1246+
: born & (REACTIVE_JOINED | REACTIVE_STAGED_READ);
1247+
}
1248+
12391249
/** L2 — park the previous pass's frame for this node's commit: the children
12401250
* (already allocated — nothing new) and the `_disposal` list move to the
12411251
* extension, keep reacting from the heap, and die when the commit publishes

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import {
5959
STATUS_UNINITIALIZED
6060
} from "./constants.js";
6161
import { attrHooks } from "./attribution-hooks.js";
62-
import { ext, stagedRead, tracking } from "./core.js";
62+
import { creatorReads, ext, stagedRead, tracking } from "./core.js";
6363
import { NotReadyError } from "./error.js";
6464
import { laneValueOf } from "./truth.js";
6565
import { enqueueSub } from "./heap.js";
@@ -261,33 +261,33 @@ function applyGuesses(parent: Transaction | null): void {
261261
* through an ancestor's guess stays its own (the screen plus its own
262262
* guesses). */
263263
export function enterLane(l: Transaction, c: Computed<any>): void {
264-
c._flags |= REACTIVE_LANE_READ;
265-
const p = passLane;
264+
const f = (c._flags |= REACTIVE_LANE_READ),
265+
p = passLane;
266266
if (p === null) {
267267
const verdict = l._parent!._verdict === l;
268-
// A derivation reading a verdict lane's value (a memo of `latest` /
269-
// `isPending`, F-6) after it read the frame's staging or joined its
270-
// hold: the verdict read does not break it out — it stays the frame's,
271-
// as the same read inline does (verdict.ts `route`; D-25, D-26).
272-
if (verdict && !(c as any)._type && c._flags & (REACTIVE_JOINED | REACTIVE_STAGED_READ)) return;
268+
// A verdict lane's value (a memo of `latest` / `isPending`, F-6) read by
269+
// a derivation that already read the frame's staging or joined its
270+
// hold, or by any pass a pass that did is creating: the verdict read
271+
// does not break it out — it stays the frame's, as the same read inline
272+
// does (verdict.ts `markVerdictReader`, `route`; D-25, D-26). An
273+
// effect's own reads do not count (its `_type`, 1–3, carries neither bit).
274+
if (!(verdict && creatorReads(c, (c as any)._type || f))) {
275+
setPassLane(l);
276+
// The pass read a held write before its first lane read (it joined the
277+
// frame's future as mainline would): lane work sees the screen — the
278+
// seam re-derives it on the committed world next round (`stagedReaders`,
279+
// the park's repair), as it does a lane pass that read a staging. Not a
280+
// pass whose held reads were all of nodes born held (no staged read,
281+
// `stagedRead`): it has no committed world to re-derive on (#3969).
282+
// (A pass not joined: a held write beside a guess, #4336; a leaf of a
283+
// verdict lane — its plain reads are the screen's, D-26 `[s(), L()]`.)
284+
if (f & REACTIVE_STAGED_READ && (guessed || verdict || f & REACTIVE_JOINED)) stagedRead(c);
285+
}
286+
} else if (sameLane(p, l)) setPassLane(l);
287+
else if (!under(p, l)) {
288+
if (!under(l, p)) linkLanes(p, l);
273289
setPassLane(l);
274-
// The pass read a held write before its first lane read (it joined the
275-
// frame's future as mainline would): lane work sees the screen — the
276-
// seam re-derives it on the committed world next round (`stagedReaders`,
277-
// the park's repair), as it does a lane pass that read a staging. Not a
278-
// pass whose held reads were all of nodes born held (no staged read,
279-
// `stagedRead`): it has no committed world to re-derive on (#3969).
280-
// (A pass not joined: a held write beside a guess, #4336; a leaf of a
281-
// verdict lane — its plain reads are the screen's, D-26 `[s(), L()]`.)
282-
if (c._flags & REACTIVE_STAGED_READ && (guessed || verdict || c._flags & REACTIVE_JOINED))
283-
stagedRead(c);
284-
return;
285290
}
286-
if (sameLane(p, l)) return setPassLane(l);
287-
if (under(p, l)) return;
288-
if (under(l, p)) return setPassLane(l);
289-
linkLanes(p, l);
290-
setPassLane(l);
291291
}
292292
/** Is `l` nested under `a` (an ancestor lane)? */
293293
function under(l: Transaction, a: Transaction): boolean {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
REACTIVE_LANE_READ,
2626
REACTIVE_PROBED,
2727
REACTIVE_PROBE_UNANSWERED,
28-
REACTIVE_RECOMPUTING_DEPS,
2928
REACTIVE_STAGED_READ,
3029
STATUS_ERROR,
3130
STATUS_PENDING,
@@ -35,6 +34,7 @@ import {
3534
bornInto,
3635
context,
3736
creatorPass,
37+
creatorReads,
3838
joinPass,
3939
markLateLinker,
4040
prepareComputed,
@@ -247,12 +247,8 @@ function markVerdictReader(window: number): void {
247247
// derivation of it does (`bornInto` once held) and stays its pass
248248
// (`route`); a verdict reader from its next pass. #4341: a memo born in
249249
// a newly opened <Match> read the screen, where its branch was closed.
250-
let p: Computed<any> | null = c,
251-
born = 0;
252-
while ((p = creatorPass(p!._parent))?._flags! & REACTIVE_RECOMPUTING_DEPS)
253-
born |= p!._flags & (REACTIVE_JOINED | REACTIVE_STAGED_READ);
254-
if (!born) c._config |= CONFIG_VERDICT;
255-
c._flags |= REACTIVE_PROBED | born;
250+
// Not such a pass: a verdict reader now.
251+
c._flags |= REACTIVE_PROBED | (creatorReads(c, 0) || ((c._config |= CONFIG_VERDICT), 0));
256252
// Observe tier: which windows this pass entered (1 `isPending`, 2
257253
// `latest`) — the hold census names the affordance (attribution.ts).
258254
if (__OBSERVE__) (c as any)._devWindows = ((c as any)._devWindows ?? 0) | window;

0 commit comments

Comments
 (0)