Skip to content

Commands

Partial

A command is one instruction sent to a component and its outcome: the “do” beside a metric or property (“know”) and an event (“happen”). It records what a component was told, and settles against what the component then reports. To issue and read commands, see commands; to manage the catalog, see command types.

A command type is something a component can be told to do. It sits beside the sample and event catalogs on the same shipped-and-local pattern (/command-types, gated by command_type:*), and carries what the abstract signal does not:

  • params_schema: the JSON Schema an issue’s params must satisfy; a violation is a 422 before anything is recorded.
  • The target: a settleable command names the value it sets in exactly one lane, target_property_type_id (set-input sets video-input) or target_metric_type_id (a volume), never both. A command with no target is fire-and-forget (reboot): its outpost’s execution report decides it.
  • settle_window_seconds: how long the device takes to act (a projector warms up in twenty seconds), so a difference from the reported value is not called a failure before then. At least 0.
  • The disruption: a disruptive type takes its device down. It carries a quiet_seconds, during which nothing runs against a held endpoint, and a hold_seconds backstop after which a held endpoint reopens anyway, counted as hold-expiry-count (ADR-1651). reboot is seeded disruptive (quiet 15 s, hold 300 s); a CHECK refuses a quiet or hold on a type that is not.
  • power_outlet_param: marks a power command, naming the param that carries the outlet. The seeded outlet-off is disruptive and power-marked; outlet-on is neither. Both require outlet as an integer from 1 to 4.
Terminal window
omniglass component command issue power-1 --command-type outlet-off --params '{"outlet": 2}'

A command intends its value in the canonical unit (set-volume intends a ratio, 0.41), and the driver’s command binding scales it to the device’s own range on the way out.

A disruptive delivery carries a hold set: the endpoints the command takes down. The outpost closes each one’s gate with reason disrupted before it sends. The server computes the set with one pure function over the dependency edges (ADR-1648):

  • A reboot holds the target’s in-band endpoints and those of every component it hosts, transitively. An out-of-band endpoint (a BMC, a management port) answers through a reboot, so its gate stays open.
  • A power command holds every endpoint of each component fed from that outlet, out-of-band ones included, and the in-band endpoints of what those host. The PDU’s own endpoints stay open.
  • Containment holds nothing: a child is not held because its parent rebooted, and a path dependent is held by the upstream gate reason, not by the disruption.

After quiet, each endpoint reopens on its own first up reading that began after quiet. The walk keeps a visited set, so a cycle cannot loop it.

Issuing a command composes the whole model

Section titled “Issuing a command composes the whole model”

POST /components/{name}/commands:issue, gated by command:issue, writes three things in one transaction:

  1. the command row: owner, type, params, actor, status = 'issued';
  2. a caused event, command-issued, on the component’s timeline. Its writer class is command-lifecycle, so nothing but a command writes one (writer class);
  3. for a settleable command, an intended row in the target lane naming the command as its lineage: the told of want, told, is.

The fence is the issue scope, not the read scope (ADR-0117): a user with a wide component read and a room-scoped command grant commands that room and no more. A component outside the caller’s read scope is a non-disclosing 404; one it can see but not command is a 403 (the three-way split).

An issue may wait. With wait, the issue holds until the command is terminal or wait_timeout (1 to 120 s, 30 by default) passes, and answers with the command as it stands. At most 64 waits run per server and 4 per user; a wait past either is a 429 refused before anything is issued.

The issue records; the wire actuates (ADR-0136):

  • A per-outpost pull. An outpost asks og.v1.command.<outpost> (request-reply) and receives the commands still issued on components that carry an endpoint it serves, whose driver binds the command’s type. A command no driver binds is never delivered. Exactly one actuating endpoint is chosen per command, so it reaches one outpost. The pull reads only its own components’ commands, through an index holding only deliverable rows.
  • Rendered at dispatch. The server resolves the binding’s request template at delivery: ${value} is the intended value, ${arg.key} an issue param. A substituted value carrying a control character is refused, so an operator’s value can never smuggle a second line onto the device. The outpost receives a finished instruction, never a template; a binding that cannot render is recorded terminal in exec_error.
  • At-least-once, idempotent. Each take stamps dispatched_at, the first first_dispatched_at, and counts delivery_count. A take whose report never lands is redelivered after 30 s of silence, and after ten minutes is no longer delivered. The outpost remembers each command’s outcome by id, so a redelivery repeats the report, never the actuation.
  • The report is confined. The outpost reports on og.v1.commandstatus.<outpost> with the device’s reply; executed_at stamps once, and only from the outpost serving the dispatched endpoint. A report from any other outpost is rejected and logged.

