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 ¶
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, curParams map[string]string, dep *ast.DepCall) (*ast.Task, map[string]string, error)
// Execute runs a single task body with its bound parameters.
Execute(task *ast.Task, params map[string]string) 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, params map[string]string, 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
}
Engine resolves dependencies and executes task bodies. The CLI layer implements it (it owns the evaluator, parameter binding, and executors).