Skip to main content

What Are Waves?

Waves are execution groups based on dependencies. Plans in the same wave run in parallel. Waves run sequentially.
Key insight: Independent work parallelizes. Dependent work waits. Wave execution maximizes throughput while respecting dependencies.

How Wave Assignment Works

Dependency Declaration

Plans declare dependencies in frontmatter:
This means: Plan 03-03 runs in Wave 2, AFTER plans 03-01 and 03-02 complete.

Wave Calculation Algorithm

Example: Result: Wave 1 has 2 plans (parallel), Wave 2 has 2 plans (parallel), Wave 3 has 1 plan.

Vertical vs Horizontal Slicing

Vertical slices (better parallelization):
Horizontal layers (forced sequential):
Planning principle: Prefer vertical slices for maximum parallelization. Each slice is an end-to-end feature that can execute independently.

Execution Orchestration

Wave Execution Flow

Orchestrator Context Efficiency

Problem: If orchestrator reads all code and summaries, context fills up. Solution: Executors read files themselves. Orchestrator only passes paths.
Result: Orchestrator context stays constant regardless of phase size.

Parallel Execution

Enabling Parallelization

Controlled by config:
When true: Plans within a wave spawn simultaneously. When false: Plans within a wave run sequentially (one at a time).

Parallel Safety

Parallelization is safe when:
  • Plans modify different files
  • Plans have no shared state
  • Plans are truly independent
Parallelization conflicts when:
  • Plans modify the same file (git merge conflicts)
  • Plans share mutable state (database, global config)
  • Plans have implicit dependencies (not declared in frontmatter)
Planner’s responsibility: Ensure plans in the same wave are truly independent. If file conflicts exist, plans must be sequential or merged into one plan.

Handling Conflicts

If parallel execution causes git conflicts:
  1. Prevention (planning stage): Plan-checker validates wave assignments
  2. Detection (execution stage): Executor detects merge conflicts, reports failure
  3. Resolution: User re-plans with sequential dependency or merged plans

Wave Execution Example

Phase: User Authentication

Plans:
  1. 03-01-PLAN.md: User model + database migration
  2. 03-02-PLAN.md: Password hashing utilities
  3. 03-03-PLAN.md: Login API endpoint (needs User model)
  4. 03-04-PLAN.md: Registration API endpoint (needs User model, password utils)
  5. 03-05-PLAN.md: Login UI (needs Login API)
Dependency graph:
Wave assignments:
  • Wave 1: 03-01, 03-02 (parallel — independent)
  • Wave 2: 03-03, 03-04 (parallel — both depend on Wave 1)
  • Wave 3: 03-05 (depends on 03-03)

Execution Timeline

Sequential execution (for comparison): 5 plans × ~5 min = 25 minutes Wave execution (actual): 3 waves, max 8 min = 22 minutes
Parallelization saves time proportional to plan independence. More vertical slices = more parallelization = faster execution.

Checkpoints in Waves

Plans can pause at checkpoints for human input:

Checkpoint Execution Flow

Checkpoints do NOT block other plans in the wave. Autonomous plans complete while checkpoint plans pause.

Auto-Advance Checkpoint Handling

When workflow.auto_advance is enabled or --auto flag present:

Failure Handling

Mid-Wave Failures

If a plan fails during execution:
User decides how to proceed. Partial progress is tracked in STATE.md.

Dependency Chain Breaks

If Wave 1 fails, dependent Wave 2 plans likely fail:
Best practice: Stop execution on critical failures. Fix the root cause, re-run /gsd:execute-phase. GSD skips completed plans (via SUMMARY.md check).

Resuming Execution

Execution is resumable:
Example: Waves recalculated: 03-03 and 03-04 → Wave 1 (parallel), 03-05 → Wave 2

Verification After Waves

After all waves complete:
Gap closure cycle:
  1. /gsd:plan-phase 3 --gaps → reads VERIFICATION.md → creates gap plans
  2. /gsd:execute-phase 3 --gaps-only → executes only gap plans
  3. Verifier re-runs → checks if gaps resolved

Performance Characteristics

Execution speed:
  • Sequential: N plans × avg_time_per_plan
  • Wave-based: W waves × max_time_in_wave
Context efficiency:
  • Orchestrator: 10-15% (constant, regardless of phase size)
  • Each executor: Fresh 200K (peak quality)
Scalability:
  • Single plan: ~5-10 min execution
  • Phase (5 plans, 2 waves): ~15 min execution
  • Phase (10 plans, 3 waves): ~25 min execution
Parallelization provides sub-linear scaling for well-structured phases.

Optimizing Wave Execution

Planning for Parallelization

  1. Vertical slices (features, not layers)
  2. Minimize cross-plan dependencies (prefer self-contained work)
  3. Declare dependencies explicitly (in frontmatter)
  4. File ownership (each plan owns different files)
  5. 2-3 tasks per plan (atomic, executable in single context)

Example: Bad vs Good Planning

Bad (horizontal layers, forced sequential):
Good (vertical slices, parallel):

Next Steps

Agent System

How agents coordinate wave execution

State Management

How STATE.md tracks wave progress