Queue health: each outpost’s command queue, measured

Section titled “Queue health: each outpost’s command queue, measured”

Every outpost’s command queue reports as platform metrics on the outpost’s platform component (ADR-1626):

  • command-dispatch-latency (issue to first take) and command-execution-latency (first take to report), one sample per command, written in the transaction of the stamp they derive from;
  • every 15 s, from one fleet-wide statement sharing the pull’s candidate resolution: command-pending-count and command-pending-age, command-stuck-count, and per window command-redelivery-count and command-expired-count (instance undelivered or unexecuted);
  • from the outpost, command-pull-failure-count, the pulls that got no usable answer.

Each is a count or a delay, 0 when healthy, and the loss ratios derive from them. Expiry keys on executed_at and age, not status, so a fire-and-forget command no outpost took counts as expired.

Settlement: the settlement is computed, the outcome is recorded

Section titled “Settlement: the settlement is computed, the outcome is recorded”

A command’s effect is a pure function of the intended value, the observation and the window:

  • none: nothing was told (fire-and-forget); the recorded status carries the outcome.
  • settled: an observation at or after the intent matches it, as soon as one arrives.
  • pending: within the window, no match yet.
  • failed: past the window, the latest observation does not match, or there is none.

The window bounds how long a command waits for its evidence, not when it may settle (ADR-0141). Where the evidence comes from is the driver’s to declare, per binding:

  • settle: { from: response, extract: { regex: ... } }: the reply carries the new value (SET INPUT hdmi3 answers INPUT hdmi3). The server settles or fails on it, and for a property target records the value as an observation, unless the device has already reported a newer one (ADR-1606).
  • settle: { from: response, success: { regex: ... } }: the reply only confirms (OK).
  • settle: { from: observe }, the default: the next observation of the target decides.

An execution error fails a response-settled command at once, and a sweep every few seconds judges each command whose window has passed, so one nothing settles reaches timed-out on its own.

Which observation judges it follows its instance: a named instance is judged on that series; one with no instance on the series of the endpoint carrying it; one no endpoint can carry on every live instance of its target, settled when any agrees. A command still queued when its window closes is a timeout that says where it stopped, never a failure.

A zero window is terminal by construction, never consulting a timestamp, and the comparison reads one clock, the database’s (ADR-0108).

Beside the computed settlement the row records its lifecycle: status is issued until a terminal settled, failed or timed-out, and a CHECK ties it to settled_at. Each terminal status writes a command-settled, command-failed or command-timed-out event on the component’s timeline in the same transaction, linked as settled_event_id.

Reading a command: from issue to settlement

Section titled “Reading a command: from issue to settlement”

GET /components/{name}/commands/{id} reads one command whole; GET /components/{name}/commands lists them newest first, narrowed by status, since, until and limit. Both need command:read, on the same three-way split as the issue. Each command carries:

  • what it was told: the type, params, intended value and target;
  • its timeline: issued_at, delivered_at, executed_at, settled_at, and its delivery history (first_delivered_at, delivery_count);
  • where it is now (phase, derived on read): queued, delivered, awaiting-reply, awaiting-observation, or its terminal status, with the deadline its window closes at;
  • how it settles (settle_mode) and what carried it: endpoint, outpost and driver;
  • the evidence and the why: the reply, the observation that decided it, settled_by (reply, observation or window), the execution error, and a reason in words;
  • who issued it, by name and uuid.

The reply is masked before it is stored (ADR-1155). A reply comes from a device the operator does not control, so the report’s reply and error are masked of the dispatched endpoint’s secret fields in the forms a device commonly echoes them (raw, url-, JSON-, html- and base64-encoded) and of anything the text labels a credential, then capped at 4 KiB. The masking (internal/redact) fails closed: a server that cannot read the endpoint’s secrets keeps neither reply nor error.

