fix(test): 修复 CI build 恒红——sandbox 测试按运行时 bwrap 能力门控 + 更新 grant 陈旧断言 - #700
Merged
Conversation
master 的 CI `build`(pnpm test) 长期失败,3 个测试文件的失败与代码/依赖无关:
## 1. plugin-mcp-sandbox / v3-distillation-runner:环境门控不足
这两个文件的真实 bwrap 用例只用 `process.platform === 'linux'`(+ 有无 bwrap 二进制)
做 skip 判断,但 GitHub Actions runner 禁用了非特权 user namespace,bwrap 起不来
(`bwrap: setting up uid map: Permission denied`)→ 用例不 skip 反而 fail。
改为复用 worker 生产同款运行时探针 `probeHostCredentialIsolationMechanism()`
(内部 `--unshare-user … -- /bin/true` 实跑一次)判断 bwrap 是否真的可用,
无能力的 runner 上 skip、有能力的主机(本机)照常真跑。这与
test/fs-policy-bwrap.e2e.test.ts 既有的 `bwrapUsable` 门控是同一思路。
## 2. card-handler-grant-partial:陈旧断言
「部分成功」用例断言 `deleteMock).toHaveBeenCalledWith('h1','om_card')`(撤回原卡),
但 2d1faa4(2026-07-31「授权成功就地更新原卡,不再发通知卡+撤回原卡」)已把行为
改成就地 patch 原卡为终态、不再撤卡。断言未同步更新 → 自那以后恒 fail。
改为断言:handleCardAction 返回就地更新的终态卡(update_multi + 绿头)、且 deleteMock
未被调用(对齐同文件「全部失败」用例的 `deleteMock).not.toHaveBeenCalled()` 风格)。
## 验证
- 本机(bwrap 可用):3 文件 38 测试全跑全绿(sandbox 用例真跑未 skip)
- 模拟 runner(PATH 塞入失败的 bwrap stub):plugin-mcp-sandbox 整块 skip、
v3-distillation PID 用例 skip,0 失败——即 CI 应得的绿
- tsc --noEmit 干净;相邻 card-handler-grant / sandbox / fs-policy-bwrap 套件 47 测试全绿
## 影响面
纯测试文件改动,不动任何 src 运行时逻辑;跨平台/CLI/后端均无影响。
Co-Authored-By: Claude <noreply@anthropic.com>
deepcoldy
added a commit
that referenced
this pull request
Aug 2, 2026
机器过载告警从 per-bot 迁到全局设置,选一个通知 Bot 由它 daemon 采样整机 load/内存发私信(其余 no-op);纯函数抽 computeOverloadThresholds/isOverloadAlertTarget;幂等迁移旧 per-bot 开关。codex 三轮复审全过。 附带修申晗 live 测时报的 3 个 dashboard UI bug(纯前端 style.css + icon-tooltip.ts): - 异形屏 sidebar 不能滚(.sidebar 改 flex column + nav flex:1/min-height:0) - 全局设置瀑布流窄屏溢出重叠(column-count:3 → columns:300px 3 自适应 + 窄列 field-row 单列堆叠) - 详情 dialog 内图标按钮 tooltip 被遮(icon-tooltip 复用 floatingPortalHost 挂 dialog[open] 进 top layer) codex ✅ 复审 delta。已 rebase 到最新 master(含 #700/#706),build 绿 + CI 全绿。
|
🚀 Released in v3.8.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
master的 CIbuildjob(跑pnpm test)长期失败(最近多次 run 均红)。排查后确认 3 个失败测试文件与被测代码/依赖无关,是测试自身的环境门控/陈旧断言问题:问题 1:sandbox 测试环境门控不足(2 个文件)
test/plugin-mcp-sandbox.test.ts、test/v3-distillation-runner.test.ts里跑真实 bwrap 的用例,skip 判断只看process.platform === 'linux'(+ 有无dist/cli.js)。但 GitHub Actions runner 禁用了非特权 user namespace,bwrap 一起就死:于是用例不 skip、反而 fail(
plugin-mcp-sandbox×3、v3-distillation-runnerPID namespace 用例 ×1)。修法:复用 worker 生产同款运行时探针
probeHostCredentialIsolationMechanism()(内部实跑一次--unshare-user … -- /bin/true)判断 bwrap 是否真的可用,无能力的 runner 上 skip、有能力的主机照常真跑。与仓库里test/fs-policy-bwrap.e2e.test.ts既有的bwrapUsable门控是同一思路(DRY:直接用生产探针,不另造一份)。问题 2:
card-handler-grant-partial陈旧断言(1 个文件)「部分成功」用例断言
expect(deleteMock).toHaveBeenCalledWith('h1', 'om_card')(撤回原卡)。但 2d1faa4(2026-07-31,fix(grant): 授权成功就地更新原卡(正文@被授权人),不再发通知卡+撤回原卡)已把行为改成就地 patch 原卡为终态、不再撤卡。断言未同步 → 自那以后恒 fail。修法:改为断言
handleCardAction返回就地更新的终态卡(config.update_multi === true+header.template === 'green')、且deleteMock未被调用——对齐同文件「全部失败」用例已有的expect(deleteMock).not.toHaveBeenCalled()风格。验证
plugin-mcp-sandbox整块 skip、v3-distillationPID 用例 skip,0 失败 = CI 应得的绿tsc --noEmitcard-handler-grant/sandbox/fs-policy-bwrap影响面
纯测试文件改动,不动任何
src运行时逻辑;跨平台 / 跨 CLI / 跨后端均无影响。关联
修复本 PR 后,CI
build将转绿,同时也会解除 #699(Dependabot 安全修复)等其它 PR 因 master 既有 CI 红而误判失败的问题。建议本 PR 先行合入。🤖 Generated with Claude Code