Skip to content

The driver spec

Built

For: someone writing or reading a driver’s spec. An admin attaching an existing driver does not need this page: the Drivers page covers the catalog, the attach flow and checking a spec. Author a spec with omniglass driver create --spec ..., and check it with omniglass driver validate before you save (see check, preview, and run a poll now).

A driver’s body is its spec (ADR-0135): a versioned declarative document (data, not code) naming the transport it rides, the inputs an attach must supply (host, port, credentials as secret references), and its three function families (poll functions, listeners, command bindings). The detail blade renders the spec as the menu it is: what each poll asks and what lands, what each listener waits for, what each command binding actuates. On a line protocol a listener’s arm commands (the subscribe conversation) are sent on every connection the outpost holds, its match rule claims the component’s pushes, and each claimed line lands as a sample, an event or a log line with no poll involved (a listener rides a held line session or a udp socket, and is refused at write on any other transport, where nothing would run it); a request may declare its reply shape (request.reply, a prefix or regex) so its answer is picked out of those pushes, plus an optional error shape (reply.error) for the device’s refusals, which then answer the request as a failure carrying the device’s text instead of timing out. Every regex in a spec is Go RE2 with substring semantics: INPUT \S+ also matches EVT INPUT hdmi2, so anchor a pattern meant to match a whole line (^INPUT \S+$). unmatched: collection-failed makes a line nobody claims a collection fault, and unmatched: log a log line on the component, rather than a counted discard (routing). An emit names a collected key. A built-in key (every outpost-probe or platform key, listed from the code), command-issued, or a key a calc rule outputs is refused at the spec’s write, naming the key, since each has its own writer (who writes a key): the outpost would otherwise take a driver’s value as its own observation, the pin or the gate. A spec stored before that refusal is held to it where it acts: the worklist strips such an emit from the tasks an outpost receives (the rest still run), a re-derivation never bakes one, and the server names the spec and its tasks in a warning at boot so you can mend it.

An emit lands on any of the four lanes (an emit lands on any lane). A metric or a property names its key and one extract. An event names its event type and carries a message and attributes, each a constant (value) or an extract with an optional transform (a cast to int or float renders a number in the payload); the message defaults to the whole claimed line or answer, and attributes the event type’s payload_schema closes out, or leaves out a field it requires, are refused at write. A log line declares log instead of a name, with its severity and facility (each a constant or an extract), its source (by default the endpoint’s transport), a message and attributes; its severity maps onto RFC 5424’s eight levels (warn reads warning, err reads error, and a word the table does not know is kept as the severity_raw attribute). A log line always lands: a message that does not extract falls back to the whole line, and a severity or attribute that does not is left out, each a collection-failed naming it. Any emit may read its time from what it reads (ts, an extract and a layout: rfc3339, rfc3164 with an optional zone, unix, unix-ms, or go: a Go reference layout); a time more than five minutes ahead lands at arrival. On a plain poll an event or a log line lands when its content changes, not every run. unmatched: log lands each line no listener claims as a log line, whole. The shipped newtron-panel-nvp lands an input push as the video-input property and an input-changed event, the panel’s diagnostics lines as log lines with their severity, and anything else it pushes as raw log lines:

unmatched: log
listeners:
- name: events
arm: ["SUBSCRIBE INPUT", "SUBSCRIBE SCENE"]
match: { prefix: "EVT INPUT " }
emits:
- { name: video-input, extract: { regex: "^EVT INPUT (\\S+)$" } }
- name: input-changed
message: { value: "Video input changed" }
attributes:
input: { extract: { regex: "^EVT INPUT (\\S+)$" } }
- name: logs
arm: ["SUBSCRIBE LOG"]
match: { prefix: "LOG " }
emits:
- log:
severity: { extract: { regex: "^LOG (\\S+)" } }
facility: { value: panel }
message: { extract: { regex: "^LOG (?:\\S+\\s+)?(.+)$" } }

