# Milestone v1.1: Test Infrastructure

**Status:** SHIPPED 2026-01-31
**Phases:** 7-9 (including 8.1 inserted)
**Total Plans:** 8

## Overview

E2E test coverage with mocked agents proving all dispatch/coordination scenarios work end-to-end. MockAgentManager enables testing without real Claude CLI, TestHarness provides full system wiring with database fixtures.

## Phases

### Phase 7: Mock Agent & Test Harness

**Goal**: Mock agent adapter with configurable scenarios + test harness foundation with DB-seeded fixtures
**Depends on**: v1.0 complete
**Plans**: 2 plans

Plans:
- [x] 07-01: MockAgentManager Adapter
- [x] 07-02: Test Harness with Database Fixtures

**Key deliverables:**
- MockAgentManager implementing full AgentManager port
- MockAgentScenario for configurable outcomes (success, crash, waiting)
- TestHarness with full system wiring (Dispatch, Coordination, Mock agents)
- Fixture helpers (SIMPLE_FIXTURE, PARALLEL_FIXTURE, COMPLEX_FIXTURE)
- MockWorktreeManager with configurable merge results

### Phase 8: E2E Scenario Tests

**Goal**: Happy path tests (basic flow, dependencies, merging) + edge case tests (conflicts, interrupts, token limits)
**Depends on**: Phase 7
**Plans**: 2 plans

Plans:
- [x] 08-01: Happy Path E2E Tests
- [x] 08-02: Edge Case E2E Tests

**Key deliverables:**
- 6 happy path tests (single task, parallel dispatch, merge flow, complex dependencies)
- 14 edge case tests (agent crash, merge conflicts, blocked tasks, waiting agents)
- Test patterns for E2E scenarios with fake timers

### Phase 8.1: Agent Output Schema (INSERTED)

**Goal**: Define structured agent output schema (done/question/error discriminated union) and update ClaudeAgentManager to use `--json-schema` flag for validated output parsing
**Depends on**: Phase 8
**Plans**: 2 plans

Plans:
- [x] 08.1-01: Agent Output Schema & ClaudeAgentManager
- [x] 08.1-02: MockAgentManager Schema Alignment

**Key deliverables:**
- Zod schema with discriminated union (done/question/unrecoverable_error)
- JSON schema export for Claude CLI --json-schema flag
- ClaudeAgentManager parsing structured output
- MockAgentManager aligned with schema
- TestHarness convenience methods (setAgentDone, setAgentQuestion, setAgentError)

### Phase 9: Extended Scenarios

**Goal**: Extended E2E scenario coverage — conflict hand-back round-trip, multi-agent parallel work, recovery/resume flows
**Depends on**: Phase 8.1
**Plans**: 2 plans

Plans:
- [x] 09-01: Conflict & Parallel E2E Tests
- [x] 09-02: Recovery & Resume E2E Tests

**Key deliverables:**
- 6 conflict and parallel tests (conflict cycle, resolution, parallel merges)
- 8 recovery and Q&A tests (state persistence, crash recovery, multi-question flows)
- Proof that database is source of truth for all state

---

## Milestone Summary

**Decimal Phases:**
- Phase 8.1: Agent Output Schema (inserted after Phase 8 for structured agent output)

**Key Decisions:**
- MockAgentManager uses in-memory Map (no database needed)
- TestHarness pre-seeds idle agents before dispatch
- Discriminated union on status field for agent output
- JSON schema passed to Claude CLI via --json-schema flag
- Database is source of truth for recovery scenarios

**Issues Resolved:**
- Agent output parsing was hacky string matching — now structured schema
- No way to test dispatch/coordination without real Claude CLI — MockAgentManager solves this

**Issues Deferred:**
- None

**Technical Debt Incurred:**
- None

---
*For current project status, see .planning/ROADMAP.md*
