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>
8 KiB
Handoff Protocol — エージェント間引き継ぎ手順
全 Phase のエージェント交代時に必ず従うプロシージャ。 引き継ぎ条件を満たさない限り、次のエージェントは作業を開始してはならない。
1. 引き継ぎの原則
前任エージェント(sender)
│
├─ 1. GATE.md の全条件を GREEN にする
├─ 2. HANDOFF_NOTE.md を書く
├─ 3. git commit + push する
└─ 4. 完了を通知する
│
▼
後任エージェント(receiver)
│
├─ 1. git pull で最新を取得
├─ 2. HANDOFF_NOTE.md を読む
├─ 3. cargo test + cargo clippy で GREEN を確認
├─ 4. TASKS.md の未完了チェックボックスを確認
└─ 5. 作業開始
2. HANDOFF_NOTE.md テンプレート
各 Phase ディレクトリに sender が書き残すファイル。
# Handoff Note: Phase N
## Sender
- Agent: {agent name}@{node}
- Completed at: {ISO 8601 timestamp}
- Commit: {git commit hash}
## Status
- cargo test: {PASS/FAIL} ({N}/{M} tests)
- cargo clippy: {PASS/FAIL}
- GATE.md: {ALL GREEN / N remaining}
## What was done
- {completed task 1}
- {completed task 2}
## What was NOT done (and why)
- {skipped task}: {reason}
## Known issues / warnings
- {issue 1}
- {issue 2}
## Context for receiver
- {important context that isn't obvious from code}
- {files that were tricky or need special attention}
## How to verify
```bash
cargo test
cargo clippy --all-targets -- -D warnings
---
## 3. エージェント別引き継ぎプロシージャ
### 3.1 Codex → Codex(worktree 間)
Codex A (sender):
- cargo test → GREEN
- cargo clippy → GREEN
- Write phase-N/HANDOFF_NOTE.md
- git add -A && git commit -m "[完了] Phase N: {summary}"
- git push
Codex B (receiver):
- git pull origin main
- Read phase-N/HANDOFF_NOTE.md
- Read phase-N+1/TASKS.md
- Read phase-N+1/ASSIGNMENT.md
- cargo test → must be GREEN (sender's work didn't break anything)
- Begin phase-N+1/TASKS.md checkboxes
### 3.2 Codex → Claude Code(worktree → local)
Codex (sender):
- cargo test → GREEN
- Write phase-N/HANDOFF_NOTE.md
- git commit + push
Claude Code (receiver):
- git pull
- Read HANDOFF_NOTE.md
- cargo test (verify locally)
- Read phase-N+1/TASKS.md
- If Phase requires interactive debugging (5, 6, 8): proceed locally
- If Phase is parallelizable: dispatch sub-tasks to Codex
### 3.3 Claude Code → Codex(local → worktree)
Claude Code (sender):
- cargo test → GREEN
- Write phase-N/HANDOFF_NOTE.md
- git commit + push
- Dispatch via tmux:
tmux send-keys -t %{pane} "codex 'Execute Phase {N+1}.
Read docs/autorun/phase-{N+1}-*/TASKS.md and HANDOFF from phase-{N}.
git pull first. Run cargo test before starting.
Write your HANDOFF_NOTE.md when done.'" Enter
Codex (receiver):
- git pull
- Read phase-N/HANDOFF_NOTE.md (predecessor context)
- cargo test → GREEN
- Execute TASKS.md
- Write phase-N+1/HANDOFF_NOTE.md
- git commit + push
### 3.4 Claude Code → OpenClaw main(local → gateway)
Claude Code (sender):
- cargo test → GREEN
- Write phase-N/HANDOFF_NOTE.md
- git commit + push
- Dispatch:
openclaw agent --agent main --message
"[TASK] Execute Phase {N+1} of DTP.
Repo: Miyabi-G-K/deterministic-task-protocol.
Read docs/autorun/phase-{N+1}-/TASKS.md.
GATE: docs/autorun/phase-{N+1}-/GATE.md.
Previous handoff: docs/autorun/phase-{N}-*/HANDOFF_NOTE.md."
OpenClaw main (receiver):
- git clone / pull
- Read HANDOFF_NOTE.md
- cargo test → GREEN
- Execute or delegate to sub-agents
- Write HANDOFF_NOTE.md
- git commit + push
- Report completion via Telegram
---
## 4. 引き継ぎ条件チェックリスト(sender 用)
sender は以下を全て満たしてから引き継ぐ:
[ ] cargo test → GREEN [ ] cargo clippy -- -D warnings → GREEN [ ] GATE.md の全条件が GREEN [ ] HANDOFF_NOTE.md を該当 Phase ディレクトリに書いた [ ] git add + commit + push 済み [ ] 次の Phase の ASSIGNMENT.md を確認し、receiver を特定した [ ] receiver への通知を送った(tmux / OpenClaw / Telegram)
---
## 5. 引き継ぎ受理チェックリスト(receiver 用)
receiver は以下を全て満たしてから作業開始:
[ ] git pull で最新コードを取得した [ ] HANDOFF_NOTE.md を読んだ [ ] cargo test → GREEN(sender の作業が壊れていないことを確認) [ ] TASKS.md の残チェックボックスを確認した [ ] GATE.md の承認条件を理解した [ ] ASSIGNMENT.md の制約(並列可否、依存)を理解した
---
## 6. 引き継ぎ失敗時のリカバリ
### sender の GATE が GREEN にならない場合
sender:
- HANDOFF_NOTE.md に "Status: PARTIAL" と書く
- What was NOT done に未完了項目を列挙
- Known issues に失敗原因を書く
- git commit + push(作業途中でも push)
- 人間に ESCALATE: "Phase N が GATE 未達。理由: {reason}。対応方針を判断してください。"
### receiver が cargo test FAIL を検出した場合
receiver:
- HANDOFF_NOTE.md を再確認(sender が認識していた問題か?)
- git log で sender の最終コミットを確認
- 自分のコードが原因でないことを確認
- sender に差し戻し(tmux / OpenClaw で通知): "Phase N の HANDOFF を受理できません。cargo test FAIL。 失敗テスト: {test name}。sender 側で修正してください。"
- 3回差し戻しで人間 ESCALATE
### エージェントがクラッシュ/応答なしの場合
監視側(Claude Code or 人間):
- tmux capture-pane で最後の出力を確認
- git log で最終コミットを確認
- cargo test で現在の状態を確認
- 代替エージェントを起動:
- 同じ Phase の TASKS.md を渡す
- HANDOFF_NOTE.md がなければ「前任クラッシュ」として扱う
- cargo test GREEN から再開
---
## 7. 並列 Phase の同期点
Phase 2 と Phase 3 は並列実行可能だが、Phase 6 は両方の完了を待つ。
Phase 2 (Codex B) ─────┐ ├──→ 同期点: 両方の GATE GREEN を確認 Phase 3 (Codex C) ─────┘ │ ▼ Phase 4 (Phase 3 依存) │ Phase 5 (Phase 3 依存) │ Phase 6 開始条件: [ ] Phase 2 GATE GREEN [ ] Phase 3 GATE GREEN [ ] Phase 4 GATE GREEN [ ] Phase 5 GATE GREEN [ ] 全 HANDOFF_NOTE.md 存在
同期点の確認は **Claude Code(オーケストレーター)** が行う:
```bash
# 全 Phase の GATE 状態を一括確認
for phase in phase-2-state-machine phase-3-event-store phase-4-file-lock phase-5-github-sync; do
echo "=== $phase ==="
cat docs/autorun/$phase/GATE.md | grep "\[x\]" | wc -l
cat docs/autorun/$phase/GATE.md | grep "\[ \]" | wc -l
done
8. 通知テンプレート
Phase 完了通知(sender → 全体)
[DTP] Phase {N} 完了
Agent: {agent}@{node}
Commit: {hash}
Tests: {N}/{M} GREEN
GATE: ALL GREEN
Next: Phase {N+1} → {receiver agent}
HANDOFF: docs/autorun/phase-{N}-*/HANDOFF_NOTE.md
Phase 開始通知(receiver → 全体)
[DTP] Phase {N} 開始
Agent: {agent}@{node}
Predecessor: Phase {N-1} by {sender agent}
HANDOFF received: ✅
cargo test: GREEN
Starting TASKS.md execution...
エスカレーション通知
🚨 [DTP] Phase {N} ESCALATION
Agent: {agent}@{node}
Issue: {description}
Attempts: {N}/3
Action needed: 人間判断
HANDOFF: docs/autorun/phase-{N}-*/HANDOFF_NOTE.md