task

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending    = "pending"
	StatusInProgress = "in_progress"
	StatusCompleted  = "completed"
	StatusFailed     = "failed"
)

Task statuses

View Source
const (
	EffortS  = "S"
	EffortM  = "M"
	EffortL  = "L"
	EffortXL = "XL"
)

Effort levels

View Source
const (
	ComplexityLow    = "low"
	ComplexityMedium = "medium"
	ComplexityHigh   = "high"
)

Complexity levels

Variables

This section is empty.

Functions

func Now

func Now() int64

Now returns the current Unix millisecond timestamp.

Types

type Store

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

func NewStore

func NewStore(database *db.DB) *Store

func (*Store) Claim

func (s *Store) Claim(taskID, sessionID, branchName, worktreePath string) (bool, error)

Claim atomically transitions a pending task to in_progress. It sets the session_id, branch_name, and worktree_path in a single UPDATE that only succeeds when the task is still pending with no session assigned. Returns false (no error) when another goroutine already claimed the task.

func (*Store) Create

func (s *Store) Create(task *Task) error

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) FailStuckTasks

func (s *Store) FailStuckTasks() (int, error)

FailStuckTasks marks every in_progress task as failed. Called on server startup to recover tasks that were running when the server was last shut down or crashed.

func (*Store) Get

func (s *Store) Get(id string) (*Task, error)

func (*Store) GetReadyTasks

func (s *Store) GetReadyTasks(planID string) ([]*Task, error)

func (*Store) ListByPlan

func (s *Store) ListByPlan(planID string) ([]*Task, error)

func (*Store) ResetFailed

func (s *Store) ResetFailed(id string) error

ResetFailed atomically clears all runtime state on a failed task and sets it back to pending so it can be re-executed cleanly. The UPDATE is conditional on status=failed so concurrent calls are safe.

func (*Store) Update

func (s *Store) Update(task *Task) error

func (*Store) UpdateStatus

func (s *Store) UpdateStatus(id string, status string) error

type Task

type Task struct {
	ID           string   `json:"id"`
	PlanID       string   `json:"planId"`
	SessionID    *string  `json:"sessionId,omitempty"`
	ParentTaskID *string  `json:"parentTaskId,omitempty"`
	Title        string   `json:"title"`
	Description  string   `json:"description"`
	Effort       string   `json:"effort"`       // S, M, L, XL
	Complexity   string   `json:"complexity"`   // low, medium, high
	Status       string   `json:"status"`       // pending, in_progress, completed, failed
	Dependencies []string `json:"dependencies"` // task IDs this task depends on
	BranchName   string   `json:"branchName"`
	WorktreePath string   `json:"worktreePath,omitempty"`
	PRURL        string   `json:"prUrl,omitempty"`
	PRNumber     *int     `json:"prNumber,omitempty"`
	OrderIndex   int      `json:"orderIndex"`
	CreatedAt    int64    `json:"createdAt"`
	UpdatedAt    int64    `json:"updatedAt"`
}

Task represents a unit of work derived from a locked Plan. Each task is executed in its own git branch with an isolated agent session.

Jump to

Keyboard shortcuts

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