Repository navigation
test(tmux): 确保私有 server 在清理目录前退出 - #3687
Conversation
Co-Authored-By: Kimi <[email protected]>
CI 首跑暴露两个 test-process-reaper 接线缺陷: 1. bun-runner-shards 集成测试的 scripts 复制清单漏了新文件 test-process-reaper.mjs,shard fixture 里的 run-bun-tests 因此 `Cannot find module './test-process-reaper.mjs'`(bun-test 1/4、4/4)。 把该文件加入复制清单。 2. reaper registryFiles 的 readdirSync 在 fence root 被并发删除时 (Bun teardown 竞态)可能返回 undefined 而非抛错,`for...of entries` 抛 TypeError(bun-test 2/4 herdr-discovery)。对非数组结果提前返回 空注册表——已消失的 root 不再持有任何 server。 均为测试基础设施、无产品代码改动。变异验证:移除复制清单项 shards 集成测试复现模块缺失;移除数组守卫 herdr 复现 TypeError,还原全绿。 Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
left a comment
There was a problem hiding this comment.
增量复审 head 9ff9b86f10bd8a49ffa3a6a5bdc51bf48639ae2e:两处修复都与首跑 CI 的失败路径精确对应,代码侧认可,待新 head 首跑 CI 结论。
test/bun-runner-shards.integration.test.ts补上test-process-reaper.mjs:这是临时 shard fixture 运行真实 runner 所需的运行时模块,声明文件不需要复制。scripts/test-process-reaper.mjs对 fence root 的readdirSync增加非数组返回守卫:root 在并发 teardown 中消失时按空注册表处理,不再进入for...of。/proc的其它目录读取没有这条 root 删除生命周期,无需扩大改动。
独立验证(未沿用提交中的数字):
bun run typecheck:通过。- Vitest:shard fixture + 两个 reaper 文件,16/16 通过。
- Bun 分文件执行:
bun-runner-shards.integration.test.ts:6/6;herdr-discovery.test.ts:16/16;tmux-process-reaper.test.ts:8/8;bun-runner-process-reaper.integration.test.ts:2/2。
未发现新的代码阻塞。合并仍以 run 44874815178 首跑全绿为准。
Co-Authored-By: Kimi <[email protected]>
deepcoldy
left a comment
There was a problem hiding this comment.
已按方案 B 追加修复并 ff 推送:df4a5f7657b668c43dde077fa8e2e637c9ad4dbd。
- fence root 恢复为
/tmp/bmxt-*,不再嵌套到botmux-bun-child-*; - scratch 仅保存
tmux-root映射,pre-sweep 与removeScratch都通过映射回收并清理 root;无映射时保留原 nested 兜底; createTmuxFence对显式 root 仅接受/tmp/bmxt-*的空目录,避免复用或删除非测试目录;- 原 reaper nested 扫描和启动等待逻辑不变。
针对 CI 的 -L 长 UUID socket 形状补了真实 runner 回归:长 root 时子测试 new-session 稳定失败,短 root 映射后通过;将 runner 变异回 BOTMUX_TMUX_FENCE_PARENT=scratch 后再次确定性失败,恢复后转绿。
验证:
bun run build/ typecheck:通过;- Vitest 聚焦回归:26/26;
- Bun:runner reaper 2/2、shard fixture 6/6、herdr-discovery 16/16;
- Bun runner self-check:通过。
新 head 的首跑 CI 已触发,继续以全绿为合码门禁。
POSIX child 的 fence root 保持 /tmp/bmxt-* 短拓扑,root 路径追加到 scratch manifest;runner 在正常关闭、信号取消和启动竞态中同时回收 scratch 与清单内的所有 root,并保留原有 nested registry/sandbox reaper。 Windows 不使用 /tmp,继续走 scratch/PARENT。损坏或截断的 manifest 仍回收可确认的进程,但保留现场并让运行失败,避免静默漏清理。 回归覆盖真实 runner 的 OSC7501 长 label socket 预算、多 fence、无 child teardown、延迟 server 启动及截断 manifest + detached fake CLI。 旧长路径变异收到 153 字节并咬红;跳过损坏清单 reaper 的变异留下 同一进程 identity 并咬红,恢复后均通过。 验证:bun run build;bun run test -- 相关 3 文件(17/17); Bun 原生 runner 集成测试(3/3);node scripts/run-bun-tests.mjs --self-check;真实 program-status-relay(23 pass、3 skip、0 fail)。 Windows 路径已静态复核,未做 Windows 实机验证。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
left a comment
There was a problem hiding this comment.
复审当前远端 head 6eb1f50643029837435dc98487abf7ce5ca1c0d5:没有推送或覆盖我本地曾尝试的另一条路线,以下结论只针对这份 manifest 实现。
这版采用 BOTMUX_TMUX_FENCE_ROOTS 多短 root 清单,而不是单 root 复用:每次嵌套 createTmuxFence 都生成独立 /tmp/bmxt-* root,因此 deny log、socket 和 teardown 不互相污染;runner 按 manifest 统一回收。manifest 只接受 /tmp/bmxt-* 直接子目录,截断或非法记录会失败并保留清理证据,没有形成任意目录删除入口。
独立验证:
- 带真实 bunfig/preload 的 runner 嵌套场景(
fenced-run、systemd-fence、minimax-long-entry、tmux-process-reaper):4/4 文件通过。 bun run build/ typecheck:通过。- Vitest 聚焦回归:27/27。
- Bun:
tmux-process-reaper8/8、bun-runner-process-reaper3/3、herdr-discovery16/16。
当前实现覆盖了二次创建、长 socket、损坏 manifest、延迟启动和回收生命周期,未发现新的代码阻塞。合入仍以 run 44881028082 首跑全绿为准。
deepcoldy
left a comment
There was a problem hiding this comment.
首跑门禁已满足:run 44881028082(attempt=1,head 6eb1f50643029837435dc98487abf7ce5ca1c0d5)全部 job 成功。
- 四个
bun-testshard 与四个testshard 全部通过; - build、三个 binary job、聚合 test/bun-test 均通过;
- PR 当前其它 checks(含 CodeQL)也全部为 SUCCESS。
结合此前的实现复核、真实 runner 嵌套场景和变异验证,#3687 已具备按既定流程合入 master 的条件。后续 #3684 同步到该 master 后,应以新 head 自己的首跑结果继续判断,不沿用本次绿灯替代。
|
@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 b58b18a…200cdf615(2 个提交),同批合入的还有 #3416,失败不一定由本 PR 引起。
|
|
🚀 Released in v3.59.27 |
问题
Closes #3683。
测试的私有 tmux server 在
kill-server失败、或子测试被直接 SIGKILL 后,可能仍存活;紧接着删除 socket/scratch 目录会让它失联并长期占用进程与内存。sandbox lab 的 fake CLI 也有同类残留路径。修改
test-process-reaper:/proc/net/unixinode 与/proc/<pid>/fd对应关系定位 server,socket 已 unlink 也能找到;lsof -U做同路径解析;/proc/<pid>/cmdline,不做宿主进程名或 fleet socket 扫描。execreal client 前同步写 intent,保持 real client 的 timeout/signal/PID 语义;kill-server前同步捕获 PID。影响面
仅修改测试 runner、测试 fence 和测试 harness,不改产品代码。共享 tmux shim 覆盖所有经 PATH 调用 tmux 的测试;真实 worker / sandbox 的 PTY 路径不变。非 Linux 的
lsof解析有行为回归,但本环境不能进行 macOS live 验证。验证
bun run build:通过(含 typecheck)。test/tmux-*.test.ts:40 文件通过,973 passed / 1 skipped。worker-codex-actor-launcherBun:6/6 通过。test/test-hygiene.test.ts:28/28 通过。🤖 Generated with Claude Code