rdev/internal/port/sdlc_executor.go
jordan f22b220c6d feat: add SDLC branch management, merge, archive, and orchestrator APIs
Add branch lifecycle commands (branch, merge, archive) to the SDLC CLI.
Introduce orchestrator handler and service for multi-step SDLC workflows.
Expand skeleton template with 15 Claude commands covering the full feature
lifecycle. Extend classifier rules, error types, and executor port for
branch operations. Split rules.go and classifier_test.go to stay within
500-line limit.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:30:03 -07:00

109 lines
4.2 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)
// CreateBranch creates a feature branch and its manifest.
CreateBranch(ctx context.Context, podName, slug string) (*sdlc.BranchManifest, error)
// GetBranchStatus returns the branch manifest and merge checklist.
GetBranchStatus(ctx context.Context, podName, slug string) (*sdlc.BranchManifest, error)
// SyncBranch syncs a feature branch with its base branch.
SyncBranch(ctx context.Context, podName, slug string) error
// MergeFeature merges a feature branch after all gates pass.
MergeFeature(ctx context.Context, podName, slug, strategy string) error
// ArchiveFeature archives a released feature.
ArchiveFeature(ctx context.Context, podName, slug string) 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"`
}