# SDLC Orchestration

**Last Updated:** 2026-02
**Confidence:** High (fully implemented - library, CLI, API, orchestrator, skeleton commands)

## Summary

Deterministic feature lifecycle management. Classifier engine evaluates priority-ordered rules to determine the next required action. State lives in `.sdlc/` directory (git-tracked). Used by Claude agents in pods (CLI) and by rdev API (Go library + kubectl exec).

**Key Facts:**
- 10 phases: draft -> specified -> planned -> ready -> implementation -> review -> audit -> qa -> merge -> released
- 25+ classifier rules, first match wins, returns Classification with action + guidance
- 7 artifact types: spec, design, tasks, qa_plan, review, audit, qa_results
- rdev drives transitions on behalf of users (approve, reject, unblock, transition)
- Multi-project: scoped by projectID (pod name), each pod has its own `.sdlc/`
- Orchestrator: execute/resolve/commit endpoints dispatch agent work and git operations

**File Pointers:**
- Library: `internal/sdlc/` (types, state, feature, classifier, rules, config, branch)
- CLI: `cmd/sdlc/` (cobra commands, --json output for API consumption)
- Port: `internal/port/sdlc_executor.go`
- Adapter: `internal/adapter/kubernetes/sdlc_executor.go`
- Service: `internal/service/sdlc_service.go`, `internal/service/sdlc_orchestrator.go`
- Handler: `internal/handlers/sdlc.go`, `internal/handlers/sdlc_*.go`
- Skeleton commands: `internal/adapter/templates/templates/skeleton/.claude/commands/` (15 files)
- Spec: `docs/specs/sdlc-orchestration-system.md`
- Guide: `.claude/guides/services/sdlc.md`

## Library Types

```go
// internal/sdlc/classifier.go
type Classification struct {
    Feature      string       `json:"feature"`
    CurrentPhase FeaturePhase `json:"current_phase"`
    RuleMatched  string       `json:"rule_matched"`
    Action       ActionType   `json:"action"`
    Message      string       `json:"message"`
    NextCommand  string       `json:"next_command,omitempty"`
    OutputPath   string       `json:"output_path,omitempty"`
    TransitionTo FeaturePhase `json:"transition_to,omitempty"`
    TaskID       string       `json:"task_id,omitempty"`
}

// internal/sdlc/branch.go
type BranchManifest struct {
    Name          string     `yaml:"name" json:"name"`
    Feature       string     `yaml:"feature" json:"feature"`
    BaseBranch    string     `yaml:"base_branch" json:"base_branch"`
    CreatedAt     time.Time  `yaml:"created_at" json:"created_at"`
    LastSyncAt    *time.Time `yaml:"last_sync_at,omitempty" json:"last_sync_at,omitempty"`
    MergedAt      *time.Time `yaml:"merged_at,omitempty" json:"merged_at,omitempty"`
    MergeStrategy string     `yaml:"merge_strategy,omitempty" json:"merge_strategy,omitempty"`
}
```

## CLI Commands

```
sdlc init                              # Create .sdlc/ structure
sdlc state [--json]                    # Full state dump
sdlc feature create <slug> <title>     # New feature
sdlc feature transition <slug> <phase> # Phase transition
sdlc feature block/unblock <slug>      # Blocker management
sdlc artifact create/approve/reject    # Artifact lifecycle
sdlc task add/start/complete/block     # Task lifecycle
sdlc next [--for <feature>] [--json] [--execute]  # Classifier output (--execute auto-runs transitions)
sdlc query blocked/ready/needs-approval # Queries
sdlc branch create/status/sync <slug>  # Branch management
sdlc merge <slug> [--strategy squash]  # Merge feature branch
sdlc archive <slug>                    # Archive released feature
```

## rdev API Endpoints

### SDLC State & Features (21 routes)
```
GET    /projects/{id}/sdlc/state
GET    /projects/{id}/sdlc/next?feature=slug
GET    /projects/{id}/sdlc/features
POST   /projects/{id}/sdlc/features
GET    /projects/{id}/sdlc/features/{slug}
POST   /projects/{id}/sdlc/features/{slug}/transition
POST   /projects/{id}/sdlc/features/{slug}/block
POST   /projects/{id}/sdlc/features/{slug}/unblock
DELETE /projects/{id}/sdlc/features/{slug}
GET    /projects/{id}/sdlc/features/{slug}/artifacts
POST   /projects/{id}/sdlc/features/{slug}/artifacts/{type}/approve
POST   /projects/{id}/sdlc/features/{slug}/artifacts/{type}/reject
GET    /projects/{id}/sdlc/features/{slug}/tasks
POST   /projects/{id}/sdlc/features/{slug}/tasks
POST   /projects/{id}/sdlc/features/{slug}/tasks/{taskId}/start
POST   /projects/{id}/sdlc/features/{slug}/tasks/{taskId}/complete
POST   /projects/{id}/sdlc/features/{slug}/tasks/{taskId}/block
POST   /projects/{id}/sdlc/features/{slug}/branches
GET    /projects/{id}/sdlc/features/{slug}/branches
POST   /projects/{id}/sdlc/features/{slug}/branches/sync
POST   /projects/{id}/sdlc/features/{slug}/merge
POST   /projects/{id}/sdlc/features/{slug}/archive
GET    /projects/{id}/sdlc/query/blocked
GET    /projects/{id}/sdlc/query/ready
GET    /projects/{id}/sdlc/query/needs-approval
```

### Orchestration (3 routes)
```
POST   /projects/{id}/sdlc/execute      # Run next classifier action (dispatches agents)
POST   /projects/{id}/sdlc/resolve      # Unblock feature and re-classify
POST   /projects/{id}/sdlc/commit       # Commit changes in pod
```

## Skeleton Template Commands (15)

Commands installed in every new project via skeleton template:

**Primary:** `spec-feature`, `design-feature`, `breakdown-feature`, `create-qa-plan`, `implement-task`, `review-feature`, `audit-feature`, `run-qa`, `next`, `deliver`

**Remediation:** `fix-review-issues`, `remediate-audit`, `fix-qa-failures`, `merge-feature`, `archive-feature`

## Related Topics

- [Kubernetes Adapter](./kubernetes.md) - Pod execution pattern (PodGitOperations)
- [Work Queue](./work-queue.md) - Task execution for agents
- [Worker Pool](./worker-pool.md) - Agent pool management
