Skip to content

Commit b31e992

Browse files
fix: reconcile the patch channel with the #3164 fold ruling
The re-ruled landing contract (truth folds into the retaining transaction, atomic reveal at settle) obsoletes the branch's landing integration wholesale: emitLandingConsumption/emitRowOpsLanding and the superseded-work generation (pc.sg + drain gate + item stamps) are DELETED with the contract they served — staged truth is transition-held (channel held-write semantics apply by construction) and the reveal rides the settle drain's existing resync loop. The registration- sequence sweep window, hold routing, visible-view resolution, and the deleted-slot gate are contract-independent and stay. Re-applies the round-10.5 primitive-owned emission gate the upstream rewrite reverted (settle-loop value emission gated on the local consumer list — silences ancestor channels, round-10 P1-3; two invariant tests caught it). Landing invariants re-pinned to fold semantics: interim landings invisible to both channels, atomic flip at settle, classic-parity oracles unchanged. The two upstream it.fails pins (same-microtask swallow, wedged until()) STILL FAIL under fold — they ride on. Full signals (1,507 + 2 expected-fail) + web (719) + hydration parity (153) green; two ratchets for upstream fold bytes (15.15/27.25). BASED ON UNPUSHED next (a536e29) — hold pushes until it lands. Co-authored-by: Cursor <[email protected]>
1 parent 59ddc1e commit b31e992

9 files changed

Lines changed: 90 additions & 76 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+
Reconcile the patch channel with the #3164 fold ruling: the branch's landing-consumption integration (landing emission hook, superseded-work generation stamps) is deleted with the contract it served — under fold, staged truth rides the channel's existing transition-held write semantics and the atomic reveal rides the settle drain's resync loop. Re-applies the primitive-owned emission gate the rewrite reverted (local-consumer-list gating silenced ancestor channels) and re-pins the landing invariants to fold semantics: interim landings under retained optimism are invisible to value and structural channels alike, with the flip atomic at settle, at classic-effect parity.

‎packages/signals/AUDIT-BRIEF-R6.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Audit brief — rounds 6–9 + patch-mode default flip + node delivery
22

3+
## Round 10.17 (2026-09-01) — #3164 FOLD reconciliation (rebase onto the re-ruled contract)
4+
5+
Upstream re-ruled landing consumption (a536e29b): the three interim #3123
6+
mechanisms (equality-scoped consumption, retained-setter replay, echo mask)
7+
are REMOVED — truth landings FOLD into the retaining transaction and reveal
8+
atomically at its settle. Channel consequences:
9+
10+
- **The branch's landing integration is DELETED, not ported** — by design.
11+
Under fold, landing visibility rides mechanisms the channel already
12+
handles: staged truth is transition-held (the channel's held-write
13+
semantics apply by construction), and the atomic reveal rides the settle
14+
drain's existing resync loop. `emitLandingConsumption` /
15+
`emitRowOpsLanding` and the superseded-work generation (`pc.sg`, its
16+
drain gate, item stamps) died with the contract they served (~90 B back).
17+
The registration-sequence window (`rq`/`sq`) and every sweep/hold/slot
18+
fix stays — those are contract-independent.
19+
- **Re-applied the round-10.5 emission-gate fix** the upstream rewrite
20+
reverted: the settle loop's value emission gated on the LOCAL consumer
21+
list again (silences ancestors, round-10 P1-3) — back to primitive-owned
22+
gating. Two invariant tests caught it immediately.
23+
- **Landing tests re-pinned to fold semantics**: an interim landing under
24+
retained optimism is INVISIBLE to both channels (classic keeps the
25+
optimistic view, count and all — the channel must not run ahead); the
26+
flip is atomic at settle, channel and classic together.
27+
- **The two upstream pins STILL FAIL under fold** (same-microtask second
28+
landing swallowed; until()-gated action wedged on it) — the re-ruling
29+
did not close them; they keep riding as it.fails.
30+
- Size: two ratchets for upstream fold bytes stacking on branch costs
31+
(createStore tier 15.15, store-family app 27.25); the deleted landing
32+
machinery clawed most of round-10.16's bytes back.
33+
- NOTE: based on an UNPUSHED next (a536e29b) — pushes held until it lands
34+
on origin.
35+
336
## Round 10.16 (2026-08-31) — structural-audit follow-up (2 P1 + 2 P2) + TWO OPEN upstream findings
437

