From e6409e37e113ef1257f011e0026cd898d69b08c6 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 13:30:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20conflict=20report=20covers=20non-ds?= =?UTF-8?q?h=20clients=20=E2=80=94=20codex=20compaction=20log=20signatures?= =?UTF-8?q?=20+=20observed=20client=20hints=20(#4649)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #3611 diagnostics enrichment was dsh-only: CONFLICT_LOG_PATTERNS held no codex signature and the host-client-versions section listed only dsh profile bundles, so a codex conflict report shipped zero log evidence and no client version (#4648 stalled on manual data collection). - conflict tail now matches the codex compaction evidence chain: not- intercepted passthrough, intercept success (both forms), forge failure - versions section lists the live pool's distinct session clientHints — for UA-carried clients like codex the hint IS the version string (codex_cli_rs/); the line appears even when no dsh profile exists (the old early-return hid it) - targeted tests pin both directions incl. dedupe and the no-profile case --- src/web/diagnostics.ts | 50 +++++++++++++++++--- tests/web-diagnostics-enrichment.test.ts | 60 ++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 6 deletions(-) diff --git a/src/web/diagnostics.ts b/src/web/diagnostics.ts index 3fa0fb13d3..68496ab682 100644 --- a/src/web/diagnostics.ts +++ b/src/web/diagnostics.ts @@ -17,6 +17,14 @@ * `--- recent conflict-related log lines ---` (the exact signatures a * maintainer greps to adjudicate a native-compaction episode). * + * #4649: the #3611 coverage was dsh-only — a codex conflict report shipped + * zero log signatures and no client version (#4648), stalling triage on data + * the reporter had to dig out by hand. The conflict tail now also matches the + * codex compaction evidence chain (intercepted / not-intercepted / forge + * failed), and the versions section lists the live pool's distinct + * `clientHint`s — for UA-carried clients like codex the hint IS the version + * string (`codex_cli_rs/`), recorded per session at first request. + * * PUBLISH DISCIPLINE: the blob lands in a PUBLIC GitHub issue body (copied * verbatim AND embedded in the prefilled URL). Every byte passes redactForPublish * at the SINK (buildDiagnostics) — unconditional host masking + credential-shape @@ -60,6 +68,7 @@ const CONFIG_SECTION_MAX_CHARS = 1600; const CONFLICT_LOG_TAIL_LINES = 20; const LOG_LINE_MAX_CHARS = 240; const DSH_PROFILE_CAP = 8; +const CLIENT_HINT_CAP = 8; const DSH_REPORT_PACKAGES = ["@deepseek-ai/dsh", "@deepseek-ai/dsh-compaction-basic", "@deepseek-ai/dsh-web-app"] as const; function humanUptime(seconds: number): string { @@ -128,12 +137,18 @@ function storageLogTail(lines: string[]): string[] { // routed-call refusals (#1729), the destruction verdict (#2193), successful // rebases (#2432), and the web-app preset notice that says whether the #3354 // load-time overlay applies to this machine's profiles. +// #4649: the codex lane's equivalent chain — whether a compaction was +// intercepted (and forged locally) or passed through unrecognized; without +// these a codex conflict report carries no log evidence at all (#4648). const CONFLICT_LOG_PATTERNS = [ "takeover gate refused", "dsh native compaction call identified", "compression substrate appears destroyed", "native compaction boundary", "profile bundles include @deepseek-ai/dsh-web-app", + "codex compaction_trigger request not intercepted", + "codex compact intercepted", + "codex compact forge failed", ]; function conflictLogTail(lines: string[]): string[] { @@ -201,19 +216,42 @@ function dshPackageVersion(profileDir: string, pkg: string): string | undefined } } +// #4649: for clients whose version lives in the User-Agent (codex et al.), +// the per-session clientHint recorded at first request IS the version +// evidence — list the live pool's distinct hints so a conflict report names +// what actually talked to this proxy. Label hints ("claude", "opencode") and +// UA strings ("codex_cli_rs/") both appear verbatim; dedupe keeps +// long-lived multi-session machines readable. +function observedClientHintLines(): string[] { + const seen: string[] = []; + try { + for (const s of listSessions()) { + const h = s.metadata.clientHint; + if (typeof h !== "string" || h.length === 0 || seen.includes(h)) continue; + seen.push(h); + } + } catch { /* degrade: no hint line */ } + if (seen.length === 0) return []; + const listed = seen.slice(0, CLIENT_HINT_CAP).join(" | "); + return [`observed client hints (${seen.length} distinct, live sessions): ${listed}${seen.length > CLIENT_HINT_CAP ? ` (+${seen.length - CLIENT_HINT_CAP} more)` : ""}`]; +} + function hostClientVersionLines(): string[] { const lines: string[] = ["--- host client versions ---"]; let dirs: string[] = []; try { dirs = dshProfileDirs(process.env); } catch { dirs = []; } if (dirs.length === 0) { lines.push(`dsh: no profiles under DSH_HOME (${path.basename(resolveDshHome(process.env)) || "?"}/profiles missing — dsh has never run here, or DSH_HOME points elsewhere)`); - return lines; - } - for (const dir of dirs.slice(0, DSH_PROFILE_CAP)) { - const vers = DSH_REPORT_PACKAGES.map((p) => `${p.split("/")[1]} ${dshPackageVersion(dir, p) ?? "?"}`).join(", "); - lines.push(`dsh profile ${path.basename(dir)}: ${vers}`); + } else { + for (const dir of dirs.slice(0, DSH_PROFILE_CAP)) { + const vers = DSH_REPORT_PACKAGES.map((p) => `${p.split("/")[1]} ${dshPackageVersion(dir, p) ?? "?"}`).join(", "); + lines.push(`dsh profile ${path.basename(dir)}: ${vers}`); + } + if (dirs.length > DSH_PROFILE_CAP) lines.push(`… ${dirs.length - DSH_PROFILE_CAP} more profile(s)`); } - if (dirs.length > DSH_PROFILE_CAP) lines.push(`… ${dirs.length - DSH_PROFILE_CAP} more profile(s)`); + // #4649: the hint line must appear even when no dsh profile exists — a + // codex-only machine is exactly the case the old early-return hid. + lines.push(...observedClientHintLines()); return lines; } diff --git a/tests/web-diagnostics-enrichment.test.ts b/tests/web-diagnostics-enrichment.test.ts index c98f1cd528..37ff1aaa22 100644 --- a/tests/web-diagnostics-enrichment.test.ts +++ b/tests/web-diagnostics-enrichment.test.ts @@ -11,6 +11,7 @@ import os from "node:os"; import * as path from "node:path"; import { buildDiagnostics, _candidateLogReadsForTest, _resetCandidateLogReadsForTest } from "../src/web/diagnostics.js"; import { isMaskHostsEnabled, setMaskHostsEnabled } from "../src/log-mask.js"; +import { getSession, _resetSessionsForTest } from "../src/session.js"; const ENV_KEYS = ["BILI_CONFIG_FILE", "DSH_HOME", "XDG_STATE_HOME", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME"] as const; @@ -194,6 +195,65 @@ test("#3813 single-read: storage tail and conflict tail share one candidate set assert.equal(_candidateLogReadsForTest(), 2, "unknown topics must not touch the log at all"); }); +// #4649: the #3611 enrichment was dsh-only — a codex conflict report shipped +// zero log signatures and no client version (#4648), stalling triage on data +// the reporter had to dig out by hand. Pin both directions: the codex +// compaction signatures match the conflict tail (and unrelated lines still do +// not), and the live pool's distinct clientHints surface as version evidence — +// including on machines with NO dsh profile, where the old early-return hid +// the whole section tail. +test("#4649 codex lane: conflict tail matches codex signatures; client hints carry versions", (t) => { + const root = mkdtempSync(path.join(os.tmpdir(), "bili-diag-codex-")); + _resetSessionsForTest(); + t.after(() => { rmSync(root, { recursive: true, force: true }); _resetSessionsForTest(); }); + const stateHome = path.join(root, "state"); + mkdirSync(path.join(stateHome, "billion-context"), { recursive: true }); + writeFileSync(path.join(stateHome, "billion-context", "bili.log"), [ + "[ses_codex_1] codex compaction_trigger request not intercepted (no active fold blocks) — forwarding verbatim (no preflight, no rebuild, no window clamp)", + "[ses_codex_2] codex compact intercepted (inline-prompt form); forged SSE with 3 block summary(s), upstream not contacted", + "[ses_codex_3] codex compact forge failed (window violation); passing through to upstream", + "[acp-usage] round 9 input=90000 cached=80000 (cache hit 88%)", + ].join("\n") + "\n"); + const env = { DSH_HOME: path.join(root, "none"), XDG_STATE_HOME: stateHome, XDG_CONFIG_HOME: root, XDG_DATA_HOME: root, XDG_CACHE_HOME: root }; + const blob = withEnv(env, () => buildDiagnostics("conflict-banner")).blob; + assert.ok(blob.includes("codex compaction_trigger request not intercepted"), "passthrough decision captured"); + assert.ok(blob.includes("codex compact intercepted"), "intercept success captured"); + assert.ok(blob.includes("codex compact forge failed"), "forge failure captured"); + assert.ok(!blob.includes("[acp-usage] round 9"), "unrelated log lines still excluded"); + // No sessions yet: the hint line must be absent, not empty-noise. + assert.ok(!blob.includes("observed client hints"), "no hint line without live sessions"); + + const a = getSession("ses_codex_1"); + a.metadata.clientHint = "codex_cli_rs/0.163.0"; + const b = getSession("ses_codex_2"); + b.metadata.clientHint = "codex_cli_rs/0.163.0"; + const c = getSession("ses_oc_1"); + c.metadata.clientHint = "opencode"; + const blob2 = withEnv(env, () => buildDiagnostics("conflict-banner")).blob; + // 3 sessions, 2 DISTINCT hints (the duplicate UA collapses): + assert.ok(blob2.includes("observed client hints (2 distinct, live sessions):"), `hint line present with distinct count:\n${blob2}`); + // entry order follows lastSeen (same-millisecond ties are insertion-ordered), + // so match on membership, not position: + const hintLine = blob2.split("\n").find((l) => l.startsWith("observed client hints")) ?? ""; + assert.ok(hintLine.includes("codex_cli_rs/0.163.0") && hintLine.includes("opencode"), + `both distinct hints on one line, got: ${hintLine}`); + assert.equal(hintLine.split("codex_cli_rs/0.163.0").length - 1, 1, "duplicate UA hint deduped to one entry"); +}); + +test("#4649 no dsh profiles: observed client hints still surface (old early-return hid them)", (t) => { + const root = mkdtempSync(path.join(os.tmpdir(), "bili-diag-codex-noprof-")); + _resetSessionsForTest(); + t.after(() => { rmSync(root, { recursive: true, force: true }); _resetSessionsForTest(); }); + mkdirSync(path.join(root, "dsh"), { recursive: true }); + const s = getSession("ses_codex_only"); + s.metadata.clientHint = "Codex Desktop/1.2.3"; + const env = { DSH_HOME: path.join(root, "dsh"), XDG_STATE_HOME: root, XDG_CONFIG_HOME: root, XDG_DATA_HOME: root, XDG_CACHE_HOME: root }; + const blob = withEnv(env, () => buildDiagnostics()).blob; + assert.ok(blob.includes("no profiles under DSH_HOME"), "no-profiles note kept"); + assert.ok(blob.includes("observed client hints (1 distinct, live sessions): Codex Desktop/1.2.3"), + `hint line present despite missing profiles:\n${blob}`); +}); + test("#3611 enrichment is generic: storage topic and unknown topics carry it too", (t) => { const root = mkdtempSync(path.join(os.tmpdir(), "bili-diag-gen-")); t.after(() => rmSync(root, { recursive: true, force: true })); From 381a49577d4da0b462d288debb461d7ebc964ae5 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 25 Oct 2026 20:57:54 +0800 Subject: [PATCH 2/2] fix(web): conflict report captures the orphan-reap verdict and OpenAI-lane codex detection (#4649, #4688) --- src/web/diagnostics.ts | 7 +++++++ tests/web-diagnostics-enrichment.test.ts | 25 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/web/diagnostics.ts b/src/web/diagnostics.ts index 68496ab682..63d2c3dcbc 100644 --- a/src/web/diagnostics.ts +++ b/src/web/diagnostics.ts @@ -140,6 +140,11 @@ function storageLogTail(lines: string[]): string[] { // #4649: the codex lane's equivalent chain — whether a compaction was // intercepted (and forged locally) or passed through unrecognized; without // these a codex conflict report carries no log evidence at all (#4648). +// #4688: the client-agnostic tail of the chain — the #2695 zombie reap verdict +// (the line a pure orphan-reap ledger lives on; without it such reports ship +// an empty evidence section even with the reap in the log pair) and the +// OpenAI-lane codex local auto-compaction detection (#2372/#4521) that lands +// beside it once PR #4542 ships. const CONFLICT_LOG_PATTERNS = [ "takeover gate refused", "dsh native compaction call identified", @@ -149,6 +154,8 @@ const CONFLICT_LOG_PATTERNS = [ "codex compaction_trigger request not intercepted", "codex compact intercepted", "codex compact forge failed", + "zombie fold reap", + "codex local auto-compaction detected", ]; function conflictLogTail(lines: string[]): string[] { diff --git a/tests/web-diagnostics-enrichment.test.ts b/tests/web-diagnostics-enrichment.test.ts index 37ff1aaa22..0fcec0712a 100644 --- a/tests/web-diagnostics-enrichment.test.ts +++ b/tests/web-diagnostics-enrichment.test.ts @@ -254,6 +254,31 @@ test("#4649 no dsh profiles: observed client hints still surface (old early-retu `hint line present despite missing profiles:\n${blob}`); }); +// #4688: a PURE orphan-reap ledger (no plugin events, no dsh/codex framing) +// shipped with an empty evidence section because neither reap verdict nor the +// OpenAI-lane codex detection was in CONFLICT_LOG_PATTERNS — the report's own +// log tail was blind to the very event it was reporting. Pin both signatures +// (and the unrelated-line exclusion) so orphan-reap reports carry their proof. +test("#4688 orphan-reap report carries the reap verdict and the OpenAI-lane codex detection", (t) => { + const root = mkdtempSync(path.join(os.tmpdir(), "bili-diag-reap-")); + t.after(() => rmSync(root, { recursive: true, force: true })); + const stateHome = path.join(root, "state"); + mkdirSync(path.join(stateHome, "billion-context"), { recursive: true }); + const reapLine = "[ses_734d5481] zombie fold reap: removed 2 block(s) (b1, b2) from ACP state; blockContents retained, refs pruned to live ids (#2695)"; + const codexOpenaiLine = "[ses_codex_9] codex local auto-compaction detected (3/120 covered ids retained) — rebasing ACP state onto the compacted history (#2372/#4521)"; + writeFileSync(path.join(stateHome, "billion-context", "bili.log"), [ + "[acp-usage] round 4 input=120000 cached=100000 (cache hit 83%)", + reapLine, + codexOpenaiLine, + ].join("\n") + "\n"); + const env = { DSH_HOME: path.join(root, "none"), XDG_STATE_HOME: stateHome, XDG_CONFIG_HOME: root, XDG_DATA_HOME: root, XDG_CACHE_HOME: root }; + const blob = withEnv(env, () => buildDiagnostics("conflict-banner")).blob; + assert.ok(blob.includes("zombie fold reap"), "orphan-reap verdict captured (pre-fix: empty evidence section)"); + assert.ok(blob.includes("blockContents retained"), "reap line kept whole enough to show contents survived"); + assert.ok(blob.includes("codex local auto-compaction detected"), "OpenAI-lane codex detection captured"); + assert.ok(!blob.includes("[acp-usage] round 4"), "unrelated log lines still excluded"); +}); + test("#3611 enrichment is generic: storage topic and unknown topics carry it too", (t) => { const root = mkdtempSync(path.join(os.tmpdir(), "bili-diag-gen-")); t.after(() => rmSync(root, { recursive: true, force: true }));