A spec may declare a session block, the auth step the held session runs before anything rides it (auth and rejection). session.login is a login dialog: its steps each wait for a prompt (expect, a prefix or regex that may match a prompt with no line ending, such as login: ) and send a line, which may name a secret input’s field (${secret.login.password}, the input declared kind: secret), and its ready match says the login passed. session.terminal lists the replies retrying cannot fix, each a match with a class (auth, host-key, certificate, protocol): a line matching one, during the login or answering any request, moves the session to rejected, where the outpost attempts nothing more until the endpoint’s connection fingerprint changes (its secret is rotated, its address, port or transport changes, the driver’s login declaration changes) or an operator retries it (Retry on the rejected session’s notice in the console, or omniglass endpoint retry <component>/<endpoint>, with endpoint:retry); a label edit changes nothing. session.reprobe (at least 5m, default never) lets a rejected session try once more on its own. A wrong password the component answers with a declared refusal then costs one attempt rather than a retry every 30 seconds; a component that hangs up on a wrong password without saying so costs three (the login budget), and then reads rejected as auth. Anchor a prompt’s regex (^login: ?$): a prompt is matched on a line the component pauses on, and an unanchored one also matches a banner such as Last login: . A spec whose session only commands would ride (no poll or listener to hold it) refuses at write. Over ssh the session’s auth step is the transport’s own: session.credential names the secret input it authenticates with (required: a basic-auth username and password, or an ssh-key username and private key; a session.login beside it only answers keyboard-interactive questions, and a question nothing declared answers, such as a one-time code, rejects the session), session.pty asks for a terminal and session.exec runs a command as the channel instead of a shell. The host key is trusted on first use and kept as the endpoint’s ssh-host-key; when it changes the session reads rejected naming both keys, which the gate carries as data (the refusal’s entry in endpoint-rejection ends with the pinned and the offered key). The console’s Trust this key on the session’s notice trusts the offered one after a confirm (held sessions), and so does omniglass endpoint retry <component>/ssh --host-key <the offered key>. While the refusal holds, the key must be the offered one it names (any other is refused, 409, and changes nothing; retry without a key first to have the outpost read a key the component presents since); with no refusal held, --host-key declares a pin ahead of time, for a replacement whose key you already know.

A driver on tls speaks the line protocol over a TLS connection, its handshake the transport rung (tls). How the handshake judges the certificate is the driver’s tls-mode input, a string input the engine reads by name, like host and port: verify (the certificate chains to one of the outpost’s system roots and names the host), pin (the first public key offered is trusted, any other refused) or skip (nothing is checked). The driver declares its default, as the official newtron-nvp-tls declares pin for gear that signs its own certificate; a driver that declares no tls-mode input verifies; and a spec that defaults it to skip refuses at write, since skipping verification is only ever an operator’s choice. An operator edits the mode in location on the endpoint like any input, which moves its connection fingerprint, so a session a certificate refused tries again under the new mode with no retry. A refused certificate reads rejected with class certificate and its reason; for a pinned key that changed, the reason names both keys and omniglass endpoint retry <component>/tls --certificate <the offered key> trusts the new one.

transport: tls
inputs:
- { name: host, kind: string, required: true }
- { name: port, kind: number, default: "51326" }
- { name: tls-mode, kind: string, default: pin }

A spec may also declare its reachability ladder (ladder), bottom up: ladder.ping.enabled (whether to ping at all; a ping is informational only and never gates), ladder.transport.rung (the gate: connect on the transport’s port, the protocol’s handshake, or a named request answered, given as ladder.transport.request, where an open port cannot be detected; it runs as a line over tcp, a datagram over udp, or a get over snmp) and ladder.session.enabled (whether a login rung exists). Every field defaults from the transport registry, so most drivers declare nothing, and a rung the transport cannot run refuses at write. A cloud API is never pinged, but its 443 is checked open before its session runs:

transport: http
ladder:
ping: { enabled: false }
transport: { rung: connect }

A refusal at a rung gates that rung and the ones above it for the endpoint; the rungs below keep reporting (the gate), except an snmp endpoint’s get, which carries the community, so beneath its auth gate it is not sent and reads up, held (held: auth since <ts>): the refusal was an answer.

A udp driver speaks the line protocol as datagrams (udp). An open udp port cannot be detected, so it must name its request rung, and it may declare a listen-port input, the local port its endpoint binds, which its requests leave from and the component’s pushes arrive on (unset, the outpost picks one, which suits a component that answers to a request’s source). A datagram counts as the component’s when it comes from the component’s address, from any port, so gear that answers from a separate send socket works; one from any other address is dropped and logged. Every udp request declares its reply’s shape (reply), since a datagram’s answer is told from a late reply to another ask only by it. An endpoint whose host is a DNS name follows the name when it moves: the outpost re-resolves it once per tick, bounded by half the endpoint’s timeout, and keeps the socket, so a component that changes address is found again without a restart (a literal IP is never resolved). A request may declare retries (udp only, 0 to 5), how many times a lost datagram is re-sent within the endpoint’s timeout: a poll and the request rung default to 2, and a command to none, so declare them only on a command that is safe to send twice (one that names its value, never a relative step):

transport: udp
inputs:
- { name: host, kind: string, required: true }
- { name: port, kind: number, default: "51327" }
- { name: listen-port, kind: number }
ladder:
transport:
request: { line: "GET INPUT", reply: { prefix: "INPUT " } }
commands:
- command_type: set-input
request: { line: "SET INPUT ${value}", reply: { prefix: "INPUT " }, retries: 2 }

Over udp a session block may declare only terminal replies: nothing logs in or is held, and a reply it names gates the endpoint at the transport rung.

An snmp driver’s rung is a get of a standard OID, sysUpTime.0 unless it names another under ladder.transport.request.get (numeric OIDs only; a line is refused), sent with the endpoint’s community secret. A v2c agent drops a wrong community silently, so it reads not answered and retryable; an agent answering authorizationError reads rejected, class auth:

transport: snmp
ladder:
transport:
request: { get: ["1.3.6.1.2.1.1.2.0"] }

An http or https driver sends real requests (http and https). A request declares its method (GET unless it says otherwise), path, query, headers, a body (a JSON value, encoded by its body_format: json, form, xml or text) and the answer’s format (json, xml, html or text, declared rather than read off the Content-Type, which gear mislabels). An emit locates its value with one selector the format admits: a jsonpath on a json answer, an xpath on an xml answer (its prefixes declared on the request’s namespaces) or on an html page, a regex on any. A selector must find exactly one value: none, or more than one outpost, is a fault naming the emit, and the rest still land. A command’s request renders ${value} and ${arg.<key>} where you place them, escaped for where they land (a path segment, a query value, a JSON or xml body), and a JSON body leaf that is exactly ${value} keeps the value’s type, so an intended volume is sent as a number. A device’s own units are shaped at the edge, so the platform holds the canon either side: an emit’s transform: { scale: 0.01 } reads a device’s percentage as the ratio (41 lands as 0.41), and a command binding’s transform: { scale: 100 }, the inverse, scales the intended value before ${value} is substituted (an intended 0.41 goes out as 41). A response settle reads the reply back through the same scale, so it compares to the intended value in the canon’s units. A command’s transform declares a scale alone, and refuses a value that is not a number. A request never names a secret and never sets Authorization or Cookie: the credential is the session block’s.

transport: https
inputs:
- { name: host, kind: string, required: true }
- { name: port, kind: number, default: "443" }
- { name: tls-mode, kind: string, default: pin }
- { name: login, kind: secret, secret_type: basic-auth, required: true }
session:
credential: login
scheme: basic
polls:
- name: audio
schedule: { every: 30s }
request: { path: /api/audio }
emits:
# The bar reports 0 to 100; volume stores the ratio (0 to 1).
- { name: volume, extract: { jsonpath: volume }, transform: { scale: 0.01 } }
- name: firmware
schedule: { every: 1h }
request: { path: /api/status.xml, format: xml, namespaces: { d: "urn:polaris:dsp:1", sys: "urn:polaris:system:1" } }
emits:
- { name: firmware-version, extract: { xpath: "/d:status/sys:device/sys:firmware" } }
commands:
- command_type: set-volume
transform: { scale: 100 } # the intended ratio, in the bar's 0 to 100
request: { method: POST, path: /api/audio/volume, body: { volume: "${value}" } }
settle: { from: response, success: { regex: '"ok":\s*true' } }

session.scheme says how the credential session.credential names rides every request: basic (a basic-auth secret), bearer (a bearer-token), api-key (an api-key, placed by session.api_key: { in: header, name: X-Census-Key } or { in: query, name: apikey }), or digest (a basic-auth secret answered as HTTP digest, MD5 or SHA-256: the outpost holds the component’s challenge, answers a stale nonce afresh, and never sends the password). A 401 to a credentialed request reads rejected, class auth, and nothing credentialed is sent again until the endpoint’s connection fingerprint changes; a session.terminal rule may name a status (a gear’s 403 for a wrong credential) or a body match. Any other 4xx faults that request alone and waits its interval; a 408, 429 or 5xx retries on the backoff, no sooner than a Retry-After; a redirect is not followed. The reachability probe never sends the credential, so an http endpoint’s endpoint-authenticated is proven by its polls; a driver whose commands carry a credential needs a poll to carry it to the outpost. Over https the tls-mode input and the pinned key work as over tls (above), and omniglass endpoint retry <component>/https --certificate <the offered key> trusts a changed key.

