Skip to content

Commit 58b9582

Browse files
ryansolidClaude via Cursorcursoragent
authored
fix(signals): index-mode mapArray publishes the optimistic frame (F1) (#3682)
* fix(signals): index-mode mapArray publishes the optimistic frame (F1) A mapArray pass writes the list's per-slot signals — the row accessors of index mode (`keyed: false`), the index accessors of a keyed `<For>` with a two-argument mapper — with `setSignal`. Under an action's lane pass those writes were staged into the action's transaction instead of joining the lane's frame (setSignal's plain path: queuePendingNode + `_pendingValue`), and the row render effects were served the committed value by readerSeesCommitted until the action landed. `<For keyed={false}>` showed the pre-action list for the whole action while the keyed modes — whose reorder rides the computed's own result into `_laneOverride` — showed the optimistic one; a keyed row rendered its old index beside its new neighbours (`1b,2c,3d,4e,5f,0a`). The slot writes now go through the engine (`writeSlot` -> `GlobalQueue._laneSlotWrite`, `laneSlotWrite` in core/optimistic.ts): under a lane pass each is published as a derived override on the slot and the slot joins the lane (assignOrMergeLane + laneOverride, lanes stage, A17); a plain pass over a slot still carrying one — the landing, the reversion, a mainline re-pass — lands through `landOnOverride` (A18: a differing landing supersedes, an equal one confirms and the revert promotes). Without the engine installed mapArray writes the slots plainly as before. `laneOverride` is widened to any OptimisticNode. Tests: tests/store/optimistic-maparray-index-frame-f1.test.ts pins the index-mode frame (insert / delete / move / swap / reverse / rotate, confirm and differing landings, reorder then a different landing, revert without a truth, overlapping actions) and the keyed index-accessor twin, on the derived and chained sources; packages/web/test/optimistic-for-index-frame- f1.spec.tsx mirrors it through `<For keyed={false}>` and `<For keyed={fn}>`. Matrix: every F1 row cleared (716/184/0 -> 821/79/0); the index reader now fails exactly where the other readers do on the derived source (F4) and is retagged there. The F6 rows (repeat, derived) were test pollution from F1 — an it.fails row throwing at its apply checkpoint never released its gate, so its action outlived the test — and pass now; unpinned. optimistic-outside-refetch-619.test.ts had pinned the torn frame and the index writes landing in a third frame; it now expects the whole frame and asserts the settle with an ambient probe write (still fails with #3663 reverted). Size: +15 B core-retained (the hook's static slot; treeshake ledger 26,649 -> 26,664), `laneSlotWrite` sheds with the engine, `writeSlot` with map. Non-frozen ledger caps ratcheted with dated notes. The two frozen page caps are exceeded — reported in the PR, not touched. Docs: SPEC A17 mechanism index and status note the slot writes; RULES-INDEX regenerated. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * fix(signals): F1 slot writes — one per-pass pick, no new hook slot Golf + perf pass on the mapArray optimistic-frame fix (F1). The per-slot `writeSlot` (a `GlobalQueue._laneSlotWrite ?? setSignal` pick at every slot write) cost the plain path per-slot work — swap +14%/+22%, insert/ remove +6% on 1000-row lists — and +129 B / +230 B brotli on the frozen page scenarios. The pick is now made ONCE per pass at the top of the update branch: a lane pass marks the map (`_laneSlots`); a marked map routes its slot writes through the engine while any lane is live (`activeLanes.size`), and drops the mark when none is — a slot's override resolves with its lane's transaction (or the batch for an orphan lane) before the completion wakes any recompute, so a pass that finds no lane knows the slots are clean. An unmarked map writes with `setSignal` directly, the pre-fix code. The engine side is a branch inside the already-installed `_landOnOverride` hook, discriminated by `!(el._config & CONFIG_OPTIMISTIC)` (mapArray slots are never optimistic nodes; existing setSignal callers are unaffected): a lane pass's write becomes the slot's derived override (A17), a plain pass's write over one takes the landing path (A18), a plain write on a clean slot is `setSignal`. The `_laneSlotWrite` static and `laneSlotWrite` are gone — core floor back to 26,649 B minified (0 B core-retained). Bench (1000 rows, median of 6 alternating rounds vs `next`): plain path -5.9% .. +1.3% (noise); plain passes on a map after a settled action -1.2% .. +3.3% (the mark clears on the first plain pass); action reverse +13% / action swap +4% (the lane pass publishing per-slot overrides — the fix itself). Size (brotli vs `next`): page base 46,872 -> 46,853 (-19), hydrating 21,416 -> 21,402 (-14), page live 51,156 -> 51,260 (+104; frozen cap 51,160, over by 100 — not touched). Minified: map +53 B, engine +144 B. Roughly 40 B of each page delta is the signals prop-mangler reordering names across map.js and scheduler.js (shared per-file frequency cache), not code: `+ createStore` moves +19 B brotli at 0 B minified. Non-frozen ledger caps re-ratcheted to the measured values with dated notes. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * chore(size): accept page:live delta for F1 index-mode frame (Size-Exception) Rebased onto `next` @ d0ad11c (#3684). Against a clean build of that commit the F1 branch measures page: base 46,885 -> 46,936 B (+51; 36 over the frozen 46.90 KB) and page: live 51,220 -> 51,255 B (+35; 25 over the frozen 51.23 KB). The maintainer accepted design (a) and the residual (2026-09-27); both caps are raised under the PR body's `Size-Exception:` line — page: base 46.90 -> 46.95 KB, page: live 51.23 -> 51.27 KB (the smallest 0.01 KB step leaving >= 10 B headroom) — with dated history notes. Real code: +53 B minified in map.js (~17 B compressed; the per-pass slot writer pick), +144 B in optimistic.js (~46 B compressed; the slot arm in landOnOverride, retained only with the engine). The remainder is the signals prop-mangler's per-file name reorder: the same code measured -19 B on page: base against the pre-#3684 `next`. Non-frozen ledger caps re-ratcheted to the post-rebase measurements (down where the PR now measures under): + createStore 17.36 -> 17.33 KB, isPending/latest 12.73 -> 12.72, hydrating + stores 32.06 -> 32.02, CSR Show/For 16.04 -> 16.05, CSR observe 17.88 -> 17.87, attribution 32.01 -> 31.99. size-limit exits 0; check-floor-caps passes with the body as SIZE_EXCEPTION and fails without. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent d0ad11c commit 58b9582

13 files changed

Lines changed: 925 additions & 112 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Index-mode `mapArray` (`<For keyed={false}>`) publishes the optimistic frame (optimistic-list-mutation-matrix finding F1).
6+
7+
A `mapArray` pass writes the list's per-slot signals — the row accessors of index mode, the index accessors of a keyed `<For>` with a two-argument mapper — with `setSignal`. Under an action's lane pass those writes were staged into the action's transaction instead of joining the lane's frame, so the row readers were served the committed value until the action landed: `<For keyed={false}>` showed the pre-action list for the whole action while the keyed modes showed the optimistic reorder, and a keyed row rendered its old index beside its new neighbours. A lane pass now routes the slot writes through the engine (`landOnOverride`'s slot arm): each is published as a derived override on the slot and the slot joins the lane (lanes stage, A17); a plain pass over a slot still carrying one lands through the same arm (A18: a differing landing supersedes, an equal one confirms and the revert promotes). The writer is picked once per pass, not per slot: a map no lane pass has touched — or whose lanes have all settled — writes its slots with `setSignal` exactly as before.

‎packages/signals/docs/RULES-INDEX.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
6161
| A14 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:165` | — | spec-async-semantics.test.ts×2 | [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… |
6262
| A15 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:199` | async.ts×4 constants.ts×1 core.ts×6 lanes.ts×2 scheduler.ts×2 store.ts×1 | async-chain-supersession.test.ts×1 first-observer-stale-reader.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-hold-on-observation.test.ts×1 lane-outside-view.test.ts×1 lane-pass-stamped-effect-3662.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 spec-async-semantics.test.ts×2 stale-read-uninitialized-cross-transition.test.ts×1 superseded-source-blocks-3462.test.ts×2 treeshake.test.ts×4 visibility-oracle-store.states.ts×6 visibility-oracle.states.ts×6 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 … |
6363
| A16 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:173` | verdict.ts×1 | 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… |
64-
| A17 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:31` | async.ts×5 constants.ts×3 core.ts×10 invariants.ts×3 optimistic.ts×7 scheduler.ts×2 verdict.ts×2 signals.ts×2 optimistic.ts×1 store.ts×2 | lane-uninitialized-landing-3648.test.ts×5 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×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.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×23 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… |
65-
| A18 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:41` | async.ts×3 constants.ts×1 core.ts×10 optimistic.ts×7 scheduler.ts×3 types.ts×2 verdict.ts×2 optimistic.ts×1 store.ts×2 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×1 lane-outside-view.test.ts×1 lane-uninitialized-landing-3648.test.ts×5 optimistic-move-duplicate-3548.test.ts×2 posture-store-parity.test.ts×5 spec-async-semantics.test.ts×3 flight-owned-transaction.test.ts×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 superseded-before-first-commit.test.ts×5 visibility-oracle-store.states.ts×9 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×24 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… |
64+
| A17 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:31` | async.ts×5 constants.ts×3 core.ts×10 invariants.ts×3 optimistic.ts×8 scheduler.ts×2 verdict.ts×2 map.ts×1 signals.ts×2 optimistic.ts×1 store.ts×2 | lane-uninitialized-landing-3648.test.ts×5 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×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-maparray-index-frame-f1.test.ts×1 optimistic-untracked-reads-f3-f5.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×23 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… |
65+
| A18 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:41` | async.ts×3 constants.ts×1 core.ts×10 optimistic.ts×7 scheduler.ts×3 types.ts×2 verdict.ts×2 map.ts×1 optimistic.ts×1 store.ts×2 | body-end-supersession-visibility.test.ts×4 createOptimistic.test.ts×1 lane-outside-view.test.ts×1 lane-uninitialized-landing-3648.test.ts×5 optimistic-move-duplicate-3548.test.ts×2 posture-store-parity.test.ts×5 spec-async-semantics.test.ts×3 flight-owned-transaction.test.ts×1 optimistic-list-mutation-matrix.test.ts×1 optimistic-untracked-reads-f3-f5.test.ts×1 superseded-before-first-commit.test.ts×5 visibility-oracle-store.states.ts×9 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×24 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… |
6666
| A19 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:101` | async.ts×1 core.ts×3 optimistic.ts×2 verdict.ts×2 | lane-uninitialized-landing-3648.test.ts×2 spec-async-semantics.test.ts×3 superseded-before-first-commit.test.ts×1 uninitialized-visibility.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×11 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled 2026-07-07 (promoted from C1)] `isPending(x)` ≡ the observable value is not final (three causes) — (was C1 — **partially reverses an earlier decision**) **Definition: `isPending(x)` ≡ the value… |
6767
| A20 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:352` | invariants.ts×1 | 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… |
6868
| A21 | superseded | `docs/SPEC-ASYNC-SEMANTICS.md:359` | — | 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… |
@@ -119,7 +119,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
119119
| INV-8 | retired | `docs/INTERNALS-ASYNC-STATE.md:179` | invariants.ts×1 | rules-index.test.ts×1 | - **INV-8 (RETIRED 2026-07-07b, §5e)** Hold-provenance: a `_pendingValue` on an |
120120
| INV-9 | live | `docs/INTERNALS-ASYNC-STATE.md:190` | invariants.ts×1 owner.ts×2 | inv4-projection-dispose-shadow.test.ts×1 | - **INV-9 (high)** An `isPending` companion of a DISPOSED owner reads `false` |
121121
| INV-10 | live | `docs/INTERNALS-ASYNC-STATE.md:195` | invariants.ts×2 | action-done-window.test.ts×1 | - **INV-10 (high)** Affects-count balance (question-scoped model, 2026-07-13; |
122-
| INV-11 | live | `docs/INTERNALS-ASYNC-STATE.md:200` | core.ts×1 optimistic.ts×2 | spec-async-semantics.test.ts×1 treeshake.test.ts×1 | - **INV-11 (high, structural — pinned, not asserted)** A recompute's equality |
122+
| INV-11 | live | `docs/INTERNALS-ASYNC-STATE.md:200` | core.ts×1 optimistic.ts×4 | spec-async-semantics.test.ts×1 treeshake.test.ts×1 | - **INV-11 (high, structural — pinned, not asserted)** A recompute's equality |
123123
## RUL — store rulings
124124

125125
| id | status | defined | cited in src | cited in tests | statement (at definition) |

0 commit comments

Comments
 (0)