Repository navigation
fix(read-isolation): 冷启动前确认旧 pane 已消失时遇到 tmux server 退出中的 unknown,先短退避重探,不再直接拒绝启动 - #2159
Merged
Merged
Conversation
…避重探,不再直接拒绝启动 read-isolation 迁移(kill-then-cold-spawn)里 confirmPaneGone 只探测一次,要求严格 missing。kill 掉 tmux server 上最后一个会话会让 server 自行退出,紧跟的 has-session 若在退出过程中连上会读到 "server exited unexpectedly" 被判 unknown,于是整个会话 被拒绝启动(Fatal worker error)。 - confirmPaneGone 的 target 分支改用 #2148 加的 probePersistentBackendTargetAfterKill (只对 unknown 有界短退避重探,exists/missing 立即返回,仍 unknown 照旧 fail-closed) - lab 的 exiting-server 注入收窄到本会话 pane 的 kill / has-session,不被诊断会话、 后端选择等无关调用触发或消费 - 沙盒形态切换用例加一个注入变体(oncall → credential-only):新 pane 必须照常冷启 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 13:09
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
Author
|
已合并 →
follow-up(不阻断,均为 master 上已有的问题):冷启动链路上还有三处 kill 后只探测一次的地方,分别是 未做:发版、部署。 |
This was referenced Oct 22, 2026
|
🚀 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:在 read-isolation 迁移的 kill-then-cold-spawn 流程里,confirmPaneGone原先在 kill 之后只探测一次。现在有 target 的分支改用 fix(sandbox): 无 worker 关闭时 kill 后探测遇到 tmux server 退出中的 unknown,先短退避重探再决定是否保留沙盒树 #2148 新增的probePersistentBackendTargetAfterKill:探测结果是unknown时做有界的短退避重探,重探次数用完仍是unknown才照旧拒绝启动。zmx 的 owned 探测和「没有 target 时按名字探测」的兜底分支不变。test/sandbox-relay-lifecycle.integration.test.ts:kill-session/has-session。这样诊断会话清理、后端选择这类无关的 tmux 调用既不会触发注入,也不会把它提前用掉。为什么
以下几类情况,successor worker 都会先 kill 旧 pane,再冷启新 pane:
kill 之后,
confirmPaneGone要求探测结果严格为missing。问题在于:kill 掉的如果是这个 tmux server 上最后一个会话,server 会自己退出;紧跟着的has-session若正好在 server 退出过程中连上,会拿到server exited unexpectedly,被判成unknown。结果是整个会话被拒绝启动,worker 报Fatal worker error后退出,用户在群里看到会话起不来。这和 #2146 / #2148 修的是同一个窗口。#2148 修的是无 worker 关闭时沙盒树被保留;这里的后果更重,是会话直接起不来。#2107 让托管会话改用独立 socket 之后,「kill 掉某个 server 上最后一个会话」这种情况会更常见,尤其是单 bot 部署。
修法与 #2148 相同,只是重探,不改报错的分类:只有拿到 tmux 自己给出的
missing,才认定旧 pane 已经消失;真卡死、或者一直答不上来的 server,最后仍然是unknown,照旧拒绝启动。对老用户的影响 / 影响面
unknown被拒绝启动的会话,现在会照常冷启;其余判定都不变。unknown时发生,最多约 0.75s,不含每次探测自身的 deadline。这段代码本来就在 worker 冷启动的同步路径上。retireSelectedPersistentPane:凭据来源 / 环境策略变化,或 Codex App 的 pane 未认证时,也是先 kill 再要求严格missing,同样可能遇到这个窗口。它的集成用例跑的是真 tmux、没有注入 shim,要补回归测试得先补这套基础设施。tearDownAndRefuse:这里不管探测结果如何都会拒绝启动,探测结果只决定 pending proof 是否保留、沙盒树是否跟着 worker 退出而保留。用户能看到的行为不变。reconcileSandboxTreeFlavour用的probeOwnPersistentPane:沙盒形态切换时,迁移闸门之后还会再探测一次旧 pane,这一次也只探测一次就要求严格missing。只有 kill 之后的第 2 次探测正好碰上窗口才会触发,比本 PR 修的那处更难碰到。评审复现过(把注入改为只作用于第 2 次 has-session)。修的时候 zmx 必须继续用probeOwnedZmxSession,这是拥有式探测,换成 target 级探测会悄悄降级成按名字探测。验证
本地环境:
TMPDIR=/var/tmp/bmxt,bun 1.4.2。只跑了改到的文件和相关文件,全量交给 CI。tsc --noEmit -p tsconfig.json:0 错vitest run test/test-hygiene.test.ts test/read-isolation.test.ts test/cli-credential-source-worker-wiring.test.ts test/persistent-backend-type.test.ts:162 passedvitest run test/sandbox-relay-lifecycle.integration.test.ts:45 passed / 2 skipped;bun test同一文件:45 pass / 2 skip / 0 fail。fix(sandbox): 无 worker 关闭时 kill 后探测遇到 tmux server 退出中的 unknown,先短退避重探再决定是否保留沙盒树 #2148 那组 worker-less close 注入用例在收窄后的注入下仍全部通过。复现与变异:
persistent pane provenance mismatch … killing + cold-spawning,紧接着Fatal worker error delivered; exiting process,新 pane 没有起来confirmPaneGone换回单次probePersistentBackendTarget第二个提交(
0fefa229d)第一次 CI 跑在
5c6022940上,test/backend-gate.test.ts的一条源码结构护栏(K2)红了:它按文本查找confirmPaneGone里的probePersistentBackendTarget(<target>)。这是本 PR 改了调用名导致的,不是偶发。现在护栏改为匹配probePersistentBackendTargetAfterKill(<target>),要守的约束没变:kill 和 kill 后的探测针对同一个捕获下来的 target,只有确认missing才重新选后端。那一轮 CI 里,除了这一条,其余全部通过:test (2/3) 1 failed / 630 passed,bun-test 1614/1615。改完后本地
backend-gatevitest 45/45、bun 19/19。🤖 Generated with Claude Code