Gear whose web API signs in once declares session.login instead of a scheme (logging in over http): the login dialog a telnet driver declares, its steps requests. A step names only the secret fields it sends (${secret.login.password}); the outpost keeps the session it opens (the component’s cookies, the values capture locates in the last answer, the headers that send them) in its memory alone, per endpoint, and logs in again only when a request draws a 401, a redirect to the declared login path, or the declared expired text, then replays that request once. A form login:

session:
login:
path: /login
steps:
- request:
method: POST
path: /login
body_format: form
body: { username: "${secret.login.username}", password: "${secret.login.password}" }

A token login captures the token and sends it as a bearer; expiry renews it before it lapses:

session:
login:
steps:
- request: { method: POST, path: /api/login, body: { username: "${secret.login.username}", password: "${secret.login.password}" } }
capture: [{ name: token, extract: { jsonpath: token } }]
expiry: { jsonpath: expires_in }
headers: { Authorization: "Bearer ${session.token}" }
expired: { regex: "token expired" }

A login the component refuses (a 401, a redirect back to the login page, another 4xx, or a last answer without its ready text or a value it captures) is tried once: the endpoint reads rejected, class auth, with the component’s reason, and logs in again only when the fingerprint moves (fix the secret in place with omniglass secret update, or edit the endpoint’s inputs). A login answered with a 5xx or a dropped connection is retried, but the third in a row reads rejected too. A session refused right after a fresh login reads rejected, never a second login. expiry is seconds, held between 10 seconds and 30 days; zero or a missing value means none. A login declares no scheme beside it, its step paths open with a literal /, and a header it sends names only a capture, never a secret, Cookie or a header a poll or command sets.

A component whose web page updates live from a server-sent events stream declares the stream in its session block, and listeners claim its events (a server-sent events stream). The stream is a GET (a path, a query, headers other than Accept and Last-Event-ID, which the outpost sends), read as json (the default) or text, and it rides the session’s scheme or login like every request. A listener over http declares no arm (a stream has no upstream); its match may name the event (event: change), and carry one data rule: a prefix, a regex, or a JSON field ({ path: path, equals: status.audio.volume }, or a regex in place of equals):

session:
credential: login
scheme: basic
stream: { path: /api/events }
listeners:
- name: volume-change
match: { event: change, field: { path: path, equals: status.audio.volume } }
emits:
- { name: volume, extract: { jsonpath: value }, transform: { scale: 0.01 } }

The outpost holds the stream as the endpoint’s session: it reads up, recovering after a drop (it resumes from the last event id after the server’s retry, landing nothing twice), and rejected when the component refuses its credential, which also gates the endpoint’s polls and commands. A stream needs a listener (with none, nothing holds it), and a listener over http needs the stream.

A component whose control API is a websocket declares transport: websocket (or wss, over the TLS handshake, with a tls-mode input as tls and https take), and one held socket carries its polls, its commands and its listeners (websocket and wss). session.upgrade is the GET that opens it (a path, the root when absent, a query, headers, never one the handshake owns), riding the session’s scheme (basic, bearer or api-key; not digest) or an http login. A request is a frame: a line sent as is, or a JSON body (a whole-leaf ${value} keeps the intended value’s type). Its reply may correlate by a field: the outpost writes a fresh id into that field of the body each time it sends it, and the answer is the frame carrying the id back, so pushes and other answers between never confuse it. A listener’s arm is the subscribe frame, sent on every connection (one line, compact JSON), and its match claims a push as any held session’s does, a JSON field match the usual choice:

transport: wss
session:
credential: login
scheme: basic
upgrade: { path: /api/ws }
listeners:
- name: volume-change
arm: ['{"type":"subscribe","paths":["status.audio.volume"]}']
match: { field: { path: path, equals: status.audio.volume } }
emits:
- { name: volume, extract: { jsonpath: value }, transform: { scale: 0.01 } }
commands:
- command_type: set-volume
transform: { scale: 100 }
request: { body: { type: set, path: status.audio.volume, value: "${value}" }, reply: { correlate: id, error: { regex: '"type":"error"' } } }
settle: { from: response, extract: { jsonpath: value } }

A component that answers a request without echoing an id declares a field reply instead (reply: { field: { path: type, equals: result } }), or a prefix or regex for a text frame. The socket reads up, recovering when the component drops it or stops answering the outpost’s pings, and rejected when the upgrade is refused with a 401 or a 403, after one attempt.

