Implementation Orchestration Specification
Version: 1.1.0 Status: DRAFT Created: 2025-12-29 Last Updated: 2025-12-29 Related: RCSD-PIPELINE-SPEC.md, MULTI-SESSION-SPEC.md, CONSENSUS-FRAMEWORK-SPEC.md, RELEASE-MANAGEMENT-SPEC.md, ISSUE-LIFECYCLE-SPEC.mdRFC 2119 Conformance
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14 RFC 2119 RFC 8174 when, and only when, they appear in all capitals, as shown here.Preamble
Purpose
This specification defines the Implementation Orchestration Protocol, a structured multi-agent workflow for executing decomposed tasks through iterative validation cycles. This specification bridges the gap between task planning (RCSD Pipeline) and actual code implementation by defining how specialized agents coordinate to implement, validate, test, and document code changes.Authority
This specification is AUTHORITATIVE for:- Implementation agent architecture and role definitions
- Agent-CLEO integration patterns and task handoff protocols
- Cyclical validation workflow (implement → validate → test → iterate)
- Task verification schema extensions (
verificationfield) - Epic lifecycle state management (
epicLifecyclefield) - Agent frontmatter and system prompt templates
- HITL gates during implementation
- Exit codes 40-49 (Implementation Orchestration)
- RCSD-PIPELINE-SPEC.md for upstream task decomposition
- MULTI-SESSION-SPEC.md for concurrent session management
- LLM-AGENT-FIRST-SPEC.md for JSON output standards
- CONSENSUS-FRAMEWORK-SPEC.md for multi-agent consensus patterns
- LLM-TASK-ID-SYSTEM-DESIGN-SPEC.md for task ID format
- RELEASE-MANAGEMENT-SPEC.md for release integration
- ISSUE-LIFECYCLE-SPEC.md for issue/bug handling
Problem Statement
The RCSD Pipeline produces decomposed, atomic tasks ready for implementation. However, no structured protocol exists for:- Agent coordination during implementation - Who implements, who validates, who tests?
- Iterative refinement - How do agents cycle until code passes all checks?
- Quality gates - When is code “done” vs “needs revision”?
- Task handoff - How does work transfer between specialized agents?
- CLEO integration - How do agents read/update task state during implementation?
Solution
A 6-agent orchestration system operating in cyclical validation rounds:Part 1: Architecture Overview
1.1 Agent Count and Roles
| Agent | Role | Claude Code subagent_type | Spawned By |
|---|---|---|---|
| Planner Agent | Task selection, decomposition, orchestration | Main session (HITL) | User/Orchestrator |
| Coder Agent | Code implementation | python-expert or backend-architect | Planner |
| Testing Agent | Test execution, validation | quality-engineer | Planner |
| QA Agent | User experience, acceptance validation | frontend-architect | Testing (on pass) |
| Cleanup Agent | Refactoring, documentation | refactoring-expert | QA (on pass) |
| Security Agent | Vulnerability scanning, red team | security-engineer | Cleanup (on pass) |
| Docs Agent | Final documentation, completion | technical-writer | Security (on pass) |
1.2 Round-Based Execution
Implementation occurs in rounds. A round is one complete cycle through the agent pipeline for a single task:implementation.maxRounds (default: 5)
1.3 Session Integration
Each implementation workflow SHOULD operate within a CLEO session:Part 2: Task Verification Schema
2.1 Schema Extension
The following fields MUST be added to task objects intodo.schema.json:
2.2 Verification State Machine
2.3 CLI Commands for Verification
Part 3: Agent Definitions
3.1 Planner Agent
Role: Orchestrator with human-in-the-loop. Selects tasks, decomposes work, spawns implementation agents. File:.claude/agents/impl-planner.md
Task Selection Criteria
status= “pending” OR “active”verification.passed= false OR null- All
dependstasks havestatus= “done” - Prefer tasks in current phase
- Sort by: priority (critical > high > medium > low), then createdAt
Spawning Coder Agent
After selecting a task, spawn the Coder Agent with context:Handoff Protocol
Before spawning the Coder Agent, you MUST:- Update task status:
ct update TXXX --status active - Set focus:
ct focus set TXXX - Add session note:
ct focus note "Starting implementation round N" - Initialize verification if null:
ct verify TXXX --init
HITL Gates
Pause and ask the user when:- Task has no acceptance criteria
- Task depends on unfinished tasks
- Maximum rounds (5) exceeded
- Epic has no decomposed subtasks
- Conflicting requirements detected
During Implementation
Git Commit Protocol
On Completion
Implementation Guidelines
- Read First: Always read existing code before writing new code
- Minimal Changes: Only modify what’s necessary for the task
- No Over-Engineering: Implement exactly what’s specified, no extras
- Error Handling: Add appropriate error handling but don’t gold-plate
- Type Safety: Use proper types, avoid
anyin TypeScript - Follow Patterns: Match existing code style and patterns
Handoff to Testing Agent
After settinggates.implemented = true, spawn the Testing Agent:
Failure Scenarios
If you cannot complete implementation:- Set
ct update TXXX --status blocked --blocked-by "Reason" - Add detailed notes explaining the blocker
- Do NOT spawn Testing Agent
- Return control to Planner Agent
Test Execution Protocol
Recording Results
On Test PASS:E2E Testing with Claude-Chrome
For UI/UX testing, use the browser automation tools:Handoff Protocol
Tests PASS → Spawn QA Agent:Failure Analysis Guidelines
When tests fail:- Identify the exact failure location (file:line)
- Determine if it’s a test bug or implementation bug
- Provide actionable fix suggestions to Coder Agent
- Include relevant stack traces in notes
Acceptance Criteria Validation
For each item intask.acceptance:
- Determine how to validate (manual, automated, visual)
- Execute validation
- Record result
Recording Results
On QA PASS:Validation Checklist
Functionality
- All acceptance criteria explicitly met
- Happy path works as expected
- Error states handled gracefully
- Edge cases don’t break functionality
User Experience
- UI renders correctly
- Interactions feel responsive
- Loading states displayed
- Error messages are helpful
Accessibility (Basic)
- Keyboard navigation works
- Focus states visible
- Screen reader labels present
- Color contrast adequate
Handoff Protocol
QA PASS → Spawn Cleanup Agent:Cleanup Rules
DO:- Fix code style violations
- Remove dead code introduced in this task
- Add missing type annotations
- Add JSDoc to public APIs
- Simplify overly complex logic
- Refactor unrelated code
- Add features not in spec
- Change behavior (tests must still pass)
- Remove code you didn’t understand
- Add extensive comments to obvious code
Git Commit Protocol
Recording Results
Handoff Protocol
After cleanup → Spawn Security Agent:Security Checklist
Injection
- SQL queries use parameterized statements
- User input is validated and sanitized
- Command execution avoids shell interpolation
- XSS vectors are escaped
Authentication
- Passwords are hashed (bcrypt, argon2)
- Tokens have appropriate expiration
- Session management is secure
- Rate limiting on auth endpoints
Authorization
- Access controls enforced server-side
- No IDOR vulnerabilities
- Proper role-based access control
Data Protection
- Sensitive data not logged
- Secrets not hardcoded
- HTTPS enforced
- Proper CORS configuration
Dependencies
Recording Results
On Security PASS:Severity Classification
| Severity | Action | Example |
|---|---|---|
| Critical | BLOCK - Return to Coder | SQL injection, auth bypass, RCE |
| High | BLOCK - Return to Coder | XSS, CSRF, data exposure |
| Medium | WARN - Proceed with note | Missing rate limit, weak validation |
| Low | NOTE - Proceed | Informational headers, minor issues |
Handoff Protocol
Security PASS → Spawn Docs Agent:Documentation Checklist
-
Does this task add user-facing functionality?
- Yes → Update README or user docs
- No → Skip user docs
-
Does this task change API?
- Yes → Update API documentation
- No → Skip API docs
-
Is this a notable change?
- Yes → Add CHANGELOG entry
- No → Skip CHANGELOG
CHANGELOG Entry Format
Task Completion
Session Note Aggregation
If task is part of an Epic, aggregate session notes:Final Output
Produce a completion summary:4.2 Handoff via Task Tool
4.3 Return-to-Coder Protocol
When any agent fails validation:- Log failure to
verification.failureLog - Increment
verification.round - Reset downstream gates to
null - Spawn Coder Agent with failure context
Part 5: CLEO CLI Extensions
5.1 New Commands
5.2 Exit Codes (40-49)
| Code | Constant | Meaning |
|---|---|---|
| 40 | E_VERIFICATION_INIT_FAILED | Could not initialize verification |
| 41 | E_GATE_UPDATE_FAILED | Could not update verification gate |
| 42 | E_INVALID_GATE | Unknown gate name |
| 43 | E_INVALID_AGENT | Unknown agent name |
| 44 | E_MAX_ROUNDS_EXCEEDED | Task exceeded maximum rounds |
| 45 | E_GATE_DEPENDENCY | Tried to set gate before prerequisite |
| 46 | E_VERIFICATION_LOCKED | Verification is locked (task completed) |
| 47 | E_ROUND_MISMATCH | Round number doesn’t match current |
Part 6: Configuration
6.1 Config Schema Addition
6.2 Default Configuration
Part 7: Observability
7.1 Metrics
Track per-task implementation metrics:7.2 Audit Log Entries
New log actions for implementation orchestration:Part 8: Error Recovery
8.1 Recovery Scenarios
| Scenario | Recovery Action |
|---|---|
| Agent crash mid-implementation | Resume from last gate; check git status |
| Max rounds exceeded | HITL escalation; human reviews and decides |
| Session lost | Recover session from sessions.json; resume |
| Git conflict | HITL escalation; manual resolution required |
| Test environment failure | Retry tests; if persistent, HITL escalation |
8.2 Recovery Commands
Part 9: Integration with RCSD Pipeline
9.1 Pipeline Flow
9.2 Task State Transitions
Part 10: Conformance
10.1 Conformance Requirements
A conforming implementation MUST:- Implement all 7 agents as specified in Part 3
- Support the verification schema extension (Part 2)
- Implement all CLEO CLI extensions (Part 5)
- Follow the handoff protocol (Part 4)
- Support configuration options (Part 6)
- Use exit codes 40-49 for implementation errors
- Track observability metrics (Part 7)
- Implement error recovery commands (Part 8)
- Integrate with RCSD pipeline (Part 9)
- Use alternative subagent_type mappings with documented rationale
- Add additional verification gates beyond the required set
- Customize agent system prompts for project-specific needs
Part 11: Epic Lifecycle Integration
11.1 Epic Lifecycle States
Epics have their own lifecycle independent of task statuses. TheepicLifecycle field tracks the Epic’s journey:
11.2 State Definitions
| State | Description | Trigger |
|---|---|---|
backlog | Epic identified but not planned | Initial state |
planning | RCSD pipeline in progress | ct research started |
active | Implementation in progress | First task goes active |
review | All tasks complete, awaiting release | All tasks done |
released | Shipped in a release | ct release ship |
archived | End of lifecycle | Manual or post-deprecation |
11.3 Epic Lifecycle State Machine
11.4 Automatic State Transitions
The following transitions happen automatically:| Transition | Trigger | Condition |
|---|---|---|
| backlog → planning | ct research TXXX | Task is type=epic |
| planning → active | First child task status=active | At least one task active |
| active → review | Last task completed | All children status=done |
| review → released | ct release ship vX.Y.Z | Epic in release.epics[] |
11.5 Manual State Commands
11.6 Implementation Orchestration Integration
The Planner Agent MUST checkepicLifecycle when selecting tasks:
11.7 Verification and Epic Lifecycle
When all tasks in an Epic haveverification.passed = true:
- Epic automatically transitions to
epicLifecycle = "review" - Epic can be added to a release
- On release ship, Epic transitions to
epicLifecycle = "released"
Part 12: Related Specifications
| Document | Relationship |
|---|---|
| RCSD-PIPELINE-SPEC.md | Upstream: Produces decomposed tasks for implementation |
| MULTI-SESSION-SPEC.md | Related: Session management for concurrent implementation |
| CONSENSUS-FRAMEWORK-SPEC.md | Pattern Source: Multi-agent architecture patterns |
| LLM-AGENT-FIRST-SPEC.md | AUTHORITATIVE: JSON output and error handling |
| TASK-DECOMPOSITION-SPEC.md | Upstream: Task atomicity criteria |
| RELEASE-MANAGEMENT-SPEC.md | Downstream: Releases aggregate completed Epics |
| ISSUE-LIFECYCLE-SPEC.md | Related: Bugs affecting Epic functionality |
Appendix A: Quick Reference
Agent Workflow
CLEO Commands for Agents
Verification Gates
| Gate | Agent | Required |
|---|---|---|
implemented | Coder | Yes |
testsPassed | Testing | Yes |
qaPassed | QA | Yes |
cleanupDone | Cleanup | No |
securityPassed | Security | Yes |
documented | Docs | Yes |
Appendix B: Version History
Version 1.1.0 (2025-12-29)
- Added Part 11: Epic Lifecycle Integration
- Added
epicLifecycleschema field - Defined epic state machine (backlog → planning → active → review → released → archived)
- Added automatic state transitions
- Added
ct epic lifecycle,ct epic verify,ct epic readycommands - Updated Related Specifications with Release and Issue specs
Version 1.0.0 (2025-12-29)
- Initial specification
- 7-agent implementation orchestration architecture
- Task verification schema with gates
- Cyclical validation workflow
- CLEO CLI extensions for verification
- Exit codes 40-49
- Integration with RCSD Pipeline and Multi-Session specs
End of Specification
