Implements deterministic feature lifecycle management for agent-driven
development. Agents use the CLI in pods; operators control via REST API.
Library (internal/sdlc/):
- Feature lifecycle with 10 phases (draft → released)
- Classifier engine with priority-ordered rules
- Artifact tracking with approval workflow
- Task management within features
- YAML-based state persistence
CLI (cmd/sdlc/):
- init, state, next, feature, artifact, task, query commands
- --json flag for machine-readable output
- Runs inside project pods
API (21 endpoints under /projects/{id}/sdlc/):
- State: GET /state, GET /next
- Features: CRUD + transition/block/unblock
- Artifacts: approve/reject per type
- Tasks: add/start/complete/block
- Queries: blocked/ready/needs-approval
Architecture:
- Port: SDLCExecutor interface (internal/port/)
- Adapter: kubectl exec into pods (internal/adapter/kubernetes/)
- Service: pod resolution + logging (internal/service/)
- Handlers: 5 files under 500-line limit (internal/handlers/)
Also includes template upgrades (chassis framework, UI components,
OpenAPI helpers, backend/frontend guides) and component improvements.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
1.7 KiB
Go
89 lines
1.7 KiB
Go
package sdlc
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestInit(t *testing.T) {
|
|
root := t.TempDir()
|
|
|
|
if err := Init(root, "test-project"); err != nil {
|
|
t.Fatalf("Init: %v", err)
|
|
}
|
|
|
|
// Verify .sdlc directory exists
|
|
sdlcRoot := SDLCRoot(root)
|
|
info, err := os.Stat(sdlcRoot)
|
|
if err != nil {
|
|
t.Fatalf("stat .sdlc: %v", err)
|
|
}
|
|
if !info.IsDir() {
|
|
t.Fatal(".sdlc is not a directory")
|
|
}
|
|
|
|
// Verify all subdirectories exist
|
|
for _, dir := range SubDirs() {
|
|
dirPath := filepath.Join(sdlcRoot, dir)
|
|
info, err := os.Stat(dirPath)
|
|
if err != nil {
|
|
t.Errorf("stat %s: %v", dir, err)
|
|
continue
|
|
}
|
|
if !info.IsDir() {
|
|
t.Errorf("%s is not a directory", dir)
|
|
}
|
|
}
|
|
|
|
// Verify state.yaml
|
|
state, err := LoadState(root)
|
|
if err != nil {
|
|
t.Fatalf("LoadState: %v", err)
|
|
}
|
|
if state.Version != 1 {
|
|
t.Errorf("state.Version = %d, want 1", state.Version)
|
|
}
|
|
if state.Project.Name != "test-project" {
|
|
t.Errorf("state.Project.Name = %q, want test-project", state.Project.Name)
|
|
}
|
|
|
|
// Verify config.yaml
|
|
config, err := LoadConfig(root)
|
|
if err != nil {
|
|
t.Fatalf("LoadConfig: %v", err)
|
|
}
|
|
if config.Project.Name != "test-project" {
|
|
t.Errorf("config.Project.Name = %q, want test-project", config.Project.Name)
|
|
}
|
|
}
|
|
|
|
func TestInitAlreadyInitialized(t *testing.T) {
|
|
root := t.TempDir()
|
|
|
|
if err := Init(root, "test"); err != nil {
|
|
t.Fatalf("Init: %v", err)
|
|
}
|
|
|
|
err := Init(root, "test")
|
|
if err == nil {
|
|
t.Fatal("Init should fail when already initialized")
|
|
}
|
|
}
|
|
|
|
func TestIsInitialized(t *testing.T) {
|
|
root := t.TempDir()
|
|
|
|
if IsInitialized(root) {
|
|
t.Error("IsInitialized = true before init")
|
|
}
|
|
|
|
if err := Init(root, "test"); err != nil {
|
|
t.Fatalf("Init: %v", err)
|
|
}
|
|
|
|
if !IsInitialized(root) {
|
|
t.Error("IsInitialized = false after init")
|
|
}
|
|
}
|