Skip to content

[PR] fix(zcode): signal the z.ai built-in account that bypasses native routing (#4692) - #4721

Open
ranxianglei wants to merge 11 commits into
masterfrom
2026-10-25_zcode-builtin-account-signal
Open

ranxianglei wants to merge 11 commits into
masterfrom
2026-10-25_zcode-builtin-account-signal

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

The z.ai built-in account connects through ZAI_BUSINESS_BASE_URL, an env var that lives in the ZCode main process and never lands in the provider store. Native routing rewrites only that store, so it has no target for this surface — its model traffic runs direct/uncompressed, and there was no signal at all when a session went blind on it (#1896 covered only the empty-store shape). Before the account form was identified, this was mis-diagnosed as "integration missing / hook not wired".

Change

Behavior change

Observability only. Old → new: when the built-in account is active, bili logged nothing → now logs one line at session start ([bili-zcode] z.ai built-in account detected … BYPASSES bili … cert-MITM …). No routing, wire, threshold, default, or persistence change; this path never writes the store.

Config surface

None. ZAI_BUSINESS_BASE_URL is ZCode's own variable — we only read it. No new BILI_*, env var, or config field.

Verification

Rebased onto current master (ac844facd); the three code/test files were unchanged upstream, so the rebase is clean. Local (targeted): typecheck clean; zcode suite 66/66. Full regression → CI.

Closes #4692

…ting (#4692)

The z.ai built-in account connects through ZAI_BUSINESS_BASE_URL, an env var in the ZCode main process that never lands in the provider store — so the JSON surgery has no target for it and its model traffic runs direct/uncompressed with no signal at all (#1896 covered only the empty-store shape).

Add a read-only detector plus a loud one-line report, wired into bootstrapZcodeNative (covers both the degraded and active outcomes) and the SessionStart hook. Pure observability: never writes config, never touches wire or thresholds.

Document the stance in CLIENTS.md en/zh: the surface cannot be routed natively (a child cannot rewrite the parent's env — same wall as codex #1660/#403); cert-MITM is the alternative; note the second layer (#661 405 on zai-series model traffic, #4593/#4610).

Closes #4692
@ranxianglei ranxianglei changed the title fix(zcode): signal the z.ai built-in account that bypasses native routing (#4692) [PR] fix(zcode): signal the z.ai built-in account that bypasses native routing (#4692) Oct 25, 2026
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-25_zcode-builtin-account-signal (57b5caa)

Latest build — install this exact version

npm install -g billion-context@0.0.9428-pr.4721.7f4f5d4

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
57b5caa billion-context@0.0.9428-pr.4721.7f4f5d4 build
a7a4955 billion-context@0.0.6152-pr.4721.0ee7a22 build
7a8c901 billion-context@0.0.6067-pr.4721.b54accb build
1926682 billion-context@0.0.5963-pr.4721.44c6703 build
c27aeb0 billion-context@0.0.5894-pr.4721.9d10f22 build
b254add billion-context@0.0.5826-pr.4721.db55e61 build
21e4026 billion-context@0.0.5766-pr.4721.b662251 build
d4454e9 billion-context@0.0.5763-pr.4721.5e3d656 build
afcbc10 billion-context@0.0.5759-pr.4721.1272189 build
1d93546 billion-context@0.0.5749-pr.4721.afcca09 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。open+closed 中触碰该表面(ZAI_BUSINESS_BASE_URL 内置账号盲区)的只有本 PR;#4610 只改 Known limitations 措辞(不同机制、不同目标区,且本 PR 已刻意把新段落放在 #4610 编辑块之外);#1896 只覆盖空 store 形态,由本 PR 扩展。

标签: bug, zcode, scope/wiring, p2(内置账号表面整体丢压缩、有 cert-MITM 绕行;非数据丢失/缓存泄露类,不升 p1)。

审核进行中。方向判定:正确——该表面无法原生路由(子进程不能改写父进程 env,与 codex #1660/#403 同一堵墙),正确处置是响亮信号 + 文档,而不是试图路由。已发现两个小问题,将按「小问题直接修」在 PR 分支上以独立标注 commit 修掉:

  1. detector 的 loopback 判断与 src/zcode/json-edit.ts 的 isLoopbackHttpUrl 重复,且语义漂移(漏 0.0.0.0、/^127\./ 过宽)→ 复用既有 helper;
  2. bootstrap-hook.ts 新增的接线没有测试覆盖(现有测试只覆盖 bootstrapZcodeNative 路径)→ 补 hook spawn 测试。

本地定向验证(typecheck + zcode 套件)与 CI 结果出来后给最终八问结论。

@ranxianglei ranxianglei added bug Something isn't working p2 scope/wiring zcode 改动范围:内核之外的主机侧接线(src/agent 适配器、server 路由、注入拦截)/范围兜底/客户端标签 labels Oct 25, 2026
ci-check added 4 commits October 25, 2026 22:53
…t-in-account detector (#4692)

The detector's inline loopback list duplicated isLoopbackHttpUrl from
json-edit.ts with drifted semantics (missed 0.0.0.0, looser /^127\./).
Export the helper and call it — one predicate for both surfaces.
…th (#4692)

The hook is an independent entry point from the authoritative MCP child;
the #4692 signal wiring added to bootstrap-hook.ts had no test. Spawn the
real hook entry: loud line present when the account var is set (attach to
a dead port -> fail-open before any store write), absent under the
BILI_NATIVE_ZCODE=0 kill-switch.
…ate)

The interface has no consumer outside src/zcode/native.ts (the two
functions are the surface; tests call them, not the type). The exported
form tripped the unused-exports guard, which fail-fast-skips the whole
test matrix (#2637 tiering) — red from the original head.
… proof re-pin (#4599)

Inherited master red (storage-engine-proofs digest drift, #4575) — per the
CI-coordination policy the fix converges on ci-fixes, not on PR branches.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

最终审核结论(结构化八问)

  1. 是什么问题:ZCode 的 z.ai 内置账号走主进程 env ZAI_BUSINESS_BASE_URL,永远不进 provider store;native routing 只改写 store,对这个表面没有路由目标——用户切到该账号后模型流量 direct/未压缩,而 bili 一行日志都不打,静默失明([ZCode native] z.ai builtin account (ZAI_BUSINESS_BASE_URL) bypasses the provider store — bili-zcode goes silently blind after the switch | [ZCode native] z.ai 内置账号(ZAI_BUSINESS_BASE_URL)绕过 provider store——切换后 bili-zcode 静默失明 #4692)。
  2. 什么原因导致的:架构墙——子进程(MCP child/hook)无法改写父进程 env(与 codex [Design] 定死端口 lane(claude 48787 / zcode 48789)端口被占时的 0 配置解法 #1660/ACP_PASSTHROUGH one-click silent kill of all compression: no logs / no banners / panel invisible and non-clearable, all sibling env knobs take effect in silence | ACP_PASSTHROUGH 一键静默关死全部压缩:无日志/无横幅/面板不可见且不可清除,同族 env 旋钮全部生效于无声 #403 同一堵墙),该表面也没有 config-file seam;所以「路由不上」不是缺陷,缺陷是可观测性缺失(fix: zcode — explain the zero-routable-provider case instead of a bare Connection closed (#1892) #1896 只覆盖了空 store 形态)。方向判定:正确——不该试图路由,应该响亮信号 + 文档。
  3. 影响范围与严重程度:切到 z.ai 内置账号且用 zcode native 车道的用户:压缩整体失效,会话照常工作、无报错、无数据丢失,成本静默上升;有 cert-MITM 绕行 → p2。
  4. 怎么修复的:两个入口(bootstrapZcodeNative 与 SessionStart hook)在 kill-switch opt-out 之后各打一行确定性信号:命名表面、解释为何 native routing 看不到、给出 cert-MITM 出口与 billion-context ACP kernel 改写 body 导致 ZCode (zcode.z.ai) 405/3012 #661 第二层提示。检测器只读、never throws、不写 store。双入口重复报告是刻意冗余(任一路径存活即有信号)。审核补强三个独立 commit:① f259b5ebe loopback 判断复用 json-edit 共享谓词(原内联版语义漂移:漏 0.0.0.0、/^127\./ 过宽);② afcbc108e hook 路径补 spawn 测试(原来只有 bootstrap 路径有测试);③ d4454e987 ZcodeBuiltinAccount 改模块私有——原 PR head 起就被 unused-exports 门禁判红,且该红会 fail-fast 跳过整个 test 矩阵(CI 排队与执行时间优化:不降低质量的前提下大幅节省(数据+方案清单) #2637 分层),本地已验证门禁转绿。
  5. 是否有回归问题:逐项清点触碰路径的既有行为——off/degraded/active 三种结果不变(纯读 env + 日志);hook 保持 fail-open exit 0;store 零写入;kill-switch 双向负例已钉死(opt-out 时不打行);文档段落放在 [PR] docs(zcode): clarify the zai-vs-bigmodel compression dead-end in CLIENTS Known limitations #4610 编辑块之外无冲突。无回归。
  6. 是否破坏缓存:不涉及——该路径不碰任何缓存/重试/游标/去重键。
  7. 是否改了设计方向:不涉及——是既有可观测性模式(fix: zcode — explain the zero-routable-provider case instead of a bare Connection closed (#1892) #1896)向非空 store 形态的自然延伸,无架构转向。
  8. 是否引入新配置:无。只读 ZCode 自己的 ZAI_BUSINESS_BASE_URL;无新 BILI_*/env/config 字段。

行为变更披露(旧→新+原因):内置账号激活时,会话开始 bili 原零日志 → 现打一行 [bili-zcode] z.ai built-in account detected … BYPASSES bili … cert-MITM …。纯可观测性,无路由/wire/阈值/默认值/持久化变化。

验证证据:typecheck clean;定向测试全绿(zcode-native 39/39、hook-graceful-exit 含新增 2 例、zcode-json-edit/mcp 全套 60/60);unused-exports 本地门禁 clean。CI:head afcbc108e 静态门禁除 unused-exports 外全绿(该红来自原 PR head,已修);master 自身 test shards 红为继承性失败(B/C 族,见 #4599),已按政策 merge ci-fixes 哨兵(18f514667)→ 新 head 21e4026da CI 跑中,全量回归以 CI 为准。

判定:代码层面可合(merge 由人操作)。注意两点:分支现比 master 多一个 ci-fixes 哨兵 commit(政策要求的收敛,ci-fixes 落 master 后自动从 diff 消失);最终以 21e4026da 的 CI 绿灯为准。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游 PR 冲突已解决 —— 已把 origin/master 合并进 PR 分支并推送,PR 现 mergeable: true(冲突已清)。新 head 57b5caa7f2。

结构化八问:

  1. 是什么问题:PR [PR] fix(zcode): signal the z.ai built-in account that bypasses native routing (#4692) #4721 与 master 冲突(dirty),无法合并。
  2. 什么原因导致的:master 在 PR 之后做了文档布局重组([PR] docs: batch-migrate 14 root-level documents into docs/ (consolidation + master index + redirect placeholders) | docs: 14 个根级文档一次性迁入 docs/(集中 + 总目录 + 重定向占位) #5920,owner ruling 2026-11-08)——CLIENTS.md / CLIENTS.zh-CN.md 整体移到 docs/clients.md / docs/clients.zh-CN.md,根目录两文件变成一行重定向 stub。而本 PR 的文档改动还落在旧的根目录位置,于是整文件冲突。
  3. 影响范围与严重程度:仅阻塞本 PR 的合并,不影响任何运行时行为。
  4. 怎么修复的:merge origin/master 进 PR 分支。冲突只落在两个文档文件上——把 PR 新增的「内置账号绕过([ZCode native] z.ai builtin account (ZAI_BUSINESS_BASE_URL) bypasses the provider store — bili-zcode goes silently blind after the switch | [ZCode native] z.ai 内置账号(ZAI_BUSINESS_BASE_URL)绕过 provider store——切换后 bili-zcode 静默失明 #4692)」段落逐字搬到新位置:docs/clients.md:448(en)与 docs/clients.zh-CN.md:113(zh),都插在 BILI_ZCODE_SIGNING_FIXED=1 行之后、看门狗 bullet 之前(与原 PR 的锚点一致);根目录 CLIENTS.md / CLIENTS.zh-CN.md 采用 master 的重定向 stub(与 master 完全一致)。代码/测试文件 master 侧 0 改动,干净自动合并。
  5. 是否有回归问题:无——PR 的 zcode 代码/测试(src/zcode/native.ts、bootstrap-hook.ts、json-edit.ts、两个 test 文件)逐字保留;文档内容逐字保留只换位置;根目录 stub 与 master 字节一致。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及——顺从 master 既定的文档布局重组,无新方向。
  8. 是否引入了新的配置:无。

验证:typecheck PASS(exit 0);zcode 定向套件 60/60 绿(zcode-native / hook-graceful-exit / zcode-json-edit)。全量回归以 CI 为准。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] auto-fix stalled: test (windows-latest, 22, 2) — stopping for human review

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] auto-fix stalled: test (windows-latest, 22, 2) — stopping for human review

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