> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rye.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Policy enforcement

> Understand how Rye evaluates model requests before they leave the workstation.

Rye evaluates policy at the network boundary before forwarding model requests upstream.

The policy engine receives structured request context:

* HTTP method.
* URI, host, and path.
* User agent.
* Content type.
* Model field when present.
* Body length.
* Parsed request body.

## Decisions

Policy rules produce one of three decisions:

| Decision          | Behavior                                                                            |
| ----------------- | ----------------------------------------------------------------------------------- |
| `Allow`           | Forward the request upstream.                                                       |
| `Deny`            | Block the request and return a structured `403` response.                           |
| `RequireApproval` | Block the request with a structured `403` response that marks approval as required. |

Blocked responses include the request ID, decision, rule ID, rule version, reason, and match metadata when available.

## Rule matching

Rules are checked in order. The first matching rule wins.

Supported condition types include:

| Condition        | Matches on           |
| ---------------- | -------------------- |
| `DomainContains` | Request host.        |
| `ModelContains`  | Parsed model value.  |
| `BodyContains`   | Parsed body content. |
| `MaxBodyBytes`   | Request body size.   |

## Local default policy

Rye starts with a local default policy so enforcement works before remote sync completes.

The default policy:

* Denies obvious SSH private-key exfiltration patterns.
* Denies oversized payloads above 2 MB.
* Allows common LLM and AI coding tool domains.
* Requires approval for requests that do not match an allow rule.

## Remote policy sync

When connected, the daemon syncs policy snapshots over gRPC.

Remote policy snapshots are:

* Validated before use.
* Stored locally in SQLite.
* Applied atomically.
* Acknowledged to the control plane.
* Reused from cache when the network is unavailable.

This makes policy a centrally managed and versioned artifact, not a local preference file inside one assistant.

## Inspect policy effects

Use `rye status` and `rye doctor` to verify daemon and policy state:

```bash theme={null}
rye status
rye doctor
```

Use history to inspect recent decisions and traffic:

```bash theme={null}
rye history --last 1h
rye history export --format json --last 1h
```

<Note>
  Rye policy is external to the assistant. Prompt instructions such as "do not send secrets" can guide behavior, but Rye policy can block a request before it leaves the workstation.
</Note>
