diff --git a/CONFIGURATION.md b/CONFIGURATION.md
index f0cda90f8d..e1b8bedd80 100644
--- a/CONFIGURATION.md
+++ b/CONFIGURATION.md
@@ -116,7 +116,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `compat.streamErrorShape` | "protocol" \| "completion" | protocol | BILI_STREAM_ERROR_SHAPE | How upstream stream failures are presented after the 200 is committed: protocol-native error frames (default) or the legacy synthesized-completion shape. |
| `compat.noCacheControl` | boolean | false | BILI_NO_CACHE_CONTROL | Stop stamping Anthropic-lane cache_control breakpoints entirely (escape hatch for upstreams/relays with their own breakpoint policy). |
| `compat.keepResponseId` | boolean | false | ACP_KEEP_RESPONSE_ID | Preserve previous_response_id on kernel-rebuilt Responses requests (default strips it so rebuilt bodies never reference ids the upstream never issued). |
-| `dsh.allowDshCompaction` | boolean | false | BILI_ALLOW_DSH_COMPACTION | Lift bili's local 422 refusal of dsh native compaction calls on EVERY wire lane bili serves — openai, anthropic, and responses (#1729/#2028; responses added by #2360, the lane dsh desktop's compaction actually rides): when true, dsh's compaction-basic may execute through bili; its checkpoint durably shadows raw history, so this is an explicit irreversible opt-in. |
+| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | Section recognized but its former escape hatch is gone (#3666, superseding #2028): the allowDshCompaction key and the BILI_ALLOW_DSH_COMPACTION env var no longer exist — dsh native compaction is refused unconditionally by the wire guard on every lane. Leftover dsh.allowDshCompaction values are ignored with a one-time deprecation warning; apply host-side suppression instead (#3354/#2474). The one live key, dsh.authoredCompaction, is documented in the next entry. |
| `dsh.authoredCompaction` | boolean | true (on, #3901 flip) | BILI_DSH_AUTHORED_COMPACTION | bili answers dsh compaction summarize calls locally with the folded snapshot instead of refusing (#3723/#3733). ON by default since the 0.1.203 dogfood window held; false (or env BILI_DSH_AUTHORED_COMPACTION=0) restores the #1729 refusal path. |
| `resign` | scheme → { enabled?, passthrough?, credentialRef? } | {} (armed; built-in scheme sdk-hmac-sha256) | BILI_RESIGN, BILI_RESIGN_PASSTHROUGH, BILI_CODEARTS_REF, BILI_RESIGN_BENEFIT | Re-sign arm keyed by Authorization scheme: signed model requests tunnel with every egress body re-signed; unresignable requests are refused locally 403 unless passthrough opts that scheme into verbatim forwarding. |
| `promptCache.routing` | "auto" \| "enabled" \| "disabled" | auto | ACP_PROMPT_CACHE_ROUTING | Prompt-cache routing posture for cache-aware lane selection. |
@@ -1708,7 +1708,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes
| `BILI_ADVISORY_CHECK` | `advisoryCheck` | true |
| `BILI_ADVISORY_URL` | `advisoryUrl` | unset (built-in feed) |
| `BILI_AFFINITY_SIMHASH` | `affinitySimhash` | true |
-| `BILI_ALLOW_DSH_COMPACTION` | `dsh.allowDshCompaction` | false |
+| `BILI_ALLOW_DSH_COMPACTION` | `dsh` | {} |
| `BILI_ALLOW_PRIVATE_HTTP_PROVIDERS` | `network.allowPrivateHttpProviders` | false |
| `BILI_AUTO_MODE_FORGE` | `autoModeForge.enabled` | true |
| `BILI_CA_FILE` | `network.caFile` | unset |
@@ -1870,8 +1870,8 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes
| `BILI_AFFINITY_SIMHASH` | Set `0` to turn OFF simhash chain-alignment adoption (#2265): anonymous requests whose exact hash chain was broken by a client-side pervasive decorative rewrite (e.g. Trae re-stamping model tags on every assistant message) re-attach the existing session with its compression state instead of minting fresh and re-folding from zero. Guards: ≥90% coverage within Hamming 10, ≥20% mutated-but-similar positions (point edits still fork, #629), ≥1 byte-identical user message, unique candidate only. Default ON. `"affinitySimhash": false` in the config file does the same; the env var wins. |
| `BILI_RESUME_INHERITANCE` | Set `0` to turn OFF resume inheritance (ON by default) (#1486): when an identified client (sends its own session id, e.g. Claude Code's `x-claude-code-session-id`) resumes a conversation under a NEW session id while replaying the full transcript (`cc --resume` forks a fresh UUID), bili matches the incoming history byte-exactly against that client's tracked chains (≥8 messages, append-only tracking) and, on the resumed session's first request, inherits the parent's ref assignments — stale model citations then resolve to their ORIGINAL messages instead of mis-hitting renumbered ones — adopts the fully-present compression blocks (together with this inheritance, #1834: losing them on resume meant the folded originals came back on the wire and the upstream request ballooned; the old `forkAdoption` co-gate now applies only to anonymous forks, #629), and records the `derivedFrom` lineage. The parent is never modified and fresh messages number above the parent's ref space. A resume must strictly EXTEND the parent's history — an equal-depth byte-exact replay under another id is a duplicate, not a resume. Anonymous sessions are unaffected (they keep their own pfa-* world, #309). `"resumeInheritance": false` in the config file does the same; the env var wins. |
| `BILI_STABLE_SYSTEM_ANCHOR` | Set `1` to enable stable-system anchoring (#1085) — a **best-effort wire-layer fallback** for prefix caching: the root fix belongs client-side (the client owns its history and decides how to present instruction changes), this only stops the proxy from letting a changed head invalidate the whole cached prefix. **Plain-proxy mode only**: plugin-mode agents (`x-bili-plugin`) own their context management and are never anchored, so clients that already inject cache-friendly updates (e.g. claude-code-style system reminders) are not double-processed. When enabled, bili remembers each session's first-seen head system/instructions block and keeps re-sending those exact bytes even when the client's system prompt later changes. A **localized** change (a file-style edit sharing ≥70% of lines with the version in effect so far) appends a trailing `[System context update] …` user note carrying a compact line diff (`-` removed / `+` added; each note composes sequentially onto the previous one). A **non-localized** change (structural reshuffle, tool-def churn, timestamped banners, heads over 400 lines) is adopted outright — one deliberate cache miss beats appending noise that would mislead the model about its instructions. Churn guard: more than 8 accumulated notes likewise replace the anchor with the newest text and clear the log. The anchor and note log persist with the session and survive compression/compaction (session metadata, not kernel state). Known residual limitation: client-placed `cache_control` breakpoints may still misalign after a head swap. Excluded from anchoring: title-gen micro-requests (OpenAI/Google), Responses compaction-trigger requests, auto-mode classifier requests. Clients implementing their own variant (stable prompt + in-history updates) get zero extra injection — such updates pass through as ordinary history. Default is OFF. `"stableSystemAnchor": true` in the config file does the same; the env var wins. |
-| `BILI_ALLOW_DSH_COMPACTION` | Set `1` to let dsh's built-in auto-compaction run through bili (#2028). By default the wire-level guard (#1729) **refuses dsh native compaction calls locally** (422) on every lane bili serves — openai, anthropic, and responses (responses added by #2360; it was the lane the pre-#2360 whitelist short-circuited before the marker was ever examined, so dsh desktop's compaction calls passed silently): dsh's `compaction-basic` answers context pressure by replaying the conversation prefix plus a fixed summarization directive as the final user message, and when such a call LANDS its checkpoint durably shadows the raw history — irreversible, and it destroys the proxy's compression substrate. This switch lifts the refusal so dsh-native compaction can actually execute. While the guard refuses, dsh's own context-pressure counter (its raw ledger) only grows — refused checkpoints never land — while bili's folds keep the wire payload small, so the session keeps working past the point where the client's gauge says "full", and dsh keeps re-requesting compaction (refused every time). Since #3384 the outgoing output budget is also no longer planned against that raw ledger, EXCEPT when bili's own folded view has already reached the enforced headroom target or the requested budget is >= 25% of the native window (the #2490 protection regimes) — before that fix the growing ledger silently shrank the model's output budget every turn, ending in error-free empty replies on onlyReasoning models. Scope note: with bili ON, dsh native auto-compaction is now off on every plane — the host-plane row via the shipped bundle patch (`auto: false`), and web-profile preset instances at load time via the #3354 overlay — so this switch mainly governs manual `/compact` on non-web profiles (auto-triggering stays suppressed there) and any residual auto-triggering on dsh builds where the #3354 overlay does not apply. The web config page exposes the same switch; the env var wins over the file. Set `"dsh": { "allowDshCompaction": true }` in the config file to the same effect (a bare top-level `"allowDshCompaction"` in an older file is auto-relocated there on load). |
-| `BILI_DSH_AUTHORED_COMPACTION` | Set `1` to have bili itself ANSWER dsh's compaction summarize calls locally instead of refusing them (#3733). Prerequisites per call: the #1729 guard fires (marker-decisive), the session holds at least one ACTIVE fold block, and `allowDshCompaction` is NOT enabled (the explicit "forward natively" choice always wins). The reply is forged with zero egress (the autoModeForge #2740 discipline): an identity header `` plus every active block's summary in the kernel render format — exactly the bytes the model already reads upstream, so client display, upstream context and server state agree for the first time, and dsh's checkpoint file shrinks (#3723's unbounded growth loop). Originals stay recoverable via CCR/export; the landed checkpoint is recognized on replay through the same #2432 rebase as a foreign one, but recorded as `dshAuthoredCheckpointLanded` (info, not warn). Env-only for the rollout window; read per-request, no restart needed. |
+| `BILI_ALLOW_DSH_COMPACTION` | **REMOVED in #3666** (superseding #2028). The former switch let dsh's built-in auto-compaction run through bili by lifting the wire-level refusal (#1729); because a landed dsh checkpoint durably shadows the raw conversation history — irreversible, destroying the proxy's compression substrate — the escape hatch has been deleted outright: dsh native compaction calls are now intercepted unconditionally on every lane bili serves, on every build — refused (422) by default, or answered locally by bili itself when `BILI_DSH_AUTHORED_COMPACTION` is set (row below). Any leftover value — `"dsh": { "allowDshCompaction": true }`, a bare top-level `"allowDshCompaction"` in an older file, or the old env var — is ignored, with a one-time deprecation warning naming it. If you need dsh-side checkpoints out entirely, apply host-side suppression instead: the shipped bundle patch (`auto: false`) on non-web profiles, or the #3354 load-time overlay / #2474 full-snapshot override of preset-standard on web profiles. |
+| `BILI_DSH_AUTHORED_COMPACTION` | Set `1` to have bili itself ANSWER dsh's compaction summarize calls locally instead of refusing them (#3733). Prerequisites per call: the #1729 guard fires (marker-decisive; unconditional since #3651) and the session holds at least one ACTIVE fold block. The reply is forged with zero egress (the autoModeForge #2740 discipline): an identity header `` plus every active block's summary in the kernel render format — exactly the bytes the model already reads upstream, so client display, upstream context and server state agree for the first time, and dsh's checkpoint file shrinks (#3723's unbounded growth loop). Originals stay recoverable via CCR/export; the landed checkpoint is recognized on replay through the same #2432 rebase as a foreign one, but recorded as `dshAuthoredCheckpointLanded` (info, not warn). Env-only for the rollout window; read per-request, no restart needed. |
| `BILI_NO_CACHE_CONTROL` | Set `1` to disable bili's Anthropic-lane `cache_control` breakpoint stamping (#1637, shipped in #1639). On by default: Anthropic-style upstreams cache only what is explicitly breakpointed (max 4 per request, counted across system + tools + message blocks combined), so bili marks the system block plus up to 3 cumulative message marks — a marked message stays marked (byte-stable prefix), marks die only by folding, and the last 3 stable messages carry the advancing frontier. Any client-set `cache_control` (message blocks, tools entries) suppresses bili's stamps entirely — client-managed caching wins. Marks persist with the session. This switch is the escape hatch for upstreams that reject the field or relays with their own breakpoint policy. Plain-proxy Anthropic lane only; OpenAI/Responses lanes cache implicitly and are never stamped. Config-file twin: [`compat.noCacheControl`](#compat) — the env var wins. |
| `BILI_CHAIN_CONTENT` | Set `1` to turn ON the ACP-artifact / `` checkpoint **body-content** detection of bili→bili chain awareness (#1086/#1421): when an inbound request carries compression artifacts (render tags / historical `acp_status`+`search_context` tool calls) or a digest-bearing checkpoint in its BODY but neither the `x-bili-hop` header nor local compression state for its session, bili records an advisory observation and/or applies first-processor-wins passthrough. **Default is OFF** (#1683 follow-up): by default ONLY the `x-bili-hop` header drives chain recognition, because scanning the request BODY can false-positive on CCR/file-introduced text and model-echoed tags that look like real markers. Enable it only for the narrow multi-bili relay case where an intermediate box strips `x-bili-hop` and you accept that false-positive risk. `"chainContentDetection": true` in the config file does the same; the env var wins. The `x-bili-hop` signal itself is unaffected by this switch. |
| `BILI_CHAIN_STAMP` | Set `1` to turn ON egress emission of the **model-visible** `` chain-integrity checkpoint carrier (#1683, default OFF): when enabled, every request THIS instance actually processes leaves with a digest-bearing stamp so a downstream bili applies first-processor-wins even when the `x-bili-hop` header was stripped in transit (#1421). The carrier lands in a slot the terminal model also reads (a trailing `user` message on OpenAI/Responses, a trailing text part on Anthropic/Google), so models treat it as phantom user input and burn tokens commenting on it — which is why it is off by default. Enable it only for the narrow multi-bili relay case where `x-bili-hop` is stripped by an intermediate box and the digest-verified body-stamp is the sole guard against double-processing. Independent of `BILI_CHAIN_CONTENT` (inbound body-detection is also default OFF) and of the `x-bili-hop` passthrough, which works either way. `"chainEgressStamp": true` in the config file does the same; the env var wins. |
diff --git a/CONFIGURATION.zh-CN.md b/CONFIGURATION.zh-CN.md
index 8115d9fe12..0052589564 100644
--- a/CONFIGURATION.zh-CN.md
+++ b/CONFIGURATION.zh-CN.md
@@ -116,7 +116,7 @@
| `compat.streamErrorShape` | "protocol" \| "completion" | protocol | BILI_STREAM_ERROR_SHAPE | 200 已提交后上游流失败的呈现方式:协议原生错误帧(默认)或旧版合成完成形态。 |
| `compat.noCacheControl` | boolean | false | BILI_NO_CACHE_CONTROL | 完全停止 Anthropic 通道的 cache_control 断点打标(面向拒收该字段或有自有断点策略的上游/中继的逃生门)。 |
| `compat.keepResponseId` | boolean | false | ACP_KEEP_RESPONSE_ID | 在内核重建的 Responses 请求上保留 previous_response_id(默认剔除,使重建请求体永不引用上游从未签发过的响应 id)。 |
-| `dsh.allowDshCompaction` | boolean | false | BILI_ALLOW_DSH_COMPACTION | 解除 bili 对 dsh 原生压缩调用的本地 422 拒绝——覆盖 bili 服务的全部线路:openai、anthropic、responses(#1729/#2028;responses 由 #2360 补上,正是 dsh 桌面端压缩实际走的线路):为 true 时 dsh 的 compaction-basic 可经 bili 执行;其 checkpoint 会永久覆盖原始历史,属显式的不可逆 opt-in。 |
+| `dsh` | object | {} | BILI_ALLOW_DSH_COMPACTION | 段仍被识别,但其原逃生门已移除(#3666,取代 #2028):allowDshCompaction 键与 BILI_ALLOW_DSH_COMPACTION 环境变量已不存在——dsh 原生压缩现在在所有线路上被无条件拒绝。遗留的 dsh.allowDshCompaction 取值会被忽略(一次性弃用警告);请改用宿主侧抑制(#3354/#2474)。唯一的存活键 dsh.authoredCompaction 见下一条目。 |
| `dsh.authoredCompaction` | boolean | true (on, #3901 flip) | BILI_DSH_AUTHORED_COMPACTION | bili 用折叠快照本地应答 dsh 压缩摘要请求而非拒绝(#3723/#3733)。0.1.203 狗粮窗口守住后默认开启;false(或环境变量 BILI_DSH_AUTHORED_COMPACTION=0)恢复 #1729 拒绝路径。 |
| `resign` | scheme → { enabled?, passthrough?, credentialRef? } | {} (armed; built-in scheme sdk-hmac-sha256) | BILI_RESIGN, BILI_RESIGN_PASSTHROUGH, BILI_CODEARTS_REF, BILI_RESIGN_BENEFIT | 按 Authorization 方案键控的重签名臂:可重签名的模型请求全程重签转发;无法重签的请求本地 403 拒绝,除非该方案经 passthrough 选择原文透传。 |
| `promptCache.routing` | "auto" \| "enabled" \| "disabled" | auto | ACP_PROMPT_CACHE_ROUTING | 面向缓存感知路由选择的提示词缓存路由姿态。 |
@@ -1707,7 +1707,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
| `BILI_ADVISORY_CHECK` | `advisoryCheck` | true |
| `BILI_ADVISORY_URL` | `advisoryUrl` | unset (built-in feed) |
| `BILI_AFFINITY_SIMHASH` | `affinitySimhash` | true |
-| `BILI_ALLOW_DSH_COMPACTION` | `dsh.allowDshCompaction` | false |
+| `BILI_ALLOW_DSH_COMPACTION` | `dsh` | {} |
| `BILI_ALLOW_PRIVATE_HTTP_PROVIDERS` | `network.allowPrivateHttpProviders` | false |
| `BILI_AUTO_MODE_FORGE` | `autoModeForge.enabled` | true |
| `BILI_CA_FILE` | `network.caFile` | unset |
@@ -1865,8 +1865,8 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
| `BILI_AFFINITY_SIMHASH` | 设为 `0` 关闭 simhash 链对齐收养(#2265):匿名请求的精确哈希链被客户端侧大面积装饰性改写(如 Trae 切模型后给每条 assistant 消息重打模型标签)打断时,重新挂回既有会话并保留压缩状态,而不是每次新铸会话、从零重折。护栏:覆盖率 ≥90%(Hamming ≤10)、变异位置 ≥20%(单点编辑仍走 fork,#629)、至少一条字节相同的用户消息、双候选歧义拒猜。默认开启。配置文件中设 `"affinitySimhash": false` 效果相同;环境变量优先。 |
| `BILI_RESUME_INHERITANCE` | 设为 `0` 关闭 resume 继承(默认开启)(#1486):当带自有会话 id 的客户端(如 Claude Code 的 `x-claude-code-session-id`)以**新**会话 id 重放完整历史来续接会话时(`cc --resume` 会 fork 出新 UUID),bili 通过字节级前缀匹配(≥8 条消息、append-only 跟踪)识别出它与该客户端已跟踪历史的父子关系,并在续接会话的首个请求上继承父会话的 ref 分配 —— 模型引用的旧代际 refs 因此命中**原始**消息、而不是错配到重新编号的新消息 —— 同时继承源内容完整存在的压缩块(随本继承一并生效,#1834:resume 丢块会导致被折叠原文重新回到线上、上游请求膨胀;旧的 `forkAdoption` 联动门现仅作用于匿名 fork,#629),并记录 `derivedFrom` 血缘。父会话不受影响;新消息在父会话 ref 空间之上继续编号。resume 必须**严格扩展**父历史 —— 同深度的字节级重放(不同 id)视为重复会话而非 resume。匿名会话不受影响(保留自己的 pfa-* 世界,#309)。配置文件中设 `"resumeInheritance": false` 效果相同;环境变量优先。 |
| `BILI_STABLE_SYSTEM_ANCHOR` | 设为 `1` 开启稳定 system 锚定(#1085)—— **wire 层兜底(best-effort)**:根治在客户端(会话历史与指令变更的呈现方式由客户端决定),本开关只是阻止代理因头部变化而使整个已缓存前缀失效。**仅限 plain-proxy 模式**:plugin-mode agent(`x-bili-plugin`)自管上下文、永不参与锚定,避免对已自带 cache-friendly 更新注入的客户端(如 claude-code 的 system-reminder)做双重处理。开启后,bili 按会话记住客户端首次发送的头部 system/instructions 块并持续原样重发。**局部变更**(文件式编辑,与当前生效版本共享 ≥70% 行)追加末尾 `[System context update] …` user 注记,内含紧凑行级 diff(`-` 删除 / `+` 新增;每条注记顺序叠加在前一条之上)。**非局部变更**(结构性重排、tool 定义增删、带时间戳的 banner、超 400 行的头部)直接采用新文本 —— 一次有意的缓存失效好过追加会误导模型的噪声 diff。防抖保护:累积超过 8 条注记同样直接替换锚点为最新文本并清空日志。锚点与注记日志随会话持久化,不受压缩/compaction 影响(session metadata 而非 kernel state)。已知残留限制:客户端自放的 `cache_control` 断点在换头后仍可能错位。不参与锚定的请求:标题生成微请求(OpenAI/Google)、Responses compaction-trigger 请求、auto-mode classifier 请求。客户端自身已实现同类机制(稳定 prompt + 历史内更新)时零额外注入 —— 这类更新作为普通历史透传。默认关闭。配置文件中设 `"stableSystemAnchor": true` 效果相同;环境变量优先。 |
-| `BILI_ALLOW_DSH_COMPACTION` | 设为 `1` 放行 dsh 内置自动压缩(#2028)。默认由 wire 级守卫(#1729)**在本地拒绝 dsh 原生压缩调用**(422),覆盖 bili 服务的全部线路——openai、anthropic、responses(responses 由 #2360 补上:此前的协议白名单在检查标记之前就把 responses 短路了,而 dsh 桌面端的压缩恰好走这条线路,调用因此静默穿过):dsh 的 `compaction-basic` 应对上下文压力时会重放会话前缀、并把固定摘要指令作为最后一条 user 消息发出,此类调用一旦落地,其 checkpoint 会永久覆盖原始历史——不可逆,且摧毁代理的压缩基底。本开关解除该拒绝,让 dsh 原生压缩真正执行。在守卫拒绝期间,dsh 自己的上下文压力计数(原始账本)只增不减——被拒的 checkpoint 永不落地——而 bili 的折叠保持 wire 体积很小,因此会话在客户端仪表显示「已满」之后仍能继续工作,dsh 会不断重新请求压缩(持续被拒)。自 #3384 起,出站输出额度也不再按该原始账本规划——除非 bili 自己的折叠视图已到达强制的 headroom 目标线,或请求的额度达到原生窗口的 25% 及以上(#2490 保护区间);修复前,增长的账本会逐轮悄悄压掉模型的输出额度,在 onlyReasoning 模型上最终表现为无报错的空回复。作用范围:bili 开启时,dsh 原生自动压缩现已在所有平面关闭 —— 宿主平面行经随附 bundle patch(`auto: false`)、web profile 的 preset 实例经 #3354 加载期 overlay —— 因此该开关主要治理非 web profile 的手动 `/compact`(那里的自动触发仍被 `auto: false` 抑制),以及 #3354 overlay 不适用的 dsh 构建上残留的自动触发。网页配置页提供同一开关;环境变量优先于文件。在配置文件的 `"dsh"` 段下设 `"allowDshCompaction": true` 效果相同(旧文件里裸写在顶层的 `"allowDshCompaction"` 会在加载时自动迁移到该位置)。 |
-| `BILI_DSH_AUTHORED_COMPACTION` | 设为 `1` 让 bili **本地应答** dsh 的压缩摘要调用,而不是拒绝它们(#3733)。每次调用的前置条件:#1729 守卫触发(由标记决定)、会话至少持有一个 ACTIVE 折叠块、且 `allowDshCompaction` 未启用(显式的「原生转发」选择始终优先)。应答零出口流量构造(autoModeForge #2740 纪律):一行身份头 `` 加上每个活跃块的内核渲染格式摘要——与模型在上游已读到的字节完全一致,客户端显示、上游上下文与服务端状态首次吻合,dsh 的 checkpoint 文件随之缩小(终结 #3723 的无界增长环)。原始历史随时可经 CCR/导出恢复;落地的检查点在重放时经同一 #2432 rebase 识别(与外部 checkpoint 同路径),但记为 `dshAuthoredCheckpointLanded`(info 而非 warn)。灰度窗口期 env-only(无配置文件键);每请求读取,无需重启。 |
+| `BILI_ALLOW_DSH_COMPACTION` | **#3666 起移除**(取代 #2028)。原开关通过解除 wire 级拒绝(#1729)放行 dsh 内置自动压缩;由于落地的 dsh checkpoint 会永久覆盖原始会话历史——不可逆、摧毁代理的压缩基底——该逃生门已被整体删除:所有 bili 服务的线路上,dsh 原生压缩调用现在一律被无条件拦截,所有构建一致——默认拒绝(422),或在设置 `BILI_DSH_AUTHORED_COMPACTION`(下一行)时由 bili 本地应答。任何遗留取值——`"dsh": { "allowDshCompaction": true }`、旧文件里裸写在顶层的 `"allowDshCompaction"`、或旧环境变量——都会被忽略,并给出一条点名该键的一次性弃用警告。若要彻底避免 dsh 侧 checkpoint 落地,请改用宿主侧抑制:非 web profile 下随附 bundle patch(`auto: false`),web profile 下用 #3354 加载期 overlay 或 #2474 对 preset-standard 的完整快照覆盖。 |
+| `BILI_DSH_AUTHORED_COMPACTION` | 设为 `1` 让 bili **本地应答** dsh 的压缩摘要调用,而不是拒绝它们(#3733)。每次调用的前置条件:#1729 守卫触发(由标记决定;#3651 起无条件)、会话至少持有一个 ACTIVE 折叠块。应答零出口流量构造(autoModeForge #2740 纪律):一行身份头 `` 加上每个活跃块的内核渲染格式摘要——与模型在上游已读到的字节完全一致,客户端显示、上游上下文与服务端状态首次吻合,dsh 的 checkpoint 文件随之缩小(终结 #3723 的无界增长环)。原始历史随时可经 CCR/导出恢复;落地的检查点在重放时经同一 #2432 rebase 识别(与外部 checkpoint 同路径),但记为 `dshAuthoredCheckpointLanded`(info 而非 warn)。灰度窗口期 env-only(无配置文件键);每请求读取,无需重启。 |
| `BILI_NO_CACHE_CONTROL` | 设为 `1` 关闭 bili 在 Anthropic 通道上的 `cache_control` 断点标注(#1637,随 #1639 落地)。默认开启:Anthropic 系上游只缓存被显式打断点的内容(每请求最多 4 个,按 system + tools + 消息块合并计数),因此 bili 会标注 system 块加上至多 3 个累积消息断点——被标注的消息保持标注(前缀字节稳定),断点只随折叠消亡,最近 3 条稳定消息承载推进前沿。客户端自设的任何 `cache_control`(消息块、tools 条目)都会完全抑制 bili 的标注——客户端自管缓存优先。断点随会话持久化。本开关是逃生阀:用于拒绝该字段的上游或有自己断点策略的中继。仅限 plain-proxy Anthropic 通道;OpenAI/Responses 通道隐式缓存,从不标注。配置文件对应项:[`compat.noCacheControl`](#compat) —— 环境变量优先。 |
| `BILI_CHAIN_CONTENT` | 设为 `1` 开启 bili→bili 链感知的 ACP 产物 / `` 检查点**正文内容**检测(#1086/#1421):当入站请求的正文携带压缩产物(渲染标签 / 历史 `acp_status`+`search_context` 工具调用)或带摘要的检查点,但既无 `x-bili-hop` 头、本实例也无该会话的压缩状态时,bili 记录一次告警性观察和/或应用「首个处理器优先」透传。**默认关闭**(#1683 后续):默认下只有 `x-bili-hop` 头驱动链识别,因为扫描请求正文可能把 CCR/文件引入的文本和模型回声标签误判为真实标记。仅在中间盒子剥掉 `x-bili-hop`、且你接受该误判风险的狭窄多 bili 中继场景下才启用。配置文件中设 `"chainContentDetection": true` 效果相同;环境变量优先。`x-bili-hop` 信号本身不受此开关影响。 |
| `BILI_CHAIN_STAMP` | 设为 `1` 开启**模型可见**的 `` 链完整性检查点载体的出站注入(#1683,默认关闭):开启后,本实例实际处理的每个请求都携带一个带摘要的戳,使下游 bili 即使 `x-bili-hop` 头在传输中被剥离也能应用「首个处理器优先」(first-processor-wins)(#1421)。该载体落在终端模型同样会读取的位置(OpenAI/Responses 上是一条尾部 `user` 消息,Anthropic/Google 上是尾部文本 part),因此模型会把它当作幽灵用户输入并花 token 去评论它——这正是它默认关闭的原因。仅在多 bili 中继、且中间盒子剥掉 `x-bili-hop`、带摘要校验的 body-stamp 是防止双重处理的唯一手段这一狭窄场景下才启用。与 `BILI_CHAIN_CONTENT`(入站正文检测同样默认关闭)及 `x-bili-hop` 透传相互独立(后者无论如何都生效)。配置文件中设 `"chainEgressStamp": true` 效果相同;环境变量优先。 |
diff --git a/src/agent/dsh-native.ts b/src/agent/dsh-native.ts
index b8e10413be..12091d5b52 100644
--- a/src/agent/dsh-native.ts
+++ b/src/agent/dsh-native.ts
@@ -2082,7 +2082,7 @@ export function apply(ctx: PluginContext): void {
// trace so a field log can tell "overlay registered" from "profile
// shape unconfirmed".
nonWebTraceLogged = true;
- persistClientEvent("profile bundles do not include @deepseek-ai/dsh-web-app — the #3354 load-time compaction-disable middleware is registered anyway (it rewrites agent-preset compaction-basic/command-compact rows through cordis' version-sensitive internal 'internal/config' hook), but no web-profile disable note applies here; if dsh native auto-compaction still lands in this profile, apply the #2474 full-snapshot override of preset-standard (CONFIGURATION.md) — and remember dsh.allowDshCompaction (#2028), when on, lets such checkpoints through instead of the #1729 wire guard refusing them");
+ persistClientEvent("profile bundles do not include @deepseek-ai/dsh-web-app — the #3354 load-time compaction-disable middleware is registered anyway (it rewrites agent-preset compaction-basic/command-compact rows through cordis' version-sensitive internal 'internal/config' hook), but no web-profile disable note applies here; if dsh native auto-compaction still lands in this profile, apply the #2474 full-snapshot override of preset-standard (CONFIGURATION.md) — and note the #1729 wire guard now refuses such native compaction calls unconditionally (the #2028 allowDshCompaction opt-in was removed in #3651)");
}
}
diff --git a/src/agent/native-intercept.ts b/src/agent/native-intercept.ts
index c8b018beab..c968ed67e3 100644
--- a/src/agent/native-intercept.ts
+++ b/src/agent/native-intercept.ts
@@ -1151,9 +1151,9 @@ export function installNativeFetchIntercept(initialState: NativeInterceptState):
// marker-sniffed POSTs into the proxy's unattributed passthrough
// lane (same stamp the overlay-routed case above uses), where the
// #2709 guard runs the decisive check: refused (422; dsh logs
- // "step compaction failed" and continues the turn) or, with
- // allowDshCompaction (#2028), relayed verbatim by explicit user
- // decision. Everything else — plain traffic, stream bodies that
+ // "step compaction failed" and continues the turn) — the former
+ // allowDshCompaction opt-out was removed (#3666), so the refusal
+ // is unconditional. Everything else — plain traffic, stream bodies that
// cannot be peeked, a dead proxy — keeps #1117's direct semantics.
if (fetchMethodOf(input, init) === "POST" && await dshCompactionMarkerInBody(input, init)) {
const compactionOrigin = await readyOrigin(state);
diff --git a/src/config.ts b/src/config.ts
index 6d26b6e4e0..283f17024a 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -882,36 +882,19 @@ export type ProxyOptions = {
* prefix cache when instruction files (AGENTS.md & co.) change mid-
* session. Default OFF; enable with env BILI_STABLE_SYSTEM_ANCHOR=1 or
* `stableSystemAnchor: true` in the config file (env wins). */
- stableSystemAnchor?: boolean;
- /** #2028: opt-in to letting dsh's built-in auto-compaction (compaction-basic)
- * run through bili instead of being refused by the #1729 wire guard.
- * Default OFF (= guard active): dsh compaction envelopes (final user
- * message = COMPACTION_INSTRUCTION template, ≤4 messages) are refused
- * locally with 422 — bili owns compression on that lane. When ON the
- * call is forwarded and may LAND: a landed checkpoint durably shadows
- * the raw history (irreversible) and destroys bili's compression
- * substrate, which is why this stays off by default. On non-web
- * profiles the shipped bundle patch (`auto: false`) still suppresses
- * AUTO-triggering — only manual /compact benefits there; on web
- * profiles the preset-nested instance is not reachable by id from any
- * bundle patch (#1772), but a profile-layer full-snapshot override of
- * preset-standard can switch it off (#2474); absent that,
- * auto-triggering works as-is. Enable with
- * `{ "dsh": { "allowDshCompaction": true } }` in the config file, or env
- * BILI_ALLOW_DSH_COMPACTION=1. */
- allowDshCompaction?: boolean;
-};
-
-/** #2028: dsh client-lane settings namespace — home for dsh-specific file
- * config so future dsh keys have a section instead of cluttering the root.
-
- * The field below USED to sit at the top level (`"allowDshCompaction": true`) in pre-review drafts;
- * a top-level value in an existing file is auto-relocated here on load
- * (normalizeLegacyAllowDshCompaction) rather than dropped (§7.3).
- */
-export interface DshFileSettings {
- /** Enable with `{ "dsh": { "allowDshCompaction": true } }`; full behavior contract on the FileConfig side. */
- allowDshCompaction?: boolean;
+ stableSystemAnchor?: boolean;
+ };
+
+/** #2028/#3651/#3723: dsh client-lane settings namespace. The former
+ * `allowDshCompaction` escape hatch was REMOVED (#3651) — dsh native
+ * compaction is now refused unconditionally by the #1729 wire guard on every
+ * lane, and a landed checkpoint durably shadows the raw history
+ * (irreversible), so no opt-in remains. The one live key is
+ * `authoredCompaction` (#3723/#3901). Leftover removed keys still sit in old
+ * files: the section stays RECOGNIZED so they don't trip the unknown-key
+ * warning, and each is ignored with a once-per-process deprecation note
+ * (warnRemovedDshAllowKey). */
+interface DshFileSettings {
/** #3723/#3901: bili-authored compaction answers (ON by default since
* the 0.1.203 dogfood window; `false` or env `BILI_DSH_AUTHORED_COMPACTION=0`
* restores the #1729 refusal path). */
@@ -1172,15 +1155,6 @@ export function passthroughState(env: NodeJS.ProcessEnv): { enabled: boolean; so
return { enabled: filePassthrough, source: filePassthrough ? "file" : null };
}
-// #2028: resolved dsh-native-compaction opt-in state shared by loadOptions and
-// the web config API (single source of truth — the GET handler must not
-// re-derive it). Same "0-off" env semantics as the loadOptions line.
-export function allowDshCompactionState(env: NodeJS.ProcessEnv): { enabled: boolean; source: "env" | "file" | null } {
- const fileAllow = loadConfigFile().dsh?.allowDshCompaction === true;
- if (env.BILI_ALLOW_DSH_COMPACTION !== undefined) return { enabled: env.BILI_ALLOW_DSH_COMPACTION !== "0", source: "env" };
- return { enabled: fileAllow, source: fileAllow ? "file" : null };
-}
-
// #1359: provider/model absorb.* overrides apply only to the proxy lane (plugin
// lane follows the base block). Warn once per load so the divergence isn't silent.
const ABSORB_DIVERGENCE_FIELDS = ["enabled", "toolName", "minToolTokens", "contextThresholdPct", "excludeTools", "mediaOnly"] as const;
@@ -1314,6 +1288,13 @@ export function loadOptions(env: NodeJS.ProcessEnv = process.env): ProxyOptions
// override it (env wins for environment-specific overrides).
const fileConfig = loadConfigFile();
+ // #3651: BILI_ALLOW_DSH_COMPACTION no longer exists — surface a stale value
+ // once instead of silently ignoring it (§7.3 honest output).
+ if (env.BILI_ALLOW_DSH_COMPACTION !== undefined && !removedDshEnvWarned) {
+ removedDshEnvWarned = true;
+ loggerLog("warn", "[acp-config] env BILI_ALLOW_DSH_COMPACTION was removed (#3651, superseding #2028) — ignored; dsh native compaction is now refused unconditionally by the wire guard");
+ }
+
// --- Source 2: env vars (highest priority) ---
const port = parseInt(env.ACP_PORT ?? env.PORT ?? `${fileConfig.port ?? 8787}`, 10);
if (!Number.isInteger(port) || port < 1 || port > 65535) {
@@ -1466,9 +1447,6 @@ export function loadOptions(env: NodeJS.ProcessEnv = process.env): ProxyOptions
chainContentDetection: (env.BILI_CHAIN_CONTENT ?? (fileConfig.chainContentDetection === true ? "1" : "0")) !== "0",
chainEgressStamp: (env.BILI_CHAIN_STAMP ?? (fileConfig.chainEgressStamp === true ? "1" : "0")) !== "0",
stableSystemAnchor: (env.BILI_STABLE_SYSTEM_ANCHOR ?? (fileConfig.stableSystemAnchor === true ? "1" : "0")) !== "0",
- // #2028: default OFF keeps the #1729 wire refusal unconditional unless
- // explicitly opted out — see the Options.allowDshCompaction docstring.
- allowDshCompaction: (env.BILI_ALLOW_DSH_COMPACTION ?? (fileConfig.dsh?.allowDshCompaction === true ? "1" : "0")) !== "0",
};
}
@@ -1705,11 +1683,11 @@ type FileConfig = {
/** Set `true` to enable the sticky head-system anchor (#1085, default
* OFF; env BILI_STABLE_SYSTEM_ANCHOR wins). */
stableSystemAnchor?: boolean;
- /** dsh client-lane settings (#2028) — nested under `dsh.*` so future dsh keys
- * get a home instead of cluttering the root; see {@link DshFileSettings}. A
- * legacy bare top-level `"allowDshCompaction"` value is auto-relocated onto
- * `dsh.allowDshCompaction` on load/save (normalizeLegacyAllowDshCompaction).
- * Env BILI_ALLOW_DSH_COMPACTION still wins over the file. */
+ /** dsh client-lane settings — see {@link DshFileSettings}. The former
+ * `allowDshCompaction` escape hatch was removed (#3651); the one live key
+ * is `authoredCompaction` (#3723/#3901). Leftover removed keys stay
+ * recognized (no unknown-key warning) and are ignored with a deprecation
+ * note (warnRemovedDshAllowKey). */
dsh?: DshFileSettings;
/** Global wire-compat block. `roles` maps message roles to the role name
* upstreams accept (e.g. `{"developer":"system"}`) — applied to the
@@ -2061,7 +2039,9 @@ const COMPRESS_SETTING_FIELDS = new Set([
const seenUnknownTopLevelKeySignatures = new Set();
export function warnUnknownTopLevelKeys(obj: Record): void {
- const unknown = Object.keys(obj).filter((key) => !KNOWN_TOP_LEVEL_KEYS.has(key));
+ // #3651: the removed top-level allowDshCompaction key gets its own deprecation
+ // note (warnRemovedDshAllowKey) — exclude it here so it isn't named twice.
+ const unknown = Object.keys(obj).filter((key) => !KNOWN_TOP_LEVEL_KEYS.has(key) && key !== "allowDshCompaction");
if (unknown.length === 0) return;
const signature = [...unknown].sort().join("\u0000");
if (seenUnknownTopLevelKeySignatures.has(signature)) return;
@@ -2131,7 +2111,7 @@ export function loadConfigFile(): FileConfig {
const parsed: unknown = parseBiliConfig(raw);
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
const obj = parsed as Record;
- normalizeLegacyAllowDshCompaction(obj);
+ warnRemovedDshAllowKey(obj);
warnUnknownTopLevelKeys(obj);
warnInertResignPassthrough(obj);
warnInertStripImages(obj);
@@ -2176,27 +2156,30 @@ export function configFileEpoch(): string {
}
-// #2028 relocation: a bare top-level allowDshCompaction predates the dsh.*
-// section (it never shipped beyond preview builds, but hand-saved files may
-// carry it) — carry the value into dsh.allowDshCompaction instead of letting
-// the loader drop it silently (§7.3 never-silently-clobber). A null/missing
-// value is a clear intent (dropped quietly); anything non-boolean is left in
-// place so the unknown-top-level-key warning still names it.
-let warnedLegacyDshConflict = false;
-export function normalizeLegacyAllowDshCompaction(obj: Record): void {
- if (!Object.prototype.hasOwnProperty.call(obj, "allowDshCompaction")) return;
- const legacy = obj.allowDshCompaction;
- if (legacy === null || legacy === undefined) { delete obj.allowDshCompaction; return; }
- if (typeof legacy !== "boolean") return;
- delete obj.allowDshCompaction;
+// #3651: the allowDshCompaction escape hatch (#2028) is GONE — dsh native
+// compaction is refused unconditionally on every lane by the #1729 wire guard.
+// Old values may still sit in config files (top-level legacy position or
+// dsh.*); they are IGNORED — never relocated or rewritten (§7.3) — and named
+// once per distinct shape so the user knows why they do nothing. Deduped per
+// key set like warnUnknownTopLevelKeys: loadConfigFile() runs on every read.
+let removedDshAllowKeySignature = "";
+let removedDshEnvWarned = false;
+function warnRemovedDshAllowKey(obj: Record): void {
+ const hits: string[] = [];
+ if (Object.prototype.hasOwnProperty.call(obj, "allowDshCompaction") && obj.allowDshCompaction !== null && obj.allowDshCompaction !== undefined) {
+ hits.push('top-level "allowDshCompaction"');
+ }
const d = obj.dsh;
- const dObj = d !== null && typeof d === "object" && !Array.isArray(d) ? (d as Record) : undefined;
- if (dObj === undefined) { obj.dsh = { allowDshCompaction: legacy }; return; }
- if (dObj.allowDshCompaction === undefined) { dObj.allowDshCompaction = legacy; return; }
- if (!warnedLegacyDshConflict) {
- warnedLegacyDshConflict = true;
- loggerLog("warn", "[acp-config] both top-level \"allowDshCompaction\" and \"dsh.allowDshCompaction\" present — the dsh.* value wins, the top-level one is dropped");
+ if (d !== null && typeof d === "object" && !Array.isArray(d)) {
+ // authoredCompaction (#3723/#3901) is the one LIVE key in the section —
+ // everything else found here is removed/unknown and gets named.
+ for (const key of Object.keys(d as Record)) if (key !== "authoredCompaction") hits.push(`dsh.${key}`);
}
+ hits.sort();
+ const sig = hits.join(",");
+ if (sig === "" || sig === removedDshAllowKeySignature) return;
+ removedDshAllowKeySignature = sig;
+ loggerLog("warn", `[acp-config] ${hits.join(", ")} was removed (#3651, superseding #2028) — value(s) ignored: dsh native compaction is now refused unconditionally by the wire guard on every lane. Delete it from your config to silence this.`);
}
/** File shape of ONE scheme's `resign` block (see FileConfig.resign). */
interface ResignFileSettings {
diff --git a/src/launcher.ts b/src/launcher.ts
index d131d9cf33..6051b52b73 100644
--- a/src/launcher.ts
+++ b/src/launcher.ts
@@ -72,7 +72,7 @@ function selfDistFile(name: string): string {
return path.join(selfPackageRoot(), "dist", name);
}
import { nonEmpty, resolvePiHome, resolveOmpHome, resolveDshHome, resolveCodexHome, resolveCodexEffectiveView, loadClientConfig, collectModelWindows, collectModelMaxOutputs, type ClientConfig, type CodexConfig, resolveOpencodeConfigFile, readOpencodeConfigRoot, opencodePluginBaseDir, type OpencodeConfig, type OpencodeProvider, type HermesConfig, type HermesProvider, qoderIsCnSite, QODER_DEFAULT_MODEL_HOSTS, resolveTraeHome, readTraeConfig, TRAE_DEFAULT_MODEL_HOSTS, JCODE_DEFAULT_MODEL_HOSTS, type TraeConfig, resolveKimiHome, readKimiConfig, parseKimiToml, KIMI_DEFAULT_MODEL_HOSTS, QWEN_DEFAULT_MODEL_HOSTS, type KimiConfig, type KimiProvider, readOpencodeProjectLayer, type OpencodeProjectLayer, readMcodeConfig, resolveMcodeInstallDir, MCODE_DEFAULT_MODEL_HOSTS, type McodeConfig, discoverAiderArgUrls, AIDER_DEFAULT_MODEL_HOSTS, COPILOT_DEFAULT_MODEL_HOSTS, AMP_DEFAULT_MODEL_HOSTS, CRUSH_DEFAULT_MODEL_HOSTS, ZED_DEFAULT_MODEL_HOSTS, readZedConfig, resolveGooseDirs, readGooseConfig, type GooseConfig, type GooseDirs } from "./client-config.js";
-import { allowDshCompactionState, loadRoutes, resolveConfiguredContextLimit, lookupContextLimit, resolveNativeAttachExternal, resolveNativeAttachLanePriority, resolveNativeAttachPolicy, resolveNativeAttachUrl, resolveMitmDomains, resolveNonHttpProviders, resolveRecordedMitmDomains, type ProviderRoutes } from "./config.js";
+import { loadRoutes, resolveConfiguredContextLimit, lookupContextLimit, resolveNativeAttachExternal, resolveNativeAttachLanePriority, resolveNativeAttachPolicy, resolveNativeAttachUrl, resolveMitmDomains, resolveNonHttpProviders, resolveRecordedMitmDomains, type ProviderRoutes } from "./config.js";
import { discoverMitmDomains } from "./discover.js";
import { contextFromRegistry } from "./registry.js";
import { parseLauncherModelWindows, parseLauncherModelMaxOutputs } from "./server/context-window.js";
@@ -5520,7 +5520,10 @@ export async function runLaunch(params: RunLaunchParams, deps: LauncherDeps = {}
let dshAcpPatch: string | undefined;
if (!dshNativeInstalled()) {
dshAcpPatch = writeDshAcpPatch(dshHomeDir, dshPluginEntry(dshOverlayHome ?? dshHomeDir));
- } else if (allowDshCompactionState(process.env).enabled !== true) {
+ } else {
+ // Unconditional (#3666): the #2028 allowDshCompaction opt-out was
+ // removed, so a native install always leaves dsh compaction armed
+ // behind the wire-level refusal below.
// #2360 §3: native install owns the plugin chain — the overlay patch
// above would insert a SECOND bili-native entry and hard-fail dsh
// boot, and DSH mounts compaction in an agent preset whose nested
diff --git a/src/rollout.ts b/src/rollout.ts
index fe727bc590..d659de6879 100644
--- a/src/rollout.ts
+++ b/src/rollout.ts
@@ -149,7 +149,7 @@ function resolveInternal(feature: string, ctx: RolloutCtx, visited: Set)
});
// Tier 1: env force. "0"/"false" = off, anything else set = on (same
- // family as BILI_PERSIST / BILI_ALLOW_DSH_COMPACTION).
+ // family as BILI_PERSIST / ACP_PASSTHROUGH).
const envRaw = env[rolloutEnvName(feature)];
if (envRaw !== undefined) return decided(envRaw !== "0" && envRaw !== "false", "env");
diff --git a/src/server/admin.ts b/src/server/admin.ts
index 222ad0897b..bd55b664cb 100644
--- a/src/server/admin.ts
+++ b/src/server/admin.ts
@@ -288,13 +288,6 @@ export async function handleAdminRoute(req: http.IncomingMessage, res: http.Serv
}
opts.passthrough = fresh.passthrough;
opts.passthroughSource = fresh.passthroughSource;
- if (fresh.allowDshCompaction !== opts.allowDshCompaction) {
- log(
- fresh.allowDshCompaction ? "warn" : "info",
- `[dsh-compaction] ${fresh.allowDshCompaction ? "dsh native compaction ALLOWED via web config — landed checkpoints durably shadow the raw history (#2028)" : "dsh native compaction interception restored via web config (#2028)"}`,
- );
- }
- opts.allowDshCompaction = fresh.allowDshCompaction;
opts.proxy = fresh.proxy;
opts.proxyMode = fresh.proxyMode;
opts.proxySource = fresh.proxySource;
diff --git a/src/server/budget.ts b/src/server/budget.ts
index e29a132a80..6d8e4c475f 100644
--- a/src/server/budget.ts
+++ b/src/server/budget.ts
@@ -309,9 +309,10 @@ export function clampOutputBudget(requested: number, inputEstimate: number, nati
* raw ledger only grows (refused checkpoints never land), so the max bounds
* every future re-send; decaying the floor would re-open the #2490 kill
* chain. Lifetime ends with the session (metadata eviction). Known
- * conservative residue: flipping allowDshCompaction on mid-session lets
- * checkpoints land and shrink the ledger, but the floor stays at its old
- * high until eviction — fail-closed over-tightening, accepted.
+ * conservative residue: if a checkpoint lands anyway (direct-bypass path;
+ * the #2028 opt-out was removed, #3666) and shrinks the ledger, the floor
+ * stays at its old high until eviction — fail-closed over-tightening,
+ * accepted.
* Note (#3384): recording stays sticky; what changed is APPLICATION — the
* clamp gates where this floor may drive planning (see clampOutgoingOutput),
* so a stale high-water mark can no longer starve a healthy session. */
diff --git a/src/server/dsh-authored-compaction.ts b/src/server/dsh-authored-compaction.ts
index decb9f3127..4ed4683cdf 100644
--- a/src/server/dsh-authored-compaction.ts
+++ b/src/server/dsh-authored-compaction.ts
@@ -22,11 +22,11 @@
// of the landing for ANY checkpoint, authored or foreign.
//
// Precedence at the guard site: authored (this module, knob + active blocks)
-// replaces the DEFAULT refusal only — an explicit allowDshCompaction
-// forward-native choice still wins over authoring, because that is the user
-// asking for dsh's own behavior. The passthrough-lane copy of the guard
-// (handle.ts #1117/#2709 site) has no session and therefore no snapshot to
-// author; it keeps refusing.
+// replaces the default refusal. Since #3651 removed the #2028 allowDshCompaction
+// opt-out there is no forward-native path left to take precedence — calls that
+// do not qualify for authoring fall through to the refusal below. The
+// passthrough-lane copy of the guard (handle.ts #1117/#2709 site) has no
+// session and therefore no snapshot to author; it keeps refusing.
import { renderForgedSummary, buildPromptForgeBody } from "../codex-compact.js";
/** Identity header prefix of an authored checkpoint. Angle brackets
diff --git a/src/server/dsh-compaction-guard.ts b/src/server/dsh-compaction-guard.ts
index 505bd8003a..69e9c7d01b 100644
--- a/src/server/dsh-compaction-guard.ts
+++ b/src/server/dsh-compaction-guard.ts
@@ -266,7 +266,8 @@ const REFUSAL_MESSAGE =
`dsh native compaction call refused by billion-context: bili owns compression on this lane (#1729, cf. #1772/#1206). ` +
`A landed dsh compaction checkpoint durably shadows the raw conversation history, which destroys the proxy's compression substrate. ` +
`No action is needed: your conversation is intact and bili compresses automatically as turns grow too large — if the session is currently over its window, it starts folding on the next turn (#3453). ` +
- `If you still want dsh native compaction on this lane, opt in explicitly: "allowDshCompaction": true in the bili config or env BILI_ALLOW_DSH_COMPACTION=1 (#2028).`;
+ `This refusal is unconditional — the former allowDshCompaction opt-in was removed (#3651, superseding #2028); ` +
+ `to keep dsh-side checkpoints out entirely, apply host-side suppression instead (#3354/#2474).`;
/** Protocol-shaped refusal body (mirrors the #554 side-request guard shape so
* clients render it natively). 422: a policy refusal of this one request — not
diff --git a/src/server/handle.ts b/src/server/handle.ts
index 40f51f9552..1a9def71e6 100644
--- a/src/server/handle.ts
+++ b/src/server/handle.ts
@@ -402,11 +402,12 @@ async function handleRequest(
// gate refuses it INTO this lane — and a verbatim relay below the #1835
// pipeline guard is exactly how 4/49 compaction calls landed in the field
// report (45 were refused through the pipeline). Same refusal, applied at
- // this lane too: marker-decisive (#2193), honors allowDshCompaction
- // (#2028), fail-open on undecodable bodies (#1835 failure direction —
- // relay verbatim, today's behavior). The check decodes only a COPY: the
- // relay still forwards the original bytes with content-encoding intact.
- if (protocol !== null && req.method === "POST" && bodyBuffer.length > 0 && opts.allowDshCompaction !== true
+ // this lane too: marker-decisive (#2193), unconditional (#3651 removed
+ // the #2028 opt-out), fail-open on undecodable bodies (#1835 failure
+ // direction — relay verbatim, today's behavior). The check decodes only
+ // a COPY: the relay still forwards the original bytes with content-
+ // encoding intact.
+ if (protocol !== null && req.method === "POST" && bodyBuffer.length > 0
&& await detectPassthroughDshCompactionCall(protocol, bodyBuffer, headerValue(req, "content-encoding"), async (enc, buf) => (await decodeRequestBody(enc, buf, knobLimitsDecodedBytes(), { signal: decodingSignal, onBytes: (bytes) => admission.observe(bytes) })).body)) {
dshPassthroughGuardStats.refusals += 1;
log("warn", `[passthrough] dsh native compaction call identified on the unattributed passthrough lane (#1117/#2709) — REFUSED, not forwarded: bili owns compression on this lane; a landed dsh checkpoint would durably shadow the raw history (#1729, cf. #1772/#1206). No session exists on this lane, so this log line (not the #2490 ledger) is the record; passthrough refusals so far: ${dshPassthroughGuardStats.refusals}`);
@@ -1834,24 +1835,24 @@ async function handleRequest(
// and destroy the compression substrate. Protocol coverage (#2360):
// openai + anthropic + responses lanes are all marker-decisive — the
// pre-#2360 whitelist short-circuited responses (dsh desktop's actual
- // wire) before the marker was ever examined. Active by default, explicitly
- // opt-out-able (#2028) — auto pressure, overflow recovery, and manual
- // /compact share one envelope, and a landed checkpoint durably shadows
- // the raw history (irreversible), while every cost of refusing is
- // dsh-side, caught, and recoverable; allowDshCompaction lifts the
- // refusal for users who accept that trade. Runs before the #388
+ // wire) before the marker was ever examined. Unconditional (#3651
+ // removed the #2028 opt-out) — auto pressure, overflow recovery, and
+ // manual /compact share one envelope, and a landed checkpoint durably
+ // shadows the raw history (irreversible), while every cost of refusing
+ // is dsh-side, caught, and recoverable. Runs before the #388
// side-request lane: the compaction call is a full-budget request, so
// only this guard can catch it.
- if (protocol !== null && opts.allowDshCompaction !== true && isDshCompactionCall(protocol, parsed)) {
+ if (protocol !== null && isDshCompactionCall(protocol, parsed)) {
// #3733: AUTHORED compaction — when the knob is on and the session
// holds active fold blocks, answer the call LOCALLY with our folded
// snapshot instead of refusing: zero egress (autoModeForge #2740
// discipline), dsh records our tagged checkpoint and its file shrinks
// (#3723), and the recorded content is exactly what the upstream
- // already sees. Replaces the DEFAULT refusal only — an explicit
- // allowDshCompaction (checked above) still forwards natively, because
- // that is the user asking for dsh's own behavior. Undecidable shapes
- // (null forge) fall through to the refusal below.
+ // already sees. Replaces the default refusal only — since #3651
+ // removed the #2028 opt-out there is no native-forward path left:
+ // an authored answer is bili answering the call, never passing it
+ // through. Undecidable shapes (null forge) fall through to the
+ // refusal below.
const authored = dshAuthoredCompactionEnabled() && session.state.blocks.some((b) => b.active)
? buildDshCompactionForgeBody(protocol as "openai" | "anthropic" | "responses", renderDshAuthoredCheckpoint(session), { inputTokens: Math.max(1, Math.round(inboundBytes / 4)), outputTokens: 0 }, (parsed as { stream?: unknown }).stream === true)
: null;
diff --git a/src/server/prepare-anthropic.ts b/src/server/prepare-anthropic.ts
index 8ae162337b..7703ef0315 100644
--- a/src/server/prepare-anthropic.ts
+++ b/src/server/prepare-anthropic.ts
@@ -259,7 +259,7 @@ export async function prepareAnthropic(
// the same session id. The openai/responses lanes rebase on that
// signature (#2432/#2451); this lane had the server-side REFUSAL gate
// but not the post-landing recovery, so any checkpoint landing here
- // (direct bypass, allowDshCompaction, future gate mismatch) left the ACP
+ // (direct bypass, future gate mismatch) left the ACP
// state permanently unrebased — the cannot-be-anchored death spiral plus
// persistent prefix-cache loss (#2596). Same signature+rebase as the
// twin lanes: detection runs BEFORE reconcileFoldCoverage/processTurn;
diff --git a/src/server/prepare-google.ts b/src/server/prepare-google.ts
index 5d8d20d165..cde34d9915 100644
--- a/src/server/prepare-google.ts
+++ b/src/server/prepare-google.ts
@@ -146,8 +146,8 @@ export async function prepareGoogle(
const loopConfig = ccrLoopConfig(session, { ...config, absorb: absorbActive ? absorbBlock : undefined });
// #2432/#2658: same post-landing recovery as the openai/responses/
// anthropic lanes — dsh desktop's native compaction can land without
- // transiting bili (direct-bypass / allowDshCompaction / future gate
- // mismatch); first notice = this request replaying [checkpoint summary,
+ // transiting bili (direct-bypass / future gate mismatch); first notice =
+ // this request replaying [checkpoint summary,
// retained tail…] against the same session id. Before #2658 every lane
// except openai/responses left such a landing unrebased (cannot-be-
// anchored death spiral + prefix-cache loss). Dual signal only:
diff --git a/src/web/api.ts b/src/web/api.ts
index f129abd84a..1f95dfe629 100644
--- a/src/web/api.ts
+++ b/src/web/api.ts
@@ -4,10 +4,8 @@ import { randomUUID } from "node:crypto";
import type { IncomingMessage, ServerResponse } from "node:http";
import { configFile } from "../paths.js";
import {
- allowDshCompactionState,
collectNamedProviders,
loadNamedProviders,
- normalizeLegacyAllowDshCompaction,
parseBiliConfig,
parseCompressSettings,
parseNamedProviderRecipe,
@@ -15,7 +13,6 @@ import {
parseUpstreamProxyMode,
passthroughState,
rejectLegacyRoute,
- type DshFileSettings,
type UpstreamProxyMode,
} from "../config.js";
import { log } from "../logger.js";
@@ -153,7 +150,6 @@ export async function handleConfigGet(res: ServerResponse): Promise {
externalSummaryCredentialStatus: credentialDetail,
agentProviders: agentRegistryStatus(),
passthrough: passthroughState(process.env),
- allowDshCompaction: allowDshCompactionState(process.env),
...(existsSync(configFile()) ? { raw: hideInvalidSummary ? JSON.stringify(config, null, 2) : readFileSync(configFile(), "utf8") } : {}),
...(parseError ? { parseError } : {}),
}, null, 2));
@@ -195,7 +191,7 @@ export async function handleConfigPut(
const hasPassthrough = Object.prototype.hasOwnProperty.call(body, "passthrough");
const hasDsh = Object.prototype.hasOwnProperty.call(body, "dsh");
const hasFile = Object.prototype.hasOwnProperty.call(body, "file");
- if (!hasProviders && !hasProxy && !hasMode && !hasCompress && !hasPassthrough && !hasDsh && !hasFile) return sendError(res, 400, "expected providers, upstream proxy, compress, passthrough, dsh compaction settings, or the full config file");
+ if (!hasProviders && !hasProxy && !hasMode && !hasCompress && !hasPassthrough && !hasDsh && !hasFile) return sendError(res, 400, "expected providers, upstream proxy, compress, passthrough, or the full config file");
// Raw whole-file save (web config card): validate the known fields exactly like the
// structured payload, then replace the ENTIRE config — preserving unknown keys such
// as promptPack/ccr that per-field PUTs cannot touch.
@@ -205,9 +201,10 @@ export async function handleConfigPut(
try {
const p = parseBiliConfig(body.file);
if (!p || typeof p !== "object" || Array.isArray(p)) throw new Error("top level must be a JSON object");
- const rec = p as Record;
- normalizeLegacyAllowDshCompaction(rec);
- next = rec as ConfigShape;
+ // #3666: legacy dsh.* / top-level allowDshCompaction keys are no
+ // longer relocated — whole-file saves preserve them verbatim (the
+ // load path warns once that they are ignored).
+ next = p as ConfigShape;
} catch (error) {
return sendError(res, 400, `file is not valid JSON: ${String(error)}`);
}
@@ -258,12 +255,9 @@ export async function handleConfigPut(
}
if (next.passthrough !== undefined && next.passthrough !== null && typeof next.passthrough !== "boolean") return sendError(res, 400, "passthrough must be a boolean or null");
if (next.passthrough === true && passthroughState(process.env).source === "env") return sendError(res, 409, "passthrough is forced by the ACP_PASSTHROUGH environment variable (or --passthrough flag); unset it and restart to change here");
- const fileDshFlag = ((next.dsh ?? {}) as Partial).allowDshCompaction;
- if (fileDshFlag !== undefined && fileDshFlag !== null && typeof fileDshFlag !== "boolean") return sendError(res, 400, "dsh.allowDshCompaction must be a boolean");
- if (fileDshFlag === true || fileDshFlag === false) {
- const dshForced = allowDshCompactionState(process.env);
- if (dshForced.source === "env" && fileDshFlag !== dshForced.enabled) return sendError(res, 409, "dsh.allowDshCompaction is forced by the BILI_ALLOW_DSH_COMPACTION environment variable; unset it and restart to change here");
- }
+ // #3666: dsh.* settings were removed — whole-file saves preserve any
+ // leftover dsh keys verbatim (the load path warns once that they are
+ // ignored), so there is nothing to validate or reconcile here.
try {
atomicWriteConfig(next);
onChanged?.();
@@ -353,21 +347,11 @@ export async function handleConfigPut(
}
}
- // #2028: same read/clear contract as passthrough (#405) — an env
- // BILI_ALLOW_DSH_COMPACTION outranks the file on every reload, so a
- // contradicting file write would be a silent no-op: refuse with the exact
- // way out instead. A matching write or a clear (null) stays allowed.
+ // #3666: dsh.* settings were removed — the wire guard now refuses dsh
+ // native compaction unconditionally, so any dsh write is rejected loudly
+ // instead of silently ignored (loud-reject rule for user config).
if (hasDsh) {
- const dshBody = (body.dsh ?? {}) as Partial;
- if (dshBody.allowDshCompaction !== null && dshBody.allowDshCompaction !== undefined && typeof dshBody.allowDshCompaction !== "boolean") {
- return sendError(res, 400, "dsh.allowDshCompaction must be a boolean or null");
- }
- if (dshBody.allowDshCompaction === true || dshBody.allowDshCompaction === false) {
- const dshState = allowDshCompactionState(process.env);
- if (dshState.source === "env" && dshBody.allowDshCompaction !== dshState.enabled) {
- return sendError(res, 409, "dsh.allowDshCompaction is forced by the BILI_ALLOW_DSH_COMPACTION environment variable; unset it and restart to change here");
- }
- }
+ return sendError(res, 400, "dsh.* settings were removed (#3651): dsh native compaction is refused unconditionally — delete the key(s) from your config");
}
const config = readConfig();
@@ -385,16 +369,6 @@ export async function handleConfigPut(
if (body.passthrough === true) config.passthrough = true;
else delete config.passthrough;
}
- if (hasDsh) {
- const curDsh = (config.dsh ?? undefined) as Partial | undefined;
- if (((body.dsh ?? {}) as Partial).allowDshCompaction === true) {
- config.dsh = { ...curDsh, allowDshCompaction: true };
- } else if (curDsh) {
- const rest: Partial = { ...curDsh };
- delete rest.allowDshCompaction;
- config.dsh = Object.keys(rest).length > 0 ? rest : undefined;
- }
- }
try {
atomicWriteConfig(config);
onChanged?.();
@@ -406,7 +380,6 @@ export async function handleConfigPut(
if (hasProxy || hasMode) changed.push("network");
if (hasCompress) changed.push("compress");
if (hasPassthrough) changed.push("passthrough");
- if (hasDsh) changed.push("dsh compaction");
log("info", `[acp-web] configuration updated (${changed.join(", ") || "none"})`);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ ok: true, providers: hasProviders && rawProviders ? Object.keys(rawProviders).length : undefined }));
diff --git a/tests/config-surface-guard.test.ts b/tests/config-surface-guard.test.ts
index 3abc2ef6c2..e7dbf041be 100644
--- a/tests/config-surface-guard.test.ts
+++ b/tests/config-surface-guard.test.ts
@@ -24,7 +24,7 @@ test("extractors are not vacuous (golden anchors survive)", () => {
"network.upstreamTimeoutMs",
"persist.enabled",
"sessions.gc.maxAgeDays",
- "dsh.allowDshCompaction",
+ "dsh.authoredCompaction",
"mitm.domains",
"compress.tiers",
"plugin.snapshotCapBytes",
diff --git a/tests/dsh-authored-compaction.test.ts b/tests/dsh-authored-compaction.test.ts
index 2dcfa97a05..c46bc4bfc3 100644
--- a/tests/dsh-authored-compaction.test.ts
+++ b/tests/dsh-authored-compaction.test.ts
@@ -287,7 +287,7 @@ async function withHarness(fn: (h: Harness) => Promise, optsOverride: Part
upstream.closeIdleConnections?.();
await once(upstream, "close");
delete process.env.BILI_DSH_AUTHORED_COMPACTION;
- delete process.env.BILI_ALLOW_DSH_COMPACTION;
+
}
}
@@ -370,19 +370,21 @@ test("e2e: no active blocks → authored mode falls through to refusal", async (
});
});
-test("e2e: explicit allowDshCompaction wins over authored mode (user asked for native)", async () => {
- const allowNative: (h: Harness) => Promise = async (h) => {
+test("e2e: a stale allowDshCompaction=true no longer lifts the guard — authored mode answers (#3666)", async () => {
+ const staleOptIn: (h: Harness) => Promise = async (h) => {
await armBlock(h, "s-allow");
process.env.BILI_DSH_AUTHORED_COMPACTION = "1";
const r = await turn(h, "s-allow", [
{ role: "user", content: `${DSH_COMPACTION_INSTRUCTION_PREFIX} Condense.` },
]);
assert.equal(r.status, 200, r.body);
- assert.ok(h.bodies.some((b) => b.includes(DSH_COMPACTION_INSTRUCTION_PREFIX)), "forwarded natively");
+ assert.equal(h.bodies.filter((b) => b.includes(DSH_COMPACTION_INSTRUCTION_PREFIX)).length, 0, "never forwarded — the removed knob no longer lifts the guard");
const s = h.sessionOf("s-allow")!;
- assert.equal(s.metadata["dshAuthoredCompactions"], undefined, "not authored");
+ assert.equal(s.metadata["dshAuthoredCompactions"], 1, "authored answer stands over the stale value");
};
- await withHarness(allowNative, { allowDshCompaction: true } as Partial);
+ // The key no longer exists on ProxyOptions (#3666); the cast simulates a
+ // stale value reaching options, which the proxy must ignore.
+ await withHarness(staleOptIn, { allowDshCompaction: true } as unknown as Partial);
});
test("e2e: landed checkpoint is recognized on replay — rebase + authored-landed mark", async () => {
@@ -547,6 +549,6 @@ test("e2e: responses wire — authored answer + landed checkpoint recognized on
upstream.closeIdleConnections?.();
await once(upstream, "close");
delete process.env.BILI_DSH_AUTHORED_COMPACTION;
- delete process.env.BILI_ALLOW_DSH_COMPACTION;
+
}
});
diff --git a/tests/issue1815-unknown-top-level-keys.test.ts b/tests/issue1815-unknown-top-level-keys.test.ts
index d65055d3cb..8e3ea49171 100644
--- a/tests/issue1815-unknown-top-level-keys.test.ts
+++ b/tests/issue1815-unknown-top-level-keys.test.ts
@@ -117,7 +117,7 @@ test("#1815: the full documented top-level surface produces no warning (#2062)",
logFile: "", compress: { promptPack: "lean" }, promptCache: {}, mitm: {}, maskHosts: true,
subagentSplit: true, forkAdoption: false, resumeInheritance: true,
chainContentDetection: true, chainEgressStamp: false, stableSystemAnchor: false,
- dsh: { allowDshCompaction: true },
+ dsh: {},
compat: {}, imageBilling: "auto", imageTokenCap: 4096,
resign: {}, claude: { nativePort: 8901 }, native: { attachExternal: false },
network: { upstreamTimeoutMs: 60000 }, persist: { enabled: true },
diff --git a/tests/issue2028-dsh-compaction-toggle.test.ts b/tests/issue2028-dsh-compaction-toggle.test.ts
index 222a86721d..72a580901c 100644
--- a/tests/issue2028-dsh-compaction-toggle.test.ts
+++ b/tests/issue2028-dsh-compaction-toggle.test.ts
@@ -1,9 +1,11 @@
-// #2028: web-configurable dsh native compaction switch (allowDshCompaction).
-// Pins: (a) config resolution matrix (file / env / default), (b) the web API
-// GET/PUT contract incl. the env-forced 409, (c) the end-to-end behavior flip —
-// the #1729 wire guard refuses dsh compaction envelopes by default, forwards
-// them once the switch is flipped ON through the LIVE web API (hot reload),
-// and refuses again once cleared.
+// #2028/#3666: the allowDshCompaction escape hatch is REMOVED — dsh native
+// compaction is refused unconditionally by the #1729 wire guard on every lane.
+// This suite pins the removal contract: (a) legacy file keys (nested dsh.* and
+// the bare top-level position) and the stale env var are ignored, each with a
+// one-time deprecation warning; (b) the refusal message states the
+// unconditional contract with no dead opt-in pointers; (c) the web API no
+// longer exposes the field, rejects structured dsh writes loudly, and
+// whole-file saves preserve leftover keys verbatim (still inert).
import test from "node:test";
import assert from "node:assert/strict";
import http from "node:http";
@@ -13,12 +15,32 @@ import { tmpdir } from "node:os";
import path from "node:path";
import { defaultConfig } from "acp-kernel";
import { startServer } from "../src/server.ts";
-import { allowDshCompactionState, loadOptions, type ProxyOptions } from "../src/config.ts";
+import { loadOptions, loadRoutes, type ProxyOptions } from "../src/config.ts";
import { DSH_COMPACTION_INSTRUCTION_PREFIX, dshCompactionRefusal } from "../src/server/dsh-compaction-guard.ts";
import { SessionStore, _setStoreForTest } from "../src/persist.ts";
import { _setForTest as setRegistryForTest } from "../src/registry.ts";
+import { setLogCapture } from "../src/logger.ts";
import { rmrf } from "./tmp-rm.ts";
+type Captured = { level: string; msg: string };
+
+const REMOVED_MARK = "was removed (#3651";
+const UNKNOWN_KEY_PREFIX = "[acp-config] ignoring unknown top-level config key(s): ";
+
+function removedWarns(captured: Captured[]): Captured[] {
+ return captured.filter((e) => e.level === "warn" && e.msg.startsWith("[acp-config]") && e.msg.includes(REMOVED_MARK));
+}
+
+function unknownKeyWarns(captured: Captured[]): Captured[] {
+ return captured.filter((e) => e.level === "warn" && e.msg.startsWith(UNKNOWN_KEY_PREFIX));
+}
+
+function captureLogs(): { captured: Captured[]; stop: () => void } {
+ const captured: Captured[] = [];
+ setLogCapture((level, msg) => captured.push({ level, msg }));
+ return { captured, stop: () => setLogCapture(null) };
+}
+
/** Point BILI_CONFIG_FILE at a temp file (or a missing path when body is
* null) for the duration of fn, restoring the previous value afterwards. */
function withConfig(body: string | null, fn: () => void): void {
@@ -36,37 +58,75 @@ function withConfig(body: string | null, fn: () => void): void {
}
}
-function envWith(value: string | undefined): NodeJS.ProcessEnv {
- const env: NodeJS.ProcessEnv = {};
- if (value !== undefined) env.BILI_ALLOW_DSH_COMPACTION = value;
- return env;
-}
+test("#3666: legacy dsh.allowDshCompaction file key is ignored with a one-time deprecation warning", () => {
+ const { captured, stop } = captureLogs();
+ try {
+ withConfig('{"dsh":{"allowDshCompaction":true}}', () => {
+ loadRoutes();
+ let warns = removedWarns(captured);
+ assert.equal(warns.length, 1, `expected 1 removal warning, got: ${captured.map((e) => e.msg).join(" | ")}`);
+ assert.ok(warns[0].msg.includes("dsh.allowDshCompaction"), warns[0].msg);
+ assert.ok(!unknownKeyWarns(captured).some((e) => e.msg.includes("dsh")), "the recognized dsh section must not trip the unknown-key warning");
+ loadRoutes();
+ assert.equal(removedWarns(captured).length, 1, "identical key set must not repeat the warning");
+ });
+ } finally {
+ stop();
+ }
+});
+
+test("#3666: the live dsh.authoredCompaction key (#3723/#3901) never trips the removed-key warning", () => {
+ const { captured, stop } = captureLogs();
+ try {
+ withConfig('{"dsh":{"authoredCompaction":false}}', () => {
+ loadRoutes();
+ assert.equal(removedWarns(captured).length, 0, `a live key must not be named in a removal warning: ${captured.map((e) => e.msg).join(" | ")}`);
+ });
+ } finally {
+ stop();
+ }
+});
-test("#2028: allowDshCompaction resolution — file, env, default OFF", () => {
- withConfig(null, () => assert.equal(loadOptions(envWith(undefined)).allowDshCompaction, false, "default OFF (#1729 behavior unchanged)"));
- withConfig('{"dsh":{"allowDshCompaction":true}}', () => assert.equal(loadOptions(envWith(undefined)).allowDshCompaction, true, "file enables (nested dsh.* section)"));
-withConfig('{"allowDshCompaction":true}', () => assert.equal(loadOptions(envWith(undefined)).allowDshCompaction, true, "legacy top-level location still enables (auto-relocated)"));
- withConfig('{"dsh":{"allowDshCompaction":true}}', () => assert.equal(loadOptions(envWith("0")).allowDshCompaction, false, "env 0 beats file"));
- withConfig(null, () => assert.equal(loadOptions(envWith("1")).allowDshCompaction, true, "env 1 enables"));
- withConfig(null, () => assert.equal(loadOptions(envWith("yes")).allowDshCompaction, true, "non-\"0\" env values enable (house BILI_ boolean semantics)"));
+test("#3666: legacy top-level allowDshCompaction gets its own warning, not the generic unknown-key one", () => {
+ const { captured, stop } = captureLogs();
+ try {
+ withConfig('{"allowDshCompaction":true}', () => {
+ loadRoutes();
+ assert.ok(!unknownKeyWarns(captured).some((e) => e.msg.includes("allowDshCompaction")), "removed key must not be flagged as an unknown typo");
+ const warns = removedWarns(captured);
+ assert.equal(warns.length, 1, `expected 1 removal warning, got: ${captured.map((e) => e.msg).join(" | ")}`);
+ assert.ok(warns[0].msg.includes('top-level "allowDshCompaction"'), warns[0].msg);
+ });
+ } finally {
+ stop();
+ }
});
-test("#2028: allowDshCompactionState source resolution", () => {
- withConfig(null, () => assert.deepEqual(allowDshCompactionState(envWith(undefined)), { enabled: false, source: null }));
- withConfig('{"dsh":{"allowDshCompaction":true}}', () => assert.deepEqual(allowDshCompactionState(envWith(undefined)), { enabled: true, source: "file" }));
-withConfig('{"allowDshCompaction":true}', () => assert.deepEqual(allowDshCompactionState(envWith(undefined)), { enabled: true, source: "file" }));
- withConfig('{"dsh":{"allowDshCompaction":true}}', () => assert.deepEqual(allowDshCompactionState(envWith("0")), { enabled: false, source: "env" }));
- withConfig(null, () => assert.deepEqual(allowDshCompactionState(envWith("1")), { enabled: true, source: "env" }));
+test("#3666: stale BILI_ALLOW_DSH_COMPACTION env warns once per process and changes nothing", () => {
+ const { captured, stop } = captureLogs();
+ try {
+ loadOptions({ BILI_ALLOW_DSH_COMPACTION: "1" });
+ let warns = removedWarns(captured);
+ assert.equal(warns.length, 1, `expected 1 env removal warning, got: ${captured.map((e) => e.msg).join(" | ")}`);
+ assert.ok(warns[0].msg.includes("BILI_ALLOW_DSH_COMPACTION"), warns[0].msg);
+ loadOptions({ BILI_ALLOW_DSH_COMPACTION: "1" });
+ warns = removedWarns(captured);
+ assert.equal(warns.length, 1, "env warning is once per process");
+ assert.ok(!("allowDshCompaction" in loadOptions({})), "the option itself is gone from ProxyOptions");
+ } finally {
+ stop();
+ }
});
-test("#2028: refusal message points at the real opt-in (stale preset reference removed)", () => {
+test("#3666: refusal message states the unconditional contract (dead opt-in pointers gone)", () => {
const body = dshCompactionRefusal("openai").body as { error: { message: string } };
assert.ok(!body.error.message.includes("standard-bili-auto-off"), "stale preset reference must be gone");
- assert.ok(body.error.message.includes("allowDshCompaction") && body.error.message.includes("BILI_ALLOW_DSH_COMPACTION"), body.error.message);
+ assert.ok(body.error.message.includes("unconditional") && body.error.message.includes("#3651"), body.error.message);
+ assert.ok(!body.error.message.includes("BILI_ALLOW_DSH_COMPACTION"), "dead env pointer must be gone");
});
// ---------------------------------------------------------------------------
-// Integration: real bili server + real mock upstream, live hot-reload flip.
+// Integration: real bili server + real mock upstream, live web API contract.
function closeServer(server: http.Server): Promise {
server.closeAllConnections?.();
@@ -124,7 +184,7 @@ async function get(port: number, reqPath: string): Promise<{ status: number; bod
return promise;
}
-test("#2028: the web toggle flips the #1729 wire guard live (refuse -> forward -> refuse)", async () => {
+test("#3666: web API no longer exposes or accepts the switch; the guard refuses unconditionally", async () => {
_setStoreForTest(new SessionStore({ enabled: false }));
setRegistryForTest({});
const root = path.join(tmpdir(), `bili-2028-${process.pid}-${Date.now()}`);
@@ -185,74 +245,35 @@ test("#2028: the web toggle flips the #1729 wire guard live (refuse -> forward -
const cfgJson = async (): Promise> => JSON.parse((await get(port, "/__bili/config")).body);
try {
- // A: default — exposed state + wire refusal, nothing reaches upstream.
- assert.deepEqual(await cfgJson().then((c) => c.allowDshCompaction), { enabled: false, source: null });
+ // A: GET no longer exposes the field; the default wire refusal stands.
+ assert.ok(!("allowDshCompaction" in (await cfgJson())), "GET must not expose the removed field");
let r = await compactionPost();
assert.equal(r.status, 422, `default must refuse (got ${r.status}: ${r.body})`);
assert.equal(JSON.parse(r.body).error.code, "dsh_compaction_refused");
assert.equal(received.length, 0, "refused call never reaches the upstream");
- // B: enable through the live web API → hot-forward, byte-exact envelope.
+ // B: structured dsh write → loud 400, file untouched, refusal stands.
r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: true } });
- assert.equal(r.status, 200, r.body);
- assert.equal(JSON.parse(readFileSync(cfgFile, "utf8")).dsh.allowDshCompaction, true, "file gained the key under dsh.*");
- assert.deepEqual((await cfgJson()).allowDshCompaction, { enabled: true, source: "file" });
+ assert.equal(r.status, 400, r.body);
+ assert.match(r.body, /removed/);
+ assert.equal(readFileSync(cfgFile, "utf8"), '{"providers":{}}\n', "rejected write must leave the file untouched");
r = await compactionPost();
- assert.equal(r.status, 200, `allowed call must be forwarded (got ${r.status}: ${r.body})`);
- assert.equal(received.length, 1, "forwarded to the upstream");
- assert.ok(received[0].includes(DSH_COMPACTION_INSTRUCTION_PREFIX), "envelope forwarded byte-exact");
+ assert.equal(r.status, 422, "nothing can lift the guard any more");
+ assert.equal(received.length, 0);
- // C: clear (null) → key removed, guard active again.
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: null } });
+ // C: whole-file save preserves a leftover dsh key verbatim (no
+ // relocation any more) — and the key stays inert.
+ r = await put(port, "/__bili/config", { file: JSON.stringify({ providers: {}, dsh: { allowDshCompaction: true } }) });
assert.equal(r.status, 200, r.body);
- const clearedFile = JSON.parse(readFileSync(cfgFile, "utf8"));
- assert.ok(!clearedFile.dsh || !("allowDshCompaction" in clearedFile.dsh), "key cleared from the file");
- assert.deepEqual((await cfgJson()).allowDshCompaction, { enabled: false, source: null });
+ assert.deepEqual(JSON.parse(readFileSync(cfgFile, "utf8")).dsh, { allowDshCompaction: true }, "leftover key preserved verbatim");
r = await compactionPost();
- assert.equal(r.status, 422, "guard restored after clear");
- assert.equal(received.length, 1, "still refused after clear");
+ assert.equal(r.status, 422, "a preserved legacy key must stay inert");
+ assert.equal(received.length, 0);
- // D: validation errors.
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: "yes" } });
- assert.equal(r.status, 400);
- assert.match(r.body, /must be a boolean or null/);
+ // D: empty-body validation survives the surface shrink.
r = await put(port, "/__bili/config", {});
assert.equal(r.status, 400);
- assert.match(r.body, /dsh compaction settings/);
-
- // E: whole-file save honors the same field.
- r = await put(port, "/__bili/config", { file: JSON.stringify({ providers: {}, dsh: { allowDshCompaction: true } }) });
- assert.equal(r.status, 200, r.body);
- assert.equal(JSON.parse(readFileSync(cfgFile, "utf8")).dsh.allowDshCompaction, true);
- r = await put(port, "/__bili/config", { file: JSON.stringify({ providers: {}, allowDshCompaction: true }) });
- assert.equal(r.status, 200, r.body);
- const relocatedFile = JSON.parse(readFileSync(cfgFile, "utf8"));
- assert.equal(relocatedFile.dsh.allowDshCompaction, true, "legacy top-level key relocated into dsh.* on save");
- assert.ok(!("allowDshCompaction" in relocatedFile), "top-level position no longer present");
- r = await put(port, "/__bili/config", { file: JSON.stringify({ providers: {} }) });
- assert.equal(r.status, 200, r.body);
- assert.ok(!("allowDshCompaction" in JSON.parse(readFileSync(cfgFile, "utf8"))));
-
- // F: env-forced contradiction → 409 (mirrors the #405 passthrough contract).
- process.env.BILI_ALLOW_DSH_COMPACTION = "0";
- try {
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: true } });
- assert.equal(r.status, 409, r.body);
- assert.match(r.body, /BILI_ALLOW_DSH_COMPACTION/);
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: false } });
- assert.equal(r.status, 200, "matching write allowed");
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: null } });
- assert.equal(r.status, 200, "clear allowed under env force");
- r = await put(port, "/__bili/config", { file: JSON.stringify({ dsh: { allowDshCompaction: true } }) });
- assert.equal(r.status, 409, "whole-file contradiction refused");
- process.env.BILI_ALLOW_DSH_COMPACTION = "1";
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: false } });
- assert.equal(r.status, 409, "env=1 forces allow; writing false contradicts");
- r = await put(port, "/__bili/config", { dsh: { allowDshCompaction: true } });
- assert.equal(r.status, 200, "matching write allowed");
- } finally {
- delete process.env.BILI_ALLOW_DSH_COMPACTION;
- }
+ assert.match(r.body, /expected providers/);
} finally {
if (prevConfig === undefined) delete process.env.BILI_CONFIG_FILE;
else process.env.BILI_CONFIG_FILE = prevConfig;
diff --git a/tests/issue2658-dsh-anthropic-google-compaction.test.ts b/tests/issue2658-dsh-anthropic-google-compaction.test.ts
index 4ec8dc77fe..68c23257d4 100644
--- a/tests/issue2658-dsh-anthropic-google-compaction.test.ts
+++ b/tests/issue2658-dsh-anthropic-google-compaction.test.ts
@@ -2,7 +2,7 @@
// (#2432) and responses (#2451) lanes — yet the server-side REFUSAL gate has
// had an anthropic branch all along (dshCompactionRefusal("anthropic")), so
// any checkpoint that LANDS on the anthropic wire (direct-bypass without ALS
-// attribution, allowDshCompaction, future gate mismatch) left the ACP state
+// attribution, future gate mismatch) left the ACP state
// permanently unrebased: cannot-be-anchored death spiral + persistent
// prefix-cache loss (#2596 main complaint). prepare-anthropic.ts now runs the
// same dual-signal detector (dsh-bound session + checkpoint framing in resent
diff --git a/tests/issue2709-passthrough-compaction-guard.test.ts b/tests/issue2709-passthrough-compaction-guard.test.ts
index dac86d1583..27b0ebf979 100644
--- a/tests/issue2709-passthrough-compaction-guard.test.ts
+++ b/tests/issue2709-passthrough-compaction-guard.test.ts
@@ -13,7 +13,7 @@
// 2. ordinary passthrough POST (title-gen shape, marker string only mentioned
// mid-text) → byte-identical verbatim relay (no false positive);
// 3. gzip-encoded marker body → still refused (decode-then-sniff path);
-// 4. allowDshCompaction:true → passthrough compaction relays (opt-out honored);
+// 4. legacy allowDshCompaction opt-in (file/env) → STILL refused (#3666 removed it);
// 5. unparseable body → verbatim relay (fail-open);
// 6. GET passthrough (e.g. /models) → untouched (method gate).
import assert from "node:assert/strict";
@@ -41,7 +41,7 @@ interface Captured {
method: string;
}
-async function startHarness(allowDshCompaction = false): Promise<{ proxyPort: number; upstreamPort: number; captured: Captured[]; close(): Promise }> {
+async function startHarness(): Promise<{ proxyPort: number; upstreamPort: number; captured: Captured[]; close(): Promise }> {
const captured: Captured[] = [];
const upstream = http.createServer((req, res) => {
const chunks: Buffer[] = [];
@@ -74,7 +74,6 @@ async function startHarness(allowDshCompaction = false): Promise<{ proxyPort: nu
promptCache: { routing: "auto" },
compress: { injectTool: false, injectNudge: false },
sessionHeader: "x-acp-session",
- allowDshCompaction,
log: false,
debug: false,
passthrough: false,
@@ -124,8 +123,8 @@ test("#2709: passthrough compaction call is refused 422, never forwarded", async
assert.equal(resp.status, 422);
const text = await resp.text();
assert.match(text, /dsh_compaction_refused/);
- // the refusal must carry the #2028 opt-out instructions like the pipeline guard
- assert.match(text, /allowDshCompaction/);
+ // the refusal must state the unconditional contract like the pipeline guard (#3666)
+ assert.match(text, /unconditional/);
// upstream saw NOTHING — the call must not land
assert.equal(h.captured.length, 0);
// process-level count (no session ledger on this lane)
@@ -171,20 +170,24 @@ test("#2709: gzip-encoded compaction body is still refused (decode path)", async
}
});
-test("#2709: allowDshCompaction:true lets the passthrough compaction relay (opt-out honored)", async () => {
- const h = await startHarness(true);
+test("#2709/#3666: the removed allowDshCompaction opt-in no longer relays (legacy env ignored)", async () => {
+ process.env.BILI_ALLOW_DSH_COMPACTION = "1";
try {
- const body = compactionBody();
- const resp = await fetch(`http://127.0.0.1:${h.proxyPort}/bili/http://127.0.0.1:${h.upstreamPort}/v1/chat/completions`, {
- method: "POST",
- headers: { "content-type": "application/json", "x-bili-passthrough": "1" },
- body,
- });
- assert.equal(resp.status, 200);
- assert.equal(h.captured.length, 1);
- assert.equal(h.captured[0].body, body);
+ const h = await startHarness();
+ try {
+ const body = compactionBody();
+ const resp = await fetch(`http://127.0.0.1:${h.proxyPort}/bili/http://127.0.0.1:${h.upstreamPort}/v1/chat/completions`, {
+ method: "POST",
+ headers: { "content-type": "application/json", "x-bili-passthrough": "1" },
+ body,
+ });
+ assert.equal(resp.status, 422, "legacy env opt-in is ignored — refusal stands");
+ assert.equal(h.captured.length, 0, "still nothing reaches upstream");
+ } finally {
+ await h.close();
+ }
} finally {
- await h.close();
+ delete process.env.BILI_ALLOW_DSH_COMPACTION;
}
});
diff --git a/website/config-reference/server.yaml b/website/config-reference/server.yaml
index ac9daf4c8a..e68a7355d8 100644
--- a/website/config-reference/server.yaml
+++ b/website/config-reference/server.yaml
@@ -342,13 +342,13 @@ entries:
group: behavior
desc_en: "Preserve previous_response_id on kernel-rebuilt Responses requests (default strips it so rebuilt bodies never reference ids the upstream never issued)."
desc_zh: "在内核重建的 Responses 请求上保留 previous_response_id(默认剔除,使重建请求体永不引用上游从未签发过的响应 id)。"
- - key: dsh.allowDshCompaction
- type: boolean
- default: "false"
+ - key: dsh
+ type: object
+ default: "{}"
env: BILI_ALLOW_DSH_COMPACTION
group: behavior
- desc_en: "Lift bili's local 422 refusal of dsh native compaction calls on EVERY wire lane bili serves — openai, anthropic, and responses (#1729/#2028; responses added by #2360, the lane dsh desktop's compaction actually rides): when true, dsh's compaction-basic may execute through bili; its checkpoint durably shadows raw history, so this is an explicit irreversible opt-in."
- desc_zh: "解除 bili 对 dsh 原生压缩调用的本地 422 拒绝——覆盖 bili 服务的全部线路:openai、anthropic、responses(#1729/#2028;responses 由 #2360 补上,正是 dsh 桌面端压缩实际走的线路):为 true 时 dsh 的 compaction-basic 可经 bili 执行;其 checkpoint 会永久覆盖原始历史,属显式的不可逆 opt-in。"
+ desc_en: "Section recognized but its former escape hatch is gone (#3666, superseding #2028): the allowDshCompaction key and the BILI_ALLOW_DSH_COMPACTION env var no longer exist — dsh native compaction is refused unconditionally by the wire guard on every lane. Leftover dsh.allowDshCompaction values are ignored with a one-time deprecation warning; apply host-side suppression instead (#3354/#2474). The one live key, dsh.authoredCompaction, is documented in the next entry."
+ desc_zh: "段仍被识别,但其原逃生门已移除(#3666,取代 #2028):allowDshCompaction 键与 BILI_ALLOW_DSH_COMPACTION 环境变量已不存在——dsh 原生压缩现在在所有线路上被无条件拒绝。遗留的 dsh.allowDshCompaction 取值会被忽略(一次性弃用警告);请改用宿主侧抑制(#3354/#2474)。唯一的存活键 dsh.authoredCompaction 见下一条目。"
- key: dsh.authoredCompaction
type: boolean
default: "true (on, #3901 flip)"