diff --git a/.changeset/lanes-guess-layer-split.md b/.changeset/lanes-guess-layer-split.md new file mode 100644 index 0000000000..80b4037d0a --- /dev/null +++ b/.changeset/lanes-guess-layer-split.md @@ -0,0 +1,5 @@ +--- +"@solidjs/signals": patch +--- + +The lane engine is split along the guess boundary: `lanes.ts` keeps the sub-hold core every lane needs (the lane record, link / blocked / reveal / landing, the lane read and a lane pass's tail — what `isPending()` and `latest()` install for their verdict lanes), and the new `guesses.ts` carries what only a written guess reaches (`createOptimistic` / `createOptimisticStore`: `optimisticWrite`, the seam's `applyGuesses`, `take`, `supersede`, `laneCorrections`, `laneOutcome`, a write landing on a guess, a revert landing's give-back), installed behind hooks when imported. Pay-for-use (#2883): an app using `isPending`/`latest` without optimism no longer ships the guess layer (−531 B brotli on `+ isPending/latest`, −454 to −533 B on the live pages); an app with both pays the indirection (+15 B brotli). No rule or screen changes. diff --git a/packages/signals/docs/INTERNALS-ASYNC-STATE.md b/packages/signals/docs/INTERNALS-ASYNC-STATE.md index 381c42a2c9..841fcb89f8 100644 --- a/packages/signals/docs/INTERNALS-ASYNC-STATE.md +++ b/packages/signals/docs/INTERNALS-ASYNC-STATE.md @@ -325,6 +325,35 @@ The findings that used to follow here (§5a–§5h, 2026-07-06 → 2026-07-16) a ## 7. Decision log +- 2026-11-10: **The lane engine split along the guess boundary** (the + §8.6 split, b3926358b, ported onto today's `lanes.ts`; a module boundary, + no rule). `lanes.ts` keeps the sub-hold core every lane needs — the lane + record (`newLane`, `verdictLane`), link / blocked / reveal / landing + (`linkLanes`, `laneSeam`, `laneSeams`, `endLanes`, `dissolveLane`, + `lanesBlocked`, `heldMountUnder`, `laneWait`), the lane read and a lane + pass's tail (`laneRead`, `enterLane`, `laneStage`), `laneWrite`'s + derivation arm, `adoptParked`, `laneServed` — installed by verdict.ts's + verdict lanes as before. The new `guesses.ts` carries what only a written + guess reaches: `optimisticWrite` and the unflushed guesses, the seam's + `applyGuesses`, `take` and the `kept` give-back, `supersede` and the + correction round (`laneCorrections`), `laneOutcome` with the provenance + test (`stale`, `answered`), a write landing on a guess (`guessWrite`, + `laneWrite`'s old guess arm) and a revert landing's give-back + (`revertLanding`, `endLanes`' old `kept` loop). The core reaches them + through `installGuessLayer` (lanes.ts: `take`, `guessWrite`, + `revertLanding`, each site behind CONFIG_GUESS or `guessed`) and + `installGuessHooks` (scheduler.ts: `laneOutcome`, `applyGuessesAt`, + `laneCorrections`, every site null-tolerant); `guessed` stays the core's + flag, armed by the layer (`armGuessed`) so a bundle without it folds the + arms, and `markJudged` is the core's side of `applyGuessesAt`. `marked`, + `inFlight`, `guessFlights`, `rerun`, `landBeneath` stay in the core + (`dissolveLane`, `lanesBlocked`, `laneSeams` read them with no guess + written). Measured (scripts/size, next @ 083a0bd78): `+ isPending/latest` + −531 B brotli / −1,551 B minified, the three live pages −454 to −533 B, + every floor and plain-store scenario 0 B, `hydrating + every store +primitive family` (both halves) +15 B brotli / +157 B minified. Suites, + the seat shadow and 50k × 3 seeds against `next`'s recording: no screen + moves (documentation/plans/reader-seat-rebuild.md §9.3). - 2026-11-09: **A store guess is one node — the guess carrier** (S2's shape, ported onto `next` without S1's staging; D-33's point-of-write clause, S-59, #4724). Before, an optimistic setter was scattered into the diff --git a/packages/signals/docs/RULES-INDEX.md b/packages/signals/docs/RULES-INDEX.md index 2a974f888c..2554271f58 100644 --- a/packages/signals/docs/RULES-INDEX.md +++ b/packages/signals/docs/RULES-INDEX.md @@ -60,7 +60,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul | F-7 | live | `docs/RULES-FUNDAMENTALS.md:93` | boundaries.ts×1 core.ts×1 effect.ts×1 lanes.ts×1 | error-staged-recovery.test.ts×1 ispending-async-derivation-4677.test.ts×1 loading-reveal-held-outside-4593.test.ts×1 optimistic-held-write-leak.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×4 verdict-memo-after-staged-read.test.ts×2 | Nothing else reveals ahead of the hold it belongs to | | F-9 | live | `docs/RULES-FUNDAMENTALS.md:101` | boundaries.ts×1 async.ts×4 core.ts×2 lanes.ts×3 scheduler.ts×1 seat.ts×3 types.ts×2 verdict.ts×8 deferred.ts×2 projection.ts×1 store.ts×1 | action-refresh-ispending-loop-4349.test.ts×1 answered-then-reasked-released-reader.test.ts×1 answered-then-reasked-same-tick.test.ts×2 derived-store-derive-settle.test.ts×2 derived-store-first-landing-verdict.test.ts×1 first-load-superseded-answer-4569.test.ts×1 latest-first-one-pass-4402.test.ts×2 latest-ispending-refetch-loop.test.ts×1 loading-on-held-filter-refresh-4379.test.ts×1 midflight-memo-over-reask-4504.test.ts×1 optimistic-question-change-4336.test.ts×2 settle-diamond-revisit.test.ts×1 staged-error-netted-write.test.ts×1 staged-error-through-async-memo-4640.test.ts×1 two-sources-answered-reasked-4495.test.ts×2 verdict-memo-flight-no-reask.test.ts×8 verdict-probe-committed-4648.test.ts×2 | `isPending` is about a new question; a re-ask is quiet; a first load is loading, not pending | | F-10 | live | `docs/RULES-FUNDAMENTALS.md:109` | async.ts×1 core.ts×1 seat.ts×3 verdict.ts×1 | latest-memo-inline-parity.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×1 proto-key-removal-4672.test.ts×1 two-sources-answered-reasked-4495.test.ts×2 verdict-memo-held-branch-4544.test.ts×1 verdict-probe-committed-4648.test.ts×2 | A write becomes visible at flush — to every channel | -| F-11 | live | `docs/RULES-FUNDAMENTALS.md:117` | core.ts×1 lanes.ts×3 scheduler.ts×1 optimistic.ts×2 | optimistic-guess-over-held-slot.test.ts×2 optimistic-held-error-untracked-read-4489.test.ts×1 optimistic-held-write-leak.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×1 optimistic-layered-filter-4336.test.ts×1 optimistic-list-push-filter-push-4642.test.ts×5 optimistic-live-echo-3898.test.ts×1 optimistic-mount-nested-gate-3835.test.ts×1 optimistic-outside-reask-4690.test.ts×7 optimistic-question-change-4336.test.ts×3 optimistic-second-log-guess-4666.test.ts×4 | An optimistic value is a guess over a hold: the displayed value until that hold commits or its own source answers differently | +| F-11 | live | `docs/RULES-FUNDAMENTALS.md:117` | core.ts×1 guesses.ts×1 lanes.ts×2 scheduler.ts×1 optimistic.ts×2 | optimistic-guess-over-held-slot.test.ts×2 optimistic-held-error-untracked-read-4489.test.ts×1 optimistic-held-write-leak.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×1 optimistic-layered-filter-4336.test.ts×1 optimistic-list-push-filter-push-4642.test.ts×5 optimistic-live-echo-3898.test.ts×1 optimistic-mount-nested-gate-3835.test.ts×1 optimistic-outside-reask-4690.test.ts×7 optimistic-question-change-4336.test.ts×3 optimistic-second-log-guess-4666.test.ts×4 | An optimistic value is a guess over a hold: the displayed value until that hold commits or its own source answers differently | | F-12 | live | `docs/RULES-FUNDAMENTALS.md:125` | optimistic.ts×1 projection.ts×1 | derived-store-derive-settle.test.ts×1 derived-store-recovery-wake.test.ts×1 errored-heal-disposed-reader-4373.test.ts×1 errored-heal-memo-reader-4644.test.ts×1 errored-held-mount-staged-error-4480.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 errored-reader-4486.test.ts×1 errored-staged-source-4364.test.ts×1 loading-reveal-held-outside-4593.test.ts×1 optimistic-derive-memo-error-4437.test.ts×1 try-catch-reactive-read.test.ts×2 | An error is a boundary returning to its fallback; pending is not an error | ## D — derived rules @@ -96,8 +96,8 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul | D-30 | live | `docs/RULES-DERIVED.md:189` | projection.ts×1 store.ts×1 | derived-store-first-landing-verdict.test.ts×1 derived-store-ispending-boundary-4269.test.ts×1 derived-store-latest-seed-4355.test.ts×1 unread-derive-midflight-mount-4491.test.ts×4 | A derived store's seed is a draft, never an observable value | | D-31 | live | `docs/RULES-DERIVED.md:197` | lanes.ts×1 seat.ts×1 | optimistic-keyed-fold.test.ts×1 optimistic-live-echo-3898.test.ts×1 optimistic-outside-reask-4690.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 until-memo-confirmation-3943.test.ts×1 | `resolve`, `until` and `refresh` deliver by the hold they are called in | | D-32 | live | `docs/RULES-DERIVED.md:211` | seat.ts×2 | — | Nothing shows a write before its flush; a guess with nothing to be optimistic over is void | -| D-33 | live | `docs/RULES-DERIVED.md:215` | lanes.ts×2 scheduler.ts×1 | optimistic-key-guess-reask-4329.test.ts×4 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-layered-filter-4336.test.ts×3 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-outside-reask-4690.test.ts×6 optimistic-question-change-4336.test.ts×3 optimistic-second-guess-reask-4629.test.ts×2 optimistic-second-log-guess-4666.test.ts×3 | An optimistic value lives exactly as long as the hold it was made over; same-slot writes entangle, disjoint slots do not | -| D-34 | live | `docs/RULES-DERIVED.md:223` | async.ts×1 core.ts×4 lanes.ts×8 scheduler.ts×3 seat.ts×8 verdict.ts×2 hooks.ts×1 optimistic.ts×15 reconcile.ts×1 store.ts×2 | errored-list-recovery-held-4526.test.ts×1 held-truth-lane-only.test.ts×1 lane-dissolve-disposed-member-4613.test.ts×1 loading-on-held-change-4605.test.ts×1 loading-on-held-filter-refresh-4379.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 optimistic-guess-memo-binding-4561.test.ts×3 optimistic-guess-parked-question-4559.test.ts×1 optimistic-guess-split-bindings-4536.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×2 optimistic-key-guess-reask-4329.test.ts×4 optimistic-keyed-fold.test.ts×3 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×4 optimistic-outside-reask-4690.test.ts×3 optimistic-question-change-4336.test.ts×8 optimistic-read-lane-not-transaction-3698.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 optimistic-second-log-guess-4666.test.ts×1 projection-lane-length-4631.test.ts×1 spec-async-semantics.test.ts×3 derived-latest-confirmed-key.test.ts×3 superseded-before-first-commit.test.ts×2 visibility-oracle.states.ts×3 | A different truth corrects the graph now and the screen at the commit; what the screen never showed is void | +| D-33 | live | `docs/RULES-DERIVED.md:215` | guesses.ts×1 lanes.ts×1 scheduler.ts×1 | optimistic-key-guess-reask-4329.test.ts×4 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-layered-filter-4336.test.ts×3 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-outside-reask-4690.test.ts×6 optimistic-question-change-4336.test.ts×3 optimistic-second-guess-reask-4629.test.ts×2 optimistic-second-log-guess-4666.test.ts×3 | An optimistic value lives exactly as long as the hold it was made over; same-slot writes entangle, disjoint slots do not | +| D-34 | live | `docs/RULES-DERIVED.md:223` | async.ts×1 core.ts×4 guesses.ts×1 lanes.ts×7 scheduler.ts×3 seat.ts×8 verdict.ts×2 hooks.ts×1 optimistic.ts×15 reconcile.ts×1 store.ts×2 | errored-list-recovery-held-4526.test.ts×1 held-truth-lane-only.test.ts×1 lane-dissolve-disposed-member-4613.test.ts×1 loading-on-held-change-4605.test.ts×1 loading-on-held-filter-refresh-4379.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 optimistic-guess-memo-binding-4561.test.ts×3 optimistic-guess-parked-question-4559.test.ts×1 optimistic-guess-split-bindings-4536.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×2 optimistic-key-guess-reask-4329.test.ts×4 optimistic-keyed-fold.test.ts×3 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×4 optimistic-outside-reask-4690.test.ts×3 optimistic-question-change-4336.test.ts×8 optimistic-read-lane-not-transaction-3698.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 optimistic-second-log-guess-4666.test.ts×1 projection-lane-length-4631.test.ts×1 spec-async-semantics.test.ts×3 derived-latest-confirmed-key.test.ts×3 superseded-before-first-commit.test.ts×2 visibility-oracle.states.ts×3 | A different truth corrects the graph now and the screen at the commit; what the screen never showed is void | | D-35 | live | `docs/RULES-DERIVED.md:231` | lanes.ts×1 optimistic.ts×1 | optimistic-guess-split-bindings-4536.test.ts×1 optimistic-layered-filter-4336.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×6 optimistic-outside-reask-4690.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 optimistic-second-log-guess-4666.test.ts×1 | Provenance: an older question's answer never corrects a newer guess; the body's end corrects what nothing authoritative is answering | | D-36 | live | `docs/RULES-DERIVED.md:235` | — | — | A resting optimistic node is a plain memo | | D-37 | live | `docs/RULES-DERIVED.md:239` | async.ts×1 core.ts×4 lanes.ts×1 scheduler.ts×2 seat.ts×9 optimistic.ts×1 | display-ahead-plain-write-content.test.ts×1 lane-mount-effects-4557.test.ts×1 optimistic-held-write-leak.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×5 optimistic-list-push-filter-push-4642.test.ts×1 | A lane sees the screen plus its own guesses and never holds a sync write | @@ -126,24 +126,24 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul | A14 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:215` | — | spec-async-semantics.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B2)] Companion nodes get child lanes that do not merge with the owner — (was B2) `isPending`/`latest` companion nodes get child lanes that do not mer… | | A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:251` | async.ts×2 constants.ts×1 core.ts×4 effect.ts×1 lanes.ts×7 scheduler.ts×18 seat.ts×1 verdict.ts×5 store.ts×1 | async-chain-supersession.test.ts×1 boundary-output-frame-reader.test.ts×1 create-deferred-3710.test.ts×2 first-observer-stale-reader.test.ts×1 fuzz-findings-l2.test.ts×17 held-restore.test.ts×1 hold-recovers-landing-reruns-4469.test.ts×1 l2-contract.test.ts×7 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 lane-pass-stamped-effect-3662.test.ts×1 latest-memo-inline-parity.test.ts×1 latest-stale-branch-hold-4661.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×1 loading-fallback-in-flush-3540.test.ts×4 mount-over-foreign-hold-3761.test.ts×2 optimistic-lane-seam-loop-4643.test.ts×1 overlapping-flights.test.ts×3 posture-born-held-and-observation.test.ts×4 posture-store-parity.test.ts×2 reveal-carve-out.test.ts×2 shared-effect-no-entangle.test.ts×1 show-stale-child-in-action-4137.test.ts×1 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 tick-scoped-pass-transaction.test.ts×1 tracked-effect-staged-dep-4606-4607.test.ts×1 treeshake.test.ts×4 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-held-branch-4544.test.ts×1 verdict-probe-committed-4648.test.ts×2 verdict-shortcut-pending-source-liveness.test.ts×1 visibility-oracle-store.states.ts×6 visibility-oracle.states.ts×7 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B3)] Transition entanglement is graph-driven; lanes settle as one reveal — (was B3) Transition entanglement is graph-driven: writes whose async work … | | A16 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:223` | scheduler.ts×1 | caught-reactive-read-diagnostic.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×2 spec-async-semantics.test.ts×1 strict-read-pending-store.test.ts×2 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×2 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from B5)] `isPending` never throws in untracked contexts — (was B5) `isPending` never throws in untracked contexts — thunks that throw real errors or read… | -| A17 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:71` | async.ts×3 constants.ts×1 lanes.ts×8 scheduler.ts×2 seat.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×5 store.ts×6 | create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×6 lane-uninitialized-landing-3648.test.ts×5 optimistic-outside-reask-4690.test.ts×1 optimistic-over-held-row-3796.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×2 optimistic-undefined-override.test.ts×1 posture-store-parity.test.ts×1 refresh-await.test.ts×1 reveal-gating-contract.test.ts×3 spec-async-semantics.test.ts×10 createOptimisticStore.test.ts×2 kanban-a17-fixture.test.ts×3 optimistic-list-mutation-matrix.test.ts×1 optimistic-maparray-index-frame-f1.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 treeshake.test.ts×1 until.test.ts×1 visibility-oracle-store.states.ts×24 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×20 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from C4)] An active override is the displayed value until its transaction commits, and the graph's value until its own source answers — **Statement (curre… | -| A18 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:81` | action.ts×1 async.ts×2 core.ts×3 lanes.ts×9 scheduler.ts×2 types.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×4 projection.ts×1 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×3 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-outside-view.test.ts×1 lane-uninitialized-landing-3648.test.ts×5 optimistic-move-duplicate-3548.test.ts×2 optimistic-read-lane-not-transaction-3698.test.ts×4 posture-store-parity.test.ts×5 spec-async-semantics.test.ts×5 flight-owned-transaction.test.ts×1 lane-authority-twins.test.ts×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 unchanged-presence-no-hold-3743.test.ts×2 superseded-before-first-commit.test.ts×4 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×17 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from B4)] An override lives exactly as long as its own transaction; a newer truth from the source supersedes it in the graph immediately, on screen at com… | +| A17 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:71` | async.ts×3 constants.ts×1 guesses.ts×3 lanes.ts×5 scheduler.ts×2 seat.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×5 store.ts×6 | create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×6 lane-uninitialized-landing-3648.test.ts×5 optimistic-outside-reask-4690.test.ts×1 optimistic-over-held-row-3796.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×2 optimistic-undefined-override.test.ts×1 posture-store-parity.test.ts×1 refresh-await.test.ts×1 reveal-gating-contract.test.ts×3 spec-async-semantics.test.ts×10 createOptimisticStore.test.ts×2 kanban-a17-fixture.test.ts×3 optimistic-list-mutation-matrix.test.ts×1 optimistic-maparray-index-frame-f1.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 treeshake.test.ts×1 until.test.ts×1 visibility-oracle-store.states.ts×24 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×20 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-06 (promoted from C4)] An active override is the displayed value until its transaction commits, and the graph's value until its own source answers — **Statement (curre… | +| A18 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:81` | action.ts×1 async.ts×2 core.ts×3 guesses.ts×7 lanes.ts×3 scheduler.ts×2 types.ts×1 verdict.ts×1 map.ts×1 optimistic.ts×4 projection.ts×1 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×3 l2-fuzz-existing-rules.test.ts×2 lane-contract.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-outside-view.test.ts×1 lane-uninitialized-landing-3648.test.ts×5 optimistic-move-duplicate-3548.test.ts×2 optimistic-read-lane-not-transaction-3698.test.ts×4 posture-store-parity.test.ts×5 spec-async-semantics.test.ts×5 flight-owned-transaction.test.ts×1 lane-authority-twins.test.ts×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 signal-store-twins-qd.test.ts×1 unchanged-presence-no-hold-3743.test.ts×2 superseded-before-first-commit.test.ts×4 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×17 visibility-oracle.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from B4)] An override lives exactly as long as its own transaction; a newer truth from the source supersedes it in the graph immediately, on screen at com… | | A19 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:151` | boundaries.ts×1 async.ts×1 constants.ts×1 core.ts×6 lanes.ts×1 scheduler.ts×2 seat.ts×1 types.ts×1 verdict.ts×5 store.ts×2 | create-deferred-3710.test.ts×2 derived-store-first-landing-verdict.test.ts×1 errored-latest-obsolete-flight-4568.test.ts×1 fuzz-findings-l2.test.ts×4 lane-uninitialized-landing-3648.test.ts×2 latest-memo-inline-parity.test.ts×1 latest-uninitialized-over-latest-4362.test.ts×2 mount-over-foreign-hold-3761.test.ts×2 spec-async-semantics.test.ts×3 derived-presence-async-3726.test.ts×2 superseded-before-first-commit.test.ts×3 uninitialized-visibility.test.ts×1 verdict-memo-flight-no-reask.test.ts×2 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×14 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPendi… | | A20 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:410` | — | question-scoped-pending.test.ts×2 spec-async-semantics.test.ts×3 createOptimisticStore.test.ts×1 | [superseded 2026-07-13 by A24] (superseded) Optimistic writes announce a store-wide pending — (**SUPERSEDED 2026-07-13 by A24** — the mask is deleted; optimistic writes are verdict-inert. Kept for the… | | A21 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:417` | — | question-scoped-pending.test.ts×3 spec-async-semantics.test.ts×3 | [superseded 2026-07-13 by A24] (superseded) The store-wide mask — (**SUPERSEDED 2026-07-13 by A24** — the store-wide mask is deleted with the mask model; nothing silences a new question. The effective… | | A22 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:231` | store.ts×1 | createProjection.draft-lifetime-3585.test.ts×1 spec-async-semantics.test.ts×1 visibility-oracle-store.states.ts×1 | [ruled, amended in place 2026-07-08] Pending is per-node; store-wide only for the firewall's own work — **Pending is per-node: store-wide verdicts exist only as the firewall's own in-flight work (A9) … | | A23 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:241` | seat.ts×1 | spec-async-semantics.test.ts×1 | [ruled 2026-07-08] The `isPending` probe is reads-only — **The `isPending` probe is reads-only — the thunk's return value is never inspected.** `isPending(() => store)` reads nothing and reports `fals… | -| A24 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:159` | affects-marks.ts×1 affects.ts×1 constants.ts×1 lanes.ts×3 types.ts×1 verdict.ts×4 affects.ts×1 optimistic.ts×2 store.ts×1 | body-end-supersession-visibility.test.ts×1 create-deferred-3710.test.ts×2 optimistic-undefined-override.test.ts×1 reveal-gating-contract.test.ts×1 spec-async-semantics.test.ts×3 kanban-a17-fixture.test.ts×1 signal-store-twins-qd.test.ts×1 visibility-oracle-store.states.ts×4 visibility-oracle.states.ts×5 visibility-oracle.test.ts×1 | [ruled 2026-07-13] Question-scoped pending: pending iff a value change is in flight or an `affects()` mark is live — (**ruled 2026-07-13** — supersedes A20/A21; the converged model from the #2844/#272… | +| A24 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:159` | affects-marks.ts×1 affects.ts×1 constants.ts×1 guesses.ts×2 lanes.ts×1 types.ts×1 verdict.ts×4 affects.ts×1 optimistic.ts×2 store.ts×1 | body-end-supersession-visibility.test.ts×1 create-deferred-3710.test.ts×2 optimistic-undefined-override.test.ts×1 reveal-gating-contract.test.ts×1 spec-async-semantics.test.ts×3 kanban-a17-fixture.test.ts×1 signal-store-twins-qd.test.ts×1 visibility-oracle-store.states.ts×4 visibility-oracle.states.ts×5 visibility-oracle.test.ts×1 | [ruled 2026-07-13] Question-scoped pending: pending iff a value change is in flight or an `affects()` mark is live — (**ruled 2026-07-13** — supersedes A20/A21; the converged model from the #2844/#272… | | A25 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:311` | projection.ts×2 store.ts×1 | derived-presence-async-3726.test.ts×2 seedless-derived-store.test.ts×1 uninitialized-visibility.test.ts×3 visibility-oracle-store.states.ts×7 visibility-oracle-store.test.ts×1 | [ruled 2026-07-16] A derived store's seed is a draft, never an observable value — (**ruled 2026-07-16**, #2897) **A derived store's seed is a draft, never an observable value.** The seed exists for th… | | A26 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:111` | — | action-await-contract.test.ts×2 fuzz-findings-l2.test.ts×1 posture-store-parity.test.ts×2 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×1 visibility-oracle.test.ts×1 | [ruled 2026-07-17] An ambient transaction window is one flush; parking is flush-driven — (**ruled 2026-07-17**, #2913; **enforcement hardened 2026-08-31**, #3141 — parking is flush-driven, and a trans… | | A27 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:303` | — | loading-value.test.ts×2 visibility-oracle.states.ts×18 visibility-oracle.test.ts×1 | [ruled 2026-08-10] The commit-#0 loading window is loading-class and verdict-quiet — (**ruled 2026-08-10**) **The commit-#0 loading window is loading-class and verdict-quiet.** A node born committed v… | -| A28 | ruled, mechanism landed | `docs/SPEC-ASYNC-SEMANTICS.md:95` | constants.ts×1 core.ts×12 lanes.ts×2 scheduler.ts×3 seat.ts×3 types.ts×1 verdict.ts×2 store.ts×5 | continuation-sibling-reader-4146.test.ts×1 createOptimistic.test.ts×5 fuzz-findings-l2.test.ts×6 held-derivation-not-a-proposal-3612.test.ts×1 issue-3800-repro.test.ts×1 latest-held-till-flush.test.ts×1 latest-memo-inline-parity.test.ts×1 posture-store-parity.test.ts×5 question-scoped-pending.test.ts×3 snapshot-derived-store-rows.test.ts×1 createOptimisticStore.test.ts×10 optimistic-draft-visibility-3665.test.ts×5 optimistic-list-mutation-matrix.harness.ts×1 optimistic-list-mutation-matrix.test.ts×2 shallow.test.ts×1 woken-transaction-adopts-staged-bump.test.ts×1 treeshake.test.ts×2 verdict-contract.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle.states.ts×8 | [ruled, mechanism landed 2026-09-15] A write becomes visible at flush — to every channel — (**ruled 2026-09-08**; supersedes the #2922 mid-tick pull) **A write becomes visible at flush — to every chan… | +| A28 | ruled, mechanism landed | `docs/SPEC-ASYNC-SEMANTICS.md:95` | constants.ts×1 core.ts×12 guesses.ts×1 lanes.ts×1 scheduler.ts×3 seat.ts×3 types.ts×1 verdict.ts×2 store.ts×5 | continuation-sibling-reader-4146.test.ts×1 createOptimistic.test.ts×5 fuzz-findings-l2.test.ts×6 held-derivation-not-a-proposal-3612.test.ts×1 issue-3800-repro.test.ts×1 latest-held-till-flush.test.ts×1 latest-memo-inline-parity.test.ts×1 posture-store-parity.test.ts×5 question-scoped-pending.test.ts×3 snapshot-derived-store-rows.test.ts×1 createOptimisticStore.test.ts×10 optimistic-draft-visibility-3665.test.ts×5 optimistic-list-mutation-matrix.harness.ts×1 optimistic-list-mutation-matrix.test.ts×2 shallow.test.ts×1 woken-transaction-adopts-staged-bump.test.ts×1 treeshake.test.ts×2 verdict-contract.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle.states.ts×8 | [ruled, mechanism landed 2026-09-15] A write becomes visible at flush — to every channel — (**ruled 2026-09-08**; supersedes the #2922 mid-tick pull) **A write becomes visible at flush — to every chan… | | A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:119` | boundaries.ts×1 action.ts×1 constants.ts×1 core.ts×14 effect.ts×1 lanes.ts×1 scheduler.ts×4 signals.ts×1 store.ts×1 | adoption-unchanged-key-read-3706.test.ts×9 body-end-supersession-visibility.test.ts×1 born-held.test.ts×3 boundary-not-born-held-3540.test.ts×4 createProjection.draft-lifetime-3585.test.ts×1 direct-commit-readers-posture.test.ts×1 fallback-born-creator-4428.test.ts×1 fuzz-findings-l2.test.ts×6 held-branch-verdict-reader-4010.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 held-frame-verdict-parity.test.ts×1 held-truth-lane-only.test.ts×3 l2-contract.test.ts×1 latest-held-till-flush.test.ts×2 loading-fallback-in-flush-3540.test.ts×6 loading-on-frame-following-3540.test.ts×1 mount-over-foreign-hold-3761.test.ts×1 optimistic-mount-nested-memo-3835.test.ts×1 optimistic-read-lane-not-transaction-3698.test.ts×3 posture-born-held-and-observation.test.ts×1 posture-store-parity.test.ts×6 derived-presence-async-3726.test.ts×3 optimistic-untracked-reads-f3-f5.test.ts×1 store-unchanged-read-independent-write-3688.test.ts×1 tick-scoped-pass-transaction.test.ts×2 treeshake.test.ts×3 verdict-born-into-other-flush-4426.test.ts×1 verdict-mount-first-pass-3851.test.ts×2 verdict-mount-loading-flush-loop.test.ts×2 visibility-oracle-store.states.ts×5 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-09-13 (#3408)] A tracked read served a live transaction's staged value enters that transaction — A tracked computation served a node's staged `_pendingValue` — a value a … | | A30 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:259` | async.ts×3 attribution.ts×1 constants.ts×1 core.ts×1 effect.ts×1 lanes.ts×1 scheduler.ts×5 projection.ts×1 | async-landing-deps-3461.test.ts×3 fuzz-findings-l2.test.ts×3 held-conditional-effect.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 ispending-in-boundary-on-3528.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-frame-held-lane-3662.test.ts×1 posture-born-held-and-observation.test.ts×1 projection-peek-loop-4342.test.ts×1 treeshake.test.ts×2 write-proposals-3494.test.ts×2 zombie-rerun-after-commit-3546.test.ts×2 | [ruled 2026-09-13 (#3410)] A memo's dependencies are the committed frame's until the frame is replaced — A pass that _staged_ its value has not replaced the committed frame, so the committed value sti… | | A31 | live | `docs/SPEC-ASYNC-SEMANTICS.md:133` | boundaries.ts×1 core.ts×1 lanes.ts×1 verdict.ts×2 | fuzz-findings-l2.test.ts×6 ispending-combined-atomic-3442.test.ts×1 latest-pulled-pass-ispending.test.ts×1 probe-pulled-pass-4429.test.ts×1 unowned-memo-ispending-reader-4366.test.ts×1 verdict-memo-held-branch-4544.test.ts×1 | [live 2026-09-14 (#3442)] A memo computes under its own lane posture, never its puller's — A memo's value is one shared slot every reader sees, so its pass runs under the lane posture the memo itself … | | A32 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:141` | core.ts×4 lanes.ts×1 seat.ts×1 store.ts×1 | visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 | [ruled 2026-09-14] Children-forbidden readers see the frame, not the graph — `createTrackedEffect` and `onSettled` callbacks are effect-phase code that runs after the frame is decided. They read the f… | | A33 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:275` | boundaries.ts×1 scheduler.ts×2 | async-chain-supersession.test.ts×2 boundary-not-born-held-3540.test.ts×2 create-deferred-3710.test.ts×1 fuzz-findings-l2.test.ts×4 ispending-in-boundary-on-3528.test.ts×2 loading-reset-collects-forwarded-3459.test.ts×3 | [ruled 2026-09-12 (#3375)] A fallback-caught flight holds no transaction; a Loading reset moves the hold onto the boundary — A `` boundary showing its fallback is the display of everything un… | -| A34 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:285` | constants.ts×1 core.ts×6 lanes.ts×2 scheduler.ts×2 optimistic.ts×2 store.ts×7 | a34-writes-then-derivations.test.ts×2 continuation-sibling-reader-4146.test.ts×1 createMemo.test.ts×1 derived-write-then-derivation-3733.test.ts×1 finalize-reentry.test.ts×2 fuzz-findings-l2.test.ts×5 held-derivation-not-a-proposal-3612.test.ts×6 optimistic-guess-over-held-slot.test.ts×2 optimistic-list-mutation-matrix.test.ts×1 unchanged-presence-no-hold-3743.test.ts×3 woken-transaction-adopts-staged-bump.test.ts×1 transition-corpse-revival.test.ts×1 treeshake.test.ts×2 visibility-oracle.states.ts×2 write-proposals-3494.test.ts×5 | [ruled 2026-09-16 (#3494)] A write is a proposal: one on a held node entangles its tick; one that nets to the committed value is none — A write proposes a value for a node. **Held, both are suggestion… | +| A34 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:285` | constants.ts×1 core.ts×6 guesses.ts×2 scheduler.ts×2 optimistic.ts×2 store.ts×7 | a34-writes-then-derivations.test.ts×2 continuation-sibling-reader-4146.test.ts×1 createMemo.test.ts×1 derived-write-then-derivation-3733.test.ts×1 finalize-reentry.test.ts×2 fuzz-findings-l2.test.ts×5 held-derivation-not-a-proposal-3612.test.ts×6 optimistic-guess-over-held-slot.test.ts×2 optimistic-list-mutation-matrix.test.ts×1 unchanged-presence-no-hold-3743.test.ts×3 woken-transaction-adopts-staged-bump.test.ts×1 transition-corpse-revival.test.ts×1 treeshake.test.ts×2 visibility-oracle.states.ts×2 write-proposals-3494.test.ts×5 | [ruled 2026-09-16 (#3494)] A write is a proposal: one on a held node entangles its tick; one that nets to the committed value is none — A write proposes a value for a node. **Held, both are suggestion… | ## V — fixed violations | id | status | defined | cited in src | cited in tests | statement (at definition) | diff --git a/packages/signals/src/core/guesses.ts b/packages/signals/src/core/guesses.ts new file mode 100644 index 0000000000..a91b02e14f --- /dev/null +++ b/packages/signals/src/core/guesses.ts @@ -0,0 +1,378 @@ +// The guess layer: what only a written guess reaches (`createOptimistic`, +// `createOptimisticStore`). lanes.ts is the sub-hold core every lane needs +// — the lane record, link / blocked / reveal / landing, the lane read and a +// lane pass's tail — installed by verdict.ts's verdict lanes too; this +// module is the user's guess: written (`optimisticWrite`), opening its lane +// at the seam (`applyGuesses`), taken over by another action's lane +// (`take`), judged by its own pass (`laneOutcome`) or a write landing on it +// (`guessWrite`), corrected at the body's end (`laneCorrections`), given +// back at a revert landing (`revertLanding`). The core reaches these arms +// through `installGuessLayer` (lanes.ts) and `installGuessHooks` +// (scheduler.ts); every site is behind CONFIG_GUESS or `guessed`, which +// nothing but this module sets, so a bundle without optimism folds them +// (#2883: pay-for-use). + +import { + CONFIG_GUESS, + CONFIG_HELD, + CONFIG_OVERRIDE, + CONFIG_SLOT_NODE, + NOT_PENDING +} from "./constants.js"; +import { attrHooks } from "./attribution-hooks.js"; +import { ext } from "./core.js"; +import { covered, covers, latestOf, underOf } from "./truth.js"; +import { + armGuessing, + clock, + commitPendingNode, + GlobalQueue, + holdNode, + insertSubs, + installGuessHooks, + laneDirty, + list, + merge, + newTransaction, + nextQuestion, + ownFlights, + question, + resolveTx, + schedule, + txOf, + type Transaction +} from "./scheduler.js"; +import { + armGuessed, + dissolveLane, + guessFlights, + inFlight, + installGuessLayer, + landBeneath, + lanes, + marked, + markJudged, + newLane, + rerun, + setLaneValue +} from "./lanes.js"; +import type { Computed, Signal } from "./types.js"; + +/** Guesses written since the last seam (`[node, value, question, …]`). + * Applied at the seam, once the frame's verdict is known — the parent is + * the frame's transaction, and there is none to be optimistic over when the + * frame commits (the write is as if it never happened: nothing was + * applied). The lane's passes run in the next round of the same flush, so + * the guess is visible at flush like any write (A28). */ +const pendingGuesses: any[] = []; +/** What the writer sees of a node: an unflushed guess to it, else the + * lane's value or the committed one — what an optimistic updater composes + * on (a store setter's draft too, store/optimistic.ts). */ +export function guessedValueOf(n: Signal | Computed): T { + let g = pendingGuessOf(n); + return g !== NOT_PENDING || (n._config & CONFIG_OVERRIDE && (g = latestOf(n)) !== NOT_PENDING) + ? (g as T) + : n._value; +} +/** The unflushed guess to `n`, else NOT_PENDING. */ +export function pendingGuessOf(n: Signal | Computed): unknown { + for (let i = pendingGuesses.length - 3; i >= 0; i -= 3) + if (pendingGuesses[i] === n) return pendingGuesses[i + 1]; + return NOT_PENDING; +} +/** Guesses another action's lane took over (#4336): the node, its guess, + * the guess's lane, its question, the lane that took it. */ +const kept: any[] = []; +/** Lane `l` takes `n`'s guess (another action's), kept to come back if `l` + * reverts. Its readers saw the guess: they re-derive at the lane's reveal + * (and, a flight's, hold the lane while they would show it). `d`: a guess + * `l` takes without writing it (a store target's other slots) — the node + * shows its truth in `l`'s world until the guess comes back. */ +export function take(n: Signal, l: Transaction, d?: boolean): void { + const x = n._x!; + const g = txOf(n); + const v = latestOf(n); + kept.push(n, v, x._transaction, x._q, l); + rerun(n, l); + // The guess leaves the node: the screen shows what it covered; a truth + // that landed beneath it stays its staging — a landing held for its + // commit, or the taker's derivation. Without one, the guess is the + // taker's derivation. + if (x._shown) n._value = covered(n); + covers.delete(n); + x._shown = false; + n._config &= d ? ~(CONFIG_GUESS | CONFIG_OVERRIDE) : ~CONFIG_GUESS; + if (d) x._transaction = null; + else { + list(n, l); + if (n._pendingValue === NOT_PENDING) setLaneValue(n, l, v); + } +} +export function optimisticWrite(n: Signal | Computed, v: T | ((prev: T) => T)): T { + // What the user sees: an unflushed guess to the same node, else the lane's + // value or the committed one. The updater composes on it; guessing it + // again is no guess (the node's comparator, as for any write) — unless + // the node already carries one: the user re-asked, and the re-ask renews + // the guess's question and entangles its frame (#3347) without notifying. + const prev = guessedValueOf(n); + if (typeof v === "function") v = (v as (prev: T) => T)(prev); + if (n._equals && n._equals(prev, v) && !(n._config & CONFIG_GUESS)) return v; + pendingGuesses.push(n, v, question || nextQuestion()); + armGuessing(); + armGuessed(); + schedule(); + return v; +} +/** The seam: each guess becomes its node's lane value, in a lane — the + * node's own if it carries one (a later write into the same lane), else a + * new one under `parent` (the frame's transaction), under the hold already + * on the node (a guess over that transition's world — the truth it holds + * stays staged beneath, for the lane's end to commit), or under a + * transaction opened for the node's own in-flight refetch (the guess is + * that flight's observer — A17, "visible until its own fetch settles"). No + * parent: the guess is dropped. The truth is untouched; readers are + * dirtied for the next round. */ +function applyGuesses(parent: Transaction | null): void { + let lane: Transaction | null = null; + for (let i = 0; i < pendingGuesses.length; i += 3) { + const n = pendingGuesses[i] as Signal; + const v = pendingGuesses[i + 1]; + let changed = true; + // The frame already holding the slot: a guess over it is a second + // suggestion for the slot, and two cannot finish apart (A34 (1)) — the + // frames entangle. + let holder: Transaction | null = null; + if (n._config & CONFIG_OVERRIDE) { + // A lane's node already: a guess re-asked, or a derivation guessed + // over (its staging is void — the guess is the value now). The same + // value re-asked renews the question; nothing to notify. + changed = !n._equals || !n._equals(latestOf(n), v); + if (!(n._config & CONFIG_GUESS)) { + n._pendingValue = NOT_PENDING; + n._config |= CONFIG_GUESS; + } + setLaneValue(n, txOf(n), v); + holder = txOf(n)._parent; + } else { + let l: Transaction; + // A held node: a truth staged there, or what a corrected guess showed. + // The guess composes on it, so it ends with that hold — and with its + // own frame's (F-11): it lands only when both have (the board's rapid + // adds — a later add's row reverted with an earlier add's landing). + if (n._config & CONFIG_HELD) l = newLane((holder = txOf(n))); + else { + if (parent === null && inFlight(n)) parent = newTransaction(false); + if (parent === null) continue; + l = lane ??= newLane(parent); + } + // (A guess equal to a truth staged beneath it is confirmed at birth — + // A24 — and still re-derives its readers as the lane's: the truth's + // derivations are the transaction's world, the lane's are the + // screen's plus the guess (plan sec. 19) — a derivation reading a held write + // beside the guess must not show it. Two flights for one input, when + // the worlds coincide, is the price.) + // The guess is the lane's (`under`, until the reveal); a truth the + // holder staged stays the node's staging beneath it, for the lane's + // end to commit. + n._config |= CONFIG_OVERRIDE | CONFIG_GUESS; + list(n, l); + setLaneValue(n, l, v); + } + if (parent !== null && holder !== null) merge(parent, holder); + ext(n)._q = pendingGuesses[i + 2]; + if (changed) { + // The lane's members re-derive as its work (REACTIVE_LANE_DIRTY): a + // blocked lane's re-guess does not re-run its render effects as stale + // readers republishing the committed view (#3460). + laneDirty(n, txOf(n)); + } + } + pendingGuesses.length = 0; +} +/** The seam's guesses open their lanes — after the core has marked the + * lanes alive before them (lanes.ts `markJudged`: a lane born at the seam + * has no work to judge yet). */ +const applyGuessesAt = (parent: Transaction | null): void => { + markJudged(); + if (pendingGuesses.length !== 0) applyGuesses(parent); +}; + +/** The truth arrived for a written guess (A18): a correction dissolves the + * lane — the guess and everything derived from it is void, the truth is + * the parent's held write and the graph re-derives from it there, one frame + * at the parent's landing — while the display keeps what it shows until + * then. A confirmation is silent (A17): the truth stays staged beneath the + * guess for the parent's commit, the guess stays the value; only a reader + * of the truth (CONFIG_AUTHORITATIVE) is told its view changed. Either way + * the parent takes this node, not the tick that carried the truth (D-33): + * one landing answering two actions' guesses (a store re-ask over two + * rows) must not tie them together; a pass that derives from the held + * truth joins the parent on its own (`joinPass`). */ +/** The correction round is replacing a guess with the value it covered (no + * landing beneath it): observe's "reverted"; the lane gives back the + * guesses it took (#4336, lanes.ts `endLanes`, `revertLanding`). */ +let reverting = false; + +export function supersede(n: Signal | Computed, value: unknown, changed: boolean): void { + const l = txOf(n); + // Resolved: the parent may have merged into another transaction since the + // lane opened (two actions guessing one slot entangle, A34 (1)) — the + // truth is held by the transaction that lands, not the merged-away one. + const parent = resolveTx(l._parent ?? l); + // A store row answered by a new object the store would reconcile into + // the guessed one unchanged is an echo, not a correction (#3898): the + // server's object never matches the guess by reference. + if (changed && n._config & CONFIG_SLOT_NODE && GlobalQueue._echoes?.(latestOf(n), value)) + changed = false; + if (changed) { + // Observe: a displayed guess is being replaced by a differing truth — a + // landing's (superseded), or the value it covered (reverted: the body + // ended with nothing coming true). + if (__OBSERVE__ && l._shown && attrHooks !== null) + attrHooks.optimisticReverted(n, latestOf(n), value, reverting ? "reverted" : "superseded"); + dissolveLane(l, parent, n); + if (reverting) marked.add(l); + // What the screen showed stays the screen until the parent lands (A18 + // (c): display and untracked reads keep the override until the commit) + // — `_value` has it; the truth is the parent's staging. + if (l._shown) marked.add(n); + n._config &= ~(CONFIG_OVERRIDE | CONFIG_GUESS); + n._x!._shown = false; + covers.delete(n); + holdNode(n, parent); + n._pendingValue = value; + if (n._subs !== null) insertSubs(n); + } else { + landBeneath(n, value); + // A confirmation is silent (A17); only truth readers are told. + GlobalQueue._confirmed?.(l); + } +} + +/** A18 body-end corollary (#3427), at the seam before the park decision + * (the guesses' own passes have run; a correction's re-derivations run in + * one more pure round and are the parent's flights before it is judged — + * #3409: the indicators clear together): the action body having returned, + * a guess whose own truth is not in flight has no answer coming — the truth + * beneath it is its truth, and the correction starts now rather than at the + * lane's flight. (A guess whose own refetch is up is superseded by its + * landing.) True when a lane was judged. */ +function laneCorrections(): boolean { + let judged = false; + const live = lanes.slice(); + for (let k = 0; k < live.length; k++) { + const l = live[k]; + if (lanes.indexOf(l) === -1) continue; + const p = resolveTx(l._parent!); + if (!p._acted || p._open !== 0 || p._lane || ownFlights(p) || guessFlights(l)) continue; + judged = true; + // Each guess's truth: the one beneath it (a landing held there), else + // the one it covered. (A correction dissolves the lane — the others are + // re-homed with theirs, `dissolveLane`.) + for (let i = 0; i < l._nodes.length && lanes.indexOf(l) !== -1; i++) { + const n = l._nodes[i]; + if (n._config & CONFIG_GUESS && n._x!._transaction === l) { + const truth = underOf(n); + reverting = n._pendingValue === NOT_PENDING; + supersede(n, truth, !n._equals || !n._equals(latestOf(n), truth)); + reverting = false; + } + } + } + return judged; +} + +/** A write landing on a guess (lanes.ts `laneWrite`; core.ts `setSignal`: a + * user's write, an async landing): its truth (A18 — an async guess's own + * landing), judged against the guess. False: a store slot's guess its + * derive's re-ask in another action's lane writes is that lane's + * derivation from here (store `_slotTake`, #4336) — the core's derivation + * arm takes it. */ +function guessWrite(el: Signal | Computed, v: unknown): boolean { + if (GlobalQueue._slotTake?.(el)) return false; + // Provenance (A18, #3331; Q-D, plan sec. 39): a write asking an OLDER + // question than the guess's — another action's landing beneath it — + // is not its answer: held beneath (the truth for the commit; the + // guess's own question judges), and nothing moves. The writer's + // question is the one being asked (`question`: a slice's, a derive's + // continuation's — the flight's); unstamped writes and mainline are + // current. + // A store re-bases a keyed arrangement guess over an older truth, and + // folds a current one beneath it (D-34): true. + const older = stale(el, question); + if (GlobalQueue._laneRebase?.(el, v, older) || older) landBeneath(el, v); + else supersede(el, v, !el._equals || !el._equals(latestOf(el), v)); + schedule(); + return true; +} + +/** A written guess's own pass finished: its source recomputed it — the + * truth (A18: "the source is whatever recomputes the node"), authoritative + * or the lane's own derivation (a guess over `config().courier` under a + * country guess: the lane's config landing confirms or corrects it). An + * errored pass stages nothing. Provenance (A18, #3331): "the source" is the + * guess's own question or a newer one; an older action's answer landing + * over a newer guess (the two entangled when the newer guess was written) + * is stale — a slow source leaking back in over the user's latest intent. + * It is staged beneath the guess, for the commit like any landing, and + * nothing moves: no downstream re-ask, no pending flip on the guess's + * readers (`isPending` of the guess itself says the held truth differs, + * A24). The guess's own question answering supersedes as usual. */ +function laneOutcome(el: Computed, value: unknown, errored: boolean): boolean { + if (errored) return true; + if (stale(el, answered(el))) { + landBeneath(el, value); + return true; + } + supersede(el, value, !el._equals || !el._equals(latestOf(el), value)); + return true; +} + +/** THE provenance test, for a derivation's pass and a write alike: an + * answer to question `q` landing on a guess is stale when `q` is older + * than the guess's own; unstamped (0) and mainline are current. */ +function stale(el: Signal | Computed, q: number): boolean { + return q !== 0 && q < el._x!._q; +} + +/** The question a derivation's pass answered: the newest among the stamped + * sources that changed this round (a flight's landing carries the question + * that started it); 0 when none is stamped. */ +function answered(el: Computed): number { + let q = 0; + for (let l = el._deps; l !== null; l = l._nextDep) { + const d = l._dep as Computed; + if (d._x !== null && d._x._q > q && d._time === clock) q = d._x._q; + } + return q; +} + +/** A revert landing (#4336): the guesses its lane took from another action + * that is still out come back in this frame, over the truth it lands — its + * readers re-derive with the landing (one frame, no bare truth between). + * Taken by a later lane since, a node stays that lane's. */ +function revertLanding(u: Transaction): void { + for (let i = kept.length - 5; i >= 0; i -= 5) + if (resolveTx(kept[i + 4]._parent) === u) { + let [n, v, g, q, t] = kept.splice(i, 5); + // (A store slot's node now: the one taken, or a read's since.) + if ( + marked.has(t) && + lanes.includes(g) && + (!(n._config & CONFIG_SLOT_NODE) || (n = GlobalQueue._slotTake!(n, true))) + ) { + const x = ext(n); + if (x._transaction === null || txOf(n) === u) { + commitPendingNode(n); + x._q = q; + n._config |= CONFIG_OVERRIDE | CONFIG_GUESS; + list(n, g); + setLaneValue(n, g, v); + rerun(n, u); + } + } + } +} + +installGuessLayer(take, guessWrite, revertLanding); +installGuessHooks(laneOutcome, applyGuessesAt, () => lanes.length !== 0 && laneCorrections()); diff --git a/packages/signals/src/core/lanes.ts b/packages/signals/src/core/lanes.ts index 350b2c93f6..80d5da272d 100644 --- a/packages/signals/src/core/lanes.ts +++ b/packages/signals/src/core/lanes.ts @@ -74,7 +74,7 @@ import { removePendingSource, settlePendingSource } from "./async.js"; -import { covered, covers, latestOf, underOf } from "./truth.js"; +import { covers, latestOf, underOf } from "./truth.js"; import { enqueueSub } from "./heap.js"; import { blocked, @@ -89,12 +89,9 @@ import { list, stagedReaders, staleReader, - merge, newTransaction, - nextQuestion, ownFlights, passLane, - question, queuePendingNode, releaseQueues, reruns, @@ -108,8 +105,7 @@ import { type Transaction, globalQueue, hiddenHook, - installLaneHooks, - armGuessing + installLaneHooks } from "./scheduler.js"; import { SLOT_C, SLOT_DV, SLOT_LV, SLOT_P, SLOT_T, shadowActual } from "./seat.js"; import type { Computed, Owner, Signal } from "./types.js"; @@ -117,13 +113,13 @@ import type { Computed, Owner, Signal } from "./types.js"; export { latestOf }; /** Live lanes (parented). Scanned at every seam while non-empty. */ -const lanes: Transaction[] = []; +export const lanes: Transaction[] = []; /** A pass left a shown lane (`laneStage`): the node's notify stamp * (`_notifiedAt`, never negative once it notifies — `insertSubs` overwrites * it, so a pass that does notify clears the mark). The seam wakes its * readers (#3892). */ const LEFT_SHOWN = -2; -function newLane(parent: Transaction): Transaction { +export function newLane(parent: Transaction): Transaction { const l = newTransaction(true, parent); lanes.push(l); return l; @@ -155,179 +151,70 @@ function cover(n: Signal): void { /** A truth landed beneath a guess: the parent's staging, held for its * landing to commit (CONFIG_HELD) — an older question's answer (A18), or the * guess's confirmation (A24). The guess stays the value. */ -function landBeneath(n: Signal | Computed, truth: unknown): void { +export function landBeneath(n: Signal | Computed, truth: unknown): void { n._pendingValue = truth; n._config |= CONFIG_HELD; } -/** Guesses written since the last seam (`[node, value, question, …]`). - * Applied at the seam, once the frame's verdict is known — the parent is - * the frame's transaction, and there is none to be optimistic over when the - * frame commits (the write is as if it never happened: nothing was - * applied). The lane's passes run in the next round of the same flush, so - * the guess is visible at flush like any write (A28). */ -const pendingGuesses: any[] = []; -/** What the writer sees of a node: an unflushed guess to it, else the - * lane's value or the committed one — what an optimistic updater composes - * on (a store setter's draft too, store/optimistic.ts). */ -export function guessedValueOf(n: Signal | Computed): T { - let g = pendingGuessOf(n); - return g !== NOT_PENDING || (n._config & CONFIG_OVERRIDE && (g = latestOf(n)) !== NOT_PENDING) - ? (g as T) - : n._value; -} -/** The unflushed guess to `n`, else NOT_PENDING. */ -export function pendingGuessOf(n: Signal | Computed): unknown { - for (let i = pendingGuesses.length - 3; i >= 0; i -= 3) - if (pendingGuesses[i] === n) return pendingGuesses[i + 1]; - return NOT_PENDING; -} /** This module's copy of scheduler.ts `guessing`: its readers here stay * foldable when a bundler splits lanes.ts from scheduler.ts into separate * chunks (a cross-chunk binding is not folded; the compiled live page). */ let guessed = false; -/** Guesses another action's lane took over (#4336): the node, its guess, - * the guess's lane, its question, the lane that took it. */ -const kept: any[] = []; +/** A guess was written (guesses.ts `optimisticWrite`). */ +export function armGuessed(): void { + guessed = true; +} +// The guess layer (guesses.ts; installed with `createOptimistic` or +// `createOptimisticStore`): the arms only a written guess reaches. `take` +// — a lane takes another action's guess (`laneStage`); `guessWrite` — a +// write landing on a guess (`laneWrite`); `revertLanding` — a revert +// landing gives back the guesses its lane took (`endLanes`). Each site is +// behind CONFIG_GUESS or `guessed`, which nothing but the layer sets: a +// bundle without it folds the sites. +export let takeHook: ((n: Signal, l: Transaction, d?: boolean) => void) | null = null; +export let guessWriteHook: ((el: Signal | Computed, v: unknown) => boolean) | null = null; +export let revertLandingHook: ((u: Transaction) => void) | null = null; +export function installGuessLayer( + take: NonNullable, + write: NonNullable, + revert: NonNullable +): void { + takeHook = take; + guessWriteHook = write; + revertLandingHook = revert; +} /** Two kinds of member, one set (a lane is never a node). Lanes a revert * dissolved: the guesses they took come back at their parent's landing * (`endLanes`). Shown guesses a correction re-homed into their hold - * (`supersede`, `dissolveLane`): the slot's value for the screen and + * (guesses.ts `supersede`, `dissolveLane`): the slot's value for the screen and * untracked reads until that hold lands (D-34), each keeps it open on its * own flight as it did while a guess (`lanesBlocked`, #4690); the hold's * landing clears them (`endLanes`). */ -const marked = /* @__PURE__ */ new WeakSet>(); -/** A shown guess a correction re-homed into its hold (`supersede`, +export const marked = /* @__PURE__ */ new WeakSet>(); +/** A shown guess a correction re-homed into its hold (guesses.ts `supersede`, * `dissolveLane`): the screen's and the untracked reads' value until the * commit, and `latest`'s (D-34, decision 3 of 2026-11-05, #4689) — the * displayed slot's newest value is the guess, the truth its staging. */ export function keptGuess(n: Signal | Computed): boolean { return guessed && marked.has(n); } -/** Lane `l` takes `n`'s guess (another action's), kept to come back if `l` - * reverts. Its readers saw the guess: they re-derive at the lane's reveal - * (and, a flight's, hold the lane while they would show it). `d`: a guess - * `l` takes without writing it (a store target's other slots) — the node - * shows its truth in `l`'s world until the guess comes back. */ -export function take(n: Signal, l: Transaction, d?: boolean): void { - const x = n._x!; - const g = txOf(n); - const v = latestOf(n); - kept.push(n, v, x._transaction, x._q, l); - rerun(n, l); - // The guess leaves the node: the screen shows what it covered; a truth - // that landed beneath it stays its staging — a landing held for its - // commit, or the taker's derivation. Without one, the guess is the - // taker's derivation. - if (x._shown) n._value = covered(n); - covers.delete(n); - x._shown = false; - n._config &= d ? ~(CONFIG_GUESS | CONFIG_OVERRIDE) : ~CONFIG_GUESS; - if (d) x._transaction = null; - else { - list(n, l); - if (n._pendingValue === NOT_PENDING) setLaneValue(n, l, v); - } -} /** `n`'s readers are stale readers of `t` (re-derived at its landing). */ -function rerun(n: Signal, t: Transaction): void { +export function rerun(n: Signal, t: Transaction): void { for (let s = n._subs; s !== null; s = s._nextSub) staleReader(s._sub, t); // A store's guess carrier: the readers of the keys it changed read their // leaves (store/optimistic.ts). if (n._config & CONFIG_SLOT_NODE) GlobalQueue._slotRerun?.(n, t); } -export function optimisticWrite(n: Signal | Computed, v: T | ((prev: T) => T)): T { - // What the user sees: an unflushed guess to the same node, else the lane's - // value or the committed one. The updater composes on it; guessing it - // again is no guess (the node's comparator, as for any write) — unless - // the node already carries one: the user re-asked, and the re-ask renews - // the guess's question and entangles its frame (#3347) without notifying. - const prev = guessedValueOf(n); - if (typeof v === "function") v = (v as (prev: T) => T)(prev); - if (n._equals && n._equals(prev, v) && !(n._config & CONFIG_GUESS)) return v; - pendingGuesses.push(n, v, question || nextQuestion()); - armGuessing(); - guessed = true; - schedule(); - return v; -} -/** The seam: each guess becomes its node's lane value, in a lane — the - * node's own if it carries one (a later write into the same lane), else a - * new one under `parent` (the frame's transaction), under the hold already - * on the node (a guess over that transition's world — the truth it holds - * stays staged beneath, for the lane's end to commit), or under a - * transaction opened for the node's own in-flight refetch (the guess is - * that flight's observer — A17, "visible until its own fetch settles"). No - * parent: the guess is dropped. The truth is untouched; readers are - * dirtied for the next round. */ /** A guess's own truth is in flight: the node's own refetch — or, a store * leaf's, its family's derive (the slot's flight; store/optimistic.ts * installs the resolver). A17: the guess stands in for the flight. */ -function inFlight(n: Signal): unknown { +export function inFlight(n: Signal): unknown { return ( (n as Computed)._statusFlags & STATUS_PENDING || (n._config & CONFIG_SLOT_NODE && GlobalQueue._slotFlight?.(n)) ); } -function applyGuesses(parent: Transaction | null): void { - let lane: Transaction | null = null; - for (let i = 0; i < pendingGuesses.length; i += 3) { - const n = pendingGuesses[i] as Signal; - const v = pendingGuesses[i + 1]; - let changed = true; - // The frame already holding the slot: a guess over it is a second - // suggestion for the slot, and two cannot finish apart (A34 (1)) — the - // frames entangle. - let holder: Transaction | null = null; - if (n._config & CONFIG_OVERRIDE) { - // A lane's node already: a guess re-asked, or a derivation guessed - // over (its staging is void — the guess is the value now). The same - // value re-asked renews the question; nothing to notify. - changed = !n._equals || !n._equals(latestOf(n), v); - if (!(n._config & CONFIG_GUESS)) { - n._pendingValue = NOT_PENDING; - n._config |= CONFIG_GUESS; - } - setLaneValue(n, txOf(n), v); - holder = txOf(n)._parent; - } else { - let l: Transaction; - // A held node: a truth staged there, or what a corrected guess showed. - // The guess composes on it, so it ends with that hold — and with its - // own frame's (F-11): it lands only when both have (the board's rapid - // adds — a later add's row reverted with an earlier add's landing). - if (n._config & CONFIG_HELD) l = newLane((holder = txOf(n))); - else { - if (parent === null && inFlight(n)) parent = newTransaction(false); - if (parent === null) continue; - l = lane ??= newLane(parent); - } - // (A guess equal to a truth staged beneath it is confirmed at birth — - // A24 — and still re-derives its readers as the lane's: the truth's - // derivations are the transaction's world, the lane's are the - // screen's plus the guess (plan sec. 19) — a derivation reading a held write - // beside the guess must not show it. Two flights for one input, when - // the worlds coincide, is the price.) - // The guess is the lane's (`under`, until the reveal); a truth the - // holder staged stays the node's staging beneath it, for the lane's - // end to commit. - n._config |= CONFIG_OVERRIDE | CONFIG_GUESS; - list(n, l); - setLaneValue(n, l, v); - } - if (parent !== null && holder !== null) merge(parent, holder); - ext(n)._q = pendingGuesses[i + 2]; - if (changed) { - // The lane's members re-derive as its work (REACTIVE_LANE_DIRTY): a - // blocked lane's re-guess does not re-run its render effects as stale - // readers republishing the committed view (#3460). - laneDirty(n, txOf(n)); - } - } - pendingGuesses.length = 0; -} - /** The running pass read lane `l`'s work as a derivation: it is `l`'s — or, * already another lane's, the frame it computes derives from both guesses * and cannot show one without the other (#3335, A15 for lanes): the two @@ -525,7 +412,7 @@ export function laneStage( el._x!._transaction?._lane && resolveTx(el._x!._transaction!._parent!) !== resolveTx(l._parent!) ) - take(el, l); + takeHook!(el, l); else if (!errored) el._config &= ~CONFIG_GUESS; } // A leaf has no lane value to seat it (`recompute`): one left waiting on @@ -554,58 +441,6 @@ export function laneStage( return true; } -/** The truth arrived for a written guess (A18): a correction dissolves the - * lane — the guess and everything derived from it is void, the truth is - * the parent's held write and the graph re-derives from it there, one frame - * at the parent's landing — while the display keeps what it shows until - * then. A confirmation is silent (A17): the truth stays staged beneath the - * guess for the parent's commit, the guess stays the value; only a reader - * of the truth (CONFIG_AUTHORITATIVE) is told its view changed. Either way - * the parent takes this node, not the tick that carried the truth (D-33): - * one landing answering two actions' guesses (a store re-ask over two - * rows) must not tie them together; a pass that derives from the held - * truth joins the parent on its own (`joinPass`). */ -/** The correction round is replacing a guess with the value it covered (no - * landing beneath it): observe's "reverted"; the lane gives back the - * guesses it took (#4336, `endLanes`). */ -let reverting = false; - -export function supersede(n: Signal | Computed, value: unknown, changed: boolean): void { - const l = txOf(n); - // Resolved: the parent may have merged into another transaction since the - // lane opened (two actions guessing one slot entangle, A34 (1)) — the - // truth is held by the transaction that lands, not the merged-away one. - const parent = resolveTx(l._parent ?? l); - // A store row answered by a new object the store would reconcile into - // the guessed one unchanged is an echo, not a correction (#3898): the - // server's object never matches the guess by reference. - if (changed && n._config & CONFIG_SLOT_NODE && GlobalQueue._echoes?.(latestOf(n), value)) - changed = false; - if (changed) { - // Observe: a displayed guess is being replaced by a differing truth — a - // landing's (superseded), or the value it covered (reverted: the body - // ended with nothing coming true). - if (__OBSERVE__ && l._shown && attrHooks !== null) - attrHooks.optimisticReverted(n, latestOf(n), value, reverting ? "reverted" : "superseded"); - dissolveLane(l, parent, n); - if (guessed && reverting) marked.add(l); - // What the screen showed stays the screen until the parent lands (A18 - // (c): display and untracked reads keep the override until the commit) - // — `_value` has it; the truth is the parent's staging. - if (l._shown && guessed) marked.add(n); - n._config &= ~(CONFIG_OVERRIDE | CONFIG_GUESS); - n._x!._shown = false; - covers.delete(n); - holdNode(n, parent); - n._pendingValue = value; - if (n._subs !== null) insertSubs(n); - } else { - landBeneath(n, value); - // A confirmation is silent (A17); only truth readers are told. - GlobalQueue._confirmed?.(l); - } -} - /** A lane's end, two ways. `into === null`: the parent landed — the lane's * values are the truth now: a guess lands the truth staged beneath it or * reverts to the one it covered (`_value`, untouched by the guess); a @@ -616,7 +451,7 @@ export function supersede(n: Signal | Computed, value: unknown, change * against what is seen), a truth staged beneath a guess is the parent's to * land, and the runs it held (showing the void guess) are dropped: the * parent's re-derivation makes the runs that show. */ -function dissolveLane(l: Transaction, into: Transaction | null, except?: Signal): void { +export function dissolveLane(l: Transaction, into: Transaction | null, except?: Signal): void { const k = lanes.indexOf(l); if (k !== -1) lanes.splice(k, 1); unlink(l); @@ -879,7 +714,7 @@ export function laneRead(c: Computed | null, el: Signal | Computed; if (n._config & CONFIG_GUESS && n._x!._transaction === l && inFlight(n)) return true; @@ -892,39 +727,6 @@ function guessFlights(l: Transaction): boolean { * the lane shows: its values are the screen from now (`_shown`), the * staging its passes made since the last reveal is promoted, their frames * (children) apply, the stale readers re-derive (#3460), its runs go. */ -/** A18 body-end corollary (#3427), at the seam before the park decision - * (the guesses' own passes have run; a correction's re-derivations run in - * one more pure round and are the parent's flights before it is judged — - * #3409: the indicators clear together): the action body having returned, - * a guess whose own truth is not in flight has no answer coming — the truth - * beneath it is its truth, and the correction starts now rather than at the - * lane's flight. (A guess whose own refetch is up is superseded by its - * landing.) True when a lane was judged. */ -function laneCorrections(): boolean { - let judged = false; - const live = lanes.slice(); - for (let k = 0; k < live.length; k++) { - const l = live[k]; - if (lanes.indexOf(l) === -1) continue; - const p = resolveTx(l._parent!); - if (!p._acted || p._open !== 0 || p._lane || ownFlights(p) || guessFlights(l)) continue; - judged = true; - // Each guess's truth: the one beneath it (a landing held there), else - // the one it covered. (A correction dissolves the lane — the others are - // re-homed with theirs, `dissolveLane`.) - for (let i = 0; i < l._nodes.length && lanes.indexOf(l) !== -1; i++) { - const n = l._nodes[i]; - if (n._config & CONFIG_GUESS && n._x!._transaction === l) { - const truth = underOf(n); - if (__OBSERVE__ || guessed) reverting = n._pendingValue === NOT_PENDING; - supersede(n, truth, !n._equals || !n._equals(latestOf(n), truth)); - if (__OBSERVE__ || guessed) reverting = false; - } - } - } - return judged; -} - function laneSeam(l: Transaction, leaked: boolean): void { // Blocked — or one of its passes read a write the frame holds this seam: // its runs wait, the pass re-derives on the screen next round. @@ -986,31 +788,9 @@ function laneSeam(l: Transaction, leaked: boolean): void { * blocked lane blocks its parent.) */ function endLanes(u: Transaction): void { if (guessed) for (const n of u._nodes) marked.delete(n); - // A revert landing (#4336): the guesses its lane took from another action - // that is still out come back in this frame, over the truth it lands — - // its readers re-derive with the landing (one frame, no bare truth - // between). Taken by a later lane since, a node stays that lane's. - if (guessed) - for (let i = kept.length - 5; i >= 0; i -= 5) - if (resolveTx(kept[i + 4]._parent) === u) { - let [n, v, g, q, t] = kept.splice(i, 5); - // (A store slot's node now: the one taken, or a read's since.) - if ( - marked.has(t) && - lanes.includes(g) && - (!(n._config & CONFIG_SLOT_NODE) || (n = GlobalQueue._slotTake!(n, true))) - ) { - const x = ext(n); - if (x._transaction === null || txOf(n) === u) { - commitPendingNode(n); - x._q = q; - n._config |= CONFIG_OVERRIDE | CONFIG_GUESS; - list(n, g); - setLaneValue(n, g, v); - rerun(n, u); - } - } - } + // A revert landing (#4336): the guesses its lane took from another + // action come back in this frame (guesses.ts `revertLanding`). + if (guessed) revertLandingHook!(u); for (let k = lanes.length - 1; k >= 0; k--) { const l = lanes[k]; if (resolveTx(l._parent!) !== u) continue; @@ -1159,86 +939,30 @@ function nestedBlocked(t: Transaction): boolean { * latest: its staging once the lane has shown (promoted at the next * reveal), its slot before; the lane's members re-derive as its work. */ function laneWrite(el: Signal | Computed, v: T): T { - // (A store slot's guess its derive's re-ask in another action's lane - // writes is that lane's derivation from here — store `_slotTake`, #4336.) - if (el._config & CONFIG_GUESS && !(guessed && GlobalQueue._slotTake?.(el))) { - // Provenance (A18, #3331; Q-D, plan sec. 39): a write asking an OLDER - // question than the guess's — another action's landing beneath it — - // is not its answer: held beneath (the truth for the commit; the - // guess's own question judges), and nothing moves. The writer's - // question is the one being asked (`question`: a slice's, a derive's - // continuation's — the flight's); unstamped writes and mainline are - // current. - // A store re-bases a keyed arrangement guess over an older truth, and - // folds a current one beneath it (D-34): true. - const older = stale(el, question); - if (GlobalQueue._laneRebase?.(el, v, older) || older) { - landBeneath(el, v); - schedule(); - return v; - } - supersede(el, v, !el._equals || !el._equals(latestOf(el) as T, v)); - } else { - const l = txOf(el); - if (el._equals && el._equals(latestOf(el) as T, v)) return v; - el._pendingValue = v; - if ((el as any)._fn !== undefined) (el as Computed)._time = clock; - laneDirty(el, l); - } + // A write on a guess: the guess layer's (guesses.ts `guessWrite`) — + // judged against the guess, or held beneath it; false: a store slot's + // guess its derive's re-ask in another action's lane writes is that + // lane's derivation from here (store `_slotTake`, #4336). + if (el._config & CONFIG_GUESS && guessWriteHook!(el, v)) return v; + const l = txOf(el); + if (el._equals && el._equals(latestOf(el) as T, v)) return v; + el._pendingValue = v; + if ((el as any)._fn !== undefined) (el as Computed)._time = clock; + laneDirty(el, l); schedule(); return v; } -/** A written guess's own pass finished: its source recomputed it — the - * truth (A18: "the source is whatever recomputes the node"), authoritative - * or the lane's own derivation (a guess over `config().courier` under a - * country guess: the lane's config landing confirms or corrects it). An - * errored pass stages nothing. Provenance (A18, #3331): "the source" is the - * guess's own question or a newer one; an older action's answer landing - * over a newer guess (the two entangled when the newer guess was written) - * is stale — a slow source leaking back in over the user's latest intent. - * It is staged beneath the guess, for the commit like any landing, and - * nothing moves: no downstream re-ask, no pending flip on the guess's - * readers (`isPending` of the guess itself says the held truth differs, - * A24). The guess's own question answering supersedes as usual. */ -function laneOutcome(el: Computed, value: unknown, errored: boolean): boolean { - if (errored) return true; - if (stale(el, answered(el))) { - landBeneath(el, value); - return true; - } - supersede(el, value, !el._equals || !el._equals(latestOf(el), value)); - return true; -} - -/** THE provenance test, for a derivation's pass and a write alike: an - * answer to question `q` landing on a guess is stale when `q` is older - * than the guess's own; unstamped (0) and mainline are current. */ -function stale(el: Signal | Computed, q: number): boolean { - return q !== 0 && q < el._x!._q; -} - -/** The question a derivation's pass answered: the newest among the stamped - * sources that changed this round (a flight's landing carries the question - * that started it); 0 when none is stamped. */ -function answered(el: Computed): number { - let q = 0; - for (let l = el._deps; l !== null; l = l._nextDep) { - const d = l._dep as Computed; - if (d._x !== null && d._x._q > q && d._time === clock) q = d._x._q; - } - return q; -} - /** The lanes alive before this seam's guesses opened theirs (a prefix of * `lanes`; nothing dissolves one between here and the seam loop): a lane * born at the seam has no work to judge yet (its passes run next round) — * it is neither shown nor blocked until it has. */ let judged = 0; -const applyGuessesAt = (parent: Transaction | null): void => { +/** The guess layer's seam (guesses.ts `applyGuessesAt`), before its + * guesses open their lanes. */ +export function markJudged(): void { judged = lanes.length; - if (pendingGuesses.length !== 0) applyGuesses(parent); -}; +} /** `t` is parked by `r`'s pass alone: each node keeping it — `t`'s own, or * a lane's under it — is `r` itself (its flight, in the verdict lane) or a * render effect pending on `r` only: the frame observing the lane work that @@ -1479,11 +1203,8 @@ const entered: Computed[] = []; installLaneHooks( laneRead, laneStage, - laneOutcome, laneWrite, - applyGuessesAt, laneSeams, - () => lanes.length !== 0 && laneCorrections(), landing, lanesBlocked, adoptParked, diff --git a/packages/signals/src/core/scheduler.ts b/packages/signals/src/core/scheduler.ts index 1770a47e7f..18d08e66aa 100644 --- a/packages/signals/src/core/scheduler.ts +++ b/packages/signals/src/core/scheduler.ts @@ -93,7 +93,7 @@ export let laneAdoptHook: ((r: Computed) => boolean) | null = null; * committed value (lanes.ts `laneServed`). */ export let laneServedHook: ((c: Computed, el: Signal | Computed) => void) | null = null; -/** A guess was written (lanes.ts `optimisticWrite`): the arms only a guess +/** A guess was written (guesses.ts `optimisticWrite`): the arms only a guess * reaches (CONFIG_GUESS) — a build without `createOptimistic` or * `createOptimisticStore` never sets it, and its bundler folds them. */ export let guessing = false; @@ -103,11 +103,8 @@ export function armGuessing(): void { export function installLaneHooks( read: NonNullable, stage: NonNullable, - outcome: NonNullable, write: NonNullable, - applyGuesses: NonNullable, seams: NonNullable, - corrections: NonNullable, end: NonNullable, blocked: NonNullable, adopt: NonNullable, @@ -115,16 +112,27 @@ export function installLaneHooks( ): void { laneReadHook = read; laneStageHook = stage; - laneOutcomeHook = outcome; laneWriteHook = write; - applyGuessesHook = applyGuesses; laneSeamsHook = seams; - laneCorrectionsHook = corrections; endLanesHook = end; lanesBlockedHook = blocked; laneAdoptHook = adopt; laneServedHook = served; } +// The guess layer (guesses.ts; installed when `createOptimistic` or +// `createOptimisticStore` is imported): a written guess's own pass judged +// (`laneOutcome`, core.ts `recompute`), the seam's guesses opening their +// lanes (`applyGuessesAt`), the body-end corrections (`laneCorrections`). +// Null without it: every site tolerates it. +export function installGuessHooks( + outcome: NonNullable, + applyGuesses: NonNullable, + corrections: NonNullable +): void { + laneOutcomeHook = outcome; + applyGuessesHook = applyGuesses; + laneCorrectionsHook = corrections; +} // Boundaries (boundaries.ts): the display consumers between an observer // and the root. `catch` — status from a frame reader, nearest boundary // first (true: caught, the root never hears of it; a clear — flags 0 — diff --git a/packages/signals/src/signals.ts b/packages/signals/src/signals.ts index b86de231b4..6bef550d6b 100644 --- a/packages/signals/src/signals.ts +++ b/packages/signals/src/signals.ts @@ -42,7 +42,7 @@ import { } from "./core/scheduler.js"; import { REACTIVE_JOINED, STATUS_ERROR, STATUS_PENDING } from "./core/constants.js"; import { unwrapStatusError } from "./core/error.js"; -import { optimisticWrite } from "./core/lanes.js"; +import { optimisticWrite } from "./core/guesses.js"; import { truthConfirmed, truthRead } from "./core/truth.js"; /** diff --git a/packages/signals/src/store/optimistic.ts b/packages/signals/src/store/optimistic.ts index baf394e622..325d4e2880 100644 --- a/packages/signals/src/store/optimistic.ts +++ b/packages/signals/src/store/optimistic.ts @@ -49,14 +49,8 @@ import { import { link } from "../core/graph.js"; import { getObserver } from "../core/owner.js"; import { devGuardOptimisticBeforeLoad } from "../core/dev.js"; -import { - guessedValueOf, - latestOf, - optimisticWrite, - pendingGuessOf, - setLaneValue, - take -} from "../core/lanes.js"; +import { latestOf, setLaneValue } from "../core/lanes.js"; +import { guessedValueOf, optimisticWrite, pendingGuessOf, take } from "../core/guesses.js"; import { covered } from "../core/truth.js"; import { clock, diff --git a/packages/signals/tests/treeshake.test.ts b/packages/signals/tests/treeshake.test.ts index 630bcefdd8..1a6e6f0494 100644 --- a/packages/signals/tests/treeshake.test.ts +++ b/packages/signals/tests/treeshake.test.ts @@ -87,6 +87,7 @@ describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => { "deferred.ts", "core/verdict.ts", "core/lanes.ts", + "core/guesses.ts", "core/action.ts", "core/context.ts" ]) @@ -478,6 +479,7 @@ describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => { retainedFrom(retained, [ "core/verdict.ts", "core/lanes.ts", + "core/guesses.ts", "affects.ts", "boundaries.ts", "map.ts" @@ -510,7 +512,12 @@ describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => { const { retained } = await bundleFixture( `export { createSignal, createEffect, createRoot, flush, createOptimistic } from "sigsrc";` ); - expect(retainedFrom(retained, ["core/lanes.ts"])).toEqual(["core/lanes.ts"]); + // The lane engine and its guess layer (guesses.ts: the written guess — + // `optimisticWrite`, `applyGuesses`, `supersede`, `laneCorrections`). + expect(retainedFrom(retained, ["core/lanes.ts", "core/guesses.ts"])).toEqual([ + "core/lanes.ts", + "core/guesses.ts" + ]); }); it("createDeferred loads the deferred module and the mark core, and nothing else new", async () => { @@ -532,6 +539,7 @@ describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => { "affects.ts", "core/verdict.ts", "core/lanes.ts", + "core/guesses.ts", "core/action.ts" ]) ).toEqual([]); @@ -559,7 +567,12 @@ describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => { // lanes, and if a future round decouples the verdict lane from the // engine this expectation is the one to flip to an exclusion. expect(retainedFrom(retained, ["core/lanes.ts"])).toEqual(["core/lanes.ts"]); - expect(retainedFrom(retained, ["store/", "boundaries.ts", "map.ts", "affects.ts"])).toEqual([]); + // Not the guess layer: a verdict lane is the core's, and nothing in a + // bundle without `createOptimistic` writes a guess (pay-for-use; the + // split measured -531 B brotli on `+ isPending/latest`, 2026-11-10). + expect( + retainedFrom(retained, ["core/guesses.ts", "store/", "boundaries.ts", "map.ts", "affects.ts"]) + ).toEqual([]); }); // ---- dist-artifact assertions ---- @@ -637,6 +650,7 @@ describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => { "affects.js", "core/verdict.js", "core/lanes.js", + "core/guesses.js", "core/action.js", "core/context.js" ]) diff --git a/scripts/size/floor-caps.json b/scripts/size/floor-caps.json index 1e9b9cfe92..7f625d5aee 100644 --- a/scripts/size/floor-caps.json +++ b/scripts/size/floor-caps.json @@ -16,8 +16,8 @@ "minified": 102212 }, "page: live server components (base + live/GET + action + isPending/latest)": { - "cap": "40.92 KB", - "minified": 123431 + "cap": "40.43 KB", + "minified": 121949 }, "server: floor (getRequestEvent + isServer)": { "cap": "1.29 KB", diff --git a/scripts/size/scenarios.js b/scripts/size/scenarios.js index 200ab7d225..fca15e10a2 100644 --- a/scripts/size/scenarios.js +++ b/scripts/size/scenarios.js @@ -1486,9 +1486,10 @@ module.exports = [ // 2026-11-08 (#4723, over next @ 701cbb3): S-58′ — a mount a probing pass opened is born held whatever its own pass reads ahead (the arm tests the stamp first in `frameRead` and `read`'s pending arm; the lane guard kept on it, D-37), and S-58″/‴ — the same mount under a guess lane waits on the lane's flight instead of being served the screen (lanes.ts `laneRead`): 12.76 -> 12.77 KB, measured 12,766 B / 35,587 B minified (+18 B brotli, +92 B minified over the batch record). 0 B on the core floor. // 2026-11-09 (#4726, over next @ db3d13d, measured locally, matching the PR's size job): a zombie does not retry an errored source (#4405's one-hop livelock, +11 B) and the S-46 mount stamp passes through a boundary in the mount (S-58, +33 B, lane engine only): 12.77 KB -> 12.79 KB, recorded minified 35,587 -> 35,631 B (+44 B), measured at 12,777 B brotli. Growth accepted by the maintainer. // 2026-11-09 (#4732, ports #4705, over next @ 5eaaf93, size job on 99197e4): an error seen through latest() shows ahead as a held value would (D-41, ruled 2026-11-09), lane engine only: 12.79 KB -> 12.81 KB, recorded minified 35,631 -> 35,699 B, measured at 12,793 B brotli. 0 B without the lane engine. Growth accepted by the maintainer. - limit: "12.81 KB", + // 2026-11-10 (the guess layer split, over next @ 083a0bd78, size job 42782123117): the arms only a written guess reaches — `optimisticWrite`, `applyGuesses`, `take`, `supersede`, `laneCorrections`, `laneOutcome`, a write landing on a guess, a revert landing's give-back — move from lanes.ts to guesses.ts, installed with `createOptimistic`/`createOptimisticStore` (lanes.ts `installGuessLayer`, scheduler.ts `installGuessHooks`); the sub-hold core every lane needs stays in lanes.ts. This chunk no longer carries the layer: 12.81 KB -> 12.27 KB, recorded minified 35,699 -> 34,128 B, measured at 12,255 B brotli. Pay-for-use: the §8.6 split (b3926358b) ported onto today's lanes.ts; rules untouched, 50k × 3 seeds diffed against next's recording, no screen moves. + limit: "12.27 KB", // latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 28,693 -> 29,086 B (+343 B minified over next), measured locally (linux) at 10,565 B brotli (+135 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured. - capMinified: 35699, + capMinified: 34128, alias }, { @@ -2829,11 +2830,13 @@ module.exports = [ // 2026-11-09 (merge of next @ 5eaaf93 into #4729, measured locally): the guess carrier and #4732 together: 34.11 KB -> 34.22 KB, recorded minified 103,381 -> 103,570 B, measured at 34,208 B brotli. Both growths accepted by the maintainer. // Batch re-record (2026-11-10, over next @ b3731b0, size job 129684675089: #4734, #4735): 34.22 KB -> 34.24 KB, recorded minified 103,570 -> 103,793 B (+223 B), measured at 34,230 B brotli. Includes the guess carrier's minified growth the #4729 merge left unrecorded (+148 B). #4734 (+29 B minified wherever mapArray is bundled) and #4735 (+46 B minified wherever the web runtime is bundled) were accepted by the maintainer. Re-recorded once after the batch, per the batch process. // 2026-11-10 (#4740, over next @ 083a0bd, size job 129714852440): a setter's returned replacement on an optimistic store is written as the keyed diff inside the setter (S-59 field parity, #4737/#4739), and a landing keeps every keyed row's target while guesses are out (#4738): 34.24 KB -> 34.30 KB, recorded minified 103,793 -> 104,123 B (+330 B), measured at 34,286 B brotli (+56 B). Every other scenario is unchanged. Growth accepted by the maintainer (2026-11-10). - limit: "34.30 KB", + // 2026-11-10 (the guess layer split, over next @ 083a0bd78, size job 42782123117): the arms only a written guess reaches — `optimisticWrite`, `applyGuesses`, `take`, `supersede`, `laneCorrections`, `laneOutcome`, a write landing on a guess, a revert landing's give-back — move from lanes.ts to guesses.ts, installed with `createOptimistic`/`createOptimisticStore` (lanes.ts `installGuessLayer`, scheduler.ts `installGuessHooks`); the sub-hold core every lane needs stays in lanes.ts. Both halves present here (optimistic stores and isPending/latest): the hook indirection, +60 B brotli / +157 B minified over the record, the trade reader-seat-rebuild.md §8.6 named; growth accepted as the trade: 34.24 KB -> 34.30 KB, recorded minified 103,793 -> 103,950 B, measured at 34,290 B brotli. Pay-for-use: the §8.6 split (b3926358b) ported onto today's lanes.ts; rules untouched, 50k × 3 seeds diffed against next's recording, no screen moves. + // 2026-11-10 (merge of next @ 78eaf88 into the guess layer split, measured locally): #4740 and the split together: 34.30 KB -> 34.36 KB, recorded minified 104,123 -> 104,280 B, measured at 34,344 B brotli (the two accepted raises, +56 B and +60 B, added up). Both growths accepted by the maintainer. + limit: "34.36 KB", // An Errored heals when the last reader that caught its error is disposed (#4373, #4384, 2026-10-28, re-recorded over next @ cbc0eebd): recorded minified 96,989 -> 97,047 B (+58 B minified over next's record), measured locally (linux) at 31,811 B brotli. Recorded minified = measured; CI re-bases. // Boundary readers keyed by the source they wait on (#4373), with enterLane's tail folded into one else-chain as an offset (-29 B on lane pages) (#4384, 2026-10-28, re-recorded over next @ 1b32ff2e): recorded minified 97,024 -> 97,045 B (+21 B minified over next's record), measured locally (linux) at 31,798 B brotli. Recorded minified = measured; CI re-bases. // latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 97,045 -> 97,426 B (+240 B minified over next), measured locally (linux) at 31,976 B brotli (+109 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured. - capMinified: 104123, + capMinified: 104280, alias }, { @@ -5800,6 +5803,7 @@ module.exports = [ // 2026-11-09 (#4726, over next @ db3d13d, measured locally, matching the PR's size job): a zombie does not retry an errored source (#4405's one-hop livelock, +11 B) and the S-46 mount stamp passes through a boundary in the mount (S-58, +33 B, lane engine only): 40.76 KB -> 40.81 KB (floor-caps.json, Size-Exception), recorded minified 123,070 -> 123,206 B (+136 B: +44 B this PR, +92 B from #4723 not yet re-recorded), measured at 40,798 B brotli. Growth accepted by the maintainer. // 2026-11-09 (#4727, over next @ ebd6283, size job 129310970054): a root ternary under a guess (#3835 shape, +29 B minified, lane engine only) and an Errored fallback's isPending ternary after a reset (+8 B): 40.81 KB -> 40.82 KB (floor-caps.json, Size-Exception), recorded minified 123,206 -> 123,243 B (+37 B), measured in CI at 40,811 B brotli. Growth accepted by the maintainer (2026-11-09). // 2026-11-09 (#4732, ports #4705, over next @ 5eaaf93, size job on 99197e4): an error seen through latest() shows ahead as a held value would (D-41, ruled 2026-11-09), lane engine only: frozen floor 40.82 -> 40.92 KB, recorded minified 123,243 -> 123,431 B, measured at 40,906 B brotli. Size-Exception: the maintainer accepted the growth (2026-11-09). + // 2026-11-10 (the guess layer split, over next @ 083a0bd78, size job 42782123117): the arms only a written guess reaches — `optimisticWrite`, `applyGuesses`, `take`, `supersede`, `laneCorrections`, `laneOutcome`, a write landing on a guess, a revert landing's give-back — move from lanes.ts to guesses.ts, installed with `createOptimistic`/`createOptimisticStore` (lanes.ts `installGuessLayer`, scheduler.ts `installGuessHooks`); the sub-hold core every lane needs stays in lanes.ts. A frozen floor, lowered (always allowed): 40.92 KB -> 40.43 KB, recorded minified 123,431 -> 121,949 B, measured at 40,422 B brotli. Pay-for-use: the §8.6 split (b3926358b) ported onto today's lanes.ts; rules untouched, 50k × 3 seeds diffed against next's recording, no screen moves. limit: floorCaps["page: live server components (base + live/GET + action + isPending/latest)"], capMinified: floorMinified["page: live server components (base + live/GET + action + isPending/latest)"], @@ -6162,11 +6166,12 @@ module.exports = [ // 2026-11-09 (#4726, over next @ db3d13d, measured locally, matching the PR's size job): a zombie does not retry an errored source (#4405's one-hop livelock, +11 B) and the S-46 mount stamp passes through a boundary in the mount (S-58, +33 B, lane engine only): 44.85 KB -> 44.87 KB, recorded minified 131,330 -> 131,469 B (+139 B), measured at 44,853 B brotli. Growth accepted by the maintainer. // 2026-11-09 (merge of next @ 5eaaf93 into #4729, measured locally): the guess carrier and #4732 together: 44.87 KB -> 44.95 KB, recorded minified 131,469 -> 131,690 B, measured at 44,935 B brotli. Both growths accepted by the maintainer. // 2026-11-10 (store guess carrier, #4729 third round): an optimistic family's target is marked at creation (`t.o`), the read-path gate a null check and a field test: measured 44,957 B / 131,704 B minified (+7 B brotli over the record; brotli layout). 0 B on the core floor and the compiled floor. - limit: "44.96 KB", + // 2026-11-10 (the guess layer split, over next @ 083a0bd78, size job 42782123117): the arms only a written guess reaches — `optimisticWrite`, `applyGuesses`, `take`, `supersede`, `laneCorrections`, `laneOutcome`, a write landing on a guess, a revert landing's give-back — move from lanes.ts to guesses.ts, installed with `createOptimistic`/`createOptimisticStore` (lanes.ts `installGuessLayer`, scheduler.ts `installGuessHooks`); the sub-hold core every lane needs stays in lanes.ts. This page no longer carries the layer: 44.96 KB -> 44.39 KB, recorded minified 131,704 -> 129,924 B, measured at 44,372 B brotli. Pay-for-use: the §8.6 split (b3926358b) ported onto today's lanes.ts; rules untouched, 50k × 3 seeds diffed against next's recording, no screen moves. + limit: "44.39 KB", // An Errored heals when the last reader that caught its error is disposed (#4373, #4384, 2026-10-28, re-recorded over next @ cbc0eebd): recorded minified 123,191 -> 123,249 B (+58 B minified over next's record), measured locally (linux) at 41,899 B brotli. Recorded minified = measured; CI re-bases. // Boundary readers keyed by the source they wait on (#4373), with enterLane's tail folded into one else-chain as an offset (-29 B on lane pages) (#4384, 2026-10-28, re-recorded over next @ 1b32ff2e): recorded minified 123,203 -> 123,224 B (+21 B minified over next's record), measured locally (linux) at 41,966 B brotli. Recorded minified = measured; CI re-bases. // latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 123,224 -> 123,733 B (+403 B minified over next), measured locally (linux) at 42,119 B brotli (+169 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured. - capMinified: 131704, + capMinified: 129924, alias: pageAlias }, { @@ -6620,11 +6625,12 @@ module.exports = [ // 2026-11-09 (store guess carrier, over next @ eef34fd9d): store.ts gained the optimistic hook call sites for the guess carrier (read, presence, descriptor, enumeration, the landing's silence and judgement — each a null check on a plain store; S-59/#4724), net of the LaneView/asBacking/follow code it lost: measured 50,594 B / 148,999 B minified (+4 B brotli, +61 B minified over the record). 0 B on the core floor and the compiled floor. // 2026-11-09 (merge of next @ 5eaaf93 into #4729, measured locally): the guess carrier and #4732 together: 50.61 KB -> 50.64 KB, recorded minified 148,999 -> 149,188 B, measured at 50,629 B brotli. Both growths accepted by the maintainer. // Batch re-record (2026-11-10, over next @ b3731b0, size job 129684675089: #4734, #4735): 50.64 KB -> 50.71 KB, recorded minified 149,188 -> 149,263 B (+75 B), measured at 50,696 B brotli. #4734 (+29 B minified wherever mapArray is bundled) and #4735 (+46 B minified wherever the web runtime is bundled) were accepted by the maintainer. Re-recorded once after the batch, per the batch process. - limit: "50.71 KB", + // 2026-11-10 (the guess layer split, over next @ 083a0bd78, size job 42782123117): the arms only a written guess reaches — `optimisticWrite`, `applyGuesses`, `take`, `supersede`, `laneCorrections`, `laneOutcome`, a write landing on a guess, a revert landing's give-back — move from lanes.ts to guesses.ts, installed with `createOptimistic`/`createOptimisticStore` (lanes.ts `installGuessLayer`, scheduler.ts `installGuessHooks`); the sub-hold core every lane needs stays in lanes.ts. This page no longer carries the layer: 50.71 KB -> 50.20 KB, recorded minified 149,263 -> 147,688 B, measured at 50,193 B brotli. Pay-for-use: the §8.6 split (b3926358b) ported onto today's lanes.ts; rules untouched, 50k × 3 seeds diffed against next's recording, no screen moves. + limit: "50.20 KB", // An Errored heals when the last reader that caught its error is disposed (#4373, #4384, 2026-10-28, re-recorded over next @ cbc0eebd): recorded minified 140,451 -> 140,509 B (+58 B minified over next's record), measured locally (linux) at 47,516 B brotli. Recorded minified = measured; CI re-bases. // Boundary readers keyed by the source they wait on (#4373), with enterLane's tail folded into one else-chain as an offset (-29 B on lane pages) (#4384, 2026-10-28, re-recorded over next @ 1b32ff2e): recorded minified 140,463 -> 140,485 B (+22 B minified over next's record), measured locally (linux) at 47,547 B brotli. Recorded minified = measured; CI re-bases. // latest() read inline and through a memo show the same screen (#4284 through a memo; a plain write beside an async memo), 2026-10-29, over next @ 7ebd4a32: recorded minified 140,485 -> 140,983 B (+405 B minified over next), measured locally (linux) at 47,722 B brotli (+162 B over next). A render effect a verdict memo's change re-runs reads as its verdict reader for that pass (`laneDirty`), a pass that read a staging before the frame had a transaction re-derives once as a verdict reader only if the frame parks, `latest()` of a first load in flight in a verdict lane is loading (also through an identity memo, a derived store and `isPending`), a lane's dissolution leaves such a load and the nodes pending on it uninitialized instead of committing `undefined`, a verdict lane born at a seam is judged at it, a pass born in a staged reader stays the frame's on a verdict-memo read (C4, #4010), a plain write beside `latest()` computes once (the seam re-derives a pre-transaction staged reader only if the frame parks), a verdict reader's plain read of a staging in a transaction only a `latest()` opened is the frame's read, so a memo of `latest()` computes once too (D-22; not a pass with no value yet, D-6), and an error stays the display while the memo it came through re-asks, a Loading fallback behind it included (D-39, async-gen 91501 #1831). recompute's CONFIG_VERDICT clear now sits behind the lane engine: -21 B minified on every floor. Correctness; the maintainer: "only flag me if brotli goes more than 20kb" (2026-10-29). Cap unchanged; recorded minified = measured. - capMinified: 149263, + capMinified: 147688, alias: pageAlias, conditions: solidConditions, compile: { hydratable: true }