Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions src/conflict-watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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);
}
Expand Down
45 changes: 30 additions & 15 deletions src/thirdparty-scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string, { at: number; result: ScanResult }>();
Expand Down Expand Up @@ -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<string>([
// #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<string>([
// 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).
Expand All @@ -206,14 +212,23 @@ const KNOWN_DISPLAY_ONLY = new Set<string>([
// 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;
Expand Down
16 changes: 11 additions & 5 deletions src/web/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = '<strong>' + sev.onText + "</strong>" + t("conflict.found") + escapeHtml(sev.what) + sev.riskText + '<span class="mono">(' + bili_conflictLine(c) + ")</span>" + conflictHintBlock(c.clients) + t("conflict.where") + '<button id="conflicts-clear-btn" class="btn sm">' + t("conflict.clear_btn") + "</button>";
cb.innerHTML = '<strong>' + sev.onText + "</strong>" + t("conflict.found") + escapeHtml(sev.what) + sev.riskText + '<span class="mono">(' + bili_conflictLine(c) + ")</span>" + (sev.showHints ? conflictHintBlock(c.clients) : "") + t("conflict.where") + '<button id="conflicts-clear-btn" class="btn sm">' + t("conflict.clear_btn") + "</button>";
// #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));
Expand Down
7 changes: 4 additions & 3 deletions src/web/sessions-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading