plugins

package
v0.3.165 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

plugins

The host side of Loomux's plugin system (LOOM-178, docs/design/target-providers.md §1). A plugin is a separate program loomuxd starts or connects to, described by a manifest, speaking loomux-plugin/1: JSON-RPC 2.0 in Content-Length frames over the subprocess's stdio or a unix socket. The host drives it; a plugin never calls into loomuxd. In this first step the only method group every plugin serves is plugin.* (describe, configure, check, shutdown); the target-provider group (targets.*, machines on demand) is the next PR.

Layout

  • manifest.go — Manifest (plugin.json: name, version, protocol, capabilities, permissions, config_schema) and its validation; the JSON Schema subset the configuration schema may use, with Validate, ApplyDefaults, SecretFields and Split.
  • protocol/ — the protocol's vocabulary: method names and the parameter and result types of plugin.*. Imports nothing of Loomux, so the host, the SDK and any plugin share it.
  • rpc/ — the wire layer: frames of at most 1 MiB, Conn (the host's side: calls with deadlines, notifications) and Serve/ServeWriter (a plugin's), whose Writer also carries the plugin's notifications.
  • sdk/ — what a plugin's main calls: implement Plugin, hand it to Main; stdio with no arguments, a socket with --listen (the sidecar form). A plugin that implements Notifying (return a *sdk.Notifier, zero value ready) can call Notifier().TargetsChanged(id, status) when a machine changes on its own; the host reconciles it within a moment instead of at its next pass (LOOM-213). It's a hint, dropped when no host is connected. A target provider that implements ReadOnlyAttacher (and declares targets.attach_read_only) answers a read_only targets.attach_commands with commands that attach read-only (tmux … attach -r), for a person who only watches (LOOM-272); without it the SDK fails such a call rather than answer with the writable commands.
  • fake/ + cmd/loomux-plugin-fake — the test plugin: scripted behaviour (crash, hang, exit after configure) and a check that reports any LOOMUX_* variable it can see. Not shipped.
  • catalog.go — Catalog: plugins found in the bundle directory (bundled, trusted as the image is), the operator's plugin directory (unsigned, until a Verifier says otherwise) and the socket directory (sidecars, isolation: container).
  • instance.go — Instance: one running plugin. A subprocess gets a clean environment (never LOOMUX_*), its stderr goes to the log, it is restarted with backoff and failed after three exits in five minutes; a socket is redialled while it is away. The handshake refuses a plugin whose describe doesn't match the manifest on disk.
  • manager.go — Manager: install (schema-validated configuration, secrets encrypted at rest, the installed manifest kept on the row), get/list (secrets shown as set or not), reconfigure in place, enable, disable, upgrade (the new version is started beside the old and checked before the swap; a failure leaves the old one running), check (unavailable, not an error, while the supervisor is restarting the plugin), uninstall with an explicit choice for the plugin's machines, StartAll at boot, Health, two metrics. Lifecycle operations are serialised per plugin id, so concurrent calls can't leave an instance running that the manager doesn't know; a supervisor that gives up marks the row; and everything a plugin produces (stderr, errors, check problems) is scrubbed of its own configured secrets before it is stored, shown or logged.
  • plugintest/ — the conformance suite any plugin must pass.

Run go test ./... from the repo root. The package's own tests build cmd/loomux-plugin-fake once and drive it as a real subprocess and over a socket.

Documentation

Overview

Package plugins is the host side of Loomux's plugin system (LOOM-178, docs/design/target-providers.md §1): the manifest, the catalog of available plugins, the supervisor of a running one, and the manager that installs, configures and runs them.

Index

Constants

View Source
const (
	// IsolationNone: a subprocess, loomuxd's own user; it could read
	// loomuxd's database and environment.
	IsolationNone = "none"
	// IsolationContainer: a sidecar reached over a socket; its own user
	// and mounts.
	IsolationContainer = "container"
)

Isolation values (Available.Isolation): what separates the plugin from loomuxd's process.

View Source
const (
	// StateRunning: connected, configured, taking calls.
	StateRunning = "running"
	// StateRestarting: the process exited (or the socket dropped) and
	// the instance is bringing it back; calls are unavailable.
	StateRestarting = "restarting"
	// StateFailed: given up (three exits in five minutes, or a handshake
	// that keeps failing); Reason says why. Stop and Start again to
	// retry.
	StateFailed = "failed"
	// StateStopped: Stop was called.
	StateStopped = "stopped"
)

