plan

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 7 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 plan is the plan plane: the missing third layer between "one task, one node" and the scenario this project exists for — develop on the Mac, train on the Windows box, report through the Pi.

A single task cannot express that. It has a state machine, a lease and an audit chain, but no notion of "this work comes after that work, and consumes what it produced". A Plan adds exactly that and nothing else: named stages, their dependencies, and per-stage capability and resource requirements. The scheduling, routing, retrying and approval of each stage stays with the existing task machinery, which is why a stage lands in the same tasks table as any other task rather than in a parallel execution model of its own.

The package is pure: no IO, no clock, no database. Everything here is a decision about a value the caller already holds, which is what makes the plan layer testable without a network of nodes.

Index

Constants

View Source
const ExampleYAML = `` /* 2008-byte string literal not displayed */

ExampleYAML is the flagship scenario as a runnable file: develop the training code where a coding agent lives, train where the VRAM is, summarize where the user is. `panda plan example` prints it so the first plan a user runs is one they edited rather than one they invented.

View Source
const MaxStages = 64

MaxStages bounds a plan's size. Plans are generated from a user's request by a model, and every stage becomes a real task row, a real delegation and a real lease — so an unbounded plan is an unbounded fan-out of live work across the network. Sixty-four is far past any hand-written pipeline and far short of a runaway.

Variables

This section is empty.

Functions

func Complete

func Complete(p Plan, done map[string]bool) bool

Complete reports whether every stage of the plan is done.

func Inputs

func Inputs(p Plan, id string) []string

Inputs returns the stage IDs whose outputs the named stage consumes, sorted so the artifact wiring is deterministic — a stage with two inputs must extract them in the same order on every node, or two runs of the same plan would produce differently laid out working trees.

func ValidID added in v0.0.7

func ValidID(s string) bool

ValidID reports whether s is a safe stage id. A stage id becomes a path segment in the executor's work dir (core.stageWorkDir) and a field on the wire, so anything outside [A-Za-z0-9_-] — separators, dots, backslashes — is refused at the boundary instead of sanitized after the fact (review P0-1: a stage id of "../../.." turned the work dir into an arbitrary directory the caller could then pack and exfiltrate).

func Validate

func Validate(p Plan) error

Validate rejects a plan that cannot be executed. Every check here is a plan that would otherwise fail *after* work had already been dispatched — a dangling dependency leaves a stage waiting for a stage that will never run, and a cycle leaves the whole plan idle with nothing ready and no error anywhere.

Types

type Plan

type Plan struct {
	Goal   string
	Stages []Stage
}

Plan is a goal decomposed into stages. The stage list carries the dependency graph in its Needs fields rather than in an explicit edge list: a stage is meaningless without the thing it depends on, so the two travel together.

func FromSpec

func FromSpec(spec entry.PlanSpec) (Plan, error)

FromSpec converts a model-emitted plan into an executable Plan, validating it. A stage with no title borrows its intent's first line: the title is what shows up on the task board, and "stage 2" tells an operator nothing.

func Parse

func Parse(data []byte) (Plan, error)

Parse decodes a YAML plan and validates it. Validation happens here rather than at the caller so no path can load a plan without it: an unvalidated plan fails after stages have already been dispatched, which is the expensive way to find out a dependency was misspelled.

KnownFields is on: a misspelled key in a plan file is silently dropped by default, and "reqires: [gpu]" quietly producing a stage with no requirements is exactly how a training stage ends up on the Pi.

type Stage

type Stage struct {
	// ID is the stage's name within the plan ("develop", "train"). It is what
	// Needs refers to, and it is persisted on the task row.
	ID string
	// Title is the human-readable label shown in the task queue.
	Title string
	// Requires is the capability set the executing node must satisfy.
	Requires []string
	// Needs lists the stage IDs that must finish before this one may start. It
	// is also the artifact wiring: a stage consumes the outputs of what it needs.
	Needs []string
	// Node is a hard pin: when set, the stage runs on exactly that node (id,
	// display name, or k:<pubkey> stable identity) — parked while the node is
	// unreachable rather than silently re-scored onto a different machine.
	// Empty means normal scored routing.
	Node string
	// Resources is the hardware the stage asks for (VRAM for a training run,
	// nothing much for a summary).
	Resources entry.ResourceProfile
	// Intent is what the executing node is actually asked to do.
	Intent string
}

Stage is one unit of a plan: work that can be routed to a node on its own. Requires and Resources are the same vocabulary the scheduler already routes a task by, so a stage is matched to a node by the existing scoring — a stage needing a GPU cannot land on the Pi because of what it declares here, not because of anything plan-specific.

func Find

func Find(p Plan, id string) (Stage, bool)

Find returns the stage with the given ID.

func Order

func Order(p Plan) ([]Stage, error)

Order returns the stages in an execution order: every stage appears after the stages it needs. It is not how the plan runs — execution is driven by Ready, one wave at a time, so independent stages occupy several nodes at once — but it is how a plan is *read*, which is what a dry run and a review need. Repeatedly draining Ready is deliberately how it is computed: one definition of readiness is easier to trust than two, and this way the printed order cannot disagree with the order the plan actually takes.

A cycle is impossible in a validated plan; the error is here so an unvalidated one cannot make this loop forever.

func Ready

func Ready(p Plan, done map[string]bool) []Stage

Ready returns the stages whose dependencies are all satisfied and which are not themselves done, in plan order.

It returns a slice rather than a single stage because that is where parallelism comes from: a linear chain yields one stage at a time, while a plan that fans out yields several at once, and the caller hands them all to the queue — so two independent stages occupy two nodes without any plan-specific scheduling.

done is keyed by stage ID. Unknown keys are ignored, so a caller may pass the completion set of a larger plan.

Jump to

Keyboard shortcuts

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