taskstate

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCorruptState      = errors.New("task state corrupt")
	ErrDependencyCycle   = errors.New("task dependency cycle")
	ErrInvalidApproval   = errors.New("invalid plan approval")
	ErrInvalidTransition = errors.New("invalid task status transition")
	ErrInvalidOwner      = errors.New("invalid task owner")
	ErrMissingDependency = errors.New("missing task dependency")
	ErrPlanExists        = errors.New("plan already exists")
	ErrPlanNotFound      = errors.New("plan not found")
	ErrTaskBlocked       = errors.New("task blocked")
	ErrTaskExists        = errors.New("task already exists")
	ErrTaskNotFound      = errors.New("task not found")
	ErrTaskOwnerMismatch = errors.New("task owner mismatch")
	ErrTaskOwned         = errors.New("task already owned")
)

Functions

This section is empty.

Types

type ApprovalDecision

type ApprovalDecision struct {
	State     ApprovalState `json:"state"`
	Actor     string        `json:"actor,omitempty"`
	Reason    string        `json:"reason,omitempty"`
	DecidedAt time.Time     `json:"decided_at,omitempty"`
}

type ApprovalRecord

type ApprovalRecord struct {
	State     ApprovalState `json:"state"`
	Actor     string        `json:"actor,omitempty"`
	Reason    string        `json:"reason,omitempty"`
	DecidedAt *time.Time    `json:"decided_at,omitempty"`
}

type ApprovalState

type ApprovalState string
const (
	ApprovalPending  ApprovalState = "pending"
	ApprovalApproved ApprovalState = "approved"
	ApprovalRejected ApprovalState = "rejected"
)

type ClaimRequest

type ClaimRequest struct {
	PlanID     string
	TaskID     string
	Owner      string
	StaleAfter time.Duration
}
type EvidenceLink struct {
	Label string `json:"label"`
	Path  string `json:"path"`
	URL   string `json:"url,omitempty"`
}

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

func NewFileStore

func NewFileStore(path string) *FileStore

func (*FileStore) ClaimNext

func (s *FileStore) ClaimNext(ctx context.Context, claim ClaimRequest) (TaskNode, error)

func (*FileStore) ClaimTask

func (s *FileStore) ClaimTask(ctx context.Context, claim ClaimRequest) (TaskNode, error)

func (*FileStore) CreatePlan

func (s *FileStore) CreatePlan(ctx context.Context, plan PlanRef) (PlanRef, error)

func (*FileStore) CreateTask

func (s *FileStore) CreateTask(ctx context.Context, task TaskNode) (TaskNode, error)

func (*FileStore) DecidePlan

func (s *FileStore) DecidePlan(ctx context.Context, planID string, decision ApprovalDecision) (PlanRef, error)

func (*FileStore) DecideTask

func (s *FileStore) DecideTask(ctx context.Context, taskID string, decision ApprovalDecision) (TaskNode, error)

func (*FileStore) GetPlan

func (s *FileStore) GetPlan(ctx context.Context, planID string) (PlanRef, error)

func (*FileStore) ListEvents

func (s *FileStore) ListEvents(ctx context.Context, planID string) ([]TaskEvent, error)

func (*FileStore) ListPlans

func (s *FileStore) ListPlans(ctx context.Context) ([]PlanRef, error)

func (*FileStore) ListTasks

func (s *FileStore) ListTasks(ctx context.Context, planID string) ([]TaskNode, error)

func (*FileStore) SetClock

func (s *FileStore) SetClock(now func() time.Time)

func (*FileStore) UpdateTask

func (s *FileStore) UpdateTask(ctx context.Context, update TaskUpdate) (TaskNode, error)

func (*FileStore) UpdateTaskIfOwned

func (s *FileStore) UpdateTaskIfOwned(ctx context.Context, update GuardedTaskUpdate) (TaskNode, error)

type GuardedTaskUpdate

type GuardedTaskUpdate struct {
	Guard  TaskOwnerGuard
	Update TaskUpdate
}

type PlanRef

type PlanRef struct {
	ID          string         `json:"id"`
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	Approval    ApprovalRecord `json:"approval"`
}

type Store

type Store interface {
	ListPlans(ctx context.Context) ([]PlanRef, error)
	CreatePlan(ctx context.Context, plan PlanRef) (PlanRef, error)
	GetPlan(ctx context.Context, planID string) (PlanRef, error)
	DecidePlan(ctx context.Context, planID string, decision ApprovalDecision) (PlanRef, error)
	ListTasks(ctx context.Context, planID string) ([]TaskNode, error)
	CreateTask(ctx context.Context, task TaskNode) (TaskNode, error)
	UpdateTask(ctx context.Context, update TaskUpdate) (TaskNode, error)
	UpdateTaskIfOwned(ctx context.Context, update GuardedTaskUpdate) (TaskNode, error)
	DecideTask(ctx context.Context, taskID string, decision ApprovalDecision) (TaskNode, error)
	ClaimTask(ctx context.Context, claim ClaimRequest) (TaskNode, error)
	ClaimNext(ctx context.Context, claim ClaimRequest) (TaskNode, error)
	ListEvents(ctx context.Context, planID string) ([]TaskEvent, error)
}

type TaskEvent

type TaskEvent struct {
	TaskID    string     `json:"task_id"`
	PlanID    string     `json:"plan_id"`
	Type      string     `json:"type"`
	Actor     string     `json:"actor,omitempty"`
	Status    TaskStatus `json:"status,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

type TaskNode

type TaskNode struct {
	ID          string         `json:"id"`
	PlanID      string         `json:"plan_id"`
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	Status      TaskStatus     `json:"status"`
	BlockedBy   []string       `json:"blocked_by,omitempty"`
	Owner       string         `json:"owner,omitempty"`
	AgentHint   string         `json:"agent_hint,omitempty"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	ClaimedAt   *time.Time     `json:"claimed_at,omitempty"`
	CompletedAt *time.Time     `json:"completed_at,omitempty"`
	Approval    ApprovalRecord `json:"approval"`
	Evidence    []EvidenceLink `json:"evidence,omitempty"`
}

type TaskOwnerGuard

type TaskOwnerGuard struct {
	PlanID string
	Owner  string
	Status TaskStatus
}

type TaskStatus

type TaskStatus string
const (
	TaskStatusPending    TaskStatus = "pending"
	TaskStatusInProgress TaskStatus = "in_progress"
	TaskStatusCompleted  TaskStatus = "completed"
	TaskStatusCancelled  TaskStatus = "cancelled"
)

type TaskUpdate

type TaskUpdate struct {
	ID          string
	Title       string
	Description string
	Status      TaskStatus
	BlockedBy   []string
	Owner       string
	AgentHint   string
	Evidence    []EvidenceLink
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL