Skip to content

Commit 227a01d

Browse files
ryansolidclaude
andauthored
fix(signals): optimistic list push after filter, keyed re-base settles by key (#4642) (#4656)
* fix(signals): optimistic list push after filter, and keyed re-base settling (#4642) - optimisticView: compare the length guess against the clone, not the source, so a removal guess past the source's end no longer leaves a hole that the next push lands after (`<For>` got an undefined row). - laneSet: a leaf the keyed re-base makes the lane's drops the frame's truth staging on it, so the lane's reveal no longer promotes it over the composed row (duplicated rows). - dissolveLane (correction): a store leaf the lane composed lands the backing's truth beneath it, as a guess does, instead of committing the composed row by position (`_slotTruth`, optimistic.ts). - dissolveLane (held, shown lane): an effect born in the parked pass keeps its first run, at the parent's landing (a row the keyed list built never rendered its title). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * test(signals): pin the first-load frame for #4642 (guess survives, re-based by key) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * docs(signals): D-34 clarification — an in-flight load is an older question (#4642) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * perf(signals): gate the dissolveLane slot-truth and first-run branches on guessed (#4642 review trim) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * fix(signals): keyed re-base frame bugs; OPTIMISTIC_WRITE_BEFORE_LOAD (#4642, #4656 review) - An earlier action's refresh() no longer blocks the lanes later guesses compose in: a refresh re-asks the guesses' own question (D-34 ¶3), so a leaf only lane work reads is kept off the derive's wake (A17, F-11). - A guess written while a refresh's flight is up is no new question (`_x._reask`): its answer re-bases, not as #4525's. - A re-base never brings back a truth row another pending guess removed (D-33, D-35). - The writer composes on the screen: a node a correction left held contributes what it shows (D-34, D-37) — key: null lists. - Drop the first-run effect branch and the laneSet staging reset (only the write-before-load frame needed them). - Ruled 2026-11-03: an optimistic write before the source's first landing throws OPTIMISTIC_WRITE_BEFORE_LOAD in DEV (0 B prod); D-34 ruling quoted, A25 corollary narrowed; pins updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * docs(diagnostics): OPTIMISTIC_WRITE_BEFORE_LOAD quick-reference row; regenerate diagnostics.json (#4656) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * perf(signals): trim #4656's optimistic growth - dissolveLane: a composed store slot with a truth staged on it lands that truth like a guess; the `_slotTruth` hook (and its mangled name) goes. - The removed-rows pass folds into the existing loop (the view's rows, then the truth's). - The refresh wake's lane-work test reads the leaf's first reader, inline in `ask`. - The held-node writer arm folds into the existing `continue` test; the DEV guard on the optimistic store setter is an expression. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * test(signals): oracle states and A18-before-first-commit under the write-before-load ruling (#4656) The "superseded before its first commit" state and its regression test wrote an override while the source had never committed: under the 2026-11-03 ruling that is OPTIMISTIC_WRITE_BEFORE_LOAD in DEV. The action catches it and stays open, so the state's reads (which were the void guess's) are unchanged; the regression test now expects the diagnostic and keeps pinning A19 exc. 1 / A18 (d) on the never-committed node. RULES-INDEX.md regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE --------- Co-authored-by: Claude <[email protected]>
1 parent 4f9768f commit 227a01d

20 files changed

Lines changed: 854 additions & 79 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Optimistic keyed lists: a push after a filter (with earlier saves still out) no longer hands `<For>` an `undefined` row; a guess written while an earlier action's `refresh()` is out shows at once instead of waiting for that refresh; a refresh landing older than a guess no longer brings back a row another pending guess removed; and an unkeyed list's guess written after a correction composes on what the screen shows, not on the truth beneath it (no duplicated, empty or missing rows).
6+
7+
New DEV diagnostic `OPTIMISTIC_WRITE_BEFORE_LOAD`: an optimistic write to a source whose first answer has not landed (`createOptimistic(async fn)`, `createOptimisticStore(fn, seed)`) throws in development and makes no guess — before its first answer the source is loading, not a value to be optimistic over. Keep pending items in a separate list until the source loads, or disable the action until then. Production behaviour is unchanged.

‎documentation/solid-2.0/08-dev-diagnostics.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,31 @@ const bump = action(async function* () {
7878
});
7979
```
8080

81+
#### `OPTIMISTIC_WRITE_BEFORE_LOAD`
82+
83+
**Message:** "Optimistic write to a source that has not loaded yet. Before its first answer the source is loading, not showing a value to be optimistic over. Keep the pending items in a separate list (an outbox) until the source loads, or disable the action until the source has loaded."
84+
85+
An optimistic setter ran before its source's first answer landed: `createOptimistic(fn)` whose async `fn` has not resolved, or `createOptimisticStore(fn, seed)` whose derive has not landed (a seed does not count — it is a draft, never shown). Until then the source is loading, so there is nothing on screen to be optimistic over (ruled 2026-11-03, #4656). Dev throws at the setter and makes no guess; inside an `action` the action rejects. Production is unchanged. `createOptimistic(value)`, `createOptimisticStore(value)` and a source that has landed once are never flagged. Repair: keep the items written before the load in a separate list (an outbox) and render it beside the source, or disable the action (the input) until the source has loaded.
86+
87+
```js
88+
const [todos, setTodos] = createOptimisticStore(() => api.list(), []);
89+
const add = action(function* (todo) {
90+
setTodos(s => {
91+
s.push(todo); // throws in dev while the first `api.list()` is out
92+
});
93+
yield api.add(todo);
94+
refresh(todos);
95+
});
96+
97+
// Fix: offer the action only once the list has loaded — inside the same
98+
// <Loading> as the list, the button is not there before the first answer…
99+
<Loading fallback={<p>loading</p>}>
100+
<For each={todos}>{t => <li>{t.title}</li>}</For>
101+
<button onClick={() => add(next())}>Add</button>
102+
</Loading>;
103+
// …or keep pre-load items in their own list (an outbox) and render both.
104+
```
105+
81106
#### `STORE_WRITE_OUTSIDE_SETTER`
82107

83108
**Message:** "Writing store property \"n\" outside its setter was ignored. Stores are read-only outside the setter's draft: use `setStore(s => { s.n = value })`."
@@ -989,6 +1014,7 @@ The runtime derives a request's trace itself in every tier — the W3C `tracepar
9891014
| ---------------------------------- | ---------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9901015
| `REACTIVE_WRITE_IN_OWNED_SCOPE` | error | write | Reactive write/invalidation inside component/computation |
9911016
| `ASYNC_STORE_SETTER` | error | write | Store setter callback returned a Promise (setters are synchronous transactions) |
1017+
| `OPTIMISTIC_WRITE_BEFORE_LOAD` | error | write | Optimistic write to a source whose first answer has not landed; no guess is made |
9921018
| `STORE_WRITE_OUTSIDE_SETTER` | warn | write | Store proxy written, deleted from, or defined on outside its setter; the write is ignored (once per store object and key) |
9931019
| `PENDING_ASYNC_UNTRACKED_READ` | error | async | Reading pending async outside tracking scope |
9941020
| `ASYNC_OUTSIDE_LOADING_BOUNDARY` | warn | async | Async computation outside Loading boundary (non-halting; root mount is deferred) |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ An override's lifetime is that of the hold it was made over — in the usual sha
292292

293293
**From:** F-11, F-1, F-6. **Scenarios:** S-33, S-44.
294294

295-
When an override's own source answers (its own landing, or a sync recompute from an upstream change): an equal answer confirms silently — nothing re-runs; a different answer corrects — derivations re-derive from the truth now as the hold's work (downstream refetches restart at once, no waterfall), the screen and untracked reads keep what the screen showed until the commit, `latest()` answers the truth and `isPending()` reads `true` while they differ, and the correction reveals with the hold. "Keep the override" means keep what _showed_: a guess the screen never displayed — its reveal held on its own downstream flight, including through a shown `Loading` — is void at the correction, and untracked reads see the committed value, as the screen does. A later landing equal to the override restores it as the graph's value.
295+
When an override's own source answers (its own landing, or a sync recompute from an upstream change): an equal answer confirms silently — nothing re-runs; a different answer corrects — derivations re-derive from the truth now as the hold's work (downstream refetches restart at once, no waterfall), the screen and untracked reads keep what the screen showed until the commit, `latest()` answers the truth and `isPending()` reads `true` while they differ, and the correction reveals with the hold. "Keep the override" means keep what _showed_: a guess the screen never displayed — its reveal held on its own downstream flight, including through a shown `Loading` — is void at the correction, and untracked reads see the committed value, as the screen does. A later landing equal to the override restores it as the graph's value. **A write before the first landing is no guess (ruled 2026-11-03, maintainer, #4656):** "if it hadn't landed it isn't optimistic, its loading" (09:22); "Write before load in the non optimistic case gets squashed.. optimistic is odd one because its visible. Idd be ok with it erroring I think"; "I guess it could be in a second list but then it wouldn't have this problem" (09:27); "That or chat input is disabled until it loads" (09:29). An optimistic write to a source whose first answer has not landed — a `createOptimistic` signal's, an optimistic store's, keyed or `key: null`, seed or not — throws `OPTIMISTIC_WRITE_BEFORE_LOAD` in DEV and guesses nothing; the remedies are a separate list (an outbox) for the pending items, or the action disabled until the source has loaded. Production behaviour is unchanged (not specified). So nothing in this rule, or in D-35's re-base, meets a first load.
296296

297297
A keyed store's arrangement guess (rows by key) that the screen showed is not voided by a correction: the truth folds beneath it (one the screen never showed is void, as above). Derivations outside the lane re-derive from the truth now and join the hold, `until`/`resolve` keep their postures over it (an `until` outside the lane reads the truth and joins the hold, D-31), and `latest()` shows the hold's world whole. Lane passes, untracked reads and the screen keep the guess until the commit, and at the commit rows match by key. So a row the truth returns keeps its identity, a row another tab added shows at the commit, and the first of two overlapping actions confirming does not void the second's guess (2026-10-21). A folded lane's list pass inside a frame that already has a transaction reads that frame's stagings as the screen, as a verdict reader does, so it never pairs the truth's length with the guess's rows.
298298

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
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… |
6262
| A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:251` | async.ts×2 constants.ts×1 core.ts×4 effect.ts×1 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 optimistic-lane-seam-loop-4643.test.ts×1 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 tracked-effect-staged-dep-4606-4607.test.ts×1 treeshake.test.ts×4 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-held-branch-4544.test.ts×1 verdict-shortcut-pending-source-liveness.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 | caught-reactive-read-diagnostic.test.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… |
64-
| 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… |
65-
| 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… |
64+
| 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×2 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… |
65+
| 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×17 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… |
6666
| A19 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:151` | boundaries.ts×1 async.ts×1 constants.ts×1 core.ts×6 lanes.ts×1 scheduler.ts×2 seat.ts×1 types.ts×1 verdict.ts×6 store.ts×2 | create-deferred-3710.test.ts×2 derived-store-first-landing-verdict.test.ts×1 errored-latest-obsolete-flight-4568.test.ts×1 fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×2 latest-memo-inline-parity.test.ts×1 latest-uninitialized-over-latest-4362.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 verdict-memo-flight-no-reask.test.ts×2 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:410` | — | 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:417` | — | 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… |

0 commit comments

Comments
 (0)