Documentation
¶
Overview ¶
Package materialise executes a spec's materialise block against a provisioned workspace, in the one fixed order the handoff specifies:
ports -> files -> commands -> services -> health -> escape
The order 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.
Index ¶
- func ManagedSpec(path string) (*fleet.Spec, string, string, error)
- func RenderPlan(spec *fleet.Spec, res *Result) string
- func TCPDial(addr string, timeout time.Duration) error
- type Dialer
- type Engine
- func (e *Engine) DestroyManaged(name string, retryUncertain bool) error
- func (e *Engine) PlanManaged(specPath, name string) (*fleet.Spec, *Result, string, error)
- func (e *Engine) Run(spec *fleet.Spec, repoRoot, name string) (*Result, error)
- func (e *Engine) RunManaged(specPath, name, trust string) (*Result, error)
- func (e *Engine) StopManaged(name string, retryUncertain bool) error
- func (e *Engine) Supervise(spec *fleet.Spec, name string) (string, error)
- func (e *Engine) TickManaged() error
- type Executor
- type FileSystem
- type HTTPProber
- type OSFileSystem
- type Prober
- type Result
- type ShellExecutor
- type Step
- type StrictHTTPProber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ManagedSpec ¶
ManagedSpec reads one bounded exact source. The hash binds shell authority to the bytes reviewed by the operator, not merely a path or parsed shape.
func RenderPlan ¶
RenderPlan prints a run's steps as a stable, ordered plan — the dry run's output and the golden file's shape.
Types ¶
type Dialer ¶
Dialer answers whether something is listening. Supervision uses it, and a test can substitute one rather than binding real ports.
type Engine ¶
type Engine struct {
Prov *workspace.Provisioner
FS FileSystem
Exec Executor
Prob Prober
// Dial reports whether something is listening; supervision uses it.
Dial Dialer
// Settle is how long a freshly started service gets to bind its port before
// supervision calls it dead. Zero means the package default.
Settle time.Duration
// DryRun records what would happen without starting services or running the
// escape hatch. Commands and probes are recorded, never executed.
DryRun bool
}
Engine materialises workspaces for one relay home.
func New ¶
func New(prov *workspace.Provisioner) *Engine
New returns an Engine backed by the real filesystem, shell and network.
func (*Engine) DestroyManaged ¶
DestroyManaged is explicitly requested, clean-worktree-only teardown. Each completed command is checkpointed; an uncertain command is never implicit.
func (*Engine) PlanManaged ¶
func (*Engine) Run ¶
Run executes the materialise block in its fixed order. It is idempotent (D3): allocated ports are reused, commands whose cache_key is unchanged are skipped, and services already up are left alone.
func (*Engine) RunManaged ¶
RunManaged is the only entrypoint that executes a newly managed spec. It atomically provisions and binds exact-hash trust, then runs the engine.
func (*Engine) StopManaged ¶
StopManaged never guesses whether a hook ran after a crash. An unresolved intent requires an explicit retry-uncertain operator decision.
func (*Engine) Supervise ¶
Supervise re-checks every supervised service in the spec and records the resulting state.
The managed-workspace cadence uses the same check and may restart within a persisted budget; this one-shot method remains useful to explicit callers. A workspace that was ready and whose service has since died must stop reading ready — and one that was marked unhealthy by this very check must be able to read ready again once the service answers, or the first blip would condemn it forever.
func (*Engine) TickManaged ¶
TickManaged makes one bounded pass over every armed workspace. The daemon calls it on a fixed cadence; the per-workspace lock serializes shell effects against stop/destroy and other managers.
type Executor ¶
type Executor interface {
Run(dir string, env []string, cmdline string, timeout time.Duration) ([]byte, error)
}
Executor runs one shell command line in a directory with an environment.
type FileSystem ¶
type FileSystem interface {
ReadFile(path string) ([]byte, error)
WriteFileWithin(root, relative string, b []byte, perm fs.FileMode) error
// Resolve returns the path with every symlink followed, so a source policy
// judges where a file really is rather than where a link says it is.
Resolve(path string) (string, error)
}
FileSystem is the small surface the engine needs: read a source, write a file that must stay inside a workspace root. It is an interface so the test suite can substitute a recorder and assert "no filesystem writes occurred".
type HTTPProber ¶
type HTTPProber struct{}
HTTPProber polls a URL until it answers below 500 or the timeout expires. A connection refused early in a service's startup is expected, not fatal — the probe's job is to decide when the workspace is usable, so it retries until the deadline rather than failing on the first attempt.
type OSFileSystem ¶
type OSFileSystem struct{}
OSFileSystem is the real filesystem.
func (OSFileSystem) WriteFileWithin ¶
type Result ¶
type Result struct {
Workspace *workspace.Record `json:"workspace"`
Steps []Step `json:"steps"`
State string `json:"state"`
Failed []string `json:"failed_probes,omitempty"`
}
Result is one materialisation's outcome.
type ShellExecutor ¶
type ShellExecutor struct{}
ShellExecutor runs command lines through `sh -c`, which is what a declared `run` string means. A timeout of 0 means no timeout.
type Step ¶
type Step struct {
Stage string `json:"stage"`
Action string `json:"action"`
Detail string `json:"detail"`
Skipped bool `json:"skipped,omitempty"`
Reason string `json:"reason,omitempty"`
}
Step is one recorded action. A run returns its steps in execution order, which is what the dry run prints and what the tests assert against.
type StrictHTTPProber ¶
type StrictHTTPProber struct{}
StrictHTTPProber is used by the opt-in managed path. An HTTP 404 is a responding server, but not a healthy declared endpoint. The one-shot legacy path retains its established below-500 behavior for compatibility.