A statute is just a function. We proved it — across four legal traditions, three languages, and one engine.
Today we released Legalis-RS 0.1.4 — the release where the legal computation engine stops being “a Japanese legaltech library” and becomes a universal one: 5 new jurisdictions (South Korea, Mexico, Malaysia, Russia, Saudi Arabia) bring the total to 23, alongside 6 production examples that prove a single generic engine handles Civil Law, Common Law, and Supranational law without special-casing any of them.
No C. No Fortran. No Z3 binary to install. No country-by-country rewrite, no bespoke SIer system per ministry, no waiting weeks for a manual legal review pass to confirm what a machine could have checked in milliseconds. Legalis-RS compiles to a single static binary — or to WASM for the browser — and carries 23 jurisdictions, an SMT verifier, and an LLM firewall inside it. This is Governance as Code, Justice as Narrative: the automatable parts of law become executable artifacts, and the parts that demand human judgment stay visibly, deliberately human.
Why Legalis-RS 0.1.4 is a game changer
The incumbent model of legaltech is structurally broken. Every jurisdiction is a separate codebase. Every amendment is a manual diff someone reads by hand. Every cross-border data question routes through a slow, expensive legal review that produces a PDF, not an artifact you can test. When a regulator updates a threshold, downstream systems learn about it in a meeting three weeks later.
Legalis-RS 0.1.4 attacks that head-on:
- One engine, 23 jurisdictions. The flagship
cross-jurisdiction-demoruns 4 legal systems, 3 languages, 1 engine — Civil Law (Japan, Germany), Common Law (United States), and Supranational law (EU) all resolve through the sameStatute/Condition/Effectprimitives. Nothing is special-cased. That is the proof of genericity, and it is now in the repo as runnable code. - 6 new production examples (4,488 lines) that each solve a real problem:
judgment-anonymization— structure-aware anonymization of court judgments via MeCab-style morphological NER, targeting APPI Article 35-2 compliance, at 95% accuracy vs 70% for naive regex redaction.llm-hallucination-firewall— validates LLM-generated legal citations against a config-driven statute database of 20 statutes across 3 jurisdictions, achieving 100% hallucination detection with zero false negatives.legislative-diff-simulator— paragraph-level legal diffing that emits 新旧対照表 (old/new comparison) amendment tables with impact-severity scoring.executable-law— a multi-language natural-language parser where Japanese18歳以上, English “at least 18 years”, and German “mindestens 18 Jahre” all compile to the sameCondition::Age { value: 18 }, with hot-reload and no recompilation.gdpr-cross-border-validator— a complete GDPR Chapter V implementation: adequacy decisions, SCCs, BCRs, derogations (Art. 45–49), and the Schrems II Transfer Impact Assessment.cross-jurisdiction-demo— the genericity proof itself.
- Real-time verification under 10ms.
legalis-verifiernow does streaming, incremental, event-driven verification and detects conflicts as statutes change — fast enough to sit in the editing loop, not in a nightly batch.
Technical Deep Dive: the four layers
Core Layer — legalis-core. The keystone is LegalResult<T>, which refuses to pretend everything is computable. A result is one of three things: Deterministic(T) for the genuinely automatable (age >= 18, income < threshold), JudicialDiscretion { .. } for what must stay human (just cause, public welfare, proportionality), or Void { reason } for logical contradictions. On top of Statute / Condition / Effect, 0.1.4 adds two ambitious modules: Quantum-Ready Legal Logic (quantum-circuit generation for legal decision problems — Hadamard / Pauli / CNOT / Toffoli gates, quantum-inspired optimization via annealing and QAOA, export to Qiskit / Cirq / Q#) and Autonomous Legal Agents (negotiation agents with Cooperative / Competitive / Mixed strategies, multi-agent systems, a legal chatbot framework, and self-improving reasoning via reinforcement learning).
Intelligence Layer — legalis-llm + legalis-verifier. legalis-llm gained Advanced Prompt Engineering (Chain-of-Thought, few-shot prompting, self-consistency voting), Performance Optimizations (request batching, response caching with TTL, streaming, token tracking), and Security & Privacy (PII detection/redaction, secure API-key management, output filtering, differential privacy). legalis-verifier gained Real-Time Verification (<10ms target latency, an event-driven update queue, automatic conflict detection), Self-Healing Systems (auto conflict-resolution suggestions — Harmonize / Repeal / Clarify / Prioritize / CreateException — each confidence-scored against a 0.6 threshold), and Cross-Domain Verification (multi-jurisdiction conflict detection, cross-border data-transfer validation). The verifier runs on OxiZ, a Pure Rust SMT solver — so formal verification needs no external library and no environment setup.
Knowledge & Output — legalis-registry + legalis-chain. legalis-registry adds a Legal Knowledge Base: ontology-based knowledge representation, semantic reasoning, knowledge-graph construction, and a SPARQL-like query interface. legalis-chain received comprehensive enhancements for multi-blockchain smart-contract generation with gas optimization, so a verified statute can be exported as on-chain logic.
API / SDK Layer — legalis-api. A new SDK Generation Framework introspects the Rust types and auto-generates fully typed TypeScript and Python SDKs (Python with asyncio). Define a statute once in Rust; ship clients to your web and data teams without hand-writing a line of glue.
Across all four layers, the Deterministic vs JudicialDiscretion split is the architectural keystone: it is what keeps Legalis-RS from becoming an “AI theocracy” that quietly automates judgments that belong to a human.
Getting Started
Add the core crate:
cargo add legalis-core
Build a statute programmatically:
use legalis_core::{Statute, Condition, Effect, EffectType, ComparisonOp};
// Build a statute programmatically: "voting rights at 18"
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,
});
Prefer to author statutes as law-like text? The DSL parser produces the same structures:
use legalis_dsl::LegalDslParser;
let parser = LegalDslParser::new();
let statute = parser.parse_statute(r#"
STATUTE adult-rights: "Adult Rights Act" {
WHEN AGE >= 18
THEN GRANT "Full legal capacity"
}
"#)?;
And when you want to see how a statute lands across a population, run a simulation:
use legalis_sim::{SimEngine, PopulationBuilder};
let population = PopulationBuilder::new()
.generate_random(1000)
.build();
let mut engine = SimEngine::new(vec![statute], population);
let metrics = engine.run_simulation().await?;
println!("{}", metrics.summary());
What’s New in 0.1.4
- 5 new jurisdictions — South Korea (
legalis-kr: 민법 Civil Code, 근로기준법 Labor Standards Act, 개인정보 보호법 PIPA), Mexico (legalis-mx), Malaysia (legalis-my: dual common/Islamic law), Russia (legalis-ru), and Saudi Arabia (legalis-sa: Sharia + PDPL 2021). Total jurisdictions: 18 → 23. - “Universal Legal Computation Engine” repositioning — 6 new production examples (4,488 lines) proving one generic engine spans Civil, Common, and Supranational law.
legalis-core: Quantum-Ready Legal Logic + Autonomous Legal Agents — quantum-circuit generation and negotiation/multi-agent frameworks.legalis-llm: prompt engineering, performance, and security — CoT/few-shot/self-consistency, batching/caching/streaming, PII redaction and differential privacy.legalis-verifier: real-time + self-healing — <10ms streaming verification with confidence-scored conflict-resolution suggestions, running on the OxiZ SMT solver.legalis-api: SDK generation — auto-emit typed TypeScript and Python SDKs from Rust.legalis-registry: Legal Knowledge Base — ontology, semantic reasoning, knowledge graphs, SPARQL-like queries.- Massive expansion of existing jurisdictions — UAE +414%, South Africa +143%, Brazil +138%, India +138% (DPDP Act 2023, plus the BNS/BNSS/BSA criminal-law reforms).
- Quality — all 37 clippy warnings resolved (now 0), benchmark compilation fixed in
legalis-verifier, and large error variants boxed inlegalis-cn.
This release ships 14,705 tests passing (up from 13,083 in 0.1.3), across 46 workspace crates (17 core + 23 jurisdictions + 6 examples), with 92 property-based tests, 42 Criterion benchmark groups, and 343 doc tests. MSRV is Rust 1.86, Edition 2024, licensed Apache-2.0 (dual MIT OR Apache-2.0). Pure Rust throughout; the few optional C dependencies are feature-gated and off by default.
Tips
- Turn on the SMT verifier with zero setup. Build with
cargo build --features smt-solverto enable OxiZ-backed formal verification. It is Pure Rust — no Z3 install, no external libraries, no environment variables. - Pull only the jurisdictions you need. Run
cargo add legalis-jp(orlegalis-kr,legalis-eu,legalis-sa, …) instead of pulling all 23. Each jurisdiction is its own crate, so your binary stays lean. - Author once, parse everywhere. Because
executable-lawmaps Japanese18歳以上, English “at least 18 years”, and German “mindestens 18 Jahre” to the sameCondition::Age { value: 18 }, you write a rule once and accept source text in any supported language — with hot-reload, no recompilation. - Ship SDKs, not glue code. Use
legalis-api’s SDK generator to emit TypeScript and Python clients straight from your Rust statute definitions, with full types andasyncio. - Triage conflicts with self-healing. When
legalis-verifierflags overlapping statutes, lean on its suggestions —Harmonize,Repeal,Clarify,Prioritize,CreateException— each scored against a 0.6 confidence threshold, so you review the ambiguous ones and auto-apply the obvious ones. - Know where automation must stop. Reach for
LegalResult::JudicialDiscretionto mark conditions that require human judgment. It is not a limitation — it is the safeguard that keeps the engine honest.
This is the foundation
Legalis-RS does not stand alone. Its formal verification rides on OxiZ, the Pure Rust SMT solver that replaces Z3 — which is why cargo build --features smt-solver needs nothing from the host system. Its Japanese-text anonymization (judgment-anonymization) uses MeCrab, the Pure Rust MeCab replacement, for the morphological NER that pushes accuracy to 95%. Both are COOLJAPAN siblings, both are Pure Rust, and both ship today — so the whole stack stays sovereign from statute text to verified result.
Repository: https://github.com/cool-japan/legalis
Star the repo if you believe legal infrastructure should be open, testable, and free of the bespoke per-country rewrite — and if you believe that not everything in law should be computable.
Pure Rust legal DX is here — fast, safe, and sovereign.
— KitaSan at COOLJAPAN OÜ January 29, 2026