Skip to content

fix: keep Responses turn separators out of fold coverage (#2627) - #2710

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-10_fix-turn-sep-coverage-drift
Oct 11, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-10_fix-turn-sep-coverage-drift

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2627

What

acp_turn_sep_* synthetic separators (inserted by repairResponsesAssistantOrdering, src/server.ts) are OUTBOUND-ONLY ordering markers — no client's resent history ever contains them. On the plugin lane the tool handler handed its mem.processed view (which carries the separators) to the shared executor without compressMessages, so applyCompression resolved compress ranges on the polluted view and wrote separator ids into new blocks' directMessageIds/effectiveMessageIds. Higher folds inherited them via child merge. Every later reconcile pass against the client's raw history then flagged them as permanently "missing": false [acp-drift]/fold-reconcile warns every turn, persisted across restarts, stalling per-block ledger evidence (p+r>=t never accrues).

The proxy-mode relay loop was never affected (it has always passed compressMessages: originalMessages).

Fix — four layers, one invariant: no block coverage may carry outbound-only ids

  1. Source (root fix, plumbing) — src/plugin.ts tool handler now passes compressMessages: mem.original, the same two-view split the relay loop ctx uses (display = processed, compress input = raw). The kernel never sees a separator.
  2. Identity (root fix, caliber) — RESPONSES_TURN_SEPARATOR_ID_PREFIX + isResponsesTurnSeparatorId() shared by the producer and every consumer; coveredRealHistoryIds() is now the single real-history coverage set for the four #1195 pre-turn snapshots, the dsh/codex local-compaction gap calibers, fold-reconcile's covered set, and the per-block ledger t count.
  3. Heal (existing state) — persist.ts mergeState (the only hydration chokepoint) scrubs already-persisted pollution on load, so long sessions stop alarming after upgrade. Block bodies/summaries/archives untouched.
  4. Backstop — stream.ts applyRanges scrubs again post-commit with a count log, covering any unforeseen future path that re-poisons via child-block inheritance.

Behavior change (disclosed, per owner policy)

Separator-only coverage gaps no longer alarm (old: every turn, never escalating, never clearing → new: silent). Real drift detection — content edits, deletions, tool-call-id rewrites — is unchanged and pinned by tests.

Verification

  • tests/issue2627-turn-sep-coverage.test.ts (new, 12 cases): predicate matrix, scrub counts, producer coupling (server.ts emits the shared prefix), a CONTROL case reproducing the old pollution through the real kernel (separator ids entering direct+effective coverage, parent inheriting them), and the healed path (compress against raw history → no separator ids anywhere, real mid-span messages still folded).
  • Adjacent regression batch on the rebased stack: fold-reconcile / issue2297 / issue783 / fix-1061 / fold-round2-shape / issue564 / responses-empty / plugin-agent / issue1195 / issue1328 / issue2432 (dsh local compaction) / plugin-passthrough ×2 / fold-images-archive / decompress-image-ref-dispatch / dsh-native = 212 pass, persist + session suites = 79 pass, wire-contract + golden = 21 pass; tsc -p tsconfig.json clean.
  • No kernel changes, no new config/env, no migration tool (state heals in place on load).

Rebase note

Originally authored as 02840d18 (the bot comment on #2627 linked the wrong PR — #2628 is the unrelated #2621 detector fix). Rebased onto current master: import-union conflicts in prepare-anthropic/google resolved, and the two dsh-local-compaction calibers that master added to the anthropic/google lanes (#2628's lanes) were switched to coveredRealHistoryIds() too — a provable no-op on those wires (separators never exist there) but keeps one caliber everywhere.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-10_fix-turn-sep-coverage-drift (67c811e)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2934-pr.2710.08a4120

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

Install instructions are refreshed on each push.

ework-agent added 2 commits October 11, 2026 08:53
…Ids (#2627)

Review follow-up on this PR, no semantic change: coveredIdsOf re-implemented
the same real-history caliber (active blocks' effective ids minus outbound-only
turn separators) inline instead of delegating to coveredRealHistoryIds, which
the PR body designates as the single source for every drift consumer. Two
implementations of one caliber is exactly the drift vector #2627 is about;
BlockLike is structurally compatible with the shared signature, so the loop
reduces to a call. Behavior identical - pinned by fold-reconcile.test.ts and
issue2627-turn-sep-coverage.test.ts (both green post-change).
@ranxianglei
ranxianglei force-pushed the 2026-10-10_fix-turn-sep-coverage-drift branch from 55ff58d to 7e032d5 Compare October 11, 2026 00:56
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 冲突已解决,rebase 完成,push 至 7e032d5a6

冲突来源与解法

master 在我原 base(a24f6b6)之后合入了 #2695(zombie fold block reap:src/fold-reconcile.ts +105、src/session.ts +70、kernel instance-reid)与 #2707/#2711(cache-proof compaction、lock metadata)。冲突仅一处模式:src/fold-reconcile.ts 的 import 行(两个提交各撞一次,#2695 新增 reapDestroyedSubstrate/recordConflict,本 PR 新增 isResponsesTurnSeparatorId/coveredRealHistoryIds)——按 union 合并,两侧符号全保留。

跨分支语义交互(重点核查项):#2695 的 zombie streak 判据是 2*(p+r) < t,其中 t = ids.length 正是本 PR 改成「过滤分隔符后的 real-history 计数」的那个值。组合后行为严格更准:分隔符 id 永远不可能计入 p/r(客户端重发历史里不存在),若留在 t 里会虚增 missing、在污染会话上可能误触发 reap。即本 PR 的口径修正同时加固了 #2695 的 reap 门禁——两个机制互相受益,无抵消。

透明度说明:push 前发现远端分支已有一个 @ranxianglei 的 merge commit(55ff58df7,merge master 进本分支)。我的 force-push(rebase 线性化)将其替换为 rebase 结果。git diff 55ff58df7..7e032d5a6 确认两者内容唯一差异是 import 行的排版(对方合并成一行,我保留两行各随其源提交),语义完全一致,无任何独有内容丢失。

Rebase 后验证(全部在 rebase 后 head 实跑)

结构化八问(本轮 rebase)

  1. 是什么问题:PR 分支与 master 文本冲突(import 区),merge state dirty。
  2. 什么原因导致的:窗口期内 [Bug][proxy] unframed host-side history deletion leaves zombie fold blocks rendering carriers forever — one carrier flaps in/out every turn (persistent prefix-cache churn) #2695/fix: reap zombie fold blocks after unannounced host history deletion (#2695) + host-compaction cache proofs #2707/fix: sync package-lock.json version metadata + add lock-sync CI guard #2711 先后合入同一组热文件(fold-reconcile/session),与本 PR 的新增 import 在同一行域相撞——典型 stale-base 并发文件竞争,非方案问题。
  3. 影响范围与严重程度:仅本 PR 分支不可合;对已发布版本零影响。
  4. 怎么修复的:rebase 到当前 master,import 取并集;逐点验证本 PR 与 [Bug][proxy] unframed host-side history deletion leaves zombie fold blocks rendering carriers forever — one carrier flaps in/out every turn (persistent prefix-cache churn) #2695 的口径交互(t 计数喂给 zombie streak)方向一致而非互斥。
  5. 是否有回归问题:无。rebase 后定向 191 例全绿(含 [Bug][proxy] unframed host-side history deletion leaves zombie fold blocks rendering carriers forever — one carrier flaps in/out every turn (persistent prefix-cache churn) #2695 自己的新测试);outbound wire 字节不变;display view 未动;reap 门禁因口径修正只会更少误触发,真实 majority-loss 检测不受影响。
  6. 是否破坏缓存:不涉及(prefix cache 相关路径未动;zombie carrier 的 prefix-cache buster 行为由 [Bug][proxy] unframed host-side history deletion leaves zombie fold blocks rendering carriers forever — one carrier flaps in/out every turn (persistent prefix-cache churn) #2695 自身逻辑决定,未被本 PR 改变)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:可合。 mergeable=true,无冲突;behind 的两笔已验证不相交,直接 merge(GitHub merge commit)即可,CI 红了我再定向排查。

@ranxianglei
ranxianglei merged commit 5b65b65 into master Oct 11, 2026
30 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.245-master.5b65b65 (rolling master tag).

npm install -g billion-context@0.0.245-master.5b65b65  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报

1 participant