scheduler

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scheduler builds and runs the task dependency DAG. It memoizes each (namespace, task, canonical-args) so a node runs at most once per invocation (FR-005), runs dependencies before the body and post-hooks after, detects cycles, and fails fast on the first error. [parallel] dependencies run concurrently (bounded by CPU count) while preserving run-once semantics. Dependency and post-hook targets the Engine reports unavailable (e.g. declared for another OS) are skipped silently — they never execute and leave no memo entry — while the depending task still runs (spec 020).

|| failure hooks (spec 022) are the one deliberate exception to run-once: a hook body runs once per FAILING task (its dependencies still memoize), carries the failure context, never alters the original error, and never chains its own || hooks. User cancellation fires no hooks. Unavailable or failing hooks warn via Engine.Warnf instead of being silent — a silent skip would hide why no diagnosis appeared.

Index

Constants

This section is empty.

Variables

View Source
var ErrBodyNotRun = errors.New("task body did not run")

ErrBodyNotRun marks an Execute error raised before the task's body started (e.g. a declined [confirm] prompt). Failure hooks fire for body failures only (spec 022 FR-003), so errors wrapping this sentinel suppress the task's || hooks.

Functions

func Run

func Run(engine Engine, roots []Invocation) error

Run executes the given root invocations in order, sharing one memo table so repeated tasks run once across the whole invocation.

Types

type CycleError

type CycleError struct {
	Path []string
}

CycleError reports a dependency cycle with the offending path.

func (*CycleError) Error

func (e *CycleError) Error() string

type Engine

type Engine interface {
	// ResolveDep evaluates a dependency/post-hook call in the scope of the
	// calling task, returning the target task and its bound parameters.
	ResolveDep(curTask *ast.Task, cur eval.Args, dep *ast.DepCall) (*ast.Task, eval.Args, error)
	// Execute runs a single task body with its bound parameters.
	Execute(task *ast.Task, args eval.Args) error
	// ExecuteFailHook runs a || failure-hook body with the failure context
	// available to it (spec 022 FR-009). Called outside the memo table.
	ExecuteFailHook(task *ast.Task, args eval.Args, f Failure) error
	// Warnf emits a one-line warning (failure-hook skip or failure).
	Warnf(format string, args ...any)
	// Namespace returns the memoization namespace for a task (mod path, or "").
	Namespace(task *ast.Task) string
	// Available reports whether a task may run on this host. Unavailable
	// dependency/post-hook targets are skipped silently.
	Available(task *ast.Task) bool
	// ExitCode is the code the run exits with for a failed body's error. The
	// failure hooks receive it, so the two always agree (spec 028 FR-009).
	ExitCode(err error) int
}

Engine resolves dependencies and executes task bodies. The CLI layer implements it (it owns the evaluator, parameter binding, and executors).

type Failure added in v0.6.0

type Failure struct {
	TaskName string // user-visible (namespaced) name of the failed task
	ExitCode int    // the code the run exits with for this failure
}

Failure is the context of one task-body failure, handed to every failure hook fired for it.

type Invocation

type Invocation struct {
	Task   *ast.Task
	Params eval.Args
}

Invocation is a task plus its resolved parameters (a scheduler root).

Jump to

Keyboard shortcuts

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