# How Rio Works

> What runs where, and what the exit code means.

Canonical HTML: https://getrio.dev/how-it-works

## Execution boundary: where every stage runs

When no Cloudflare endpoint is configured, steps 1 through 3 and step 7 run offline on your machine; steps 4 through 6 report as deferred.

### On your machine (steps 01, 02, 03, 07)

- **01 Prepare**: Computes diff against working tree, staged index, or merge-base.
- **02 Checks**: Runs tsc, ESLint, Pyright, Ruff, Clippy, tests, coverage, secrets, and audit.
- **03 Graph**: Builds bounded caller, import, and test graph around every changed symbol.
- **07 Report**: Renders interactive ratatui TUI or exports SARIF, JSON, and Markdown.

### In your Cloudflare account (steps 04, 05, 06)

- **04 Triage**: Selects risk-weighted hunks and bounded graph slices under your token budget.
- **05 Agents**: Runs specialist reviewers (correctness, security, performance, tests, contracts).
- **06 Verify**: Blind multi-voter quorum checks every proposed issue independently before surfacing.
- **Memory & PRs**: D1 and R2 store finding lineage, dismissals, and suppression proposals for your team.

## CI exit codes

Read check outcomes before reading findings. Zero findings combined with skipped or failed checks means the review is incomplete.

| Exit code | Meaning |
| --- | --- |
| `0` | No policy failure (optional checks may still be skipped) |
| `1` | One or more findings matched the repository failure policy |
| `2` | Usage, configuration, or profile validation error |
| `3` | Repository, internal, or persistence failure |
| `4` | Incomplete or cancelled analysis, or a required check was skipped |
| `5` | PR publication failed after an otherwise passing review |
| `130` | Interrupted twice (second Ctrl-C / SIGTERM) |

## Version-controlled review policy in YAML

Commit `.rio/profiles/default.yaml` to extend a built-in profile (`rio/base`, `rio/openrouter`, `rio/security`, `rio/critical`, `rio/qa`). Maps merge, lists replace.

```yaml
version: 1
name: strict
extends: rio/openrouter
publish: ask
fail_on:
  required_checks: [typecheck, lint]
  min_evidence: static_proven
```

Inspect and validate profiles before running:

```sh
rio profile show rio/base
rio profile init
rio profile validate
```
