22 breaking releases

Uses new Rust 2024

0.23.0 May 22, 2026
0.22.0 Mar 31, 2026
0.21.0 Mar 18, 2026
0.17.0 Dec 11, 2025
0.1.0 Oct 16, 2024

#267 in Authentication

Download history 2214/week @ 2026-02-16 3037/week @ 2026-02-23 1450/week @ 2026-03-02 1052/week @ 2026-03-09 1869/week @ 2026-03-16 1924/week @ 2026-03-23 4712/week @ 2026-03-30 1968/week @ 2026-04-06 1435/week @ 2026-04-13 2468/week @ 2026-04-20 1415/week @ 2026-04-27 1231/week @ 2026-05-04 1625/week @ 2026-05-11 778/week @ 2026-05-18 511/week @ 2026-05-25 2151/week @ 2026-06-01

5,070 downloads per month
Used in 2 crates

AGPL-3.0-only

530KB
12K SLoC

aranya-policy-compiler

The Aranya Policy Compiler is a core component of the Aranya project that compiles policies written in the Aranya Policy Language into modules that can be loaded and executed by the Aranya runtime.

Overview

The compiler reads policy source code, often stored in a Markdown file, and emits bytecode that can be executed by the Aranya Policy VM.

Usage

As a Library

use aranya_policy_compiler::{Compiler, validate};
use aranya_policy_lang::lang::parse_policy_document;
use aranya_policy_vm::VM;

// Parse policy source code
let policy_str = std::fs::read_to_string("policy.md")?;
let policy = parse_policy_document(&policy_str)?;

// Compile to module
let compiler = Compiler::new(&policy);
let module = compiler.compile()?;

// Validate the compiled module
if !validate(&module) {
    eprintln!("Module validation failed");
}

// Execute a policy action
let mut vm = VM::new();
vm.load_module(module)?;
let result = vm.call_action("my_action", &args)?;
println!("Action result: {:?}", result);

As a Command-Line Tool

The crate also provides a command-line interface through the policy-compiler binary:

# Compile a policy file
policy-compiler input.md -o output.pmod

# Compile without validation
policy-compiler input.md --no-validate

# Compile with FFI stubbing for testing
policy-compiler input.md --stub-ffi

Dependencies

~23MB
~354K SLoC