System Architecture
From question to verified answer — how Lawmadi OS works
4-Stage Hybrid Pipeline
Every legal query passes through a 4-stage pipeline to produce verified answers. Each stage has independent failure detection and recovery. If verification fails, the system blocks the answer (Fail-Closed policy).
Stage 0+1 — Classification + RAG Search (Parallel)
NLU intent analysis assigns the optimal leader from 60 specialists while simultaneously searching Vertex AI Search and the statute cache for relevant laws and precedents. 3-tier routing classifies queries: greeting, non-legal, or legal.
Stage 1.5~1.7 — Statute Enrichment
Injects the assigned leader's core statutes (LAW_BOOST), links delegation clauses and enforcement decree forms via 3-tier comparison, and pre-fetches full article text from the DRF API to maximize accuracy.
Stage 3 — Claude Real-Time Streaming Analysis
Claude Sonnet 5 generates answers via real-time SSE streaming, using the leader's persona and RAG context. Responses follow a 5-step framework: Empathize, Diagnose, Action Roadmap, Safety Net, and Closing.
Stage 4 — DRF Full Verification (Fail-Closed)
Every statute, precedent, and constitutional court decision cited in the answer is cross-verified in real-time against Korea's National Law Information Center (law.go.kr) DRF API. If unverified citations exceed 0.1%, the answer is blocked. Verified corrections replace text in real-time.
8-Layer Processing Architecture
Lawmadi OS is designed like an operating system with 8 independent layers, each performing a specialized role.
SSOT Data Sources
All answers are grounded in Korea's official legal databases (Single Source of Truth). Self-generated inference or fabrication is strictly prohibited.
Current Statutes
Laws, enforcement decrees, and enforcement rules
Supreme Court Precedents
Supreme Court and High Court case law
Constitutional Court Decisions
Constitutional Court rulings and opinions
Administrative Rules & Ordinances
Directives, regulations, notices, and local ordinances
Legal Interpretations
Official statutory interpretation cases
Treaties & Legal Terminology
International treaties and legal glossary
Technology Stack
AI Engine
Claude Sonnet 5 — real-time SSE streaming, 429 exponential backoff
RAG Search
Vertex AI Search — 48,955 verified assets indexed, extractive answers
Backend
FastAPI + Uvicorn — async Python on Cloud Run (Seoul region)
Agent interfaces
MCP (19 tools) · A2A agent card · OAuth 2.0 with PKCE and open client registration — all three enter the same auth, quota and billing gate, so there is no second metered path
Database
Cloud SQL PostgreSQL 17 — statute cache, audit logs, session management
Frontend
Firebase Hosting — Korean/English static pages, PWA support
CI/CD
GitHub Actions 5-stage — Test, Staging, Production, Frontend, Notify
6 Constitutional Principles
Every answer in Lawmadi OS is governed by 6 constitutional principles. These are enforced at code level with zero exceptions.
SSOT_FACT_ONLY
All answers based on official statutory data in real-time
ZERO_INFERENCE
No self-generated legal citations or reasoning
FAIL_CLOSED
Verification failure blocks the answer entirely
IDENTITY
No encouragement of illegal acts or evidence tampering
TIMELINE_RULE
Law at time of act takes precedence; transitional provisions checked
SOURCE_TRANSPARENCY
Every citation includes law ID and enforcement date