diff --git a/kernel/package-lock.json b/kernel/package-lock.json index 8a2c4491d7..7ecaea2d8c 100644 --- a/kernel/package-lock.json +++ b/kernel/package-lock.json @@ -1,12 +1,12 @@ { "name": "acp-kernel", - "version": "0.0.201", + "version": "0.0.202", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "acp-kernel", - "version": "0.0.201", + "version": "0.0.202", "license": "MIT", "devDependencies": { "@types/node": "^22.0.0", diff --git a/kernel/package.json b/kernel/package.json index 5ac694d897..80a65d212a 100644 --- a/kernel/package.json +++ b/kernel/package.json @@ -1,6 +1,6 @@ { "name": "acp-kernel", - "version": "0.0.201", + "version": "0.0.202", "description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.", "license": "MIT", "author": "ranxianglei", diff --git a/kernel/src/compress.ts b/kernel/src/compress.ts index 43a0238c6e..9ec488174a 100644 --- a/kernel/src/compress.ts +++ b/kernel/src/compress.ts @@ -933,6 +933,20 @@ export function createCore(ports: Ports = {}): CompressionCore { state.pendingOrphanSweepMinRef === undefined ? foldStartRef : Math.min(state.pendingOrphanSweepMinRef, foldStartRef); + // #6116: upper bound of the same window. Every message in history at + // apply time carries a ref <= this frontier; the successful call and + // any later same-turn calls only get refs on the next assignRefs pass, + // so they land strictly above it and survive the sweep with their + // failure feedback intact (under-sweep is safe; over-sweep is not). + // Running MAX mirrors the min side's running MIN across folds that + // commit before one consuming turn. + const frontier = highestUsedIndex(state.messageRefs); + if (frontier > 0) { + state.pendingOrphanSweepMaxRef = + state.pendingOrphanSweepMaxRef === undefined + ? frontier + : Math.max(state.pendingOrphanSweepMaxRef, frontier); + } } // Compress succeeded: clear the growth baseline so the next turn // re-establishes it at the new (lower) token count. Without this the @@ -1434,6 +1448,8 @@ const hideCompressCallsNode: PipelineNode = { const patch: Partial = { hiddenOrphanRefs: hidden.hiddenOrphanRefs, pendingOrphanSweepMinRef: undefined, + // #6116: the window bound is one-shot with the marker it bounds. + pendingOrphanSweepMaxRef: undefined, }; if (hidden.newlySweptCallIds.length > 0) { patch.sweptOrphanCallIds = [ @@ -2632,6 +2648,7 @@ function cloneState(state: CompressionState): CompressionState { ? [...state.sweptOrphanCallIds] : undefined, pendingOrphanSweepMinRef: state.pendingOrphanSweepMinRef, + pendingOrphanSweepMaxRef: state.pendingOrphanSweepMaxRef, // #6116 (sweep window upper bound) deadRefs: state.deadRefs ? [...state.deadRefs] : undefined, lastPassIds: state.lastPassIds ? [...state.lastPassIds] : undefined, // #4797: the one-time ledger-alignment gate must survive the fold clone diff --git a/kernel/src/hide-consumed.ts b/kernel/src/hide-consumed.ts index fd62ef7585..f251212613 100644 --- a/kernel/src/hide-consumed.ts +++ b/kernel/src/hide-consumed.ts @@ -10,11 +10,14 @@ import type { CompressionState, CoreMessage } from "./types.js"; // (billion-context-pi #9: 3,849 identical calls over 5h13m under keep=0), AND a // quiet turn must never move the cached prefix breakpoint forward just to delete // a few hundred chars of old failure residue — the old keep-last-two rotation did -// exactly that (hid the oldest failure on EVERY turn, seam cost far exceeding the -// bytes removed). Now: between folds nothing is swept; on a fold the node sweeps -// orphans at/after the fold's earliest start ref onto the persistent -// sweptOrphanCallIds set (they stay hidden forever), leaving orphans before it -// visible. Residue is bounded by fold cadence, not a fixed pair count. + // exactly that (hid the oldest failure on EVERY turn, seam cost far exceeding the + // bytes removed). Now: between folds nothing is swept; on a fold the node sweeps + // orphans at/after the fold's earliest start ref — and at/before the highest ref + // allocated when that fold committed (#6116: the successful call and any later + // same-turn calls get refs above that frontier and keep their failure feedback + // visible) — onto the persistent sweptOrphanCallIds set (they stay hidden + // forever), leaving orphans outside the window visible. Residue is bounded by + // fold cadence, not a fixed pair count. export interface HideConsumedResult { messages: CoreMessage[]; @@ -319,8 +322,15 @@ export function hideConsumedCompressCalls( // fold pending nothing new is swept, so a quiet turn never breaks the prefix. // Orphans quoting an ACTIVE block's folded range are that block's summary // carrier (#1567) and are exempt from the sweep (quotesActiveBlock). + // #6116: the window is bounded above by pendingOrphanSweepMaxRef — the highest + // allocated ref when the pending fold committed. The successful call and any + // same-turn calls after it only get refs above that frontier, so their failure + // feedback must stay visible for the model to react to; sweeping them would be + // over-sweep (under-sweep is safe, over-sweep is not). States written before + // #6116 lack the max bound and keep the pre-fix unbounded behavior. const sweptSet = new Set(state.sweptOrphanCallIds ?? []); const foldMinRef = state.pendingOrphanSweepMinRef; + const foldMaxRef = state.pendingOrphanSweepMaxRef; const newlySweptCallIds: string[] = []; const keepCallIds = new Set(); @@ -346,7 +356,9 @@ export function hideConsumedCompressCalls( hide = true; } else if (foldMinRef !== undefined && !quotesActiveBlock(messages[i]!.text, activeRangeKeys)) { const num = refNum(ref); - if (num !== null && num >= foldMinRef) { + // #6116: window is [foldMinRef, foldMaxRef]; a missing max bound + // (pre-#6116 state) degrades to the pre-fix unbounded sweep. + if (num !== null && num >= foldMinRef && (foldMaxRef === undefined || num <= foldMaxRef)) { hide = true; newlySweptCallIds.push(callId); } diff --git a/kernel/src/sync.ts b/kernel/src/sync.ts index 87008df298..a6a63e9827 100644 --- a/kernel/src/sync.ts +++ b/kernel/src/sync.ts @@ -84,6 +84,7 @@ export function syncBlocks( hiddenOrphanRefs: state.hiddenOrphanRefs ? [...state.hiddenOrphanRefs] : undefined, sweptOrphanCallIds: state.sweptOrphanCallIds ? [...state.sweptOrphanCallIds] : undefined, pendingOrphanSweepMinRef: state.pendingOrphanSweepMinRef, + pendingOrphanSweepMaxRef: state.pendingOrphanSweepMaxRef, // #6116 (sweep window upper bound) // #3939 ③: the truncation latch must survive the sync node — dropping it // here would re-expose clipped bytes mid-history after a sync carried the // rest of the state (#3691 oscillation via the sync path). diff --git a/kernel/src/types.ts b/kernel/src/types.ts index 928504c10a..73664a952c 100644 --- a/kernel/src/types.ts +++ b/kernel/src/types.ts @@ -363,6 +363,19 @@ export interface CompressionState { * Carries the position so the sweep is cache-neutral: it only removes records * the fold already invalidated. Optional: absent until the first post-fix fold. */ pendingOrphanSweepMinRef?: number; + /** UPPER bound of the same pending orphan-sweep window (#6116): the highest + * allocated m-ref at the moment the most recent pending fold committed + * (highestUsedIndex of messageRefs in applyCompression). Every message that + * was already in history then carries a ref <= this value; the successful + * compress call itself and anything issued after it (mixed multi-tool turns) + * only gets a ref on the NEXT assignRefs pass — strictly above it — so it + * stays out of the sweep and its failure feedback remains visible for the + * model to react to. Consumed together with pendingOrphanSweepMinRef (the + * sweep condition becomes min <= refNum <= max). Across several folds that + * commit before one consuming turn it keeps the running MAX, mirroring the + * min side's running MIN. Optional: states written before #6116 lack it, and + * a missing max degrades to the pre-fix unbounded sweep (upgrade compat). */ + pendingOrphanSweepMaxRef?: number; /** Emergency-truncation latch (#3939 ③/#3691): the clipped texts (post-clip * bytes, keyed by padded ref) of messages clipped by the emergency-truncate * node. The watermark decision is made ONCE — replaying these clips on every diff --git a/kernel/tests/issue6116-sweep-window.test.ts b/kernel/tests/issue6116-sweep-window.test.ts new file mode 100644 index 0000000000..6700c6b48d --- /dev/null +++ b/kernel/tests/issue6116-sweep-window.test.ts @@ -0,0 +1,325 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { createCore } from "../src/compress.js"; +import { assignRefs } from "../src/refs.js"; +import { hideConsumedCompressCalls } from "../src/hide-consumed.js"; +import { createInitialState } from "../src/state.js"; +import type { CompressionState, Config, CoreMessage } from "../src/types.js"; + +// #6116 regression: the fold-gated orphan sweep (#3769) is bounded by a WINDOW — +// [earliest covered ref of the pending fold, highest ref allocated when it committed]. +// The successful compress call and any same-turn calls issued after it only receive +// refs above that frontier, so their failure feedback must survive the sweep: wiping +// fresh error text would push the model straight back into re-issuing the same no-op +// compress (the pathology #3769 exists to prevent). Under-sweep is safe; over-sweep +// is not. States written before #6116 lack the max bound and keep the pre-fix +// unbounded behavior (upgrade compat). + +const isMcp = (n: string) => n === "compress" || n === "mcp__bili__compress"; + +function msg(id: string, text: string): CoreMessage { + return { id, role: "user", contentType: "text", text }; +} + +function failPair(callId: string): [CoreMessage, CoreMessage] { + return [ + { + id: `c-${callId}`, + role: "assistant", + contentType: "tool-call", + toolName: "mcp__bili__compress", + toolCallId: callId, + text: JSON.stringify({ content: [{ startId: "mA", endId: "mB", summary: "s" }] }), + }, + { + id: `r-${callId}`, + role: "tool", + contentType: "tool-result", + toolCallId: callId, + text: "nothing to compress", + }, + ]; +} + +function seqRefs(state: CompressionState, messages: CoreMessage[]): void { + messages.forEach((m, i) => { + state.messageRefs.byRaw[m.id] = `m${String(i + 1).padStart(5, "0")}`; + }); +} + +function config(): Config { + return { + tiers: { enabled: true, tier2Trigger: 5, tier3Trigger: 10 }, + nudge: { + maxContextLimitPct: 0.55, + minContextLimitPct: 0.45, + frequency: 5, + iterationThreshold: 15, + force: "soft", + growthRatio: 0.05, + growthFloor: 6000, + growthCap: 50000, + minGrowthFloor: 5000, + minGrowthRatio: 0.45, + emergencyThresholdPct: 0.98, + }, + promotionThreshold: 5, + truncate: { threshold: 1 }, + merge: { maxSummaryLength: 3000, minOldGenBlocks: 3 }, + compress: { minCompressRange: 0, maxSummaryLength: 0, minSummaryLength: 0 }, + protectedTools: [], + preserveRecentMessages: 0, + preserveRecentTokens: 0, + modelContextLimit: 100000, + }; +} + +// refs: p1=1 c-f1=2 r-f1=3 p2=4 c-f2=5 r-f2=6 p3=7 c-f3=8 r-f3=9 p4=10 c-f4=11 r-f4=12 +function windowLayout(): { state: CompressionState; messages: CoreMessage[] } { + const state = createInitialState(); + const messages: CoreMessage[] = []; + messages.push(msg("p1", "early")); + messages.push(...failPair("f1")); + messages.push(msg("p2", "mid")); + messages.push(...failPair("f2")); + messages.push(msg("p3", "late")); + messages.push(...failPair("f3")); + messages.push(msg("p4", "later")); + messages.push(...failPair("f4")); + seqRefs(state, messages); + return { state, messages }; +} + +test("the sweep window is inclusive on both ends: inside swept, outside visible (#6116)", () => { + const { state, messages } = windowLayout(); + state.pendingOrphanSweepMinRef = 5; + state.pendingOrphanSweepMaxRef = 9; + + const r = hideConsumedCompressCalls(state, messages, isMcp); + assert.deepEqual(r.newlySweptCallIds, ["f2", "f3"], "only orphans inside [min,max] swept"); + const ids = r.messages.map((m) => m.id); + assert.ok(ids.includes("c-f1"), "orphan below min stays visible (still-cached prefix)"); + assert.ok(!ids.includes("c-f2") && !ids.includes("c-f3"), "in-window orphans removed"); + assert.ok(ids.includes("c-f4"), "orphan above max stays visible (fresh failure feedback)"); + + // Endpoint inclusivity, one side each. + const lo = createInitialState(); + seqRefs(lo, messages); + lo.pendingOrphanSweepMinRef = 5; + lo.pendingOrphanSweepMaxRef = 5; + assert.deepEqual( + hideConsumedCompressCalls(lo, messages, isMcp).newlySweptCallIds, + ["f2"], + "lower endpoint inclusive", + ); + const hi = createInitialState(); + seqRefs(hi, messages); + hi.pendingOrphanSweepMinRef = 8; + hi.pendingOrphanSweepMaxRef = 8; + assert.deepEqual( + hideConsumedCompressCalls(hi, messages, isMcp).newlySweptCallIds, + ["f3"], + "upper endpoint inclusive", + ); +}); + +test("a legacy state without the max bound degrades to the pre-fix unbounded sweep (#6116 upgrade compat)", () => { + const { state, messages } = windowLayout(); + state.pendingOrphanSweepMinRef = 5; + // pendingOrphanSweepMaxRef absent: exactly the shape of states written before #6116. + + const r = hideConsumedCompressCalls(state, messages, isMcp); + assert.deepEqual( + r.newlySweptCallIds, + ["f2", "f3", "f4"], + "min-only marker keeps the #3769 unbounded-at/after behavior", + ); +}); + +test("a max bound without a min marker sweeps nothing (defensive invariant, #6116)", () => { + const { state, messages } = windowLayout(); + state.pendingOrphanSweepMaxRef = 12; + // Cannot arise in practice — applyCompression sets both markers together — but + // the guard order must make a stray max inert rather than an all-history sweep. + + const r = hideConsumedCompressCalls(state, messages, isMcp); + assert.equal(r.hidden, 0, "no min marker -> no sweep"); + assert.equal(r.newlySweptCallIds.length, 0, "stray max bound is inert"); +}); + +test("a real fold writes BOTH markers: min = earliest covered ref, max = commit-time frontier (#6116)", () => { + const core = createCore(); + const messages: CoreMessage[] = [ + msg("h1", "first detailed work item alpha content"), + msg("h2", "second detailed work item beta content"), + msg("h3", "third detailed work item gamma content"), + ...failPair("f1"), + msg("h4", "fourth detailed work item delta content"), + msg("last", "latest user intent theta"), + ]; + // refs: h1=1 h2=2 h3=3 c-f1=4 r-f1=5 h4=6 last=7 + const state = createInitialState(); + state.messageRefs = assignRefs(messages, { + existing: state.messageRefs, + nextIndex: 1, + }).map; + + const out = core.applyCompression({ + ranges: [{ startRef: "m00001", endRef: "m00003", summary: "fold the spent head", topic: "head" }], + messages, + state, + config: config(), + }); + assert.equal(out.result.errors.length, 0, `unexpected errors: ${out.result.errors.join("; ")}`); + assert.ok(out.result.blocksCreated >= 1, "the head genuinely folds"); + assert.equal(out.state.pendingOrphanSweepMinRef, 1, "min marker points at the fold's earliest start ref"); + assert.equal(out.state.pendingOrphanSweepMaxRef, 7, "max marker is the highest allocated ref at commit time"); +}); + +test("a failure issued after the successful call keeps its feedback visible (mixed multi-tool turn, #6116)", () => { + // THE issue scenario: the model fires several tools in one assistant turn. The + // request history the fold applies to ends BEFORE the response's calls land; the + // successful call and any later same-turn failures only get refs on the next + // assignRefs pass — strictly above the committed frontier — so they must stay + // out of the sweep while the pre-success residue inside the window goes away. + const core = createCore(); + const requestHistory: CoreMessage[] = [ + msg("h1", "first detailed work item alpha content"), + msg("h2", "second detailed work item beta content"), + msg("h3", "third detailed work item gamma content"), + ...failPair("f1"), + msg("h4", "fourth detailed work item delta content"), + msg("last", "latest user intent theta"), + ]; + const state = createInitialState(); + state.messageRefs = assignRefs(requestHistory, { + existing: state.messageRefs, + nextIndex: 1, + }).map; + + const out = core.applyCompression({ + ranges: [ + { startRef: "m00001", endRef: "m00003", summary: "fold the spent head", topic: "head", compressCallId: "s1" }, + ], + messages: requestHistory, + state, + config: config(), + }); + assert.equal(out.result.errors.length, 0, `unexpected errors: ${out.result.errors.join("; ")}`); + assert.equal(out.state.pendingOrphanSweepMaxRef, 7, "frontier frozen at apply time"); + + // The response then rides the history: success s1 (the block's carrier) plus a + // fresh failure fAfter issued in the same turn. + const extended: CoreMessage[] = [ + ...requestHistory, + { + id: "c-s1", + role: "assistant", + contentType: "tool-call", + toolName: "mcp__bili__compress", + toolCallId: "s1", + text: JSON.stringify({ content: [{ startId: "m00001", endId: "m00003", summary: "fold the spent head" }] }), + }, + { + id: "r-s1", + role: "tool", + contentType: "tool-result", + toolCallId: "s1", + text: "compressed the head", + }, + ...failPair("fAfter"), + ]; + out.state.messageRefs = assignRefs(extended, { + existing: out.state.messageRefs, + nextIndex: 8, + }).map; + // c-s1=8 r-s1=9 c-fAfter=10 r-fAfter=11 — all strictly above the frontier. + + const r = hideConsumedCompressCalls(out.state, extended, isMcp); + assert.deepEqual(r.newlySweptCallIds, ["f1"], "only the pre-success failure inside the window is swept"); + const ids = r.messages.map((m) => m.id); + assert.ok(ids.includes("c-fAfter") && ids.includes("r-fAfter"), "post-success failure stays visible for the model to react to"); + assert.ok(ids.includes("c-s1"), "the active success carrier is untouched"); +}); + +test("two folds before one consuming turn: running min + running max define the union window (#6116)", () => { + const core = createCore(); + const m1: CoreMessage[] = [ + msg("h1", "first detailed work item alpha content"), + msg("h2", "second detailed work item beta content"), + msg("h3", "third detailed work item gamma content"), + ...failPair("f1"), + msg("h4", "fourth detailed work item delta content"), + msg("last", "latest user intent theta"), + ]; + // refs: h1=1 h2=2 h3=3 c-f1=4 r-f1=5 h4=6 last=7 + const state = createInitialState(); + state.messageRefs = assignRefs(m1, { existing: state.messageRefs, nextIndex: 1 }).map; + + const first = core.applyCompression({ + ranges: [{ startRef: "m00001", endRef: "m00003", summary: "fold the head", topic: "head" }], + messages: m1, + state, + config: config(), + }); + assert.equal(first.result.errors.length, 0, `unexpected errors: ${first.result.errors.join("; ")}`); + assert.equal(first.state.pendingOrphanSweepMinRef, 1, "first fold: min=1"); + assert.equal(first.state.pendingOrphanSweepMaxRef, 7, "first fold: max=7"); + + // Next request appends two messages and folds the tail — no consuming turn in + // between, so the markers accumulate instead of resetting. + const m2: CoreMessage[] = [ + ...m1, + msg("p5", "fifth detailed work item epsilon content"), + msg("p6", "sixth detailed work item zeta content"), + ]; + first.state.messageRefs = assignRefs(m2, { existing: first.state.messageRefs, nextIndex: 8 }).map; + // p5=8 p6=9 + const second = core.applyCompression({ + ranges: [{ startRef: "m00006", endRef: "m00009", summary: "fold the tail", topic: "tail" }], + messages: m2, + state: first.state, + config: config(), + }); + assert.equal(second.result.errors.length, 0, `unexpected errors: ${second.result.errors.join("; ")}`); + assert.ok(second.result.blocksCreated >= 1, "the tail genuinely folds"); + assert.equal(second.state.pendingOrphanSweepMinRef, 1, "running MIN keeps the earliest fold start"); + assert.equal(second.state.pendingOrphanSweepMaxRef, 9, "running MAX tracks the newest frontier"); + + const r = hideConsumedCompressCalls(second.state, m2, isMcp); + assert.deepEqual(r.newlySweptCallIds, ["f1"], "union window [1,9] sweeps the pre-fold orphan once"); +}); + +test("the full pipeline carries the max bound and consumes BOTH markers one-shot (#6116)", () => { + const core = createCore(); + const messages: CoreMessage[] = [ + msg("p1", "early cached prefix alpha"), + ...failPair("f2"), + msg("p2", "mid detailed work item beta content"), + ...failPair("f3"), + ]; + const state = createInitialState(); + seqRefs(state, messages); + // refs: p1=1 c-f2=2 r-f2=3 p2=4 c-f3=5 r-f3=6 — a fold covering refs 2..3 + // committed last turn. Without the sync-blocks carry of the NEW field the max + // would die on the first pipeline node and degrade to the unbounded sweep, + // wrongly taking f3 (ref 5 > intended max 3). + state.pendingOrphanSweepMinRef = 2; + state.pendingOrphanSweepMaxRef = 3; + + const cfg = { ...config(), isCompressTool: isMcp }; + const turn = core.processTurn({ + messages, + state, + config: cfg, + tokenCount: 1000, + renderTags: "none", + }); + + const ids = turn.messages.map((m) => m.id); + assert.ok(!ids.includes("c-f2") && !ids.includes("r-f2"), "orphan inside the window swept inside the pipeline"); + assert.ok(ids.includes("c-f3") && ids.includes("r-f3"), "orphan above the carried max bound stays visible"); + assert.deepEqual(turn.state.sweptOrphanCallIds, ["f2"], "swept id folded into the persistent set"); + assert.equal(turn.state.pendingOrphanSweepMinRef, undefined, "min marker consumed one-shot"); + assert.equal(turn.state.pendingOrphanSweepMaxRef, undefined, "max marker consumed one-shot"); +}); diff --git a/package-lock.json b/package-lock.json index 72519f7f77..8f31611801 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,7 @@ }, "kernel": { "name": "acp-kernel", - "version": "0.0.201", + "version": "0.0.202", "dev": true, "license": "MIT", "devDependencies": { diff --git a/src/state-hydration.ts b/src/state-hydration.ts index 8bd9b10b4d..4fa735d2b1 100644 --- a/src/state-hydration.ts +++ b/src/state-hydration.ts @@ -64,6 +64,11 @@ export function mergeState(parsed: CompressionState): CompressionState { // transient, losing it only defers the sweep to the next fold. sweptOrphanCallIds: parsed.sweptOrphanCallIds ?? fresh.sweptOrphanCallIds, pendingOrphanSweepMinRef: parsed.pendingOrphanSweepMinRef ?? fresh.pendingOrphanSweepMinRef, + // #6116: the window's upper bound is transient like the min marker; + // states written before #6116 lack it and keep the pre-fix unbounded + // sweep for that one pending window (upgrade compat, pinned by + // kernel/tests/issue6116-sweep-window.test.ts). + pendingOrphanSweepMaxRef: parsed.pendingOrphanSweepMaxRef ?? fresh.pendingOrphanSweepMaxRef, // #3939 ③/#3691: the emergency-truncate latch must survive hydration — // dropping it re-exposes clipped bytes mid-history after a restart, // rewriting the still-cached prefix on the first post-restart turn. diff --git a/tests/golden/storage-render/anthropic.json b/tests/golden/storage-render/anthropic.json index 7c01ccf504..3ee76ea242 100644 --- a/tests/golden/storage-render/anthropic.json +++ b/tests/golden/storage-render/anthropic.json @@ -121,6 +121,7 @@ "rules": "4f53cda18c2baa0c", "sweptOrphanCallIds": "74234e98afe7498f", "pendingOrphanSweepMinRef": "74234e98afe7498f", + "pendingOrphanSweepMaxRef": "74234e98afe7498f", "emergencyTruncateLatch": "74234e98afe7498f", "renderDeferredRefs": "74234e98afe7498f", "viewLatches": "74234e98afe7498f", diff --git a/tests/golden/storage-render/chat.json b/tests/golden/storage-render/chat.json index 5ecde5722b..469fc5bda7 100644 --- a/tests/golden/storage-render/chat.json +++ b/tests/golden/storage-render/chat.json @@ -121,6 +121,7 @@ "rules": "4f53cda18c2baa0c", "sweptOrphanCallIds": "74234e98afe7498f", "pendingOrphanSweepMinRef": "74234e98afe7498f", + "pendingOrphanSweepMaxRef": "74234e98afe7498f", "emergencyTruncateLatch": "74234e98afe7498f", "renderDeferredRefs": "74234e98afe7498f", "viewLatches": "74234e98afe7498f", diff --git a/tests/golden/storage-render/google.json b/tests/golden/storage-render/google.json index 26c5f73b94..4711eb7486 100644 --- a/tests/golden/storage-render/google.json +++ b/tests/golden/storage-render/google.json @@ -121,6 +121,7 @@ "rules": "4f53cda18c2baa0c", "sweptOrphanCallIds": "74234e98afe7498f", "pendingOrphanSweepMinRef": "74234e98afe7498f", + "pendingOrphanSweepMaxRef": "74234e98afe7498f", "emergencyTruncateLatch": "74234e98afe7498f", "renderDeferredRefs": "74234e98afe7498f", "viewLatches": "74234e98afe7498f", diff --git a/tests/golden/storage-render/responses.json b/tests/golden/storage-render/responses.json index 8041cd5155..abc142bfee 100644 --- a/tests/golden/storage-render/responses.json +++ b/tests/golden/storage-render/responses.json @@ -121,6 +121,7 @@ "rules": "4f53cda18c2baa0c", "sweptOrphanCallIds": "74234e98afe7498f", "pendingOrphanSweepMinRef": "74234e98afe7498f", + "pendingOrphanSweepMaxRef": "74234e98afe7498f", "emergencyTruncateLatch": "74234e98afe7498f", "renderDeferredRefs": "74234e98afe7498f", "viewLatches": "74234e98afe7498f", diff --git a/tests/storage-state-fields.test.ts b/tests/storage-state-fields.test.ts index 501daeab1a..beb74be4fc 100644 --- a/tests/storage-state-fields.test.ts +++ b/tests/storage-state-fields.test.ts @@ -25,6 +25,8 @@ test("#4192: sweptOrphanCallIds / pendingOrphanSweepMinRef survive the unified r ...createInitialState(), sweptOrphanCallIds: ["m00042", "m00043"], pendingOrphanSweepMinRef: 42, + // #6116: the window's upper bound rides the same derived field list. + pendingOrphanSweepMaxRef: 43, }; const legacy = { id: "sf-1", @@ -51,6 +53,7 @@ test("#4192: sweptOrphanCallIds / pendingOrphanSweepMinRef survive the unified r // The two fields the hand list dropped (#4192) must round-trip intact. assert.deepEqual((view.state as Record).sweptOrphanCallIds, ["m00042", "m00043"]); assert.equal((view.state as Record).pendingOrphanSweepMinRef, 42); + assert.equal((view.state as Record).pendingOrphanSweepMaxRef, 43); // #6116 store.close(); } finally { rmSync(dir, { recursive: true, force: true });