Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("plan not found")
Functions ¶
Types ¶
type Plan ¶
type Plan struct {
ID string `json:"id"`
Name string `json:"name"`
Goal string `json:"goal"`
Status PlanStatus `json:"status"`
SessionID string `json:"session_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Plan maps to the plans table.
type PlanStatus ¶
type PlanStatus string
PlanStatus represents the current state of a plan.
const ( PlanStatusActive PlanStatus = "active" PlanStatusCompleted PlanStatus = "completed" PlanStatusArchived PlanStatus = "archived" )
type PlanStep ¶
type PlanStep struct {
ID string `json:"id"`
PlanID string `json:"plan_id"`
Ordinal int `json:"ordinal"`
Description string `json:"description"`
Status StepStatus `json:"status"`
ExecutionResult string `json:"execution_result"`
ExecutedAt time.Time `json:"executed_at"` // Zero time if not executed
}
PlanStep maps to the plan_steps table.
type StepStatus ¶
type StepStatus string
StepStatus represents the current state of a plan step.
const ( StepStatusPending StepStatus = "pending" StepStatusRunning StepStatus = "running" StepStatusCompleted StepStatus = "completed" StepStatusFailed StepStatus = "failed" StepStatusSkipped StepStatus = "skipped" )
type Store ¶
type Store interface {
// Plan operations
CreatePlan(ctx context.Context, plan *Plan) error
GetPlanByID(ctx context.Context, id string) (*Plan, error)
GetPlanByName(ctx context.Context, name string) (*Plan, error)
// GetActivePlan returns the most recently updated active plan, or ErrNotFound.
GetActivePlan(ctx context.Context) (*Plan, error)
ListPlans(ctx context.Context) ([]*Plan, error)
DeletePlan(ctx context.Context, id string) error
UpdatePlanStatus(ctx context.Context, planID string, status PlanStatus) error
// Step operations
CreatePlanSteps(ctx context.Context, steps ...*PlanStep) error
ListPlanSteps(ctx context.Context, planID string) ([]*PlanStep, error)
UpdatePlanStepStatus(ctx context.Context, stepID string, status StepStatus, result string) error
DeletePendingPlanSteps(ctx context.Context, planID string) error
// ClaimNextPendingStep atomically marks the next pending step as running
// and returns it. Returns ErrNotFound when no pending step exists.
ClaimNextPendingStep(ctx context.Context, planID string) (*PlanStep, error)
// Bulk operations for efficiency
// DeleteFinishedPlans removes all completed/archived plans; returns count.
DeleteFinishedPlans(ctx context.Context) (int, error)
// ArchiveActivePlans sets all active plans to archived status.
ArchiveActivePlans(ctx context.Context) error
}
Store defines the data access interface for plans and steps.
Click to show internal directories.
Click to hide internal directories.