Operating an Engine Through Its Operate Grant
Whatever runs an engine for a company (an orchestrator, a Kubernetes operator, a script on a schedule) has to watch it, back it up and stop it. It has no need to read the company’s work. The operate grant is one credential for exactly that job: it opens the /operate/ routes and nothing else, and no other credential opens them. An engine run this way needs no admin token in the hands of whatever runs it, and with its first person seeded it needs no Tier A token at all.
Setting it up
Section titled “Setting it up”-
Make a credential of at least 26 characters, as random as an
api.auth.tokensvalue (crewlet secrets keygenprints one), and keep it where the caller reads it. -
Put its SHA-256, never the credential, in the node’s Tier A, with the directory an operate backup is written under:
Terminal window printf '%s' "$CREDENTIAL" | sha256sum # the 64 hex characters# crewlet.yaml (Tier A)operate:credential_sha256: "${CREWLET_OPERATE_CREDENTIAL_SHA256}"allowed_sources: [10.0.0.0/8] # where whatever runs the engine calls frombackup_dir: /var/lib/crewlet/operate-backupsbackup_limit: 3 # the default -
Restart the node, and present the credential as
Authorization: Bearer <credential>on every operate request.
The digest opens nothing, so a rendered Tier A file, its backups and a log of it hold no credential. A credential under the 26-character floor is never admitted, even where its digest is set, and one that is also an api.auth.tokens value is refused at start. The routes answer only the address blocks allowed_sources lists, judged on the client address as the rest of the API judges it (through api.trusted_proxies); every other caller meets an unserved path. To rotate, set the new digest and restart: the old credential stops working at that restart. With no operate block, no /operate/ route exists and each answers 404 no_route.
Versions and the capabilities document
Section titled “Versions and the capabilities document”The routes are versioned by path, /operate/v1/.... An engine serves its current version and at most the one before it, so one caller runs engines of two releases at once. Within a version, fields are only added to an answer.
GET /operate/capabilities sits outside every version, so a caller learns what this engine serves before choosing:
{ "schema": 1, "version": "v0.2.0", "operate": ["v1"], "features": ["operate.health", "operate.revision", "operate.fleet", "operate.integrations", "operate.usage", "operate.members", "operate.schedule", "operate.backup", "operate.drain", "operate.stop_boxes", "operate.limits"]}Switch a behaviour on by its feature, never by version. The document’s own schema only gains fields, so a reader of schema 1 reads every later one.
What version 1 serves
Section titled “What version 1 serves”Every route below needs the grant. What it reads is how the company runs; what it writes runs the deployment or bounds it. It never reads a work item, page, message, transcript, credential, or a person’s name, address or login, and never writes the company document, the secret store or the identity directory.
| Route | Answers |
|---|---|
GET /operate/v1/health | health, the body /health answers (the health envelope), and readiness, the body /ready answers, read together. |
GET /operate/v1/revision | The active revision: revision_id, parent_revision_id, created_at, activated_at, and document_sha256, the SHA-256 of its document as GET /config answers it, which moves exactly when the document does. Never the document, which holds the company’s people, accounts and words. 503 no_active_revision before the first. |
GET /operate/v1/fleet | The answer GET /fleet gives an administrator, whole: every live node, its roles, posture, drain and the revision it runs, and which node holds each seat. |
GET /operate/v1/integrations | integrations: each integration tool’s key, state (connected; attention, a person has to act; not_connected, not working yet with nobody to act; not_in_use) and label, the state in words. No ids, addresses or vendor wording. |
GET /operate/v1/usage | Model usage per company day, every seat and person summed: since, until, and days, each day with its tokens, cache share, calls and reported cost. The window is days=N (1 to 90) or since and until (two company dates, both inclusive), as the spend questions take it; without one, today. A day with no usage is absent. |
GET /operate/v1/members | One page of the company’s people: members, each id, role (admin or member), state (invited, enrolling, active, suspended, retired) and updated_at, and next, the ?after= of the following page, absent at the end. ?limit= is 50 by default and at most 200. Service accounts are not members and are left out. |
GET /operate/v1/schedule | next_fire_at: the soonest any schedule fires next, absent when none will. |
POST /operate/v1/backup | A backup, as POST /backup takes one, into a new directory under operate.backup_dir named for its UTC start (20261201T083000.000000000Z). The caller names no path. With operate.backup_limit such directories already there, it is refused 409 backup_limit and writes nothing: move one away or remove it first. A backup_dir that cannot take a backup is 500 backup_failed with a fixed hint, its path in this node’s log alone. Otherwise it answers and refuses as POST /backup does, and is recorded in the same audit with the caller’s address. |
POST /operate/v1/drain | 202 {"draining": true} at once, and the node begins the drain SIGTERM begins: it takes no new work, lets running turns finish and hands its seats back, while it keeps serving. One way: only a restart ends it. /ready and the health read say how far it has got. Asked again, it answers the same. |
GET /operate/v1/limits | The company’s limits: max_people, max_agent_seats (each null where none is set), version (0 before any is set) and set_at. |
PUT /operate/v1/limits | Replaces the limits: {"max_people": n or null, "max_agent_seats": n or null, "version": v}, at the version last read. A write that read an older version is 409 stale_version naming the one that holds; a max_people below 1, or a limit past 1,000,000, is 400 invalid. Answers the limits as stored, and is recorded on the runtime audit as set_limits. |
POST /operate/v1/stop-boxes | Ends every running executor box of the seats this node holds: seats, the seats stopped, and failed, those it could not stop yet (ask again). It pauses no seat, so a seat’s next turn may start a box again; after a drain, none does. A seat held by another node is that node’s to stop. |
A write is recorded as operate, of kind operator: a name no login can take, so nothing a person, token or service account did is ever filed under it. A drain, a stop of every box and a limits write each leave an operator_acted record on the runtime audit (transport operate, the caller’s remote address, and for a stop the count of seats), and a backup its backup_requested record.
Limits
Section titled “Limits”Whatever runs the engine can bound what the company adds to itself. The limits are one record the whole company agrees on, written through PUT /operate/v1/limits and nowhere else; no person, token or the company document changes them. Each holds where it is written:
max_people: the most people the company holds, counting its persons at every stage (a retired person keeps their place, since reinstating them is a stage change nothing counts) and its open invitations together. An invitation or a create past it is refused409 limit_reached(limit: "max_people"), on the dashboard and every surface that writes the directory; redeeming an invitation adds nobody it did not already count, and removing a person frees their place. Every add is a record on the directory’s one subject, so adds racing for the last place are decided one after the other and the limit holds exactly.max_agent_seats: the most agent seats the company document declares. Any write that adds agent seats past it is refused400with one problem atroles: a save, a check, a revert to an older revision and a reload alike. A company already past a lowered limit still saves every other change, and removes seats, but adds none. Over an active revision this node cannot read, a write is held to the limit itself, since its seats cannot be counted.
A limit this node cannot read refuses the write rather than lets it past. Lowering a limit removes nobody and no seat, and an invitation already open stays redeemable: withdraw open invitations to enforce a lowered people limit.
Where the limits do not reach:
- A node of an earlier build enforces none of them; in a fleet mid-upgrade, only nodes running this build refuse.
- Writes outside the API: an offline
crewlet config importand the company a node boots with are not held to the seat limit. - A restore brings back the limits the backup held: set them again after restoring.
Refusals
Section titled “Refusals”Every refusal is the one envelope.
404 no_routefor a caller outsideallowed_sources, whatever it presents, logged asoperate_refused_source.401 invalid_tokenfor anything but the grant: no credential, a wrong one, anapi.auth.tokenstoken, a person’s or a service account’s access token, or a signed-in session. A credential refused here counts as a failed attempt on the audit trail’s per-source failure row, as one the guard refuses does; a request that presented nothing does not. Which operate routes exist is the grant’s to learn, so an unknown one is the same401without it, and404 no_routewith it.- The grant opens nothing else. Presented on any other route it is a bearer the engine does not know:
401. - No answer is stored. Every response under
/operate/carriesCache-Control: no-store, refusals included. - During a drain the operate routes are all served, writes included: a backup after the drain is the copy to roll back to, and the stop of every box ends what the drain does not wait for (see During a drain).
- Never on the public listener.
/operate/is served onapi.portonly; keep that port off the internet, reachable by whatever runs the engine.
Part of Crewlet. Generated from crewlet/crewlet main at 3f5565e.