Skip to content

[PR] fix(zcode): normalize sess_ prefix + ring-record non-plugin tool calls (#6433) - #6472

Open
ranxianglei wants to merge 12 commits into
masterfrom
2026-11-13_zcode-sess-prefix-normalization
Open

ranxianglei wants to merge 12 commits into
masterfrom
2026-11-13_zcode-sess-prefix-normalization

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Two zcode defects in one PR (same thread, same root area — the zcode shim ↔ proxy identity/routing seam):

  1. sess_ prefix never stripped — zcode bootstrap-hook injects CLAUDE_CODE_SESSION_ID=sess_<uuid>; the proxy keys sessions by bare uuid. Neither side stripped the prefix, so the shim's default binding always 404'd with unknown plugin conversation.
  2. Subagent MCP calls structurally unrouteable — the unbound zcode subagent shim (no CLAUDE_CODE_SESSION_ID) routes via the witness ring, but the ring was only fed by the plugin-mode response pipe (settleWitnesses), which early-returns when no session object is passed. The non-plugin lane deliberately passes undefined to keep usage accounting off, so a subagent's own outbound tool calls were never ring-recorded and the witness route always missed.

How

Fix 1 (stripSessPrefix): new helper in src/session-id.ts that trims and strips a leading sess_. Applied at all 3 id-extraction points:

  • src/mcp.ts CONVERSATION_FROM_ENV (shim-side env read)
  • src/plugin.ts handlePluginTool body conversationId (proxy-side body parse)
  • src/session-id.ts conversationHeaderSource header walk (proxy-side header parse)

Fix 2 (witnessSessionId): optional last param on pipePluginChatWithStrip and pipePluginResponsesWithStrip; settleWitnesses now records under witnessSessionId ?? session?.id, so the witness ring is fed on the non-plugin lane while usage accounting stays off. relay.ts non-plugin SSE branch passes p.session?.id.

Tests

  • tests/proxy-session-id.test.ts: 2 new cases (stripSessPrefix unit + header normalization), 23/23 pass.
  • tests/tool-ring.test.ts: 24/24 pass (no regression).
  • tests/tool-witness-pipes.test.ts: 7/7 pass (no regression).
  • Typecheck clean.

Related

Closes #6433

ci-check added 2 commits November 13, 2026 02:43
…roxy session (#6433)

zcode's bootstrap-hook injects CLAUDE_CODE_SESSION_ID with a sess_ prefix
(sess_<uuid>), but the proxy's plugin routing keys sessions by the bare uuid
(the model request header carries the bare form). Neither side stripped the
prefix, so the shim's default binding always 404'd with 'unknown plugin
conversation'.

Fix: strip the sess_ prefix at all three id-extraction points:
- src/mcp.ts: CONVERSATION_FROM_ENV (shim env binding)
- src/plugin.ts: handlePluginTool body conversationId (defensive, for older shims)
- src/session-id.ts: conversationHeaderSource (model request header, for robustness)

The shared stripSessPrefix helper lives in src/session-id.ts. No other client
uses this prefix (grep-verified), so a global strip is safe.
…e lane (#6433)

The unbound zcode subagent shim (no CLAUDE_CODE_SESSION_ID) routes via the
witness ring, but the ring was only fed by the plugin-mode response pipe
(settleWitnesses), which early-returns when no session object is passed. The
non-plugin lane deliberately passes undefined to keep usage accounting off,
so a subagent's own outbound tool calls were never ring-recorded and the
witness route always missed.

Add an optional witnessSessionId parameter to pipePluginChatWithStrip and
pipePluginResponsesWithStrip; settleWitnesses now records under that id even
when the full session is absent, so usage accounting stays off while the
witness ring is still fed. The non-plugin SSE branch in relay.ts passes
p.session?.id as the witness id.
@ranxianglei ranxianglei added bug Something isn't working p2 scope/wiring zcode 改动范围:内核之外的主机侧接线(src/agent 适配器、server 路由、注入拦截)/范围兜底/客户端标签 labels Nov 12, 2026
@ranxianglei ranxianglei changed the title fix(zcode): normalize sess_ prefix + ring-record non-plugin tool calls (#6433) [PR] fix(zcode): normalize sess_ prefix + ring-record non-plugin tool calls (#6433) Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-13_zcode-sess-prefix-normalization (155e7e4)

Latest build — install this exact version

npm install -g billion-context@0.0.10202-pr.6472.a50a479

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
155e7e4 billion-context@0.0.10202-pr.6472.a50a479 build
3ee5770 billion-context@0.0.9901-pr.6472.8f501bb build
71c754b billion-context@0.0.9869-pr.6472.1e803c5 build
908c34c billion-context@0.0.9395-pr.6472.a6cd8df build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: qwen/qwen3.8-27b) PR #6472 review.

Duplicate screening: Not a duplicate. Two distinct zcode defects in the same root area (zcode shim ↔ proxy identity/routing seam). Related to #4661/PR#4691 (zcode doesn't inject session id, not merged) — that's the OTHER HALF of the same root area (Problem A here is "injected but prefixed, resolution fails"; #4661 is "not injected at all"). Different mechanisms, same root area — correctly kept in one PR.

Reviewed the full 5-file diff at head 908c34ca7f, traced all session-id extraction points, and verified the witness-ring call graph. CI is still running (in_progress/queued on the mirror cache) — full-suite verdict is from CI.

8-question review (8问):

  1. 是什么问题: zcode 两个缺陷。(A) bootstrap-hook 注入 CLAUDE_CODE_SESSION_ID=sess_<uuid>(带前缀),但代理按裸 uuid 键控会话,两侧都不剥前缀 → shim 默认绑定永远 404 "unknown plugin conversation"。(B) zcode 子代理(Task/Agent 工具)复用服务级未绑定 shim(无 CLAUDE_CODE_SESSION_ID),路由走见证环,但环只由插件车道响应管喂(settleWitnesses 无 session 时早退),非插件车道刻意传 undefined(用量核算关)→ 子代理自身的出站工具调用从未被环记录 → 见证路由永远 miss → "cannot route tool ... N conversations active — refuse to guess"。

  2. 什么原因导致的: (A) 前缀不对称:zcode 的 env 注入带 sess_ 前缀,但代理的 header/body 解析按裸值键控,两侧都不归一化。(B) 见证环喂给路径不完整:settleWitnesses 依赖 session 对象,非插件车道传 undefined(为关用量核算),导致非插件车道的出站工具调用从未被环记录。

  3. 影响范围与严重程度: (A) 所有 zcode 会话的 shim 默认绑定(BILI_MCP_PROXY 指向代理时)全部 404,zcode 用户无法使用 mcp__bili__* 工具的默认绑定路径(需手动 pin 或 prompt 子代理不调用)。(B) zcode 子代理的出站工具调用全部无法路由(≥2 个 fresh 会话时 refuse to guess)。严重程度:p2(用户有 workaround——pin BILI_MCP_PROXY 到常驻实例 + prompt 子代理不调 mcp__bili__*——但核心功能坏了)。

  4. 怎么修复的: (A) 新增 stripSessPrefix helper(trim + 剥 sess_ 前缀),在全部 3 个 id 提取点一致应用:src/mcp.ts env 读取、src/plugin.ts body 解析、src/session-id.ts header 遍历。两侧(shim env + proxy header/body)都归一化 → 永远匹配。(B) pipePluginChatWithStrip / pipePluginResponsesWithStrip 加可选末参 witnessSessionId,settleWitnesses 改为 witnessSessionId ?? session?.id,非插件车道传 p.session?.id → 见证环在非插件车道被喂,用量核算保持关。

  5. 是否有回归问题:

    • 插件车道:session 传入时 witnessSessionId 为 undefined,sid = session.id,行为不变。✓
    • 非插件车道:环从"不喂"变为"喂",是正确性改进——消除了一个误路由 bug(非插件会话的工具调用被误路由到碰巧做了相同调用的插件会话)。但有一个行为变更:对歧义 case(多个会话做了相同工具调用),路由从"误路由到插件会话(静默错)"变为"refuse to guess(显式正确)"。这是正确行为变更,但 PR 描述未显式披露(按 AGENTS.md 行为变更披露规则应补充)。
    • GAP(非阻塞)— 非流式 JSON 路径未喂环:relay.ts:2579 非插件车道 pipePluginJson(responseBody, res, undefined, ...) 传 undefined,而 pipePluginJson 内部的 recordJsonToolWitnesses(src/plugin.ts:5130)只在 session 非空时记录。PR 只扩展了两个 SSE 管(pipePluginChatWithStrip/pipePluginResponsesWithStrip),未扩展 JSON 管。对非流式非插件会话,见证仍不记录。zcode 子代理的模型流量大概率是流式(SSE),所以本 PR 的主 case 能修好;但非流式 case 是残留缺口。
    • 测试覆盖 GAP:PR 未为非插件车道的 witnessSessionId 路径加测试。tests/tool-witness-pipes.test.ts(7/7)只测 SSE 管的既有行为,未验证 session=undefined 时 witnessSessionId 被用于环记录。Fix 2 的核心路径无回归测试钉住。
  6. 是否破坏缓存: 不涉及。改动不触碰缓存/重试/增量游标/去重键。

  7. 是否改了设计方向: 无架构/边界/数据流转向。stripSessPrefix 是对 session-id "verbatim" 原则的有理由偏离(zcode 的 env/header 不对称),代码注释已披露,grep 验证无其他客户端用 sess_ 前缀键控会话,UUID 是 hex 不可能以 sess_ 开头(无碰撞)。witnessSessionId 是对见证环喂给路径的扩展(插件车道 → 非插件车道),不改变环的语义。

  8. 是否引入了新的配置: 不涉及。无新 env/config/默认值。

结论: 方向正确。Fix 1 完整且安全(3 个提取点全覆盖、两侧一致、无碰撞)。Fix 2 对 SSE(流式)case 正确且是正确性改进(消除误路由 bug)。两个 GAP(非流式 JSON 路径未喂环 + 非插件车道 witnessSessionId 无测试)建议 follow-up 补上,不阻塞本 PR。CI 仍在跑,全量判定以 CI 为准。

建议(follow-up,不阻塞):

  1. 补非插件非流式 JSON 路径(relay.ts:2579 pipePluginJson)的见证环喂给——加 witnessSessionId 参数(同 SSE 管),非插件车道传 prepared.session?.id。
  2. 补非插件车道 witnessSessionId 路径的测试(验证 session=undefined 时 witnessSessionId 被用于 recordToolWitness)。
  3. PR 描述补充披露行为变更:歧义 case 从"误路由"变为"refuse to guess"。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: qwen/qwen3.8-27b) CI update: green — 30/30 checks complete, 14 success + 16 skipped, 0 failed (head 908c34ca7f).

Final verdict: 可合。Fix 1(stripSessPrefix)完整且安全;Fix 2(witnessSessionId)对 SSE 流式 case 正确且是正确性改进。两个非阻塞 GAP(非流式 JSON 路径未喂环 + 非插件车道 witnessSessionId 无测试)建议 follow-up 补上,不阻塞本 PR 合并。

ci-check added 3 commits November 14, 2026 13:40
Resolve the signature conflict: both this PR (#6433, witnessSessionId)
and master (#5951, hostOwnsTruncationRecovery) added a new last param to
pipePluginChatWithStrip / pipePluginResponsesWithStrip. Keep
hostOwnsTruncationRecovery in its original position and append
witnessSessionId after it; the 3 non-plugin call sites in relay.ts pass
hostOwnsTruncationRecovery first, then the witness id.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 工程师接管完成:冲突已解、继承红项已收敛、已推送,CI 正在新 head 上跑。

做了什么

  • 解掉 PR 与 master 的签名冲突(src/plugin.ts + src/server/relay.ts)。
  • 合并 ci-fixes(11 个 master 级 test-pinning 修复)+ 新 master(update-inplace-backup 修复),清掉继承红。
  • 本地定向验证:typecheck 干净 + PR 自带测试 23/23 + tool-ring 26/26 + plugin-protocol 23/23。
  • 已推送到 PR 分支(908c34ca7f → 71c754bec3,fast-forward,PR 原 2 个 commit 完整保留)。

八问

  1. 是什么问题:PR [PR] fix(zcode): normalize sess_ prefix + ring-record non-plugin tool calls (#6433) #6472 与 master 产生合并冲突(两个 PR 在同一位置给同一 pipe 函数追加了新的尾参);同时 PR 的 CI 红是继承自 master 的(JSON-writer e2e 抖动 + notice-registry pin),不是本 PR 代码问题。
  2. 什么原因:[Bug][zcode] ① bound shim sends sess_-prefixed session id that the proxy never resolves ("unknown plugin conversation"); ② subagent (Task/Agent tool) MCP calls are structurally unrouteable — "cannot route tool … N conversations active" #6433(本 PR)和 Replay a stream cut that lands after reasoning-only output #5951(master)各自给 pipePluginChatWithStrip / pipePluginResponsesWithStrip 的同一位置追加了新尾参 → 文本冲突。红项是 master 既有的 e2e 抖动,与本 PR 无关。
  3. 影响范围与严重程度:冲突面 = 2 个文件的签名 + relay 里 3 个非插件调用点。若解错会破坏非插件响应车道(witness ring 记录)或 Replay a stream cut that lands after reasoning-only output #5951 的 host-owns-truncation-recovery 路径。已正确解决,无运行时影响。
  4. 怎么修复:保留 master 的 hostOwnsTruncationRecovery 在原位置,把本 PR 的 witnessSessionId 追加在其后;relay 的 3 个非插件调用点先传 hostOwnsTruncationRecovery 再传 witness id。两个语义都完整保留。
  5. 是否有回归:审过既有行为——Replay a stream cut that lands after reasoning-only output #5951(host 自管截断恢复)与本 PR(witness ring 记录)语义都完整保留,无漂移;typecheck + 4 组定向测试全绿。
  6. 是否破坏缓存:不涉及——未触碰 cache/retry/cursor/dedup 逻辑。
  7. 是否改了设计方向:不涉及——纯机械冲突解决 + 收敛 master 修复,无架构改动。
  8. 是否引入新配置:不涉及。

待办:CI 正在新 head 71c754bec3 上跑(全套件由远程 CI 把关),结果出来后我报最终判定。之前 review 记的 2 个非阻塞 GAP(非流式 JSON 路径 pipePluginJson 未喂 witness ring;非插件 witnessSessionId 路径无测试)保持原状,不影响本次合入。

判定:冲突与红项已一次处理完,代码侧就绪,等 CI 绿即可合。

…ON lane (#6433)

The witnessSessionId seam added by this PR covered only the two SSE pipes
(pipePluginChatWithStrip / pipePluginResponsesWithStrip). The non-streaming
non-plugin lane (relay.ts pipePluginJson) still passed no session, so a
non-streaming subagent's outbound tool calls were never ring-recorded and the
unbound shim's witness route kept missing them.

Mirror the SSE pattern: pipePluginJson takes an optional trailing
witnessSessionId and records under witnessSessionId ?? session?.id; the relay
JSON branch passes prepared.session?.id. Plugin-lane callers are unaffected
(session already passed, witnessSessionId omitted). Adds the missing
non-plugin witnessSessionId regression tests (SSE + JSON).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #6472 审核(head 3ee5770cbc,含我顺手补的 JSON 车道修复 commit)。

查重:不重复。两个独立的 zcode 缺陷,同一根因区域(zcode shim ↔ 代理身份/路由缝)。与 #4661/PR#4691 相关但机制不同——那是「根本没注入 session id」,本 PR 是「注入了但带 sess_ 前缀、解析失败」,是同一根因区的另一半,正确合在一个 PR。

独立审核:未照抄前几轮结论。自己重读了 5 文件 diff、追踪了 witness ring 的完整调用图(settleWitnesses / recordJsonToolWitnesses / handlePluginTool 路由阶梯)、grep 验证了 sess_ 前缀唯一性、核对了 relay.ts 四个非注入分支各自传了什么。

8问:

  1. 是什么问题:zcode 两个缺陷。(A) bootstrap-hook 注入 CLAUDE_CODE_SESSION_ID=sess_<uuid>(带 sess_ 前缀),但代理按裸 uuid 键控会话,两侧都不剥前缀 → shim 默认绑定永远 404 "unknown plugin conversation"。(B) zcode 子代理(无 CLAUDE_CODE_SESSION_ID)复用服务级未绑定 shim,路由走见证环,但环只由插件车道响应管喂(settleWitnesses 无 session 时早退),非插件车道刻意传 undefined(关用量核算)→ 子代理自身的出站工具调用从未被环记录 → 见证路由永远 miss → "cannot route tool … refuse to guess"。

  2. 什么原因:(A) 前缀不对称——env 注入带 sess_,header/body 解析按裸值键控,两侧都不归一化。(B) 见证环喂给路径不完整——settleWitnesses 依赖 session 对象,非插件车道传 undefined,导致非插件车道的出站工具调用从未被环记录。

  3. 影响范围与严重程度:(A) 所有 zcode 会话的 shim 默认绑定(BILI_MCP_PROXY 指向代理时)全部 404。(B) zcode 子代理的出站工具调用全部无法路由(≥2 个 fresh 会话时 refuse to guess)。p2——有 workaround(pin BILI_MCP_PROXY 到常驻实例 + prompt 子代理不调 mcp__bili__*),但核心功能坏了。

  4. 怎么修复的:(A) stripSessPrefix helper(trim + 剥 sess_ 前缀),在全部 3 个 id 提取点一致应用——src/mcp.ts env 读取、src/plugin.ts handlePluginTool body 解析、src/session-id.ts conversationHeaderSource header 遍历(conversationHeaderSource 是 header 解析的唯一入口,一处改全覆盖所有 header 调用点)。两侧(shim env + proxy header/body)都归一化 → 永远匹配。(B) 响应管加可选末参 witnessSessionId,settleWitnesses/recordJsonToolWitnesses 改为 witnessSessionId ?? session?.id,非插件车道传 prepared.session?.id → 见证环在非插件车道被喂,用量核算保持关。

  5. 是否有回归:逐项审过既有行为——

    • 插件车道:session 传入时 witnessSessionId 为 undefined,sid = session.id,行为字节不变。✓
    • 非插件车道:环从「不喂」变「喂」,是正确性改进——非插件会话现在可被见证环路由到(之前对环不可见)。歧义 case(多会话做了相同工具调用)从「误路由到碰巧做了相同调用的插件会话(静默错)」变「refuse to guess(显式正确)」,是改进不是回归。
    • stripSessPrefix 唯一性:只剥 sess_(双 s);opencode 的 ses_(单 s,subagent-sessions.ts 的 SES_ID_RE = /^ses_[A-Za-z0-9]+$/、thirdparty-scan.ts)不受影响;grep 验证 src/ 内除本 PR 外无其他客户端用 sess_ 前缀;UUID 是 hex 不可能以 sess_ 开头(无碰撞)。✓
    • JSON 车道:原 PR 只扩展了两个 SSE 管,非流式 pipePluginJson 仍传 undefined → 非流式子代理的出站工具调用仍不被环记录(残留缺口)。我已补齐(见下)。
    • 缓存/时序/输出格式:不触碰。✓
  6. 是否破坏缓存:不涉及。改动不触碰 cache/retry/增量游标/去重键。

  7. 是否改了设计方向:无架构/边界/数据流转向。stripSessPrefix 是对 session-id「verbatim」原则的有理由偏离(zcode env/header 不对称),注释已披露;witnessSessionId 是对见证环喂给路径的扩展(插件车道 → 非插件车道),不改变环的语义。

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

已顺手修:非流式 JSON 车道的见证环喂给缺口(原 PR 只扩展了 SSE 管,relay.ts:2620 的 pipePluginJson 仍传 undefined,非流式子代理的出站工具调用仍不被环记录)+ 补非插件 witnessSessionId 路径的回归测试(SSE + JSON 各一,钉住 session=undefined 时环按 witnessSessionId 记录)。commit 3ee5770cbc。本地验证:typecheck 干净 + proxy-session-id 23/23 + tool-witness-pipes 9/9 + tool-ring 26/26 全绿。

ci-fixes 说明:diff 里 tests/e2e/*、tests/notice-registry.test.ts、tests/plugin-fork.test.ts、tests/fork-ccr-adoption.test.ts 的改动是 CI 工程师合并 origin/ci-fixes 带进来的 master 级 test-pinning(BILI_STORAGE_JSON_WRITER=on / BILI_STORAGE_UNIFIED=sqlite,对应 pure-sqlite 默认 #6480),不是本 PR 的改动,按 CI 协调政策(2026-10-24)属正常继承,不阻塞。

CI:我推了新 head 3ee5770cbc(JSON 车道修复 + 测试),CI 在新 head 上重跑中(旧 head 71c754bec 全绿)。全量判定以 CI 为准。

判定:方向正确,两个缺陷都修到根因(前缀不对称 + 见证环喂给路径不完整);我补齐 JSON 车道缺口后 SSE+JSON 全覆盖,测试钉住核心路径。可合(等 CI 绿)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #6472 审核完成,判定:可合(等 CI 绿)。

做了什么:

  1. 独立审核了 PR 的 5 文件 diff(stripSessPrefix + witnessSessionId),追踪了 witness ring 完整调用图,grep 验证了 sess_ 前缀唯一性(ses_ 单 s 不受影响,UUID 是 hex 无碰撞)。
  2. 发现并顺手修了原 PR 的残留缺口:非流式 JSON 车道(pipePluginJson)未喂 witness ring + 非插件 witnessSessionId 路径无回归测试。commit 3ee5770cbc,已推送到 PR 分支。
  3. 本地验证:typecheck 干净 + proxy-session-id 23/23 + tool-witness-pipes 9/9 + tool-ring 26/26 全绿。

状态:CI 在新 head 3ee5770cbc 上重跑中(旧 head 71c754bec 全绿 30/30)。全量判定以 CI 为准。完整 8 问审核见上条。

ework-agent added 6 commits November 14, 2026 16:52
# Conflicts:
#	tests/e2e/e2e-native-dsh-persona.test.ts
#	tests/e2e/e2e-native-dsh.test.ts
#	tests/e2e/e2e-native-opencode.test.ts
#	tests/e2e/e2e-native-pi.test.ts
#	tests/e2e/e2e-pi-codex-ws.test.ts
#	tests/e2e/e2e-subagent-sessions.test.ts
#	tests/notice-registry.test.ts
#	tests/plugin-fork.test.ts
On Windows, new URL(import.meta.url).pathname yields /D:/a/... (leading
slash before the drive), so path.resolve prepends the current drive and
the module-level readFileSync opens D:\D:\a\...\package.json and
crashes the whole test file at import time. import.meta.dirname is the
cross-platform form already used by every sibling e2e test.
# Conflicts:
#	tests/e2e/e2e-selfupdate-cli.test.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict resolved + red item handled

Duplicate screening: not a duplicate — this PR is the zcode sess_ prefix normalization + non-plugin tool-call ring-record; the current CI red is a timing flake in wire-exit-matrix.test.ts abort tests, a different mechanism from the earlier #4347 EBUSY teardown-lock (sqlite handle leak → unlink EBUSY).

What I did

  1. Resolved the conflict: master and the PR both added a new LAST param to pipePluginChatWithStrip / pipePluginResponsesWithStrip (master added hostOwnsTruncationRecovery, the PR added witnessSessionId) → merged as "keep both" (master's first, the PR's after), call sites updated to match.
  2. Merged origin/master (2e3cfc9) + origin/ci-fixes (3544530).
  3. npm run typecheck clean (exit 0); PR tests 32/32 pass (proxy-session-id + tool-witness-pipes).
  4. Pushed (fast-forward, no force) → head 155e7e447.

CI status: 26 success + 1 fail + 1 skipped. The only red = test(windows,22,2) — 2 wire-exit-matrix.test.ts abort tests timing out (21401 ms / 22310 ms, closed=0).

Red-item verdict

  • The failing wire-exit-matrix.test.ts is not in this PR's diff;
  • This PR's relay.ts changes (12 ins / 1 del) do not touch the abort/destroy/socket/close path (grep verified empty);
  • 21–22 s duration + closed=0 = the upstream socket close was delayed beyond the test's budget on the heavily-loaded Windows runner (6 shards in parallel) → a timing flake, not a regression from this PR;
  • Triggered a fresh-runner re-run (HTTP 201) — awaiting the result to confirm.

八问 (8-question checklist)

  1. 是什么问题:PR 与 master 冲突(dirty)+ CI 红(windows 22,2 的 2 个 abort 测试超时)。
  2. 什么原因:冲突 = master 与 PR 都给同一函数加了新的最后一个参数(签名冲突);CI 红 = 负载型 Windows runner 上 abort 测试时序超时(上游 socket 关闭延迟超过测试预算,closed=0)。
  3. 影响范围与严重程度:冲突影响合并(必须解);CI 红是 windows 22,2 时序 flake,不影响 PR 正确性(本 PR 不碰 abort 路径)。
  4. 怎么修复:冲突解为「两个新参数都保留」(master 的在前 + PR 的在后)+ 调用点同步;CI 红触发 fresh runner 重跑验证。
  5. 是否有回归:本 PR 的 relay.ts 改动不碰 abort/destroy/socket/close(grep 空);失败测试不在本 PR diff → 非本 PR 回归。
  6. 是否破坏缓存:不涉及(本 PR 是 zcode sess_ 前缀 + 工具调用 ring-record,不碰缓存)。
  7. 是否改了设计方向:不涉及(冲突解法保留两个新参数,不改变设计)。
  8. 是否引入新配置:不涉及。

Verdict: conflict resolved, PR code correct (typecheck + tests pass), CI red is a windows 22,2 timing flake (not introduced by this PR), fresh-runner re-run triggered — will follow up with the result.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-run result: CI is now fully green

The fresh-runner re-run of the failed test(windows,22,2) job completed with conclusion=success — all jobs passed. This confirms the 2 wire-exit-matrix.test.ts abort test failures were a timing flake (upstream socket close delayed beyond the test's budget on the loaded runner), not a regression from this PR.

Final state

  • Conflict: resolved — merged origin/master (2e3cfc9) + origin/ci-fixes (3544530); the signature conflict resolved as a union of both new params (master's hostOwnsTruncationRecovery first, the PR's witnessSessionId after), call sites updated.
  • typecheck: clean (exit 0); PR tests: 32/32 pass (proxy-session-id + tool-witness-pipes).
  • CI: green (re-run attempt 2, conclusion=success, all jobs passed).
  • PR: mergeable=True, mergeable_state=blocked — "blocked" here means it's waiting for the required human review approval, not a CI or conflict issue.
  • head 155e7e447, base 2e3cfc973.

Verdict: the PR is ready for human review and merge — no conflict, CI green, code correct. The only remaining gate is the required review approval (human-only).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

新 head 155e7e447 复核(CI 工程师合并 origin/master + origin/ci-fixes 后的 merge head)。

这次 head 变了什么:相对我上轮审核的 3ee5770cbc,新 head 只多了两个 merge commit(3a7bf8fef merge origin/master、155e7e447 merge origin/ci-fixes)——把 master 从 1ff89e8785 推进到 2e3cfc973(期间合入 #6824/#6810/#6765 等),并带上 ci-fixes 的 master 级 test-pinning。PR 自身代码 commit 一个没动:8c989a43a(Fix 1 stripSessPrefix)+ 908c34ca7(Fix 2 SSE 管 witnessSessionId)+ 3ee5770cb(我上轮顺手补的 JSON 车道 witnessSessionId + 回归测试)。

独立复核(未照抄上轮):重新拉了新 head 相对新 master(2e3cfc973)的净 diff——现在只剩 6 个核心文件(之前 ci-fixes 的 test-pinning 已随 master 合入,不再出现在 diff 里,diff 反而更干净了):

  • src/session-id.ts:stripSessPrefix helper + conversationHeaderSource 归一化 ✓
  • src/mcp.ts:CONVERSATION_FROM_ENV 用 stripSessPrefix ✓
  • src/plugin.ts:handlePluginTool body 归一化 + 三个响应管(chat/responses/json)的 witnessSessionId 末参 + settleWitnesses/recordJsonToolWitnesses 改 witnessSessionId ?? session?.id ✓
  • src/server/relay.ts:4 个非注入分支各自传 session id(native-compact / SSE responses / SSE chat / JSON)✓
  • tests/proxy-session-id.test.ts(+2 用例)+ tests/tool-witness-pipes.test.ts(+2 用例,我上轮补的)✓

merge 有没有破坏 PR 逻辑:没有。merge 是纯 master/ci-fixes 推进,PR 的 6 个核心文件内容与我上轮审核逐字一致(plugin.ts/relay.ts 的 diff 行数变多只是 merge-base 移动带来的上下文位移,逻辑行没变)。

本地验证(新 head):typecheck 干净(exit 0)+ 定向测试全绿——proxy-session-id 23/23、tool-witness-pipes 9/9(含我上轮补的 2 条)、tool-ring 26/26。
CI:新 head 155e7e447 全绿(30 checks:27 success + 3 skipped,0 failed)。

8问:

  1. 是什么问题:zcode 两个缺陷。(A) bootstrap-hook 注入 CLAUDE_CODE_SESSION_ID=sess_<uuid>(带 sess_ 前缀),但代理按裸 uuid 键控会话,两侧都不剥前缀 → shim 默认绑定永远 404 "unknown plugin conversation"。(B) zcode 子代理(无该 env)复用服务级未绑定 shim,路由走见证环,但环只由插件车道响应管喂(settleWitnesses 无 session 时早退),非插件车道刻意传 undefined(关用量核算)→ 子代理自身出站工具调用从未被环记录 → 见证路由永远 miss → "cannot route tool … refuse to guess"。

  2. 什么原因:(A) 前缀不对称——env 注入带 sess_,header/body 解析按裸值键控,两侧都不归一化。(B) 见证环喂给路径不完整——settleWitnesses 依赖 session 对象,非插件车道传 undefined,非插件车道出站工具调用从未被环记录。

  3. 影响范围与严重程度:(A) 所有 zcode 会话的 shim 默认绑定(BILI_MCP_PROXY 指向代理时)全部 404。(B) zcode 子代理出站工具调用全部无法路由(≥2 个 fresh 会话时 refuse to guess)。p2——有 workaround(pin BILI_MCP_PROXY 到常驻实例 + prompt 子代理不调 mcp__bili__*),但核心功能坏了。

  4. 怎么修复的:(A) stripSessPrefix(trim + 剥 sess_),在全部 3 个 id 提取点一致应用。(B) 三个响应管加可选末参 witnessSessionId,记录逻辑改 witnessSessionId ?? session?.id,非插件车道传 prepared.session?.id → 见证环在非插件车道被喂,用量核算保持关。

  5. 是否有回归:逐项审过既有行为——

    • 插件车道:session 传入时 witnessSessionId 为 undefined,sid = session.id,行为字节不变。✓
    • 非插件车道:环从「不喂」变「喂」,是正确性改进——歧义 case(多会话相同工具调用)从「误路由到碰巧相同调用的插件会话(静默错)」变「refuse to guess(显式正确)」,是改进不是回归。
    • stripSessPrefix 唯一性:只剥 sess_(双 s);opencode 的 ses_(单 s)不受影响;grep 验证 src/ 内除本 PR 外无其他客户端用 sess_ 前缀;UUID 是 hex 不可能以 sess_ 开头(无碰撞)。✓
    • merge 交互:新 head 相对新 master 净 diff 只剩 6 个核心文件,PR 逻辑与上轮逐字一致,merge 未引入任何 PR 侧改动。✓
    • 缓存/时序/输出格式:不触碰。✓
  6. 是否破坏缓存:不涉及。

  7. 是否改了设计方向:无架构/边界/数据流转向。stripSessPrefix 是对 session-id「verbatim」原则的有理由偏离(zcode env/header 不对称,注释已披露);witnessSessionId 是见证环喂给路径的扩展(插件车道 → 非插件车道),不改变环语义。

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

判定:方向正确,两个缺陷都修到根因;我上轮补齐的 JSON 车道缺口 + 回归测试已在新 head 内;merge 干净、无新 PR 代码、CI 全绿、本地定向全绿。可合。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

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

Labels

bug Something isn't working p2 scope/wiring zcode 改动范围:内核之外的主机侧接线(src/agent 适配器、server 路由、注入拦截)/范围兜底/客户端标签

Projects

None yet

1 participant