The Architecture of Generative Jurisprudence
Governance as Code, Justice as Narrative
Legalis-RS is a Rust framework for parsing, analyzing, and simulating legal statutes across multiple jurisdictions. It transforms natural language legal documents into structured, machine-verifiable code while preserving the essential distinction between:
- Deterministic Logic (Code): Computationally derivable legal outcomes (age requirements, income thresholds, deadlines)
- Judicial Discretion (Narrative): Areas requiring human interpretation and judgment
This separation is the philosophical core of Legalis-RS - it explicitly marks where AI-assisted legal processing must yield to human judgment, serving as a safeguard against algorithmic overreach in legal systems.
๐ Global Coverage: 23 operational jurisdictions spanning Civil Law, Common Law, Socialist, Islamic Law, and Supranational legal traditions:
- ๐ฆ๐ช UAE - Civil Law + Islamic Law (Federal Law, Commercial, Labor, PDPL, Free Zones - DIFC/ADGM)
- ๐ฆ๐บ Australia - Common Law + Statutory (Torrens system, Fair Work Act, Consumer Law, Privacy, Immigration)
- ๐ง๐ท Brazil - Civil Law (Cรณdigo Civil, CDC, LGPD, CLT, Tax Law - ISR/IVA/IEPS)
- ๐จ๐ฆ Canada - Common Law + Civil Law (Quebec) (Charter of Rights, Aboriginal rights, Federal-provincial)
- ๐จ๐ณ China - Socialist Civil Law (ๆฐๆณๅ ธ 7 Books, Data Security Law, Foreign Investment Law, Anti-Monopoly Law)
- ๐ฉ๐ช Germany - Civil Law (BGB, GmbHG, HGB, Grundgesetz)
- ๐ช๐บ European Union - Supranational Law (GDPR, Competition Law, Treaties, 11 languages)
- ๐ซ๐ท France - Civil Law (Code civil, Code du travail, 35-hour work week)
- ๐ฎ๐ฉ Indonesia - Civil Law (Civil Code, UU Cipta Kerja Omnibus Law, Investment, Labor, Tax)
- ๐ฎ๐ณ India - Common Law + Statutory (Constitution, BNS/BNSS/BSA, DPDP, Companies Act, IBC)
- ๐ฏ๐ต Japan - Civil Law + Asian Tradition (Minpล, Labor, IP Law, e-Gov integration, 16+ domains)
- ๐ฐ๐ท South Korea - Civil Law (๋ฏผ๋ฒ, ๊ทผ๋ก๊ธฐ์ค๋ฒ, ๊ฐ์ธ์ ๋ณด ๋ณดํธ๋ฒ, Commercial Code, Fair Trade Act)
- ๐ฑ๐ฆ Lao PDR (Laos) - Civil Law + Socialist Tradition (Civil Code 2020, Japanese/French influences, ODA)
- ๐ฒ๐ฝ Mexico - Civil Law (Cรณdigo Civil Federal, LFT, LFPDPPP, Tax Law - ISR/IVA/IEPS)
- ๐ฒ๐พ Malaysia - Common Law + Islamic Law (Federal Constitution, Companies Act, PDPA, Islamic Family Law)
- ๐ท๐บ Russia - Civil Law (ะัะฐะถะดะฐะฝัะบะธะน ะบะพะดะตะบั 4 Parts, Tax Code, Labor Code, 152-FZ Data Protection)
- ๐ธ๐ฆ Saudi Arabia - Islamic Law + Civil Law (Basic Law, Sharia, Companies Law 2015, PDPL 2021)
- ๐ธ๐ฌ Singapore - Common Law + Statutory (Companies, Employment, PDPA, Banking, Payment Services)
- ๐น๐ญ Thailand - Civil Law (Civil & Commercial Code 6 Books, Labor Law, BOI, Tax Law)
- ๐ฌ๐ง United Kingdom - Common Law (Employment Rights, Consumer Rights, Financial Services)
- ๐บ๐ธ United States - Common Law (Restatement of Torts, 51 jurisdictions, Choice of Law)
- ๐ป๐ณ Vietnam - Socialist Civil Law (Civil Code 91/2015, Cybersecurity Law, Competition Law)
- ๐ฟ๐ฆ South Africa - Mixed Law (Constitution 1996, Companies Act, LRA/BCEA, POPIA, Customary Law)
Total: 1,553 jurisdiction files (~383k jurisdiction LoC), 74 workspace crates (16 core + 23 jurisdictions + 35 examples), 18,398 tests passing with comprehensive coverage across all jurisdictions.
"Not everything should be computable."
The LegalResult<T> type embodies this principle:
pub enum LegalResult<T> {
Deterministic(T), // Automated processing possible
JudicialDiscretion { ... }, // Human judgment required
Void { reason: String }, // Logical inconsistency detected
}legalis-rs/
โโโ crates/
โ โโโ # Core Layer
โ โโโ legalis-core/ # Core types, traits, state management
โ โโโ legalis-dsl/ # Domain Specific Language parser
โ โโโ legalis-registry/ # Statute registry with version control
โ โโโ # Intelligence Layer
โ โโโ legalis-llm/ # LLM integration (OpenAI, Anthropic, etc.)
โ โโโ legalis-verifier/ # Formal verification (SMT solver)
โ โโโ # Simulation & Analysis Layer
โ โโโ legalis-sim/ # Simulation engine (ECS-like)
โ โโโ legalis-diff/ # Statute diffing and change detection
โ โโโ # Internationalization & Porting Layer
โ โโโ legalis-i18n/ # Multi-language/jurisdiction support
โ โโโ legalis-porting/ # Cross-jurisdiction law transfer
โ โโโ # Interoperability Layer
โ โโโ legalis-interop/ # Import/export: Catala, Stipula, L4 formats
โ โโโ # Output Layer
โ โโโ legalis-viz/ # Visualization (decision trees, flowcharts)
โ โโโ legalis-chain/ # Smart contract export (Solidity, WASM, Ink!)
โ โโโ legalis-lod/ # Linked Open Data (RDF/TTL) export
โ โโโ # Infrastructure Layer
โ โโโ legalis-audit/ # Audit trail and decision logging
โ โโโ legalis-api/ # REST API server
โ โโโ legalis/ # Command-line interface
โโโ jurisdictions/
โ โโโ ae/ # UAE: Federal Law, Commercial, Labor, PDPL, Free Zones
โ โโโ au/ # Australia: Torrens, Fair Work, Consumer, Privacy, Immigration
โ โโโ br/ # Brazil: Civil Code, Consumer, LGPD, CLT Labor
โ โโโ ca/ # Canada: Charter, Aboriginal rights, Federal-provincial
โ โโโ cn/ # China: Civil Code, Contract, Corporate, Data Protection
โ โโโ de/ # Germany: BGB, GmbHG, HGB, Grundgesetz
โ โโโ eu/ # EU: GDPR (11 languages), Competition, Treaties
โ โโโ fr/ # France: Code civil, Code du travail (35h week)
โ โโโ id/ # Indonesia: Civil Code, Investment, Labor, Tax
โ โโโ in/ # India: Constitution, IPC/BNS, DPDP, Consumer, Corporate
โ โโโ jp/ # Japan: Minpล, e-Gov, APPI, 16+ domains
โ โโโ la/ # Lao PDR: Civil Code 2020, Japanese/French influences
โ โโโ sg/ # Singapore: Banking, Payments, PDPA, CPF
โ โโโ th/ # Thailand: Civil Code, Labor, Investment, Data Protection
โ โโโ uk/ # UK: Employment, Consumer, Financial Services
โ โโโ us/ # USA: Restatement, 51 jurisdictions, Choice of Law
โ โโโ vn/ # Vietnam: Civil Code, Investment, Labor, Cybersecurity
โ โโโ za/ # South Africa: Companies Act, LRA/BCEA, POPIA, BBBEE
โโโ examples/
โ โโโ jp-constitution-3d/ # 3D visualization of Japanese Constitution
โ โโโ welfare-benefits/ # Welfare benefits eligibility system
โโโ legalis.md # Full specification document
โโโ Cargo.toml # Workspace configuration
โโโ README.md
Project Scale (v0.1.6):
| Metric | Count | Details |
|---|---|---|
| Total Lines of Code | 1,422,375 | Rust (1.12M), Python (8.6k), Markdown (63k), TypeScript (1.7k) |
| Rust Code Lines | 961,371 | Code only (from tokei) |
| Documentation Lines | 177,689 | Inline Rust documentation (/// and //!) |
| Rust Files | 2,718 | Across 74 workspace crates |
| Tests Passing | 18,398 | cargo nextest: 18,398 passed, 2 skipped (across 136 binaries) |
| Workspace Crates | 74 | 16 core + 23 jurisdictions + 35 examples |
| Jurisdictions | 23 | AE, AU, BR, CA, CN, DE, EU, FR, ID, IN, JP, KR, LA, MX, MY, RU, SA, SG, TH, UK, US, VN, ZA |
| Supported Languages | 60+ | Multi-language i18n support |
| Documentation Ratio | 17.5% | Comments to code ratio (industry average: 10-20%) |
| Zero Warnings | โ | Strict clippy compliance enforced |
| Universal Engine Examples | 6 | Proof of universal legal computation engine (introduced v0.1.4) |
Testing Infrastructure:
- Unit Tests: 18,398 passing (cargo nextest, 2 skipped)
- Integration Tests: 22+ test files
- Benchmark Suites: 13 Criterion benchmarks
- Property-Based Tests: 10+ tests across multiple crates
- Fuzzing Targets: 3 libFuzzer-based fuzz targets
- Doc Tests: 343 passing
Edition: Rust 2024 | MSRV: 1.86
All 74 workspace crates (16 core + 23 jurisdictions + 35 examples) compile cleanly with NO WARNINGS - strict quality policy enforced.
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-core |
0.3.0 | 631 | Core type definitions: LegalResult, Statute, Condition, Effect. Case law database, TypedEntity system, hierarchical relationships. |
legalis-dsl |
0.2.0 | 453 | Parser for the Legal DSL syntax with LSP support, REPL, error recovery, AST optimization. |
legalis-registry |
0.2.9 | 680 | Central statute registry with distributed Raft consensus, vector search, blockchain anchoring, real-time collaboration. |
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-llm |
0.4.8 | 543 | LLM provider abstraction (OpenAI, Anthropic, Gemini, Ollama) with law compiler, federated learning, neuro-symbolic integration. |
legalis-verifier |
0.2.9 | 392 | Static analysis with OxiZ SMT solver (Pure Rust), temporal logic (LTL/CTL), formal methods (Coq, Lean 4), distributed verification. |
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-sim |
0.2.9 | 643 | Async simulation engine with GPU acceleration, distributed execution, agent-based modeling, economic/healthcare/urban simulation. |
legalis-diff |
0.4.0 | โ | Statute diffing with AI-powered analysis, ML integration, quantum-ready algorithms, time-travel diffing. |
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-i18n |
0.3.4 | 584 | Multi-language support (60+ languages), ICU message format, legal citation formatting (Bluebook, OSCOLA, etc.), RTL support. |
legalis-porting |
0.3.0 | 298 | Cross-jurisdiction law transfer with cultural adaptation (Soft ODA), multi-hop porting chains, confidence scoring. |
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-interop |
0.2.8 | 465 | Import/export for Catala, Stipula, L4, Akoma Ntoso, LegalRuleML, BPMN, DMN formats. |
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-viz |
0.2.0 | 453 | Visualization with VR/AR support, 3D/holographic display, AI-powered selection, legal history scrollytelling. |
legalis-chain |
0.3.7 | โ | Smart contract generation (Solidity, WASM, Ink!, Move, Cairo, CosmWasm) with gas optimization, L2 support. |
legalis-lod |
0.3.9 | 799 | Linked Open Data (RDF/TTL) export, SPARQL queries, OWL reasoning, triple store integration. |
| Crate | Version | Tests | Description |
|---|---|---|---|
legalis-audit |
0.2.4 | 529 | Audit trail with blockchain anchoring, Merkle trees, SIEM integration, compliance frameworks (GDPR, SOX, ISO 27001). |
legalis-api |
0.2.3 | 200 | REST + gRPC + GraphQL APIs with OAuth2/OIDC, WebSocket, SSE, API Gateway features. |
legalis (CLI) |
0.2.3 | โ | Command-line tool with AI-powered features, interactive TUI, workflow automation, cloud integration. |
Legalis-RS now includes comprehensive support for 23 major jurisdictions (all fully implemented):
| Jurisdiction | Status | Files | Tests | Description |
|---|---|---|---|---|
au (Australia) |
โ Complete | 118 | 571 | Common Law + Statutory: Commonwealth Constitution with implied rights, Contract Law (ACL), Corporate Law (Corporations Act), Criminal Law, Employment Law (Fair Work Act), Family Law, Property Law (Torrens system, Native Title), Tort Law (defamation, negligence). |
ca (Canada) |
โ Complete | 48 | 239 | Common Law + Civil Law (Quebec): Canadian Charter of Rights and Freedoms, Federal-provincial division of powers, Contract Law, Corporate Law (oppression remedy), Criminal Code, Employment Law, Family Law (child/spousal support), Property Law (Aboriginal rights), Tort Law (occupiers' liability). |
de (Germany) |
โ Complete | 115 | 835 | Civil Law System: BGB 5-book structure (Erbrecht, Familienrecht, Sachenrecht, Schuldrecht, Unerlaubte Handlungen ยง823-826), GmbHG, HGB, AKTG, Arbeitsrecht, Grundgesetz. 22 examples, 2 test suites. |
eu (European Union) |
โ Complete | 102 | 309 | Supranational Law: GDPR (11 languages), Consumer Rights Directive, Competition Law (Articles 101-102 TFEU), Charter of Fundamental Rights, Four Freedoms, Treaty Framework. EUR-Lex/CELEX citation system. 25 examples. |
fr (France) |
โ Complete | 79 | 573 | Civil Law System: Code civil (Napoleonic Code 1804, 2016 reform), Code de commerce (SA/SARL/SAS), Code du travail (35-hour work week, SMIC), Constitution de 1958. 11 domains (highest coverage), 69.7% documentation ratio (industry-leading), 573 tests passing. |
jp (Japan) |
โ Complete | 122 | 676 | Civil Law + Asian Tradition: 16+ domains (most extensive) - ๆฐๆณ (Minpล 709-715), ๅๆณ/ไผ็คพๆณ, ๅดๅๅบๆบๆณ, ็ฅ็่ฒก็ฃๆณ, ๆถ่ฒป่ ไฟ่ญทๆณ, ๅไบบๆ ๅ ฑไฟ่ญทๆณ (APPI), ๅปบ่จญๆฅญๆณ, ่กๆฟๆ็ถๆณ (e-Gov integration), ็ฐๅขๆณ. 676 tests, 27,600+ lines, 7 test suites, 21 examples. Era system (ๅ ๅท), contract risk analysis. |
la (Lao PDR) |
โ Complete | 104 | 702 | Civil Law + Socialist Tradition: Civil Code 2020 (Law No. 66/NA, 1087 articles, 6 books) - General Provisions, Property, Obligations, Family, Inheritance. Japanese/French influences, JICA ODA legal assistance documentation, comparative law analysis (ๆฏ่ผๆณๅญฆ), legal transplantation research. Bilingual (Lao/English), ODA program evaluation. |
sg (Singapore) |
โ Complete | 114 | 711 | Common Law + Statutory: Companies Act (ACRA), Employment Act (CPF), PDPA 2012 (DPO, DNC), Consumer Protection, IP Laws, Banking Act (Basel III CAR), Payment Services Act 2019 (DPT/Crypto, 7 service types). 2 test suites, 19 examples, trilingual (EN/ไธญๆ/Melayu). |
uk (United Kingdom) |
โ Complete | 140 | 680 | Common Law: Employment Rights Act 1996 (unfair dismissal, redundancy), UK GDPR + DPA 2018, Consumer Rights Act 2015 (tiered remedies), Contract Law (common law precedents), Companies Act 2006, Financial Services (AML/CFT, MiFID2, Payment Services). Most RS files (127), 10-11 domains. |
us (United States) |
โ Complete | 121 | 626 | Common Law System: Restatement of Torts (ALI ยง158, ยง46, ยง402A), 51 jurisdictions (50 states + DC) with state-specific variations, Choice of Law (5 approaches), Uniform Acts (UCC/UPA), Federal-State boundary analysis, Professional licensing (UBE, IMLC, NCARB), Tax variations, Cannabis/Privacy tracking. 626 tests, 18,700+ lines. |
ae (UAE) |
โ Complete | 37 | 170 | Civil Law + Islamic Law: Federal Decree-Laws (Labor 33/2021, Companies 32/2021, PDPL 45/2021), Free Zones (DIFC/ADGM Common Law), Islamic Law (Sharia family/inheritance), Tax Law (VAT 15%, Corporate Tax 2023), Civil Code 5/1985, Banking & Finance. Bilingual (Arabic/English). |
br (Brazil) |
โ Complete | 39 | 199 | Civil Law System: Cรณdigo Civil (Lei 10.406/2002) with 7 books, Consumer Protection (CDC), LGPD Data Protection, CLT Labor Law, Tax System (ICMS/ISS/IPI/IRPF/IRPJ), Corporations Law 6.404/1976, Bankruptcy Law 11.101/2005. Portuguese language support. |
cn (China) |
โ Complete | 38 | 190 | Socialist Civil Law: ๆฐๆณๅ ธ (Civil Code 2021) - 7 Books/1,260 articles, Data Security Law, Foreign Investment Law, Anti-Monopoly Law 2022, Company Law 2023, Labor Contract Law, Cybersecurity Law. Bilingual (ไธญๆ/English), Chinese authoritative. |
id (Indonesia) |
โ Complete | 35 | 164 | Civil Law System: KUHP (Criminal Code), Company Law 40/2007, UU Cipta Kerja (Omnibus Law 2020), Tax Law (PPN/PPh), Capital Markets Law 8/1995, Banking Law, IP Law, Land Law 5/1960 (UUPA). Bahasa Indonesia support. |
in (India) |
โ Complete | 94 | 235 | Common Law + Statutory: Constitution, BNS/BNSS/BSA 2023 (new criminal codes), Companies Act 2013, IBC 2016 (Insolvency), DPDP 2023, GST, SEBI Regulations, IP Laws (Patents/Trademarks/Copyright), Competition Act 2002, FEMA 1999. Hindi/English bilingual. |
kr (South Korea) |
โ Complete | 40 | 131 | Civil Law System: ๋ฏผ๋ฒ (Civil Code 1958) - 1,118 articles, ๊ทผ๋ก๊ธฐ์ค๋ฒ (Labor Standards Act) - 40h/week, ๊ฐ์ธ์ ๋ณด ๋ณดํธ๋ฒ (PIPA 2011), Commercial Code 1962, ์๋ฒ (Company Law), ๊ณต์ ๊ฑฐ๋๋ฒ (Fair Trade Act). Bilingual (ํ๊ตญ์ด/English), Korean Won currency. |
mx (Mexico) |
โ Complete | 42 | 111 | Civil Law System: Cรณdigo Civil Federal, LFT (Federal Labor Law) - Aguinaldo/Vacation, LFPDPPP (Data Protection), Tax Laws (ISR/IVA/IEPS), LGSM (Commercial Companies Law), LFCE (Competition Law). Spanish language support, Mexican Peso currency. |
my (Malaysia) |
โ Complete | 42 | 93 | Common Law + Islamic Law: Federal Constitution 1957, Companies Act 2016, Employment Act 1955, PDPA 2010, Contracts Act 1950, Islamic Family Law (for Muslims), Islamic Finance, Tax Law (Income Tax/SST). Trilingual (Malay/English/Chinese), dual legal system. |
ru (Russia) |
โ Complete | 22 | 80 | Civil Law System: ะัะฐะถะดะฐะฝัะบะธะน ะบะพะดะตะบั (Civil Code) - 4 Parts, ะฃะณะพะปะพะฒะฝัะน ะบะพะดะตะบั (Criminal Code 63-FZ), ะขััะดะพะฒะพะน ะบะพะดะตะบั (Labor Code 197-FZ) - 40h/week, Tax Code (VAT 20%, Income 13%), 152-FZ Personal Data Law, Company Laws (LLC/JSC), Competition Law 135-FZ. Bilingual (ะ ัััะบะธะน/English). |
sa (Saudi Arabia) |
โ Complete | 22 | 133 | Islamic Law + Civil Law: Basic Law of Governance 1992, Sharia principles (Hanbali), Companies Law 2015, Labor Law 2005 (EOSA/Nitaqat), PDPL 2021, Tax Laws (VAT 15%, Zakat 2.5%, CIT 20%), Capital Market Law, Arbitration Law 2012. Bilingual (ุงูุนุฑุจูุฉ/English), Hijri calendar. |
th (Thailand) |
โ Complete | 37 | 174 | Civil Law System: Civil & Commercial Code (6 Books), Criminal Code, Labor Law, Tax Law (Revenue Code - CIT/PIT/VAT), BOI Investment Promotion, IP Law, Immigration Act, Land Code, Securities Law. Thai Buddhist calendar (เธ.เธจ.), bilingual Thai/English. |
vn (Vietnam) |
โ Complete | 24 | 154 | Socialist Civil Law: Civil Code 91/2015 (7 Chapters, 689 articles), Penal Code 100/2015, Tax Laws (VAT/CIT/PIT), Cybersecurity Law 24/2018, Competition Law 23/2018, IP Law 50/2005, Labor Code, Land Law 45/2013. Vietnamese language support. |
za (South Africa) |
โ Complete | 18 | 162 | Mixed Law System: Constitution 1996 (Bill of Rights), Companies Act 71/2008, LRA/BCEA Labor Laws, POPIA (Data Protection), Tax Laws (VAT/Income Tax/CGT), Competition Act 89/1998, Customary Law, IP Law, Financial Services (FAIS). English + customary law integration. |
Total: 1,553 jurisdiction files (~383k jurisdiction LoC), 74 workspace crates (16 core + 23 jurisdictions + 35 examples), comprehensive test coverage across all 23 jurisdictions
| Example | Description |
|---|---|
jp-constitution-3d |
3D visualization of the Japanese Constitution demonstrating multi-dimensional legal relationships |
welfare-benefits |
Welfare benefits eligibility determination system showcasing rule-based processing |
minpo-709-tort |
Japanese Civil Code Article 709 tort simulation |
comparative-tort-law |
Comparative tort law analysis across Japan, Germany, France, and USA |
jp-drone-regulation |
Aviation Act drone regulations: registration, flight categories, Level 4 |
| Example | Country | Description |
|---|---|---|
eu-gdpr-compliance |
EU | GDPR data protection compliance checker (Articles 6-49) |
uk-employment-law |
UK | Employment Rights Act 1996, Working Time Regulations, Equality Act 2010 |
brazil-consumer-protection |
Brazil | Consumer Defense Code (CDC Lei 8.078/1990) |
india-rti-act |
India | Right to Information Act 2005 transparency law |
singapore-business |
Singapore | Companies Act, PDPA, Employment Act compliance |
australia-immigration |
Australia | Migration Act 1958 visa eligibility (189, 190, 500, etc.) |
canada-healthcare |
Canada | Canada Health Act and provincial health plans (OHIP, MSP, RAMQ) |
korea-labor-law |
South Korea | Labor Standards Act (๊ทผ๋ก๊ธฐ์ค๋ฒ) worker protections |
mexico-tax-law |
Mexico | Codigo Fiscal de la Federacion (ISR, IVA, IEPS) |
thailand-business |
Thailand | Foreign Business Act, BOI Investment Promotion |
| Example | Focus | Description |
|---|---|---|
soviet-law-history |
Historical | USSR 1922-1991 legal system reconstruction for basic research |
private-international-law |
PIL | Conflict of Laws: Japan PIL, Rome I/II, Hague Conventions |
laos-civil-code |
Soft ODA | Laos Civil Code 2020 - Japan's legal technical assistance case study |
religious-legal-systems |
Comparative | Canon Law, Islamic Finance, Jewish/Hindu Personal Law (academic) |
| Example | Crate | Description |
|---|---|---|
smart-contract-export |
legalis-chain | Export statutes to Solidity, WASM, Ink!, Move contracts |
legal-knowledge-graph |
legalis-lod | RDF/TTL, JSON-LD export with SPARQL generation |
statute-version-control |
legalis-registry | Version history, snapshots, backup/restore |
legal-dsl-interop |
legalis-interop | Catala, L4, Stipula DSL conversion |
multilingual-statute |
legalis-i18n | Multi-language display with citation formatting |
The following 6 examples (4,488 lines total) demonstrate that Legalis-RS is NOT country-specific code - it is a universal legal computation platform that handles ANY legal system with the SAME engine:
| Example | Lines | Purpose | Key Innovation |
|---|---|---|---|
judgment-anonymization |
428 | Automated Document Anonymization | Structure-Aware Processing: Detects 4 judgment sections (parties, main text, facts, signatures) using morphological analysis. NOT simple regex replacement - understands legal document structure. APPI Article 35-2 compliance. |
llm-hallucination-firewall |
829 | Neuro-Symbolic AI Verification | Configuration-Driven Database: Validates 20 statutes across 3 jurisdictions (Japan, Germany, USA) using statute_ranges.json. Detects hallucinations (non-existent articles, invalid ranges) with ZERO false negatives. Production-grade. |
legislative-diff-simulator |
586 | CI/CD for Law Amendments | Paragraph-Level Tracking: Fine-grained structural diff beyond line-based git diff. Detects article renumbering, cross-reference shifts. Generates ๆฐๆงๅฏพ็ ง่กจ (amendment comparison tables). Impact severity analysis. |
executable-law |
1,167 | Law as Code | Multi-Language Natural Language Parser: Parses Japanese (18ๆญณไปฅไธ), English (at least 18 years), German (mindestens 18 Jahre) into the SAME Condition::Age { value: 18 }. Hot reload without recompilation. ยฅ50M cost โ ยฅ0. |
gdpr-cross-border-validator |
758 | Compliance as Code | Complete GDPR Implementation: Chapter V validation (Art. 45-49), adequacy decisions, SCCs, Schrems II impact assessment. Instant ยฅ1M legal review. Real-world production use case. |
cross-jurisdiction-demo |
720 | ๐ PROOF OF GENERICITY | THE DECISIVE EVIDENCE: 4 legal systems (Japan Civil Law, Germany Civil Law, USA Common Law, EU Supranational), 3 languages, 1 engine. NOT 4 codebases - ONE universal platform. Same Condition::Age for all. |
Total Implementation: 4,488 lines (1,851 Rust + 1,752 Markdown + 116 JSON + 203 sample data)
Quality Metrics:
- โ Clippy warnings: 0
- โ All tests passing
- โ No warnings policy: 100% compliant
- โ Implementation time: 17 hours (12h initial + 3h polish + 2h generalization)
Achievement Unlocked: "Individual Logic" โ "Universal Engine"
Market Impact:
- Before: "Japanese law parser" (niche market, ~ยฅ100M)
- After: "Universal Legal Computation Platform" (global market, ยฅๅ ๅ่ฆๆจก)
- Evidence: Same engine processes Civil Law (JP/DE), Common Law (US), Supranational (EU)
- Scalability: Adding jurisdiction #19 requires ~0.1% new code (vs traditional: +100% new codebase)
Key Insight:
Traditional Legal Tech: Country-specific code (each jurisdiction = separate system)
Legalis-RS: Generic engine + data files (one engine for all jurisdictions)
Comparison with Traditional SIer Approach:
| Task | Traditional SIer | Legalis-RS (Generic Engine) |
|---|---|---|
| Anonymization | String search & replace | Structure recognition (4 sections) + MeCab |
| Law Execution | Hand-code each article | Multi-language NL parser + generic evaluator |
| Diff Analysis | git diff (line-based) | Structural diff (Article + Paragraph) |
| Multi-Jurisdiction | Separate system per country | 1 engine for 18 jurisdictions |
| Multi-Language | Separate code per language | 1 engine for 3+ languages |
This is the proof that Legalis-RS has transcended from "niche tool" to "universal platform".
- Rust 1.85+ (Edition 2024)
- Cargo
# Clone the repository
git clone https://github.com/cool-japan/legalis
cd legalis
# Build all crates (default features: includes REST + gRPC APIs)
cargo build
# Build without gRPC (minimal dependencies)
cargo build --no-default-features
# Run tests
cargo test
# Check for issues
cargo clippyThe legalis-verifier crate has an optional smt-solver feature for rigorous formal verification using OxiZ (Pure Rust SMT solver):
# Build with SMT solver (Pure Rust - no external dependencies)
cargo build --features smt-solver
# Build with all features
cargo build --all-features
# Run tests with all features
cargo nextest run --all-featuresNote: OxiZ is a Pure Rust SMT solver, so no external libraries or environment variables are needed!
use legalis_core::{Statute, Condition, Effect, EffectType, ComparisonOp};
use legalis_dsl::LegalDslParser;
// Parse a statute from 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 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,
});use legalis_sim::{SimEngine, PopulationBuilder};
// Create a test population
let population = PopulationBuilder::new()
.generate_random(1000)
.build();
// Run simulation
let engine = SimEngine::new(vec![statute], population);
let metrics = engine.run_simulation().await;
println!("{}", metrics.summary());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);
}
}Transform complex municipal ordinances into decision trees, highlighting ambiguous "gray zones" requiring human interpretation.
Detect logical contradictions in draft legislation before enactment - treating legal bugs as compile errors.
Port legal frameworks across jurisdictions while adapting to local cultural parameters.
Automate Deterministic cases (small claims, administrative procedures) while routing JudicialDiscretion cases to human judges.
Legalis-RS provides pluggable LLM support through the LLMProvider trait:
use legalis_llm::{OpenAiClient, AnthropicClient, LawCompiler};
// Use OpenAI
let client = OpenAiClient::new("your-api-key", "gpt-4");
let compiler = LawCompiler::new(client);
let statute = compiler.compile("Any person aged 18 or older may vote.").await?;
// Or Anthropic
let client = AnthropicClient::new("your-api-key", "claude-3-opus");Generate blockchain-deployable contracts from verified statutes:
use legalis_chain::{ContractGenerator, TargetPlatform};
let generator = ContractGenerator::new(TargetPlatform::Solidity);
let contract = generator.generate(&statute)?;
println!("{}", contract.source);Legalis-RS can import from and export to other legal DSL formats:
use legalis_interop::{LegalConverter, LegalFormat};
let converter = LegalConverter::new();
// Auto-detect and import from Catala
let catala_source = r#"
declaration scope AdultRights:
context input content integer
"#;
let (statutes, report) = converter.auto_import(catala_source)?;
// Export to L4 format
let (l4_output, _) = converter.export(&statutes, LegalFormat::L4)?;
// Direct format conversion
let (stipula_output, _) = converter.convert(
catala_source,
LegalFormat::Catala,
LegalFormat::Stipula
)?;| Format | Origin | Features |
|---|---|---|
| Catala | Inria, France | Literate programming, scope-based, strong typing |
| Stipula | U. Bologna, Italy | Smart contracts, party/asset model, state machines |
| L4 | Singapore | Deontic logic (MUST/MAY/SHANT), rule-based reasoning |
| Akoma Ntoso | OASIS Standard | XML legislative documents, semantic markup |
Export statutes to RDF/TTL format for semantic web integration:
use legalis_lod::LodExporter;
let exporter = LodExporter::new();
let ttl_output = exporter.export_to_turtle(&statutes)?;
// Or export to RDF/XML
let rdf_output = exporter.export_to_rdf_xml(&statutes)?;This enables integration with knowledge graphs and semantic web systems, allowing legal data to be linked with other open data sources.
- No External Orchestrator Dependency: Uses Rust's native async (Tokio) instead of external task queues
- Vendor-Agnostic LLM Layer: Trait-based abstraction allows swapping providers without code changes
- Explicit Discretion Markers: The type system enforces acknowledgment of human judgment requirements
- SMT Solver Integration: Uses OxiZ (Pure Rust) for formal verification of legal consistency
- Achieved: 100% Pure Rust implementation with no external C/C++ dependencies
- Object Storage: S3-compatible storage support for audit trails
- Note: MinIO can be replaced with rs3gw (Pure Rust S3-compatible gateway) from the COOLJAPAN Ecosystem
- v0.1.6 (June 16, 2026) - CUDA GPU acceleration, legalis-api security/governance layer, legalis-audit new modules (autonomous, federation, quantum, scale, tenant), OxiSQL migration (pure Rust), DSL round-trip improvements, French law enhancements
- v0.1.5 (February 2026) - Pure-Rust PDF Backend (fop-render), Full Code Splitting (2,221 Rust files), No-Unwrap Policy, Workspace Versioning, CVE Remediation
- v0.1.4 (January 27, 2026) - Universal Engine Proof: 6 new examples proving Legalis-RS is a generic legal computation platform (not country-specific code)
- v0.1.3 (January 21, 2026) - Global Expansion: 11 new jurisdictions (AE, AU, BR, CN, ID, IN, TH, VN, ZA + more)
- v0.1.2 (January 15, 2026) - Code Quality: Clippy Compliance
- v0.1.1 (January 10, 2026) - Jurisdiction Expansion: EU, Singapore, UK
- v0.1.0 (January 5, 2026) - Genesis: Initial release
Detailed technical papers are available in multiple languages:
| Language | Document |
|---|---|
| ๆฅๆฌ่ช (Japanese) | PAPER-JA.md |
| English | PAPER-EN.md |
| Franรงais (French) | PAPER-FR.md |
| Deutsch (German) | PAPER-DE.md |
| ไธญๆ (Chinese) | PAPER-ZH.md |
| เนเธเธข (Thai) | PAPER-TH.md |
| เบฅเบฒเบง (Lao) | PAPER-LO.md |
| Tiแบฟng Viแปt (Vietnamese) | PAPER-VI.md |
| Bahasa Indonesia | PAPER-ID.md |
| Bahasa Melayu (Malay) | PAPER-MS.md |
| ุงูุนุฑุจูุฉ (Arabic) | PAPER-AR.md |
| เฎคเฎฎเฎฟเฎดเฏ (Tamil) | PAPER-TA.md |
| Eesti (Estonian) | PAPER-ET.md |
| เคนเคฟเคจเฅเคฆเฅ (Hindi) | PAPER-HI.md |
| Espaรฑol (Spanish) | PAPER-ES.md |
| Portuguรชs (Portuguese) | PAPER-PT.md |
These papers provide comprehensive coverage of the system architecture, core technologies, design philosophy, and case studies.
Legalis is developed and maintained by COOLJAPAN OU (Team Kitasan).
If you find Legalis useful, please consider sponsoring the project to support continued development of the Pure Rust ecosystem.
https://github.com/sponsors/cool-japan
Your sponsorship helps us:
- Maintain and improve the COOLJAPAN ecosystem
- Keep the entire ecosystem (OxiBLAS, OxiFFT, SciRS2, etc.) 100% Pure Rust
- Provide long-term support and security updates
Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).
Contributions are welcome! Please read the contribution guidelines before submitting pull requests.
This project draws inspiration from legal informatics research and the growing field of computational law. The goal is not to replace human judgment in law, but to clarify where such judgment is necessary.
"Code is Law" - but Law must preserve space for human narrative.