Skip to content

test(agent-core-v2): stabilize process group reaping coverage - #5156

Open
kimi-agent-bot wants to merge 1 commit into
mainfrom
test/agent-core-v2-stabilize-process-group-reap
Open

kimi-agent-bot wants to merge 1 commit into
mainfrom
test/agent-core-v2-stabilize-process-group-reap

Conversation

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator

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 注入了两个最小变异,并在每次验证后立即还原生产源码:

  1. 让 reap 定时任务直接丢弃进程组:目标用例按预期失败(expected +0 to be 4097),证明保留存活进程组的断言有效。
  2. 删除 ESRCH 分支中的进程组清理:目标用例按预期失败(expected 4097 to be +0),同组两个 Windows executor 用例仍通过,证明回收已消失进程组的断言有效。

结论:用例同时守护“不过早淘汰存活组”和“回收已消失组”两项业务契约,具有独立回归价值,应保留并修复测试调度方式。

修改内容

仅将上述两处定时器推进改为同步 vi.advanceTimersByTime(5_000)。回调内没有需要等待的异步操作,因此业务断言与 fake timer 时间窗口保持不变,同时避免不必要的微任务让出。未修改生产代码,未添加 changeset。

本地验证

  • 目标用例连续运行 50/50 次通过。
  • 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。
  • 包级回归:7710 passed / 1 failed / 6 skipped;唯一失败为未修改的 test/features/tower/store.test.ts 状态锁超时,该用例隔离重跑通过,与本次测试文件改动无关。

Requested by 刘金 via Mira.

Co-authored-by: Grapedge <grapedge@gmail.com>
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 25cd9e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T01:42:25.676354Z 25cd9e6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 25cd9e6328

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@25cd9e6
npx https://pkg.pr.new/@moonshot-ai/kimi-code@25cd9e6

commit: 25cd9e6

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant