contract

package
v0.1.50 Latest Latest
Warning

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

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

Documentation

Overview

Package contract holds the Go mirror of packages/api-contract. These structs describe the /api/v1 wire surface shared between the Ruust control plane and the Go host agent. Reconciliation is pull based: the agent polls

GET  /api/v1/hosts/:id/desired-state

and reports back with

POST /api/v1/hosts/:id/status

Vocabulary note. The unit a customer deploys and pays for is an "Egg". Internally, and in this schema, that same unit is modelled as a "Blob". The Egg-to-Blob mapping stays in code only and must never surface in user-facing text. See EggID and BlobID on WorkloadSpec below.

Keep this file in step with packages/api-contract/src/index.ts whenever either side changes. Both sides tolerate at least one minor version of skew in either direction, so unknown JSON fields are ignored rather than rejected.

Index

Constants

View Source
const APIVersion = "v1"

APIVersion is the current contract version, reflected in the /api/v1 route prefix.

Variables

View Source
var EggTiers = []EggTierSpec{
	{ID: TierNano, Label: "Nano", PricePerMonthGbp: 4, MemoryMb: 256, Vcpu: "⅛ vCPU, bursts to ½", UnmeteredEgress: true},
	{ID: TierSmall, Label: "Small", PricePerMonthGbp: 8, MemoryMb: 512, Vcpu: "¼ vCPU, bursts to 1", UnmeteredEgress: true},
	{ID: TierStandard, Label: "Standard", PricePerMonthGbp: 16, MemoryMb: 1024, Vcpu: "½ vCPU, bursts to 2", UnmeteredEgress: true, MostPopular: true},
	{ID: TierLarge, Label: "Large", PricePerMonthGbp: 30, MemoryMb: 2048, Vcpu: "1 vCPU, bursts to 4", UnmeteredEgress: true},
}

EggTiers is the static catalogue of flat pricing tiers, in GBP. Every tier has unmetered egress.

View Source
var Regions = []RegionInfo{
	{ID: RegionEUWest, Label: "EU West", Centre: "London", Availability: RegionLive},
	{ID: RegionUSEast, Label: "US East", Centre: "Virginia", Availability: RegionLive},
	{ID: RegionEUCentral, Label: "EU Central", Centre: "Frankfurt", Availability: RegionSoon},
	{ID: RegionAPSoutheast, Label: "Asia Pacific South East", Centre: "Singapore", Availability: RegionSoon},
}

Regions is the static catalogue of regions.

Functions

This section is empty.

Types

type AgentUpdate added in v0.1.45

type AgentUpdate struct {
	// Version is the pinned release tag, for logging and to scope the hash to a build.
	Version string `json:"version"`
	// Sha256 is the expected lowercase-hex sha256 of ruust-agent-linux-<arch>, per arch.
	Sha256 AgentUpdateHash `json:"sha256"`
}

AgentUpdate pins the expected agent binary hash the control plane is serving.

type AgentUpdateHash added in v0.1.45

type AgentUpdateHash struct {
	Amd64 string `json:"amd64,omitempty"`
	Arm64 string `json:"arm64,omitempty"`
}

AgentUpdateHash carries the expected binary hash per architecture.

func (AgentUpdateHash) For added in v0.1.45

func (h AgentUpdateHash) For(goarch string) string

For returns the expected hash for a GOARCH value, or "" when none is pinned.

type BackupDirective added in v0.1.19

type BackupDirective struct {
	// BackupID is echoed back on the status report.
	BackupID string `json:"backupId"`
	// Action is "capture", "restore", "upload", "store", "fetch" or "delete".
	Action string `json:"action"`
	// Engine is the database engine ("postgres").
	Engine string `json:"engine"`
	// Ref is a file path: the snapshot to restore/upload/fetch, or where to write a
	// downloaded snapshot in the Vault volume (store).
	Ref string `json:"ref,omitempty"`
	// Retention, for a capture, is how many newest snapshots to keep on the host
	// (older ones are pruned after this capture).
	Retention int `json:"retention,omitempty"`
	// PutURL, for upload/fetch, is where to PUT the snapshot bytes (control-plane
	// staging, authenticated with the host token).
	PutURL string `json:"putUrl,omitempty"`
	// GetURL, for store and restore-from-vault, is where to GET the snapshot bytes.
	GetURL string `json:"getUrl,omitempty"`
	// Checksum, for store, is the sha256 to verify the downloaded snapshot against.
	Checksum string `json:"checksum,omitempty"`
}

BackupDirective tells the agent what to do with a database Egg's snapshot. The agent runs a given (BackupID, Action) only once per process.

  • capture: run pg_dump inside the Egg's container to a durable host file, report the ref/size/checksum back.
  • restore: load a snapshot (Ref, a local host file, or GetURL for a Vault copy) back into the Egg's container.
  • upload: (source host, durable backups) send the local snapshot at Ref to PutURL (control-plane staging) so it can be relayed to the Vault.
  • store: (Vault host) download the snapshot from GetURL and write it into the Vault volume at Ref, verifying Checksum.
  • fetch: (Vault host, restore) send the Vault copy at Ref to PutURL so the source host can download and restore it.

type BackupReport added in v0.1.19

type BackupReport struct {
	// BackupID is the backup this report is for (from the backup directive).
	BackupID string `json:"backupId"`
	// Action is which directive action this report is for ("capture", "restore",
	// "upload", "store", "fetch"), so the control plane can tell them apart for the
	// same BackupID.
	Action string `json:"action,omitempty"`
	// Status is the backup phase: "running", "done" or "failed".
	Status string `json:"status"`
	// Ref, on a capture "done", is the durable host file the snapshot was written to;
	// on a store "done", the file path written inside the Vault volume.
	Ref string `json:"ref,omitempty"`
	// SizeBytes is the snapshot size on a capture "done".
	SizeBytes int64 `json:"sizeBytes,omitempty"`
	// Checksum is the snapshot sha256 on a capture "done".
	Checksum string `json:"checksum,omitempty"`
	// Log is incremental, redacted output since the last report (may be empty).
	Log string `json:"log,omitempty"`
}

BackupReport is capture/restore progress for a database Egg's backup, driving the Backup's status. On a capture "done" it carries the durable file Ref, its size and checksum so the control plane can record and later restore the snapshot.

type BuildDirective added in v0.1.14

type BuildDirective struct {
	// DeploymentID is echoed back on the status report so the control plane can move
	// the right Deployment through building -> live/failed.
	DeploymentID string `json:"deploymentId"`
	// RepoURL is the https git repository to clone.
	RepoURL string `json:"repoUrl"`
	// Branch to build.
	Branch string `json:"branch"`
	// GitSha is a short revision label; a change rolls the build.
	GitSha string `json:"gitSha"`
	// RootDirectory is the subdirectory to build from, for a monorepo. Empty = root.
	RootDirectory string `json:"rootDirectory,omitempty"`
	// StartCommand overrides the start command baked into the image (Nixpacks).
	StartCommand string `json:"startCommand,omitempty"`
	// BuildEnvKeys are the build-time env var KEYS; values come from EnvValues.
	BuildEnvKeys []string `json:"buildEnvKeys,omitempty"`
	// ImageTag is the local tag the agent must produce (and, for BYO, then run).
	ImageTag string `json:"imageTag"`
	// PushTo, when set, makes this a BUILD-ONLY job on a dedicated build host: the
	// agent builds ImageTag, tags it to PushTo, pushes it to the private registry,
	// and does NOT run a container. Empty = bring-your-own-host (build and run
	// locally, nothing pushed).
	PushTo string `json:"pushTo,omitempty"`
	// Private is true when the repo needs a clone token (delivered via BuildToken).
	Private bool `json:"private,omitempty"`
}

BuildDirective tells a bring-your-own-host agent to build a workload's image from its git repository locally (nixpacks, or the repo Dockerfile), tag it ImageTag, and then run it. The build is idempotent: if ImageTag already exists locally the agent skips it. Build progress and logs are reported back on the status endpoint.

type BuildReport added in v0.1.14

type BuildReport struct {
	// DeploymentID is the deployment this build produces (from the build directive).
	DeploymentID string `json:"deploymentId"`
	// Status is the build phase: "building", "built" or "failed".
	Status string `json:"status"`
	// Log is incremental, redacted build output since the last report (may be empty).
	Log string `json:"log,omitempty"`
}

BuildReport is host-side build progress for a workload the agent is building locally. Distinct from the runtime Logs above: this drives the Deployment's build status and the dashboard Build tab.

type CertStatusReport added in v0.1.39

type CertStatusReport struct {
	Hostname string `json:"hostname"`
	// Status is "issued", "pending", or "failed".
	Status string `json:"status"`
}

CertStatusReport is one Egg hostname's certificate state, as seen by the local Caddy.

type CgroupUsage

type CgroupUsage struct {
	// MemoryBytes is current memory usage in bytes (cgroup memory.current).
	MemoryBytes int64 `json:"memoryBytes"`
	// CpuUsage is CPU usage as a fraction of one core (for example 0.25),
	// derived from cpu.stat.
	CpuUsage float64 `json:"cpuUsage"`
	// EgressBytes is observed egress in bytes. Reported for insight only, never
	// metered.
	EgressBytes int64 `json:"egressBytes"`
}

CgroupUsage is the measured cgroup v2 usage for one container. Egress is reported for observability only. It is never used to cap or bill traffic, since egress is unmetered.

type ContainerHealth

type ContainerHealth struct {
	// WorkloadID is the workload this container belongs to.
	WorkloadID string `json:"workloadId"`
	// BlobID is the internal Blob identity of the Egg.
	BlobID string `json:"blobId"`
	// State is the runtime container state.
	State ContainerState `json:"state"`
	// Healthy reports whether the workload is currently passing its health check.
	Healthy bool `json:"healthy"`
	// RestartCount is the number of times the container has been restarted.
	RestartCount int `json:"restartCount"`
	// Usage is the measured cgroup usage.
	Usage CgroupUsage `json:"usage"`
	// DiskBytes is the on-disk usage of the Egg's persistent volume in bytes, for a
	// stateful (database) Egg. Zero/omitted for a stateless web Egg (no volume), and
	// omitted on reports where it was not measured this cycle (measured on a slower
	// cadence than the poll to keep du off the hot path).
	DiskBytes int64 `json:"diskBytes,omitempty"`
	// Logs are the container output lines produced since the last report
	// (incremental, may be empty).
	Logs []LogLine `json:"logs"`
	// Build, when set, reports host-side build progress for a bring-your-own-host Egg
	// the agent is building locally, so the control plane can move the Deployment
	// through building -> live/failed and show the build output in the Build tab. Nil
	// for a normal (non host-built) workload.
	Build *BuildReport `json:"build,omitempty"`
	// Import, when set, reports data-import progress for a database Egg the agent is
	// importing into, so the control plane can move the Import through
	// importing -> done/failed and show progress. Nil when there is no active import.
	Import *ImportReport `json:"import,omitempty"`
	// Backup, when set, reports backup capture/restore progress for a database Egg.
	// Nil when there is no active backup. See BackupReport.
	Backup *BackupReport `json:"backup,omitempty"`
	// Release, when set, reports the outcome and captured output of the one-shot release
	// command (e.g. migrations) the agent ran before rolling this workload, so the control
	// plane can show it as a Release log on the deploy. Nil when the workload has no release
	// command, or none ran this cycle. See ReleaseReport.
	Release *ReleaseReport `json:"release,omitempty"`
}

ContainerHealth is the health and usage of a single container, as reported by the agent.

type ContainerState

type ContainerState string

ContainerState is the low-level runtime state of a single container as observed by the agent. It maps up to EggLifecycleState in the control plane, but the two are kept distinct on the wire.

const (
	// StatePending means scheduled but not yet started.
	StatePending ContainerState = "pending"
	// StateBuilding means the image is being built or pulled.
	StateBuilding ContainerState = "building"
	// StateStarting means the container process is starting.
	StateStarting ContainerState = "starting"
	// StateRunning means running and passing health checks.
	StateRunning ContainerState = "running"
	// StateStopped means stopped on purpose (the Egg is cold).
	StateStopped ContainerState = "stopped"
	// StateCrashed means the container exited unexpectedly (the Egg is cracked).
	StateCrashed ContainerState = "crashed"
	// StateUnknown means the agent cannot determine the state.
	StateUnknown ContainerState = "unknown"
)

type DesiredState

type DesiredState struct {
	// HostID is the host this desired state is for.
	HostID string `json:"hostId"`
	// Version is an opaque content hash of this desired state. The agent compares
	// it against the last applied version to decide whether to reconcile.
	Version string `json:"version"`
	// Workloads are the workloads that should be running on this host.
	Workloads []WorkloadSpec `json:"workloads"`
	// RebootRequestedAt is an admin-requested reboot, as an RFC3339 instant. The
	// agent reboots when this is after the box's own boot time, and skips it once
	// the box has booted since (so it is idempotent across polls). Empty = none.
	// Deliberately outside the version hash: a reboot must not roll workloads.
	RebootRequestedAt string `json:"rebootRequestedAt,omitempty"`
	// IngressEnabled controls whether this host serves public ingress. When true (or
	// absent, for an older control plane) the agent pushes per-Egg routes and on-demand
	// TLS to the local Caddy; when false it tears them down, so the host runs Eggs
	// privately. A pointer so absent (nil) is distinguishable from an explicit false and
	// defaults to on. Outside the version hash: toggling ingress must not roll workloads.
	IngressEnabled *bool `json:"ingressEnabled,omitempty"`
	// CancelledDeploymentIDs are deployments whose in-flight build on this host
	// should be stopped (cancelled by a customer/admin, or superseded by a newer
	// deploy). The agent SIGTERMs the matching build if still running; unknown ids
	// are ignored. Outside the version hash: cancelling never rolls workloads.
	CancelledDeploymentIDs []string `json:"cancelledDeploymentIds,omitempty"`
	// ShellSessions are pending interactive shell requests for workloads on this host.
	// For each, the agent dials the relay, execs an interactive PTY into the workload's
	// live container, and bridges the two. Only a container this host runs. Outside the
	// version hash: a shell request never rolls a workload.
	ShellSessions []ShellSessionRequest `json:"shellSessions,omitempty"`
	// HostConfig carries operational fair-use tunables the agent applies OUT OF BAND:
	// per-Egg egress rate caps, and the ingress hardening defaults. A pointer so a nil
	// (absent) block means "use built-in behaviour" for an older control plane. Outside
	// the version hash: tweaking any of these must never, by itself, roll a workload.
	HostConfig *HostConfig `json:"hostConfig,omitempty"`
	// AgentUpdate pins the expected sha256 of the agent binary the control plane wants
	// this host on, per architecture, delivered over THIS authenticated channel rather
	// than beside the binary on the open download path. The agent verifies a self-update
	// download against this hash and refuses a mismatch, so tampering with the download
	// endpoint or the transit alone cannot install a substituted binary. Nil for an older
	// control plane (the agent then falls back to the published .sha256). Outside the
	// version hash: an update pin must never, by itself, roll a workload.
	AgentUpdate *AgentUpdate `json:"agentUpdate,omitempty"`
}

DesiredState is the full desired state for one host, returned by GET /api/v1/hosts/:id/desired-state.

The Version field is a hash of the desired state. The agent stores the last version it applied and cheaply no-ops whilst the hash is unchanged, so it only reconciles when something has actually moved.

type EggLifecycleState

type EggLifecycleState string

EggLifecycleState is the customer-facing lifecycle of an Egg, surfaced in status badges, logs and the dashboard.

incubating -> building the image
hatching   -> deploying / rolling out
hatched    -> live and serving traffic
cold       -> stopped or suspended
cracked    -> crashed
const (
	// EggIncubating means the Egg's image is being built.
	EggIncubating EggLifecycleState = "incubating"
	// EggHatching means the Egg is deploying or rolling out.
	EggHatching EggLifecycleState = "hatching"
	// EggHatched means the Egg is live and serving traffic.
	EggHatched EggLifecycleState = "hatched"
	// EggCold means the Egg is stopped or suspended.
	EggCold EggLifecycleState = "cold"
	// EggCracked means the Egg has crashed.
	EggCracked EggLifecycleState = "cracked"
)

func EggLifecycleFor

func EggLifecycleFor(s ContainerState) EggLifecycleState

EggLifecycleFor maps a low-level container state up to the customer-facing Egg lifecycle state. This is the only place the two vocabularies meet on the agent side.

type EggTier

type EggTier string

EggTier enumerates the flat pricing tiers, per Egg, per month, in GBP. Egress is unmetered on every tier, so there is deliberately no egress cap anywhere in this contract.

const (
	// TierNano is the Nano tier.
	TierNano EggTier = "nano"
	// TierSmall is the Small tier.
	TierSmall EggTier = "small"
	// TierStandard is the Standard tier (most popular).
	TierStandard EggTier = "standard"
	// TierLarge is the Large tier.
	TierLarge EggTier = "large"
)

type EggTierSpec

type EggTierSpec struct {
	ID EggTier `json:"id"`
	// Label is the human-readable tier name.
	Label string `json:"label"`
	// PricePerMonthGbp is the flat price per Egg per month, in whole GBP.
	PricePerMonthGbp int `json:"pricePerMonthGbp"`
	// MemoryMb is the hard memory allowance in megabytes.
	MemoryMb int `json:"memoryMb"`
	// Vcpu is the human-readable vCPU allowance.
	Vcpu string `json:"vcpu"`
	// UnmeteredEgress is always true. Egress is unmetered on every tier.
	UnmeteredEgress bool `json:"unmeteredEgress"`
	// MostPopular flags the tier we highlight in the dashboard.
	MostPopular bool `json:"mostPopular,omitempty"`
}

EggTierSpec describes one flat pricing tier. Egress is unmetered on every tier, so UnmeteredEgress is always true and no egress cap is modelled.

type EgressCap added in v0.1.41

type EgressCap struct {
	WorkloadID     string `json:"workloadId"`
	BytesPerSecond int64  `json:"bytesPerSecond"`
}

EgressCap is one workload's egress ceiling.

type EgressConfig added in v0.1.41

type EgressConfig struct {
	// Enforce is the master switch. False means the agent removes any egress shaping.
	Enforce bool `json:"enforce"`
	// Caps are the per-workload egress ceilings, in bytes per second (0 = unlimited).
	Caps []EgressCap `json:"caps"`
}

EgressConfig is the network egress fair-use policy for this host.

type FirewallConfig added in v0.1.42

type FirewallConfig struct {
	// BlockedOutboundPorts are outbound TCP ports blocked from Egg containers, to stop
	// direct-to-MX SMTP abuse. 25 by default; submission ports 587/465 stay open for
	// authenticated relays.
	BlockedOutboundPorts []int `json:"blockedOutboundPorts"`
}

FirewallConfig is the Egg egress firewall policy, applied on top of the static metadata/RFC1918/host blocks the reconciler always writes.

type HostConfig added in v0.1.41

type HostConfig struct {
	Egress  *EgressConfig  `json:"egress,omitempty"`
	Ingress *IngressConfig `json:"ingress,omitempty"`
}

HostConfig is the set of operational fair-use tunables applied out of band (never part of the version hash). Every field is optional; a nil sub-block leaves that dimension at the agent's built-in behaviour.

type HostStatus

type HostStatus struct {
	// HostID is the host this report is for.
	HostID string `json:"hostId"`
	// AgentVersion is the version string of the reporting agent.
	AgentVersion string `json:"agentVersion"`
	// AppliedVersion is the desired-state version the agent has applied, if any.
	AppliedVersion string `json:"appliedVersion,omitempty"`
	// CpuCores is the real CPU cores of the physical box (fractional allowed),
	// detected on the host and reported on every heartbeat so a resized VPS is
	// picked up automatically. omitempty: a zero (detection miss) is not sent, so
	// it can never overwrite a known-good Host value (version-skew safety).
	CpuCores float64 `json:"cpuCores,omitempty"`
	// TotalRamMb is total host RAM in MB, agent-detected. Same omitempty rule.
	TotalRamMb int `json:"totalRamMb,omitempty"`
	// DiskTotalGb and DiskFreeGb are the total and available space of the host's
	// tenant-data filesystem in GB, agent-detected each heartbeat. The control plane
	// budgets placement against these. Same omitempty (0 = miss, keep known value).
	DiskTotalGb int `json:"diskTotalGb,omitempty"`
	DiskFreeGb  int `json:"diskFreeGb,omitempty"`
	// OSName and OSVersion identify the host operating system (for example "Ubuntu"
	// and "22.04"), for the operator fleet view. Omitted when not detected.
	OSName    string `json:"osName,omitempty"`
	OSVersion string `json:"osVersion,omitempty"`
	// Kernel is the running kernel release (uname -r), for spotting an unpatched box.
	Kernel string `json:"kernel,omitempty"`
	// SecurityUpdates is the count of pending OS security updates. A pointer so nil
	// (not determined) stays distinct from 0 (checked and patched); omitempty drops
	// only the nil, so a real 0 is still sent and clears a stale count.
	SecurityUpdates *int `json:"securityUpdates,omitempty"`
	// RebootRequired is true when the OS has flagged that a reboot is needed to
	// finish applying updates. Sent even when false (no omitempty), so the control
	// plane can clear a stale flag after the box has been rebooted.
	RebootRequired bool `json:"rebootRequired"`
	// UptimeSeconds is how long the host has been up (from /proc/uptime). Lets the
	// control plane tell when a box has rebooted (uptime resets), so an admin reboot
	// request self-clears once the host reports a boot after the request. omitempty:
	// a host that cannot determine it (0) omits it rather than claiming a fresh boot.
	UptimeSeconds int64 `json:"uptimeSeconds,omitempty"`
	// RolledBack lists agent versions this node fetched, failed to run, and rolled
	// back from (quarantined). Always sent (even empty, no omitempty) so the control
	// plane can clear the alert once the node's quarantine is cleared.
	RolledBack []string `json:"rolledBack"`
	// Ingress is the local Caddy ingress health, so the console can show whether the
	// host's public front door works. Nil on a host with no Caddy (a workload-only host).
	Ingress *IngressHealth `json:"ingress,omitempty"`
	// QuotaEnforced is true when this host can hard-enforce a per-volume size quota
	// (its data filesystem is xfs mounted with prjquota and the agent has the scoped
	// xfs_quota privilege), false when volume sizes are advisory only. A pointer so a
	// host that has not probed yet (nil) stays distinct from a real false, and the
	// control plane can show operators which hosts actually cap disk.
	QuotaEnforced *bool `json:"quotaEnforced,omitempty"`
	// SSH is the EFFECTIVE sshd state the root provision reconciler last probed (sshd -T
	// plus the managed operator-key count), for the console's per-node SSH health badge.
	// Nil from an agent that predates this. The main (unprivileged) loop cannot run sshd -T
	// itself, so it reports what the root reconciler wrote; ReconcilerActive is false when no
	// fresh probe is available (for example a host with no provision reconciler installed).
	SSH *SSHReport `json:"ssh,omitempty"`
	// Containers is the health of every container the agent is currently running.
	Containers []ContainerHealth `json:"containers"`
	// AgentLogs is the agent's OWN recent log output (a rolling window, not
	// incremental), so an operator can stream a node's agent logs from the console
	// without shell access. May be empty. Never contains secrets.
	AgentLogs []LogLine `json:"agentLogs,omitempty"`
}

