Skip to content

fix: port dsh native-compaction single-turn rebase to anthropic + google lanes (#2658) - #2684

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

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

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #2658

是什么问题

#2432 的单轮 rebase 兜底(dsh 原生压缩未经过 bili 落地 → 检测 checkpoint framing + fold coverage 锐减 → 当轮 mark+reconcile)只落在 openai 与 responses 两条线路。anthropic 线路完全没有恢复路径:checkpoint 落地后 ACP 状态永久未 rebase——部分存活的 block、自毁的 fold anchor、之后每次 compress 都 "cannot be anchored"(#2432 死亡螺旋);google 线路同样缺失。

怎么修复的

把 prepare-openai.ts / prepare-responses.ts 的双信号门(同一常量、同一阈值、同一 conflict-ledger 分类)原样移植到 prepare-anthropic.ts 与 prepare-google.ts。anthropic 线路上,当本轮已分类为 dsh native compaction 时跳过既有的 detectUnannouncedHistoryRewrite 块(镜像 openai 线的 !dshRebased 门)——一次事件只记一条(native-compaction),不再旁边多记一条 unannounced-rewrite。

Behavior change disclosure(行为变更披露)

  • 变更前:anthropic/google 线路上,dsh checkpoint 单轮落地后 ACP 状态漂移且永不恢复,后续 compress 全部失败。
  • 变更后:双信号命中(pluginAgent==="dsh" + active block + gap≥8 且 missing*2≥expected + 重放历史含 checkpoint framing)时,当轮执行 markNativeCompactionBoundary + reconcileNativeCompactionBoundary,与 openai/responses 线路行为一致。
  • 不命中的流量:字节级不变(无信号路径全部保持原样;仅信号之一仍走既有路径)。
  • 无配置面变更、无 wire 形状变更、无 kernel/ 变更。

测试证据(本地定向,全量交给 CI)

  • 新增 tests/issue2658-dsh-local-compaction-lanes.test.ts:anthropic /v1/messages 正例、google :generateContent 正例、anthropic 无 framing 负例——3 pass。
  • tests/issue2432-dsh-local-compaction.test.ts 既有 7 例全绿(openai 线路无回归)。
  • tests/fix-1001-history-rewrite.test.ts + tests/conflict-lifecycle.test.ts(被 !dshRebased 门触碰的既有路径)10 pass。
  • npm run typecheck 干净。

Drive-by(独立标注 commit)

第二个 commit 同步 package-lock.json 中滞后的 file-link 版本(acp-kernel 0.0.110→0.0.111、billion-context-pi-subagents 0.1.3→0.1.4),与 master 上 kernel/package.json、pi-subagents/package.json 实际版本对齐;npm install 再生成,无任何依赖或内容变更。

ework-agent added 2 commits October 10, 2026 22:08
…gle lanes (#2658)

The #2432 detector (dsh desktop compaction landing without transiting bili →
checkpoint framing in resent history + decimated fold coverage → mark+reconcile
in-turn) shipped only on the openai and responses wires. On the anthropic wire
a landed checkpoint left ACP state unrebased forever: partially-alive blocks,
self-destructing fold anchors, and every later compress failing 'cannot be
anchored' (the #2432 death spiral); the google wire had the identical gap.

Port the dual-signal gate verbatim from prepare-openai.ts / prepare-responses.ts
to prepare-anthropic.ts and prepare-google.ts (same constants, same thresholds,
same conflict-ledger classification). On the anthropic wire the existing
detectUnannouncedHistoryRewrite block is now skipped when the rewrite was just
classified as dsh native compaction — mirroring the openai lane, so one event
is recorded ('native-compaction'), not two.

Regression tests: tests/issue2658-dsh-local-compaction-lanes.test.ts — positive
rebase e2e per new wire (anthropic /v1/messages, google :generateContent) plus
the no-framing negative on the anthropic wire.
…nd while testing #2658)

npm install regenerated the lock against the in-repo file: devDependencies:
acp-kernel 0.0.110 → 0.0.111, billion-context-pi-subagents 0.1.3 → 0.1.4,
matching kernel/package.json and pi-subagents/package.json already on master.
No dependency or content change.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始 review 这个 PR(anthropic + google 线路的 dsh native-compaction 单轮 rebase 移植)。先拉分支核对代码与 CI,随后按八问体例给结论。

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-10_dsh-rebase-anthropic-lane (5c38ebc)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2887-pr.2684.271cc8b

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-pr2684.tgz
npm install -g package

Install instructions are refreshed on each push.

ranxianglei pushed a commit that referenced this pull request Oct 10, 2026
Drive-by (review of #2684): master's lockfile lags the in-repo component
versions — acp-kernel recorded 0.0.110 while kernel/package.json is 0.0.112
(d16c341), and billion-context-pi-subagents recorded 0.1.3 while
pi-subagents/package.json is 0.1.4. Align both entries to what npm install
writes against current master. No dependency or content change.
@ranxianglei

Copy link
Copy Markdown
Owner Author

Closing as duplicate of #2664 — both PRs implement the same fix for #2658 (porting the #2432 dual-signal dsh native-compaction rebase gate from prepare-openai.ts / prepare-responses.ts to prepare-anthropic.ts and prepare-google.ts). Two review sessions raced on the same issue; per one-issue-one-PR, one survives.

Why #2664 survives:

  • Its suite pins BOTH signal dimensions on BOTH wires (positive rebase · framing-paste-with-intact-history does NOT rebase · gap-without-framing does NOT rebase) plus post-rebase continuity — 6 cases vs this PR's 3, which omits the framing-paste negative entirely (the property that makes the gate dual-signal rather than framing-triggered).
  • CI fully green including the complete test matrix; this PR's matrix was still running at review time.
  • This PR's lockfile-sync drive-by targets acp-kernel 0.0.111, but master has already moved to 0.0.112 (d16c34157) — merging it would leave the lock one version behind again. The intent was salvaged as a corrected commit on the surviving branch (497242d2d: acp-kernel → 0.0.112, pi-subagents → 0.1.4, 2-line diff).

Recorded nuance (no action forced): this PR's anthropic gate omits the !isTitleGen clause present in the openai reference (and in this PR's own google port). The anthropic lane carries no title-gen idiom anywhere else, so omitting it is defensible and I found no functional divergence in realistic traffic shapes (the gate self-defends via its active-blocks requirement — title-gen sidecars fire before any block exists). #2664 instead adds a local max_tokens <= 200 heuristic mirroring the openai semantics. Both readings are acceptable; the surviving PR stands as-is.

@ranxianglei ranxianglei added the duplicate This issue or pull request already exists label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] dsh 原生压缩单轮 rebase 兜底缺失于 anthropic 线路(#2432 修复未覆盖):checkpoint 落地后 ACP 状态永久失效

1 participant