Agent Constitution
The agent’s system prompt includes a tiered constitution that governs its behavior. Higher tiers cannot be overridden by lower ones.| Tier | Name | Can Override? | Examples |
|---|---|---|---|
| 1 | Safety-Critical | Never | Physical harm prevention, e-stop respect, workspace bounds, stale sensor handling |
| 2 | Security | Never | Prompt injection defense, tenant isolation, credential protection |
| 3 | Operational | AGENTS.md can refine | Investigate before hypothesizing, prefer reversible actions, work incrementally |
| 4 | Quality | Client can override | Response format, verbosity, structured output compliance |
- React mode adds pure reasoning guidance (no physical side effects, parallel tool calls allowed)
- OodaReAct mode adds physical execution guidance (OODA loop, one physical tool at a time, spatial context required)
SafetyFilterTask
TheSafetyFilterTask sits between the WASM controller output and the actuator input in the Copper task graph. It runs at 100 Hz and enforces hard limits on every command frame.
The safety pipeline applies four checks in order on every tick:
NaN / Inf fail-safe
Non-finite values (NaN, infinity) are replaced with zero. A controller producing NaN will not move the robot.
Velocity clamping
Each command value is clamped to the channel’s configured
limits range. For example, a UR5 joint velocity is clamped to +/-3.14 rad/s.Acceleration limiting
The delta from the previous tick’s clamped velocity is capped at
max_rate_of_change per tick. For a UR5 with max_rate_of_change: 0.5, this limits acceleration to 50 rad/s^2 at 100 Hz. This prevents step changes that could shear gears or damage the drivetrain.Position limit enforcement
When a velocity command channel has a paired
position_state_index, the filter checks the current joint position against its limits. If the joint is at or beyond a boundary (within a 0.05 rad safety margin) and the velocity would drive it further past, the velocity is zeroed.- Legacy mode (
clamp): uniform limits across all joints, used for backward compatibility - Channel mode (
clamp_frame): per-channel limits from theChannelManifest, used with the channel interface
roz-safety Daemon
The safety daemon is a separate OS process that monitors the health of the agent and worker processes. It communicates via NATS and operates independently of the control loop. Heartbeat monitoring. Each worker publishes periodic heartbeats. TheHeartbeatTracker watches for workers that miss their heartbeat deadline (30 seconds). When a worker goes stale, the daemon publishes an EStopEvent on safety.estop.{worker_id}.
Watchdog heartbeat. The daemon publishes its own heartbeat on safety.watchdog.heartbeat every 5 seconds, so other components can verify the safety daemon itself is alive.
E-stop events. When triggered (by heartbeat timeout, explicit request, or safety violation), the daemon publishes an EStopEvent that causes:
- The Copper control loop to zero all command outputs
- The agent to refuse further physical tool calls until the operator clears the e-stop
- The event to be logged for audit
Emergency Halt
The Copper control loop has a built-in emergency halt mechanism. When theCopperHandle is dropped (process exit, panic, or explicit halt), it sends a halt command that zeroes all outputs immediately.
This is a last-resort safety mechanism. The controller stops producing commands, and the safety filter’s default behavior (all channels at their default value, typically 0.0) takes over.
WASM Sandbox Isolation
WASM controllers are memory-isolated by wasmtime:- 16 MiB memory cap — the store limits prevent unbounded memory growth
- Single instance — only one WASM instance per store
- Epoch interruption — 8 ms budget per tick; long computations are trapped
- No host access — controllers cannot touch the filesystem, network, or any state beyond the channel interface host functions
- Verification before deployment — every controller runs 100 ticks under production limits before reaching the real robot
No Unsafe Code
Theunsafe keyword is denied workspace-wide in roz:
unsafe escape hatches in the codebase.
Source
- Constitution:
roz-agent/src/constitution.rs - Safety filter:
roz-copper/src/safety_filter.rs - Safety daemon:
roz-safety/src/main.rs - E-stop events:
roz-safety/src/estop.rs - Heartbeat tracker:
roz-safety/src/heartbeat.rs