From 589314ca0513a2c59084727895372d15b8592207 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sun, 25 Oct 2026 01:45:50 +0800 Subject: [PATCH 01/12] fix(storage): block interval bounds survive post-fold resaves (#4608) A post-fold client resend carries the folded view, not the covered raws, so the next ingest batch re-derives -1/-1 'unknown' for the same block and the upsert clobbered previously-resolved interval evidence. Bounds are now durable: the upsert keeps the stored start_seq/end_seq whenever the incoming side is unknown (sqlite CASE + mysql IF twin). Ghost coverage never fabricates a resolved interval. Found end-to-end by the docker dogfood harness (plugin + proxy lanes, real built server). --- CHANGELOG.md | 3 + src/storage/mysql.ts | 6 +- src/storage/store.ts | 13 ++- tests/storage-block-bounds-preserve.test.ts | 113 ++++++++++++++++++++ 4 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 tests/storage-block-bounds-preserve.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index ff50df9720..e85958ef36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag ## [Unreleased] +### Fixed +- 块区间边界在重存时不再回退:折叠后客户端重发的视图不含已覆盖原文,重入库时该批次无法重新解析区间(-1/-1),旧逻辑会把已解析的真实区间抹掉。现在区间证据一旦解析即持久(入库 `CASE` 保留;sqlite/mysql 双后端),未知块保持诚实缺口(#4592)。 + ### Added ### D5-5 — 渲染源窗口化 + 判官 tailStart 视图域修复 diff --git a/src/storage/mysql.ts b/src/storage/mysql.ts index 46d68a3895..48e799d078 100644 --- a/src/storage/mysql.ts +++ b/src/storage/mysql.ts @@ -574,7 +574,11 @@ export class MysqlBackend implements StorageBackend { summary_hash, one_hash, supersedes_block_id, active, created_at, covered_hash, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE - ord = VALUES(ord), start_seq = VALUES(start_seq), end_seq = VALUES(end_seq), + ord = VALUES(ord), + // #4592: keep durable interval evidence when a later batch can no + // longer re-derive it (post-fold client resends carry no covered raws) + start_seq = IF(VALUES(start_seq) >= 0, VALUES(start_seq), start_seq), + end_seq = IF(VALUES(end_seq) >= 0, VALUES(end_seq), end_seq), start_ref = VALUES(start_ref), end_ref = VALUES(end_ref), tier = VALUES(tier), summary_hash = VALUES(summary_hash), one_hash = VALUES(one_hash), supersedes_block_id = VALUES(supersedes_block_id), active = VALUES(active), diff --git a/src/storage/store.ts b/src/storage/store.ts index 8903060935..cd413832c9 100644 --- a/src/storage/store.ts +++ b/src/storage/store.ts @@ -905,6 +905,11 @@ export class UnifiedStore { .prepare("SELECT summary_hash, one_hash FROM blocks WHERE session_id = ? AND block_id = ?") .get(s.sessionId, b.blockId) as { summary_hash: string; one_hash: string | null } | undefined; if (existing) { + // #4592: preserve interval bounds across resaves. A later batch that + // no longer contains the covered raws (a post-fold client resend sees + // the folded view, not the raw tail) re-derives -1/-1 "unknown" from + // its own log; once real evidence exists it is durable — the upsert's + // CASE keeps the stored bounds when the incoming side is unknown. // #4242: redirect the row BEFORE the undo/release so a // released-to-zero old hash is no longer FK-referenced by // this blocks row when the content DELETE fires. The @@ -917,7 +922,9 @@ export class UnifiedStore { summary_hash, one_hash, supersedes_block_id, active, created_at, covered_hash, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(session_id, block_id) DO UPDATE SET - ord = excluded.ord, start_seq = excluded.start_seq, end_seq = excluded.end_seq, + ord = excluded.ord, + start_seq = CASE WHEN excluded.start_seq >= 0 THEN excluded.start_seq ELSE blocks.start_seq END, + end_seq = CASE WHEN excluded.end_seq >= 0 THEN excluded.end_seq ELSE blocks.end_seq END, start_ref = excluded.start_ref, end_ref = excluded.end_ref, tier = excluded.tier, summary_hash = excluded.summary_hash, one_hash = excluded.one_hash, supersedes_block_id = excluded.supersedes_block_id, active = excluded.active, @@ -955,7 +962,9 @@ export class UnifiedStore { summary_hash, one_hash, supersedes_block_id, active, created_at, covered_hash, payload_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(session_id, block_id) DO UPDATE SET - ord = excluded.ord, start_seq = excluded.start_seq, end_seq = excluded.end_seq, + ord = excluded.ord, + start_seq = CASE WHEN excluded.start_seq >= 0 THEN excluded.start_seq ELSE blocks.start_seq END, + end_seq = CASE WHEN excluded.end_seq >= 0 THEN excluded.end_seq ELSE blocks.end_seq END, start_ref = excluded.start_ref, end_ref = excluded.end_ref, tier = excluded.tier, summary_hash = excluded.summary_hash, one_hash = excluded.one_hash, supersedes_block_id = excluded.supersedes_block_id, active = excluded.active, diff --git a/tests/storage-block-bounds-preserve.test.ts b/tests/storage-block-bounds-preserve.test.ts new file mode 100644 index 0000000000..e95da8e2f7 --- /dev/null +++ b/tests/storage-block-bounds-preserve.test.ts @@ -0,0 +1,113 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { UnifiedStore } from "../src/storage/store.js"; +import { planIngest } from "../src/storage/ingest.js"; +import { createInitialState } from "acp-kernel"; + +interface CoreLike { + id: string; + role: "user" | "assistant"; + contentType: "text"; + text: string; +} + +function wmsg(id: string, role: "user" | "assistant", text: string): CoreLike { + return { id, role, contentType: "text", text }; +} + +function histLike(sessionId: string, messages: CoreLike[], blocks: Array<{ blockId: string; effectiveMessageIds: string[] }>) { + const state = { ...createInitialState(), requests: 1 }; + state.nextBlockId = blocks.length + 1; + state.blocks = blocks.map((b) => ({ + blockId: b.blockId, + runId: "r1", + tier: 1 as const, + summary: `summary for ${b.blockId} — covered history retained in the block store, recoverable via decompress`, + directMessageIds: b.effectiveMessageIds, + effectiveMessageIds: b.effectiveMessageIds, + directBlockIds: [], + compressedTokens: 500, + createdAt: Date.now(), + survivedCount: 1, + generation: "young" as const, + active: true, + })) as never; + const contents = new Map(); + for (const b of blocks) contents.set(b.blockId, { one: null, full: { text: `full summary for ${b.blockId} — durable interval evidence test fixture`, count: 3 } }); + return { + id: sessionId, + createdAt: Date.now(), + lastSeen: Date.now(), + meta: { label: sessionId, protocol: "anthropic", upstreamOrigin: "https://api.anthropic.com" }, + stats: { requests: 1, blocks: blocks.length, tokensSaved: 100 }, + metadata: { pluginAgent: null }, + state: state as never, + blockContents: contents as never, + lastMessages: messages as never, + lastMessagesFolded: false, + }; +} + +test("block interval bounds survive a resave whose batch no longer contains the covered raws (#4592)", () => { + const dir = mkdtempSync(join(tmpdir(), "bounds-preserve-")); + const dbPath = join(dir, "index.db"); + try { + const store = UnifiedStore.open(dbPath); + try { + const m1 = wmsg("h_1", "user", "question one about the durable ledger bounds"); + const m2 = wmsg("h_2", "assistant", "answer one with some content so the row carries bytes"); + const m3 = wmsg("h_3", "user", "question two about the durable ledger bounds"); + // first ingest: rows land together with a block covering them → real bounds + store.ingestSession(planIngest(histLike("bounds-1", [m1, m2, m3], [{ blockId: "b1", effectiveMessageIds: ["h_1", "h_2", "h_3"] }]))); + let row = (store as unknown as { db: { prepare(q: string): { get(...a: unknown[]): { start_seq: number; end_seq: number } } } }) + .db.prepare("SELECT start_seq, end_seq FROM blocks WHERE session_id = ? AND block_id = ?") + .get("bounds-1", "b1"); + assert.ok(row.start_seq >= 0 && row.end_seq >= row.start_seq, `first ingest resolves real bounds: ${JSON.stringify(row)}`); + + // second ingest: the post-fold client view — covered raws GONE, only the + // summary anchor + a fresh tail message ride; the same block re-saves. + const anchor = wmsg("acp_summary_b1", "user", "[Compressed b1 — summary anchor]"); + const tail = wmsg("h_4", "user", "tail message after the fold"); + store.ingestSession(planIngest(histLike("bounds-1", [anchor, tail], [{ blockId: "b1", effectiveMessageIds: ["h_1", "h_2", "h_3"] }]))); + row = (store as unknown as { db: { prepare(q: string): { get(...a: unknown[]): { start_seq: number; end_seq: number } } } }) + .db.prepare("SELECT start_seq, end_seq FROM blocks WHERE session_id = ? AND block_id = ?") + .get("bounds-1", "b1"); + // the regression: the second batch re-derived -1/-1 and clobbered the evidence + assert.deepEqual( + { start: row.start_seq, end: row.end_seq }, + { start: 0, end: 2 }, + `bounds must stay durable across the post-fold resave: ${JSON.stringify(row)}`, + ); + } finally { + store.close(); + } + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); + +test("a block that never resolved keeps the honest -1/-1 gap", () => { + const dir = mkdtempSync(join(tmpdir(), "bounds-gap-")); + const dbPath = join(dir, "index.db"); + try { + const store = UnifiedStore.open(dbPath); + try { + const m1 = wmsg("h_1", "user", "one shot imported history without covered rows"); + store.ingestSession(planIngest(histLike("bounds-2", [m1], [{ blockId: "b-ghost", effectiveMessageIds: ["h_ghost1", "h_ghost2"] }]))); + const row = (store as unknown as { db: { prepare(q: string): { get(...a: unknown[]): { start_seq: number; end_seq: number } } } }) + .db.prepare("SELECT start_seq, end_seq FROM blocks WHERE session_id = ? AND block_id = ?") + .get("bounds-2", "b-ghost"); + // "unknown" has two legacy shapes: -1/-1 (plan side) and the + // pre-layer-3 0/0 placeholder (store side). Either is honest here; + // what must NEVER happen is a resolved interval for ghost ids. + assert.ok(row.start_seq <= 0 && row.end_seq <= Math.max(row.start_seq, 0), `ghost coverage stays unknown: ${JSON.stringify(row)}`); + } finally { + store.close(); + } + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); From c560a2a3b66425633da1b6b4460164a8e5751d26 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 01:55:16 +0800 Subject: [PATCH 02/12] fix(gates): de-export internal-only ClientBuildCheck (inherited master-red #4602, same one-liner as #4603/#4559) --- src/agent/client-build-note.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/client-build-note.ts b/src/agent/client-build-note.ts index 8ca7e9ddaf..6c08149309 100644 --- a/src/agent/client-build-note.ts +++ b/src/agent/client-build-note.ts @@ -29,7 +29,7 @@ import path from "node:path"; import { isVersionNewer } from "../update.js"; import { logHostEvent } from "./host-log.js"; -export type ClientBuildCheck = { +type ClientBuildCheck = { /** Short human label used in the note text ("dsh", "pi", ...). */ label: string; /** The client's npm id, as shown in the note (@deepseek-ai/dsh, ...). */ From 218871e8b86a454dea1d4173d53531789aaf3a22 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 02:13:16 +0800 Subject: [PATCH 03/12] docs: point changelog entry at the right issue (#4608, not #4592) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e85958ef36..4ea5e594a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag ## [Unreleased] ### Fixed -- 块区间边界在重存时不再回退:折叠后客户端重发的视图不含已覆盖原文,重入库时该批次无法重新解析区间(-1/-1),旧逻辑会把已解析的真实区间抹掉。现在区间证据一旦解析即持久(入库 `CASE` 保留;sqlite/mysql 双后端),未知块保持诚实缺口(#4592)。 +- 块区间边界在重存时不再回退:折叠后客户端重发的视图不含已覆盖原文,重入库时该批次无法重新解析区间(-1/-1),旧逻辑会把已解析的真实区间抹掉。现在区间证据一旦解析即持久(入库 `CASE` 保留;sqlite/mysql 双后端),未知块保持诚实缺口(#4608)。 ### Added From 6931798dda72596c3e229d5a9d7f386ae72e87b2 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 02:23:15 +0800 Subject: [PATCH 04/12] docs(storage): fix remaining #4592 -> #4608 refs in block-bounds code comments Completes the label correction started in 218871e8b (which fixed the CHANGELOG entry): the two explanatory comments on the interval-preserve upserts still cited #4592 (an unrelated zcode risk-control issue); the correct issue is #4608. --- src/storage/mysql.ts | 2 +- src/storage/store.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage/mysql.ts b/src/storage/mysql.ts index 48e799d078..f3c46ea373 100644 --- a/src/storage/mysql.ts +++ b/src/storage/mysql.ts @@ -575,7 +575,7 @@ export class MysqlBackend implements StorageBackend { VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE ord = VALUES(ord), - // #4592: keep durable interval evidence when a later batch can no + // #4608: keep durable interval evidence when a later batch can no // longer re-derive it (post-fold client resends carry no covered raws) start_seq = IF(VALUES(start_seq) >= 0, VALUES(start_seq), start_seq), end_seq = IF(VALUES(end_seq) >= 0, VALUES(end_seq), end_seq), diff --git a/src/storage/store.ts b/src/storage/store.ts index cd413832c9..a13acf4edb 100644 --- a/src/storage/store.ts +++ b/src/storage/store.ts @@ -905,7 +905,7 @@ export class UnifiedStore { .prepare("SELECT summary_hash, one_hash FROM blocks WHERE session_id = ? AND block_id = ?") .get(s.sessionId, b.blockId) as { summary_hash: string; one_hash: string | null } | undefined; if (existing) { - // #4592: preserve interval bounds across resaves. A later batch that + // #4608: preserve interval bounds across resaves. A later batch that // no longer contains the covered raws (a post-fold client resend sees // the folded view, not the raw tail) re-derives -1/-1 "unknown" from // its own log; once real evidence exists it is durable — the upsert's From 6f4eb16351caa6c4904a5e4601a1d0c24e53be7f Mon Sep 17 00:00:00 2001 From: Zhishulo <963336185@qq.com> Date: Sun, 25 Oct 2026 01:34:00 +0800 Subject: [PATCH 05/12] fix(types): keep ClientBuildCheck module-private to clear the unused-exports gate (#4602) --- src/agent/client-build-note.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/client-build-note.ts b/src/agent/client-build-note.ts index 8ca7e9ddaf..6c08149309 100644 --- a/src/agent/client-build-note.ts +++ b/src/agent/client-build-note.ts @@ -29,7 +29,7 @@ import path from "node:path"; import { isVersionNewer } from "../update.js"; import { logHostEvent } from "./host-log.js"; -export type ClientBuildCheck = { +type ClientBuildCheck = { /** Short human label used in the note text ("dsh", "pi", ...). */ label: string; /** The client's npm id, as shown in the note (@deepseek-ai/dsh, ...). */ From 79eedfd83936c2696864057a5f79ba2d67cbd514 Mon Sep 17 00:00:00 2001 From: Zhishulo <963336185@qq.com> Date: Sun, 25 Oct 2026 01:34:00 +0800 Subject: [PATCH 06/12] fix(ci): register the #3890 drain suite in LIVE_FILES (#4604) --- scripts/live-files.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/live-files.mjs b/scripts/live-files.mjs index 41cb876080..c7b3df0ee3 100644 --- a/scripts/live-files.mjs +++ b/scripts/live-files.mjs @@ -61,6 +61,9 @@ export const LIVE_FILES = [ // #4434 (split-brain surface): spawns bili CLI children against a throwaway // origin; own probe server is listen(0) so only the zone band matters "tests/issue-split-brain-surface.test.ts", + // #3890: spawns the drain fixture; that fixture is listen(0) and reports + // READY , so no zone band is needed — the entry is for the tripwire + "tests/issue3890-parent-gone-confirm-drain.test.ts", ]; /** Band width per live file: the zone ladder drifts +1 per EADDRINUSE retry; From 701f149a30a0747286767135daa2f95460637ac9 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 01:58:35 +0800 Subject: [PATCH 07/12] test: pass generationBoundaryActive correctly in #4305 injectSystem test (master born-red, #4599 sentinel) The tier-5 train added generationBoundaryActive as injectSystem's 9th parameter and updated every caller except this test's 'active' case: its trailing true landed in mcpDialectNote, so the note never appeared and the assertion must fail. Identical one-line fix already committed on PR #4559's branch (e82ccd7d6); drop that commit when rebasing whichever way merges first. --- tests/generation-boundary.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generation-boundary.test.ts b/tests/generation-boundary.test.ts index 48afbb44a1..e4408e18d5 100644 --- a/tests/generation-boundary.test.ts +++ b/tests/generation-boundary.test.ts @@ -126,7 +126,7 @@ test("#4305: injectSystem appends the note only when the boundary is active", () const parsed = { system: "You are a helpful assistant.", messages: [] }; const off = injectSystem({ ...parsed }, OPTS, undefined, defaultConfig(400_000), undefined, true, false, false) as string; assert.ok(!off.includes(GENERATION_BOUNDARY_NOTE), "inactive: system block unchanged by this feature"); - const on = injectSystem({ ...parsed }, OPTS, undefined, defaultConfig(400_000), undefined, true, false, true) as string; + const on = injectSystem({ ...parsed }, OPTS, undefined, defaultConfig(400_000), undefined, true, false, false, true) as string; assert.ok(on.includes(GENERATION_BOUNDARY_NOTE), "active: note rides the ACP standing block"); assert.ok(on.startsWith("You are a helpful assistant."), "client system block stays byte-exact (appended, never merged)"); // sysParts order contract: client head, standing prompt (attribution outermost), THEN the note. From 945f993f0fb1cfb861e855a1ede9eb291e944f75 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 01:58:35 +0800 Subject: [PATCH 08/12] fix(ci): suspend pages deploy push trigger while the repo has no Pages site (#4598, #4599 sentinel) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pages.yml has failed 75/75 runs since landing: actions/configure-pages@v5 gets 'Get Pages site failed ... Not Found' because GitHub Pages was never enabled on this repo (the earlier enablement:true attempt was reverted without a recorded reason — not re-applied here). Stop-the-bleed per #4598 option 1: drop the push trigger, keep manual workflow_dispatch so the deploy path stays intact and no website push red-lines master again. Final direction (re-enable Pages vs retire the workflow vs in-install serving) awaits owner decision. --- .github/workflows/pages.yml | 8 +++----- website/README.md | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9376f56812..89fe4b1c79 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,11 +1,9 @@ name: Deploy website to GitHub Pages on: - push: - branches: [master] - paths: - - "website/**" - - ".github/workflows/pages.yml" + # Push trigger suspended (#4598): the repo has no GitHub Pages site, so every + # website push red-lined the deploy job. Manual dispatch stays until the + # publishing direction is decided. workflow_dispatch: permissions: diff --git a/website/README.md b/website/README.md index d66681d3b4..3a50cac46e 100644 --- a/website/README.md +++ b/website/README.md @@ -2,7 +2,8 @@ Static landing page + docs. No build step, no dependencies — plain HTML/CSS/JS. Deployed to [GitHub Pages](https://ranxianglei.github.io/billion-context/) by -`.github/workflows/pages.yml` (publishes this folder on every push to master). +`.github/workflows/pages.yml` — manual `workflow_dispatch` only for now: the repo +has no GitHub Pages site yet, so auto-deploy on push is suspended (#4598). ## Local preview From 78046a55de80a777e67695a69b55817e0c1b5086 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 09:58:19 +0800 Subject: [PATCH 09/12] fix(web): restore the #/updates topbar anchor dropped by the #3536 line-rewrite (#4599 sentinel) The #3719 Updates tab stayed routed (PAGES/route/loadUpdates in client.ts) but its topbar anchor was dropped when #3536 rewrote the whole topbar line, making nav.updates a dead catalog key (web-i18n born-red on every PR head). Restored at the original position (after logs); identical to the sibling fix on the panel-blog branch (900c09c67), adapted to master (no blog anchor yet). --- src/web/page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/page.ts b/src/web/page.ts index 6df33d1844..881b0c77ca 100644 --- a/src/web/page.ts +++ b/src/web/page.ts @@ -23,7 +23,7 @@ export function renderPage(origin: string, version: string, embed = false, theme // that request used to miss every admin route and get relayed onto the // configured upstream (a wasted request + 403 noise in the log). return `billion-context -
billion-contextv${version}
+
billion-contextv${version}
From e59e0206028f8bf47698c4f1ebcd2a3431df93af Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 09:58:19 +0800 Subject: [PATCH 10/12] fix(log-mask): mask every home-root spelling at the publish boundary (#4427 Windows red, #4599 sentinel) maskPathsForPublish keyed off os.homedir() alone. On Windows that reads %USERPROFILE% while git-bash-style tool output carries $HOME paths, so the publish-boundary identity leak masked one spelling and leaked the other (#4427 suite red on windows shards only). Now masks the deduped set of os.homedir() + $HOME + %USERPROFILE%; POSIX behavior unchanged (values dedupe to one root), anchored-flank semantics preserved. --- src/log-mask.ts | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/log-mask.ts b/src/log-mask.ts index 83e8e89c08..6e41c3a6e6 100644 --- a/src/log-mask.ts +++ b/src/log-mask.ts @@ -156,17 +156,32 @@ function escapeRegExp(s: string): string { * publish-boundary text, rewriting it to `~` (the shell universal for $HOME). * This is the identity leak #3959 proved in the wild — a public diagnostics * report naming /home//... hands a stranger the reporter's username and - * home layout. Only THIS machine's os.homedir() is rewritten, as an ANCHORED - * match on BOTH flanks: preceded by start-of-string or a non-token boundary - * (whitespace / quote / bracket / colon / equals) AND followed by a path - * separator (/ or \), a quote, whitespace or end-of-string — so sibling homes - * (/home/), URL hosts and URL pathnames are all left alone. The result - * stays actionable: ~/.cache/billion-context/... is exactly where the user - * looks to recover. Idempotent (~ has no homedir in it). */ + * home layout. Every spelling of THIS machine's home root is rewritten — + * os.homedir() plus the $HOME and %USERPROFILE% env values (on Windows they + * diverge: os.homedir() reads USERPROFILE while git-bash-style tool output + * carries $HOME paths, so masking only one leaks the other; POSIX values + * dedupe to one root) — each as an ANCHORED match on BOTH flanks: preceded by + * start-of-string or a non-token boundary (whitespace / quote / bracket / + * colon / equals) AND followed by a path separator (/ or \), a quote, + * whitespace or end-of-string — so sibling homes (/home/), URL hosts + * and URL pathnames are all left alone. The result stays actionable: + * ~/.cache/billion-context/... is exactly where the user looks to recover. + * Idempotent (~ has no homedir in it). */ +function publishHomeRoots(): string[] { + const roots = new Set(); + for (const raw of [os.homedir(), process.env.HOME, process.env.USERPROFILE]) { + if (typeof raw !== "string") continue; + const r = raw.replace(/[/\\]+$/, ""); + if (r) roots.add(r); + } + return [...roots].sort((a, b) => b.length - a.length); +} + export function maskPathsForPublish(text: string): string { - const home = os.homedir(); - if (!text || !home) return text; - const re = new RegExp("(? Date: Sun, 25 Oct 2026 09:58:19 +0800 Subject: [PATCH 11/12] test(golden): regenerate storage-render goldens for the #4316 layer-3 restamp flag (#4599 sentinel) Deliberate persisted-state change: 380ef4dac (#4316 layer 3 PR3/3) added the one-time refLedgerAligned boolean to session state. All four wire digests are UNCHANGED; only the metadata section digest moved (+refLedgerAligned state key). Regen per the suite's own protocol (justification recorded here and in the ci-fixes PR body). --- tests/golden/storage-render/anthropic.json | 5 +++-- tests/golden/storage-render/chat.json | 5 +++-- tests/golden/storage-render/google.json | 5 +++-- tests/golden/storage-render/responses.json | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/golden/storage-render/anthropic.json b/tests/golden/storage-render/anthropic.json index 627cad7a26..5afa14b2c4 100644 --- a/tests/golden/storage-render/anthropic.json +++ b/tests/golden/storage-render/anthropic.json @@ -80,12 +80,12 @@ "foldAt": 9, "editedAt": 12, "summaryFrom": 9, - "stateDigest": "2afbea1dbbc9381f8ec7b49a4fa6b5d55b4084ff20304f20a1f51cb120b9a49f", + "stateDigest": "6727f42bd91879a7aa370e1ce0c78963bcba0df92e50390d4a8011f8f0da334d", "sectionDigests": { "state": "f93dc1c876c672d4", "blockContents": "dc7d13d250c94bb4", "stats": "c6f1d434975d047d", - "metadata": "9c05fef8fb761941" + "metadata": "f1ec4aab3aff777a" }, "stateKeyDigests": { "blocks": "3a454b9a16e4f0b9", @@ -98,6 +98,7 @@ "lastPassIds": "f13452893a1b4980", "hiddenOrphanRefs": "4f53cda18c2baa0c", "deadRefs": "74234e98afe7498f", + "refLedgerAligned": "74234e98afe7498f", "terminalStreak": "5feceb66ffc86f38", "nextRuleId": "6b86b273ff34fce1", "absorbed": "4f53cda18c2baa0c", diff --git a/tests/golden/storage-render/chat.json b/tests/golden/storage-render/chat.json index c3686433ba..46764f97db 100644 --- a/tests/golden/storage-render/chat.json +++ b/tests/golden/storage-render/chat.json @@ -80,12 +80,12 @@ "foldAt": 9, "editedAt": 12, "summaryFrom": 9, - "stateDigest": "a4abd4cb1cc9ade667c277fb1095641d6135cae0ac2d6ee2905920365f4f56b4", + "stateDigest": "e149c301f382438ee063a38f70dd794207b88e94bdf3c14c5191da0eeaa99bc9", "sectionDigests": { "state": "8390f21336885863", "blockContents": "94a58f96d7c5cfc3", "stats": "24d705b0e39bd13c", - "metadata": "68d1e5ca212cef7b" + "metadata": "55733fb81ccf7d69" }, "stateKeyDigests": { "blocks": "d9770feee91dafc6", @@ -98,6 +98,7 @@ "lastPassIds": "d18ace2914339891", "hiddenOrphanRefs": "4f53cda18c2baa0c", "deadRefs": "74234e98afe7498f", + "refLedgerAligned": "74234e98afe7498f", "terminalStreak": "5feceb66ffc86f38", "nextRuleId": "6b86b273ff34fce1", "absorbed": "4f53cda18c2baa0c", diff --git a/tests/golden/storage-render/google.json b/tests/golden/storage-render/google.json index 145d5c3f6e..ba999cadec 100644 --- a/tests/golden/storage-render/google.json +++ b/tests/golden/storage-render/google.json @@ -80,12 +80,12 @@ "foldAt": 9, "editedAt": 12, "summaryFrom": 9, - "stateDigest": "9ad5cff9d94aa21024b20aa870e94cd0a62c9dedc452ad7e76d8821a3635f30a", + "stateDigest": "80e83935e5fa7b052a3cb0f1d641bd81cb6ee59f91f3c1f2f31c204de29368a5", "sectionDigests": { "state": "2e1def3a3234afdc", "blockContents": "473264d9df8ba338", "stats": "900481685c848462", - "metadata": "2f0093fdaa6fb5a7" + "metadata": "88cd02a467b4457e" }, "stateKeyDigests": { "blocks": "0cfd0b9c0fc53073", @@ -98,6 +98,7 @@ "lastPassIds": "1e3edaf045fbb7d1", "hiddenOrphanRefs": "4f53cda18c2baa0c", "deadRefs": "74234e98afe7498f", + "refLedgerAligned": "74234e98afe7498f", "terminalStreak": "5feceb66ffc86f38", "nextRuleId": "6b86b273ff34fce1", "absorbed": "4f53cda18c2baa0c", diff --git a/tests/golden/storage-render/responses.json b/tests/golden/storage-render/responses.json index 2070742004..7004d90435 100644 --- a/tests/golden/storage-render/responses.json +++ b/tests/golden/storage-render/responses.json @@ -80,12 +80,12 @@ "foldAt": 9, "editedAt": 12, "summaryFrom": 9, - "stateDigest": "f1c5b00ba772868d48c8addcb150a54908eb308f9bd3a4fd46d7a79084effdbc", + "stateDigest": "08526d3552fca7ac7552cd16a221893a652fbe740c9b8dccac6db57b3d6302ee", "sectionDigests": { "state": "db313e8eba2d65fc", "blockContents": "b6701268a0bdcd8a", "stats": "327d3967b8371aa8", - "metadata": "e4cac45276f335cc" + "metadata": "b5c39d84db67f424" }, "stateKeyDigests": { "blocks": "34b0dc17f8c24595", @@ -98,6 +98,7 @@ "lastPassIds": "de5c5da67428b09f", "hiddenOrphanRefs": "4f53cda18c2baa0c", "deadRefs": "74234e98afe7498f", + "refLedgerAligned": "74234e98afe7498f", "terminalStreak": "5feceb66ffc86f38", "nextRuleId": "6b86b273ff34fce1", "absorbed": "4f53cda18c2baa0c", From 177bbce322bf4af7144fe725c432dbfd6a9e129b Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 09:58:19 +0800 Subject: [PATCH 12/12] test(snapshot-render): bring stale test doubles up to the #D5-5 windowed-load interface (#4599 sentinel) #D5-5 changed buildView to call store.unifiedMessageIdRows() + store.unifiedUncoveredRows(id, intervals) first; the pre-existing fake stores (only unifiedTailSeqs/unifiedTailViewRows) threw TypeError, caught by the by-design degrade net as transcript-error, turning every render-expecting assertion red (chain 6/6, verif replay). Extended both real-JS fakes and the symbolic harness portImpls (__method_unifiedMessageIdRows / __method_unifiedUncoveredRows) to mirror SessionStore semantics. --- tests/snapshot-render-chain.test.ts | 5 ++++- tests/verif-snapshot-render.test.ts | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/snapshot-render-chain.test.ts b/tests/snapshot-render-chain.test.ts index 637c247a46..0d8f60b9f3 100644 --- a/tests/snapshot-render-chain.test.ts +++ b/tests/snapshot-render-chain.test.ts @@ -47,10 +47,13 @@ let nextSessionId = 0; /** Install a fabricated unified-store tail view and render `client` through it. */ function render(blocks: BlockLike[], client: BiliMessage[], rows: BiliMessage[]): { session: Session; view: BiliMessage[] } { - const rawRows = rows.map((m, i) => ({ seq: i + 1, content: JSON.stringify(m) })); + const rawRows = rows.map((m, i) => ({ seq: i + 1, msgId: m.id, content: JSON.stringify(m) })); + const inWindow = (seq: number, intervals: readonly [number, number][]) => intervals.some(([a, b]) => seq >= a && seq <= b); const fake = { unifiedTailSeqs: () => rawRows.map((r) => r.seq), unifiedTailViewRows: () => rawRows, + unifiedMessageIdRows: () => rawRows.map(({ seq, msgId }) => ({ seq, msgId })), + unifiedUncoveredRows: (_id: string, intervals: readonly [number, number][]) => rawRows.filter((r) => !inWindow(r.seq, intervals)), }; _setStoreForTest(fake as unknown as SessionStore); nextSessionId++; diff --git a/tests/verif-snapshot-render.test.ts b/tests/verif-snapshot-render.test.ts index 05a0b7a4df..78ab2a200a 100644 --- a/tests/verif-snapshot-render.test.ts +++ b/tests/verif-snapshot-render.test.ts @@ -75,6 +75,7 @@ test("bug3756 judge: buildView keeps the client tail and the summary anchor (sym const row = (seq: number, id: Term, text: Term): SymVal => objv([ ["seq", numv(seq)], + ["msgId", strv(id)], ["content", strv(S0.concat(id).concat(S1).concat(ROLE).concat(S2).concat(CT).concat(S3).concat(text).concat(S4))], ]); const rows = arrv([row(1, r1, t1), row(2, r2, t2), row(3, r3, t3)]); @@ -107,6 +108,12 @@ test("bug3756 judge: buildView keeps the client tail and the summary anchor (sym getStore: (): SymVal => objv([]), __method_unifiedTailViewRows: (): SymVal => rows, __method_unifiedTailSeqs: (): SymVal => arrv([numv(1), numv(2), numv(3)]), + __method_unifiedMessageIdRows: (): SymVal => arrv([ + objv([["seq", numv(1)], ["msgId", strv(r1)]]), + objv([["seq", numv(2)], ["msgId", strv(r2)]]), + objv([["seq", numv(3)], ["msgId", strv(r3)]]), + ]), + __method_unifiedUncoveredRows: (): SymVal => rows, }, }, }).exec(); @@ -189,8 +196,16 @@ test("bug3756 replay: maybeSnapshotView end-to-end on real JS (success / #3812 l content: JSON.stringify({ id, role: "user", contentType: "text", text: `body-${id}` }), contentHash: `h${i}`, tokens: 3, })); - const fakeStore = (rows: unknown[] | null): SessionStore => - ({ unifiedTailViewRows: () => rows, unifiedTailSeqs: () => (rows ? rows.map((_, i) => i + 1) : null) }) as unknown as SessionStore; + const fakeStore = (rows: unknown[] | null): SessionStore => { + const list = rows as { seq: number; msgId: string }[] | null; + return ({ + unifiedTailViewRows: () => rows, + unifiedTailSeqs: () => (rows ? rows.map((_, i) => i + 1) : null), + unifiedMessageIdRows: () => (list ? list.map(({ seq, msgId }) => ({ seq, msgId })) : null), + unifiedUncoveredRows: (_id: string, intervals: readonly [number, number][]) => + (list ? list.filter((r) => !intervals.some(([a, b]) => r.seq >= a && r.seq <= b)) : null), + }) as unknown as SessionStore; + }; const mkSession = (blockIds: string[]): { session: never; blocks: never } => { const session = { id: "s1",