Documentation
¶
Overview ¶
Package provision is muster's pluggable provisioner contract: the seam between "an agent should exist, configured like this" and whatever actually runs it — a Kubernetes cluster, a container daemon, a process on the box.
It declares the interface, the data that crosses it, and a capability declaration callers are expected to BRANCH on. It contains no driver-specific code and imports nothing outside the standard library, so a caller that wires the no-op driver pays for none of a cluster client's dependency tree.
Why this exists at all ¶
The project muster was extracted from had this boundary physically — its 1,201-line provisioning file imported nothing from any cluster library and talked to two injected clients at roughly 25 call sites — but never declared it. The consequences were not theoretical:
- The lifecycle entry point took a DATABASE ROW ID and loaded the row itself, so a second driver would have needed the first one's schema.
- The conversation with the running agent was on the same interface as "create a pod", so the interface carried a sentinel error naming a specific vendor's image VERSION.
- The one address an agent was reachable at was a hardcoded string with no override anywhere in the codebase.
- Every file placed into an agent was shipped as base64 inside a shell one-liner, wrapped in `{ … } || :` because the surrounding script ran under `set -e` and a bare non-zero exit was a crash loop.
Each of those is fixed here by the shape of the types rather than by a rule somebody has to remember: Ref carries identity without a database, the interface has no chat method at all, Provisioner.Endpoint is a method, and Spec.Files is data.
The four contract rules ¶
These are behavioural promises, not documentation. Each rule's MAIN clause is pinned by a test in provisiontest.RunContract, which every driver in this repository must pass.
🔴 ONE CLAUSE IS DELIBERATELY NOT CONTRACT-PINNED, AND THIS SENTENCE USED TO CLAIM OTHERWISE. Rule 2's ErrNotManaged carve-out cannot be expressed in RunContract: a foreign co-named object requires a SHARED backend, and Noop's backend is its own map, so the case would be unfalsifiable for half the drivers here — see ErrNotManaged, which states that decision. It is pinned in the kubernetes driver's own ownership tests instead. RunContract has 20 cases and none of them mentions ErrNotManaged; a reader who trusted the old wording would have believed a driver's compliance with that clause was checked by the suite it passes.
🔴 A DRIVER THAT CANNOT SEE ITS BACKEND RETURNS AN ERROR, NEVER AN EMPTY SET. Provisioner.List and Provisioner.Get must fail loudly when the backend is unreachable. This looks like a nicety and is not: the caller treats a List error as "no live information, keep the stored status" and an empty List as "nothing is running" — so a blind driver returning `nil, nil` silently rewrites every instance's state to stopped. Return ErrBlind (wrapped is fine) rather than an empty slice.
🔴 Provisioner.Destroy RETURNS nil ONLY IF THE INSTANCE WAS REMOVED OR WAS ALREADY ABSENT. A bare `return nil` satisfies the compiler and means nothing; it is the "declared but inert" shape, and it reads as coverage. A driver must be able to say afterwards that the thing is gone — Provisioner.Get must return ErrNotFound. A FOREIGN object holding the instance's name is neither case: it is ErrNotManaged, and that error must not also satisfy errors.Is(err, ErrNotFound) or the `!errors.Is(err, ErrNotFound)` idiom this rule invites discards it. That refusal must also mean NOTHING WAS REMOVED — a driver decides ownership before it deletes, so a caller can read the sentinel as "the backend is as it was" rather than guessing. See Provisioner.Destroy and ErrNotManaged.
🔴 Provisioner.Create IS IDEMPOTENT, AND A DIVERGENT SPEC IS AN ERROR. Creating the same instance twice with the same spec succeeds twice. Creating it with a DIFFERENT spec returns ErrDivergentSpec rather than silently overwriting — the caller that wanted the overwrite has Provisioner.Update and can say so.
🔴 Capabilities IS USELESS UNLESS CALLERS BRANCH ON IT. A field that exists is not a guard. Each capability's refusal lives in exactly one place, and Capabilities's own doc comment is the AUTHORITY on which capability is refused where — this rule deliberately does not repeat the list, because the copy of it that used to be here named CheckSpec and a since-removed policy Grant only, and a partial enumeration of the guards reads as a complete one.
What is deliberately NOT here ¶
Talking to a running agent. Sending it a message, streaming its tokens, servicing its tool calls — none of that is provisioning, and putting it here is what made the original interface un-implementable by anything that was not one specific container image. A runtime interface is separate work.
Index ¶
- Constants
- Variables
- func CheckScale(caps Capabilities, replicas int) error
- func CheckSpec(caps Capabilities, s Spec) error
- func Exec(ctx context.Context, p Provisioner, ref Ref, cmd []string, stdin io.Reader, ...) error
- func ExecIn(ctx context.Context, p Provisioner, ref Ref, container string, cmd []string, ...) error
- func ExecTTY(ctx context.Context, p Provisioner, ref Ref, cmd []string, stdin io.Reader, ...) error
- func Fingerprint(s Spec) string
- type Capabilities
- type ContainerExecer
- type Endpoint
- type EndpointTemplate
- type EndpointVars
- type EnvVar
- type Execer
- type File
- type Health
- type Instance
- type Isolation
- type KeyHolder
- type Network
- type Noop
- func (n *Noop) Capabilities() Capabilities
- func (n *Noop) Create(ctx context.Context, spec Spec) error
- func (n *Noop) Destroy(ctx context.Context, ref Ref) error
- func (n *Noop) Driver() string
- func (n *Noop) Endpoint(ctx context.Context, ref Ref) (Endpoint, error)
- func (n *Noop) Get(ctx context.Context, ref Ref) (Instance, error)
- func (n *Noop) List(ctx context.Context) ([]Instance, error)
- func (n *Noop) Scale(ctx context.Context, ref Ref, replicas int) error
- func (n *Noop) StreamLogs(ctx context.Context, ref Ref, emit func(line string)) error
- func (n *Noop) Update(ctx context.Context, spec Spec) error
- type NoopOption
- type Phase
- type Port
- type Provisioner
- type Ref
- type Repo
- type Resources
- type Runtime
- type SecretMount
- type Security
- type Sidecar
- type Spec
- type TTYExecer
- type TermSize
- type Workspace
Constants ¶
const DefaultNoopEndpointTemplate = "{{.Name}}.noop.invalid"
DefaultNoopEndpointTemplate is what a Noop reports addresses under. `.invalid` is reserved by RFC 2606 and is guaranteed never to resolve, which is the point: a fake driver must not hand out an address that might accidentally reach something real.
const DefaultPortName = "gateway"
DefaultPortName is the port Endpoint resolves when a spec declares several and the caller did not say which.
Variables ¶
var ( // ErrNotFound — the backend was reached and does not have this instance. ErrNotFound = errors.New("provision: instance not found") // ErrBlind — the driver could not reach its backend, so it knows NOTHING. // // 🔴 THIS IS THE ERROR THAT MUST NOT BECOME AN EMPTY SLICE. See the contract // rules in the package doc: a caller reads a List error as "keep the stored // status" and an empty List as "nothing is running", so a driver that // swallows a connection failure and returns `nil, nil` rewrites every // instance's state to stopped and looks, from the outside, like a cluster // that emptied itself. ErrBlind = errors.New("provision: backend unreachable") // ErrNotManaged — the backend was REACHED, and it has an object under the // name this instance asks for that the driver did not create. // // 🔴 IT IS A PERMANENT DECISION AND IT IS NOT ErrBlind. Five call sites in // the kubernetes driver's apply() wrapped this refusal in the ErrBlind // constructor, which formats with %v, so a caller saw only "backend // unreachable": a refusal that will never resolve on its own presented as a // transient fault, so a caller that retries never converges and a caller // that alerts pages for an outage that is not happening. TWO MORE were // found a round later, in that driver's (since removed) policy grant path, // because the fix consolidated apply's sites and nobody asked which OTHER // paths wrote objects. A predicate corrected at some of its sites is wrong // at the rest of them, in the same direction. // // 🔴 A BY-NAME READ ALSO REPORTS ErrNotFound; A WRITE OR A TEARDOWN DOES // NOT. Those are different questions with different right answers, and the // asymmetry is deliberate: // // - Get, Scale, Endpoint and the log paths were asked "what is instance // X". A stranger's co-named object is not instance X, so the answer is // "muster has no instance by that name" — ErrNotFound AND this. // Reporting it as an instance is how a status read describes somebody // else's Deployment as an agent. // - Update and Destroy were asked to ACT on X. "There is no such // instance" is not what happened — something else holds the name and // muster refused — so these report this sentinel ALONE. Reporting // ErrNotFound there is worse than imprecise: `if err != nil && // !errors.Is(err, ErrNotFound)` is the idiom Destroy's own contract // invites, and it SILENTLY DISCARDS the refusal. // // 🔴 Create IS AN EXCEPTION AND THIS DOC USED TO NAME IT AS A PRODUCER. // Measured: Create over a foreign co-named Deployment gives // errors.Is(err, ErrDivergentSpec) true and errors.Is(err, ErrNotManaged) // FALSE. That is the DECISION, not a defect — "refused, nothing written" is // the branch Create's caller already has, and a single error claiming to be // both a divergence and an ownership refusal makes the caller's switch // order decide which one it is. The refusal's PROSE still names the label // that is wrong, because relabelling is the only escape. The kubernetes // driver's ownership tests now assert the absence of this sentinel there, // which nothing did while this paragraph was wrong. // // It is not pinned by provisiontest.RunContract: a driver has to have a // SHARED backend for a foreign co-named object to be expressible at all, // and Noop's backend is its own map (and compose's a volume only muster // writes), so a contract case would be unfalsifiable for most of the // drivers in this repository. It is pinned in // the kubernetes driver's own ownership tests instead. ErrNotManaged = errors.New("provision: an object under this name is not managed by this driver") // ErrDivergentSpec — Create was called for an instance that already exists // with a materially different spec. The caller that meant to change it has // Update. ErrDivergentSpec = errors.New("provision: instance exists with a different spec") // ErrUnsupported — the driver cannot do what was asked and is REFUSING // rather than doing part of it. Returned by CheckSpec, CheckScale and Exec. ErrUnsupported = errors.New("provision: unsupported by this driver") // ErrInvalidSpec — the spec is wrong regardless of driver. ErrInvalidSpec = errors.New("provision: invalid spec") )
The sentinel errors every driver reports through. They are sentinels rather than strings because callers BRANCH on them: the difference between "I cannot see the backend" and "the backend says there is nothing there" decides whether stored state is preserved or overwritten, and a caller cannot tell those apart from prose.
var DefaultNoopCapabilities = Capabilities{ Isolation: IsolationNone, Secrets: true, Files: true, Persistence: true, ResourceLimits: true, Scale: true, NetworkIsolation: true, Sidecar: true, KeyHolder: true, }
DefaultNoopCapabilities is what a Noop declares by default.
⚠ IT CLAIMS Files, Secrets, Persistence, ResourceLimits, Scale AND NetworkIsolation BECAUSE IT RECORDS THEM FAITHFULLY, AND CLAIMS NOTHING ELSE. The honest reading of a capability for an in-memory driver is "a spec asking for this survives a round trip through me unchanged", and those six do — which for NetworkIsolation is a statement about the RECORD and not about any confinement: nothing runs here, so nothing is confined, and Isolation below already says so. Exec does not — there is no process to enter — so it is false and the refusal in Exec has a real subject to fire on.
🔴 Isolation IS IsolationNone AND THAT IS NOT A PLACEHOLDER. Nothing runs, so nothing is isolated. An interface that warns on IsolationNone should warn here too; a fake that quietly claimed a safe isolation level would train people to ignore the warning on the driver where it matters.
var ErrNoEndpoint = errors.New("provision: instance declares no reachable endpoint")
ErrNoEndpoint — the instance exists but declares no address a caller could reach it at. Distinct from ErrNotFound (the instance is gone) and from ErrBlind (the driver cannot see), because "running but not reachable" is a real, diagnosable state and collapsing it into either of the others hides it.
Functions ¶
func CheckScale ¶
func CheckScale(caps Capabilities, replicas int) error
CheckScale is the same branch for Scale, which does not take a spec.
Replica counts of 0 and 1 are universal — every driver can stop and start one instance — so only a count above 1 needs the capability.
func CheckSpec ¶
func CheckSpec(caps Capabilities, s Spec) error
CheckSpec is THE capability branch. It is the answer to "Capabilities is useless unless callers branch on it", and it exists exactly once so there is exactly one place to be wrong.
Every driver calls it at the top of Create and Update, before it touches a backend. It returns an error wrapping ErrUnsupported naming the capability and what the spec asked for, so the refusal is legible to whoever wrote the spec rather than being a generic rejection.
🔴 THE REFUSALS ARE NOT PEDANTRY. Each one is a case where honouring part of a spec and dropping the rest produces something that LOOKS like it worked: secrets written into plain environment, a resource ceiling that is not enforced, a workspace that is a tmpfs. Silently degrading any of those is the shape the original project's noop driver had, where every method returned nil and the interface reported success for work nobody did.
func Exec ¶
func Exec(ctx context.Context, p Provisioner, ref Ref, cmd []string, stdin io.Reader, stdout, stderr io.Writer) error
Exec runs a command inside an instance, refusing when the driver declares it cannot. Callers use this rather than asserting, so the Capabilities check cannot be forgotten at one of several call sites.
func ExecIn ¶ added in v0.110.0
func ExecIn(ctx context.Context, p Provisioner, ref Ref, container string, cmd []string, stdin io.Reader, stdout, stderr io.Writer) error
ExecIn runs a command inside the named container of an instance, refusing when the driver declares it cannot exec, or cannot exec into a container other than the instance's own.
func ExecTTY ¶
func ExecTTY(ctx context.Context, p Provisioner, ref Ref, cmd []string, stdin io.Reader, stdout io.Writer, resize <-chan TermSize) error
ExecTTY runs a command inside an instance on a terminal, refusing when the driver declares it cannot exec. It is Exec's rule reached by a second entry point — one capability, Capabilities.Exec, refused in this file and nowhere else — so a caller cannot reach a terminal by asserting TTYExecer itself.
func Fingerprint ¶
Fingerprint is a stable digest of the parts of a spec that, if changed, mean the instance must be rebuilt rather than left alone.
It is how a driver answers Create's idempotence question without storing the whole spec: record the fingerprint at create time, compare on the next Create, return ErrDivergentSpec when they differ.
🔴 WHAT IT COVERS IS A DECISION, AND THE OMISSIONS ARE DELIBERATE. Ref.ID is excluded because it is a correlation hint whose change means nothing about the running instance. Replicas is excluded because Scale changes it legitimately and a scaled instance is not a divergent one. Labels are excluded because they are the operator's own annotation space.
⚠ SECRET VALUES ARE HASHED, NOT RECORDED. The digest goes into a label or an annotation on a real backend, and an annotation is world-readable to anything that can read the object.
Types ¶
type Capabilities ¶
type Capabilities struct {
// Isolation is how well instances are separated. See the constants.
Isolation Isolation
// Secrets: the driver has a confidential store distinct from plain
// environment. False means Spec.Secrets and secret Files are refused rather
// than written somewhere readable.
//
// ⚠ A container daemon is the motivating false case. Its secret support is
// an orchestrator feature, so a plain-daemon driver has only environment
// variables and bind mounts, and an environment variable is visible to
// anything that can read the process table.
Secrets bool
// Files: the driver can place Spec.Files natively.
Files bool
// Persistence: storage that outlives the instance's process.
Persistence bool
// ResourceLimits: enforceable cpu/memory ceilings.
ResourceLimits bool
// Scale: replica counts other than 0 and 1.
Scale bool
// Exec: the driver implements Execer AND TTYExecer against a live instance.
Exec bool
// NetworkIsolation: the driver can confine an instance's network as
// [Network] describes. False means a spec setting Network.Isolate is refused
// rather than started unconfined.
//
// ⚠ FOR A DRIVER THAT ONLY DECLARES THE CONFINEMENT TO SOMETHING ELSE — the
// kubernetes driver writes a NetworkPolicy, and the cluster's network plugin
// is what enforces it or does not — true means "I will write it and refuse to
// start the instance if I cannot", NOT "I measured it enforced".
NetworkIsolation bool
// Sidecar: the driver runs Spec.Sidecar beside the instance, sharing its
// network and workspace (see provision.Sidecar).
Sidecar bool
// KeyHolder: the driver runs Spec.KeyHolder as its own container under its
// own uid, mounts the holder's secrets into it alone, shares its directory
// read-only with the instance, and execs into it (ContainerExecer).
KeyHolder bool
// ImagePullSecret: the driver pulls the instance's image with the registry
// credential Spec.ImagePullSecret names. False means a spec carrying one is
// refused rather than started without it (a pod that cannot pull its image
// sits in ImagePullBackOff, which reads as a slow worker).
ImagePullSecret bool
}
Capabilities is what a driver can actually do.
🔴 A CAPABILITY NOBODY BRANCHES ON IS NOT A GUARD, IT IS A FIELD. Every bool here is refused on somewhere, and each one's refusal is spelled in exactly one place: Files, Secrets, Persistence, ResourceLimits, NetworkIsolation, Sidecar, KeyHolder and ImagePullSecret in CheckSpec; Scale in CheckSpec and CheckScale, which are one rule reached by two entry points; Exec in Exec and ExecTTY, one rule reached by two entry points like Scale's. A predicate open-coded per driver instead is a predicate that is wrong in all but one of them, in the same direction, and nobody hears the disagreement.
⚠ Isolation IS THE EXCEPTION, AND IT HAS NO BRANCH AT ALL. Every driver WRITES it; nothing in this repository READS it. It is kept because IsolationNone is a safety statement — an agent running as the muster process's own user, with its credentials — that a future CheckSpec should be able to refuse on, and that branch does not exist yet. Until it does, Isolation is a field and not a guard, and this comment says so rather than supplying it a purpose. Do not read the sentence above as covering it.
Every bool is false-by-default and false means "cannot", so a driver that forgets to declare something is treated as unable to do it. That is the safe direction: the failure is a refusal a developer sees immediately, not a silent downgrade a user discovers later. Isolation is safe in the same direction for a different reason — its zero value is IsolationNone, the LEAST isolated level, so forgetting to declare it understates isolation.
type ContainerExecer ¶ added in v0.110.0
type ContainerExecer interface {
ExecContainer(ctx context.Context, ref Ref, container string, cmd []string, stdin io.Reader, stdout, stderr io.Writer) error
}
ContainerExecer runs a command inside a NAMED container of a live instance — on Kubernetes, a container of the instance's pod other than its own, such as a KeyHolder's. OPTIONAL and type-asserted like Execer, and gated by the same capability through ExecIn.
type Endpoint ¶
type Endpoint struct {
// Scheme is "http", "https", "tcp", …. Empty means "http".
Scheme string
// Host is a hostname or address, WITHOUT a port.
Host string
// Port is the port number.
Port int
// Path is a base path, if the instance is not served at the root.
Path string
}
Endpoint is where an instance can be reached.
func ResolveEndpoint ¶
func ResolveEndpoint(override *Endpoint, tmpl EndpointTemplate, vars EndpointVars, port int, scheme string) (Endpoint, error)
ResolveEndpoint is the three-layer precedence every driver uses, stated once.
- override — the per-instance Spec.Endpoint, recorded at create time. Wins outright.
- tmpl — the driver's configured template.
- neither — ErrNoEndpoint.
port and scheme are the driver's answers for the layers the override does not supply; an override that omits them inherits them rather than being rejected, because "reach it at this host instead" is a much more common intent than "reach it at this host, on a port I will now restate".
⚠ ONE RULE, ONE PLACE. This precedence open-coded per driver is a predicate that will be subtly different in each of them, and the difference only shows up for whoever set the override.
type EndpointTemplate ¶
type EndpointTemplate struct {
// contains filtered or unexported fields
}
EndpointTemplate renders an instance's HOST from its identity.
🔴 THIS TYPE IS THE OVERRIDE THAT DID NOT EXIST. The address of an agent in the project muster was extracted from was one hardcoded format string, in one file, reachable from nowhere else — no environment variable, no config field, no per-instance override. Running an agent anywhere but that project's own cluster was therefore not expressible, and the single most valuable thing this package does is make that a parameter.
The template is text/template over EndpointVars. A driver parses one at construction, so a bad template is a startup failure naming itself rather than a per-request error.
func ParseEndpointTemplate ¶
func ParseEndpointTemplate(raw string) (EndpointTemplate, error)
ParseEndpointTemplate compiles raw. An empty raw yields a zero EndpointTemplate, which ResolveEndpoint treats as "the driver has no template and must supply a host another way".
`missingkey=error` is set so a template naming a field that does not exist fails loudly instead of rendering the string "<no value>" into a hostname — which would produce an address that resolves to nothing and an error message about DNS rather than about the template.
func (EndpointTemplate) Host ¶
func (e EndpointTemplate) Host(v EndpointVars) (string, error)
Host renders the template.
func (EndpointTemplate) IsZero ¶
func (e EndpointTemplate) IsZero() bool
IsZero reports whether no template was configured.
func (EndpointTemplate) String ¶
func (e EndpointTemplate) String() string
String returns the template source, for logs and for an operator asking what a driver is configured with.
type EndpointVars ¶
type EndpointVars struct {
// Name is the instance name.
Name string
// Group is the driver's scoping unit — a namespace, a project. Empty where
// the driver has none.
Group string
// ID is the correlation id, which may be zero. A template that depends on
// it is a template that breaks for every caller who does not set one.
ID int64
}
EndpointVars is what an endpoint template may reference.
type Execer ¶
type Execer interface {
Exec(ctx context.Context, ref Ref, cmd []string, stdin io.Reader, stdout, stderr io.Writer) error
}
Execer runs a command inside a live instance. OPTIONAL: callers type-assert for it, and Capabilities.Exec declares whether the assertion will succeed meaningfully.
⚠ A DRIVER MAY IMPLEMENT THIS AND STILL REPORT Exec FALSE. Implementing it is a compile-time fact; being able to do it can depend on runtime configuration the driver was given. Callers must consult Capabilities, not the assertion — which is what Exec (the helper below) does.
type File ¶
type File struct {
// Path is the absolute in-instance path.
Path string
// Content is the literal bytes. Not a string: this carries binaries and
// archives as readily as configuration.
Content []byte
// Mode is the file mode. Zero means "let the driver choose", which is 0644
// for a plain file and 0600 when Secret is set — stated here rather than
// left to each driver, because a secret that lands world-readable because
// one driver defaulted differently is the kind of difference nobody looks
// for.
Mode fs.FileMode
// Secret marks content that must not be visible in a non-confidential
// store. A driver whose Capabilities.Secrets is false MUST refuse a spec
// carrying one rather than downgrade it silently — see CheckSpec.
Secret bool
}
File is a file to place inside the instance before its process starts.
🔴 THIS TYPE REPLACES A SHELL-QUOTING HAZARD, AND THAT IS THE WHOLE POINT OF IT BEING DATA. In the project muster was extracted from, every file placed into an agent travelled as
printf '%s' '<base64>' | base64 -d > /path
appended to a list of init commands, wrapped in `{ … } || :` because the surrounding startup script ran under `set -e` and any bare non-zero exit was a crash loop rather than a missing file. An audit found three shapes where the guard had been missed. Every backend muster targets — a cluster, a container daemon, a directory — can place a file natively, so the content is carried here and the driver decides how. Spec.Init survives for genuinely imperative steps.
func (File) EffectiveMode ¶
EffectiveMode resolves Mode's zero value per the rule stated on the field.
type Health ¶
type Health struct {
// HTTPGetPath is the path a serving instance answers 2xx/3xx on. Empty
// means "this spec declares no health signal", and a driver then reports
// Ready from whatever its backend says about the process alone.
//
// ⚠ IT IS A PATH AND NOT A URL. The scheme is the backend's business and
// the host is the instance itself; a URL here would invite an absolute one
// pointing somewhere else entirely.
HTTPGetPath string
// PortName names the [Port] to probe. It must match a declared port's Name
// — [Spec.Validate] refuses a name that resolves to nothing, because the
// alternative is a driver silently dropping the probe and reporting the
// pre-Health behaviour under a spec that asked for better.
PortName string
}
Health is how a driver can tell a SERVING instance from a merely RUNNING one.
🔴 IT EXISTS BECAUSE Instance.Ready WAS A CLAIM NOTHING MEASURED. Phase and Ready are separate fields precisely so that "the process is up" and "it is serving" can disagree — and with no health declaration anywhere in a spec, no driver had anything to decide the second one from. Measured against the agent runtime image muster's own deployment pins: an instance whose gateway refuses to start (`Missing config`, exit 78) sat in CrashLoopBackOff reporting 0/1 indefinitely, with nothing in the cluster timing it out and nothing in muster saying why. The crash was loud in `kubectl logs` and invisible everywhere a person actually looks.
🔴 IT DECLARES A PROPERTY OF THE INSTANCE, NOT A BEHAVIOUR ASKED OF THE DRIVER, WHICH IS WHY IT HAS NO Capabilities GATE. "This instance answers HTTP GET <path> on port <name> when it is serving" is a fact about what is inside, in the same way Spec.Ports is — and Ports has no capability bit either. A driver with no supervision concept ignores it; a driver that has one translates it into its own idiom, with its own timings, because a period and a failure threshold are shaped by the backend and a portable spelling of them here would be a second, wrong authority (the argument Resources makes for keeping quantities as strings).
⚠ THERE IS DELIBERATELY NO WAY TO SAY "DO NOT PROBE ME" OTHER THAN LEAVING HTTPGetPath EMPTY, and no separate readiness/liveness split. Both were considered and both are knobs whose only use is to make a non-serving instance look fine again, which is the state this type exists to end.
type Instance ¶
type Instance struct {
// Ref identifies it. Name is always set; ID is set only if the driver
// recorded one at create time.
Ref Ref
// Driver is the name of the driver reporting this.
Driver string
// Group is the driver's own scoping unit — a namespace, a compose project,
// a directory. Empty where the concept does not apply.
Group string
// InstanceID is the backend's own name for the running thing: a pod name, a
// container id, a pid. It changes when the process is replaced, and callers
// use that fact.
InstanceID string
// Phase is the coarse state.
Phase Phase
// Ready reports whether the instance is serving, as distinct from running.
Ready bool
// Replicas is how many are currently up.
Replicas int
// Restarts is the cumulative restart count.
Restarts int32
// Reason is why the instance is NOT running now, when it is not — a waiting
// or pending reason.
Reason string
// RestartReason is why the instance LAST DIED, for one that has since come
// back ("OOMKilled", "Error", …), or "" when nothing has terminated.
//
// 🔴 IT IS DELIBERATELY DISTINCT FROM Reason AND MUST NOT BE FOLDED INTO
// IT. An out-of-memory kill is invisible in every other field once the
// supervisor restarts the process: the instance reads running and ready,
// with a bumped restart count, and nothing anywhere says WHY. This field is
// the only signal that says an agent is simply too small for the repository
// it was given, which is the difference between a useful message and a
// mysteriously slow agent.
RestartReason string
// Image is the image reference the running instance's application
// container was started from, as the backend reports it (for Kubernetes,
// the newest pod's spec image of its one application container), or ""
// when the driver does not report one or no instance is running. It is
// what lets a caller report which image a restart brought the instance up
// on (chief_restart); comparing it with the configured image is the
// caller's business.
Image string
}
Instance is one instance's live state, as the driver currently observes it.
type Isolation ¶
type Isolation int
Isolation is how well a driver separates an instance from the machine it runs on. It is ordered, so a caller can compare.
const ( // IsolationNone — the instance runs as the muster process's own user, in its // filesystem, with its credentials. // // 🔴 A DRIVER THAT REPORTS THIS IS A DEVELOPMENT DRIVER AND MUST BE // PRESENTED AS ONE. A prompt-injected agent under IsolationNone is a // prompt-injected agent with your ssh keys. Any interface that shows // instances should say so, on every instance, whenever their driver reports // it — not once in a settings page. IsolationNone Isolation = iota // IsolationProcess — a separate process with some kernel-level confinement, // but a shared filesystem and user. IsolationProcess // IsolationContainer — its own filesystem, process table and user, sharing // the host kernel and a flat namespace of container names. IsolationContainer // IsolationNamespace — a container plus a scoping unit the driver owns // entirely, so a teardown can delete the unit rather than enumerate objects. IsolationNamespace )
type KeyHolder ¶ added in v0.110.0
type KeyHolder struct {
// Name names the container: a DNS label, not the instance's own container's
// or a sidecar's.
Name string
// RunAsUser is the holder's uid (and gid): non-zero, and not the instance's.
RunAsUser int64
// Command is what the holder runs, with the instance's image. Required: a
// holder has no other entry point.
Command []string
// Env and Files are the holder's own (Files are placed in it alone; their
// paths must not repeat the instance's or a sidecar's).
Env []EnvVar
Files []File
// SecretMounts place keys of the operator's objects into the holder,
// read-only. At least one: a holder that holds nothing has no reason to
// exist.
SecretMounts []SecretMount
// writable by the holder and mounted READ-ONLY at the same path into the
// instance's container.
SharedDir string
// Resources is the holder's own budget.
Resources Resources
}
KeyHolder is a container beside the instance's that alone mounts operator-made secrets (SecretMounts) and does the work that needs them, handing the instance only the RESULT through a shared directory. On Kubernetes: a second container in the pod, under its own runAsUser.
🔴 THE INSTANCE'S PROCESS CANNOT READ WHAT IT HOLDS — AND THAT IS THE WHOLE POINT OF IT. The guarantee is structural, not a file mode:
- the secret volumes are mounted into THIS container only, so the file does not exist in the instance's mount namespace at any mode;
- it runs as RunAsUser, which Validate requires to differ from the instance's (non-zero) Security.RunAsUser, non-root, without privilege escalation;
- the pod shares no process namespace (the driver never sets one), so the instance cannot reach its /proc/<pid>/root, environ or memory;
- SharedDir is writable HERE and mounted READ-ONLY into the instance's container, so the instance cannot plant anything this container reads. It is NOT the workspace, which the instance writes; this container never mounts the workspace.
It is reached by exec into the named container (ContainerExecer), so only whoever can exec into the pod — muster — can ask it to do anything; the instance has no channel to it.
type Network ¶
type Network struct {
// Isolate asks the backend to confine the instance:
//
// - inbound: only the instance's declared [Spec.Ports], and only from
// whatever the driver is configured to treat as its controller (muster
// itself);
// - outbound: name resolution (unless NoClusterDNS), plus
// PublicEgressTCPPorts on public addresses and ControllerEgressTCPPorts
// on the controller. Nothing else.
Isolate bool
// PublicEgressTCPPorts are the TCP ports the instance may reach on public
// addresses. Empty with Isolate set means "name resolution only".
//
// ⚠ SETTING IT WITHOUT Isolate IS REFUSED by [Spec.Validate]: a port list on
// an unconfined instance is an allow-list that allows nothing it was not
// already allowed, and reads like confinement.
PublicEgressTCPPorts []int
// ControllerEgressTCPPorts are the TCP ports the instance may reach on its
// CONTROLLER — muster's own pods, selected exactly as the inbound rule selects
// them. It exists for muster's agent-facing connector surface, which an
// isolated agent reaches on a dedicated port; nothing else of muster's is
// reachable through it.
//
// ⚠ SETTING IT WITHOUT Isolate IS REFUSED, for PublicEgressTCPPorts' reason.
ControllerEgressTCPPorts []int
// NoClusterDNS drops the name-resolution allowance: the backend writes NO
// rule for the cluster's DNS, so the instance resolves nothing unless the
// cluster's own policy allows it.
//
// 🔴 IT EXISTS SO A NAME-FILTERED DNS POLICY CAN MEAN SOMETHING. Network
// plugins union allows: an L4 "port 53 to the DNS pods" rule written here,
// next to a cluster-side DNS rule that allows only some names (Cilium's DNS
// proxy with rules.dns), widens that rule back to "any name" — and any name
// is a DNS tunnel. An instance with this set depends on the operator's
// policy for DNS entirely; without one it cannot resolve a name (closed,
// loud).
//
// ⚠ SETTING IT WITHOUT Isolate IS REFUSED, for PublicEgressTCPPorts' reason.
//
// omitempty: every spec that keeps cluster DNS marshals byte-identically to
// before the field existed (the agentspec goldens pin that).
NoClusterDNS bool `json:",omitempty"`
}
Network is the instance's network confinement, as a property of what runs inside it: who may reach it, and what it may reach.
🔴 THE ZERO VALUE IS "DECLARE NOTHING", FOR THE REASON Security'S IS. Every spec built before this type existed carried no such field; a driver renders a zero Network exactly as it rendered those, and Fingerprint writes nothing for it, so introducing the type moved no existing instance's fingerprint.
🔴 UNLIKE Health, IT IS A BEHAVIOUR ASKED OF THE DRIVER, SO IT HAS A Capabilities GATE. A driver that ignored Isolate would start an instance that LOOKS confined — the declaration is on the spec, the card says the kind is the confined one — and can reach everything. CheckSpec refuses it instead (Capabilities.NetworkIsolation).
⚠ WHAT "PUBLIC" MEANS IS THE DRIVER'S TO SPELL, in its own address-range idiom, for the reason Resources keeps quantities as strings. What is portable is the intent: the instance may open TCP connections on these ports to the public internet, and to nothing private — not the backend's own control plane, not its neighbours, not the operator's LAN.
type Noop ¶
type Noop struct {
// contains filtered or unexported fields
}
Noop is a provisioner that records instead of provisioning.
What it is for ¶
Developing and testing everything ABOVE the provisioner without a backend: the interface renders, the lifecycle transitions happen, the state is real and queryable. The project muster was extracted from had one of these and it proved the separation was genuine — a struct of methods returning nil satisfied that project's entire agent interface.
What is different here, and why ¶
That original had four defects this one exists to not have:
- It took a DATABASE ROW ID and loaded the row itself, so a second driver would have needed its schema. This one takes Ref and is exercised with Ref.ID zero.
- It carried the CONVERSATION with the agent — chat, and a tool-calling variant returning a sentinel that named a specific image version. There is no such method on Provisioner at all, so there is none here.
- It declared NO CAPABILITIES, and its Destroy was a bare `return nil` — indistinguishable from success, the "declared but inert" shape. This one declares capabilities that its own CheckSpec calls enforce, and its Destroy actually removes state, so Provisioner.Get afterwards returns ErrNotFound and the nil is a claim about something.
- Its real contract was NINE THINGS WIDER than the declared one — seven setters wired by concrete type plus two type-asserted interfaces. The optional surface here is the exec interfaces, routed through Exec and ExecTTY so the capability branch cannot be skipped.
Blind mode ¶
NoopBlind makes List and Get return ErrBlind. That is not a fault injector bolted on for tests — it is the shape the original had, and it was right: its pod lister returned an error rather than an empty slice specifically so callers fell back to STORED state instead of recomputing it from nothing and flipping every instance to stopped. Blind mode is how that behaviour stays available to anyone developing against the fake, and how provisiontest.RunContract exercises the rule on a driver whose backend it can actually take away.
func MustNewNoop ¶
func MustNewNoop(opts ...NoopOption) *Noop
MustNewNoop is NewNoop for callers with static options, where a failure is a programming error rather than a condition.
func NewNoop ¶
func NewNoop(opts ...NoopOption) (*Noop, error)
NewNoop builds a recording provisioner.
func (*Noop) Capabilities ¶
func (n *Noop) Capabilities() Capabilities
Capabilities implements Provisioner.
func (*Noop) Destroy ¶
Destroy implements Provisioner.
🔴 THE nil IS A CLAIM. It is returned when the instance was removed from the store, or when it was not in the store to begin with — and in both cases a subsequent Get returns ErrNotFound, which is the property the contract test asserts. The version this replaces returned nil having done nothing.
func (*Noop) StreamLogs ¶
StreamLogs implements Provisioner. The recorded log is finite, so the stream ends rather than following — and it ends by RETURNING, not by blocking until the context is cancelled, because a caller that cannot distinguish "the stream finished" from "nothing will ever arrive" has no way to show either.
type NoopOption ¶
NoopOption configures a Noop.
func NoopBlind ¶
func NoopBlind() NoopOption
NoopBlind makes List and Get report ErrBlind. See the type's note.
func NoopCapabilities ¶
func NoopCapabilities(c Capabilities) NoopOption
NoopCapabilities overrides what the driver declares it can do. Used to build a deliberately restricted fake, which is how the capability refusals in CheckSpec get exercised against a driver that really does refuse.
func NoopClock ¶
func NoopClock(now func() time.Time) NoopOption
NoopClock injects the clock used for log timestamps, so a test can assert on a log line's whole content rather than on a prefix of it.
func NoopEndpointTemplate ¶
func NoopEndpointTemplate(raw string) NoopOption
NoopEndpointTemplate overrides the host template.
type Phase ¶
type Phase string
Phase is an instance's coarse lifecycle state, spelled the same way by every driver so a caller can switch on it.
const ( // PhasePending — accepted, not yet running. PhasePending Phase = "pending" // PhaseRunning — the process is up. Ready says whether it is serving. PhaseRunning Phase = "running" // PhaseSucceeded — the process exited zero and is not expected back. PhaseSucceeded Phase = "succeeded" // PhaseFailed — the process exited non-zero and is not expected back. PhaseFailed Phase = "failed" // PhaseStopped — deliberately scaled to zero. Distinct from Failed, because // conflating them is how a stop gets reported as an outage. PhaseStopped Phase = "stopped" // PhaseUnknown — the driver reached its backend but could not classify what // it found. NOT the same as being unable to reach it, which is an error. PhaseUnknown Phase = "unknown" )
type Port ¶
type Port struct {
// Name identifies the port to Endpoint. The name muster's own callers look
// for is DefaultPortName.
Name string
// Port is the container/process port number.
Port int
// Protocol is "TCP" or "UDP". Empty means TCP.
Protocol string
}
Port is a network port the instance listens on.
type Provisioner ¶
type Provisioner interface {
// Driver returns the driver's short name ("noop", "kubernetes"). It appears
// in Instance.Driver and in error messages, and it is how an operator knows
// which set of capability losses applies to what they are looking at.
Driver() string
// Capabilities declares what this driver can do. Callers MUST branch on
// it, and the branches live in this package — Capabilities' own doc
// comment is the single authority on which capability is refused where.
// This line used to enumerate them as "CheckSpec and Grant", which omitted
// CheckScale and Exec (and Grant is gone with the policy capability); the
// enumeration exists once, there, because a stale copy of it reads exactly
// like a complete one.
Capabilities() Capabilities
// Create brings the instance into existence.
//
// It is IDEMPOTENT for an identical spec: calling it twice succeeds twice
// and leaves one instance. Called for an existing instance with a
// materially different spec it returns ErrDivergentSpec and changes
// nothing — the caller that wanted the change has Update and can say so.
Create(ctx context.Context, spec Spec) error
// Update reconciles an existing instance to spec. Unlike Create it is
// explicit about overwriting. An instance that does not exist yet is
// created, because "make it look like this" has an obvious answer when
// there is nothing there.
Update(ctx context.Context, spec Spec) error
// Scale sets the instance's replica count. Zero is a stop and is expected
// to be reversible: the instance's declaration survives, its processes do
// not.
Scale(ctx context.Context, ref Ref, replicas int) error
// Destroy removes the instance and everything the driver created for it.
//
// 🔴 IT RETURNS nil ONLY IF THE INSTANCE WAS REMOVED OR WAS ALREADY ABSENT.
// Anything else — a partial teardown, an unreachable backend, an object
// that survived the delete — is an error. A `return nil` that means "I did
// not try" is the defect this sentence exists to forbid.
//
// 🔴 A FOREIGN OBJECT UNDER THE INSTANCE'S NAME IS NOT "ALREADY ABSENT",
// AND IT IS NOT nil. On a shared backend a name is not an identity:
// something the driver did not create can already hold the name, and a
// teardown that proceeded by name alone would delete a stranger's objects
// and report success. A driver on such a backend MUST return
// [ErrNotManaged] — and must NOT make that error satisfy
// errors.Is(err, ErrNotFound), because `if err != nil && !errors.Is(err,
// ErrNotFound)` is the idiom this contract invites and it would discard the
// refusal. Which objects count as the instance's identity is the driver's
// call; the kubernetes driver's Destroy doc states its answer.
//
// 🔴 AN OWNERSHIP REFUSAL FROM Destroy MEANS NOTHING WAS REMOVED, AND IT IS
// TERMINAL. A driver must check every object it treats as the instance's
// identity BEFORE it deletes anything, so the two outcomes are the only two
// there are: the instance is gone (nil), or the backend is exactly as it
// was (ErrNotManaged). A driver that removed the instance and THEN reported
// a permanent refusal leaves a caller unable to tell which happened — and
// "retry Destroy until it returns nil" never terminates, because the
// refusal is about state only an operator can change. The kubernetes driver
// had that defect where an instance's own objects were muster's and its
// per-instance NAMESPACE was a stranger's: three consecutive Destroys
// returned the same ErrNotManaged with the instance already torn down. It
// now refuses first and removes nothing, so the pod keeps running until the
// namespace is relabelled or removed. Callers branch on the SENTINEL: retry
// [ErrBlind], surface [ErrNotManaged] to a human, treat nil as done.
Destroy(ctx context.Context, ref Ref) error
// List returns every instance this driver manages.
//
// 🔴 ERROR, NEVER AN EMPTY SLICE, WHEN THE BACKEND CANNOT BE SEEN. Wrap
// ErrBlind. An empty slice is a positive claim that there is nothing there.
List(ctx context.Context) ([]Instance, error)
// Get returns one instance. ErrNotFound when the backend was reached and
// does not have it; ErrBlind when the backend could not be reached. Those
// are different answers and must not be collapsed.
Get(ctx context.Context, ref Ref) (Instance, error)
// Endpoint returns where the instance can be reached.
//
// 🔴 THIS METHOD IS THE POINT OF THE INTERFACE'S EXISTENCE AS MUCH AS
// ANYTHING ELSE ON IT. In the project muster was extracted from, this was a
// hardcoded format string in one file, with no override of any kind, which
// meant running an agent anywhere other than that project's own cluster was
// not expressible. Drivers resolve Spec.Endpoint first, then their own
// configured template, then a default — and every layer of that is settable
// from outside the driver.
Endpoint(ctx context.Context, ref Ref) (Endpoint, error)
// StreamLogs follows the instance's output, calling emit once per line,
// until ctx is cancelled or the stream ends. emit is called from the
// calling goroutine's stream and must not block indefinitely.
StreamLogs(ctx context.Context, ref Ref, emit func(line string)) error
}
Provisioner is the lifecycle of an instance: create it, observe it, reach it, read its output, destroy it.
🔴 READ THE FOUR CONTRACT RULES IN THE PACKAGE DOC BEFORE IMPLEMENTING THIS. They are behavioural, they are not inferable from the signatures, and provisiontest.RunContract will fail a driver that breaks any of them.
Note what is absent: nothing here talks TO the instance. No chat, no tool loop, no protocol. That absence is the reason a second driver is writable at all.
type Ref ¶
type Ref struct {
// Name is the instance's stable identity. It is expected to be
// DNS-label-safe because several drivers use it directly as an object,
// container or directory name; Validate enforces that rather than leaving
// each driver to discover it.
Name string
// ID is an optional correlation id from whatever system asked for this
// instance. Drivers may surface it in labels or logs. Nothing may depend on
// it being non-zero, and nothing may look it up.
ID int64
}
Ref identifies one provisioned instance.
🔴 Name IS THE KEY. ID IS A CORRELATION HINT AND MAY BE ZERO. In the project muster was extracted from, the lifecycle methods took an `agentID int64`, loaded the row themselves, and decided from its contents what to do — which meant a second driver would have needed that project's Postgres schema to create a container. Ref is the fix: a driver may use ID to label or log, and MUST NOT require it. Every driver in this repository is exercised with ID zero by provisiontest.RunContract for exactly that reason.
type Repo ¶
type Repo struct {
// URL is the clone URL. It must NOT carry credentials; a driver that finds
// a userinfo component in it refuses the spec (see CheckSpec), because a
// URL is the one field of a spec that reliably ends up in a log.
URL string
// Branch is the ref to check out. Empty means the repository's default.
Branch string
// Path is where the instance should expect the checkout. Empty means the
// driver's default, under the workspace.
Path string
}
Repo is the source repository the instance is meant to work in.
⚠ NOTHING IN THIS PACKAGE CLONES IT, AND THAT IS A DELIBERATE NARROWING. In the project muster was extracted from, the deployment template cloned the repository itself, roughly 250 lines BEFORE the init commands ran — which is why that project's credential handling had to work in two different environments at once and grew a documented fallback to survive it. Here the repository is DECLARED, passed to the instance as environment, and cloned by the instance's own runtime or by an explicit Init step. The driver's job ends at making the declaration and the credential available.
type Resources ¶
Resources is the instance's compute budget. Values are strings in the units the driver understands ("512Mi", "2", "1500m"); they are passed through rather than parsed here, because the set of legal spellings is a property of the backend and a parser in this package would be a second, wrong authority.
Empty fields mean "unset" and the driver applies no limit of its own. A driver whose Capabilities.ResourceLimits is false refuses a spec that sets any of them — silently running an agent with no ceiling is how a box gets taken out by one repository that was bigger than the last one.
type Runtime ¶
type Runtime struct {
// Image is a container image reference. Empty for a driver that runs a
// command directly.
Image string
// Command overrides the image's entrypoint, or IS the thing to run when
// there is no image.
Command []string
// Args are appended after Command (or after the image's entrypoint when
// Command is empty).
Args []string
// WorkingDir is the process's cwd. Empty means the runtime's default.
WorkingDir string
}
Runtime is what the instance actually runs.
🔴 IT IS A UNION OF Image AND Command, AND BOTH HALVES ARE LOAD-BEARING. An image-only Runtime cannot express a local-process driver, which has no images at all; a command-only Runtime cannot express the container case, where the image supplies its own entrypoint and the caller wants exactly that. Requiring both would make every caller invent one of them. So: at least one must be set, which is what Validate checks, and a driver refuses the half it cannot honour through CheckSpec rather than by ignoring it.
type SecretMount ¶ added in v0.110.0
type SecretMount struct {
// Secret names the object (a DNS subdomain).
Secret string
// Key is the key within it.
Key string
// Path is the absolute in-instance file path.
Path string
}
SecretMount places one key of an EXISTING confidential object at Path inside a KeyHolder, read-only: on Kubernetes, a key of a Secret in the instance's namespace, mounted from a secret volume into the holder's container only.
🔴 IT IS A REFERENCE, AND MUSTER NEITHER STORES NOR LOGS WHAT IT NAMES. Unlike a secret File, whose bytes are in the spec, the content stays in the operator's object, which a driver never changes or deletes. A driver MAY copy it, data and type only, from a namespace the operator keeps it in into the instance's (the kubernetes driver's Config.SecretSourceNamespace); that copy passes through the driver's memory and is written nowhere else. A source that does not exist then fails the apply, naming it; without a copy, a Secret that does not exist leaves the pod unable to start (the kubelet's FailedMount).
It is a field of KeyHolder, never of the Spec itself: a type that cannot place it into the instance's container is what keeps it out of there.
type Security ¶
type Security struct {
// RunAsUser, RunAsGroup and FSGroup are numeric ids; 0 = unset.
RunAsUser int64
RunAsGroup int64
FSGroup int64
// RunAsNonRoot asks the backend to refuse to start the process as root.
RunAsNonRoot bool
// Restricted drops every capability, forbids privilege escalation and uses
// the runtime's default seccomp profile.
Restricted bool
// NoServiceAccountToken keeps the backend's own API credential out of the
// instance (Kubernetes: automountServiceAccountToken false).
NoServiceAccountToken bool
}
Security is the instance's process isolation, as a property of what runs inside it (the image's uid, whether it needs cluster credentials).
🔴 THE ZERO VALUE IS "DECLARE NOTHING", AND THAT IS WHAT EVERY SPEC CARRIED BEFORE THIS TYPE EXISTED. A driver renders a zero Security exactly as it rendered a spec with no such field, and Fingerprint writes nothing for it, so introducing the type moved no existing instance's fingerprint and rolled no pod.
⚠ A ZERO ID MEANS UNSET, NOT ROOT. Nothing muster builds asks to run as uid 0 explicitly, so the type does not spend a pointer on expressing it.
type Sidecar ¶
type Sidecar struct {
// Name names the container. A DNS label, and not the instance's own
// container's name.
Name string
// Runtime is what the sidecar runs. Image is required: a sidecar is a
// container.
Runtime Runtime
// Env, Secrets and Files are as Spec's, for the sidecar alone. File paths
// must not repeat the instance's.
Env []EnvVar
Secrets []EnvVar
Files []File
// Resources is the sidecar's own budget.
Resources Resources
}
Sidecar is a second long-running process in the same instance: on Kubernetes a second container in the same pod.
⚠ NO SPEC muster BUILDS CARRIES ONE NOW: its one user, the gateway runtime beside a claude-code chief's ccd, was removed from agentspec. The support stays because applying a spec WITHOUT a sidecar is what takes one away from an instance built with it — the k8s driver drops the container and deletes the stale `<name>-sidecar-env` Secret. CLOSING CONDITION: remove it once no agent pod has a second container (every claude-code chief Stop → Started on a muster without the sidecar).
🔴 IT SHARES THE INSTANCE'S NETWORK NAMESPACE AND NOTHING ELSE, ON PURPOSE. Same network: the instance's own process reaches it on loopback, so a sidecar needs no port of its own and declares none — it is never exposed (no Service port, no NetworkPolicy ingress rule names it). NOT the workspace: the volume is the instance's, and whatever the sidecar writes there (a runtime's own credential store, say) would be readable by the instance's process; its state lives in its own container and is lost with the pod. Its environment, confidential environment and files are ITS OWN: the instance's Secrets are not exported into the sidecar, nor the sidecar's into the instance — each process holds only the credentials it uses. Security and Network are the instance's and apply to both processes.
type Spec ¶
type Spec struct {
// Ref is the instance's identity. Required.
Ref Ref
// Runtime is what runs. Required (see the type's own note on the union).
Runtime Runtime
// Env is non-sensitive environment.
Env []EnvVar
// Secrets is sensitive environment. Kept separate from Env rather than
// flagged inside it so that a driver CANNOT accidentally treat the two the
// same: the type system makes the confidential set enumerable.
Secrets []EnvVar
// Files are placed before the process starts. See File.
Files []File
// Init are imperative steps to run before the main process, in order.
//
// ⚠ KEEP THIS FOR THINGS THAT ARE GENUINELY IMPERATIVE. It is a shell
// contract and therefore the least portable field in the spec: every entry
// is a string some shell has to parse. Placing content belongs in Files,
// where it is data and can be asserted on.
Init []string
// Resources is the compute budget.
Resources Resources
// Workspace is the working storage.
Workspace Workspace
// Repo is the declared source repository. See the type's note: declared,
// not cloned.
Repo Repo
// Config is OPAQUE to the provisioner. Whatever runtime ends up inside the
// instance gets it verbatim; no driver may interpret a key of it, and no
// driver may fail because of its contents. It exists so that runtime-specific
// configuration does not have to become provisioner-specific fields — the
// exact pressure that grew the original project's value map to a shape only
// one template could read.
Config map[string]any
// Ports the instance listens on.
Ports []Port
// Health is how a driver tells serving from running. See the type.
Health Health
// Security is the instance's process isolation. See the type.
Security Security
// Network is the instance's network confinement. See the type.
Network Network
// Endpoint, when non-nil, is the address callers should use to reach this
// instance, OVERRIDING whatever the driver would compute.
//
// 🔴 THIS FIELD IS THE POINT OF THE WHOLE Endpoint DESIGN. The address in
// the original project was a hardcoded format string with no override
// anywhere — not an environment variable, not a config field, not a
// per-instance one — so reaching an agent through anything other than that
// project's own cluster DNS was not expressible. There are now three
// layers: this, the driver's configurable template, and the driver's
// default.
Endpoint *Endpoint
// Replicas is the desired instance count. Zero means one; use Scale to stop
// something, which keeps "I did not think about replicas" and "I want this
// stopped" from being the same value.
Replicas int
// Labels are attached to whatever objects the driver creates, for the
// operator's own selection. Drivers add their own and MUST NOT let these
// overwrite them.
Labels map[string]string
// Sidecar, when non-nil, is a second process run BESIDE the instance's own,
// sharing its network and its workspace, and nothing else. See the type.
//
// ⚠ omitempty, so a spec without one serialises exactly as before the field
// existed (agentspec's spec golden is a json.Marshal of a Spec).
Sidecar *Sidecar `json:",omitempty"`
// KeyHolder, when non-nil, is a container that ALONE holds confidential
// objects the OPERATOR made, under a uid that is not the instance's. See
// the type.
//
// ⚠ omitempty, for Sidecar's reason: a spec without one serialises exactly
// as before the field existed.
KeyHolder *KeyHolder `json:",omitempty"`
// ImagePullSecret, when set, names a registry credential the instance's
// image is pulled with: on Kubernetes, a `kubernetes.io/dockerconfigjson`
// Secret listed in the pod's imagePullSecrets. Like a [SecretMount] it is a
// REFERENCE to an object the operator made; muster never stores what it
// holds. A driver MAY copy it, its `.dockerconfigjson` key and type only,
// from a namespace the operator keeps it in (the kubernetes driver's
// Config.SecretSourceNamespace), and then refuses the apply when the source
// is missing, lacks that key, or is of another type. A DNS subdomain.
// Needs [Capabilities.ImagePullSecret].
//
// ⚠ omitempty, for Sidecar's reason: a spec without one serialises exactly
// as before the field existed.
ImagePullSecret string `json:",omitempty"`
}
Spec is the complete desired state of one instance.
It is the genericised form of what the original project assembled as a map of chart values: the same information, minus every field that only one specific deployment template understood, plus Config for everything that does not generalise.
func (Spec) DesiredReplicas ¶
DesiredReplicas resolves Replicas' zero value per the rule stated on the field.
func (Spec) PortNumber ¶
PortNumber resolves the port named `name` from the spec, falling back to DefaultPortName and then to the single declared port when there is exactly one. It returns 0 when nothing matches, which callers treat as "this instance declares no reachable port" rather than as an error.
type TTYExecer ¶
type TTYExecer interface {
ExecTTY(ctx context.Context, ref Ref, cmd []string, stdin io.Reader, stdout io.Writer, resize <-chan TermSize) error
}
TTYExecer runs a command inside a live instance ON A TERMINAL: the command gets a pseudo-terminal, its stdout and stderr arrive merged on stdout (that is what a terminal is), and every size sent on resize is applied to it. OPTIONAL and type-asserted, exactly like Execer, and gated by the SAME capability — Capabilities.Exec — through ExecTTY. A driver that declares Exec must implement both; provisiontest.RunContract fails one that does not.
ExecTTY returns when the command exits, when stdin reaches EOF and the command exits because of it, or when ctx is cancelled — whichever is first. 🔴 ctx CANCELLATION MUST END IT. A caller bridging a browser socket cancels ctx when the socket closes, and a driver that kept the stream open after that would leave a goroutine in muster for every closed tab.
🔴 ENDING THE STREAM DOES NOT END THE COMMAND. Measured on containerd (the kubernetes driver, 2026-10-10): after the exec stream was cancelled the command — a tmux client — was still running in the container, with its pty, more than 60 s later; the runtime signals it nothing. A caller whose command must not outlive the stream has to end it itself, with a second exec (agentprovision's AttachTerminal does).
resize may be nil (the terminal keeps the driver's default size). The driver stops reading it when ExecTTY returns; it never closes it.
type TermSize ¶
type TermSize struct {
Cols, Rows uint16
}
TermSize is a terminal's size in character cells.
type Workspace ¶
type Workspace struct {
// Path is where it is mounted. Empty means the driver's default.
Path string
// Size is the requested capacity ("20Gi"). Ignored when Persist is false.
Size string
// Persist asks for storage that outlives the instance's process. A driver
// whose Capabilities.Persistence is false refuses a spec that sets it,
// because "your work was saved" and "your work was in a tmpfs" are not a
// difference to discover after a restart.
Persist bool
}
Workspace is the instance's working storage.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compose is the provisioner driver for the chief on the public `docker compose` install: a container the Compose file declares (the `chief` service, `--profile chief`), configured by FILES this driver writes into a named volume the two containers share.
|
Package compose is the provisioner driver for the chief on the public `docker compose` install: a container the Compose file declares (the `chief` service, `--profile chief`), configured by FILES this driver writes into a named volume the two containers share. |
|
Package k8s provisions muster instances onto a Kubernetes cluster by rendering its own minimal manifests.
|
Package k8s provisions muster instances onto a Kubernetes cluster by rendering its own minimal manifests. |
|
Package provisiontest is the CONTRACT SUITE every muster provisioner driver must pass.
|
Package provisiontest is the CONTRACT SUITE every muster provisioner driver must pass. |