@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.20

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 (198) hide show
  1. package/dist/dev-shared.js +6505 -0
  2. package/dist/dev.attribution.js +3484 -0
  3. package/dist/dev.js +10227 -9508
  4. package/dist/observe/affects-marks.js +86 -0
  5. package/dist/observe/affects.js +112 -0
  6. package/dist/observe/attribution.js +7 -0
  7. package/dist/observe/boundaries.js +696 -0
  8. package/dist/observe/core/action.js +182 -0
  9. package/dist/observe/core/async.js +824 -0
  10. package/dist/observe/core/attribution-costs.js +66 -0
  11. package/dist/observe/core/attribution-feedback.js +280 -0
  12. package/dist/observe/core/attribution-hooks.js +83 -0
  13. package/dist/observe/core/attribution-queries.js +43 -0
  14. package/dist/observe/core/attribution.js +3079 -0
  15. package/dist/observe/core/constants.js +269 -0
  16. package/dist/observe/core/context.js +63 -0
  17. package/dist/observe/core/copies.js +10 -0
  18. package/dist/observe/core/core.js +1707 -0
  19. package/dist/observe/core/dev.js +394 -0
  20. package/dist/observe/core/effect.js +193 -0
  21. package/dist/observe/core/error-hooks.js +71 -0
  22. package/dist/observe/core/error.js +82 -0
  23. package/dist/observe/core/external.js +97 -0
  24. package/dist/observe/core/graph.js +162 -0
  25. package/dist/observe/core/heap.js +124 -0
  26. package/dist/observe/core/identities.js +62 -0
  27. package/dist/observe/core/invariants.js +12 -0
  28. package/dist/observe/core/lanes.js +972 -0
  29. package/dist/observe/core/owner.js +371 -0
  30. package/dist/observe/core/scheduler.js +1157 -0
  31. package/dist/observe/core/truth.js +47 -0
  32. package/dist/observe/core/verdict.js +470 -0
  33. package/dist/observe/deferred.js +186 -0
  34. package/dist/observe/flatten.js +79 -0
  35. package/dist/observe/from.js +248 -0
  36. package/dist/observe/index.js +71 -0
  37. package/dist/observe/map.js +593 -0
  38. package/dist/observe/reveal.js +212 -0
  39. package/dist/observe/signals.js +717 -0
  40. package/dist/observe/store/affects.js +142 -0
  41. package/dist/observe/store/edges.js +39 -0
  42. package/dist/observe/store/hooks.js +16 -0
  43. package/dist/observe/store/index.js +47 -0
  44. package/dist/observe/store/optimistic.js +713 -0
  45. package/dist/observe/store/projection.js +345 -0
  46. package/dist/observe/store/reconcile.js +281 -0
  47. package/dist/observe/store/store.js +2127 -0
  48. package/dist/observe/store/storePath.js +103 -0
  49. package/dist/observe/store/target.js +46 -0
  50. package/dist/observe/store/types.js +83 -0
  51. package/dist/observe/store/utils.js +1063 -0
  52. package/dist/prod/affects-marks.js +86 -0
  53. package/dist/prod/affects.js +98 -112
  54. package/dist/prod/attribution.js +45 -0
  55. package/dist/prod/boundaries.js +578 -468
  56. package/dist/prod/core/action.js +92 -59
  57. package/dist/prod/core/async.js +522 -336
  58. package/dist/prod/core/attribution-hooks.js +3 -0
  59. package/dist/prod/core/constants.js +168 -44
  60. package/dist/prod/core/context.js +12 -16
  61. package/dist/prod/core/copies.js +10 -0
  62. package/dist/prod/core/core.js +1345 -627
  63. package/dist/prod/core/dev.js +123 -1
  64. package/dist/prod/core/effect.js +113 -80
  65. package/dist/prod/core/error-hooks.js +71 -0
  66. package/dist/prod/core/error.js +18 -4
  67. package/dist/prod/core/external.js +6 -7
  68. package/dist/prod/core/graph.js +119 -72
  69. package/dist/prod/core/heap.js +85 -109
  70. package/dist/prod/core/identities.js +62 -0
  71. package/dist/prod/core/invariants.js +1 -32
  72. package/dist/prod/core/lanes.js +931 -132
  73. package/dist/prod/core/owner.js +192 -129
  74. package/dist/prod/core/scheduler.js +948 -642
  75. package/dist/prod/core/truth.js +47 -0
  76. package/dist/prod/core/verdict.js +409 -420
  77. package/dist/prod/deferred.js +184 -0
  78. package/dist/prod/flatten.js +77 -0
  79. package/dist/prod/from.js +248 -0
  80. package/dist/prod/index.js +40 -16
  81. package/dist/prod/map.js +481 -211
  82. package/dist/prod/reveal.js +212 -0
  83. package/dist/prod/signals.js +401 -84
  84. package/dist/prod/store/affects.js +142 -0
  85. package/dist/prod/store/edges.js +39 -0
  86. package/dist/prod/store/hooks.js +16 -0
  87. package/dist/prod/store/index.js +27 -18
  88. package/dist/prod/store/optimistic.js +707 -0
  89. package/dist/prod/store/projection.js +331 -0
  90. package/dist/prod/store/reconcile.js +281 -0
  91. package/dist/prod/store/store.js +1952 -267
  92. package/dist/prod/store/storePath.js +1 -1
  93. package/dist/prod/store/target.js +43 -0
  94. package/dist/prod/store/types.js +83 -0
  95. package/dist/prod/store/utils.js +997 -138
  96. package/dist/types/affects-marks.d.ts +14 -0
  97. package/dist/types/affects.d.ts +12 -30
  98. package/dist/types/attribution.d.ts +19 -0
  99. package/dist/types/attribution.prod.d.ts +22 -0
  100. package/dist/types/boundaries.d.ts +99 -124
  101. package/dist/types/carved.d.ts +1 -0
  102. package/dist/types/core/action.d.ts +23 -9
  103. package/dist/types/core/async.d.ts +34 -6
  104. package/dist/types/core/attribution-costs.d.ts +35 -0
  105. package/dist/types/core/attribution-feedback.d.ts +133 -0
  106. package/dist/types/core/attribution-hooks.d.ts +307 -8
  107. package/dist/types/core/attribution-queries.d.ts +24 -0
  108. package/dist/types/core/attribution.d.ts +802 -72
  109. package/dist/types/core/constants.d.ts +195 -38
  110. package/dist/types/core/copies.d.ts +54 -0
  111. package/dist/types/core/core.d.ts +295 -65
  112. package/dist/types/core/dev.d.ts +509 -22
  113. package/dist/types/core/effect.d.ts +1 -1
  114. package/dist/types/core/error-hooks.d.ts +71 -0
  115. package/dist/types/core/error.d.ts +18 -1
  116. package/dist/types/core/graph.d.ts +40 -1
  117. package/dist/types/core/heap.d.ts +5 -5
  118. package/dist/types/core/identities.d.ts +17 -0
  119. package/dist/types/core/index.d.ts +11 -7
  120. package/dist/types/core/invariants.d.ts +1 -26
  121. package/dist/types/core/lanes.d.ts +74 -43
  122. package/dist/types/core/owner.d.ts +27 -9
  123. package/dist/types/core/scheduler.d.ts +353 -102
  124. package/dist/types/core/truth.d.ts +18 -0
  125. package/dist/types/core/types.d.ts +97 -71
  126. package/dist/types/core/verdict.d.ts +35 -0
  127. package/dist/types/deferred.d.ts +28 -0
  128. package/dist/types/flatten.d.ts +8 -0
  129. package/dist/types/from.d.ts +47 -0
  130. package/dist/types/index.d.ts +33 -7
  131. package/dist/types/map.d.ts +4 -2
  132. package/dist/types/reveal.d.ts +19 -0
  133. package/dist/types/signals.d.ts +196 -45
  134. package/dist/types/store/affects.d.ts +12 -0
  135. package/dist/types/store/edges.d.ts +9 -0
  136. package/dist/types/store/hooks.d.ts +62 -0
  137. package/dist/types/store/index.d.ts +42 -15
  138. package/dist/types/store/optimistic.d.ts +24 -45
  139. package/dist/types/store/projection.d.ts +17 -68
  140. package/dist/types/store/reconcile.d.ts +3 -46
  141. package/dist/types/store/store.d.ts +133 -136
  142. package/dist/types/store/storePath.d.ts +1 -1
  143. package/dist/types/store/target.d.ts +166 -0
  144. package/dist/types/store/types.d.ts +105 -0
  145. package/dist/types/store/utils.d.ts +188 -0
  146. package/package.json +31 -26
  147. package/dist/node.cjs +0 -8745
  148. package/dist/prod/core/optimistic.js +0 -265
  149. package/dist/prod/store/next/optimistic.js +0 -385
  150. package/dist/prod/store/next/projection.js +0 -172
  151. package/dist/prod/store/next/reconcile.js +0 -331
  152. package/dist/prod/store/next/store.js +0 -1499
  153. package/dist/prod/store/next/target.js +0 -20
  154. package/dist/types/core/optimistic.d.ts +0 -6
  155. package/dist/types/store/next/optimistic.d.ts +0 -20
  156. package/dist/types/store/next/projection.d.ts +0 -8
  157. package/dist/types/store/next/reconcile.d.ts +0 -3
  158. package/dist/types/store/next/store.d.ts +0 -77
  159. package/dist/types/store/next/target.d.ts +0 -117
  160. package/dist/types-cjs/affects.d.cts +0 -47
  161. package/dist/types-cjs/boundaries.d.cts +0 -175
  162. package/dist/types-cjs/core/action.d.cts +0 -64
  163. package/dist/types-cjs/core/async.d.cts +0 -21
  164. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -52
  165. package/dist/types-cjs/core/attribution.d.cts +0 -186
  166. package/dist/types-cjs/core/constants.d.cts +0 -97
  167. package/dist/types-cjs/core/context.d.cts +0 -36
  168. package/dist/types-cjs/core/core.d.cts +0 -163
  169. package/dist/types-cjs/core/dev.d.cts +0 -81
  170. package/dist/types-cjs/core/effect.d.cts +0 -30
  171. package/dist/types-cjs/core/error.d.cts +0 -47
  172. package/dist/types-cjs/core/external.d.cts +0 -15
  173. package/dist/types-cjs/core/graph.d.cts +0 -6
  174. package/dist/types-cjs/core/heap.d.cts +0 -22
  175. package/dist/types-cjs/core/index.d.cts +0 -13
  176. package/dist/types-cjs/core/invariants.d.cts +0 -59
  177. package/dist/types-cjs/core/lanes.d.cts +0 -44
  178. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  179. package/dist/types-cjs/core/owner.d.cts +0 -124
  180. package/dist/types-cjs/core/scheduler.d.cts +0 -180
  181. package/dist/types-cjs/core/types.d.cts +0 -192
  182. package/dist/types-cjs/core/verdict.d.cts +0 -2
  183. package/dist/types-cjs/index.d.cts +0 -10
  184. package/dist/types-cjs/map.d.cts +0 -69
  185. package/dist/types-cjs/package.json +0 -3
  186. package/dist/types-cjs/signals.d.cts +0 -624
  187. package/dist/types-cjs/store/index.d.cts +0 -19
  188. package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
  189. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  190. package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
  191. package/dist/types-cjs/store/next/store.d.cts +0 -77
  192. package/dist/types-cjs/store/next/target.d.cts +0 -117
  193. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  194. package/dist/types-cjs/store/projection.d.cts +0 -70
  195. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  196. package/dist/types-cjs/store/store.d.cts +0 -138
  197. package/dist/types-cjs/store/storePath.d.cts +0 -58
  198. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -0,0 +1,972 @@
