fix(orchestrator): wire TASK.md writing and §6.2 pickup validation (B6, partial)

Fixes AUDIT.md's B6: nothing wrote a TASK.md into a worktree, so
continuity.ValidatePickup had no caller and no file to check.

- continuity.RenderTaskFile/TaskFileHash: render and hash the immutable
  §6.2 TASK.md from a domain.Task.
- GitWorktrees.Create writes and commits TASK.md into every freshly
  created worktree (must be committed, not dirty, for ScratchCommit's
  immutability check and for a stable hash).
- Coordinator.Start now runs continuity.ValidatePickup (anchor SHA,
  dirty-file hashes, TASK.md hash) against the real worktree before
  bootstrapping a successor onto a handoff_ref, and blocks the task
  instead of bootstrapping on a validation failure.

Still open from Phase 4: handoff production (agent writing the real
handoff; Release still refuses per B5), ScratchCommit wiring before
release, and the §6.2 bootstrap-prompt rewrite — see AUDIT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1rkJ2hBMybnJctPbcy4tT
This commit is contained in:
kami
2026-07-27 21:44:00 +04:00
parent a2c3d040d3
commit 7bcad64398
7 changed files with 289 additions and 3 deletions
+25 -1
View File
@@ -75,7 +75,31 @@ Fixed so far:
`main()`) so this follows the existing (untested) pattern rather than
introducing a one-off test harness.
Not yet started: B6 (Layer 3 wiring), B7 (quota projection has no producer),
- **B5 (loose end)** — `CLIAdapter.Lease`'s initial prompt used `wait=0`,
skipping the inline wait `Bootstrap` already used; the spec (§5.1) requires
inline `wait` on `agent.prompt` for bootstrap injection to avoid sending
into a half-rendered prompt. Changed to `time.Minute`, matching `Bootstrap`.
Small, contained fix — `Release`'s real implementation (needs Phase 4
handoff production) is still outstanding from B5.
- **B6 (partial — Phase 4 items 1 and 4)** — nothing wrote a `TASK.md` into a
worktree, so pickup validation had nothing to check and never ran anyway.
Fixed both halves: `GitWorktrees.Create` now writes and commits an
immutable `TASK.md` (`continuity.RenderTaskFile`) into every freshly
created worktree, and `Coordinator.Start` now runs
`continuity.ValidatePickup` (loading the handoff from CAS, checking anchor
SHA + dirty-file hashes + TASK.md hash) before bootstrapping a successor
onto a `handoff_ref` — a failure kills the session and emits `TaskBlocked`
instead of trusting an unvalidated ref. Covered by
`TestGitWorktreesCommitsTaskFile` and `TestStartBlocksOnInvalidPickup` in
`internal/orchestrator`. **Not done:** handoff *production* (nothing yet
writes a real §6.1 handoff — `Release` still refuses per B5), wiring
`ScratchCommit` before release, and the §6.2 bootstrap-prompt rewrite. See
AUDIT.md's "B6 — partial fix" section for the full breakdown, including a
named caveat: TASK.md hashing is best-effort and untested for the
herdr-hosted (`WorktreeCreator`) worktree path.
Not yet started: B7 (quota projection has no producer),
Codex/opencode completion producers, the turn-decision endpoint, S2S4,
S7S11. See `AUDIT.md` for the full plan.