command_type (telemetry): generated from the migrated schema by make gen
Column Type Constraints Notes
id uuid PK, default uuidv7()
name text not null
label text
description text not null, default ''::text
params_schema jsonb The JSON Schema an issue's params must satisfy
settle_window_seconds integer not null, default 0 How long settlement waits for agreeing evidence
target_property_type_id uuid FK → property_type.id One arm of the target: the property it sets
official boolean not null, default false
registered_at timestamp with time zone not null, default now()
target_metric_type_id uuid FK → metric_type.id The other arm: the metric it sets; never both
namespace text not null, default 'local'::text
disruptive boolean not null, default false Whether it takes its device down, closing its hold set's gates
quiet_seconds integer not null, default 0 Nothing runs against a held endpoint for this long
hold_seconds integer not null, default 0 The backstop: a held endpoint with no up reading by then reopens
power_outlet_param text The param naming the outlet, on a power command
CHECK constraints and unique indexes on command_type
  • command_type_disruption_check: CHECK (((quiet_seconds >= 0) AND (hold_seconds >= 0) AND (disruptive OR ((quiet_seconds = 0) AND (hold_seconds = 0))) AND ((NOT disruptive) OR (hold_seconds > quiet_seconds))))
  • command_type_namespace_check: CHECK ((namespace ~ '^[a-z0-9][a-z0-9-]*$'::text))
  • command_type_og_official_check: CHECK (((namespace <> 'og'::text) OR official))
  • command_type_power_outlet_param_check: CHECK (((power_outlet_param IS NULL) OR (disruptive AND ((char_length(power_outlet_param) >= 1) AND (char_length(power_outlet_param) <= 64)))))
  • command_type_target_arc_check: CHECK (((target_property_type_id IS NULL) OR (target_metric_type_id IS NULL)))
  • command_type_namespace_name_key: CREATE UNIQUE INDEX command_type_namespace_name_key ON public.command_type USING btree (namespace, name)
command (telemetry): generated from the migrated schema by make gen
Column Type Constraints Notes
id bigint PK
ts timestamp with time zone not null, default now()
owner_kind text not null
instance text not null, default ''::text
params jsonb The issue's arguments, validated against the type's schema
actor uuid Who told it
component_id uuid FK → component.id
system_id uuid FK → system.id
location_id uuid FK → location.id
outpost_id uuid FK → outpost.user_id
command_type_id uuid FK → command_type.id, not null What the component was told to do
caused_event_id bigint FK → event.id The command-issued event
status text not null, default 'issued'::text issued until a terminal settled, failed or timed-out
settled_at timestamp with time zone The terminal moment; null exactly while issued
dispatched_at timestamp with time zone
executed_at timestamp with time zone
exec_error text
dispatched_endpoint_id uuid FK → endpoint.id The endpoint chosen to actuate over; anchors the report's confinement
reply text The device's answer, masked and capped
reason text
settled_by text What decided it: reply, observation or window
observed_value jsonb
observed_at timestamp with time zone
settled_event_id bigint FK → event.id The event its terminal status wrote
first_dispatched_at timestamp with time zone
delivery_count integer not null, default 0
CHECK constraints and unique indexes on command
  • command_owner_arc_check: CHECK ((((owner_kind = 'component'::text) AND (component_id IS NOT NULL) AND (system_id IS NULL) AND (location_id IS NULL) AND (outpost_id IS NULL)) OR ((owner_kind = 'system'::text) AND (system_id IS NOT NULL) AND (component_id IS NULL) AND (location_id IS NULL) AND (outpost_id IS NULL)) OR ((owner_kind = 'location'::text) AND (location_id IS NOT NULL) AND (component_id IS NULL) AND (system_id IS NULL) AND (outpost_id IS NULL)) OR ((owner_kind = 'outpost'::text) AND (outpost_id IS NOT NULL) AND (component_id IS NULL) AND (system_id IS NULL) AND (location_id IS NULL))))
  • command_owner_kind_check: CHECK ((owner_kind = ANY (ARRAY['component'::text, 'system'::text, 'location'::text, 'outpost'::text])))
  • command_settled_by_check: CHECK (((settled_by IS NULL) OR (settled_by = ANY (ARRAY['issue'::text, 'reply'::text, 'observation'::text, 'window'::text]))))
  • command_settlement_recorded_check: CHECK (((status = 'issued'::text) = (settled_at IS NULL)))
  • command_status_check: CHECK ((status = ANY (ARRAY['issued'::text, 'settled'::text, 'failed'::text, 'timed-out'::text])))