@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/dev-shared.js +2059 -3768
  2. package/dist/dev.attribution.js +237 -101
  3. package/dist/dev.js +7466 -8497
  4. package/dist/observe/affects.js +128 -104
  5. package/dist/observe/boundaries.js +492 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +243 -379
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +394 -253
  10. package/dist/observe/core/constants.js +120 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +874 -1440
  13. package/dist/observe/core/dev.js +3 -3
  14. package/dist/observe/core/effect.js +73 -84
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +62 -71
  17. package/dist/observe/core/heap.js +75 -98
  18. package/dist/observe/core/invariants.js +1 -34
  19. package/dist/observe/core/lanes.js +750 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +719 -1356
  22. package/dist/observe/core/verdict.js +314 -621
  23. package/dist/observe/flatten.js +79 -0
  24. package/dist/observe/index.js +15 -13
  25. package/dist/observe/map.js +232 -235
  26. package/dist/observe/reveal.js +212 -0
  27. package/dist/observe/signals.js +144 -216
  28. package/dist/observe/store/affects.js +142 -0
  29. package/dist/observe/store/hooks.js +13 -0
  30. package/dist/observe/store/index.js +27 -24
  31. package/dist/observe/store/optimistic.js +571 -0
  32. package/dist/observe/store/projection.js +308 -0
  33. package/dist/observe/store/reconcile.js +259 -0
  34. package/dist/observe/store/store.js +1988 -277
  35. package/dist/observe/store/storePath.js +1 -1
  36. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  37. package/dist/observe/store/types.js +73 -0
  38. package/dist/observe/store/utils.js +1 -13
  39. package/dist/prod/affects.js +130 -106
  40. package/dist/prod/boundaries.js +476 -654
  41. package/dist/prod/core/action.js +71 -74
  42. package/dist/prod/core/async.js +306 -444
  43. package/dist/prod/core/constants.js +117 -186
  44. package/dist/prod/core/context.js +3 -3
  45. package/dist/prod/core/core.js +888 -1462
  46. package/dist/prod/core/effect.js +88 -99
  47. package/dist/prod/core/external.js +5 -5
  48. package/dist/prod/core/graph.js +62 -71
  49. package/dist/prod/core/heap.js +75 -98
  50. package/dist/prod/core/invariants.js +1 -32
  51. package/dist/prod/core/lanes.js +712 -181
  52. package/dist/prod/core/owner.js +75 -96
  53. package/dist/prod/core/scheduler.js +686 -1335
  54. package/dist/prod/core/verdict.js +309 -621
  55. package/dist/prod/flatten.js +77 -0
  56. package/dist/prod/index.js +15 -13
  57. package/dist/prod/map.js +142 -145
  58. package/dist/prod/reveal.js +212 -0
  59. package/dist/prod/signals.js +155 -227
  60. package/dist/prod/store/affects.js +142 -0
  61. package/dist/prod/store/hooks.js +13 -0
  62. package/dist/prod/store/index.js +26 -19
  63. package/dist/prod/store/optimistic.js +566 -0
  64. package/dist/prod/store/projection.js +301 -0
  65. package/dist/prod/store/reconcile.js +259 -0
  66. package/dist/prod/store/store.js +1883 -272
  67. package/dist/prod/store/storePath.js +1 -1
  68. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  69. package/dist/prod/store/types.js +73 -0
  70. package/dist/prod/store/utils.js +1 -11
  71. package/dist/types/affects.d.ts +11 -30
  72. package/dist/types/boundaries.d.ts +66 -176
  73. package/dist/types/carved.d.ts +1 -0
  74. package/dist/types/core/action.d.ts +5 -6
  75. package/dist/types/core/async.d.ts +10 -5
  76. package/dist/types/core/attribution-hooks.d.ts +20 -1
  77. package/dist/types/core/attribution.d.ts +26 -11
  78. package/dist/types/core/constants.d.ts +130 -180
  79. package/dist/types/core/core.d.ts +134 -264
  80. package/dist/types/core/dev.d.ts +2 -2
  81. package/dist/types/core/effect.d.ts +0 -7
  82. package/dist/types/core/graph.d.ts +7 -1
  83. package/dist/types/core/heap.d.ts +5 -7
  84. package/dist/types/core/index.d.ts +5 -5
  85. package/dist/types/core/invariants.d.ts +0 -29
  86. package/dist/types/core/lanes.d.ts +74 -86
  87. package/dist/types/core/owner.d.ts +3 -3
  88. package/dist/types/core/scheduler.d.ts +255 -331
  89. package/dist/types/core/types.d.ts +45 -85
  90. package/dist/types/core/verdict.d.ts +3 -0
  91. package/dist/types/flatten.d.ts +8 -0
  92. package/dist/types/index.d.ts +6 -4
  93. package/dist/types/reveal.d.ts +19 -0
  94. package/dist/types/signals.d.ts +35 -91
  95. package/dist/types/store/affects.d.ts +12 -0
  96. package/dist/types/store/hooks.d.ts +48 -0
  97. package/dist/types/store/index.d.ts +34 -15
  98. package/dist/types/store/optimistic.d.ts +23 -0
  99. package/dist/types/store/projection.d.ts +18 -0
  100. package/dist/types/store/reconcile.d.ts +3 -0
  101. package/dist/types/store/store.d.ts +132 -145
  102. package/dist/types/store/storePath.d.ts +1 -1
  103. package/dist/types/store/target.d.ts +151 -0
  104. package/dist/types/store/types.d.ts +84 -0
  105. package/package.json +1 -1
  106. package/dist/observe/core/optimistic.js +0 -669
  107. package/dist/observe/store/next/optimistic.js +0 -717
  108. package/dist/observe/store/next/projection.js +0 -266
  109. package/dist/observe/store/next/reconcile.js +0 -375
  110. package/dist/observe/store/next/store.js +0 -2608
  111. package/dist/prod/core/optimistic.js +0 -658
  112. package/dist/prod/store/next/optimistic.js +0 -710
  113. package/dist/prod/store/next/projection.js +0 -257
  114. package/dist/prod/store/next/reconcile.js +0 -373
  115. package/dist/prod/store/next/store.js +0 -2484
  116. package/dist/types/core/optimistic.d.ts +0 -6
  117. package/dist/types/store/next/optimistic.d.ts +0 -25
  118. package/dist/types/store/next/projection.d.ts +0 -27
  119. package/dist/types/store/next/reconcile.d.ts +0 -10
  120. package/dist/types/store/next/store.d.ts +0 -145
  121. package/dist/types/store/next/target.d.ts +0 -196
@@ -1,24 +1,20 @@
1
1
  import { releaseFlightTeardown, handleAsync, clearStatus, parkLoadingWindow, notifyStatus, settlePendingSource, settleErroredDependents } from "./async.js";
2
2
 
3
- import { NOT_PENDING, EFFECT_TRACKED, EFFECT_USER, REACTIVE_OPTIMISTIC_DIRTY, CONFIG_DERIVED_OVERRIDE, CONFIG_HELD_CHILDREN, CONFIG_LANE_FRAME, CONFIG_OPTIMISTIC, STATUS_UNINITIALIZED, STATUS_ERROR, STATUS_PENDING, REACTIVE_REASK, REACTIVE_RECOMPUTING_DEPS, REACTIVE_ZOMBIE, CONFIG_SYNC, CONFIG_HAS_LANE, REACTIVE_MISSED_WAKE, REACTIVE_DISPOSED, REACTIVE_SNAPSHOT_STALE, unwrapOverride, CONFIG_DIRECT_COMMIT, CONFIG_HAS_COMPANIONS, CONFIG_PROMOTED, CONFIG_ADOPTED_UNFLUSHED, CONFIG_CHILDREN_FORBIDDEN, CONFIG_FRESH_READ, CONFIG_INPUTS_PUBLISHED, CONFIG_AUTO_DISPOSE, REACTIVE_LAZY, REACTIVE_CHECK, REACTIVE_DIRTY, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_MANUAL_WRITE, CONFIG_AUTHORITATIVE_READ, CONFIG_OVERRIDE_SUPERSEDED, CONFIG_AUTHORITATIVE_OBSERVED, defaultContext, REACTIVE_NONE, CONFIG_HELD_TRUTH, CONFIG_TRANSPARENT, CONFIG_OWNED_WRITE, CONFIG_NO_SNAPSHOT, CONFIG_PLUMBING, CONFIG_IN_SNAPSHOT_SCOPE, NO_SNAPSHOT, CONFIG_HAS_SNAPSHOT, CONFIG_FW_CHILDREN, CONFIG_SLOT_NODE, STORE_SNAPSHOT_PROPS } from "./constants.js";
3
+ import { STATUS_UNINITIALIZED, REACTIVE_LAZY, REACTIVE_NONE, defaultContext, CONFIG_TRANSPARENT, CONFIG_OWNED_WRITE, CONFIG_AUTO_DISPOSE, CONFIG_SYNC, CONFIG_NO_SNAPSHOT, CONFIG_PLUMBING, CONFIG_IN_SNAPSHOT_SCOPE, NOT_PENDING, NO_SNAPSHOT, CONFIG_HAS_SNAPSHOT, CONFIG_HELD, REACTIVE_MANUAL_WRITE, REACTIVE_DIRTY, CONFIG_OVERRIDE, REACTIVE_DISPOSED, REACTIVE_CHECK, REACTIVE_IN_HEAP, REACTIVE_REASK, REACTIVE_SNAPSHOT_STALE, REACTIVE_LANE_DIRTY, CONFIG_GUESS, REACTIVE_RECOMPUTING_DEPS, STATUS_PENDING, CONFIG_VERDICT, EFFECT_RENDER, CONFIG_HELD_FRAME, EFFECT_TRACKED, CONFIG_STAGED, STATUS_ERROR, REACTIVE_ZOMBIE, REACTIVE_MISSED_WAKE, REACTIVE_JOINED, REACTIVE_PROBED, REACTIVE_FRAME_READ, REACTIVE_STAGED_READ, REACTIVE_LANE_READ, REACTIVE_SCREEN_READ, REACTIVE_PROBE_UNANSWERED, CONFIG_CHILDREN_FORBIDDEN, CONFIG_PROMOTED, CONFIG_INPUTS_PUBLISHED, CONFIG_FRESH_READ, REACTIVE_IN_HEAP_HEIGHT, CONFIG_SLOT_NODE, EFFECT_USER } from "./constants.js";
4
4
 
5
5
  import { NotReadyError } from "./error.js";
6
6
 
7
7
  import { clearDeps, trimStaleDeps, link, dormantNodes } from "./graph.js";
8
8
 
9
- import { deleteFromHeap, queueFor, insertIntoHeapHeight, enqueueSub, markNode, markHeap, insertIntoHeap } from "./heap.js";
10
-
11
- import { findLane } from "./lanes.js";
9
+ import { insertIntoHeap, deleteFromHeap, insertIntoHeapHeight, enqueueSub, markNode, markHeap } from "./heap.js";
12
10
 
13
11
  import { GRAPH_SIZE_WARN_AT, noteFanIn } from "./dev.js";
14
12
 
15
13
  import { attrHooks } from "./attribution-hooks.js";
16
14
 
17
- import "./invariants.js";
18
-
19
- import { disposeChildren, markDisposal, linkChild, inheritId } from "./owner.js";
15
+ import { inheritId, disposeChildren, linkChild, markDisposal } from "./owner.js";
20
16
 
21
- import { GlobalQueue, bumpNotifyEpoch, activeTransition, globalQueue, clock, currentTransition, insertSubs, queuePendingNode, wakeParked, heldTrims, runInTransition, schedule, batchJoins, notifyEpoch, dirtyQueue, projectionWriteActive, reaskArmed, armReaskClear } from "./scheduler.js";
17
+ import { schedule, GlobalQueue, clock, txOf, flushTransaction, joinFuture, queuePendingNode, globalQueue, notifyEpoch, insertSubs, dirtyQueue, bumpNotifyEpoch, setPassLane, passLane, joinPassTx, passTx, holdNode, laneDirty, heldTrim, staleReader, stagedReaders, deferZombie } from "./scheduler.js";
22
18
 
23
19
  // The heap's per-node step. A tracked effect's heap visit is its compute
24
20
  // phase — empty, like a user effect whose compute reads nothing — and hands
