You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c827758
Browse filesBrowse the repository at this point in the historyBrowse files
committed
fix(signals): a projection's leaf companions die with the projection; latest() of a dead leaf creates none (spec O5, INV-4)
Disposing a store whose async source was mid-refetch left the latest()
shadow of a leaf orphaned: never derived (its compute read through the
projection in flight, the backfilled override stood in), its override
dropped at the settle, NotReady/uninitialized forever against a leaf whose
committed value differed — INV-4 at the next quiescence. Externally
coherent (latest() fell back to the committed value), but a companion
outliving its source, which is what INV-9's rationale forbids. The
disposal snap covered the disposed computed's own companions only; a
projection's leaves hang off the firewall, not the child chain.
Two parts:
- disposeChildren(self) snaps the companions of the firewall's
_companionChildren (the set markFirewallChildCompanions maintains,
#3038); snapCompanionsToState retires a shadow whose owner's firewall is
disposed — a disposed shadow reads as absent, a later read recreates it
from the committed view. The isPending signal snaps as the owner's does.
- latestRead of a leaf whose firewall is disposed serves the committed
value and creates no shadow: a boundary's content re-running after the
teardown recreated one that no teardown would ever retire. That
recreated shadow was the posture matrix's actual trigger.
Surfaced once #3495 stopped leaking parked transactions, which had kept
`transitions.size > 0` and masked every __TEST__ quiescence check in the
matrix. All 621 matrix cells run with zero invariant violations; the two
excluded cells are back. Pin flipped from it.fails and extended with the
post-disposal read. +104 B minified (owner.ts, core floor); five brotli
caps +13…+43 B.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
A projection's leaf companions die with the projection. Disposing a store whose async source was mid-refetch left the `latest()` shadow of a leaf orphaned: never derived (its compute read through the projection in flight, the backfilled override stood in), its override dropped at the settle, NotReady forever against a leaf whose committed value differed — the `__TEST__` quiescence invariant INV-4 at the next flush. Externally coherent, but a companion outliving its source. The firewall's teardown now snaps the companions of its companion-bearing leaves (the shadow is retired; a later read recreates it from the committed view), and `latest()` of a leaf whose firewall is already disposed serves the committed value without creating a shadow — a boundary's content re-running after the teardown had recreated one that nothing would retire. Surfaced once #3495 stopped leaking parked transactions, which had masked every quiescence check in the posture matrix; all 621 matrix cells now run with zero invariant violations.
Copy file name to clipboardExpand all lines: packages/signals/docs/SPEC-ASYNC-SEMANTICS.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -326,10 +326,11 @@ An error escaping every boundary permanently halts the system with `REACTIVITY_H
326
326
**Rule:** same-tick adoption is by design (O1); A28 (1)/(2) still govern visibility — nothing is visible before the flush that carries the write, on any channel. The store is right.
327
327
**Mechanism (current):** adoption stamps the signal with the transaction (`initTransition`'s pending-node loop); `unflushedValue` reads a stamped node with no `_flushedStaged` stash as a flushed held node and serves `_pendingValue`. The store's selection (`nodeValue` / `serveDataKey`, `flushedStaged`) does not take that path. One rule, two implementations — the fix is making "unflushed" mean the same thing at both sites (a node staged outside a flush and adopted before any flush is unflushed whatever its stamp).
328
328
329
-
### O5. INV-4 — a projection leaf's `latest()` shadow is stale on the flush right after its root is disposed mid-refetch — violation, open
329
+
### O5. INV-4 — a projection leaf's `latest()` shadow is stale on the flush right after its root is disposed mid-refetch — fixed
330
330
331
-
**Status:****violation, recorded** 2026-09-16 — surfaced by O3's fix: the posture matrix had been leaking parked transactions (dead reporters never re-judged), which kept `transitions.size > 0` and silenced every quiescence invariant for the rest of the run. With the leak gone, INV-4 fires. Pre-existing on `next` (standalone repro: projection store with a held refetch, `latest()` read of a leaf, `dispose()`, synchronous `flush()`); pinned `it.fails` in `tests/inv4-projection-dispose-shadow.test.ts` (its own file: a live action in a sibling test masks the check). Externally the leaf and its `latest()` agree throughout — the stale pair is an internal companion owner. Transient — the shadow is re-derived a microtask later — but under `__TEST__` a throw from the runtime's own scheduled flush leaves the scheduler mid-flush, so the matrix excludes the two triggering cells (`gatedAway` × the projection states) until fixed.
332
-
**Where to look:** the disposal snap (`disposeChildren` → `_snapCompanions`) covers the disposed computed's own companions; a projection's leaves hang off the firewall, not the child chain, and their companions are re-derived only by the scheduled pass that follows.
331
+
**Status:****violation, fixed** 2026-09-16 — surfaced by O3's fix: the posture matrix had been leaking parked transactions (dead reporters never re-judged), which kept `transitions.size > 0` and silenced every quiescence invariant for the rest of the run. With the leak gone, INV-4 fires. Pre-existing on `next` (standalone repro: projection store with a held refetch, `latest()` read of a leaf, `dispose()`, synchronous `flush()`); pinned `it.fails` in `tests/inv4-projection-dispose-shadow.test.ts` (its own file: a live action in a sibling test masks the check). Externally the leaf and its `latest()` agree throughout — the stale pair is an internal companion owner. Transient — the shadow is re-derived a microtask later — but under `__TEST__` a throw from the runtime's own scheduled flush leaves the scheduler mid-flush, so the matrix excludes the two triggering cells (`gatedAway` × the projection states) until fixed.
332
+
**Cause:** the leaf's shadow had never derived a value — its compute reads through a projection in flight (NotReady), so the backfilled override stood in — and the settle after disposal dropped the override, leaving a shadow NotReady/uninitialized forever against a leaf whose committed value differs. Not a skipped sync: an orphan. The disposal snap covered the disposed computed's own companions only; a projection's leaves hang off the firewall, not the child chain.
333
+
**Mechanism:**`disposeChildren(self)` snaps the companions of the firewall's `_companionChildren` (the set `markFirewallChildCompanions` already maintains, #3038), and `snapCompanionsToState` retires a shadow whose owner's firewall is disposed — `getLatestValueComputed` treats a disposed shadow as absent, so a later read recreates it from the committed view; the isPending signal snaps as the owner's own does. And `latestRead` of a leaf whose firewall is disposed serves the committed value and creates no shadow — a boundary's content re-running after the teardown recreated one (a disposed shadow reads as absent) that no teardown would ever retire; that recreated shadow was the matrix's actual trigger. The matrix's two excluded cells are back; 0 invariant cells across all 621.
0 commit comments