Skip to content

Commit 380940c

Browse files
chore: rebase reconciliation — restore #3123 optimistic landing semantics, combined budgets
-X theirs clobbered upstream's contradicted-landing gate and retained- edit drop() in optimistic.ts (caught by upstream's own suites); the file is reset to next's version with only the branch's three emission-gate changes re-applied (diff verified minimal). Native compiler binary rebuilt (stale pre-rebase build re-minted the #3105 lone-spread merge — hydrate parity caught it). Four size tiers ratcheted for upstream drift stacking with branch bytes; treeshake core floor merged at 21.7k. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8672659 commit 380940c

2 files changed

Lines changed: 19 additions & 75 deletions

File tree

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

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ function installNextBlockedHalf(): void {
117117
// ONE emission (round 10.5, F7): the primitive self-gates on
118118
// consumers/machinery and bubbles ancestors internally —
119119
// compiled bodies reading INTO reverted children through
120-
// nested chains are reached without a second (duplicating)
121-
// ancestor call on the undeduped lane path.
120+
// nested chains are reached without a duplicating ancestor
121+
// call on the undeduped lane path.
122122
if (patchHooks !== null) patchHooks.emitPatchOptimistic(ot, null, null);
123123
// Row-ops resync (family increment 2): reverts flip node values
124124
// back engine-natively; a driven list must rebuild retention by
@@ -543,8 +543,9 @@ function wipeStructuralOverrides(t: StoreNextTarget): void {
543543
}
544544
// Patch channel (override-consumption site): visible truth flipped to
545545
// committed for the consumed keys — force a re-apply from the live
546-
// view so the DOM leaves the override state.
547-
if (t.pc !== null && t.pc.p !== null) patchHooks!.emitPatchOptimistic(t, null, null);
546+
// view so the DOM leaves the override state. ONE emission (round 10.5,
547+
// F7): the primitive self-gates and bubbles.
548+
if (patchHooks !== null) patchHooks.emitPatchOptimistic(t, null, null);
548549
}
549550

550551
/** Settle-time re-derivation (#3123 re-ruling, the second reckoning point):
@@ -603,73 +604,10 @@ export function consumeOverridesNext(fam: StoreNextFamily, replacing: boolean):
603604
let consumed = false;
604605
runAuthoritative(() => {
605606
for (const t of overlaid as Set<StoreNextTarget>) {
606-
const drop = (node: Signal<any>, committed: any) => {
607-
if (!hasActiveOverride(node)) return;
608-
const prev = unwrapOverride(node._x?._overrideValue);
609-
// Full legacy reset (clearOptimisticOverride parity): the landing is
610-
// authoritative NOW — fold committed into the node directly instead
611-
// of riding a transaction's commit (whose queues may be stashed with
612-
// the transaction parked; the wake would strand until it settles).
613-
ext(node)._overrideValue = NOT_PENDING;
614-
node._config |= CONFIG_OPTIMISTIC;
615-
const nx = (node as any)._x;
616-
if (nx) {
617-
nx._overrideOwner = null;
618-
nx._optimisticLane = undefined;
619-
}
620-
node._pendingValue = NOT_PENDING;
621-
node._value = committed;
622-
if (!node._equals || !node._equals(prev, committed)) {
623-
insertSubs(node, true);
624-
schedule();
625-
}
626-
};
627-
// Landing consumes STRUCTURAL optimism only (legacy layer parity):
628-
// membership edits, array length, and the value overrides written WITH
629-
// them (a key carrying an active presence override is an add/delete —
630-
// classified BEFORE the adoption may have made the key exist in landed
631-
// data). A pure value override on a key the landing carries stays with
632-
// its owning transaction (rapid-toggle contract: a live action's edit
633-
// of an existing entity rides on top of landed truth).
634-
const isArr = Array.isArray(t.v);
635-
const has = t.h;
636-
let structuralKeys: Set<PropertyKey> | null = null;
637-
if (has !== null) {
638-
for (const key of Reflect.ownKeys(has)) {
639-
if (hasActiveOverride(has[key as any])) (structuralKeys ??= new Set()).add(key);
640-
}
641-
}
642-
const nodes = t.n;
643-
if (nodes !== null) {
644-
for (const key of Reflect.ownKeys(nodes)) {
645-
const structural =
646-
structuralKeys?.has(key) || !(key in t.v) || (isArr && key === "length");
647-
if (!structural) continue;
648-
drop(
649-
nodes[key as any],
650-
isArr && key === "length" ? (t.v as any[]).length : t.v[key as any]
651-
);
652-
}
653-
}
654-
if (has !== null) {
655-
for (const key of Reflect.ownKeys(has)) drop(has[key as any], key in t.v);
656-
}
657-
if (t.k !== null && hasActiveOverride(t.k)) {
658-
ext(t.k)._overrideValue = NOT_PENDING;
659-
t.k._config |= CONFIG_OPTIMISTIC;
660-
const kx = (t.k as any)._x;
661-
if (kx) {
662-
kx._overrideOwner = null;
663-
kx._optimisticLane = undefined;
664-
}
665-
insertSubs(t.k, true);
666-
schedule();
667-
}
668-
// Patch channel (override-consumption site): visible truth flipped to
669-
// committed for the consumed keys — force a re-apply from the live
670-
// view so the DOM leaves the override state. ONE emission (round
671-
// 10.5, F7): the primitive self-gates and bubbles.
672-
if (patchHooks !== null) patchHooks.emitPatchOptimistic(t, null, null);
607+
if (!contradicted.has(t)) continue;
608+
consumed = true;
609+
overlaid.delete(t);
610+
wipeStructuralOverrides(t);
673611
}
674612
contradicted.clear();
675613
});

scripts/size/.size-limit.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ module.exports = [
178178
// Re-audit-9 (2026-08-29): held-view admission, committed-visible skip
179179
// markers, tentative self-emission, unchanged-reconcile gate, function-
180180
// intermediate probes. Measured 14.80.
181-
limit: "14.9 KB",
181+
// Rebase onto next (2026-08-31): upstream rc.5 drift stacks with the
182+
// branch bytes. Measured 14.99.
183+
limit: "15.05 KB",
182184
modifyEsbuildConfig
183185
},
184186
{
@@ -344,7 +346,9 @@ module.exports = [
344346
path: "hydrating-store-app.js",
345347
// Round-10.9 (2026-08-31): demotion-lifecycle bytes (per-entry
346348
// envelopes, commit skip, akAll refcount). Measured 26.56.
347-
limit: "26.65 KB",
349+
// Rebase onto next (2026-08-31): upstream drift + lifecycle fixes
350+
// stack with the branch bytes. Measured 27.06.
351+
limit: "27.15 KB",
348352
modifyEsbuildConfig
349353
},
350354
{
@@ -413,7 +417,8 @@ module.exports = [
413417
// Round-10.9 (2026-08-31): per-entry manifest envelopes (write-free
414418
// demotion computes), failed-compute commit skip, akAll refcount,
415419
// transparent redrive roots. Measured 16.25.
416-
limit: "16.3 KB",
420+
// Rebase onto next (2026-08-31): upstream drift stacks. Measured 16.36.
421+
limit: "16.45 KB",
417422
modifyEsbuildConfig
418423
},
419424
{
@@ -456,7 +461,8 @@ module.exports = [
456461
// Size pass (2026-08-31): same trims. Measured 18.60 — tightened.
457462
// Round-10.9 (2026-08-31): demotion-lifecycle bytes (see value tier).
458463
// Measured 18.72.
459-
limit: "18.8 KB",
464+
// Rebase onto next (2026-08-31): upstream drift stacks. Measured 18.82.
465+
limit: "18.9 KB",
460466
modifyEsbuildConfig
461467
},
462468
{

0 commit comments

Comments
 (0)