Repository navigation
[PR] fix(hermes): self-heal after bootstrap failure and routed-origin death - #4646
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6032-pr.4646.2274ac4This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4646.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 审核完成:通读本 PR 全部 diff( 1. 是什么问题:hermes 原生车道三个缺陷——① bootstrap 失败一次性落定 2. 什么原因导致的:① 失败路径没有重试机制(一次性 fail-fast 早于自愈需求);② env 路由是单向写入、无反向路径——没有任何东西检测 origin 死亡并清理路由;③ Python 侧写 marker 时未跟进 #1225 的 lane 协议。三者都是「机制缺失」,不是参数错误。 3. 影响范围与严重程度:p1 可用性档。① 任何瞬时 bootstrap 失败(端口竞争、磁盘繁忙)即触发,影响 = 整个宿主生命周期无压缩;② 会话中途代理死亡即触发,影响 = 模型流量风暴报错或静默直连直到重启;③ 仅多车道并发启动时触发,影响 = hermes 冷启动被无关车道 marker 阻塞。 4. 怎么修复的:三个机制都打在产生层,不遮症状——① 有界重试:失败阶段按 10/30/60 s 退避重试,每次尝试全新 90 s 预算,共 4 次;已成功阶段不重跑(origin/env/tools 各有守门);耗尽后响亮落定 5. 是否有回归问题:触碰路径的既有行为逐项清点——register() 仍 4 s 内返回( 6. 是否破坏缓存:不涉及。不动会话存储/fold 状态/缓存键;恢复换新 origin 后由磁盘状态继续服务(fold 状态跨代理存活)。 7. 是否改了设计方向:不改。三个机制都在既有架构内(bootstrap 线程 + lifecycle lock + marker 仲裁)补自愈面,无新层、无数据流转向。一条依赖声明:恢复生效依赖 hermes 在请求时读取进程 env(纯 env 驱动路由,middleware 只打 header)——driver 测试验证的是进程内 env 迁移,真实 hermes httpx 的行为在宿主侧,建议合并后实测一次(会话中途 kill 代理,观察 ~90 s 内恢复)。 8. 是否引入了新的配置:无。 测试有效性:5 个新场景断言有牙——重试计数(attempt==2 / ==4)、「after 4 attempts」错误文本、env 恢复为用户原值而非删键、 判定:可合(等新 head |
register() no longer waits on discovery/spawn/manifest inside the host's 10s load budget; a daemon thread bootstraps under one 90s deadline, the first model request is held for readiness (falling back to proxy mode, never a silent direct turn), /acp reports starting/failed/unloaded, and unload can no longer be raced by a late registration or env write.
#4644) A failed hermes bootstrap was terminal until host restart: one transient hiccup settled state 'failed' forever, and a routed proxy that died later left the process env pointing at a dead port for the whole host lifetime (silent direct connection, connect-refused storms). - bootstrap retries failed stages with backoff (10/30/60s, 4 attempts total), each attempt on a fresh 90s budget; already-succeeded stages are not re-run; an unload mid-backoff still settles 'stopped', never clobbered by a late 'failed' - origin watchdog: 30s probe x 3 consecutive misses (or our own child exiting) unroutes the process env — restoring the values present before routing — and re-bootstraps inline, re-arming the registered tools without re-registering them - starting marker gains the lane field (#1225 alignment, additive): our claims declare lane 'hermes'; undeclared lanes wildcard both sides; a same-lane starter is honored (wait + attach), a live foreign-lane starter is neither waited on nor removed, stale markers are removed and re-claimed Tests: 5 new hermes-native scenarios (retry-land, retry-exhaust, origin-death, marker-foreign, marker-same-lane); local targeted suite 48/48 green, typecheck clean.
… sliver (#4644) Review fix on 2026-10-25_hermes-selfheal: the same-lane marker wait loop in ensure_origin exited at the shared deadline without a last discovery pass, while the reference implementation (waitForStarterInstance, src/launcher.ts) probes once more first — its success path clears the starting marker, so an attach landing right at the boundary is indistinguishable from a failure bail without that look, and we double-spawn over the starter's bring-up instead of attaching. Add the single-shot pass (no deadline arg = pure one-shot) before the post-wait claim, mirroring the TS lane.
…ed spawn poll (#4646, #4656) Rebase follow-up on #4646: the branch rewrote the spawn-poll loop inside the background _bootstrap and thereby dropped the #4656 fix that #4658 implements on master's structure. Port it into the new loop: - _find_spawned_in_registry(child_pid) (latest started_at among same-pid markers, #4658 review hardening) after the shared-pointer token check and before the child-exit check, with the manifest health probe before adoption - adoption now also records instance_id (the #4658 review nit — /acp panels show the adopted instance instead of a blank id) - tests ported under the new structure: spawn-clobber waits on the bootstrap readiness event (register() returns early now) and pins the instance_id; registry-find keeps rf_own/rf_foreign/rf_dead/rf_none plus the dup-pid aaa-stale vs zzz-own started_at tie-break
5e7e912 to
f74c28d
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.844-master.257afab # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #4644
Stacked on #4642 (branch cut from its head
65a9a6a4d): #4642 removes the cold-start failure mode (plugin lost when bootstrap outlived the host's load deadline); this PR adds the recovery surface for what happens AFTER a bootstrap fails or a routed proxy dies. If #4642 merges first, this rebases cleanly onto master.Behavior changes (disclosed)
Bootstrap retry (new policy). A failed bootstrap stage no longer settles
faileduntil host restart: up to 4 attempts with 10/30/60 s backoff, each attempt on a fresh 90 s budget; an already-succeeded stage is not re-run (no re-probe of a healthy origin, no re-fetch of registered tools). An unload mid-backoff still settlesstopped— the latefailedwrite path was removed so_shutdownowns the record.Origin watchdog (new mechanism). Old behavior: none — a routed proxy that died left
HTTPS_PROXYet al. pointing at a dead port for the whole host lifetime (silent direct connection, connect-refused storms). New: 30 s probe x 3 consecutive misses (our own child exiting = instant detection) unroutes the process env — RESTORING the values present before routing, so a user's own proxy config survives; keys without a prior value are dropped — then re-bootstraps inline in the watchdog thread. Tool registration is re-armed, not repeated (the host session snapshot keeps the tools; their handlers follow the new origin). One loud warning per episode.Starting marker gains
lane(#1225 alignment, additive field). Our claims now declarelane: "hermes"; undeclared lanes wildcard both sides, so pre-#1225 markers stay compatible. Semantics mirrorsrc/launcher.ts: a same-lane starter is honored (wait for its instance + attach); a live DIFFERENT-lane starter is neither waited on nor removed — we spawn without coordinating and leave its marker intact; stale markers are removed and re-claimed. Note: the old python code waited behind ANY non-stale marker regardless of lane; it now waits only behind same-lane/legacy ones.Non-changes
kernel/changes, no wire/message-shape changes, no version bump.register()still returns within REGISTER_WAIT_S; first-request gate still FIRST_REQUEST_WAIT_S).Tests
Five new hermes-native driver scenarios: retry-land (attempt 2 succeeds after a blocked first), retry-exhaust (4 attempts ->
failed+ "after 4 attempts" + direct traffic with settled ready-event), origin-death (env gap restores the user's prior proxy value, recovery re-routes, each tool registered exactly once), marker-foreign (foreign-lane starter untouched, we spawn anyway), marker-same-lane (wait + attach, no double-spawn, starter marker kept). Local targeted run: 48/48 green; typecheck clean. Full-suite verdict deferred to CI on this head.