Skip to content

Commit fff1615

Browse files
ryansolidClaude via Cursorcursoragent
authored
fix(signals): a lane holds through a boundary showing content (F6) (#3811)
A boundary output that forwards its tree's pending (CONFIG_REDERIVE, status exactly pending) is now a frame reader of the lane in blockedBy's one hop, so a Loading showing content no longer lets the lane release past it. An output that has never committed holds nothing. Rulings recorded in SPEC-ASYNC-SEMANTICS.md (A18 amendment and the never-committed clause); three #3331 pins re-pinned, the F6 pin flipped to passing. No size caps change: +20 B minified on every signals bundle is within the #3821 allowance. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent 7acc039 commit fff1615

8 files changed

Lines changed: 267 additions & 108 deletions
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+
A lane now holds through a `Loading` boundary showing content: a boundary output forwarding its tree's pending counts as a frame reader, so `latest()` no longer reveals beside the boundary's stale content (A33). An output that never committed — a mount the frame has not revealed — holds nothing. A corrected guess that never showed is void at the correction: untracked reads return the committed value (A18 amendment, 2026-10-05).

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

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

‎packages/signals/docs/SPEC-ASYNC-SEMANTICS.md‎

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
CONFIG_GUESS,
55
CONFIG_INPUTS_PUBLISHED,
66
CONFIG_OVERRIDE,
7+
CONFIG_REDERIVE,
78
CONFIG_STAGED,
89
CONFIG_VERDICT,
910
EFFECT_RENDER,
@@ -313,9 +314,16 @@ function blockedBy(nodes: Signal<any>[], owner: Transaction, own = false): boole
313314
// `frameRead`): served committed instead of going pending, it derives
314315
// from the flight all the same and is re-derived at the landing — the
315316
// frame's observation survives its reader becoming a lane's (a guess
316-
// over a held window, V5/A17). A probe alone does not hold.
317+
// over a held window, V5/A17). A probe alone does not hold. A
318+
// boundary showing content forwards the pending (its output pending,
319+
// CONFIG_REDERIVE): transparent, its readers hold through it (A33; the
320+
// lane-membership ruling, 2026-10-05). An output that never committed
321+
// shows nothing — a mount the frame has not revealed — and holds
322+
// nothing.
317323
if (
318-
((r as any)._type === EFFECT_RENDER || r._flags & REACTIVE_FRAME_READ) &&
324+
((r as any)._type === EFFECT_RENDER ||
325+
r._flags & REACTIVE_FRAME_READ ||
326+
(r._config & CONFIG_REDERIVE && r._statusFlags === STATUS_PENDING)) &&
319327
(s._gen === r._depGen || r._x?._error != null) &&
320328
!(r._flags & REACTIVE_DISPOSED) &&
321329
onScreen(r, judge ?? owner)
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// F6 (fuzz-findings-l2.test.ts) counts a boundary output forwarding its
2+
// tree's pending as a frame reader of the lane. Its limits: an output that
3+
// never committed (a mount the action staged, never shown) holds nothing —
4+
// counting it strands the lane and the action's last write never publishes
5+
// (fuzzer seed 91501 `latest` #138); a withdrawn mount's output is a zombie
6+
// whose removal the action stages (A15); and nothing outlives a failed action.
7+
import { expect, it } from "vitest";
8+
import {
9+
action,
10+
createLoadingBoundary,
11+
createMemo,
12+
createRenderEffect,
13+
createRoot,
14+
createSignal,
15+
flush,
16+
latest,
17+
onCleanup
18+
} from "../src/index.js";
19+
20+
const tick = () => new Promise<void>(r => setTimeout(r, 0));
21+
async function drain(n = 4) {
22+
for (let i = 0; i < n; i++) {
23+
await tick();
24+
flush();
25+
}
26+
}
27+
28+
function setup(fail = false) {
29+
const [s, setS] = createSignal(0);
30+
const [mounted, setMounted] = createSignal(true);
31+
const view = { out: "absent" as unknown };
32+
let resume!: () => void;
33+
let run!: () => Promise<void>;
34+
let dispose!: () => void;
35+
createRoot(d => {
36+
dispose = d;
37+
const node0 = createMemo(() => Promise.resolve(latest(s)));
38+
createRenderEffect(
39+
() =>
40+
mounted()
41+
? createRoot(dd => {
42+
const b = createLoadingBoundary(
43+
() => node0(),
44+
() => "loading"
45+
);
46+
createRenderEffect(b, v => {
47+
view.out = v;
48+
});
49+
onCleanup(() => {
50+
view.out = "absent";
51+
});
52+
return dd;
53+
})
54+
: undefined,
55+
dd => {
56+
if (dd) onCleanup(dd);
57+
}
58+
);
59+
run = action(function* () {
60+
setS(0);
61+
yield new Promise<void>(r => (resume = r));
62+
if (fail) throw new Error("cancelled");
63+
setS(1);
64+
});
65+
});
66+
return { s, setS, setMounted, view, run, resume: () => resume(), dispose };
67+
}
68+
69+
it("an action's mount withdraw + restore over a Loading forwarding latest() completes", async () => {
70+
const t = setup();
71+
flush();
72+
await drain();
73+
const p = t.run();
74+
t.setMounted(false);
75+
flush();
76+
await drain();
77+
t.setMounted(true);
78+
flush();
79+
await drain();
80+
t.resume();
81+
await p;
82+
await drain(8);
83+
expect([t.view.out, t.s()]).toEqual([1, 1]);
84+
t.dispose();
85+
});
86+
87+
it("an action's mount withdraw, not restored, completes with the mount gone", async () => {
88+
const t = setup();
89+
flush();
90+
await drain();
91+
const p = t.run();
92+
t.setMounted(false);
93+
flush();
94+
await drain();
95+
t.resume();
96+
await p;
97+
await drain(8);
98+
expect([t.view.out, t.s()]).toEqual(["absent", 1]);
99+
t.setMounted(true);
100+
flush();
101+
await drain(8);
102+
expect([t.view.out, t.s()]).toEqual([1, 1]);
103+
t.dispose();
104+
});
105+
106+
for (const restore of [false, true]) {
107+
it(`an action failing after staging a mount withdraw${restore ? " + restore" : ""} leaves nothing held`, async () => {
108+
const t = setup(true);
109+
flush();
110+
await drain();
111+
const p = t.run().catch(e => e);
112+
t.setMounted(false);
113+
flush();
114+
await drain();
115+
if (restore) {
116+
t.setMounted(true);
117+
flush();
118+
await drain();
119+
}
120+
t.resume();
121+
expect(await p).toBeInstanceOf(Error);
122+
await drain(8);
123+
t.setMounted(true);
124+
t.setS(7);
125+
flush();
126+
await drain(8);
127+
expect([t.view.out, t.s()]).toEqual([7, 7]);
128+
t.setMounted(false);
129+
flush();
130+
await drain(8);
131+
expect(t.view.out).toBe("absent");
132+
t.dispose();
133+
});
134+
}

‎packages/signals/tests/fuzz-findings-l2.test.ts‎

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -505,63 +505,65 @@ describe("fuzz findings on L2 — lanes", () => {
505505
// boundary's tree is the subscriber and the blocker predicate sees no frame
506506
// reader: the lane is judged unblocked, `latest=1` shows beside
507507
// `details=0`, and when `details(1)` lands it never displays — the stale
508-
// frame stays until the action ends.
509-
it.fails(
510-
"F6: a retaining boundary between a lane's derivation and its reader does not unblock the lane (A17)",
511-
async () => {
512-
const [$id, setId] = createSignal(0);
513-
const gates = new Map<string, () => void>();
514-
let resume!: () => void;
515-
let run!: () => Promise<void>;
516-
let L = 0;
517-
let D: unknown = "?";
518-
const frames: string[] = [];
519-
let dispose!: () => void;
520-
createRoot(d => {
521-
dispose = d;
522-
const details = createMemo(() => {
523-
const id = latest($id);
524-
return gated(gates, `d:${id}`, id);
525-
});
526-
createRenderEffect(
527-
() => latest($id),
528-
v => {
529-
L = v;
530-
frames.push(`L=${L} D=${D}`);
531-
}
532-
);
533-
const view = createLoadingBoundary(details, () => "loading" as const);
534-
createRenderEffect(view, v => {
535-
D = v;
508+
// frame stays until the action ends. A33/B5 and the lane-membership ruling
509+
// (2026-10-05, reading A): a boundary showing content is transparent — the
510+
// lane holds through it. A boundary output forwarding its tree's pending
511+
// (CONFIG_REDERIVE, itself pending) now counts as a frame reader in
512+
// `blockedBy`'s one hop over the pending tree; one showing its fallback is
513+
// not pending and still holds nothing.
514+
it("F6: a lane holds through a Loading boundary showing content, revealing with the derivation under it (A17, A33)", async () => {
515+
const [$id, setId] = createSignal(0);
516+
const gates = new Map<string, () => void>();
517+
let resume!: () => void;
518+
let run!: () => Promise<void>;
519+
let L = 0;
520+
let D: unknown = "?";
521+
const frames: string[] = [];
522+
let dispose!: () => void;
523+
createRoot(d => {
524+
dispose = d;
525+
const details = createMemo(() => {
526+
const id = latest($id);
527+
return gated(gates, `d:${id}`, id);
528+
});
529+
createRenderEffect(
530+
() => latest($id),
531+
v => {
532+
L = v;
536533
frames.push(`L=${L} D=${D}`);
534+
}
535+
);
536+
const view = createLoadingBoundary(details, () => "loading" as const);
537+
createRenderEffect(view, v => {
538+
D = v;
539+
frames.push(`L=${L} D=${D}`);
540+
});
541+
run = action(function* () {
542+
setId(1);
543+
yield new Promise<void>(r => {
544+
resume = r;
537545
});
538-
run = action(function* () {
539-
setId(1);
540-
yield new Promise<void>(r => {
541-
resume = r;
542-
});
543-
setId(2);
544-
});
546+
setId(2);
545547
});
546-
flush();
547-
gates.get("d:0")!();
548-
await drain();
549-
expect([L, D]).toEqual([0, 0]);
550-
const p = run();
551-
await drain();
552-
// The lane is held by details' flight: no frame shows latest=1 alone.
553-
expect([L, D]).toEqual([0, 0]);
554-
gates.get("d:1")!();
555-
await drain();
556-
// The derivation landed: the lane reveals both.
557-
expect([L, D]).toEqual([1, 1]);
558-
resume();
559-
gates.get("d:2")?.();
560-
await p;
561-
await drain();
562-
dispose();
563-
}
564-
);
548+
});
549+
flush();
550+
gates.get("d:0")!();
551+
await drain();
552+
expect([L, D]).toEqual([0, 0]);
553+
const p = run();
554+
await drain();
555+
// The lane is held by details' flight: no frame shows latest=1 alone.
556+
expect([L, D]).toEqual([0, 0]);
557+
gates.get("d:1")!();
558+
await drain();
559+
// The derivation landed: the lane reveals both.
560+
expect([L, D]).toEqual([1, 1]);
561+
resume();
562+
gates.get("d:2")?.();
563+
await p;
564+
await drain();
565+
dispose();
566+
});
565567

566568
// F8. A15 lanes corollary (#3460): "a render effect OFF the lane that reads
567569
// what the lane is revealing … shows the committed value, publishes now,

‎packages/signals/tests/spec-async-semantics.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ describe("A18 (was B4): an override's lifetime is bound to its own async source,
10681068
return g;
10691069
}
10701070

1071-
it("differing arrival: downstream async restarts from the truth immediately; screen and untracked reads keep the override until commit", async () => {
1071+
it("differing arrival: downstream async restarts from the truth immediately; screen and untracked reads keep what showed until commit", async () => {
10721072
const g = await primed();
10731073

10741074
g.setValue(1);
@@ -1086,15 +1086,19 @@ describe("A18 (was B4): an override's lifetime is bound to its own async source,
10861086
await settle();
10871087
expect(g.flights.map(f => f.n)).toEqual([3, 2]);
10881088
expect(latest(g.double)).toBe(2); // the arrived truth
1089-
expect(g.double()).toBe(3); // untracked read: still the displayed override
1089+
// Untracked read: what the screen shows. The guess never revealed (the
1090+
// lane held on its downstream flight through the boundary), so it is
1091+
// void at the correction and the committed value stays (A18
1092+
// amendment, 2026-10-05: correction display is what showed).
1093+
expect(g.double()).toBe(0);
10901094
expect(isPending(g.double)).toBe(true); // displayed ≠ final
10911095
expect(g.log).toEqual([]);
10921096

10931097
// The superseded 3-flight landing changes nothing — it is not the truth.
10941098
g.flights.shift()!.resolve();
10951099
await settle();
10961100
expect(g.log).toEqual([]);
1097-
expect(g.double()).toBe(3);
1101+
expect(g.double()).toBe(0);
10981102

10991103
// The 2-flight lands: the transaction commits, the optimism is gone.
11001104
g.flights.shift()!.resolve();
@@ -1172,7 +1176,7 @@ describe("A18 (was B4): an override's lifetime is bound to its own async source,
11721176
await settle();
11731177
expect(flights.map(f => f.n)).toEqual([3, 2]);
11741178
expect(latest(double)).toBe(2);
1175-
expect(double()).toBe(3);
1179+
expect(double()).toBe(0); // the never-shown guess is void (A18 amendment, 2026-10-05)
11761180
expect(isPending(double)).toBe(true);
11771181
expect(log).toEqual([]);
11781182

‎packages/signals/tests/store/lane-authority-twins.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,16 @@ describe("store twins of the lane-authority fixes (#3335/#3334/#3330/#3331)", ()
213213
await settle();
214214
expect(flights.map(f => f.n)).toEqual([3, 2]); // graph moves to 2 NOW
215215
expect(latest(() => state.d)).toBe(2);
216-
expect(state.d).toBe(3);
216+
// The guess never showed (held on its downstream flight through the
217+
// boundary): void at the correction (A18 amendment, 2026-10-05).
218+
expect(state.d).toBe(0);
217219
expect(isPending(() => state.d)).toBe(true);
218220
expect(log).toEqual([]);
219221

220222
flights.shift()!.resolve(); // superseded 3-flight: nothing
221223
await settle();
222224
expect(log).toEqual([]);
223-
expect(state.d).toBe(3);
225+
expect(state.d).toBe(0);
224226

225227
flights.shift()!.resolve();
226228
await settle();

0 commit comments

Comments
 (0)