Stations and failover
A Station is a node running the ai6 daemon. It checks in to the shared Registry
with its roles, labels, capacity, active work, the Operation checkouts it has and its
host's CPU and memory (resources). One
control Station holds the Headquarters lease at a time and is the Headquarters Station
(HQS); M's authority follows that lease.
A Station's roles and labels are its station record (Configuration):
stations/<id>/station.toml in a configuration directory, or the station:<id> row of a
SQL provider, over the global station record. Start a Station with both roles, the
default:
ai6 serve --station hq-1
A standby control Station takes over the Headquarters lease if it expires (relocation to a fallback Station). The lease carries an election term that grows each time a different Station takes it; Run leases draw their fencing tokens from it (Recovery):
# stations/hq-2/station.toml
roles = ["control"]
An execution-only Station (an outstation) runs work but cannot hold the lease:
# stations/lab-gpu/station.toml
roles = ["execution"]
labels = { gpu = "yes" }
The default roles are control and execution. Every Station is also labeled with its
Station ID, host and operating system; the record's labels adds more.
The record's tables bound and pace the Station's own work: how often it checks in
([scheduler] check_in), how long its leases on Missions last without a renewal
([scheduler] lease, 180 seconds by default: keep it well above the longest a check-in takes on a
distant Registry), how much it holds for Universal Exports ([publisher]), how it
probes Theaters and re-attaches to Runs, how long its secret leases last, and so on, each
key with a default (Station runtime limits). Its
[providers.<id>] tables configure the handlers, terminals and safe houses it builds:
# stations/hq-1/station.toml
[scheduler]
check_in = 5
[providers.pty]
scrollback = 2000
Configured choices that loosen a default are reported at information level when applied. Outer Office's Station settings and Theaters views show the settings with their defaults. A choice that widens what an Agent can reach appears as a risk status badge. A feature or policy the Station could not apply gives a warning with the reason. An ambient credential found by a Theater probe also gives a warning.
A Mission's Timeline tells the operator when agents = "auto" chooses remote hands and names
what field mode needs. When a detached Run starts without a Cable endpoint under
cables = "optional", the Timeline explains which Theater capability was missing.
Serving Operations
Operations are global: they live in operations.toml, and no Station owns one. A Station
runs an Operation's Missions when its labels satisfy the Operation's station_labels and, for
a local Operation, when it has the checkout. One Station can serve many Operations, and
one Operation can be served by many Stations.
Placement
The Headquarters Station places each queued brief with M's placement. For one Mission it considers every Station that has checked in, each Theater that Station reaches (see Theaters) and each Agent posted to the Operation, and keeps the combinations that pass these checks:
| Check | A Station, Theater or Agent is ruled out when |
|---|---|
Operation stations |
the Operation lists Stations and this one is not among them |
Mission stations |
the brief narrows to Stations and this one is not among them. A Mission can only narrow the Operation's list, never widen it |
| Role | the Station has no execution role |
| Health | its last check-in is older than [registry.limits.stations] gone_dark_after, 180 seconds by default (gone dark) |
| Capacity | its capacity is 0, or it already holds that many Missions: its leases or the Runs it reported running, whichever is more |
| Resources | it reported less free memory than min_free_memory_mb (default 512) or a CPU busier than max_cpu_percent (default 95). The same limits rule out a Theater by its own sample. A figure that was not reported never rules anything out |
| Theater binding | the Operation's theater names a different Theater |
| Theater reachable | the Station cannot reach the Theater now (no transport provider, or the last contact failed), or has not reported what its transport can do |
| Theater capabilities | neither mode below is possible: field mode needs a route to the provider's API and either a runner on the Theater (reached with run on another host), terminal and files on the Station's own host, or, for the detached wrapper on another host, run, files, a POSIX host and a declared harness; remote-hands mode needs the transport's run. agents = "local" or "remote-hands" allows only that mode, and the reason names the missing capability |
| Theater requirements | the Theater declares requires and the Station's probe has not checked them yet, or its os, tools or disk_mb are unmet (see Fitting a Theater out) |
| Harness | in field mode, the Theater lists requires.harnesses and the Agent's handler is not among them or is not installed there; that Agent is ruled out on that Theater only |
| Labels | station_labels is not satisfied. Patterns are globs matched against the Station's labels overlaid by the Theater's |
| Checkout | in field mode on the Station's own host, the Operation has a local path and the Station does not hold it. On another host, and in remote-hands mode, the checkout is on the Theater, so the Operation must be bound to the Theater or the Theater must set a workdir |
| Handler | the Agent's handler is not available on the Station, so the next qualified Agent is the backup. A Station that did not report its handlers is not excluded |
Each (Station, Theater) that remains gets a load score from 0 (idle) to 4, the sum of
four shares from 0 to 1: the Missions the Station holds against its capacity, how busy the
CPU is (the CPU percent, or for a Theater the load average per CPU), the memory in use, and
the Station's Runs on that Theater against its capacity. A Theater on the Station's own
host is judged by the Station's sample. A figure that was not reported adds nothing, so a
Station that reports no resources scores on its Missions alone. The Operation's placement
decides the order: spread (the default) puts the lowest score first, pack the highest
(see Operations). Equal scores keep the order
without scores: the least-loaded Station first (the deciding Station wins a tie, then Station
ID), the local Theater before other Theaters, then the Agent with the highest priority.
The Headquarters Station judges each Station on what that Station published, never on its
own: a brief that names no Agent is offered, on each Station, the posted Agents whose handler
that Station has (so a handler the Headquarters Station lacks is no obstacle), and a Station
at its published capacity is passed over. The first choice whose Agent and Operation are
within their max_concurrent is taken; when there is none, the brief waits. Each choice also
says its mode:
field runs the harness on the Theater, remote-hands runs it on the Station and acts on the
Theater through its transport (see Theaters).
Ask before launching: GET /v1/user/operations/{id}/placement-preview on Universal
Exports (needs mission.read on the Operation) returns the eligible choices, best first,
each with its score, and a reason for every rejection. Outer Office's Stations view has a
Placement preview panel for it, and each Station card shows the host's CPUs, CPU busy,
load, free memory and when they were sampled (unknown for a figure not reported); a
Theater's tooltip shows its own and how many Runs run there. ai6ctl stations prints
the same figures as columns. Linux and macOS report their own one-minute load average. Windows
keeps none, so a Windows Station estimates one the way Python's psutil does: every
load_sample_every seconds (default 5, 0 leaves the load unknown) it reads the processor
queue, the threads waiting for a CPU, adds the CPUs that are busy (CPU percent times the
CPUs) so the number compares with a Linux host's, and folds the sum into an average with a
one-minute window. It is an estimate, and unknown until a full sample exists. The query parameters agent, role, stations and tags narrow it the
way a Mission would. The preview uses the Operation's policy as the Headquarters Station
published it at its last check-in, and it lists every Station in the Registry, not only
those hosting the Operation.
Terminal
The Station, not the Agent, decides which terminal provider harnesses run in. It uses
an available provider that suits what the handler declares: one without a terminal,
preferring pipe, for a harness that speaks JSON (Claude Code, Codex), else preferring
pty. The station record's terminal pins one, and a Mission whose harness the pin does not suit
is refused at start. See Terminals.
Shared Registry
Stations sharing a Registry coordinate check-ins, leases and Headquarters election. The
Registry is a directory every Station mounts, a SQLite file for a single Station, or a
PostgreSQL database for Stations that share no filesystem. The bootstrap file ai6.cfg
names it in [registry] location (or ai6 serve --registry LOCATION): a directory,
sqlite:PATH or a postgres:// URL. Without one the Station uses its configuration
provider's database when that is SQL, else registry in its state directory; the ai6
command reads the same file, and so does Universal Exports. One SQL
location therefore configures a whole HA deployment:
# /etc/ai6/ai6.cfg
[provider]
location = "postgres://ai6@db.internal/ai6?sslrootcert=/etc/ai6/db-ca.pem"
password = { provider = "file", key = "db-password" } # relative to this file
In a directory Registry lease expiry uses each Station's clock, so Stations need
synchronized clocks; a SQL Registry uses the database's clock. Check-ins expire after 45
seconds; a Station whose check-ins lapse has gone dark and its leased briefs are
recovered by the Headquarters Station: a Run a runner still supervises is adopted by
another Station, any other is lost and tried again (Recovery). The
Headquarters lease lasts 60 seconds between renewals; ai6.cfg's [registry]
headquarters_lease sets how long a standby control Station waits before taking over from one
that went dark.
In a SQL Registry each kind of record has its own table. Each open compares the tables and
indexes this build needs with what the database's catalog holds, under the same lock two Stations
opening together wait on, and makes only what is missing, so a new table needs no script. Nothing
runs when nothing is missing, so a role with no CREATE right starts on a database someone else
keeps up to date. A role that cannot make what is missing stops at start, naming itself, the schema
and what is missing: start that build once as a role that may, or create them from
crates/ai6/src/directorates/registry/sql/schema/postgres.sql, and grant them to it. A script still
does what moves data. A database whose schema version is newer than the Station knows is refused,
when it is opened and on every write.
The schema files alone make a column or table: a table a database lacks is made when it opens,
and every table is then compared with the columns this build makes it with. One that lacks a
column, such as a database from before the Session-to-Run rename or one with a column dropped by
hand, stops the Station naming the table and column, and nothing is moved or altered: what moves
data is a script run by hand. A column the build does not know, as a later build leaves after a
rollback, is allowed. A database made before this build may hold an ai6_schema_steps table; it
is left as it is and nothing reads it.
Every write first takes the Registry's row in ai6_clock, so writers queue as they do on the directory's lock, and leases, the Headquarters term and Run
fencing behave the same on every backend. A Station that stalls inside a write (a paused
VM, a half-open connection) loses its run after a quarter of the Headquarters lease,
so it cannot hold the others back from taking over: the statement, lock and idle
timeouts, and the connection's own, are derived from the Headquarters lease, and a
location that sets one itself keeps it. No secret is stored there: access tokens are kept
by digest, and credentials stay with Q.
PostgreSQL connections use TLS and verify the server: against the platform's trusted
roots, or only against sslrootcert=PATH when the location names a CA file. A location
may weaken that with sslmode=require (encrypted, server not verified) or
sslmode=disable (no TLS); ai6 serve and Universal Exports then print a warning at
start. Keep the password out of the location, where a process listing shows it: ai6.cfg's
[provider] and [registry] password take a secret reference:
{ provider = "file", key = "PATH" }, { provider = "env", key = "NAME" } or { provider =
"inline", value = "…" }; the last two are printed as a warning and reported at check-in. Messages print locations with the password hidden.
Stations and Universal Exports reach the Registry only through the RegistryBackend
traits (one per kind of record: briefs, Stations, Runs, Cables, approvals and so on),
which the directory (FileRegistry) and the database (SqlRegistry) implement; a program
embedding the Station can pass another store with ServeConfig::with_registry.
A Station's page in Outer Office
Outer Office's Stations page lists the Stations (a card each; once one is open, a row each) and opens the
one you pick as its page, at #/stations?station_id=ID. Its tabs have addresses of their own
(tab=overview, theaters, charge, settings, overrides, placement, audit), so a link or
Moneypenny can land on one and Back returns to the tab before. The header shows whether the Station is
online, degraded or dark, whether it is the Headquarters, and its configuration status (the revision it
runs, a refusal, or files that wait for a restart).
- Overview is the Station Watch: health, load, resources, roles, the Chief of Station's report, the Runs running there, and its configuration. A Station keeps only its newest refusal and clears it when it accepts a later revision, so a refusal it no longer reports is listed from the audit log, labelled historical.
- Theaters lists each Theater with what it can do, why it cannot be used, and any setting looser than its default.
- Charge is the Station's charge, as the Charges page draws it: live, decisions and logbook.
- Runtime settings is the Station's capacity and resource limits, and its full
stationrecord. - Overrides lists, for each kind of record a Station may have of its own, which records every Station
reads and which this Station overrides. It shows what an override changes, edits it for this Station and
reverts it to the global record (a person with
config.manageon the family). - Runs and placement lists the Runs running here and previews where an Operation's Mission would go.
- Audit is the audit log of this Station.
A tab shows only to a person who may read what it holds.
Capacity and visibility
Operators granted station.configure can change a Station's maximum concurrent Missions
(1 to [registry.limits.stations] mission_capacity, 1,024 by default) in Outer Office under
Stations → Settings; the change applies to new Missions and is
audited. The same settings hold the Station's resource limits, min_free_memory_mb (default
512; 0 never rules it out) and max_cpu_percent (default 95; 100 never does), set in the
same view or through PUT /v1/user/stations/{id}/settings; the Station publishes them at check-in and placement
applies them to the Station and each Theater it reaches. GET /v1/stations on Universal Exports returns the signed-in user's authorized
view of Station health, roles, capacity, the Operations each Station serves, the Theaters
each Station reaches and the current Headquarters Station; host and process details are
omitted.
Chief of Station
A Station answers for running, and for providing what the Operations that work on it ask of
it. The Chief of Station (head_of_station in code and in the settings) is the
charge that does this: one standing Run, station:<id>, kept by an Agent of your
choice on that Station. It is not a Mission and no Sleeper queues it; the Station wakes it with what
happened, and it takes a turn. It keeps the Station fit (its free space, its safe houses, its
Theaters), watches its Runs' progress, and answers the 00 Agents who ask it for an Agent, a Theater,
an account or capacity. It never judges an Operation's work: that is the Operation's 00 Agent's
(Missions).
# charge records (Roster, Charges)
[charge."station:hq-1"]
agent = "chief" # any Agent whose handler this Station can start
stall_after = 1800 # seconds a Run may make no progress before it is told of; "none" leaves it to the Run's watchdog
The charge's other settings (wake_every, max_turns_per_hour, lease, …) are the ones every
charge has (Charges); like them, stall_after is a record edited live,
never a restart-only setting. A Station's charge sends and receives Cables only once its table names an operation for them.
- One Run, a logbook. A single endless Run would hit context limits and spend tokens idling, so
the Station wakes the charge only for events (and every
wake_every); the Run is resumed across turns and restarts, and a fresh one is given the charge's logbook. The Station's own logbook of filed reports (the newest 20, kept in the Registry aslogbook/<station>.jsonor theai6_logbookstable) is what the next check-in publishes. - What wakes it. A Run that has made no progress for
stall_after, or that its own watchdog judged stalled (health, flagrun-stalled, told once per Run); a request of an Operation's 00 Agent (request, below); a quarantine of an Agent it works with; a Cable to the charge's Agent; a person's control; the timer. - Untrusted text.
station_reportquotes what other Missions' Agents wrote (commit subjects, branch names) and a request carries the asker's words, so a charge that reads them is treated as exposed to untrusted input: it sends no Cable that is not a reply, and its requests always go to a person.
Station tools and reports
The charge's Cable endpoint also lists tools that no other Run has. Every call checks again that this Station still runs the charge.
station_report: the Station's capacity and the Missions not over, each with how long its Run has made no progress and whether that counts asstalled; the queue (Missions this Station holds the claim on that have no Run here yet, and the briefs no Station has claimed); free space where its state and safe houses are; its resources; each Theater it reaches and why placement would not use it; every safe house it keeps (the Mission's state, age, size, cache directories and whether its work exists anywhere else, as the safe-house provider tells it); provider libraries loaded without a pin; and the limits below. It carries no secret: no environment value, token, loadout or brief text.file_report { summary, findings }: findings are typed (disk,theater,safe-house,provider,other) with a severity (info,warning,critical). The report goes into the logbook, is published with the Station's next check-in (head_of_stationinGET /v1/stationsfor people withstation.readonstation:ID, since it covers every Operation there, and on the Station's card in Outer Office), and is sent as a Cable to theheads-of-stationchannel whencables.tomldefines it and lets the Agent send there:
# cables.toml
[[grants]]
agent = "008"
action = "send"
scope = "channel"
name = "heads-of-station"
[channels]
heads-of-station = ["007", "008"]
The same report is also kept as a Report of the Station (kind station, filed by the
charge, linked to no Mission), read with station.read on station:ID; when it cannot be stored,
the logbook entry stands and the answer says why.
tidy_safe_house,provision_theater: below.surrender_claim { mission, reason? }: gives up this Station's claim on a stalled Mission. See Runs that make no progress.answer_request { request, operation, kind, name?, decision, reason? }: see What an Operation asks of a Station.
Keeping the Station's Missions working
The Chief of Station is told of stuck Missions whose Run is its Station's (a Run lost or ended
without settling its Mission, a Mission blocked or held for long; see
Stuck work) and fixes what it can with the area tools: board and
mission_detail (state and Runs, never the Operation's brief or report), settle_mission to file a
Mission nothing holds as failed or stalled, retry_mission, resume_mission and cancel_mission
for the Missions it holds, wake_charge to ask the Operation's charge to look, and notify_person
for what it cannot fix. Each act is audited with charge:station:<id> as the actor before it is taken.
It decides no outcome: a Mission waiting to be verified is its Operation's 00's, and when the
Operation has no charge the Chief says so with notify_person. A Mission of another Station answers
as one that does not exist. The thresholds are settings of the charge record
(Charges).
Runs that make no progress
A Run counts as stalled when it has made no progress (output, or an operator's input) for the charge's
stall_after, or when its own watchdog already judged the Mission stalled. A Run that waits on a
person (green ink, a question) is never stalled. The charge is told once per Run, and station_report
shows quiet_secs and stalled for every Run.
Sources that do not poll
Each Source's poll is in the check-in's source_polls: when one last finished, its state (never_ran
for a Source that has not polled yet, running, ok or failed) and, for a failed poll, the step it
failed at (build, cursor, fetch, deliver or cursor-store) with the error. A failed poll degrades the
Station (source-poll) with that step as the reason. When an item cannot be taken by the Registry the
poll fails at deliver and the cursor stays where it was, so the next poll offers the item again. An entry also
carries cursor_updated and cursor_age_secs, when its cursor was last stored and how long ago (null when none
is), and the check-in lists charges, each charge the Station runs with last_turn_ended and age_secs, so a
frozen cursor or a charge that stopped taking turns shows as an age. Neither is compared with a limit.
Only the Headquarters Station polls, so any other Station reports no Sources: the board is cleared whenever a
Station does not hold the lease, and a Station that takes it again starts from a fresh one. That clearing is the
acknowledgement: there is no verb to dismiss a source-poll entry. A poll that finds nothing still finishes and
clears it.
Trackers that do not take writes
The Headquarters Station checks every canary_every that each tracker instance of an Operation's
Sources still takes writes (Configuration). A failing check degrades the Station and
tells the Chief of Station of the instance (health, flag source-write-failing, with the instance as
<operation>/<instance>, the reason and when the failure began), once per failure: the same instance
failing again at the next check is the same failure, and a check that passes clears it, so a later
failure is told afresh. station_report lists the failing instances as source_writes while they
fail. The reason can quote what the tracker answered, so the event is untrusted text; it never carries
a credential. The Chief acts with notify_person.
surrender_claim is the one way the charge ends a Run, and the Station, not the charge, decides
whether it may: a Mission that is not stalled, one that waits on someone, one that is over, or one
this Station does not keep is refused and nothing is touched. When it is accepted the Station stops the
Run and lets its leases lapse, and the Registry queues the brief again (the Mission is abandoned here)
or files it under the Operation's on_lost, exactly as for a Run whose harness is gone. The surrender is
audited (head_of_station.surrendered).
What an Operation asks of a Station
The Operation's 00 Agent in charge asks with request_resources { kind, name?, detail?, station?,
idempotency_key? }, kind being agent, theater, account or capacity. The request is a record
in the Registry addressed to the Station's charge (default: the Station that runs the 00's charge), so
the two charges can be on different Stations. The Station's charge is woken with a request event that
carries the asker's words (untrusted) and the Station's own check of what it can provide:
| Kind | can_provide |
cannot_provide |
|---|---|---|
theater |
the Theater and an Agent M's placement would put a Mission on here | busy (the Operation's or Agent's max_concurrent or the Station's places are taken), not fitted (the Theater is not among the places that fit, with the unmet requirement), outside the Operation's allowance |
agent |
the Agent and the Theater it would run on | as above, plus a handler this Station lacks |
capacity |
a place, with the Theater and Agent | as above |
account |
the pools with an account that has room (no account is named or claimed) | no room, or outside the Operation's allowance (its pools) |
It answers with answer_request: provide, or refuse with the reason. The Station verifies a
provision again before it is promised, so a charge that says provide for what the Station cannot give
sends a refusal with the Station's reason. The answer is a record addressed to the Operation's charge,
which wakes with a resources event. Both are audited (resources.requested, resources.answered).
Being outside the Operation's allowance means the Operation's stations does not name this Station, a
station_labels entry does not match, or a pool does not admit it; the Station never judges the
Operation's work, only what it can run and provide.
The Station answers only a request the Operation's charge made of it: answer_request for a request
ID that is not among the Station charge's controls from that Operation, so one the charge was not woken
with in this turn, is refused and audited (resources.answer_refused), and nothing reaches the
Operation's charge.
Safe-house hygiene: fixed limits
Kept safe houses (the working directories of Missions that held work when they ended) grow
with their build caches. tidy_safe_house { mission, action } tidies them within limits the
Station enforces in its own code, whatever the prompt or the Operation's policy says:
| What | When |
|---|---|
Read anything station_report shows |
always |
caches: remove the cache directories (target, node_modules, .dart_tool; the station record's safe_house_caches replaces the list); in a Git safe house only those Git ignores whole |
unattended, for a Mission that is over whose safe house has been left alone for 7 days (safe_house_cache_age) |
remove a safe house whose work all exists elsewhere (every commit on a remote, checked against the remote itself; nothing uncommitted or untracked; ignored files only inside cache directories) |
unattended, for a Mission that is over |
remove a safe house holding anything else (unpushed commits, uncommitted or ignored files such as .env, submodules, Git LFS objects), or whose provider cannot tell (the copy provider) |
green ink, kind safe-house-delete, asked of the Operation the safe house belongs to; no class authorisation approves it. The charge carries on; a later call, in this wake or a later one, removes it once a person approved, spending that approval on that one removal |
provision_theater with apply: the steps a Theater's declaration calls for |
unattended; anything outside the declaration is a finding |
surrender_claim on a Mission whose Run is stalled |
unattended |
| Change configuration, the roster or policy; read a secret; act on another Station; touch the safe house of a Mission that is not over | never: the tools cannot, or refuse |
provision_theater { theater, apply } checks a Theater this Station reaches against its
declaration, or with apply runs exactly the declared steps (see
Provisioning); that is unattended because the operator
declared them, and a run that changed something is audited (head_of_station.provisioned).
A green ink request for a removal is made even when the Operation's green ink policy would let
the Agent delete unattended. A tidy holds the Mission's start reservation while it works, so a
retry or resume of that Mission waits for it, and a tidy of a Mission being started is
refused. Applying a Theater's provisioning is refused while a Mission of this Station works on
it, and a failed step's output is withheld from the charge (ai6 theater provision shows it). Every removal is audited (head_of_station.caches_removed,
head_of_station.removed) with the Station as its resource.
The /internal token
Every request to a Station's /internal API carries Authorization: Bearer TOKEN, the token in
the api-token file of its state directory (made on first start, readable only by its user on
Unix). To replace a leaked or aged one:
ai6 api-token rotate --config /etc/ai6/ai6.cfg
The command writes a new 256-bit token beside the file and renames it over api-token, so the old
token is refused from that moment, and a running Station follows the file on its next request:
nothing restarts. It prints the file's path and never the token. Every client of /internal (the
harness gate, the Cable tunnel, a script of yours) must read the file again; the file is the only
copy. The gateway's own credential for a Station is a separate matter and is not rotated here.
Auditing reads of Mission data
A read of a Mission through the Station's own /internal API (GET /internal/missions/{id} and the
Mission's Cable inbox and held lists) writes an internal.read record to the audit log before it
is answered, and is refused with 503 when the record cannot be written. The record names the
Mission's Operation, this Station (station:ID) and the route's template, never a query, a body or
the Mission's ID. Its actor is station-api: the API's bearer token is shared by everything that
reads it, so this is an access review of the API, not of a person; the person-level trail is the
gateway's (ai6ctl audit list --action run.context). Polling (events/next), the provider listings
and /healthz are not read from a Mission and write nothing. [api] audit_reads = false turns it off
and the Station logs the weakening.
Station identity
Stations do not connect to each other: they coordinate through the Registry, and each publishes to
Universal Exports. With the station-tls feature a Station still has an identity of its own, a
persistent certificate kept in identity.pem in its state directory, with the peers it trusts under
peers/, and beside it the sealing key logins are sealed to, published
in the Registry and signed by this identity. ai6 identity prints its fingerprint (sha256: and 64 hex digits), ai6 peer waiting lists
what is waiting in that store, and ai6 peer accept FINGERPRINT pins one; any spelling of a
fingerprint is read, grouped base32 included.
ai6::station::identity also holds the mutual TLS configurations for a link between Stations, the
ai6-station/1 protocol with the modern policy by default (TLS 1.3, SHA-2 pins), on the shared
coqui-peer-tls crate. A Station listens for other
Stations only when [station.peers] listen (or ai6 serve --peer-listen ADDRESS) names an address;
see the next section for how two Stations come to accept each other.
Pairing Stations
Two Stations meet without anyone copying a fingerprint. Both pin each other's certificate in their
peers/ store; pairing is how that happens. One port serves two ALPN protocols: ai6-station/1, strict (a
peer whose certificate this Station has not accepted is refused at the handshake and left waiting, as
ai6 peer waiting lists it), and coqui-pair/1, which takes a certificate nobody trusts yet, carries only
the pairing exchange, and ends with each side accepting the other's certificate. An unknown key that offers
ai6-station/1 is still refused. The listener answers a connection that completed ai6-station/1 with the
protocol's name, then takes and gives one successor-certificate announcement
(see Rotating a Station's certificate) and closes: the point is that both
ends pinned each other.
Three ways in, each switchable live in the station record's [peers] table (edited through
Universal Exports; ai6 serve restarts its peer listener loop itself when modes, lifetimes,
pin_attempts or max_connections change, and applies handshake_timeout on the next
connection):
| Mode | How | Default |
|---|---|---|
| Invitation | ai6 peer invite makes a one-use link (--uses N, --valid-for 24h, --label L, --address HOST:PORT) and prints ai6-join:sha256:ID/SECRET@HOST:PORT. The joiner runs ai6 peer join LINK. The joiner pins the inviter's id first and sends the secret only to that certificate, so a wrong address leaks nothing. |
on |
| Device flow | ai6 peer join ai6-join:sha256:ID@HOST:PORT (a link with no secret) prints a code and waits. The operator at the other Station runs ai6 peer pending CODE (the joiner's id, address and label, which is its own word and proves nothing), then ai6 peer approve CODE or deny CODE. |
on |
| PIN | ai6 peer pin at the listening Station shows a PIN; the joiner runs ai6 peer join --pin PIN ADDRESS. |
off |
ai6 peer ping ID ADDRESS connects over ai6-station/1, pinned by id, and prints what the Station says, to
check that both ends accepted each other. invite needs no running Station (the invitations are files in the
store); pin, pending, approve and deny call the running Station's /internal/pairing routes with its
API token, so they run on its host.
Beyond the host, operators enroll and pair peers through Universal Exports (/v1/user/stations/pairing/*,
each audited and gated by station.enroll on station:<id>). Universal Exports relays requests to the
named Station or the active Headquarters Station. The relay requires a Station proof unless the gateway
operator explicitly allows the shared Station token (AI6_EXPORTS_SHARED_STATION_TOKEN=on), which is
reported as a weakening.
- CLI (
ai6ctl):ai6ctl stations pair [--station ID]withinvite [--uses N] [--valid-for D] [--label L] [--address HOST:PORT],pin [--clear],pending [CODE],submit [--slot N](reads the PIN from stdin or a hidden prompt, never from argv),approve CODE --peer-id PEER_IDanddeny CODE. - Outer Office: each Station's Pairing tab (
#/stations?station_id=ID&tab=pairing, visible to people withstation.enroll) shows the listener state, non-secret status, waiting PIN slots, and[peers]weakenings (peers_weakened, also shown on/v1/stationsand as risk status where the settings widen credential reach), lets the operator mint invitations (automatically cleared on Refresh and at expiry), show/withdraw/submit PINs (cleared on Refresh and at expiry), and look up a device-flow code to see its peer ID, address and claimed label (marked unverified) before approving (bound to the inspected peer ID) or denying. - Moneypenny: reads pairing status through the gateway and can propose withdrawing a PIN with operator confirmation. Both require
station.enroll. Invitations, PINs and device-flow codes are credentials handled directly by operators.
| Key | Where | Default | |
|---|---|---|---|
listen |
[station.peers] (ai6.cfg) |
none | Where it listens for Stations. With none it listens nowhere. |
invitation, device |
[peers] (station record) |
true | Turn a mode off to refuse it (stricter). |
pin |
[peers] (station record) |
false | A weakening, reported at start and on change: a short secret, with pin_attempts as its only guard. Enables both Station-shown PINs and submitting a joiner-shown PIN (submit). |
pin_ttl, device_ttl |
[peers] (station record) |
600 | Seconds a PIN or a device code lasts; none never expires, reported. |
pin_attempts |
[peers] (station record) |
1 | Tries a shown PIN allows; more is reported. A wrong PIN spends the try, so the right one then finds none. |
invitation_uses |
[peers] (station record) |
1 | Maximum uses an operator-minted invitation may allow; more is reported. |
invitation_ttl |
[peers] (station record) |
86400 | Maximum lifetime in seconds (24 hours) for an operator-minted invitation; more is reported. |
max_connections |
[peers] (station record) |
256 | Connections served at once; more are closed unanswered. |
handshake_timeout |
[peers] (station record) |
10 | Seconds to finish the TLS handshake. |
| rotate_margin | [peers] (station record) | 2592000 | Seconds before its certificate ends that this Station makes a successor and announces it (30 days). |
| rotate_check | [peers] (station record) | 3600 | Seconds between the Station's looks at whether its certificate is due and its peers have the successor. |
| retire_after | [peers] (station record) | 604800 | Seconds a peer's old certificate stays accepted here after its successor is promoted (7 days); more is reported, 0 ends it at once. |
| require_approval | [peers] (station record) | false | A peer's successor waits for an operator here (promote_successor in the trust store) instead of being promoted by the first handshake that proves it. |
| switch_without_peers | [peers] (station record) | false | A peer this Station has no address for and that has not connected holds the switch until it does. true switches anyway and that peer refuses this Station until an operator pairs it again; a weakening, reported. |
Not yet available: ai6 serve --join. A device-flow joiner cannot be listed, only found by the code it shows: the pairing library keeps no list of them.
Rotating a Station's certificate
A certificate ends, and a key can leak, so a Station replaces its certificate without becoming a new Station.
Nobody runs a command: the Station looks every rotate_check seconds, and when its certificate ends within
rotate_margin it makes a successor (a new key, kept in identity.next.pem beside identity.pem).
- It announces the successor to each Station that accepted it, over an
ai6-station/1connection the current certificate authenticated. Only that key can name its successor: the peer's trust store records the announcement against the certificate the connection proved, so a Station it never accepted, an accepted one claiming another's successor, and a certificate nobody announced are all refused. The announcement goes in either direction of a connection: a Station also hands its successor to a peer that dials it. - It connects to the peer again presenting the successor. The peer's handshake proves the successor holds
its key and promotes it: the successor is accepted and the old certificate is accepted only for
retire_afterseconds more. Withrequire_approvalthe peer records the proof and refuses until its operator promotes the successor. - When every peer that accepted it has the successor, it switches: the successor becomes
identity.pemin one rename and the listener presents it from the next connection. A peer it has no address for (one that joined it, so it never dialed) is handed the successor when it next connects, and promotes it when this Station presents it. A Station learns where a peer listens fromai6 peer joinandai6 peer ping.
A peer that is itself rotating is followed the same way: a Station that dials it by the certificate it accepted accepts the successor the peer announced and promoted, and records where it now answers.
Replaying an old announcement does nothing: once a successor is promoted the old certificate is retiring, and a
retiring certificate cannot announce another. After the retire window the old certificate is refused at the
handshake. The trust store's rotation events (a successor announced, a successor promoted) and this Station's own
(station.identity.successor.made, station.identity.switched) are written to the Registry's audit log as
station.peer.successor.announced, station.peer.successor.promoted, station.identity.successor.made and
station.identity.switched.
The sealing key keeps working across a switch. Before it switches, a Station has its old identity sign a
link to the new one (kept in identity.succession.json) and re-publishes its sealing key signed by the new
identity with those links. A secret grant or ai6ctl secret grant --trust STATION=FINGERPRINT that names the old
fingerprint still holds: the check accepts a key signed by the pinned identity or by one it vouched for through
an unbroken chain of links, and refuses a key signed by any other identity. Sixteen links are kept.
The gateway does not pin identity.pem (it knows a Station by the certificate a root signed,
below; that certificate is renewed on its own).
How a Station proves itself to Universal Exports
Every request a Station makes under /v1/station/ is authenticated in one place at the gateway, before
any route runs. A Station that holds a certificate proves itself with
it: the request carries an ai6-station-proof header, the Station's certificate (the one ai6 secret-trust
certify-station makes, signed by a root the gateway pins) and a signature of the request's method, path and
query, the time and a random nonce with the key the certificate names. The gateway checks the certificate
against AI6_EXPORTS_SECRET_TRUST (its pinned roots, its clock skew and the revocations it has read), the
signature, and that the nonce is new, and the route then knows which Station asked. A station the request
names, in its query or its body, that is not the certificate's own is refused with 403 on every route that
carries one (controls, the assistant desk, attach, pages). The certificate is the one a Station already holds
for its sealing, so there is no second credential to make, rotate or revoke: ai6 secret-trust revoke
stops a Station here as it stops it there, within revocation_refresh (5 seconds by default).
A Station proves itself this way when its sealing.trust pins a root and it has a certificate that holds. A
Station that has no certificate that holds sends the shared [unex] station_token after all, and says so
once on standard error; a gateway that pins a root refuses it. A Station never sends both.
The shared token. The station_token names no Station: any holder can poll, report and answer for any
other. AI6_EXPORTS_SHARED_STATION_TOKEN on the gateway sets whether it is still accepted:
| Value | Meaning |
|---|---|
auto (default) |
Accepted while the gateway pins no root (AI6_EXPORTS_SECRET_TRUST names none), since no certificate could be believed; refused as soon as one root is pinned. |
on |
Accepted always. A weakening, reported. |
off |
Refused always. |
While the token is accepted the gateway says so on standard error at start and /v1/stations lists it among the
gateway's degradations (station-credentials). AI6_EXPORTS_STATION_PROOF_NONCES (100000 by default) is how many
proof nonces the gateway keeps, each for twice its clock skew; a proof is refused when they are all in use.
Moving a Station off the shared token. A Station that proves itself and one that sends the token can use one gateway together, so a deployment moves one Station at a time:
- Upgrade the gateway first: an older one does not read proofs, so a Station that proves itself is refused by it.
A gateway that already pins a root refuses the token under
autoas soon as it is upgraded, so putAI6_EXPORTS_SHARED_STATION_TOKEN=onin its environment before the upgrade. This is the weakening, and it is reported (start-up line,/v1/stations). Stations that have not moved keep working. - Make each Station prove itself: pin the root in its
sealing.trustand certify it (ai6 secret-trust pinandcertify-station, see Secrets), then upgrade and restart it. It sends proofs from its first request; with no certificate that holds it sends the token and says so on its standard error (cannot prove itself). - When every Station has moved, restart the gateway with
AI6_EXPORTS_SHARED_STATION_TOKEN=onand watch its standard error: it printsa Station request used the shared Station tokenat the first use after it starts, so no such line after a few minutes of polling means no Station uses the token any more. - Set
AI6_EXPORTS_SHARED_STATION_TOKEN=off, or remove the setting (autorefuses the token while a root is pinned). A Station's[unex] station_tokenis then never sent while its certificate holds; the gateway still needs its own copy to start.
The proof says nothing of a request's body, which a TLS connection keeps whole: a gateway behind a reverse proxy
that ends TLS should be reached from the proxy over a network no one else is on. What the gateway does not yet
bind to a Station is a Run (any certified Station can write any Run's events), the input queue and the source-read
queue; those have no station to check.
Renew a Station certificate without interrupting it
This procedure is certificate renewal with the Station's same existing keys (sealing.key and
sealing.sign) for expiry — for example, the deployed Stations' serial-1 certificates, which expire on
2027-02-26. Renew each Station early enough to allow seven days of overlap, one Station at a time.
Compromised key: This renewal procedure does not rotate keys. If a Station's sealing or signing key is compromised, it needs new keys (revoke the affected serial first, then provision new keys; key replacement is not covered by
rotate-stationyet).
- Upgrade Universal Exports first. It must provide the Station-proof-only
GET /v1/station/credentialroute, which verifies the candidate and audits a Station and serial not already recorded (station.certificate.verified). - On the Station host, run
ai6 secret-trust station-keys --config STATION_CONFIG. Carry the Station ID and both printed public keys to the certifying host over a trusted channel. - On the certifying host, sign a replacement using those same public keys, with a higher serial and
an overlapping validity period (or a new validity period if renewing an already expired
certificate). Include
--headquartersif the current certificate has that purpose. This example renews serial 1.
ai6 secret-trust certify-station --issuer ROOT_KEY --station STATION_ID \
--sealing-key SEALING_PUBLIC_KEY --signing-key SIGNING_PUBLIC_KEY \
--serial 2 --days 90 --out replacement.cert
Keep the root key on the certifying host. Carry replacement.cert back to the Station. Use a
staging path outside the Station's active sealing.cert and leave --publish off at issuance.
4. Activate the staged certificate on the Station.
ai6 secret-trust rotate-station --config STATION_CONFIG --certificate replacement.cert
The command checks the signed replacement against the Station's pinned root, local keys and
current certificate (even if the current certificate has already expired, the candidate is still
verified against the pinned root). It refuses a replacement whose not_after is earlier than the
current certificate's unless --force is passed. After verifying the candidate with Universal
Exports, it writes a station.certificate.activate.intent audit record (aborting on failure),
updates the shared Registry using compare-and-swap on the read revision, keeps the replaced
certificate as the previous copy (sealing.cert.prev locally and cert.prev in the Registry)
until that old serial is revoked (the Station falls back to it only if the current certificate is
unusable), installs the replacement as sealing.cert, and records station.certificate.activated.
Running Station publishers pick up the new serial within 30 seconds. The shared Station token can
remain disabled throughout. A refusal from the gateway leaves the current certificate active. If
publication succeeds and the local write fails, rerun with the same replacement file.
5. Confirm that the command reported the new serial. Check the Station and its traffic in Universal
Exports. In a deployment with multiple gateways, verify that every instance pins the issuer and
accepts the successor. Keep both serials valid during the overlap (normally seven days for a
planned expiry renewal; wait until all active Stations/gateways have adopted the new serial and
in-flight requests using the old serial have finished) so requests still carrying the old
certificate succeed. Only after the replacement serial is verified and active everywhere,
publish the previous serial's revocation from the root host:
ai6 secret-trust revoke --config REGISTRY_CONFIG --root ROOT_KEY \
--subject station:STATION_ID --serial 1 --publish
revoke --publish writes a station.certificate.revoke.intent audit before publishing and
station.certificate.revoked after (removing any kept sealing.cert.prev / cert.prev copy of
that serial). It refuses to revoke the serial the Station currently uses unless --force is
passed. Gateways refresh the root-signed revocation within the configured refresh interval (5
seconds by default). Peer TLS uses the separately pinned identity.pem.
When Universal Exports goes away
A Station publishes each Run's states and terminal output to Universal Exports. A gateway that
stops answering costs the Run nothing: the harness runs on, and the Station tries again with
growing pauses ([publisher] publish_retry_delay, retry_max_delay). Its /internal/publisher
reports it unhealthy, with the reason, until an event gets through.
Universal Exports holds its Runs in memory, so one that comes back has forgotten them. When it
answers, and every refresh_every seconds in case it restarted during a quiet spell, the Station
registers each live Run again with its Mission's brief and sends its latest state, and its
sequence goes on from where it was, so a viewer's cursor stays good. Operator controls and terminal
input resume by themselves, since each is a poll the Station keeps making.
What is lost while it is away:
- Terminal output past the queue.
[publisher] queueframes wait, of up toterminal_byteseach, across the Station's Runs; past that the oldest go. The Station counts them (lost_terminal_bytesin/internal/publisher), and the Run's sequence skips a number there. - States in between. When the queue is full, a Run's newer state replaces its older one, so the gateway's timeline can skip a state the Run passed through. Its latest state always arrives.
- Whatever the gateway held, if it restarted: every Run's scrollback, and any Run that ended before the gateway came back and has no state still waiting. The Registry keeps the Missions themselves.
- Input typed into a gateway that went away, and controls it had queued and not handed over, since it holds them in memory too.
The Run itself loses nothing: its harness and its record of the work are on the Station.
A viewer is told when output is missing: a sequence that skips a number, or a position older than what the gateway holds, reaches its terminal as a notice. A state skipped in the timeline is not announced.
Provider libraries: pins and publishers
A Station runs every provider library it loads with its own privileges, so it checks them
first (bona fides). The pin set, the plugin records of its configuration provider
(plugins.toml in a configuration directory, global or in stations/<id>/), names the
libraries it accepts:
[[library]]
file = "ai6_agent_claude.dll"
pin = "sha256:..." # the library's own digest
[[library]]
file = "ai6_agent_codex.dll"
publisher = "ed25519:..." # or: whoever holds this key signed it
# require = "both" # with pin and publisher together: both must hold
Signing libraries
Signing is the normal path. A digest pin changes with every build; a signature travels with the build, so a rebuild changes no record and one entry serves every architecture and both sides of a rolling upgrade, which a digest cannot:
ai6 plugins keygen --out publisher.key # once, on the host that builds
ai6 plugins pin --publisher publisher.key lib/*.dll # once for each file name: the plugin records
ai6 plugins sign --key publisher.key lib/*.dll # in every build: FILE.sig beside each library
ai6 plugins check --config ai6.cfg lib/ # before a restart
keygen prints the publisher = "ed25519:..." line and nothing of the key, and refuses a file
that exists. pin --publisher takes that ed25519:... text or the key's file. sign reads the
key only from its file. check says what a strict scan would say about each library against
the plugin records of this host's Station, printing its path, digest and verdict; it loads
nothing and writes no copy, and exits 1 on any refusal or when it found no library to check.
A pin set's plugin family applies at restart, so run it after importing and before restarting.
Copy FILE.sig with its library wherever libraries are copied, field runners included. A new
library name still takes one record, once: naming what may load is the policy.
Storing pins
pin prints entries for a plugins.toml. With a configuration provider that takes changes
(SQL), --import stores them as its plugin records instead, which suits digest pins, renewed
with every build:
ai6 plugins pin --import --config ai6.cfg lib/*.dll # the global records
ai6 plugins pin --import --scope station:s1 --config ai6.cfg lib/*.dll # one Station's own
Each entry replaces the record of its file name, and records for other names stay as they are.
It prints a line per library, added, changed (with the old entry and the new) or
unchanged, and how many records it wrote; the change is checked and kept whole, as ai6ctl
apply does. A directory of family files takes no changes, so --import is refused
there and writes nothing: add the printed entries to its plugins.toml. A Station applies
plugin records at restart.
Approving a library from Outer Office
Under strict, a library no record accepts does not load. A Station lists each one it found and
did not load in its check-in (found_libraries: file name, digest, the kinds it declares, whether
FILE.sig sits beside it, and the publisher key among those its records name that the signature
verifies for), read as data without running it. A library declares its kinds, not its provider IDs,
so the IDs are known only once it loads. At most [scheduler] found_libraries (64) are listed.
GET /v1/user/stations/{id}/libraries answers them (station.read). The list is the Station's own
claim: the gateway shows only well-formed entries (a file name and not a path, a sha256: digest
of 64 lowercase hex digits, no control or invisible characters) from a Station it heard from within
[registry] gone_dark_after. A person who holds
plugin.manage on config:plugin approves one on the Roster page, in the Provider library records:
Outer Office shows the file name, digest, kinds and publisher, and what the gateway says will
change, before anything is stored. POST /v1/user/stations/{id}/libraries/approve takes the file
and digest the Station reported, "trust": "pin" or "publisher" and confirm; without confirm
it stores nothing and answers applied: false with changes, weakened, the
record_revision it read and, for a publisher trust, the publisher; confirm has to carry both
back, a record changed since is a 409, and another key is refused.
- A pin stores
{pin = digest}as that Station's ownpluginrecord for the file, keeping a publisher the record already named; the answer says which pin it replaces. Only what is approved is written: when the Station has no record of its own for the file, a global one is not copied, and the preview says that the new record replaces it on that Station. A publisher trust stores{publisher = key}and is offered only when the Station recognised the signer and the gateway finds the key named by apluginrecord (global or the Station's own); the preview says which files it is already trusted for. It admits anything that key signs for that file name, and the answer lists that as a weakening, as for any publisher entry. A record requiring both a pin and a publisher is approved by pin. - The record is the Station's own, never the global one, so approving a library on one Station changes what no other Station loads. Promote it by writing the global record.
- Only a file and digest the Station reported can be approved. The gateway takes no library bytes: the file reaches the host by deployment.
- The Station reads
pluginrecords at its next start.plugin.manageis in no built-in role butchief; the write is auditedplugin.approveonconfig:pluginwith the person, the Station, the file and the digest (a refusal, including one for lacking the action, isplugin.refused). Every other write to thepluginfamily through the gateway needsplugin.managetoo. - A rebuild signed by a key a record already names for that file needs no approval.
What a publisher entry gives up
A publisher entry is weaker than a digest pin, and the compromise of its key matters more. Against a digest pin it gives up:
- Exact bytes. Any file that key signed for that name loads, an older vulnerable build included: nothing in a signature binds a version, so a signed old build can be put back.
- Revocation. A stolen key signs anything until the record changes and each host restarts.
There is no key server and no revocation list: removing the
publisherline, or the entry, is how a key or a library stops being accepted. - Holding no secret. The key sits on whatever signs, where a digest pin needs none.
So each publisher whose signature alone is enough is listed as a weakening,
publisher ed25519:... alone admits N libraries: anything it signed loads, older builds
included, printed at start, in GET /internal/plugins and in the check-in's
plugins_weakened. An entry with a pin and a publisher accepts either one, so it is listed
too, unless it says require = "both". With require = "both" the library must be those exact
bytes and carry the signature: it gives none of this up and is not listed, and every rebuild
is a change to its record, as with a digest pin.
Keep the key on the host that builds, never on a Station, which needs only the public half. On
Unix keygen writes it 0600; on Windows the file takes its directory's access list, so put it
in a directory only you can read. A CI system should get it only for release builds, as a
repository secret. To rotate, sign everything with the new key, copy the signatures out and
change the records together, then restart; one key per entry is the whole model, with no list
of keys to overlap them, so a host restarted between the two steps refuses what does not match.
For development profile = "report" is the setting: everything loads from where it was found
and needs no signature, and each library no entry accepts is listed.
The signature's format
What sign writes, for anything that signs without ai6: Ed25519 over the tag
ai6-provider-library-v1, a NUL, the library's file name, a NUL and the library's 32-byte
SHA-256, shipped as the 64 bytes of FILE.sig. The name is part of what is signed, so a library
signed for one slot does not load in another. With OpenSSL and a POSIX shell:
{ printf 'ai6-provider-library-v1\0%s\0' ai6_agent_codex.dll
openssl dgst -sha256 -binary ai6_agent_codex.dll; } > message.bin
openssl pkeyutl -sign -rawin -inkey publisher.pem -in message.bin -out ai6_agent_codex.dll.sig
openssl pkey -in publisher.pem -pubout -outform DER | tail -c 32 | od -An -tx1 | tr -d ' \n'
The last line prints the key's 64 hex digits for publisher = "ed25519:...". ai6 plugins sign
and pin --publisher read such a key too.
Providers written in other languages
A provider need not be a Rust library. Guatiao loads providers written in Python, JavaScript, Lua,
Rhai and WebAssembly through a source file: a native library that declares source=<type>
(guatiao_source_py, guatiao_source_js, ...). A provider is then a script library: a
manifest NAME.guatiao (TOML) with type naming the source (python, js, lua, rhai,
wasm or remote), the kinds its providers serve and the paths where its code is, and the
files under those paths. A Station reads both from the same configured plugin paths as native
libraries: a directory's source files, and the manifests in it and in its immediate
subdirectories; a manifest named as a path is read too.
Every way a provider arrives passes the same checks, under the same profiles, with the same messages and the same approval from Outer Office:
- A source file is code the Station maps, so it is pinned by the digest of its bytes (or
signed) by its own file name, copied under
strict, and refused when unpinned, exactly as a provider library is. - A script library is pinned, and signed, by its manifest's file name. Its digest is
SHA-256 over one byte string: for each file in name order (the manifest, then every file under
its
paths, with the signatureNAME.guatiao.sigleft out), the length of its name, the name, the length of its content and the content, each length 8 bytes big endian.ai6 plugins pinandai6 plugins signtake the manifest and print or write exactly that. Understrictan accepted library is copied into the verified directory assha256-HEX.script/and served from the copy; old copies are cleared as library copies are. - What is refused under every profile that checks (
strictandreport; onlyoffchecks nothing), since such a library cannot be told from another by its bytes: apathsentry that is absolute, leaves the manifest's directory, or has a symbolic link on its way; a symbolic link, a__pycache__directory (in any case), a.pycor.pyofile, or a name that is not UTF-8 anywhere under the paths; amodulethat is not a plain name (no/,\,:or..) or is not a file underpathsthat the pin covers (a dotted Python module only asa/b.py, witha/__init__.pyin the bundle too; Python, Lua, Rhai and WebAssembly libraries need one); a JavaScript entry (main, ormaininpackage.json) that is not a file of the bundle. An emptypathsis the manifest's directory, as guatiao reads it. A library whosepathsis["."]includes everything in its directory, so give each library a directory of its own. - Limits. A library is walked by metadata first and refused before any file is read when it
has more than 10,000 files and directories together (guatiao's limit counts files), 512 MiB,
directories nested deeper than 8, more than 64
pathsentries (each once, and none under another), or a manifest over 1 MiB; its files are then hashed and copied as streams, each read to the length the walk saw and refused if it grew.PluginPolicy::bundle_limitsraises them, and each limit raised is reported as a weakening. The pin check sees the SHA-256 only, so a library pinned by another digest never matches. - A manifest that names
child(aremotelibrary's server program) is refused under every profile that checks, and nothing is read for it: a program the bundle's digest does not cover is code the pin cannot vouch for. Guatiao itself refuseschildin a peer manifest, so only a source setting an operator wrote could reach it. Start a peer server yourself and name it by address. - The verified copy is read-only, and on Windows its directory is restricted to the account the
process runs as, named by its token's SID (
whoami /user), with inheritance cut and every other entry removed (icaclsfromSystem32); native library copies go in the same directory. A copy that holds any entry outside the bundle is rebuilt, never reused. The Windows side has not been built or run: there is no Windows build host. - A manifest with no source file of its type on the paths is reported in
failed; a source file with no manifest to serve is not run.
The sources are handed the kind descriptions of every AI6 kind (crates/ai6/kinds.json, kept
current by a test and written by the Station for the scan), which a provider written in another
language builds its kinds from: in Python kinds.kinds_of(document), in JavaScript
kindsOf(document). A source's own settings (isolation, paths, home, limits) come from
PluginPolicy::source_settings; a source tells what it was given that weakens its isolation in
notes of the scan summary.
Scripts run with the Station's own powers. A Python, JavaScript, Lua, Rhai or WebAssembly
provider is no more confined than a native one: it runs in the Station's process as the Station's
account, so the pin is the whole defence and a pinned script is trusted like a pinned library.
Every script library of one type shares one interpreter, so one can see
and change what another imported (the Python source runs one CPython per process, whatever its
source files, so it shares one for every Python library; see Reach below). Python starts isolated unless the source settings say
otherwise (only the standard library and paths, no environment, no user site); under
shipped or inherit the installation's site-packages is read, and any .pth file there
runs code at start, so those are weaker settings that an operator chooses. Python's bytecode
cannot be redirected from here (the source ignores PYTHON* variables); the verified copy is
read-only, so none is written beside the code, and a library holding __pycache__ is refused.
Lua's io, os, dofile, loadfile and require are available to a Lua provider and cannot
be turned off from AI6. dirs and manifests in a source's settings are dropped and reported:
only the scan names the libraries a source serves.
Reach. A script library sees no other provider unless its pin record (reach in
plugins.toml, the provider kinds it may look up or bind) says so, and never because its manifest
does. The kinds are the owner's, set before any library opens, and a source that cannot be scoped
serves no library at all. Reach covers only what a library looks up through its host: objects AI6
passes it as arguments, and calls into a provider it can see that has a wider reach, are outside it.
For JavaScript each library is served at its own reach, which holds because each library has its own
host. It does not hold for Python: every Python library of a process can use any other's host (and
ctypes), so all are served at the union of the Python libraries' reaches. A Station whose Python
libraries differ in reach says so at start, as a weakening that names each library the union
widens and the kinds it adds; give every Python library the same reach, or none, to hold it to what
its pin approved. ai6 plugins pin, the gateway's approval of a library and the start report each
show a reach, and a reach is never a default: an empty one is strict.
A remote manifest names a peer; the pin covers the manifest (where it connects and how), not the
code that runs there. Guatiao's watch_dir loads whatever appears in a directory with no hook for
a check, so a Station does not use it: libraries are read at a scan.
Profiles
The profile (--plugin-profile, else ai6.cfg's [station.plugins] profile; each host's own,
never the shared provider's) decides what loads:
| Profile | Default when | What loads |
|---|---|---|
strict |
a pin set exists | only libraries a pin or publisher accepts. Each is read once, checked, and loaded from a copy written to the state directory's plugins/verified/sha256-HEX.EXT, never from where it was found. A refusal names the expected and found digests or the publisher. |
report |
there is no pin set | every library, from where it was found; each one no entry accepts is a weakening |
off |
never | every library, unchecked (itself a weakening) |
At startup the Station logs configured choices and reports unpinned libraries allowed by the
profile as risk status, at information level. A library loaded despite a pin mismatch produces a
warning that names the mismatch. GET /internal/plugins lists each library's digest and verdict,
and the Station publishes the report at check-in (plugins_weakened). The scan checks libraries
that declare an AI6 provider kind.
After a strict scan the copies in plugins/verified/ it did not load are removed, keeping the
newest [station.plugins] keep_verified files by when each was written (default 8; 0 keeps none of
them; "none" means no limit, so every copy stays). A process keeps a shared lock on each copy it
loaded for as long as it runs, so another process's scan leaves that copy, and a scan holds
the directory's .lock from before its first copy until its last load, so no clearing removes a
copy between the two: clearing happens only when no other scan is under way, and otherwise waits
for the next one. A copy that cannot be removed is left and listed (verified_held in
GET /internal/plugins); it never fails the scan. On a file system that takes no locks nothing is
removed. verified_removed lists what went.
Every command that loads providers checks them the same way, with the same defaults:
ai6 theater provision, Universal Exports for its access providers (the provider's plugin
records, [unex.plugins] profile or --plugin-profile), and the field runner
(ai6 runner serve --pins PATH --plugin-profile P --keep-verified N, whose verified copies go
under its own state directory; a Station starting one on its own host writes the pins it
resolved into the runner's state directory and passes them with its own keep_verified). Each
prints what it refused and every weakening when it starts. A Station hands every runner it starts its record's [runner] and
[providers.<id>] tables (--settings, The field runner).
What a pin covers is the library file. A library that imports another non-system library
gets it from wherever the operating system's loader finds it; on Windows that includes
the directory of the executable, the current directory and PATH, which no pin covers.
AI6's own providers import only system libraries.