Repository navigation
fix(worker): 冷启动链路上 kill 后确认旧 pane 消失的四处探测统一走 probePaneAfterKill,tmux server 退出中的 unknown 不再拒绝启动或留树 - #2170
Merged
Conversation
…nknown 不再拒绝启动或留树 kill 掉 tmux server 上最后一个会话会让 server 自行退出,紧跟的 has-session 在退出 过程中连上会读到 "server exited unexpectedly" 被判 unknown。#2159 只修了 read-isolation 迁移的 confirmPaneGone,同一条冷启动链路上还有三处 kill 后单次严格探测: - retireSelectedPersistentPane(凭据来源 / 环境策略变化、Codex App 未认证 pane 冷启):拒绝启动 - tearDownAndRefuse(提交失败等):保留 pending proof,沙盒树不回滚 - probeOwnPersistentPane(形态切换 reconcile、失败的新建 pane 回收、Codex App 代际 kill):拒绝启动或留树 四处统一到 spawnCli 里的 probePaneAfterKill:tmux/zellij/herdr 走 target 的 probePersistentBackendTargetAfterKill(只对 unknown 有界重探),zmx 保留 probeOwnedZmxSession 的拥有式探测,不降级成按名字探测。 测试:lab 注入改为「kill 后第几次探测」的序号集合并计数;形态切换加 [2](reconcile), 提交失败加 [1]/[1,2](tearDownAndRefuse),新增严格环境策略换代用例 []/[1]/[1,2] (retire);backend-gate 加 K2 护栏钉 zmx 分支用 owned 探测。 Closes #2166 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 22, 2026 17:27
…PersistentPane 注释,注入计数按行统计 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
Author
|
已合并 →
follow-up(不阻断,都是注释层面):
未做:发版、部署。 |
deepcoldy
added a commit
that referenced
this pull request
Oct 22, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
added a commit
to zsnjuts/botmux
that referenced
this pull request
Oct 23, 2026
按双审查 G7 合前对齐并入 8bbb626(deepcoldy#2167 会话环境变量可视化、deepcoldy#2168 默认工作目录 退回选仓卡、deepcoldy#925 worker exit 对账、deepcoldy#2170 kill 后 pane 探测)。git ort 自动合并, 无文本冲突:deepcoldy#2167 与 PR 的同区文件(bot-registry / dashboard-ipc-server / bot-config-store / types)是相邻配置字段、位置不相交;deepcoldy#2168 对 daemon.ts 的改动 位于工作目录选仓路径,与 PR 第 296 行的 canonical bindings 读取相距甚远。 最终树相对 8bbb626 恰好 20 个 PR 文件、零夹带;tsc 0、12 个同区测试文件 586 项全绿、bun run build 绿。 Co-Authored-By: Claude Code <[email protected]>
|
🚀 Released in v3.50.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
src/worker.ts:在spawnCli里新增闭包probePaneAfterKill(name, target),作为 kill 之后确认 pane 已消失的唯一入口:probePersistentBackendTargetAfterKill(fix(sandbox): 无 worker 关闭时 kill 后探测遇到 tmux server 退出中的 unknown,先短退避重探再决定是否保留沙盒树 #2148),只在结果为unknown时做有界的短退避重探;probeOwnedZmxSession,按完整 sessionId 和冻结的 PID 做拥有式探测,不退化成按名字探测;以下四处 kill 之后的探测都改为走这个入口:
unknown的后果confirmPaneGone(#2159 已修,这次只是收进统一入口)retireSelectedPersistentPanecould not confirm stale tmux pane termination (post-kill probe: unknown)tearDownAndRefuseprobeOwnPersistentPaneprevious oncall sandbox tree may still be in use by its pane (probe: unknown);另外两处会把树留下为什么
#2166:kill 掉 tmux server 上最后一个会话后,server 会自己退出。紧跟着的
has-session如果在 server 退出过程中连上,会拿到server exited unexpectedly,被判成unknown。#2148 修了无 worker 关闭的路径,#2159 修了confirmPaneGone,同一条冷启动链路上剩下的三处这次一起收掉,并统一到一个入口,以后新增调用点也不会漏。修法和前两次一样,只重新探测,不改报错的分类:只有 tmux 自己明确答
missing,才算旧 pane 已经消失。真卡死或一直答不上来的情况,最后结果仍是unknown,照旧拒绝启动或保留现场。对老用户的影响 / 影响面
unknown拒绝启动或留下沙盒树的会话,现在照常冷启或回滚;其余判断不变。unknown,不发探测也不等待;unknown时发生,最多约 0.75s,不含每次探测自身的 deadline。这些调用点本来都在 worker 冷启动的同步路径上。worker.ts7861–7905 行附近;tearDownAndRefuse约 50 行;worker.ts;测试
test/sandbox-relay-lifecycle.integration.test.ts:has-session读到server exited unexpectedly」,用序号集合指定,并记录实际触发了几次,用例会断言注入确实被消费。kill 的识别同时覆盖 retire 发出的if-shell … kill-session条件 kill。confirmPaneGone,第 2 次是 reconcile;[1](confirmPaneGone)、[2](reconcile);[]、[1]、[1,2](tearDownAndRefuse);[]、[1]、[1,2](retireSelectedPersistentPane)。lab 的start新增envPolicy选项。test/backend-gate.test.ts:probePaneAfterKill(<name>, <target>);probeOwnedZmxSession。入口是闭包,CI 上也没有真实的 zmx 运行时,没有行为层面的 seam 可测。验证
本地:
TMPDIR=/var/tmp/bmxt,bun 1.4.2。只跑改到的文件和相关文件,全量交给 CI。tsc --noEmit -p tsconfig.json:0 错(rebase 到6bae75231后重跑过;master 这段新提交没有改worker.ts)vitest run test/backend-gate.test.ts test/cli-credential-source-worker-wiring.test.ts test/read-isolation.test.ts test/test-hygiene.test.ts test/api-only-mode-wiring.test.ts test/persistent-backend-type.test.ts test/strict-env-worker.integration.test.ts:201 passedvitest run test/sandbox-relay-lifecycle.integration.test.ts:55 passed / 2 skipped;bun test同一文件:55 pass / 2 skip / 0 failbun test test/backend-gate.test.ts:20 pass;bun test test/strict-env-worker.integration.test.ts:5 pass变异(临时改动,跑完已还原;vitest、bun 结果一致):
retireSelectedPersistentPane改回单次probePersistentBackendTarget[1]、[1,2]probeOwnPersistentPane改回单次探测[2](reconcile)tearDownAndRefuse改回单次探测[1]、[1,2],三种形态共 6 条[1,2]变体(共 4 条)不注入的原始变体在每一种变异下都保持通过。
第二个提交(
bbd7d8b5d):顺手修掉评审提的 P3probePaneAfterKill的:这个闸门只在 pane 被证实仍然存活时才拒绝(shouldRejectPersistentPostKillProbe),所以 tmux server 退出过程中出现的unknown在这里本来就会被当作已消失,不需要再探一次。PR 标题也相应收窄为「四处」。probeOwnPersistentPane的注释收紧:大多数调用方是在 kill 之后来问的;reconcile 问的那个 pane 也可能是自己消失的,这种情况下多付出的代价只是在unknown时那一次有界重探。fired,再按非空行计数,避免以后往文件里追加别的内容时把次数算错。backend-gate、test-hygiene等护栏 62/62。src/core/worker-pool.ts的destroyLivePaneBeforeRestart(/restart 路径)遇到unknown并不会挡住流程,只记一条「refork may reattach」的日志,属于 fix(worker): 冷启动链路其余三处 kill 后单次严格探测,tmux server 退出中的 unknown 仍会拒绝启动 #2166 范围外的参考信息。Closes #2166
🤖 Generated with Claude Code