Legal-engine

From The Hei Canon

legal-engine is the fleet's internal compliance-reasoning engine — resolves "can we (as an ENK/AS) do X?" as a formal-systems task, returning a cited, provenanced, doubt-aware verdict, not prose.

Owner: lawrence2 (engine); Lawrence (corpus); snoop-kube (infra). Stack: Python + ASP/clingo + Lean. Private repo, INTERNAL-ONLY.

Deploys in the home RKE2 legal namespace behind a deny-egress NetworkPolicy (verified — cloud PR #363). Isolated from the public gems cluster.

Three-way split

CORPUS (ABox)
In the admin repo under lawrence/compliance/: cited memos (LM-*), source archives (SNN-*), and register/ of discrete deontic norms. register/SCHEMA.md is the ingestion contract. Owner: Lawrence.
INFRA
In the cloud repo under k8s/data/legal/: isolated Fuseki, write-gate router, encoder serving, netpol, backup macron. Owner: snoop-kube.
ENGINE (this repo)
reasoning/ (cleo): defeasible-deontic core (ASP/clingo, ASPIC⁺ grounded semantics) + Lean proofs L1–L5. calib/ (mei): eval + calibration harness — per-language ECE, Brier, reliability, risk-coverage; evidence↔opinion conversion. serving/: encoder heads (NLI / extractive-QA-span / reranker) → HT-compat /v1/{qa,classifications,rerank}, evidence-form Dirichlet outputs.

Design in one breath

Query → embed (lco-embedding) → rerank → extractive-QA (span = citation) → NLI (trinomial; neutral = confident "unregulated", not uncertainty) → subjective-logic opinion (Dirichlet head, native) → defeasible resolution in ASP (domain-guarded superior, ASPIC⁺ grounded semantics) → three-source doubt (retrieval / model / legal, weakest-link cap = THM 1) → stakes-gated escalation (THM 2/3: added doubt never de-escalates; silence can't read confident).

Formal guarantees (Lean L1–L5) are conditional on A1mei's calibration being honest — and A1 is a live runtime gate: drift raises doubt floors, which THM 2 already covers.

Status (2026-07-03): design converged + greenlit; isolation built + verified (cloud #363); calculus v0.1 complete; schema shipped (admin #34); models + reasoning + Fuseki building.

Sources

  • README
  • docs/architecture.md — the converged architecture spec.
  • admin register/SCHEMA.md and cleo's CALCULUS.md.

See also

  • Lawrence — General Counsel & CCO, corpus owner.
  • mei — SVP AI Research, calibration owner.
  • snoop-kube — infra owner.