Repository navigation
test(agent-core-v2): stabilize process group reaping coverage - #5156
kimi-agent-bot wants to merge 1 commit into
Conversation
Co-authored-by: Grapedge <grapedge@gmail.com>
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
commit: |
CI 失败现象
main分支 run 44537151668 / job 135605543365 中,packages/agent-core-v2/test/remote/process.test.ts的does not evict live groups at the former cache limit and reaps missing groups在 30 秒后超时;紧随其后的 Windows executor 用例还观测到前一用例残留的 6444 次process.kill调用。main分支 run 44556645563 / job 135674373960 的同一测试分片通过。失败提交仅修改 TUI 与 changeset,未触及远程进程模块,符合主分支偶发失败特征。根因分析
该用例构造 4097 个已退出进程组,并两次调用
advanceTimersByTimeAsync(5_000)推进 reap 定时器。定时器回调均为同步逻辑,但异步推进 API 会在大量定时器回调之间引入额外的微任务调度;CI 高负载下这会显著放大执行时间并撞上 30 秒超时。Vitest 超时不会取消仍在执行的异步函数,导致前一用例的定时器继续运行并污染后一用例。Mutation Test 与用例意义判定
针对
ProcessManager.scheduleGroupReap注入了两个最小变异,并在每次验证后立即还原生产源码:expected +0 to be 4097),证明保留存活进程组的断言有效。ESRCH分支中的进程组清理:目标用例按预期失败(expected 4097 to be +0),同组两个 Windows executor 用例仍通过,证明回收已消失进程组的断言有效。结论:用例同时守护“不过早淘汰存活组”和“回收已消失组”两项业务契约,具有独立回归价值,应保留并修复测试调度方式。
修改内容
仅将上述两处定时器推进改为同步
vi.advanceTimersByTime(5_000)。回调内没有需要等待的异步操作,因此业务断言与 fake timer 时间窗口保持不变,同时避免不必要的微任务让出。未修改生产代码,未添加 changeset。本地验证
test/remote/process.test.ts整文件:23/23 通过。pnpm --filter @moonshot-ai/agent-core-v2 typecheck:通过。oxlint --type-aware --deny-warnings packages/agent-core-v2/test/remote/process.test.ts:0 warnings / 0 errors。test/features/tower/store.test.ts状态锁超时,该用例隔离重跑通过,与本次测试文件改动无关。Requested by 刘金 via Mira.