Skip to content

[PR] fix(#2592): rebase dsh native compaction on the Anthropic Messages lane too - #2599

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-10_dsh-compaction-anthropic-lane
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-10_dsh-compaction-anthropic-lane

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Follows #2592 — 本 PR 实现该 issue 机制家族清单中的 F1(Anthropic 车道 framed-detection 接线);issue 已按粒度纪律重组为 F1–F5 清单,未决 facet(F2/F3/F5)留在 issue 线程待 owner 拍板。

是什么

#2436 的 dsh 本地压缩检测器(f48424c41)只接线在 OpenAI 车道;dsh desktop 走 Anthropic Messages 车道(Anthropic 兼容端点,如 deepseek-official)时,宿主本地压缩落地后 ACP state 不 rebase:partially-alive block 引用已消失的 id → nudge 持续广播死 ref(事故现场 m01196–m01362 vs session highest ref=m01191)→ compress 全灭("every ref is unknown to this session")→ 4 连败熔断。本 PR 把同一检测器移植到 prepare-anthropic.ts。

修法

与 openai/responses 车道完全同构(纯接线 + 复用既有路径):

  • 检测点插在 loopConfig 之后、reconcileFoldCoverage/processTurn 之前(与其他车道同一位置、同一理由——先 rebase 再让 processTurn 在压缩后的视图上播种新 ref);
  • 门:metadata.pluginAgent === "dsh"(dsh 插件对所有它讲的 wire 都盖 x-bili-plugin,src/agent/dsh-native.ts headersFor URL 无关)+ 存在活跃 block + carriesDshLocalCompactionSummary(msgs)(checkpoint 定界符谓词,协议无关)+ foldCoverage 缺口 ≥ DSH_LOCAL_COMPACTION_MIN_MISSING(8) 且过半;
  • 命中即 recordConflict("native-compaction") + markNativeCompactionBoundary + reconcileNativeCompactionBoundary 背靠背执行(本回合内完成 rebase),并跳过随后的 模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001 unannounced-rewrite 块(防双记账,与 openai 车道同一守卫)。

anthropic 车道没有 isTitleGen 概念(auto-mode classifier 在更早处 passthrough),故门中不含该子句——与 responses 车道的处理一致。

四车道清点结果(issue 要求,同一 PR 内完成)

车道 状态
openai ✅ f48424c(PR #2436)
responses ✅ db585ef(已在 v0.1.189 内,git merge-base --is-ancestor 验证)
anthropic ❌→✅ 本 PR
google N/A —— dsh 从不讲 Google wire(#2360 证据,dsh-compaction-guard.ts 头注释);检测器在那里是不可能触发的死代码,按 KDD #9 证据许可清单纪律不加。另发现 google 车道从未接线 #1001 通用静默重写检测器(其 applyCompactionArchive 恒为 no-op)——不同机制,已单独立项 #2598(待流量证据 + owner 拍板,不在本 PR 范围)。

行为变更(明示)

  • 旧:dsh 会话经 Anthropic 车道遭遇宿主本地压缩 → 会话压缩能力永久失效(需换会话恢复)。
  • 新:同一事件被识别为「宿主原生压缩」,当回合整体 rebase(kernel state 重置、ref 从 m00001 重播到压缩后视图),随后回合正常追加。这与 openai/responses 车道对同一事件的行为完全对齐——是把坏掉的分支修成与其他三车道一致,不是语义漂移。
  • 非 dsh 绑定会话、无 checkpoint 定界符的缺口、历史完整时的定界符粘贴:均不受影响(三个 negative 测试钉住)。

验证


补充一(评审注意,来自 #2592 线程后续现场证据):同环境同症状的另一份现场日志显示一个不同的生产者——主对话因反复 model/provider 切换迁移到 |sub:<fp> persona fork,宿主盖章的 compress/decompress/acp_status 仍解析在陈旧父 id(KDD #9 身份分裂域;honoring the native caller, refusing the witness (#2024) 行为其标志)。该替代生产者已单独立项跟踪:#2601 。本 PR 修复的未宣告压缩车道缺口仍然真实存在且由测试钉死,但它不覆盖该 fork-migration 形态;原始事故的最终归因取决于事发窗口日志(两个生产者的判别判据见 #2601)。

补充二(2026-10-10,后续现场证据 → 范围澄清):#2592 线程又收到两份新样本,逐条代码核对后确认均不由本 PR 覆盖:(a) 无定界符的全量丢失重写——#2193 升级只观测不行动,而本检测器要求 checkpoint 定界符;(b) #1001 触发并 prune 成功后模型持续重试旧代 ref——receipt 措辞缺口(未告知 ref 空间已重排)。另本轮新发现:rebase 路径(三车道共享的 reconcileNativeCompactionBoundary → resetSessionCompression)不保留 ref 高水位(REF_FLOOR),与 applyCompactionArchive 的 floor pinning 不一致——记入 issue 清单 F5,待 owner 批准;若批准将直接在本 PR 补一个独立 commit 修复。因此本 PR 由 "Closes #2592" 改为 Follows:它只关闭 F1,F2/F3/F5 的处置决定见 issue 线程。

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-10_dsh-compaction-anthropic-lane (a9ddc1d)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2864-pr.2599.c539bdb

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2599.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR review 完成(本 PR 出自 #2592 工作线程,按「识别自己的 PR」规程执行:核对代码 + CI + 回归审查,未重做)。所有验证均为本会话独立复跑,非转述作者声明。

独立验证证据

  • diff:单提交 5f9324da0,仅 2 文件 +337/-3——src/server/prepare-anthropic.ts + 新增 tests/issue2592-dsh-local-compaction-anthropic.test.ts;无 version 变更、无 kernel/、无 lockfile 连带;分支与 master 齐平(merge-base = base sha 8e7bb1294,零落后)。
  • 同构性逐行比对:检测块位置(loopConfig 之后、reconcileFoldCoverage/processTurn 之前)、门条件(dsh 绑定 ∧ 活跃 block ∧ checkpoint 定界符 ∧ gap≥8 且过半)、mark+reconcile 背靠背、if (!dshRebased) 防双记账守卫——与 prepare-openai.ts:142-152 / prepare-responses.ts:219-241 完全一致。openai 车道多出的 !isTitleGen 子句在 anthropic 车道确实不需要:classifier 请求在 prepare-anthropic.ts:56 更早 passthrough return,到不了检测点(已核实代码路径);responses 车道以 !isCompactionTrigger 为对应门,三者各自自洽。
  • 本地定向测试(PR head):新套件 5/5、issue2432 openai 回归 7/7、anthropic-pck-verbatim + dsh-persona-continuity 8/8,共 20/20 绿;typecheck 干净、build 干净(build-info commit=5f9324da0)。
  • A/B 复现:临时检出 master 版 prepare-anthropic.ts 后跑正向 e2e → 失败(AssertionError expected 0 actual 1:压缩回放后 block 未重置)→ 还原。回归测试有牙,钉得住原 bug。
  • CI:26 项检查 0 失败,余 2 项在途(test windows-latest 22/24 两腿);e2e、registry e2e、各 real-client 车道全绿。
  • 四车道清点复核:db585effe(responses 车道修复)经 git merge-base --is-ancestor 确认已在 master 内;google N/A 的论据(bili 插件模式下 allowDshCompaction 在 responses 线路上完全失效 —— DSH 原生压缩落地、折叠基底被摧毁、compress 连片失败 #2360:dsh 不讲 Google wire)成立;[Bug] Google 车道从未接线 #1001 unannounced-history-rewrite 检测——applyCompactionArchive 在该车道恒为 no-op #2598(google 车道从未接线 模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001 通用重写检测)确认已立项且 open——不同机制家族,拆分合规。

结构化八问

  1. 是什么问题:dsh desktop 走 Anthropic Messages 车道时,宿主本地压缩落地后 ACP state 永不 rebase——partially-alive block 引用死 id,nudge 持续广播不可解析 ref,compress 全灭直至熔断,整会话压缩能力失效。
  2. 什么原因导致的:fix: dsh 原生压缩落地的单 turn rebase + 熔断 cause-aware 化与表面可见(#2432) #2436 的检测器提交 f48424c 只接线 prepareOpenai,对 anthropic/google/responses 零改动;谓词与阈值在 dsh-compaction-guard.ts 里本就是协议无关的,所以这是纯车道覆盖缺口而非检测器逻辑错误。机制链与 [bug] DSH 桌面端 0.1.188:宿主原生压缩落地摧毁折叠基底 → 同一区间永久不可锚定、compress 连片失败并熔断(compaction-basic auto:false 仍无效) #2432 同构(未宣告改写落地 → syncBlocks 保留 partially-alive block → nudge 枚举死 ref → kernel 拒绝 → 循环至熔断)。注:[Bug] #2436 的宿主本地压缩检测只接在 OpenAI 车道,Anthropic 车道缺失——未宣告宿主压缩后 nudge 广播的 compress ref 永久不可解析 #2592 讨论中曾提出 M1/M2/M3 备选假设,但车道缺口本身由四车道实现 diff 客观证明,事故签名与其吻合——即便事发日志日后揭示叠加因素,那也是另一机制,不削弱本修复的正当性。
  3. 影响范围与严重程度:所有走 Anthropic Messages 车道的 dsh 插件用户(含 deepseek-official 等兼容端点),触发条件=会话有活跃 ACP block 且宿主实际执行了本地压缩;特定条件下整会话压缩能力失效(proxy 转发正常、无数据丢失、换会话可恢复)。
  4. 怎么修复的:纯接线移植——在 anthropic 车道同一位置插入与其他三车道同构的检测+当回合 rebase 块,全部复用既有 recordConflict/mark/reconcileNativeCompactionBoundary 路径,命中时跳过 模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001 通用重写块防双记账。无新机制、无新谓词、无新阈值。
  5. 是否有回归问题:无。逐项过改动路径承担的既有行为:非 dsh 绑定会话(pi 负例钉住)、无定界符的缺口(nomarker 负例)、历史完整时的定界符粘贴(paste 负例)均不受影响;openai 车道行为不变(issue2432 7/7);anthropic 车道既有行为不变(pck-verbatim + persona-continuity 8/8);其余三车道文件零触碰。唯一行为变更即 PR 正文明示的那条(旧:漂移至熔断 → 新:当回合 rebase),是把坏分支修成与其他三车道一致,非语义漂移。reconcileNativeCompactionBoundary 返回 false 时回落到原 模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001 路径(保守方向),守卫安全。
  6. 是否破坏缓存:不涉及。rebase 语义与 openai/responses 车道路径完全一致;head-system anchor、prefix cache、重试策略均在改动面之外。
  7. 是否改了设计方向:没有——把第四车道拉齐到既有方向;google 车道按 KDD release v0.1.2 #9 证据许可清单纪律不加死代码,发现的 模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001 缺口单独立项 [Bug] Google 车道从未接线 #1001 unannounced-history-rewrite 检测——applyCompactionArchive 在该车道恒为 no-op #2598。
  8. 是否引入了新的配置:无。

diff 整洁度:每一行都与本 PR 目的相关;注释全部携带 issue 溯源引用;无空行/重排噪音。

判定:可合。 待余下 2 个 Windows test 矩阵腿转绿即可合并(全局回归由 CI 把关,定向验证已全部通过)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 全绿确认:26/26 检查通过(含此前在途的 test windows-latest 22/24 两腿),0 失败。上一条 review 的合并条件已满足——PR #2599 可合并,合并动作留给人工(系统规则禁止 agent merge)。

awork and others added 2 commits October 10, 2026 18:20
…ne too

The #2432 dsh local-compaction detector (f48424c) landed on the OpenAI
lane only. A dsh desktop session riding the Anthropic Messages lane
(Anthropic-compatible endpoints) hit the pre-#2432 death spiral when dsh
compacted locally: the first replay of [checkpoint summary, retained
tail...] against the same session id left the ACP state unrebased —
syncBlocks kept partially-alive blocks whose dead refs the nudge kept
broadcasting, every later compress failed ("every ref is unknown to this
session"), and the compress circuit breaker armed after four consecutive
failures (#2592 repro, bili 0.1.189 / DSH Desktop 0.2.0-rc.2).

prepare-anthropic now runs the same detection as the openai/responses
lanes: dsh-bound session (metadata.pluginAgent === "dsh") + checkpoint
framing in resent history (carriesDshLocalCompactionSummary) + decimated
fold coverage (missing >= DSH_LOCAL_COMPACTION_MIN_MISSING and >= half
the covered set) -> markNativeCompactionBoundary + reconcile back-to-back,
re-seeding refs onto the compacted view in the SAME turn. The #1001
unannounced-rewrite block is skipped when the dsh detector already rebased
(same double-record guard as the openai lane).

Lane inventory (same PR): responses already fixed (db585ef, in
v0.1.189); google — dsh speaks no Google wire (#2360 evidence), so the
dsh detector cannot fire there. The google lane's separate missing
generic #1001 detector coverage is tracked in #2598.
…xt guard contract

Rebased onto current master, where f9d3a0f (#2621) tightened
carriesDshLocalCompactionSummary to role=user TEXT messages only
(quotes of the checkpoint framing from assistant prose / reasoning /
tool results / compress echoes must not fire the detector). This
port's call site passes the normalized BiliMessage array, so it
inherits the gate automatically — no src change needed.

The unit test pinned the pre-#2621 contract (role-less bare shapes
reading true); under the tightened gate those shapes read false by
design (safe-miss direction). Updated to pin the anthropic wire
shape against the CURRENT contract: user-text block arrays still
match, an anthropic-lane tool result (role=user,
contentType=tool-result) quoting the marker reads false.

Verified on the rebased head: typecheck clean, build clean, 22/22
across issue2592-anthropic + issue2432 (#2621 cases included) +
anthropic-pck-verbatim + dsh-persona-continuity.
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

陈旧票清理(第三批动作①):目标 issue #2592 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。

@ranxianglei ranxianglei changed the title fix(#2592): rebase dsh native compaction on the Anthropic Messages lane too [PR] fix(#2592): rebase dsh native compaction on the Anthropic Messages lane too Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant