Repository navigation
test(kap-server): stabilize remote git session tests - #4911
Conversation
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
@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: |
Port MoonshotAI#4901, MoonshotAI#4909 and MoonshotAI#4911: complete the task before asserting a zero-timeout wait sees the completed snapshot, restore the instructions reload spy after the failure assertion, poll the search index until it is ready before asserting the page, and run remote-session git probes through a host process that refuses gh. Record MoonshotAI#4840 as equivalent (the refresh path already rebuilds from the effective binding here) and pin it with a regression case, record MoonshotAI#4883 as ported with the compaction profile already present, and record MoonshotAI#4830 as blocked on the absent loop requester/request-attribution layering. Clear the generated-bundle, release-sync and working-notes rows with their applicable verdicts.
Requirement or Bug
Related to #4818 and its failed CI shard.
kap-server的两条远程 Git 路由测试在 CI 分片运行时偶发将branch读成null,重跑后恢复。本 PR 消除测试对 runner 上gh进程耗时的依赖,同时保留真实git、环境路由和缓存行为验证。Bug Reproduction Steps
在测试进程
PATH的最前面放入一个执行sleep 5的临时gh,保持仓库代码不变。运行:
两条用例均稳定失败,报错为
AssertionError: expected null to be 'master',与 CI 失败一致。应用本 PR 后保持同一个慢
gh环境再次运行,两条用例均通过。Root Cause
远程会话通过
GitDomainResolver.fetch()创建真实GitService。GitService.status()在完成git rev-parse和git status后,默认还会串行执行gh pr view查询 PR。远程列表查询外层只有 3 秒预算;CI 分片并发时,额外的
gh进程启动与执行可能使总耗时超过预算,触发超时降级,最终返回{ branch: null, pull_request: null }。这是测试侧的根本修复:两条用例只验证 Git 路由与缓存,不验证 PR 查询,因此移除它们与外部
gh实现及机器负载之间的非确定性依赖。生产代码和超时预算保持不变。Code Changes
在
packages/kap-server/test/v2Sessions.test.ts中新增实例级hostProcessWithoutGh()包装,并接入两条远程 Git 用例:routes session git by environment even when local and remote cwds collidedoes not cache remote git while its environment is not readygh的 spawn failure 由现有GitService按 PR 不可用处理,已读取的分支正常保留。其他命令继续执行真实HostProcessService,所以本地/远程 cwd 冲突、环境从 connecting 转为 ready、缓存次数及真实 Git 分支读取仍由原断言覆盖。包装只作用于这两个环境实例,不修改全局 prototype,也不影响相邻的超时测试。Behavior Changes and Affected Users
None。仅修改测试文件;生产路由、配置默认值、API 契约、CLI 输出和发布产物均未改变,TUI、print 模式、desktop 与 web、VS Code、ACP 及 SDK 用户无可感知变化。
受影响模块与覆盖:
packages/kap-server/test/v2Sessions.test.tsnull结果仍不会被缓存到 ready 之后。git调用、重复请求缓存及相邻的远程超时测试保持原路径。验证明细
gh确定性复现:修复前 2 个用例失败,修复后 2 个用例通过。packages/kap-server/test/v2Sessions.test.ts:52/52 通过。pnpm --filter @moonshot-ai/kap-server run typecheck:通过。pnpm exec oxlint --type-aware packages/kap-server/test/v2Sessions.test.ts:0 errors;仅有未改动代码中的 2 个已有 warnings。git diff --check:通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.