Repository navigation
test(kap-server): stabilize trust recovery fixtures - #5003
kimi-agent-bot wants to merge 1 commit into
Conversation
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>
|
@codex review |
|
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. |
commit: |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
CI 失败现象
main的 CI run 43371537526(job131708189701)以及文档 PR feat(kap): add agent-to-agent HTTP wait/interactions/kap.md, web --json, and KAP guide #4966 的 CI run 43972549806(job133668176989)均在packages/kap-server/test/workspaces.test.ts的reloads project config when trust initialization recovers to an existing marker用例出现偶发失败:初始化后的 MCP servers 期望为{},实际却提前包含了projectOnly。不稳定根因
测试把
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;结论:这两个用例能够捕获“信任恢复后必须加载项目级 MCP 配置”的回归,具有有效守门价值,因此保留并修复同步机制,不删除用例。
本地验证
基于最新
origin/main(fec742878d73678082b304c887e4fb1564088c54):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-expressionwarnings);git diff --check:通过;提交后git show复核仅包含上述测试文件的 2 处故障清除位置调整,无生产代码变异或额外文件。纯测试夹具修复,不添加 changeset。
Requested by 刘金 via Mira.