538
- **FIXED P1 (slot registrants unstamped)**: `registerSlotPatchNext` now

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ function installNextBlockedHalf(): void {
102102
const overlaid = t?.fam?.overlaid as Set<StoreNextTarget> | undefined;
103103
if (overlaid !== undefined) {
104104
for (const ot of overlaid) {
105-
if (ot.pc !== null && ot.pc.p !== null) patchHooks!.emitPatchOptimistic(ot, null, null);
105+
// ONE emission (round 10.5, F7): the primitive self-gates on
106+
// consumers/machinery and bubbles ancestors internally —
107+
// compiled bodies reading INTO reverted children through
108+
// nested chains are reached without a duplicating ancestor
109+
// call on the undeduped lane path. Gating on the LOCAL
110+
// consumer list here silenced ancestor channels (round 10,
111+
// P1-3).
112+
if (patchHooks !== null) patchHooks.emitPatchOptimistic(ot, null, null);
106113
// Row-ops resync (family increment 2): reverts flip node values
107114
// back engine-natively; a driven list must rebuild retention by
108115
// row identity against the post-revert view (resolved from the

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ export interface PatchRowHooks {
4646
emitSlotPatch(t: StoreNextTarget, index: number, next: any, prev: any): void;
4747
emitSetterRowOps(t: StoreNextTarget, prevRows: any[], nextRows: any[]): void;
4848
emitRowOpsOptimistic(t: StoreNextTarget, next: any[] | null, ops: RowOps | null): void;
49-
/** Landing-consumption resync: regular queue, drain-time resolution,
50-
* structural-generation bump (supersedes queued pre-consumption work). */
51-
emitRowOpsLanding(t: StoreNextTarget): void;
5249
}
5350

5451
/** Raw→proxy wrap for captured structural rows (re-audit 8, P1-2).

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

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ interface QueuedApply {
123123
si?: number;
124124
/** Registration-sequence watermark at emission (see PatchChannel.rq). */
125125
rq?: number;
126-
/** Structural generation at emission (see PatchChannel.sg). */
127-
sg?: number;
128126
}
129127
let queue: QueuedApply[] | null = null;
130128
let scheduled = false;
@@ -176,23 +174,12 @@ function visibleStructRows(t: StoreNextTarget): any {
176174
* drain they were resynced in; repeats within it skip. */
177175
let drainGen = 0;
178176

179-
/** Drain-side `next` resolution with the SUPERSEDED-work gate (structural
180-
* audit F4, refined by the follow-up P2): a landing consumption bumped the
181-
* channel's structural generation and queued its own resync — stale ROW
182-
* items describe baselines the consumption invalidated and are covered by
183-
* that resync, so they drop. Stale SLOT items are STANDALONE value
184-
* notifications the row resync does NOT cover — they re-resolve against
185-
* the live visible view (their captured payload is pre-landing) and keep
186-
* their delivery; a slot the landing deleted drops (range gate). Returns
187-
* UNSET to skip the item. */
177+
/** Drain-side `next` resolution (structural audit F2): live targets read
178+
* the VISIBLE view at drain time. (The old-contract superseded-work
179+
* generation gate lived here; the #3164 fold ruling removed landing-time
180+
* consumption, and with it the stale-work window the gate closed — staged
181+
* truth now rides the retaining transaction's own queues.) */
188182
function drainNext(item: QueuedApply): unknown {
189-
const pc = item.pc;
190-
if (pc !== undefined && ((pc.sg as number) | 0) !== ((item.sg as number) | 0)) {
191-
if (item.si === undefined) return UNSET;
192-
const rows = visibleStructRows(pc.t as StoreNextTarget);
193-
if (!Array.isArray(rows) || (item.si as number) >= rows.length) return UNSET;
194-
return rows[item.si as number];
195-
}
196183
const { force, t } = item;
197184
return t !== null ? (force ? forcedNext(t) : visibleStructRows(t)) : item.next;
198185
}
@@ -637,8 +624,7 @@ export function emitRowOpsOptimistic(
637624
t: nextRows === null ? t : null,
638625
ops,
639626
pc: t.pc as PatchChannel,
640-
rq: ((t.pc as any).rq as number) | 0,
641-
sg: ((t.pc as any).sg as number) | 0
627+
rq: ((t.pc as any).rq as number) | 0
642628
});
643629
if (!scheduled) {
644630
scheduled = true;
@@ -1561,8 +1547,7 @@ export function emitSlotPatch(t: StoreNextTarget, index: number, next: any, prev
15611547
t: null,
15621548
si: index,
15631549
pc: t.pc as PatchChannel,
1564-
rq: ((t.pc as any).rq as number) | 0,
1565-
sg: ((t.pc as any).sg as number) | 0
1550+
rq: ((t.pc as any).rq as number) | 0
15661551
});
15671552
}
15681553

@@ -1598,26 +1583,6 @@ export function registerSlotPatchNext(
15981583
return structuralUnbind(entry, list, pc, "sp", false);
15991584
}
16001585

1601-
/** Landing-consumption structural notification (audit follow-up P1,
1602-
* back-to-back continuations): the LANE with the DRAIN-RESOLVED resync
1603-
* form. Lane, because the ambient transaction at consumption is an
1604-
* optimistic action's — the regular queue would stash the item there and a
1605-
* reverting action DROPS its stash (the landing's notification must not
1606-
* die with a transaction it doesn't belong to). Drain-resolved, because an
1607-
* emission-time composed snapshot reads the MID-RECKONING draft — a parked
1608-
* or superseded landing's topology reached the DOM while classic readers
1609-
* held the previous view until its commit; visibleStructRows at drain time
1610-
* reads exactly what classic renders at that moment. Bumps the structural
1611-
* generation FIRST: row/slot work queued before this consumption is
1612-
* superseded (F4) whether or not row consumers exist. */
1613-
export function emitRowOpsLanding(t: StoreNextTarget): void {
1614-
const pc = t.pc as any;
1615-
if (pc === null) return;
1616-
pc.sg = ((pc.sg as number) | 0) + 1;
1617-
if (pc.ro === null) return;
1618-
emitRowOpsOptimistic(t, null, null);
1619-
}
1620-
16211586
/** Row-ops ride the SAME apply queue/timing as record patches: transition-
16221587
* stamped, applied at effect phase, in emission order (structure before the
16231588
* new rows' own patches can exist; retained rows' value patches commute). */
@@ -1633,8 +1598,7 @@ export function emitRowOps(t: StoreNextTarget, next: any[], ops: RowOps): void {
16331598
t: null,
16341599
ops,
16351600
pc: t.pc as PatchChannel,
1636-
rq: ((t.pc as any).rq as number) | 0,
1637-
sg: ((t.pc as any).sg as number) | 0
1601+
rq: ((t.pc as any).rq as number) | 0
16381602
});
16391603
}
16401604

