Skip to content

[PR] kernel: number demotable protected carriers at birth instead of BLOCKING them (#3999) - #4371

Open
ranxianglei wants to merge 5 commits into
masterfrom
2026-10-23_kernel-durable-numbered-at-birth
Open

ranxianglei wants to merge 5 commits into
masterfrom
2026-10-23_kernel-durable-numbered-at-birth

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Decouples ref-blocking from fold-protection so durable / latest-per-identity protected carriers are numbered at birth instead of carrying the unaddressable BLOCKED sentinel. Sub-defect of #3837 (per-round prefix-cache breakage in dsh sessions); managed inside that issue's sub-defect checklist.

Why

In the dsh plugin lane every new runtime-context snapshot demotes the previous one. Under the old code the live carrier was BLOCKED_REF at birth (no wire tag) and only got a real number minted mid-history the instant it was superseded — inserting ~48 bytes of ACP tag into the outbound prefix and breaking the per-round prefix cache from that point on (#3837 user evidence: single-round 5,701 tok full-price; up to 89,863 tok on long sessions after client mid-history splicing). Ref assignment is kernel-owned (the id-never-reused contract + render pipeline), so the host cannot fix this — it can only choose whether to attach the classifier at all.

The change (kernel, acp-kernel 0.0.136 → 0.0.137)

assignRefsNode (kernel/src/compress.ts) now keeps a BLOCKED ref for ONLY the permanently-pinned class:

The demotable latest-per-identity class (durable/* carriers, cumulative-snapshot tools like todo_list) is now numbered at birth. While one sits at the tail a fresh tag is append-stable, so its later demotion inserts zero bytes. Fold exclusion moves entirely to projection time — the existing unit-projection.ts / recommend.ts carve via isMessageLatestProtected, which is independent of the ref value — so numbering them never makes them foldable. This also matches rebuildCompressionState, which always numbered them.

Behavior change (old → new)

aspect before after
live durable/latest carrier ref BLOCKED (no wire tag) numeric mNNNNN (wire tag present, append-stable at tail)
bytes inserted when it demotes ~48 B tag minted mid-history → prefix-cache break 0
foldability excluded via ref value excluded via projection-time carve — same outcome
decompress citability unavailable available (consistent with #2607 archivable-media goal)
unrecoverable media / static protectedTools BLOCKED BLOCKED — unchanged

No config surface added. No wire-shape change beyond the tag the kernel already emits for any numbered ref.

Tests

  • New kernel suite kernel/tests/issue3999-numbered-at-birth.test.ts: numbered at first sight; two-shot demotion zero-insertion (rendered outbound byte-stable across the demotion); boundary guard (static tools still BLOCKED).
  • New host e2e tests/issue3999-dsh-append-stable.test.ts: two consecutive dsh-shaped requests through the real proxy assert the outbound body stays append-stable (demoted snapshot identical bytes, new snapshot appended at the tail).
  • Reworked 8 host tests that asserted the old BLOCKED detail for latest/durable carriers (issue2419/2446/2447/2481, protected-latest-tools, protected-tool-paths skill/*, session-continuity-proof scenario B, plugin-fork [bug]dsh 在191版本上或者说之前版本,分支(带上下文窗口)以及带上下文的子智能体会一直静默没反应 #2676) to the numbered-at-birth contract. Static-protectedTools siblings are untouched and still assert BLOCKED.

Both layers green on this head: kernel suite 1320 pass / 0 fail; root typecheck clean. Full bili-suite verdict comes from CI. Five local-only CCR … cold disk restore failures reproduce identically on clean master (environmental, not introduced here).

kernel-change

kernel-change: decouple ref-blocking from fold-protection so demotable latest/durable protected carriers are numbered at birth (append-stable), eliminating the mid-history tag insertion that breaks the per-round prefix cache (#3837/#3999)

Fixes #3999

@ranxianglei ranxianglei changed the title kernel: number demotable protected carriers at birth instead of BLOCKING them (#3999) [PR] kernel: number demotable protected carriers at birth instead of BLOCKING them (#3999) Oct 23, 2026
@ranxianglei
ranxianglei force-pushed the 2026-10-23_kernel-durable-numbered-at-birth branch from 8722d34 to bdd1ef0 Compare October 23, 2026 12:36
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

上游冲突已解决:分支已 rebase 到最新 master(a7e55cc86)并 force-push,head bdd1ef017,GitHub 已确认 mergeable。当前状态 blocked 仅表示等 CI 全量跑绿,非文本冲突。

冲突点与解法(共 2 处,均在 commit 1):

  1. kernel/package.json 版本号:master 已被推进到 0.0.160,本 PR 基于旧基线 bump 到 0.0.137 → 按 Kernel Boundary 版本纪律取 0.0.161(当前 master 之上 +1)。
  2. kernel/src/compress.ts 的 assignRefsNode blockedFn——语义冲突(本次真正的坑):本 PR(Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999)删掉了 collectLatestProtected/latest 判定,而 master 侧刚合入的 Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289(failed-compress fold 保护)在同一谓词位置新增了 failedCompressCallIds 透传。机械合并会留下「引用已删除变量」或「丢掉 Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289 机制」两种坏结果 → 取意图并集:保留 Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289 的 isMessageProtectedWithPairing(m, ctx.config, pathProtectedCallIds, failedCompressCallIds) / isMessageProtected(m, ctx.config, failedCompressCallIds) 线程,同时按 Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 设计彻底移除 latest 条款(可降级 protected carrier 出生即编号、不再 BLOCK)。collectLatestProtected/isMessageLatestProtected 仍由 recommend/unit-projection/absorb 在投影期使用(fold 排除与 ref 取值相互独立),未受影响。

commit 2(host 测试对齐)在 rebase 中干净应用,无冲突。最终 diff 相对 master 恰为本 PR 原范围的 14 个文件(+444/−71),无夹带。

定向验证(本地,全绿):

  • npm run typecheck clean;npm run build OK;
  • kernel 定向:issue3999-numbered-at-birth + protected-latest + issue4289-failed-compress-fold(交叉验证两机制共存于同一谓词)→ 30/30 通过;
  • host 定向(受影响的 9 个测试文件,含 dsh catalog/instructions/runtime-context 与 protected-latest/protected-tool-paths/session-continuity/plugin-fork)→ 88/88 通过;
  • tests/verif-subset-guard.test.ts 2/2 通过(compress.ts 属 verif 守护清单,KDD 14 要求)。
  • 全量套件判定以 push 后远程 CI 为准。

八问:

  1. 是什么问题:PR 分支与 master 冲突无法合并——master 期间合入的变更与本 PR 在同一代码位置发生文本+语义双重分歧。
  2. 什么原因导致的:本 PR 基于较早的 master 开发;期间 master 合入 [PR] feat(ci): surface per-commit PR build versions in the sticky comment (#3692) #3727/[PR] test(gate): Prohibit tool calls in recall rounds — eliminate S07-type "model self-initiated verification" false reds | test(gate): 召回轮禁止调工具 — 消掉 S07 类「模型自发验证」假红 #4029 等(kernel 版本推进到 0.0.160),且 Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289 恰好改动了本 PR 重构的同一谓词函数(assignRefsNode 的 protected 判定),两边意图不同但落点相同。
  3. 影响范围与严重程度:仅限本 PR 的可构建性/可合并性;不影响任何已发布行为。不解决则 Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999(dsh 每轮前缀缓存断裂的子缺陷)持续搁置。
  4. 怎么修复的:rebase 到最新 master,冲突按「意图并集」解——Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289 机制完整保留、Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 设计完整落地,版本号按纪律在当前基线上 bump。
  5. 是否有回归问题:审过的既有行为——Failed compression invocations are never folded back for reclamation, and the context keeps ballooning under the weight | 失败的压缩调用永远不会被折叠回收,上下文被压缩残渣越撑越大 #4289 failed-compress fold 保护(专属测试过)、latest-protected 投影期排除(recommend/absorb 路径,测试过)、verif 子语言守卫(过);阈值/时序/输出格式/错误处理语义均无漂移。全量回归待 CI。
  6. 是否破坏缓存:不涉及(本次是冲突解决,未触碰任何缓存/重试/去重策略)。
  7. 是否改了设计方向:不涉及——仅解冲突,PR 原有设计方向不变。
  8. 是否引入了新的配置:不涉及。

结论:冲突已清,PR 可进入正常 review/CI 流程,等 CI 绿后可合(合并仍是人工操作)。

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-23_kernel-durable-numbered-at-birth (5676c8e)

Latest build — install this exact version

npm install -g billion-context@0.0.10111-pr.4371.4c6a697

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
5676c8e billion-context@0.0.10111-pr.4371.4c6a697 build
ecc81a9 billion-context@0.0.10107-pr.4371.4e58e93 build
a13e385 billion-context@0.0.10100-pr.4371.68cac7c build
85d684d billion-context@0.0.9715-pr.4371.970f895 build
6d6148c billion-context@0.0.5290-pr.4371.fae1d2e build
bdd1ef0 billion-context@0.0.5262-pr.4371.2cc8a97 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4371.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

(ai: vllm-qwen/qwen3.8-27b)

独立审核结论(我对 diff 重新做过,不复读 #3999 线程此前的八问)。

结构化八问

  1. 是什么问题:dsh 车道里,durable/latest 受保护消息(runtime-context 快照、todo_list 等累积快照)出生时内核给它发 BLOCKED_REF(不打线上标签),等到被新快照降级时才在历史中段补号打标签 → 前缀缓存从该点断裂、后缀全价重计(OpenAI/Codex channel: Per-request body rewriting causes the prefix cache to periodically reset to zero (degenerate foldi | OpenAI/Codex 通道:每请求改写请求体导致前缀缓存周期性归零(退化折叠 foldPoint=m00001 + abort 后 stamped 漂移),单会话 66.7% 计费为全价输入 #3837 用户字节级证据:单轮 5701 tok 全价)。本 PR 把这类可降级载体改为出生即编号。

  2. 什么原因导致的:内核 assignRefsNode 里「折叠保护」和「编号/打标」被耦合成一件(受保护⇒发 BLOCKED)。但 latest-per-identity 保护是可降级的,降级瞬间才补号,插入点落中段 ⇒ 断缓存。根因是两职责耦合;宿主侧解不了(编号/标签是内核所有物,id-never-reused 契约 + 渲染管线)。

  3. 影响范围与严重程度:dsh 车道所有会周期性更新 runtime-context / 累积快照工具的会话,每更新断一次、成本随轮次累积。程度:性能/成本回归(能用但明显变贵),非数据丢失/不可用 ⇒ p2(独立认同 Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 定级)。

  4. 怎么修复的:解耦——只有永久固定类(不可恢复媒体、静态 protectedTools)保留 BLOCKED;可降级 latest 类出生即发正常号+标签(此刻它在尾部,append-stable)。折叠排除完全交给投影期裁切(unit-projection.ts/recommend.ts/absorb.ts 的 isMessageLatestProtected carve,与 ref 值无关)。效果:降级瞬间零字节、新快照仍尾部追加。方向与 建议:compress.stripImages 默认开启——否则带图消息不可压缩会形成只升不降的输入地板撑爆上下文 #2607 一致,只是提前到出生时刻。

  5. 是否有回归问题(我逐环节独立核过):

    • 折叠排除搬层:成立且安全——unit-projection.ts:491-503 对每个候选现算 isMessageLatestProtected(msg, latest) 命中即 removedIds.add(id),且 latest.callIds 喂进 protectedCallIds(:480)连带保护配对的 tool-result,全程与 ref 值无关 ⇒ 编号后不会变得可折叠。
    • 静态 protectedTools / 不可恢复媒体:仍走 blockedFn 原分支,BLOCKED 不变。
    • hasStaticProtection 收窄掉 protectedLatestTools 项:isMessageProtected 只依赖三个静态配置(hook/patterns),仅设 latest-tools 时它本就全返回 false ⇒ 收窄无行为差。
    • fork/rebuild 一致性:rebuild.ts:36 不传 isProtected 本就全编号,现 processTurn 与之对齐(一致性提升非回归)。
    • 高危模式逐项:无语义漂移(fold 结果不变)、无 fail-fast→吞错、无阈值/时序/输出格式漂移(wire 形态不变)、BLOCKED 集合只缩小不扩大。结论:无回归。
  6. 是否破坏缓存:正是要修的——修复后前缀 append-stable、命中恢复,不引入新失效路径。附带:decompress 引用对这类消息从「不可用」变「可用」(对齐 建议:compress.stripImages 默认开启——否则带图消息不可压缩会形成只升不降的输入地板撑爆上下文 #2607 archivable-media 目标),属能力增强非破坏(见下方披露)。

  7. 是否改了设计方向:不改架构/边界/数据流。仅在内核 assignRefsNode 内部拆此前耦合的两个职责(编号策略 vs 折叠排除策略)。id-never-reused 契约、wire 形态均不变。

  8. 是否引入新配置:无新增 env / config / 默认值。

我额外做的(独立于审核本身)

CI 两个红 unused-exports + lock-sync 经我在干净 master(a7e55cc86)复跑确认为 master 既有红、非本 PR 引入,且它们卡在 ci.yml:218 的 test job needs: 上,导致本 head 上 typecheck/build/全量测试一次都没跑过(作者本地「kernel 1320/0、typecheck 绿」此前无 CI 佐证)。按「CI 失败类小修首选当前 PR 顺手修(独立标注 commit)」政策,推了两个零决策依赖的 commit 解锁:

已 push(head 现为 6d6148c6c),CI 将在新 head 重跑全量。

本地定向验证(已装 deps、kernel build 绿):新内核测试 issue3999-numbered-at-birth 3/3;KDD#14 verif-subset-guard 2/2(compress.ts/refs.ts 属守护清单,子语言守卫必过);dsh append-stable e2e 1/1;issue2481-dsh-runtime-context 4/4;protected-latest-tools 6/6。其余改动宿主测试(issue2419/2446/2447、plugin-fork、protected-tool-paths、session-continuity-proof)+ 全量以 CI 为准。

行为变更披露(Deliverables 第 4 条)

合并判定

代码层面我独立审核通过:核心不变量成立、无回归、KDD#14 守卫过、定向测试绿。合并前置仅剩 CI 在新 head 6d6148c6c 上转绿(已解锁,等它跑完);kernel 改动 human-only review,由 owner 合并。

@ranxianglei
ranxianglei force-pushed the 2026-10-23_kernel-durable-numbered-at-birth branch from 6d6148c to 85d684d Compare November 14, 2026 00:30
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Conflict rebase done — PR #4371 is no longer dirty. I rebased master (e1f31ad) into the PR branch 2026-10-23_kernel-durable-numbered-at-birth, resolved every conflict as a union of intent, verified locally, and force-pushed. Head is now 85d684db90. GitHub re-evaluated: mergeable=true, mergeable_state=blocked — the "blocked" is branch-protection (kernel PRs are human-gated / need owner approval), not a merge conflict. The conflict itself is resolved.

Conflicts resolved (5 sites):

  1. kernel/src/compress.ts — kept the PR's blockedFn rename + single top-of-node comment, and folded master's [Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620 media accuracy into that comment (ref-based media / archivable inline images are NOT unrecoverable — their handles ride the stored summary). blockedFn = hasUnrecoverableMediaPayload(m) || (hasStaticProtection ? … : false).
  2. kernel/package.json — version conflict (master 0.0.196 vs PR 0.0.161) → 0.0.197 (master + the PR's +1 bump).
  3. Four dsh host tests (issue2419/2446/2447/2481) — kept master's newer DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656 two-turn structure (turn 1 rides the sidecar side lane, no refs; turn 2 is the first full-pipeline turn) and placed the PR's new numbered-at-birth assertion (eff.protectedLatestTools?.includes("durable/*") + a m\d+ ref witness) after turn 2.
  4. Lockfiles (kernel/package-lock.json ×2, package-lock.json ×1) — kernel version → 0.0.197.
  5. tests/corrupt-index-child.ts — the PR's fourth commit (drop leading export) became a no-op: master had already dropped those exports and rewritten the check names to the SQLite unified storage degraded to legacy-only (bili v0.1.208, node v24.21.0, win32-x64) #4816/[Bug][split-brain] Restart-handover notice persists forever after the peer pid is gone (stale storage.splitBrain) #4626 policy chain. Resolved to master's version; that commit was dropped by the rebase.

Local verification (all green): npm run typecheck PASS (kernel 0.0.197 + pi-subagents build, root tsc --noEmit); the 4 touched dsh test files = 16/16 PASS; targeted kernel compress/refs/protected-latest/message-protection/issue5620-ref-recoverable-media = 76/76 PASS; storage-engine-proofs (exercises corrupt-index-child) = 12/12 PASS. Full-suite verdict is the remote CI test lanes on the pushed head.

Notes: (a) I did not edit the PR body — the kernel-change: declaration is already present and kernel-guard is a human gate, not mine to satisfy. (b) The PR's ref witness refs.some((r) => /^m\d+$/.test(r)) is weak (passes if any message is numbered, not specifically the carrier); I kept it verbatim as the author's choice rather than silently strengthening it — flagging for the author/reviewer.


结构化八问(中文,供审核):

  1. 是什么问题:PR [PR] kernel: number demotable protected carriers at birth instead of BLOCKING them (#3999) #4371 相对 master 产生合并冲突(merge state = dirty),无法合并。
  2. 什么原因导致的:PR 分支落后 master 约 2519 个提交,期间 master 在 kernel 侧落地了 [Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620(可恢复媒体可折叠)、DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656(dsh 单发 sidecar 侧车道)、SQLite unified storage degraded to legacy-only (bili v0.1.208, node v24.21.0, win32-x64) #4816/[Bug][split-brain] Restart-handover notice persists forever after the peer pid is gone (stale storage.splitBrain) #4626(corrupt-index 策略链)等改动,与 PR 的 4 个提交在同一批文件上发生语义冲突。
  3. 影响范围与严重程度:仅影响本 PR 的可合并性;冲突未解决前 PR 完全无法合并(阻断性),解决后恢复正常。无用户面/运行期影响。
  4. 怎么修复的:把 master rebase 进 PR 分支,逐处按「双方意图并集」解决——保留 PR 的 blockedFn 重命名与 Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 出生即编号契约,同时吸收 master 的 [Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620 媒体精度注释、DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656 两轮测试结构;kernel 版本号取 master+1 = 0.0.197;corrupt-index-child.ts 的 PR 提交因 master 已含同等改动而变空、被 rebase 丢弃。
  5. 是否有回归问题:本地定向验证全绿(typecheck + 4 个 dsh 测试 16/16 + kernel 压缩/保护/ref 76/76 + storage-engine-proofs 12/12)。blockedFn 语义与 master 的 [Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620 一致;dsh 测试结构沿用 master 的 DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656 两轮,未改变保护落点。未见无意回归;全量判定以远程 CI test 车道为准。
  6. 是否破坏缓存:不涉及——本次仅解决合并冲突,未触碰缓存/重试/增量游标/去重键逻辑。
  7. 是否改了设计方向:不涉及——冲突解决严格沿用 PR 既有方向(Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 出生即编号)与 master 既有方向([Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620/DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656),未引入新架构/边界/数据流转向。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。kernel 版本号 0.0.161→0.0.197 是 rebase 追踪 master 版本线的机械结果,非行为变更。

收工判定:冲突已解决、本地定向验证全绿、已 force-push(head 85d684db90),PR 现处于「可合并但被分支保护门禁 block(kernel 人工门禁)」状态,等待 owner 审核/CI 全量绿。本次 auto-fix 车道(attempt 1/3)目标达成。

awork added 3 commits November 15, 2026 14:09
…ING them (#3999)

Decouple ref-blocking from fold-protection in assignRefsNode: only the permanently-pinned class (unrecoverable media, statically-protected tools) keeps a BLOCKED ref. Latest-per-identity protected carriers (durable/*, cumulative-snapshot tools) are now NUMBERED at birth while append-stable at the tail, so their later demotion inserts zero bytes instead of minting a tag mid-history - the #3837 per-round prefix-cache break. Fold exclusion stays at projection time (unit-projection/recommend carve via isMessageLatestProtected), independent of the ref value. Also matches rebuildCompressionState, which already numbered them. Bumps acp-kernel to 0.0.137.
…ract

Host tests that asserted the old BLOCKED behavior for latest/durable carriers now assert the new contract: live carriers are numbered at birth (addressable) while fold-exclusion is carve-based. Reworks issue2419/2446/2447/2481 (guard proven directly on the stamped effectiveConfig), protected-latest-tools, protected-tool-paths (skill/*), session-continuity-proof scenario B, and plugin-fork #2676. Adds issue3999-dsh-append-stable e2e asserting the outbound body stays append-stable across two consecutive dsh runtime-context snapshots.
The PR bumped kernel/package.json to 0.0.161 but neither lockfile was
regenerated, leaving the root lock recording acp-kernel 0.0.159. The
lock-sync gate (#2704/#3782) regens both locks and fails on any drift.
This staleness already existed on master (kernel 0.0.160 vs root lock
0.0.159); the bump merely widened it. Pure version-line regen, no
structural churn. Un-blocks the `test` lane.
@ranxianglei
ranxianglei force-pushed the 2026-10-23_kernel-durable-numbered-at-birth branch from 85d684d to a13e385 Compare November 15, 2026 06:11
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-rebased onto the moved master — PR #4371 is clean again. Verified live first: master advanced 208 commits since my last rebase (now at 1ee510c528), and the PR head was still at my previous push (85d684db90), so the new conflict came from master's movement — no concurrent work on the branch. I rebased onto the new master, resolved the conflicts, verified, and force-pushed. Head is now a13e385570. GitHub re-evaluated: mergeable=true, mergeable_state=blocked — "blocked" is the kernel human-gate (owner approval), not a merge conflict.

Why it conflicted again: master landed #6709 (kernel: let content-free BLOCKED partners close their turn, 399cd2b8c0) — a kernel change in the same BLOCKED-ref semantic area as this PR. It bumped the kernel to 0.0.198 and touched kernel/src/unit-projection.ts, while this PR's core change is in kernel/src/compress.ts. Different files, so the code auto-merged cleanly; only the version collided.

Conflicts resolved (version-only, 4 sites):

  1. kernel/package.json — master 0.0.198 vs PR 0.0.197 → 0.0.199 (master + the PR's +1 bump).
  2. kernel/package-lock.json (top-level + packages."".version) → 0.0.199.
  3. package-lock.json (packages.kernel.version) → 0.0.199.

kernel/src/compress.ts (PR's blockedFn + #5620 comment) and kernel/src/unit-projection.ts (master's #6709 content-free-BLOCKED exemption) auto-merged without conflict — they live in different files. The dsh-test commit applied cleanly.

Local verification (all green): npm run typecheck PASS (kernel 0.0.199 + pi-subagents build, root tsc --noEmit); 4 dsh host tests = 16/16 PASS; kernel #3999-numbered-at-birth + compress + refs + protected-latest + message-protection + master's #6709 issue5919-shredded-merge + #5620 ref-recoverable-media = 87/87 PASS (confirms the PR's #3999 change and master's #6709 change coexist correctly in the shared BLOCKED area). Full-suite verdict is the remote CI test lanes on the pushed head.

Notes: (a) I did not edit the PR body — the kernel-change: declaration is present and kernel-guard is a human gate, not mine to satisfy. (b) No new issues/design decisions needed — this was a pure version-collision rebase.


结构化八问(中文,供审核):

  1. 是什么问题:PR [PR] kernel: number demotable protected carriers at birth instead of BLOCKING them (#3999) #4371 再次相对 master 产生合并冲突(merge state = dirty)。
  2. 什么原因导致的:我上次 rebase 后 master 又前进了 208 个提交,其中 Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709(content-free BLOCKED partner 可关 turn)是 kernel 侧改动,把 kernel 版本推到 0.0.198 并改了 unit-projection.ts;本 PR 的核心改动在 compress.ts,两者文件不同、代码可自动合并,只有 kernel 版本号撞上。
  3. 影响范围与严重程度:仅影响本 PR 可合并性;冲突未解决前 PR 无法合并(阻断性),解决后恢复。无用户面/运行期影响。
  4. 怎么修复的:rebase 到新 master(1ee510c528),版本号取 master+1 = 0.0.199(package.json + 两个 lockfile 共 4 处);compress.ts 与 unit-projection.ts 因文件不同自动合并,代码未动。
  5. 是否有回归问题:本地定向验证全绿(typecheck + 4 个 dsh 测试 16/16 + kernel Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999/compress/refs/protected-latest/message-protection/Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709/[Bug] Config save rejects valid mitm:// provider lanes as "invalid recipe on named provider" | 整文件保存把 mitm:// 路由误判为命名配方 #5620 共 87/87)。Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 与 Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709 同处 BLOCKED 语义域但分文件,87 个 kernel 测试同时覆盖两者并全绿,确认共存正确。未见无意回归;全量判定以远程 CI 为准。
  6. 是否破坏缓存:不涉及——仅解决版本冲突,未触碰缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及——沿用 PR 既有方向(Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999 出生即编号)与 master 既有方向(Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709),无架构/边界/数据流转向。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。kernel 版本号 0.0.197→0.0.199 是 rebase 追踪 master 版本线的机械结果(master 已至 0.0.198,本 PR +1),非行为变更。

收工判定:冲突已解决、本地定向验证全绿、已 force-push(head a13e385570),PR 现处于「可合并但被 kernel 人工门禁 block」状态,等待 owner 审核 + CI 全量绿。本次 auto-fix 车道(attempt 1/6)目标达成。

…irth contract

#3999 numbers demotable latest-protected carriers at birth instead of giving
them the BLOCKED sentinel. Two comments still described the carrier as holding
a BLOCKED ref, which is now only true for the permanently-protected class:
- src/server/side-request.ts: the side-lane veto exists so the durable carrier
  goes through the kernel and gets a ref stamped (numeric now, not BLOCKED).
- kernel/src/boundaries.ts: snapToNeighborVisible skips permanently-protected
  (BLOCKED) refs; demotable carriers are now visible snap targets.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: vllm-qwen/qwen3.8-27b)

Reviewed end-to-end: PR body, linked issue #3999 (sub-defect of #3837), the full diff (kernel + host tests + lockfiles), and every touched code path.

Correctness — sound. The fix decouples ref-blocking from fold-protection:

  • kernel/src/compress.ts assignRefsNode: ref-blocking (blockedFn) now covers only the permanently-pinned class — hasUnrecoverableMediaPayload OR static protection (protectedTools / isToolProtected / isMessageProtected). The demotable latest-protected class (collectLatestProtected + isMessageLatestProtected) is no longer blocked, so those carriers get a numeric ref at birth (append-stable).
  • Fold exclusion is ref-independent and happens at projection time: kernel/src/unit-projection.ts filterProtectedToolMessages still carves out isMessageLatestProtected(msg, latest) (plus hasUnrecoverableMediaPayload / non-exempt isMessageProtected), and buildProjectionShared seeds baseProtectedCallIds from latestProtected.callIds. The live carrier is still excluded from folding while it is the latest — by identity, not by ref value.
  • The apply path is unchanged and safe: applySingleRange runs projectUnit (the single shared projection, KDD #12); a model-cited range covering the live carrier carves it out (silent, like static protected tools) or no-ops if entirely protected.
  • The BLOCKED→numeric migration path (renderDeferredRefs, #3939②/#3805) is untouched and still handles stale persisted state from pre-#3999 kernels or config-changed static protection.
  • rebuildCompressionState (kernel/src/rebuild.ts) already called assignRefs with no isProtected (always numbered) — the PR body's claim is accurate.

Tests — real teeth.

  • kernel/tests/issue3999-numbered-at-birth.test.ts (new, 3 tests): carrier numbered at first sight; two-shot demotion keeps the old carrier's ref and renders a byte-identical prefix (the #3837 symptom negated at the kernel level); static protectedTools stays BLOCKED while the durable carrier is numbered.
  • tests/issue3999-dsh-append-stable.test.ts (new e2e, real proxy): two consecutive shots, asserts t2[0] === t1[0] byte-identical (demotion zero-insertion) and the newest snapshot is numbered at the tail.
  • Reworked host tests (issue2419/2446/2447/2481, protected-latest-tools, protected-tool-paths, plugin-fork, session-continuity-proof) are consistent with the new contract.
  • Targeted suites run locally: kernel 16/16 pass, host 97/97 pass. No golden/wire-contract drift (no golden files in the diff). Full-suite verdict is the remote CI on the pushed head.

Behavior drift (旧值→新值) — disclosed:

  • Demotable latest-protected carrier (e.g. dsh durable runtime-context snapshot): ref BLOCKED (no tag) → mNNNNN (tag at birth). This is the intended fix.
  • acp_status protected ranges: the live carrier was invisible (BLOCKED, skipped in recommend.ts) → now listed as a protected range with a ref. Natural consequence; consistent with the existing numbered+fold-excluded precedent (unnamed results of name-only protected tool calls).
  • snapToNeighborVisible (kernel/src/boundaries.ts): demotable carriers were skipped (BLOCKED) → now eligible as visible snap targets. Correct — they are visible.
  • Permanently-protected carriers: unchanged (still BLOCKED).

House conventions — compliant. kernel-change: line present in the PR body; version bump 0.0.198→0.0.199; both test layers (kernel + host) covered.

已顺手修:synced two stale comments that still described the carrier as holding a BLOCKED ref (now only true for the permanently-protected class) — src/server/side-request.ts:244 and kernel/src/boundaries.ts:408 + commit ecc81a9

Verdict: findings-only, no blockers. This PR touches kernel/ and carries a kernel-change: declaration, so per the authorization boundary I am NOT approving — the merge waits on the human-only kernel review tier. See the follow-up comment.


八问(中文,供人工审核):

  1. 是什么问题:dsh 会话里,每轮压缩把「最新受保护载体」的 tag 插到历史中间,破坏前缀缓存(单轮 5,701 tok 全价,最高 89,863 tok)。
  2. 什么原因导致的:ref 阻塞与折叠保护耦合——最新受保护载体出生时拿 BLOCKED 哨兵(不渲染 tag),demote 时才补发数字 ref,tag 被插到历史中间,前缀缓存失效。
  3. 影响范围与严重程度:仅 dsh 车道带 durable 载体的会话;特定条件触发(每轮 demote);严重度=缓存失效→成本上升(非不可用)。
  4. 怎么修复的:解耦——ref 阻塞只留「永久保护」类(静态 protectedTools + 不可恢复媒体),可 demote 的最新保护载体出生即编号(append-stable),折叠排除改到投影期(filterProtectedToolMessages 按 isMessageLatestProtected,与 ref 值无关)。
  5. 是否有回归问题:审过——永久保护仍 BLOCKED(不变);折叠排除在投影期(ref 无关,结果同);apply 路径 projectUnit 仍 fatal 抛错;迁移路径(renderDeferredRefs)只处理旧持久化态;acp_status 现在列出活载体(带 ref,自然推论,与既有「编号+折叠排除」先例一致);snapToNeighborVisible 现在把可 demote 载体当可见 snap 目标(正确,它们可见)。无回归。
  6. 是否破坏缓存:本 PR 正是修复前缀缓存失效;不破坏其他缓存/重试/游标/去重键。
  7. 是否改了设计方向:是——ref 阻塞与折叠保护解耦(kernel 内设计变更);理由:阻塞 ref 破坏 append-stability,而折叠本就该在投影期按身份排除。
  8. 是否引入了新的配置:不涉及。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🔶 需要决策

本 PR (#4371) 触碰 kernel/ 且带 kernel-change: 声明。按 Kernel Boundary(human-only review tier,始终适用),我不能 approve——合并需要你(owner)的明确批准。

受门禁的 kernel diff:

  • kernel/src/compress.ts — assignRefsNode:解耦 ref 阻塞与折叠保护(可 demote 的最新保护载体出生即编号,不再 BLOCKED)。
  • kernel/src/refs.ts — AssignRefsOptions.isProtected 文档注释(明确只传永久保护类)。
  • kernel/package.json + kernel/package-lock.json — 版本 0.0.198→0.0.199。
  • kernel/src/boundaries.ts — 注释同步(我顺手修的 commit ecc81a9)。
  • kernel/tests/issue3999-numbered-at-birth.test.ts(新增)、kernel/tests/protected-latest.test.ts(rework)。

我的审核结论: 无阻塞项;修复正确;测试扎实(定向 kernel 16/16 + host 97/97 通过)。唯一门禁是 human-only kernel 批准档。

请批准(或驳回)该 kernel 变更。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Review complete — findings-only, no blockers. NOT approved (this PR touches kernel/ and carries a kernel-change: declaration, so the merge waits on the human-only kernel review tier — see my 🔶 需要决策 comment and the needs-decision label).

What I verified (end-to-end: PR body, issue #3999, full diff, every touched path):

已顺手修: two stale comments that still described the carrier as holding a BLOCKED ref — src/server/side-request.ts:244 and kernel/src/boundaries.ts:408 + commit ecc81a9 (pushed to this branch).

The full findings + the Chinese 八问 checklist are in my review above. Next step is yours: approve (or reject) the kernel change.

)

ecc81a9 synced two stale BLOCKED-ref comments; its side-request.ts edit is comment-only, which lane-guard (#2170) treats as a lane-logic change and requires a side-lane suite update alongside. A comment has no behavior to pin, so restore the line and let the kernel PR proceed; the comment re-sync can land with a real suite change later. The kernel/src/boundaries.ts comment sync from the same commit is kept (kernel/, not gated by lane-guard).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

lane-guard fixed — pushed 5676c8e4cf, check now green.

What I found (verified live first): On head ecc81a92e2 the only failing check was lane-guard; every other gate (kernel-guard, config-surface-guard, unused-exports, docs-coverage, plan, pi-subagents-guard, all gate jobs) was success/skipped.

Root cause: the PR's comment-sync commit ecc81a92e2 ("sync two stale BLOCKED-ref comments") made a comment-only edit to src/server/side-request.ts (dropped "BLOCKED" from a stale ref comment). The lane-guard gate (#2170) fires on any +/- line in git diff origin/master...HEAD -- src/server/side-request.ts and demands a side-lane suite update alongside — but a comment has no lane behavior to pin, so this was a false positive. The PR's real work is the kernel change (#3999) plus host ref-assertion tests; none of the four side-lane suites were (or needed to be) touched.

Fix (small, mechanical): restored that one comment line to its pre-change form (BLOCKED ref …), i.e. reverted the comment-only edit to side-request.ts. That makes git diff origin/master...HEAD -- src/server/side-request.ts empty, so the gate no longer triggers. I kept the same commit's kernel/src/boundaries.ts comment sync (it's under kernel/, not gated by lane-guard). The comment re-sync can land later alongside a real side-lane suite change if it's wanted.

Notes on process:

  • The local branch had diverged from the authoritative origin PR head (a stale local copy, ~1747 commits behind). I reset it to origin/2026-10-23_kernel-durable-numbered-at-birth (ecc81a92e2) before working, then pushed a fast-forward (no force-push).
  • The mirror check cache was stuck at the pre-push sha, so I did a single one-time GitHub API read (not polling) to confirm the new run: lane-guard → success on 5676c8e4cf; no failed checks (11 long test/e2e lanes still in progress at read time).

中文八问

  1. 是什么问题:lane-guard CI 门禁在本 PR head (ecc81a92e2) 上失败。PR 的注释同步提交 (ecc81a92e2) 对 src/server/side-request.ts 做了一处纯注释改动(把过时的 "BLOCKED ref" 改成 "ref"),而 lane-guard (dsh 回归防护:泳道判定真值表 + 侧请求不变量 + dsh e2e lane + 运行时金丝雀 + lane-guard(5 项) #2170) 对该文件的任何 diff 都会触发并要求同步更新 side-lane 测试套件——纯注释没有可固定的行为,属于误报。
  2. 什么原因导致的:lane-guard 的判定是 git diff origin/master...HEAD -- src/server/side-request.ts | grep -qE '^[+-]',只要该文件有任何 +/- 行就视为"lane 逻辑变更",不区分注释与代码。纯注释改动触发了这个保守启发式,而 PR 没有(也不需要)更新 side-lane 套件,于是 gate 红。
  3. 影响范围与严重程度:仅影响本 PR 的 CI 门禁,不影响任何运行时行为(改动是纯注释)。严重程度:流程瑕疵——内核修复 (Kernel change request: durably protected messages now numbered at birth (fixes per-round prefix cache breakage in dsh se | 内核改动申请:durable 保护消息改为出生即编号(修 dsh 会话每轮前缀缓存断裂,#3837 子缺陷) #3999) 被一个与行为无关的 gate 误报卡住,无法推进。
  4. 怎么修复的:把 src/server/side-request.ts 那行注释还原为改动前的 "BLOCKED ref"(撤销 ecc81a92e2 对该文件的纯注释改动),使 git diff origin/master...HEAD -- src/server/side-request.ts 为空,从而 lane-guard 不再触发。保留同一提交对 kernel/src/boundaries.ts 的注释同步(kernel/ 下,不受 lane-guard 管辖)。注释重新同步可后续与真正的 side-lane 套件改动一起落地。
  5. 是否有回归问题:无。改动是纯注释还原,不触碰任何代码路径/行为;lane-guard 的判定逻辑本身未改(没有削弱 gate)。新 head 上其余检查(kernel-guard、config-surface-guard、unused-exports、docs-coverage、plan 等)均为 success。
  6. 是否破坏缓存:不涉及。纯注释改动,不触碰缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及。无架构/边界/数据流转向。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:lane-guard 已在新 head (5676c8e4cf) 转为 success,本 PR 的 CI 阻断解除;可合并(待其余长时 test/e2e lane 跑完)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-verified live — already green, no further work needed this run.

The triggering event was stale: it reported head ecc81a92e2, but this bot's earlier wake already fixed lane-guard and pushed 5676c8e4cf (reverted the comment-only edit to src/server/side-request.ts that was tripping gate #2170).

Live state on the current PR head 5676c8e4cf (confirmed via a single one-time API read, since the mirror check cache is still pinned at the pre-fix sha ecc81a92e2):

  • lane-guard → success
  • 0 failed checks (39 success / 15 skipped / 1 in-progress long e2e lane)

No new fixes pushed this run. Stopping here per the "already green" rule.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

head 已移动(5676c8e4c),我重新核对了 delta。

新提交 5676c8e4cf(CI bot)只动了一处:把我之前顺手修的 src/server/side-request.ts:244 注释改回 "BLOCKED ref"(保留了我对 kernel/src/boundaries.ts 的同步)。原因(见其 commit message):lane-guard #2170 把 side-request.ts 的纯注释改动也当成 lane-logic 变更、要求配套 side-lane 套件;注释无可钉行为,CI bot 还原该行让 kernel PR 继续走,注释重同步留待真正的套件变更一起落。

重审结论:

  • kernel 变更零改动(delta 仅 side-request.ts 一行注释,kernel/ 未触碰),我之前的审核结论全部成立——修复正确、测试扎实(定向 kernel 16/16 + host 97/97)、行为漂移已披露、house conventions 合规。
  • CI green(仅 1 个 shard in-progress),mergeable_state = blocked(等批准,非 CI 失败)。

状态不变: 触碰 kernel/ + 带 kernel-change: → human-only kernel 档,等你(owner)明确批准。needs-decision 标签已挂。

This branch has not been deployed

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

Projects

None yet

1 participant