From ce1da3971f3dcbc134e4bff2a1122d831e5cf196 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Fri, 13 Nov 2026 22:28:27 +0800 Subject: [PATCH 01/13] fix(overflow): recognize the native-intercept oversize-gate refusal as a parseable overflow marker (#6122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The relay saw bili's OWN oversize refusal (bili_gate_oversize_refusal_*) come back through the client as a 400 and logged the #4452 CANNOT-engage warning on its own body — self-heal (same-request refold / emergency shrink) never armed and the oversized history was re-sent every turn (400 forever). The gate code is bili's definitive over-window proof: it now reads as an overflow with no learnable window (the 1,000,000 in the prose is a pricing floor), so the no-window arm (min of judging window and payload estimate) engages. The compaction refusal is a different class and stays dark. --- src/util.ts | 14 ++++++++ tests/context-overflow.test.ts | 39 +++++++++++++++++++++++ tests/issue4452-markerless-reject.test.ts | 25 +++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/src/util.ts b/src/util.ts index 7755425244..5ef4d559a9 100644 --- a/src/util.ts +++ b/src/util.ts @@ -398,6 +398,20 @@ const CONTEXT_OVERFLOW_PATTERNS: RegExp[] = [ /输入[^。;;!!\n]{0,12}(?:超出|超过|超限)/, // (f) #3240/#3246 consolidation: mixed-language gateways write "prompt 过长". /prompt[^。;;!!\n]{0,6}(?:过长|太长|超长)/i, + // #6122: the native-intercept gate's OWN oversize refusal (src/agent/ + // native-intercept.ts) — bili's definitive "provably over window" signal. + // The field case: the gate refused an unattributed oversized body, the + // relay saw that refusal come back through the client as a 400, and — no + // parseable marker — logged the #4452 CANNOT-engage warning while the + // oversized history was re-sent on every turn (400 forever). The code + // covers all five oversize variants (bare / _fallback / _no_live_state / + // _unattributed / _unattributed_bytes). The compaction refusal + // (bili_gate_dsh_compaction_refused) is a different class (no proxy + // available, body fits fine) and must stay dark. No window number is + // learnable from the prose ("1,000,000 tokens" is a pricing FLOOR, not + // the model's window) — the no-window arm (min of judging window and + // payload estimate) is what engages. + /bili_gate_oversize_refusal/i, ]; function toTokenNumber(s: string): number | undefined { diff --git a/tests/context-overflow.test.ts b/tests/context-overflow.test.ts index c2720a0a0d..2804881e00 100644 --- a/tests/context-overflow.test.ts +++ b/tests/context-overflow.test.ts @@ -308,6 +308,45 @@ test("empty body is NOT an overflow", () => { assert.equal(inspectContextOverflow(400, "").isOverflow, false); }); +test("#6122: bili's own oversize-gate refusal (bili_gate_oversize_refusal*) is an overflow, window undefined", () => { + // Field case: the native-intercept gate refused an unattributed oversized + // body; the relay saw that refusal come back through the client as a 400 + // and — with no parseable marker — logged the #4452 CANNOT-engage warning + // while the oversized history was re-sent every turn. bili's own refusal + // code IS the definitive over-window proof: it must read as an overflow so + // self-heal (same-request refold / emergency shrink) arms. + const body = JSON.stringify({ + error: { + type: "server_error", + code: "bili_gate_oversize_refusal_unattributed", + message: + "billion-context refused this request locally: it is not attributed to any bili-managed session, and its core text is priced over the model's context window (conservative text pricing — every declared byte counts as text, and the bar is never assumed below the larger of the client-declared window and 1,000,000 tokens) — sending it directly to the provider can only be rejected (every retry re-sends the same oversized history, #4068). ", + retryable: false, + }, + }); + const info = inspectContextOverflow(400, body); + assert.equal(info.isOverflow, true, "the gate's own refusal must read as an overflow"); + assert.equal( + info.window, + undefined, + "the 1,000,000 in the prose is a pricing FLOOR, not the model's window — the no-window arm (min of judging window and payload estimate) must fire", + ); + // Every oversize variant shares the code prefix. + for (const code of [ + "bili_gate_oversize_refusal", + "bili_gate_oversize_refusal_fallback", + "bili_gate_oversize_refusal_no_live_state", + "bili_gate_oversize_refusal_unattributed_bytes", + ]) { + const v = inspectContextOverflow(400, JSON.stringify({ error: { type: "server_error", code } })); + assert.equal(v.isOverflow, true, `${code} must be recognized`); + } + // The compaction refusal is a different class (no proxy available, body + // fits fine) — it must stay dark. + const compaction = inspectContextOverflow(400, JSON.stringify({ error: { type: "server_error", code: "bili_gate_dsh_compaction_refused" } })); + assert.equal(compaction.isOverflow, false, "compaction refusal is not an over-window proof"); +}); + // reserveOutputHeadroom: the effective window handed to the kernel after // reserving the model's per-request output budget. The kernel's nudge/truncate // bands are a fraction of this window, so reserving maxOutput keeps the context diff --git a/tests/issue4452-markerless-reject.test.ts b/tests/issue4452-markerless-reject.test.ts index 817cbda1bb..3d7d0cfcd2 100644 --- a/tests/issue4452-markerless-reject.test.ts +++ b/tests/issue4452-markerless-reject.test.ts @@ -25,6 +25,19 @@ const OPENAI_OVERFLOW_BODY = JSON.stringify({ const CJK_OVERFLOW_BODY = JSON.stringify({ error: { message: "上下文长度超出限制", type: "invalid_request_error" } }); +// #6122 field case: bili's OWN oversize-gate refusal (native-intercept) came +// back through the client as a 400 and was logged as "no parseable overflow +// marker … CANNOT engage" — while it IS the definitive over-window proof. +const GATE_REJECTION_BODY = JSON.stringify({ + error: { + type: "server_error", + code: "bili_gate_oversize_refusal_unattributed", + message: + "billion-context refused this request locally: it is not attributed to any bili-managed session, and its core text is priced over the model's context window (conservative text pricing — every declared byte counts as text, and the bar is never assumed below the larger of the client-declared window and 1,000,000 tokens) — sending it directly to the provider can only be rejected (every retry re-sends the same oversized history, #4068). ", + retryable: false, + }, +}); + test("generic gateway body on 400 is overflow-shaped but carries no parseable marker", () => { // The first-order failure: the marker gate itself says "not overflow". assert.equal(inspectContextOverflow(400, GENERIC_BODY).isOverflow, false); @@ -52,6 +65,18 @@ test("5xx is excluded — those already self-heal via the local estimate (#604)" assert.equal(isMarkerlessOverflowReject(503, GENERIC_BODY), false); }); +test("#6122: bili's own oversize-gate refusal is NOT markerless — self-heal engages from it", () => { + // The gate body IS the marker: it is bili's own definitive over-window + // proof. Reading it as an opaque gateway rewrite (the #4452 warn) is what + // left the #6122 child session 400-looping — the CANNOT-engage warning + // fires on its own refusal. + assert.equal(inspectContextOverflow(400, GATE_REJECTION_BODY).isOverflow, true); + assert.equal(isMarkerlessOverflowReject(400, GATE_REJECTION_BODY), false); + // …and the prose's "1,000,000 tokens" is a pricing floor, not a learnable + // model window — the no-window arm must be what fires, not a 1M learning. + assert.equal(inspectContextOverflow(400, GATE_REJECTION_BODY).window, undefined); +}); + test("non-overflow 4xx and success codes are excluded (no false alarm on auth/malformed)", () => { assert.equal(isMarkerlessOverflowReject(200, GENERIC_BODY), false); assert.equal(isMarkerlessOverflowReject(401, GENERIC_BODY), false); From 518b175fde386545f4d0c156cd6d124d298339dc Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Fri, 13 Nov 2026 22:28:27 +0800 Subject: [PATCH 02/13] test(fork): name the straddled blocks on the resume-inheritance log line (#6122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A fork that inherited 1 of 5 active blocks logged only the adopted count — the 4 straddling blocks were invisible, forcing manual ledger archaeology in field triage. The inherited line now appends the straddled count when non-zero (the lineage-reconcile line already does, #2807); byte-identical when nothing straddles. --- src/fork-adoption.ts | 2 +- tests/issue6122-fork-straddled-log.test.ts | 110 +++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/issue6122-fork-straddled-log.test.ts diff --git a/src/fork-adoption.ts b/src/fork-adoption.ts index 7d2e8be995..46268e2ba5 100644 --- a/src/fork-adoption.ts +++ b/src/fork-adoption.ts @@ -533,7 +533,7 @@ export function maybeAdoptResume(args: { session.state.timestampsHighWaterRefSeq = parent.state.timestampsHighWaterRefSeq; log( "info", - `[resume-inheritance] ${session.id} ${rel}: inherited ${seededRefs} ref(s) up to ${plan.maxRef || "n/a"}${plan.adoptedActive > 0 ? `, ${plan.adoptedActive} block(s) (~${plan.adoptedTokens} tokens)` : ""}; stale citations now resolve to their original messages (#1486)`, + `[resume-inheritance] ${session.id} ${rel}: inherited ${seededRefs} ref(s) up to ${plan.maxRef || "n/a"}${plan.adoptedActive > 0 ? `, ${plan.adoptedActive} block(s) (~${plan.adoptedTokens} tokens)` : ""}${plan.straddled > 0 ? `, ${plan.straddled} active block(s) straddled the fork point (adopted once fully present, #6122)` : ""}; stale citations now resolve to their original messages (#1486)`, ); const wanted = new Set([...Object.keys(plan.refs.byRef), ...citedPlaceholderRefs(incomingMsgs)]); const storeSlice = cloneStoreForRefs(contentStoreOf(parent), wanted); diff --git a/tests/issue6122-fork-straddled-log.test.ts b/tests/issue6122-fork-straddled-log.test.ts new file mode 100644 index 0000000000..bcfe682273 --- /dev/null +++ b/tests/issue6122-fork-straddled-log.test.ts @@ -0,0 +1,110 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { maybeAdoptResume, incomingCoreMessages } from "../src/fork-adoption.ts"; +import { SessionStore, _setStoreForTest } from "../src/persist.ts"; +import { type Session } from "../src/session.ts"; + +process.env.NODE_ENV = "test"; + +// #6122: a DSH fork that inherited 1 of 5 active blocks logged only the +// adopted count — the 4 straddling blocks were invisible in the log, so the +// field triage had to rebuild the ledger by hand to see what would (and when) +// still be adopted. The inherited line must name the straddled count, the +// way the lineage-reconcile line already does (#2807). + +function fixtures(straddle: boolean) { + const parsed = { + model: "m", + max_tokens: 1, + messages: [ + { role: "user", content: "hello world 6122" }, + { role: "assistant", content: "hi there 6122" }, + ], + }; + const msgs = incomingCoreMessages("anthropic", parsed)!; + const byRaw: Record = {}; + const byRef: Record = {}; + const tsStamps: Record = {}; + msgs.forEach((m, i) => { + const ref = `m${String(i + 1).padStart(5, "0")}`; + byRaw[m.id] = ref; + byRef[ref] = m.id; + tsStamps[m.id] = 1730000000 + i; + }); + // b1 is fully present in the incoming core; b2 names a raw id the child + // never sent (a message the child's replay omitted) — it straddles. + const blocks = [ + { blockId: "b1", active: true, effectiveMessageIds: [msgs[0].id], directBlockIds: [], compressedTokens: 42 }, + ]; + if (straddle) { + blocks.push({ + blockId: "b2", + active: true, + effectiveMessageIds: [msgs[1].id, "raw-id-the-child-never-sent"], + directBlockIds: [], + compressedTokens: 13, + }); + } + const meta = { protocol: "anthropic", upstreamOrigin: "test" }; + const parent = { + id: "parent-6122", + meta, + blockContents: new Map(), + state: { blocks, tokenSnapshot: {}, nextBlockId: blocks.length + 1, nextRunId: 1, messageRefs: { byRaw, byRef }, tsStamps }, + } as unknown as Session; + const child = { + id: "child-6122", + meta, + state: { + blocks: [] as unknown[], + tokenSnapshot: {} as Record, + nextBlockId: 1, + nextRunId: 1, + messageRefs: { byRaw: {} as Record, byRef: {} as Record }, + }, + blockContents: new Map(), + } as unknown as Session; + return { parsed, parent, child }; +} + +test("#6122: the inherited line names the straddled active blocks", () => { + _setStoreForTest(new SessionStore({ enabled: false })); + const { parsed, parent, child } = fixtures(true); + const lines: string[] = []; + const outcome = maybeAdoptResume({ + session: child, + parent, + sharedDepth: 0, + protocol: "anthropic", + parsed, + upstreamOrigin: "test", + blocksEnabled: true, + log: (_level, msg) => { lines.push(msg); }, + }); + const adoptLine = lines.find((l) => l.includes("inherited")); + assert.ok(adoptLine, "the inherited line was logged"); + assert.equal(outcome.adoptedActive, 1, "only the fully-present block is adopted"); + assert.ok( + adoptLine.includes("1 active block(s) straddled the fork point"), + `the straddled count must appear on the inherited line, got: ${adoptLine}`, + ); +}); + +test("#6122: nothing straddling → the line keeps its pre-#6122 wording", () => { + _setStoreForTest(new SessionStore({ enabled: false })); + const { parsed, parent, child } = fixtures(false); + const lines: string[] = []; + maybeAdoptResume({ + session: child, + parent, + sharedDepth: 0, + protocol: "anthropic", + parsed, + upstreamOrigin: "test", + blocksEnabled: true, + log: (_level, msg) => { lines.push(msg); }, + }); + const adoptLine = lines.find((l) => l.includes("inherited")); + assert.ok(adoptLine, "the inherited line was logged"); + assert.ok(!adoptLine.includes("straddled"), `no straddle, no clause — got: ${adoptLine}`); +}); From cfa8ee4e0f7efec033d7c43c2763ce652a6deef5 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 14 Nov 2026 02:07:49 +0800 Subject: [PATCH 03/13] fix(test): let the notice-registry suite see the fresh-install storage default (#6480) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The suite-wide baseline (tests/preload-storage-baseline.mjs) pins BILI_STORAGE_UNIFIED ??= "legacy" for the legacy-written corpus, but this suite asserts the fresh-install default posture — the exact #6480 pure-sqlite flip the storage-sqlite-default notice advertises. Under the CI preload chain the pin hid the notice and two subtests failed deterministically (red in every shard leg containing the file). Drop the inherited pin so the production default applies, per the preload's own pin-yourself contract. --- tests/notice-registry.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/notice-registry.test.ts b/tests/notice-registry.test.ts index 6d3b60edb4..c2f408b544 100644 --- a/tests/notice-registry.test.ts +++ b/tests/notice-registry.test.ts @@ -17,6 +17,13 @@ const cfgPath = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "notice-reg-cfg- process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "notice-reg-dsh-")); process.env.XDG_STATE_HOME = stateDir; process.env.BILI_CONFIG_FILE = cfgPath; +// The suite-wide storage baseline (tests/preload-storage-baseline.mjs) pins +// BILI_STORAGE_UNIFIED ??= "legacy" for the legacy-written corpus; this suite +// asserts the FRESH-INSTALL default posture — exactly the #6480 pure-sqlite +// flip the notice advertises — so drop the inherited pin and let the +// production default apply. (Preload contract: suites whose assertions depend +// on a specific storage mode MUST pin BILI_STORAGE_UNIFIED themselves.) +delete process.env.BILI_STORAGE_UNIFIED; const { NOTICES, visibleNotices, SQLITE_DEFAULT_NOTICE_ID } = await import("../src/notices.ts"); const { IOT_INCOMPAT_NOTICE_ID, PCK_NOTICE_ID, WM_FASTPATH_INTRO_ID, dismissUpgradeNotice } = await import("../src/pck-notice.ts"); From c6369fb6a195fbd1e8794c911adaff87d4dba0f0 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 04:35:44 +0800 Subject: [PATCH 04/13] fix(tests): pin pure-sqlite selection in notice-registry suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The suite baseline preload (preload-storage-baseline.mjs) pins BILI_STORAGE_UNIFIED="legacy" for the broad corpus. After #6480 flipped the storage default to pure-sqlite, the notice-registry suite's visibleNotices assertions expect the pure-sqlite default notice, which is gated on unifiedSelectionIsSqlite (unified "sqlite" or absent) — the preload's "legacy" made the notice silent, so the suite was born-red on master. Pin the selection explicitly (#4011 lesson: a test that depends on the production default passes locally but fails in CI). --- tests/notice-registry.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/notice-registry.test.ts b/tests/notice-registry.test.ts index 6d3b60edb4..b3b0d0e8a4 100644 --- a/tests/notice-registry.test.ts +++ b/tests/notice-registry.test.ts @@ -17,6 +17,11 @@ const cfgPath = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "notice-reg-cfg- process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "notice-reg-dsh-")); process.env.XDG_STATE_HOME = stateDir; process.env.BILI_CONFIG_FILE = cfgPath; +// #4011 lesson: this suite asserts the pure-sqlite default notice is visible, +// which requires the pure-sqlite SELECTION (unified "sqlite" or absent — the +// gate is unifiedSelectionIsSqlite, not the resolved mode). The suite baseline +// preload pins "legacy" for the broad corpus, so pin the selection explicitly. +process.env.BILI_STORAGE_UNIFIED = "sqlite"; const { NOTICES, visibleNotices, SQLITE_DEFAULT_NOTICE_ID } = await import("../src/notices.ts"); const { IOT_INCOMPAT_NOTICE_ID, PCK_NOTICE_ID, WM_FASTPATH_INTRO_ID, dismissUpgradeNotice } = await import("../src/pck-notice.ts"); From b1bc17b40454480c7204c2d2e7b44afb5216e367 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 10:20:31 +0800 Subject: [PATCH 05/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in CCR cold-disk-restore test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dsh plugin lane (ci-e2e-dsh.yml) runs node --import tsx --test WITHOUT the preload-storage-baseline.mjs preload, so BILI_STORAGE_UNIFIED is unset and the storage mode defaults to 'full'. Under the pure-sqlite default flip (5a80e2b8e, #6480), 'full' mode turns the JSON envelope writer OFF — so the .content-store.json sidecar is never written, and the test's readdirSync(namespace) hits ENOENT. Pin BILI_STORAGE_JSON_WRITER=on in the test so the content-store sidecar is written regardless of the storage mode. This keeps the corrupted-store detection path exercised in both full and legacy modes. Closes: dsh plugin lane red on master (run 43532980164, job 132255459726) --- tests/plugin-fork.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/plugin-fork.test.ts b/tests/plugin-fork.test.ts index 2763aa2f4e..4bd98e328f 100644 --- a/tests/plugin-fork.test.ts +++ b/tests/plugin-fork.test.ts @@ -909,6 +909,12 @@ test("HTTP CCR shared payload deletion fails closed before persistence", { timeo for (const corruption of ["missing-ref", "missing-payload", "orphan-payload", "wrong-raw-alias", "changed-payload"] as const) { test(`HTTP CCR ${corruption} fails closed after cold disk restore`, async () => { + // The corrupted-store detection path needs the JSON content-store + // sidecar on disk. Under the pure-sqlite default (5a80e2b8e) the + // JSON writer is OFF, so pin it ON to keep exercising the envelope + // corruption path this test was written for. + const oldJsonWriter = process.env.BILI_STORAGE_JSON_WRITER; + process.env.BILI_STORAGE_JSON_WRITER = "on"; const h = await harness(true); try { const parent = resolveConversation("parent").session!; @@ -966,7 +972,11 @@ for (const corruption of ["missing-ref", "missing-payload", "orphan-payload", "w assert.equal(parentState(), before); assert.equal(readFileSync(path, "utf8"), JSON.stringify(disk)); store2.closeQuietly(); - } finally { await h.close(); } + } finally { + if (oldJsonWriter === undefined) delete process.env.BILI_STORAGE_JSON_WRITER; + else process.env.BILI_STORAGE_JSON_WRITER = oldJsonWriter; + await h.close(); + } }); } From 7492c35c2ad980560c3289c4cdb73e9f32af9dfe Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 12:11:32 +0800 Subject: [PATCH 06/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in native opencode e2e lane The pure-sqlite default flip (5a80e2b8e, #6480) turns the JSON envelope writer OFF, so the .json session file this lane asserts on is never written and 'proxy must persist the session' / 'no persisted session carried compressed blocks' fail after the 20s wait. Pin the writer ON in the spawned client's env (the bootstrapped proxy inherits it) so the envelope this test was written for is still produced. Closes: native opencode lane red on master (run 43547593803, job 132302438610) --- tests/e2e/e2e-native-opencode.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/e2e-native-opencode.test.ts b/tests/e2e/e2e-native-opencode.test.ts index 8b5578020d..78975d418d 100644 --- a/tests/e2e/e2e-native-opencode.test.ts +++ b/tests/e2e/e2e-native-opencode.test.ts @@ -421,6 +421,11 @@ async function ocRun( cwd: ctx.ocCwd, env: { ...cleanEnv(), + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope + // writer OFF, but this lane asserts on the on-disk .json session + // file. Pin the writer ON so the envelope this test was written for + // is still produced regardless of the storage-mode default. + BILI_STORAGE_JSON_WRITER: "on", HOME: ctx.homeDir, TMPDIR: ctx.tmdir, XDG_CONFIG_HOME: ctx.xdg.config, From 45f93dbb8fc88523e3015a413ea7620281d11d1e Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 12:11:32 +0800 Subject: [PATCH 07/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in native dsh e2e lane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same pure-sqlite default flip (5a80e2b8e, #6480) as the opencode lane: the JSON envelope writer is OFF, so 'proxy must persist the session within 20000ms' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned dsh client's env (the bootstrapped proxy inherits it). Closes: native dsh lane red on master (run 43547497015, job 132302138843) --- tests/e2e/e2e-native-dsh.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/e2e-native-dsh.test.ts b/tests/e2e/e2e-native-dsh.test.ts index 7b7402356c..ea8c3969e4 100644 --- a/tests/e2e/e2e-native-dsh.test.ts +++ b/tests/e2e/e2e-native-dsh.test.ts @@ -463,6 +463,11 @@ function dshRun( cwd: ctx.dshCwd, env: { ...cleanEnv(), + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope + // writer OFF, but this lane asserts on the on-disk .json session + // file. Pin the writer ON so the envelope this test was written for + // is still produced regardless of the storage-mode default. + BILI_STORAGE_JSON_WRITER: "on", HOME: ctx.homeDir, TMPDIR: ctx.tmpDir, DSH_HOME: ctx.dshHome, From d67cc43557b98d9aa9ce61c24f4dcff93d882558 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 12:11:32 +0800 Subject: [PATCH 08/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in pi codex-responses WS e2e lane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same pure-sqlite default flip (5a80e2b8e, #6480) as the opencode/dsh lanes: the JSON envelope writer is OFF, so 'session persisted' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned pi client's env (the bootstrapped proxy inherits it). Closes: pi codex-responses WS lane red on master (run 43547626291, job 132302540960) --- tests/e2e/e2e-pi-codex-ws.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/e2e/e2e-pi-codex-ws.test.ts b/tests/e2e/e2e-pi-codex-ws.test.ts index 15788e0224..c5b3625224 100644 --- a/tests/e2e/e2e-pi-codex-ws.test.ts +++ b/tests/e2e/e2e-pi-codex-ws.test.ts @@ -342,6 +342,12 @@ function piRun( cwd: ctx.piCwd, env: { ...cleanEnv(opts.extraEnv), + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON + // envelope writer OFF, but this lane asserts on the on-disk + // .json session file. Pin the writer ON so the envelope this + // test was written for is still produced regardless of the + // storage-mode default. + BILI_STORAGE_JSON_WRITER: "on", PI_CODING_AGENT_DIR: ctx.piAgentDir, XDG_CONFIG_HOME: ctx.xdg.config, XDG_CACHE_HOME: ctx.xdg.cache, From c392237d4702601246f5bcb70235b46f8becdc8d Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 13:18:32 +0800 Subject: [PATCH 09/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in pi package-native e2e lane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4th lane of the pure-sqlite default flip (5a80e2b8e, #6480) family: the JSON envelope writer is OFF, so 'proxy must persist the session' and 'at least one persisted session must carry compressed blocks' fail — the on-disk .json session file is never written. Pin the writer ON in the spawned pi client's env (the bootstrapped proxy inherits it). Closes: pi package-native lane red on ci-fixes (run 43558179054, job 132336647955) --- tests/e2e/e2e-native-pi.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e-native-pi.test.ts b/tests/e2e/e2e-native-pi.test.ts index 151b1606e1..cbedc8dd9b 100644 --- a/tests/e2e/e2e-native-pi.test.ts +++ b/tests/e2e/e2e-native-pi.test.ts @@ -468,8 +468,13 @@ function piRun( // (CI sentinel incident, #4599). Pin the legacy posture so this // coverage stays deterministic; inline posture is covered by // tests/pi-inline-ws.test.ts and tests/pi-native.test.ts. - BILI_PI_INLINE: "0", - PI_CODING_AGENT_DIR: ctx.piAgentDir, + BILI_PI_INLINE: "0", + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope + // writer OFF, but this lane asserts on the on-disk .json session + // file. Pin the writer ON so the envelope this test was written for + // is still produced regardless of the storage-mode default. + BILI_STORAGE_JSON_WRITER: "on", + PI_CODING_AGENT_DIR: ctx.piAgentDir, XDG_CONFIG_HOME: ctx.xdg.config, XDG_CACHE_HOME: ctx.xdg.cache, XDG_STATE_HOME: ctx.xdg.state, From 974cd4c2f67c9ee5a1f8879709224cc00b2f91df Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 13:18:32 +0800 Subject: [PATCH 10/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in fork-ccr-adoption suite Same pure-sqlite default flip (5a80e2b8e, #6480) family: the JSON writer is OFF, so the per-session CCR content-store sidecar (.content-store.json) that 'child persists its own companion and survives a proxy restart' asserts on is never written (0 !== 1). The earlier b1bc17b40 pin only covered tests/plugin-fork.test.ts, not this file. Pin the writer ON at module load (before any SessionStore is constructed). Closes: dsh plugin lane red on ci-fixes (run 43558179102, job 132336519539) --- tests/fork-ccr-adoption.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/fork-ccr-adoption.test.ts b/tests/fork-ccr-adoption.test.ts index 4cd9a7b586..ea8004f747 100644 --- a/tests/fork-ccr-adoption.test.ts +++ b/tests/fork-ccr-adoption.test.ts @@ -38,6 +38,12 @@ import { maybeAdoptForkBlocks } from "../src/fork-adoption.ts"; import { rmrf } from "./tmp-rm.ts"; process.env.BILI_PERSIST = "0"; +// Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope writer OFF, +// so the per-session CCR content-store sidecar (.content-store.json) this +// suite asserts on is never written. Pin the writer ON at module load (before +// any SessionStore is constructed) so the companion-envelope coverage this +// test was written for still runs regardless of the storage-mode default. +process.env.BILI_STORAGE_JSON_WRITER = "on"; const LIMIT = 200_000; const META = { protocol: "openai" as const, upstreamOrigin: "http://upstream.example/v1" }; From 271abba541666260a2142767c78cb2e53ea00595 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 13:31:56 +0800 Subject: [PATCH 11/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in subagent-sessions e2e lane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure-sqlite default flip (5a80e2b8e, #6480) family: the JSON envelope writer is OFF, so 'proxy must persist the session' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned opencode client's env (the bootstrapped proxy inherits it). --- tests/e2e/e2e-subagent-sessions.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/e2e-subagent-sessions.test.ts b/tests/e2e/e2e-subagent-sessions.test.ts index af08050217..b1a6188bca 100644 --- a/tests/e2e/e2e-subagent-sessions.test.ts +++ b/tests/e2e/e2e-subagent-sessions.test.ts @@ -394,6 +394,11 @@ async function ocRun( cwd: ctx.ocCwd, env: { ...cleanEnv(), + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope + // writer OFF, but this lane asserts on the on-disk .json session + // file. Pin the writer ON so the envelope this test was written for + // is still produced regardless of the storage-mode default. + BILI_STORAGE_JSON_WRITER: "on", HOME: ctx.homeDir, TMPDIR: ctx.tmdir, XDG_CONFIG_HOME: ctx.xdg.config, From 5d47196a267e20b63ed7965b6fea58374cc599f7 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 13:31:56 +0800 Subject: [PATCH 12/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in dsh-persona e2e lane Pure-sqlite default flip (5a80e2b8e, #6480) family: the JSON envelope writer is OFF, so the on-disk .json session envelope this lane asserts on (exactly ONE persisted session under the raw key) is never written. Pin the writer ON in the spawned dsh client's env. --- tests/e2e/e2e-native-dsh-persona.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/e2e-native-dsh-persona.test.ts b/tests/e2e/e2e-native-dsh-persona.test.ts index 82f3abc94b..8d3ea3d34c 100644 --- a/tests/e2e/e2e-native-dsh-persona.test.ts +++ b/tests/e2e/e2e-native-dsh-persona.test.ts @@ -400,6 +400,11 @@ function buildRig(tag: string, withAutoReview: boolean): Rig { const env: NodeJS.ProcessEnv = { ...cleanEnv(), + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope + // writer OFF, but this lane asserts on the on-disk .json session + // envelope. Pin the writer ON so the envelope this test was written + // for is still produced regardless of the storage-mode default. + BILI_STORAGE_JSON_WRITER: "on", HOME: home, TMPDIR: tmp, DSH_HOME: dshHome, From 1ca40871581c5009fdb69eea944f448d002098e7 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 13:31:56 +0800 Subject: [PATCH 13/13] fix(tests): pin BILI_STORAGE_JSON_WRITER=on in update-state e2e lane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure-sqlite default flip (5a80e2b8e, #6480) family: the JSON envelope writer is OFF, so the on-disk .json session file this lane asserts on (state survival across the OLD→NEW update) is never written. Pin the writer ON in the spawned proxy's env (both update phases share envBase). --- tests/e2e/e2e-update-state.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/e2e-update-state.test.ts b/tests/e2e/e2e-update-state.test.ts index 03f2b1db22..e31baf7659 100644 --- a/tests/e2e/e2e-update-state.test.ts +++ b/tests/e2e/e2e-update-state.test.ts @@ -299,6 +299,11 @@ test("self-update keeps live compression state: folds survive the OLD→NEW hop envBase.BILI_UPDATE_POLICY_URL = "http://127.0.0.1:1/no-policy.json"; envBase.BILI_PERSIST_DEBOUNCE_MS = "200"; envBase.BILI_SESSIONS_DIR = sessionsDir; + // Pure-sqlite default (5a80e2b8e, #6480) turns the JSON envelope + // writer OFF, but this lane asserts on the on-disk .json session file + // (state survival across the update). Pin the writer ON so the + // envelope this test was written for is still produced. + envBase.BILI_STORAGE_JSON_WRITER = "on"; const port = await freePort(); proxy = spawnProxy(installDir, port, envBase);