Repository navigation
test(tmux): 两个起 worker 的 tmux 测试自带私有 tmux 目录,不再落到宿主 -L botmux - #3000
Merged
Merged
Conversation
worker-codex-app-turn-routing 和 worker-pi-cot 拉起的 worker 直接继承 process.env,靠全局 tmux 围栏给的 TMUX_TMPDIR 隔离。绕过 setupFiles 的运行(如 0 字节 vitest 配置)里 TMUX_TMPDIR 为空,worker 的 `-L botmux` 就落到宿主 /tmp/tmux-<uid>/botmux,和线上 fleet 共用同一个 server——和 #2975 修的 traex 测试是同一类问题。 - 每个文件在 /tmp 下建一个短的私有目录,worker env 改用 privateTmuxEnv(私有目录),并删掉 BOTMUX_TMUX_SOCKET,把 socket 名固定成 botmux; - afterAll 只用 -S 关私有目录里的 server,再删目录; - 回归绊线:codex-app 测试侧的 tmux 调用改用私有 socket 的绝对路径,pi-cot 的 tmux 用例 等私有 socket 出现。全局围栏也会给私有 TMUX_TMPDIR,没有绊线的话覆盖一旦失效, 标准配置下仍是绿的。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 09:11
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.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.
背景
#2975 修了 traex hook 接线测试:绕过
setupFiles的运行里TMUX_TMPDIR为空,它拉起的 worker 在宿主/tmp/tmux-<uid>/botmux上起了 server(2026-11-06 断线的第二波)。当时另列了 8 个起 worker、用 tmux 后端、没自设TMUX_TMPDIR的测试。本 PR 逐个核实了它们,只修确认会落到宿主 socket 的两个。核实方法
在 isolate-run(私有
/tmp)里用scripts/fenced-run.ts给临时 HOME,再去掉TMUX_TMPDIR/TMUX/TMUX_PANE和 PATH 上的 tmux shim,用 0 字节 vitest 配置逐个跑,跑完看/tmp/tmux-<uid>/里有没有出现 socket(tmux 3.3 不删自己的 socket,用过就会留下)。阳性对照是 #2975 修复前的 traex 测试。/tmp/tmux-0/botmuxbotmuxbotmuxtmux -S <私有 socket>包装,已隔离process.env,但 0 字节配置的默认 include 选不中*.e2e.ts(实测 "No test files found"),只能从带围栏的 e2e project 进入,本 PR 不改改动
做法同 #2975:
/tmp下建一个短的私有目录(bmx-cr-*/bmx-pc-*),worker env 改用privateTmuxEnv(私有目录),并删掉BOTMUX_TMUX_SOCKET,把 socket 名固定成botmux;afterAll只用-S关私有目录里的 server,再删目录;worker-codex-app-turn-routing测试侧的 tmux 调用(kill-session/send-keys/display-message/has-session)改用私有 socket 的绝对路径;worker-pi-cot的 tmux 用例等私有 socket 出现。全局围栏也会给一个私有TMUX_TMPDIR,没有绊线的话,覆盖一旦失效,标准配置下仍是绿的。只改测试,不改生产代码。
验证
vitest run --project unit(isolate-run)两个文件:31 通过,2 个跳过(需要 bwrap PID namespace,isolate 里没有);这 2 个另在宿主(有围栏)单跑-t 'publishes a host engine PID':2/2 通过,宿主/tmp/tmux-0条目数前后不变,私有目录已清。/tmp/tmux-0/保持为空(master 上两个都会建出botmux)。...process.env,在正常围栏下跑,codex-app 的 4 个 tmux 用例和 pi-cot 的 2 个 tmux 用例失败;还原后通过。bun test --timeout=180000(两个文件都在 bun 腿):worker-pi-cot通过。worker-codex-app-turn-routing在 isolate-run 里整文件连跑时偶尔有用例报worker exited early (1)(tmux pane 里的 runner 启动即以状态 1 退出),本分支和 master 版本都出现过。这是 isolate-run 环境造成的,不是 master 上的偶发(此前这里误写成 master 既有偶发,已更正):worker 拉起 CLI 前调systemd-run --user --scope,isolate-run 有独立的 PID 命名空间却共用宿主的 user systemd,systemd 252 按它自己的命名空间解释这个 PID,建 scope 时要么报Process with ID … does not exist让 pane 秒退,要么把宿主上同号的进程挪进测试的 scope。根因修复见 fix(scope): 隔离 PID 命名空间里不再把进程号交给宿主 user systemd #3088。本 PR 首跑 CI 的 bun-test 腿通过。顺带发现(未处理)
codex-app 的 endpoint socket 目录在
src/utils/codex-app-control.ts里写死为/tmp/botmux-codex-app-<uid>,测试围栏不覆盖它,测试会在宿主这个目录里留下 endpoint socket 文件。名字按哈希生成,没有看到和线上冲突的证据。本 PR 不发版、不部署。
🤖 Generated with Claude Code