From 27289a0c846ac36dd3b969c8e17b31d0bbf0b68e Mon Sep 17 00:00:00 2001 From: resec Date: Wed, 18 Nov 2026 20:28:23 +0800 Subject: [PATCH] fix(dsh): stand the host-plane /compact command down on a bili-owned lane (#7154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /compact drives the host's own compaction call — the same envelope bili's wire guard refuses unconditionally (#1729) — so on a bili-owned lane the command has no outcome except failure. dsh reports that failure as "Compaction could not produce a useful summary", blaming the model for a policy refusal, and every retry fails identically because the refusal is terminal. Disable the command entry in both patch carriers (persistent bundle + launcher overlay) with the same static semantics as the adjacent compaction-basic auto:false row. Escape hatch: a profile-level `disabled: false` for the same id brings it back; invocations are still refused at the wire. --- dsh.bundle.patch.yml | 11 ++++ src/launcher.ts | 2 +- ...issue7154-command-compact-disabled.test.ts | 58 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/issue7154-command-compact-disabled.test.ts diff --git a/dsh.bundle.patch.yml b/dsh.bundle.patch.yml index d7b815f249..2b0327ab5d 100644 --- a/dsh.bundle.patch.yml +++ b/dsh.bundle.patch.yml @@ -26,6 +26,17 @@ - id: compaction-basic config: auto: false +# #7154: `/compact` drives the SAME host-side compaction call bili's wire +# guard refuses unconditionally (#1729) — on a lane bili owns the command has +# no outcome except failure, and dsh reports that failure as "Compaction could +# not produce a useful summary", which blames the model for a policy refusal. +# Stand it down with the same static semantics as the `auto: false` row above +# (a kill-switched bili-native does not bring it back either). To get the +# command back, set `disabled: false` for this id in the profile's own +# cordis.patch.yml — be aware every invocation is still refused at the wire. +# Keep in sync with the launcher overlay (writeDshAcpPatch). +- id: command-compact + disabled: true # #3354: keep in sync with writeDshAcpPatch in src/launcher.ts — entry inject # lists are REPLACED by patches, not concatenated; if a future dsh ships its # own inject list on these entries, merge manually in BOTH layers. diff --git a/src/launcher.ts b/src/launcher.ts index b09d4a80ad..008e1ecfd6 100644 --- a/src/launcher.ts +++ b/src/launcher.ts @@ -3611,7 +3611,7 @@ export function writeDshAcpPatch(dshHome: string, entryName?: string): string | writeOverlayFileAtomic( dir, ".bili-acp.patch.yml", - `- insert:\n - id: bili-native\n name: ${pluginUrl}\n - id: bili-compaction-gate\n name: ${gateUrl}\n- id: compaction-basic\n config:\n auto: false\n# #3354/#3662: keep in sync with dsh.bundle.patch.yml — web-profile presets run their own compaction-basic in nested rows no patch layer can address by id (#1772); these gates make them wait for the load-time overlay the always-on bili-compaction-gate entry registers (vendored from deshark42/dsh-compaction-basic-disable, MIT)\n${compactionDisablePatchRows()}# #2605: keep in sync with dsh.bundle.patch.yml — a patch replaces the row's whole config, so every default code is restated\n- id: llm-deepseek\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n- id: llm-deepseek-account\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n`, + `- insert:\n - id: bili-native\n name: ${pluginUrl}\n - id: bili-compaction-gate\n name: ${gateUrl}\n- id: compaction-basic\n config:\n auto: false\n# #7154: keep in sync with dsh.bundle.patch.yml — /compact drives the host compaction call the #1729 wire guard refuses unconditionally, so on a bili-owned lane it can only fail (and dsh blames the model for it)\n- id: command-compact\n disabled: true\n# #3354/#3662: keep in sync with dsh.bundle.patch.yml — web-profile presets run their own compaction-basic in nested rows no patch layer can address by id (#1772); these gates make them wait for the load-time overlay the always-on bili-compaction-gate entry registers (vendored from deshark42/dsh-compaction-basic-disable, MIT)\n${compactionDisablePatchRows()}# #2605: keep in sync with dsh.bundle.patch.yml — a patch replaces the row's whole config, so every default code is restated\n- id: llm-deepseek\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n- id: llm-deepseek-account\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n`, ); const file = path.join(dir, ".bili-acp.patch.yml"); try { diff --git a/tests/issue7154-command-compact-disabled.test.ts b/tests/issue7154-command-compact-disabled.test.ts new file mode 100644 index 0000000000..09f9018473 --- /dev/null +++ b/tests/issue7154-command-compact-disabled.test.ts @@ -0,0 +1,58 @@ +// #7154: on a bili-owned lane, `/compact` can only fail. The command drives +// the host's own compaction call (compaction-basic → COMPACTION_INSTRUCTION), +// the same envelope bili's wire guard refuses unconditionally (#1729), and +// dsh reports the refusal as "Compaction could not produce a useful summary" +// — a policy decision surfaced as a model failure, with no working retry. +// Both patch carriers therefore stand the command down, with the same static +// semantics as the `compaction-basic: auto:false` row that precedes them +// (a kill-switched bili-native does not bring it back either). This test pins +// BOTH carriers, because they are the only two ways the lane gets mounted: +// the persistent bundle (dsh.bundle.patch.yml) and the launcher's --patch +// overlay (writeDshAcpPatch). +import test from "node:test"; +import assert from "node:assert/strict"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { writeDshAcpPatch } from "../src/launcher.ts"; + +const TESTS_DIR = path.dirname(fileURLToPath(import.meta.url)); + +const AUTO_OFF_ROW = "- id: compaction-basic\n config:\n auto: false\n"; +const COMPACT_COMMAND_ROW = "- id: command-compact\n disabled: true\n"; + +test("#7154 the bundle layer stands the host-plane /compact command down", () => { + const bundle = fs.readFileSync(path.join(TESTS_DIR, "..", "dsh.bundle.patch.yml"), "utf8").replaceAll("\r\n", "\n"); + assert.ok(bundle.includes(COMPACT_COMMAND_ROW), "dsh.bundle.patch.yml must disable command-compact"); + assert.ok(bundle.includes(AUTO_OFF_ROW), "the existing auto:false row must stay (this row follows the same static semantics)"); + // The row must be a top-level patch entry, never part of the insert list: + // an insert would mount a SECOND command-compact beside the host's. + const insertStart = bundle.indexOf("- insert:"); + const insertEnd = bundle.indexOf("\n- id: compaction-basic"); + assert.ok(insertStart !== -1 && insertEnd > insertStart, "insert block and the compaction-basic row must both exist"); + assert.ok( + !bundle.slice(insertStart, insertEnd).includes("command-compact"), + "command-compact must not be inserted (that would leave the host's own entry live)", + ); +}); + +test("#7154 the launcher overlay stands the same command down (both carriers agree)", () => { + const home = fs.mkdtempSync(path.join(os.tmpdir(), "bili-dsh-cc-")); + try { + const file = writeDshAcpPatch(home, "billion-context"); + assert.ok(file, "overlay patch must be written"); + const overlay = fs.readFileSync(file!, "utf8").replaceAll("\r\n", "\n"); + assert.ok(overlay.includes(COMPACT_COMMAND_ROW), "the launcher overlay must disable command-compact too"); + assert.ok(overlay.includes(AUTO_OFF_ROW), "the auto:false row must stay in the overlay"); + assert.ok( + overlay.indexOf(COMPACT_COMMAND_ROW) > overlay.indexOf(AUTO_OFF_ROW), + "the two rows stay adjacent and ordered (auto:false first) so a reader sees them as one decision", + ); + // The overlay must not disable the entry by inserting a second one. + assert.ok(!/- insert:\n(?: {4}- .*\n)* {4}- id: command-compact/.test(overlay), "command-compact must not be inserted"); + } finally { + fs.rmSync(home, { recursive: true, force: true }); + fs.rmSync(`${home}-bili`, { recursive: true, force: true }); + } +});