Instance states (InstanceStatus.State).

View Source
const (
	DefaultCallTimeout       = 30 * time.Second
	DefaultStopTimeout       = 10 * time.Second
	DefaultRestartBackoff    = time.Second
	DefaultReconnectInterval = 2 * time.Second
)

Defaults an InstanceOptions zero value gets.

View Source
const (
	UninstallDestroy = "destroy"
	UninstallKeep    = "keep"
)

What an uninstall does with the plugin's machines (design §1.5).

View Source
const (
	DefaultSocketWait           = 10 * time.Minute
	DefaultSocketWaitBackoff    = time.Second
	DefaultSocketWaitMaxBackoff = 30 * time.Second
)

Defaults for a Manager's socket wait (#465): as long as the seed retries a missing plugin (LOOM-219).

View Source
const (
	SeedCreate    = "create"
	SeedUpdate    = "update"
	SeedUnchanged = "unchanged"
	SeedNotOurs   = "not the seed's"
	SeedKeep      = "keep"
	SeedPrune     = "prune"
	SeedError     = "error"
)

What ApplySeed does with an instance (SeedAction.Do).

View Source
const ManifestFile = "plugin.json"

ManifestFile is the manifest's file name in a plugin's directory.

View Source
const ProtocolV1 = protocol.Version

ProtocolV1 is the protocol this host speaks.

View Source
const ReasonWaitingForSocket = "waiting for the sidecar's socket"

ReasonWaitingForSocket is the instance reason (state restarting) of a sidecar plugin whose socket isn't there yet.

Variables

View Source
var ErrBadLabel = errors.New("plugins: label: lowercase letters, digits and '-' only, at most 32, starting with a letter or digit")

ErrBadLabel is an install with a label outside the grammar.

View Source
var ErrBadUninstallMode = errors.New("plugins: targets must be destroy or keep")

ErrBadUninstallMode is an uninstall with a targets choice that isn't destroy or keep.

View Source
var ErrManifestMismatch = errors.New("plugins: the plugin's manifest doesn't match the one on disk")

ErrManifestMismatch is a plugin whose describe doesn't match the manifest the host read for it.

View Source
var ErrNotAvailable = errors.New("plugins: not available")

ErrNotAvailable is a plugin the catalog doesn't have.

View Source
var ErrUnavailable = &rpc.Error{Code: rpc.CodeUnavailable, Message: "the plugin isn't running"}

ErrUnavailable is a call while the instance isn't running.

View Source
var KnownCapabilities = []string{
	"targets.create",
	"targets.stop_start",
	"targets.recreate",
	"targets.persistent",
	"targets.ephemeral",
	"targets.egress_policy",
	"targets.attach_commands",
	"targets.attach_read_only",
}

KnownCapabilities are the capabilities a manifest may declare. Each maps to UI affordances and host behaviour; the host refuses a method a plugin didn't declare.

Functions

func DialSocket

func DialSocket(ctx context.Context, path string) (*rpc.Conn, error)

DialSocket connects to a plugin's unix socket.

func ExecutableName

func ExecutableName(name string) string

ExecutableName is the executable's name in a plugin's directory.

func MergeSecrets

func MergeSecrets(stored, update map[string]string) map[string]string

Merge returns stored with the keys of update written over it (an update's secret omitted keeps the stored one; "" clears it).

func Refused added in v0.3.78

func Refused(err error) bool

Refused reports whether err is an *IncompatibleError the host acts on (as opposed to one it only warns about).

func SeedSummary added in v0.3.112

func SeedSummary(actions []SeedAction) string

SeedSummary is actions on one line: "label: do (detail) [warning]; …".

func ValidPluginLabel

func ValidPluginLabel(label string) bool

ValidPluginLabel reports whether label can name an installed plugin.

func ValidPluginName

func ValidPluginName(name string) bool

ValidPluginName reports whether name can name a plugin.

Types

type Available

type Available struct {
	Manifest Manifest
	Source   registry.PluginSource
	// Path is the plugin's directory, or its socket.
	Path  string
	Trust string
	// TrustReason is why a plugin from the plugin directory isn't
	// verified, "" when it is or doesn't need to be (LOOM-218).
	TrustReason string
	Isolation   string
	// Incompatible is why this host refuses the plugin (below its
	// min_host_version, or another major: Manifest.HostCompatible), ""
	// when it doesn't; an install answers 409 with it. Warning is why
	// the plugin may not match this host though it runs (built for an
	// older 0.Y). The entry is listed either way, so the UI can say.
	Incompatible string
	Warning      string
}

Available is a plugin the catalog found (installed or not).

type CapabilityDroppedError

type CapabilityDroppedError struct{ Capability string }

CapabilityDroppedError: an upgrade whose new manifest lacks a capability the plugin's machines rely on.

func (*CapabilityDroppedError) Error

func (e *CapabilityDroppedError) Error() string

type CapabilityMissingError added in v0.3.69

type CapabilityMissingError struct{ Method, Capability string }

ErrCapabilityMissing is a call of a method the plugin's manifest doesn't declare the capability for.

func (*CapabilityMissingError) Error added in v0.3.69

func (e *CapabilityMissingError) Error() string

type Catalog

type Catalog struct {
	BundleDir string
	PluginDir string
	SocketDir string
	Verifier  Verifier
	Logger    *slog.Logger
	// HostVersion is this server's version string (version.Version),
	// against which every manifest's min_host_version is checked.
	HostVersion string
}

Catalog finds plugins in the three places the host looks (design §1.8): the image's bundle directory, the operator's plugin directory, and the socket directory where sidecars listen. An empty directory setting is skipped.

func (*Catalog) Available

func (c *Catalog) Available(ctx context.Context) ([]Available, error)

Available lists every plugin found, bundled first, then the plugin directory's, then sockets, each group by name. An entry that can't be read (a bad manifest, a missing executable, a socket nobody answers on) is logged and skipped; the listing itself only fails when a configured directory can't be read.

func (*Catalog) Find

func (c *Catalog) Find(ctx context.Context, name string, source registry.PluginSource) (*Available, error)

Find returns the plugin called name from source.

type CheckFailedError

type CheckFailedError struct {
	Reason   string
	Problems []protocol.Problem
}

CheckFailedError: the plugin started but can't work; Reason says why in one line and Problems carry its check's findings, if it got that far.

func (*CheckFailedError) Error

func (e *CheckFailedError) Error() string

type ConfigError

type ConfigError struct {
	Field string
	Msg   string
}

ConfigError says which configuration field is wrong and how; safe to show.

func (*ConfigError) Error

func (e *ConfigError) Error() string

type HasMachinesError

type HasMachinesError struct{ N int }

HasMachinesError: an uninstall of a plugin that still owns machines, with no choice made for them.

func (*HasMachinesError) Error

func (e *HasMachinesError) Error() string

type HealthReport

type HealthReport struct {
	// Status is healthy (every enabled plugin runs and checks ok, or
	// none is installed) or degraded.
	Status  string
	Error   string
	Plugins map[string]PluginHealth
}

HealthReport is the plugin system's health for GET /health/deep.

type IncompatibleError added in v0.3.78

type IncompatibleError struct {
	Name, Version, MinHost, Host string
	Refuse                       bool
}

IncompatibleError: a manifest built for another Loomux than this host (LOOM-194). Refuse says the host won't run it (below its min_host_version, or another major); otherwise it runs, warned about: a plugin built for an older 0.Y than the host's. Safe to show.

func (*IncompatibleError) Error added in v0.3.78

func (e *IncompatibleError) Error() string

type InstallRequest

type InstallRequest struct {
	Name   string
	Source registry.PluginSource
	Label  string
	Config map[string]any
}

InstallRequest is what Install needs.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance is one running plugin: a supervised subprocess, or a connection to a sidecar's socket, kept up until Stop.

func Start

func Start(ctx context.Context, o InstanceOptions) (*Instance, error)

Start starts (or connects to) the plugin, runs the handshake (describe must match o.Manifest) and configures it. A handshake failure returns the error with nothing left running.

func (*Instance) Call

func (i *Instance) Call(ctx context.Context, method string, params, result any) error

Call sends method to the plugin with the call deadline. While the instance isn't running it returns ErrUnavailable.

func (*Instance) Check

func (i *Instance) Check(ctx context.Context) (protocol.CheckResult, error)

Check runs plugin.check.

func (*Instance) Label

func (i *Instance) Label() string

Label is the plugin instance's label.

func (*Instance) Status

func (i *Instance) Status() InstanceStatus

Status is the instance's state.

func (*Instance) Stop

func (i *Instance) Stop(ctx context.Context) error

Stop asks the plugin to shut down, then ends the process or the connection; a subprocess still alive after StopTimeout is killed.

type InstanceOptions

type InstanceOptions struct {
	Label  string
	Source registry.PluginSource
	// Path is the plugin's directory (subprocess) or socket.
	Path     string
	Manifest *Manifest
	// Config is the whole configuration, secrets included, for
	// plugin.configure.
	Config map[string]any
	Host   protocol.HostInfo
	Logger *slog.Logger
	// OnCall, if set, is told about every call's outcome (for metrics).
	OnCall func(method string, err error)
	// Redact, if set, scrubs text the plugin produced (stderr lines,
	// handshake errors) before it is kept or logged: the plugin's own
	// secrets must not come back out through it.
	Redact func(string) string
	// OnState, if set, is told of every state change, outside the
	// instance's lock; it must not block on a Stop of this instance.
	OnState func(i *Instance, st InstanceStatus)
	// OnNotify, if set, receives the plugin's notifications.
	OnNotify func(method string, params json.RawMessage)

	CallTimeout       time.Duration
	StopTimeout       time.Duration
	RestartBackoff    time.Duration
	ReconnectInterval time.Duration
}

InstanceOptions is what Start needs.

type InstanceStatus

type InstanceStatus struct {
	State  string
	Reason string
}

InstanceStatus is where a running plugin is.

type Manager

type Manager struct {

	// MachineCounter reports how many machines a plugin instance owns.
	// Nil means none (before the target-provider capability exists).
	MachineCounter func(ctx context.Context, pluginID string) (int, error)
	// UninstallMachines deals with a plugin's machines on uninstall,
	// mode UninstallDestroy or UninstallKeep. Nil means there are none
	// to deal with.
	UninstallMachines func(ctx context.Context, pluginID, mode string) error
	// InstanceOptions, if set, adjusts every instance's options before
	// it starts (tests shorten the supervisor's timings).
	InstanceOptions func(*InstanceOptions)
	// OnNotify, if set, receives every plugin's notifications with the
	// plugin instance's id.
	OnNotify func(pluginID, method string, params json.RawMessage)
	// RequireVerified refuses to install, upgrade to or start a plugin
	// from the plugin directory that nothing vouches for (LOOM-218,
	// verify.go; plugins/attest verifies): the app sets it unless
	// LOOMUX_PLUGIN_ALLOW_UNSIGNED.
	// Bundled plugins and sidecars aren't affected.
	RequireVerified bool
	// SocketWait is how long a sidecar plugin whose socket isn't there
	// yet (no such file, or nothing listening on it) keeps being started
	// again before its row is marked error (#465). The retries back off
	// from SocketWaitBackoff, doubling, up to SocketWaitMaxBackoff.
	// NewManager sets the defaults; a zero SocketWait fails at once.
	SocketWait, SocketWaitBackoff, SocketWaitMaxBackoff time.Duration
	// contains filtered or unexported fields
}

Manager installs, configures and runs plugins (design §1.5). It owns the rows and the running instances; nothing else touches either. Lifecycle operations on one plugin are serialised by a lock per plugin id, so two requests (a double-click, a boot racing an enable) can never leave an instance running that the Manager doesn't know.

func NewManager

func NewManager(store registry.Store, catalog *Catalog, host protocol.HostInfo, logger *slog.Logger, met *metrics.Metrics) *Manager

NewManager makes a Manager over store and catalog. host is what every plugin is told at configure; met may be nil.

func (*Manager) ApplySeed added in v0.3.105

func (m *Manager) ApplySeed(ctx context.Context, s *Seed, dryRun bool) (actions []SeedAction, pending bool)

ApplySeed brings the installed plugins in line with s, as its doc says, and returns what it did; with dryRun it only works out and returns what it would do. pending reports entries that failed before anything was made (their plugin isn't in the catalog yet: a sidecar still starting), which a later ApplySeed may complete.

func (*Manager) Available

func (m *Manager) Available(ctx context.Context) ([]Available, error)

Available is the catalog.

func (*Manager) Call added in v0.3.69

func (m *Manager) Call(ctx context.Context, id, method string, params, result any) error

Call sends method to the plugin instance id, refusing a method whose capability the installed manifest doesn't declare, and ErrUnavailable while the instance isn't running. Errors a plugin answers with come back as *rpc.Error, their text redacted.

func (*Manager) Capabilities added in v0.3.69

func (m *Manager) Capabilities(ctx context.Context, id string) ([]string, error)

Capabilities are the installed manifest's, for plugin id.

func (*Manager) Check

func (m *Manager) Check(ctx context.Context, id string) (*View, error)

Check runs the plugin's check again and records the result. While the instance is restarting (a transient the supervisor is handling) the row is left alone and the error is ErrUnavailable.

func (*Manager) Close

func (m *Manager) Close(ctx context.Context) error

Close stops every running plugin and ends every socket wait.

func (*Manager) Disable

func (m *Manager) Disable(ctx context.Context, id string) (*View, error)

Disable stops the plugin and keeps everything else. Its machines keep working as plain targets; only lifecycle control pauses.

func (*Manager) Enable

func (m *Manager) Enable(ctx context.Context, id string) (*View, error)

Enable starts a disabled plugin (or retries one in error). A plugin already running is left as it is.

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, id string) (*View, error)

Get is one installed plugin.

func (*Manager) Health

func (m *Manager) Health(ctx context.Context) HealthReport

Health reports every installed plugin.

func (*Manager) Install

func (m *Manager) Install(ctx context.Context, r InstallRequest) (*View, error)

Install installs a plugin from the catalog with config, starts it, and checks it. The row is kept on a failure (status error) so the configuration can be fixed; the error then is a *CheckFailedError.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]*View, error)

List is every installed plugin, by label.

func (*Manager) RunSeed added in v0.3.105

func (m *Manager) RunSeed(ctx context.Context, s *Seed, dryRun bool) bool

RunSeed logs what s would do, as one "plugins seed plan" line, and unless dryRun applies it, logging each instance's outcome (an error as a warning). It reports whether entries are pending (ApplySeed).

func (*Manager) Running added in v0.3.69

func (m *Manager) Running(id string) bool

Running reports whether plugin id's instance is running.

func (*Manager) SetConfig

func (m *Manager) SetConfig(ctx context.Context, id string, config map[string]any) (*View, error)

SetConfig replaces the plugin's configuration: a secret left out keeps its stored value, "" clears it. A running plugin is reconfigured and checked again; one in error is started again.

func (*Manager) StartAll

func (m *Manager) StartAll(ctx context.Context) error

StartAll starts every enabled plugin at boot. A failure marks its row and goes on; the error returned is them joined, for the log.

func (*Manager) Uninstall

func (m *Manager) Uninstall(ctx context.Context, id, targets string) error

Uninstall stops the plugin, deals with its machines as targets says (required when it has any), erases its secrets and removes the row.

func (*Manager) Upgrade

func (m *Manager) Upgrade(ctx context.Context, id string) (*View, error)

