Safety API Reference¶
effero.safety
¶
Runtime guardrail engine: policy-as-code checks that run independently of the LLM, between the skill layer and the Device Abstraction Layer.
Evaluates declarative policies against live telemetry and device facts via the high-performance out-of-process Rust safety kernel daemon (TCP 127.0.0.1:9400).
ApprovalHandler
¶
Bases: ABC
Abstract interface for receiving and resolving HITL approval requests.
Source code in src/effero/safety/approval.py
request_approval(request)
abstractmethod
async
¶
ApprovalRequest
dataclass
¶
A request for human approval before executing a sensitive action.
Source code in src/effero/safety/approval.py
ApprovalResponse
dataclass
¶
The human decision for an approval request.
Source code in src/effero/safety/approval.py
AutoApprovalHandler
¶
Bases: ApprovalHandler
Approval handler that resolves requests automatically.
Supports:
- All-or-nothing mode (default: approve_all=True or approve_all=False)
- Graduated per-SafetyClass mode (graduated=True):
- READ_ONLY / ACT_AUTONOMOUS: auto-approved (True)
- ACT_RESTRICTED: auto-denied (False, simulation only)
- ACT_WITH_APPROVAL: evaluates according to approve_approval_gated (default False)
Source code in src/effero/safety/approval.py
CallbackApprovalHandler
¶
Bases: ApprovalHandler
Approval handler that dispatches to an async callback (e.g. Web UI, WebSocket, Telegram).
Source code in src/effero/safety/approval.py
resolve(request_id, approved, comment=None)
¶
Resolve a pending approval request externally.
Source code in src/effero/safety/approval.py
ConsoleApprovalHandler
¶
Bases: ApprovalHandler
Interactive CLI terminal approval prompt.
Source code in src/effero/safety/approval.py
GraduatedApprovalHandler
¶
Bases: ApprovalHandler
Graduated approval handler: auto-approves safe classes, gates ACT_WITH_APPROVAL via delegate.
- READ_ONLY: auto-approved
- ACT_AUTONOMOUS: auto-approved
- ACT_WITH_APPROVAL: delegates to secondary handler (e.g. Console or Callback)
- ACT_RESTRICTED: denied by default (simulation/sandbox only)
Source code in src/effero/safety/approval.py
SafetyClient
¶
Async TCP client for the effero-safety-kernel.
The safety kernel is an independent Rust process that evaluates proposed actions against a declarative policy before they reach hardware. Communication uses newline-delimited JSON over TCP.
Source code in src/effero/safety/client.py
connect()
async
¶
Connect to the safety kernel.
check_action(skill_name, facts=None)
async
¶
Check whether an action is allowed by the safety policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skill_name
|
str
|
The skill being invoked (e.g., 'iot.lights.toggle') |
required |
facts
|
dict[str, Any] | None
|
Optional dict of numeric/boolean facts for condition evaluation |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict with 'decision' key: 'allow', 'require_approval', 'deny', or 'limit' |
Source code in src/effero/safety/client.py
send_heartbeat()
async
¶
Send a heartbeat to prevent the safety kernel watchdog from tripping.
get_status()
async
¶
reset_watchdog()
async
¶
SafetyDaemonManager
¶
Discovers, starts, monitors, and stops the Rust safety kernel daemon.
Source code in src/effero/safety/daemon.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
find_binary()
¶
Find the effero-safety-kerneld binary on PATH or local workspace targets.
Source code in src/effero/safety/daemon.py
is_running()
async
¶
Check if a safety kernel daemon is already accepting connections on host:port.
Source code in src/effero/safety/daemon.py
ensure_running()
async
¶
Ensure the safety daemon is running; spawn it if absent and binary is found.
Source code in src/effero/safety/daemon.py
stop()
async
¶
Stop the child safety daemon process if we started it.