Skip to content

Commit ab3e844

Browse files
ryansolidcursoragentclaude
authored
fix(signals): a derived store heals with its Errored like the memo it derives from (#4451) (#4522)
A derive's lane-pass write to a key nobody had read yet stages on the container (`stageOn` → `holdWithDerive` lists it in the lane, #4478); the leaf born from that staging in the same flush was a plain staging the park then held with the frame, so frame readers saw the committed `undefined` beneath while the memo the derive reads showed the lane's value. An `Errored` over the store stayed on its fallback until the action landed; a memo over the key derived NaN. `bornStaged` now hands a leaf born from a lane container's staging (OVERRIDE without GUESS) to `holdWithDerive` with the container's lane: the staging becomes the lane's derivation, as the write would have left a leaf that existed then (E3, D-25, D-39). `holdWithDerive`'s `userWrite` discriminator moves to its callers so the born leaf — a read, possibly inside a user setter's body — is classified by the container's staging, not the caller's. The #4137 pin's mid-action screen changes from `["a",null]` to `["a","b"]` (accepted by the maintainer): the derive's new key is the lane's derivation for a leaf born after the write as for one that existed; the memo twin shows `["a","b"]` on both. Size: "app: hydrating + every store primitive family" 32.48 -> 32.50 KB (+48 B minified / +58 B brotli over next on that scenario; core floor, hello world and every bundle without stores 0 B). Accepted by the maintainer. Co-authored-by: Cursor <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent d815fd4 commit ab3e844

6 files changed

Lines changed: 405 additions & 16 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+
A derived store heals with its Errored like the memo it derives from (#4451). A leaf born from a lane container's staging — a derive's lane-pass write to a key nobody had read yet — takes the staging as the lane's derivation, as the write would have left a leaf that existed then; before, the leaf was born a plain staging the park held with the frame, and an Errored the memo's lane value healed stayed on its fallback over the store.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
5959
| A12 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:199` | — | createOptimistic.test.ts×2 spec-async-semantics.test.ts×1 | [ruled, amended in place] Resting optimistic nodes report pending like a plain memo — A resting optimistic node reports pending via exactly the causes a plain async memo does (A19) — a reverting optim… |
6060
| A13 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:207` | — | spec-async-semantics.test.ts×7 | [ruled 2026-07-06 (promoted from B1)] Resting optimistic ≡ plain async memo at every checkpoint — (was B1) A resting optimistic node (no active override) is observationally identical to a plain async … |
6161
| A14 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:215` | — | spec-async-semantics.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B2)] Companion nodes get child lanes that do not merge with the owner — (was B2) `isPending`/`latest` companion nodes get child lanes that do not mer… |
62-
| A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:251` | async.ts×2 constants.ts×1 core.ts×4 lanes.ts×6 scheduler.ts×16 seat.ts×1 verdict.ts×4 store.ts×1 | async-chain-supersession.test.ts×1 boundary-output-frame-reader.test.ts×1 create-deferred-3710.test.ts×2 first-observer-stale-reader.test.ts×1 fuzz-findings-l2.test.ts×17 held-restore.test.ts×1 hold-recovers-landing-reruns-4469.test.ts×1 l2-contract.test.ts×7 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 lane-pass-stamped-effect-3662.test.ts×1 latest-memo-inline-parity.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×1 loading-fallback-in-flush-3540.test.ts×4 mount-over-foreign-hold-3761.test.ts×2 overlapping-flights.test.ts×3 posture-born-held-and-observation.test.ts×4 posture-store-parity.test.ts×2 reveal-carve-out.test.ts×2 shared-effect-no-entangle.test.ts×1 show-stale-child-in-action-4137.test.ts×2 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 tick-scoped-pass-transaction.test.ts×1 treeshake.test.ts×4 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 visibility-oracle-store.states.ts×6 visibility-oracle.states.ts×7 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B3)] Transition entanglement is graph-driven; lanes settle as one reveal — (was B3) Transition entanglement is graph-driven: writes whose async work … |
62+
| A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:251` | async.ts×2 constants.ts×1 core.ts×4 lanes.ts×6 scheduler.ts×16 seat.ts×1 verdict.ts×4 store.ts×1 | async-chain-supersession.test.ts×1 boundary-output-frame-reader.test.ts×1 create-deferred-3710.test.ts×2 first-observer-stale-reader.test.ts×1 fuzz-findings-l2.test.ts×17 held-restore.test.ts×1 hold-recovers-landing-reruns-4469.test.ts×1 l2-contract.test.ts×7 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 lane-pass-stamped-effect-3662.test.ts×1 latest-memo-inline-parity.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×1 loading-fallback-in-flush-3540.test.ts×4 mount-over-foreign-hold-3761.test.ts×2 overlapping-flights.test.ts×3 posture-born-held-and-observation.test.ts×4 posture-store-parity.test.ts×2 reveal-carve-out.test.ts×2 shared-effect-no-entangle.test.ts×1 show-stale-child-in-action-4137.test.ts×1 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 tick-scoped-pass-transaction.test.ts×1 treeshake.test.ts×4 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 visibility-oracle-store.states.ts×6 visibility-oracle.states.ts×7 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B3)] Transition entanglement is graph-driven; lanes settle as one reveal — (was B3) Transition entanglement is graph-driven: writes whose async work … |
6363
| A16 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:223` | scheduler.ts×1 | latest-uninitialized-over-latest-4362.test.ts×2 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:71` | async.ts×3 constants.ts×1 lanes.ts×7 scheduler.ts×2 seat.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×1 store.ts×3 | create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×6 lane-uninitialized-landing-3648.test.ts×5 optimistic-over-held-row-3796.test.ts×1 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:81` | 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 l2-fuzz-existing-rules.test.ts×2 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×5 flight-owned-transaction.test.ts×1 lane-authority-twins.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… |
@@ -78,7 +78,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
7878
| A31 | live | `docs/SPEC-ASYNC-SEMANTICS.md:133` | boundaries.ts×1 core.ts×1 lanes.ts×1 verdict.ts×2 | fuzz-findings-l2.test.ts×6 ispending-combined-atomic-3442.test.ts×1 latest-pulled-pass-ispending.test.ts×1 probe-pulled-pass-4429.test.ts×1 unowned-memo-ispending-reader-4366.test.ts×1 | [live 2026-09-14 (#3442)] A memo computes under its own lane posture, never its puller's — A memo's value is one shared slot every reader sees, so its pass runs under the lane posture the memo itself … |
7979
| A32 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:141` | core.ts×4 lanes.ts×1 seat.ts×1 store.ts×1 | visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 | [ruled 2026-09-14] Children-forbidden readers see the frame, not the graph — `createTrackedEffect` and `onSettled` callbacks are effect-phase code that runs after the frame is decided. They read the f… |
8080
| A33 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:275` | boundaries.ts×1 scheduler.ts×2 | async-chain-supersession.test.ts×2 boundary-not-born-held-3540.test.ts×2 create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×4 ispending-in-boundary-on-3528.test.ts×2 loading-reset-collects-forwarded-3459.test.ts×3 | [ruled 2026-09-12 (#3375)] A fallback-caught flight holds no transaction; a Loading reset moves the hold onto the boundary — A `<Loading>` boundary showing its fallback is the display of everything un… |
81-
| A34 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:285` | constants.ts×1 core.ts×6 lanes.ts×2 scheduler.ts×2 store.ts×6 | a34-writes-then-derivations.test.ts×2 continuation-sibling-reader-4146.test.ts×1 createMemo.test.ts×1 derived-write-then-derivation-3733.test.ts×1 finalize-reentry.test.ts×2 fuzz-findings-l2.test.ts×5 held-derivation-not-a-proposal-3612.test.ts×6 optimistic-guess-over-held-slot.test.ts×2 optimistic-list-mutation-matrix.test.ts×1 unchanged-presence-no-hold-3743.test.ts×3 woken-transaction-adopts-staged-bump.test.ts×1 transition-corpse-revival.test.ts×1 treeshake.test.ts×2 visibility-oracle.states.ts×2 write-proposals-3494.test.ts×5 | [ruled 2026-09-16 (#3494)] A write is a proposal: one on a held node entangles its tick; one that nets to the committed value is none — A write proposes a value for a node. **Held, both are suggestion… |
81+
| A34 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:285` | constants.ts×1 core.ts×6 lanes.ts×2 scheduler.ts×2 store.ts×7 | a34-writes-then-derivations.test.ts×2 continuation-sibling-reader-4146.test.ts×1 createMemo.test.ts×1 derived-write-then-derivation-3733.test.ts×1 finalize-reentry.test.ts×2 fuzz-findings-l2.test.ts×5 held-derivation-not-a-proposal-3612.test.ts×6 optimistic-guess-over-held-slot.test.ts×2 optimistic-list-mutation-matrix.test.ts×1 unchanged-presence-no-hold-3743.test.ts×3 woken-transaction-adopts-staged-bump.test.ts×1 transition-corpse-revival.test.ts×1 treeshake.test.ts×2 visibility-oracle.states.ts×2 write-proposals-3494.test.ts×5 | [ruled 2026-09-16 (#3494)] A write is a proposal: one on a held node entangles its tick; one that nets to the committed value is none — A write proposes a value for a node. **Held, both are suggestion… |
8282
## V — fixed violations
8383

8484
| id | status | defined | cited in src | cited in tests | statement (at definition) |

‎packages/signals/src/store/store.ts‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { attrHooks } from "../core/attribution-hooks.js";
3232
import {
3333
$REFRESH,
3434
CONFIG_CHILDREN_FORBIDDEN,
35+
CONFIG_GUESS,
3536
CONFIG_HELD,
3637
CONFIG_MANUAL_WRITE,
3738
CONFIG_OVERRIDE,
@@ -383,12 +384,22 @@ function bornStaged(target: StoreTarget, node: Signal<any>, staged: any, key: Pr
383384
node._pendingValue = staged;
384385
const k = target.k;
385386
if (k === null) return; // a node-less staging holds nothing (`stageOn`)
387+
// The staging is a derive's lane pass's (`stageOn` → `holdWithDerive`
388+
// listed the container in the lane, #4478), not a guess's: the leaf takes
389+
// it as the lane's derivation, as the write would have left a leaf that
390+
// existed then — a lane reader sees the lane's value, the frame the
391+
// committed one, as a reader of the memo the derive reads does (E3,
392+
// D-25). Born a staging instead, the park held it with the frame, and an
393+
// Errored the memo's lane value heals stayed on its fallback over the
394+
// store (#4451, D-39).
395+
if (laneStageHook && (k._config & (CONFIG_OVERRIDE | CONFIG_GUESS)) === CONFIG_OVERRIDE)
396+
holdWithDerive(target, node, txOf(k));
386397
// Held by the container's transaction only for a key the HELD staging
387398
// changed — a mainline layer's change above it stages mainline. (A
388399
// container carrying a guess is a lane's: the flush's park decides —
389400
// unless a correction folded under the guess, D-34: the key is that
390401
// correction's hold's.)
391-
if (k._config & CONFIG_HELD && heldKeyChanged(target, key)) {
402+
else if (k._config & CONFIG_HELD && heldKeyChanged(target, key)) {
392403
const l = txOf(k);
393404
if (!(k._config & CONFIG_OVERRIDE) || l.folded) holdNode(node, resolveTx(l._parent ?? l));
394405
}
@@ -501,7 +512,7 @@ function stageOn(target: StoreTarget, pb: Record<PropertyKey, any>): void {
501512
// A28 (4): a write issued inside a pass outside a flush (a creation-time
502513
// derive) is promoted at the pass's end — the batch with it.
503514
if (context !== null) notePromotedWrite(k);
504-
if (target.fam !== null) holdWithDerive(target, k);
515+
if (target.fam !== null && !userWrite) holdWithDerive(target, k);
505516
}
506517

507518
/** The projection's derive is held by a transaction and this is its own
@@ -1265,7 +1276,7 @@ function notifyWrites(t: StoreTarget): void {
12651276
const node = has[key as any];
12661277
if (node !== undefined) {
12671278
setSignal(node, key in pb && !t.del?.has(key));
1268-
if (t.fam !== null) holdWithDerive(t, node);
1279+
if (t.fam !== null && !userWrite) holdWithDerive(t, node);
12691280
}
12701281
}
12711282
}
@@ -1914,19 +1925,27 @@ function pullFamily(target: StoreTarget): void {
19141925
* callback's late write) belongs to the derive's transaction and reveals
19151926
* with it, never drained early — and answers the derive's question: a quiet
19161927
* re-ask's landing is quiet through its reveal (A19 exc. 2; the leaf's own
1917-
* classification, as core reads it — `heldNotFinal`). */
1918-
function holdWithDerive(target: StoreTarget, node: Signal<any>): void {
1928+
* classification, as core reads it — `heldNotFinal`). Callers pass only the
1929+
* derive's own writes (its draft or landing), never a user setter's
1930+
* (`userWrite`): a user's is a proposal (A34 (3)'s discriminator). */
1931+
function holdWithDerive(
1932+
target: StoreTarget,
1933+
node: Signal<any>,
1934+
// The lane the staging is work of: the pass's, or — a leaf born from a lane
1935+
// container's staging (`bornStaged`, #4451) — the container's.
1936+
lane: Transaction | null = passLane
1937+
): void {
19191938
const fw = target.fam?.node;
19201939
// A pass that is a lane's work (a display-ahead read, F-6): its write is
1921-
// the lane's derivation, as a memo's value would be (D-25).
1940+
// the lane's derivation, as a memo's value would be (D-25) — the lane's
1941+
// value, the committed value untouched beneath; the lane's end commits it.
19221942
if (
19231943
laneStageHook &&
1924-
passLane !== null &&
1925-
!userWrite &&
1944+
lane !== null &&
19261945
node._pendingValue !== NOT_PENDING &&
19271946
!(node._config & CONFIG_OVERRIDE)
19281947
) {
1929-
list(node, passLane);
1948+
list(node, lane);
19301949
node._x!._lane = node._pendingValue;
19311950
node._pendingValue = NOT_PENDING;
19321951
node._config |= CONFIG_OVERRIDE;
@@ -1935,7 +1954,6 @@ function holdWithDerive(target: StoreTarget, node: Signal<any>): void {
19351954
if (
19361955
fw !== undefined &&
19371956
fw !== null &&
1938-
!userWrite && // the derive's own write (its draft or landing), not a user setter's
19391957
fw._config & CONFIG_HELD &&
19401958
node._pendingValue !== NOT_PENDING &&
19411959
// A node carrying a guess is the lane's: its staging is the truth beneath

‎packages/signals/tests/show-stale-child-in-action-4137.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ describe("#4137: a Show branch hidden by its own lane does not re-run", () => {
107107
await tick();
108108
flush();
109109
expect(stale).toEqual([]);
110-
// The lane lists `b`; the record, derived from what the action holds,
111-
// does not have it yet: the branch shows its fallback (A15 lanes
112-
// corollary — a lane sees the screen plus its own guesses).
113-
expect(log).toEqual(['["a"]', '["a",null]']);
110+
// The lane lists `b`, and the record has it too: the derive's pass is the
111+
// lane's work (it reads the lane's rows), so its write of the new key is
112+
// the lane's derivation, as a memo building the same record would be —
113+
// for a leaf born after the write as for one that existed (#4478,
114+
// #4451; E3). (Before #4451 the leaf was born a staging the park held,
115+
// and the branch showed its fallback mid-action: `["a",null]`.)
116+
// Pin flipped with #4451 (accepted by the maintainer): the store now matches its memo twin.
117+
expect(log).toEqual(['["a"]', '["a","b"]']);
114118
release();
115119
await tick();
116120
flush();

0 commit comments

Comments
 (0)