// Package port defines interfaces (ports) for external dependencies. package port import ( "context" "github.com/orchard9/rdev/internal/domain" ) // SagaRepository manages saga persistence. type SagaRepository interface { // Create creates a new saga with its steps. Create(ctx context.Context, saga *domain.Saga) error // Get returns a saga by ID, including all steps. Get(ctx context.Context, id string) (*domain.Saga, error) // Update updates a saga's status and metadata (not steps). Update(ctx context.Context, saga *domain.Saga) error // UpdateStep updates a single step's status and output. UpdateStep(ctx context.Context, step *domain.SagaStep) error // List returns sagas matching the given filters. List(ctx context.Context, filters domain.SagaFilters) ([]*domain.Saga, error) // Delete removes a saga and its steps. Delete(ctx context.Context, id string) error // GetPendingSteps returns steps ready to execute (no unmet dependencies). GetPendingSteps(ctx context.Context, sagaID string) ([]domain.SagaStep, error) } // SagaExecutor executes saga workflows. type SagaExecutor interface { // Execute runs a saga from the beginning. Execute(ctx context.Context, saga *domain.Saga) error // Resume continues execution of a paused or failed saga. Resume(ctx context.Context, sagaID string) error // Compensate runs compensation steps for a failed saga. Compensate(ctx context.Context, sagaID string) error // RetryStep retries a specific failed step. RetryStep(ctx context.Context, sagaID, stepName string) error // SkipStep skips a step and continues execution. SkipStep(ctx context.Context, sagaID, stepName string) error }