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,371 jurisdiction files (~341k jurisdiction LoC), 46 workspace crates (17 core + 23 jurisdictions + 6 examples), 14,705 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.4):
| Metric | Count | Details |
|---|---|---|
| Total Lines of Code | 933,027 | Rust (867k), Python (8.6k), Markdown (50k), TypeScript (1.7k) |
| Rust Code Lines | 867,470 | 723,696 executable + 26,669 comments + 117,105 blanks |
| Documentation Lines | 152,112 | Inline Rust documentation (/// and //!) |
| Rust Files | 1,657 | Across 65 workspace crates |
| Test Functions | 13,083 | Unit tests + async tests + property tests |
| Workspace Crates | 70 | 17 core + 23 jurisdictions + 30 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 |
| New Examples (v0.1.4) | 6 | Proof of universal legal computation engine |
Testing Infrastructure:
- Unit Tests: 13,083 passing tests
- 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 70 workspace crates (17 core + 23 jurisdictions + 30 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 | 39 | 168 | 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 | 47 | 238 | 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 | 76 | 318 | 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 | 80 | 240 | Supranational Law: GDPR (196 tests, 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 | 76 | 545 | 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), 524 tests passing. |
jp (Japan) |
✅ Complete | 119 | 440 | Civil Law + Asian Tradition: 16+ domains (most extensive) - 民法 (Minpō 709-715), 商法/会社法, 労働基準法, 知的財産法, 消費者保護法, 個人情報保護法 (APPI), 建設業法, 行政手続法 (e-Gov integration), 環境法. 398 tests, 27,600+ lines, 7 test suites, 10 examples. Era system (元号), contract risk analysis. |
la (Lao PDR) |
✅ Complete | 8 | 49 | 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 | 56 | 211 | 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, 10 examples, trilingual (EN/中文/Melayu). |
uk (United Kingdom) |
✅ Complete | 127 | 646 | 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 | 102 | 473 | 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. 436 tests, 18,700+ lines. |
ae (UAE) |
✅ Complete | 36 | 169 | 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 | 38 | 198 | 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 | 37 | 189 | 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 | 34 | 163 | 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 | 93 | 234 | 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 | 39 | - | 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 | 29 | 62 | 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 | 21 | - | 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 | 21 | 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 | 21 | 132 | 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 | 36 | - | 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 | 23 | 153 | 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 | 17 | 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,371 jurisdiction files (~341k jurisdiction LoC), 46 workspace crates (17 core + 23 jurisdictions + 6 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.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.
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.