Wave Architecture
Overview
Wave is a multi-agent orchestrator that wraps Claude Code (and other LLM CLIs) to execute complex workflows through pipeline DAGs. It enforces safety through personas, contracts, and workspace isolation.
Core Components
Manifest System
The manifest (wave.yaml) is the single source of truth:
- Adapters: Define how to invoke LLM CLIs
- Personas: Define agent roles, permissions, and behaviors
- Runtime: Global settings like workspace root and limits
- Pipelines: DAG definitions for workflows
Pipeline Execution Engine
DAG Resolution
Pipelines are resolved to execution order:
- Parse YAML structure
- Validate step dependencies
- Detect cycles (error if found)
- Topological sort for execution order
Step Execution Loop
For each step:
- Create ephemeral workspace
- Inject artifacts from dependencies
- Bind persona configuration
- Invoke adapter subprocess
- Monitor for timeout/relay trigger
- Validate handover contract
- Persist state
- Emit progress event
Workspace Isolation
Each step runs in isolation:
/tmp/wave/<pipeline-id>/<step-id>/
├── src/ # Mounted readonly from repo
├── artifacts/ # Step outputs
├── .claude/ # Claude Code settings
└── CLAUDE.md # Persona system promptPersona System
Personas enforce boundaries:
Context Relay
Long-running tasks trigger relay:
- Monitor token usage
- At threshold (default 80%), trigger compaction
- Summarizer persona creates checkpoint
- Fresh instance resumes from checkpoint
Handover Contracts
Contracts validate between steps:
- JSON Schema: Structure validation
- TypeScript Interface: Compile checking
- Test Suite: Behavioral validation
Failed contracts trigger retries or pipeline halt.
Security Model
Permission Enforcement
- Deny patterns take precedence
- Evaluated before tool invocation
- Persona-scoped restrictions
Credential Handling
- Never written to disk
- Passed via environment variables
- Scrubbed from audit logs
Audit Trail
- All tool calls logged when enabled
- File operations tracked
- Structured JSON output for parsing
Performance Characteristics
Concurrency
- Matrix strategy for parallel workers
- Configurable concurrency limits
- Goroutine-based execution
Resource Usage
- Workspace cleanup is manual
- State persisted in SQLite
- Single static binary, no runtime deps
Scalability Limits
- Up to 20 steps per pipeline
- Up to 10 concurrent workers
- Repositories up to 1M LOC
Failure Handling
Step Failures
- Transition to
retryingstate - Exponential backoff
- Max retries configurable per step
- Pipeline halts on exceeded retries
Process Crashes
- Process group isolation
- Timeout kills entire tree
- Workspace preserved for debugging
System Failures
- State persisted before failure
- Resumable from last completed step
- Detailed error reporting
Integration Points
Adapter Interface
Pluggable adapter system:
- Claude Code (implemented)
- OpenCode (future)
- Custom adapters via configuration
Hooks System
Pre/post tool execution:
- Security checks
- Quality gates
- Custom validation
Event System
Structured events for:
- CI/CD integration
- Monitoring systems
- Custom tooling
Design Principles
- Single Source of Truth: Manifest drives all behavior
- Persona Boundaries: Clear security and role separation
- Fresh Memory: No shared state between steps
- Contract Validation: Quality gates at boundaries
- Observable Execution: All state changes emit events
- Graceful Failure: Retry and recovery mechanisms