Repository navigation
fix: lane-aware attach discovery + native.attachLanePriority (#2905) - #2916
Conversation
A dsh-spawned instance was the last writer of the single proxy-origin file, so a hermes native session attached to it blindly (the Python plugin checked neither lane nor code fingerprint nor config shape). Its MITM whitelist does not cover hermes's providers, so model traffic blind-tunneled, no session ever arrived under hermes's conversation id, and every compression tool call 404'd. - hermes-plugin: discovery now mirrors probeLiveInstances + pickAttachable (src/launcher.ts) — scans every registry marker plus the proxy-origin file (registry wins id collisions), requires entry-script fingerprint, bind host/passthrough/MITM-whitelist/model-table identity, and applies the lane rules: own lane first, operator-listed foreign lanes next, user zone (manual bili start, the 8787 global) ALWAYS last. The #1335 lifecycle gate keeps applying except to the user zone (#1660 twin). Spawned proxies now declare lane: hermes (BILI_LAUNCHER_LANE) so no other lane can ride them. - launcher.ts: attachClass() replaces the two-class rule with own lane -> listed foreign lanes (native.attachLanePriority order) -> undeclared lanes last; instanceCompatible admits a foreign declared lane only when listed. Default [] = zero behavior change for existing TS lanes. - config.ts: native.attachLanePriority (string[], file-only, no env var per #2030) + resolveNativeAttachLanePriority(). Closes #2905
- hermes driver: existing discover-* fixtures now carry full identity fields (fingerprint/lane/host/passthrough/mitm/modelWindows); new scenarios: discover-foreign-lane (the reported bug — dsh instance is refused, not ridden), discover-user-zone (unarmed 8787-style daemon is a legitimate last-resort target, #1660 twin), discover-lane-first (own lane beats a NEWER user zone; registry scanned beyond the file), discover-priority-config (attachLanePriority opt-in rides a listed foreign lane), spawn-env (spawned proxies declare BILI_LAUNCHER_LANE). - launcher: listed foreign lane attachable / list position beats recency / unlisted foreign lane stays refused with user zone last. - config: resolveNativeAttachLanePriority normalization (trim, dedupe, non-array/garbage -> []).
CONFIGURATION.md en/zh (summary table + native section), README en/zh port note, CLIENTS en/zh hermes lifecycle bullet, website config reference. New key: native.attachLanePriority (string[], file-only, default [] = own lane -> user zone -> spawn).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3251-pr.2916.e9f3c9cThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2916.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…2905) check-coverage forbids backticks in desc_en/desc_zh (tools/gen-config-docs.mjs:118); remove them from the native.attachLanePriority seed and take the generator's canonical table rows instead of the hand-edited ones (docs-sync drift).
[bot] 🏷 收到,开始核对 #2916。 身份确认:这是带 CI 现状(红): 根因(单点缺陷级联): 处置:我现在就去掉这两处反引号(纯文档 seed 改动,不动配置语义、不 bump 版本),本地跑 |
…esynced the code fingerprint (#2905) install_sidecar used text-mode open("w"): on Windows \n becomes \r\n on disk, so the sha256 discovery hashes (real file bytes) never matched fp_of() (LF constant) and every candidate was refused pre-probe — all discover-* scenarios inert on windows-latest. Binary write makes on-disk bytes equal the fixture hash on every platform.
[bot] 🏷 核对完成。#2916 现已全绿(22/22 checks,0 fail),可合并。 下面是结构化结论。 先交代我的实际动作:这是带 关键背景:我接手时 CI 是红的,而且红的原因不是单一缺陷——是两个相互独立的缺陷,先后由原作者在 1. 是什么问题(两个,不是一个)
2. 什么原因导致的
3. 影响范围与严重程度
4. 怎么修复的
5. 是否有回归问题:无。两个修复都是纠正性/增量,无语义漂移:
6. 是否破坏缓存:不涉及。两处改动都不触碰缓存/重试/增量游标/去重键(这里的 fingerprint 是 attach-discovery 的身份判定,不是缓存失效路径)。 7. 是否改了设计方向:不涉及。架构/边界/数据流未转向;lane-aware attach 的设计(本 lane → 列出的外部 lane → 用户区 → spawn)完整保留,且现在有跨平台通过的测试兜底。 8. 是否引入新的配置:本 PR 引入 收工判定:两处缺陷均已修复并经我核验正确且充分,CI 在当前 head |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.330-master.c76650f # this exact build
npm install -g billion-context@master # always the newest merged build
|
What
#2905: dsh spawn 一个实例之后 Hermes 会尝试 attach 到 dsh 实例上,导致 hermes 工具 404。根因修复 + 泳道优先级配置。
Root cause
The hermes native plugin's discovery (
hermes-plugin/__init__.py) read only the single last-writerproxy-originfile and checked only pid-liveness + manifest probe + watchdog gate — no lane, no code fingerprint, no config shape. After dsh spawned its lane proxy (last writer), hermes attached to it; dsh's MITM whitelist doesn't cover hermes's providers, so model traffic blind-tunneled, no session ever arrived under hermes's conversation id, and every/__bili/plugin/toolcall 404'd with "unknown plugin conversation".Compounding it: hermes-spawned proxies never declared a lane (
BILI_LAUNCHER_LANEunset) — wildcard instances ANY lane could ride — and an older lane-less record lost to a newer one by recency, so the 8787 user-zone daemon could beat the lane's own instance ("8787 优先级第一").Fix
probeLiveInstances+pickAttachable(src/launcher.ts): scans EVERY registry marker plus the proxy-origin file (registry wins id collisions), requires entry-script sha256 fingerprint, bind host / passthrough / MITM-whitelist / model-table identity, and applies the lane rules: own lane first → operator-listed foreign lanes → user zone ALWAYS last. The claude-native hooks must not attach to a lifecycle-less proxy — attach gate + self-managed fallback #1335 lifecycle gate still applies except to the user zone ([Design] 定死端口 lane(claude 48787 / zcode 48789)端口被占时的 0 配置解法 #1660 twin). Spawned proxies now declarelane: hermes, so no other lane can ride them and a second hermes session converges on the first hermes proxy.attachClass(): own lane (0) → listed foreign lanes in list order (1..n) → undeclared lanes / user zone ALWAYS last (n+1). A foreign DECLARED lane is attachable only when listed. Default[]= zero behavior change for existing TS lanes.config surface
native.attachLanePriority: string[]in~/.config/billion-context/billion-context.json. File-only, NO env var (env discipline 彻底整治环境变了滥用,除非必要都走配置文件 #2030: behavior knobs are file keys resolved through the existing hierarchy).native.attachExternalis a boolean over WATCHDOG state — it cannot express ordering or per-lane opt-in; the providers table and the compress hierarchy have no notion of attach targets at all.hermes.attachLanes) — rejected: attach priority is one machine-level policy shared by every lane-aware site (TS lanes + python twin), not a per-lane knob; env var — rejected per 彻底整治环境变了滥用,除非必要都走配置文件 #2030 category rules; port-pinning style keys — unrelated dimension (port ≠ identity).[]→ exactly today's behavior (own lane → user zone → spawn). Nothing to migrate.Behavior changes (old → new)
lane: hermes(were wildcard). Other lanes can no longer ride them; a second hermes session converges on the first hermes proxy instead of possibly preferring 8787 by recency.bili start/ 8787) become attachable as LAST-resort fallback even when unarmed — mirrors the TS lanes' [Design] 定死端口 lane(claude 48787 / zcode 48789)端口被占时的 0 配置解法 #1660 semantics (the python twin previously refused them unlessnative.attachExternal=true).native.attachLanePriority— default[]= no cross-lane attach; own lane always first; 8787 always last. Example:"native": {"attachLanePriority": ["dsh"]}.Notes
pick_port()norapply_env()/port semantics; the two coexist.src/mcp.ts resolveProxyOrigin()(codex MCP shell) still resolves the last-writer proxy-origin record across lanes. MCP shells never spawn, so impact is lower; tracked as follow-up in the dsh spawn 一个实例之后 Hermes会尝试 attach到dsh实例上 导致hermes工具404 #2905 thread rather than a separate issue (one mechanism family).Closes #2905