rdev/internal/port/sdlc_executor.go
jordan 425ef0f806 feat: add SDLC orchestration - library, CLI, and API integration
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>
2026-02-02 09:57:05 -07:00

94 lines
3.5 KiB
Go

package port
import (
"context"
"github.com/orchard9/rdev/internal/sdlc"
)
// SDLCExecutor defines operations for executing SDLC commands in project pods.
// The adapter runs `sdlc` CLI commands via kubectl exec and parses JSON output.
type SDLCExecutor interface {
// GetState returns the global SDLC state for a project pod.
GetState(ctx context.Context, podName string) (*sdlc.State, error)
// GetNext returns the classifier's recommendation for the next action.
// If feature is empty, the classifier picks the most relevant feature.
GetNext(ctx context.Context, podName, feature string) (*sdlc.Classification, error)
// ListFeatures returns all features in the project.
ListFeatures(ctx context.Context, podName string) ([]*sdlc.Feature, error)
// GetFeature returns a single feature by slug.
GetFeature(ctx context.Context, podName, slug string) (*sdlc.Feature, error)
// CreateFeature creates a new feature with the given slug and title.
CreateFeature(ctx context.Context, podName, slug, title string) (*sdlc.Feature, error)
// TransitionFeature moves a feature to the specified phase.
TransitionFeature(ctx context.Context, podName, slug string, phase sdlc.FeaturePhase) error
// BlockFeature adds a blocker reason to a feature.
BlockFeature(ctx context.Context, podName, slug, reason string) error
// UnblockFeature removes all blockers from a feature.
UnblockFeature(ctx context.Context, podName, slug string) error
// DeleteFeature removes a feature entirely.
DeleteFeature(ctx context.Context, podName, slug string) error
// GetArtifactStatus returns artifact statuses for a feature.
GetArtifactStatus(ctx context.Context, podName, slug string) (map[sdlc.ArtifactType]*sdlc.Artifact, error)
// ApproveArtifact approves a feature artifact.
ApproveArtifact(ctx context.Context, podName, slug string, artType sdlc.ArtifactType) error
// RejectArtifact rejects a feature artifact.
RejectArtifact(ctx context.Context, podName, slug string, artType sdlc.ArtifactType) error
// ListTasks returns all tasks for a feature.
ListTasks(ctx context.Context, podName, slug string) ([]sdlc.Task, error)
// AddTask adds a new task to a feature.
AddTask(ctx context.Context, podName, slug, title string) (*sdlc.Task, error)
// StartTask marks a task as in-progress.
StartTask(ctx context.Context, podName, slug, taskID string) error
// CompleteTask marks a task as complete.
CompleteTask(ctx context.Context, podName, slug, taskID string) error
// BlockTask marks a task as blocked.
BlockTask(ctx context.Context, podName, slug, taskID string) error
// QueryBlocked returns all blocked features.
QueryBlocked(ctx context.Context, podName string) ([]BlockedInfo, error)
// QueryReady returns features ready for work.
QueryReady(ctx context.Context, podName string) ([]ReadyInfo, error)
// QueryNeedsApproval returns features awaiting approval.
QueryNeedsApproval(ctx context.Context, podName string) ([]ApprovalInfo, error)
}
// BlockedInfo describes a blocked feature (matches sdlc query --json output).
type BlockedInfo struct {
Slug string `json:"slug"`
Phase string `json:"phase"`
Blockers []string `json:"blockers"`
}
// ReadyInfo describes a feature ready for work (matches sdlc query --json output).
type ReadyInfo struct {
Slug string `json:"slug"`
Phase string `json:"phase"`
Action string `json:"action"`
}
// ApprovalInfo describes a feature awaiting approval (matches sdlc query --json output).
type ApprovalInfo struct {
Slug string `json:"slug"`
Phase string `json:"phase"`
Message string `json:"message"`
}