RIL
The open policy language, formal verifier, and tamper-evident control plane for AI agents.
Write one .ril file to specify finite-state machines (machine), bounded runtime contracts (promise), authorization/budget rules (law), algebraic invariants (proof), and inline test blocks — verify it in ~6 ms (ril check), prevent PR policy weakening (ril laws diff & extends), migrate from AWS Cedar / CODEOWNERS / MCP in one command (ril import), generate typed Rust & TypeScript guards (ril codegen), and ship Ed25519-signed EU AI Act / SOC 2 / ISO 42001 compliance bundles (ril audit-pack).
Try RIL in your browser · Download v0.3.1 · PyPI (pip install retvest-ril) · Read RIL 0.3 Spec
10-Second Example: State Machine + Law + Inline Test
ril "Payment Settlement" version 3
machine settlement-flow
states Pending, Committed, Fulfilled, Breached
initial Pending
terminal Fulfilled, Breached
var approvals: int(0..3) = 0
var frozen: bool = false
transition approve: Pending -> Pending when !frozen && approvals < 3 set approvals = approvals + 1
transition commit: Pending -> Committed when !frozen && approvals >= 2
transition fulfill: Committed -> Fulfilled when !frozen
transition breach: Committed -> Breached set frozen = true
invariant quorum-before-commit: state == Committed => approvals >= 2
eventually reaches-terminal: state == Fulfilled || state == Breached
law allow-public-read
says "Agents may read public docs unless suspended."
why "Read-only access to public documents is safe for active principals."
on action read of Doc
permit when resource.public == true
forbid when principal.suspended == true
test suspended-user-is-denied
for "allow-public-read"
principal User::"mallory" { suspended: true }
resource Doc::"readme" { public: true }
expect deny
Run ril check — RIL exhaustively model-checks reachable states, deadlocks, invariants, liveness, algebraic proofs, and inline tests (printing the shortest counterexample trace if anything breaks).
Remove one rule. Watch the PR check fail.
This file-access policy denies a credentials read. The proposed version drops that deny rule. RIL flags the change before it can pass a required CI check.

Open the original policy and the proposed policy. The only policy change is the removed forbid line.
ril laws diff examples/file-access/laws.ril examples/file-access/weakened.ril
WEAKENED protect-files: removed or altered Forbid rule
BLOCKED: one or more laws were removed or weakened (owner approval required).
The command exits with code 1. You can also layer org baselines with extends "org-baseline.ril" — RIL mathematically proves child policies can only tighten, never loosen, parent laws or machine invariants.
Quickstart
1. Install
- Python standalone (SDK + ril CLI): pip install retvest-ril ril --version (Automatically downloads, SHA-256 verifies against SHA256SUMS.txt, and caches the matching native binary on first run; set RIL_NO_AUTO_DOWNLOAD=1 for air-gapped environments.)
pip install retvest-ril
ril --version
- Direct native binaries: Download from v0.3.1 (macOS arm64; cross-platform archives on v0.2.1) and verify against SHA256SUMS.txt.
2. Core Workflows
# Scaffold an enterprise starter pack and formally verify it
ril new --pack quorum-settlement --out settlement.ril
ril check settlement.ril
# Migrate existing AWS Cedar, CODEOWNERS, or MCP configs with auto-generated parity tests
ril import --from cedar policy.cedar --out migrated.ril
ril check migrated.ril
# Generate zero-dependency typed Rust or TypeScript runtime state machines
ril codegen examples/settlement.ril --lang rust --out settlement.rs
ril codegen examples/settlement.ril --lang ts --out settlement.ts
# Generate and independently verify an EU AI Act / SOC 2 / ISO 42001 compliance bundle
ril audit-pack examples/settlement.ril --framework all --out audit.json --markdown audit.md
ril verify-audit-pack audit.json
# Launch the zero-dependency local interactive playground (http://127.0.0.1:8787)
node playground/server.mjs
3. Govern AI Agent Tools in 5 Lines
Python (pip install retvest-ril) — works with sync & async def tools (OpenAI Agents SDK, Anthropic Tool Use, LangGraph):
from ril_sdk import RilClient, ril_govern
client = RilClient()
@ril_govern(client, "settlement.ril", action="read", actor='Agent::"assistant"')
async def read_doc(doc_id: str) -> str:
return f"content:{doc_id}"
TypeScript / Node (sdks/ts) — works with plain tool handlers & Vercel AI SDK { execute } objects:
import { RilClient, wrapTools } from "./sdks/ts/src/index.mjs";
const client = new RilClient();
const tools = wrapTools({ readDoc }, { client, lawFile: "settlement.ril" });
Integrations, Packs & Specs
| Surface | Start here |
|---|---|
| Specification & Conformance | RIL 0.3 Spec · LAWS-SPEC.md · 11-Vector Conformance Suite |
| Enterprise Packs | Quorum Settlement · PR Deploy Safety · PII Audit Access |
| AI Agent SDKs | Python SDK ( retvest-ril ) · TypeScript SDK ( @retvest/ril ) |
| Interactive Playground & Benchmarks | Local Playground · Reproducible Benchmarks |
| Coding Agents & CI | Claude Code · GitHub Action · Homebrew Formula |
| Language Starters | Rust + Kani · Python FastAPI · TypeScript Next.js |
Licensing
| Component | License |
|---|---|
| Native engine ( ril and ril.exe ), including the reference evaluator, model checker, prover, and verifier | Proprietary, closed source and free of charge under the Retvest Free Binary License |
| Language specifications & LAWS-SPEC.md , 11-case conformance suite , starter & enterprise packs , Python & TypeScript SDKs , playground , benchmarks , editor grammar , and installer scripts ( shell and PowerShell ) | Apache-2.0 (Part II of LICENSE) |
Retvest is an independent, non-commercial software project. See CONTRIBUTING.md to contribute a starter policy, conformance case, or editor integration.