HostStatus is the status report from the agent, sent to POST /api/v1/hosts/:id/status.

AppliedVersion echoes back the DesiredState.Version the agent has reconciled to, so the control plane can tell when a host is up to date.

type ImportDirective added in v0.1.18

type ImportDirective struct {
	// ImportID is echoed back on the status report so the control plane can move the
	// right Import through importing -> done/failed.
	ImportID string `json:"importId"`
	// Engine is the database engine ("postgres"), so the agent picks the right tool.
	Engine string `json:"engine"`
}

ImportDirective tells the agent to load data into a database Egg from an external source: pg_dump of the source (ImportSourceURL, from secrets) piped into the Egg's own running container, so the data never leaves the host. Progress is reported on the status endpoint. The agent runs a given ImportID only once per process.

type ImportReport added in v0.1.18

type ImportReport struct {
	// ImportID is the import this report is for (from the import directive).
	ImportID string `json:"importId"`
	// Status is the import phase: "importing", "done" or "failed".
	Status string `json:"status"`
	// Log is incremental, redacted import output since the last report (may be empty).
	Log string `json:"log,omitempty"`
}

ImportReport is data-import progress for a database Egg the agent is importing into, driving the Import's status and dashboard progress.

type IngressConfig added in v0.1.41

type IngressConfig struct {
	ReadTimeout  string `json:"readTimeout,omitempty"`
	IdleTimeout  string `json:"idleTimeout,omitempty"`
	WriteTimeout string `json:"writeTimeout,omitempty"`
	DialTimeout  string `json:"dialTimeout,omitempty"`
	MaxBodyBytes int64  `json:"maxBodyBytes,omitempty"`
}

IngressConfig is the ingress hardening the agent applies to the local Caddy. The timeouts are Caddy duration strings ("30s"); an empty string leaves that timeout unset. MaxBodyBytes of 0 means no request-body cap.

type IngressHealth added in v0.1.39

type IngressHealth struct {
	// Ready is true when Caddy's admin API is reachable and the last config push applied.
	Ready bool `json:"ready"`
	// Listening is true when Caddy is bound to the public ports (80/443).
	Listening bool `json:"listening"`
	// Certs is the per-hostname certificate state, so an Egg's cert can show its status.
	Certs []CertStatusReport `json:"certs,omitempty"`
}

IngressHealth is the local Caddy ingress health the agent reports each heartbeat.

type LogLine

type LogLine struct {
	// Ts is the runtime timestamp of the line (RFC3339).
	Ts string `json:"ts"`
	// Stream is which stream the line came from: "stdout" or "stderr".
	Stream string `json:"stream"`
	// Text is the log text, stripped of the runtime timestamp prefix.
	Text string `json:"text"`
}

LogLine is one line of container output, shipped incrementally by the agent.

type MigrationCounts added in v0.1.12

type MigrationCounts struct {
	Tables int `json:"tables,omitempty"`
	Rows   int `json:"rows,omitempty"`
	Keys   int `json:"keys,omitempty"`
}

MigrationCounts is the engine-specific verification measure an agent reports for a migration snapshot or restore, so the control plane can confirm the copy is complete before it cuts over. Postgres reports the table count, Redis the key count; rows is carried when cheap. Zero fields are omitted.

type MigrationDirective added in v0.1.12

type MigrationDirective struct {
	// ID is the migration id, the idempotency key for every step.
	ID string `json:"id"`
	// Role is this host's part: "source" or "target".
	Role string `json:"role"`
	// Phase is which snapshot this directive is for: "base" or "delta".
	Phase string `json:"phase"`
	// Engine is the database engine: "postgres" or "redis".
	Engine string `json:"engine"`
	// VolumeName is the Egg's persistent volume name, identical on both hosts.
	VolumeName string `json:"volumeName"`
	// PutURL / GetURL are where to move the snapshot bytes. Empty means use the
	// control-plane relay endpoint (authenticated with the host token); a production
	// deploy supplies presigned object-storage URLs instead.
	PutURL string `json:"putUrl,omitempty"`
	GetURL string `json:"getUrl,omitempty"`
	// Checksum is the sha256 the target verifies against the downloaded snapshot.
	Checksum string `json:"checksum,omitempty"`
	// Quiesce (source only) means stop serving writes before the delta snapshot.
	Quiesce bool `json:"quiesce,omitempty"`
}

