Skip to content

Commit 554520c

Browse files
fix(signals): entangle-tear consolidation pass 1 — visibility decisions move to the seam
Held #3091 out of rc.5 over the until()-entanglement patch tear. This pass fixes the class at the read seam, zero core-scheduler changes: - nodeValue held-truth arm: the steal parks node truth PAST the flush while the backing commits eagerly — committed truth then lives only in _value, which the untracked fallthrough never served. Untracked readers (userland untrack(), the channel's visible view) saw the future while tracked readers held. User-visible beyond the channel. - Parked-truth deferral (value): optimistic-family deliveries whose record truth is parked under a not-done transaction defer without consuming; a redrive stashes on the holder (named by the nodes' own _transition — follows merges and the steal for free) and re-bumps at its commit. Landings emit with no ambient transaction, so transaction stamps could not gate this; only t.fam?.opt probes (plain bumps park the delivery signal itself — dbmon path never probes). - Parked-truth re-stash (structural): apply-time probing subsumes the carrier-side mirrors (steal stash-move + forwarding pointer were built, proven, then DELETED — ordering-free beats carrier games). Probes pinned as regular tests (value + structural twins). Sizes: +36 B createStore, +294 B patchDriver tier, +221 B list tier (ratcheted). Co-authored-by: Cursor <[email protected]>
1 parent d6e9484 commit 554520c

7 files changed

Lines changed: 358 additions & 66 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Entangle-tear consolidation pass 1: untracked store reads now serve committed truth for held-truth-masked nodes (the until()-flip steal parks node truth past the flush, so the backing is ahead of the committed world — tracked and untracked readers previously disagreed); patch-channel deliveries and structural applies defer on parked truth, riding the holding transaction's commit via the holder named by the nodes' own `_transition` — one seam decision that follows merges and steals with no scheduler-specific mirrors.

‎packages/signals/DESIGN-PATCH-CHANNEL.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,51 @@ Deferred from the audit's secondary list: staged exception-safe applyOps
8686
@ts-nocheck on patch-driver.ts, and a versioned internal compiler entry
8787
for the runtime primitives.
8888

89+
## 24. Entangle-tear consolidation, pass 1 (2026-09-01) — visibility moves to the seam
90+
91+
Held #3091 out of rc.5 over an external probe: a `registerPatch` consumer
92+
on a confirming foreign store observed the new world mid-`until()`-hold
93+
(patch DOM showing the confirmation beside value bindings correctly
94+
holding). A second structural review named the root pattern: the channel
95+
re-decides visibility with private bookkeeping, so every new scheduler
96+
behavior needs a hand-written mirror. This pass moves the decisions to
97+
the seam. THREE mechanisms, ZERO core-scheduler changes:
98+
99+
- **`nodeValue` held-truth committed arm** (store.ts): the O6 single-home
100+
rule ("committed truth lives in the backing; `_value` is never served")
101+
assumed backing and nodes converge at flush. The steal extends node
102+
parking PAST the flush while the backing committed eagerly — for the
103+
hold's duration, committed truth exists ONLY in `_value`. Untracked
104+
readers (userland `untrack()`, the channel's visible view) fell through
105+
to the backing and saw the future while every tracked reader held.
106+
The held-truth refusal arm now serves `_value`: one seam, both reader
107+
kinds agree. This was a USER-VISIBLE bug beyond the channel.
108+
- **Parked-truth deferral, value channel** (patch.ts): an optimistic-
109+
family delivery whose record's truth is parked under a not-done
110+
transaction defers WITHOUT consuming (`dv` stays behind `bc`) unless a
111+
live override justifies a lane frame (classic shows the draft; so do
112+
we). The holder is named by the nodes' own `_transition` — the steal
113+
re-stamps it, merges canonicalize it, so the deferral follows the hold
114+
wherever the scheduler moves it with no steal-specific code. A redrive
115+
stashes on the holder's `_heldPatches` and re-bumps at its commit.
116+
Transaction stamps could NOT gate this: landings emit at microtask time
117+
with no ambient transaction. Only `t.fam?.opt` gates the probe — plain
118+
bumps park the delivery signal itself, so their wakes are commit-timed
119+
by construction (the dbmon path never probes).
120+
- **Parked-truth re-stash, structural channel** (patch.ts drain): landing
121+
row ops rode a DIFFERENT carrier than the landing's node staging (the
122+
fold's transition committed early; the nodes parked ambient and were
123+
stolen later) — carrier-side mirrors (a steal stash-move, a forwarding
124+
pointer) were built, WORKED, and were then DELETED: probing parked
125+
truth at APPLY time subsumes them, ordering-free. Items re-stash on the
126+
holder and release at the reveal; version chains absorb the replay.
127+
128+
Cost: +36 B createStore (the seam arm), +294 B patchDriver tier, +221 B
129+
list tier. The probes (value + structural) are pinned as REGULAR tests.
130+
Remaining for pass 2 (before default-on re-proposes): visible-view
131+
snapshot compare to retire the bt/bo dedup stamps, and the auditor's
132+
node-attached structural stash evaluation.
133+
89134
## 23. Fold audit 6 (2026-09-01) — dn override lifecycle + matcher key spaces
90135

