Repository navigation
Commit 8ff4803
feat(signals): A28 — a write becomes visible at flush, to every channel (read-side) (#3473)
Between set(x) and the flush that carries it the write is unflushed: not the
committed value, not the staged value latest()/isPending() serve, and not an
input to a derivation created meanwhile. Optimistic writes match (A28 (5)):
setOptimistic(v) becomes the active override at the carrying flush; the
writer's own channels compose on it. A rewrite of a held node keeps the
staged value the last flush left for the verdict channels until the next
flush. Companions and store keys first materialized under a hold are born
as the holding transaction's (#3336).
Landed as a read-side rule rather than #3337's deferred subscriber walk:
"unflushed" is structural (an ambient staged value outside a flush), read
sites test one module flag (`unflushedStaged`, set when a node is staged or
a held node rewritten outside a flush, cleared at flush start), and the
write-path arms are cold helpers gated on loads the write already pays
(`_transition`, `context`) — setSignal stays within every setter's inlining
budget (~360 B bytecode; the arms inline cost 140 B and 10–20% on the
write-loop benches). Readers served the flushed value are latched for the
carrying flush (REACTIVE_MISSED_WAKE).
A companion created lazily while its source carries an unflushed write joins
the flush-start re-sync like one that existed at the write, so a derivation
over latest() direct-commits as the optimistic view it is rather than being
staged under whatever hold the round entered (a memo — and an effect — over
latest() of a held source created mid-tick answered the previous value, or
never ran, until the fetch settled).
Supersedes the #2922 mid-tick latest() pull (flush() first to read your own
write); OL-R2 / OS-R1 / CS-R34 superseded. Spec: A28 ruled + mechanism,
A29 creation-time form, A7 amendment (latest() throws in every uninitialized
scope). Oracles: every pre-flush cell reads the rule; no violation cells
remain. Size: core floor 23,752 → 24,480 (conscious bump, notes in
treeshake.test.ts and .size-limit.js).
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>1 parent 3ae9e92 commit 8ff4803
32 files changed
Lines changed: 1840 additions & 456 deletions
File tree
- .changeset
- packages/signals
- docs
- rules-mining
- scripts
- src
- core
- store/next
- tests
- store
- scripts/size
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
0 commit comments