# Safety pipeline

> Propose, validate, approve, execute. Nothing un-validated runs.

The model has no wire to execution. Everything it wants done is a **proposal**, and every proposal
passes the same deterministic steps:

1. **Structural validation.** Is the proposal well-formed?
2. **Semantic validation.** Is `method` one of this bundle's capabilities? Do `params` match its
   `params_schema`? A wrong param goes back to the model with the errors; it is never executed.
3. **Policy gate.** The capability's approval policy, and its optional condition, resolve to one of:

   | Decision | Meaning |
   |---|---|
   | `auto` | Runs now. |
   | `parent` | The parent agent decides (see [Agent trees](/loom-site/agents/agent-trees/)). |
   | `human` | Parked until a person approves or rejects it over the API. |
   | `deny` | Refused, and recorded. |

4. **Execute.** Only now is the capability's handler called, with the validated `params`.

Every step is written to the [audit ledger](/loom-site/concepts/audit-ledger/).

## Risk tiers

Each capability declares a `risk`: `read_only`, `mutating` or `dangerous`. The first two are labels
for readers. A `dangerous` capability can only be `human` or `deny`: a bundle that makes one `auto` or
`parent` is refused at load.

## Conditions

A capability may add a CEL `condition` over measures, the proposal and the caller:

```yaml
capabilities:
  - method: restart_host
    risk: dangerous
    approval: human
    condition: "m.disk_pct_avg > 95 && action.params.confirm == true"
```

## Approval

A parked proposal is released only by `POST /proposals/{id}/approve` (or `/reject`). The request
carries nothing but the caller's token: the method and params come from what the ledger recorded.
Approval re-runs validation and the gate, so a condition that now denies still stops it. A second
approval is refused.

Read the [Security model](/loom-site/deploy/security/) for what the gate does and does not guarantee.