From d5556ba435a2533fac028db045c6f328dea13daa Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 14 Nov 2026 00:18:07 +0800 Subject: [PATCH 1/4] fix(e2e): pin dual-write storage in the native-pi sandbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #6480 flipped the storage default to pure-SQLite (JSON envelope writer off unless dual-write is explicitly requested). This suite's persistence assertions all walk the sandbox's session JSON files (sessionFiles()), so the pure-sqlite default left them structurally failing on master — the 'real pi package-native lane' CI leg has been red since the flip. Pin dual-write in the sandbox config, the same pattern the suite already uses for BILI_PI_INLINE=0: the assertions verify what they have always verified (envelope presence, folded blocks, pluginAgent binding); the pure-sqlite default is covered by the storage-json-writer-off* unit suites. ensureConfigTemplate() never overwrites an existing file, so the pre-seed survives plugin bootstrap. --- tests/e2e/e2e-native-pi.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/e2e/e2e-native-pi.test.ts b/tests/e2e/e2e-native-pi.test.ts index 7f0ee66eb3..e9c957658f 100644 --- a/tests/e2e/e2e-native-pi.test.ts +++ b/tests/e2e/e2e-native-pi.test.ts @@ -246,6 +246,23 @@ async function startCtx(): Promise { ]) fs.mkdirSync(d, { recursive: true }); + // #6480 flipped the storage default to pure-SQLite (the JSON envelope + // writer is off unless dual-write is explicitly requested), so a default- + // posture sandbox no longer contains session JSON files at all — and every + // persistence assertion in this suite walks those files (sessionFiles() + // below), failing structurally. Pin dual-write the way BILI_PI_INLINE=0 + // pins the spawn posture above: these assertions verify what they have + // always verified (envelope presence, folded blocks, the pluginAgent + // binding); the pure-sqlite default itself is covered by the unit suites + // (storage-json-writer-off*). ensureConfigTemplate() never overwrites an + // existing file, so this pre-seed survives plugin bootstrap. + const cfgDir = path.join(ctx.xdg.config, "billion-context"); + fs.mkdirSync(cfgDir, { recursive: true }); + fs.writeFileSync( + path.join(cfgDir, "billion-context.json"), + JSON.stringify({ storage: { unified: "full", jsonWriter: "on" } }, null, 2), + ); + await assertPortDead(ctx.fakePort); // #1689: prove still free right before the child binds it const fake = spawn(process.execPath, [FAKE_UPSTREAM], { env: { From f9e10ec4eb974049ccf532d0132ae029a5a09be7 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 14 Nov 2026 01:03:07 +0800 Subject: [PATCH 2/4] fix(e2e): pin dual-write storage in the dsh-native lane rigs too (#6480) The real-dsh headless profile lane went red on master the same way the pi package-native lane did: #6480 made pure-SQLite the default (jsonWriter off), so the JSON session envelopes this lane's waitForPersistedSession()/persistedSessions() traversal asserts on are no longer written. The lane's own rigs pre-write their sandbox billion-context.json without a storage key, so they silently inherited the new default. Same test-only pin as the pi lane (e2e-native-pi): an explicit storage.{unified: full, jsonWriter: on} for a lane whose assertions deliberately read the JSON envelope layout. Verified locally with the real dsh 0.2.0-rc.2: both files 2/2 after the pin, red before. --- tests/e2e/e2e-native-dsh-persona.test.ts | 10 +++++++++- tests/e2e/e2e-native-dsh.test.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e-native-dsh-persona.test.ts b/tests/e2e/e2e-native-dsh-persona.test.ts index 82f3abc94b..a976204519 100644 --- a/tests/e2e/e2e-native-dsh-persona.test.ts +++ b/tests/e2e/e2e-native-dsh-persona.test.ts @@ -396,7 +396,15 @@ function buildRig(tag: string, withAutoReview: boolean): Rig { // compress could never fold ("Range is entirely within the protected // zone"). Zeroing them is established product behavior, not a hack. fs.writeFileSync(path.join(xdg.config, "billion-context", "billion-context.json"), - JSON.stringify({ providers: {}, compress: { preserveRecentTokens: 0, preserveRecentMessages: 0 } }, null, 2) + "\n"); + JSON.stringify({ + providers: {}, + compress: { preserveRecentTokens: 0, preserveRecentMessages: 0 }, + // #6480 made pure-SQLite the default (jsonWriter off), so the JSON + // envelopes this lane's persistedSessions() traversal asserts on are + // no longer written. Pin dual-write the way BILI_PI_INLINE=0 pins the + // posture: a test-only, explicit choice for this lane's assertions. + storage: { unified: "full", jsonWriter: "on" }, + }, null, 2) + "\n"); const env: NodeJS.ProcessEnv = { ...cleanEnv(), diff --git a/tests/e2e/e2e-native-dsh.test.ts b/tests/e2e/e2e-native-dsh.test.ts index 7b7402356c..159b0489eb 100644 --- a/tests/e2e/e2e-native-dsh.test.ts +++ b/tests/e2e/e2e-native-dsh.test.ts @@ -363,7 +363,15 @@ function writeBiliConfig(ctx: Ctx): void { // cannot fold under the kernel's default protected-zone token window. fs.writeFileSync( path.join(dir, "billion-context.json"), - JSON.stringify({ providers: {}, compress: { preserveRecentTokens: 0 } }, null, 2) + "\n", + JSON.stringify({ + providers: {}, + compress: { preserveRecentTokens: 0 }, + // #6480 made pure-SQLite the default (jsonWriter off), so the JSON + // envelopes this lane's sessionFiles() traversal asserts on are no + // longer written. Pin dual-write the way BILI_PI_INLINE=0 pins the + // posture: a test-only, explicit choice for this lane's assertions. + storage: { unified: "full", jsonWriter: "on" }, + }, null, 2) + "\n", ); } From e891908e8093c9de102e029ebb00b22c5ab2ef33 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 14 Nov 2026 02:07:49 +0800 Subject: [PATCH 3/4] 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 65391418e35138cf4c236760669623a0f8b9833c Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 14 Nov 2026 02:07:49 +0800 Subject: [PATCH 4/4] fix(e2e): pin dual-write storage in the opencode + pi-codex-ws lane rigs too (#6480) Same regression as the native-pi/dsh lanes: #6480's pure-sqlite default made the jsonWriter off by default, so the lanes' persisted-session file walks (sessionFiles()/persistedSessions()) saw zero JSON envelopes and their persistence assertions failed. Pre-seed the sandbox config with storage:{unified:"full",jsonWriter:"on"} like the other lanes. Verified locally (pi 0.83.6): without the pin the opencode lane fails 2 of 4 and the codex-ws lane fails 1 of 6; with it, both are fully green. --- tests/e2e/e2e-native-opencode.test.ts | 13 ++++++++++++- tests/e2e/e2e-pi-codex-ws.test.ts | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e-native-opencode.test.ts b/tests/e2e/e2e-native-opencode.test.ts index 8b5578020d..2554cc02ba 100644 --- a/tests/e2e/e2e-native-opencode.test.ts +++ b/tests/e2e/e2e-native-opencode.test.ts @@ -287,7 +287,18 @@ async function startCtx(): Promise { // the two push-back runs clear deterministically. fs.writeFileSync( path.join(ctx.xdg.config, "billion-context", "billion-context.json"), - JSON.stringify({ compress: { preserveRecentTokens: 0 } }, null, 2), + JSON.stringify( + { + compress: { preserveRecentTokens: 0 }, + // #6480 made pure-SQLite the default (jsonWriter off), so the JSON + // session envelopes this lane's sessionFiles() traversal asserts on + // are no longer written. Same test-only dual-write pin as the + // pi/dsh native lanes: an explicit choice for this lane's assertions. + storage: { unified: "full", jsonWriter: "on" }, + }, + null, + 2, + ), ); await assertPortDead(ctx.fakePort); // #1689: prove still free right before the child binds it diff --git a/tests/e2e/e2e-pi-codex-ws.test.ts b/tests/e2e/e2e-pi-codex-ws.test.ts index a8df48ae7c..961a1c0280 100644 --- a/tests/e2e/e2e-pi-codex-ws.test.ts +++ b/tests/e2e/e2e-pi-codex-ws.test.ts @@ -322,7 +322,10 @@ async function startCtx(transport: string, mockPort: number): Promise { ); // Loosen the kernel's recent-content protection so the scripted fold can // target the planted bulk (same seam the opencode WS suite uses). - fs.writeFileSync(path.join(biliCfgDir, "billion-context.json"), JSON.stringify({ compress: { preserveRecentTokens: 0 } })); + // #6480 made pure-SQLite the default (jsonWriter off), so the JSON session + // envelopes this lane's sessionFiles() traversal asserts on are no longer + // written — same test-only dual-write pin as the pi/dsh native lanes. + fs.writeFileSync(path.join(biliCfgDir, "billion-context.json"), JSON.stringify({ compress: { preserveRecentTokens: 0 }, storage: { unified: "full", jsonWriter: "on" } })); return ctx; }