Skip to content

[PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) - #5800

Open
ranxianglei wants to merge 3 commits into
masterfrom
2026-11-06_tool-delta-relocate-heal
Open

ranxianglei wants to merge 3 commits into
masterfrom
2026-11-06_tool-delta-relocate-heal

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #4818

kernel-change: healIllegalSystemPositions must stop splitting tool-delta chains — demote-strip orphans paired tool_removal blocks (hard 400 tool_reference_unresolved, session death) and silently drops addition-only carriers (permanent tool loss); the host side cannot fix this because the decision lives in the kernel's outbound render pass (coreToAnthropic), the only layer that sees the final wire layout.

What

The position-based backstop (#4457 precede-side, #5438 follow-side) healed each illegal system independently by demoting in place: re-voice to user, strip tool_addition/tool_removal blocks (WC-022), drop when nothing remains. Tool deltas form an ORDERED CHAIN (add → remove → add …) that controls the effective tool set under Anthropic's mid-conversation-tool-changes contract, so stripping one link breaks its neighbours:

Fix

healIllegalSystemPositions gains a settle pre-pass (settleToolDeltaPositions): when any system carrying tool deltas sits in an illegal position, ALL such carriers are moved together (original relative order preserved) to the earliest forward slot that is legal under BOTH halves of the position rule (run-aware, mirroring the demote pass exactly). Moving systems never changes any other message's legality verdict (systems are transparent to both halves), so one pass suffices. When no forward slot exists (e.g. a trailing carrier behind plain assistant text — the Maziar123 example-2 shape where both options demote anyway), the carriers fall back to the existing #5438 demote path UNCHANGED — and now emit a [acp-kernel] warn naming every dropped tool, making silent tool loss diagnosable.

Plain systems keep the owner-approved #5438 demote semantics byte-for-byte. Legal layouts (assistant next, array end, directive-only anywhere) are a cache-safe no-op: the settle pass returns without touching the array.

Behavior change disclosure (old → new)

For systems carrying tool_addition/tool_removal blocks in an ILLEGAL position only:

  • old: re-voiced to user with delta blocks stripped; dropped silently when nothing remained
  • new: relocated verbatim to the earliest forward legal slot; demote-strip only when no such slot exists, plus a stderr warn naming every dropped tool

Why: availability (#3128) — the old path hard-400'd sessions (orphaned removal) or silently removed tools (addition-only drop). Relocation preserves the exact chain order the contract requires.

Related

Tests

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-06_tool-delta-relocate-heal (329b263)

Latest build — install this exact version

npm install -g billion-context@0.0.10981-pr.5800.5c8e521

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
329b263 billion-context@0.0.10981-pr.5800.5c8e521 build
6e96e24 billion-context@0.0.10882-pr.5800.5ad3acc build
c4de64a billion-context@0.0.10051-pr.5800.ccf4fbd build
ff95b5a billion-context@0.0.9142-pr.5800.820bafb build
a9a92a0 billion-context@0.0.9029-pr.5800.984fc60 build
4be887d billion-context@0.0.8978-pr.5800.77e4a60 build
c9f323b billion-context@0.0.8378-pr.5800.ca94c06 build
a5f6d3d billion-context@0.0.8348-pr.5800.5f6dc61 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5800.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) Nov 6, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重结论:不重复。open PR 里只有本 PR(#5800)在修 #4818;同族的 #4715 修的是相邻的 #4570(follow-side heal,不同半区),master 已在其基础上落了 #5438 实现,本 PR 是构建其上而非重复;#5031(move vs demote 决策)已关闭,本 PR 按 2026-11-02 拍板落地 delta-carrier 子集的重定位。同症状(系统位置 heal 触发 400)但机制/位置不同,判为同族不同半区,非重复。

标签:bug / claude-code / scope/kernel / p1(理由:#4818 硬 400 tool_reference_unresolved 让后续每个请求全挂、模型回复也丢 = 会话不可用 → p1;缺陷面在内核出站渲染 coreToAnthropic → scope/kernel;报告来自 Claude Code MCP connect/disconnect → claude-code)。注:本镜像未实现 labels API(shim 返回 "endpoint not implemented in ework shim"),标签在此以文本申报、未能落库。

审核状态(进行中):这是 owner 的内核 PR,我按 kernel-change 高审档独立过一遍(不复读 issue 结论)。已确认——

正在收尾:核对被改的旧 pin 是否只是「strip→relocate」行为变更而非削弱断言、确认 anthropic.ts 是否在 verif 守护集(CI 已覆盖)。随后给结构化八问结论。

一个合并顺序提示:正文自述 open PR #5777 也把 acp-kernel bump 到 0.0.183——若 #5777 先合,本分支需 rebase 到 0.0.184,否则 release 门禁会因版本冲突而红。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #5800 审核结论 — 结构化八问(独立审,不复读 issue 侧)

  1. 是什么问题:Claude Code MCP connect/disconnect 抖动(以及 addition-only carrier)时,内核把带工具增删的 sidecar system「就地降级」(strip tool_addition/tool_removal + re-voice user + 空则丢弃),拆散了有序的工具增删链——被 strip 的 addition 留下后面一条 verbatim removal 引用不存在的工具 → 后续每个请求硬 400 tool_reference_unresolved(模型回复也丢);addition-only 载体则被静默剥掉、延迟加载工具永久失效且无报错。
  2. 什么原因导致的:位置兜底 heal([Bug][anthropic] 0.1.205: 400 "role 'system' must precede an 'assistant' message" still occurs with #4396 present (mid-conversation system + tool_addition, cf. #4400) #4457 precede / kernel authorization request: heal must enforce the FOLLOW side of Anthropic's mid-conversation system position rule (#5432) #5438 follow)对每个非法 system 独立地就地降级;但工具 delta 是有序链(add→remove→add…),控制 Anthropic mid-conversation-tool-changes 契约下的有效工具集,strip 掉一环就破坏邻居。决策点在内核出站渲染 coreToAnthropic(host 侧够不到),所以只能在内核修。
  3. 影响范围与严重程度:触发条件 = MCP 工具集在折叠边界附近抖动 / addition-only deferred-load 载体落在非法位置。p1:命中即会话不可用(连续 400 + 回复丢失)或静默永久丢工具。仅 Anthropic wire(claude-code/anthropic 上游),OpenAI/Responses 线不受影响。
  4. 怎么修复的:healIllegalSystemPositions 前置 settle 预扫(settleToolDeltaPositions)——只要有任一 tool-delta system 非法,就把所有这类载体保序整体搬到「不早于首个载体原位置」的最早合法槽位(两半位置规则同时满足、run-aware,判定与 demote pass 完全一致)。搬 system 不改任何其它消息的合法性(system 对两半都透明)→ 一次搬移收敛全集;找不到前向合法槽才回退到原 kernel authorization request: heal must enforce the FOLLOW side of Anthropic's mid-conversation system position rule (#5432) #5438 降级路径(字节不变)+ 新增 [acp-kernel] warn 点名每个被丢工具。纯 system 保持 kernel authorization request: heal must enforce the FOLLOW side of Anthropic's mid-conversation system position rule (#5432) #5438 降级语义逐字节不变;合法布局是缓存安全 no-op(早退不动数组)。
  5. 是否有回归问题:逐项过既有行为——directive-only system(两处都跳过,不变)✓;纯 system(carriesToolDelta 为假 → 新 guard 不生效,demote-strip 路径逐字节不变)✓;合法布局(settle 早退,数组零改动)✓;demote 循环 prevNonSystem 索引簿记(新增 continue 只作用于合法 carrier,不扰动 splice)✓。唯一行为差异 = 「非法位置的 tool-delta carrier 从降级改为重定位」,正是本 PR 目的;无 fail-fast 变吞错、无阈值/时序/输出格式漂移。无回归。
  6. 是否破坏缓存:健康会话零改动(早退);只有本就在 400 的死会话输出变化(其缓存本就失效),严格优于死会话。未触及任何既有缓存失效策略。
  7. 是否改了设计方向:无架构转向。在既有位置兜底 heal 上为 delta-carrier 子集加一个更聪明的动作(relocate),demote 保留为兜底,与已关闭的 decision request: keep tool delta when healing a misplaced Anthropic sidecar system (move vs demote) #5031 move-vs-demote 拍板一致。
  8. 是否引入新配置:无。无 env/config/默认值变更。

测试有效性:新测试 issue4818-tool-delta-relocation.test.ts 有链解析 oracle(每条 removal 必须引用更早一条存活 addition,直接编码 #4818 的 400)+ add/remove/add 保序保数断言 + fallback-warn 捕获 + 合法布局字节不变负向门(#3617 双向)。被改的旧 pin 是「strip→relocate」行为变更且强化为断言块完整存活(split-of-fates 同时钉住纯 system 降级 + carrier 重定位两分支),非削弱;旧的 "dropped" pin 已改写为 #4818 静默丢工具的回归钉(@BBleae 现场报告)。

CI / verif:head a5f6d3d 全绿(30 项 = 16 success + 14 skipped + 0 failed/pending,test ubuntu/windows × node22/24 分片全过)。anthropic.ts 不在 verif Tier-A 子语言守护集(仅 openai/responses),故 verif-subset-guard 不适用;定向的 verif-wire-anthropic-roundtrip 已随 CI 跑绿。Kernel Boundary 合规:diff 聚焦 ✓ / 版本 bump 0.0.182→0.0.183 ✓ / kernel-change: 声明 ✓ / human-only 审档(mergeable_state: blocked = 等 owner 人审批准,非 CI 红)✓。

两个合并顺序提示(非代码缺陷):① open PR #5777 也把 acp-kernel bump 到 0.0.183——若它先合,本分支需 rebase 到 0.0.184,否则 release 门禁会因版本冲突而红。② 同族 #4715(follow-side,#4570)与本 PR 不同半区、master 已在其上落 #5438,二者不冲突,可各自推进。

非阻塞小观察(备查):settle 槽位搜索用「紧邻前驱 out[pos-1]」判 follow 侧,而 isLegalSystemSlot 会向后跳过 system run 找最近非 system 前驱——在「插入点紧贴另一条 system 之后」时两者不一致,使搜索比理论所需略保守(极少数边缘布局可能少搬一次而回退降级)。方向安全(绝不产出非法布局),非缺陷,记录备查即可。

判定:可合(approve) — 代码正确、测试有牙、Kernel Boundary 合规、CI 全绿。剩两项人工动作:owner 内核人审批准(human-only 档)+ 视 #5777 合入顺序决定是否 rebase 到 0.0.184。PR 合并 human-only,我不代合。

@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)

Findings-only review — 不 approve(触及 kernel/ + 带 kernel-change 声明,转需 owner 授权,见下方 🔶 评论)。

结构化八问

  1. 是什么问题:#4818 — Anthropic 中会话工具变更(tool delta)链被位置修复逻辑拆断。当携带 tool_addition/tool_removal 的 system 落在非法位置时,旧逻辑就地 demote 并按 WC-022 剥掉它的工具块,但同一链条上更靠后、位置合法的 tool_removal 被原样保留 → 孤儿 removal 引用不存在的工具 → Anthropic 硬 400 tool_reference_unresolved,会话整体死亡(模型回复也丢)。另一变体:addition-only 载体被静默剪掉 → deferred-load 工具永久失效,无报错无日志(@BBleae 现场报告)。

  2. 什么原因导致的:healIllegalSystemPositions(kernel/src/wire/anthropic.ts)对每个 mid-history system 独立判位置合法性并独立处置。tool delta 是一条有序链(add→remove→add),控制生效工具集;独立降级会拆链——剥掉一个 addition 就让它后面的 removal 悬空。根因在 kernel 出站渲染层(coreToAnthropic),是唯一能看到最终 wire 布局的层,host 侧修不了(PR 声明成立)。

  3. 影响范围与严重程度:p1(会话级死亡)。触发条件:Claude Code MCP connect/disconnect 抖动使 delta 落到折叠边界后的非法位置,或任何让 delta-carrier 孤立到非法位置的折叠序列。严重度:受影响会话每次请求都 400,完全不可用(Claude Code 靠丢 beta 恢复但付缓存代价;无 fallback 客户端永久卡死);addition-only 变体是静默永久工具丢失。

  4. 怎么修复的:给 healIllegalSystemPositions 加一个 settle 预通道(settleToolDeltaPositions):只要有任何 delta-carrier 在非法位置,就把所有 carrier(保持相对顺序)一起搬到「最早的正向合法槽位」(同时满足位置规则两半、run-aware、与 demote 通道判定一致)。移动 system 不改变其它消息的合法性(system 对两半都透明),故一次搬移即收敛。仅当不存在正向合法槽位(trailing carrier 在纯 assistant 文本之后),才回退到既有 #5438 demote 路径(字节不变),并新增 [acp-kernel] warn 点名每个被丢的工具。普通(非 delta)system 保持 owner 已批的 #5438 demote 语义逐字节不变;合法布局是缓存安全的 no-op。

  5. 是否有回归问题:逐项审过既有行为——① 普通 system 的 demote 语义:settle 只碰 carriesToolDelta && !isDirectiveOnlySystem,demote 通道新增的那行 if (carriesToolDelta(e) && isLegalSystemSlot(...)) continue; 也只作用于 carrier,普通 system 不受影响;② 合法 delta 布局(mid 合法位、Pi trailing run):settle 直接 return,负向 gate 测试钉住 byte-identical;③ 我手工推演了 #4818 精确 repro([user, sys(add), user, sys(rem), assistant] → [user, user, sys, sys, assistant],add<rem,链条解析)与 add/rem/add flap 序列,均收敛正确;④ 关键交互:settle 之后 demote 通道再降级的普通 system 不会破坏已搬移 carrier 的合法性——因为夹在 carrier 与其 assistant-successor 之间的 system 本身是合法的(其后继就是 assistant),不会被 demote。本地跑 6 个受影响套件全绿(46 kernel 用例 + 5 root 用例,root 需先 npm --prefix kernel build 出 dist,否则 import acp-kernel/wire 报 ERR_MODULE_NOT_FOUND,属环境非代码问题);CI 30 checks 0 fail 0 pending。发现一处非阻塞缺陷(见下)。

  6. 是否破坏缓存:合法布局 no-op(零搬移零重分配);非法布局才搬移且只改 delta-carrier 的位置不改内容——这是有意行为变更(见 PR 披露 old→new),不引入超出既有 demote 路径范围的额外缓存扰动。

  7. 是否改了设计方向:未转向架构。在既有 #5438/#4457 位置修复框架内新增「delta-carrier 优先 relocate」预通道,demote 保留为最后手段。符合 owner 在 #4818 拍板的方向(relocate 优先于 consistency-pass)。

  8. 是否引入了新的配置:无新 env/config/默认值。纯 kernel 内部行为。

非阻塞缺陷(建议合并前修)

kernel/src/wire/anthropic.ts:481-490(fallback warn 点名逻辑)对真实 wire 形状的 tool_removal 失效。 fallback warn 的设计目的(@BBleae 明确诉求)是让「被丢工具可诊断」。但 removal 分支只读 b.tool_reference ?? b.tool_name(合成测试用的扁平字段),没读真实生产形状 b.tool.name(issue #4818 repro:{type:"tool_removal", tool:{type:"tool_reference", name:T}})。我用构建后的内核实测三种形状走 fallback warn 路径:

removal 形状 warn 输出
真实 nested {tool:{type:tool_reference,name}} unknown ❌
扁平 {tool_reference:name} 正确打印工具名 ✓
扁平 {tool_name:name} 正确打印工具名 ✓

而 addition 分支读 b.tool.definition.name ?? b.name,两种形状都覆盖——不对称。新测试的 removal helper(kernel/tests/issue4818-tool-delta-relocation.test.ts:37)恰好用扁平 tool_reference(与 buggy 读法自洽),所以测不出来;且 warn 路径的用例(test 3/4)只喂了 addition。修法(几行):removal 分支补 ?? (b.tool as {name?:string})?.name,并加一条「真实 nested removal 走 fallback warn 且 warn 点名 T」的用例。因属 kernel/,按授权边界我不代改,列此供 author/owner 决定(建议并入本 PR 一起合)。

协调提示(非缺陷)

PR 正文已声明:in-flight #5777 也把 acp-kernel bump 到 0.0.183;若 #5777 先合,本分支需 rebase 到 0.0.184(本 PR 当前 bump 到 0.0.183)。合并时序注意即可。

结论:核心 relocate 逻辑正确、测试有牙、回归审过、合法布局缓存安全;唯一实质问题是 fallback warn 对真实 removal 形状打 unknown(非阻塞但削弱该特性诊断价值,建议合并前补)。因触及 kernel/ + 带 kernel-change 声明,按授权边界不 approve。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策
(ai: vllm-qwen/qwen3.8-27b)

本 PR 触及 kernel/(kernel/src/wire/anthropic.ts +99)并带 kernel-change 声明 —— 按授权边界(agent 不得自批 kernel 变更),不 approve,请 owner 授权。

请拍板:A 授权合入(建议先补 warn-name 那处再合)/ B 要求 author 补 warn-name + 测试后重新 review。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #5800(#4818 kernel tool-delta relocate 修复)review 完成 —— findings-only,未 approve,已转 🔶 需要决策。

因触及 kernel/(kernel/src/wire/anthropic.ts +99)且带 kernel-change 声明,按授权边界不 approve、不改 kernel 代码、不开新 issue、不代作者自声明。

审核结论:核心 relocate 逻辑正确——#4818 精确 repro 手工推演通过(add/rem 链保序、每个 removal 都能解析到更早的 live addition),settle→demote 交互安全(夹在 carrier 与 assistant-successor 之间的普通 system 本身合法、不会被 demote)。6 个受影响套件本地全绿;CI 30 checks 0 fail 0 pending(读镜像缓存,非 gh 轮询)。合法布局 no-op 缓存安全;version bump 0.0.182→0.0.183 合规;console.warn 符合 kernel 既有惯例。

一处非阻塞缺陷(已实测复现,未代改——属 kernel/):fallback warn 点名逻辑对真实 wire 形状的 tool_removal 失效——只读扁平 tool_reference/tool_name,漏了生产形状 b.tool.name。用构建后内核实测:issue #4818 的 canonical removal {type:"tool_removal", tool:{type:"tool_reference", name}} → warn 打 unknown;扁平形状才正确。削弱 @BBleae 要求的「被丢工具可诊断」价值。修法几行(removal 分支补 ?? b.tool.name + 一条真实形状 warn 测试),建议合并前补。详见上方 findings-only review。

协调提示:in-flight #5777 同 bump 0.0.183,若先合本分支 rebase 到 0.0.184。

已做:① findings-only review(COMMENT,含八问+finding)已发;② 🔶 需要决策 授权请求评论已发(选项 A/B);③ needs-decision 标签已打。待补:coordination issue 一行状态——本环境查不到 review-lane 协调 issue(唯一具名的 #4599 是 CI 专用、本 PR 绿不适用),请给编号我再补一行。

@ranxianglei

Copy link
Copy Markdown
Owner Author

有问题改

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

已按「有问题改」处理。已顺手修:fallback warn 对真实 nested tool_removal 形状打 unknown 的问题 —— kernel/src/wire/anthropic.ts removal 分支补读 b.tool.name(issue #4818 的真实生产形状,与 addition 分支对称),保留扁平 tool_reference/tool_name fallback;并加一条回归测试,用 #4818 的真实 nested removal 走 no-slot warn 路径断言点名该工具。commit c9f323be(已推到本 PR 分支 2026-11-06_tool-delta-relocate-heal)。

验证:kernel typecheck 干净;6 个受影响套件本地 52/52 绿(含新用例,旧代码下会因 unknown 而红,有牙);CI 将在新 head 重跑。版本无需再 bump(version-guard 走 master...HEAD 累计 diff,本 PR 已带 0.0.182→0.0.183)。#5777 同 bump 0.0.183 的协调提示仍有效:若其先合,本分支 rebase 到 0.0.184。

至此唯一实质 finding 已闭环,PR 现仅剩 owner 人工合并(kernel 变更恒需人审)。

@ranxianglei
ranxianglei force-pushed the 2026-11-06_tool-delta-relocate-heal branch from c9f323b to 4be887d Compare November 10, 2026 16:41
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved on PR #5800 (2026-11-06_tool-delta-relocate-heal) by rebasing it onto current master.

What I found & did this run:

  • The branch was 5678 commits behind master. Rebase surfaced only 3 conflicts, all version/lockfile lines: kernel/package.json, kernel/package-lock.json, root package-lock.json. The real code file kernel/src/wire/anthropic.ts auto-merged cleanly (its edits sit in different regions than master's own follow-side work).
  • Root cause of the conflict: master advanced acp-kernel from 0.0.182 → 0.0.192, while this PR had only bumped its base to 0.0.183. Resolved all three files to 0.0.193 (= current master 0.0.192 + 1, per the Kernel Boundary rule that any kernel/src/** change bumps from the current version). All three kept consistent.
  • Validation (targeted, per local-test discipline; full suite left to CI): kernel typecheck clean · 47/47 across the five kernel heal suites (issue4818-tool-delta-relocation, issue4457-sidecar-system-folds, issue4292-orphan-system-guard, issue5432-follow-side-heal, anthropic-system-message-passthrough) · kernel build clean · 5/5 root integration test tests/issue4292-anthropic-fold-orphan-system.test.ts.
  • Push discipline: fetched and confirmed the remote head was unchanged from my baseline (c9f323be1d) before pushing — no concurrent agent — then force-pushed with --force-with-lease pinned to that SHA. New head: 4be887dd17 (2 commits preserved).
  • Result: merge state went dirty → clean (mergeable: true, mergeable_state: blocked = awaiting CI / branch protection, not a conflict). CI re-ran on the push: failed 0 so far; static-gates / gate / lane-guard / test-import-graph / mysql-contract green; 11 test shards still in progress.
  • I did not edit the PR body (the existing kernel-change: declaration already satisfies the kernel gate) and opened no new issue — nothing here needs an owner decision.

结构化八问

  1. 是什么问题:PR [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800(工具增量系统"重定位而非降级"修复)与 master 出现合并冲突(merge state = dirty),导致 PR 无法合并。
  2. 什么原因导致的:PR 基于较旧 master(落后 5678 提交)切出;期间 master 把 acp-kernel 版本从 0.0.182 推进到 0.0.192,而本 PR 只在自己基线上 bump 到 0.0.183,于是三处版本/锁文件行冲突。真正的代码文件 kernel/src/wire/anthropic.ts 改动位于不同区域,自动合并干净,不涉及冲突。
  3. 影响范围与严重程度:仅该 PR 自身的合并能力被阻塞(合不进 master),不影响任何已发布行为或运行中会话;严重度低——属阻塞性、非功能性问题。
  4. 怎么修复的:把 master rebase 进 PR 分支,三个版本文件统一解析为 0.0.193(当前 master 0.0.192 + 1,符合 Kernel Boundary「改 kernel/src 必须从当前版本 +1」的版本纪律),推送前确认远端 head 未变后以 --force-with-lease(钉死基线 SHA)推回,避免踩到并发 agent。
  5. 是否有回归问题:rebase 本身不改任何代码语义,只移动版本号;本地定向验证全绿(kernel typecheck 干净、5 个内核 heal 套件 47/47、kernel build 干净、根侧集成测试 5/5),全量回归交给 CI(当前 failed 0)。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、阈值/时序/输出格式均未改动。
  6. 是否破坏缓存:不涉及。rebase 未触碰任何缓存/重试/游标逻辑;且新增的 settleToolDeltaPositions 对合法布局本就提前返回(cache-safe no-op),仅在非法布局才重排。
  7. 是否改了设计方向:不涉及。纯冲突消解,未改架构、边界或数据流。
  8. 是否引入了新的配置:不涉及。无新 env / config / 默认值。

判定:冲突已解决并通过定向验证,PR 现处可合并状态(blocked 仅待 CI 跑完与分支保护放行);无需 owner 决策、未开新 issue、未触碰 PR 正文与授权卡点。本轮收工。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Red CI fixed and verified green — PR #5800 is now conflict-free, all checks passing, awaiting human approval.

What happened this run (verified live, nothing asserted from memory):

  • Re-checked the reported "dirty/conflict" trigger — it was stale. Live mergeable_state is blocked (not dirty), remote head unchanged at 4be887dd17, PR 0 commits behind master. No merge conflict remained to resolve.
  • Found the real blocker: red CI. Both static-gates jobs (ubuntu-latest/24, windows-latest/22) failed at step 6 npm --prefix kernel test. Pulling that step's log showed exactly 2 failing subtests, both in kernel/tests/issue4570-system-position-final-wire.test.ts, still asserting the old demote-and-strip-on-demotion behavior (WC-022) that this PR's [Bug][anthropic][claude-code] 0.1.208: the system-position heal drops a tool_addition but keeps the later tool_removal for the same tool → 400 tool_reference_unresolved #4818 change replaced with relocate-not-demote.
  • Root cause: an oversight, not a design disagreement. The same old-behavior pins were already updated in 5 sibling files (issue4457-sidecar-system-folds, issue4292-orphan-system-guard, issue5432-follow-side-heal, anthropic-system-message-passthrough, root tests/issue4292-anthropic-fold-orphan-system); this one file was missed. The [Bug][anthropic] 0.1.206: system 400 still fires on nudge turns: the heal keeps a trailing system, then prepare-anthropic appends user notes after it #4570 test predates the PR (present at merge-base), so the relocation logic invalidated its expectations.
  • Fix (test-only): updated those 2 subtests to pin the new relocate-not-demote output — tool-delta carriers relocated verbatim (deltas preserved), layout legal, text kept. No kernel/src change, no version bump (stays 0.0.193). Same direction as the 5 files the author already updated.
  • Validated locally: issue4570 file now 7/7 (was 5/7); the 5 heal suites + root integration test stay green.
  • Push discipline: fetched first, confirmed remote head unchanged (concurrency guard), pushed as a clean fast-forward (no force) → head now a9a92a02fc.
  • Verified green live via one permitted one-shot read (not polling): all 52 check-runs completed — 38 success, 14 skipped, zero failures; static-gates (both OS) and kernel-guard green.

Behavioral-expectation note (flagged per policy): this commit changes test expectations only, not runtime behavior. The relocate-vs-demote behavior change was already made and disclosed by the PR author (old: revoice tool-delta carriers as user + strip their deltas; new: relocate them verbatim to the earliest forward legal slot, demote-strip only when no slot exists). I introduced no new behavior — I aligned two stale pins to that already-approved direction (#5031, approved 2026-11-02).


中文八问(结构化结论):

  1. 是什么问题:PR [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800 的 CI 红了 —— static-gates(ubuntu/24、windows/22)在 step 6 npm --prefix kernel test 挂掉,卡住合并。
  2. 什么原因导致的:kernel/tests/issue4570-system-position-final-wire.test.ts 里两个子测试仍断言旧的「降级即剥离 delta」(WC-022) 行为,而本 PR 的 [Bug][anthropic][claude-code] 0.1.208: the system-position heal drops a tool_addition but keeps the later tool_removal for the same tool → 400 tool_reference_unresolved #4818 已把它换成「原样重定位」。作者改了另外 5 个同类测试钉却漏了这个文件;[Bug][anthropic] 0.1.206: system 400 still fires on nudge turns: the heal keeps a trailing system, then prepare-anthropic appends user notes after it #4570 测试早于本 PR(merge-base 就存在),故被新逻辑判失败。属实现遗漏,非设计分歧。
  3. 影响范围与严重程度:仅卡 CI 门禁(阻塞合并),不影响任何运行时行为或用户面;严重度=发布被卡,必须修。
  4. 怎么修复的:只改测试预期——把两个子测试改为钉住新的「重定位后保留 delta、布局合法、文本保留」输出;不动 kernel/src、不加版本号(维持 0.0.193),与作者已改的 5 个兄弟文件同向。
  5. 是否有回归问题:无。未触碰任何 src/运行时路径;本地 issue4570 7/7、5 个 heal 套件 + 根集成测试全绿;CI 全量 52 项 0 失败。高危模式逐项过:无语义漂移、无 fail-fast→吞错、无阈值/时序/输出格式漂移(测试对齐的是已批准行为,非新行为)。
  6. 是否破坏缓存:不涉及。纯测试文件改动,不触及任何缓存/重试/游标/去重键。
  7. 是否改了设计方向:不涉及。relocate-vs-demote 的方向由 PR 作者定并已获 owner 批准(decision request: keep tool delta when healing a misplaced Anthropic sidecar system (move vs demote) #5031,2026-11-02);本次只是让漏网测试跟上既有方向,没有转向。
  8. 是否引入了新的配置:不涉及。无新增 env/config/默认值。

收工判定:可交付人工审核。 冲突已在上一轮解决,本轮红 CI 已修复并实测转绿;PR 现无冲突、CI 全绿,仅剩 kernel PR 必需的人工审批这一关(我无权也不应代批)。

@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)

复审(rebase 后新 head a9a92a02f)

分支已 rebase 到更新的 master,本 PR 三笔提交:

  • 7db7552307 kernel: relocate misplaced tool-delta systems instead of demoting them (#4818) —— 核心改动,与我首轮审核内容一致,rebase 未改语义。
  • 4be887dd17 kernel: name real nested tool_removal shape in heal-fallback warn (#4818) —— 我上轮顺手修的 warn 取名缺陷,rebase 后原样保留(kernel/src/wire/anthropic.ts:485-491 先读 b.tool.name,再落扁平 fallback)。
  • a9a92a02fc kernel: align #4570 final-wire test pins …… —— 本轮新增:纯测试。原 PR 把 demote-strip 改成 relocate 时漏更了 issue4570-system-position-final-wire.test.ts 里两处仍断言旧 WC-022 行为的 pin,此提交把它们对齐到新行为。

对新增提交 a9a92a02fc 的核查(逐条对照 settle 算法):

  • 尾部 carrier [user, sys(text+add), …, user] → 重定位到数组末尾、仍是 system、tool_addition 保留、texts=["q","nudge","tools updated"]、violations=[]。✓
  • assistant 后 carrier [user, assistant(tool_use), sys(text+add), user(tool_result), assistant] → 重定位到 index 3(tool_result 之后、收尾 assistant 之前),sent[2]=user、sent[3]=system、delta 保留。✓
  • 两处新断言有牙:旧(demote-strip)行为下会红,旧断言恰恰是只有旧行为才过的形状。纯测试、无 src 改动、无需再 bump 版本(累计 PR 已带 0.0.182→0.0.183 + src 变更,version-guard 走 master...HEAD 通过)。

CI:镜像缓存 30 checks,0 failed / 0 pending(16 success + 14 skipped)——绿。PR body 仍带 kernel-change: 声明 + Fixes #4818。

八问

  1. 是什么问题:#4818——anthropic 线 mid-history system heal 逐个独立判定,非法位的 tool-delta carrier 被降级为 user 且剥掉 tool block(WC-022),而后面合法位的同名 tool_removal 原样保留 → 孤儿 removal → 硬 400 tool_reference_unresolved,会话死亡并丢模型回复;另有静默变体(只剥 addition 不报错,工具永久失效)。
  2. 什么原因导致的:heal 对每个 system 独立判定 + 「降级即剥离」,破坏了「addition/removal 成链」这一不变量——链的一端被删、另一端留下。
  3. 影响范围与严重程度:claude-code / anthropic 线;触发条件 = mid-history 出现带 tool delta 的 system 且其位置非法。严重度 p1(会话不可用 + 丢模型回复)。
  4. 怎么修复的:healIllegalSystemPositions 加 settle 预遍 settleToolDeltaPositions——只要有一个 delta carrier 在非法位,就把全部 carrier(保持相对序)搬到最早的前向合法槽;搬 system 不改变其它消息的合法性(system 对前后两半都透明)→ 一遍收敛。无前置合法槽(carrier 落在纯 assistant 文本之后)才回退到既有 #5438 demote(不变)+ 新增 warn 点名被丢工具。普通 system 仍按 #5438 逐字节降级;合法布局 = cache-safe no-op。
  5. 是否有回归问题:审过的既有行为——①普通(非 delta)system 的 #5438 降级路径逐字节不变;②合法 delta 布局 no-op(cache-safe);③无槽位时回退旧 demote 语义(含 warn)。高危模式逐项:语义漂移——delta carrier 由「剥」变「搬」是本 PR 有意变更,已披露 旧值=demote+strip → 新值=relocate verbatim;fail-fast 变吞错——无;阈值/时序/输出格式——无。
  6. 是否破坏缓存:合法布局下 relocate 是 no-op(不碰已合法消息)→ 前缀缓存稳定;仅非法布局才移动 carrier,而那正是必须修的场景。不破坏缓存。
  7. 是否改了设计方向:否。仍在 healIllegalSystemPositions 内做位置修正,未动架构/边界/数据流;只是把同一决策点的「降级剥离」换成「重定位保链」。
  8. 是否引入新的配置:否。无 env/config/默认值变更。

结论:代码与测试均干净、完整,CI 绿;核心算法正确、warn 取名缺陷已补、遗漏的 #4570 pin 已对齐。但本 PR 触碰 kernel/ 且携带 kernel-change: 声明——按 HARD RULE 我无法 approve,合并须走人工 tier(owner 裁定)。除此之外无阻塞项。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策

复审后仍需 owner 授权合并(rebase 到新 head a9a92a02f)。

本 PR 触碰 kernel/ 且携带 kernel-change: 声明,按 HARD RULE 我(agent)不能 approve——合并走人工 tier。本轮复审结论:代码与测试干净完整、CI 绿(镜像缓存 30 checks,0 failed/0 pending),无阻塞项:

  • 核心 7db7552307(relocate-not-demote)与上轮顺手修的 warn 取名缺陷 4be887dd17(kernel/src/wire/anthropic.ts:485-491)在 rebase 后原样保留;
  • 新增 a9a92a02fc 为纯测试:对齐被原 PR 漏更的 issue4570-system-position-final-wire.test.ts 两处旧 WC-022 pin 到 relocate 行为,断言有牙。

被门禁的 diff:kernel/src/wire/anthropic.ts(settle 预遍 settleToolDeltaPositions + fallback warn 取名)、kernel/tests/* 六处、内核版本 0.0.182→0.0.183。

请 owner 裁定合并(或指出需调整处)。完整八问见 Reviews 区本轮 review。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

复审完成(新 head a9a92a02f) —— 结论:代码与测试干净完整、CI 绿,但按 HARD RULE(触碰 kernel/ 且带 kernel-change:)我不能 approve,合并须 owner 人工裁定。

本轮相比上轮的变化是分支 rebase 到了更新的 master:

  • 核心 relocate 7db7552307 与我上轮顺手修的 warn 取名缺陷 4be887dd17(kernel/src/wire/anthropic.ts:485-491 先读 b.tool.name)rebase 后原样保留;
  • 新增 a9a92a02fc(纯测试):对齐被原 PR 漏更的 issue4570-system-position-final-wire.test.ts 两处旧 WC-022 pin 到 relocate 行为——我逐条对照 settle 算法核过,两处断言都「有牙」(旧行为下会红),无 src/版本影响。

已验证:CI 镜像缓存 30 checks,0 failed / 0 pending;PR body 仍带 kernel-change: + Fixes #4818;version-guard 走累计 diff(0.0.182→0.0.183)通过。无遗留非阻塞项(NO OPEN ENDS)。

已落地:findings-only GitHub review(id 5853042145,含完整八问)+ 🔶 需要决策 评论 + needs-decision 标签。未开新 issue、未自声明、未 approve。

一处待办说明:规则要求「在协调 issue 报一行」,但现有工具查不到 review-lane 协调 issue(镜像 shim 不列 issue,全文检索无果)——为避免误报到无关线程,先在此标记该缺口;若你给协调 issue 编号,我补一行过去。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-verified live before doing anything — no work needed this wake.

  • Current PR head is a9a92a02fc (the fix I pushed last run), not the 4be887dd17 this event names. That head and its failing run 42857298023 are already superseded by the test-pin alignment.
  • Live check state on a9a92a02fc: all 52 check-runs completed — 38 success + 14 skipped, zero failures (both static-gates jobs and kernel-guard green).

Everything is already green; the reported blockers were on the pre-fix commit. Stopping without further changes.

中文:已实测当前头 a9a92a02fc 全绿(52 项 0 失败);本事件所报失败属于已被取代的旧提交 4be887dd17。无需再改,收工。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-verified live this run — still fully green, no work needed. (This is the third identical wake on an already-fixed commit.)

  • Current branch head is a9a92a02fc. Fresh one-shot check-runs read: all 52 completed — 38 success + 14 skipped, zero failures.
  • This event again names the superseded pre-fix head 4be887dd17 and its old failing run 42857298023 — that state no longer exists on the branch; it was fixed last run by aligning two stale test pins.
  • Note for the owner: master has moved ahead, so the PR is now a few commits behind base. That is not a blocker — no merge conflict is reported and every check on the current head is green. I am deliberately not rebasing here, because doing so would require a force-push that this event does not authorize (it reports CI failures, not a conflict). The base can be updated at merge time.

Bottom line: the only remaining step is the human-only kernel approval. Further auto-wakes keyed to the old commit are expected noise until the PR is merged/closed.

中文:本轮已实测当前头 a9a92a02fc 全绿(52 项 0 失败)。本事件第三次重复报告已被取代的旧提交 4be887dd17(其失败运行 42857298023 已不存在)。另提示:master 已前进、PR 落后若干提交,但这不是阻塞项(无冲突、CI 全绿);本事件未授权 rebase 所需的强推,故不擅自处理,base 可在合并时更新。仅剩人工内核审批一步;在那之前针对旧提交的自动唤醒属预期噪音。

@ranxianglei
ranxianglei force-pushed the 2026-11-06_tool-delta-relocate-heal branch from a9a92a0 to ff95b5a Compare November 11, 2026 12:47
@BBleae

BBleae commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

结论:这个分支(ff95b5a62)在下面每一种形状里都把工具定义留住了;master(c26c31ace)在每一种里都把它丢了。

我用自己报告里那种「只追加」(append-only)的形状核了这个分支:宿主只会发 tool_addition,从不发 tool_removal。另外补了几种尾部形状。

每个用例都过一遍 coreToAnthropic。S[...] 是 system 边车(sidecar)消息;「summary」是折叠块,渲染成一条 user 消息。

master c26c31ace:

(1) summary, S[add], summary, A, U            (append-only host, fold boundary right after the carrier)
   out: U[text] U[text] A[text] U[text]
   addition kept: false
(2) summary, S[text+add], summary, S[text+rem], A   (the #4818 chain)
   out: U[text] U[text] U[text] S[text+removal] A[text]
   addition kept: false, removal kept: true
(3) summary, S[add], summary, U               (no assistant after the carrier; live user turn is last)
   out: U[text] U[text+text]
   addition kept: false
(4) summary, S[add], summary, U, A(tool_use), tool_result   (tail is an open tool round)
   out: U[text] U[text+text] A[use] U[result]
   addition kept: false
(5) U, A, S[add], A, U                        (carrier between two assistant messages)
   out: U[text] A[text] A[text] U[text]
   addition kept: false

这个分支 ff95b5a62:

(1) summary, S[add], summary, A, U            (append-only host, fold boundary right after the carrier)
   out: U[text] U[text] S[addition] A[text] U[text]
   addition kept: true
(2) summary, S[text+add], summary, S[text+rem], A   (the #4818 chain)
   out: U[text] U[text] S[text+addition] S[text+removal] A[text]
   addition kept: true, removal kept: true
(3) summary, S[add], summary, U               (no assistant after the carrier; live user turn is last)
   out: U[text] U[text+text] S[addition]
   addition kept: true
(4) summary, S[add], summary, U, A(tool_use), tool_result   (tail is an open tool round)
   out: U[text] U[text+text] S[addition] A[use] U[result]
   addition kept: true
(5) U, A, S[add], A, U                        (carrier between two assistant messages)
   out: U[text] A[text] A[text] U[text] S[addition]
   addition kept: true

要留意的一点:(3) 和 (5) 里,载体(带 tool_addition 的那条 system 消息,也就是标签里的 carrier)最后落在数组末尾,排在当前这轮 user 消息之后。kernel/src/wire/anthropic.ts 里的位置规则把数组末尾算作合法位置,但这种排法我自己没有发给真实 API 试过。其余三种里,载体都排在一条 assistant 消息前面。

heal.mts
// usage: KSRC=<file URL of kernel/src> node --import tsx heal.mts
const { coreToAnthropic } = await import(`${process.env.KSRC}/wire/anthropic.ts`);
const T = "late_tool";
const add = { type: "tool_addition", tool: { type: "tool_definition", definition: { name: T, description: "d", input_schema: { type: "object", properties: {} } } } };
const rem = { type: "tool_removal", tool: { type: "tool_reference", name: T } };
const U = (id: string, text: string) => ({ id, role: "user", contentType: "text", text });
const A = (id: string, text: string) => ({ id, role: "assistant", contentType: "text", text });
const S = (id: string, content: any[]) => ({ id, role: "system", contentType: "text", text: "", rawAnthropicMessage: { role: "system", content } });
const show = (label: string, msgs: any[]) => {
  const warns: string[] = [];
  const w = console.warn; console.warn = (...a: any[]) => { warns.push(a.join(" ")); };
  let out: any[];
  try { out = coreToAnthropic(msgs as any); } finally { console.warn = w; }
  const row = out.map((m: any) => m.role[0].toUpperCase() + (Array.isArray(m.content) ? "[" + m.content.map((b: any) => b.type.replace("tool_", "")).join("+") + "]" : "")).join(" ");
  const j = JSON.stringify(out);
  console.log(`${label}\n   out: ${row}\n   addition kept: ${j.includes("tool_addition")}${JSON.stringify(msgs).includes("tool_removal") ? `, removal kept: ${j.includes("tool_removal")}` : ""}${warns.length ? `\n   warn: ${warns.join(" | ").slice(0, 200)}` : ""}`);
};
show("(1) summary, S[add], summary, A, U            (append-only host, fold boundary right after the carrier)",
  [U("u0", "summary 1"), S("s1", [add]), U("u2", "summary 2"), A("a3", "ok"), U("u4", "use it")]);
show("(2) summary, S[text+add], summary, S[text+rem], A   (the #4818 chain)",
  [U("u0", "summary 1"), S("s1", [{ type: "text", text: "now available" }, add]), U("u2", "summary 2"), S("s3", [{ type: "text", text: "gone" }, rem]), A("a4", "ok")]);
show("(3) summary, S[add], summary, U               (no assistant after the carrier; live user turn is last)",
  [U("u0", "summary 1"), S("s1", [add]), U("u2", "summary 2"), U("u3", "now use the tool")]);
show("(4) summary, S[add], summary, U, A(tool_use), tool_result   (tail is an open tool round)",
  [U("u0", "summary 1"), S("s1", [add]), U("u2", "summary 2"), U("u3", "question"),
    { id: "a4", role: "assistant", contentType: "tool-call", toolCallId: "t1", toolName: "other_tool", text: "{}" },
    { id: "r5", role: "tool", contentType: "tool-result", toolCallId: "t1", toolName: "other_tool", text: "ok" }]);
show("(5) U, A, S[add], A, U                        (carrier between two assistant messages)",
  [U("u0", "q"), A("a1", "a"), S("s2", [add]), A("a3", "b"), U("u4", "go")]);

在仓库根目录跑,KSRC 设成 kernel/src 的 file URL(我是把这个分支的 kernel/src 取出来,放在一份 master 检出旁边跑的)。这只跑了 kernel 的渲染这一步,没有在真实会话里跑。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Thanks for the careful field test — I traced all five shapes through coreToAnthropic at ff95b5a62 and your output matches the code exactly. The (3)/(5) array-end placement is intentional and, per Anthropic's contract, legal. On your caveat:

Array end is an explicitly allowed position, not a heuristic. The contract is documented verbatim at kernel/src/wire/anthropic.ts:380-388: a mid-conversation system must "FOLLOW a user message (or an assistant ending in a server tool_result), AND PRECEDE an assistant message or end the array" — and the comment states plainly "Pi's trailing tool-delta + effort-marker runs are legal at array end." The literal API error is quoted at :588-589: role 'system' must precede an 'assistant' message or end the array. So the precede half is satisfied by array end.

Your (3)/(5) satisfy the follow half too. In both, the relocated carrier lands right after a user message, which legitimatesFollowSide accepts (user → true). The only illegal array-end case is a carrier preceded by a plain assistant-text turn (no trailing tool_result) — and that's the fallback-demote path, not relocation (pinned at kernel/tests/issue4818-tool-delta-relocation.test.ts:172, which demotes + warns). So your (3)/(5) are the legal array-end shape, distinct from the illegal one.

It's not a new or untested position. Array-end systems are pinned as legal across the suite:

  • kernel/tests/anthropic-system-message-passthrough.test.ts:108 is literally your case (3): [user, system, user] → [user, user, system].
  • kernel/tests/issue4570-system-position-final-wire.test.ts:111 relocates a trailing tool-delta run to array end and asserts violations === [].
  • kernel/tests/issue4457-sidecar-system-folds.test.ts:174 asserts out[out.length-1] === healed ("relocated forward to array end").
  • kernel/tests/issue4292-orphan-system-guard.test.ts:141,177,295 pin array-end sidecar/tool-delta runs as verbatim-legal.
  • The insertBeforeTrailingSystemRun helper (kernel/src/wire/anthropic.ts:593) has been emitting array-end systems for a while.

Honest residual: the test violations() oracle mirrors the documented contract; it's not a live API call. So "legal per the contract" ≠ "verified against the real API this session." The contract wording is the authoritative source (it's the exact error Anthropic returns), and the helper has shipped array-end systems without 400s, so I'd rate the risk low. If you do get a chance to send (3)/(5) to the real API, that closes the last gap — but I don't see a defect here.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Status update (process was force-restarted after a 34-min stall):

The review of @BBleae's field report on PR #5800 is complete — my full reply is already in the thread above (addressing the (3)/(5) array-end placement concern). No defect found:

  • Array end is an explicitly legal position per Anthropic's contract (kernel/src/wire/anthropic.ts:380-388 + the literal API error quoted at :588-589), not a heuristic.
  • The (3)/(5) layouts satisfy both halves of the rule: precede half = array end (legal), follow half = user-preceded (legitimatesFollowSide → true). The only illegal array-end case (assistant-text-preceded) is the separate fallback-demote path, pinned at kernel/tests/issue4818-tool-delta-relocation.test.ts:172.
  • Array-end placement is pinned as legal across 5+ test files (anthropic-system-message-passthrough.test.ts:108 is literally case 3; issue4570-system-position-final-wire.test.ts:111; issue4457-sidecar-system-folds.test.ts:174; issue4292-orphan-system-guard.test.ts:141,177,295).
  • Honest residual: the test violations() oracle mirrors the documented contract, not a live API call — risk rated low (contract wording is the authoritative source; insertBeforeTrailingSystemRun has shipped array-end systems without 400s).

The stall was a hung wait after posting that reply — no pending tool call, no blocked dependency, nothing lost; the analysis and reply are intact in the thread. Avoiding the trigger: I'm not re-running any checks.

PR status: remains pending owner human approval (kernel changes are human-only tier). I did not approve or merge. Workspace restored to review-5800 (no detached HEAD, no stray files). No further action needed from me.

@ranxianglei
ranxianglei force-pushed the 2026-11-06_tool-delta-relocate-heal branch from ff95b5a to c4de64a Compare November 15, 2026 01:21
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved on PR #5800 (2026-11-06_tool-delta-relocate-heal) — rebased onto current master (f21b601893), all conflicts resolved, force-pushed. New head: c4de64a35a.

What I did this run (all verified live, nothing from memory):

  • State check: the branch head was ff95b5a626 (3 commits over merge-base dc041dd1ab); master had advanced 310 commits to f21b601893, moving acp-kernel from 0.0.195 (merge-base) to 0.0.197, and — new this round — adding healUnpairedServerToolBlocks to the same file this PR modifies (kernel/src/wire/anthropic.ts, +80 lines, the server-tool pairing backstop).
  • Rebase: the 3 PR commits replayed with conflicts in only the 3 version/lockfile lines (kernel/package.json, kernel/package-lock.json, root package-lock.json) — master 0.0.197 vs PR 0.0.196. All resolved to 0.0.198 (= current master 0.0.197 + 1, per the Kernel Boundary "bump from the current version" rule).
  • The code file auto-merged cleanly — the PR's settle-pass hunks (old lines 405–446) and master's new server-tool hunks (old lines 511+, plus the coreToAnthropic call site) sit in disjoint regions. I verified the merged file by hand: settleToolDeltaPositions + carriesToolDelta + isLegalSystemSlot intact, healUnpairedServerToolBlocks intact, and the coreToAnthropic call order preserved (healUnpairedServerToolBlocks(out) → healIllegalSystemPositions(out)).
  • Targeted validation (full suite left to CI): kernel typecheck clean · kernel build clean · 54/54 across the six kernel heal suites (issue4818-tool-delta-relocation, issue4457-sidecar-system-folds, issue4292-orphan-system-guard, issue5432-follow-side-heal, anthropic-system-message-passthrough, issue4570-system-position-final-wire) · 9/9 on master's new server-tool-pair-heal + regression-bili-470 suites (proves the two features coexist in the merged file) · 5/5 root integration tests/issue4292-anthropic-fold-orphan-system.test.ts.
  • Push discipline: fetched first, confirmed the remote head was still ff95b5a626 (no concurrent agent), then --force-with-lease pinned to that exact SHA.
  • Live result (mirror cache, fetched this run): mergeable_state went dirty → blocked (i.e. conflict-free; blocked = awaiting CI + human approval only), and CI re-ran on c4de64a35a: all 30 check-runs completed — 16 success + 14 skipped, zero failures.

No PR-body edits, no new issues, no design decisions needed — this was a pure mechanical conflict resolution.


结构化八问

  1. 是什么问题:PR [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800(工具增量 system「重定位而非降级」内核修复)与 master 再次出现合并冲突(merge state = dirty),PR 无法合并。
  2. 什么原因导致的:PR 分支基于较旧的 master(merge-base dc041dd1ab,落后 310 提交)切出;期间 master 把 acp-kernel 从 0.0.195 推进到 0.0.197,且在同一文件 kernel/src/wire/anthropic.ts 新增了 server-tool 配对兜底(+80 行)。三处版本/锁文件行因此冲突;代码改动位于互不重叠的区域,自动合并干净。
  3. 影响范围与严重程度:仅该 PR 自身的合并能力被阻塞,不影响任何已发布行为或运行中会话;严重度低——阻塞性、非功能性。
  4. 怎么修复的:把当前 master rebase 进 PR 分支,三个版本文件统一解析为 0.0.198(当前 master 0.0.197 + 1,符合 Kernel Boundary 版本纪律);推送前 fetch 确认远端 head 未变(无并发 agent),以 --force-with-lease 钉死基线 SHA 强推。
  5. 是否有回归问题:无。rebase 只移动版本号,不改任何代码语义;anthropic.ts 自动合并后逐处核对(两个新函数均在、coreToAnthropic 调用顺序保持 master 原序);本地定向验证全绿(kernel typecheck/build 干净、6 个 heal 套件 54/54、master 新增 server-tool 套件 9/9、根侧集成 5/5);CI 全量 30 项 0 失败。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及。未触碰任何缓存/重试/游标逻辑;settleToolDeltaPositions 对合法布局本就提前返回(cache-safe no-op)。
  7. 是否改了设计方向:不涉及。纯冲突消解,未改架构、边界或数据流。
  8. 是否引入了新的配置:不涉及。无新 env / config / 默认值。

判定:冲突已解决(dirty → blocked),定向验证全绿,CI 在新 head c4de64a35a 上 30 项 0 失败。PR 现处可合并状态,仅剩 kernel 变更必需的人工审批(human-only 档,我不代批)。本轮收工。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Findings-only review — kernel PR, cannot approve per HARD RULE (merge waits on owner human tier).

Verdict: code correct, tests comprehensive, no blocking findings. Routed to owner for kernel approval.

1. Correctness (PASS). settleToolDeltaPositions (kernel/src/wire/anthropic.ts:454) relocates tool-delta carriers to the earliest forward slot legal under BOTH halves of the position rule; no forward slot → fallback to #5438 demote UNCHANGED + [acp-kernel] warn naming dropped tools. Plain systems keep the #5438 demote byte-for-byte. Legal layouts = cache-safe no-op (early return). The prevNonSystem tracking in the demote pass is valid (settle runs first, finalizes the array).

2. Tests (PASS). New kernel/tests/issue4818-tool-delta-relocation.test.ts (+264): 6 tests — exact #4818 repro, flap sequence, fallback demote+warn, negative direction (legal layouts byte-identical, #3617 both directions), warn-name fix (nested tool_removal shape). The assertChainResolved oracle encodes the #4818 400 invariant (every tool_removal must reference a tool an earlier tool_addition put live). Modified test files (issue4292, issue4457, issue4570, issue5432, anthropic-system-message-passthrough, tests/issue4292) aligned to new behavior, not weakened — assert relocation for carriers, demote for plain systems, no illegal-position system remains.

3. Risks. Behavior change (disclosed in PR body): illegal-position tool-delta carriers old=revoice user+strip, new=relocate verbatim (demote only when no slot + warn). No security risk. No data-loss risk — the fix PREVENTS silent tool loss.

4. House conventions (PASS). Kernel Boundary: version 0.0.197→0.0.198 ✓, kernel-change: declaration ✓, kernel: commit prefix ✓. Gate Test Discipline (#3617): both directions asserted ✓. No as any/@ts-ignore ✓. console.warn consistent with kernel convention (3 existing uses) ✓.

Non-blocking observation (safe, first noted floor 5): the settle slot search uses the immediate predecessor out[pos-1] for the follow half, while isLegalSystemSlot skips back over the system run. When the insertion point is right after another system, the search is slightly more conservative (may fall back to demote where a relocate would work). SAFE — never produces an illegal layout. Not a defect.

No small mechanical findings to fix. Code clean, tests comprehensive, comments accurate.

Gated diff (owner approval): kernel/src/wire/anthropic.ts (+101), kernel/package.json (0.0.197→0.0.198), kernel/tests/* (6 files), tests/issue4292-anthropic-fold-orphan-system.test.ts.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策

PR #5800 (kernel) requires owner authorization for merge.

The PR touches kernel/ and carries a kernel-change: declaration. Per the Kernel Boundary (human-only review tier, always) and the review-lane HARD RULE, I cannot approve — the merge waits on your human approval.

Gated diff: kernel/src/wire/anthropic.ts (+101: carriesToolDelta, isLegalSystemSlot, settleToolDeltaPositions, modified healIllegalSystemPositions), kernel/package.json (0.0.197→0.0.198), kernel/tests/* (6 test files), tests/issue4292-anthropic-fold-orphan-system.test.ts.

My review verdict (findings-only, above): code correct, tests comprehensive, no blocking findings. The fix resolves #4818 (tool-delta chains split by demote-strip → hard 400 tool_reference_unresolved / silent tool loss) by relocating carriers to the earliest forward legal slot, with a safe fallback to demote+warn.

Request: please review and approve (or request changes) at your discretion. The human-only kernel review tier is the required gate.

@ranxianglei
ranxianglei force-pushed the 2026-11-06_tool-delta-relocate-heal branch from c4de64a to 6e96e24 Compare November 18, 2026 19:45
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved (second occurrence) on PR #5800 (2026-11-06_tool-delta-relocate-heal) — rebased onto current master (a446a3c1c8), conflicts resolved, force-pushed. New head: 6e96e24edf.

What I did this run (all verified live in this run):

  • Wake-state check: the previous run's head c4de64a35a was clean (no [ework:ci-held] marker — it had completed normally). Since then master advanced 273 commits to a446a3c1c8, moving acp-kernel from 0.0.198 to 0.0.199 and adding a root devDependency (@deepseek-ai/cordis) — re-dirtying the PR.
  • Rebase: the 3 PR commits replayed with conflicts in only the 3 version/lockfile lines again (kernel/package.json, kernel/package-lock.json, root package-lock.json — master 0.0.199 vs PR 0.0.198). Resolved all to 0.0.200 (= current master 0.0.199 + 1, per the Kernel Boundary bump rule). kernel/src/wire/anthropic.ts was not touched by master since my last rebase and applied cleanly; I re-verified the file still carries both features (settleToolDeltaPositions + healUnpairedServerToolBlocks) with the coreToAnthropic call order intact.
  • Targeted validation (full suite left to CI): root + kernel deps re-synced to the new lockfile · kernel typecheck clean · kernel build clean · 63/63 across the six kernel heal suites + master's server-tool-pair-heal / regression-bili-470 · 5/5 root integration tests/issue4292-anthropic-fold-orphan-system.test.ts.
  • Push discipline: fetched first, confirmed the remote head was still c4de64a35a (no concurrent agent), then --force-with-lease pinned to that exact SHA. This push is the final head (work verified locally), so per the CI-hold policy it carries no [ework:ci-held] marker — it is the branch's one full CI pass.
  • Live result (mirror cache, fetched this run): mergeable_state went dirty → blocked (conflict-free; blocked = awaiting CI + human approval only). CI re-ran on 6e96e24edf: 17 check-runs already completed (4 success + 13 skipped), zero failures; the remaining test shards were still in progress/queued when I stopped.

Honest status note: the mirror cache stopped refreshing ~13 minutes ago (last fetch still shows the shards in flight), so I could not verify full CI completion this run — I'm not asserting green. The conflict itself is resolved and verified; if any shard goes red, the auto-fix lane will pick it up on the next wake.

No PR-body edits, no new issues, no design decisions needed — pure mechanical conflict resolution again.


结构化八问

  1. 是什么问题:PR [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800(工具增量 system「重定位而非降级」内核修复)与 master 第二次出现合并冲突(merge state = dirty),PR 无法合并。
  2. 什么原因导致的:master 在上轮 rebase(f21b601893)后又前进 273 提交到 a446a3c1c8,期间 acp-kernel 从 0.0.198 推进到 0.0.199、根 package-lock 新增 devDependency;三处版本/锁文件行再次冲突。代码文件 anthropic.ts 本轮 master 未触碰,干净应用。
  3. 影响范围与严重程度:仅该 PR 自身的合并能力被阻塞,不影响任何已发布行为或运行中会话;严重度低——阻塞性、非功能性。
  4. 怎么修复的:把当前 master rebase 进 PR 分支,三个版本文件统一解析为 0.0.200(当前 master 0.0.199 + 1,符合 Kernel Boundary 版本纪律);推送前 fetch 确认远端 head 未变(无并发 agent),以 --force-with-lease 钉死基线 SHA 强推;本次为最终 head 推送,按 CI-hold 政策不带 [ework:ci-held] 标记。
  5. 是否有回归问题:无。rebase 只移动版本号,不改任何代码语义;本地定向验证全绿(kernel typecheck/build 干净、6 个 heal 套件 + master 新增 server-tool 套件 63/63、根侧集成 5/5);CI 新 head 已完成项 0 失败(全量完成未及验证,见上)。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及。未触碰任何缓存/重试/游标逻辑;settleToolDeltaPositions 对合法布局本就提前返回(cache-safe no-op)。
  7. 是否改了设计方向:不涉及。纯冲突消解,未改架构、边界或数据流。
  8. 是否引入了新的配置:不涉及。无新 env / config / 默认值(master 侧新增的 @deepseek-ai/cordis 是其自身变更,非本 PR 引入)。

判定:冲突已解决(dirty → blocked,实测确认),定向验证全绿,已强推最终 head 6e96e24edf 触发本轮唯一一次完整 CI;CI 全量结果待镜像缓存刷新后确认(本轮未断言绿)。PR 合并仍需 kernel 变更必需的人工审批(human-only 档,我不代批)。本轮收工。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-review (head advanced c4de64a → 6e96e24): PR rebased onto a newer master, code unchanged.

The PR was rebased onto a newer master (a446a3c1c8, batch11-wave11). I verified:

  • Code IDENTICAL: kernel/src/wire/anthropic.ts and all 6 test files are byte-identical to the previously reviewed head (c4de64a).
  • Version bump updated: 0.0.197→0.0.198 became 0.0.199→0.0.200 (the new base has kernel at 0.0.199; the bump is correct per the Kernel Boundary rule).
  • No new code changes, no new findings.

My previous review verdict stands (findings-only, above): code correct, tests comprehensive, no blocking findings. The single non-blocking observation (conservative slot search — safe, never produces an illegal layout) is unchanged.

Still routed to owner for kernel approval (HARD RULE — kernel PR, human-only tier). The 🔶 需要决策 comment and needs-decision label from the previous round remain in effect.

ci-check added 3 commits November 19, 2026 19:50
)

The fallback diagnostic read removals as flat tool_reference/tool_name only, printing 'unknown' for the production Claude Code shape {tool:{type:tool_reference,name}}. Read b.tool.name first (mirrors the addition branch), keep the flat fallbacks for synthetic test shapes. Adds a regression pin driving the real nested removal through the no-slot warn path.
…demote behavior

issue4570-system-position-final-wire.test.ts still asserted the old
demote+strip-on-demotion behavior (WC-022) for tool-delta carriers. The
#4818 change relocates those carriers verbatim instead of stripping them,
so two subtests now pin the relocated output: deltas preserved, layout
legal. This completes the set of stale pins the PR already updated in
issue4457-sidecar-system-folds / issue4292-orphan-system-guard /
issue5432-follow-side-heal / anthropic-system-message-passthrough / root
tests/issue4292-anthropic-fold-orphan-system.

Test-only; no kernel/src change, no version bump.
@ranxianglei
ranxianglei force-pushed the 2026-11-06_tool-delta-relocate-heal branch from 6e96e24 to 329b263 Compare November 19, 2026 11:51
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict rebase run 3 — done. This time it was a real code conflict, not just version lines.

What I did this run:

  1. Live state check: master had advanced 21 commits (a446a3c1c8 → 6453feeeb, Merge PR [PR] perf: batch-1 hash dedup — anonymous-lane v1 skip + incremental wire-hash pair (#7149) #7151); PR head was still 6e96e24edf (clean, no [ework:ci-held] marker — the previous run had completed normally).
  2. Why it conflicted for real this time: master's [Bug][anthropic][opencode] 0.1.216: After degenerate fold, messages[2] system is dispatched as-is (bypassing the final h | [Bug][anthropic][opencode] 0.1.216: degenerate fold 后 messages[2] system 原样出站(越过最终 healAnthropicSystemPositions)→ 400 must precede … #7270 change (issue7270-directive-only-precede-heal) modified the SAME function this PR modifies — healIllegalSystemPositions in kernel/src/wire/anthropic.ts. Directive-only systems (empty content + output_config) are no longer skipped unconditionally: when their PRECEDE side is illegal they are now moved to the trailing run.
  3. Rebased the 3 PR commits and resolved:
  4. Validated (targeted, full suite = CI): deps re-synced (npm ci root + kernel), kernel typecheck clean, kernel build success, 68/68 kernel tests across 9 suites (6 heal suites + master's server-tool-pair-heal + regression-bili-470 + the NEW issue7270-directive-only-precede-heal.test.ts), 5/5 root integration test.
  5. Pushed final head 329b263f6 with --force-with-lease pinned to the verified-unchanged remote head 6e96e24edf (unmarked — this is the branch's one full CI pass).
  6. Mirror cache: still stale — cached sha is the OLD head 6e96e24edf (fetched_at 2026-11-18T20:19:46Z), so I cannot verify the new head's CI or merge state live and am not asserting it. One positive from the stale cache: the old head's CI is now shown fully complete, 30/30 checks, 0 failures — confirming the completion that was unverified in the previous run.

结构化八问

  1. 是什么问题:PR 分支与 master 再次冲突——master 前进 21 个提交,其中 [Bug][anthropic][opencode] 0.1.216: After degenerate fold, messages[2] system is dispatched as-is (bypassing the final h | [Bug][anthropic][opencode] 0.1.216: degenerate fold 后 messages[2] system 原样出站(越过最终 healAnthropicSystemPositions)→ 400 must precede … #7270 改动了本 PR 修改的同一个函数(healIllegalSystemPositions),这次是真正的代码冲突而非仅版本行。
  2. 什么原因导致的:[Bug][anthropic][opencode] 0.1.216: After degenerate fold, messages[2] system is dispatched as-is (bypassing the final h | [Bug][anthropic][opencode] 0.1.216: degenerate fold 后 messages[2] system 原样出站(越过最终 healAnthropicSystemPositions)→ 400 must precede … #7270(directive-only system 在 PRECEDE 侧非法时移到尾部 run)与 [Bug][anthropic][claude-code] 0.1.208: the system-position heal drops a tool_addition but keeps the later tool_removal for the same tool → 400 tool_reference_unresolved #4818(tool-delta carrier 重定位)都改 kernel/src/wire/anthropic.ts 的同一函数,文本区域重叠;另外 master 与 PR 各自独立地把 kernel 版本 0.0.199→0.0.200,合并后累计 diff 不显示版本提升。
  3. 影响范围与严重程度:仅影响本 PR 的合并状态(dirty 需解冲突才能合并),对用户无影响;解完后两个特性行为都保留。
  4. 怎么修复的:rebase 三个 PR commit,手工合并两处冲突区(保留 master 的 [Bug][anthropic][opencode] 0.1.216: After degenerate fold, messages[2] system is dispatched as-is (bypassing the final h | [Bug][anthropic][opencode] 0.1.216: degenerate fold 后 messages[2] system 原样出站(越过最终 healAnthropicSystemPositions)→ 400 must precede … #7270 directive 块,PR 的 carrier skip 检查放在其后;头注释合并双方描述),版本手动提升到 0.0.201。
  5. 是否有回归问题:无。两特性正交性已验证——directive-only system 不可能携带 tool delta(空 content + output_config),移动 system 对其他消息的位置判定透明;68/68 kernel 测试(含 master 新增的 [Bug][anthropic][opencode] 0.1.216: After degenerate fold, messages[2] system is dispatched as-is (bypassing the final h | [Bug][anthropic][opencode] 0.1.216: degenerate fold 后 messages[2] system 原样出站(越过最终 healAnthropicSystemPositions)→ 400 must precede … #7270 套件)+ 5/5 根集成测试全过。
  6. 是否破坏缓存:否。settle pass 在健康会话上是 no-op(cache-safe),[Bug][anthropic][opencode] 0.1.216: After degenerate fold, messages[2] system is dispatched as-is (bypassing the final h | [Bug][anthropic][opencode] 0.1.216: degenerate fold 后 messages[2] system 原样出站(越过最终 healAnthropicSystemPositions)→ 400 must precede … #7270 改动不触及 carrier 路径。
  7. 是否改了设计方向:否,纯合并冲突解决,无设计变更。
  8. 是否引入了新的配置:否。

判定:冲突已解决并推送(329b263f6),本地定向验证全绿;镜像缓存滞后,新 head 的 CI 状态本轮无法实时验证(不臆断),待 CI 完成 + kernel 人工审批后由 owner 合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-review (head advanced 6e96e24 → 329b263): PR rebased again, code functionally unchanged.

The PR was rebased onto a newer master (6453feeeb, hash-cleanup-batch1). I verified:

My previous review verdict stands (findings-only, above): code correct, tests comprehensive, no blocking findings. The single non-blocking observation (conservative slot search — safe, never produces an illegal layout) is unchanged.

Still routed to owner for kernel approval (HARD RULE — kernel PR, human-only tier). The 🔶 需要决策 comment and needs-decision label remain in effect.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Status update: The re-review of PR #5800 (head advanced 6e96e24 → 329b263) is complete — my full re-review reply is already in the thread above (floor 69). Summary:

Verdict stands (findings-only): code correct, tests comprehensive, no blocking findings. Still routed to owner for kernel approval (HARD RULE — kernel PR, human-only tier). The 🔶 需要决策 comment and needs-decision label remain in effect. PR #5800 is OPEN, pending owner human approval. No further action needed from me.

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

2 participants