MigrationDirective tells this host its part in a database Egg migration, so a node can be drained without losing the Egg's host-local volume. It is emitted to the SOURCE host (role "source": snapshot the live database and upload the bytes) and to the TARGET host (role "target": download and restore into a fresh volume). Every step keys on ID so it is idempotent and safely retryable, and the source stays authoritative and untouched until the target is verified.

type MigrationReport added in v0.1.12

type MigrationReport struct {
	MigrationID string           `json:"migrationId"`
	Role        string           `json:"role"`
	Phase       string           `json:"phase,omitempty"`
	State       string           `json:"state"`
	Counts      *MigrationCounts `json:"counts,omitempty"`
	Checksum    string           `json:"checksum,omitempty"`
	SizeBytes   int64            `json:"sizeBytes,omitempty"`
	Error       string           `json:"error,omitempty"`
}

MigrationReport is what an agent POSTs to /api/v1/hosts/:id/migration-status to advance a database Egg migration it has a part in. State is one of "started", "uploaded" (source finished snapshot + upload), "restored", "verified" (target restored and self-checked) or "failed". Never carries secret values.

type NetworkAttachment

type NetworkAttachment struct {
	// Name is the pair network, identical for both peered Eggs.
	Name string `json:"name"`
	// Alias is this Egg's stable DNS name on that network.
	Alias string `json:"alias"`
}

NetworkAttachment is one private-network peering: a two-party bridge shared with exactly one peered sibling, and the alias this Egg answers to on it.

type ProvisioningManifest added in v0.1.42

type ProvisioningManifest struct {
	// Generation bumps on any provisioning change; the reconciler applies only when it
	// differs from the generation it last applied. A stable hash of the inputs below.
	Generation string `json:"generation"`
	// Firewall is the Egg egress firewall policy. Nil leaves the agent's built-in rules.
	Firewall *FirewallConfig `json:"firewall,omitempty"`
	// Packages are OS packages the host must have for the agent to do its job (egress
	// shaping needs iproute2 + util-linux). The reconciler installs any that are missing.
	Packages []string `json:"packages,omitempty"`
	// AgentNetworkCaps is true when the agent's systemd unit must carry the network
	// capabilities (CAP_NET_ADMIN/CAP_SYS_ADMIN + the setns syscall) that egress shaping
	// needs. The reconciler rewrites the unit and restarts the agent only if missing.
	AgentNetworkCaps bool `json:"agentNetworkCaps,omitempty"`
	// SSH is the managed-host SSH auth policy (nil = the agent does not touch sshd). The
	// control plane sends it to MANAGED hosts only, never a BYO host.
	SSH *SSHConfig `json:"ssh,omitempty"`
}

ProvisioningManifest is the OS-level host state the control plane wants, returned by GET /api/v1/hosts/:id/provisioning and applied by the root `ruust-agent provision` reconciler on a timer. Pull-based like everything else: the control plane never dials a host. Generation changes whenever any input below changes, so the reconciler is a cheap no-op when it matches the generation it last applied, and never re-applies on an unchanged host. Every field is desired-state the agent converges idempotently; an older agent ignores what it does not understand. This carries the privileged host substrate (firewall, packages, agent capabilities) that the agent's own unprivileged loop cannot change, so a host stays current with no re-enrol. It does NOT carry workloads or secrets (those stay on desired-state).

type Region

type Region string

Region enumerates the deployment regions. Each region is an independent cell: one region going down never affects another. An Egg lives in exactly one region for its whole life and cannot be moved between regions.

const (
	// RegionEUWest is London (live).
	RegionEUWest Region = "eu-west"
	// RegionUSEast is Virginia (live).
	RegionUSEast Region = "us-east"
	// RegionEUCentral is Frankfurt (coming soon).
	RegionEUCentral Region = "eu-central"
	// RegionAPSoutheast is Singapore (coming soon).
	RegionAPSoutheast Region = "ap-southeast"
)

type RegionAvailability

type RegionAvailability string

RegionAvailability marks whether a region is live or coming soon.

const (
	// RegionLive means the region is accepting workloads now.
	RegionLive RegionAvailability = "live"
	// RegionSoon means the region is coming soon.
	RegionSoon RegionAvailability = "soon"
)

type RegionInfo

type RegionInfo struct {
	ID           Region             `json:"id"`
	Label        string             `json:"label"`
	Centre       string             `json:"centre"`
	Availability RegionAvailability `json:"availability"`
}

RegionInfo is a static catalogue entry describing a region, its display centre and its availability.

type ReleaseReport added in v0.1.34

type ReleaseReport struct {
	// Status is the release outcome: "succeeded" or "failed".
	Status string `json:"status"`
	// Log is the release container's full combined output (stdout+stderr), redacted.
	Log string `json:"log,omitempty"`
	// DeploymentID is the deployment the release ran for, so the control plane
	// attaches the outcome to the exact deployment rather than the workload's
	// current pointer (which can have rolled on to a newer, still-building deploy).
	DeploymentID string `json:"deploymentId,omitempty"`
}

ReleaseReport is the outcome and captured output of a workload's one-shot release command (e.g. database migrations), run once before the workload rolls. Distinct from the build (which produces the image) and the runtime Logs (the serving container): this drives the dashboard's Release log for a deploy. The log is captured in full after the release container exits (not incremental), and is redacted of env values.

