From e325694c36fc112c616c9816d350901ff56bd72d Mon Sep 17 00:00:00 2001 From: ework-agent Date: Tue, 13 Oct 2026 11:11:26 +0800 Subject: [PATCH] fix: exempt @openma/deepseek-harness-acp from name-only conflict scan (#2969) - add the dsh ACP protocol adapter to the verified non-compressor list (its 'acp' suffix names Agent Client Protocol, not acp-kernel); exact token match, lookalikes still flagged; stock [suspected] records are neutralized at display time, no data migration - widen the path-segment matcher so scoped names match Windows paths too - pure [suspected] ledgers drop the imperative per-client fix footer / web hint block (acp_status + banner); confirmed and unconfirmed-signal tiers keep remediation, mixed ledgers stay verbatim (#2802 gate) - CONFIGURATION.md scanner section updated to match --- CONFIGURATION.md | 4 +- src/conflict-watch.ts | 16 +++-- src/thirdparty-scan.ts | 45 ++++++++---- src/web/client.ts | 16 +++-- src/web/sessions-data.ts | 7 +- tests/issue1206-thirdparty-scan.test.ts | 96 ++++++++++++++++++++++++- tests/web-conflict-banner.test.ts | 21 +++++- 7 files changed, 174 insertions(+), 31 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 707b6472c9..979bb6732b 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2071,9 +2071,9 @@ Kill switch: `BILLION_CONTEXT_PLUGIN=0` disables plugin mode entirely (wire-leve Two compressors on one conversation double-compress and corrupt message refs, so bili actively looks for other compressors co-resident with itself: -- **Scan** (read-only, best-effort, 5-minute cache): opencode global + project config `plugin` arrays; pi global + project `.pi/settings.json` `packages`; omp `config.yml` `extensions`; claude settings `enabledPlugins`/`plugins` keys + `~/.claude/plugins/` dir; kimi `plugins/installed.json`; hermes `~/.hermes/plugins/` dir; dsh profile `package.json` dependencies. Two tiers: **known conflicts** (`opencode-acp`, legacy `billion-context-pi` — deterministic) and **keyword-suspected** entries (names matching compress* / compact* / acp / summar*; bare `context` deliberately does NOT match — it names the domain, not the act of compressing, so read-only tools like `context7`/`dsh-context` do not flag); verified read-only/display-only plugins (e.g. `pi-compact-transcript`, `pi-context-inspector`) are exempt outright. +- **Scan** (read-only, best-effort, 5-minute cache): opencode global + project config `plugin` arrays; pi global + project `.pi/settings.json` `packages`; omp `config.yml` `extensions`; claude settings `enabledPlugins`/`plugins` keys + `~/.claude/plugins/` dir; kimi `plugins/installed.json`; hermes `~/.hermes/plugins/` dir; dsh profile `package.json` dependencies. Two tiers: **known conflicts** (`opencode-acp`, legacy `billion-context-pi` — deterministic) and **keyword-suspected** entries (names matching compress* / compact* / acp / summar*; bare `context` deliberately does NOT match — it names the domain, not the act of compressing, so read-only tools like `context7`/`dsh-context` do not flag); verified non-compressing plugins are exempt outright by EXACT package name — read-only/display-only tools (e.g. `pi-compact-transcript`, `pi-context-inspector`) and protocol adapters whose name merely collides with a keyword (`@openma/deepseek-harness-acp`: its `acp` means Agent Client Protocol, not the acp-kernel ecosystem marker; #2969) — lookalike names still flag. - **Where findings surface:** launcher stderr before the client starts; a proxy warn log on each session's first request (client identified from the `x-bili-plugin` header or wire headers); and the session's conflict ledger — `acp_status`'s `COMPRESSION CONFLICTS` section, `GET /__bili/stats` → `conflicts`, web-UI banner. -- **Runtime evidence, tiered for display (#2545):** unannounced history rewrites (#1001) and orphan-gc deactivations (summarized content deleted out of the client's history) are recorded in the same ledger as *suspected* coexistence. Severity surfaces grade by EVIDENCE TIER: **confirmed** = a detected client-native compaction landing (bili rebases onto it, #2372/#2432) or a non-suspected plugin finding — only this triggers the imperative "keep one compressor" warning; **unconfirmed signals** = unannounced rewrites + orphan-gc deactivations — observed changes whose cause is NOT identified ("history changed, cause unknown"), never presented as native auto-compaction or a second compressor; name-only [suspected] matches stay in the soft "verify first" tier (#1736). Stock ledger records naming verified read-only plugins are neutralized at display time instead of persisting as alarms, and cross-session aggregate counts of unconfirmed signals never escalate to a same-conversation double-compression claim. +- **Runtime evidence, tiered for display (#2545):** unannounced history rewrites (#1001) and orphan-gc deactivations (summarized content deleted out of the client's history) are recorded in the same ledger as *suspected* coexistence. Severity surfaces grade by EVIDENCE TIER: **confirmed** = a detected client-native compaction landing (bili rebases onto it, #2372/#2432) or a non-suspected plugin finding — only this triggers the imperative "keep one compressor" warning; **unconfirmed signals** = unannounced rewrites + orphan-gc deactivations — observed changes whose cause is NOT identified ("history changed, cause unknown"), never presented as native auto-compaction or a second compressor; name-only [suspected] matches stay in the soft "verify first" tier (#1736) and a PURE [suspected] ledger gets verify-first advice only — no imperative per-client fix footer ("disable auto-compaction / start a fresh session") while nothing is confirmed (#2969). Stock ledger records naming verified non-compressing plugins (read-only viewers, or protocol adapters such as #2969's ACP adapter) are neutralized at display time instead of persisting as alarms, and cross-session aggregate counts of unconfirmed signals never escalate to a same-conversation double-compression claim. - **dsh's `auto: false` disables only the automatic triggers.** The `compaction-basic: { auto: false }` line installed by the profile bundle patch (`dsh.bundle.patch.yml`) skips pressure/overflow auto-compaction — a manual `/compact` (and idle-session compaction) still fires. Calls routed through bili are refused by the server-side guard (#1729/#2360); calls that reach the provider without transiting bili (desktop-lane paths the plugin's takeover gate does not attribute) land, and bili detects them on the next replay — checkpoint framing + decimated fold coverage — rebasing its compression state in one turn instead of failing every later compress forever (#2432). #### Turning dsh native auto-compaction OFF in a web profile (#1772/#2474) diff --git a/src/conflict-watch.ts b/src/conflict-watch.ts index 6481cb4169..8a8ba1a59a 100644 --- a/src/conflict-watch.ts +++ b/src/conflict-watch.ts @@ -129,7 +129,7 @@ function isSuspectedEvent(e: ConflictEvent): boolean { // #2545: evidence tiers. NEUTRAL = records naming things that are NOT second // compressors by verification: bili's own siblings (stand down while bili drives -// the session, #2261) and KNOWN_DISPLAY_ONLY read-only plugins (#2324/#2545). +// the session, #2261) and verified non-compressing plugins (#2324/#2545/#2969). // CONFIRMED = bili identified who rewrote the conversation: a detected // native-compaction landing, or a plugin finding that is not name-only // [suspected]. UNCONFIRMED SIGNALS = observations consistent with external @@ -194,7 +194,7 @@ export function formatConflictSection(events: ConflictEvent[], now: number = Dat // unconfirmed signals -> "cause not identified" framing, never imperative let advice: string; if (meaningful.length === 0) { - advice = "Every event above names bili's OWN sibling extension (billion-context-pi / opencode-acp) or a verified read-only plugin (display-only by design): while bili drives the session the sibling stands down automatically (BILLION_CONTEXT_NATIVE marker in native mode, /bili/ baseUrl self-check otherwise) and the read-only plugin does not compress anything, so no second compressor is active. Verify your bili/sibling versions are recent, then clear this ledger — Web UI conflict banner / session page, or POST /__bili/conflicts/clear."; + advice = "Every event above names bili's OWN sibling extension (billion-context-pi / opencode-acp) or a verified non-compressing plugin (a read-only viewer/tool, or a protocol adapter whose name merely collides with a compression keyword — e.g. 'acp' meaning Agent Client Protocol): while bili drives the session the sibling stands down automatically (BILLION_CONTEXT_NATIVE marker in native mode, /bili/ baseUrl self-check otherwise) and the verified plugin does not compress anything, so no second compressor is active. Verify your bili/sibling versions are recent, then clear this ledger — Web UI conflict banner / session page, or POST /__bili/conflicts/clear."; } else if (foreignConfirmed) { advice = activeConfirmed ? "Keep exactly ONE compressor per conversation: remove/disable the other plugin (or its native auto-compaction), then start a fresh session." @@ -236,8 +236,16 @@ export function formatConflictSection(events: ConflictEvent[], now: number = Dat // active, so a per-client fix command would contradict it. Also skipped // for #2802-review orphan-only ledgers: their advice names the real fix // (restore the identity-stamping lane) — a generic auto-compaction command - // would contradict it too. - if (meaningful.length > 0 && !orphanOnly) { + // would contradict it too. And skipped for PURE [suspected] ledgers (#2969): + // every event is an unverified name match, so the default command ("disable + // the client's own auto-compaction ... start a fresh session") demands + // corrective action although nothing was confirmed — the verify-first advice + // above already covers what to do. Confirmed, unconfirmed-signal, and MIXED + // ledgers (incl. orphan+suspected, kept verbatim by the #2802-review gate) + // keep the footer. + const pureSuspectedTier = meaningful.length > 0 && confirmed.length === 0 && signals.length === 0 + && !meaningful.some((e) => e.kind === "identity-orphan"); + if (meaningful.length > 0 && !orphanOnly && !pureSuspectedTier) { lines.push("", `Fix${client ? ` (${client})` : ""}: ${conflictRemediation(client)}`); lines.push(CONFLICT_DOCS_POINTER); } diff --git a/src/thirdparty-scan.ts b/src/thirdparty-scan.ts index b36826f50d..6fc46fce44 100644 --- a/src/thirdparty-scan.ts +++ b/src/thirdparty-scan.ts @@ -90,10 +90,12 @@ export function isSiblingConflictDetail(detail: string): boolean { return isLegacyBcpEntry(p.entry) || isOpencodeAcpEntry(p.entry); } -/** #2545: true when the recorded detail names a VERIFIED read-only plugin from - * KNOWN_DISPLAY_ONLY. Such records were only ever written as [suspected] by - * pre-#1736 keyword rules (which matched bare "context"), and must count for - * NO conflict severity on any display surface — the plugin does not compress. */ +/** #2545/#2969: true when the recorded detail names a VERIFIED non-compressing + * plugin from KNOWN_NON_COMPRESSORS. Such records were only ever written as + * [suspected] by the keyword rules (pre-#1736 matched bare "context"; the + * ecosystem-marker rule misfires on "acp" naming Agent Client Protocol), and + * must count for NO conflict severity on any display surface — the plugin + * does not compress. */ export function isDisplayOnlyConflictDetail(detail: string): boolean { const p = parsePluginConflictDetail(detail); if (!p) return false; @@ -108,7 +110,9 @@ const SCAN_CACHE_TTL_MS = 5 * 60 * 1000; // "context-viewer"/"context-memory" share the domain without compressing and // flooded the suspected tier with false positives. A real compressor carries // an action token (compress*/compact*/summar*) or the ecosystem marker "acp". -// \b keeps embedded words ("context7", a docs plugin) from matching. +// \b keeps embedded words ("context7", a docs plugin) from matching. Verified +// non-compressors whose names collide with these tokens are exempted below in +// KNOWN_NON_COMPRESSORS (#2324/#2545/#2969). const KEYWORD_RE = /\b(compress\w*|compact\w*|acp|summar\w*)\b/i; const cache = new Map(); @@ -188,14 +192,16 @@ export function isOpencodeAcpEntry(entry: string): boolean { return bare === "opencode-acp" || /^opencode-acp@/.test(bare) || /(^|[/\\])opencode-acp([/\\]|$)/.test(trimmed); } -// #2324: third-party plugins VERIFIED to touch only terminal rendering / tool-output -// folding and never the model context — so a name like "pi-compact-transcript" must not -// raise a compression-conflict alarm. Matched as an EXACT token — bare name, npm spec -// (with or without version), or a bounded path segment — mirroring isOpencodeAcpEntry's -// discipline so the two can't drift. Deliberately NOT a transcript/display substring rule: -// a real compressor ("context-compactor") or a lookalike ("my-pi-compact-transcript-fork") -// must still flag. Evidence-backed, one entry at a time. -const KNOWN_DISPLAY_ONLY = new Set([ +// #2324/#2545/#2969: third-party plugins VERIFIED to never compress the model +// context — so their names must not raise a compression-conflict alarm. Two +// evidence classes: read-only display/viewer plugins, and protocol adapters +// whose keyword hit is a pure name collision ("acp" = Agent Client Protocol, +// not the acp-kernel ecosystem marker). Matched as an EXACT token — bare name, +// npm spec (with or without version), or a bounded path segment — mirroring +// isOpencodeAcpEntry's discipline so the two can't drift. Deliberately NOT a +// substring rule: a real compressor ("context-compactor") or a lookalike +// ("my-pi-compact-transcript-fork") must still flag. Evidence-backed, one entry at a time. +const KNOWN_NON_COMPRESSORS = new Set([ // pi terminal extension: folds tool output / re-lays AssistantMessage rendering, // registers display toggles; README states "changes display only" — no context // replacement or compression handler (#2324). @@ -206,14 +212,23 @@ const KNOWN_DISPLAY_ONLY = new Set([ // matched its name (bare "context") and wrote stock [suspected] ledger records; // isDisplayOnlyConflictDetail neutralizes those at display time. "pi-context-inspector", + // dsh ACP protocol adapter: the "-acp" suffix names the Agent Client Protocol, + // NOT the acp-kernel compression ecosystem — a pure keyword collision (#2969). + // Its shipped cordis.patch.yml disables dsh native compaction features + // (compaction-basic / command-compact / tool-result-pruner); no observed double + // compression. Stock [suspected] records are neutralized at display time. + "@openma/deepseek-harness-acp", ]); export function isKnownDisplayOnlyPlugin(entry: string): boolean { const trimmed = entry.trim(); const bare = trimmed.replace(/^npm:/, ""); - for (const name of KNOWN_DISPLAY_ONLY) { + for (const name of KNOWN_NON_COMPRESSORS) { if (bare === name || bare.startsWith(name + "@")) return true; - const esc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + // Scoped names carry an inner "/" — widen it to EITHER separator so the + // bounded path-segment match holds on Windows paths too (#2969); unscoped + // names pass through split/join unchanged. + const esc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").split("/").join("[/\\\\]"); if (new RegExp(`(^|[/\\\\])${esc}([/\\\\]|$)`).test(trimmed)) return true; } return false; diff --git a/src/web/client.ts b/src/web/client.ts index cf04f2e73c..3f0320bf77 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -88,9 +88,10 @@ export const WEB_CLIENT = `(function () { // one unexplained rewrite into a "two compressors on one conversation" alarm (#2545); // they outrank name-only [suspected] matches (an observed change is stronger than a // name guess), so any signal takes the unconfirmed tier even next to suspected names. - // SUSPECTED-ONLY keeps the #2324 verify-first tier. Siblings and verified read-only - // (display-only) plugins are NEUTRAL. Old payloads without c.suspected / c.displayOnly - // degrade to the previous view; without c.activeConfirmed, liveness falls back to c.active. + // SUSPECTED-ONLY keeps the #2324 verify-first tier. Siblings and verified + // non-compressing plugins (read-only viewers, protocol adapters — #2324/#2545/#2969) + // are NEUTRAL. Old payloads without c.suspected / c.displayOnly degrade to the + // previous view; without c.activeConfirmed, liveness falls back to c.active. // Pure (reads only c), exported for tests the same way bili_conflictLine is. function bili_conflictSeverity(c) { const kinds = c.kinds || {}; @@ -137,7 +138,12 @@ export const WEB_CLIENT = `(function () { // stands down completely — compatible family / non-compressors, not conflicts. const siblingOnly = !hasConfirmed && suspectedN === 0 && signalN === 0 && siblingN > 0; const neutralOnly = !hasConfirmed && suspectedN === 0 && signalN === 0 && (siblingN + displayOnlyN) > 0; - return { onKey: onKey, riskKey: riskKey, onText: onText, riskText: riskText, hasConfirmed: hasConfirmed, siblingOnly: siblingOnly, neutralOnly: neutralOnly, what: whatParts.join(t("conflict.what_join")), active: active, activeConfirmed: activeConfirmed }; + // #2969: per-client remediation hints are imperative ("disable auto-compaction, + // start a fresh session") — they belong to CONFIRMED and UNCONFIRMED-SIGNAL tiers. + // A suspected-only ledger already carries verify-first wording in riskText; an + // imperative hint block beneath it contradicts it and demands action on a guess. + const showHints = hasConfirmed || signalN > 0; + return { onKey: onKey, riskKey: riskKey, onText: onText, riskText: riskText, hasConfirmed: hasConfirmed, siblingOnly: siblingOnly, neutralOnly: neutralOnly, showHints: showHints, what: whatParts.join(t("conflict.what_join")), active: active, activeConfirmed: activeConfirmed }; } window.bili_conflictLine = bili_conflictLine; window.bili_conflictSeverity = bili_conflictSeverity; @@ -540,7 +546,7 @@ export const WEB_CLIENT = `(function () { // #2219: per-client remediation block between the summary line and the // details pointer — clients[] comes from summarizeConflicts (server-side // resolution); payloads without it degrade to the generic hint only. - cb.innerHTML = '' + sev.onText + "" + t("conflict.found") + escapeHtml(sev.what) + sev.riskText + '(' + bili_conflictLine(c) + ")" + conflictHintBlock(c.clients) + t("conflict.where") + '"; + cb.innerHTML = '' + sev.onText + "" + t("conflict.found") + escapeHtml(sev.what) + sev.riskText + '(' + bili_conflictLine(c) + ")" + (sev.showHints ? conflictHintBlock(c.clients) : "") + t("conflict.where") + '"; // #2545: red styling follows CONFIRMED liveness — a fresh unconfirmed // signal beside a stale confirmed ledger renders as info, not warn. cb.classList.toggle("info", !(sev.hasConfirmed && sev.activeConfirmed > 0)); diff --git a/src/web/sessions-data.ts b/src/web/sessions-data.ts index 0140a5233e..8220365171 100644 --- a/src/web/sessions-data.ts +++ b/src/web/sessions-data.ts @@ -837,9 +837,10 @@ function renderDetail(session: Session, live: boolean): WebSessionDetail { const pluginAgent = typeof session.metadata["pluginAgent"] === "string" ? session.metadata["pluginAgent"] : undefined; const clientHint = pluginAgent ?? (typeof session.metadata["clientHint"] === "string" ? session.metadata["clientHint"] : undefined); const sysPrompt = typeof session.metadata["systemPromptTokens"] === "number" ? session.metadata["systemPromptTokens"] : 0; - // #2430/#2545: bili's own siblings (billion-context-pi / opencode-acp) are compatible - // family and verified read-only plugins (KNOWN_DISPLAY_ONLY) are not compressors — keep - // both out of the session evidence card so such sessions render no conflict block at all. + // #2430/#2545/#2969: bili's own siblings (billion-context-pi / opencode-acp) are + // compatible family and verified non-compressing plugins (KNOWN_NON_COMPRESSORS) + // are not compressors — keep both out of the session evidence card so such + // sessions render no conflict block at all. // Recording (acp_status #2261 calm footer) is unchanged. const conflicts = conflictEventsOf(session).filter((e) => !(e.kind === "third-party-plugin" && (isSiblingConflictDetail(e.detail) || isDisplayOnlyConflictDetail(e.detail)))); const conflictClient = conflicts.length > 0 ? conflictClientOf(session) : undefined; diff --git a/tests/issue1206-thirdparty-scan.test.ts b/tests/issue1206-thirdparty-scan.test.ts index 3f03353a93..27a5b7fd4c 100644 --- a/tests/issue1206-thirdparty-scan.test.ts +++ b/tests/issue1206-thirdparty-scan.test.ts @@ -580,7 +580,7 @@ test("formatConflictSection: display-only-only ledger stands down neutrally (#25 recordConflict(s, "third-party-plugin", "pi: npm:pi-context-inspector (C:\\Users\\Administrator\\.pi\\agent\\settings.json) [suspected]"); recordConflict(s, "third-party-plugin", "pi: npm:pi-context-inspector@1.3.0 (C:\\Users\\Administrator\\.pi\\agent\\settings.json) [suspected]"); const text = formatConflictSection(conflictEventsOf(s)).join("\n"); - assert.ok(text.includes("verified read-only plugin"), "names the verified read-only tier"); + assert.ok(text.includes("verified non-compressing plugin"), "names the verified non-compressing tier"); assert.ok(!text.includes("Two compressors on one conversation"), "header claim requires confirmed/native evidence"); assert.ok(!text.toLowerCase().includes("keep exactly one compressor"), "no removal command for non-compressors"); assert.ok(text.includes("/__bili/conflicts/clear"), "points at the clear path"); @@ -608,3 +608,97 @@ test("formatConflictSection: stale confirmed stock next to a fresh signal -> ver assert.ok(text.includes("Two compressors on one conversation"), "header claim holds while confirmed evidence exists"); assert.ok(!text.toLowerCase().includes("keep exactly one compressor"), "stock confirmed events get verify-then-clear, not the live command"); }); + +// #2969: @openma/deepseek-harness-acp — the "-acp" suffix names the Agent Client +// Protocol, not the acp-kernel ecosystem marker. The adapter is verified NOT to +// compress (its shipped cordis.patch.yml disables dsh native compaction features), +// so it must be exempted by exact name AND its stock [suspected] records neutralized +// at display time — while real compressors and runtime evidence stay fully visible. + +test("isKnownDisplayOnlyPlugin exempts the dsh ACP protocol adapter in every spec form, rejects lookalikes (#2969)", () => { + assert.ok(isKnownDisplayOnlyPlugin("@openma/deepseek-harness-acp")); + assert.ok(isKnownDisplayOnlyPlugin("npm:@openma/deepseek-harness-acp")); + assert.ok(isKnownDisplayOnlyPlugin("npm:@openma/deepseek-harness-acp@0.4.37")); + assert.ok(isKnownDisplayOnlyPlugin("/u/dsh/profiles/desktop/node_modules/@openma/deepseek-harness-acp/index.js")); + assert.ok(isKnownDisplayOnlyPlugin("C:\\Users\\Administrator\\dsh\\profiles\\desktop\\node_modules\\@openma\\deepseek-harness-acp\\index.js"), "windows path form"); + assert.ok(!isKnownDisplayOnlyPlugin("@openma/deepseek-harness-acp-fork"), "scoped lookalike NOT excluded"); + assert.ok(!isKnownDisplayOnlyPlugin("deepseek-harness-acp"), "unscoped lookalike NOT excluded"); + assert.ok(!isKnownDisplayOnlyPlugin("@other/deepseek-harness-acp"), "other scope NOT excluded"); +}); + +test("dsh scan: ACP protocol adapter alone yields NO finding; real compressors still flagged (#2969)", () => { + clearScanCache(); + const root = tmp("bili-2969-dsh-"); + const env: NodeJS.ProcessEnv = { ...hermeticEnv(root), DSH_HOME: path.join(root, "dsh") }; + const pkg = path.join(root, "dsh", "profiles", "desktop", "package.json"); + assertTestOwned(pkg, root); + writeFile(pkg, JSON.stringify({ + dependencies: { + "billion-context": "^0.1.0", + "@openma/deepseek-harness-acp": "^0.4.0", + "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2", + }, + })); + const res = scanClientPlugins("dsh", { env, cwd: root }); + const names = res.findings.map((f) => f.entry); + assert.ok(!names.some((n) => n.includes("@openma/deepseek-harness-acp")), "protocol adapter never flagged in any spec form"); + assert.ok(names.includes("@deepseek-ai/dsh-compaction-basic"), "real compressor still flagged"); +}); + +test("isDisplayOnlyConflictDetail neutralizes stock records of the dsh ACP adapter (#2969)", () => { + assert.ok(isDisplayOnlyConflictDetail("dsh: @openma/deepseek-harness-acp (/home/u/.dsh/profiles/desktop/package.json) [suspected]"), "the issue's exact stock detail shape"); + assert.ok(isDisplayOnlyConflictDetail("dsh: npm:@openma/deepseek-harness-acp@0.4.37 (/u/dsh/profiles/desktop/package.json) [suspected]")); + assert.ok(!isDisplayOnlyConflictDetail("dsh: @openma/deepseek-harness-acp-fork (/u/dsh/profiles/desktop/package.json) [suspected]"), "lookalike stays suspected"); + assert.ok(!isDisplayOnlyConflictDetail("event 5"), "non-plugin shapes never classify"); +}); + +test("summarizeConflicts counts the ACP adapter record as displayOnly, overlapping suspected (#2969)", () => { + const a = makeSession(); + recordConflict(a, "third-party-plugin", "dsh: @openma/deepseek-harness-acp (/u/dsh/profiles/desktop/package.json) [suspected]"); + recordConflict(a, "third-party-plugin", "dsh: dsh-context-compressor (/u/dsh/profiles/desktop/package.json) [suspected]"); + const s = summarizeConflicts([a]); + assert.equal(s.events, 2); + assert.equal(s.suspected, 2, "both records are name-only matches on the raw counter"); + assert.equal(s.displayOnly, 1, "only the adapter record classifies as non-compressing"); + assert.equal(s.activeConfirmed, 0, "no confirmed-tier evidence from names alone"); +}); + +test("formatConflictSection: ACP-adapter-only ledger stands down neutrally, no fix footer (#2969)", () => { + const s = makeSession(); + recordConflict(s, "third-party-plugin", "dsh: @openma/deepseek-harness-acp (/u/dsh/profiles/desktop/package.json) [suspected]"); + recordConflict(s, "third-party-plugin", "dsh: @openma/deepseek-harness-acp (/u/dsh/profiles/desktop/package.json) [suspected]"); + const text = formatConflictSection(conflictEventsOf(s)).join("\n"); + assert.ok(text.includes("verified non-compressing plugin"), "names the verified non-compressing tier"); + assert.ok(!text.includes("Two compressors on one conversation"), "header claim requires confirmed/native evidence"); + assert.ok(!text.toLowerCase().includes("keep exactly one compressor"), "no removal command for non-compressors"); + assert.ok(!text.includes("\n\nFix"), "no per-client fix footer for a neutral ledger"); + assert.ok(text.includes("/__bili/conflicts/clear"), "points at the clear path"); +}); + +test("formatConflictSection: pure-[suspected] ledger drops the imperative fix footer (#2969)", () => { + const s = makeSession(); + recordConflict(s, "third-party-plugin", "dsh: dsh-context-compressor (/u/dsh/profiles/desktop/package.json) [suspected]"); + const text = formatConflictSection(conflictEventsOf(s)).join("\n"); + assert.ok(text.includes("[suspected] = name-only"), "explains the suspected marker"); + assert.ok(text.includes("do not drop a read-only tool"), "verify-first advice present"); + assert.ok(!text.includes("\n\nFix"), "no imperative per-client fix footer when nothing is confirmed"); + assert.ok(!text.includes("disable the client's own auto-compaction"), "no disable/restart command for name-only guesses"); + assert.ok(!text.includes("Detecting other compression plugins"), "docs pointer rides with the footer"); + + const s2 = makeSession(); + recordConflict(s2, "third-party-plugin", "dsh: dsh-context-compressor (/u/dsh/profiles/desktop/package.json) [suspected]"); + recordConflict(s2, "unannounced-rewrite", "47/247 incoming message(s) carry pre-turn refs of 290 known"); + const text2 = formatConflictSection(conflictEventsOf(s2)).join("\n"); + assert.ok(text2.includes("\n\nFix"), "unconfirmed-signal tier keeps the remediation footer"); + assert.ok(text2.includes("UNCONFIRMED signal"), "signal framing intact"); +}); + +test("formatConflictSection: ACP adapter record next to a native landing stays neutral, native tier intact (#2969)", () => { + const s = makeSession(); + recordConflict(s, "third-party-plugin", "dsh: @openma/deepseek-harness-acp (/u/dsh/profiles/desktop/package.json) [suspected]"); + recordConflict(s, "native-compaction", "codex: compaction_trigger item"); + const text = formatConflictSection(conflictEventsOf(s)).join("\n"); + assert.ok(text.includes("Two compressors on one conversation"), "confirmed evidence keeps the header claim"); + assert.ok(text.includes("client's OWN native compaction landing"), "native tier advice intact"); + assert.ok(text.includes("\n\nFix"), "confirmed tier keeps the remediation footer"); +}); diff --git a/tests/web-conflict-banner.test.ts b/tests/web-conflict-banner.test.ts index 445e4c3695..59742d84dd 100644 --- a/tests/web-conflict-banner.test.ts +++ b/tests/web-conflict-banner.test.ts @@ -19,7 +19,7 @@ type LatestEntry = { kind: string; detail?: string; at?: number; sessionId?: str type BannerInput = { events?: number; sessions?: number; active?: number; historical?: number; kinds?: Record; latest?: LatestEntry[] }; // #2545: displayOnly/activeConfirmed are additive payload fields from summarizeConflicts. type SeverityInput = BannerInput & { sibling?: number; suspected?: number; displayOnly?: number; activeConfirmed?: number }; -interface Severity { onKey: string; riskKey: string; hasConfirmed: boolean; siblingOnly?: boolean; neutralOnly?: boolean; what: string; active: number; activeConfirmed: number } +interface Severity { onKey: string; riskKey: string; hasConfirmed: boolean; siblingOnly?: boolean; neutralOnly?: boolean; showHints?: boolean; what: string; active: number; activeConfirmed: number } // Both helpers share the same extracted slice (they sit together in WEB_CLIENT); // the slice ends at the first window.* export so no `window` reference runs under Node. @@ -284,3 +284,22 @@ test("#2709 inferred native-compaction landing counts as CONFIRMED, not an uncon assert.strictEqual(unannounced.onKey, "conflict.on_unconfirmed"); assert.strictEqual(unannounced.riskKey, "conflict.risk_unconfirmed"); }); + +test("#2969 suspected-only ledger -> no imperative per-client hints (showHints false)", () => { + const sev = bannerSeverity(); + const r = sev({ events: 3, sessions: 3, kinds: { "third-party-plugin": 3 }, sibling: 0, suspected: 3, active: 3 }); + assert.strictEqual(r.onKey, "conflict.on_suspected"); + assert.strictEqual(r.showHints, false, "name-only guesses get verify-first wording, not disable/restart commands"); +}); + +test("#2969 confirmed and unconfirmed-signal ledgers keep the per-client hints (showHints true)", () => { + const sev = bannerSeverity(); + const confirmed = sev({ events: 2, kinds: { "third-party-plugin": 2 }, suspected: 0, active: 2 }); + assert.strictEqual(confirmed.showHints, true, "confirmed tier keeps imperative remediation"); + const signal = sev({ events: 2, kinds: { "unannounced-rewrite": 2 }, active: 2 }); + assert.strictEqual(signal.showHints, true, "unconfirmed-signal tier keeps the hints (cause may be native compaction)"); + const mixed = sev({ events: 5, kinds: { "third-party-plugin": 3, "unannounced-rewrite": 2 }, sibling: 0, suspected: 3, active: 5 }); + assert.strictEqual(mixed.showHints, true, "a single signal event keeps the hints alongside suspected names"); + const oldPayload = sev({ events: 96, kinds: { "third-party-plugin": 96 }, active: 96 }); + assert.strictEqual(oldPayload.showHints, true, "pre-#2324 payloads degrade to the all-confirmed view WITH hints"); +});