@@ -1705,7 +1669,6 @@ function armRowHooks(): void {
17051669
emitRowOps,
17061670
emitSlotPatch,
17071671
emitSetterRowOps,
1708-
emitRowOpsOptimistic,
1709-
emitRowOpsLanding
1672+
emitRowOpsOptimistic
17101673
});
17111674
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export function pcOf(t: StoreNextTarget): PatchChannel {
170170
akAll: false,
171171
mlc: 0,
172172
rq: 0,
173-
sg: 0,
174173
t
175174
})
176175
);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ export interface PatchChannel {
103103
* `sq > item.rq`, with the drain-start `rq` as the FIXED window's far
104104
* edge (mid-drain registrants are excluded). */
105105
rq?: number;
106-
/** Structural generation (structural audit): a landing consumption bumps
107-
* it AFTER retained-edit replay — queued items stamped with an older
108-
* generation are superseded by the consumption's own resync and skipped
109-
* at drain (stale transition-held ops, the replay's interim ops). */
110-
sg?: number;
111106
/** Accessed-key set for the channel's compiled bodies (union across
112107
* registrations). Compiler-manifested registrations (re-audit 7, P1-1)
113108
* hand the STATIC read envelope — complete across branches the applies

‎packages/signals/tests/store/patch-invariants.test.ts‎

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,21 +1720,28 @@ describe("INVARIANT: landings integrate with the patch channel at classic-effect
17201720
expect(classic.at(-1)).toBe("x:1");
17211721
const watermark = patched.length;
17221722

1723-
// EQUAL interim landing: membership unchanged (same single id), but a
1724-
// sibling field moved (count 1 -> 2) so adoption genuinely emits. The
1725-
// label override is HELD — classic keeps "x"; the patch channel must
1726-
// deliver the override-composed view, never raw committed "a".
1723+
// Interim landing under FOLD semantics (#3164 re-ruling): the family
1724+
// retains optimism (the action is open), so fresh truth STAGES into the
1725+
// retaining transaction — classic readers keep the optimistic view
1726+
// exactly as it was (count still 1: staged truth is invisible until the
1727+
// reveal). The channel must deliver NOTHING newer than classic sees —
1728+
// no "a:" flash, no early count.
17271729
h.setServer([{ id: 1, label: "a", count: 2 }]);
17281730
h.poll();
17291731
await settle();
1730-
expect(classic.at(-1)).toBe("x:2");
1732+
expect(classic.at(-1)).toBe("x:1");
17311733
const sinceLanding = patched.slice(watermark);
17321734
expect(sinceLanding.some(v => v.startsWith("a:"))).toBe(false);
1733-
expect(patched.at(-1)).toBe("x:2");
1735+
expect(sinceLanding.some(v => v.endsWith(":2"))).toBe(false);
17341736

1737+
// ATOMIC REVEAL at settle: override dies, staged truth lands — both
1738+
// channels flip together to committed "a:2".
17351739
confirm();
17361740
await run;
17371741
await settle();
1742+
await settle();
1743+
expect(classic.at(-1)).toBe("a:2");
1744+
expect(patched.at(-1)).toBe("a:2");
17381745
disposeConsumers();
17391746
h.dispose();
17401747
});
@@ -1771,29 +1778,29 @@ describe("INVARIANT: landings integrate with the patch channel at classic-effect
17711778
const patchMark = patched.length;
17721779
const rowMark = rowEvents.length;
17731780

1774-
// CONTRADICTING landing: arrangement changed (id 2 never landed, id 3
1775-
// did) — overrides are consumed AT THE LANDING. The driven list must be
1776-
// told the view flipped NOW (resync against live truth — the optimistic
1777-
// ops it holds are baseline-relative and stale), and the value channel
1778-
// must deliver the authoritative view exactly once.
1781+
// CONTRADICTING landing under FOLD semantics (#3164 re-ruling): the
1782+
// family retains optimism (the action is open), so the landing STAGES —
1783+
// classic readers keep the optimistic arrangement [1, 2], and the
1784+
// channel must stay exactly there with them: no early flip, no early
1785+
// value.
17791786
h.setServer([
17801787
{ id: 1, label: "a2" },
17811788
{ id: 3, label: "c" }
17821789
]);
17831790
h.poll();
17841791
await settle();
1792+
expect(rowEvents.slice(rowMark)).toEqual([]);
1793+
expect(patched.slice(patchMark)).toEqual([]);
17851794

1786-
// Structural consumers saw the flip at the landing, not at owner settle.
1787-
const structSince = rowEvents.slice(rowMark);
1788-
expect(structSince.length).toBeGreaterThan(0);
1789-
expect(structSince.at(-1)!.ids).toEqual([1, 3]);
1790-
// Value channel: authoritative view, exactly one application.
1791-
expect(patched.slice(patchMark)).toEqual(["a2"]);
1792-
1795+
// ATOMIC REVEAL at settle: override dies, staged truth lands — the
1796+
// driven list flips to [1, 3] and the value channel delivers the
1797+
// authoritative "a2", both on the settle drain.
17931798
confirm();
17941799
await run;
17951800
await settle();
1801+
await settle();
17961802
expect(rowEvents.at(-1)!.ids).toEqual([1, 3]);
1803+
expect(patched.at(-1)).toBe("a2");
17971804
disposeConsumers();
17981805
h.dispose();
17991806
});

‎scripts/size/.size-limit.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ module.exports = [
191191
// gate reads; the replay machinery itself stays in the optimistic
192192
// module (see the store-family app scenario). Held at 14.99 post-rebase
193193
// — the earlier replay landing was already absorbed here.
194-
limit: "15.05 KB",
194+
//
195+
// #3164 fold ruling (upstream, 2026-09-01): heldTruthNodes ledger +
196+
// retainsOptimism seams ride paths createStore retains. Measured 15.12
197+
// post-rebase.
198+
limit: "15.15 KB",
195199
modifyEsbuildConfig
196200
},
197201
{
@@ -373,7 +377,11 @@ module.exports = [
373377
// Structural audit (2026-08-31): one-reckoning landing notification
374378
// (review commit 3e12ffdb) + superseded-work generation stamps and the
375379
// rebuilt late-registrant sweep. Measured 27.18.
376-
limit: "27.2 KB",
380+
// #3164 fold ruling (upstream, 2026-09-01): the fold/reveal machinery
381+
// replaces replay wholesale; net near-wash here after the branch's
382+
// landing hook + generation stamps were deleted with the contract they
383+
// served. Measured 27.21 post-rebase.
384+
limit: "27.25 KB",
377385
modifyEsbuildConfig
378386
},
379387
{

0 commit comments

Comments
 (0)