91136
Three findings at `c48aed8b`; the first one also indicted the gate

‎packages/signals/src/store/next/patch.ts‎

Lines changed: 153 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ import {
4040
} from "../../core/scheduler.js";
4141
import type { Owner } from "../../core/types.js";
4242
import { $TARGET, isWrappable } from "../store.js";
43-
import { markDescendants, ownedRaw, type PatchChannel, type StoreNextTarget } from "./target.js";
43+
import {
44+
markDescendants,
45+
ownedRaw,
46+
storeNextLookup,
47+
type PatchChannel,
48+
type StoreNextTarget
49+
} from "./target.js";
4450
import { installPatchHooks, installRowHooks, wrapRecordHook } from "./patch-hooks.js";
4551
import { optHooks } from "./target.js";
4652
// One-way: reconcile emits through the hooks (never imports this module),
@@ -151,6 +157,23 @@ function drainApplyQueue(): void {
151157
let firstError: unknown = UNSET;
152158
for (let i = 0; i < q.length; i++) {
153159
const item = q[i];
160+
// PARKED-TRUTH re-stash (2026-09-01 tear, structural half): whichever
161+
// carrier the ops rode (the fold's transition, the ambient batch, an
162+
// early-committing landing), at APPLY time a record whose truth is
163+
// still parked names its holder through the nodes' `_transition` — the
164+
// steal re-stamped them, so this follows the hold wherever the
165+
// scheduler moved it, ordering-free. Overrides exempt (a draft's lane
166+
// ops are live display). Optimistic families only: plain stores'
167+
// structural emissions are commit-timed by their stash.
168+
const t0 = (item.pc as any)?.t as StoreNextTarget | undefined;
169+
if (t0 !== undefined && t0.fam?.opt === true) {
170+
scanHadOverride = false;
171+
const holder = nodesParkedHolder(t0);
172+
if (holder !== null && !scanHadOverride) {
173+
(((holder as any)._heldPatches ??= []) as QueuedApply[]).push(item);
174+
continue;
175+
}
176+
}
154177
const next = drainNext(item);
155178
if (next === UNSET) continue;
156179
if (item.ops !== undefined || item.si !== undefined)
@@ -514,11 +537,100 @@ function applyEntries(list: PatchEntry[], next: any, firstError: unknown, pc: an
514537
// the ambient batch never stashes.
515538
let commitHookInstalled = false;
516539

540+
/** PARKED-TRUTH probe (2026-09-01 tear): a record whose node values are
541+
* parked under a NOT-DONE transaction has truth the visible world hasn't
542+
* revealed — a landing's fold mid-flight, fold-staged reveals, or the
543+
* until()-flip steal's held mask (which re-stamps `_transition` to the
544+
* awaiting transaction, so the SAME probe follows the hold wherever the
545+
* scheduler moves it — no steal-specific code). The scan also notes
546+
* active overrides (`scanHadOverride`): an override is a live lane
547+
* display classic readers see NOW, so its delivery must not defer.
548+
* Cold by construction: the caller gates on `bt`/`bo`, so
549+
* transaction-free ticks (the dbmon shape) never reach this. */
550+
let scanHadOverride = false;
551+
552+
function nodesParkedHolder(t: StoreNextTarget): Transition | null {
553+
const n = t.n as Record<PropertyKey, any> | null | undefined;
554+
let holder: Transition | null = null;
555+
if (n != null) {
556+
for (const k in n) {
557+
const nd = n[k];
558+
if (hasActiveOverrideNode(nd)) scanHadOverride = true;
559+
else if (nd._pendingValue !== NOT_PENDING && nd._transition != null) {
560+
const tx = currentTransition(nd._transition as Transition);
561+
if (tx != null && tx._done !== true) holder = tx;
562+
}
563+
}
564+
}
565+
return holder;
566+
}
567+
568+
function hasActiveOverrideNode(nd: any): boolean {
569+
const ov = nd._x?._overrideValue;
570+
return ov !== undefined && ov !== NOT_PENDING;
571+
}
572+
573+
function deepHeldHolder(node: DeepNode, raw: any, fam: any): Transition | null {
574+
if (raw === null || (typeof raw !== "object" && typeof raw !== "function")) return null;
575+
const ct = (fam?.map ?? storeNextLookup).get(raw) as StoreNextTarget | undefined;
576+
if (ct !== undefined) {
577+
const h = nodesParkedHolder(ct);
578+
if (h !== null) return h;
579+
}
580+
const children = node.c;
581+
if (children !== null) {
582+
for (let i = 0; i < children.length; i++) {
583+
const f = deepHeldHolder(children[i], raw[children[i].k as any], fam);
584+
if (f !== null) return f;
585+
}
586+
}
587+
return null;
588+
}
589+
590+
function parkedTruthHolder(t: StoreNextTarget, pc: any): Transition | null {
591+
const h = nodesParkedHolder(t);
592+
if (h !== null) return h;
593+
const dp = pc.dp as DeepNode[] | null;
594+
if (dp !== null && t.v != null) {
595+
for (let i = 0; i < dp.length; i++) {
596+
const f = deepHeldHolder(dp[i], (t.v as any)[dp[i].k as any], t.fam);
597+
if (f !== null) return f;
598+
}
599+
}
600+
return null;
601+
}
602+
603+
/** Defer the delivery WITHOUT consuming the bump (`dv` stays behind `bc`):
604+
* the holder's commit releases a redrive that wakes the effect, and content
605+
* then resolves through the read seam post-reveal. One redrive per holder
606+
* (`pc.hh`); a REVERTED holder drops its stash by design — the revert
607+
* restores the world the unconsumed bump would have re-applied, so the
608+
* missed wake is content-free and the next genuine bump supersedes it. */
609+
function deferRedrive(pc: any, holder: Transition): void {
610+
if (pc.hh != null && currentTransition(pc.hh as Transition) === holder) return;
611+
pc.hh = holder;
612+
(((holder as any)._heldPatches ??= []) as any[]).push({ rd: pc });
613+
}
614+
517615
function releaseBatch(batch: Transition): void {
518616
const held = (batch as any)._heldPatches as QueuedApply[] | undefined;
519617
if (held === undefined) return;
520618
(batch as any)._heldPatches = undefined;
521-
for (let i = 0; i < held.length; i++) pushLive(held[i]);
619+
for (let i = 0; i < held.length; i++) {
620+
const item = held[i] as any;
621+
if (item.rd !== undefined) {
622+
// Parked-truth redrive: the holder committed — bump and wake (the
623+
// bump makes redelivery unconditional even when the deferring
624+
// delivery fell through and consumed); the seam serves the revealed
625+
// world. A REVERTED holder drops this with its stash by design: the
626+
// revert restored the world, the wake would be content-free.
627+
item.rd.hh = null;
628+
item.rd.bc++;
629+
setSignal(item.rd.dn, (v: number) => v + 1);
630+
continue;
631+
}
632+
pushLive(item);
633+
}
522634
}
523635

524636
/** The VISIBLE-version bump (version-chain redesign): an emission's effect
@@ -637,6 +749,23 @@ function drainOptimistic(): void {
637749
let firstError: unknown = UNSET;
638750
for (let i = 0; i < q.length; i++) {
639751
const item = q[i];
752+
// PARKED-TRUTH re-stash (2026-09-01 tear, structural half): whichever
753+
// carrier the ops rode (the fold's transition, the ambient batch, an
754+
// early-committing landing), at APPLY time a record whose truth is
755+
// still parked names its holder through the nodes' `_transition` — the
756+
// steal re-stamped them, so this follows the hold wherever the
757+
// scheduler moved it, ordering-free. Overrides exempt (a draft's lane
758+
// ops are live display). Optimistic families only: plain stores'
759+
// structural emissions are commit-timed by their stash.
760+
const t0 = (item.pc as any)?.t as StoreNextTarget | undefined;
761+
if (t0 !== undefined && t0.fam?.opt === true) {
762+
scanHadOverride = false;
763+
const holder = nodesParkedHolder(t0);
764+
if (holder !== null && !scanHadOverride) {
765+
(((holder as any)._heldPatches ??= []) as QueuedApply[]).push(item);
766+
continue;
767+
}
768+
}
640769
const next = drainNext(item);
641770
if (next === UNSET) continue;
642771
if (item.ops !== undefined || item.si !== undefined)
@@ -1057,7 +1186,29 @@ function ensureDelivery(t: StoreNextTarget, pc: any): void {
10571186
() => void readSignal(dn),
10581187
() => {
10591188
if (pc.bc === pc.dv) return; // pure-registration run: baselines are per-entry
1189+
// PARKED-TRUTH DEFERRAL (2026-09-01 tear): an OPTIMISTIC-family
1190+
// record whose truth is parked under a not-done transaction — a
1191+
// landing mid-flight (landings emit at microtask time with NO
1192+
// ambient transaction, so transaction stamps can't gate this), a
1193+
// fold stage, or the until()-flip steal (the wake outruns the
1194+
// steal; the probe follows `_transition` wherever the scheduler
1195+
// re-stamps it). With no live override to display, classic emits
1196+
// NO frame now — defer without consuming (`dv` stays behind `bc`)
1197+
// and ride the holder's commit. With one (a draft mid-flight),
1198+
// deliver the lane view now AND redeliver at the reveal. Only
1199+
// optimistic families own the lane-timed early-wake rail: plain
1200+
// bumps park the delivery signal itself, so their wakes are
1201+
// commit-timed by construction — no probe on the dbmon path.
1202+
if (t.fam?.opt === true) {
1203+
scanHadOverride = false;
1204+
const holder = parkedTruthHolder(t, pc);
1205+
if (holder !== null) {
1206+
deferRedrive(pc, holder);
1207+
if (!scanHadOverride) return;
1208+
}
1209+
}
10601210
pc.dv = pc.bc;
1211+
if (pc.hh == null) pc.hh = null;
10611212
// The delivery CONSUMES any override on the notification signal
10621213
// (INV-6, fold audit 6): optimistic bumps arm dn so in-flight
10631214
// visibility rides the lane — but dn is PURE NOTIFICATION, and a

‎packages/signals/src/store/next/store.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export function pcOf(t: StoreNextTarget): PatchChannel {
164164
dmq: false,
165165
bt: null,
166166
bo: null,
167+
hh: null,
167168
ak: null,
168169
dp: null,
169170
ks: false,
@@ -1751,7 +1752,17 @@ function nodeValue(node: Signal<any>, backing: any): any {
17511752
((inOwnerContext() || authoritativeServe()) &&
17521753
!(node._config & CONFIG_HELD_TRUTH && !authoritativeServe())))
17531754
? node._pendingValue
1754-
: backing;
1755+
: node._pendingValue !== NOT_PENDING && node._config & CONFIG_HELD_TRUTH
1756+
? // HELD truth is the O6 exception (entangle-steal tear, 2026-09-01):
1757+
// the steal extends node parking PAST the flush while the backing
1758+
// committed eagerly — for the hold's duration committed truth
1759+
// lives ONLY in `_value`. Serving the backing here handed
1760+
// untracked readers (userland untrack(), the patch channel's
1761+
// visible view) the confirming world while every tracked reader
1762+
// correctly held — same seam, two worlds. Authoritative/latest
1763+
// readers never reach this arm (served pending above).
1764+
node._value
1765+
: backing;
17551766
return v === (FORCE as any) ? backing : v;
17561767
}
17571768

‎packages/signals/src/store/next/target.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export interface PatchChannel {
9797
* always writes (scheduler owns merge bookkeeping). */
9898
bt?: unknown;
9999
bo?: unknown;
100+
/** Steal-deferral holder (2026-09-01 tear): the transition whose commit
101+
* carries this channel's redrive while its record sits under a
102+
* held-truth node mask — one redrive per holder. */
103+
hh?: unknown;
100104
/** Structural VERSION (version-chain redesign): bumped at every
101105
* structural emission; items stamp `svAt`. Entries apply an item only on
102106
* an unbroken chain from their own applied version (`av === svAt - 1`) —

0 commit comments

Comments
 (0)