comet-guard.sh 是 Comet phase transitions 的 enforcement layer。在从一个 phase 推进到下一个 phase 之前,它会检查所有 exit conditions 是否满足,例如 tasks 已完成、verification report 已存在、branch status 已处理。检查失败时,guard 会输出 BLOCKED message,包含每项检查的 [FAIL] 行和可执行的 Next: 建议,而不是静默阻止进度。
用法
| Argument | 说明 |
|---|---|
<change-name> | active change 的名称(字母数字、hyphens、underscores) |
<phase> | 要验证 exit conditions 的当前 phase |
--apply | 所有检查通过后自动更新 .comet.yaml |
open、design、build、verify、archive
Guard 按 Phase 检查什么
Guard 会根据当前 phase 运行不同检查。只有所有检查通过后,--apply 才会写入 state。
open — exit to design
open — exit to design
| Check | Condition |
|---|---|
proposal.md | File exists and is non-empty |
design.md | File exists and is non-empty |
tasks.md | File exists and is non-empty |
| Task list | tasks.md contains at least one task entry |
--apply 下通过时,guard 会调用 comet-state.sh transition <name> open-complete,将 phase 从 open 推进到 design(full workflow),或直接推进到 build(hotfix/tweak)。design — exit to build
design — exit to build
| Check | Condition |
|---|---|
proposal.md | File exists and is non-empty |
design.md | File exists and is non-empty |
tasks.md | File exists and is non-empty |
handoff_context | Points to a non-empty file in .comet/handoff/ |
handoff_hash | Valid 64-character hex SHA256, matches current source material |
| Handoff markdown | design-context.md exists alongside design-context.json |
| Handoff traceability | Markdown contains Generated-by, Mode, per-file Source: and SHA256: markers |
| Design Doc (if set) | File exists, frontmatter links current change (comet_change), declares role: technical-design and canonical_spec: openspec |
--apply 下通过时,guard 会调用 comet-state.sh transition <name> design-complete,设置 phase: build。build — exit to verify
build — exit to verify
| Check | Condition |
|---|---|
isolation | Set to branch or worktree |
build_mode | Set to subagent-driven-development, executing-plans, or direct |
build_mode authorization | direct is only allowed for hotfix/tweak workflows, or when direct_override: true is set |
tasks.md | All tasks marked [x]; no remaining [ ] tasks |
proposal.md | File exists and is non-empty |
| Build command | If build_command is configured, it must exit 0 |
--apply 下通过时,guard 会调用 comet-state.sh transition <name> build-complete,设置 phase: verify、verify_result: pending、verification_report: null 和 branch_status: pending。verify — exit to archive
verify — exit to archive
| Check | Condition |
|---|---|
tasks.md | All tasks marked [x] |
| Verify command | If verify_command is configured, it must exit 0; otherwise falls back to build_command |
verification_report | Set and points to an existing file |
branch_status | Equal to handled |
--apply 下通过时,guard 会调用 comet-state.sh transition <name> verify-pass,设置 verify_result: pass、phase: archive 和 verified_at。archive — completeness check
archive — completeness check
| Check | Condition |
|---|---|
archived | Equal to true |
proposal.md | File exists and is non-empty |
tasks.md | All tasks marked [x] |
archive 时,--apply 不会产生效果,也不会触发 state transition。—apply Flag
不带--apply 时,guard 会以 code 0(全部通过)或 1(blocked)退出并打印结果,但不会修改 .comet.yaml。
带 --apply 时,所有检查通过后,guard 会在内部把 state update 委托给 comet-state.sh transition:
--apply 不会产生效果。guard 会以 1 退出,state file 不会被修改。
Blocked Output
验证失败时,guard 会输出BLOCKED,包含每项检查的 [PASS]/[FAIL] 结果,并为每个失败检查提供 Next: 建议。以下是 blocked build phase 示例:
[FAIL] 行都会包含失败的具体条件,以及用于解决问题的具体 Next: action。
Project Build 和 Verify Commands
如果.comet.yaml 包含 build_command 或 verify_command 字段,guard 会把它作为 phase check 的一部分运行:
buildphase:如果配置了build_command则运行它;否则自动检测package.json、pom.xml或Cargo.tomlverifyphase:如果配置了verify_command则运行它;否则 fallback 到build_command或相同的自动检测
"$COMET_BASH" -lc "<command>" 运行;如果失败,会打印其输出。测试期间可设置 COMET_SKIP_BUILD=1 来跳过 build/verify command execution。
Schema Validation
在运行任何 phase checks 之前,guard 会调用comet-yaml-validate.sh 验证 .comet.yaml schema。如果 validation 失败,guard 会立即以 fatal error 退出,不会运行 phase checks。