Skip to content

Compressing two adjacent ranges in one batch makes both sibling blocks claim the same boundary tool pair (live incident: pi session 01a1f6ff) #7429

Closed

Description

@ranxianglei

🤖 Powered by ework · qwen3.8-27b

来源: PR #7428 (#7428) — companion issue recording the live incident that PR fixes (promised in the PR body, filed at review time).

Symptom (live, pi session 01a1f6ff, v0.1.216, 2026-11-20)

The model asked to compress TWO adjacent ranges in one call (the batch seam sits on a tool pair). BOTH sibling blocks (b100/b101) recorded the same two messages in directMessageIds — the compress call's own carrier pair at the seam. Their seq intervals overlapped (4694–4698 / 4697–4698), and a later fold then consumed b101 positionally although b101's ref range (m04513–m04515) lay completely OUTSIDE the newer block's range (m04469–m04511) — the "nested compression" confusion reported in the web UI.

Root cause

The no-overlap contract (no two active sibling blocks may directly claim the same message) was enforced on every path EXCEPT same-batch siblings: the coverage snapshot (collectCoverage) was frozen once before the batch started, so each range's projection judged "already covered" without seeing what an earlier sibling in the SAME batch had just claimed. The batch overlap check compares resolved (pre tool-pair-adjustment) spans, which are disjoint for adjacent ranges — the pair widening happens inside the projection, after the check.

Fix

PR #7428 — refresh the coverage snapshot at the top of the apply loop (first-come-first-served): the earlier range keeps the seam tool pair; the later range shrinks to its own new messages or becomes the #4521 idempotent no-op (warning, not an error; the batch survives). No binary split, no new config knob, no wire/protocol/storage change.

Status

PR #7428 open (kernel, human review tier). Regression test: kernel/tests/regression-batch-seam-double-claim.test.ts (red before / green after; 3 cases incl. the pre-existing-covering-block no-op wording case added at review).


Mirrored from ework issue #7431

Activity

  1. ranxianglei commented on Nov 21, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷

    Duplicate screening (查重): Not a duplicate. The only related items are the fix PR (GitHub #7428) and this companion issue (GitHub #7429 = mirror #7431). No other open issue/PR addresses this same seam double-claim bug.

    Labels: bug p2 pi scope/kernel (kernel ledger-integrity bug in a pi session). Note: I initially applied p1 (cache-ref-rewrite class per owner 2026-10-19), but on reflection the user-visible impact is a display/correctness confusion in the web UI — the session remained usable, there is a workaround (don't batch two adjacent ranges whose seam sits on a tool pair), and the impact is localized. It is not a crash, data loss, session-unusable, or a direct cache leak / stale-cache / unbounded-growth. So p2 (functional defect with workaround + localized impact) is the more accurate class, and it matches the PR's own label.

    Status (verified live just now):

    结构化八问 (structured 8-question review):

    1. 是什么问题: 模型一次调用压缩两个相邻 range(很常见——批接缝正好落在一个 tool pair 上)时,两个兄弟块都声明了共享边界上的那个 tool pair,违反了内核「任意两个 active 兄弟块不得直接声明同一条消息」的不变量。
    2. 什么原因导致的: 每个 range 的投影用来判定「已被覆盖」的 coverage 快照(collectCoverage)在批开始前只冻结了一次(apply 循环里的 const),所以同一批里靠后的 sibling 看不到靠前的 sibling 刚刚声明了什么。批前的 overlap 检查只比较解析后(tool-pair 调整前)的 span,对相邻 range 是互斥的——pair 的扩宽发生在投影内部、检查之后。于是 no-overlap 契约在除「同批 sibling」之外的所有路径上都被执行了。
    3. 影响范围与严重程度: 任何「一次调用压缩两个相邻 range 且接缝落在 tool pair 上」的会话(很常见——fold 自己的 carrier pair 就正好在那)。线上实际影响(pi session 01a1f6ff, v0.1.216):两个兄弟块(b100/b101)直接拥有同两条消息;seq 区间重叠(4694–4698 / 4697–4698);之后的一次 fold 按位置消费了其中一个块,尽管它的 ref 范围(m04513–m04515)完全在新块范围(m04469–m04511)之外——即 web UI 里报的「nested compression」混乱。严重程度:内核账本完整性缺陷(压缩账本的 direct-claims 错了,可能让后续 fold 归错位);会话仍可用,用户可见影响是展示/正确性混乱。p2(有绕行的功能性缺陷 + 局部影响)。
    4. 怎么修复的: 在 apply 循环顶部刷新 coverage 快照(先来先得):靠前的 range 保留接缝 tool pair;靠后的 range 收缩到它自己的新消息——若接缝是它唯一的内容,则退化为既有的 Compression conflict banner (bili v0.1.205, node v24.19.0, win32-x64) #4521 幂等 no-op(warning 而非 error,批和它的 sibling 都存活)。no-op warning 拆成两种措辞:「all covered by active block(s)」(新的同批/既有覆盖情形)vs 原「protected or filtered」(原类逐字保留)。不做任何 range 的二分、不加新配置项、不改 wire/协议/存储。
    5. 是否有回归问题: 未发现回归。原「protected or filtered」no-op 措辞对其原类逐字保留(test 3 钉死);新「all covered」措辞只出现在修复前不可能发生的情形(修复的目的就是让它变成 no-op 而非 double-claim);model-facing 文本变更已按最高优先级标注,且不含模型能锚定传播的数字/ref/计数(无 phantom-value 类),最坏误读(重发同一已覆盖 range)落回同一 no-op,按 Compression conflict banner (bili v0.1.205, node v24.19.0, win32-x64) #4521 设计是 livelock-safe 的;golden wire-contract pin 未动(行为常量、nudge floor/cap、prompts、wire markers 全未变)——36/36 通过;该修复在最后一条绕过路径上恢复了已声明的不变量,不改变其他任何路径的行为。
    6. 是否破坏缓存: 否。修复只改变批内 coverage 快照的刷新方式(一次状态读取,不是缓存失效),不触碰 cache key、重试策略、增量游标或去重键;前缀缓存稳定性不受影响。
    7. 是否改了设计方向: 否。修复恢复的是已声明的「先来先得」sibling-声明设计,只是快照在一批之内变陈旧了;无架构/边界/数据流转向。
    8. 是否引入了新的配置: 否。无新 env、无新 config key、无新默认值。

    判定: 该 companion issue 是对线上事故的完整、准确记录;修复在 PR #7428(open、CI 中、human review tier、已用 Fixes #7429 关联)。本线程无需新的代码改动——交付物即记录 + triage。等待内核 PR 的人工评审。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions