Skip to content

kernel: 已消费但非重折叠的压缩单元不再被推荐——推荐端与执行端对同一形状意见一致 - #3381

Merged
ranxianglei merged 2 commits into
masterfrom
fix/kernel-screen-nonrefold-units
Oct 16, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
fix/kernel-screen-nonrefold-units

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

ai: zhipuai-lb/glm-5.3

kernel-change: screen consumed non-refold units out of recommendations so the recommend lane cannot advertise a range the apply lane is guaranteed to reject (#3371, owner-approved in-issue)

什么坏了(#3371)

压缩分两端,推荐端(screenRecommendedUnits)决定给模型推荐哪些压缩区间,执行端(applySingleRange)决定提交后能不能真压。有一种形状两端意见相反:区间内没有任何新消息、整个区间都已被某个活跃折叠块占有,但该块不是行内还原状态(未 restoredInline)。

  • 执行端对这种形状必然拒绝——防死循环守卫(billion-context-pi#199)抛 "Range .. contains no new compressible messages";只有当 evaluateRefold 认定它是合法的 fix: isolate side requests (title-gen) from main session kernel state #398 就地重折叠(区间内所有块已行内还原、祖先链完整)才放行。
  • 推荐端原来照样推荐它(筛选只排掉 filteredIds 和 consumedBlockIds 双零的形状)。

结果是:推荐 → 拒绝 → 状态没变 → 再推荐 → 再拒绝,模型被卡在死循环里——这正是 #3236 立项要消灭的循环,穿过最后一个没堵的形状活着。

修复

  1. evaluateRefold + requestedRefoldSpan + RefoldDecision 逐字从 compress.ts 提取到新模块 kernel/src/refold.ts,推荐端和执行端从此查同一份判定——与 [Bug] recommend/apply 对同一区间的 turn-integrity 判定永久不一致:acp_status 反复推荐的区间被 apply 侧整段拒绝(0.1.196,Range would split N turn(s) at the protected-zone boundary) #3236 把 projectUnit 提取为单一投影同一纪律。
  2. 推荐端镜像执行端守卫:filteredIds===0 && consumedBlockIds>0 && !isBlockBoundary 的单元只有 evaluateRefold 判 "refold" 才保留;真重折叠(fix: isolate side requests (title-gen) from main session kernel state #398)照常推荐,块边界区间(bN..bM 提升/合并)照常豁免——与执行端完全同构。
  3. 无公共 API 变化,golden ledger 未动。

顺带:kernel 版本 0.0.126 → 0.0.127,并重新生成 kernel/package-lock.json——它已漂移到 0.0.123(六次版本 bump 没重新生成,#3331 审查 C-H1),干净 checkout 上 npm ci 会挂。此 PR 一并修正。

测试

  • kernel 套件 1279/1279 全绿,含新 fixture kernel/tests/issue3371-consumed-unit-screen.test.ts:①坏形状被筛掉且执行端同意见(拒绝信息正是 livelock 守卫);②真重折叠仍被推荐且执行端就地把 b1 更新(摘要换新、还原标记清除、不建新块);③新消息区间不受影响(无过度筛选)。
  • bili 侧:compress-reject-reasons 4/4、compress-recovery-ranges 10/10、e2e-compress-cascade 7/7、根 tsc 干净。

Kernel Boundary 合规

来自 #3331 区间审查(C-M1)。Closes #3371。

screenRecommendedUnits advertised a message-ref unit whose entire span
is already owned by an active, NOT restored-inline block — the exact
shape applySingleRange's livelock guard (pi#199) is guaranteed to reject
('Range .. contains no new compressible messages'), unless the #398
refold verdict classifies it a genuine in-place refold. Recommend and
apply disagreed on one shape: advertise -> reject -> re-advertise, the
#3236 loop family reached through the consumed-unit corner.

The verdict (evaluateRefold + requestedRefoldSpan + RefoldDecision) moves
verbatim from compress.ts to refold.ts so both lanes consult the SAME
definition — the projectUnit discipline. The screen now mirrors the
apply-side guard exactly: filteredIds === 0 && consumedBlockIds > 0 &&
!isBlockBoundary survives only when evaluateRefold says 'refold'.
Block-boundary units (bN..bM promote/merge) stay exempt, same as apply.
No public kernel surface change; the golden ledger is untouched.

Also bumps kernel to 0.0.127 and regenerates package-lock.json, which
had drifted to 0.0.123 through six version bumps (#3331 review C-H1) —
npm ci in a clean checkout would have failed.

Kernel boundary: owner-approved via #3371.

Tests: kernel suite 1279/1279 incl. new issue3371 fixture (screened-out
shape + apply agreement, genuine refold stays advertised and updates b1
in place, fresh spans unaffected); bili-side compress-reject-reasons 4/4,
compress-recovery-ranges 10/10, e2e-compress-cascade 7/7; root tsc clean.

Closes #3371
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/kernel-screen-nonrefold-units (7fe214b)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3988-pr.3381.ef2d103

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-pr3381.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] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 本 PR 是 #3371(来自 #3331 区间审查 C-M1)的修复 PR。open PR 里扫过同域(refold / recommend 筛选):#2785(overflow refold 采纳 Prepared)、#3353(coverage-regressing fold 拒绝)、#3141(empty view DEAD refs)——症状与机制均不同,无并行修复同一形状的死循环。

开始正式 review:拉分支、核对 diff、跑定向测试、查 CI,随后按八问出结论。

)

The #3371 fix bumped kernel/package.json 0.0.126 -> 0.0.127 and regenerated
kernel/package-lock.json, but the ROOT package-lock.json still recorded the
linked kernel entry at 0.0.126 — the lock-sync gate (npm install
--package-lock-only + git diff) fails on exactly that line, which cascades
skips into every test leg (needs: lock-sync). Regenerated with
npm install --package-lock-only; single-line change.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

PR #3381 审核完成——可合(kernel 变更按规矩留人类合并)。审核独立重做:diff 逐文件读了改动前/后两侧代码,行为清单按既有行为逐项清点,不是复读 issue 结论。

结构化八问

  1. 是什么问题:有一种压缩区间形状——区间内没有新消息、整段被活跃折叠块占有、且该块未行内还原——推荐端会推荐它,执行端必然拒绝(防死循环守卫抛 contains no new compressible messages),模型被卡在「推荐→拒绝→状态不变→再推荐」的循环里。这是 [Bug] recommend/apply 对同一区间的 turn-integrity 判定永久不一致:acp_status 反复推荐的区间被 apply 侧整段拒绝(0.1.196,Range would split N turn(s) at the protected-zone boundary) #3236 要消灭的循环穿最后一个没堵的形状活着。
  2. 什么原因导致的:「是不是合法就地重折叠」的判定(evaluateRefold/requestedRefoldSpan)原本私有在 compress.ts(执行端)里,推荐端没有查它、自己判同一形状时只排掉了 filteredIds/consumedBlockIds 双零的单元。两端对同一形状各持一份意见,分歧就是缺陷本身。
  3. 影响范围与严重程度:触发需同时满足「单元全部由已消费块覆盖 + 无新消息 + 非块边界 + 非真重折叠」。后果是功能性卡死(livelock),不是数据损坏或 wire 污染;kernel: recommend screen misses the apply-side throw — last shape of the permanent advertise→reject loop may survive on pruned hosts | kernel:#3236 筛选未建模 apply 侧 throw,pruned host 上可能复活「永久 advertise→reject 死循环」的最后一个形状 #3371 原文也承认可达性未经流量证实、也没有测试证明不可达。严重度:特定条件下的会话级卡死。
  4. 怎么修复的:把三个符号逐字提取到 kernel/src/refold.ts,推荐端镜像执行端守卫——同一谓词(filteredIds===0 && consumedBlockIds>0 && !isBlockBoundary)加同一个 evaluateRefold 判定,判「refold」才保留。真重折叠照常推荐、块边界区间(bN..bM 提升/合并)照常豁免,与执行端完全同构。修的是「两份判定」这个根因,不是在推荐端再叠一层症状过滤。
  5. 是否回归:无。逐项清点的既有行为:screenRecommendedUnits 唯一调用方是 compress.ts:1012,新增排除只命中「执行端保证拒绝」的形状,任何原先会被接受的区间都不受影响(refold.test 48/48、issue3236-recommend-apply-consistency、recommend.test 全绿);compress.ts 是纯搬移,执行路径语义不变(compress-reject-reasons 4/4、bili 侧 21/21 全绿);golden ledger / wire-contract 零改动;公共 API 面不变(refold.ts 不在 kernel exports map .//wire//panel//persist 里,index.ts 也未 re-export);配置面零变化(config-surface-guard 绿)。一处潜在不对称我核过:两端各自在自己数组类上跑 projectUnit(KDD refactor: reapOrphanBlocks should live in acp-kernel, not the proxy #12 的 applyView 机制已存在并对齐),本 PR 只是在其上叠加同一共享判定,不引入新的分歧域。
  6. 是否破坏缓存:不涉及——纯推荐/拒绝内部逻辑,不动 wire 格式、前缀缓存、会话持久化。
  7. 是否改了设计方向:不转向。是 [Bug] recommend/apply 对同一区间的 turn-integrity 判定永久不一致:acp_status 反复推荐的区间被 apply 侧整段拒绝(0.1.196,Range would split N turn(s) at the protected-zone boundary) #3236「资格判定与执行共用单一投影」纪律的自然延伸(projectUnit 之后,refold 判定也收敛成一份)。
  8. 是否引入了新的配置:无。

证据(本地定向验证,非全量预跑)

  • 复现钉死:新 fixture 拷到 master worktree 跑,test 1 失败(master 上坏形状仍被推荐);PR 分支 3/3 通过。fixture 真抓 bug,不是恒真测试。
  • 本地定向:kernel 侧 issue3371+refold+recommend+issue3236 共 48/48;bili 侧 compress-reject-reasons 4/4、compress-recovery-ranges 10/10、e2e-compress-cascade 7/7。
  • 远程 CI(head 7fe214bfe):全部绿——6 条核心 test lane(ubuntu22×3、ubuntu24×1、windows22×2)+ 全部门禁(kernel-guard/version-guard/lock-sync/unused-exports/config-surface-guard/docs-sync/build-artifact/static-gates),e2e 真实客户端 lane 按 path 门设计跳过。

审核中发现并已修的问题(独立标注 commit)

原 head 3649e24a1 上 lock-sync CI 红:PR 把 kernel 版本 bump 到 0.0.127 并同步了 kernel/package-lock.json,但根 package-lock.json 里的 file-link 记录还停在 0.0.126,lock-sync 门禁(regenerate + git diff --exit-code)必挂,且按 ci.yml 的分层 fail-fast 连带跳过全部 6 条核心 test lane——即 PR 描述里的「两层测试全绿」在 GitHub 上其实没跑到。已在 PR 分支直接补 1 行修复并推送:commit 7fe214bfe(仅根 package-lock.json 一行,kernel 记录 0.0.126→0.0.127),上述全绿 CI 即在该 head 上取得。此问题与 #3331 审查 C-H1 同源(lock 漂移),属 PR 自身遗漏而非范围外发现,故顺手修掉不再单开 issue。

收工判定

方向对(修根因不修症状)、方案与执行端同构、回归清单干净、测试有牙且复现钉死、CI 全绿。建议合并;kernel 变更按 Kernel Boundary 第 3 条由人类执行合并,合并后 #3371 自动关闭。

@ranxianglei
ranxianglei merged commit 73d9360 into master Oct 16, 2026
42 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.494-master.73d9360 (rolling master tag).

npm install -g billion-context@0.0.494-master.73d9360  # 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

1 participant