Skip to content

Commit 3e80a25

Browse files
ryansolidClaude via Cursorcursoragent
committed
fix(signals): lanes stage — an optimistic derivation is an override (#3479 review)
A lane pass on a memo publishes its speculative result into the override slot (`laneOverride`, CONFIG_DERIVED_OVERRIDE) instead of direct-committing `_value`, so the committed view a reader off the lane is served (#3460) is a whole frame: the held source and its derivations together, never a committed shadow beside a speculative memo (gabbev's fuzzer, latest cohort: 57 -> 5 published-derivation disagreements, torn tuples to an effect 26 -> 0). - Off the lane is provenance, not membership: a pass under the lane's own transaction (its async's landing re-entering it) is the lane's work — the `1:0` frame of an optimistic value that never finished preparing. - The revert PROMOTES a derived override the truth confirmed instead of re-deriving (no re-ask waterfall after the reveal); a superseded one drops. - A derived override is a plain member: merges lanes through itself, does not stop pending propagation, suspends its lane readers on its re-ask, is skipped by body-end supersession and the authoritative-blockage census, carries no `_overrideTime` or provenance stamp, is no acknowledgement to the hold census. - Every pass over a live lane member carrying a derived override is the lane's pass, whatever channel dirtied it (a boundary reset re-running a lane-born memo read its re-derived lane view as a differing truth and demoted the lane; fuzzer latest-1 #2481). A fresh lane publish clears a supersession in force. Pins in tests/lane-outside-view.test.ts; A17 and INV-11 amended; size caps ratcheted (isPending/latest 11.90 -> 12.05, store app 29.60 -> 29.75, hydrating 19.60 -> 19.70 KB). Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent 9936204 commit 3e80a25

13 files changed

Lines changed: 419 additions & 58 deletions

File tree

‎.changeset/hold-consistency-batch-2.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Five hold-consistency fixes (#3456, #3458, #3460, #3463, #3469)
66

77
- #3456: a pass that re-parks on a new pending source set retires the sources it stopped carrying from its dependents, so a conditional whose async branch was cancelled no longer stays pending forever on a flight it has no path to.
88
- #3458: a stale render reader that is a flight's first observer registers the flight with the transaction it reveals a reader of (INV-3, via the reader's queue chain), so the transaction waits for it instead of revealing its other inputs beside the reader's pre-flight value.
9-
- #3460: lanes mirror transitions from the outside — a render effect off a held lane (mounted mid-hold, or re-run by an unrelated sync write) is served the committed value, publishes at once, entangles nothing, and re-runs at the lane's release; `latest()` and `createOptimistic` sources alike. Only direct reads return the override while the lane holds.
9+
- #3460: lanes mirror transitions from the outside — a render effect off a held lane (mounted mid-hold, or re-run by an unrelated sync write) is served the committed value, publishes at once, entangles nothing, and re-runs at the lane's release; `latest()` and `createOptimistic` sources alike. Only direct reads return the override while the lane holds. Off the lane is provenance, not membership: a pass under the lane's own transaction (its async's landing) is the lane's work.
10+
- Lanes stage (#3479 review): an optimistic derivation is an override. A lane pass on a memo publishes its speculative result as a _derived override_ instead of direct-committing `_value`, so the committed view an outsider sees is a whole frame — the held source and its derivations together, never a committed shadow beside a speculative memo. The revert promotes a derived override the truth confirmed (no re-ask waterfall) and re-derives one it superseded.
1011
- #3463: a reader whose removal is staged in a live transaction (a zombie) is still on screen and keeps holding until the commit that disposes it; it is moot only for that transaction's own verdict.
1112
- #3469 (A30): a pass that changed nothing replaced nothing either — its dependency trim waits on the flush's verdict (`heldTrims`), so a same-value branch switch under a hold still follows its committed inputs.

‎packages/signals/docs/INTERNALS-ASYNC-STATE.md‎

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,48 @@ Confidence: **high** = implementation self-consistency, assert now.
196196
verdict `true` forever (the declared-motion analogue of the INV-9 latch).
197197
- **INV-11 (high, structural — pinned, not asserted)** A recompute's equality
198198
gate compares the new result against the slot it is about to publish to:
199-
the override for an override-covered node, `_value` for a lane (OPT-dirty)
200-
direct commit, `_pendingValue` for a transaction-staged run. "Unchanged" is
199+
the override for an override-covered node (a written one, or the derived
200+
one a previous lane pass left — `CONFIG_DERIVED_OVERRIDE`, #3479), `_value`
201+
for a lane pass's FIRST publish (no override yet: the compare is against the
202+
committed value the override will shadow) and for an effect's or a
203+
reversion pass's direct commit, `_pendingValue` for a transaction-staged
204+
run. **Lanes stage (#3479):** a lane pass on a memo no longer direct-commits
205+
`_value`; it publishes into the override slot (`laneOverride`), so the
206+
committed view an outsider is served (`readsHeldCommitted`) is a whole frame
207+
— the source's shadow and its derivations — and the lane's own view is the
208+
override end to end. The reversion pass (OPT-dirty with no live lane, the
209+
override dropped) and an effect's lane pass still direct-commit. "Unchanged" is
201210
a statement about what the publishing view will show, so comparing against
202211
a different view produces torn frames: #3330 compared a lane recompute
203212
against a `_pendingValue` an earlier action write had staged, called the
204213
identical result unchanged, and revealed the override without its
205214
derivation. Pinned in `tests/spec-async-semantics.test.ts` (A17, #3330);
206215
not a runtime assertion because the publishing slot is decided inside the
207-
same branch that compares. Corollary (#3377): a lane direct commit also
208-
_retires_ the transaction-staged `_pendingValue` it supersedes, override
209-
or not — a node that adopted the lane through its deps (a `latest()` read;
210-
the companion is an optimistic node) may have staged a hold on an earlier,
216+
same branch that compares. Corollary (#3377): a lane pass also _retires_
217+
the transaction-staged `_pendingValue` it supersedes, override or not — a
218+
node that adopted the lane through its deps (a `latest()` read; the
219+
companion is an optimistic node) may have staged a hold on an earlier,
211220
lane-free pass of the same transaction, and left in place that older frame
212-
commits over the fresh `_value`.
221+
commits over the fresh one. Derived-override lifecycle (#3479): joins the
222+
lane's transaction's `_optimisticNodes` on its first publish (the ambient
223+
batch would revert an async landing's at its own end); reverts with it —
224+
_promoted_ to `_value` when not superseded (sources revert before their
225+
derivations in that list, and a source whose truth differs dirties them, so
226+
a derivation the revert did not dirty is what the truth yields), dropped
227+
when superseded (the truth is staged); the slot disarms to `undefined` for
228+
a plain memo and stays `NOT_PENDING` for a written node the lane corrected.
229+
Demoted by its source's supersession (A18), its plain re-derivation runs
230+
the sync twin and its landing takes `asyncWrite`'s hold-and-supersede
231+
branch (never the plain `setSignal`, which would read the armed slot as a
232+
fresh optimistic write and open a lane with the memo as source). Until then,
233+
_every_ pass over it is the lane's pass, whatever channel dirtied it
234+
(`recompute`'s derived-override branch): it is still a member, its inputs
235+
serve the lane's view, and its result is the lane's — run plain, the sync
236+
twin read a re-derived lane view (a fresh tuple) as a differing truth,
237+
superseded and demoted, and the lane's next pass dropped that staged
238+
"truth" and left the flag pointing at a `_value` never committed (fuzzer
239+
latest-1 #2481: a boundary reset re-ran a lane-born memo). A fresh lane
240+
publish clears `CONFIG_OVERRIDE_SUPERSEDED` for the same reason.
213241

214242
Rejected for assertion (state space too dynamic, would need semantic rulings):
215243
whether `_optimisticLane` must always resolve to a live lane (stale lanes are

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

Lines changed: 4 additions & 4 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:165` | — | spec-async-semantics.test.ts×2 | [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:199` | async.ts×3 core.ts×3 lanes.ts×2 scheduler.ts×2 | async-chain-supersession.test.ts×1 first-observer-stale-reader.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 overlapping-flights.test.ts×3 posture-born-held-and-observation.test.ts×3 reveal-carve-out.test.ts×2 shared-effect-no-entangle.test.ts×1 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 treeshake.test.ts×4 visibility-oracle-store.test.ts×5 visibility-oracle.states.ts×6 visibility-oracle.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:173` | verdict.ts×1 | pending-contract.test.ts×2 rules.ts×2 spec-async-semantics.test.ts×1 strict-read-pending-store.test.ts×2 uninitialized-visibility.test.ts×1 visibility-oracle-store.test.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:31` | async.ts×3 constants.ts×2 core.ts×7 invariants.ts×3 optimistic.ts×5 scheduler.ts×2 verdict.ts×2 signals.ts×2 optimistic.ts×1 store.ts×3 | optimistic-undefined-override.test.ts×1 refresh-await.test.ts×1 reveal-gating-contract.test.ts×3 spec-async-semantics.test.ts×10 createOptimisticStore.test.ts×1 treeshake.test.ts×1 until.test.ts×1 visibility-oracle-store.test.ts×12 visibility-oracle.states.ts×25 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:41` | async.ts×2 constants.ts×1 core.ts×4 optimistic.ts×6 scheduler.ts×3 types.ts×2 verdict.ts×2 optimistic.ts×1 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×1 spec-async-semantics.test.ts×3 flight-owned-transaction.test.ts×1 superseded-before-first-commit.test.ts×5 visibility-oracle-store.test.ts×10 visibility-oracle.states.ts×24 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:31` | async.ts×4 constants.ts×2 core.ts×9 invariants.ts×3 optimistic.ts×6 scheduler.ts×2 verdict.ts×2 signals.ts×2 optimistic.ts×1 store.ts×3 | optimistic-undefined-override.test.ts×1 refresh-await.test.ts×1 reveal-gating-contract.test.ts×3 spec-async-semantics.test.ts×10 createOptimisticStore.test.ts×1 treeshake.test.ts×1 until.test.ts×1 visibility-oracle-store.test.ts×12 visibility-oracle.states.ts×25 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:41` | async.ts×3 constants.ts×1 core.ts×6 optimistic.ts×6 scheduler.ts×3 types.ts×2 verdict.ts×2 optimistic.ts×1 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×1 lane-outside-view.test.ts×1 spec-async-semantics.test.ts×3 flight-owned-transaction.test.ts×1 superseded-before-first-commit.test.ts×5 visibility-oracle-store.test.ts×10 visibility-oracle.states.ts×24 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 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:101` | async.ts×1 core.ts×1 optimistic.ts×1 verdict.ts×1 | spec-async-semantics.test.ts×3 superseded-before-first-commit.test.ts×1 uninitialized-visibility.test.ts×1 visibility-oracle-store.test.ts×6 visibility-oracle.states.ts×11 visibility-oracle.test.ts×1 | [ruled 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPending(x)` ≡ the value… |
6767
| A20 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:317` | invariants.ts×1 | 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:324` | — | 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… |
@@ -72,7 +72,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
7272
| A25 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:241` | verdict.ts×1 | uninitialized-visibility.test.ts×3 visibility-oracle-store.test.ts×8 | [ruled 2026-07-16] A derived store's seed is a draft, never an observable value — (**ruled 2026-07-16**, #2897) **A derived store's seed is a draft, never an observable value.** The seed exists for th… |
7373
| A26 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:67` | scheduler.ts×1 | action-await-contract.test.ts×2 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×1 visibility-oracle.test.ts×1 | [ruled 2026-07-17] An ambient transaction window is one flush; parking is flush-driven — (**ruled 2026-07-17**, #2913; **enforcement hardened 2026-08-31**, #3141 — parking is flush-driven, and a trans… |
7474
| A27 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:233` | — | loading-value.test.ts×2 visibility-oracle.states.ts×18 visibility-oracle.test.ts×1 | [ruled 2026-08-10] The commit-#0 loading window is loading-class and verdict-quiet — (**ruled 2026-08-10**) **The commit-#0 loading window is loading-class and verdict-quiet.** A node born committed v… |
75-
| A28 | ruled, mechanism landed | `docs/SPEC-ASYNC-SEMANTICS.md:51` | constants.ts×1 core.ts×18 scheduler.ts×3 types.ts×1 verdict.ts×6 optimistic.ts×3 store.ts×1 | createOptimistic.test.ts×5 latest-held-till-flush.test.ts×1 optimistic-store-layer-scope.test.ts×1 question-scoped-pending.test.ts×3 snapshot-derived-store-rows.test.ts×1 createOptimisticStore.test.ts×10 shallow.test.ts×1 treeshake.test.ts×2 visibility-oracle-store.test.ts×8 visibility-oracle.states.ts×8 | [ruled, mechanism landed 2026-09-15] A write becomes visible at flush — to every channel — (**ruled 2026-09-08**; supersedes the #2922 mid-tick pull) **A write becomes visible at flush — to every chan… |
75+
| A28 | ruled, mechanism landed | `docs/SPEC-ASYNC-SEMANTICS.md:51` | constants.ts×1 core.ts×18 optimistic.ts×1 scheduler.ts×3 types.ts×1 verdict.ts×6 optimistic.ts×3 store.ts×1 | createOptimistic.test.ts×5 latest-held-till-flush.test.ts×1 optimistic-store-layer-scope.test.ts×1 question-scoped-pending.test.ts×3 snapshot-derived-store-rows.test.ts×1 createOptimisticStore.test.ts×10 shallow.test.ts×1 treeshake.test.ts×2 visibility-oracle-store.test.ts×8 visibility-oracle.states.ts×8 | [ruled, mechanism landed 2026-09-15] A write becomes visible at flush — to every channel — (**ruled 2026-09-08**; supersedes the #2922 mid-tick pull) **A write becomes visible at flush — to every chan… |
7676
| A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:75` | core.ts×5 effect.ts×1 optimistic.ts×1 | body-end-supersession-visibility.test.ts×1 born-held.test.ts×3 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 latest-held-till-flush.test.ts×2 treeshake.test.ts×1 visibility-oracle-store.test.ts×4 visibility-oracle.states.ts×5 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-09-13 (#3408)] A tracked read served a live transaction's staged value enters that transaction — A tracked computation served a node's staged `_pendingValue` — a value a … |
7777
| A30 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:207` | async.ts×1 attribution.ts×1 core.ts×1 effect.ts×1 scheduler.ts×3 | async-landing-deps-3461.test.ts×3 held-conditional-effect.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 treeshake.test.ts×1 | [ruled 2026-09-13 (#3410)] A memo's dependencies are the committed frame's until the frame is replaced — A pass that _staged_ its value has not replaced the committed frame, so the committed value sti… |
7878
| A31 | live | `docs/SPEC-ASYNC-SEMANTICS.md:83` | core.ts×2 | ispending-combined-atomic-3442.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 … |
@@ -118,7 +118,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
118118
| INV-8 | retired | `docs/INTERNALS-ASYNC-STATE.md:176` | invariants.ts×1 | rules-index.test.ts×1 | - **INV-8 (RETIRED 2026-07-07b, §5e)** Hold-provenance: a `_pendingValue` on an |
119119
| INV-9 | live | `docs/INTERNALS-ASYNC-STATE.md:187` | invariants.ts×1 owner.ts×1 | — | - **INV-9 (high)** An `isPending` companion of a DISPOSED owner reads `false` |
120120
| INV-10 | live | `docs/INTERNALS-ASYNC-STATE.md:192` | invariants.ts×2 | action-done-window.test.ts×1 | - **INV-10 (high)** Affects-count balance (question-scoped model, 2026-07-13; |
121-
| INV-11 | live | `docs/INTERNALS-ASYNC-STATE.md:197` | core.ts×1 optimistic.ts×1 | spec-async-semantics.test.ts×1 treeshake.test.ts×1 | - **INV-11 (high, structural — pinned, not asserted)** A recompute's equality |
121+
| INV-11 | live | `docs/INTERNALS-ASYNC-STATE.md:197` | core.ts×1 optimistic.ts×2 | spec-async-semantics.test.ts×1 treeshake.test.ts×1 | - **INV-11 (high, structural — pinned, not asserted)** A recompute's equality |
122122
## RUL — store rulings
123123

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

0 commit comments

Comments
 (0)