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
11 changes: 11 additions & 0 deletions dsh.bundle.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
58 changes: 58 additions & 0 deletions tests/issue7154-command-compact-disabled.test.ts
Original file line number Diff line number Diff line change
@@ -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 });
}
});
Loading