substrate

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package substrate defines the confinement-substrate sub-interface: the seam beneath runner.Runner that lets a non-OCI microVM VMM back a Confinement Class alongside the OCI/Docker substrate.

A Substrate brings up + tears down one governed sandbox. Every Substrate MUST: prove confined egress rather than merely assert it (L0 structural or L1 network-policy, see ClassSupport.NetworkPolicy); advertise NO Confinement Classes if it can prove neither, except behind an explicit, still-warning operator opt-out that MUST keep advertising StructuralEgress=false, NetworkPolicy=false so it never reads as confined on /healthz; error from CreateSandbox BEFORE creating anything, never silently downgrade, when the demanded class can't be enforced; never let the run token/secrets reach the agent's environment; make teardown idempotent and reconstructable from the run id.

Index

Constants

View Source
const RemotePrefix = "runner:"

RemotePrefix starts the Name of every substrate that reaches a registered runner ("runner:<id>"), and every ref such a substrate hands out is prefixed "runner:<id>/". The orchestrator never class-routes to, aggregates capabilities over, or falls back to one.

Variables

This section is empty.

Functions

func IsRemote added in v0.9.0

func IsRemote(s Substrate) bool

IsRemote reports whether s reaches a registered runner rather than this deployment's own executor.

func Names added in v0.3.1

func Names() []string

Names returns the registered substrate names (for /healthz and error messages).

func RecordEnabled added in v0.8.0

func RecordEnabled(store string) bool

RecordEnabled maps a recording-store selection (WARDYN_RECORDING_STORE: "pg", "fs", or "off") to Deps.Record: every selection records except "off". cmd/wardynd and each substrate's register_test.go both call this rather than hardcoding a bool.

func Register added in v0.3.1

func Register(name string, c Constructor)

Register adds a confinement-substrate implementation, called from an init(). The OCI/Docker substrate registers only under `-tags docker`, so a tagless build fails closed at Resolve.

Types

type Advertiser added in v0.9.0

type Advertiser interface {
	Advertised() (runner.TargetFacts, bool)
}

Advertiser is implemented by a remote (runner) substrate: what the runner last advertised, or false while it has advertised nothing.

type ClassSupport

type ClassSupport struct {
	Classes                   []types.ConfinementClass          // strongest last; never overclaim
	Resolved                  map[types.ConfinementClass]string // substrate label ("oci/<runtime>") per class
	StructuralEgress          bool                              // L0: no default route; sole egress = wardyn-proxy
	NetworkPolicy             bool                              // L1, true only once a boot-time canary confirms enforcement
	NetworkPolicyAcknowledged bool                              // an OPERATOR accepted a canary failure; never a substitute for NetworkPolicy=true
	SessionRecording          bool                              // wardyn-rec PTY recording support
	// UserDrives and ManagedFiles are CONJUNCTION-aggregated (read BEFORE
	// routing, unlike every OR-merged flag above): can this substrate BIND a
	// member's user drive / deliver a root-owned file; false fail-closed.
	UserDrives   bool
	ManagedFiles bool
	// EphemeralDiskEnforcement names what binds runner.Resources.DiskMiB —
	// `filesystem`, `eviction`, or `none`/empty. Aggregated as the WEAKEST.
	EphemeralDiskEnforcement types.StorageEnforcement
	Freeze                   map[types.ConfinementClass]bool // per-class pause/resume support; absent/false = none
	ExecOutputUncaptured     bool                            // an exec's output cannot be captured (runner.Capabilities.ExecOutputUncaptured)
}

ClassSupport reports the Confinement Classes a substrate can enforce and the substrate label backing each.

type Constructor added in v0.3.1

type Constructor func(Deps) (Substrate, error)

Constructor builds a Substrate from Deps.

type Deps added in v0.3.1

type Deps struct {
	// ProxyImage is the wardyn-proxy sidecar image the substrate launches beside each agent (the sole egress path).
	ProxyImage string
	// DriveProbeImage is the OCI image the docker substrate's host_path drive-readability
	// probe runs in; empty means the substrate's own pinned default (a non-OCI substrate ignores it).
	DriveProbeImage string
	// ConfinementRuntimes are the operator's fail-closed per-class runtime pins (WARDYN_CONFINEMENT_MAP); nil = built-in defaults.
	ConfinementRuntimes map[types.ConfinementClass]string
	// UserDriveHostRoots is WARDYN_USER_DRIVE_HOST_ROOTS, parsed once at boot and passed here
	// so every substrate agrees on one host_path ceiling instead of re-reading the env itself.
	// nil (default) refuses every host_path drive; Kubernetes (no host-path backend) ignores it.
	UserDriveHostRoots []string
	// Record is whether a substrate should wrap Exec's argv with wardyn-rec (PTY recording),
	// set by cmd/wardynd from the resolved recording-store selection (RecordEnabled) rather
	// than hardcoded; each substrate must carry it through to Config.Record verbatim, never defaulting it to true.
	Record bool
}

Deps are the platform primitives a Substrate constructor may use. Heterogeneous seams keep their own typed Deps; an impl ignores fields it doesn't need and reads its own impl-specific config from the env in its constructor.

type Substrate

type Substrate interface {
	Name() string // reports the substrate kind, surfaced on /healthz
	// Classes reports the enforceable Confinement Classes + their substrate labels.
	Classes(ctx context.Context) (ClassSupport, error)
	// CreateSandbox provisions the run's sandbox, fail-closed with full rollback on any error.
	CreateSandbox(ctx context.Context, spec runner.SandboxSpec) (runner.Sandbox, error)
	// Exec launches the agent process inside ref, returning the exec id for
	// restart-safe liveness. A substrate MAY support only ONE Exec per ref
	// (k8s ephemeral containers are ADD-ONLY) and MUST error rather than
	// no-op or return the PRIOR id when it can't honour a second.
	Exec(ctx context.Context, ref string, argv []string) (agentExecID string, err error)
	Wait(ctx context.Context, ref string) (int, error)                                         // blocks until the agent process for ref exits and returns its code
	Attach(ctx context.Context, ref string, opts runner.AttachOptions) (runner.Session, error) // opens an interactive PTY session inside ref
	// ExecStream launches a fresh, streamable exec, repeatable against the SAME ref (see runner.ExecStream's doc).
	ExecStream(ctx context.Context, ref string, spec runner.ExecSpec) (*runner.ExecSession, error)
	Status(ctx context.Context, ref string) (runner.Status, error) // reports the sandbox lifecycle state
	// AgentStatus reports the AGENT's state restart-safely, falling back to Status when agentExecID is "".
	AgentStatus(ctx context.Context, ref, agentExecID string) (runner.Status, error)
	// StopSandbox is the graceful teardown (idempotent on a gone sandbox).
	StopSandbox(ctx context.Context, ref string) error
	// KillSandbox is the immediate kill-switch teardown (idempotent).
	KillSandbox(ctx context.Context, ref string) error
}

Substrate is runner.Runner's lifecycle contract for ONE confinement substrate.

func New added in v0.3.1

func New(name string, d Deps) (Substrate, error)

New constructs the substrate selected by name (empty => default).

Jump to

Keyboard shortcuts

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