COOLJAPAN
← All posts

Legalis-RS 0.1.0 Released — Pure Rust Legal DX: Statutes as Verifiable Code

Legalis-RS is a Pure Rust framework that turns legal statutes into structured, machine-verifiable code — a Legal DSL parser, formal verifier, population simulator, and multi-jurisdiction support (JP/DE/FR/US). An honest first release.

release legalis legal-tech rust legal-dx formal-verification govtech

The law is the oldest source code humanity has ever written — and until now, it had no compiler.

Today we released Legalis-RS 0.1.0 — a Pure Rust framework for parsing, analyzing, and simulating legal statutes, transforming natural-language law into structured, machine-verifiable code.

No C. No C++. No Fortran. No JVM. No Python runtime in the core. The legal-tech world has long been split between opaque closed SaaS legal platforms you cannot inspect and academic tools like Catala, the Z3 SMT solver, and assorted Java/Python legal-reasoning stacks that nobody can actually deploy. Legalis-RS is Pure Rust — it compiles to a single static binary (or WASM) you can run anywhere, audit fully, and trust completely. This is what we call The Architecture of Generative Jurisprudence: Governance as Code, Justice as Narrative.

Its philosophical core is a single, deliberate constraint: not everything should be computable. Legalis-RS preserves the distinction between Deterministic Logic — computable outcomes like ages, income thresholds, and deadlines — and Judicial Discretion — the human interpretation that no machine should arrogate to itself.

Why 0.1.0 matters

Legal logic today lives locked inside PDFs, buried in opaque SaaS platforms, or trapped in academic prototypes that never leave a research lab. When a statute contains a contradiction — a benefit that can never be granted, a condition that can never be satisfied, a circular cross-reference — there is no compiler to catch it. We ship legal bugs straight into law and discover them only when a citizen falls through the gap.

Legalis-RS treats statutes the way we treat software. Concrete wins in this first release:

Technical Deep Dive: the Legalis-RS layers

Legalis-RS ships as 16 core crates plus 4 jurisdiction packs, organized into layers.

Core Layer. legalis-core holds the foundational types — LegalResult, Statute, Condition, Effect. legalis-dsl provides the Legal DSL parser together with an LSP server, so statutes get real IDE support. legalis-registry is a statute registry with Git-based version control, tags, and cross-reference resolution.

Intelligence Layer. legalis-llm is a multi-provider LLM integration framework (OpenAI, Anthropic, Google) that can compile law from natural language, with cost analytics and streaming. legalis-verifier performs formal verification: circular-reference detection, dead-statute detection of unsatisfiable conditions, constitutional-compliance checking, and complexity metrics — with an optional Z3 SMT solver integration for rigorous proofs.

Simulation & Analysis Layer. legalis-sim is an async simulation engine with population-based testing, temporal simulations, and economic-impact modeling on an ECS-like architecture. legalis-diff handles statute comparison and change detection — structural diffing and impact analysis.

Internationalization & Porting Layer. legalis-i18n provides multi-language and locale support plus a jurisdiction registry. legalis-porting enables cross-jurisdiction law transfer with cultural adaptation — a “Soft ODA” approach built on equivalence mapping.

Interoperability Layer. legalis-interop imports and exports Catala, Stipula, and L4 formats, with custom DSL converters.

Output Layer. legalis-viz renders decision trees, flowcharts, and 3D legal-space visualizations with SVG/PNG export. legalis-chain exports smart contracts to Solidity, WASM, and Ink!/Substrate. legalis-lod produces Linked Open Data — RDF/Turtle, SPARQL, and legal knowledge graphs.

Infrastructure Layer. legalis-audit provides immutable decision logging, forensic analysis, and partitioned storage with SQL/PostgreSQL backends. legalis-api serves REST and gRPC APIs with streaming, GraphQL, rate limiting, and OpenTelemetry. And legalis is the CLI itself — an interactive REPL, batch processing, LSP integration, and profiling.

The shipped jurisdictions are legalis-jp (Japan), legalis-de (Germany), legalis-fr (France), and legalis-us (USA).

Getting Started

Legalis-RS is a library-first framework. Add the core crate:

cargo add legalis-core

The framework also ships a legalis CLI binary — an interactive REPL with batch processing, LSP integration, and profiling.

Here is a statute built two ways — parsed from the Legal DSL, and constructed programmatically:

use legalis_core::{Statute, Condition, Effect, EffectType, ComparisonOp};
use legalis_dsl::LegalDslParser;

// Parse a statute from the Legal DSL
let parser = LegalDslParser::new();
let statute = parser.parse_statute(r#"
    STATUTE adult-rights: "Adult Rights Act" {
        WHEN AGE >= 18
        THEN GRANT "Full legal capacity"
    }
"#)?;

// Or build it programmatically
let statute = Statute::new(
    "voting-rights",
    "Voting Rights Act",
    Effect::new(EffectType::Grant, "Right to vote in elections"),
)
.with_precondition(Condition::Age {
    operator: ComparisonOp::GreaterOrEqual,
    value: 18,
});

The heart of the framework is the LegalResult<T> enum — the type that encodes not everything should be computable:

pub enum LegalResult<T> {
    Deterministic(T),            // Automated processing possible
    JudicialDiscretion { /* … */ }, // Human judgment required
    Void { reason: String },     // Logical inconsistency detected
}

And verifying a body of statutes before you trust it:

use legalis_verifier::StatuteVerifier;

let verifier = StatuteVerifier::new();
let result = verifier.verify(&statutes);
if !result.passed {
    for error in result.errors {
        eprintln!("Verification error: {}", error);
    }
}

Built with Rust 1.85+ / Edition 2024.

What’s inside

Tips

  1. Plain cargo build already gives you REST + gRPC. legalis-api now includes grpc in its default features, so a plain build works cross-platform on macOS, Linux, and Windows without --all-features and without any Z3 install.
  2. Want rigorous SMT proofs? Opt in. Enable the optional z3-solver feature on legalis-verifier. It requires a system Z3 install — brew install z3 — followed by source setup-z3-env.sh. Everything else works without it.
  3. Mark the human boundary explicitly. Use LegalResult::JudicialDiscretion wherever a rule must defer to a human. This is the seam between what you automate and what you must not.
  4. Simulate before you enact. Run legalis-sim against a generated population to see who a proposed rule actually affects before it becomes law.
  5. Bridge to the academic ecosystem. Export to Catala or L4 via legalis-interop to interoperate with existing formal-legal tooling.

A few honest caveats for a 0.1.0: the optional Z3 integration requires manual environment setup; a handful of examples still have dependency conflicts we are addressing; performance optimization is ongoing; and the documentation is English-only for now, with multilingual support planned.

Joining the COOLJAPAN family

Legalis-RS is a new Pure-Rust member of the COOLJAPAN ecosystem. It stands on its own — 0.1.0 has no COOLJAPAN crate dependencies — but it shares the same sovereign, Pure-Rust philosophy as siblings like SciRS2 for scientific computing: C/C++/Fortran-free, auditable, and self-contained.

Repository: https://github.com/cool-japan/legalis

Star the repo if you believe the law deserves a compiler too — and if you do, try modeling a statute you know and run the verifier against it.

Pure Rust legal-tech is here — fast, safe, and sovereign.

KitaSan at COOLJAPAN OÜ January 5, 2026

↑ Back to all posts