Repository navigation
fix(#2082): dsh 插件工具消失 — 注册卡死自愈 + 桌面副本 boot smoke 门 - #2091
Conversation
…p copy
Two compounding mechanisms kept bili tools from coming back on desktop:
A. dsh register lifecycle could wedge permanently:
- one "inactive context" rejection during teardown poisoned
register.dead forever (a later re-activation never re-registered);
- with register.base unset (proxy died before first bind) and
state.respawn not armed, maybeRetry returned early on every call —
with no model traffic there was no other driver, so the plugin
never recovered.
apply() now clears register.dead on every activation, maybeRetry arms
the spawn fallback itself, and a self-clearing recovery timer (env
knob BILI_DSH_RECOVERY_INTERVAL_MS) keeps retrying while the register
is neither dead nor ready. RETRY_INTERVAL_MS is also overridable via
BILI_DSH_RETRY_INTERVAL_MS so tests do not need to wait 10s.
B. refreshDshDesktopCopy (#1575) replaced the desktop profile copy in
place with zero coordination: verifyEntries proves entries parse but
not that the package boots, so a top-level throw could commit an
unbootable copy — the running app then respawns from it forever and
the tools vanish until dsh restarts.
installViaTarball gains opts.bootSmoke: after post-install
verification (and before dropping the backup) it spawns
node <installDir>/<main> --version with a scrubbed env; any nonzero
exit, timeout, or spawn error rolls the copy back to the previous
version and fails the update loudly. refreshDshDesktopCopy enables
it and its success log now explains the handoff boundary.
|
补充:与 #1632(install-dir-resolution)无冲突面——其 findInstallDir/describeInstallLocation 不触 installViaTarball 失败分支语义;若后合并者是我方可 trivial rebase。 |
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2130-pr.2091.c6caae1This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2091.tgz
npm install -g packageInstall instructions are refreshed on each push. |
已核实,且比「无冲突面」更强一步:#1632 已经合进 master(merge commit 代码层面复核了你的判断:
CI 现状(head 无其他待办:按 §7.4 等人工合并(touched |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.5-master.d8d1f8a # this exact build
npm install -g billion-context@master # always the newest merged build
|
…INTERVAL_MS in CONFIGURATION.md en+zh The #2091 recovery knobs shipped without CONFIGURATION.md entries while every sibling dsh-plugin knob (incl. the adjacent BILI_MODEL_INFO_RETRY_MS) is documented — 'document or don't ship' (env-var discipline #2030, hard rule 4). Both are test/ops hooks with unchanged defaults; production behavior is untouched.
…elf in place (ranxianglei#2082) The ranxianglei#2082 boot smoke (PR ranxianglei#2091) was wired into refreshDshDesktopCopy only, the lane where another bili process refreshes the dsh desktop profile copy. When the running proxy IS that copy, hostManagedInstall exempts the layout (ranxianglei#1575) and the copy updates itself through the plain self-update lanes: checkForUpdate (periodic check, `bili update`) and forceInstallVersion (advisory force-install, web-panel install). Both called installViaTarball without bootSmoke, so a tarball whose entry parses but throws at load was swapped into the copy dsh respawns its plugin from. Arm the smoke on both lanes when the install dir is the dsh desktop copy. Other install layouts keep their current behaviour. (cherry picked from commit 4e7ac09)
修复 #2082(dsh 中工具会突然消失,0.179→最新回归,桌面版)。
机制(承接 issue 两份排查/复现评论)
复现证实换代边界(#1575 原地替换)只造成一次性 404,下一回合模型请求 re-bind 自愈;要变成用户那种持续消失,必须叠加注册侧卡死 = B×A 交集。本 PR 两端都堵:
A. 注册生命周期自愈(src/agent/dsh-native.ts)
三个卡死缺口,全部修复:
register.dead永久毒化:teardown 期间一次 "inactive context" 拒绝把 dead 置 true,此后没有任何复位点——cordis 停用/重激活(桌面文件变更可触发)后工具永不恢复。→apply()每次激活先register.dead = false。maybeRetry的 base-less 分支在state.respawn === undefined时直接返回,之后没有任何驱动。→ 自行武装 fallback(singleFlight(_spawnForTest ?? bootstrap))。maybeRetry调用点。→ 自清恢复定时器:每 tick 检查 dead/toolsReady,就绪即clearInterval,unref()不阻退出。旋钮:BILI_DSH_RECOVERY_INTERVAL_MS(默认沿用 RETRY_INTERVAL_MS=10s)、BILI_DSH_RETRY_INTERVAL_MS(测试可缩,生产语义不变)。B. 桌面副本 boot smoke 门(src/update.ts)
verifyEntries只证明入口可解析,不证明可启动——top-level throw 语法合法能穿过。桌面副本是运行中 dsh 在 proxy 死后 respawn 的目标,提交不可启动的副本 = respawn 无限失败。→installViaTarball新尾参opts.bootSmoke:post 验证通过后、成功清理(删备份)前,spawnnode <installDir>/<main> --version(env 剔除 BILI_/BILLION_CONTEXT_/ACP_*/NODE_OPTIONS/NODE_TEST_CONTEXT/NODE_ENV,超时 20s);非零退出/超时/spawn 失败 →restoreFromBackup()回滚到旧版本 + 响亮失败。refreshDshDesktopCopy启用该门,成功日志同时讲清换代边界("restart dsh to load it … across the handoff bili tools may fail once until dsh restarts, #2082")。七问速答
tests/issue2082-dsh-recovery.test.ts(dead 复位恢复 / respawn fallback + timer 零流量自愈)+tests/issue2082-desktop-boot-smoke.test.ts(坏入口→ok:false+回滚;好入口→落地;refreshDshDesktopCopy 坏 tarball→磁盘保留旧版+warn)。node子进程(fixturethrowvsexport)。_resetRegisterForTest清 timer 防跨测试泄漏;NODE_TEST_CONTEXT 下未设旋钮不 arm(防测试噪声)。兼容性
installViaTarball新参数默认{}:CLI/npm 安装路径行为不变(不 smoke)。tsc --noEmit --project tsconfig.build.jsonrc=0。发布说明
touch
src/update.ts(load-bearing)+src/agent/dsh-native.ts(dsh lane)→ §5:先合本 PR 再发版;合后建议 dispatchci-release-canary(ref=master)走一遍自更新链路。按 §7.4 由人工合并(改 wire 行为相关的 load-bearing 文件)。