@solidjs/signals 2.0.0-rc.11 → 2.0.0-rc.14

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 (118) hide show
  1. package/dist/dev-shared.js +2056 -3773
  2. package/dist/dev.attribution.js +159 -91
  3. package/dist/dev.js +7263 -8384
  4. package/dist/observe/affects.js +125 -104
  5. package/dist/observe/boundaries.js +458 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +240 -383
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +271 -199
  10. package/dist/observe/core/constants.js +115 -178
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +840 -1428
  13. package/dist/observe/core/dev.js +41 -18
  14. package/dist/observe/core/effect.js +75 -86
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +61 -70
  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 +704 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +708 -1351
  22. package/dist/observe/core/verdict.js +302 -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 +133 -215
  28. package/dist/observe/store/affects.js +135 -0
  29. package/dist/observe/store/index.js +29 -24
  30. package/dist/observe/store/optimistic.js +538 -0
  31. package/dist/observe/store/projection.js +302 -0
  32. package/dist/observe/store/reconcile.js +257 -0
  33. package/dist/observe/store/store.js +1945 -277
  34. package/dist/observe/store/storePath.js +1 -1
  35. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  36. package/dist/observe/store/types.js +73 -0
  37. package/dist/observe/store/utils.js +1 -13
  38. package/dist/prod/affects.js +127 -106
  39. package/dist/prod/boundaries.js +442 -654
  40. package/dist/prod/core/action.js +71 -74
  41. package/dist/prod/core/async.js +307 -442
  42. package/dist/prod/core/constants.js +112 -177
  43. package/dist/prod/core/context.js +3 -3
  44. package/dist/prod/core/core.js +852 -1448
  45. package/dist/prod/core/effect.js +88 -99
  46. package/dist/prod/core/external.js +5 -5
  47. package/dist/prod/core/graph.js +61 -70
  48. package/dist/prod/core/heap.js +75 -98
  49. package/dist/prod/core/invariants.js +1 -32
  50. package/dist/prod/core/lanes.js +666 -181
  51. package/dist/prod/core/owner.js +75 -96
  52. package/dist/prod/core/scheduler.js +677 -1332
  53. package/dist/prod/core/verdict.js +297 -621
  54. package/dist/prod/flatten.js +77 -0
  55. package/dist/prod/index.js +15 -13
  56. package/dist/prod/map.js +143 -146
  57. package/dist/prod/reveal.js +212 -0
  58. package/dist/prod/signals.js +144 -226
  59. package/dist/prod/store/affects.js +135 -0
  60. package/dist/prod/store/index.js +28 -19
  61. package/dist/prod/store/optimistic.js +533 -0
  62. package/dist/prod/store/projection.js +295 -0
  63. package/dist/prod/store/reconcile.js +257 -0
  64. package/dist/prod/store/store.js +1840 -272
  65. package/dist/prod/store/storePath.js +1 -1
  66. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  67. package/dist/prod/store/types.js +73 -0
  68. package/dist/prod/store/utils.js +1 -11
  69. package/dist/types/affects.d.ts +11 -30
  70. package/dist/types/boundaries.d.ts +62 -176
  71. package/dist/types/carved.d.ts +1 -0
  72. package/dist/types/core/action.d.ts +5 -6
  73. package/dist/types/core/async.d.ts +10 -5
  74. package/dist/types/core/attribution-hooks.d.ts +48 -1
  75. package/dist/types/core/attribution.d.ts +29 -9
  76. package/dist/types/core/constants.d.ts +125 -171
  77. package/dist/types/core/core.d.ts +104 -264
  78. package/dist/types/core/dev.d.ts +60 -7
  79. package/dist/types/core/effect.d.ts +0 -7
  80. package/dist/types/core/graph.d.ts +7 -1
  81. package/dist/types/core/heap.d.ts +5 -7
  82. package/dist/types/core/index.d.ts +6 -6
  83. package/dist/types/core/invariants.d.ts +0 -29
  84. package/dist/types/core/lanes.d.ts +65 -87
  85. package/dist/types/core/owner.d.ts +3 -3
  86. package/dist/types/core/scheduler.d.ts +249 -331
  87. package/dist/types/core/types.d.ts +51 -85
  88. package/dist/types/core/verdict.d.ts +3 -0
  89. package/dist/types/flatten.d.ts +8 -0
  90. package/dist/types/index.d.ts +7 -5
  91. package/dist/types/reveal.d.ts +19 -0
  92. package/dist/types/signals.d.ts +53 -92
  93. package/dist/types/store/affects.d.ts +1 -0
  94. package/dist/types/store/index.d.ts +35 -15
  95. package/dist/types/store/optimistic.d.ts +23 -0
  96. package/dist/types/store/projection.d.ts +18 -0
  97. package/dist/types/store/reconcile.d.ts +3 -0
  98. package/dist/types/store/store.d.ts +165 -143
  99. package/dist/types/store/storePath.d.ts +1 -1
  100. package/dist/types/store/target.d.ts +151 -0
  101. package/dist/types/store/types.d.ts +84 -0
  102. package/package.json +1 -1
  103. package/dist/observe/core/optimistic.js +0 -669
  104. package/dist/observe/store/next/optimistic.js +0 -717
  105. package/dist/observe/store/next/projection.js +0 -266
  106. package/dist/observe/store/next/reconcile.js +0 -375
  107. package/dist/observe/store/next/store.js +0 -2480
  108. package/dist/prod/core/optimistic.js +0 -658
  109. package/dist/prod/store/next/optimistic.js +0 -710
  110. package/dist/prod/store/next/projection.js +0 -257
  111. package/dist/prod/store/next/reconcile.js +0 -373
  112. package/dist/prod/store/next/store.js +0 -2356
  113. package/dist/types/core/optimistic.d.ts +0 -6
  114. package/dist/types/store/next/optimistic.d.ts +0 -25
  115. package/dist/types/store/next/projection.d.ts +0 -27
  116. package/dist/types/store/next/reconcile.d.ts +0 -10
  117. package/dist/types/store/next/store.d.ts +0 -143
  118. package/dist/types/store/next/target.d.ts +0 -196
@@ -1,205 +1,690 @@
1
- import { CONFIG_DERIVED_OVERRIDE, CONFIG_HAS_LANE, REACTIVE_DISPOSED } from "./constants.js";
1
+ import { CONFIG_GUESS, NOT_PENDING, CONFIG_OVERRIDE, REACTIVE_DISPOSED, CONFIG_VERDICT, REACTIVE_PROBE_UNANSWERED, CONFIG_AUTHORITATIVE, CONFIG_CHILDREN_FORBIDDEN, STATUS_PENDING, EFFECT_RENDER, CONFIG_HELD, STATUS_UNINITIALIZED, REACTIVE_SCREEN_READ, REACTIVE_FRAME_READ, REACTIVE_LANE_READ, REACTIVE_RECOMPUTING_DEPS, REACTIVE_LANE_DIRTY, CONFIG_STAGED, REACTIVE_JOINED, CONFIG_SLOT_NODE, REACTIVE_IN_HEAP, REACTIVE_DIRTY, REACTIVE_CHECK, CONFIG_INPUTS_PUBLISHED } from "./constants.js";
2
2
 
