fix(test): codex-hooks-config 在 .codex/ 不存在时自适应跳过 (closes #3 Gap 2) - #7
Merged
Conversation
PR #4 dogfood 后跑 Ubuntu CI 的 pnpm test 报 7 个 fail,全在 packages/cli/src/__tests__/codex-hooks-config.test.ts 一个文件里, 错误一致: Error: ENOENT: no such file or directory, open '/home/runner/work/Matrix/Matrix/.codex/hooks.json' 根因:这套测试来自 TeamBrain(issue #290 Codex CLI hook adapter), Matrix baseline(2026-05-14 history-stripped fork)没把 .codex/ 目录 带过来。target 文件不存在 → ENOENT。 按内存 [Matrix is independent]:Matrix 自走、不反向 merge TeamBrain, 不该把 .codex/ 拉回来。改用 vitest describe.skipIf: const codexHooksExist = existsSync(hooksJsonPath); describe.skipIf(!codexHooksExist)('.codex/hooks.json ...', () => { ... }) 行为: - Matrix(.codex/ 不存在) → 整个 describe block 跳过,7 tests skipped - 上游 TeamBrain(.codex/ 存在) → 测试照常激活 - 以后 Matrix 决定接 Codex hooks → 自动重新生效,无须改测试 本地验证(`vitest run` 单文件): Test Files: 1 skipped Tests: 7 skipped (7) 至此 issue #3 Gap 2 收尾。理论上下一次 pr-review.yml 跑应该: - repro-pass: pass(豁免,PR #4 修) - tests-and-merge-clean: pass(0 failed) → verdict: pass → can-auto-merge: 全部门控过 → 自动 squash merge 这将是仓库第一次真全自动合 PR。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ 远程评审 verdict: passcommit
|
…init 流程产物 PR #7(Gap 2)dogfood 第一次跑暴露第二个 sub-gap: codex-hooks-config 的 skipIf 修复让 pnpm test 真过(3526 / 56 skip / 0 fail),但 tests job 仍 failure。根因是后一个 step「Working tree must be clean」检测到 untracked 文件: ##[error]tests 跑完后工作树不干净: ?? .claude/hooks/check-teamagent.sh `teamagent init` 是 pnpm test 链路里跑的(测试产物之一)。它生成: - .teamagent/required.json(已被 .teamagent/ ignore) - .claude/hooks/check-teamagent.sh(漏了) 两个是同一 "Required 模式产物" pipeline 的输出,语义一致 → 加进 .gitignore。 至此 PR #7 应能让 tests-and-merge-clean 真翻绿,verdict=pass, 触发首次完全自动 squash-merge。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR #7 v2 dogfood 第三个 sub-gap:tests + tree-clean 都修过后,verdict job 在 'Post comment + set status' step 仍崩: Error: update comment 失败: gh: Not Found (HTTP 404) 根因(本 session PR #2 引入的 post-pr-comment.ts bug): - line 71: `gh pr view --json comments` 返回 GraphQL node ID(IC_kwDOI...) - line 81: `gh api repos/.../issues/comments/{id}` PATCH 要 REST integer id - 不匹配 → PATCH 404 为什么 PR #2 / #4 没炸:每个 PR 只跑过一次 verdict → 没现成评论可更新 → 只走 CREATE 路径(line 87 `gh pr comment`)→ 没暴露。PR #7 是本仓库 第一个 multi-commit PR:v1 (2798a32) 创了评论 → v2 (1aa98e3) 想更新 → 404。 修复: - 列评论改用 `gh api repos/.../issues/{pr}/comments` —— 返回 REST id, 跟 PATCH 端点格式一致 - CREATE 也改走 REST POST(对称;新评论的 id 直接是 REST 制式,下次能 正确 UPDATE) 这是 dogfood 的核心价值 —— 第一次真有 multi-commit PR 跑流水线就揪出了 首次 ship 时遗漏的 code path bug。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR #7 v3 dogfood 全部 review 翻绿后,auto-merge.yml workflow 真触发 (workflow_run on PR Review success),但本身崩在 setup-node 那步: ##[error]Unable to locate executable file: pnpm. 根因:actions/setup-node@v5 默认 package-manager-cache=true,看到 pnpm-lock.yaml 就要找 pnpm 来计算 cache 目录;auto-merge.yml 没在 setup-node 之前先 pnpm/action-setup → setup-node 找不到 pnpm 报错。 setup-repo composite action 顺序是对的(pnpm 先,node 后);auto-merge.yml 没复用 composite,自己 inline 两行,顺序错了。 修复:加 pnpm/action-setup@v5 在 setup-node@v5 之前,并显式 cache: pnpm。 至此 PR #7 应能真触发 auto-merge.yml + 真合 main。这条路径要等本 commit 进 main 之后下一个 PR 才能真测。本 PR(#7)自己的 auto-merge 还会用 main 上现有的(broken)auto-merge.yml,所以 PR #7 仍要 human-merge 一次。 链式 dogfood 揪 bug 数累计:4 个。所有 4 个都是本 session 之前 ship 时未被多 commit / 第一个真 SHA 路径覆盖到的盲区。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
fix(test): codex-hooks-config 在
.codex/不存在时自适应跳过 (issue #3 Gap 2)根因
PR #4 dogfood Ubuntu CI 的
pnpm test跑出 7 failed / 3526 passed / 49 skipped(3582 总)。7 个 fail 全在一个文件:packages/cli/src/__tests__/codex-hooks-config.test.ts,错误一致:这套测试来自上游 TeamBrain 的 issue #290(Codex CLI hook adapter contract)。Matrix baseline(2026-05-14 history-stripped fork)没把
.codex/目录带过来,target 文件不存在 → ENOENT。(本地 Windows 21 个 fail 是另一波 ——
install-rollback/session-start-input-shape/symphony,Ubuntu 上不复现;那 3 类是 Windows-only 问题,本 PR 不在范围。)修复(10 行)
按 memory
[Matrix is independent]:Matrix 自走、不反向 merge TeamBrain,不该把.codex/拉回来。改用 vitestdescribe.skipIf:行为:
.codex/不存在) → 整个describeblock 跳过,7 tests skipped.codex/存在) → 测试照常激活,contract 不丢本地验证
$ vitest run packages/cli/src/__tests__/codex-hooks-config.test.ts Test Files: 1 skipped Tests: 7 skipped (7)预期 dogfood —— 仓库第一次真全自动合
本 PR 一开,
pr-review.yml跑应该:repro-passtests-and-merge-clean→ verdict: pass 🎉
→
can-auto-merge.ts所有门控通过(state=OPEN, base=main, !draft, !fork, !do-not-merge, !visual-proof, reviewVerdictState=success, mergeable=MERGEABLE)→
auto-merge.yml触发gh pr merge --squash --delete-branch—— 本仓库历史首次完全自动合关联
🤖 Generated with Claude Code