@@ -28,62 +24,34 @@ import { GlobalQueue, bumpNotifyEpoch, activeTransition, globalQueue, clock, cur
28
24
  // render-effect callback stages its value for the next pass, but a wake pushed
29
25
  // directly into the user queue ran in the SAME pass, read the old value, and
30
26
  // nothing re-notified it when the value landed (#3291).
31
- GlobalQueue.nt = e => {
32
- if (e.He === EFFECT_TRACKED) {
33
- deleteFromHeap(e, queueFor(e));
34
- e.it = true;
35
- e.T.enqueue(EFFECT_USER, e.lt);
36
- } else recompute(e);
27
+ GlobalQueue.et = e => {
28
+ if (e.u === EFFECT_TRACKED) {
29
+ deleteFromHeap(e, dirtyQueue);
30
+ e.lt = true;
31
+ globalQueue.enqueue(EFFECT_USER, e.M);
32
+ }
33
+ // L2: a zombie's fate is the seam's — its owner's commit disposes it, or
34
+ // the park cancels the pass (the write that dirtied it is held). It runs
35
+ // only past a seam that left it alive (a live write to a frame whose
36
+ // owner is held in the future). Its lane's own re-staging is a live write
37
+ // (REACTIVE_LANE_DIRTY — a lane shows ahead of any park): it runs now, as
38
+ // the lane's work, for the reveal this seam (#3463).
39
+ else if (e.R & REACTIVE_ZOMBIE && !(e.R & REACTIVE_LANE_DIRTY)) deferZombie(e); else recompute(e);
37
40
  };
38
41
 
39
- GlobalQueue.ut = disposeChildren;
42
+ GlobalQueue.Et = disposeChildren;
40
43
 
41
44
  let tracking = false;
42
45
 
43
- /** @internal verdict-module glue */ function setPendingCheckActive(e) {
44
- pendingCheckActive = e;
45
- }
46
-
47
- /** @internal verdict-module glue */ function setLatestReadActive(e) {
48
- latestReadActive = e;
49
- }
50
-
51
- /** @internal verdict-module glue */ function setContextInternal(e) {
52
- context = e;
53
- }
54
-
55
- let stale = false;
56
-
57
- let pendingCheckActive = false;
58
-
59
- let latestReadActive = false;
60
-
61
46
  let context = null;
62
47
 
63
- let currentOptimisticLane = null;
64
-
65
- /** Notify `node`'s subscribers on `lane`'s channel: they recompute as the
66
- * lane's passes — a memo publishes a derived override (lanes stage, #3479),
67
- * an effect runs from the lane's queue, at the park, ahead of the
68
- * transaction — the display-ahead view. The write itself is already staged
69
- * (setSignal) and commits with the frame; this walk shows it now. Used by a
70
- * boundary re-armed from a lane pass (boundaries.ts `_swap`, #3540). */ function notifyOnLane(e, t) {
71
- const n = currentOptimisticLane;
72
- currentOptimisticLane = t;
73
- try {
74
- insertSubs(e, true);
75
- } finally {
76
- currentOptimisticLane = n;
77
- }
78
- }
79
-
80
48
  let snapshotCaptureActive = false;
81
49
 
82
50
  let snapshotSources = null;
83
51
 
84
52
  function ownerInSnapshotScope(e) {
85
53
  while (e) {
86
- if (e.ot) return true;
54
+ if (e.st) return true;
87
55
  e = e._parent;
88
56
  }
89
57
  return false;
@@ -95,34 +63,34 @@ function setSnapshotCapture(e) {
95
63
  }
96
64
 
97
65
  function markSnapshotScope(e) {
98
- e.ot = true;
66
+ e.st = true;
99
67
  }
100
68
 
101
69
  function releaseSnapshotScope(e) {
102
- e.ot = false;
70
+ e.st = false;
103
71
  releaseSubtree(e);
104
72
  schedule();
105
73
  }
106
74
 
107
75
  function releaseSubtree(e) {
108
- let t = e.On;
76
+ let t = e.nn;
109
77
  while (t) {
110
- if (t.ot) {
111
- t = t._n;
78
+ if (t.st) {
79
+ t = t.tn;
112
80
  continue;
113
81
  }
114
- if (t.Se) {
82
+ if (t.ee) {
115
83
  const e = t;
116
- e.C &= ~CONFIG_IN_SNAPSHOT_SCOPE;
117
- if (e.oe & REACTIVE_SNAPSHOT_STALE) {
118
- e.oe &= ~REACTIVE_SNAPSHOT_STALE;
119
- e.oe |= REACTIVE_DIRTY;
120
- if (dirtyQueue.st > e.ft) dirtyQueue.st = e.ft;
84
+ e.i &= ~CONFIG_IN_SNAPSHOT_SCOPE;
85
+ if (e.R & REACTIVE_SNAPSHOT_STALE) {
86
+ e.R &= ~REACTIVE_SNAPSHOT_STALE;
87
+ e.R |= REACTIVE_DIRTY;
88
+ if (dirtyQueue.ut > e.it) dirtyQueue.ut = e.it;
121
89
  insertIntoHeap(e, dirtyQueue);
122
90
  }
123
91
  }
124
92
  releaseSubtree(t);
125
- t = t._n;
93
+ t = t.tn;
126
94
  }
127
95
  }
128
96
 
@@ -133,12 +101,8 @@ function clearSnapshots() {
133
101
  // pre-initialized to undefined (see ext()), and every reader tests
134
102
  // `!== undefined` — assign, don't `delete`: deleting a field pushes the
135
103
  // object to dictionary mode for every later read of every field.
136
- const t = e.o;
137
- if (t != null) t.ct = undefined;
138
- // StoreNode targets share one pre-initialized hidden class (see
139
- // createStoreProxy) — same rule, and only when present so signal-node
140
- // sources don't grow the field.
141
- if (e[STORE_SNAPSHOT_PROPS] !== undefined) e[STORE_SNAPSHOT_PROPS] = undefined;
104
+ const t = e.m;
105
+ if (t != null) t.ot = undefined;
142
106
  }
143
107
  snapshotSources = null;
144
108
  }
@@ -148,246 +112,164 @@ function clearSnapshots() {
148
112
  function recompute(e, t = false) {
149
113
  // §12d: any recompute can clean a marked subscriber — invalidate skips.
150
114
  bumpNotifyEpoch();
151
- const n = e.He;
115
+ const n = e.u;
116
+ // Lanes (plan sec. 28): the seat of a pass is its node's. A node carrying a lane's
117
+ // derived value runs as the lane's whoever dirtied it — a sync write, a
118
+ // boundary reset, a frame rerun — so its children and its result are the
119
+ // lane's; so does a member the lane's own re-staging dirtied
120
+ // (REACTIVE_LANE_DIRTY, lanes.ts — a leaf the lane owns). A written guess's
121
+ // own pass is its truth arriving (A18), the frame's. A first pass is its
122
+ // creator's (ruling A: a lane pass's children are the lane's frame), and
123
+ // under a guess's lane it reads as the lane's too — a binding the lane
124
+ // mounts sees the screen, like the pass that mounted it (#3835). Not
125
+ // under a verdict lane, for its reads or its result: a verdict lane holds
126
+ // verdicts, and a mount it makes is a mainline mount (A29's boundary
127
+ // exemption, #3851). A tracked read of a lane's value moves a
128
+ // derivation's pass into the lane (`read`); a leaf's never moves.
129
+ // Restored at the end, after this pass's staging and runs have been
130
+ // routed.
131
+ const l = passLane;
132
+ setPassLane((e.R & REACTIVE_LANE_DIRTY || (e.i & (CONFIG_OVERRIDE | CONFIG_GUESS)) === CONFIG_OVERRIDE) && e.m?._t?.B ? e.m._t : // Loose `!=`: false with no creator lane (undefined == null).
133
+ t && l?._parent.rt != l && (creatorPass(context)?.R ?? 0) & REACTIVE_RECOMPUTING_DEPS ? l : null);
152
134
  // Attribution hook: fired before this run touches the dep list — `_deps`
153
135
  // still holds the previous run's links (the subscriptions that could have
154
136
  // triggered this run, and the baseline for the engine's subscription diff).
155
- let i = false;
156
- if (attrHooks !== null) attrHooks.recomputeStart(e, t);
157
- // Lane posture is resolved BEFORE the previous frame is parked below: a
158
- // lane pass parks a lane frame, not a transaction zombie (#3662, #3698;
159
- // see the parking site), so the decision must be known there. `lane` is applied to
160
- // `currentOptimisticLane` further down, once the previous posture is saved.
161
- let l = !!(e.oe & REACTIVE_OPTIMISTIC_DIRTY);
162
- let u = null;
163
- if (l) {
164
- u = GlobalQueue._t(e, true);
165
- // `false` = wake-only lane demotion: recompute plain so a mid-tick
166
- // latest()/isPending() pull stages instead of direct-committing (#3009).
167
- // The predicate lives with the engine (recomputeLane).
168
- if (u === false) l = false;
169
- } else if (e.C & CONFIG_DERIVED_OVERRIDE) {
170
- // Lanes stage (#3479): a pass over a live lane member carrying a derived
171
- // override is the lane's pass whatever channel dirtied it (a boundary
172
- // reset, an unrelated sync write) — its inputs serve the lane's view, so
173
- // its result is the lane's and belongs in the override slot. Run plain,
174
- // A18's sync twin below read that re-derived lane view as a differing
175
- // truth (a fresh array), superseded the override and demoted the lane;
176
- // the lane's next pass then dropped the staged "truth" and left the node
177
- // flagged superseded with nothing to serve (fuzzer latest-1 #2481). A
178
- // demoted node resolves no lane and stays plain: its pass IS the truth.
179
- u = GlobalQueue._t(e, true);
180
- if (u) l = true;
181
- } else if (activeTransition && !t && activeTransition.bn.length) {
182
- // Lane adoption: parent-deeper-than-owned-child can run before its OPT-dirty
183
- // child propagates. Walk deps once and inherit the OPT lane so this node
184
- // recomputes under the right posture and propagates correctly.
185
- u = GlobalQueue._t(e, false);
186
- if (u) l = true;
137
+ let E = false;
138
+ {
139
+ e.Ze = 0;
140
+ if (attrHooks !== null) attrHooks.recomputeStart(e, t);
187
141
  }
188
- if (!t) {
189
- // A stamped memo re-enters its hold: its value is that transaction's work.
190
- // An effect's pass belongs to whatever dirtied it (A15 corollary: effects
191
- // don't entangle parallel transactions); it joins its stamp only when the
192
- // pass observes the held flight — queue notification (#3407).
193
- if (e.me && !n && activeTransition !== e.me) globalQueue.initTransition(e.me);
194
- deleteFromHeap(e, queueFor(e));
195
- if (e.o !== null) {
196
- e.o.pe = null;
142
+ // CARVE 2: lane posture resolution (OPTIMISTIC_DIRTY, derived-override
143
+ // re-derivation, lane adoption through deps) went with the optimistic engine.
144
+ if (!t) {
145
+ deleteFromHeap(e, dirtyQueue);
146
+ if (e.m !== null) {
147
+ e.m.Te = null;
197
148
  // Supersede is where an iterator flight dies (#3122): close it now.
198
- // Its cleanup(close) registration may sit in a zombie-deferred
199
- // disposal list that a held transition only drains when the
200
- // SUPERSEDING flight settles — cancellation must not wait for the
201
- // work that replaced it. Idempotent with the cleanup-channel close.
149
+ // Idempotent with the cleanup-channel close.
202
150
  releaseFlightTeardown(e);
203
151
  }
204
- // Tracked effects run after finalizePureQueue, so dispose immediately
205
- // instead of deferring. Children built by an uncommitted recompute
206
- // (CONFIG_HELD_CHILDREN) die immediately too: no frame ever showed them.
207
- // Everything else is the committed frame's. Which frame retires it is
208
- // decided by who owns the pass, never by the node's kind (A15 lane work
209
- // and transaction work, ruled 2026-09-28, #3698). Transaction work — a
210
- // pass under a held transaction — defers them as zombies until this
211
- // node's commit, a transaction-owned node included (#3404): a parked
212
- // node's children predate the hold, and tearing them down when the
213
- // source lands ran cleanups before the transaction's atomic reveal.
214
- // Lane work — a pass over a lane, effect or memo alike — parks a LANE
215
- // frame instead (CONFIG_LANE_FRAME, #3662, #3698): the frame it replaces
216
- // leaves the screen when the lane's queue applies this pass (A30) — not
217
- // at the action's commit — and a held lane defers that with the frame
218
- // still displayed. The drain is the lane's first render entry for this
219
- // pass, pushed before the pass builds the new frame: cleanups before
220
- // side effects — the retired frame's `onCleanup`s run ahead of every
221
- // effect callback of the new frame. While the frame waits, the live
222
- // children were never shown: a superseding pass disposes them here like
223
- // held children, and the parked frame stays. Zombies exist for
224
- // transaction work only: #3662 gated the lane frame on `isEffect`, and a
225
- // memo's lane pass (its value a derived override, A17) parked a
226
- // transaction zombie that made the memo a pending node of the action,
227
- // stamped it, and sent its next mainline recompute through the
228
- // stamped-memo arm above — a `Show` whose `when` getter owns a
229
- // compiler-emitted memo held an unrelated sync write for the action's
230
- // lifetime, against the #3460 ruling that a lane never holds a sync write.
231
- if (n === EFFECT_TRACKED || e.C & (CONFIG_HELD_CHILDREN | CONFIG_LANE_FRAME)) disposeChildren(e); else if (e.On !== null || e.Ve !== null) {
232
- markDisposal(e);
233
- const t = ext(e);
234
- t.Et = e.Ve;
235
- t.dt = e.On;
236
- e.Ve = null;
237
- e.On = null;
238
- e.Nt = 0;
239
- if (u) {
240
- e.C |= CONFIG_LANE_FRAME;
241
- findLane(u).It[0].push(() => {
242
- e.C &= ~CONFIG_LANE_FRAME;
243
- disposeChildren(e, false, true);
244
- });
152
+ // L2: a pass over a held derivation joins its transaction — the
153
+ // propagation that reached this node reached the transaction, and this
154
+ // pass's answer replaces the held one there. A node held with nothing
155
+ // staged — pending when its flush parked, or a member of a held frame —
156
+ // joins all the same. Not a render effect (rule 3): it is the frame.
157
+ // Re-run outside its transaction's flush it publishes mainline — the
158
+ // value it staged there is superseded (`frameRead` remembers it for the
159
+ // landing). A frame born into the transaction (`bornInto`: never run,
160
+ // A29, or mounted by a pass of it still awaiting its commit, #4010) keeps
161
+ // staging: live writes keep it current, it effects at the swap (ruling
162
+ // A).
163
+ // A pending flight is the transition's own work (#3884). A probe on an
164
+ // earlier pass left CONFIG_VERDICT, and a frame read here would serve the
165
+ // committed screen, settle the flight and drop the hold — a superseding
166
+ // write's verdict would depend on that probe. Cleared for this pass; a
167
+ // probe in the body re-stamps it after the plain reads.
168
+ if (e.S & STATUS_PENDING) e.i &= ~CONFIG_VERDICT;
169
+ if (e.i & CONFIG_HELD) {
170
+ const t = txOf(e);
171
+ // Held by a blocked lane: the frame joins nothing — a lane never holds
172
+ // a sync write (#3460). The pass is the lane's if it reads the lane's
173
+ // world (`read`), and has left it otherwise.
174
+ if (t.B) ; else if (n !== EFFECT_RENDER && !(e.i & CONFIG_VERDICT)) joinPassTx(t); else if (t !== flushTransaction && !(e.S & STATUS_UNINITIALIZED || e.i & CONFIG_HELD_FRAME)) {
175
+ // Published mainline, it is not held: the frame this pass builds is
176
+ // replaced on the spot (#3404) — this flush's commit retires the
177
+ // committed frame the held pass had parked (`commitPendingNode`),
178
+ // after the new frame's first runs, and the held pass's own
179
+ // children die below (`disposeChildren`). The landing re-derives a
180
+ // fresh held frame for the reveal (`_reruns`).
181
+ e.Oe = NOT_PENDING;
182
+ if (n === EFFECT_RENDER) e.i &= ~CONFIG_HELD;
245
183
  }
246
- } else ;
184
+ }
185
+ // The previous pass's frame. If that pass is still awaiting its commit
186
+ // (CONFIG_STAGED) its children were never shown and die on the spot — the
187
+ // frame parked before it stays parked. Otherwise they ARE the frame:
188
+ // park them until this pass commits. Tracked effects run after the seam
189
+ // and own nothing to park.
190
+ if (n === EFFECT_TRACKED || e.i & CONFIG_STAGED) disposeChildren(e); else if (e.nn !== null || e.Re !== null) parkChildren(e);
247
191
  }
248
- // A derived override (lanes stage, #3479) is override-covered like a written
249
- // one: a plain pass over it — its source superseded (A18) — stages the truth
250
- // and supersedes the override through the sync twin below.
251
- const o = (e.C & (CONFIG_OPTIMISTIC | CONFIG_DERIVED_OVERRIDE)) !== 0 && e.o?.we !== NOT_PENDING && e.o?.we !== undefined;
252
- const r = !!(e.S & STATUS_UNINITIALIZED);
192
+ const s = !!(e.S & STATUS_UNINITIALIZED);
253
193
  // Capture both error and pending status before the compute clears them.
254
194
  // A conditional can drop its pending source and recover to an unchanged
255
195
  // value, leaving blocked dependents outside that source’s settle walk.
256
- const s = e.S & STATUS_ERROR ? e.o?._ : undefined;
257
- const a = (e.S & STATUS_PENDING) !== 0;
258
- const f = a ? e.o?.ue : undefined;
196
+ const u = e.S & STATUS_ERROR ? e.m?.F : undefined;
197
+ const i = (e.S & STATUS_PENDING) !== 0;
198
+ const o = i ? e.m?.Se : undefined;
259
199
  // Pending SOURCE-hood, captured before the compute clears status: a node
260
200
  // whose own flight parked dependents self-registers in _pendingSources
261
201
  // (notifyStatus, isSource). If this recompute supersedes that flight and
262
202
  // settles synchronously, those dependents settle HERE — asyncWrite's
263
203
  // settlePendingSource walk never runs for a landing that was preempted
264
204
  // (#3181).
265
- const c = e.o?.ue?.has(e);
266
- // Re-ask classification lives in the verdict module; capture the flag before
267
- // the recompute wipes _flags below.
268
- const _ = (e.oe & REACTIVE_REASK) !== 0;
269
- // Captured before the compute clears it on a sync landing: if that landing
270
- // is transition-held below, the window must stay open until the hold
271
- // commits (commitPendingNode) — a closed window plus a held value reads as
272
- // a pending frame to live observers of the verdict (#2990).
273
- const E = e.ye;
274
- // Creation-time A29 (see enterStagedRead): a pass outside a flush that is
275
- // served a live transaction's staged value records the transaction here
276
- // and is staged INTO it below — "born held" — instead of committing.
277
- const d = stagedEntry;
278
- stagedEntry = null;
279
- const N = context;
205
+ const _ = e.m?.Se?.has(e);
206
+ // A19 exc. 2: a `refresh()` re-asks the question already answered — quiet
207
+ // for the verdict — unless the question in flight is a new one, which the
208
+ // re-ask does not launder (a poll during a quiet confirm stays quiet).
209
+ const r = (e.R & REACTIVE_REASK) !== 0 && !(e.S & STATUS_PENDING && e.m !== null && !e.m.It);
210
+ const a = context;
280
211
  context = e;
281
- e.Je = null;
282
- e.We++;
283
- // REACTIVE_ZOMBIE is position, not scheduling state: it says the node sits
284
- // on its owner's `_pendingFirstChild` chain, and `disposeChildren` keys its
285
- // parent-chain splice off it. A zombie reruns for mainline writes until the
286
- // commit that disposes it (#3463), so the per-pass wipe here — and in the
287
- // finally below and in updateIfNecessary — must carry it (#3543): a
288
- // de-flagged zombie spliced itself out of the LIVE chain at disposal,
289
- // orphaning the owner's current child, which stayed subscribed forever.
290
- e.oe = REACTIVE_RECOMPUTING_DEPS | e.oe & REACTIVE_ZOMBIE;
291
- e.Ge = clock;
292
- let I = e._e === NOT_PENDING ? e.ce : e._e;
293
- let T = e.ft;
294
- let S = false;
295
- let O = tracking;
296
- let A = currentOptimisticLane;
212
+ e.p = null;
213
+ e.pe++;
214
+ // REACTIVE_ZOMBIE is position: it says the node sits on its owner's parked
215
+ // frame, and the splice/reawaken paths key off it. A zombie reruns for
216
+ // live writes until the commit that disposes it, so every per-pass wipe
217
+ // — here, the finally below, updateIfNecessary — carries it (#3543).
218
+ e.R = REACTIVE_RECOMPUTING_DEPS | e.R & REACTIVE_ZOMBIE;
219
+ e.Ie = clock;
220
+ // The pass's previous value: its staging, else a lane node's lane value
221
+ // when it has one (lanes.ts), else the committed one.
222
+ let I = e.Oe !== NOT_PENDING ? e.Oe : e.i & CONFIG_OVERRIDE && e.m.B !== NOT_PENDING ? e.m.B : e.Ae;
223
+ let N = e.it;
224
+ let f = false;
225
+ // L2: did this pass read the future (REACTIVE_JOINED, set by read)?
226
+ let T = false;
227
+ let S = tracking;
297
228
  tracking = true;
298
- // A computed's fn establishes its OWN dependencies, so it must never run
299
- // inside a latest() read window: read() short-circuits through the
300
- // companion path before dependency linking, so a memo created (eagerly
301
- // computed) inside latest(fn) came out permanently dependency-less (#2926).
302
- // latestRead() already suspends the flag for its pull-recomputes; this
303
- // covers creation-time computes and flushes that run inside the window.
304
- const C = latestReadActive;
305
- latestReadActive = false;
306
- // A memo computes under its OWN lane posture, never the puller's (A31,
307
- // #3442): its value is one shared slot every reader sees, so a pull from a
308
- // lane-carrying reader (a probe effect on its companion lane pulling a sync
309
- // memo) must not run it with that lane's read carve-outs — under a lane, a
310
- // pending node on no lane serves its committed value instead of throwing,
311
- // and the memo then published a stale "settled" value, dropped its
312
- // pending status, and stopped holding its transaction. The branches below
313
- // re-establish the posture the memo itself owns (OPT-dirty, or adopted
314
- // through its deps). Effects keep the ambient lane: their runs are the
315
- // lane's own view.
316
- if (!n) currentOptimisticLane = null;
317
- // Lane posture lives with the engine: OPTIMISTIC_DIRTY is only ever set by
318
- // engine-driven paths, and _optimisticNodes is only pushed by
319
- // _optimisticWrite, so the hook is installed whenever either gate holds.
320
- // (Resolved at the top of this pass, ahead of the parking site.)
321
- if (u) currentOptimisticLane = u;
322
- const p = n && n !== EFFECT_USER;
323
- const R = stale;
324
- if (p) stale = true;
325
- // An effect recorded for this transaction's commit replay (it once read a
326
- // node the transaction held and showed the committed value) and now
327
- // recomputing UNDER the transaction sees its staged view: the value this
328
- // run produces is applied by the commit itself, and the stale recording
329
- // would publish the frame a second time. Drop it; the reads below re-record
330
- // if they are served the committed view again (a lane's committed read).
331
- if (n && activeTransition !== null && activeTransition.Tt.size) activeTransition.Tt.delete(e);
332
229
  try {
333
- if (!false && e.C & CONFIG_SYNC) {
334
- I = e.Se(I);
335
- if (e.o !== null) e.o.pe = null;
336
- e.ye = false;
230
+ if (!false && e.i & CONFIG_SYNC) {
231
+ I = e.ee(I);
232
+ if (e.m !== null) e.m.Te = null;
233
+ e.De = false;
337
234
  } else {
338
- // Snapshot `_inFlight` so we can detect whether `_fn` self-registered an async
339
- // subscription (e.g. `createProjection` calls `handleAsync` from inside its body
340
- // with a setter callback). In that case, the outer `handleAsync` call below would
341
- // clobber the fresh subscription, so we skip it and let the internally-registered
342
- // iteration drive updates.
343
- const t = e.o?.pe;
344
- const n = e.Se(I);
345
- const i = typeof n === "object" && n !== null;
346
- const l = e.o?.pe !== t;
347
- I = l || !i ? n : handleAsync(e, n);
348
- if (!l && !i) {
349
- if (e.o !== null) e.o.pe = null;
235
+ // A projection's body self-registers its flight through handleAsync
236
+ // (with the commit as setter): its undefined return is not a sync
237
+ // answer, and the outer handleAsync must not clobber the registration.
238
+ const t = e.m?.Te;
239
+ const n = e.ee(I);
240
+ const l = typeof n === "object" && n !== null;
241
+ const E = e.m?.Te !== t;
242
+ I = E || !l ? n : handleAsync(e, n);
243
+ if (!E && !l) {
244
+ if (e.m !== null) e.m.Te = null;
350
245
  // A sync (non-object) return is the first real answer; async-shaped
351
246
  // results clear inside handleAsync at their own landing points, and a
352
- // self-registered flight (inFlightChanged — projections) clears when
353
- // its internal handleAsync lands.
354
- e.ye = false;
247
+ // self-registered flight clears when its own handleAsync lands.
248
+ e.De = false;
355
249
  }
356
250
  }
357
251
  // On a status-free node clearStatus is a guaranteed no-op: every field
358
252
  // its body gates on is either _statusFlags or lives in the cold
359
253
  // extension — no extension, no status to clear. (_x from an unrelated
360
254
  // installer just makes clearStatus a cheap re-verified no-op.)
361
- // A node born held keeps STATUS_UNINITIALIZED until its transaction
362
- // commits: it has no committed value, and read() holds its readers.
363
- if (e.S !== 0 || e.o !== null) clearStatus(e, t && stagedEntry === null);
364
- // _optimisticLane is only ever assigned by engine paths (CONFIG_HAS_LANE
365
- // is their sticky presence mark).
366
- if (e.C & CONFIG_HAS_LANE && e.o?.Ce) GlobalQueue.St(e);
255
+ if (e.S !== 0 || e.m !== null) clearStatus(e, t);
367
256
  } catch (t) {
368
257
  const n = t instanceof NotReadyError;
369
- if (n && e.ye) {
258
+ if (n && e.De) {
370
259
  // Loading window with an unready sync dependency: register for the
371
260
  // source's settle (the settlePendingSource walk runs off
372
261
  // _pendingSources + _blocked alone) but take NO read-visible pending
373
- // status, no downstream propagation, no transition, no lane
374
- // registration — the committed loading value keeps serving. If the
262
+ // status and no downstream propagation — the committed loading value
263
+ // keeps serving. If the
375
264
  // node is currently errored the error stays the answer until this
376
265
  // retry can actually run.
377
266
  parkLoadingWindow(e, t);
378
267
  } else {
379
- // Track pending async in the lane (not the lane's source — it creates the lane
380
- // but doesn't belong to it). Set lane BEFORE notifyStatus for downstream propagation.
381
- if (n && currentOptimisticLane) GlobalQueue.Ot(e);
382
- let i = false;
383
- if (n) {
384
- ext(e).Oe = true;
385
- if (GlobalQueue.At !== null) i = GlobalQueue.At(e, _);
386
- }
387
- notifyStatus(e, n ? STATUS_PENDING : STATUS_ERROR, t, undefined, n ? e.o?.Ce : undefined);
268
+ if (n) ext(e).de = true;
269
+ notifyStatus(e, n ? STATUS_PENDING : STATUS_ERROR, t);
388
270
  // The replacement source is fully propagated now. If no new flight
389
271
  // re-owned self, retire the superseded flight and its dependent copies.
390
- if (n && c && !e.o?.pe) settlePendingSource(e);
272
+ if (n && _ && !e.m?.Te) settlePendingSource(e);
391
273
  // A re-park drops what the earlier pass carried (#3456): a source this
392
274
  // pass no longer reaches — its branch switched, or a fresh flight
393
275
  // replaced the inputs' pending with its own — stays copied onto
@@ -396,32 +278,34 @@ function recompute(e, t = false) {
396
278
  // dependent then waits forever on a flight it has no path to. The
397
279
  // re-park twin of the unchanged-value recovery sweep below; dependents
398
280
  // with another path keep the source (retryReaches).
399
- if (n && f) for (const t of f) if (t !== e && !e.o?.ue?.has(t)) settlePendingSource(e, t);
400
- if (i) GlobalQueue.k(e);
281
+ if (n && o) for (const t of o) if (t !== e && !e.m?.Se?.has(t)) settlePendingSource(e, t);
401
282
  }
402
283
  } finally {
403
- tracking = O;
404
- latestReadActive = C;
405
- if (p) stale = R;
284
+ tracking = S;
406
285
  // Consume the missed-wake latch (#3037, set by insertSubs): a dep write
407
286
  // landed beneath this pass on a link it had already validated. The wipe
408
287
  // below must not key off DIRTY/CHECK — the read-time pull protocol
409
288
  // (markNode(c) in read()) marks the running node as part of ordinary
410
289
  // bookkeeping, and those marks are correctly discarded here.
411
- S = (e.oe & REACTIVE_MISSED_WAKE) !== 0;
290
+ f = (e.R & REACTIVE_MISSED_WAKE) !== 0;
291
+ T = (e.R & REACTIVE_JOINED) !== 0;
292
+ // A verdict reader is one for as long as it probes: a pass that entered
293
+ // no window (REACTIVE_PROBED) is an ordinary derivation again.
294
+ if (!(e.R & REACTIVE_PROBED)) e.i &= ~CONFIG_VERDICT;
412
295
  // REACTIVE_DISPOSED survives too (#3621): the pass may have disposed its
413
296
  // own owner (a memo calling its root's `dispose()`, a cleanup doing so
414
297
  // #3601/#3606), and `disposeChildren` set the flag on this node
415
298
  // reentrantly. Dropped, the node read as live — `refresh()` re-ran it
416
- // and `isDisposed()` lied.
417
- e.oe = e.oe & (REACTIVE_ZOMBIE | REACTIVE_DISPOSED) | (t ? e.oe & REACTIVE_SNAPSHOT_STALE : 0);
418
- context = N;
299
+ // and `isDisposed()` lied. REACTIVE_FRAME_READ (A15 stale reader) is
300
+ // this pass's verdict for the landing; the next pass's wipe at the top
301
+ // clears it.
302
+ e.R = e.R & (REACTIVE_ZOMBIE | REACTIVE_DISPOSED | REACTIVE_FRAME_READ | REACTIVE_STAGED_READ | REACTIVE_LANE_READ | REACTIVE_SCREEN_READ | REACTIVE_PROBE_UNANSWERED) | (t ? e.R & REACTIVE_SNAPSHOT_STALE : 0);
303
+ context = a;
304
+ // A19 exc. 2: a pass that went pending on a `refresh()` re-asks the
305
+ // question already answered — quiet for the verdict; any other pending
306
+ // pass is a new question. Settled, there is nothing to classify.
307
+ if (e.m !== null) e.m.It = r && (e.S & STATUS_PENDING) !== 0;
419
308
  }
420
- // The cast re-widens: TS narrowed `stagedEntry` to `null` at the reset
421
- // above and does not invalidate that across the compute call that
422
- // `enterStagedRead` runs under. No emitted code.
423
- const G = stagedEntry;
424
- stagedEntry = d;
425
309
  // A node that died during its own pass (#3621) is dead at the end of it,
426
310
  // and the pass is void. Its owner's teardown already unlinked its deps,
427
311
  // removed it from the heap and ran its cleanups; what remains is what the
@@ -433,14 +317,26 @@ function recompute(e, t = false) {
433
317
  // so nothing is staged, committed, or propagated to subscribers, and an
434
318
  // effect's run is not enqueued (runEffect would refuse it anyway). The
435
319
  // attribution frame opened at the top is still closed.
436
- if (e.oe & REACTIVE_DISPOSED) {
320
+ if (e.R & REACTIVE_DISPOSED) {
437
321
  clearDeps(e);
438
- if (e.o !== null) e.o.pe = null;
322
+ if (e.m !== null) e.m.Te = null;
439
323
  if (attrHooks !== null) attrHooks.recomputeEnd(e, t, false, false, false, false);
440
- currentOptimisticLane = A;
324
+ setPassLane(l);
441
325
  return;
442
326
  }
443
- if (!e.o?._) {
327
+ // The lane this pass is work of, if any: its seat (the node's, its
328
+ // creator's, or the one a lane read moved it into). A pass in a lane's
329
+ // seat that read none of the lane's world has left it: its result is the
330
+ // frame's (a derivation whose branch no longer reaches the guess). A
331
+ // guess is written, not derived — it never leaves this way.
332
+ let c = passLane;
333
+ // Listed before its staging, a pending pass included (the lane's own
334
+ // flight is the lane's); false: the pass left the lane (lanes.ts).
335
+ const A = !!e.m?.F;
336
+ if (c !== null) {
337
+ if (GlobalQueue.W(e, c, t, A)) setPassLane(c); else c = null;
338
+ }
339
+ if (!e.m?.F) {
444
340
  // Observe-tier fan-in (HUGE_FAN_IN): the validated prefix [_deps.._depsTail]
445
341
  // IS this pass's distinct sources — count it here rather than per link. A
446
342
  // begin/end bracket around the pass plus a per-link increment measured
@@ -451,22 +347,20 @@ function recompute(e, t = false) {
451
347
  // this pass, or at its commit — see recompute's tail.)
452
348
  {
453
349
  let t = 0;
454
- for (let n = e.Ee; n !== null; n = n.Ie) {
350
+ for (let n = e.G; n !== null; n = n._) {
455
351
  t++;
456
- if (n === e.Je) break;
352
+ if (n === e.p) break;
457
353
  }
458
354
  if (t >= GRAPH_SIZE_WARN_AT) noteFanIn(e, t);
459
355
  }
460
356
  // INV-11 (#3330): the equality gate compares against the slot this run
461
- // publishes to. An override-covered node publishes the override; a lane
462
- // recompute (OPT-dirty) direct-commits `_value` — the lane's own reveal
463
- // schedule — so a transaction-held `_pendingValue` that already equals
464
- // the new result is not "unchanged": the screen still shows `_value`.
465
- // Only a transaction-staged run compares against `_pendingValue`.
466
- const u = o ? unwrapOverride(e.o?.we) : l || e._e === NOT_PENDING ? e.ce : e._e;
467
- let a = false;
357
+ // publishes to — the staged `_pendingValue` when staged; a lane node's
358
+ // lane value (a node entering the lane this pass has none yet — its
359
+ // committed value, `laneStage` having voided a frame staging).
360
+ const i = e.Oe !== NOT_PENDING ? e.Oe : e.i & CONFIG_OVERRIDE && e.m.B !== NOT_PENDING ? e.m.B : e.Ae;
361
+ let r = false;
468
362
  try {
469
- a = !n && r || !e.Fe || !e.Fe(u, I);
363
+ r = !n && s || !e.en || !e.en(i, I);
470
364
  } catch (t) {
471
365
  // A throwing user comparator is an error of this node's computation.
472
366
  // Route it through the same status path as a compute-phase throw so
@@ -477,263 +371,164 @@ function recompute(e, t = false) {
477
371
  // A committed derived change becomes a cause for this node's subscribers,
478
372
  // chaining their attribution through this node to the root write.
479
373
  if (attrHooks !== null) {
480
- i = a && !e.o?._;
481
- if (i && !n && !t) attrHooks.derivedChanged(e);
374
+ E = r && !e.m?.F;
375
+ if (E && !n && !t) attrHooks.derivedChanged(e);
482
376
  }
483
377
  // Effects use `_equals: false` (no per-effect closure). The side effects that
484
378
  // the equals closure used to perform — flagging the effect dirty and enqueueing
485
379
  // its runner — happen here instead. `!create` matches the previous `initialized`
486
380
  // gate: the explicit recompute(node, true) inside effect() does not enqueue, so
487
381
  // effect() can call its runner synchronously for the first run.
488
- if (n && a) {
489
- e.it = !e.o?._;
382
+ if (n && r &&
383
+ // A stale reader of a lane (REACTIVE_SCREEN_READ) that computed what it
384
+ // last applied owes no run (lanes.ts).
385
+ !(e.R & REACTIVE_SCREEN_READ && !e.lt && Object.is(e.Nt, I)) &&
386
+ // A re-staging pass owes no run: the commit replays the effect (#3802).
387
+ e.Oe === NOT_PENDING) {
388
+ e.lt = !e.m?.F;
490
389
  // Reuse one bound runner per effect — runEffect no-ops on a stale
491
390
  // `_modified`, so re-enqueueing the same function is harmless.
492
- if (!t) {
493
- e.T.enqueue(n, e.Ct ??= GlobalQueue.Rt.bind(null, e));
494
- // Contested effect (#3322). Effects don't entangle transactions (a
495
- // shared effect is not shared state), yet they have one value slot:
496
- // when this write commits under a different transaction
497
- // (`activeTransition`, null = mainline) than the one that produced the
498
- // previous value (`_valueTransition`), that view is gone. Rather than
499
- // merge the two, each commit re-derives the effect against its own
500
- // committed world (Transition._contested, re-dirtied by
501
- // finalizePureQueue ahead of the heap run). The previous owner always
502
- // needs it if still live: its commit is silent (staging already
503
- // notified) and the value it computed is gone. The new owner needs it
504
- // too, for the same reason, unless it is mainline — mainline publishes
505
- // what it computes. A previous owner that was mainline, or already
506
- // committed, left nothing to protect.
507
- let t = e.Gt;
508
- if (t !== activeTransition) {
509
- e.Gt = activeTransition;
510
- if (t !== null && (t = currentTransition(t)) !== activeTransition && !t.Dt) {
511
- (t.ht ??= []).push(e);
512
- if (activeTransition !== null) (activeTransition.ht ??= []).push(e);
513
- }
514
- }
515
- }
391
+ // Lane work's run is the lane's (released at its reveal) — a first
392
+ // pass under a lane too: `effect()` skips the synchronous first run of
393
+ // a lane's node.
394
+ if (!t || c !== null) globalQueue.enqueue(n, e.Y ??= GlobalQueue.q.bind(null, e), c);
516
395
  }
517
- if (e.o?._) ; else if (a) {
518
- const i = o ? e.o?.we : undefined;
519
- if (t && G === null ||
520
- // Plain sync flush (no transition on either side) commits effect
521
- // values directly — the pending round-trip (queuePendingNode +
522
- // commitPendingNodes) exists to sequence transition reveals, and
523
- // paying it per effect on the plain path is pure overhead.
524
- // DIRECT_COMMIT effects (resolve/until) commit directly even under
525
- // their own held transition: their applies deliver on a microtask,
526
- // not the stashed queues, so a staged value would hand the immediate
527
- // apply stale state — see CONFIG_DIRECT_COMMIT.
528
- n && G === null && (activeTransition !== e.me || activeTransition === null || e.C & CONFIG_DIRECT_COMMIT) || l) {
529
- // Lanes stage (#3479): a lane pass on a memo publishes its speculative
530
- // result as an OVERRIDE — `_value` stays the committed truth, so a
531
- // reader off the lane (A17's committed view, #3460) sees a whole
532
- // committed frame: the source's shadow and its derivations together,
533
- // never a committed shadow beside a speculative memo. The lane's own
534
- // readers and untracked reads see the override (A17); the revert
535
- // drops it and re-derives (resolveOptimisticNodes). Effects keep the
536
- // direct commit — their `_value` is a run result the lane's queues
537
- // already sequence. Either way the lane pass drops any superseded
538
- // older hold so its queued commit can't clobber the fresh frame: a
539
- // hold staged on an earlier, lane-free pass of the SAME transaction
540
- // is superseded — left in place, the commit published the older
541
- // frame over the fresh one (#3377). A reversion pass (OPT-dirty with
542
- // no lane — the override dropped) commits directly: it IS the truth.
543
- if (l && !n && currentOptimisticLane !== null) GlobalQueue.je(e, I, currentOptimisticLane); else e.ce = I;
544
- if (l) e._e = NOT_PENDING;
396
+ // Lanes. A written guess's own pass from the frame: its source
397
+ // recomputed it — the truth (A18: "the source is whatever recomputes the
398
+ // node"). It stages under the lane's parent whether or not it changed (a
399
+ // confirm is a landing too — the lane's end commits it) and notifies
400
+ // only a correction: an equal truth re-runs nothing (lanes.ts). (As the
401
+ // lane's own work the lane judged it — `laneStage`.)
402
+ if (!t && c === null && e.i & CONFIG_GUESS && GlobalQueue.ft(e, I, A)) ; else if (A) ; else if (r) {
403
+ // L2: a first pass is born held — staged, committed with the
404
+ // transaction, its effect's first run the landing's (A29; `effect()`
405
+ // skips the synchronous first run on a staged value) — when the flush
406
+ // has joined a transaction and either the pass read a held node (it
407
+ // derives from that world — the join merged the node's transaction
408
+ // into the flush's), or — a verdict lane's mount, mainline — read a
409
+ // staging of this flush (the same world before the seam parks it; the
410
+ // mount is not shown ahead of it: #3851), or a pass created it (ruling
411
+ // A: a held pass's children are the transaction's). Any other mount
412
+ // that read a staging does not join by being new (2026-10-07): it
413
+ // publishes and re-derives if the flush parks. A node created outside any pass
414
+ // that read only the committed world (root setup, a mount, an effect
415
+ // callback) is nobody's frame and publishes directly, as does a first
416
+ // pass that runs before anything joins: the pass's input, not a verdict
417
+ // after it. An effect still carrying an uncommitted staged value
418
+ // re-stages: the commit applies the latest pass, not the born-held one.
419
+ if (c !== null) {
420
+ // Lane work: the lane's value — into the slot while the lane has not
421
+ // revealed (its reveal shows it), as its staging once it has (the
422
+ // next reveal promotes it; the screen keeps the revealed value). An
423
+ // effect's value slot is private: the run the lane holds is what
424
+ // shows it — unless the effect was born held, whose first run is the
425
+ // commit's (A29): it re-stages, as below.
426
+ if (n && e.Oe === NOT_PENDING) e.Ae = I; else if (n || c.Tt) e.Oe = I; else e.m.B = I;
427
+ } else if (t ? !((flushTransaction !== null || passTx !== null) && (T || l && e.R & REACTIVE_STAGED_READ || (creatorPass(a)?.R ?? 0) & REACTIVE_JOINED)) : n && e.Oe === NOT_PENDING) {
428
+ // A first pass publishes directly. So does an effect: its value slot
429
+ // is private (only its own run reads it), and the staging round-trip
430
+ // (queuePendingNode + commitPendingNodes) paid per effect on the
431
+ // plain path is pure overhead.
432
+ // NOTE (stage-3, 2026-08-21): a quiet-world MEMO direct-commit was
433
+ // attempted here and REVERTED — memo staging is load-bearing beyond
434
+ // transitions: mid-batch pulls (read-triggered recomputes before
435
+ // sources commit) must see the fresh value while PLAIN reads stay
436
+ // committed until flush (#3009 purity). The pending round-trip is
437
+ // that separation; it cannot be skipped on any path a pull can reach.
438
+ e.Ae = I;
545
439
  } else {
546
- e._e = I;
547
- if (G !== null) {
548
- // Born held: the pass ran from mainline and derived from this
549
- // transaction's staged world (enterStagedRead). Its value is the
550
- // transaction's — staged into it directly, stamped, and committed
551
- // with it; mainline's batch never sees it. A born-held effect
552
- // skips its synchronous first run (effect()) and is replayed by
553
- // the commit like a stale reader that showed the committed frame.
554
- // (A re-pass under a fresh boundary — the in-flush form — is
555
- // already the transaction's: restaged, not re-queued.)
556
- if (e.me !== G) {
557
- e.me = G;
558
- G.In.push(e);
559
- }
560
- if (n) G.Tt.add(e);
561
- // Under a boundary that has not revealed, a held first value is
562
- // something not ready under it (#3540): the boundary collects this
563
- // node as a source and shows its fallback; the source stays
564
- // collected while born held (CollectionQueue._checkSources) and
565
- // is released by the commit that initializes it. A boundary that
566
- // already shows content is not told — it holds like any reader.
567
- if (underFreshLoadingBoundary(e)) e.T.notify(e, STATUS_PENDING, STATUS_PENDING, new NotReadyError(e));
440
+ e.Oe = I;
441
+ // Born held: in the transaction from birth, so a read of it this
442
+ // tick is a read of its world (the mount-during-a-hold case), not
443
+ // only after the seam parks it.
444
+ if (t) {
445
+ holdNode(e, flushTransaction ?? passTx);
446
+ // Born into the future: no committed value until the landing
447
+ // (`commitPendingNode` initializes it) — every reader of it
448
+ // derives from the future (`read`), an untracked one throws
449
+ // (A19 exc. 1).
450
+ e.S |= STATUS_UNINITIALIZED;
451
+ // A boundary that has not shown content catches it: its fallback
452
+ // waits for the commit (#3540). (The pass's own status clear above
453
+ // dropped what the read recorded.)
454
+ GlobalQueue.fe?.(e);
568
455
  }
569
- // A window landing that gets held re-opens the window until the hold
570
- // commits — the verdict's held-value branch is window-gated (#2990).
571
- if (E) e.ye = true;
572
- // A staged sync recompute is a write path like setSignal/asyncWrite,
573
- // so sync derivations of held sources stay visible to isPending()/latest()
574
- // (#2831). Both companion writes are transition-scoped (optimistic) and
575
- // auto-revert/re-derive at commit. Not gated on an active transition:
576
- // a plain flush can still become a hold after this recompute — an
577
- // async memo downstream pends and the batch is adopted into a
578
- // transaction (scheduler.enterTransition) — and nothing re-derives
579
- // the companion at adoption, so a memo held that way read
580
- // isPending() false while its held source read true (#3413).
581
- if (e.C & CONFIG_HAS_COMPANIONS && GlobalQueue.Le !== null) GlobalQueue.Le(e, I);
582
456
  }
583
457
  // insertSubs only walks _subs (no scheduling of its own), so a
584
458
  // subscriber-less node has nothing to notify.
585
- if (e.u !== null && (!o || l || e.o?.we !== i)) insertSubs(e, l || o);
586
- // A18 supersession, sync twin of asyncWrite's override branch (#3331):
587
- // this pass published truth that differs from the override (the gate
588
- // compared against it) into the transaction-held slot. Whether the
589
- // source is this node's own async or an upstream node it derives from
590
- // synchronously makes no difference — "the source recomputed". The
591
- // override stays displayed until the commit; the graph moves to the
592
- // staged truth now (plain channel, lane demoted). Ordering: "a new
593
- // value from the source" postdates the override — an override written
594
- // in this same tick (optimisticWrite stamps `_overrideTime`) is the
595
- // newer intent over whatever this pass derives from the batch's staged
596
- // inputs, and is not superseded by it.
597
- else if (o && !l && e.o.Pt !== clock) GlobalQueue.Qe(e, I);
598
- } else if (o) {
599
- // Unchanged value (equals the override) recomputed while the override
600
- // is active: _value may still be stale, so hold the authoritative value
601
- // for commit on its own transition's schedule — invisibly (A17/A18).
602
- if (e._e === NOT_PENDING) queuePendingNode(e);
603
- e._e = I;
604
- if (E) e.ye = true;
605
- // see the held branch above (#2990)
606
- // A confirmation after a supersession restores the override as the
607
- // graph's value and notifies; a plain confirmation wakes only an
608
- // authoritative-view reader (until()'s predicate, refresh()'s waiter)
609
- // that observed this node past its override — "authoritative arrival
610
- // equal to the override" is exactly the acknowledgment it waits for;
611
- // A17 silence holds for every ordinary subscriber. Both live in the
612
- // engine's supersedeOverride.
613
- GlobalQueue.Qe(e, I);
614
- } else if (e.ft != T) {
615
- for (let t = e.u; t !== null; t = t.Pe) {
616
- insertIntoHeapHeight(t.Ae, queueFor(t.Ae));
459
+ if (e.t !== null) {
460
+ insertSubs(e);
461
+ // Lane work re-staged: the lane's members re-derive as its work.
462
+ if (c !== null) laneDirty(e, c);
617
463
  }
464
+ } else if (e.it != N) {
465
+ for (let t = e.t; t !== null; t = t.o) insertIntoHeapHeight(t.l, dirtyQueue);
618
466
  }
619
467
  // Silent recovery: errored → unchanged value fires no notification, but
620
468
  // dependents still holding the propagated error consumed their dirty flag
621
469
  // in an errored run and may sit on stale commits (#2949). Changed-value
622
470
  // recoveries ride insertSubs above; a comparator throw re-errored the node
623
471
  // (el._x?._error re-set), so this only runs on a genuinely clean recovery.
624
- if (!a && !e.o?._) {
625
- if (s !== undefined) settleErroredDependents(e, s);
472
+ if (!r && !e.m?.F) {
473
+ if (u !== undefined) settleErroredDependents(e, u);
626
474
  // Self-registration (this node's own superseded flight) is the #3181
627
475
  // sweep's business below — retiring it here too would walk twice.
628
- if (f) for (const t of f) if (t !== e) settlePendingSource(e, t);
476
+ if (o) for (const t of o) if (t !== e) settlePendingSource(e, t);
629
477
  }
630
478
  // #3181: a synchronous settle supersedes the old landing callback, so
631
479
  // recompute owns its pending-source sweep. An uninitialized node without
632
480
  // a replacement source still has no truth to reveal and must stay parked.
633
- if (c && !(e.S & (STATUS_PENDING | STATUS_UNINITIALIZED))) {
634
- settlePendingSource(e);
635
- // The superseded flight will not enter its waiting transactions at
636
- // landing. Recheck them now so an unchanged value cannot leave their
637
- // writes parked after the last pending source has settled.
638
- wakeParked();
639
- }
481
+ if (_ && !(e.S & (STATUS_PENDING | STATUS_UNINITIALIZED))) settlePendingSource(e);
640
482
  }
641
- // A REPORTER whose pass stopped reading a source it reported on (a gate
642
- // closed) stops counting for the transaction waiting on it (A15 / #3426:
643
- // the hold lasts while a live reporter observes the flight). Nothing else
644
- // re-judges a parked transaction (see wokenTransitions; the disposal
645
- // (#3372) and boundary (#3375) twins of this site), so the writes it held
646
- // stayed staged for as long as the flight stayed up — forever, for one
647
- // that never lands (fuzzer #3446 P1, spec O3). The event is "this pass
648
- // dropped a dep" — deps past `_depsTail` (trimmed below, or kept by A30
649
- // for a staged pass), or a pass that read nothing — not "recovered from
650
- // pending": a reporter registered by the stale-reader carve-out
651
- // (heldFromStale, an INITIALIZED source refetching) displays the committed
652
- // value and is never pending (fuzzer case 79). Every parked transaction,
653
- // not the reporter's stamp: the transaction waiting on it registered it
654
- // without stamping it. One idle pass per parked transaction; done ones
655
- // return at re-entry. Effects only — reporters register from render-effect
656
- // notification (INV-3).
657
- // (`_depsTail` was reset at the top of the pass; TS keeps that narrowing.)
658
- const D = e.Je;
659
- if (n && (a && !(e.S & STATUS_PENDING) || (D === null ? e.Ee !== null : D.Ie !== null))) wakeParked();
660
- // Dependencies are the committed frame's until it is replaced (A30, #3410; the
661
- // deps twin of the held children above): a pass that staged its value
662
- // leaves the previous pass's tail linked for `commitPendingNode` to trim,
663
- // so a write to a dependency the committed value still derives from
664
- // reaches this node — and joins its hold if the stage is transaction-held
665
- // by then (a plain flush decides nothing here: the transaction that holds
666
- // the pass may open later in the same flush). A pass that published
667
- // directly (a first pass, a lane's own reveal) trims now. An errored pass
668
- // (a throw, NotReady included, or a comparator throw above) keeps its full
483
+ // A first pass that went pending where the born-held arm would have held
484
+ // its value (it read a held node, or a verdict lane's mount read a staging,
485
+ // #3851) is held like it: its answer is the hold's, and the hold waits
486
+ // for it (A29, #3800) — unless a boundary that has not shown content
487
+ // catches it: then it is the boundary's, and the hold does not wait (#3540).
488
+ if (t && c === null && (T || l && e.R & REACTIVE_STAGED_READ) && e.S & STATUS_PENDING) {
489
+ const t = flushTransaction ?? passTx;
490
+ if (t !== null && !t.B && !GlobalQueue.fe?.(e)) holdNode(e, t);
491
+ }
492
+ // Dependencies are the committed frame's until it is replaced (A30, #3410):
493
+ // a pass that staged its value leaves the previous pass's tail linked for
494
+ // `commitPendingNode` to trim, so a write to a dependency the committed
495
+ // value still derives from reaches this node until the commit. A pass that
496
+ // published directly, or changed nothing, trims now. An errored pass (a
497
+ // throw, NotReady included, or a comparator throw above) keeps its full
669
498
  // list as before — `_depsTail` marks where it stopped — and the commit
670
499
  // skips it by the same `_error`. An effect's frame is the run its value is
671
- // applied by, not the value slot (#3438): a direct-committed pass that
672
- // still owes a run (`_modified`) has not replaced what the last run
673
- // published — the same flush may stash that run into a transaction it
674
- // opens later — so its tail waits for `runEffect` to trim once the run
675
- // applies. A pass that changed nothing replaced nothing either (#3469): the
676
- // same flush may park with its inputs held, and the committed frame still
677
- // derives from the tail — its trim waits on the flush's verdict (heldTrims).
678
- // A tracked effect's pass IS its run (it bypasses the heap and runs after
679
- // the commit): the frame is replaced, trim now.
680
- if (!e.o?._ && e._e === NOT_PENDING && !(n && e.it)) {
681
- if (t || l || n === EFFECT_TRACKED) trimStaleDeps(e); else if (e.Je?.Ie ?? e.Ee) heldTrims.push(e);
682
- }
683
- // Attribution hook: fired before the lane restore so `currentOptimisticLane`
684
- // still reflects THIS run's posture. The facts distinguish an overlay
685
- // recompute (optimistic lane, transition replay, transition-held commit)
686
- // from a plain committed one — the engine must not blame overlay runs as
687
- // waste or double-count them against plain aggregates.
688
- if (attrHooks !== null) attrHooks.recomputeEnd(e, t, i, l || currentOptimisticLane !== null, activeTransition !== null || e.me !== null, e._e !== NOT_PENDING);
689
- currentOptimisticLane = A;
690
- // A parked LANE frame is not a hold (#3662): its drain is the effect's own
691
- // run, not a commit — the node is neither queued nor stamped for it, and
692
- // the release below (for transaction zombies) leaves it parked.
693
- const h = (e.C & CONFIG_LANE_FRAME) !== 0;
694
- const P = e._e !== NOT_PENDING || !h && e.o !== null && (e.o.dt !== null || e.o.Et !== null) || (e.S & (STATUS_PENDING | STATUS_UNINITIALIZED)) !== 0;
695
- // Override-covered holds (hasOverride) always queue: their commit belongs
696
- // to their own transition's schedule (A18 re-rule) and is unobservable
697
- // under the override (A17). Revert no longer commits anything, so an
698
- // unqueued covered hold would leak (INV-7) once the revert clears
699
- // _transition.
700
-
701
- // While a pass's result waits on a commit, its children (and `_disposal`)
702
- // wait with it, and a re-run may tear them down immediately
703
- // (CONFIG_HELD_CHILDREN, #3404). One exception: a transaction-owned effect
704
- // recomputed mainline (contested, #3322) published its value directly — a
705
- // `_pendingValue` left from an earlier held pass is that transaction's,
706
- // not this one's — so this pass's children are the frame's, and any
707
- // zombies deferred at the top are superseded on that same frame. Its
708
- // commit rides the transaction, not this flush: release them here rather
709
- // than let two generations render at once. A LANE pass is the same case
710
- // (#3662): it direct-commits ahead of its transaction, so its children are
711
- // the frame's too. Left flagged for an OLDER frame's zombies, the stamped
712
- // transaction's same-flush re-run below disposed the lane's freshly built
713
- // children (an insert's inner effect, its run still queued in the lane)
714
- // and held their replacements for a commit that never came.
715
- let F = P && (!t || G !== null || (e.S & STATUS_PENDING) !== 0);
716
- if (F && (!e.me || o)) queuePendingNode(e); else if (F && (activeTransition === null || l) && !(e.S & (STATUS_PENDING | STATUS_UNINITIALIZED))) {
717
- F = false;
718
- if (!h) disposeChildren(e, false, true);
500
+ // applied by, not the value slot (#3438): a pass that still owes a run
501
+ // (`_modified`) has not replaced what the last run published, so its tail
502
+ // waits for `runEffect` to trim once the run applies. A pass that changed
503
+ // nothing replaced nothing either (#3469): it cannot know at its tail
504
+ // whether the flush that ran it will park with its inputs held, so the
505
+ // trim waits on the flush's verdict (`heldTrim`: trimmed at the commit,
506
+ // kept at a park — one spurious recompute at most). A creation pass and a
507
+ // tracked effect trim now: their frames are replaceable like a direct
508
+ // commit, and a tracked effect's spurious run would be user-visible.
509
+ if (!e.m?.F && e.Oe === NOT_PENDING && !(n && e.lt)) {
510
+ if (t || n === EFFECT_TRACKED) trimStaleDeps(e); else heldTrim(e);
719
511
  }
720
- if (F) e.C |= CONFIG_HELD_CHILDREN; else e.C &= ~CONFIG_HELD_CHILDREN;
721
- // (A born-held pass IS the transaction's staged view — nothing to refresh.)
722
- if (e.me && n && activeTransition !== e.me && G === null) {
723
- // The re-run refreshes the transaction's STAGED view (_pendingValue); the
724
- // value this pass published in _value belongs to the run that just
725
- // finished. Keep that ownership, or the effect phase parks a
726
- // mainline-computed value with the transaction (#3412).
727
- const t = e.Gt;
728
- runInTransition(e.me, () => recompute(e));
729
- e.Gt = t;
512
+ // Observe: the posture the run executed under — lane work (optimistic:
513
+ // overlay, never waste), a transaction's pass (held), or plain.
514
+ if (attrHooks !== null) attrHooks.recomputeEnd(e, t, E, c !== null, flushTransaction !== null || passTx !== null || (e.i & CONFIG_HELD) !== 0, e.Oe !== NOT_PENDING);
515
+ // A staged value, a parked frame (L2: the commit retires it), or status the
516
+ // commit sweep must settle (a pending or uninitialized pass), queues the
517
+ // node for this flush's commit. A first pass queues only when pending or
518
+ // born held: otherwise its value published directly. A queued pass's
519
+ // children are uncommitted (CONFIG_STAGED) until that commit.
520
+ if (e.Oe !== NOT_PENDING || e.m !== null && (e.m.St !== null || e.m.ct !== null) || (e.S & (STATUS_PENDING | STATUS_UNINITIALIZED)) !== 0 && (!t || (e.S & STATUS_PENDING) !== 0)) {
521
+ e.i |= CONFIG_STAGED;
522
+ // Lane work is the lane's to reveal (its seam), not this flush's commit.
523
+ if (c === null) queuePendingNode(e);
730
524
  }
525
+ setPassLane(l);
731
526
  // Missed-wake reschedule (see the finally above): values this pass read
732
527
  // before the nested commit are stale, so run again now that the heap will
733
528
  // accept the node. Equality gates stop same-value landings from cascading,
734
529
  // and a re-run only latches again if another nested commit changes a dep
735
530
  // beneath it — convergent unless deps genuinely keep changing.
736
- if (S) {
531
+ if (f) {
737
532
  enqueueSub(e);
738
533
  schedule();
739
534
  }
@@ -746,30 +541,30 @@ function updateIfNecessary(e) {
746
541
  // (#3037); readers meanwhile serve the values the pass has so far.
747
542
  // Never recompute a DISPOSED node either: recompute rewrites _flags and
748
543
  // would resurrect it (#2983) — readers serve its last value.
749
- if (e.oe & (REACTIVE_RECOMPUTING_DEPS | REACTIVE_DISPOSED)) return;
750
- if (e.oe & REACTIVE_CHECK) {
751
- for (let t = e.Ee; t; t = t.Ie) {
752
- const n = t.De;
753
- const i = n.Ne || n;
754
- if (i.Se) {
755
- updateIfNecessary(i);
544
+ if (e.R & (REACTIVE_RECOMPUTING_DEPS | REACTIVE_DISPOSED)) return;
545
+ if (e.R & REACTIVE_CHECK) {
546
+ for (let t = e.G; t; t = t._) {
547
+ const n = t.I;
548
+ if (n.ee) {
549
+ updateIfNecessary(n);
756
550
  }
757
- if (e.oe & REACTIVE_DIRTY) {
551
+ if (e.R & REACTIVE_DIRTY) {
758
552
  break;
759
553
  }
760
554
  }
761
555
  }
762
- if (e.oe & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || e.o?._ && e.Ge < clock && !e.o?.pe) {
556
+ if (e.R & REACTIVE_DIRTY || e.m?.F && e.Ie < clock && !e.m?.Te) {
763
557
  recompute(e);
764
558
  }
765
559
  // The guard above refused an already-disposed node; the recompute it just
766
560
  // ran may have disposed it (#3621) — carry the flag, or it comes back alive.
767
- // The manual-write mask is state, not scheduling (#3612): it says the
768
- // node's staging is a PROPOSAL, and only the commit (or a later-tick
769
- // refresh, #3026) lifts it — a pull that recomputed nothing must not, or
770
- // an isPending()/latest() probe decided whether a later write to a held
771
- // node was a second proposal or the derivation's `prev`.
772
- e.oe = e.oe & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_ZOMBIE | REACTIVE_DISPOSED | REACTIVE_MANUAL_WRITE);
561
+ // The manual-write mark is state, not scheduling (#3612, A34 rule B): it
562
+ // says the node's staging is a PROPOSAL, lifted by a pass that re-derives
563
+ // or by the commit — a pull that recomputed nothing must not. Nor may it
564
+ // erase the last pass's verdicts for the landing (a stale reader's
565
+ // REACTIVE_FRAME_READ — a verdict reader pulled by a sibling before the
566
+ // landing lost its re-derivation; the lane reads likewise).
567
+ e.R = e.R & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_ZOMBIE | REACTIVE_DISPOSED | REACTIVE_MANUAL_WRITE | REACTIVE_FRAME_READ | REACTIVE_STAGED_READ | REACTIVE_LANE_READ | REACTIVE_SCREEN_READ | REACTIVE_PROBE_UNANSWERED);
773
568
  }
774
569
 
775
570
  function computed(e, t) {
@@ -777,7 +572,7 @@ function computed(e, t) {
777
572
  // `in` (not `!== undefined`): an explicit `loadingValue: undefined` on a
778
573
  // `T | undefined` node is a real commit #0. The typeof guard tolerates
779
574
  // non-object option values that older call shapes force through `as any`.
780
- const i = t !== null && typeof t === "object" && "loadingValue" in t;
575
+ const l = t !== null && typeof t === "object" && "loadingValue" in t;
781
576
  // Two literals, one per tier, selected at build time (the observe flag is
782
577
  // a literal after replacement; the untaken branch is dead code). The observe
783
578
  // literal is the prod literal plus its `_name` slot — a slot in the
@@ -786,159 +581,240 @@ function computed(e, t) {
786
581
  // (measured: the whole of the observe tier's creation overhead). Keep the
787
582
  // two in sync — the dist artifact test pins observe's key set to prod's
788
583
  // plus `_name`.
789
- const l = {
584
+ const E = {
790
585
  id: inheritId(t, n, context),
791
- C: (n ? CONFIG_TRANSPARENT : 0) | (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (!context || t?.lazy ? CONFIG_AUTO_DISPOSE : 0) | (t?.sync ? CONFIG_SYNC : 0) | (t?.Z ? CONFIG_NO_SNAPSHOT : 0) | (
586
+ i: (n ? CONFIG_TRANSPARENT : 0) | (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (!context || t?.lazy ? CONFIG_AUTO_DISPOSE : 0) | (t?.sync ? CONFIG_SYNC : 0) | (t?.ae ? CONFIG_NO_SNAPSHOT : 0) | (
792
587
  // Plumbing is an observe-tier notion (a name and records to
793
588
  // withhold); the prod literal never carries the bit.
794
- t?.Ft ? CONFIG_PLUMBING : 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
795
- Fe: t?.equals ?? isEqual,
796
- Ve: null,
797
- T: context?.T ?? globalQueue,
798
- rt: context?.rt ?? defaultContext,
799
- Nt: 0,
800
- Se: e,
801
- ce: i ? t.loadingValue : undefined,
802
- ft: 0,
803
- gt: undefined,
804
- vt: null,
805
- Ee: null,
806
- Je: null,
807
- We: 0,
808
- u: null,
809
- Ht: null,
589
+ t?.At ? CONFIG_PLUMBING : 0) | (t?.Ct ?? 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
590
+ en: t?.equals ?? isEqual,
591
+ Re: null,
592
+ D: context?.D ?? defaultContext,
593
+ dt: 0,
594
+ ee: e,
595
+ Ae: l ? t.loadingValue : undefined,
596
+ it: 0,
597
+ Ot: undefined,
598
+ Rt: null,
599
+ G: null,
600
+ p: null,
601
+ pe: 0,
602
+ t: null,
603
+ Dt: null,
810
604
  _parent: context,
811
- _n: null,
812
- kt: null,
813
- On: null,
814
- oe: t?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
815
- S: i ? 0 : STATUS_UNINITIALIZED,
816
- Ge: clock,
817
- _e: NOT_PENDING,
818
- me: null,
819
- Lt: -1,
820
- ye: i,
821
- o: null,
605
+ tn: null,
606
+ Gt: null,
607
+ nn: null,
608
+ R: t?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
609
+ S: l ? 0 : STATUS_UNINITIALIZED,
610
+ Ie: clock,
611
+ Oe: NOT_PENDING,
612
+ Pt: -1,
613
+ De: l,
614
+ m: null,
822
615
  // The slot is always present (hidden class); plumbing leaves it
823
616
  // unset, which `ownerPath` skips.
824
- _name: t?.Ft ? undefined : t?.name ?? "computed"
617
+ _name: t?.At ? undefined : t?.name ?? "computed",
618
+ // Observe: the verdict windows this pass entered (verdict.ts) — a
619
+ // slot, so the stamp is never a write after construction.
620
+ Ze: 0
825
621
  };
826
- if (t?.unobserved) ext(l).bt = t.unobserved;
827
- setupComputedNode(l, t);
828
- return l;
622
+ if (t?.unobserved) ext(E).Ft = t.unobserved;
623
+ setupComputedNode(E, t);
624
+ return E;
829
625
  }
830
626
 
831
627
  /** Lazily allocate a node's cold extension (ONE shape for signals and
832
628
  * computeds — `_x` access stays monomorphic). Installers write through
833
629
  * this; hot paths read `el._x?._field` gated by the _config presence bits.
834
630
  * Never call ext() just to store a field's default. */ function ext(e) {
835
- return e.o ??= {
836
- we: undefined,
837
- Vt: undefined,
838
- Pt: 0,
839
- Ut: NOT_PENDING,
840
- yt: 0,
841
- Ce: undefined,
842
- xe: undefined,
843
- Me: undefined,
844
- $n: undefined,
845
- t: 0,
846
- pe: null,
847
- be: null,
848
- _: undefined,
849
- Oe: undefined,
850
- ue: undefined,
851
- h: undefined,
852
- ve: false,
853
- i: null,
854
- bt: undefined,
855
- ct: undefined,
856
- Et: null,
857
- dt: null,
858
- xt: undefined
631
+ return e.m ??= {
632
+ Te: null,
633
+ Ne: null,
634
+ F: undefined,
635
+ de: undefined,
636
+ Se: undefined,
637
+ Ft: undefined,
638
+ ot: undefined,
639
+ St: null,
640
+ ct: null,
641
+ _t: null,
642
+ It: false,
643
+ ht: NOT_PENDING,
644
+ Vt: -1,
645
+ _e: 0,
646
+ B: NOT_PENDING,
647
+ T: 0
859
648
  };
860
649
  }
861
650
 
651
+ /** A tracked read of a held node (the reader derives from its transaction's
652
+ * world): the reading pass is marked as having read it (born-held decision
653
+ * in `recompute`), and the flush joins the node's transaction — unless the
654
+ * reader is a render effect. A render effect is the frame, not a derivation
655
+ * (rule 3): in that transaction's own flush, or born into it (uninitialized,
656
+ * A29), it reads the staged value and holds nothing of its own; otherwise it
657
+ * reads the committed value instead (`frameRead`). A node born into the
658
+ * future has no committed value: every reader joins it. A first pass is
659
+ * something not ready under a loading boundary that has not shown content:
660
+ * the boundary collects it and shows its fallback, and the pass is the
661
+ * boundary's, not the tick's (A29's boundary exemption, #3540). */ function joinPass(e, t) {
662
+ e.R |= REACTIVE_JOINED;
663
+ // A new memo's first pass is the hold's work (born held) but not the
664
+ // tick's: a render effect that reads it decides — under a boundary that
665
+ // catches it, the boundary's; otherwise the tick joins the hold (#3540:
666
+ // the reader's position, not where the memo was created). Its catch, if
667
+ // any, is at its staging.
668
+ if (t.S & STATUS_UNINITIALIZED || e.u !== EFFECT_RENDER) joinPassTx(txOf(t), !e.u && e.S & STATUS_UNINITIALIZED || GlobalQueue.fe?.(e));
669
+ }
670
+
671
+ /** A15's stale reader (shared-hole and reveal corollaries): a render effect
672
+ * reading a node held by a transaction that is not the flush's. It is served
673
+ * the committed value — a pending one's too — publishes mainline, and is
674
+ * re-derived after that transaction's landing (`_reruns`,
675
+ * REACTIVE_FRAME_READ) so the frame catches up with it once it is the
676
+ * committed world. Not a frame born into that transaction (held and never
677
+ * committed — created by one of its held passes, A29; `bornInto`): that
678
+ * one reads its transaction's values and keeps staging. Not of a flight
679
+ * whose inputs are already visible (CONFIG_INPUTS_PUBLISHED, #3305): its
680
+ * committed value would tear against them, so the reveal observes the
681
+ * flight instead. Once per pass.
682
+ *
683
+ * Lane work is a stale reader too (maintainer, 2026-10-01: a lane sees the
684
+ * screen plus its own guesses). A held write is held because showing it
685
+ * would tear against the rest of its frame; a lane revealing a derivation
686
+ * of it would show it anyway, beside inputs still committed elsewhere on
687
+ * the page. The guess is the one value the user opted into predicting. So
688
+ * a lane pass reading a transaction's held node — its parent's or any
689
+ * other's — derives from the committed value and is re-derived at that
690
+ * landing. The case read-through was built for — a corrected guess whose
691
+ * downstream async must refetch with the truth at once, while another of
692
+ * the parent's flights is still up — needs none of this: the correction
693
+ * dissolves the lane, and the refetching pass is the parent's own, reading
694
+ * the truth as a member (`joinPass`). */ function frameRead(e, t) {
695
+ // Frame readers: a render effect, a verdict reader (CONFIG_VERDICT — it
696
+ // reads the screen like one: `[isPending(x), x()]` never pairs the fresh
697
+ // value with pending, A10, because the reader never sees the fresh value),
698
+ // and lane work (a lane sees the screen plus its own guesses). Not a
699
+ // mount's memo (2026-10-02, considered and reverted): a memo is not a
700
+ // leaf — the transaction's own later passes read it — so a mainline mount's
701
+ // derivations carry the future (A29, born held); only its direct bindings
702
+ // read the screen. Lane work with no committed value yet reads a flight
703
+ // as a mount's memo does: it enters, and the boundary it mounts catches
704
+ // the pending (#3540).
705
+ const n = e.i & CONFIG_VERDICT;
706
+ if ((passLane === null || e.S & STATUS_UNINITIALIZED && t.S & STATUS_PENDING) && !n && (e.u !== EFFECT_RENDER || t.i & CONFIG_INPUTS_PUBLISHED)) return false;
707
+ const l = txOf(t);
708
+ // Lane work and verdict readers are never the transaction's pass, whichever
709
+ // flush runs it: a node T holds re-enters T when it re-runs (`recompute`'s
710
+ // head), and the pass may then read a guess and become the lane's.
711
+ if (l === flushTransaction && passLane === null && !n || bornInto(e, l)) return false;
712
+ staleReader(e, l);
713
+ return true;
714
+ }
715
+
716
+ /** A node born into transaction `t`: held by it and never committed (A29,
717
+ * ruling A) — uninitialized (born held), or a member of the frame one of its
718
+ * held passes built (CONFIG_HELD_FRAME). Its branch exists only in `t`: it
719
+ * has no screen to read, so it reads `t`'s values, whichever flush runs it,
720
+ * and keeps staging (#4010). */ function bornInto(e, t) {
721
+ return (e.S & STATUS_UNINITIALIZED || e.i & CONFIG_HELD_FRAME) && e.i & CONFIG_HELD && txOf(e) === t;
722
+ }
723
+
724
+ /** The computed whose pass a creation under `owner` belongs to (a root's is
725
+ * its nearest computed ancestor's), or null outside every pass. */ function creatorPass(e) {
726
+ return e !== null && e.Ht ? e.gt : e;
727
+ }
728
+
729
+ /** L2 — park the previous pass's frame for this node's commit: the children
730
+ * (already allocated — nothing new) and the `_disposal` list move to the
731
+ * extension, keep reacting from the heap, and die when the commit publishes
732
+ * the frame that replaces them (`commitPendingNode`) or when the owner does. */ function parkChildren(e) {
733
+ markDisposal(e);
734
+ const t = ext(e);
735
+ t.ct = e.Re;
736
+ t.St = e.nn;
737
+ e.Re = null;
738
+ e.nn = null;
739
+ e.dt = 0;
740
+ }
741
+
862
742
  /**
863
743
  * Build an Effect node with all effect-specific fields baked into a single object literal,
864
744
  * so V8 sees the full hidden class shape at construction time. Effects always run in lazy
865
745
  * mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
866
746
  * the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
867
- */ function createEffectNode(e, t, n, i, l) {
868
- const u = l?.transparent ?? false;
747
+ */ function createEffectNode(e, t, n, l, E) {
748
+ const s = E?.transparent ?? false;
869
749
  // Prod and observe boilerplates — see computed() for why the observe tier
870
750
  // gets its `_name` as a literal slot rather than a write after the fact.
871
751
  // The default label is the node kind (tracked effects relabel their computed
872
752
  // in trackedEffect); the wrappers in signals.ts no longer spread a name into
873
753
  // the options to get it.
874
- const o = {
875
- id: inheritId(l, u, context),
876
- C: (u ? CONFIG_TRANSPARENT : 0) | (l?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (l?.sync ? CONFIG_SYNC : 0) | (l?.Qt ?? 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
877
- Fe: false,
878
- Ve: null,
879
- T: context?.T ?? globalQueue,
880
- rt: context?.rt ?? defaultContext,
881
- Nt: 0,
882
- Se: e,
883
- ce: undefined,
884
- ft: 0,
885
- gt: undefined,
886
- vt: null,
887
- Ee: null,
888
- Je: null,
889
- We: 0,
890
- u: null,
891
- Ht: null,
754
+ const u = {
755
+ id: inheritId(E, s, context),
756
+ i: (s ? CONFIG_TRANSPARENT : 0) | (E?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (E?.sync ? CONFIG_SYNC : 0) | (E?.Ct ?? 0) | (snapshotCaptureActive && ownerInSnapshotScope(context) ? CONFIG_IN_SNAPSHOT_SCOPE : 0),
757
+ en: false,
758
+ Re: null,
759
+ D: context?.D ?? defaultContext,
760
+ dt: 0,
761
+ ee: e,
762
+ Ae: undefined,
763
+ it: 0,
764
+ Ot: undefined,
765
+ Rt: null,
766
+ G: null,
767
+ p: null,
768
+ pe: 0,
769
+ t: null,
770
+ Dt: null,
892
771
  _parent: context,
893
- _n: null,
894
- kt: null,
895
- On: null,
896
- oe: REACTIVE_LAZY,
897
- S: STATUS_UNINITIALIZED,
898
- Ge: clock,
899
- _e: NOT_PENDING,
900
- me: null,
901
- Lt: -1,
902
- ye: false,
903
- it: false,
904
- Mt: undefined,
905
- wt: t,
906
- Wt: n,
907
- qt: undefined,
908
- He: i,
772
+ tn: null,
909
773
  Gt: null,
910
- o: null,
911
- _name: l?.name ?? "effect"
774
+ nn: null,
775
+ R: REACTIVE_LAZY,
776
+ S: STATUS_UNINITIALIZED,
777
+ Ie: clock,
778
+ Oe: NOT_PENDING,
779
+ Pt: -1,
780
+ De: false,
781
+ lt: false,
782
+ Nt: undefined,
783
+ Ut: t,
784
+ Lt: n,
785
+ kt: undefined,
786
+ u: l,
787
+ m: null,
788
+ _name: E?.name ?? "effect",
789
+ Ze: 0
912
790
  };
913
791
  // Effects dispatch status through the SHARED notifier (statusNotifierOf,
914
792
  // keyed off _type) — storing it per node forced a full NodeExtension
915
793
  // allocation on EVERY effect at creation (an alloc + 19 field stores,
916
794
  // +23% effect creation, caught by the creation benches). Only genuinely
917
795
  // per-node channels (boundaries) live on _x.
918
- if (l?.unobserved) ext(o).bt = l.unobserved;
919
- setupComputedNode(o, lazyOptions);
920
- return o;
796
+ if (E?.unobserved) ext(u).Ft = E.unobserved;
797
+ setupComputedNode(u, lazyOptions);
798
+ return u;
921
799
  }
922
800
 
923
801
  /**
924
802
  * The shared status notifier for effect nodes, installed once by effect.ts
925
803
  * at module evaluation (`this`-dispatched — one function serves every
926
- * effect, so nodes never store it). Boundary computeds keep their own
927
- * per-node channel on `_x._notifyStatus`, which takes precedence.
804
+ * effect, so nodes never store it). CARVE 4: the boundaries' per-node
805
+ * channel (`_x._notifyStatus`) went with them; effects are the only
806
+ * display consumers.
928
807
  */ let effectStatusNotify = null;
929
808
 
930
809
  function setEffectStatusNotify(e) {
931
810
  effectStatusNotify = e;
932
811
  }
933
812
 
934
- /** Resolve a node's status notifier: an own `_x` channel (boundaries) wins;
935
- * effect nodes (`_type` — EFFECT_PURE is 0, and only effect literals carry
936
- * the field) fall back to the shared notifier. Presence doubles as the
937
- * "display consumer" membership test in the status walks, exactly as the
938
- * per-node field did when every effect carried one. */ function statusNotifierOf(e) {
939
- const t = e.o?.h;
940
- if (t !== undefined) return t;
941
- return e.He ? effectStatusNotify ?? undefined : undefined;
813
+ /** Resolve a node's status notifier: effect nodes (`_type` — EFFECT_PURE is
814
+ * 0, and only effect literals carry the field) get the shared notifier.
815
+ * Presence doubles as the "display consumer" membership test in the status
816
+ * walks, exactly as the per-node field did when every effect carried one. */ function statusNotifierOf(e) {
817
+ return e.u ? effectStatusNotify ?? undefined : undefined;
942
818
  }
943
819
 
944
820
  const lazyOptions = {
@@ -946,152 +822,93 @@ const lazyOptions = {
946
822
  };
947
823
 
948
824
  function setupComputedNode(e, t) {
949
- e.vt = e;
950
- const n = context?.Zt ? context.Yt : context;
825
+ e.Rt = e;
826
+ const n = context?.Ht ? context.gt : context;
951
827
  if (context) linkChild(context, e);
952
- if (n) e.ft = n.ft + 1;
953
- if (GlobalQueue.Bt !== null) GlobalQueue.Bt(e);
828
+ if (n) e.it = n.it + 1;
829
+ GlobalQueue.xt?.(e);
954
830
  !t?.lazy && recompute(e, true);
955
831
  if (snapshotCaptureActive && !t?.lazy) {
956
- if (!(e.S & STATUS_PENDING) && !(e.C & CONFIG_NO_SNAPSHOT)) {
957
- ext(e).ct = e.ce === undefined ? NO_SNAPSHOT : e.ce;
958
- e.C |= CONFIG_HAS_SNAPSHOT;
832
+ if (!(e.S & STATUS_PENDING) && !(e.i & CONFIG_NO_SNAPSHOT)) {
833
+ ext(e).ot = e.Ae === undefined ? NO_SNAPSHOT : e.Ae;
834
+ e.i |= CONFIG_HAS_SNAPSHOT;
959
835
  snapshotSources.add(e);
960
836
  }
961
837
  }
962
838
  }
963
839
 
964
- function signal(e, t, n = null) {
840
+ function signal(e, t) {
965
841
  // Prod and observe boilerplates — see computed(). The observe literal adds
966
842
  // `_name` and `_owner` (the creating owner, stamped by registerGraph for
967
843
  // createSignal nodes so ownerPath can locate signal subjects; null here,
968
844
  // and staying null on internal signals — one shape either way).
969
- const i = {
970
- Fe: t?.equals ?? isEqual,
971
- C: (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (t?.Z ? CONFIG_NO_SNAPSHOT : 0),
972
- ce: e,
973
- u: null,
974
- Ht: null,
975
- Ge: clock,
976
- Ne: n,
977
- ge: n?.o?.i || null,
978
- jt: null,
979
- _e: NOT_PENDING,
980
- me: null,
981
- Lt: -1,
982
- o: null,
845
+ const n = {
846
+ en: t?.equals ?? isEqual,
847
+ i: (t?.ownedWrite ? CONFIG_OWNED_WRITE : 0) | (t?.ae ? CONFIG_NO_SNAPSHOT : 0),
848
+ Ae: e,
849
+ t: null,
850
+ Dt: null,
851
+ Ie: clock,
852
+ Oe: NOT_PENDING,
853
+ Pt: -1,
854
+ m: null,
983
855
  _name: t?.name ?? "signal",
984
- ie: null
856
+ L: null
985
857
  };
986
- if (t?.unobserved) ext(i).bt = t.unobserved;
987
- if (n) linkFirewallChild(n, i);
988
- if (snapshotCaptureActive && !(i.C & CONFIG_NO_SNAPSHOT) && !((n?.S ?? 0) & STATUS_PENDING)) {
989
- ext(i).ct = e === undefined ? NO_SNAPSHOT : e;
990
- i.C |= CONFIG_HAS_SNAPSHOT;
991
- snapshotSources.add(i);
858
+ if (t?.unobserved) ext(n).Ft = t.unobserved;
859
+ if (snapshotCaptureActive && !(n.i & CONFIG_NO_SNAPSHOT)) {
860
+ ext(n).ot = e === undefined ? NO_SNAPSHOT : e;
861
+ n.i |= CONFIG_HAS_SNAPSHOT;
862
+ snapshotSources.add(n);
992
863
  }
993
- return i;
994
- }
995
-
996
- // ---------------------------------------------------------------------------
997
- // SLOT SIGNALS (store leaves) — the create-floor diet. Store mounts
998
- // materialize one signal per touched leaf (~13 × rows on dbmon), so per-node
999
- // allocations are mount bytes: the generic path costs an options object, an
1000
- // equals closure, an unobserved closure, a NodeExtension to hold it, and
1001
- // three post-construction expandos (acc/px/pxv → hidden-class transitions).
1002
- // slotSignal bakes everything into ONE literal: `_host`/`_key` backrefs
1003
- // replace the closures (equals is a method call — `this` is the node; the
1004
- // unobserved sweep dispatches CONFIG_SLOT_NODE to one shared hook), and the
1005
- // store's wrap-cache fields are pre-shaped.
1006
- /** The shared slot-node unobserved handler — a live binding read directly by
1007
- * the sweep sites (no wrapper frame, no null check: a CONFIG_SLOT_NODE node
1008
- * existing implies the store module loaded and registered the hook). */ let slotUnobservedHook;
1009
-
1010
- /** Install the shared slot-node unobserved handler (store module, once). */ function setSlotUnobserved(e) {
1011
- slotUnobservedHook = e;
1012
- }
1013
-
1014
- /** Push a new node onto its firewall's child chain (the literal already
1015
- * points `_nextChild` at the old head). Doubly linked so a released leaf
1016
- * unlinks in O(1) — the chain is walked per mark of the projection and
1017
- * would otherwise grow by one node per leaf ever read (#3351). */ function linkFirewallChild(e, t) {
1018
- const n = t.ge;
1019
- if (n !== null) n.jt = t;
1020
- ext(e).i = t;
1021
- e.C |= CONFIG_FW_CHILDREN;
864
+ return n;
1022
865
  }
1023
866
 
1024
- /** Release a firewall child the store no longer addresses (unobserved sweep
1025
- * dropped it from its target's cache): unlink it from the chain so the
1026
- * projection stops retaining it and its last value. The node keeps its own
1027
- * `_nextChild` so a walk that is mid-chain on it still terminates. It also
1028
- * leaves `_companionChildren` (#3503): the companions themselves are
1029
- * permanent on the node, but the node is unreachable through the store, so
1030
- * the set would only retain it and its last value. */ function unlinkFirewallChild(e) {
1031
- const t = e;
1032
- const n = t.Ne;
1033
- if (!n) return;
1034
- const i = t.jt;
1035
- const l = t.ge;
1036
- if (i !== null) i.ge = l; else if (n.o.i === t) n.o.i = l;
1037
- if (l !== null) l.jt = i;
1038
- t.jt = null;
1039
- // #3503: the companion set is the last projection-side reference to a
1040
- // released leaf; leaving it there kept the leaf and its last value alive
1041
- // for the projection's lifetime after every latest()/isPending() reader
1042
- // was disposed.
1043
- n.o.xt?.delete(t);
867
+ function isEqual(e, t) {
868
+ return e === t;
1044
869
  }
1045
870
 
1046
- function slotSignal(e, t, n, i, l, u = null) {
1047
- // Prod and observe boilerplates — see computed(). The store relabels the
1048
- // observe slot (`store.<key>`) when the attribution engine is installed.
1049
- const o = {
1050
- Fe: t,
1051
- C: CONFIG_OWNED_WRITE | CONFIG_SLOT_NODE,
1052
- ce: e,
1053
- u: null,
1054
- Ht: null,
1055
- Ge: clock,
1056
- Ne: u,
1057
- ge: u?.o?.i || null,
1058
- jt: null,
1059
- _e: NOT_PENDING,
1060
- me: null,
1061
- Lt: -1,
1062
- o: null,
1063
- Kt: n,
1064
- zt: i,
1065
- acc: l,
871
+ /** A store slot node (CONFIG_SLOT_NODE): the whole node in ONE literal — the
872
+ * target and key as back-refs in place of closures (`equals` is a method
873
+ * call, `this` the node; the unobserved sweep dispatches to one shared hook,
874
+ * graph.ts), the store's wrap cache (`px`/`pxv`: the proxy last served for
875
+ * this key and the raw it wrapped — one pointer compare replaces a WeakMap
876
+ * lookup per read) and the accessor verdict (`acc`) pre-shaped. No options
877
+ * object, no NodeExtension, no post-construction expandos. `ownedWrite` is
878
+ * baked in: the setter carries the owned-scope guard; node-level writes are
879
+ * the store's notification machinery. The observe literal adds the label
880
+ * slot (the store relabels it `store.<key>` when the engine is installed). */ function slotSignal(e, t, n, l, E) {
881
+ const s = {
882
+ en: t,
883
+ i: CONFIG_OWNED_WRITE | CONFIG_SLOT_NODE,
884
+ Ae: e,
885
+ t: null,
886
+ Dt: null,
887
+ Ie: clock,
888
+ Oe: NOT_PENDING,
889
+ Pt: -1,
890
+ m: null,
891
+ yt: n,
892
+ bt: l,
893
+ acc: E,
1066
894
  px: undefined,
1067
895
  pxv: undefined,
1068
- _name: "signal"
896
+ _name: "signal",
897
+ L: null
1069
898
  };
1070
- if (u) linkFirewallChild(u, o);
1071
- if (snapshotCaptureActive && !((u?.S ?? 0) & STATUS_PENDING)) {
1072
- ext(o).ct = e === undefined ? NO_SNAPSHOT : e;
1073
- o.C |= CONFIG_HAS_SNAPSHOT;
1074
- snapshotSources.add(o);
1075
- }
1076
- return o;
1077
- }
1078
-
1079
- function optimisticSignal(e, t) {
1080
- const n = signal(e, t);
1081
- ext(n).we = NOT_PENDING;
1082
- n.C |= CONFIG_OPTIMISTIC;
1083
- return n;
899
+ return s;
1084
900
  }
1085
901
 
1086
- function optimisticComputed(e, t) {
1087
- const n = computed(e, t);
1088
- ext(n).we = NOT_PENDING;
1089
- n.C |= CONFIG_OPTIMISTIC;
1090
- return n;
1091
- }
902
+ /**
903
+ * When set to a component name string, any reactive read that is not inside a nested tracking
904
+ * scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
905
+ */
906
+ /** The verdict windows' read (verdict.ts), installed while a `latest` or
907
+ * `isPending` window is open and null otherwise: `read` dispatches to it
908
+ * then, and a program that never imports them never has one. */ let verdict = null;
1092
909
 
1093
- function isEqual(e, t) {
1094
- return e === t;
910
+ function setVerdict(e) {
911
+ verdict = e;
1095
912
  }
1096
913
 
1097
914
  /**
@@ -1116,11 +933,11 @@ function isEqual(e, t) {
1116
933
  * );
1117
934
  * ```
1118
935
  */ function untrack(e, t) {
1119
- if (GlobalQueue.Jt === null && !tracking && true) return e();
936
+ if (GlobalQueue.Wt === null && !tracking && true) return e();
1120
937
  const n = tracking;
1121
938
  tracking = false;
1122
939
  try {
1123
- if (GlobalQueue.Jt !== null) return GlobalQueue.Jt(e);
940
+ if (GlobalQueue.Wt) return GlobalQueue.Wt(e);
1124
941
  return e();
1125
942
  } finally {
1126
943
  tracking = n;
@@ -1139,685 +956,365 @@ function isEqual(e, t) {
1139
956
  * born-held tree would otherwise pull the mounting pass into the hold).
1140
957
  */ let spectating = false;
1141
958
 
1142
- /**
1143
- * Evaluates `fn` untracked, recording nothing on the current `context`: no
1144
- * untracked-pending re-run link, no transaction entry. For bookkeeping reads
1145
- * made on behalf of no node — see `spectating`.
1146
- */ function spectate(e) {
1147
- const t = spectating;
1148
- spectating = true;
1149
- try {
1150
- return untrack(e);
1151
- } finally {
1152
- spectating = t;
1153
- }
1154
- }
1155
-
1156
959
  /**
1157
960
  * Bring a computed to a readable state: lazy/disposed nodes are (re)computed;
1158
- * an isPending() probe (`refresh`) additionally pulls the node fully up to
1159
- * date so its status flags reflect the current graph.
961
+ * `refresh` additionally pulls the node fully up to date so its status flags
962
+ * reflect the current graph.
1160
963
  */ function prepareComputed(e, t) {
1161
- if (e.oe & REACTIVE_LAZY) {
1162
- e.oe &= ~REACTIVE_LAZY;
964
+ if (e.R & REACTIVE_LAZY) {
965
+ e.R &= ~REACTIVE_LAZY;
1163
966
  recompute(e, true);
1164
- } else if (e.oe & REACTIVE_DISPOSED) {
967
+ } else if (e.R & REACTIVE_DISPOSED) {
1165
968
  // Two disposal lifecycles share the flag (#3024). Observation-lifecycle
1166
969
  // nodes (CONFIG_AUTO_DISPOSE) are dormant — torn down by unobserved()
1167
970
  // when the last subscriber left — and reads reawaken them; that is the
1168
971
  // pay-for-use contract. Owner-lifecycle nodes are dead: recomputing would
1169
972
  // re-run user code in a torn-down tree (and discard manual writes on
1170
973
  // derived-writable signals), so reads return the last committed value.
1171
- if (e.C & CONFIG_AUTO_DISPOSE) {
974
+ if (e.i & CONFIG_AUTO_DISPOSE) {
1172
975
  const t = e._parent;
1173
976
  if (t !== null) {
1174
977
  // A dormant node was off the chain when its owner died, so the strip
1175
978
  // in disposeChildren missed it: freeze here instead (#3024).
1176
- if (t.oe & REACTIVE_DISPOSED) {
1177
- e.C &= ~CONFIG_AUTO_DISPOSE;
979
+ if (t.R & REACTIVE_DISPOSED) {
980
+ e.i &= ~CONFIG_AUTO_DISPOSE;
1178
981
  return;
1179
982
  }
1180
- // A zombie never left its chain: settleAutodispose releases without
1181
- // the !ZOMBIE check its siblings have, so this guard is load-bearing.
1182
- if (!(e.oe & REACTIVE_ZOMBIE)) linkChild(t, e);
983
+ // A zombie never left its chain (the parked frame is drained whole,
984
+ // and its members skip the splice): relinking would put it on the
985
+ // live chain too.
986
+ if (!(e.R & REACTIVE_ZOMBIE)) linkChild(t, e);
1183
987
  }
1184
988
  recompute(e, true);
1185
989
  }
1186
- } else if (t) {
1187
- updateIfNecessary(e);
1188
- }
990
+ } else ;
1189
991
  }
1190
992
 
993
+ // CARVE 3: until()'s authoritative-view wakeup (notifyAuthoritativeObservers /
994
+ // installAuthoritativeRead), the stale-of-foreign clause (heldFromStale,
995
+ // recordStaleReplay, ownsHold) and the transaction entry on a staged read
996
+ // (enterStagedRead, stagedEntry / born held, underFreshLoadingBoundary) went
997
+ // with the transactions.
1191
998
  /**
1192
- * Sentinel returned by readNodeFast when the plain-signal fast path does not
1193
- * apply and the caller must fall back to the full read().
1194
- */ const READ_SLOW = Symbol("read-slow");
1195
-
1196
- /**
1197
- * read()'s plain-signal fast path as a standalone entry for hot callers
1198
- * (store traps). Safe to substitute for read() only because the bail
1199
- * conditions mirror read()'s prelude and fast-path guard exactly: the
1200
- * latestRead and pendingCheck windows run side-effectful hooks before the
1201
- * fast path, `_fn` nodes need prepareComputed, and firewall / override /
1202
- * snapshot / transition / lane / dev-strictRead state all take the full
1203
- * resolution. Anything slow returns READ_SLOW; the caller then calls read().
1204
- */
1205
- /**
1206
- * Wake only authoritative-view readers (until() predicates) subscribed to `el`.
1207
- * The A17-silent ack paths — an authoritative arrival equal to the active
1208
- * override — use this so the predicate re-evaluates without re-firing
1209
- * ordinary subscribers whose visible (override) value did not change.
1210
- * Pay-for-use: reached through GlobalQueue._notifyAuthoritativeObservers,
1211
- * installed at first until() call — apps that never use until() shake it.
1212
- */ function notifyAuthoritativeObservers(e) {
1213
- for (let t = e.u; t !== null; t = t.Pe) {
1214
- const e = t.Ae;
1215
- if (!(e.C & CONFIG_AUTHORITATIVE_READ)) continue;
1216
- // Missed-wake latch (#3037), same contract as insertSubs: the reader may
1217
- // itself have pulled this recompute (updateIfNecessary from its own
1218
- // read), and the heap refuses RECOMPUTING nodes — latch so recompute's
1219
- // tail reschedules it with the staged value visible.
1220
- if (e.oe & REACTIVE_RECOMPUTING_DEPS && t.Ze === e.We && t !== e.Je) e.oe |= REACTIVE_MISSED_WAKE;
1221
- enqueueSub(e);
1222
- }
1223
- schedule();
1224
- }
1225
-
1226
- /** Installs the authoritative-reader wakeup hook. Idempotent; called by every
1227
- * creator of a CONFIG_AUTHORITATIVE_READ computation — until() and refresh() —
1228
- * before its first read (same late-binding contract as the optimistic engine;
1229
- * the gating bit is only ever set by such a read, so the `!` call sites are
1230
- * safe once every setter installs, #3303). */ function installAuthoritativeRead() {
1231
- if (GlobalQueue.Xt === null) GlobalQueue.Xt = notifyAuthoritativeObservers;
1232
- }
1233
-
1234
- /**
1235
- * Stale-reader term of the value selections below: a render effect reading a
1236
- * node some OTHER live transaction has staged sees the committed value. The
1237
- * commit is silent — the staging walk was the notification — so a reader
1238
- * that linked AFTER that walk (an effect created during the hold, a store
1239
- * key first read under it) would show the old value past the reveal: record
1240
- * it for the transaction's commit replay (the `_gatedSubs` contract lanes
1241
- * already use). An effect the transaction itself computed re-derives at its
1242
- * commit on its own (parked run, or the contested re-derive, #3322) and is
1243
- * not recorded — replaying it too would publish the frame twice.
1244
- *
1245
- * Flight twin (the pending-branch carve-out): the reader is served the
1246
- * node's committed, pre-flight value and now observes that flight — A15:
1247
- * async work observed by a reader settles as one unit with the writes that
1248
- * asked it — so it joins the transaction's reporters for the node. The
1249
- * reporter the transaction recorded when the flight started may be gone (a
1250
- * keyed remount disposed it, #3374); a completion check that found no live
1251
- * reporter committed the writes ahead of the answer, tearing the new
1252
- * reader's frame (`Count: 1` beside `Details: 0`). Joins an entry the
1253
- * transaction already holds; a flight nobody had observed yet has none (the
1254
- * reader is its first observer — a conditional that just revealed it, #3458)
1255
- * and is notified up the reader's own queue chain under that transaction,
1256
- * the one sanctioned registration site (INV-3): a collecting boundary above
1257
- * the reader consumes it as it would any pending, an unboundaried reader
1258
- * opens the entry — and the transaction, judged complete on its other
1259
- * flights, revealed the inputs beside the reader's pre-flight value
1260
- * otherwise (`Count: 1 | A: 1` beside `B: 0`). A staged signal or a settled
1261
- * node registers nothing. Every reporter dies with its reader
1262
- * (reporterBlocksSource: the read linked it as a dep). The node's own entry
1263
- * is the only one that can matter: a chain's intermediate memo is re-pulled
1264
- * by the read (updateIfNecessary's retry) and enters the transaction, so the
1265
- * reader holds through the normal path; a node with its own flight that is
1266
- * also pending on an upstream re-ask blocks through that flight until it
1267
- * lands, and its landing re-runs the reader into the normal path.
1268
- */
1269
- /** The replay half of the stale-of-foreign clause (A15 / A26): a stale reader
1270
- * served the committed value because `txn` holds what it read re-runs at
1271
- * txn's commit, when the value it was denied becomes the frame — unless its
1272
- * own last value already came from that transaction. One registration for
1273
- * the node path (heldFromStale) and the store's backing paths, which have
1274
- * no node to carry the hold (heldFromReader, the adoption hold view). */ function recordStaleReplay(e, t) {
1275
- const n = t.Gt;
1276
- if (n == null || currentTransition(n) !== e) e.Tt.add(t);
1277
- }
1278
-
1279
- /**
1280
- * The ownership relation (DESIGN-CONSOLIDATION §6, ruled 2026-09-17): is
1281
- * `hold` part of the running pass's world? A plain reader's world is the
1282
- * transaction it runs under, through merges. A lane reader's world is its
1283
- * lane AND the transition that owns the lane — the one asymmetry between a
1284
- * lane and a separate transaction (a lane sees what lands from its parent as
1285
- * its own; a separate transaction would wait for the parent to settle) —
1286
- * see `ownsLane` in lanes.ts, built on this. One relation for the
1287
- * stale-of-foreign clause (heldFromStale), the lane arm (readsHeldCommitted)
1288
- * and the store's backing holds (foreignHold); `serve` has no lane arm of
1289
- * its own, the lane's extra visibility lives here.
1290
- */ function ownsHold(e) {
1291
- return activeTransition !== null && currentTransition(e) === currentTransition(activeTransition);
1292
- }
1293
-
1294
- function heldFromStale(e, t) {
1295
- const n = e.me;
1296
- if (n === null || ownsHold(n)) return false;
1297
- const i = currentTransition(n);
1298
- recordStaleReplay(i, t);
1299
- const l = i.ae.get(e);
1300
- if (l) l.add(t); else if (e.S & STATUS_PENDING) runInTransition(i, () => t.T.notify(t, STATUS_PENDING, STATUS_PENDING, e.o._));
1301
- return true;
1302
- }
1303
-
1304
- /**
1305
- * A tracked computation about to be served a live transaction's staged value
1306
- * derives from that transaction's world, so it enters the transaction and
1307
- * this pass's result is held with it (A29, #3408). The write side (`setSignal`)
1308
- * and a stamped node's recompute already enter; a reader that only now
1309
- * starts reading the held node — a conditional memo whose branch flipped —
1310
- * was the gap: it published a value derived from the staged world into the
1311
- * mainline frame. Not for a probe (`isPending(() => x())` observes, it does
1312
- * not derive) and a no-op for the ambient batch (`_transition` null) or the
1313
- * transaction already active.
1314
- */
1315
- /** The transaction a pass running OUTSIDE a flush was served a staged value
1316
- * from (A29, creation-time form). Inside a flush the pass enters through
1317
- * initTransition; outside one — a memo or effect created from mainline code
1318
- * while a hold is live — entering would leave `activeTransition` and the
1319
- * batch pointed at the transaction for the rest of the synchronous block,
1320
- * so an unrelated write made after the mount was held with someone else's
1321
- * action. The entry is the pass's alone: recompute stages the node into the
1322
- * transaction (born held) and mainline is never touched.
1323
- *
1324
- * A pass under a FRESH loading boundary takes this path inside a flush too
1325
- * (#3540). Born held is right for a plain memo or effect: published, its
1326
- * value would tear the frame. A boundary that has not revealed yet is the
1327
- * exception by definition — its job is to catch what is not ready under it
1328
- * rather than let it hold: the pass is staged into the transaction as
1329
- * above, and the boundary is told (recompute's born-held arm notifies it
1330
- * with a `NotReadyError` sourced at the node) so it shows its fallback now
1331
- * and reveals the staged result at the commit.
1332
- * Entering instead adopted the whole flush into the hold — a `Show` that
1333
- * flipped mainline to mount a `Loading` over a held value waited for the
1334
- * hold with it. A boundary that already shows content keeps the entering
1335
- * path: it has content to keep, and holds like any reader. */ let stagedEntry = null;
1336
-
1337
- /** Is `el` routed to a loading boundary that still shows its fallback — the
1338
- * nearest pending-collecting queue up its chain is uninitialized? (Measured
1339
- * 2026-09-18: relocating the walk behind a `GlobalQueue` slot installed by
1340
- * boundaries.ts saved ~8 B on the core floor and cost boundary-using apps
1341
- * 50–70 B — the indirection's tokens outweigh the walk. Kept inline.) */ function underFreshLoadingBoundary(e) {
1342
- for (let t = e.T; t !== null; t = t._parent) if (t.te & STATUS_PENDING) return !t.H;
1343
- return false;
1344
- }
1345
-
1346
- function enterStagedRead(e, t = e.me) {
1347
- if (!t || t === activeTransition || pendingCheckActive) return;
1348
- // A companion (the latest() shadow, the isPending() verdict signal) is the
1349
- // engine's mirror of the flushed world — reading it, or being it, is an
1350
- // observation, not a derivation from the hold: latest(x) never enters x's
1351
- // transaction, and the shadow's own pass never enters either (it would
1352
- // flip activeTransition under the reader that pulled it). (`el` is null for
1353
- // a store backing served under a hold — no node, the transaction is the
1354
- // fold's.)
1355
- if (e?.o?.$n || context?.o?.$n) return;
1356
- // A bookkeeping read (`spectate`) is nobody's derivation: it compares or
1357
- // probes, and enters nothing — the boundary priming read of a born-held
1358
- // tree must not enter the creator's pass into the hold (#3540).
1359
- if (spectating) return;
1360
- // Verdict machinery (GlobalQueue._verdictPull: companion creation and the
1361
- // latest()/isPending() pulls — the latest() shadow is created before it is
1362
- // marked optimistic, so the bit alone cannot tell) and optimistic nodes
1363
- // (own lane posture, A31) read staged truth by design; they keep the
1364
- // entering path.
1365
- // (`context` is non-null here: every caller selected a value for a reader.)
1366
- const n = context;
1367
- const i = activeTransition === null && !globalQueue.$t;
1368
- // Verdict pulls are observations, not derivations: a latest() /
1369
- // isPending() call from mainline must never enter a transaction (it
1370
- // would capture the rest of the caller's synchronous block).
1371
- if (i && GlobalQueue.Tn) return;
1372
- if (n.oe & REACTIVE_RECOMPUTING_DEPS && !(n.C & CONFIG_OPTIMISTIC) && (stagedEntry === null || stagedEntry === t) && (i || !GlobalQueue.Tn && underFreshLoadingBoundary(n))) {
1373
- stagedEntry = t;
1374
- return;
1375
- }
1376
- globalQueue.initTransition(t);
1377
- }
1378
-
1379
- /**
1380
- * Rule 1 (value selection), the full arm: does this reader see a STAGED
1381
- * node's COMMITTED value? One implementation of the rule the fast paths
1382
- * (readNodeFast, read's fast block) carry as their trivial ternary and that
1383
- * every slow site — read's tail, the store's backing selection, the lane and
1384
- * verdict arms — used to restate by hand (docs/DESIGN-CONSOLIDATION.md, move 3b). In order:
999
+ * Rule 1 (value selection): does this reader see a STAGED node's COMMITTED
1000
+ * value? One implementation of the rule the fast paths (read's fast block)
1001
+ * carry as their trivial ternary. In order:
1385
1002
  * - no reader at all (an untracked read) — the committed frame;
1386
- * - a reader under an optimistic lane the engine says reads committed
1387
- * (laneReadsCommitted: another lane's hold, #3460);
1388
1003
  * - nothing staged;
1389
1004
  * - a children-forbidden reader (createTrackedEffect / onSettled: the frame,
1390
- * never the graph — A32);
1391
- * - a stale reader (render effect) of a FOREIGN transaction's staged write —
1392
- * committed, no entanglement (heldFromStale registers the replay; a node
1393
- * born held has no committed frame to fall back to, `noCommitted`);
1394
- * - HELD truth (#3164, CONFIG_HELD_TRUTH) read by a LANE pass: staged
1395
- * confirming truth — fold-staged onto an armed family, or entangle-stolen
1396
- * by an awaited until() — is masked from lane passes only, owning
1397
- * transaction or not. A lane applies its frame display-ahead at the park,
1398
- * so a lane pass served the truth would paint the confirmation beside the
1399
- * optimism it confirms (`saving=true` beside the saved row — the #3164
1400
- * tear); it keeps committed and is re-run by the reveal's post-revert
1401
- * wake. Every other deriving reader falls through to A29 below: the truth
1402
- * is a staged value like any other, and the pass that derives from it is
1403
- * held with it — including the retaining transaction's own passes, which
1404
- * a superseded override already hands the truth (#3568: masking them
1405
- * composed the landed `length` with rows still masked to committed).
1406
- * latest() and authoritative readers (until()'s predicate) tunnel
1407
- * through — the tunnel that keeps the hold deadlock-free.
1408
- * False means the reader derives from the staged value and enters its
1409
- * transaction (enterStagedRead, A29).
1410
- */ function readerSeesCommitted(e, t, n, i) {
1411
- return !!(!t || currentOptimisticLane !== null && GlobalQueue.An(e, n, t) || e._e === NOT_PENDING || t.C & CONFIG_CHILDREN_FORBIDDEN || stale && !i && heldFromStale(e, t) || e.C & CONFIG_HELD_TRUTH && currentOptimisticLane !== null && !latestReadActive && !(t.C & CONFIG_AUTHORITATIVE_READ));
1005
+ * never the graph — A32).
1006
+ * False means the reader derives from the staged value.
1007
+ */ function readerSeesCommitted(e, t) {
1008
+ return !!(!t || e.Oe === NOT_PENDING || t.i & CONFIG_CHILDREN_FORBIDDEN);
1412
1009
  }
1413
1010
 
1414
- /** A28 — set when a node is staged (queuePendingNode) or a held node rewritten
1415
- * (stashHeldRewrite) OUTSIDE a flush; cleared when the next flush begins. The
1416
- * read sites test this one module boolean instead of `globalQueue._running`:
1417
- * inside a flush it is false and the A28 arm costs nothing; outside, only a
1418
- * tick with unflushed writes pays the staged-node check. */ let unflushedStaged = false;
1011
+ /** A28 — set when a node is staged (queuePendingNode) OUTSIDE a flush;
1012
+ * cleared when the next flush begins. The read sites test this one module
1013
+ * boolean instead of `globalQueue._running`: inside a flush it is false and
1014
+ * the A28 arm costs nothing; outside, only a tick with unflushed writes pays
1015
+ * the staged-node check. */ let unflushedStaged = false;
1419
1016
 
1420
1017
  function markUnflushedStaged() {
1421
1018
  unflushedStaged = true;
1422
1019
  }
1423
1020
 
1424
- /** A28 — a write becomes visible at flush. Outside a flush, a node holding an
1425
- * AMBIENT staged value (no transaction stamp) was written since the last
1426
- * flush: ambient staging commits at flush end, so nothing else leaves a node
1427
- * in this state; a stamped value is the flushed held world, which A28 says
1428
- * latest() serves. Inside a flush the rule does not apply (A28 (4): promoted
1429
- * within the round). Structural — no marker on the write path. */ function unflushed(e) {
1430
- return unflushedValue(e) !== NOT_PENDING;
1021
+ /** A28 — a write becomes visible at flush. Outside a flush, a node holding a
1022
+ * staged value was written since the last flush: staging commits at flush
1023
+ * end, so nothing else leaves a node in this state. Inside a flush the rule
1024
+ * does not apply (A28 (4): promoted within the round). The value an
1025
+ * unflushed node serves is its committed value, or NOT_PENDING when nothing
1026
+ * is unflushed. Exempt: promoted writes (A28 (4): a write issued inside a
1027
+ * recompute is promoted at that recompute's end — boundary and loading
1028
+ * machinery, signals declared for in-computation writes). */ function unflushedValue(e) {
1029
+ if (globalQueue.X || e.Oe === NOT_PENDING || e.i & CONFIG_PROMOTED) return NOT_PENDING;
1030
+ // A held node (L2) carries a staged value between flushes too, but it was
1031
+ // flushed — and parked. Not an unflushed write — unless rewritten since:
1032
+ // then the flushed staging is what the world sees until the next flush.
1033
+ if (e.i & CONFIG_HELD) return e.m.Vt === clock ? e.m.ht : NOT_PENDING;
1034
+ return e.Ae;
1431
1035
  }
1432
1036
 
1433
- /** The value an unflushed node serves — the committed value for an ambient
1434
- * write, the flushed staged value for a rewrite of a held node — or
1435
- * NOT_PENDING when nothing is unflushed. Exempt: owned-write nodes (A28 (4):
1436
- * a write issued inside a recompute is promoted at that recompute's end —
1437
- * boundary and loading machinery, until()'s internals, signals declared for
1438
- * in-computation writes) and engine companions (the isPending() verdict
1439
- * signal, the latest() shadow: the system's own writes, made at the source's
1440
- * write to mirror it, installing eagerly — A28, A8). */ function unflushedValue(e, t = e.ce) {
1441
- if (globalQueue.$t || e._e === NOT_PENDING || e.C & CONFIG_PROMOTED || e.o?.$n) return NOT_PENDING;
1442
- // Ambient, or adopted by a transaction before any flush carried the staging
1443
- // (CONFIG_ADOPTED_UNFLUSHED): nothing flushed is staged — the committed
1444
- // value answers (the caller's notion of committed: a store node's backing).
1445
- // A held node: unflushed only if rewritten since the last flush (stash).
1446
- if (e.me === null || e.C & CONFIG_ADOPTED_UNFLUSHED) return t;
1447
- return e.o === null ? NOT_PENDING : e.o.Ut;
1037
+ /** A28: a held node rewritten outside a flush keeps the staging the last
1038
+ * flush left (`_flushed`) until the flush that carries the rewrite — the
1039
+ * stash is stamped with the clock, which that flush advances. */ function stashFlushed(e) {
1040
+ const t = e.m;
1041
+ if (t.Vt !== clock) {
1042
+ t.ht = e.Oe;
1043
+ t.Vt = clock;
1044
+ unflushedStaged = true;
1045
+ }
1448
1046
  }
1449
1047
 
1450
- /** Held nodes rewritten since the last flush (setSignal); the flush clears
1451
- * their stash — from then on latest() answers with the rewrite. */ const unflushedRewrites = [];
1452
-
1453
1048
  /** Nodes written inside a creation-time recompute (CONFIG_PROMOTED). */ const promotedWrites = [];
1454
1049
 
1455
- /** A28 (5): an optimistic write becomes the ACTIVE override at the flush that
1456
- * carries it. `_overrideTime` is stamped with `clock` at the write and `clock`
1457
- * advances after every flush, so "this tick, outside a flush" is unflushed. */ function unflushedOverride(e) {
1458
- // Companions are optimistic signals written by the engine (see unflushed).
1459
- return !globalQueue.$t && e.o?.Pt === clock && !e.o?.$n;
1460
- }
1461
-
1462
- /** Active optimistic override on an armed node (an armed slot idles at
1463
- * NOT_PENDING; undefined = unarmed plain node). The writer's own channels —
1464
- * the draft, `in`/keys inside the setter — compose on this regardless of
1465
- * flush state. */ function hasActiveOverride(e) {
1466
- const t = e.o;
1467
- return t !== null && t.we !== undefined && t.we !== NOT_PENDING;
1468
- }
1469
-
1470
- /** The override a READER sees: installed, and carried by a flush (A28 (5) —
1471
- * an optimistic write is a write; until its flush no reader sees it). One
1472
- * implementation for read()'s override arm, the verdict channels
1473
- * (latestRead, computePendingState) and the store's selection
1474
- * (docs/DESIGN-CONSOLIDATION.md, move 3b). */ function visibleOverride(e) {
1475
- return hasActiveOverride(e) && !unflushedOverride(e);
1476
- }
1477
-
1478
1050
  /** A derivation served the committed value because of an unflushed write
1479
1051
  * (A28) must run again in the flush that carries it — the late-linker case
1480
1052
  * (#3337's reason to defer the walk): it linked after the write walked. */ function markLateLinker(e) {
1481
1053
  // The pass's own tail re-enqueues on this latch (recompute's finally) —
1482
1054
  // a direct enqueue here would be wiped by the pass's flag reset.
1483
- e.oe |= REACTIVE_MISSED_WAKE;
1055
+ e.R |= REACTIVE_MISSED_WAKE;
1484
1056
  return true;
1485
1057
  }
1486
1058
 
1487
- /** Companion-bearing nodes written outside a flush (setSignal); the flush
1488
- * that carries their writes re-syncs their companions (A28). */ const unflushedCompanions = [];
1489
-
1490
1059
  function resyncUnflushedCompanions() {
1491
1060
  unflushedStaged = false;
1492
- // Length-guarded: the common flush has nothing here, and must allocate nothing.
1493
1061
  // Length-guarded: the common flush has nothing here and allocates nothing.
1494
- if (unflushedRewrites.length !== 0) {
1495
- for (const e of unflushedRewrites) e.o.Ut = NOT_PENDING;
1496
- unflushedRewrites.length = 0;
1497
- }
1498
- if (promotedWrites.length !== 0) {
1499
- for (const e of promotedWrites) e.C &= ~CONFIG_PROMOTED;
1062
+ if (promotedWrites.length !== 0) {
1063
+ for (const e of promotedWrites) e.i &= ~CONFIG_PROMOTED;
1500
1064
  promotedWrites.length = 0;
1501
1065
  }
1502
- if (unflushedCompanions.length !== 0) {
1503
- for (const e of unflushedCompanions) GlobalQueue.Le(e, e._e !== NOT_PENDING ? e._e : e.ce);
1504
- unflushedCompanions.length = 0;
1505
- }
1506
1066
  }
1507
1067
 
1508
- function readNodeFast(e) {
1509
- if (latestReadActive || pendingCheckActive || e.Se || e.Ne || e.o?.we !== undefined || e.o?.ct !== undefined || activeTransition !== null || currentOptimisticLane !== null || snapshotCaptureActive ||
1510
- // A28: a staged node read outside a flush may serve its committed value;
1511
- // that arm lives on the slow path so this body stays inlinable.
1512
- unflushedStaged && e._e !== NOT_PENDING || false) return READ_SLOW;
1513
- let t = context;
1514
- if (t?.Zt) t = t.Yt;
1515
- if (t && tracking) link(e, t);
1516
- // Children-forbidden readers (createTrackedEffect / onSettled callbacks) get
1517
- // committed visibility: like the effect half of createEffect and event
1518
- // handlers, effect-phase code never observes its own unsettled write — the
1519
- // write lands in the same flush's continuation (#3006).
1520
- // A stale reader (render effect) recomputing with no transaction active is
1521
- // mainline: a write staged by a live transaction (`_transition` stamped —
1522
- // ambient staging never is) stays masked until that transaction's reveal,
1523
- // the same rule the slow path applies (#3322). Without it a zombie
1524
- // recompute, or a commit-time re-derive of a contested effect, published
1525
- // another transaction's uncommitted value.
1526
- return !t || e._e === NOT_PENDING || t.C & CONFIG_CHILDREN_FORBIDDEN || stale && heldFromStale(e, t) ? e.ce : (enterStagedRead(e),
1527
- e._e);
1068
+ /** A tracked read's pull of a computed: bring it current when the flush has
1069
+ * reached its height (or the reader is a fresh-pull waiter), and sit the
1070
+ * reader above it. */ function pullComputed(e, t) {
1071
+ if (e.it >= dirtyQueue.ut) {
1072
+ markNode(t);
1073
+ markHeap(dirtyQueue);
1074
+ updateIfNecessary(e);
1075
+ }
1076
+ // Fresh-pull readers (awaitable refresh's waiter) recompute a dirty
1077
+ // source inline even when the height gate defers to the flush: the
1078
+ // waiter must park on the re-ask's window (or serve its sync answer),
1079
+ // never read the PRE-re-ask value as settled. Self-guarded: a clean
1080
+ // node no-ops and updateIfNecessary refuses disposed nodes (#2983) —
1081
+ // a dead target serves its last value, which is already quiescent.
1082
+ else if (t.i & CONFIG_FRESH_READ) updateIfNecessary(e);
1083
+ const n = e.it;
1084
+ // parent check is shallow, might need to be recursive
1085
+ if (n >= t.it && e._parent !== t) t.it = n + 1;
1528
1086
  }
1529
1087
 
1530
1088
  function read(e) {
1531
- // Handle latest() mode: read from _latestValueComputed
1532
- // Checked before isPending so that isPending(() => latest(x)) checks
1533
- // the _pendingSignal of _latestValueComputed (async in flight) rather
1534
- // than the original node (which stays "pending" while held in a transition).
1535
- if (latestReadActive) return GlobalQueue.Cn(e);
1536
1089
  let t = context;
1537
- if (t?.Zt) t = t.Yt;
1090
+ if (t?.Ht) t = t.gt;
1538
1091
  const n = e;
1539
- const i = e.Ne;
1540
- const l = i || e;
1541
- // Handle isPending() mode: collect pending state while preserving normal read semantics.
1542
- // Probe mode is suspended while preparing the node so nested reads during a
1543
- // recompute don't collect into the probe.
1544
- if (pendingCheckActive) {
1545
- GlobalQueue.Rn(e, t, l, i);
1546
- } else if (typeof n.Se === "function") {
1547
- prepareComputed(e, false);
1548
- }
1549
- if (!n.Se && l === e && e.o?.we === undefined && e.o?.ct === undefined && activeTransition === null && currentOptimisticLane === null && !snapshotCaptureActive && (!unflushedStaged || e._e === NOT_PENDING) && // A28, see readNodeFast
1092
+ // CARVE 1: `owner` was `el._firewall || el` — a store leaf's status,
1093
+ // height and error were read off its projection computed. (Typed loosely
1094
+ // as the `||` expression was: a signal's `_statusFlags`/`_height` read as
1095
+ // undefined and mask to 0 on every site below.)
1096
+ const l = e;
1097
+ if (typeof n.ee === "function") prepareComputed(e);
1098
+ // The verdict windows (`latest`, `isPending`; verdict.ts): one cold path,
1099
+ // off this one, present only while a window is open.
1100
+ if (verdict !== null) return verdict(e, t);
1101
+ if (!n.ee && e.m?.ot === undefined && !snapshotCaptureActive && (!unflushedStaged || e.Oe === NOT_PENDING) && // A28, see readNodeFast
1102
+ !(e.i & CONFIG_OVERRIDE) && // lanes: the slow path's one arm
1550
1103
  true) {
1551
- if (t && tracking) link(e, t);
1552
- // Committed visibility for children-forbidden readers and for stale
1553
- // readers of a foreign transaction's staged write — see readNodeFast.
1554
- return !t || e._e === NOT_PENDING || t.C & CONFIG_CHILDREN_FORBIDDEN || stale && heldFromStale(e, t) ? e.ce : (enterStagedRead(e),
1555
- e._e);
1556
- }
1557
- if (t && tracking) {
1558
- link(e, t, pendingCheckActive);
1559
- if (l.Se) {
1560
- const n = queueFor(e);
1561
- if (l.ft >= n.st) {
1562
- markNode(t);
1563
- markHeap(n);
1564
- updateIfNecessary(l);
1565
- }
1566
- // Fresh-pull readers (awaitable refresh's waiter) recompute a dirty
1567
- // source inline even when the height gate defers to the flush: the
1568
- // waiter must park on the re-ask's window (or serve its sync answer),
1569
- // never read the PRE-re-ask value as settled. Self-guarded: a clean
1570
- // node no-ops and updateIfNecessary refuses disposed nodes (#2983) —
1571
- // a dead target serves its last value, which is already quiescent.
1572
- else if (t.C & CONFIG_FRESH_READ) updateIfNecessary(l);
1573
- const i = l.ft;
1574
- // parent check is shallow, might need to be recursive
1575
- if (i >= t.ft && e._parent !== t) {
1576
- t.ft = i + 1;
1104
+ if (t) {
1105
+ if (tracking) link(e, t);
1106
+ // L2: a pass that reads something already in the future joins it —
1107
+ // the one mechanism behind "a write that reaches the future joins
1108
+ // it". Tracked or not (`untrack` is about dependencies, not about
1109
+ // which world a pass derives from — posture-store-parity S4/S5): a
1110
+ // derivation of a held write published mainline would tear. Frame
1111
+ // readers (children-forbidden, A32) see committed below and stay
1112
+ // out; a render effect outside a parking flush sees committed and
1113
+ // stays out too (rule 3, `frameRead`). The pass remembers it read the
1114
+ // future (REACTIVE_JOINED): a first pass that did is born held (A29),
1115
+ // wherever it was created. Lane work sees the screen (`frameRead`).
1116
+ if (e.i & CONFIG_HELD && !(t.i & CONFIG_CHILDREN_FORBIDDEN)) {
1117
+ if (frameRead(t, e)) return e.Ae;
1118
+ joinPass(t, e);
1577
1119
  }
1578
1120
  }
1121
+ // Committed visibility for untracked and children-forbidden readers.
1122
+ if (!t || e.Oe === NOT_PENDING || t.i & CONFIG_CHILDREN_FORBIDDEN) return e.Ae;
1123
+ // (A plain signal is never uninitialized — the carve-out is `serve`'s.)
1124
+ if (t.i & CONFIG_VERDICT && stagedScreen(t)) return e.Ae;
1125
+ stagedRead(t);
1126
+ return e.Oe;
1127
+ }
1128
+ // Rule 3: this read serves the committed value to a render effect outside a
1129
+ // parking flush (decided after the pull below — a pull can join).
1130
+ let E = false;
1131
+ if (t) {
1132
+ if (tracking) {
1133
+ link(e, t);
1134
+ if (l.ee) pullComputed(l, t);
1135
+ }
1136
+ // L2, as in the fast block above (tracked or not). A node born into the
1137
+ // future (uninitialized) has no committed value: every reader derives
1138
+ // from the future there, a render effect included (A29: a stale reader
1139
+ // of it cannot fall back to the committed frame and enters instead).
1140
+ if (e.i & CONFIG_HELD && !(e.i & CONFIG_OVERRIDE) && !(t.i & CONFIG_CHILDREN_FORBIDDEN)) {
1141
+ if (l.S & STATUS_UNINITIALIZED || !frameRead(t, e)) joinPass(t, e); else E = true;
1142
+ }
1143
+ }
1144
+ // Lanes: a lane's node (after the pull — the node is current). NOT_PENDING
1145
+ // falls through: lane work's read of a pending member throws like any.
1146
+ if (e.i & CONFIG_OVERRIDE) {
1147
+ const n = GlobalQueue.Zt(t, e);
1148
+ if (n !== NOT_PENDING) return n;
1579
1149
  }
1580
- if (l.S & STATUS_PENDING) {
1581
- // A reader landing on a pending node throws — the reveal that discovered
1582
- // the flight holds on it (A15: observed async settles as one unit) — with
1583
- // one carve-out: a stale (render) reader of a node pending in some OTHER
1584
- // transaction keeps showing the node's committed value, no entanglement
1585
- // (parallel transactions; the reader is recorded for that transaction's
1586
- // commit replay, `heldFromStale`). The carve-out is sound only while the
1587
- // committed value is coherent with the visible frame, i.e. while the
1588
- // flight's inputs are themselves unpublished: the stamp alone does not
1589
- // say so (it is pending-node bookkeeping), so it is refused when the
1590
- // inputs are on screen — committed by a batch that left the flight in
1591
- // the air (CONFIG_INPUTS_PUBLISHED, #3305) or revealed through a lane
1592
- // (optimistic / latest, #3334) — and the reader holds instead. An
1593
- // UNINITIALIZED node has no committed value to show and holds too
1594
- // (firewall-backed store reads always did; plain memos since the #3043
1595
- // port): falling through served `undefined` as if settled and stranded
1596
- // the reader outside both transactions, so it never re-ran.
1597
- if (t && !(stale && !(l.S & STATUS_UNINITIALIZED) && !(l.C & CONFIG_INPUTS_PUBLISHED) && !(l.C & CONFIG_HAS_LANE && GlobalQueue.Gn(l)) && heldFromStale(l, t))) {
1598
- // Per-lane suspension lives with the engine (a non-null lane implies it
1599
- // is installed): under a lane, only same-lane pending async without an
1600
- // active override throws — plus uninitialized sources regardless of
1601
- // lane (#3276); that check rides laneSuspends so floor bundles don't
1602
- // pay for it.
1603
- if (currentOptimisticLane === null || GlobalQueue.Dn(l)) {
1150
+ // A stale reader of a held flight (rule 3, A15's reveal corollary) is served
1151
+ // the committed value — coherent with the frame, whose inputs are the
1152
+ // committed ones too — and does not go pending on it. So is lane work
1153
+ // reading a flight that is not the lane's own (the parent's, or
1154
+ // mainline's): a lane breaks out of its parent's hold and waits only on
1155
+ // what derives from the guess (A31: "under a lane, a pending node on no
1156
+ // lane serves its committed value").
1157
+ // A verdict reader likewise (CONFIG_VERDICT): a frame reader sees the
1158
+ // screen, and for a flight the screen is the committed value — a render
1159
+ // effect keeps its DOM by throwing, a memo has no DOM and is handed the
1160
+ // value. `[isPending(x), x()]` reads `[true, stale]` in either order (A10)
1161
+ // — unless the flight committed beneath inputs already on screen
1162
+ // (`observeFlight`), or the reader was born into the flight's transaction
1163
+ // (#4010): it has no screen, and waits on the flight with its frame.
1164
+ if (l.S & STATUS_PENDING && !E && !(e.i & CONFIG_OVERRIDE) && !(l.S & STATUS_UNINITIALIZED)) {
1165
+ // A reader with no committed value yet sees the flight pending: a
1166
+ // boundary a lane mounts shows its fallback (A29's boundary exemption).
1167
+ if (passLane !== null && !(t?.S & STATUS_UNINITIALIZED)) E = true; else if (t !== null && t.i & CONFIG_VERDICT) E = GlobalQueue.vt(t, l);
1168
+ }
1169
+ if (l.S & STATUS_PENDING && !E) {
1170
+ // A reader landing on a pending node throws; an untracked read of an
1171
+ // UNINITIALIZED node has no committed value to serve and throws too. A
1172
+ // children-forbidden reader (createTrackedEffect / onSettled) sees the
1173
+ // frame, not the graph (A32): the committed value, and the NotReady only
1174
+ // where there is none (uninitialized).
1175
+ if (t) {
1176
+ if (!(t.i & CONFIG_CHILDREN_FORBIDDEN) || l.S & STATUS_UNINITIALIZED) {
1604
1177
  // An untracked read of a pending node still re-runs its reader when
1605
1178
  // the node settles — unless nobody is reading (`spectating`, #3528)
1606
1179
  // or the reader is the node itself.
1607
1180
  if (!tracking && !spectating && e !== t) link(e, t);
1608
- throw l.o?._;
1181
+ throw l.m?.F;
1609
1182
  }
1610
- } else if (!t && l.S & STATUS_UNINITIALIZED &&
1611
- // An armed DERIVED override shields the uninitialized state from a
1612
- // read with no reader identity (#3648 follow-up, A18 (d)): a memo
1613
- // whose first landing rode its lane (asyncWrite's lane branch →
1614
- // `laneOverride`) has no `_value` — the flag stays set until the lane's
1615
- // commit promotes the override — yet the override IS the displayed
1616
- // value of a pending node (A18 (c), the screen keeps it until the
1617
- // commit), exactly as an initialized node re-deriving under its override
1618
- // displays it. "Uninitialized must suspend" (#3276, A19 exception 1) was
1619
- // written for a node with NOTHING to show; this node has the override.
1620
- // The arm fires in the body-end window: the source override superseded
1621
- // (A18 body-end, #3427), the memo re-deriving on the plain channel and
1622
- // held, its own slot still armed. Fall through to serve()'s override
1623
- // arm. Readers WITH identity are untouched: a tracked lane reader keeps
1624
- // the override (A17), an off-lane one suspends (#3651, `overrideRead`).
1625
- !(hasActiveOverride(e) && e.C & CONFIG_DERIVED_OVERRIDE)) {
1626
- throw l.o?._;
1183
+ } else if (l.S & STATUS_UNINITIALIZED) {
1184
+ throw l.m?.F;
1627
1185
  }
1628
1186
  }
1629
- // `owner` is the computed itself, or the firewall behind a store node —
1630
- // firewall-backed reads follow the same rules (memo parity, #2897 ruling):
1631
- // an errored derive throws for every late reader instead of silently
1632
- // serving node values (the seed, or last-good data after a failed refetch).
1633
- if (l.Se && l.S & STATUS_ERROR) {
1187
+ // An errored derive throws for every late reader instead of silently
1188
+ // serving node values (memo parity, #2897 ruling).
1189
+ if (l.ee && l.S & STATUS_ERROR) {
1634
1190
  // Only a genuine reactive re-read may retry an errored async source:
1635
1191
  // - tracking: owned/tracked scope only (never events / `untrack` / effect side-effect phase)
1636
- // - !pendingCheckActive: an `isPending` probe observes the error, never refetches
1637
1192
  // - owner._time < clock: only on a later cycle than the one the error was found
1638
- if (tracking && !pendingCheckActive && l.Ge < clock) {
1193
+ if (tracking && l.Ie < clock) {
1639
1194
  recompute(l);
1640
1195
  return read(e);
1641
- } else throw l.o?._;
1196
+ } else throw l.m?.F;
1642
1197
  }
1643
- if (snapshotCaptureActive && t && t.C & CONFIG_IN_SNAPSHOT_SCOPE) {
1644
- const n = e.o?.ct;
1198
+ if (snapshotCaptureActive && t && t.i & CONFIG_IN_SNAPSHOT_SCOPE) {
1199
+ const n = e.m?.ot;
1645
1200
  if (n !== undefined) {
1646
- const i = n === NO_SNAPSHOT ? undefined : n;
1647
- const l = e._e !== NOT_PENDING ? e._e : e.ce;
1648
- if (l !== i) t.oe |= REACTIVE_SNAPSHOT_STALE;
1649
- return i;
1201
+ const l = n === NO_SNAPSHOT ? undefined : n;
1202
+ const E = e.Oe !== NOT_PENDING ? e.Oe : e.Ae;
1203
+ if (E !== l) t.R |= REACTIVE_SNAPSHOT_STALE;
1204
+ return l;
1650
1205
  }
1651
1206
  }
1652
- const u = serve(e, t, l, e.ce);
1653
- if (!t && l === e && typeof n.Se === "function" && e.C & CONFIG_AUTO_DISPOSE && !(l.S & STATUS_PENDING) && !e.u &&
1654
- // An untracked read served a visible override returned before this
1655
- // sweep registration when the arm was inline; keep that.
1656
- !visibleOverride(e)) {
1207
+ if (E) return e.Ae;
1208
+ const s = serve(e, t);
1209
+ if (!t && typeof n.ee === "function" && e.i & CONFIG_AUTO_DISPOSE && !(l.S & STATUS_PENDING) && !e.t) {
1657
1210
  // Deferred, not inline (#3078): an inline unobserved() here made untracked
1658
1211
  // reads destructive — dispose on this read, full revival recompute on the
1659
1212
  // next — so consecutive reads could answer differently with no write in
1660
- // between (the revival samples the ambient transition/lane context).
1213
+ // between.
1661
1214
  // The sweep at flush finalization re-validates and reclaims; schedule()
1662
1215
  // guarantees that flush happens even if nothing else is queued.
1663
1216
  dormantNodes.add(e);
1664
1217
  schedule();
1665
1218
  }
1666
- return u;
1219
+ return s;
1667
1220
  }
1668
1221
 
1669
1222
  /**
1670
1223
  * Rule 1, the one slow implementation (DESIGN-CONSOLIDATION move 3b, step
1671
1224
  * 6c): the value a reader `c` (null = untracked, no pass) is served from
1672
- * `el`, whose committed value is `committed` — the node's own `_value` for
1673
- * a signal or memo, the BACKING for a store property node (single-home rule,
1674
- * O6: committed truth lives in the backing and a node's `_value` is never
1675
- * served for one). Called by read()'s slow tail and by the store's untracked
1676
- * node path (nodeValue); the fast paths (readNodeFast, read's fast block)
1677
- * keep their trivial ternary by design (perf, see the doc). Arms, in order:
1678
- * - the override (A17), routed through the engine for a tracked reader under
1679
- * a lane or a supersession (A18), an authoritative reader marked instead;
1680
- * - the lane entanglement gate (committed, recorded for replay);
1681
- * - a node born held has nothing for an untracked reader (A19 exception 1);
1225
+ * `el`. Called by read()'s slow tail; the fast path (read's fast block) keeps
1226
+ * its trivial ternary by design (perf, see the doc). Arms, in order:
1227
+ * - a node born staged has nothing for an untracked reader (A19 exception 1);
1682
1228
  * - an unflushed write serves committed and re-runs the reader in the
1683
1229
  * carrying flush (A28);
1684
- * - readerSeesCommitted, else the staged value and the transaction (A29).
1685
- */ function serve(e, t, n, i) {
1686
- if (hasActiveOverride(e)) {
1687
- // A17: the override IS the value for every reader — except an authoritative
1688
- // reader (until()'s predicate carries CONFIG_AUTHORITATIVE_READ): it must
1689
- // observe independently-arriving truth, and serving it the caller's own
1690
- // tentative write would trivially satisfy the predicate. The bit is checked
1691
- // on the reading computation itself, so a shared computed the predicate
1692
- // pulls recomputes as ITSELF (context = the memo, no bit) under the normal
1693
- // view. Fall through to normal value selection (staged `_pendingValue` is
1694
- // authoritative — optimism never lives there); the sticky mark makes the
1695
- // A17-silent "landing equals override" paths notify this node's subs so
1696
- // the reader re-runs when truth arrives.
1697
- // A28 (5): an optimistic write written this tick, outside a flush, is not
1698
- // yet the active override — fall through to the normal selection (the
1699
- // authoritative mark below still applies: until() must wake on landing).
1700
- if (!(t && t.C & CONFIG_AUTHORITATIVE_READ) && !unflushedOverride(e)) {
1701
- // A tracked read of an override is the engine's selection (a lane or a
1702
- // supersession implies the engine): a render effect OFF the override's
1703
- // held lane sees the committed value (#3460, lanes mirror transitions);
1704
- // a node whose own source answered with a DIFFERENT value hands a
1705
- // tracked reader the staged truth (A18 supersession, #3331). Untracked
1706
- // reads display the override.
1707
- if (t && e.C & (CONFIG_HAS_LANE | CONFIG_OVERRIDE_SUPERSEDED)) return GlobalQueue.Pn(e, t);
1708
- return unwrapOverride(e.o?.we);
1709
- }
1710
- e.C |= CONFIG_AUTHORITATIVE_OBSERVED;
1711
- }
1712
- // Entanglement gate: a reader recomputing under an optimistic lane that reads
1713
- // a pending mid-transition write sees the committed value. Projection-store
1714
- // manual writes use the firewall's manual-write flag to opt into this path.
1715
- // Async drivers are not under an optimistic lane and so bypass this, reading
1716
- // _pendingValue for correct fetching. The sub is recorded for replay at commit
1717
- // so it re-runs with the new committed view. (Gate details live with the
1718
- // engine — a non-null lane implies it is installed.)
1719
- if (currentOptimisticLane !== null && activeTransition !== null && t !== null && GlobalQueue.Fn(e, n, t)) {
1720
- return i;
1721
- }
1722
- // In optimistic lane context, return _value for optimistic/lane-assigned signals
1723
- // and for regular signals in stale mode (render effects). Non-stale readers (user
1724
- // effects) see _pendingValue so that latest() and direct reads stay consistent.
1725
- // (The lane-context clause lives with the engine.) Children-forbidden readers
1726
- // (createTrackedEffect / onSettled callbacks) get committed visibility — see
1727
- // readNodeFast (#3006).
1728
- // A node born held (recompute) has a staged value and no committed one: a
1729
- // stale reader cannot fall back to the committed frame, so it takes the
1730
- // staged value and enters like a tracked reader (A29); an untracked reader
1731
- // has nothing to serve and holds (A19 exception 1) — a bookkeeping read
1732
- // (`spectate`) likewise: it derives nothing, so it cannot enter, and a
1733
- // held-only value is simply not ready to it.
1734
- const l = e._e !== NOT_PENDING && (e.S & STATUS_UNINITIALIZED) !== 0;
1735
- if (l && (!t || spectating)) throw new NotReadyError(null);
1736
- const u = t && unflushedStaged ? unflushedValue(e, i) : NOT_PENDING;
1737
- if (u !== NOT_PENDING) {
1230
+ * - readerSeesCommitted, else the staged value.
1231
+ */ function serve(e, t) {
1232
+ // A node born staged (recompute) has a staged value and no committed one:
1233
+ // an untracked reader has nothing to serve and holds (A19 exception 1) — a
1234
+ // bookkeeping read (`spectate`) likewise, and a children-forbidden reader
1235
+ // (A32: the frame, which has nothing here).
1236
+ if (e.Oe !== NOT_PENDING && e.S & STATUS_UNINITIALIZED && (!t || spectating || t.i & CONFIG_CHILDREN_FORBIDDEN)) throw new NotReadyError(null);
1237
+ const n = t && unflushedStaged ? unflushedValue(e) : NOT_PENDING;
1238
+ if (n !== NOT_PENDING) {
1738
1239
  markLateLinker(t);
1739
- if (pendingCheckActive) GlobalQueue.Hn(e, u);
1740
- return u;
1240
+ return n;
1741
1241
  }
1742
- const o = readerSeesCommitted(e, t, n, l) ? i : (enterStagedRead(e), e._e);
1743
- // Record that this isPending() probe observed the fresh pending value, so
1744
- // the probe doesn't pair "pending" with the new value (#2831).
1745
- if (pendingCheckActive) GlobalQueue.Hn(e, o);
1746
- return o;
1242
+ if (readerSeesCommitted(e, t)) return e.Ae;
1243
+ if (t.i & CONFIG_VERDICT && !(e.S & STATUS_UNINITIALIZED) && stagedScreen(t)) return e.Ae;
1244
+ stagedRead(t, e);
1245
+ return e.Oe;
1747
1246
  }
1748
1247
 
1749
- /** A28 — a rewrite of a HELD node outside a flush keeps the staged value the
1750
- * last flush left, for latest()/verdicts, until the next flush carries it
1751
- * (stash, cleared at that flush). Cold: only stamped nodes reach here. */ function stashHeldRewrite(e) {
1752
- if (globalQueue.$t) return;
1753
- const t = ext(e);
1754
- if (t.Ut === NOT_PENDING) {
1755
- t.Ut = e._e;
1756
- unflushedRewrites.push(e);
1757
- unflushedStaged = true;
1248
+ /** A pass read a staging of this flush: it derives from what the flush may
1249
+ * yet hold (REACTIVE_STAGED_READ — the seam decides). Lane work too (plan sec. 28, a
1250
+ * lane sees the screen plus its own guesses): the staging is the screen if
1251
+ * the frame commits — one pass, the common case — and a held write if it
1252
+ * parks, which the seam repairs (`stagedReaders`): the pass re-derives on
1253
+ * the committed world and its lane's runs wait that round, so the held
1254
+ * write never shows through the lane. A verdict lane's work likewise: the
1255
+ * lane holds verdicts, not the frame's other stagings (#3851) — except a
1256
+ * verdict reader, which answered for itself (the lane seam, lanes.ts). Not
1257
+ * a read of a node born staged at all: it has no committed value to
1258
+ * re-derive on, and a re-run would read the same staging and re-queue every
1259
+ * round (#3969: nor does it make a later lane read a re-derive, `enterLane`). */ function stagedRead(e, t) {
1260
+ if (!(t?.S & STATUS_UNINITIALIZED)) {
1261
+ e.R |= REACTIVE_STAGED_READ;
1262
+ if (passLane !== null) stagedReaders.push(e);
1758
1263
  }
1759
1264
  }
1760
1265
 
1266
+ /** A10 for a staged node: a verdict reader (the pass entered a window) that
1267
+ * also reads a frame's proposal plainly sees the screen — `[latest(q), q()]`
1268
+ * is `[b, a]` — once the frame has a transaction, and re-derives when it
1269
+ * lands: at this very seam if nothing holds it (the stale run is void,
1270
+ * #3322 — one run, on the committed world), or with the hold. Before any
1271
+ * transaction the answer is the seam's and the reader watches it
1272
+ * (verdict.ts). A node born into the future has no screen: its staging is
1273
+ * its only value (A29). Nor has a reader born into the flush's transaction
1274
+ * (`bornInto`, #4010): its branch exists only there. */ function stagedScreen(e) {
1275
+ if (flushTransaction === null || bornInto(e, flushTransaction)) return false;
1276
+ staleReader(e, flushTransaction);
1277
+ return true;
1278
+ }
1279
+
1761
1280
  /** A28 (4) — written inside a recompute that runs OUTSIDE a flush (a
1762
1281
  * creation-time compute): promoted at that pass's end, visible to the rest of
1763
1282
  * the block. Cold: only contextual writes reach here. */ function notePromotedWrite(e) {
1764
- if (globalQueue.$t || e.C & CONFIG_PROMOTED) return;
1765
- e.C |= CONFIG_PROMOTED;
1283
+ if (globalQueue.X || e.i & CONFIG_PROMOTED) return;
1284
+ e.i |= CONFIG_PROMOTED;
1766
1285
  promotedWrites.push(e);
1767
1286
  }
1768
1287
 
1769
- /** Cold half of setSignal's snapshot arm (see there): first write during
1770
- * capture to a plain signal without a live snapshot records the pre-write
1771
- * value. Only plain user signals qualify. Computeds reach setSignal from an
1288
+ /** Cold half of setSignal's snapshot arm (see there), shared with a store
1289
+ * container's structural notify: first write during capture to a plain
1290
+ * signal without a live snapshot records the pre-write value. Only plain
1291
+ * user signals qualify. Computeds reach setSignal from an
1772
1292
  * async landing (asyncWrite), and a value arriving from async during the pass
1773
1293
  * REVEALS — the creation-time arm skips pending computeds for the same
1774
1294
  * reason. Firewall leaves belong to a projection whose compute is the tree's
1775
1295
  * own work, captured (or deliberately not) at creation. */ function captureWriteSnapshot(e, t) {
1776
- if (e.C & CONFIG_NO_SNAPSHOT || e.Se !== undefined || e.Ne || e.o?.ct !== undefined) return;
1777
- ext(e).ct = t === undefined ? NO_SNAPSHOT : t;
1778
- e.C |= CONFIG_HAS_SNAPSHOT;
1296
+ if (e.i & CONFIG_NO_SNAPSHOT || e.ee !== undefined || e.m?.ot !== undefined) return;
1297
+ ext(e).ot = t === undefined ? NO_SNAPSHOT : t;
1298
+ e.i |= CONFIG_HAS_SNAPSHOT;
1779
1299
  snapshotSources.add(e);
1780
1300
  }
1781
1301
 
1782
1302
  function setSignal(e, t) {
1783
- // A write to a held node is a second proposal on a contested node (A34, #3494):
1784
- // the writer's tick reveals with the hold, the same value or another. Inside
1785
- // a flush the round enters now; from mainline the entry waits for the next
1786
- // flush's start (batchJoins) — entering here left activeTransition set for
1787
- // the rest of the caller's block, so a memo created after the write became
1788
- // the transaction's instead of mainline's (A28, A29). Before the equality
1789
- // gate below: repeating the held value proposes it too — and that repeat
1790
- // leaves through the gate, so the join schedules its own flush here; left
1791
- // for the next flush to find, it adopted an unrelated tick (#3519 review).
1792
- // A held DERIVATION is not a proposal (A34 amendment, #3612): the user
1793
- // setters of derived nodes (setMemo, the derived store's setter) classify
1794
- // the write before it reaches here — see heldDerivation — and re-derive
1795
- // under the hold instead of masking; the join stands either way.
1796
- if (e.me && activeTransition !== e.me) {
1797
- if (globalQueue.$t) globalQueue.initTransition(e.me); else {
1798
- batchJoins.push(e.me);
1799
- // dupes: a bare return in initTransition
1800
- schedule();
1801
- }
1802
- }
1803
- // The optimistic write path lives with the engine: only optimisticSignal /
1804
- // optimisticComputed callers and optimistic store nodes carry an
1805
- // _overrideValue slot (flagged by CONFIG_OPTIMISTIC — a masked read of the
1806
- // always-present config instead of a missing-property probe), and every
1807
- // module that installs one installs the engine first.
1808
- if (e.C & CONFIG_OPTIMISTIC) {
1809
- if (!projectionWriteActive) return GlobalQueue.Ln(e, t);
1810
- // An authoritative store landing on an override-covered node: the store
1811
- // twin of asyncWrite's override branch, decided by the engine (#3331).
1812
- const n = e.o?.we;
1813
- if (n !== undefined && n !== NOT_PENDING) return GlobalQueue.Vn(e, t);
1814
- }
1815
- const n = e._e === NOT_PENDING ? e.ce : e._e;
1303
+ const n = e.Oe === NOT_PENDING ? e.Ae : e.Oe;
1816
1304
  if (typeof t === "function") t = t(n);
1305
+ // Lanes: a write landing on a guess is its truth (A18 — an async guess's
1306
+ // own landing), judged against the guess; one landing on a lane's
1307
+ // derivation (its flight) is the lane's staging (lanes.ts).
1308
+ if (e.i & CONFIG_OVERRIDE) return GlobalQueue.Qt(e, t);
1309
+ // L2 (T4) / A34 (1): a write to a node whose staged state is held is a
1310
+ // second proposal for the slot — the same value again or another — and
1311
+ // the two cannot finish at different times: the writer's tick joins the
1312
+ // hold, before the equality gate.
1313
+ if (e.i & CONFIG_HELD) joinFuture(txOf(e));
1817
1314
  // Uninitialized check first: the first commit has no previous value, so the
1818
1315
  // user comparator must not run against `undefined` (matches recompute).
1819
- const i = !!(e.S & STATUS_UNINITIALIZED) || !e.Fe || !e.Fe(n, t);
1820
- if (!i) return t;
1316
+ const l = !!(e.S & STATUS_UNINITIALIZED) || !e.en || !e.en(n, t);
1317
+ if (!l) return t;
1821
1318
  // Attribution hook: this committed write is where a re-run chain begins.
1822
1319
  if (attrHooks !== null) attrHooks.write(e, n, t);
1823
1320
  // A write during hydration's snapshot capture to a source that has no
@@ -1830,93 +1327,57 @@ function setSignal(e, t) {
1830
1327
  // pass reads a value the server never had. Store leaves written here are
1831
1328
  // plain signals and qualify the same way.
1832
1329
  if (snapshotCaptureActive) captureWriteSnapshot(e, n);
1833
- const l = e._e !== NOT_PENDING;
1834
- if (!l) queuePendingNode(e);
1835
- // A28 arms, gated on the loads the write already pays for (a plain ambient
1836
- // rewrite outside a flush — the write-loop shape — costs `_transition` and
1837
- // `context` here and nothing else; the arms themselves are cold helpers so
1838
- // setSignal stays within every setter's inlining budget, ~300 B bytecode).
1839
- else if (e.me !== null) stashHeldRewrite(e);
1840
- e._e = t;
1330
+ const E = e.Oe !== NOT_PENDING;
1331
+ if (!E) queuePendingNode(e);
1332
+ // A28: a held node rewritten outside a flush keeps its flushed staging
1333
+ // for every reader until the flush that carries the rewrite.
1334
+ else if (e.i & CONFIG_HELD && !globalQueue.X) stashFlushed(e);
1335
+ e.Oe = t;
1841
1336
  if (context !== null) notePromotedWrite(e);
1842
- // syncCompanions only pokes _pendingSignal/_latestValueComputed — with
1843
- // neither companion present the call is a guaranteed no-op (companions are
1844
- // only ever created, never removed, and creating one installs the hook and
1845
- // sets CONFIG_HAS_COMPANIONS — one masked read replaces two optional-field
1846
- // probes on every write).
1847
- if (e.C & CONFIG_HAS_COMPANIONS && GlobalQueue.Le !== null) {
1848
- GlobalQueue.Le(e, t);
1849
- // A28 (2): the verdict computed here is the PRE-flush one (an unflushed
1850
- // write is not pending); the flush that carries the write re-syncs so
1851
- // the companions mirror the flushed world. Only companion nodes pay.
1852
- if (!globalQueue.$t) unflushedCompanions.push(e);
1853
- }
1854
1337
  // _time is a computed-only slot (§12e): writing it on a signal would fork
1855
1338
  // the lean shape. Every read site is computed-typed.
1856
- if (e.Se !== undefined) e.Ge = clock;
1339
+ if (e.ee !== undefined) e.Ie = clock;
1857
1340
  // Staged-rewrite fast path (§12d): a re-write to a node whose subscribers
1858
1341
  // were already walked — and where nothing has recomputed or linked since
1859
1342
  // (epoch) — re-stages the value and stops. The walk is idempotent (subs
1860
- // marked, heap entries flag-guarded, effects queued once); lane and reask
1861
- // contexts change what a walk MEANS, so they always walk.
1862
- if (l && e.Lt === notifyEpoch && currentOptimisticLane === null && !reaskArmed) return t;
1343
+ // marked, heap entries flag-guarded, effects queued once).
1344
+ if (E && e.Pt === notifyEpoch) return t;
1863
1345
  insertSubs(e);
1864
1346
  schedule();
1865
1347
  return t;
1866
1348
  }
1867
1349
 
1868
1350
  /**
1869
- * Suppresses automatic recomputation of `el` until the scheduler drains. Used
1870
- * when a manual write should win over dependency changes queued in the same
1871
- * tick. The MANUAL_WRITE flag is cleared by the pending-node drain; projection
1872
- * computeds don't commit values, but they still need the same end-of-tick
1873
- * cleanup point.
1874
- */ function suppressComputedRecompute(e) {
1875
- deleteFromHeap(e, queueFor(e));
1876
- if (!(e.oe & REACTIVE_MANUAL_WRITE) && e._e === NOT_PENDING) {
1877
- queuePendingNode(e);
1878
- schedule();
1879
- }
1880
- e.oe = e.oe & -4 | REACTIVE_MANUAL_WRITE;
1881
- e.Un = clock;
1882
- }
1883
-
1884
- /** A34 amendment (#3612) — is `el`'s staging a DERIVATION another transaction
1885
- * holds: stamped by a transaction that is not the writer's, and not a manual
1886
- * proposal (the mask, on the node or — a store leaf — its firewall)? #2692's
1887
- * "manual write wins" is a rule for one synchronous frame; across a hold the
1888
- * held pass result is nobody's proposal, and a user setter reaching it
1889
- * composes on the committed frame it was written against and becomes `prev`
1890
- * for the transaction's re-derivation (rederiveHeld) instead of replacing it.
1891
- * Writes made under the holding transaction masked the node and keep
1892
- * A34(1)'s last-write-wins. Only the user setters ask; an async landing or a
1893
- * companion writing a stamped node is the transaction's own work. */ function heldDerivation(e) {
1894
- return e.me !== null && activeTransition !== e.me && !((e.Ne || e).oe & REACTIVE_MANUAL_WRITE);
1895
- }
1896
-
1897
- /** The held-derivation write's second half: the node re-derives under its
1898
- * hold with the written staging as the pass's `prev`. Nothing is masked. The
1899
- * write took the A34 join (setSignal), which scheduled the flush that drains
1900
- * this; recompute re-enters the stamp. */ function rederiveHeld(e) {
1901
- e.oe |= REACTIVE_DIRTY;
1902
- // over CHECK: the heap visit recomputes, not re-checks
1903
- enqueueSub(e);
1904
- }
1905
-
1906
- /**
1907
- * User-facing setter for the memo form of `createSignal(fn)`. Behaves like
1908
- * `setSignal`, but also cancels any pending recompute of the memo so the
1909
- * manual value wins over a value that would otherwise be produced by an
1910
- * upstream change in the same tick. Across a hold the write is not a
1911
- * proposal: a memo another transaction holds as a pass result composes on the
1912
- * committed value and re-derives under the hold with the write as `prev`
1913
- * (A34 amendment, #3612; heldDerivation).
1351
+ * User-facing setter for the memo form of `createSignal(fn)`. A write applies
1352
+ * first, then derivations re-run (A34 as amended 2026-10-01, rule B; core
1353
+ * R31): the write stages like any other, and a source change — in this flush
1354
+ * or a later one, under a hold or on mainline — re-derives with the staged
1355
+ * write as `prev`. The write never refuses the re-run (the frame-scoped mask
1356
+ * of #3733/#3740 and #2692's "write wins the tick" before it are gone; call
1357
+ * order inside a flush was never observable) and on its own never causes one.
1358
+ * REACTIVE_MANUAL_WRITE only marks the staging as a user proposal — the A34
1359
+ * (1)/(3) discriminator — until a pass re-derives it or the commit lands it.
1914
1360
  */ function setMemo(e, t) {
1915
- const n = heldDerivation(e);
1916
- if (n && typeof t === "function") t = t(e.ce);
1917
- const i = setSignal(e, t);
1918
- n ? rederiveHeld(e) : suppressComputedRecompute(e);
1919
- return i;
1361
+ // A34 (3), #3612: is `el`'s staging a derivation another transaction holds
1362
+ // — held, not a manual proposal, and the writer not that transaction
1363
+ // (mainline, or a flush joined elsewhere)? A held pass result is nobody's
1364
+ // proposal: a setter reaching it composes on the committed frame it was
1365
+ // written against and becomes `prev` for the hold's re-derivation, instead
1366
+ // of replacing it. A write made under the hold carries the mark and keeps
1367
+ // (1)'s last-write-wins. Only the user setter asks; an async landing
1368
+ // writing a held node is the transaction's own work.
1369
+ const n = e.i & CONFIG_HELD && !(e.R & REACTIVE_MANUAL_WRITE) && txOf(e) !== flushTransaction;
1370
+ // The writer read the committed frame; its updater composes on it.
1371
+ if (n && typeof t === "function") t = t(e.Ae);
1372
+ const l = setSignal(e, t);
1373
+ if (n) {
1374
+ // The one write that re-runs: the staging it replaced was derived from
1375
+ // inputs the writer never saw, so the hold re-derives over the write.
1376
+ e.R = e.R & ~REACTIVE_CHECK | REACTIVE_DIRTY;
1377
+ insertIntoHeap(e, dirtyQueue);
1378
+ schedule();
1379
+ } else if (e.Oe !== NOT_PENDING) e.R |= REACTIVE_MANUAL_WRITE;
1380
+ return l;
1920
1381
  }
1921
1382
 
1922
1383
  /**
@@ -1939,25 +1400,21 @@ function setSignal(e, t) {
1939
1400
  * ```
1940
1401
  */ function runWithOwner(e, t) {
1941
1402
  const n = context;
1942
- const i = tracking;
1403
+ const l = tracking;
1943
1404
  context = e;
1944
1405
  tracking = false;
1945
1406
  try {
1946
1407
  return t();
1947
1408
  } finally {
1948
1409
  context = n;
1949
- tracking = i;
1410
+ tracking = l;
1950
1411
  }
1951
1412
  }
1952
1413
 
1953
1414
  function staleValues(e, t = true) {
1954
- const n = stale;
1955
- stale = t;
1956
1415
  try {
1957
1416
  return e();
1958
- } finally {
1959
- stale = n;
1960
- }
1417
+ } finally {}
1961
1418
  }
1962
1419
 
1963
1420
  /**
@@ -1965,45 +1422,22 @@ function staleValues(e, t = true) {
1965
1422
  * it validates the target, marks through here, then builds the quiescence
1966
1423
  * promise on the resolve()/until() effect machinery). Flags the node's next
1967
1424
  * recompute as a quiet re-ask and schedules it; no-ops for non-derived or
1968
- * disposed targets and for same-tick manual writes.
1425
+ * disposed targets.
1969
1426
  */ function markRefresh(e) {
1970
- if (typeof e.Se === "function" && !(e.oe & REACTIVE_DISPOSED)) {
1971
- if (e.oe & REACTIVE_MANUAL_WRITE) {
1972
- // A manual write in the CURRENT tick wins over the refresh (#2692).
1973
- // A mask stamped in an earlier tick only survives because a
1974
- // transaction (action) is holding the pending drain open; there the
1975
- // refresh is a later, explicit re-ask and lifts the mask — otherwise
1976
- // any setStore early in an action silently swallows every refresh()
1977
- // for the rest of the transaction (#3026).
1978
- if (e.Un === clock) return;
1979
- e.oe &= ~REACTIVE_MANUAL_WRITE;
1980
- // The lift falls through to the re-ask classification below. The held
1981
- // write's value change already rides the transaction; the refetch it
1982
- // asks for is the same question with unchanged inputs. Skipping the
1983
- // mark here classified that refetch as a NEW question, which pends
1984
- // every leaf (3.1) — an action doing setStore + yield + refresh(store)
1985
- // lit up every sibling row, and affects() could not narrow it (a mark
1986
- // only turns pending on). Same-question motion stays silent (3.4);
1987
- // the written slot and any declared mark carry the pending instead.
1988
- }
1989
- // A refresh with no value-change dirt already queued is a re-ask of the
1990
- // same question: mark it so the recompute classifies any resulting
1991
- // pending window as quiet (not pending). If the node is already dirty
1992
- // from a real input change, the question changed — don't mark.
1993
- // REACTIVE_IN_HEAP counts as dirt: insertSubs schedules subscribers by
1994
- // heap insertion alone (no DIRTY/CHECK flag), so a same-batch value
1995
- // change followed by refresh() must not be laundered into a quiet re-ask.
1996
- if (!(e.oe & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP))) {
1997
- e.oe |= REACTIVE_REASK;
1998
- armReaskClear();
1999
- }
2000
- e.oe = e.oe & ~REACTIVE_CHECK | REACTIVE_DIRTY;
1427
+ if (typeof e.ee === "function" && !(e.R & REACTIVE_DISPOSED)) {
1428
+ // A manual write never refuses the re-run (A34 rule B): a refresh in the
1429
+ // write's own frame re-asks with the write as `prev`, like any source
1430
+ // change (#3026 generalized).
1431
+ // The re-ask of an answered question (A19 exc. 2): the next pass, going
1432
+ // pending, classifies its flight quiet for the verdict. Not when an
1433
+ // input already changed this tick — that pass asks a new question.
1434
+ e.R = e.R & ~REACTIVE_CHECK | REACTIVE_DIRTY | (e.R & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP) ? 0 : REACTIVE_REASK);
2001
1435
  // A refresh() self-invalidation is a root cause too — the target's next
2002
1436
  // run has no changed dep to point at, so it points here instead.
2003
1437
  if (attrHooks !== null) attrHooks.refreshed(e);
2004
- insertIntoHeap(e, queueFor(e));
1438
+ insertIntoHeap(e, dirtyQueue);
2005
1439
  schedule();
2006
1440
  }
2007
1441
  }
2008
1442
 
2009
- export { READ_SLOW, clearSnapshots, computed, context, createEffectNode, currentOptimisticLane, effectStatusNotify, enterStagedRead, ext, hasActiveOverride, heldDerivation, installAuthoritativeRead, isEqual, latestReadActive, markLateLinker, markRefresh, markSnapshotScope, markUnflushedStaged, notifyAuthoritativeObservers, notifyOnLane, optimisticComputed, optimisticSignal, ownsHold, pendingCheckActive, prepareComputed, read, readNodeFast, readerSeesCommitted, recompute, recordStaleReplay, rederiveHeld, releaseSnapshotScope, resyncUnflushedCompanions, runWithOwner, serve, setContextInternal, setEffectStatusNotify, setLatestReadActive, setMemo, setPendingCheckActive, setSignal, setSlotUnobserved, setSnapshotCapture, signal, slotSignal, slotUnobservedHook, snapshotCaptureActive, snapshotSources, spectate, spectating, stale, staleValues, statusNotifierOf, suppressComputedRecompute, tracking, unflushed, unflushedCompanions, unflushedOverride, unflushedStaged, unflushedValue, unlinkFirewallChild, untrack, visibleOverride };
1443
+ export { bornInto, captureWriteSnapshot, clearSnapshots, computed, context, createEffectNode, effectStatusNotify, ext, isEqual, joinPass, markLateLinker, markRefresh, markSnapshotScope, markUnflushedStaged, notePromotedWrite, prepareComputed, pullComputed, read, readerSeesCommitted, recompute, releaseSnapshotScope, resyncUnflushedCompanions, runWithOwner, serve, setEffectStatusNotify, setMemo, setSignal, setSnapshotCapture, setVerdict, signal, slotSignal, snapshotCaptureActive, snapshotSources, spectating, stagedRead, stagedScreen, staleValues, stashFlushed, statusNotifierOf, tracking, unflushedStaged, unflushedValue, untrack, verdict };