Repository navigation
fix: hermes plugin attach paths register their host pid as a proxy watchdog owner (#1199) - #1219
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1219Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1219.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review complete — verified mergeable. This is prior ework-daemon work (per #1199 floor 2), so I did a full verification pass rather than redoing it. Everything checks out; all evidence below reproduced locally at head ① Original issue (direction) — #1199 is real and this fixes the root cause, not a symptom. On master I confirmed: ② Regression review (existing behaviors touched by the diff)
③ Code review — ④ Test validity — real tests with teeth, not tautologies:
⑤ Diff cleanliness — 2 files, +66/-8, every line related to #1199. No whitespace churn, no lockfile/version changes. Freshness & CI — branch is exactly at current master tip (0 behind); CI green on head commit across all jobs (test matrix ubuntu 22/24 + windows 22/24, codex fake-upstream e2e, version-guard, build-artifact). Local pre-flight at head — Duplicate screening — no duplicate. Sibling open PR #1200 fixes the same bug class for the TS launcher (#1190/kimi) and touches disjoint files ( Auto-merge gate (§7.4) — all 8 criteria met: single-module scope (Python plugin + its test harness), regression tests added and passing, green on rebased head, no config/persistence/wire/cross-repo changes, pure 中文摘要:修复了 hermes 插件两条附着路径(显式 ATTACH 环境变量、发现共享实例)不注册宿主 pid 导致首个会话退出即杀死共享代理的问题(#1199),注册策略与 TS 端完全一致(409 静默、失败只告警不阻塞),已本地复验 typecheck/build/测试全绿且 CI 全绿,测试断言有牙,diff 干净无重复无冲突——可以合并。 |
Fixes #1199.
Problem
hermes-plugin/__init__.pyhas two attach paths that bypass the TS-side watcher registration introduced by the #1183/#1190 fix (PRs #1184–#1186):BILLION_CONTEXT_ATTACHenv target;discover_instance()finding a healthy shared instance (including via the marker-wait poll loop).Neither registered a host pid at
POST /__bili/watcher, so when multiple hermes sessions shared a proxy, the first session's exit killed the proxy's only watched owner (BILI_PARENT_PID) and took the remaining sessions down with it — same symptom as #1183/#1190.Change
register_watcher(origin)inhermes-plugin/__init__.py: after a successful attach,POST {origin}/__bili/watcherwith{"pid": os.getpid()}— the same endpoint and policy as the TS launcher (src/claude-native-bootstrap.ts): 409 = daemon proxy (no watchdog) → silent; any other failure logs a warning and never blocks session start. 2s timeout (same as the health probe).ensure_originnow funnel through a single_attach(origin)helper (state update + watcher registration), so no future attach site can skip registration. The spawn path is unchanged: the spawner's own pid is already the proxy's initial watcher viaBILI_PARENT_PID.Behavior change (intended)
WATCHER_IDLE_GRACE_MSgrace window). Daemon proxies (no parent pid) refuse with 409 and are unaffected. Worst case, plugin startup gains one synchronous HTTP call with a 2s timeout, only on the attach path.Tests
attachdriver scenario: asserts the stub proxy received exactly one watcher registration carrying the plugin process's own pid.attach-daemon(stub returns 409 → silent, session starts, tools registered) andattach-watcher-fail(stub returns 500 → warning path, session still starts). Both pin the never-block contract.Pre-flight
npm run typecheck— cleannpm run build— cleannpm test— 2379 pass / 3 fail / 2 skip. The 3 failures are intests/claude-native.test.tshook-e2e tests that spawn real proxy processes and walk liveps; they fail identically when that file runs alone, and this diff touches nosrc/file (onlyhermes-plugin/+ its test harness), so they are unrelated to this change. All 15 hermes tests pass.Auto-merge gate (§7.4): single-module fix (Python plugin + its test harness), regression tests added, green on rebased head, no config/persistence/wire/cross-repo changes, pure
fix:, clean diff, references its issue, does not touch load-bearing infra.