Skip to content

kernel: selector screens live carriers; withdrawal judged on original array class (#2663) - #2669

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-10_kernel-live-carrier-screening
Oct 11, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-10_kernel-live-carrier-screening

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #2663

kernel-change: advertise/validate disagreement lives INSIDE the kernel — buildCompressibleRanges (selector) and applySingleRange (apply gate) judge different array classes and lacked carrier awareness; the host side cannot express this screening (no access to the pruned-vs-original view split or the apply-side carve order). Owner-approved via #2663 (owner-opened issue stating why host-side cannot solve it, with explicit fix direction).

What changed

One failure domain — every advertised range must be foldable:

  1. Live checkpoint carriers are screened in the selector (state.ts shared isLiveCheckpointCarrier predicate + recommend.ts gap+skip, same shape as the existing integrity-withdrawal screening). A carrier of an ACTIVE block (fix: detect codex compaction requests before preflight; verbatim passthrough when not intercepted (#332) #335) sits outside that block's coverage on purpose and survives pruning; a span bridging over it drags the covering block in as consumed coverage while every direct message gets carved out → zero foldable messages → livelock guard threw EVERY turn ([Bug][preflight] range selector re-nominates a fully-folded span every turn — permanent "no new compressible messages" rejection loop + nudge churn #2638 production: spans like m00018..m00242 re-nominated+rejected per request on DSH/full-log hosts). Stale carriers (block inactive/unknown) still fold normally.
  2. Integrity withdrawal is judged on the original array class (pipeline.ts effects.originalMessages, stashed by the prune node; recommend.ts new optional integritySource param, default = passed array for external callers). Turn grouping and call/result pairing are array-dependent; the selector previously computed withdrawals on the pruned view while the apply gate computes them on the full resent log.
  3. acp_status UNCOMPRESSED rows open a gap at live carriers (report.ts) so no reported range bridges across one; the carrier stays listed as visible mass. The primary Compressible-ranges table follows change 1 automatically.

Rebase note (#2607 interaction)

Rebased onto current master after #2607 (fold archivable media like text) landed. The originally drafted blanket media carve was DROPPED: filterProtectedToolMessages already enforces the #1188 never-fold exemption for unrecoverable payloads (and removes them from effectiveMessageIds via the Bug-39 block), so the extra carve was redundant — and under #2607's split it would have wrongly re-pinned archivable inline media. Media handling is untouched by this PR; the new test pins both directions of the #2607 split (archivable folds like text; unrecoverable stays pinned) as regression cover. Correction to the issue's facet 2: pre-#2607 apply did NOT silently fold media either — the same filter carved all media before the warning point; the warning was accurate.

Behavior changes (old → new)

Config surface

None. No new env vars, config fields, or CLI flags.

Tests

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-10_kernel-live-carrier-screening (e7e5ea8)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2970-pr.2669.7bc7081

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-pr2669.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] 🏷 PR #2669 review(kernel 变更 · human-only tier)

已对 master 7c993f9ed 逐文件通读分支 2026-10-10_kernel-live-carrier-screening(单提交 fec676de,8 文件,+461/−14)。CI 26/26 绿(含 kernel-guard、ubuntu 22/24、windows 24、docs-coverage、lane-guard、hermetic registry e2e、real-client lanes),mergeable_state: clean,基于当前 master,无 stale-base。

结构化八问

  1. 是什么问题:选择器(buildCompressibleRanges)会 advertise 出 apply 侧结构性拒绝的 range——跨 live checkpoint carrier(fix: detect codex compaction requests before preflight; verbatim passthrough when not intercepted (#332) #335)的 span 在 apply 时解析为零可折叠消息,每轮必抛([Bug][preflight] range selector re-nominates a fully-folded span every turn — permanent "no new compressible messages" rejection loop + nudge churn #2638 生产 livelock);同机制族另两隐患:media payload 警告声称排除却照折销毁(这个插件压缩上下文,会导致deepseek识图出问题。 #1188)、integrity withdrawal 两个 screen 判两种数组类。
  2. 什么原因导致的:「advertised ⇒ foldable」在选择器侧没有落点——carrier 概念只存在于 compress.ts apply 路径,recommend.ts 完全没有;且两 screen 一个判 pruned view、一个判原始重发数组,无共享判据保证一致。根因是 selector/applier 缺单一判据,不是某条报错本身。PR 的层次判断正确。
  3. 影响范围与严重程度:full-log plugin host(DSH 等)带 carrier 的深度会话每轮重复 advertise 死 span→apply 拒绝,永久循环+浪费 token+干扰模型行为([Bug][preflight] range selector re-nominates a fully-folded span every turn — permanent "no new compressible messages" rejection loop + nudge churn #2638 实证);media 静默折叠=数据丢失级(字节折叠后不可恢复);数组类分歧当前可达状态无可观察影响(prune orphan-stripping 保 pair-complete),属结构性漂移风险。
  4. 怎么修复的(策略层):抽出共享谓词 isLiveCheckpointCarrier(state.ts)让 selector 与 applier 用同一份定义;selector 把 live carrier 当 gap+skip(stale carrier 保持可折);prune node 把 pre-prune 数组 stash 进 effects.originalMessages,selector 的 withdrawal 改在与 apply 相同的数组类上判(新可选参 integritySource,缺省=传入数组,外部调用方语义不变);applied span 内 media 像 protected tool 一样从 filteredIds+effectiveMessageIds carve 掉,原警告变诚实;acp_status UNCOMPRESSED 行同样不跨 live carrier。
  5. 是否有回归问题:逐项过过——无 carrier 会话 advertise 输出不变(segmentation 规则未动);carrier-bridging span 不再广告(本目标);media carve 只改含 media 的新块覆盖集(旧=折毁,新=保留,有意变更已披露);media-only range 现由 validateCompressionRange 报错而非造空块(安全向);withdrawal 换原始数组后可观察影响今日为 0,若分歧方向是 under-advertise(安全);BLOCKED-ref 更宽碎片化刻意不动(另一机制族,PR 注明 follow-up 候选);golden wire-contract pin 未触碰。未见无意回归。
  6. 是否破坏缓存:不涉及。prefix cache / 更新节流 / 持久化格式均未动;block 覆盖集语义未变(media 只是不进新块,与 protected-tool 先例一致)。
  7. 是否改了设计方向:不涉及。仍是「selector advertise、apply validate」架构,只在两者之间加共享判据(single source of truth),数据流与边界未转向。
  8. 是否引入新配置:不涉及。无 env/config/CLI flag;buildCompressibleRanges 新参可选且带默认值。

版本纪律:仅 kernel/package.json 0.0.112→0.0.113(Kernel Boundary 要求的 bump);root 恒 0.1.191、pi-subagents 恒 0.1.4 均未动,lockfile 三处纯 resync 既有漂移,无依赖变更、无越权 bump。

测试有效性:5 个新测试全有牙——主 repro(#2638 几何)对每一个广告区间跑 applyCompression 断言零错(3 轮稳态)+负控制证旧死 span 确实失败(排除恒真假绿);live/stale 边界、media carve 断真实 block.effectiveMessageIds 不含 media、withdrawal 数组类契约(hand-crafted view pair,诚实标注结构不可达)、status 不跨 carrier。bug 被钉住。

diff 整洁度:单提交、每行都服务于本 PR 目的,无跑题/空行/生成物 churn(除已说明的 lockfile resync)。干净。

次要观察(非阻塞,未推 commit):① mediaExcluded 从 directMessageIds 而非当前 filteredIds 计算——若某消息同时是 protected tool 又带 media,警告计数会多算 1(实际剔除集仍正确,仅 advisory 数字偏差);② media-only range 抛出的通用报错文案("…already covered by active blocks or protected")未点明 media 原因(media 专属 warning 在 throw 时不落盘)。两者均为罕见边缘的措辞级瑕疵,安全向、零数据风险;因属 human-gated kernel PR 且低于可行动阈值,我不擅自改 load-bearing kernel 字节,留给 owner 决定是否要一轮 polish(若要,①是一行改动)。

收工判定:可合并——方向打到根因、四个 facet 一并处理、双层测试有牙、CI 全绿、diff 干净、所有行为变更均已披露。按 Kernel Boundary,kernel 变更为 human-only,我不合并,请 owner 自行合并:#2669

@ranxianglei
ranxianglei force-pushed the 2026-10-10_kernel-live-carrier-screening branch 2 times, most recently from 6a50baf to 835db70 Compare October 11, 2026 03:47
… array class (#2663)

The range selector (buildCompressibleRanges) advertised spans the apply side
structurally rejects: live checkpoint carriers (#335) survive pruning but are
carved out at apply time, so a span bridging carriers over covered raws
resolved to zero foldable messages and threw every turn (#2638). The two
screens also judged two different array classes for integrity withdrawal.

- state.ts: shared isLiveCheckpointCarrier predicate — single source of truth
  for selector and apply side
- recommend.ts: live carriers screen as gaps so no advertised group bridges
  across them; new optional integritySource param lets the withdrawal screening
  run on the same array class the apply gate judges (default: passed array)
- pipeline.ts/compress.ts: prune node stashes the pre-prune resent array in
  effects.originalMessages; recommend feeds it as the withdrawal source
- report.ts: acp_status UNCOMPRESSED rows open a gap at live carriers so no
  reported range bridges across them
- tests: carrier-advertise-validate.test.ts — #2638 production geometry
  end-to-end, carrier boundary (live/stale), withdrawal array-class contract,
  status-row consistency, plus both directions of the #2607 media split
  (archivable folds like text, unrecoverable stays pinned)

Rebased after #2607 landed on master: the originally drafted blanket media
carve was dropped — filterProtectedToolMessages already enforces the #1188
never-fold exemption for unrecoverable payloads, and a blanket carve would
have re-pinned archivable media against #2607's fold-like-text direction.
Media handling itself is untouched by this PR.

kernel-change: advertise/validate disagreement lives inside the kernel
(recommend.ts vs compress.ts); host side cannot express carrier-aware screening
or the pruned-vs-original view split. Closes #2663
@ranxianglei
ranxianglei force-pushed the 2026-10-10_kernel-live-carrier-screening branch from 835db70 to e7e5ea8 Compare October 11, 2026 03:56
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
上游冲突处理完成(过程中有一次误覆盖,已回滚,如实汇报)

结论先行:PR #2669 分支现在干净地落在当前 master 上、无冲突,可交 CI。但过程里我基于一个过期的本地快照做了一次 force-push,覆盖了分支上当时真正的 HEAD;发现后我已把它逐字节恢复。下面按八问说明。

  1. 是什么问题:收到「上游 PR 与 base 冲突」的系统唤醒。该转发来自未验证的 @ework-web(bot),我按安全基线没有盲信,先用 git 客观核实了冲突确实存在(master 已在 PR 基线之后前进)才动手。

  2. 什么原因导致:master 在 PR 基线之后合入了约 100+ 提交,其中 建议:compress.stripImages 默认开启——否则带图消息不可压缩会形成只升不降的输入地板撑爆上下文 #2607/Google wire 的 fileData(URL 引用)图像不被识别为媒体负载:可被折叠、折叠后静默丢失且无警告(#1188 不变量缺口) #2609 重构了媒体模型(从 hasMediaPayload 拆出 hasUnrecoverableMediaPayload),与本 PR 触碰的 kernel/src/compress.ts、kernel/src/recommend.ts、package-lock.json 及 kernel 版本号重叠 → 真冲突。

  3. 影响范围与严重程度:仅该 PR 分支自身的合并状态;不处理则无法合并。不影响任何已发布行为或线上用户。

  4. 怎么修复的:rebase 到当前 master(4ecd82f3f),冲突按「意图并集」解——保留本 PR 的 live-checkpoint-carrier 筛查块 + master 的不可恢复媒体 gap(两块都留,carrier 在前);kernel 版本 bump 到 0.0.116(> master 的 0.0.115);lockfile 取 master 版并把 acp-kernel 同步到 0.0.116。

  5. 是否有回归:恢复后的内核内容与被覆盖前的 6a50baf95 逐字节一致(diff 为空);相对 master 只改 8 个内核文件;aac8bc3fe..master 区间没有任何内核文件改动 → rebase 干净、无遗留冲突。版本纪律 OK(0.0.116 > 0.0.115,lockfile 一致)。

  6. 是否破坏缓存:不涉及(纯 rebase,未改持久化/缓存/重试策略)。

  7. 是否改了设计方向:这里有一个想请你拍板的点,是我核对两个版本时发现的分歧——对「不可恢复媒体永不折叠」的落地方式:

  8. 是否引入新配置:不涉及。

判定:分支现为 e7e5ea8a6,单提交,父 = 当前 master(4ecd82f3f),相对 master 仅 8 个内核文件,无冲突,交 CI 全量把关。内核改动按 Kernel Boundary 是 human-only 合并,我不代合。第 7 点的方向请你定夺。

@ranxianglei
ranxianglei merged commit cccf47d into master Oct 11, 2026
28 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.269-master.cccf47d (rolling master tag).

npm install -g billion-context@0.0.269-master.cccf47d  # 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