Repository navigation
[PR] fix: refuse coverage-regressing folds before commit (#3322) - #3353
Conversation
A committed fold must never leave a previously-covered message without ANY covering block. On full-resend hosts the kernel's turn-integrity gate judged splits against the fold's own set instead of post-fold coverage, so ids carried by non-consumed sibling blocks were withdrawn from the new block while their source blocks got deactivated - they lost ALL coverage, the processed view doubled (253->519), the local estimate blew past the model window and preflight fail-fasted forever while upstream still had headroom (566K/750K). Add a pre-commit backstop in applyRanges (both relay and plugin lanes share it): measure active-block coverage before vs after on the clone returned by applyCompression; if any previously-covered id loses every covering block, refuse the fold BEFORE committing - state untouched, prefix cache untouched, receipt tells the model why and how to retry. Healthy folds never trip it: fresh folds add coverage, refolds preserve it, integrity withdrawals only touch direct ids of the folded range. Behavior change (disclosed): folds that used to commit while regressing coverage (and then brick the session behind permanent preflight rejections) are now refused with outcome 'refused' / reason 'gate:coverage-regression'. Nothing else changes: the refusal happens strictly before the state commit, so accepted folds, receipts, logs and the #2748 net-shrink gate are untouched. Refs #3322 (root-cause kernel fix follows separately under owner approval).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3956-pr.3353.620dd5bThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3353.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——#3353 是 #3322 在途的唯一修复 PR(floor 9 已纠正此前误链的 #3325);无其他在途 PR 触碰 独立审核(非复读 issue 结论)方向(①):#3322 的根因已在前序会话用最小 fixture 复现钉死(kernel turn-integrity 判定输入错误)。本 PR 定位是「宿主侧提交契约护栏」而非根因修复——这个切分是对的:护栏与 producer 无关、能兜住未来同类 kernel 回归,且完全无决策依赖,按「无决策依赖的部分先修」应当先行;kernel 根治走决策 A 单独声明。方向成立。 代码(③):逐行读过 diff(
回归清点(②)——diff 触碰路径承担的既有行为逐项过:
未发现无意回归。 测试有效性(④):双向钉住,断言有牙。测试 1 若门被移后/弱化 → state 引用变化或 fold 被提交,必红;测试 2 若门过紧(误伤嵌套消费)→ applied 变 refused,必红。monkeypatch diff 整洁度(⑤/⑤b):单 commit,两文件,+155 行,每行都与目的相关;命名达意( 本地验证(f14abb2,worktree 实测)
CI 现状(f14abb2)40 个 check run:0 failure / 0 cancelled;全部静态门绿(static-gates/docs-sync/version-guard/kernel-guard/config-surface-guard/lane-guard/lock-sync/test-import-graph/unused-exports/docs-coverage/plan/gate);仅剩 2 个 test shard 在跑(windows-22#2、ubuntu-24#1),其余 test shard 已绿。base 新鲜(PR head 包含当前 master 745be9f,rebase 干净自动合并)。 结构化八问
行为变更披露(旧→新)
备注
判定:可合并——无拦截项;待剩余 2 个 CI shard 转绿即可(当前 0 失败)。 |
kernel-change: merging existing blocks retracted their own coverage. The turn-integrity gate judged the fold over this unit's ids only and withdrew ids carried solely by the consumed blocks; those blocks deactivate on apply and the new block does not inherit them, so the folded messages lose all coverage and the host pre-commit guard refuses the fold (gate:coverage-regression), causing repeated rejections of legitimate merges. Fix lives in projectUnit's integrity step, scoped to merges (consumedBlockIds > 0); fresh folds keep the legacy behavior verbatim: - judge post-fold coverage as this unit's ids PLUS every still-active sibling block's coverage, so a tool half already covered by an unconsumed sibling reads as folded rather than as a spurious visible half (#3322 facet); - unfold only ids whose coverage does not depend on a consumed block, re-checking to a fixed point; if consistency would force unfolding such an id, fail honestly (split fatal) instead of emitting a doomed regressive candidate. Host coverage guard (src/stream.ts, #3353/#3322) left intact as defense-in-depth. Regression tests: kernel/tests/issue4484-merge-coverage.test.ts (interior hard-protected tool; tail cut mid-tool-group; clean-merge control). Bumps acp-kernel 0.0.161 -> 0.0.162.
Refs #3322
What
A committed fold must never leave a previously-covered message without ANY covering block. On full-resend hosts (compressMessages = raw history, #2627) the kernel's turn-integrity gate judged splits against the fold's own set instead of post-fold coverage: ids carried by non-consumed sibling blocks were withdrawn from the new block while their source blocks deactivated — they lost ALL coverage. Production shape (#3322): one block-range batch stripped ~305 previously-covered ids, doubled the processed live view (253→519), blew the local estimate past the model window (1.65M vs 750K) and bricked the session behind permanent preflight fail-fasts while upstream still had headroom (566K billed).
This PR adds a host-side backstop in applyRanges (shared by relay and plugin lanes): measure active-block coverage before vs after on the clone returned by applyCompression; if any previously-covered id loses every covering block, refuse the fold BEFORE committing — state untouched, prefix cache untouched, receipt tells the model why and how to retry. Healthy folds never trip it: fresh folds add coverage, refolds preserve it, integrity withdrawals only touch direct ids of the folded range.
Behavior change (disclosed)
Folds that used to commit while regressing coverage (then brick the session behind permanent preflight rejections) are now refused: outcome
refused, reasongate:coverage-regression. Refusal happens strictly before the state commit — accepted folds, receipts, logs and the #2748 net-shrink gate are untouched. No config surface changes.Scope note
The root-cause fix lives in the kernel (the judgment input inside projectUnit, #3236 shared-judgment structure) and ships separately under owner approval with a kernel-change declaration. This host gate pins the commit contract regardless of producer and also catches future kernel regressions of the same class.
Tests