tasks

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSelfDependency  = errors.New("tasks: task cannot depend on itself")
	ErrDependencyCycle = errors.New("tasks: dependency cycle detected")
)
View Source
var (
	ErrEmptySubject      = errors.New("tasks: subject is required")
	ErrInvalidTaskID     = errors.New("tasks: invalid task id")
	ErrTaskNotFound      = errors.New("tasks: task not found")
	ErrInvalidTaskStatus = errors.New("tasks: invalid task status")
	ErrTaskBlocked       = errors.New("tasks: task is blocked by incomplete dependencies")
)

Functions

This section is empty.

Types

type Store

type Store interface {
	Create(subject, description, activeForm string) (*Task, error)
	Get(id string) (*Task, error)
	Update(id string, updates TaskUpdate) (*Task, error)
	List() []*Task
	Snapshot() []*Task
	Delete(id string) error
	AddDependency(taskID, blockedByID string) error
	RemoveDependency(taskID, blockedByID string) error
	GetBlockedTasks(taskID string) []*Task
	GetBlockingTasks(taskID string) []*Task
	Close() error
}

Store defines the task storage contract used by builtin task tools. The interface enables dependency injection of external persistent store implementations (e.g., database-backed) beyond the default in-memory store.

type Task

type Task struct {
	ID          string     `json:"id"`
	Subject     string     `json:"subject"`
	Description string     `json:"description"`
	ActiveForm  string     `json:"activeForm"`
	Status      TaskStatus `json:"status"`
	Owner       string     `json:"owner"`
	Blocks      []string   `json:"blocks"`
	BlockedBy   []string   `json:"blockedBy"`
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   time.Time  `json:"updatedAt"`
}

type TaskStatus

type TaskStatus string
const (
	TaskPending    TaskStatus = "pending"
	TaskInProgress TaskStatus = "in_progress"
	TaskCompleted  TaskStatus = "completed"
	TaskBlocked    TaskStatus = "blocked"
)

type TaskStore

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

func NewTaskStore

func NewTaskStore() *TaskStore

func NewTaskStoreFromSnapshot

func NewTaskStoreFromSnapshot(snapshot []*Task) *TaskStore

NewTaskStoreFromSnapshot creates a store from an external snapshot. Invalid entries (empty IDs) are skipped.

func (*TaskStore) AddDependency

func (s *TaskStore) AddDependency(taskID, blockedByID string) error

func (*TaskStore) Close

func (s *TaskStore) Close() error

Close is a no-op for the in-memory implementation. It exists in the Store interface so that persistent implementations can release resources (e.g., close database connections) on shutdown.

func (*TaskStore) Create

func (s *TaskStore) Create(subject, description, activeForm string) (*Task, error)

func (*TaskStore) Delete

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

func (*TaskStore) Get

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

func (*TaskStore) GetBlockedTasks

func (s *TaskStore) GetBlockedTasks(taskID string) []*Task

func (*TaskStore) GetBlockingTasks

func (s *TaskStore) GetBlockingTasks(taskID string) []*Task

func (*TaskStore) List

func (s *TaskStore) List() []*Task

func (*TaskStore) RemoveDependency

func (s *TaskStore) RemoveDependency(taskID, blockedByID string) error

func (*TaskStore) Snapshot

func (s *TaskStore) Snapshot() []*Task

Snapshot returns a deep copy of all tasks preserving insertion order.

func (*TaskStore) Update

func (s *TaskStore) Update(id string, updates TaskUpdate) (*Task, error)

type TaskUpdate

type TaskUpdate struct {
	Subject     *string
	Description *string
	ActiveForm  *string
	Status      *TaskStatus
	Owner       *string
}

Jump to

Keyboard shortcuts

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