1
+ import { CONFIG_GUESS, NOT_PENDING, CONFIG_OVERRIDE, REACTIVE_DIRTY, REACTIVE_CHECK, REACTIVE_IN_HEAP, STATUS_PENDING, CONFIG_SLOT_NODE, REACTIVE_STAGED_READ, REACTIVE_DISPOSED, CONFIG_VERDICT, REACTIVE_PROBE_UNANSWERED, REACTIVE_LANE_DIRTY, CONFIG_HELD, REACTIVE_LANE_READ, STATUS_UNINITIALIZED, REACTIVE_RECOMPUTING_DEPS, CONFIG_AUTHORITATIVE, STATUS_ERROR, CONFIG_CHILDREN_FORBIDDEN, EFFECT_RENDER, REACTIVE_SCREEN_READ, REACTIVE_FRAME_READ, CONFIG_INPUTS_PUBLISHED, CONFIG_STAGED, REACTIVE_JOINED } from "./constants.js";
2
+
3
+ import { attrHooks } from "./attribution-hooks.js";
4
+
5
+ import { ext, bornInto, tracking, creatorReads, stagedRead } from "./core.js";
6
+
7
+ import { NotReadyError } from "./error.js";
8
+
9
+ import { removePendingSource, releaseFlightTeardown, handleAsync, notifyStatus, isThenable } from "./async.js";
10
+
11
+ import { laneValueOf } from "./truth.js";
12
+
13
+ import { enqueueSub } from "./heap.js";
14
+
15
+ import { schedule, question, nextQuestion, armGuessing, installLaneHooks, GlobalQueue, resolveTx, newTransaction, list, staleReader, txOf, commitPendingNode, ownFlights, stagedReaders, blocked, clock, insertSubs, laneDirty, flushTransaction, queuePendingNode, passLane, setPassLane, sameLane, releaseQueues, holdNode, reruns, merge } from "./scheduler.js";
16
+
17
+ // Lanes (plan sec. 28 replay, 2026-10-02; maintainer rulings 2026-10-01/02). A lane
18
+ // is "a new base of a transition": the sub-frame an optimistic write opens
19
+ // in the transition of the frame it is made in. It sees the screen plus its
20
+ // own guesses (plan sec. 19), breaks out of the parent's hold — its effects run now —
21
+ // and holds itself if its own derivations hit async (and, blocked, holds its
22
+ // parent). It ends when the parent lands: a guess reverts to the truth it
23
+ // covered, or lands as the truth that superseded it. A frame that does not
24
+ // park has nothing to be optimistic over: the write is void.
25
+ // Three places per node, each meaning one thing always: `_value` is the
26
+ // committed truth, `_pendingValue` a transaction's staging (the future), and
27
+ // `_x._lane` the lane's value — a written guess or a lane pass's derivation.
28
+ // The lane carries the state machine: `_shown` once it has revealed. The
29
+ // screen shows a lane's value once the lane has shown (`display`); a direct
30
+ // read sees it throughout (A17); an authoritative reader (`until`) sees the
31
+ // truth beneath it (Q3, 2026-10-02: "optimistic overrides are intentionally
32
+ // not part of authoritative truth").
33
+ // The seat of a pass is its node's (core.ts `recompute`): a node carrying a
34
+ // lane's derived value runs as the lane's whoever dirtied it; a derivation's
35
+ // tracked read of a lane's value moves its pass into the lane (`enterLane`);
36
+ // a leaf's never does — it reads the screen, a stale reader of a lane that
37
+ // has not shown (#3460). Lane work's values go to the lane slot (or, once
38
+ // the lane has shown, to its staging for the next reveal), its runs to the
39
+ // lane's queues.
40
+ // This module is the lane engine, installed on `GlobalQueue` when something
41
+ // imports it (`createOptimistic`, or verdict.ts for its verdict lanes). The
42
+ // core keeps only bit tests and `passLane`: a program with no optimism
43
+ // carries none of this.
44
+ /** Live lanes (parented). Scanned at every seam while non-empty. */
45
+ const lanes = [];
46
+
47
+ /** A pass left a shown slot the equality gate can no longer see (#3892). */ const LEFT_SHOWN = 1 << 20;
48
+
49
+ function newLane(e) {
50
+ const n = newTransaction(true, e);
51
+ lanes.push(n);
52
+ return n;
53
+ }
54
+
55
+ /** What the screen shows for a lane's node: the lane's value once the lane
56
+ * has revealed, the committed truth before — NOT_PENDING when there is none
57
+ * (uninitialized, as `laneValueOf`): its read throws NotReady. */ function display(e) {
58
+ const n = e.T.V;
59
+ return e.T.Je.Nt && n !== NOT_PENDING ? n : e.m & STATUS_UNINITIALIZED ? NOT_PENDING : e.le;
60
+ }
61
+
62
+ /** Guesses written since the last seam (`[node, value, question, …]`).
63
+ * Applied at the seam, once the frame's verdict is known — the parent is
64
+ * the frame's transaction, and there is none to be optimistic over when the
65
+ * frame commits (the write is as if it never happened: nothing was
66
+ * applied). The lane's passes run in the next round of the same flush, so
67
+ * the guess is visible at flush like any write (A28). */ const pendingGuesses = [];
68
+
69
+ /** What the writer sees of a node: an unflushed guess to it, else the
70
+ * lane's value or the committed one — what an optimistic updater composes
71
+ * on (a store setter's draft too, store/optimistic.ts). */ function guessedValueOf(e) {
72
+ let n = pendingGuessOf(e);
73
+ return n !== NOT_PENDING || e.l & CONFIG_OVERRIDE && (n = laneValueOf(e)) !== NOT_PENDING ? n : e.le;
74
+ }
75
+
76
+ /** The unflushed guess to `n`, else NOT_PENDING. */ function pendingGuessOf(e) {
77
+ for (let n = pendingGuesses.length - 3; n >= 0; n -= 3) if (pendingGuesses[n] === e) return pendingGuesses[n + 1];
78
+ return NOT_PENDING;
79
+ }
80
+
81
+ /** This module's copy of scheduler.ts `guessing`: its readers here stay
82
+ * foldable when a bundler splits lanes.ts from scheduler.ts into separate
83
+ * chunks (a cross-chunk binding is not folded; the compiled live page). */ let guessed = false;
84
+
85
+ /** Guesses another action's lane took over (#4336): the node, its guess,
86
+ * the guess's lane, its question, the lane that took it. */ const kept = [];
87
+
88
+ /** Lanes a revert dissolved: the guesses they took come back at their
89
+ * parent's landing (`endLanes`). */ const reverted = /* @__PURE__ */ new WeakSet;
90
+
91
+ /** Lane `l` takes `n`'s guess (another action's), kept to come back if `l`
92
+ * reverts. Its readers saw the guess: they re-derive at the lane's reveal
93
+ * (and, a flight's, hold the lane while they would show it). `d`: a guess
94
+ * `l` takes without writing it (a store target's other slots) — the node
95
+ * shows its truth in `l`'s world until the guess comes back. */ function take(e, n, s) {
96
+ const t = e.T;
97
+ kept.push(e, t.V, t.Je, t.Ie, n);
98
+ rerun(e, n);
99
+ e.l &= s ? -10241 : ~CONFIG_GUESS;
100
+ if (s) t.Je = null, t.V = NOT_PENDING; else list(e, n);
101
+ }
102
+
103
+ /** `n`'s readers are stale readers of `t` (re-derived at its landing). */ function rerun(e, n) {
104
+ for (let s = e.o; s !== null; s = s.t) staleReader(s.u, n);
105
+ }
106
+
107
+ function optimisticWrite(e, n) {
108
+ // What the user sees: an unflushed guess to the same node, else the lane's
109
+ // value or the committed one. The updater composes on it; guessing it
110
+ // again is no guess (the node's comparator, as for any write) — unless
111
+ // the node already carries one: the user re-asked, and the re-ask renews
112
+ // the guess's question and entangles its frame (#3347) without notifying.
113
+ const s = guessedValueOf(e);
114
+ if (typeof n === "function") n = n(s);
115
+ if (e.je && e.je(s, n) && !(e.l & CONFIG_GUESS)) return n;
116
+ pendingGuesses.push(e, n, question || nextQuestion());
117
+ armGuessing();
118
+ guessed = true;
119
+ schedule();
120
+ return n;
121
+ }
122
+
123
+ /** The seam: each guess becomes its node's lane value, in a lane — the
124
+ * node's own if it carries one (a later write into the same lane), else a
125
+ * new one under `parent` (the frame's transaction), under the hold already
126
+ * on the node (a guess over that transition's world — the truth it holds
127
+ * stays staged beneath, for the lane's end to commit), or under a
128
+ * transaction opened for the node's own in-flight refetch (the guess is
129
+ * that flight's observer — A17, "visible until its own fetch settles"). No
130
+ * parent: the guess is dropped. The truth is untouched; readers are
131
+ * dirtied for the next round. */
132
+ /** A guess's own truth is in flight: the node's own refetch — or, a store
133
+ * leaf's, its family's derive (the slot's flight; store/optimistic.ts
134
+ * installs the resolver). A17: the guess stands in for the flight. */ function inFlight(e) {
135
+ return e.m & STATUS_PENDING || e.l & CONFIG_SLOT_NODE && GlobalQueue.k?.(e);
136
+ }
137
+
138
+ function applyGuesses(e) {
139
+ let n = null;
140
+ for (let s = 0; s < pendingGuesses.length; s += 3) {
141
+ const t = pendingGuesses[s];
142
+ const l = pendingGuesses[s + 1];
143
+ let r = true;
144
+ // The frame already holding the slot: a guess over it is a second
145
+ // suggestion for the slot, and two cannot finish apart (A34 (1)) — the
146
+ // frames entangle.
147
+ let u = null;
148
+ if (t.l & CONFIG_OVERRIDE) {
149
+ // A lane's node already: a guess re-asked, or a derivation guessed
150
+ // over (its staging is void — the guess is the value now). The same
151
+ // value re-asked renews the question; nothing to notify.
152
+ r = !t.je || !t.je(laneValueOf(t), l);
153
+ if (!(t.l & CONFIG_GUESS)) {
154
+ t.ue = NOT_PENDING;
155
+ t.l |= CONFIG_GUESS;
156
+ }
157
+ t.T.V = l;
158
+ u = txOf(t)._parent;
159
+ } else {
160
+ let s;
161
+ // A held node: a truth staged there, or what a corrected guess showed.
162
+ // The guess composes on it, so it ends with that hold — and with its
163
+ // own frame's (F-11): it lands only when both have (the board's rapid
164
+ // adds — a later add's row reverted with an earlier add's landing).
165
+ if (t.l & CONFIG_HELD) s = newLane(u = txOf(t)); else {
166
+ if (e === null && inFlight(t)) e = newTransaction(false);
167
+ if (e === null) continue;
168
+ s = n ??= newLane(e);
169
+ }
170
+ // (A guess equal to a truth staged beneath it is confirmed at birth —
171
+ // A24 — and still re-derives its readers as the lane's: the truth's
172
+ // derivations are the transaction's world, the lane's are the
173
+ // screen's plus the guess (plan sec. 19) — a derivation reading a held write
174
+ // beside the guess must not show it. Two flights for one input, when
175
+ // the worlds coincide, is the price.)
176
+ ext(t).V = l;
177
+ t.l |= CONFIG_OVERRIDE | CONFIG_GUESS;
178
+ list(t, s);
179
+ }
180
+ if (e !== null && u !== null) merge(e, u);
181
+ ext(t).Ie = pendingGuesses[s + 2];
182
+ if (r) {
183
+ // The lane's members re-derive as its work (REACTIVE_LANE_DIRTY): a
184
+ // blocked lane's re-guess does not re-run its render effects as stale
185
+ // readers republishing the committed view (#3460).
186
+ insertSubs(t);
187
+ laneDirty(t, txOf(t));
188
+ }
189
+ }
190
+ pendingGuesses.length = 0;
191
+ }
192
+
193
+ /** The running pass read lane `l`'s work as a derivation: it is `l`'s — or,
194
+ * already another lane's, the frame it computes derives from both guesses
195
+ * and cannot show one without the other (#3335, A15 for lanes): the two
196
+ * lanes are linked — one reveal unit, each blocked while any is — while
197
+ * their lifetimes stay their own (#2912: a guess reverts with its own
198
+ * action, not with the one it shares a reader with). A nested lane reading
199
+ * through an ancestor's guess stays its own (the screen plus its own
200
+ * guesses). */ function enterLane(e, n) {
201
+ const s = n.R |= REACTIVE_LANE_READ, t = passLane;
202
+ if (t === null) {
203
+ const t = e._parent.it === e;
204
+ // A verdict lane's value (a memo of `latest` / `isPending`, F-6) read by
205
+ // a derivation that already read the frame's staging or joined its
206
+ // hold, or by any pass a pass that did is creating: the verdict read
207
+ // does not break it out — it stays the frame's, as the same read inline
208
+ // does (verdict.ts `markVerdictReader`, `route`; D-25, D-26). An
209
+ // effect's own reads do not count (its `_type`, 1–3, carries neither bit).
210
+ if (!(t && creatorReads(n, n.i || s))) {
211
+ setPassLane(e);
212
+ // The pass read a held write before its first lane read (it joined the
213
+ // frame's future as mainline would): lane work sees the screen — the
214
+ // seam re-derives it on the committed world next round (`stagedReaders`,
215
+ // the park's repair), as it does a lane pass that read a staging. Not a
216
+ // pass whose held reads were all of nodes born held (no staged read,
217
+ // `stagedRead`): it has no committed world to re-derive on (#3969).
218
+ // (A pass not joined: a held write beside a guess, #4336; a leaf of a
219
+ // verdict lane — its plain reads are the screen's, D-26 `[s(), L()]`.)
220
+ if (s & REACTIVE_STAGED_READ && (guessed || t || s & REACTIVE_JOINED)) stagedRead(n);
221
+ }
222
+ } else if (sameLane(t, e)) setPassLane(e); else if (!under(t, e)) {
223
+ if (!under(e, t)) linkLanes(t, e);
224
+ setPassLane(e);
225
+ }
226
+ }
227
+
228
+ /** Is `l` nested under `a` (an ancestor lane)? */ function under(e, n) {
229
+ for (let s = e._parent; s !== null && s.V; s = s._parent) if (s === n) return true;
230
+ return false;
231
+ }
232
+
233
+ /** One link group (a shared array) for both lanes' groups. */ function linkLanes(e, n) {
234
+ const s = e.nn ?? (e.nn = [ e ]);
235
+ const t = n.nn;
236
+ if (t === s) return;
237
+ if (t === null) {
238
+ s.push(n);
239
+ n.nn = s;
240
+ } else for (let e = 0; e < t.length; e++) {
241
+ s.push(t[e]);
242
+ t[e].nn = s;
243
+ }
244
+ }
245
+
246
+ /** A linked lane blocked on its own account blocks the group — `blocked(k)`
247
+ * without the group recursion. (A guess in `k` whose own truth is in flight
248
+ * blocks `k`'s parent, not `k` — nor, through the link, `l`: the guess
249
+ * shows, A17.) */ function linkBlocked(e) {
250
+ const n = e.nn;
251
+ if (n !== null) for (let s = 0; s < n.length; s++) {
252
+ const t = n[s];
253
+ if (t !== e && (t.tt !== 0 || ownFlights(t) || nestedBlocked(t))) return true;
254
+ }
255
+ return false;
256
+ }
257
+
258
+ function unlink(e) {
259
+ const n = e.nn;
260
+ if (n === null) return;
261
+ const s = n.indexOf(e);
262
+ if (s !== -1) n.splice(s, 1);
263
+ e.nn = null;
264
+ }
265
+
266
+ /** Verdicts (maintainer, 2026-10-01): `isPending` and `latest` are
267
+ * optimistic state the system supplies — a verdict is a guess ("pending,
268
+ * until this lands"; "the proposal is the value") decided at the seam like
269
+ * a user's, and its readers break out of the hold the same way: work of a
270
+ * lane under the holder, shown now, re-derived at the landing, ending with
271
+ * it. Judged at the seam like any lane: blocked while a verdict reader's
272
+ * own derivation is in flight (lane rule 3), shown otherwise. */ function verdictLane(e) {
273
+ return e.it ??= newLane(e);
274
+ }
275
+
276
+ /** A lane pass's node (core.ts `recompute`, before its staging; a pending
277
+ * propagation under a lane pass, async.ts): listed, carrying the lane's
278
+ * value from now (a derivation of a guess — its readers become lane work).
279
+ * Entering the lane supersedes a frame staging the node carried: this
280
+ * pass's answer replaces it, and the frame's hold on it is over. An
281
+ * effect's value slot is private (no lane value). A pass in a lane's seat
282
+ * that read none of the lane's world has left it (false): its result is the
283
+ * frame's — a derivation whose branch no longer reaches the guess — and no
284
+ * hold the lane took over from a transaction stays on it (#3698: lane work
285
+ * never makes its node transaction work; a born-held effect's hold went to
286
+ * the lane). A pass interrupted before it got there (pending, errored) did
287
+ * not leave (A30: it never got there). A first pass under a lane is the
288
+ * lane's (ruling A); a guess is written, not derived — it never leaves this
289
+ * way. `errored`: the pass has no answer — or, a lane pass's pending
290
+ * propagation (async.ts `propagateStatus`), the node gone pending. */ function laneStage(e, n, s, t) {
291
+ if (!(s || t || e.R & REACTIVE_LANE_READ || e.l & CONFIG_GUESS)) {
292
+ const n = e.T;
293
+ if (n !== null) {
294
+ const s = n.Je;
295
+ if (s?.V) {
296
+ // Cleared before equality, so a return to the committed value
297
+ // notifies nobody. The seam wakes it (#3892) — always for a pass
298
+ // outside any transaction's flush: its value is the screen's now
299
+ // (#4367). While a transaction's flush runs the pass and the lane's
300
+ // frame is still held, what the screen shows stays the screen until
301
+ // the landing, and `_value` takes it (as `dissolveLane` keeps a shown
302
+ // lane's), so this pass's answer — the frame's — is a change against
303
+ // what is seen and reaches the screen with the frame's commit. (Only
304
+ // a lane is ever `_shown`.)
305
+ if (s.Nt) if (!flushTransaction || !blocked(resolveTx(s._parent))) e.R |= LEFT_SHOWN; else e.le = display(e);
306
+ n.Je = null;
307
+ }
308
+ n.V = NOT_PENDING;
309
+ }
310
+ e.l &= -1050881;
311
+ return false;
312
+ }
313
+ if (!e.i) {
314
+ if (!(e.l & CONFIG_OVERRIDE)) {
315
+ e.ue = NOT_PENDING;
316
+ e.l = e.l & -1048833 | CONFIG_OVERRIDE;
317
+ ext(e);
318
+ }
319
+ // A written guess whose own pass is the lane's work — its source is a
320
+ // derivation of another guess (a guess over `config().courier` under a
321
+ // country guess) — is confirmed or corrected by the lane: a derivation
322
+ // of the lane from here (its value the lane's, its fate the lane's), no
323
+ // longer a written guess. A pass with no answer (pending, errored)
324
+ // leaves the guess.
325
+ // Nor a pass of another action's guess: the re-ask is this lane's new
326
+ // question, which the guess (over the old one) does not answer — the
327
+ // lane waits for its own answer (F-1, F-6, #4336). (A guess of the
328
+ // lane's own action, D-33's entangled slot, still stands in.)
329
+ // (Read behind `guessed`: a bundle without optimism drops the reads.)
330
+ if (guessed && e.l & CONFIG_GUESS && e.T.Je?.V && resolveTx(e.T.Je._parent) !== resolveTx(n._parent)) take(e, n); else if (!t) e.l &= ~CONFIG_GUESS;
331
+ }
332
+ // A leaf has no lane value to seat it (`recompute`): one left waiting on
333
+ // the lane's flight runs its next pass as the lane's — the landing that
334
+ // wakes it is the lane's re-staging (A31), and the lane holds its render
335
+ // effects until its derivations land (A17; #3766, F5). Not a leaf whose
336
+ // seat is its frame's, reached by a propagation from a node the screen has
337
+ // a value of: one a transaction holds (born held — its frame waits on it,
338
+ // A29), or one whose own mainline pass is running (it pulled the node;
339
+ // `laneRead` decides — its frame holds). Its pending is the frame's: queued
340
+ // for the commit sweep as mainline's (async.ts). A node born in the lane
341
+ // has nothing on screen: its leaf waits as the lane's.
342
+ else if (t) {
343
+ if (t !== true && !(t.m & STATUS_UNINITIALIZED) && (e.l & CONFIG_HELD || e.R & REACTIVE_RECOMPUTING_DEPS) && !e.T?.Je?.V) {
344
+ queuePendingNode(e);
345
+ return false;
346
+ }
347
+ e.R |= REACTIVE_LANE_DIRTY;
348
+ }
349
+ list(e, n);
350
+ return true;
351
+ }
352
+
353
+ /** The truth arrived for a written guess (A18): a correction dissolves the
354
+ * lane — the guess and everything derived from it is void, the truth is
355
+ * the parent's held write and the graph re-derives from it there, one frame
356
+ * at the parent's landing — while the display keeps what it shows until
357
+ * then. A confirmation is silent (A17): the truth stays staged beneath the
358
+ * guess for the parent's commit, the guess stays the value; only a reader
359
+ * of the truth (CONFIG_AUTHORITATIVE) is told its view changed. Either way
360
+ * the parent takes this node, not the tick that carried the truth (D-33):
361
+ * one landing answering two actions' guesses (a store re-ask over two
362
+ * rows) must not tie them together; a pass that derives from the held
363
+ * truth joins the parent on its own (`joinPass`). */
364
+ /** The correction round is replacing a guess with the value it covered (no
365
+ * landing beneath it): observe's "reverted"; the lane gives back the
366
+ * guesses it took (#4336, `endLanes`). */ let reverting = false;
367
+
368
+ function supersede(e, n, s) {
369
+ const t = txOf(e);
370
+ // Resolved: the parent may have merged into another transaction since the
371
+ // lane opened (two actions guessing one slot entangle, A34 (1)) — the
372
+ // truth is held by the transaction that lands, not the merged-away one.
373
+ const l = resolveTx(t._parent ?? t);
374
+ // A store row answered by a new object the store would reconcile into
375
+ // the guessed one unchanged is an echo, not a correction (#3898): the
376
+ // server's object never matches the guess by reference.
377
+ if (s && e.l & CONFIG_SLOT_NODE && GlobalQueue.sn?.(e.T.V, n)) s = false;
378
+ if (s) {
379
+ // Observe: a displayed guess is being replaced by a differing truth — a
380
+ // landing's (superseded), or the value it covered (reverted: the body
381
+ // ended with nothing coming true).
382
+ if (t.Nt && attrHooks !== null) attrHooks.optimisticReverted(e, e.T.V, n, reverting ? "reverted" : "superseded");
383
+ dissolveLane(t, l, e);
384
+ if (guessed && reverting) reverted.add(t);
385
+ // What the screen showed stays the screen until the parent lands (A18
386
+ // (c): display and untracked reads keep the override until the commit).
387
+ if (t.Nt) e.le = e.T.V;
388
+ e.l &= -10241;
389
+ e.T.V = NOT_PENDING;
390
+ holdNode(e, l);
391
+ if (e.o !== null) insertSubs(e);
392
+ } else {
393
+ e.l |= CONFIG_HELD;
394
+ // A confirmation is silent (A17); only truth readers are told.
395
+ GlobalQueue.tn?.(t);
396
+ }
397
+ e.ue = n;
398
+ }
399
+
400
+ /** A lane's end, two ways. `into === null`: the parent landed — the lane's
401
+ * values are the truth now: a guess lands the truth staged beneath it or
402
+ * reverts to the one it covered (`_value`, untouched by the guess); a
403
+ * derivation's latest value commits (its frame with it); what the screen
404
+ * showed and changes notifies. Otherwise the lane dissolves into `into`
405
+ * (the parent, on a correction): its values are void — what it showed stays
406
+ * the screen (`_value` takes it, so the parent's re-derivation compares
407
+ * against what is seen), a truth staged beneath a guess is the parent's to
408
+ * land, and the runs it held (showing the void guess) are dropped: the
409
+ * parent's re-derivation makes the runs that show. */ function dissolveLane(e, n, s) {
410
+ const t = lanes.indexOf(e);
411
+ if (t !== -1) lanes.splice(t, 1);
412
+ unlink(e);
413
+ // Its verdicts end with it (a correction's dissolution reaches here before
414
+ // `endLanes` would): the readers re-derive from the truth's notification.
415
+ const l = e.it;
416
+ if (l !== null) {
417
+ e.it = null;
418
+ if (lanes.indexOf(l) !== -1) dissolveLane(l, null);
419
+ }
420
+ // First loads this dissolution leaves loading (below).
421
+ const r = [];
422
+ for (let t = 0; t < e.Ye.length; t++) {
423
+ const l = e.Ye[t];
424
+ const u = l.T;
425
+ if (l === s || u.Je !== e) continue;
426
+ const i = l.i;
427
+ const o = l.l & CONFIG_GUESS;
428
+ const E = u.V;
429
+ // What the screen shows of it (NOT_PENDING: nothing — a lane pass that
430
+ // errored or pends staged no value), and the lane's latest.
431
+ const a = e.Nt && !i ? E : l.le;
432
+ const f = laneValueOf(l);
433
+ u.V = NOT_PENDING;
434
+ l.l &= -10241;
435
+ if (n === null) {
436
+ // The parent landed: a guess lands the truth beneath it or reverts to
437
+ // the one it covered; a derivation's latest commits (its frame with
438
+ // it); what the screen showed and changes notifies. Observe: a
439
+ // displayed guess that lifts to something else — the truth staged
440
+ // beneath it (superseded by a landing held there) or the value it
441
+ // covered (reverted: nothing came true).
442
+ if (o && e.Nt && attrHooks !== null) {
443
+ const e = l.ue !== NOT_PENDING ? l.ue : l.le;
444
+ if (e !== E) attrHooks.optimisticReverted(l, E, e, l.ue !== NOT_PENDING ? "superseded" : "reverted");
445
+ }
446
+ // A derivation the revert re-derives (dirtied by the guess's
447
+ // notification — listed before it), or one still in flight, shows the
448
+ // lane's answer beside inputs that are the truth now: a fresh reader
449
+ // of its flight observes it (#3648, #3651; #3305's commit beneath a
450
+ // flight).
451
+ // Not a first load the lane produced nothing for whose own flight is
452
+ // up, nor one pending on such a load kept here (an identity memo of
453
+ // it, a derived store's derive): committing its empty `_value` would
454
+ // initialize it as `undefined`, which `latest()` would serve and
455
+ // `isPending()` call pending. It stays loading until its flight
456
+ // answers (D-22, A19 exc. 1; async-gen 3289 #929, 91501 #504, #156).
457
+ u.Je = null;
458
+ if (!i && !o) E === NOT_PENDING && (l.m & (STATUS_UNINITIALIZED | STATUS_PENDING)) === (STATUS_UNINITIALIZED | STATUS_PENDING) && (u.Ee || r.some(e => u.se?.has(e))) ? r.push(l) : l.ue = f;
459
+ commitPendingNode(l);
460
+ if (!i) {
461
+ if (l.R & (REACTIVE_IN_HEAP | REACTIVE_DIRTY | REACTIVE_CHECK) || l.m & STATUS_PENDING) l.l |= CONFIG_INPUTS_PUBLISHED;
462
+ if (a !== NOT_PENDING && (!l.je || !l.je(a, l.le))) insertSubs(l);
463
+ }
464
+ // A stale reader's own error — its pass (a memo's or a render
465
+ // effect's) threw over the committed value of what the parent held
466
+ // (A10), served as the screen — is no answer of the world landing now:
467
+ // it re-derives on it (A15; D-39, the landing is the new answer). The
468
+ // landing's `reruns` skips an errored reader: its error is an errored
469
+ // source's (#3945).
470
+ if (l.R & REACTIVE_FRAME_READ && l.m & STATUS_ERROR && u.U.source === l) enqueueSub(l);
471
+ } else if (o) {
472
+ // A guess of a dissolving lane: its truth — a landing held beneath it,
473
+ // else the value it covered — is the parent's to land, and its readers
474
+ // re-derive from it there. What the screen showed stays the screen
475
+ // until then (A18 (c)).
476
+ if (l.ue === NOT_PENDING) l.ue = covered(l);
477
+ if (e.Nt) l.le = E;
478
+ holdNode(l, n);
479
+ insertSubs(l);
480
+ } else {
481
+ // A correction: the lane's derivations are void. Shown, what the
482
+ // screen showed stays the screen (committed, inputs published — every
483
+ // one re-derives); never shown, nothing of it reached the screen (a
484
+ // node born in the lane stays uninitialized; its frame goes). One in
485
+ // flight is asking the void world's question: its landing is nobody's
486
+ // answer — it re-asks from the truth (whose notification may not reach
487
+ // it: an input's truth equal to its committed value is silent).
488
+ u.Je = null;
489
+ if (!i) {
490
+ if (a !== NOT_PENDING && e.Nt) l.ue = a;
491
+ if (l.m & STATUS_PENDING) {
492
+ u.Ee = null;
493
+ enqueueSub(l);
494
+ }
495
+ }
496
+ if (e.Nt) {
497
+ commitPendingNode(l);
498
+ if (!i) l.l |= CONFIG_INPUTS_PUBLISHED;
499
+ } else {
500
+ if (u.ft !== null || u.Tt !== null) GlobalQueue.et(l, false, true);
501
+ l.l &= -1048961;
502
+ }
503
+ }
504
+ }
505
+ // The parent landed: the runs the lane held (blocked on its own judgment
506
+ // alone — a zombie it could not dispose) are the landing's. A correction
507
+ // of a SHOWN lane keeps its runs too: "what it showed stays the screen"
508
+ // means the runs this round's lane passes queued (the body-end seam judges
509
+ // before the lane seam would have released them) must reach the screen —
510
+ // their derivations' values are the committed ones now, and a
511
+ // re-derivation that lands on the same value notifies nobody (a mapArray
512
+ // whose rows the lane pass already built). A never-shown lane's runs are
513
+ // void: nothing of it reached the screen. So are the runs a blocked lane
514
+ // parked: they show a re-guess the seam never revealed, beside derivations
515
+ // that keep what the screen showed.
516
+ if (n === null || e.Nt && !e.ln) releaseQueues(e); else e.rn[0].length = e.rn[1].length = 0;
517
+ }
518
+
519
+ /** Lanes. A lane's node is read by its reader's kind: an authoritative
520
+ * reader (`until`) sees the truth — staged beneath a guess, else committed
521
+ * — and is no lane's; an untracked read sees the lane's latest value (A17:
522
+ * "direct read shows optimistic"; A28); a children-forbidden reader sees
523
+ * the frame (A32). A render effect in the frame's seat reading a lane the
524
+ * seam found blocked, or a member whose own flight is up (held or not — the
525
+ * lane-membership ruling, 2026-10-05), sees the screen, re-derived at the
526
+ * reveal (#3460's stale reader) — or, the node a
527
+ * flight that has never shown (nothing to show), waits on it: its own frame
528
+ * holds (A15, #3334), not the lane's parent. Any other tracked reader is
529
+ * the lane's work from this read — a derivation; a leaf reading a lane that
530
+ * has shown, or one the seam has not judged yet (its run waits on the
531
+ * verdict: released if the lane shows, held if it blocks) — and sees the
532
+ * lane's latest. NOT_PENDING falls through: lane work's read of a pending
533
+ * member throws like any. A verdict reader entering a lane the seam has
534
+ * not judged reads ahead of it like a staging read: if the seam holds the
535
+ * lane, the pass re-derives on the screen (`entered`, #4284) — `latest()`
536
+ * beside the lane's nodes tears ahead of the hold however the reads are
537
+ * grouped into effects. */ function laneRead(e, n) {
538
+ const s = n.l & CONFIG_GUESS;
539
+ const t = txOf(n);
540
+ // A lane a correction folded under (D-34): store/optimistic.ts reads it.
541
+ // Before the authoritative arm: an `until` outside the lane reads the
542
+ // same truth there, and joins the hold it folded into — its posture over
543
+ // a foreign hold (D-31), which the truth read alone would not take.
544
+ const l = e !== null && t.folded;
545
+ if (l) {
546
+ const s = l(e, n);
547
+ if (s !== NOT_PENDING) return s;
548
+ }
549
+ if (e !== null && e.l & CONFIG_AUTHORITATIVE) return GlobalQueue.un(n);
550
+ const r = n.m;
551
+ // An errored member's lane value predates its error; the error is the answer (#4106).
552
+ if (!s && r & STATUS_ERROR) return NOT_PENDING;
553
+ if (e === null) return laneValueOf(n);
554
+ const u = !s && r & STATUS_PENDING;
555
+ if (!tracking || e.l & CONFIG_CHILDREN_FORBIDDEN) {
556
+ // An untracked read inside lane work derives from the lane like a
557
+ // tracked one, minus the subscription — `untrack` is about
558
+ // dependencies, not about which world a pass derives from (a mapper's
559
+ // row reads under its root, store/map): the pass enters the lane (two
560
+ // lanes read by one pass link, as for tracked reads). Outside lane
561
+ // work, the screen.
562
+ if (passLane === null || e.l & CONFIG_CHILDREN_FORBIDDEN) return display(n);
563
+ } else if (e.i === EFFECT_RENDER) {
564
+ // A flight whose value has never shown: nothing to show — the leaf
565
+ // waits on it, and its own frame holds (A15, #3334), not the lane's
566
+ // parent. The landing lands the frame: its own pass (the flush joined
567
+ // its transaction) reads the answer it waited on — the lane's staging,
568
+ // revealed at this seam.
569
+ const l = u && n.T.V === NOT_PENDING;
570
+ // D-28: a leaf a verdict read moved into the lane still throws on such
571
+ // a flight — the pass leaves the lane, and its frame holds as if the
572
+ // read had come first (S-39, #4275). Nor does a verdict lane's seat carry
573
+ // the leaf into another lane (no link): it reads that lane as from the
574
+ // frame's seat (#4284).
575
+ if ((l || passLane !== t) && passLane?._parent.it === passLane) setPassLane(null);
576
+ if (passLane === null || !sameLane(passLane, t)) {
577
+ // (A lane that has never shown: the screen is the committed value.)
578
+ if (l && t.Nt) return NOT_PENDING;
579
+ if (!s && n.ue !== NOT_PENDING && e.l & CONFIG_HELD && flushTransaction !== null && resolveTx(flushTransaction) === txOf(e)) return n.ue;
580
+ if (t.ln || u) {
581
+ // Re-derived at the reveal; once per pass (the pass may also be a stale
582
+ // reader of a transaction, REACTIVE_FRAME_READ — both reruns apply).
583
+ // Before the throw below: a leaf that waits on a lane that has never
584
+ // shown has no flight to settle it — only the reveal re-derives it,
585
+ // and its pending holds its frame until then (#4338).
586
+ if (!(e.R & REACTIVE_SCREEN_READ)) {
587
+ e.R |= REACTIVE_FRAME_READ | REACTIVE_SCREEN_READ;
588
+ t.En.push(e);
589
+ }
590
+ // Nothing on screen yet (uninitialized: `display` is NOT_PENDING).
591
+ const s = display(n);
592
+ if (s === NOT_PENDING) throw new NotReadyError(null);
593
+ return s;
594
+ }
595
+ // A verdict reader reads ahead of the seam's verdict: re-derived on the
596
+ // screen if the lane holds (#4284).
597
+ if (e.l & CONFIG_VERDICT && t._parent.it !== t) entered.push(e);
598
+ }
599
+ }
600
+ enterLane(t, e);
601
+ return u ? NOT_PENDING : laneValueOf(n);
602
+ }
603
+
604
+ /** The value a guess covered: the node's committed value — a store slot's
605
+ * asked of the store (a chained link follows the inner store's commits). */ function covered(e) {
606
+ return e.l & CONFIG_SLOT_NODE && GlobalQueue.an !== undefined ? GlobalQueue.an(e) : e.le;
607
+ }
608
+
609
+ /** A guess in `l` whose own truth is in flight (its refetch — authoritative:
610
+ * the landing supersedes, not the body's end). */ function guessFlights(e) {
611
+ for (let n = 0; n < e.Ye.length; n++) {
612
+ const s = e.Ye[n];
613
+ if (s.l & CONFIG_GUESS && s.T.Je === e && inFlight(s)) return true;
614
+ }
615
+ return false;
616
+ }
617
+
618
+ /** The seam's verdict on a lane. Blocked — its own flight is up — nothing
619
+ * moves: the screen keeps what it shows, the lane's runs wait. Unblocked,
620
+ * the lane shows: its values are the screen from now (`_shown`), the
621
+ * staging its passes made since the last reveal is promoted, their frames
622
+ * (children) apply, the stale readers re-derive (#3460), its runs go. */
623
+ /** A18 body-end corollary (#3427), at the seam before the park decision
624
+ * (the guesses' own passes have run; a correction's re-derivations run in
625
+ * one more pure round and are the parent's flights before it is judged —
626
+ * #3409: the indicators clear together): the action body having returned,
627
+ * a guess whose own truth is not in flight has no answer coming — the truth
628
+ * beneath it is its truth, and the correction starts now rather than at the
629
+ * lane's flight. (A guess whose own refetch is up is superseded by its
630
+ * landing.) True when a lane was judged. */ function laneCorrections() {
631
+ let e = false;
632
+ const n = lanes.slice();
633
+ for (let s = 0; s < n.length; s++) {
634
+ const t = n[s];
635
+ if (lanes.indexOf(t) === -1) continue;
636
+ const l = resolveTx(t._parent);
637
+ if (!l.nt || l.tt !== 0 || l.V || ownFlights(l) || guessFlights(t)) continue;
638
+ e = true;
639
+ // Each guess's truth: the one beneath it (a landing held there), else
640
+ // the one it covered. (A correction dissolves the lane — the others are
641
+ // re-homed with theirs, `dissolveLane`.)
642
+ for (let e = 0; e < t.Ye.length && lanes.indexOf(t) !== -1; e++) {
643
+ const n = t.Ye[e];
644
+ if (n.l & CONFIG_GUESS && n.T.Je === t) {
645
+ const e = n.ue !== NOT_PENDING ? n.ue : covered(n);
646
+ reverting = n.ue === NOT_PENDING;
647
+ supersede(n, e, !n.je || !n.je(n.T.V, e));
648
+ reverting = false;
649
+ }
650
+ }
651
+ }
652
+ return e;
653
+ }
654
+
655
+ function laneSeam(e, n) {
656
+ // Blocked — or one of its passes read a write the frame holds this seam:
657
+ // its runs wait, the pass re-derives on the screen next round.
658
+ if (n || blocked(e)) {
659
+ e.ln = true;
660
+ return;
661
+ }
662
+ e.ln = false;
663
+ e.Nt = true;
664
+ if (reruns(e)) revealing.push(resolveTx(e._parent));
665
+ for (let n = 0; n < e.Ye.length; n++) {
666
+ const s = e.Ye[n];
667
+ if (s.R & LEFT_SHOWN) {
668
+ s.R ^= LEFT_SHOWN;
669
+ insertSubs(s);
670
+ }
671
+ const t = s.T;
672
+ if (t.Je !== e) continue;
673
+ if (!(s.l & CONFIG_GUESS) && !s.i && s.ue !== NOT_PENDING) {
674
+ t.V = s.ue;
675
+ s.ue = NOT_PENDING;
676
+ }
677
+ // The frame this pass built is the screen's now; the one it replaced
678
+ // goes (as `commitPendingNode` retires a committed pass's).
679
+ if (t.ft !== null || t.Tt !== null) GlobalQueue.et(s, false, true);
680
+ s.l &= ~CONFIG_STAGED;
681
+ }
682
+ releaseQueues(e);
683
+ }
684
+
685
+ /** The parent landed: its lanes end, nested first. (None is blocked: a
686
+ * blocked lane blocks its parent.) */ function endLanes(e) {
687
+ // A revert landing (#4336): the guesses its lane took from another action
688
+ // that is still out come back in this frame, over the truth it lands —
689
+ // its readers re-derive with the landing (one frame, no bare truth
690
+ // between). Taken by a later lane since, a node stays that lane's.
691
+ if (guessed) for (let n = kept.length - 5; n >= 0; n -= 5) if (resolveTx(kept[n + 4]._parent) === e) {
692
+ let [s, t, l, r, u] = kept.splice(n, 5);
693
+ // (A store slot's node now: the one taken, or a read's since.)
694
+ if (reverted.has(u) && lanes.includes(l) && (!(s.l & CONFIG_SLOT_NODE) || (s = GlobalQueue.fn(s, true)))) {
695
+ const n = ext(s);
696
+ if (n.Je === null || txOf(s) === e) {
697
+ commitPendingNode(s);
698
+ n.V = t;
699
+ n.Ie = r;
700
+ s.l |= CONFIG_OVERRIDE | CONFIG_GUESS;
701
+ list(s, l);
702
+ rerun(s, e);
703
+ }
704
+ }
705
+ }
706
+ for (let n = lanes.length - 1; n >= 0; n--) {
707
+ const s = lanes[n];
708
+ if (resolveTx(s._parent) !== e) continue;
709
+ endLanes(s);
710
+ dissolveLane(s, null);
711
+ }
712
+ }
713
+
714
+ /** A blocked lane blocks its parent (maintainer, 2026-10-01): the lane's
715
+ * pending work derives from the frame's write through the guess, so the
716
+ * frame is not complete without it (A15) — landing it would commit the write
717
+ * beside a derivation still showing the old one. A guess whose own flight is
718
+ * up likewise: the question was asked in this frame. */ function lanesBlocked(e) {
719
+ return e.V && linkBlocked(e) || nestedBlocked(e);
720
+ }
721
+
722
+ /** Parents whose lane revealed this seam with readers to re-derive there
723
+ * (`laneSeam`): the lane shows ahead of its parent (F-6), so the parent lands
724
+ * a round later — after those readers have shown the lane's answer — even
725
+ * when nothing else holds it (#4393). */ const revealing = [];
726
+
727
+ /** The lanes under `t` (its own; a link group's are each other's). */ function nestedBlocked(e) {
728
+ if (revealing.indexOf(e) !== -1) return true;
729
+ for (let n = 0; n < lanes.length; n++) {
730
+ const s = lanes[n];
731
+ if (resolveTx(s._parent) !== e) continue;
732
+ if (blocked(s) || guessFlights(s)) return true;
733
+ }
734
+ return false;
735
+ }
736
+
737
+ /** A write landing on a lane's node (core.ts `setSignal`: a user's write, an
738
+ * async landing). On a guess it is its truth (A18 — an async guess's own
739
+ * landing), judged against the guess. On a derivation it is the lane's
740
+ * latest: its staging once the lane has shown (promoted at the next
741
+ * reveal), its slot before; the lane's members re-derive as its work. */ function laneWrite(e, n) {
742
+ // (A store slot's guess its derive's re-ask in another action's lane
743
+ // writes is that lane's derivation from here — store `_slotTake`, #4336.)
744
+ if (e.l & CONFIG_GUESS && !(guessed && GlobalQueue.fn?.(e))) {
745
+ // Provenance (A18, #3331; Q-D, plan sec. 39): a write asking an OLDER
746
+ // question than the guess's — another action's landing beneath it —
747
+ // is not its answer: held beneath (the truth for the commit; the
748
+ // guess's own question judges), and nothing moves. The writer's
749
+ // question is the one being asked (`question`: a slice's, a derive's
750
+ // continuation's — the flight's); unstamped writes and mainline are
751
+ // current.
752
+ // A store re-bases a keyed arrangement guess over an older truth, and
753
+ // folds a current one beneath it (D-34): true.
754
+ const s = stale(e, question);
755
+ if (GlobalQueue.Nn?.(e, n, s) || s) {
756
+ e.ue = n;
757
+ e.l |= CONFIG_HELD;
758
+ schedule();
759
+ return n;
760
+ }
761
+ supersede(e, n, !e.je || !e.je(e.T.V, n));
762
+ } else {
763
+ const s = txOf(e);
764
+ if (e.je && e.je(laneValueOf(e), n)) return n;
765
+ if (s.Nt) e.ue = n; else e.T.V = n;
766
+ if (e.X !== undefined) e.ie = clock;
767
+ insertSubs(e);
768
+ laneDirty(e, s);
769
+ }
770
+ schedule();
771
+ return n;
772
+ }
773
+
774
+ /** A written guess's own pass finished: its source recomputed it — the
775
+ * truth (A18: "the source is whatever recomputes the node"), authoritative
776
+ * or the lane's own derivation (a guess over `config().courier` under a
777
+ * country guess: the lane's config landing confirms or corrects it). An
778
+ * errored pass stages nothing. Provenance (A18, #3331): "the source" is the
779
+ * guess's own question or a newer one; an older action's answer landing
780
+ * over a newer guess (the two entangled when the newer guess was written)
781
+ * is stale — a slow source leaking back in over the user's latest intent.
782
+ * It is staged beneath the guess, for the commit like any landing, and
783
+ * nothing moves: no downstream re-ask, no pending flip on the guess's
784
+ * readers (`isPending` of the guess itself says the held truth differs,
785
+ * A24). The guess's own question answering supersedes as usual. */ function laneOutcome(e, n, s) {
786
+ if (s) return true;
787
+ if (stale(e, answered(e))) {
788
+ e.ue = n;
789
+ e.l |= CONFIG_HELD;
790
+ return true;
791
+ }
792
+ supersede(e, n, !e.je || !e.je(e.T.V, n));
793
+ return true;
794
+ }
795
+
796
+ /** THE provenance test, for a derivation's pass and a write alike: an
797
+ * answer to question `q` landing on a guess is stale when `q` is older
798
+ * than the guess's own; unstamped (0) and mainline are current. */ function stale(e, n) {
799
+ return n !== 0 && n < e.T.Ie;
800
+ }
801
+
802
+ /** The question a derivation's pass answered: the newest among the stamped
803
+ * sources that changed this round (a flight's landing carries the question
804
+ * that started it); 0 when none is stamped. */ function answered(e) {
805
+ let n = 0;
806
+ for (let s = e.C; s !== null; s = s.G) {
807
+ const e = s.S;
808
+ if (e.T !== null && e.T.Ie > n && e.ie === clock) n = e.T.Ie;
809
+ }
810
+ return n;
811
+ }
812
+
813
+ /** The lanes alive before this seam's guesses opened theirs (a prefix of
814
+ * `lanes`; nothing dissolves one between here and the seam loop): a lane
815
+ * born at the seam has no work to judge yet (its passes run next round) —
816
+ * it is neither shown nor blocked until it has. */ let judged = 0;
817
+
818
+ const applyGuessesAt = e => {
819
+ judged = lanes.length;
820
+ if (pendingGuesses.length !== 0) applyGuesses(e);
821
+ };
822
+
823
+ /** `t` is parked by `r`'s pass alone: each node keeping it — `t`'s own, or
824
+ * a lane's under it — is `r` itself (its flight, in the verdict lane) or a
825
+ * render effect pending on `r` only: the frame observing the lane work that
826
+ * read its staging. Anything else (an open action, a guess's flight,
827
+ * another flight) holds it on its own. */ function heldBy(e, n) {
828
+ if (e.tt !== 0 || e.V && linkBlocked(e)) return false;
829
+ for (let s = -1, t = e; t; t = lanes[++s]) if (t === e || resolveTx(t._parent) === e) {
830
+ if (t !== e && guessFlights(t)) return false;
831
+ for (let e = 0; e < t.Ye.length; e++) {
832
+ const s = t.Ye[e];
833
+ if (s === n || !(s.m & STATUS_PENDING) || s.T.Je !== null && txOf(s) !== t) continue;
834
+ const l = s.T.se;
835
+ if (s.i !== EFFECT_RENDER || l?.size !== 1 || !l.has(n)) return false;
836
+ }
837
+ }
838
+ return true;
839
+ }
840
+
841
+ const laneSeams = e => {
842
+ // Passes that read a write the parked frame holds as the screen
843
+ // (`stagedReaders`: lane work, a verdict reader before the verdict): they
844
+ // re-derive on the committed world next round (and register as stale
845
+ // readers of the transaction there); a lane's runs wait that round — a
846
+ // lane sees the screen plus its own guesses.
847
+ if (revealing.length) revealing.length = 0;
848
+ const n = [];
849
+ if (e !== null) for (let s = 0; s < stagedReaders.length; s++) {
850
+ const t = stagedReaders[s],
851
+ // A pass no transaction holds that read the frame's staging (an
852
+ // effect, a `[s(), latest(s)]` reader watched before the frame had
853
+ // a transaction): judged by the frame's — it re-derives only if the
854
+ // frame stays parked; landing here, what it read is the screen (one
855
+ // run, D-22).
856
+ l = t.T?.Je || (t.R & REACTIVE_STAGED_READ ? e : null);
857
+ // A verdict reader a later read of the same pass routed into a verdict
858
+ // lane answered for itself: it re-derives at the holder's landing, not
859
+ // now (one run — #3322, #3540). Other verdict-lane work re-derives only
860
+ // if the frame stays parked: a transaction landing at this seam makes
861
+ // what it read the screen (one run). The frame is the transaction that
862
+ // holds what it read (`t`, this flush's — not always the lane's parent:
863
+ // a landing that reached a frame held elsewhere joined that one). Nor
864
+ // when only this pass keeps it parked (`heldBy`): the frame lands with
865
+ // the pass's answer, so what the pass read is the screen when anything
866
+ // shows it — re-derived on the committed world, it would ask a question
867
+ // already asked, over inputs the landing replaces. A reader a
868
+ // transaction holds that read none of its stagings (a verdict reader
869
+ // that probed only a flight, held as the frame's pending observer or
870
+ // its staged derivation) has nothing to re-derive: its re-run
871
+ // re-enters that transaction and parks it again, every round — it
872
+ // runs at the landing (#4349). One that read a staging re-derives only
873
+ // if its frame stays parked: landing at this seam, what it read is the
874
+ // screen (one run, D-22). Not one born into that frame (a held pass's
875
+ // child, ruling A): it has no screen, its reads are the transaction's
876
+ // either way — it runs again at the landing, not now.
877
+ if (t.R & REACTIVE_DISPOSED || (l?.V ? l._parent?.it === l && (t.l & CONFIG_VERDICT ? !(t.R & REACTIVE_PROBE_UNANSWERED) : !blocked(e) || heldBy(e, t)) : l && !(t.R & REACTIVE_PROBE_UNANSWERED || t.R & REACTIVE_STAGED_READ && blocked(l) && !bornInto(t, l)))) continue;
878
+ // A leaked effect re-derives seated in its lane from its first read: it
879
+ // carries no lane value (`laneStage`), so without this its pass starts
880
+ // as mainline, joins the parked frame on its first held read and reads
881
+ // the staging, then re-enters the lane at its guess read and leaks
882
+ // again — every round (#4014). A computed is already seated by its
883
+ // override, and a written guess's own pass stays the frame's.
884
+ if (l?.V && t.i) t.R |= REACTIVE_LANE_DIRTY;
885
+ // R5 for an async reader: its frame pass asked the frame's question
886
+ // (F-6's lane gets its own pass now). That flight is the frame's
887
+ // answer: the landing adopts it rather than asking it again (F-9: a
888
+ // re-ask of the same question is no new question; `reruns`). A frame
889
+ // landing at this seam has nothing to re-derive: the pass was the
890
+ // landing's, its flight the screen's answer. Sync or async, the
891
+ // reader's lane pass is still to come: the verdict lane it joins does
892
+ // not reveal this seam (F-6: the lane's readers show its answer
893
+ // together, D-23: atomic with the value) — revealed now, it showed a
894
+ // verdict beside the frame pass's value, before the pass that answers
895
+ // for the lane, and a reader of the re-derived memo read it outside
896
+ // the shown lane and waited for the frame (#4393).
897
+ else if (!l?.V && t.R & REACTIVE_PROBE_UNANSWERED) {
898
+ if (isThenable(t.T?.Ee)) {
899
+ if (!blocked(e)) continue;
900
+ t.T.rt = t.T.Ee;
901
+ } else if (blocked(e))
902
+ // A sync reader's lane pass re-derives the async memos over it (a
903
+ // memo over a verdict memo is a verdict reader, D-25 #4050; D-22:
904
+ // `latest()` extracted into a memo reads as inline). The flight
905
+ // each asked over its frame staging, up and held by `t`, is the
906
+ // frame's answer too: the landing adopts it (F-9).
907
+ for (let n = t.o, s; n; n = n.t) if (isThenable((s = n.u).T?.Ee) && s.T.se?.has(s) && s.l & CONFIG_HELD && txOf(s) === e) s.T.rt = s.T.Ee;
908
+ if (e?.it && n.indexOf(e.it) === -1) n.push(e.it);
909
+ }
910
+ enqueueSub(t);
911
+ if (l?.V && n.indexOf(l) === -1) n.push(l);
912
+ }
913
+ // A verdict lane born at this seam is judged with it: it exists only once
914
+ // a pass routed into it — the park seam's zombie verdict readers re-run
915
+ // as its work so that this seam reveals them (#3444).
916
+ for (let e = lanes.length - 1; e >= 0; e--) if (e < judged || lanes[e]._parent?.it === lanes[e]) laneSeam(lanes[e], n.indexOf(lanes[e]) !== -1);
917
+ // A verdict reader that entered a lane this seam held: its run waits with
918
+ // the lane, and the verdict beside it would freeze — it re-derives next
919
+ // round from the frame's seat, a stale reader of the lane (#4284).
920
+ for (let e; e = entered.pop(); ) if (e.T.Je?.ln) {
921
+ e.R &= ~REACTIVE_LANE_DIRTY;
922
+ enqueueSub(e);
923
+ }
924
+ };
925
+
926
+ /** The landing's re-derive of a reader whose frame flight the seam parked
927
+ * (R5): the flight asked the question the landing would — adopted, it is
928
+ * asked once (F-9). Not over a pass already queued: that one asks anew.
929
+ * Registered as if this pass had returned it — the node pending on it, its
930
+ * landing the answer — through a promise of its own: the frame pass's
931
+ * registration still listens to the flight, and must not land it a second
932
+ * time. */ const adoptParked = e => {
933
+ const n = e.T?.rt;
934
+ if (!n || e.R & (REACTIVE_DIRTY | REACTIVE_CHECK | REACTIVE_IN_HEAP)) return false;
935
+ e.T.rt = undefined;
936
+ releaseFlightTeardown(e);
937
+ try {
938
+ handleAsync(e, n.then());
939
+ } catch {}
940
+ e.T.fe = true;
941
+ notifyStatus(e, STATUS_PENDING, new NotReadyError(e));
942
+ return true;
943
+ };
944
+
945
+ /** A15: lane work or a verdict reader was served `el`'s committed value
946
+ * (core.ts `frameRead`), so its pass does not wait on `el`'s flight: what
947
+ * `el`'s pending propagated onto it before the pass (its origins, `el`
948
+ * included) is not this pass's — the landing re-derives it (`reruns`).
949
+ * Kept, a pass that went pending on another source never woke when that
950
+ * source settled (#4397). Only a reader something made pending has anything
951
+ * to drop. */ const laneServed = (e, n) => {
952
+ const s = n.T?.se;
953
+ if (s && e.T?.se) for (const n of s) removePendingSource(e, n);
954
+ };
955
+
956
+ /** Render effects that read a verdict and entered a lane before its seam (#4284). */ const entered = [];
957
+
958
+ installLaneHooks(laneRead, laneStage, laneOutcome, laneWrite, applyGuessesAt, laneSeams, () => lanes.length !== 0 && laneCorrections(), endLanes, lanesBlocked, adoptParked, laneServed);
959
+
960
+ GlobalQueue.xe = e => {
961
+ const n = [];
962
+ for (let s = 0; s < lanes.length; s++) {
963
+ const t = lanes[s];
964
+ if (resolveTx(t._parent) !== e) continue;
965
+ for (let e = 0; e < t.Ye.length; e++) if (t.Ye[e].l & CONFIG_GUESS && t.Ye[e].T.Je === t) n.push(t.Ye[e]);
966
+ }
967
+ return n;
968
+ };
969
+
970
+ GlobalQueue.J = verdictLane;
971
+
972
+ export { display, enterLane, guessedValueOf, laneRead, laneStage, laneValueOf, optimisticWrite, pendingGuessOf, supersede, take, verdictLane };