A telnet driver:

session:
login:
steps:
- { expect: { regex: "^login: ?$" }, send: "${secret.login.username}" }
- { expect: { regex: "^Password: ?$" }, send: "${secret.login.password}" }
ready: { prefix: "Newtron Panel 7 NVP ready" }
terminal:
- { class: auth, match: { prefix: "auth rejected" } }
reprobe: 1h

A command binding declares its settle rule to read the device’s answer: settle: { from: response, ... } to judge the reply as success or failure (extracting a value or matching a confirmation), or settle: { from: observe } to wait for the next probe to report the intended value (or simply record the issue if the device answers nothing you can judge). A fire-and-forget command (for example reboot) sets no value: it has no target_property_type or target_metric_type arm in the command type catalog. Fire-and-forget commands settle at their issue (the execution report lands them or times them out) and declare no settle rule. A settleable command (for example set-input) sets a value and opens an intended one, and judges success by reading the reply or waiting for the next probe to observe it.

A poll’s schedule.every is how often the outpost asks the device, on the outpost’s own timer rather than its heartbeat: a 10s poll runs every ten seconds at a stable phase of its own, whatever the heartbeat (ADR-1634). A poll whose fetch fails (the device rebooting, say) retries sooner, on a backoff that starts at one second and doubles up to the interval, so a daily poll is not lost for a day. A listener’s pushes land as they arrive whatever the schedule. Changing a spec (or its version) reaches the endpoints already attached through it: their tasks re-derive in the update’s own transaction, under its one audit row, and the next poll runs the new spec; an official spec a new release ships reaches them at boot the same way. A row without a spec is a stub and cannot be attached; specs are authored over the API or CLI (omniglass driver create --spec ...) and validate at write, so a spec that references an unregistered sample name, an unknown secret shape, or a broken template refuses with the fault named (422). Attaching a driver to a component happens on the component’s own detail (outposts and reachability): the spec derives the endpoint and its tasks. Its inputs (the host, the port, an attached secret’s name) then edit in place on the endpoint’s blade or with omniglass endpoint update <component>/<endpoint> --inputs ..., checked against the spec’s declared inputs; no re-attach. Clearing an optional input restores its default; a required one cannot be cleared.

A cloud service or a component that posts to omniglass declares transport: webhook (push ingress). Nothing is dialed, so the spec declares listeners alone (no poll, no command, no ladder), and the server hosts them. The session block says how a post is authenticated, never by default: scheme: hmac with a credential naming an hmac-key secret input and a webhook.signature (the header it rides, algorithm sha256 or sha1, encoding hex or base64, a prefix such as sha256=, and the timestamp header the sender signs, joined to the body by a separator), scheme: token with a bearer-token input and webhook.token (its header and prefix), scheme: basic with a basic-auth input, or scheme: none, which checks nothing and leaves the endpoint reading unsigned. Teach hmac over a signed timestamp first: a timestamp more than five minutes off is refused, and webhook.delivery (the header carrying each post’s delivery id) makes a sender’s redelivery land once. webhook.format says how the body is read (json, xml, form read by key, or text), webhook.challenge names the query parameter a sender’s GET verifies the URL with, and a listener’s match may read a header the sender sets (header: { name, equals } or regex). What no listener claims lands as a log line, and a claimed post also lands its raw line unless the listener says log: false. The shipped ucc-webhook driver maps the simulated UCC service’s meetings:

transport: webhook
inputs:
- { name: signing-key, kind: secret, secret_type: hmac-key, required: true }
session:
scheme: hmac
credential: signing-key
webhook:
signature: { header: X-UCC-Signature, prefix: "sha256=", timestamp: X-UCC-Timestamp }
delivery: X-UCC-Delivery
listeners:
- name: meeting-started
match: { header: { name: x-ucc-event, equals: meeting.started } }
emits:
- name: call-started
message: { value: "Meeting started" }
attributes: { meeting: { extract: { jsonpath: meeting } } }
- { name: call-state, extract: { jsonpath: event }, transform: { map: { meeting.started: active } } }

Attaching it creates the endpoint and mints its token, the webhook-token secret on the component: reveal it with omniglass secret reveal <component id>/webhook-token (audited) and give the sender /api/v1/webhooks/<token> on the server’s address and the signing key. omniglass endpoint rotateToken <component>/webhook mints another, and the old URL answers 404 at once.