Skip to content

Commit a337a2a

Browse files
ryansolidClaude via Cursorcursoragent
committed
fix(signals): a verdict reader re-derives when its source settles silently (fuzzer F9)
A verdict reader holds no pending source of its own: when the source goes pending, `propagateStatus`'s verdict arm re-derives it (CONFIG_VERDICT), and it answers `isPending` true without inheriting the status. A flight that then lands equal to the committed value notifies nobody — `setSignal` skips `insertSubs` on an equal value — and the settle walk returned at `removePendingSource` for a node without the source, so the probe read `true` forever. Shape: `setSrc(1); setSrc(0)` re-asks an async memo for the committed input; a probe-only `isPending(m)` reader stays true after the re-ask lands. A19: "a node is pending while any cause holds it and final the moment none does". The settle walk's early return now re-derives a verdict reader it reaches — the source settling is the reader's verdict changing, the third transition beside `propagateStatus`'s pending and error arms. Folded into the walk's existing early-return condition, which keeps the minifier's single `if` (a separate branch split it and cost 25 B). F9 flips from `it.fails` to `it`. No other pin moved. Size: +16 B minified (core floor and every scenario carrying the settle walk). Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent e9e0e15 commit a337a2a

4 files changed

Lines changed: 52 additions & 39 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 `isPending` reader of an async memo settles when the memo's flight lands equal to its committed value: the settle walk re-derives the verdict reader instead of leaving it `true` (fuzzer F9).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
6363
| A16 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:193` | scheduler.ts×1 | 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:51` | async.ts×3 constants.ts×1 lanes.ts×5 scheduler.ts×2 verdict.ts×1 map.ts×1 store.ts×3 | fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×5 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:61` | 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 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×3 flight-owned-transaction.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×19 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… |
66-
| A19 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:121` | constants.ts×1 core.ts×6 scheduler.ts×2 types.ts×1 verdict.ts×4 store.ts×1 | fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×2 mount-over-foreign-hold-3761.test.ts×2 spec-async-semantics.test.ts×3 derived-presence-async-3726.test.ts×2 superseded-before-first-commit.test.ts×3 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×14 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPendi… |
66+
| A19 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:121` | async.ts×1 constants.ts×1 core.ts×6 scheduler.ts×2 types.ts×1 verdict.ts×4 store.ts×1 | fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×2 mount-over-foreign-hold-3761.test.ts×2 spec-async-semantics.test.ts×3 derived-presence-async-3726.test.ts×2 superseded-before-first-commit.test.ts×3 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×14 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPendi… |
6767
| A20 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:380` | — | question-scoped-pending.test.ts×2 spec-async-semantics.test.ts×3 createOptimisticStore.test.ts×1 | [superseded 2026-07-13 by A24] (superseded) Optimistic writes announce a store-wide pending — (**SUPERSEDED 2026-07-13 by A24** — the mask is deleted; optimistic writes are verdict-inert. Kept for the… |
6868
| A21 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:387` | — | question-scoped-pending.test.ts×3 spec-async-semantics.test.ts×3 | [superseded 2026-07-13 by A24] (superseded) The store-wide mask — (**SUPERSEDED 2026-07-13 by A24** — the store-wide mask is deleted with the mask model; nothing silences a new question. The effective… |
6969
| A22 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:201` | store.ts×1 | createProjection.draft-lifetime-3585.test.ts×1 spec-async-semantics.test.ts×1 visibility-oracle-store.states.ts×1 | [ruled, amended in place 2026-07-08] Pending is per-node; store-wide only for the firewall's own work — **Pending is per-node: store-wide verdicts exist only as the firewall's own in-flight work (A9) … |

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,22 @@ export function settlePendingSource(el: Computed<any>, source: Computed<any> = e
249249
let released: Computed<any>[] | undefined;
250250
const visited = new Set<Computed<any>>();
251251
const settle = (node: Computed<any>) => {
252-
if (visited.has(node)) return;
253-
// A conditional dropped this source, but another dependency can still
254-
// carry it. Only retire pending state inherited through the recovered
255-
// branch. Deliberately NOT marked visited on this early return: the
256-
// carrying dependency may itself be a later branch of this same walk
257-
// (two unchanged memos converging), and its visit must be free to
258-
// re-examine this node once that branch has retired the source.
259-
if (source !== el && retryReaches(node, source)) return;
260-
if (!removePendingSource(node, source)) return;
252+
if (
253+
visited.has(node) ||
254+
// A conditional dropped this source, but another dependency can still
255+
// carry it. Only retire pending state inherited through the recovered
256+
// branch. Deliberately NOT marked visited on this early return: the
257+
// carrying dependency may itself be a later branch of this same walk
258+
// (two unchanged memos converging), and its visit must be free to
259+
// re-examine this node once that branch has retired the source.
260+
(source !== el && retryReaches(node, source)) ||
261+
!removePendingSource(node, source)
262+
)
263+
// A19: a verdict reader holds no pending of its own (it was re-derived
264+
// when the source went pending, `propagateStatus`), and a landing
265+
// equal to the committed value notifies nobody — the source settling
266+
// is its verdict changing: it runs again.
267+
return node._config & CONFIG_VERDICT && enqueueSub(node);
261268
visited.add(node);
262269
node._time = clock;
263270
const remaining = node._x?._pendingSources?.values().next().value;

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

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -593,35 +593,36 @@ describe("fuzz findings on L2 — verdicts", () => {
593593
// F9. A19: "`isPending(x)` ≡ the observable value is not final … final the
594594
// moment [no cause] holds it"; A34 (2): a tick whose writes net to the
595595
// committed value "pends nothing: `isPending` stays false". `setSrc(1);
596-
// setSrc(0)` re-asks the async memo for the committed input; the quiet
597-
// re-ask lands and nothing is held — yet a probe-only reader of the memo
598-
// reads `true` forever. (With a plain data reader beside it the verdict
599-
// settles; the probe alone is stranded.)
600-
it.fails(
601-
"F9: a probe-only isPending settles after a coalesced toggle's re-ask lands (A19, A34 (2))",
602-
async () => {
603-
const [src, setSrc] = createSignal(0);
604-
let verdict: unknown = "unpublished";
605-
let dispose!: () => void;
606-
createRoot(d => {
607-
dispose = d;
608-
const m = createMemo(() => Promise.resolve(src()));
609-
createRenderEffect(
610-
() => isPending(m),
611-
v => {
612-
verdict = v;
613-
}
614-
);
615-
});
616-
await drain();
617-
expect(verdict).toBe(false);
618-
setSrc(1);
619-
setSrc(0); // nets to the committed value: no proposal
620-
await drain(5);
621-
expect(verdict).toBe(false);
622-
dispose();
623-
}
624-
);
596+
// setSrc(0)` re-asks the async memo for the committed input; the probe
597+
// reader was re-derived when the memo went pending (`propagateStatus`'s
598+
// verdict arm) and read `true`. The re-ask landed equal to the committed
599+
// value: `setSignal` notified nobody, and the settle walk skipped the
600+
// reader — a verdict reader holds no pending source of its own — so it
601+
// read `true` forever. (A plain data reader beside it re-ran on its own
602+
// settle and took the probe with it.) The settle walk now re-derives a
603+
// verdict reader it reaches: the source settling is its verdict changing.
604+
it("F9: a probe-only isPending settles when a coalesced toggle's re-ask lands silently (A19, A34 (2))", async () => {
605+
const [src, setSrc] = createSignal(0);
606+
let verdict: unknown = "unpublished";
607+
let dispose!: () => void;
608+
createRoot(d => {
609+
dispose = d;
610+
const m = createMemo(() => Promise.resolve(src()));
611+
createRenderEffect(
612+
() => isPending(m),
613+
v => {
614+
verdict = v;
615+
}
616+
);
617+
});
618+
await drain();
619+
expect(verdict).toBe(false);
620+
setSrc(1);
621+
setSrc(0); // nets to the committed value: no proposal
622+
await drain(5);
623+
expect(verdict).toBe(false);
624+
dispose();
625+
});
625626

626627
// F10. A31: "A memo computes under its own lane posture, never its
627628
// puller's"; A28: "a write becomes visible at flush — to every channel". A

0 commit comments

Comments
 (0)