Documentation
¶
Overview ¶
Package taskqueue implements a central SQLite-backed queue that records every unit of work cloop performs — PM task executions, auto-heal retries, evolve discoveries, and externally-added tasks. The queue is the single source of truth for "what is cloop doing right now and what did it just do," giving the UI full auditability and ensuring no work runs anonymously.
The queue is intentionally append-mostly: rows are inserted when work begins and updated only with terminal status. List() returns rows newest-first.
As of Task 20079 the queue table lives inside the project state database (.cloop/state.db) so a project has exactly one SQLite file. Existing .cloop/queue.db files are migrated transparently on first Open and removed.
Index ¶
- func QueuePath(workDir string) string
- type Entry
- type Kind
- type ListOptions
- type Queue
- func (q *Queue) Close() error
- func (q *Queue) Enqueue(e Entry) (int64, error)
- func (q *Queue) List(opts ListOptions) ([]Entry, error)
- func (q *Queue) MarkDone(id int64, summary string) error
- func (q *Queue) MarkFailed(id int64, errMsg string) error
- func (q *Queue) MarkRunning(id int64) error
- func (q *Queue) MarkSkipped(id int64, reason string) error
- func (q *Queue) Path() string
- func (q *Queue) Stats() (map[Status]int, error)
- func (q *Queue) Truncate() error
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
ID int64 `json:"id"`
Kind Kind `json:"kind"`
TaskID int `json:"task_id,omitempty"` // 0 if not linked to a plan task
Attempt int `json:"attempt,omitempty"` // 1-based attempt counter (heal retries)
ParentID int64 `json:"parent_id,omitempty"` // queue id of the parent entry, if any
Title string `json:"title"`
Description string `json:"description,omitempty"`
Status Status `json:"status"`
Source string `json:"source,omitempty"` // "orchestrator" | "evolve" | "external" | "api" | "cli"
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
OutputSummary string `json:"output_summary,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
Entry is a single queue row.
type Kind ¶
type Kind string
Kind identifies what type of work the queue entry represents.
const ( KindTask Kind = "task" // PM task execution KindHeal Kind = "heal" // auto-heal retry attempt KindEvolve Kind = "evolve" // evolve discovery cycle KindExternal Kind = "external" // externally-added task merged in KindSession Kind = "session" // session-level work (decompose, optimize, etc.) )
type ListOptions ¶
type ListOptions struct {
// Limit caps the number of returned rows. 0 = default 200.
Limit int
// Offset for pagination. 0 = from newest.
Offset int
// Status filter. Empty = all statuses.
Status Status
// Kind filter. Empty = all kinds.
Kind Kind
// TaskID filter. 0 = all tasks.
TaskID int
}
ListOptions filters and paginates List results.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a thread-safe handle to the queue database.
func Open ¶
Open opens (or creates) the queue database. The caller must Close() it.
Storage is the project's state.db (the queue table is part of that file's schema, see pkg/statedb). On first call, any rows in a legacy .cloop/queue.db are migrated into state.db and the legacy file is removed.
func (*Queue) Enqueue ¶
Enqueue inserts a new queue entry and returns its assigned id. The Status, CreatedAt, ID, StartedAt, and CompletedAt fields of the input are ignored — Enqueue assigns its own values.
func (*Queue) List ¶
func (q *Queue) List(opts ListOptions) ([]Entry, error)
List returns queue entries matching opts, newest first.
func (*Queue) MarkDone ¶
MarkDone sets the entry status to "done" and records a brief output summary.
func (*Queue) MarkFailed ¶
MarkFailed sets the entry status to "failed" and records an error message.
func (*Queue) MarkRunning ¶
MarkRunning transitions an entry to the running state and stamps started_at. No-op if id is zero.
func (*Queue) MarkSkipped ¶
MarkSkipped sets the entry status to "skipped" and records a reason.