type ResourceLimits

type ResourceLimits struct {
	// MemoryMb is the hard memory limit in megabytes (cgroup memory.max).
	MemoryMb int `json:"memoryMb"`
	// CpuFloor is the guaranteed vCPU share under contention, in fractional cores
	// (for example 0.5). Enforced as cgroup cpu.weight, proportional to this floor.
	CpuFloor float64 `json:"cpuFloor"`
	// CpuBurst is the burst ceiling when the host is idle, in fractional cores
	// (for example 2.0). Enforced as cgroup cpu.max. Always >= CpuFloor.
	CpuBurst float64 `json:"cpuBurst"`
	// PidsLimit is the maximum number of process IDs allowed (cgroup pids.max).
	PidsLimit int `json:"pidsLimit"`
	// ReadOnlyRootfs mounts the root filesystem read only. Defaults to true.
	ReadOnlyRootfs bool `json:"readOnlyRootfs"`
	// DroppedCaps lists the Linux capabilities to drop. Defaults to ["ALL"].
	DroppedCaps []string `json:"droppedCaps"`
}

ResourceLimits are the hard limits the agent enforces on every axis for a workload's containers. Note the deliberate absence of any egress or bandwidth limit: egress is unmetered on every tier.

type SSHConfig added in v0.1.47

type SSHConfig struct {
	// AuthorizedKeys are operator PUBLIC keys to install on the host.
	AuthorizedKeys []string `json:"authorizedKeys,omitempty"`
	// DisablePasswordAuth turns password auth off (key-only), applied only when at least
	// one authorized key is present.
	DisablePasswordAuth bool `json:"disablePasswordAuth,omitempty"`
}

