---
phase: 14-parallel-phase-execution
plan: 04
type: execute
wave: 3
depends_on: ["14-03"]
files_modified:
  - src/dispatch/phase-manager.ts
  - src/dispatch/index.ts
autonomous: true
---

<objective>
Implement DefaultPhaseDispatchManager adapter with in-memory queue and dependency checking.

Purpose: Enable actual phase dispatch with dependency resolution.
Output: Working adapter implementation.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/14-parallel-phase-execution/14-03-SUMMARY.md

# Reference implementations:
@src/dispatch/manager.ts
@src/dispatch/types.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Implement DefaultPhaseDispatchManager</name>
  <files>src/dispatch/phase-manager.ts</files>
  <action>
Create DefaultPhaseDispatchManager class implementing PhaseDispatchManager:

Constructor dependencies:
- phaseRepository: PhaseRepository
- eventBus: EventBus

Internal state:
- phaseQueue: Map<string, QueuedPhase>
- blockedPhases: Map<string, {phaseId: string, reason: string}>

Implement methods:
- queuePhase: fetch phase, get dependencies from phaseRepository.getDependencies(), add to queue, emit PhaseQueuedEvent
- getNextDispatchablePhase: filter queue for phases with all deps complete (phase.status === 'completed'), sort by queuedAt
- dispatchNextPhase: get next, update phase status to 'in_progress', emit PhaseStartedEvent, return result
- completePhase: update phase status to 'completed', remove from queue, emit PhaseCompletedEvent
- blockPhase: update phase status, add to blocked map, remove from queue, emit PhaseBlockedEvent
- getPhaseQueueState: return current state of queued, ready, blocked

Private helper:
- areAllPhaseDependenciesComplete(dependsOn: string[]): check each phase status via phaseRepository.findById

Follow exact patterns from DefaultDispatchManager for consistency.
  </action>
  <verify>npx tsc --noEmit passes</verify>
  <done>DefaultPhaseDispatchManager implements all interface methods</done>
</task>

<task type="auto">
  <name>Task 2: Export DefaultPhaseDispatchManager</name>
  <files>src/dispatch/index.ts</files>
  <action>
Add export for DefaultPhaseDispatchManager class.
  </action>
  <verify>npx tsc --noEmit passes</verify>
  <done>DefaultPhaseDispatchManager exported from dispatch module</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npm run build` succeeds without errors
- [ ] `npm test` passes all tests
- [ ] DefaultPhaseDispatchManager importable from src/dispatch
</verification>

<success_criteria>

- All tasks completed
- All verification checks pass
- Adapter follows hexagonal architecture pattern
- Event emission matches phase event types from 14-02
</success_criteria>

<output>
After completion, create `.planning/phases/14-parallel-phase-execution/14-04-SUMMARY.md`
</output>
