---
phase: 14-parallel-phase-execution
plan: 05
type: execute
wave: 3
depends_on: ["14-01"]
files_modified:
  - src/trpc/context.ts
  - src/trpc/router.ts
autonomous: true
---

<objective>
Add tRPC procedures for phase dependencies and dispatch.

Purpose: Expose phase dependency and dispatch operations via API.
Output: tRPC procedures for creating dependencies and managing phase queue.
</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-01-SUMMARY.md

# Reference implementations:
@src/trpc/router.ts
@src/trpc/context.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add PhaseDispatchManager to tRPC context</name>
  <files>src/trpc/context.ts</files>
  <action>
Add optional phaseDispatchManager to AppContext:
- phaseDispatchManager?: PhaseDispatchManager

Import PhaseDispatchManager from dispatch module.
Follow same pattern as agentManager (optional, undefined by default).
  </action>
  <verify>npx tsc --noEmit passes</verify>
  <done>PhaseDispatchManager available in tRPC context</done>
</task>

<task type="auto">
  <name>Task 2: Add phase dependency and dispatch procedures</name>
  <files>src/trpc/router.ts</files>
  <action>
Add procedures under existing phase group:

createPhaseDependency:
- input: { phaseId: string, dependsOnPhaseId: string }
- validates both phases exist
- calls phaseRepository.createDependency()
- returns { success: true }

getPhaseDependencies:
- input: { phaseId: string }
- returns { dependencies: string[] } from phaseRepository.getDependencies()

Add new phase dispatch procedures:

queuePhase:
- input: { phaseId: string }
- requires phaseDispatchManager
- calls phaseDispatchManager.queuePhase()
- returns { success: true }

dispatchNextPhase:
- no input
- requires phaseDispatchManager
- calls phaseDispatchManager.dispatchNextPhase()
- returns PhaseDispatchResult

getPhaseQueueState:
- no input
- requires phaseDispatchManager
- returns queue state

Follow existing router patterns for error handling and input validation.
  </action>
  <verify>npx tsc --noEmit passes</verify>
  <done>Phase dependency and dispatch procedures available via tRPC</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npm run build` succeeds without errors
- [ ] `npm test` passes all tests
- [ ] New procedures type-check correctly
</verification>

<success_criteria>

- All tasks completed
- All verification checks pass
- Procedures follow existing naming conventions
- Error handling consistent with other procedures
</success_criteria>

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