fleet

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 5 Imported by: ? 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 fleet is the single ingress for a fleet spec (D6): every path into materialisation parses and validates here first, so no other package needs to re-check the shape of what it was handed.

Index

Constants

View Source
const SpecVersion = "menagerie.fleet.v1"

SpecVersion is the only accepted value of the `spec` field. A spec that does not name it is refused rather than guessed at — a future v2 must be a deliberate migration, not a silent reinterpretation of a v1 document.

Variables

View Source
var BuiltinVars = []string{"WORKSPACE", "BRANCH", "REPO_ROOT"}

BuiltinVars are the names ${VAR} interpolation resolves beyond the declared ports. Nothing else: no environment inheritance, no arbitrary shell expansion in declared fields.

Functions

func ValidateBytes

func ValidateBytes(b []byte) (*Spec, []Issue)

ValidateBytes is the ingress (D6). It parses and validates in one call so no caller can hold a Spec that never passed the validator. A malformed document returns a single /-rooted issue; the secret-leak lint (D4) runs on the raw bytes, before anything else, because a leaked credential in an unparseable document is still a leaked credential.

Types

type Budgets

type Budgets struct {
	PerAgentUSD          float64 `json:"per_agent_usd,omitempty"`
	PerRunUSD            float64 `json:"per_run_usd,omitempty"`
	PerAgentWallclockMin int     `json:"per_agent_wallclock_min,omitempty"`
	OnExceed             string  `json:"on_exceed,omitempty"`
}

Budgets caps spend and wall-clock. OnExceed is "drain" (finish the current unit, checkpoint, stop) or "kill" (immediate); empty means drain.

type Command

type Command struct {
	Run      string `json:"run"`
	CacheKey string `json:"cache_key,omitempty"`
}

Command is a setup step. CacheKey names a file whose unchanged hash skips the same expanded command in the same workspace. A different workspace must create its own artifacts even when that file has the same hash.

type Exits

type Exits struct {
	NoProgressRepeats int      `json:"no_progress_repeats,omitempty"`
	ConvergeOn        []string `json:"converge_on,omitempty"`
}

Exits are the run's loop-breakers.

type File

type File struct {
	From     string   `json:"from,omitempty"`
	Template string   `json:"template,omitempty"`
	To       string   `json:"to"`
	Vars     []string `json:"vars,omitempty"`
}

File is either a copy (From) or a rendered template (Template). Exactly one.

type Hooks

type Hooks struct {
	OnStart   string `json:"on_start,omitempty"`
	OnStop    string `json:"on_stop,omitempty"`
	OnDestroy string `json:"on_destroy,omitempty"`
}

Hooks run at workspace lifecycle transitions. on_start runs after a successful materialise.

on_stop and on_destroy execute only through the opt-in, hash-trusted managed workspace path. The one-shot legacy materialise command still does not run them; a declared hook is not an implicit daemon service.

type Issue