SSHConfig is the managed-host SSH auth policy the agent converges. It installs operator keys in a managed file (never clobbering a user's own authorized_keys) and, only when a key is present, disables password auth. The agent validates sshd and RELOADS it (never restarts), so a change cannot drop a live session or lock the fleet out.

type SSHReport added in v0.1.49

type SSHReport struct {
	// PasswordAuthEnabled is the EFFECTIVE `PasswordAuthentication` from `sshd -T` (which
	// merges all drop-ins, so it catches a cloud-init file re-enabling passwords). Nil when
	// not probed.
	PasswordAuthEnabled *bool `json:"passwordAuthEnabled,omitempty"`
	// OperatorKeyCount is the number of managed operator public keys installed on the host.
	// Nil when not probed.
	OperatorKeyCount *int `json:"operatorKeyCount,omitempty"`
	// ReconcilerActive is true when the root provision reconciler has written a FRESH SSH
	// probe. False means no recent probe (no reconciler installed, or it is not running), so
	// the console can flag "SSH health unknown / reconciler not installed".
	ReconcilerActive bool `json:"reconcilerActive"`
}

SSHReport is the effective SSH state of a host, for the operator/customer console badge. PasswordAuthEnabled and OperatorKeyCount are pointers so "not probed" stays distinct from a real value; they are present only when ReconcilerActive is true (a fresh probe exists).

type SecretsResponse

type SecretsResponse struct {
	HostID    string            `json:"hostId"`
	Workloads []WorkloadSecrets `json:"workloads"`
}

SecretsResponse is the out-of-band secrets document for a host, returned by GET /api/v1/hosts/:id/secrets. Kept separate from the desired state on purpose.

type ShellSessionRequest added in v0.1.40

type ShellSessionRequest struct {
	ID         string `json:"id"`
	WorkloadID string `json:"workloadId"`
}

ShellSessionRequest is one pending interactive shell: its session id (used to pair the agent's relay WebSocket with the client's) and the workload to exec into.

type VolumeMount

type VolumeMount struct {
	// Name is the stable Docker volume name for this Egg's data.
	Name string `json:"name"`
	// Path is the absolute mount point inside the container (the engine's data dir).
	Path string `json:"path"`
	// SizeGb is the billed allocation. Advisory to the agent for now (the local
	// volume driver does not hard-enforce a quota).
	SizeGb int `json:"sizeGb,omitempty"`
}

VolumeMount is one persistent named volume mounted into a stateful Egg. The volume name is stable across recreations, so a database Egg keeps its data over a redeploy or restart.

type WorkloadSecrets

type WorkloadSecrets struct {
	WorkloadID string            `json:"workloadId"`
	Env        map[string]string `json:"env"`
	// BuildToken is a short-lived git clone token for a private host-built repo. Used
	// only to clone the source for the build, then discarded; never injected into the
	// running container. Empty for public repos and non host-built workloads.
	BuildToken string `json:"buildToken,omitempty"`
	// ImportSourceURL is the external Postgres source connection string for an
	// in-progress data import. Used only to dump the source; never injected into the
	// running container's env. Empty when there is no active import.
	ImportSourceURL string `json:"importSourceUrl,omitempty"`
}

WorkloadSecrets is the decrypted env for one workload, from the secrets endpoint. Plaintext values live only here and in the container; never logged.

type WorkloadSpec

type WorkloadSpec struct {
	// ID is the stable identifier for this workload on the host.
	ID string `json:"id"`
	// EggID is the customer-facing Egg identifier. Safe to show in the dashboard
	// and logs.
	EggID string `json:"eggId"`
	// BlobID is the internal Blob identifier for the same unit. Never render this
	// in user-facing text.
	BlobID string `json:"blobId"`
	// ImageRef is the OCI image reference (registry/name@digest or
	// registry/name:tag).
	ImageRef string `json:"imageRef"`
	// Replicas is the desired number of running replicas.
	Replicas int `json:"replicas"`
	// Port is the container port the workload listens on.
	Port int `json:"port"`
	// PublishPort optionally publishes the container Port to this host port, for
	// local development and demos, and for a game-server Egg (which needs a real
	// public host:port). Zero (omitted) for a plain web Egg in production, where the
	// ingress tier routes traffic and the agent publishes nothing.
	PublishPort int `json:"publishPort,omitempty"`
	// PublishProtocol is the transport to publish PublishPort with: "udp" for a
	// native game server (FishNet Tugboat), else "tcp" (the default when empty).
	PublishProtocol string `json:"publishProtocol,omitempty"`
	// Hostnames this Egg serves: its platform subdomain plus any verified custom
	// domains. The agent registers ingress routes for these and answers the ask
	// endpoint for them.
	Hostnames []string `json:"hostnames,omitempty"`
	// Env lists the names of environment variables the workload expects. Only the
	// keys travel over this contract. Secret values are injected out of band and
	// are never included here, and are never logged.
	Env []string `json:"env"`
	// HealthCheckPath is the HTTP path polled for health checks (when HealthProbe
	// is "http").
	HealthCheckPath string `json:"healthCheckPath"`
	// HealthProbe is how the agent decides a container is healthy: "http" (GET the
	// health path), "tcp" (connect to the port) or "running" (healthy whenever it
	// runs, for a database or game-server Egg that speaks a wire protocol). Empty
	// keeps the agent's existing volume/port heuristic.
	HealthProbe string `json:"healthProbe,omitempty"`
	// ReleaseCommand is an optional command from the repo Procfile's release: line
	// (e.g. "bin/rails db:migrate"). The agent runs it once as a one-shot container
	// with this deployment's image, env and private networks BEFORE rolling the
	// workload, and gates the roll on its success. Empty means no release step.
	ReleaseCommand string `json:"releaseCommand,omitempty"`
	// DeploymentID is the current deployment's id. The agent echoes it in a
	// ReleaseReport so the control plane attaches the release outcome to the exact
	// deployment that ran it (a redeploy points the workload at a new deployment).
	// Reporting only; the agent does not otherwise interpret it.
	DeploymentID string `json:"deploymentId,omitempty"`
	// Revision is an opaque deployment revision. It changes on redeploy, which
	// changes the desired-state version and rolls the container even when the
	// image is unchanged. The agent does not interpret it.
	Revision string `json:"revision,omitempty"`
	// EnvHash is a hash over the env set (keys plus ciphertext). It changes when a
	// value changes, rolling the container. Carries no plaintext.
	EnvHash string `json:"envHash,omitempty"`
	// Networks are the private-network peerings this Egg joins: one dedicated
	// two-party bridge per explicitly peered sibling, each with the alias this Egg
	// answers to on it. Deny-by-default: empty means fully isolated. The agent
	// joins the isolated base bridge plus one bridge per entry, so only an
	// explicitly peered sibling shares a network and can route to this Egg.
	Networks []NetworkAttachment `json:"networks,omitempty"`
	// NetworkName is the deprecated single-network form, kept for one version of
	// skew. Preferred is Networks; this is used only when Networks is empty.
	NetworkName string `json:"networkName,omitempty"`
	// InternalAlias is this Egg's alias on the deprecated NetworkName.
	InternalAlias string `json:"internalAlias,omitempty"`
	// Volumes are persistent named volumes to mount, for stateful Eggs (databases).
	// Each survives container recreation, so the data outlives a redeploy or
	// restart. Empty for stateless (web) Eggs.
	Volumes []VolumeMount `json:"volumes,omitempty"`
	// Migration, when set, is a database Egg migration in flight this host has a part
	// in (source: snapshot + upload; target: download + restore). Nil for a normal
	// workload. See MigrationDirective.
	Migration *MigrationDirective `json:"migration,omitempty"`
	// Build, when set, tells this host to build the image from source LOCALLY (bring
	// your own host) before running it, so the customer's code never leaves the box.
	// Nil for a normal, already-built or registry-pulled workload. See BuildDirective.
	Build *BuildDirective `json:"build,omitempty"`
	// Import, when set, is a one-off data import into this database Egg from an
	// external Postgres source (pg_dump piped into the Egg's own container). Nil when
	// there is no active import. See ImportDirective.
	Import *ImportDirective `json:"import,omitempty"`
	// Backup, when set, is a backup capture or restore for this database Egg (pg_dump
	// to a durable host file, or restore of one). Nil when there is no active backup.
	// See BackupDirective.
	Backup *BackupDirective `json:"backup,omitempty"`
	// Limits are the hard resource limits enforced by the agent.
	Limits ResourceLimits `json:"limits"`
	// EnvValues is the decrypted env as "KEY=VALUE" lines, populated locally by the
	// agent from the secrets endpoint. It is never on the wire (json:"-") and is
	// never logged.
	EnvValues []string `json:"-"`
	// BuildToken is a short-lived git clone token for a PRIVATE host-built repo,
	// populated locally from the secrets endpoint. Never on the wire (json:"-"),
	// never logged, and never injected into the running container.
	BuildToken string `json:"-"`
	// ImportSourceURL is the external Postgres source connection string for an
	// in-progress data import, populated locally from the secrets endpoint. Never on
	// the wire (json:"-"), never logged, passed to the import as an env var not argv.
	ImportSourceURL string `json:"-"`
}

WorkloadSpec models a single workload the agent should run on a host. One WorkloadSpec models one Egg (the BlobID is the internal identity of that Egg).

Jump to

Keyboard shortcuts

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