3
- import { hasActiveOverride, ext, ownsHold, currentOptimisticLane } from "./core.js";
3
+ import { tracking, ext, stagedRead } from "./core.js";
4
+
5
+ import { NotReadyError } from "./error.js";
4
6
 
5
7
  import { enqueueSub } from "./heap.js";
6
8
 
7
- import { currentTransition, activeTransition, waitingTransition } from "./scheduler.js";
8
-
9
- // Map from optimistic signal to its lane (reused for multiple writes to same signal)
10
- const signalLanes = new WeakMap;
11
-
12
- // All active lanes (for cleanup on transition completion)
13
- const activeLanes = new Set;
14
-
15
- /**
16
- * Get an existing lane for a signal or create a new one.
17
- * Reuses lane for multiple writes to the same signal.
18
- */ function getOrCreateLane(n) {
19
- let e = signalLanes.get(n);
20
- if (e) {
21
- return findLane(e);
22
- }
23
- // Detect parent lane: _parentSource chains from pendingSignal → pendingValueComputed → original.
24
- // The child lane should not merge with the parent lane.
25
- const i = n.o?.kn;
26
- const t = i?.o?.me;
27
- const r = t ? findLane(t) : null;
28
- e = {
29
- ni: n,
30
- Qe: new Set,
31
- dn: [ [], [] ],
32
- ei: null,
33
- we: activeTransition,
34
- ii: r
35
- };
36
- signalLanes.set(n, e);
37
- activeLanes.add(e);
38
- // A companion may have written before the owner's first optimistic write
39
- // (affects() as an action's first statement pokes the verdict companion of a
40
- // still lane-less node, #2887), leaving its lane parentless. Adopt it now:
41
- // parent-child is a property of the nodes, not of write order — otherwise
42
- // the owner's write merges the companion's subscribers into this lane and
43
- // their effects wait on its async instead of flushing immediately.
44
- adoptCompanionLane(n.o?.Ze, e);
45
- adoptCompanionLane(n.o?.He, e);
46
- return e;
9
+ import { schedule, question, nextQuestion, GlobalQueue, blocked, txOf, passLane, sameLane, flushTransaction, resolveTx, queuePendingNode, list, clock, insertSubs, laneDirty, merge, newTransaction, reruns, releaseQueues, ownFlights, setPassLane, holdNode, joinFuture, commitPendingNode } from "./scheduler.js";
10
+
11
+ // Lanes (plan sec. 28 replay, 2026-10-02; maintainer rulings 2026-10-01/02). A lane
12
+ // is "a new base of a transition": the sub-frame an optimistic write opens
13
+ // in the transition of the frame it is made in. It sees the screen plus its
14
+ // own guesses (plan sec. 19), breaks out of the parent's hold — its effects run now —
15
+ // and holds itself if its own derivations hit async (and, blocked, holds its
16
+ // parent). It ends when the parent lands: a guess reverts to the truth it
17
+ // covered, or lands as the truth that superseded it. A frame that does not
18
+ // park has nothing to be optimistic over: the write is void.
19
+ // Three places per node, each meaning one thing always: `_value` is the
20
+ // committed truth, `_pendingValue` a transaction's staging (the future), and
21
+ // `_x._lane` the lane's value — a written guess or a lane pass's derivation.
22
+ // The lane carries the state machine: `_shown` once it has revealed. The
23
+ // screen shows a lane's value once the lane has shown (`display`); a direct
24
+ // read sees it throughout (A17); an authoritative reader (`until`) sees the
25
+ // truth beneath it (Q3, 2026-10-02: "optimistic overrides are intentionally
26
+ // not part of authoritative truth").
27
+ // The seat of a pass is its node's (core.ts `recompute`): a node carrying a
28
+ // lane's derived value runs as the lane's whoever dirtied it; a derivation's
29
+ // tracked read of a lane's value moves its pass into the lane (`enterLane`);
30
+ // a leaf's never does — it reads the screen, a stale reader of a lane that
31
+ // has not shown (#3460). Lane work's values go to the lane slot (or, once
32
+ // the lane has shown, to its staging for the next reveal), its runs to the
33
+ // lane's queues.
34
+ // This module is the lane engine, installed on `GlobalQueue` when something
35
+ // imports it (`createOptimistic`, or verdict.ts for its verdict lanes). The
36
+ // core keeps only bit tests and `passLane`: a program with no optimism
37
+ // carries none of this.
38
+ /** Live lanes (parented). Scanned at every seam while non-empty. */
39
+ const lanes = [];
40
+
41
+ function newLane(e) {
42
+ const n = newTransaction(true, e);
43
+ lanes.push(n);
44
+ return n;
45
+ }
46
+
47
+ /** A lane node's current value: its guess, or the latest it derived — the
48
+ * staging a shown lane holds for its next reveal, else its slot; the
49
+ * committed value while it has none (its first lane pass in flight). */ function laneValueOf(e) {
50
+ if (!(e.u & CONFIG_GUESS) && e.Ae !== NOT_PENDING) return e.Ae;
51
+ const n = e.m.Z;
52
+ return n !== NOT_PENDING ? n : e.pe;
47
53
  }
48
54
 
49
- function adoptCompanionLane(n, e) {
50
- if (!n) return;
51
- const i = signalLanes.get(n);
52
- if (!i) return;
53
- const t = findLane(i);
54
- // Only the companion's own unmerged root is safely re-parentable: a root
55
- // that absorbed other lanes carries work that is not a child of this owner.
56
- if (t !== e && t.ni === n && !t.ii) t.ii = e;
55
+ /** What the screen shows for a lane's node: the lane's value once the lane
56
+ * has revealed, the committed truth before. */ function display(e) {
57
+ const n = e.m.Z;
58
+ return e.m.ke.ve && n !== NOT_PENDING ? n : e.pe;
57
59
  }
58
60
 
59
- /**
60
- * Union-find: find the root lane.
61
- */ function findLane(n) {
62
- while (n.ei) n = n.ei;
61
+ /** Guesses written since the last seam (`[node, value, question, …]`).
62
+ * Applied at the seam, once the frame's verdict is known — the parent is
63
+ * the frame's transaction, and there is none to be optimistic over when the
64
+ * frame commits (the write is as if it never happened: nothing was
65
+ * applied). The lane's passes run in the next round of the same flush, so
66
+ * the guess is visible at flush like any write (A28). */ const pendingGuesses = [];
67
+
68
+ /** What the writer sees of a node: an unflushed guess to it, else the
69
+ * lane's value or the committed one — what an optimistic updater composes
70
+ * on (a store setter's draft too, store/optimistic.ts). */ function guessedValueOf(e) {
71
+ const n = pendingGuessOf(e);
72
+ if (n !== NOT_PENDING) return n;
73
+ return e.u & CONFIG_OVERRIDE ? laneValueOf(e) : e.pe;
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
+ function optimisticWrite(e, n) {
82
+ // What the user sees: an unflushed guess to the same node, else the lane's
83
+ // value or the committed one. The updater composes on it; guessing it
84
+ // again is no guess (the node's comparator, as for any write) — unless
85
+ // the node already carries one: the user re-asked, and the re-ask renews
86
+ // the guess's question and entangles its frame (#3347) without notifying.
87
+ const u = guessedValueOf(e);
88
+ if (typeof n === "function") n = n(u);
89
+ if (e.We && e.We(u, n) && !(e.u & CONFIG_GUESS)) return n;
90
+ pendingGuesses.push(e, n, question || nextQuestion());
91
+ schedule();
63
92
  return n;
64
93
  }
65
94
 
66
- /**
67
- * Is the lane held? `_pendingAsync` records the async the lane OWNS (derived
68
- * under it); a transaction's reporter map records the async a render effect
69
- * OBSERVED pending with no boundary taking it (INV-3, the one registration
70
- * site). A hold needs both — the same rule the transaction itself uses, so a
71
- * memo nobody renders, or one a fallback-showing boundary caught, cannot tear
72
- * a frame and holds nothing (#3289). An orphan lane has no observation record
73
- * and never holds.
74
- *
75
- * The observation is looked up per NODE, in whichever live transaction
76
- * recorded it — not in this lane's transaction. Lanes merge across
77
- * transactions (#2912: ownership never travels through lanes), so after a
78
- * merge the root's transaction holds the observations of only one member;
79
- * the async the other member's transaction observed must hold the merged
80
- * reveal just the same (A15 for lanes, #3335).
81
- */ function laneHeld(n) {
82
- if (!n.we) return false;
83
- for (const e of n.Qe) if (waitingTransition(e) !== null) return true;
95
+ /** The seam: each guess becomes its node's lane value, in a lane — the
96
+ * node's own if it carries one (a later write into the same lane), else a
97
+ * new one under `parent` (the frame's transaction), under the hold already
98
+ * on the node (a guess over that transition's world — the truth it holds
99
+ * stays staged beneath, for the lane's end to commit), or under a
100
+ * transaction opened for the node's own in-flight refetch (the guess is
101
+ * that flight's observer — A17, "visible until its own fetch settles"). No
102
+ * parent: the guess is dropped. The truth is untouched; readers are
103
+ * dirtied for the next round. */
104
+ /** A guess's own truth is in flight: the node's own refetch — or, a store
105
+ * leaf's, its family's derive (the slot's flight; store/optimistic.ts
106
+ * installs the resolver). A17: the guess stands in for the flight. */ function inFlight(e) {
107
+ return (e.G & STATUS_PENDING) !== 0 || (e.u & CONFIG_SLOT_NODE) !== 0 && GlobalQueue.F?.(e) === true;
108
+ }
109
+
110
+ function applyGuesses(e) {
111
+ let n = null;
112
+ for (let u = 0; u < pendingGuesses.length; u += 3) {
113
+ const l = pendingGuesses[u];
114
+ const t = pendingGuesses[u + 1];
115
+ let s = true;
116
+ if (l.u & CONFIG_OVERRIDE) {
117
+ // A lane's node already: a guess re-asked, or a derivation guessed
118
+ // over (its staging is void — the guess is the value now). Two
119
+ // suggestions for one slot cannot finish apart (A34 (1)): the frames
120
+ // entangle. The same value re-asked renews the question; nothing to
121
+ // notify.
122
+ s = !l.We || !l.We(laneValueOf(l), t);
123
+ if (!(l.u & CONFIG_GUESS)) {
124
+ l.Ae = NOT_PENDING;
125
+ l.u |= CONFIG_GUESS;
126
+ }
127
+ l.m.Z = t;
128
+ const n = txOf(l)._parent;
129
+ if (e !== null && n !== null) merge(e, n);
130
+ } else {
131
+ let u;
132
+ if (l.u & CONFIG_HELD) u = newLane(txOf(l)); else {
133
+ if (e === null && inFlight(l)) e = newTransaction(false);
134
+ if (e === null) continue;
135
+ u = n ??= newLane(e);
136
+ }
137
+ // (A guess equal to a truth staged beneath it is confirmed at birth —
138
+ // A24 — and still re-derives its readers as the lane's: the truth's
139
+ // derivations are the transaction's world, the lane's are the
140
+ // screen's plus the guess (plan sec. 19) — a derivation reading a held write
141
+ // beside the guess must not show it. Two flights for one input, when
142
+ // the worlds coincide, is the price.)
143
+ ext(l).Z = t;
144
+ l.u |= CONFIG_OVERRIDE | CONFIG_GUESS;
145
+ list(l, u);
146
+ }
147
+ ext(l).Oe = pendingGuesses[u + 2];
148
+ if (s) {
149
+ // The lane's members re-derive as its work (REACTIVE_LANE_DIRTY): a
150
+ // blocked lane's re-guess does not re-run its render effects as stale
151
+ // readers republishing the committed view (#3460).
152
+ insertSubs(l);
153
+ laneDirty(l, txOf(l));
154
+ }
155
+ }
156
+ pendingGuesses.length = 0;
157
+ }
158
+
159
+ /** The running pass read lane `l`'s work as a derivation: it is `l`'s — or,
160
+ * already another lane's, the frame it computes derives from both guesses
161
+ * and cannot show one without the other (#3335, A15 for lanes): the two
162
+ * lanes are linked — one reveal unit, each blocked while any is — while
163
+ * their lifetimes stay their own (#2912: a guess reverts with its own
164
+ * action, not with the one it shares a reader with). A nested lane reading
165
+ * through an ancestor's guess stays its own (the screen plus its own
166
+ * guesses). */ function enterLane(e, n) {
167
+ n.R |= REACTIVE_LANE_READ;
168
+ const u = passLane;
169
+ if (u === null) {
170
+ setPassLane(e);
171
+ // The pass read a held write before its first lane read (it joined the
172
+ // frame's future as mainline would): lane work sees the screen — the
173
+ // seam re-derives it on the committed world next round (`stagedReaders`,
174
+ // the park's repair), as it does a lane pass that read a staging.
175
+ if (n.R & REACTIVE_JOINED) stagedRead(n);
176
+ return;
177
+ }
178
+ if (sameLane(u, e)) return setPassLane(e);
179
+ if (under(u, e)) return;
180
+ if (under(e, u)) return setPassLane(e);
181
+ linkLanes(u, e);
182
+ setPassLane(e);
183
+ }
184
+
185
+ /** Is `l` nested under `a` (an ancestor lane)? */ function under(e, n) {
186
+ for (let u = e._parent; u !== null && u.Z; u = u._parent) if (u === n) return true;
84
187
  return false;
85
188
  }
86
189
 
87
- /**
88
- * Lanes mirror transitions (#3460): a render effect OFF a HELD lane that reads
89
- * a value the lane is revealing — an override, a `latest()` shadow — sees the
90
- * committed value, exactly as a stale reader of a held transaction does
91
- * (A15 reveal corollary): it publishes now, with the frame that is on screen
92
- * (the lane defers its own readers' runs, so the committed value is what is
93
- * visible), entangles nothing — a sync write is never held by a lane — and
94
- * re-derives at the release. The release re-run rides the lane's own render
95
- * queue, which runs when the lane reveals (runLaneEffects) or its transaction
96
- * commits (cleanupCompletedLanes). A reader ON the lane computes the lane's
97
- * reveal and takes the value as before.
98
- *
99
- * OFF the lane is provenance, not membership — the transaction mirror
100
- * exactly: a stale reader of a transaction is a pass that runs outside it. A
101
- * pass under the lane's own transaction is the lane's work — its write (lane
102
- * posture), or the landing of its async, which re-enters the transaction
103
- * (#3334) and runs a member with no ambient lane. Read as an outsider, that
104
- * pass published the committed view and queued a replay that revealed the
105
- * override beside its unready derivation at the release (`1:0` for an
106
- * optimistic frame that never became ready; #3479 review). Membership is the
107
- * wrong test the other way: a member re-run by a sibling's sync write is a
108
- * mainline pass and shows the committed view.
109
- */ function readsHeldCommitted(n, e) {
110
- const i = resolveLane(n);
111
- if (!i || !laneHeld(i)) return false;
112
- if (ownsLane(i, n)) return false;
113
- i.dn[0].push(() => e.oe & REACTIVE_DISPOSED || enqueueSub(e));
190
+ /** One link group (a shared array) for both lanes' groups. */ function linkLanes(e, n) {
191
+ const u = e.nn ?? (e.nn = [ e ]);
192
+ const l = n.nn;
193
+ if (l === u) return;
194
+ if (l === null) {
195
+ u.push(n);
196
+ n.nn = u;
197
+ } else for (let e = 0; e < l.length; e++) {
198
+ u.push(l[e]);
199
+ l[e].nn = u;
200
+ }
201
+ }
202
+
203
+ /** A linked lane blocked on its own account blocks the group — `blocked(k)`
204
+ * without the group recursion. (A guess in `k` whose own truth is in flight
205
+ * blocks `k`'s parent, not `k` — nor, through the link, `l`: the guess
206
+ * shows, A17.) */ function linkBlocked(e) {
207
+ const n = e.nn;
208
+ if (n !== null) for (let u = 0; u < n.length; u++) {
209
+ const l = n[u];
210
+ if (l !== e && (l.tt !== 0 || ownFlights(l) || nestedBlocked(l))) return true;
211
+ }
212
+ return false;
213
+ }
214
+
215
+ function unlink(e) {
216
+ const n = e.nn;
217
+ if (n === null) return;
218
+ const u = n.indexOf(e);
219
+ if (u !== -1) n.splice(u, 1);
220
+ e.nn = null;
221
+ }
222
+
223
+ /** Verdicts (maintainer, 2026-10-01): `isPending` and `latest` are
224
+ * optimistic state the system supplies — a verdict is a guess ("pending,
225
+ * until this lands"; "the proposal is the value") decided at the seam like
226
+ * a user's, and its readers break out of the hold the same way: work of a
227
+ * lane under the holder, shown now, re-derived at the landing, ending with
228
+ * it. Judged at the seam like any lane: blocked while a verdict reader's
229
+ * own derivation is in flight (lane rule 3), shown otherwise. */ function verdictLane(e) {
230
+ return e.ye ??= newLane(e);
231
+ }
232
+
233
+ /** A lane pass's node (core.ts `recompute`, before its staging; a pending
234
+ * propagation under a lane pass, async.ts): listed, carrying the lane's
235
+ * value from now (a derivation of a guess — its readers become lane work).
236
+ * Entering the lane supersedes a frame staging the node carried: this
237
+ * pass's answer replaces it, and the frame's hold on it is over. An
238
+ * effect's value slot is private (no lane value). A pass in a lane's seat
239
+ * that read none of the lane's world has left it (false): its result is the
240
+ * frame's — a derivation whose branch no longer reaches the guess — and no
241
+ * hold the lane took over from a transaction stays on it (#3698: lane work
242
+ * never makes its node transaction work; a born-held effect's hold went to
243
+ * the lane). A pass interrupted before it got there (pending, errored) did
244
+ * not leave (A30: it never got there). A first pass under a lane is the
245
+ * lane's (ruling A); a guess is written, not derived — it never leaves this
246
+ * way. `errored`: the pass has no answer — or, a lane pass's pending
247
+ * propagation (async.ts `propagateStatus`), the node gone pending. */ function laneStage(e, n, u, l) {
248
+ if (!(u || l || e.R & REACTIVE_LANE_READ || e.u & CONFIG_GUESS)) {
249
+ if (e.m !== null) {
250
+ if (e.m.ke?.Z) e.m.ke = null;
251
+ e.m.Z = NOT_PENDING;
252
+ }
253
+ e.u &= -2305;
254
+ return false;
255
+ }
256
+ if (!e.i) {
257
+ if (!(e.u & CONFIG_OVERRIDE)) {
258
+ e.Ae = NOT_PENDING;
259
+ e.u = e.u & ~CONFIG_HELD | CONFIG_OVERRIDE;
260
+ ext(e);
261
+ }
262
+ // A written guess whose own pass is the lane's work — its source is a
263
+ // derivation of another guess (a guess over `config().courier` under a
264
+ // country guess) — is confirmed or corrected by the lane: a derivation
265
+ // of the lane from here (its value the lane's, its fate the lane's), no
266
+ // longer a written guess. A pass with no answer (pending, errored)
267
+ // leaves the guess.
268
+ if (!l) e.u &= ~CONFIG_GUESS;
269
+ }
270
+ // A leaf has no lane value to seat it (`recompute`): one left waiting on
271
+ // the lane's flight runs its next pass as the lane's — the landing that
272
+ // wakes it is the lane's re-staging (A31), and the lane holds its render
273
+ // effects until its derivations land (A17; #3766, F5). Not a leaf whose
274
+ // seat is its frame's, reached by a propagation from a node the screen has
275
+ // a value of: one a transaction holds (born held — its frame waits on it,
276
+ // A29), or one whose own mainline pass is running (it pulled the node;
277
+ // `laneRead` decides — its frame holds). Its pending is the frame's: queued
278
+ // for the commit sweep as mainline's (async.ts). A node born in the lane
279
+ // has nothing on screen: its leaf waits as the lane's.
280
+ else if (l) {
281
+ if (l !== true && !(l.G & STATUS_UNINITIALIZED) && (e.u & CONFIG_HELD || e.R & REACTIVE_RECOMPUTING_DEPS) && !e.m?.ke?.Z) {
282
+ queuePendingNode(e);
283
+ return false;
284
+ }
285
+ e.R |= REACTIVE_LANE_DIRTY;
286
+ }
287
+ list(e, n);
114
288
  return true;
115
289
  }
116
290
 
117
- /** The ownership relation for a lane hold (core `ownsHold`, §6 ruling 2): the
118
- * running pass owns `lane`'s hold if it runs under the transition that owns
119
- * the lane (the node's, resolved through override ownership and merges) or
120
- * inside the lane itself. */ function ownsLane(n, e) {
121
- if (activeTransition !== null) {
122
- const n = resolveTransition(e);
123
- if (n && ownsHold(n)) return true;
124
- }
125
- return currentOptimisticLane !== null && findLane(currentOptimisticLane) === n;
126
- }
127
-
128
- /**
129
- * Merge two lanes when their dependency graphs overlap.
130
- */ function mergeLanes(n, e) {
131
- n = findLane(n);
132
- e = findLane(e);
133
- if (n === e) return n;
134
- e.ei = n;
135
- // Move (not copy) the merged lane's work: after the merge all routing goes
136
- // through findLane() to the root, so anything left behind here is dead —
137
- // and anything *added* here later is a routing bug (INV-5).
138
- for (const i of e.Qe) n.Qe.add(i);
139
- e.Qe.clear();
140
- n.dn[0].push(...e.dn[0]);
141
- n.dn[1].push(...e.dn[1]);
142
- e.dn[0].length = 0;
143
- e.dn[1].length = 0;
144
- return n;
291
+ function supersede(e, n, u) {
292
+ const l = txOf(e);
293
+ // Resolved: the parent may have merged into another transaction since the
294
+ // lane opened (two actions guessing one slot entangle, A34 (1)) — the
295
+ // truth is held by the transaction that lands, not the merged-away one.
296
+ const t = resolveTx(l._parent ?? l);
297
+ if (u) {
298
+ dissolveLane(l, t, e);
299
+ // What the screen showed stays the screen until the parent lands (A18
300
+ // (c): display and untracked reads keep the override until the commit).
301
+ if (l.ve) e.pe = e.m.Z;
302
+ e.u &= -10241;
303
+ e.m.Z = NOT_PENDING;
304
+ e.Ae = n;
305
+ holdNode(e, t);
306
+ joinFuture(t);
307
+ if (e.t !== null) insertSubs(e);
308
+ } else {
309
+ e.Ae = n;
310
+ e.u |= CONFIG_HELD;
311
+ joinFuture(t);
312
+ for (let n = e.t; n !== null; n = n.l) if (n.o.u & CONFIG_AUTHORITATIVE) enqueueSub(n.o);
313
+ }
314
+ }
315
+
316
+ /** A lane's end, two ways. `into === null`: the parent landed — the lane's
317
+ * values are the truth now: a guess lands the truth staged beneath it or
318
+ * reverts to the one it covered (`_value`, untouched by the guess); a
319
+ * derivation's latest value commits (its frame with it); what the screen
320
+ * showed and changes notifies. Otherwise the lane dissolves into `into`
321
+ * (the parent, on a correction): its values are void — what it showed stays
322
+ * the screen (`_value` takes it, so the parent's re-derivation compares
323
+ * against what is seen), a truth staged beneath a guess is the parent's to
324
+ * land, and the runs it held (showing the void guess) are dropped: the
325
+ * parent's re-derivation makes the runs that show. */ function dissolveLane(e, n, u) {
326
+ const l = lanes.indexOf(e);
327
+ if (l !== -1) lanes.splice(l, 1);
328
+ unlink(e);
329
+ // Its verdicts end with it (a correction's dissolution reaches here before
330
+ // `endLanes` would): the readers re-derive from the truth's notification.
331
+ const t = e.ye;
332
+ if (t !== null) {
333
+ e.ye = null;
334
+ if (lanes.indexOf(t) !== -1) dissolveLane(t, null);
335
+ }
336
+ for (let l = 0; l < e.un.length; l++) {
337
+ const t = e.un[l];
338
+ const s = t.m;
339
+ if (t === u || s.ke !== e) continue;
340
+ const i = t.i;
341
+ const r = t.u & CONFIG_GUESS;
342
+ const o = s.Z;
343
+ // What the screen shows of it (NOT_PENDING: nothing — a lane pass that
344
+ // errored or pends staged no value), and the lane's latest.
345
+ const E = e.ve && !i ? o : t.pe;
346
+ const f = laneValueOf(t);
347
+ s.Z = NOT_PENDING;
348
+ t.u &= -10241;
349
+ if (n === null) {
350
+ // A derivation the revert re-derives (dirtied by the guess's
351
+ // notification — listed before it), or one still in flight, shows the
352
+ // lane's answer beside inputs that are the truth now: a fresh reader
353
+ // of its flight observes it (#3648, #3651; #3305's commit beneath a
354
+ // flight).
355
+ s.ke = null;
356
+ if (!i && !r) t.Ae = f;
357
+ commitPendingNode(t);
358
+ if (!i) {
359
+ if (t.R & (REACTIVE_IN_HEAP | REACTIVE_DIRTY | REACTIVE_CHECK) || t.G & STATUS_PENDING) t.u |= CONFIG_INPUTS_PUBLISHED;
360
+ if (E !== NOT_PENDING && (!t.We || !t.We(E, t.pe))) insertSubs(t);
361
+ }
362
+ } else if (r) {
363
+ // A guess of a dissolving lane: its truth — a landing held beneath it,
364
+ // else the value it covered — is the parent's to land, and its readers
365
+ // re-derive from it there. What the screen showed stays the screen
366
+ // until then (A18 (c)).
367
+ if (t.Ae === NOT_PENDING) t.Ae = covered(t);
368
+ if (e.ve) t.pe = o;
369
+ holdNode(t, n);
370
+ insertSubs(t);
371
+ } else {
372
+ // A correction: the lane's derivations are void. Shown, what the
373
+ // screen showed stays the screen (committed, inputs published — every
374
+ // one re-derives); never shown, nothing of it reached the screen (a
375
+ // node born in the lane stays uninitialized; its frame goes). One in
376
+ // flight is asking the void world's question: its landing is nobody's
377
+ // answer — it re-asks from the truth (whose notification may not reach
378
+ // it: an input's truth equal to its committed value is silent).
379
+ s.ke = null;
380
+ if (!i) {
381
+ if (E !== NOT_PENDING && e.ve) t.Ae = E;
382
+ if (t.G & STATUS_PENDING) {
383
+ s.De = null;
384
+ enqueueSub(t);
385
+ }
386
+ }
387
+ if (e.ve) {
388
+ commitPendingNode(t);
389
+ if (!i) t.u |= CONFIG_INPUTS_PUBLISHED;
390
+ } else {
391
+ if (s.Me !== null || s.Be !== null) GlobalQueue.he(t, false, true);
392
+ t.u &= -385;
393
+ }
394
+ }
395
+ }
396
+ // The parent landed: the runs the lane held (blocked on its own judgment
397
+ // alone — a zombie it could not dispose) are the landing's. A correction
398
+ // of a SHOWN lane keeps its runs too: "what it showed stays the screen"
399
+ // means the runs this round's lane passes queued (the body-end seam judges
400
+ // before the lane seam would have released them) must reach the screen —
401
+ // their derivations' values are the committed ones now, and a
402
+ // re-derivation that lands on the same value notifies nobody (a mapArray
403
+ // whose rows the lane pass already built). A never-shown lane's runs are
404
+ // void: nothing of it reached the screen. So are the runs a blocked lane
405
+ // parked: they show a re-guess the seam never revealed, beside derivations
406
+ // that keep what the screen showed.
407
+ if (n === null || e.ve && !e.ln) releaseQueues(e); else e.tn[0].length = e.tn[1].length = 0;
408
+ }
409
+
410
+ /** Lanes. A lane's node is read by its reader's kind: an authoritative
411
+ * reader (`until`) sees the truth — staged beneath a guess, else committed
412
+ * — and is no lane's; an untracked read sees the lane's latest value (A17:
413
+ * "direct read shows optimistic"; A28); a children-forbidden reader sees
414
+ * the frame (A32). A render effect in the frame's seat reading a lane the
415
+ * seam found blocked, or a member whose own flight is up (held or not — the
416
+ * lane-membership ruling, 2026-10-05), sees the screen, re-derived at the
417
+ * reveal (#3460's stale reader) — or, the node a
418
+ * flight that has never shown (nothing to show), waits on it: its own frame
419
+ * holds (A15, #3334), not the lane's parent. Any other tracked reader is
420
+ * the lane's work from this read — a derivation; a leaf reading a lane that
421
+ * has shown, or one the seam has not judged yet (its run waits on the
422
+ * verdict: released if the lane shows, held if it blocks) — and sees the
423
+ * lane's latest. NOT_PENDING falls through: lane work's read of a pending
424
+ * member throws like any. */ function laneRead(e, n) {
425
+ const u = n.u & CONFIG_GUESS;
426
+ if (e !== null && e.u & CONFIG_AUTHORITATIVE) return u && n.Ae !== NOT_PENDING ? n.Ae : n.pe;
427
+ if (e === null) return laneValueOf(n);
428
+ const l = txOf(n);
429
+ const t = n.G;
430
+ if (!tracking || e.u & CONFIG_CHILDREN_FORBIDDEN) {
431
+ // An untracked read inside lane work derives from the lane like a
432
+ // tracked one, minus the subscription — `untrack` is about
433
+ // dependencies, not about which world a pass derives from (a mapper's
434
+ // row reads under its root, store/map): the pass enters the lane (two
435
+ // lanes read by one pass link, as for tracked reads). Outside lane
436
+ // work, the screen.
437
+ if (passLane === null || e.u & CONFIG_CHILDREN_FORBIDDEN) return display(n);
438
+ enterLane(l, e);
439
+ if (!u && t & STATUS_PENDING) return NOT_PENDING;
440
+ return laneValueOf(n);
441
+ }
442
+ if (e.i === EFFECT_RENDER && (passLane === null || !sameLane(passLane, l))) {
443
+ if (!u) {
444
+ // A flight whose value has never shown: nothing to show — the leaf
445
+ // waits on it, and its own frame holds (A15, #3334), not the lane's
446
+ // parent. The landing lands the frame: its own pass (the flush
447
+ // joined its transaction) reads the answer it waited on — the lane's
448
+ // staging, revealed at this seam.
449
+ if (t & STATUS_PENDING && n.m.Z === NOT_PENDING) return NOT_PENDING;
450
+ if (n.Ae !== NOT_PENDING && e.u & CONFIG_HELD && flushTransaction !== null && resolveTx(flushTransaction) === txOf(e)) return n.Ae;
451
+ }
452
+ if (l.ln || !u && t & STATUS_PENDING) {
453
+ if (!u && !l.ve && t & STATUS_UNINITIALIZED) throw new NotReadyError(null);
454
+ // Re-derived at the reveal; once per pass (the pass may also be a stale
455
+ // reader of a transaction, REACTIVE_FRAME_READ — both reruns apply).
456
+ if (!(e.R & REACTIVE_SCREEN_READ)) {
457
+ e.R |= REACTIVE_FRAME_READ | REACTIVE_SCREEN_READ;
458
+ l.sn.push(e);
459
+ }
460
+ return display(n);
461
+ }
462
+ }
463
+ enterLane(l, e);
464
+ if (!u && t & STATUS_PENDING) return NOT_PENDING;
465
+ return laneValueOf(n);
466
+ }
467
+
468
+ /** The value a guess covered: the node's committed value — a store slot's
469
+ * asked of the store (a chained link follows the inner store's commits). */ function covered(e) {
470
+ return e.u & CONFIG_SLOT_NODE && GlobalQueue.rn !== undefined ? GlobalQueue.rn(e) : e.pe;
145
471
  }
146
472
 
147
- /**
148
- * Resolve a node's lane: follow union-find chain, verify active, clear if stale.
149
- */ function resolveLane(n) {
150
- const e = n.o?.me;
151
- if (!e) return undefined;
152
- const i = findLane(e);
153
- if (activeLanes.has(i)) return i;
154
- if (n.o !== null) n.o.me = undefined;
155
- return undefined;
156
- }
157
-
158
- function resolveTransition(n) {
159
- // An active override answers with its owner, not its lane: lanes are
160
- // scheduling affinity and a shared subscriber merges them across
161
- // transactions (#2912) — the merged root's _transition would hand this
162
- // node's override to whichever action wrote last through the shared
163
- // reader. Chase merge chains; a dead owner settled through another path.
164
- if (hasActiveOverride(n) && n.o?.Ln) {
165
- const e = ext(n).Ln = currentTransition(n.o?.Ln);
166
- if (e.Rn !== true) return e;
167
- if (n.o !== null) n.o.Ln = null;
168
- }
169
- return resolveLane(n)?.we ?? n.we;
170
- }
171
-
172
- /**
173
- * Assign or merge a lane onto a node. At convergence points (node already has
174
- * a different active lane), merge unless the node has an active override.
175
- */ function assignOrMergeLane(n, e) {
176
- const i = findLane(e);
177
- const t = n.o?.me;
178
- if (t) {
179
- // A merged lane is followed to its root like any other: the root is where
180
- // the subscriber's affinity lives now. Replacing it with the source lane
181
- // outright (as this once did) skipped the parent/child check below — an
182
- // isPending reader of two async siblings had their two companion lanes
183
- // merge, and the next parent-lane notification then moved it onto the
184
- // held parent, where its verdict waited on the async it reports (#3409).
185
- const r = findLane(t);
186
- if (activeLanes.has(r)) {
187
- // A WRITTEN override is its own lane's source and merges nothing
188
- // through it; a derived one (lanes stage, #3479) is a plain member —
189
- // the shared reader that merges two writers' lanes carries one.
190
- if (r !== i && (!hasActiveOverride(n) || n.C & CONFIG_DERIVED_OVERRIDE)) {
191
- // Parent-child lanes stay independent so isPending resolves without
192
- // waiting for the parent's async. The child keeps ownership.
193
- if (i.ii && findLane(i.ii) === r) {
194
- ext(n).me = e;
195
- n.C |= CONFIG_HAS_LANE;
196
- } else if (r.ii && findLane(r.ii) === i) ; else mergeLanes(i, r);
473
+ /** A guess in `l` whose own truth is in flight (its refetch — authoritative:
474
+ * the landing supersedes, not the body's end). */ function guessFlights(e) {
475
+ for (let n = 0; n < e.un.length; n++) {
476
+ const u = e.un[n];
477
+ if (u.u & CONFIG_GUESS && u.m.ke === e && inFlight(u)) return true;
478
+ }
479
+ return false;
480
+ }
481
+
482
+ /** The seam's verdict on a lane. Blocked — its own flight is up — nothing
483
+ * moves: the screen keeps what it shows, the lane's runs wait. Unblocked,
484
+ * the lane shows: its values are the screen from now (`_shown`), the
485
+ * staging its passes made since the last reveal is promoted, their frames
486
+ * (children) apply, the stale readers re-derive (#3460), its runs go. */
487
+ /** A18 body-end corollary (#3427), at the seam before the park decision
488
+ * (the guesses' own passes have run; a correction's re-derivations run in
489
+ * one more pure round and are the parent's flights before it is judged —
490
+ * #3409: the indicators clear together): the action body having returned,
491
+ * a guess whose own truth is not in flight has no answer coming — the truth
492
+ * beneath it is its truth, and the correction starts now rather than at the
493
+ * lane's flight. (A guess whose own refetch is up is superseded by its
494
+ * landing.) True when a lane was judged. */ function laneCorrections() {
495
+ let e = false;
496
+ const n = lanes.slice();
497
+ for (let u = 0; u < n.length; u++) {
498
+ const l = n[u];
499
+ if (lanes.indexOf(l) === -1) continue;
500
+ const t = resolveTx(l._parent);
501
+ if (!t.nt || t.tt !== 0 || t.Z || ownFlights(t) || guessFlights(l)) continue;
502
+ e = true;
503
+ // Each guess's truth: the one beneath it (a landing held there), else
504
+ // the one it covered. (A correction dissolves the lane — the others are
505
+ // re-homed with theirs, `dissolveLane`.)
506
+ for (let e = 0; e < l.un.length && lanes.indexOf(l) !== -1; e++) {
507
+ const n = l.un[e];
508
+ if (n.u & CONFIG_GUESS && n.m.ke === l) {
509
+ const e = n.Ae !== NOT_PENDING ? n.Ae : covered(n);
510
+ supersede(n, e, !n.We || !n.We(n.m.Z, e));
197
511
  }
198
- return;
199
512
  }
200
513
  }
201
- ext(n).me = e;
202
- n.C |= CONFIG_HAS_LANE;
514
+ return e;
203
515
  }
204
516
 
205
- export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, laneHeld, mergeLanes, ownsLane, readsHeldCommitted, resolveLane, resolveTransition, signalLanes };
517
+ function laneSeam(e, n) {
518
+ // Blocked — or one of its passes read a write the frame holds this seam:
519
+ // its runs wait, the pass re-derives on the screen next round.
520
+ if (n || blocked(e)) {
521
+ e.ln = true;
522
+ return;
523
+ }
524
+ e.ln = false;
525
+ e.ve = true;
526
+ reruns(e);
527
+ for (let n = 0; n < e.un.length; n++) {
528
+ const u = e.un[n];
529
+ const l = u.m;
530
+ if (l.ke !== e) continue;
531
+ if (!(u.u & CONFIG_GUESS) && !u.i && u.Ae !== NOT_PENDING) {
532
+ l.Z = u.Ae;
533
+ u.Ae = NOT_PENDING;
534
+ }
535
+ // The frame this pass built is the screen's now; the one it replaced
536
+ // goes (as `commitPendingNode` retires a committed pass's).
537
+ if (l.Me !== null || l.Be !== null) GlobalQueue.he(u, false, true);
538
+ u.u &= ~CONFIG_STAGED;
539
+ }
540
+ releaseQueues(e);
541
+ }
542
+
543
+ /** The parent landed: its lanes end, nested first. (None is blocked: a
544
+ * blocked lane blocks its parent.) */ function endLanes(e) {
545
+ for (let n = lanes.length - 1; n >= 0; n--) {
546
+ const u = lanes[n];
547
+ if (resolveTx(u._parent) !== e) continue;
548
+ endLanes(u);
549
+ dissolveLane(u, null);
550
+ }
551
+ }
552
+
553
+ /** A blocked lane blocks its parent (maintainer, 2026-10-01): the lane's
554
+ * pending work derives from the frame's write through the guess, so the
555
+ * frame is not complete without it (A15) — landing it would commit the write
556
+ * beside a derivation still showing the old one. A guess whose own flight is
557
+ * up likewise: the question was asked in this frame. */ function lanesBlocked(e) {
558
+ return e.Z && linkBlocked(e) || nestedBlocked(e);
559
+ }
560
+
561
+ /** The lanes under `t` (its own; a link group's are each other's). */ function nestedBlocked(e) {
562
+ for (let n = 0; n < lanes.length; n++) {
563
+ const u = lanes[n];
564
+ if (resolveTx(u._parent) !== e) continue;
565
+ if (blocked(u) || guessFlights(u)) return true;
566
+ }
567
+ return false;
568
+ }
569
+
570
+ /** A write landing on a lane's node (core.ts `setSignal`: a user's write, an
571
+ * async landing). On a guess it is its truth (A18 — an async guess's own
572
+ * landing), judged against the guess. On a derivation it is the lane's
573
+ * latest: its staging once the lane has shown (promoted at the next
574
+ * reveal), its slot before; the lane's members re-derive as its work. */ function laneWrite(e, n) {
575
+ if (e.u & CONFIG_GUESS) {
576
+ // Provenance (A18, #3331; Q-D, plan sec. 39): a write asking an OLDER
577
+ // question than the guess's — another action's landing beneath it —
578
+ // is not its answer: held beneath (the truth for the commit; the
579
+ // guess's own question judges), and nothing moves. The writer's
580
+ // question is the one being asked (`question`: a slice's, a derive's
581
+ // continuation's — the flight's); unstamped writes and mainline are
582
+ // current.
583
+ if (stale(e, question)) {
584
+ e.Ae = n;
585
+ e.u |= CONFIG_HELD;
586
+ GlobalQueue.En?.(e, n);
587
+ schedule();
588
+ return n;
589
+ }
590
+ supersede(e, n, !e.We || !e.We(e.m.Z, n));
591
+ } else {
592
+ const u = txOf(e);
593
+ if (e.We && e.We(laneValueOf(e), n)) return n;
594
+ if (u.ve) e.Ae = n; else e.m.Z = n;
595
+ if (e.re !== undefined) e.Ne = clock;
596
+ insertSubs(e);
597
+ laneDirty(e, u);
598
+ }
599
+ schedule();
600
+ return n;
601
+ }
602
+
603
+ /** A written guess's own pass finished: its source recomputed it — the
604
+ * truth (A18: "the source is whatever recomputes the node"), authoritative
605
+ * or the lane's own derivation (a guess over `config().courier` under a
606
+ * country guess: the lane's config landing confirms or corrects it). An
607
+ * errored pass stages nothing. Provenance (A18, #3331): "the source" is the
608
+ * guess's own question or a newer one; an older action's answer landing
609
+ * over a newer guess (the two entangled when the newer guess was written)
610
+ * is stale — a slow source leaking back in over the user's latest intent.
611
+ * It is staged beneath the guess, for the commit like any landing, and
612
+ * nothing moves: no downstream re-ask, no pending flip on the guess's
613
+ * readers (`isPending` of the guess itself says the held truth differs,
614
+ * A24). The guess's own question answering supersedes as usual. */ function laneOutcome(e, n, u) {
615
+ if (u) return true;
616
+ if (stale(e, answered(e))) {
617
+ e.Ae = n;
618
+ e.u |= CONFIG_HELD;
619
+ return true;
620
+ }
621
+ supersede(e, n, !e.We || !e.We(e.m.Z, n));
622
+ return true;
623
+ }
624
+
625
+ /** THE provenance test, for a derivation's pass and a write alike: an
626
+ * answer to question `q` landing on a guess is stale when `q` is older
627
+ * than the guess's own; unstamped (0) and mainline are current. */ function stale(e, n) {
628
+ return n !== 0 && n < e.m.Oe;
629
+ }
630
+
631
+ /** The question a derivation's pass answered: the newest among the stamped
632
+ * sources that changed this round (a flight's landing carries the question
633
+ * that started it); 0 when none is stamped. */ function answered(e) {
634
+ let n = 0;
635
+ for (let u = e._; u !== null; u = u.p) {
636
+ const e = u.I;
637
+ if (e.m !== null && e.m.Oe > n && e.Ne === clock) n = e.m.Oe;
638
+ }
639
+ return n;
640
+ }
641
+
642
+ GlobalQueue.Nt = laneRead;
643
+
644
+ GlobalQueue.M = laneStage;
645
+
646
+ GlobalQueue.Qe = laneOutcome;
647
+
648
+ GlobalQueue.Tt = laneWrite;
649
+
650
+ /** The lanes alive before this seam's guesses opened theirs (a prefix of
651
+ * `lanes`; nothing dissolves one between here and the seam loop): a lane
652
+ * born at the seam has no work to judge yet (its passes run next round) —
653
+ * it is neither shown nor blocked until it has. */ let judged = 0;
654
+
655
+ GlobalQueue.fn = e => {
656
+ judged = lanes.length;
657
+ if (pendingGuesses.length !== 0) applyGuesses(e);
658
+ };
659
+
660
+ GlobalQueue.Nn = e => {
661
+ // Passes that read a write the parked frame holds as the screen
662
+ // (`stagedReaders`: lane work, a verdict reader before the verdict): they
663
+ // re-derive on the committed world next round (and register as stale
664
+ // readers of the transaction there); a lane's runs wait that round — a
665
+ // lane sees the screen plus its own guesses.
666
+ const n = [];
667
+ if (e !== null) for (let u = 0; u < e.length; u++) {
668
+ const l = e[u];
669
+ const t = l.m?.ke;
670
+ // A verdict reader a later read of the same pass routed into a verdict
671
+ // lane answered for itself: it re-derives at the holder's landing, not
672
+ // now (one run — #3322, #3540). Other verdict-lane work re-derives only
673
+ // if the frame stays parked: a transaction landing at this seam makes
674
+ // what it read the screen (one run).
675
+ if (l.R & REACTIVE_DISPOSED || t != null && t._parent?.ye === t && (l.u & CONFIG_VERDICT ? !(l.R & REACTIVE_PROBE_UNANSWERED) : !blocked(t._parent))) continue;
676
+ enqueueSub(l);
677
+ if (t != null && t.Z && n.indexOf(t) === -1) n.push(t);
678
+ }
679
+ for (let e = Math.min(judged, lanes.length) - 1; e >= 0; e--) laneSeam(lanes[e], n.indexOf(lanes[e]) !== -1);
680
+ };
681
+
682
+ GlobalQueue.an = () => lanes.length !== 0 && laneCorrections();
683
+
684
+ GlobalQueue.In = endLanes;
685
+
686
+ GlobalQueue.cn = lanesBlocked;
687
+
688
+ GlobalQueue.ne = verdictLane;
689
+
690
+ export { display, enterLane, guessedValueOf, laneRead, laneStage, laneValueOf, optimisticWrite, pendingGuessOf, supersede, verdictLane };