type Issue struct {
	Path    string `json:"path"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

Issue is one validation failure. Path is a JSON Pointer into the document, so an editor can put the cursor on the offending field rather than on the file.

func LintSecrets

func LintSecrets(b []byte) []Issue

LintSecrets reports credential-shaped strings anywhere in the raw document. It runs on bytes rather than on the parsed Spec so that a credential in a field this version does not model is still caught.

func Validate

func Validate(s *Spec) []Issue

Validate normalises the spec IN PLACE and then returns every issue in it, in document order. An empty slice means the spec is safe to execute.

The in-place normalisation is deliberate and load-bearing: the engine must never see a string the validator did not see. Every engine entry point calls Validate first, so this is the single point where whitespace stops mattering.

func (Issue) Error

func (i Issue) Error() string

type Materialise

type Materialise struct {
	Ports    []Port    `json:"ports,omitempty"`
	Files    []File    `json:"files,omitempty"`
	Commands []Command `json:"commands,omitempty"`
	Services []Service `json:"services,omitempty"`
	Health   []Probe   `json:"health,omitempty"`
	// Escape runs last, after everything declared, with all variables exported.
	// It is the honest hatch, not the default path.
	Escape string `json:"escape,omitempty"`
	// Hooks are a lifecycle layer beside the six stages, not a seventh stage:
	// the ports->files->commands->services->health->escape order is unchanged,
	// and on_start runs once that whole sequence has succeeded.
	Hooks *Hooks `json:"hooks,omitempty"`
}

Materialise is the environment-materialisation block. Its stages run in a fixed order — ports → files → commands → services → health → escape — which is not configurable: a file that needs a port must be able to read it, and a command that needs a file must run after it.

type Port

type Port struct {
	Name  string `json:"name"`
	Range [2]int `json:"range"`
}

Port is a variable bound to a port the relay allocates from Range. Hardcoded ports are the top cause of parallel-workspace collisions (D5).

type Probe

type Probe struct {
	Probe    string `json:"probe"`
	URL      string `json:"url,omitempty"`
	Run      string `json:"run,omitempty"`
	TimeoutS int    `json:"timeout_s,omitempty"`
}

Probe gates completion. A workspace whose probes fail is `unhealthy`, never `ready`.

type Role

type Role struct {
	Role                string `json:"role"`
	Agent               string `json:"agent"`
	Model               string `json:"model,omitempty"`
	Count               int    `json:"count"`
	ContextBudgetTokens int    `json:"context_budget_tokens,omitempty"`
	MaxDepth            int    `json:"max_depth,omitempty"`
}

Role is one row of the roster: how many of which agent, at what budget.

type Service

type Service struct {
	Name    string `json:"name"`
	Run     string `json:"run"`
	PortVar string `json:"port_var,omitempty"`
	// Supervise re-checks the service during materialisation. The opt-in managed
	// path also checks on the owning daemon's 10-second cadence with a persisted
	// three-attempt restart budget and explicit resume after daemon restart.
	// Supervision needs something concrete to check, so it requires
	// PortVar — and PortVar must name an allocated port, not merely an
	// interpolatable name.
	Supervise bool `json:"supervise,omitempty"`
}

Service starts once per repo, unless PortVar is set — then once per workspace, because a per-workspace port implies a per-workspace instance.

type Spec

type Spec struct {
	Spec string `json:"spec"`
	Name string `json:"name"`
	// Repo locates the repository the spec describes, relative to the spec
	// file ("." for the spec's own repo). `legacy materialise` resolves its
	// default --repo from it; an explicit --repo overrides it.
	Repo string `json:"repo"`
	// Topology is required and has no default. The handoff's reasoning: roughly
	// four in five multi-agent failures are specification and coordination
	// problems, and an unnamed topology is the first of them. The *value* is not
	// enumerated here — the requirement is that the author names it, and an
	// invented enum would refuse valid future shapes.
	Topology string `json:"topology"`

	Workspace Workspace `json:"workspace"`
	Roster    []Role    `json:"roster"`
	Budgets   *Budgets  `json:"budgets,omitempty"`
	Exits     *Exits    `json:"exits,omitempty"`
}

Spec is a whole fleet.json document.

type Teardown

type Teardown struct {
	Commands   []string `json:"commands,omitempty"`
	KeepBranch bool     `json:"keep_branch,omitempty"`
}

Teardown reverses materialisation. KeepBranch defaults to false only when the block is present and says so; a missing Teardown keeps the branch.

Executed only by explicit managed-workspace destroy, after stop and before on_destroy. The one-shot legacy materialise path does not execute teardown.

type Workspace

type Workspace struct {
	Isolation    string      `json:"isolation"`
	BranchPrefix string      `json:"branch_prefix,omitempty"`
	Materialise  Materialise `json:"materialise"`
	Teardown     *Teardown   `json:"teardown,omitempty"`
}

Workspace describes how one agent's working copy is isolated and made runnable.

Directories

Path Synopsis
fleetcheck validates fleet specs from the command line.
fleetcheck validates fleet specs from the command line.
cmd
fleetcheck command

Jump to

Keyboard shortcuts

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