This release is a pre-release and may not be stable for production use.
robot-md-gateway
The enforcement gateway for the OpenCastor stack. Receives signed RCAN action envelopes, verifies manifest provenance, applies tier policy + tool allowlist, dispatches to drivers. Designed to be the only path between agent intent and any actuator; that holds only when the deployment makes it so (see Where this fits in the stack). Open source; intended to become OpenCastor's safety kernel via open-core extraction.
Renamed in 2026-05. This package was previously published as
robot-md-dispatcher. The old name is now a tombstone on PyPI;pip install robot-md-dispatchercontinues to work and pulls this package as a dependency. Imports and therobot-md-dispatcherCLI keep working through v0.4.x via a backward-compat shim. See CHANGELOG.md for migration notes.
Where this fits in the stack
robot-md-gateway is Layer 3 of the OpenCastor stack — the
enforcement gateway. It is designed to be the only path from agent
intent to any actuator. That holds only when the deployment makes it
so: the gateway runs as its own service account, and the GW-001 udev
rule makes that account the owner and group of the robot's device nodes
(mode 0660), so other non-root users get EACCES when they open them
(procedure). The default
systemd/install.sh does not set this up: it gives the device to the
dialout group and adds the installing user to that group, so another
local process can still reach the servos. Adding users to the device's
group, as the onboarding checklist
describes for interactive use, has the same effect.
| Layer | Piece | What it is |
|---|---|---|
| 1 — Declaration | robot-md | The ROBOT.md file + Python CLI. Declares identity, capabilities, safety gates. |
| 2 — Agent runtime | (any MCP host) | Claude Code, Codex, Gemini — plans actions, calls tools, and is not meant to reach actuators directly. |
| 3 — Gateway / Enforcement ← this | robot-md-gateway | Designed to be the only path to the actuators, when the deployment enforces it (see above). Verifies signatures, applies policy, signs audit bundles. |
| 4 — Robot-facing runtime | OpenCastor | Productized open-core runtime. Embeds the gateway as its safety kernel. |
| 5 — Protocol | rcan-spec | Wire format, envelopes, conformance suite. |
| 6 — Registry | Robot Registry Foundation | Identity (RRN/RCN/RMN/RHN), public keys, evidence. |
See the live compatibility matrix →
What it does
The gateway accepts incoming signed RCAN INVOKE envelopes — never plaintext goals, never SDK sessions. Every envelope is checked for:
- Manifest provenance — the ROBOT.md being actuated against has a verified signature from a key registered to this robot's RRN at RRF.
- Tier + RBAC — the caller's bearer token resolves to a tier authorized for this scope.
- Tool allowlist — the requested tool is in the operator's policy (default-deny on unknown). A tool the actuator declares as motion (
motion_capabilities) must also be invoked under an actuation scope (MANIPULATE,NAVIGATE,ACTUATE,EXECUTE,COMMISSION, in any case): the same motion relabelledOBSERVEis refused, because the tier, confidence and HiTL gates key off that caller-written field. For a motion tool those gates also apply the strictest motion scope's rule (HiTL on any of MANIPULATE, NAVIGATE, ACTUATE, EXECUTE covers all four), so relabelling among them buys nothing. - Confidence + HiTL gates (Phase 4 — Plan 6) — model-asserted confidence above threshold; human-in-the-loop approval if scope demands it.
- Replay protection + freshness (Plan 6; freshness v0.5.0a7): the envelope's
msg_idis checked against a bounded FIFO window of ids already seen (oldest evicted first), and when the envelope carries atimestamp_msit must fall inside a configurable window, by default 300 seconds either side of the gateway's clock. An envelope that carries notimestamp_msis not freshness-checked unlessROBOT_MD_REQUIRE_ENVELOPE_TIMESTAMPis on: the iOS client signs the field into its pre-image, older CLI signers do not send it at all, and refusing them all would be a silent break. The window is bounded, so this limits how long a captured envelope stays useful; it is not a permanent ledger of every id ever seen. - ESTOP precedence (Plan 6) — physical or operator stop signal preempts any pending action. A declared stop sent through
/v1/invokeby a bearer the gateway knows runs on worker threads of its own (STOP_LANES), so it does not wait behind other requests for a thread. It holds its lane only for its checks and the actuator's answer; its records and its response go to lanes of their own, so storage that stops answering holds back no other stop. Only such a request gets a lane: one that merely names a stop tool, for an actuator that does not declare it or with no known bearer, shares the default pool, so it cannot hold the lanes; whether it then preempts a motion in progress is up to the actuator (so-arm101-actuator latches first and ends a paced move at its next setpoint). A flood of requests that saturates the gateway's CPU still delays it, because CPU and the GIL are shared by every thread (the stop latched 4.7 s after it was sent under 200 looping clients on two cores, in simulation; 0.05 s with no other traffic): the software stop is not the physical e-stop. A declared stop (a tool the actuator that receives it declares instop_capabilities) takes a path of its own. It passes in every gateway state,safe_stopandestop_activeincluded, which refuse everything else. It is judged asSAFETYwhatever scope the envelope carries. It is never refused for its signature, freshness, revocation or replay (a replayed stop is processed and recorded asREPLAY_DETECTED), and the key registry is never consulted for it. That departs from rcan-spec's replay-prevention page, which rejects an ESTOP more than 10 s old (src/pages/docs/replay-prevention.astro:70), and follows its safety and offline pages, which accept an ESTOP always (safety.astro:351,offline.astro:47). The spec contradicts itself there (RobotRegistryFoundation/rcan-spec#240). The gateway takes the side that never refuses a stop: a stale or replayed stop can only stop the robot, and replaying one needs a bearer that could send a fresh stop anyway. The actuator gets the pinned manifest, or none, never the one the request names, and confidence and HiTL do not apply. It is sent to the actuator before it is recorded (see Record before dispatch). A stop still needs a bearer the gateway knows (any tier), the operator's allowlist and the operator's per-tool tiers (see Heartbeat and safe-stop).
Which of those run depends on one setting, so read this before quoting the
list. Checks 1, 2, 3, 4 and 6 run on every request but a declared stop, which
skips 1, 4 and 5 as item 6 says. The envelope signature
check itself, and check 5 (replay and freshness) which sits behind it, run
only when ROBOT_MD_REQUIRE_ENVELOPE_SIGNATURE is on, and it is off by
default. With it off the gateway still reads the envelope and still applies
the other five checks, but it does not require the envelope to be signed and
therefore does not check the id against the replay window or the timestamp
against the freshness window. Turning it on is one environment variable, and a
deployment that wants any of what check 5 describes has to turn it on. The
defaults are permissive on purpose, for bring-up; they are not the
configuration this section describes unless you set them that way.
If all checks pass, the gateway dispatches to a local actuation tool (typically a robot-md-mcp tool call or a direct driver invocation) and emits a signed audit bundle entry per action. If any check fails, the action is denied and the failure is logged + signed.
Record before dispatch, and record again after
The gateway writes its record before dispatch. This is implemented, not spec text. Since v0.5.0a8 the allow path writes two entries per invoke, in this order:
- an intent entry, written after every check above has passed and
before
target_actuator.execute()is called. It carries the tool, the envelope id and msg id, the caller and tier, the nonce and the name of the actuator about to be driven, signed with the same Ed25519 recipe the outcome uses. It says the gateway was about to dispatch. It says nothing about whether the dispatch happened. - an outcome entry, written after the actuator returned or raised. This is the entry that says what happened, and it carries the intent entry's chain hash so the pair is one hop apart.
Read the pair through that hash and the shared corr_id, never off the chain
by position. Two invokes at once are two threads, and A-intent, B-intent,
A-outcome, B-outcome is an ordinary interleaving: the entries stay correctly
linked and correctly ordered, but a pair need not be adjacent.
The record used to be written only after the dispatch, on purpose, so that it could say what actually happened. That reason is still true, which is why the late record stayed. What the late record could never cover is the case where nothing comes back at all: a driver that hangs, a process killed mid-motion, a robot unplugged between the gate and the wire. Those used to leave no trace that anything had been attempted. RCAN §6.3 makes the write before driver dispatch normative, and the pair is how both halves are true at once.
An intent with no outcome beside it is a dispatch that never reported. It is
not an action that happened, and scripts/verify_receipt.py --walk names it in
exactly those words rather than counting it either way.
Both writes are on the request path, before and after the dispatch, and on a
Pi 5 with the export on the SD card they add about 16.6 ms of blocking IO per
invoke, of which about 8.3 ms falls before the actuator is called. That is one
fsync per line and it is the floor for a record that is on disk before the
robot moves. An fsync has no timeout, so a failing card can make an invoke
slow; it cannot make it wrong, and unsetting
ROBOT_MD_ATTESTATION_EXPORT_FILE takes the export off the path entirely.
Between the intent and the call to the actuator the gateway checks its safety
state once more. A trip in that interval refuses the request (safety_state),
and the refusal is the outcome of that intent, with its hash. A trip can also
begin while the actuator runs, and its own stop to that actuator then runs at
the same time. The motion's goal may land after that stop, and the order in
which the two calls return does not say which landed first: a stop that lands
and then waits for an acknowledgement returns after a goal that landed after
it. So once a motion tool returns, the gateway waits for the trip's own stop to
that actuator to answer and then sends the stop again (stopped_again in the
response, and in the outcome record). It waits first so that the two stops
never queue on one bus. The stop sent again runs on a thread of its own, as a
trip's stops do, and the motion's request waits for the two at most 10 s in
all (STOP_TIMEOUT_S), so a stop that hangs holds the request no longer than
that. A read gets no second stop: it leaves no goal behind.
A declared stop is the exception: it is sent first and recorded after. Its
intent and outcome are still both written, in that order and linked the same
way, but after the actuator was called, and the intent's reason says so. A stop
never waits for the export lock or an fsync, which on storage that has stopped
answering would hold it back indefinitely, and it gives up its stop lane before
its records are written. The gateway's own trip stop has always worked that way.
The cost is that a process killed during a stop leaves no intent for it.
Both writes are best effort, unchanged from the contract the outcome record has always had: a signing failure, a full disk or an unwritable export is logged and swallowed. It never crashes the request and it never changes whether the robot moves. A record is evidence, not enforcement.
Is anything missing? --walk
Every NDJSON trace line written from v0.5.0a8 carries a seq (monotonic within
one export file) and a chain_prev (sha256 of the previous line's bytes), with
the head persisted in a sibling <export>.head file written before the line
it describes. Deleting or truncating a line now leaves a hole:
python scripts/verify_receipt.py --walk attestation-export.ndjsonl
No key and no network needed, so a third party handed the file can run it. Walking Bob's real 4437-line, 4.1 MB export takes 0.15 s on a Pi 5. Exit 0 is a clean walk, 1 is a gap or a chain break, 3 is named findings a person has to read. A clean walk means the numbering and the links agree with each other; it does not mean the file is complete. A line cut from the end, with the head file taken too, leaves nothing local to notice, which is the whole reason there is an off-box copy.
The file grows, and it is meant to
The export is append-only and there is no cap and no rotation. Two lines per invoke since v0.5.0a8, roughly a kilobyte each: Bob's export was 4437 lines and 4.1 MB before any of this, from one robot and no shipper. Plan for it the way you would plan for a journal, and watch the disk.
Rotation is deliberately not built in, and a rotated export reads as
tampering, which is the correct reading and not a bug. The shipper's offset
would land past the end of the shorter file and it stops with a named
TAMPER/TRUNCATED line rather than re-delivering, because from the outside a
rotation and somebody cutting the file are the same event. --walk on the new
file sees a seq that does not start where the old one stopped. If you must
move the file, do it deliberately: stop the gateway, move the export, the head
and the offset together, and keep the old file, because the off-box copy is the
only thing that shows what the local one no longer holds.
Lines written before v0.5.0a8 carry no seq and bind nothing; the walk says
how many there are and refuses to imply otherwise. The first numbered line after
them binds the last unnumbered line's bytes and is marked unnumbered_history.
A missing head file beside a numbered export is reported the same way, on the
line, as head_recovered_from_file: the gateway continues from what the file
itself still proves rather than refusing to append (which would destroy evidence
to protect the appearance of an unbroken chain) or silently restarting at 1
(which is the failure this whole format exists to end).
What it does not do
- ❌ Spawn LLM planners. That was the v0.2.x mode; it now ships as
--legacy-byok-launcherfor backward compat (deprecation-warned), removed in v0.4.0. Planners run in agent runtimes (Layer 2), separately, and produce signed envelopes that come to the gateway. - ❌ Be optional. If you can move the robot without going through the gateway, you don't have an enforcement gateway — you have a hint.
- ❌ Cover Layer 4. Drivers, fleet UI, cloud bridge belong to OpenCastor (or any future Layer-4 runtime); not here.
Where safety is meant to be enforced.
Physical limits are meant to be enforced at Layer 3 (
robot-md-gatewayand the actuator driver it calls), and only for commands that pass through it. OpenCastor (Layer 4) does not embed the gateway yet, so actuators it drives directly are not covered. Declaration alone (Layer 1) does not enforce safety. Agent host alone (Layer 2) is not the safety boundary. If a deployment lacks Layer 3, no safety claim attaches to it. Layer 3 is not a certified safety function, and hostile-input testing in simulation (October 2026) found motions it does not yet bound.
Status (v0.3.0a1)
This release lands the rename + scope-shift skeleton. The receive-only
RCAN handler, manifest provenance verification (test properties MF-001 /
MF-002), and direct-device-bypass denial (test property GW-001) ship in upcoming patch
releases under Plan 6. The legacy planner-launcher mode is preserved
behind --legacy-byok-launcher for one minor release.
Installation
pip install robot-md-gateway
Quick start (legacy mode, until receive-only ships)
python3 -m venv .venv
.venv/bin/pip install robot-md-gateway robot-md # robot-md-mcp ships with robot-md
.venv/bin/robot-md-gateway init --yes
.venv/bin/robot-md-gateway --legacy-byok-launcher serve \
--bearers ./bearers.yaml --robot-md ./ROBOT.md
init --yes writes bearers.yaml, .env, and dispatch-test.sh next to your
ROBOT.md and prints a generated actuate-tier token once. Save the token — it's
not stored anywhere else. Run robot-md-gateway init (no --yes) for a
guided walk that explains each knob.
Production install
systemd/install.sh handles the full setup: dedicated robot system user, /opt/robot-md-dispatcher/.venv with hardened unit, DeviceAllow=/dev/ttyACM0 rw, MemoryMax=1G, CPUQuota=80%, journal logging.
The on-disk names still carry the package's old name: the install goes to
/opt/robot-md-dispatcher, config to /etc/robot-md-dispatcher, and the unit
is robot-md-dispatcher.service. The installer writes
/etc/robot-md-dispatcher/dispatcher.env with absolute paths; the unit reads
that file, not a .env.
Run robot-md-gateway init --yes first (next to your ROBOT.md) to generate
bearers.yaml, .env, and dispatch-test.sh. Then:
sudo ./systemd/install.sh
sudo cp ./bearers.yaml ./ROBOT.md /etc/robot-md-dispatcher/
sudo systemctl daemon-reload && sudo systemctl enable --now robot-md-dispatcher
Run install.sh before the copy. It creates bearers.yaml root:robot with
mode 0640, and copying onto an existing file keeps that owner and mode. The file
init writes has an actuate entry (and a read one) but no supervisor and no
commission entry: add both (see Bearer tokens), or the gateway
stays held.
Bearer tokens
The unit runs serve --bearers /etc/robot-md-dispatcher/bearers.yaml. Without
that file systemd refuses to start it (AssertPathExists=). These stop the
gateway at startup:
- a file with no entries, or an entry with an empty token;
- a placeholder token, as any template here or in robot-md's installer has
shipped one: anything containing
REPLACEin any case (REPLACE_ME,replace-me-read,REPLACE-WITH-MINTED-TOKEN), anything starting with<, or nothing but dots (...); - a supervisor or commission token shorter than 32 characters. Those keep the robot movable or arm it.
Any other token shorter than 32 characters loads, with a weak_bearer_token
warning. If there is no file, install.sh creates one with
two generated tokens, an actuate-tier one for the agent's client and a
supervisor one for the heartbeat, and no commission token. It is root:robot
0640, so the service reads it through its group and cannot rewrite it. No token
is printed, and the installer never overwrites an existing file. Neither file is
ever committed: bearers.yaml and dispatch-test.sh are in .gitignore.
How a client gets its token:
-
On the robot, read it with
sudo cat /etc/robot-md-dispatcher/bearers.yaml. -
Prefer one entry per client, so each receipt names the credential that acted (
caller). Edit withsudoedit, which keeps the owner and mode, thensudo systemctl restart robot-md-dispatcher:bearers: - token: "..." # python3 -c 'import secrets; print(secrets.token_urlsafe(32))' tier: actuate # read | actuate | commission caller: craig-iphone # names the credential, never a person - token: "..." # a token of its own, never one used above role: supervisor # the heartbeat credential: read tier, nothing more caller: craig-laptop
-
Give the token to the client out of band, for example in the app's settings or in an environment variable on the agent host. The client sends it as
Authorization: Bearer <token>.
The credentials, and who holds them:
actuate: the agent's client. It can move the robot; it cannot clear a stop.role: supervisor: the device of the person supervising the robot, never the agent's host and never the robot. It is the only credential the heartbeat accepts. It holds the read tier, so on/v1/invokeit can stop the robot and read, and nothing else. The gateway refuses to start if a supervisor entry has any other tier, or if one token is listed twice.commission: the operator, and nobody else. The gateway starts held, and only a commission clear arms it (POST /v1/safety/clear); clearing so-arm101's latch (arm.estop.clear) needs it too. Add this entry by hand; the installer does not create one. Keep it out of every agent's config.- A stop (
arm.estop) needs any of these. A request with no bearer, or one the gateway does not know, is refused even for a stop.
Onboarding checklist for the operator
The systemd service runs as the unprivileged robot user, which the install
script adds to dialout so it can open /dev/ttyACM*. The interactive human
who installs the gateway usually also wants to run robot-md,
robot-md-mcp, or robot-md-gateway from their own shell — and that
requires the same group membership for their UID. Without it,
backend.open fails with EACCES and the MCP server silently falls through
to "no backend" mode (see issue #21).
systemd/install.sh handles this by default: it adds $SUDO_USER to
dialout alongside the service user. To opt out (strictly service-only
install), pass --no-interactive-user:
sudo ./systemd/install.sh --no-interactive-user
You must log out and back in for the new group membership to attach to your login session. After re-login, verify with:
groups | grep -E 'dialout|robot-md-gateway' && ls -l /dev/ttyACM0 && echo OK
If /dev/ttyACM0 is owned by a custom group (e.g. a site-local udev rule
that hands the device to robot-md-gateway:robot-md-gateway rather than
dialout), add yourself to that group too. Pass the username explicitly —
under sudo, $USER is root and would add the wrong account:
sudo usermod -aG <group> <your-login-username>
# or, programmatically: sudo usermod -aG <group> "$(logname)"
Ingress — do not port-forward
The gateway binds to 127.0.0.1 by design. Expose it via Tailscale Funnel (named, revocable, TLS-terminated):
tailscale serve --bg --https=443 http://127.0.0.1:8080
tailscale funnel 443 on
Heartbeat and safe-stop (SF-002)
robot-md-gateway serve always runs a safety monitor, and there is no switch to
turn it off.
It starts held. A gateway that starts, or restarts, is in safe_stop: it
refuses every request with deny: safety_state, except a declared stop, until
an operator arms it. A restart is never a resume. To arm it, in this order:
-
Make the gateway reachable from the supervisor's device. It listens on 127.0.0.1 on the robot, so publish it on your tailnet with
tailscale serve(see Ingress). -
From the supervisor's device, never from the robot, send heartbeats at least every 3 seconds.
robot-md-gateway heartbeatsends one a second until Ctrl-C, and prints each change in what the gateway answers.--gatewayis the robot's gateway as that device reaches it; the token comes from a file orROBOT_MD_GATEWAY_TOKEN, never from the command line:robot-md-gateway heartbeat --gateway https://bob.<your-tailnet>.ts.net \ --token-file ~/.config/robot-md-gateway/supervisor.token
It refuses a gateway whose address is the machine it runs on (a loopback address, or one bound to an interface there, such as the robot's own tailnet name) unless
--i-am-on-the-robotis given. An SSH tunnel to the robot (ssh -L) is refused too, since from here it is a loopback address like the robot's own gateway; use the tailnet address. The guard catches a mistake, and keeping the supervisor token off the robot is the control: it cannot see a process in its own network namespace on the robot (a container), nor a name that resolves to a public relay (Funnel without MagicDNS). It stops at once on a 401 or 403: only a supervisor credential can send heartbeats. Stopping it stops the heartbeat, and the gateway trips 3 s later.Neither command follows a redirect or uses a proxy: a 3xx from the gateway's URL is a refusal, and
HTTP_PROXYandHTTPS_PROXYare ignored, so the token goes nowhere but the address given. Neither repeats anything typed on its command line in an error, so a mistyped flag such as--tokdoes not print the token that follows it. Neither refuses plainhttp://, and over the tailnet address that is fine, since WireGuard encrypts it; over an ordinary LAN, plainhttp://sends the token in clear. -
As the operator, clear it with the
commissioncredential. WhereROBOT_MD_REQUIRE_ENVELOPE_SIGNATUREis on, as on bob, the clear must be a signedESTOP_CLEARenvelope (see "Resuming" below);--keysigns one with a newmsg_idand the current time, with robot-md's keystore file (the keyrobot-md invokesigns with, and itspq_kid) or with an Ed25519 PEM and--kid:robot-md-gateway clear --gateway https://bob.<your-tailnet>.ts.net \ --token-file ~/.config/robot-md-gateway/commission.token \ --key ~/.robot-md/keys/RRN-000000000011.signing.json
A refused clear has spent its
msg_id; running the command again signs a new one.
Who may send the heartbeat. Only a credential with role: supervisor in
bearers.yaml (see Bearer tokens). Every other credential is
refused (403 not_a_supervisor), the agent's included: the heartbeat says that
the person supervising the robot can still reach it, so the thing being
supervised must never be able to keep it alive. A request with no bearer is
refused (401), and so is an unknown one (403).
Keep the supervisor token on the supervising person's device, such as the operator's app or laptop. Never put it on the host that runs the agent, and never on the robot. Where the agent runs on the robot itself, as on bob, either would put the heartbeat beside the thing it supervises, and a heartbeat sent from the robot only proves that the gateway is running.
When the heartbeat stops. After 3 seconds without one, the gateway enters
safe_stop. A watchdog thread checks every 0.1 s, whether or not requests are
arriving. Every move into safe_stop or estop_active (the in-process ESTOP
wire, app.state.safety_monitor.on_estop_wire), safe_stop to estop_active
included, is a trip:
- The gateway sends each actuator that declares a stop (
stop_capabilities) that stop, as itself: no bearer and no gate, at tierread, with the pinned manifest or none. For so-arm101-actuator 0.3.0 and later that isarm.estop: it latches, ends a paced move at its next setpoint and holds the pose. The hold is done in software; it is not a hardware e-stop. so-arm101-actuator 0.2.2 and earlier declare no stop at all (see "the arm's driver" below). - Each stop runs on a thread of its own, so a stop that hangs on its bus delays
no other actuator's stop and does not stop the watchdog. After 10 s without an
answer the gateway records it as failed and stops waiting for it, and from
then on refuses every motion through that actuator until it restarts
(
deny: stop_unreachable): a stop that does not answer is one the gateway cannot count on. A late answer does not lift that. A stop whose thread could not start is tried again on the next tick. - Nothing on this path reads ROBOT.md: what to stop, and the robot's RRN, were resolved when the gateway started.
- An actuator that refuses this stop, or answers it with an error, cannot be
counted on to stop, so every motion through it is refused from then until
the gateway restarts (
deny: stop_unreachable). The same holds from startup for one whose declared tiers (required_tiers, or a module-levelREQUIRED_TIERS) leave outread. A tool declared both as a stop and as a motion stops the gateway at startup. - The trip, each stop and each timeout are recorded in the audit chain and the
export (
safety_trip: ...,safety_stop: ...,safety_stop_timeout: ...). The trip record names the caller of the last accepted heartbeat. An actuator that declares no stop cannot be stopped this way: the gateway logsno_declared_stopfor it at startup, the trip record saysnothing was told to stop, and if it may move, the clear refuses to arm the gateway (below). - A request already past the gateway's checks when the trip begins is checked
once more just before the actuator is called, and refused there. If the trip
begins while a motion runs, the gateway sends that actuator its stop again
once the motion returns and the trip's own stop to it has answered
(
stopped_againin the response), and a clear waits for that stop too. The wait matters for so-arm101-actuator, whose stop latches at once and then waits for the bus that a paced move gives up at its next setpoint: a second stop sent while the first still waited was refused as busy. After the wait it is a stop repeated while latched, which writes the hold again. The stop sent again runs on a thread of its own, and the motion's request waits for the two stops at most 10 s in all. A stop sent again that is refused or fails is recorded and not held against the actuator, since a latching driver may refuse a repeat; one that does not answer within 10 s is, as the trip's own would be (deny: stop_unreachableuntil a restart). A paced driver must latch: one that does not would finish a move admitted before the trip, and the stop sent again would arrive only at its end.
From then on every request is refused with deny: safety_state, except a
declared stop (item 6 under What it does).
If the watchdog itself stops ticking for 1 s, the gateway fails closed: it
enters safe_stop and sends the stops, and the heartbeat and the clear answer
503 safety_watchdog, never 200. The heartbeat does that work on a stop lane,
not on the event loop, so the gateway keeps answering while it records. The
watchdog ticks every 0.1 s (SAFETY_TICK_S) and counts as stale after 1.0 s
without a tick (WATCHDOG_STALE_S). Run the gateway as a process of its own: a
CPU-bound thread inside the gateway's process can hold the watchdog off for
that long, and the next request or heartbeat then trips the gateway. Such a
trip fails safe: the actuators are sent their stops, and the gateway stays held
until a clear.
That check runs only when a request, a heartbeat or a clear arrives. If the
watchdog thread dies and nothing arrives, because the supervisor's device has
gone too, nothing would notice. So under systemd the watchdog also tells
systemd that it is ticking. The unit is Type=notify with WatchdogSec=5s:
the watchdog sends READY=1 after its first tick and WATCHDOG=1 every
quarter of WatchdogSec while its ticks run. When those stop, because the
thread died, hung, or fails on every tick, systemd stops the gateway with
SIGABRT and Restart=on-failure starts it again, held. A notification never
waits: if systemd stops reading its socket, the send fails, the tick goes on,
and the next tick that runs sends it again. Outside systemd nothing is sent.
A start after any end but a clean one sends every declared stop. A killed
process (the watchdog's SIGABRT, an out-of-memory kill, a crash) ends any
paced move it was streaming, but hardware that keeps its last goal when its
host process ends keeps it, and booting held is not a trip. So serve first
reads and removes a clean-shutdown marker in $STATE_DIRECTORY
(StateDirectory=robot-md-dispatcher in the unit). If there was none, it
sends each actuator that declares a stop that stop as the app is built,
before it serves anything, as a trip would (safety_start: ... in the audit
chain). Everything fails toward stops: no STATE_DIRECTORY, no marker, or one
that cannot be read, parsed or removed means the stops go out.
- The marker is left only at the end of the app's shutdown (uvicorn's graceful exit on SIGTERM or Ctrl-C), and only when the gateway is held, its watchdog is ticking, every stop it sent has answered (it waits up to 10 s for one still in flight), and no actuator's stop has failed or gone unconfirmed. So after a clean stop while held, the next start leaves the hardware alone: an arm someone is posing by hand does not stiffen. A stop while armed leaves no marker, and the next start sends the stops.
- A stop at start that fails, or does not answer within 10 s, leaves its
actuator refused (
deny: stop_unconfirmed) until a stop to it succeeds: its own late answer, a trip's stop, or a declared stop sent through/v1/invoke. The first commission clear after that sends the stop again and answers 409; a clear once it has answered arms the gateway. If it failed again, the gateway still arms, and motion through that actuator stays refused. - so-arm101-actuator latches on its stop, so after an unclean end the
documented resume also takes
arm.estop.clear(commission tier). WithoutStateDirectory=every start sends the stops.
Two more limits:
- from the kill until the new process listens, nothing answers on the port:
RestartSec=3splus the gateway's start-up. A stop sent then is refused at connect. Until the kill, the old process still serves stops on its stop lanes; - the unit and the gateway must come from the same version: this unit waits
for
READY=1, which an older gateway never sends, so its start fails after 90 s (TimeoutStartSec) andRestart=on-failurestarts it again, stopping an otherwise working gateway about every 93 s. robot-md'sinstall-gatewaywrites its own unit (robot-md-gateway.service), which needs the same four lines in the release whose gateway floor includes them.
Resuming takes two explicit steps. A heartbeat alone never resumes.
-
POST /v1/safety/clear, which is refused:- with 409 while any configured actuator may move and declares no stop: no
trip could stop it. "May move" means it declares motion
(
motion_capabilities) or says nothing about motion at all. An actuator that declares an emptymotion_capabilitiesmoves nothing and does not hold the gateway (castor-hal's read-only J1939 tap, the built-innoop); - with 409 while a stop of the last trip has neither answered nor timed out (the clear first sends any stop not yet sent);
- with 503 while the watchdog is not ticking;
- with 403 while the heartbeat is stale, or before any has arrived since the gateway started;
- with 403 below the commission tier;
- with 403, where
ROBOT_MD_REQUIRE_ENVELOPE_SIGNATUREis on, unless the body is a signed envelope of typeESTOP_CLEAR, with a freshtimestamp_ms, amsg_idnever seen before, and a key that is not revoked.
Allowed or refused, the clear is recorded like any decision: the audit chain, a signed receipt on the response, and a line in the export.
- with 409 while any configured actuator may move and declares no stop: no
trip could stop it. "May move" means it declares motion
(
-
Clear the actuator's own latch. For so-arm101-actuator, invoke
arm.estop.clearat the commission tier. It must be onROBOT_MD_TOOL_ALLOWLIST. Until then the arm refuses motion itself (deny: actuator_policy,estop_latched).
The arm's driver, and every other actuator. The clear refuses to arm a
gateway while any configured actuator may move and declares no stop. So every
actuator in bearers.yaml must declare a stop, or declare an empty
motion_capabilities, before the gateway can be armed. On bob that is two
packages:
- so-arm101-actuator 0.2.2 and earlier declare no stop and nothing about motion. Bob needs so-arm101-actuator 0.3.0 or later.
- oak-d-actuator, bob's camera, declares neither attribute up to 0.2.1, so a
gateway that loads it beside the arm answers every clear with 409, naming
oak-d. oak-d-actuator 0.2.2 declares both empty (RobotRegistryFoundation/oak-d-actuator#13); bob needs 0.2.2 or later.
To check what is installed, look for no_declared_stop in the gateway's
startup log (... so the gateway refuses to be cleared (armed) while it is configured), or run, in the gateway's environment:
python -c 'import so_arm101_actuator.actuator as a; print(a.STOP_CAPABILITIES)'
python -c 'from oak_d_actuator.actuator import OakDActuator as a; print(a.motion_capabilities, a.stop_capabilities)'
The arm's main prints frozenset({'arm.estop'}), and the camera with #13 prints
frozenset() frozenset(). Either fails with AttributeError on a version that
declares nothing.
A restart and the arm's latch. so-arm101-actuator keeps its latch in memory, inside the gateway's process, so a restart forgets it. The gateway's own hold stands in for it: a restarted gateway starts held and dispatches nothing but stops until a commission clear. After that clear the arm is not latched, so the clear alone resumes it. A restart also discards the in-memory audit chain; a clear keeps it.
What is not built yet. The design names the
robot-md-pendant
as the heartbeat's source (docs/gateway-integration-spec.md: a signed
heartbeat every second, 3 s staleness, an explicit resume). Nothing delivers a
pendant heartbeat yet, so the supervisor credential is a bearer token for now;
later the gateway should accept only the pendant's verified, signed heartbeat.
A second lease, renewed by the agent harness only when it has heard from the
model, would also stop the robot when the connection to the model is lost.
Configuration
Environment variables (also settable via CLI flags — flags win):
| Variable | Purpose | Default |
|---|---|---|
ROBOT_MD_PATH |
Path to the ROBOT.md this gateway enforces. When set, /v1/invoke denies (403 manifest_pin, audited) any envelope whose manifest_path resolves to a different file. Unset = no pin; bench only |
unset |
ROBOT_MD_BEARERS_FILE |
Path to bearers.yaml |
required |
ROBOT_MD_MCP_COMMAND |
Stdio MCP command the gateway dispatches to | robot-md-mcp |
ROBOT_MD_MCP_ARGS |
Space-separated args for the MCP command | (none) |
ROBOT_MD_LOG_LEVEL |
Python log level | INFO |
ROBOT_MD_REQUIRE_ENVELOPE_SIGNATURE |
Require every envelope to carry a signature this gateway can check. The replay window and the freshness window below only run when this is on. | off |
ROBOT_MD_ENVELOPE_MAX_SKEW_S |
Half-width of the envelope freshness window, in seconds, both directions. Unparseable, zero or negative values log a warning and fall back to the default, because a zero window would deny every envelope that carries a timestamp | 300 |
ROBOT_MD_REQUIRE_ENVELOPE_TIMESTAMP |
Deny an envelope that carries no timestamp_ms instead of letting it through unchecked |
off |
What a client gets back
/v1/invoke answers with exactly three shapes. A client that handles these
three handles every tool on every actuator.
Allowed and executed — 200:
{
"ok": true,
"manifest_kid": "bob-manifest-2026",
"scope": "MANIPULATE",
"tool_name": "arm.move_to",
"actuator_name": "so-arm101",
"outcome_kind": "executed",
"telemetry": {"...": "whatever the driver measured"},
"attestation": "attested",
"outcome": {"...": "the signed receipt"},
"envelope_signature": {"kid": "...", "alg": "Ed25519", "sig": "..."}
}
Denied — 403. By a gateway gate, or by the driver's own policy. Either
way it is signed, audited, and safe to keep as evidence:
{
"detail": {
"deny": "actuator_policy",
"reason": "out_of_workspace: x=500mm is outside the declared workspace (-200 to 340mm)",
"actuator_name": "so-arm101",
"telemetry": {"deny": "out_of_workspace", "reason": "x=500mm is outside ..."},
"attestation": "attested",
"envelope_signature": {"kid": "...", "alg": "Ed25519", "sig": "..."}
}
}
detail.deny names which gate refused (tier_policy, tool_allowlist,
manifest_provenance, safety_state, actuator_policy, …). For
actuator_policy — the driver's own refusal — detail.telemetry carries the
driver's machine-readable code when it produced one; branch on that, not on the
wording of reason. The key is absent when the driver had nothing structured to
say. A driver's refusal is recorded as a refusal: status: "denied" in the
signed receipt and decision: "deny", reason actuator_policy: ..., in the
audit chain.
Broken — 500. The driver raised. A fault is never dressed up as a
decision, so it does not arrive as a deny and carries no receipt.
Any of the three can also carry stopped_again: the gateway tripped while a
motion was being dispatched, so it sent that actuator its stop again after the
call returned and the trip's own stop had answered. The text names the trip and
the stop. Whatever else the response says, the actuator has since been told to
stop. If that stop had not answered within 10 s of the call's return, the text
ends by saying so: the response did not wait for it any longer, and the
gateway goes on waiting for it as for a trip's own stop.
What is inside the signed receipt
The outcome object is the receipt. Its bytes are what the Ed25519 signature
covers, so every field listed here is bound to the signature and cannot be
edited without breaking it.
{
"receipt_version": 2,
"corr_id": "the envelope's msg_id",
"rrn": "RRN-... (the robot, from its signed manifest)",
"status": "ok | denied | failure | error",
"started_at": "2026-09-14T...", "ended_at": "2026-09-14T...",
"caller": "craig-iphone",
"tier": "actuate",
"envelope_signature": {"kid": "...", "alg": "Ed25519", "sig": "..."}
}
caller names a CREDENTIAL, never a person. It is the caller field of
the bearer entry in bearers.yaml that authorised the request, the name the
operator wrote beside a token (craig-iphone, host-config,
readonly-probe). It says which token was presented. It does not say who was
holding the device, and no field in this receipt does. A bearer entry with no
caller declared produces "caller": null, which is the honest answer rather
than a guess.
receipt_version tells a reader which shape they have. Receipts signed before
v0.5.0a7 carry no receipt_version key at all, no caller and no tier;
those are version 1 and they stay valid forever. scripts/verify_receipt.py
accepts both, and prints which one it read:
python scripts/verify_receipt.py --receipt receipt.json --pubkey gateway.pub
Exit 0 means the bytes carry a signature from the key you supplied AND a
one-byte-flipped copy was rejected. On a version 2 receipt the flipped field is
caller, so a hand-edited caller exits non-zero. That is all a pass means: the
record has not changed since it was signed. It is not a statement that the
action was safe, correct, or authorised by any particular person. A signed
receipt is an accountability artifact, and reading it is the check.
Development
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest -q
.venv/bin/ruff check src tests
The test suite mocks external SDK boundaries via Protocol shims, so pytest runs offline. The tier gate, auth, and HTTP surface are exercised end-to-end with a TestClient. Real tool names from robot-md-mcp's server are pinned in tests/test_gating.py; if the upstream tool surface shifts in a way that inverts a read/actuate classification, the test fails loudly.
License
Apache-2.0. See LICENSE.
Metadata
Release files for robot-md-gateway 0.5.0a12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| robot_md_gateway-0.5.0a12.tar.gz | 376.2 kB | Without provenance | Details for robot_md_gateway-0.5.0a12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robot_md_gateway-0.5.0a12-py3-none-any.whl | Python 3 | none | any | Details for robot_md_gateway-0.5.0a12-py3-none-any.whl |
Total release size: 511.8 kB
Release files / robot_md_gateway-0.5.0a12.tar.gz
| Download URL | robot_md_gateway-0.5.0a12.tar.gz |
|---|---|
| Size | 376.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53522f866e0ec0ff67b1846ac095aee781d7ee3ba04d207ae65a2cb0e60c53b8
|
|
BLAKE2b-256 checksum How to use checksums |
0399ee0a0bdbdb050a95aeb075cc00635911d426370b0ccc1f7d38030fa09be8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / robot_md_gateway-0.5.0a12-py3-none-any.whl
| Download URL | robot_md_gateway-0.5.0a12-py3-none-any.whl |
|---|---|
| Size | 135.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c052b55ce8db4c1090c21264881d6f880a7658c9b2dd508acc0ab15a67a7c1d4
|
|
BLAKE2b-256 checksum How to use checksums |
8e23bee1a90fde5d0efcef9c67928ce3abbf63939a47ff529f516a3006386f41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for robot-md-gateway 0.5.0a12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.