Skip to content

Commit 9d46716

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 1b816c4 commit 9d46716

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
@@ -535,8 +535,9 @@ function wipeStructuralOverrides(t: StoreNextTarget): void {
535535
}
536536
// Patch channel (override-consumption site): visible truth flipped to
537537
// committed for the consumed keys — force a re-apply from the live
538-
// view so the DOM leaves the override state.
539-
if (t.pc !== null && t.pc.p !== null) patchHooks!.emitPatchOptimistic(t, null, null);
538+
// view so the DOM leaves the override state. ONE emission (round 10.5,
539+
// F7): the primitive self-gates and bubbles.
540+
if (patchHooks !== null) patchHooks.emitPatchOptimistic(t, null, null);
540541
}
541542

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

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)