Repository navigation
fix: zcode — explain the zero-routable-provider case instead of a bare Connection closed (#1892) - #1896
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1927-pr.1896.2730557This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1896.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Acknowledged — this is the [PR] tracking issue for PR #1896 ( |
[bot] 🏷 Review 完成(审核 + 定向验证,未重做)。结论先行:方向正确、代码正确;但审查中发现一个让本 PR 核心价值失效的缺陷,已在 PR 分支补一个独立标注 commit 修掉并验证。另发现 PR 描述里有一处披露失实,见下。 结构化七问
需你处理的一处:PR 描述披露失实"Behavior change disclosure" 引用的两条旧字符串—— 验证与 CI
判定可合并(待 test matrix 转绿;合并操作按规约由人执行)。若你希望我把披露段文案直接改掉或再调整措辞,说一声即可。 |
[bot] 🏷 补一条 CI 状态更新:上轮回复后 红的是什么: 与本 PR 无关的证据:
当前状态:head |
|
零可路由 provider 是啥? |
[bot] 🏷 解释一下,直接回答你两个问题: 「零可路由 provider」是啥 bili 的 zcode native 模式启动时,会读 ZCode 的 provider 配置,逐条尝试把它的 base URL 改写到 bili 代理——这个改写就叫「路由」,改上了这条流量才进压缩。如果检查完所有条目,一条都没能改写(要么根本没有条目,要么每条都有跳过理由:#1621 客户端签名墙、loopback、direct 豁免、没有可用 base URL),就是「零可路由」:routable 数量 = 0。 这个状态下 bili 不启动 MCP 服务,ZCode 端看到的就是那个莫名其妙的 这个 PR 修复了这个问题吗 没有。 它不改任何路由行为:之前路由不上,现在还是路由不上,客户端还是看到
真正让这类流量进压缩的路径(都不在这个 PR 里):① 原生路由实际生效的 provider——被 #1621 客户端签名挡着;② cert-MITM 路径——#1621 下的独立工作。「改写旧文件兜底」的方案(plan B)在 #1892 里已明确不做:有效 personal store 存在后,旧文件就不是运行时 provider 来源。 另外我 review 时顺手修了一个会让这个诊断本身失效的问题(bf1e0be):mcp-entry 之前直接 |
bf1e0be to
92cfe40
Compare
Review + 实机复现矩阵(独立验证,approve)代码审阅改动面小而干净:+132/−2,3 文件。 实机测试(真实 dist + 真实 stdio MCP 客户端行为,非单测)用
两点如实披露(不阻塞)
边界确认(与 PR 声明一致)本 PR 只改诊断,不改行为:routed undefined 时仍在 MCP 初始化前退出(实测 initialize 无响应),客户端侧 本地:typecheck ✓;zcode 套件 48/48。CI 13/13 绿(实查 head bf1e0be)。可合。 |
#1892 行为修复(第三 commit 92cfe40):不再 Connection closed,降级服务#1896 前两个 commit 只补诊断日志。这个 commit 把行为本身修掉:mcp-entry 任何情况下都不再在 MCP 握手前退出。 机制
实测(真机,本仓库 dist + 真 ~/.zcode,空个人 provider store = #1892 报告者的世界)
本地 3.7.6 桌面版 zcode 无 3.14.4 公开下载渠道,用等价 stdio 契约复现 + 验证(空 store 语义与 3.14.4 报告一致)。 测试
|
The acp_status/panel tests render through the real process VERSION, so their hardcoded 0.1.179-running spans broke on the first release after #1873 landed (0.1.180): pull_request CI runs the merge tree, and PR #1896 inherited the red lanes. Derive the UI fixtures with patchBump(VERSION, ±n) instead; pure-function tests keep the static ENTRIES (running is explicit there). Adds a teeth assertion: at-or-below-running entries stay out of the span.
92cfe40 to
27073b2
Compare
[bot] 🏷 两条评论都处理完了。分支期间 rebase 到最新 master(f7cc681,含 #1873)并新增一个测试修复 commit,最终 head 27073b2,CI 全绿。先答你的两点披露,再给行为修复 commit 的结构化结论。 对你两条披露的回应① flush 修复在你环境观察不到差量 —— 两个观察都对,是时序问题:我的复现环境 8/8 丢(零路由路径每次必丢最后一行),你的快 tmpfs 机器上 libuv worker 恰好赶在 teardown 前完成了 write。补充一点:行为修复之后,零路由路径不再 process.exit(degraded 模式让进程活着服务握手),日志丢失的暴露面进一步缩小到剩余早退路径(off/degraded/fatal),那些路径上 ② 「Settings → Network」UI 命名假设 —— 同意,非阻塞。可选软化措辞(不坚持):「在 ZCode 的网络设置里配置 HTTP proxy + root CA」,不断言具体菜单名。你拍板。 行为修复 commit(d6f821c,内容 ≡ 我此前审的 92cfe40,rebase 后逐字节一致,diff 验证过)1. 是什么问题:零可路由时 mcp-entry 在 MCP 2. 什么原因导致的:入口把「没有可路由对象」当成致命错误——路由可行性判定和进程存活耦合在一起,判定为不可路由就直接死亡,而不是降级服务。 3. 怎么修复的:解耦。 4. 是否回归:逐项审过,默认路径字节不变(无参调用方 cli/kimi 不受影响,kimi 有独立的 BootstrapMode,grep 核实);happy path 逐字节相同(watchdog/handoff 只在 happy path 安装);干跑纯度核实(
5. 是否破坏缓存:不涉及——未触碰任何缓存/重试/游标/去重键,persist 未动。 6. 是否改设计方向:是,有意为之——zcode mcp-entry 从 fail-fast-exit 转为 always-serve-degraded。理由:MCP 子进程的存活是客户端契约,路由可行性与之正交。边界清晰:发现逻辑按序探活(BILI_MCP_PROXY→instance file→8787),空闲模式惰性(不打死 origin)。 7. 是否引入新配置:无——BILI_MCP_PROXY 是既有变量(mcp.ts/launcher/plugin-install/cli 都在用),8787 是规范默认端口(config.ts:952)。 测试有效性:强。e2e 钉住精确回归点(空 store 场景断言 rebase 与第四个 commit(27073b2)
验证汇总本地:typecheck ✓;定向 52/52(zcode-native + zcode-json-edit + zcode-mcp-degraded,含两个新 e2e)。CI(最终 head 27073b2):主 CI run 37007385372 completed success + e2e(fake-codex/native-pi/native-dsh)+ build artifact 全绿。与你本地全量 3660/3641 pass / 0 fail / 19 skipped 一致。 合并前一件事PR 正文的「Behavior change disclosure」段还写着诊断边界原话(does not fix the pre-init MCP exit),commit 3 之后已过时——建议更新正文以反映新范围(commit message 本身披露得很完整,正文对齐即可)。 判定:可合并。 合并操作按规约由你执行。 |
新增:真实 zcode 客户端 canary CI lane(#1892 加固)
实测发现(3.14.4 实机)
触发条件
|
…e Connection closed (#1892) routeZcodeConfig's zero-wrapped path logged only 'no routable provider entry found', which surfaced to the client as an opaque MCP 'Connection closed'. Add a read-only classifier (logNoRouteNextSteps) that names the real shape, per ZCode source (#1892): an empty personal store is NOT 'no provider' — this build sources active providers from the built-in/account layer, not the legacy file — so legacy records are noted as migration leftovers, never as routing targets. A personal store whose every rule is skipped by the v3.14+ client- signing wall (#1621) names cert-MITM; mixed/other skips rely on the existing per-entry skip list. Pure observability: never writes; routing behavior, #1621 signing protection, and #1622 direct/loopback exemptions are unchanged. Diagnosis-only boundary: this does NOT fix the pre-init MCP exit or activate compression. With routed===undefined mcp-entry still exits before runMcpStdio; coding-plan accounts need native routing of the actually-active provider (blocked by #1621) or the cert-MITM path (separate, to be verified on 3.14.4). Tests: four #1892 scenarios pinning both the log classification and the bootstrap outcome (active + routed undefined). zcode suite 48/48.
process.exit drops the logger's async file-stream buffer, and zcode captures none of this MCP child's stderr — so the final diagnostic lines of the zero-route path (incl. the #1892 next-steps classifier) were lost from bili.log in 8/8 empirical runs (attach mode, empty personal store; only the first logged line survived). Await closeLogger() — already exported for exactly this purpose — before all four early-exit paths in main(). Log durability only: no routing/wire/default/threshold change. Verified: typecheck clean, zcode suite 48/48, repro now shows the diagnostic in bili.log 8/8.
…1892) Native routing that finds nothing to wrap (empty personal store, #1621 signing wall, missing store) no longer spawns a doomed proxy and exits before the MCP handshake — the zcode client saw a bare 'Connection closed'. planZcodeRouting() settles viability with a pure dry-run BEFORE bring-up; the entry serves degraded: through any live proxy it can find (cert-MITM boxes get the real ACP tools), else as an idle MCP server (empty tools/list, loud isError on tools/call) whose handshake always completes.
…spawn contract (#1892) - ci-zcode-real.yml: download the pinned ZCode AppImage (3.14.4, sha256-pinned, cached), extract the real CLI bundle + bundled provider registry, run the canary on PRs touching src/zcode/** and on dispatch. - tests/zcode-real-cli.test.ts (ACP_TEST_ZCODE_CLI): (1) real CLI boots, (2) config-path/store-schema assumptions bili's json-edit depends on still hold in the binary (.zcode/cli, provider_config.json, mcp.servers, providerRules) — upstream renames fail loudly here, (3) the real client discovers + spawns our mcp-entry from cli/config.json; a real turn needs OAuth so the handshake-level proof stays in the matrix suite (zcode-mcp-degraded).
pull_request events use the workflow file from the base branch, so a newly added workflow never triggers on its own introducing PR — the master push trigger makes it self-validate right after merge.
4053ebc to
6dc290c
Compare
actions/cache@v4 restores at the start of its OWN step. With the Cache step after Download, "if [ -f ZCode.AppImage ]" never matched on a fresh runner, so every run re-downloaded the full AppImage and the checksum-keyed cache was only ever saved, never used. Move the Cache step above Download; the post-download sha256 check still guards restored artifacts.
[bot] 🏷 canary lane 两个 commit( 结构化七问(本轮范围:canary lane)1. 是什么问题:加固需求——bili 对 zcode 内部结构的假设(路径 2. 什么原因导致的:假设与真实二进制之间没有绑定——没有固定版本的真实制品参与回归,假设腐化只能靠生产事故暴露。 3. 怎么修复的:钉死版本+校验和的官方 AppImage(3.14.4,sha256 硬编码,cache key 含 version+sha256,升版必须同步改 hash 否则响亮失败),三个测试: 4. 是否回归:纯增量——compare 核实仅两个新文件,零存量改动; 5. 是否破坏缓存:不涉及运行时缓存/游标/去重键。(CI 侧的 AppImage cache 见下条我的修复。) 6. 是否改设计方向:不涉及——纯 CI 加固,产品行为零变化。 7. 是否引入新配置:无用户侧配置。 我修掉的缺陷(385cf15,ci-zcode-real.yml)
对你 rebase 的观察(确认无误)我审到一半时分支已从 dirty(与 master 冲突)变为可合并:你把分支 rebase 到 e60d6cd 并丢掉了 27073b2(update-notes fixture 修复)——正确处置:master 的 #1922 已经落了等价修复( 实测发现核对你列的三条(桌面嵌套形 vs CLI 扁平形两套 schema、无 OAuth 时 SIGKILL 整个 MCP 栈、pull_request 用 base 分支 workflow 故加 master push 触发器)与代码/测试所编码的内容逐条一致,判断准确。 非阻塞微疵(记录不修):下载 curl 无 验证汇总:本地 YAML 校验 ✓;CI @385cf155 = 14/14 success(build-artifact、version-guard、test matrix ubuntu/windows×22/24、hermetic registry e2e×2、codex/pi/dsh/opencode/codex-overlay 全 lane、zcode-real)。 判定:可合并。 合并后 master push 触发器会让这条 lane 在未来每个触碰 zcode 路径的合并上自验;升版时按文件头纪律同步 |
Part of #1892. Related constraints: #1621 (coding-plan client signing), #1622 (routing scope).
What this changes
routeZcodeConfig's zero-wrapped path previously logged onlyno routable provider entry found, which surfaced to the ZCode client as an opaque MCPConnection closedwith no next step. This adds a read-only classifier (logNoRouteNextSteps) that names the actual shape, based on the ZCode source evidence linked in #1892:Diagnosis-only boundary (important)
This improves diagnostics only. It does not fix the pre-init MCP exit or activate compression:
routed === undefined,mcp-entry.tsstill exits beforerunMcpStdio()→ the client still seesConnection closed, now accompanied by an actionable log line.Behavior change disclosure
Log wording in the zero-wrapped case changed (log-only; no routing/wire/default/threshold change):
every provider entry …→every provider rule …(+ cert-MITM confirmation note)the provider store has no provider entries to route.→ built-in/account-layer explanation (+ optional legacy-leftover note)No new config surface (no env vars / config fields added). Pure observability — never writes; #1621 signing protection and #1622 direct/loopback exemptions unchanged.
Verification
npm run typecheckclean.tests/zcode-native.test.ts+tests/zcode-json-edit.test.ts): 48/48 pass, incl. four new [Bug] ZCode 3.14.4 原生插件:新版 providerRules 为空时 MCP 在初始化前退出,客户端报 Connection closed #1892 scenarios pinning both log classification and the bootstrap outcome (mode:"active",attached:true,routed:undefined).