mergegate/autorun/phase-2-state-machine/TASKS.md
林 駿甫 (Shunsuke Hayashi) 146fcafc5e [追加] DTP (Deterministic Task Protocol) 設計文書・指示書を移植
deterministic-task-protocol リポから miyabi-cli-standalone に統合:
- docs/dtp/: PLAYBOOK, PLAN, UML, GIT-RULES, Codex レビュー 3件
- autorun/: Phase 0-8 の TASKS/ASSIGNMENT/GATE + INDEX/HANDOFF/ROLLBACK
- project_memory/tasks.json: 全9 Phase の DAG SSOT
- skills/: polaris-ops, rust-llm-pitfalls
- .codex/instructions.md: Codex 設定

実装は miyabi-core に gate.rs, lock.rs, protocol.rs, store.rs を追加する方針。
既存の dag.rs, github.rs, approval.rs 等は変更不要。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 01:07:32 +09:00

37 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Phase 2: ステートマシンに GATE predicate を統合
> 依存: Phase 1 GREEN
> 承認ゲート: 全遷移ルールにテスト + 不正遷移が全て拒否される
## 現状
`src/state.rs``can_transition(from, to) -> bool` の単純な matches! 式。
conditions/predicates の実評価がないCodex R1-1 の致命的指摘)。
## タスク
- [ ] `TaskStateMachine``Merged``AwaitingGithubSync` の遷移ルールを追加
- [ ] `can_transition()``can_transition(task: &ManagedTask, to: TaskState) -> Result<(), GateError>` に変更
- draft → pending: title 非空 + github_issue_number > 0
- pending → ready: dependencies.all(done) DAG 経由で検証)
- ready → analyzing: 無条件
- analyzing → implementing: impact.is_some() + lock.is_some() + HIGH/CRITICAL は human_approval
- implementing → reviewing: branch_name.is_some() + pr_number > 0
- reviewing → merged: github_evidence.pr_state == MERGED + merge_commit_sha が 40hex
- merged → done: github_evidence.issue_state == CLOSED
- [ ] `skip_analysis` ルールpending → implementingを削除R1-7
- [ ] 不正遷移テスト: analyzing → implementing を impact なしで試みる → GateError
- [ ] 不正遷移テスト: reviewing → merged を不正 SHA で試みる → GateError
- [ ] 不正遷移テスト: merged → done を Issue Open で試みる → GateError
- [ ] 全合法遷移の happy path テスト
## 承認ゲート
- `cargo test` 全 GREEN
- 不正遷移テストが最低 5 件存在し、全て正しく拒否される
- `can_transition()` が ManagedTask を受け取る形に変更されている
## リトライ条件
- 既存テスト破壊 → protocol.rs のテストが新しい can_transition() に対応しているか確認
- gate.rs との責務重複 → gate.rs は個別 GATE 関数、state.rs は遷移の orchestration と明確に分離