Upgrade moves the plugin to the catalog's version of it. No-op when the versions match. The new version is started beside the old one and checked; only then is the old one stopped and the row changed. If the new one can't start or fails its check, it is stopped again, the old version keeps running, the row keeps its version, and the error is a *CheckFailedError.

type Manifest

type Manifest struct {
	Name           string          `json:"name"`
	Title          string          `json:"title"`
	Version        string          `json:"version"`
	Protocol       string          `json:"protocol"`
	Vendor         string          `json:"vendor"`
	Homepage       string          `json:"homepage"`
	Description    string          `json:"description"`
	MinHostVersion string          `json:"min_host_version"`
	Capabilities   []string        `json:"capabilities"`
	Permissions    []Permission    `json:"permissions"`
	HostRequests   []string        `json:"host_requests"`
	ConfigSchema   json.RawMessage `json:"config_schema,omitempty"`
}

Manifest describes a plugin (plugin.json beside its executable, or what plugin.describe returns).

func DescribeSocket

func DescribeSocket(ctx context.Context, path string) (*Manifest, error)

DescribeSocket asks the plugin on path for its manifest, validated.

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

ParseManifest reads and validates a manifest. Unknown fields are ignored: a newer plugin may carry more than this host knows.

func (*Manifest) Equal

func (m *Manifest) Equal(o *Manifest) bool

Equal reports whether two manifests agree on what the host compares at the handshake: name, version, protocol and capabilities.

func (*Manifest) HasCapability

func (m *Manifest) HasCapability(c string) bool

HasCapability reports whether the manifest declares c.

func (*Manifest) HostCompatible added in v0.3.78

func (m *Manifest) HostCompatible(host string) error

HostCompatible checks this host's version against the manifest's min_host_version (user decision 2026-10-11): nil when it is met on the same line; an *IncompatibleError with Refuse when the host is below the minimum or on another major (from 1.0, the major is the compatibility unit); one without Refuse, a warning, when the plugin was built for an older 0.Y than the host's (under 0.x the minor is the unit, but such a plugin still runs). A manifest without a minimum, or a host without a version (dev, a plain commit build), is compatible with anything.

func (*Manifest) ProtocolMajor

func (m *Manifest) ProtocolMajor() (int, error)

ProtocolMajor parses the manifest's protocol ("loomux-plugin/1").

func (*Manifest) SameCapabilitiesAndSchema added in v0.3.78

func (m *Manifest) SameCapabilitiesAndSchema(o *Manifest) bool

SameCapabilitiesAndSchema reports whether o declares the same capabilities (as a set) and the same configuration schema as m, whatever its version: what lets the host adopt a plugin's new version without an upgrade (D3, LOOM-194). Defaults are not part of the schema's shape: a stamped build changes the agent_image default with every agent rebuild, and a stored setting that still equals the old default follows the new one at adoption (Manager.followDefaults).

func (*Manifest) Schema

func (m *Manifest) Schema() (*Schema, error)

Schema returns the manifest's configuration schema; an absent one is an empty object (no configuration).

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate refuses a manifest the host can't accept. Its errors are safe to show.

type Permission

type Permission struct {
	Scope  string `json:"scope"`
	Detail string `json:"detail"`
}

Permission is one thing a plugin declares it needs on the infrastructure: for informed consent, shown before install.

type PluginHealth

type PluginHealth struct {
	Name     string `json:"name"`
	Status   string `json:"status"`
	Instance string `json:"instance,omitempty"`
	Reason   string `json:"reason,omitempty"`
	CheckOK  bool   `json:"check_ok"`
	Machines int    `json:"machines"`
}

PluginHealth is one plugin's line in the report.

type Property

type Property struct {
	Type        string   `json:"type"`
	Description string   `json:"description"`
	Default     any      `json:"default"`
	Enum        []any    `json:"enum"`
	Minimum     *float64 `json:"minimum"`
	// Secret fields are stored encrypted, never returned, and shown as
	// set/not set. Only a string may be secret, and only at the top
	// level.
	Secret bool `json:"x-secret"`
	// Format tells the UI which widget to show: ssh-private-key,
	// kubeconfig, image-reference, socks5-url.
	Format               string               `json:"x-format"`
	Properties           map[string]*Property `json:"properties"`
	Required             []string             `json:"required"`
	AdditionalProperties *Property            `json:"additionalProperties"`
}

Property is one schema property.

type Schema

type Schema struct {
	Type       string               `json:"type"`
	Properties map[string]*Property `json:"properties"`
	Required   []string             `json:"required"`
	// AdditionalProperties, when set, is the schema of any key not in
	// Properties (a map of sizes); nil refuses unknown keys.
	AdditionalProperties *Property `json:"additionalProperties"`
}

Schema is the subset of JSON Schema a manifest's config_schema may use: an object of string, integer, number, boolean and object properties, with required, enum, default, x-secret and x-format. The web renders it as a form.

func (*Schema) ApplyDefaults

func (s *Schema) ApplyDefaults(config map[string]any) map[string]any

ApplyDefaults returns a copy of config with every absent top-level field that has a default filled in.

func (*Schema) FollowDefaults added in v0.3.79

func (s *Schema) FollowDefaults(config map[string]any, from *Schema) map[string]any

FollowDefaults returns a copy of config in which every top-level setting that still equals from's default, where s's default differs, is set to s's default: a setting the operator never changed follows the plugin's new default (the stamped agent image pin, LOOM-194), one they set stays. Secret fields are never touched.

func (*Schema) SecretFields

func (s *Schema) SecretFields() []string

SecretFields are the top-level fields marked x-secret, sorted.

func (*Schema) Split

func (s *Schema) Split(config map[string]any) (plain map[string]any, secrets map[string]string)

Split separates a validated configuration into its plain part and its secret fields (as strings; the schema makes them strings).

func (*Schema) Validate

func (s *Schema) Validate(config map[string]any) error

Validate refuses a configuration the schema doesn't describe: a missing required field, a wrong type, a value outside its enum or minimum, or a key the schema doesn't name.

type SecretRef added in v0.3.105

type SecretRef struct {
	Env  string `json:"env,omitempty"`
	File string `json:"file,omitempty"`
}

SecretRef says where a secret's value is: exactly one of an environment variable or a file (its content, trailing newlines trimmed).

type Seed added in v0.3.105

type Seed struct {
	// Prune uninstalls the instances the seed made and no longer lists
	// (those without machines).
	Prune   bool        `json:"prune"`
	Plugins []SeedEntry `json:"plugins"`
	// Machines are persistent machines to make on those instances
	// (LOOM-236): made when missing, their policy kept as the seed says,
	// never destroyed (prune doesn't apply to them).
	Machines []SeedMachine `json:"machines"`
}

Seed is LOOMUX_PLUGINS_SEED.

func ParseSeed added in v0.3.105

func ParseSeed(raw string) (*Seed, error)

ParseSeed reads LOOMUX_PLUGINS_SEED: JSON when it starts with "{", else the path of a file holding it. Unknown fields and a seed that can't be right (no label, a label twice, a secret both inline and referenced) are errors: the server doesn't start on one.

type SeedAction added in v0.3.105

type SeedAction struct {
	Label  string
	Do     string
	Detail string
	// Warning is what the seed asks for and didn't do because only the
	// API may (a machine change that needs a recreate): logged as a
	// warning beside the action.
	Warning string
}

SeedAction is what ApplySeed did, or would do, with one instance (or ApplyMachineSeed with one machine, Label then its name).

type SeedEntry added in v0.3.105

type SeedEntry struct {
	// Label names the instance, and is what the seed matches it by.
	Label string `json:"label"`
	// Plugin and Source are the manifest's name and where it comes from
	// (bundled, dir, socket), as POST /api/v1/plugins takes them.
	Plugin string                `json:"plugin"`
	Source registry.PluginSource `json:"source"`
	// Config is the configuration without its secret fields.
	Config map[string]any `json:"config"`
	// Secrets are the secret fields, each read from an environment
	// variable or a file.
	Secrets map[string]SecretRef `json:"secrets"`
}

SeedEntry is one plugin instance the seed declares.

type SeedMachine added in v0.3.112

type SeedMachine struct {
	Name string `json:"name"`
	// Plugin is the label of the plugin instance that makes it (seeded
	// or not).
	Plugin string `json:"plugin"`
	// Size, Persistent and Egress shape the machine; empty or left out
	// is the plugin's default. On an existing machine they are only
	// compared: changing one needs a recreate or a new machine, which the
	// seed logs and leaves to the API.
	Size       string `json:"size"`
	Persistent *bool  `json:"persistent"`
	Egress     string `json:"egress"`
	// The target options a machine takes (POST and PUT /api/v1/targets);
	// these can change on an existing machine, and the seed keeps them.
	PermissionMode      *string   `json:"permission_mode"`
	Purpose             *string   `json:"purpose"`
	AllowedAgentTypes   *[]string `json:"allowed_agent_types"`
	AllowProvision      *bool     `json:"allow_provision"`
	AllowShell          *bool     `json:"allow_shell"`
	RequireConfirmation *bool     `json:"require_confirmation"`
	Relay               *string   `json:"relay"`
	// KeepIdleSessions exempts the machine's sessions from the idle
	// reaper (LOOM-227), as a hub's must be.
	KeepIdleSessions *bool `json:"keep_idle_sessions"`
}

SeedMachine is one machine the seed declares: a target a plugin instance makes, as POST /api/v1/targets with a plugin object would. Name is the target's name, and is what the seed matches it by. A pointer field left out says nothing: the API's default on a create, the machine's current value after that.

func (SeedMachine) ApplyTargetOptions added in v0.3.112

func (m SeedMachine) ApplyTargetOptions(t *registry.Target)

ApplyTargetOptions sets on t the target options m gives, spelled the way the store keeps them (as the API's target decoding does).

type UnverifiedError added in v0.3.111

type UnverifiedError struct {
	Plugin, Reason string
}

UnverifiedError refuses to install or upgrade a plugin from the plugin directory that nothing vouches for (LOOM-218).

func (*UnverifiedError) Error added in v0.3.111

func (e *UnverifiedError) Error() string

type Verifier

type Verifier interface {
	// Verify is the trust of the plugin executable at path:
	// registry.PluginTrustSignedPrefix + the identity that signed it, or
	// registry.PluginTrustPinnedPrefix + its pinned digest; else
	// registry.PluginTrustUnsigned and why, for the person refused.
	Verify(ctx context.Context, path string) (trust, why string)
}

Verifier decides the trust of a plugin from the plugin directory (design §1.6, LOOM-218: AttestationVerifier). Nil means every such plugin is unsigned.

type View

type View struct {
	registry.Plugin
	// AvailableVersion is the catalog's version of the same plugin from
	// the same source, "" when it isn't in the catalog any more.
	AvailableVersion string
	// Check is the last check's result, nil if none ran.
	Check *protocol.CheckResult
	// Instance is the running instance's state; State "" when none runs.
	Instance InstanceStatus
	// Machines is how many machines the plugin owns.
	Machines int
	// SecretsUnreadable: the stored secrets don't decrypt with this
	// server's master key.
	SecretsUnreadable bool
}

View is an installed plugin as the API shows it: the row with its secrets replaced by whether each is set, plus what is only known at run time.

Directories

Path Synopsis
Package attest verifies plugin executables for loomuxd (LOOM-218): the plugins.Verifier the catalog asks about plugins from the plugin directory.
Package attest verifies plugin executables for loomuxd (LOOM-218): the plugins.Verifier the catalog asks about plugins from the plugin directory.
Package fake is a plugin for tests (docs/design/target-providers.md §12): no infrastructure behind it, and a configuration that scripts how it behaves, so the host's supervisor, manager and API can be exercised against a real subprocess.
Package fake is a plugin for tests (docs/design/target-providers.md §12): no infrastructure behind it, and a configuration that scripts how it behaves, so the host's supervisor, manager and API can be exercised against a real subprocess.
Command manifeststamp writes a release into plugin manifests at build time (LOOM-194; docs/release/versioning.md, "Images"):
Command manifeststamp writes a release into plugin manifests at build time (LOOM-194; docs/release/versioning.md, "Images"):
Package plugintest is the conformance suite a loomux-plugin/1 plugin must pass (docs/design/target-providers.md §12): the analogue of registry/storetest and targets/executortest.
Package plugintest is the conformance suite a loomux-plugin/1 plugin must pass (docs/design/target-providers.md §12): the analogue of registry/storetest and targets/executortest.
Package protocol is the loomux-plugin/1 protocol's vocabulary: the method names the host calls and the parameter and result types they carry (docs/design/target-providers.md §1.3).
Package protocol is the loomux-plugin/1 protocol's vocabulary: the method names the host calls and the parameter and result types they carry (docs/design/target-providers.md §1.3).
Package rpc is the wire layer of loomux-plugin/1 (docs/design/target-providers.md §1.3): JSON-RPC 2.0 messages in Content-Length frames, the LSP convention, over a subprocess's stdio or a unix socket.
Package rpc is the wire layer of loomux-plugin/1 (docs/design/target-providers.md §1.3): JSON-RPC 2.0 messages in Content-Length frames, the LSP convention, over a subprocess's stdio or a unix socket.
Package sdk is what a plugin's main calls to speak loomux-plugin/1 (docs/design/target-providers.md §1.3): implement Plugin, hand it to Main, and the plugin serves stdio when started with no arguments or a unix socket with --listen <path> (the sidecar form).
Package sdk is what a plugin's main calls to speak loomux-plugin/1 (docs/design/target-providers.md §1.3): implement Plugin, hand it to Main, and the plugin serves stdio when started with no arguments or a unix socket with --listen <path> (the sidecar form).

Jump to

Keyboard shortcuts

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