Help us shape the future of Go! Take the 2026 Go Developer Survey

runtime

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package runtime defines the sandbox backend contract (design §11.3).

A backend provisions and operates the execution environment of one seat: capability discovery, validation, provisioning with a desired replica count of 0 or 1, status, quiescing and stopping, and cleanup with retention. Backends never fall back to a weaker runtime: a requested feature that is unsupported, misconfigured or temporarily unavailable is reported as a typed *Error and nothing is started (A16).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Capabilities reports the backend's supported features.
	Capabilities(ctx context.Context) Capabilities
	// Validate checks that the seat's requested runtime, enforcement and
	// lifecycle features are available. It returns a typed *Error otherwise.
	Validate(ctx context.Context, s *Seat) error
	// PublishManifest writes the seat's read-only manifest files.
	PublishManifest(ctx context.Context, s *Seat, files map[string]string) error
	// Ensure validates the seat and converges its objects with the desired
	// replica count (0 or 1). On validation failure it creates no workload,
	// scales an existing one to zero and returns the typed error.
	Ensure(ctx context.Context, s *Seat, replicas int32) (*Status, error)
	// Status observes the seat's backend instance.
	Status(ctx context.Context, s *Seat) (*Status, error)
	// Quiesce asks the running Pod to stop at a safe boundary (graceful
	// termination; the runner checkpoints on SIGTERM). It never force-deletes.
	Quiesce(ctx context.Context, s *Seat, pod string) error
	// Stop sets the desired replicas to zero.
	Stop(ctx context.Context, s *Seat) error
	// PodGone confirms with a live read that no Pod with the UID exists.
	PodGone(ctx context.Context, s *Seat, uid string) (bool, error)
	// Cleanup removes the runtime objects. With RetainData the workspace
	// volume is kept. It returns done=false while removal is in progress.
	Cleanup(ctx context.Context, s *Seat, retention Retention) (done bool, err error)
	// VerifyEnforcement runs (or returns the cached result of) the network
	// policy enforcement probe.
	VerifyEnforcement(ctx context.Context, p EnforcementProbe) (ProbeResult, error)
}

Backend is the sandbox backend contract (§11.3).

type Capabilities

type Capabilities struct {
	Backend  string
	Features []string
	// Enforcement lists the sandbox enforcement features the backend can provide.
	Enforcement []string
}

Capabilities describes what a backend supports.

type EnforcementProbe

type EnforcementProbe struct {
	Namespace string
	// ProfileDigest identifies the sandbox profile contents.
	ProfileDigest string
	// Seat is a seat using the profile; the probe runs under its policy.
	Seat *Seat
	// Nonce forces a fresh probe when it differs from the cached result's nonce.
	Nonce string
}

EnforcementProbe asks the backend to verify that the seat network policy is actually enforced in a namespace for a sandbox profile.

type Error

type Error struct {
	Kind    ErrorKind
	Feature string
	Message string
}

Error is a typed backend failure. It never contains secret values.

func Errorf

func Errorf(kind ErrorKind, feature, format string, args ...any) *Error

Errorf builds a typed backend error.

func (*Error) Error

func (e *Error) Error() string

type ErrorKind

type ErrorKind string

ErrorKind classifies why a requested feature cannot be provided (§11.3).

const (
	// Unsupported: the backend cannot provide the feature at all.
	Unsupported ErrorKind = "Unsupported"
	// Misconfigured: the feature could be provided but the cluster or
	// declaration is wrong (e.g. a RuntimeClass that does not exist).
	Misconfigured ErrorKind = "Misconfigured"
	// Unavailable: a dependency is temporarily unavailable; retry later.
	Unavailable ErrorKind = "Unavailable"
)

func KindOf

func KindOf(err error) ErrorKind

KindOf returns the kind of a typed backend error, or "" for other errors.

type PodStatus

type PodStatus struct {
	Name        string
	UID         string
	Revision    string
	Phase       string
	Ready       bool
	Terminating bool
	// Waiting is the container waiting reason (e.g. CrashLoopBackOff, ImagePullBackOff).
	Waiting   string
	StartTime *time.Time
	NodeName  string
}

PodStatus is the observed state of one seat Pod.

type ProbeResult

type ProbeResult struct {
	State  ProbeState
	Detail string
	Nonce  string
	Time   time.Time
}

ProbeResult is a cached enforcement probe result.

type ProbeState

type ProbeState string

ProbeState is the outcome of an enforcement probe.

const (
	ProbePending ProbeState = "pending"
	ProbePassed  ProbeState = "passed"
	ProbeFailed  ProbeState = "failed"
)

type Retention

type Retention string

Retention selects what cleanup keeps.

const (
	// RetainData removes the runtime and keeps the workspace volume.
	RetainData Retention = "retain"
	// DeleteData removes the runtime and the workspace volume.
	DeleteData Retention = "delete"
)

type Seat

type Seat struct {
	Namespace string
	// Name is the deterministic base name (pkg/names.Seat).
	Name           string
	OrgKey         string
	OrgID          string
	SeatKey        string
	SeatID         string
	ConfigRevision string
	// Manifest is the effective seat manifest (harness, execution and sandbox profiles).
	Manifest compile.SeatManifest
	// Owner, if set, owns every seat object except the workspace volume.
	Owner *metav1.OwnerReference
	// AdoptFrom is the retired seat ID whose retained workspace may be adopted.
	AdoptFrom string
}

Seat is the backend's view of one seat.

type Status

type Status struct {
	// BackendRef identifies the backend instance, e.g. statefulset/<name>.
	BackendRef string
	Exists     bool
	// Replicas is the desired replica count currently set on the backend.
	Replicas int32
	Pods     []PodStatus
	// StorageHandle is the workspace volume claim.
	StorageHandle string
	StorageExists bool
	StoragePhase  string
	// ManifestRevision is the config revision of the published manifest, if any.
	ManifestRevision string
}

Status is the observed state of a seat's backend instance.

Directories

Path Synopsis
Package kube is the Kubernetes implementation of the sandbox backend (ADR-0002): per seat a ServiceAccount, a retained workspace PVC, a manifest ConfigMap, a default-deny NetworkPolicy and a StatefulSet with 0 or 1 replicas.
Package kube is the Kubernetes implementation of the sandbox backend (ADR-0002): per seat a ServiceAccount, a retained workspace PVC, a manifest ConfigMap, a default-deny NetworkPolicy and a StatefulSet with 0 or 1 replicas.

Jump to

Keyboard shortcuts

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