taskrunner

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package taskrunner schedules and executes tasks with dependency resolution. It performs topological sorting to determine execution order, tracks task status, and supports self-healing retries for failed tasks.

Index

Constants

View Source
const MaxParallelTasks = types.DefaultMaxParallelTasks

MaxParallelTasks is the default maximum number of tasks to execute concurrently within a group. Deprecated: use types.DefaultMaxParallelTasks or Runner.MaxParallel instead.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecuteFunc

type ExecuteFunc func(ctx context.Context, task types.Task) TaskResult

ExecuteFunc is the function called to execute a single task.

type Runner

type Runner struct {
	OnTaskStart  func(task types.Task)
	OnTaskUpdate func(task types.Task, status string)
	// TaskTimeout is the per-task timeout. Zero means no timeout.
	// Defaults to 30 minutes to match the Bash tool's default timeout.
	TaskTimeout time.Duration
	// MaxRetries is the number of retry attempts for failed tasks. Default 0.
	MaxRetries int
	// MaxParallel is the maximum number of tasks to execute concurrently within a group.
	// Zero means use DefaultMaxParallelTasks (4).
	MaxParallel int
	// contains filtered or unexported fields
}

Runner schedules and executes tasks with dependency resolution.

func New

func New(tasks []types.Task) *Runner

New creates a Runner for the given tasks.

func (*Runner) AllDone

func (r *Runner) AllDone() bool

AllDone returns true when all tasks are done, skipped, failed, or unrecoverable.

func (*Runner) ExecuteGroup

func (r *Runner) ExecuteGroup(ctx context.Context, group []int, fn ExecuteFunc) error

ExecuteGroup runs all tasks in the group concurrently with bounded parallelism. Dependencies must have been completed in prior groups. The provided ctx is used as the parent context for all tasks, ensuring that cancellation (e.g. from TUI shutdown) propagates to running tasks.

func (*Runner) Results

func (r *Runner) Results() map[int]TaskResult

Results returns a copy of all task results.

func (*Runner) Schedule

func (r *Runner) Schedule() ([][]int, error)

Schedule performs topological sort and returns execution groups. Each group contains task IDs that are ready to execute (dependencies met). In V1, tasks within a group run sequentially.

func (*Runner) Status

func (r *Runner) Status(id int) types.TaskStatus

Status returns the current status of a task.

func (*Runner) Summary

func (r *Runner) Summary() (total, done, failed, skipped int)

Summary returns task counts by status.

func (*Runner) Tasks

func (r *Runner) Tasks() []types.Task

Tasks returns the current task list with updated statuses.

type TaskResult

type TaskResult struct {
	Success    bool
	Output     string
	Error      string
	CommitHash string
	DurationMs int64
	ToolCalls  int // number of tool calls made during task execution
}

TaskResult holds the outcome of executing a single task.

Jump to

Keyboard shortcuts

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