Skip to content

test(kap-server): stabilize trust recovery fixtures - #5003

Open
kimi-agent-bot wants to merge 1 commit into
mainfrom
test/kap-server-stabilize-trust-recovery
Open

kimi-agent-bot wants to merge 1 commit into
mainfrom
test/kap-server-stabilize-trust-recovery

Conversation

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator

CI 失败现象

不稳定根因

测试把 shouldFail 设计成一次性故障:第一次读取 workspace-trust 抛错时就立即清除故障。异步初始化发生重试时,后续读取可能提前成功,导致项目级 MCP 配置在 mcpConfig.ready 断言前就被加载;同时,已有信任标记的恢复事件可能早于测试注册 onDidChange 监听器,形成时序竞态。

本 PR 对两个同模式用例做相同修复:让故障在整个初始化阶段持续生效,只在 mcpConfig.ready、初始空配置断言及恢复监听器注册完成后、显式调用 trust/untrust 接口前清除故障。这样初始失败与显式恢复两个阶段被确定性地分开,生产代码不变。

Mutation Test 与用例意义

针对 WorkspaceMcpConfigService.initialize 的关键契约注入最小变异:将加载 MCP 配置时的 includeProject: trusted 改为 includeProject: false,重新构建 agent-core-v2 后运行整个 workspaces.test.ts:

  • 两个信任恢复用例均按预期失败,报错为缺少 projectOnly;
  • 同文件其余 24 个稳定用例仍通过;
  • 变异后立即还原生产源码并重新构建,还原后整文件 26/26 通过。

结论:这两个用例能够捕获“信任恢复后必须加载项目级 MCP 配置”的回归,具有有效守门价值,因此保留并修复同步机制,不删除用例。

本地验证

基于最新 origin/main(fec742878d73678082b304c887e4fb1564088c54):

  • 两个目标用例连续运行 20 轮,20/20 全部通过;
  • packages/kap-server/test/workspaces.test.ts:26/26 通过;
  • pnpm -C packages/kap-server typecheck:通过;
  • pnpm exec oxlint --type-aware packages/kap-server/test/workspaces.test.ts:0 errors(仅该文件原有 3 条 no-confusing-void-expression warnings);
  • git diff --check:通过;提交后 git show 复核仅包含上述测试文件的 2 处故障清除位置调整,无生产代码变异或额外文件。

纯测试夹具修复,不添加 changeset。

Requested by 刘金 via Mira.

Keep the injected trust-read failure active through initialization and clear it only when the explicit recovery begins. This prevents initialization retries from consuming the one-shot failure before the test registers its recovery listener.

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

Copy link
Copy Markdown
Collaborator Author

@codex review

@changeset-bot

changeset-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1199bdb

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 17, 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-17T01:46:43.817587Z 1199bdb 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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

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

commit: 1199bdb

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 1199bdba73

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

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