Code-as-Auditor: Executable Compliance Reasoning via Regulation-to-Code

Jisoo Kim, Taeyoon Kwack, Jinwoo Jang, Woo Kyung Kim, Honguk WooarXiv 2026

TL;DR

Code-as-Auditor is a novel framework that transforms ambiguous legal regulations into executable Python code to automate compliance auditing. By combining an iterative self-verification loop with a checklist refinement strategy grounded in legal theory, it bridges the gap between abstract rules and concrete case facts. This approach significantly reduces LLM hallucinations and logical errors, outperforming standard legal reasoning baselines across complex privacy frameworks like GDPR and PIPA.

What Problem Does This Paper Address?

Large Language Models (LLMs) are increasingly being deployed to tackle legal and compliance tasks. However, relying on open-ended natural language reasoning is highly problematic: LLMs frequently hallucinate legal facts, miss complex exceptions, and fail to follow strict logical chains.

A major reason for this failure is the "semantic gap" between abstract statutory rules and the messy realities of real-world cases. For instance, as shown in Figure 1, a standard LLM might falsely declare a company compliant simply because they disclosed outsourcing details, completely missing the temporal requirement that the disclosure must happen at any time (i.e., continuously accessible from the start of outsourcing, rather than delayed by over a year).

Figure 1: An example of false compliance determined by an LLM, where legality is concluded from disclosure alone, missing the regulation’s temporal conditions.

Prior neuro-symbolic approaches have attempted to translate laws into formal logic graphs or tuples, but these representations often lack the expressiveness needed to handle cross-provision dependencies and intricate legal exceptions.

Methods

Code-as-Auditor solves this by reframing compliance auditing as an executable code generation and execution pipeline. The framework operates in two main stages:

  1. Regulation-to-Code Reformulation: The framework translates statutory texts into an executable code template based on the classic IRAC (Issue, Rule, Application, Conclusion) legal framework. The template explicitly separates logic into Applicable Condition, Compliance Condition, and Effect (handling cross-article exceptions). To ensure the generated code is robust, the authors implement an iterative Self-Verification Loop where a Code Generator proposes code and checklist variables, and a Code Verifier scores them across five dimensions (Necessity, Atomicity, Hierarchical Integrity, Logical Completeness, and Syntactic Validity) to refine the output.
  2. Case-Grounded Checklist Refinement: To bridge the semantic gap at runtime, the framework generates a case-agnostic checklist. When evaluating a specific case, it refines this checklist using Hans Kelsen’s theory of normative validity. It systematically breaks down each abstract legal predicate into four distinct spheres:
  3. Personal: Who is the responsible party?
  4. Material: What action is required?
  5. Temporal: What are the time constraints?
  6. Spatial: What is the applicable jurisdiction?
Figure 2: Overview of Code-as-Auditor with empirical results, showing successful detection of the temporal violation missed by LLM in Figure 1.

Finally, a hierarchical Compliance Decision Tree executes the code over these grounded case facts using ternary logic (True, False, None) to gracefully handle missing evidence.

Datasets

The authors evaluated the framework across multiple regulatory domains using three primary datasets:

  • PrivaCI-Bench: Used for evaluating the European Union Artificial Intelligence Act (EU AI Act) and the General Data Protection Regulation (GDPR). It consists of real court cases, privacy policies, and synthetic vignettes.
  • PIPA Dataset: A new, highly complex dataset constructed by the authors containing 406 publicly available real-world deliberation decisions issued by the Personal Information Protection Commission (PIPC) of the Republic of Korea.
  • LegalBench: Used to test the framework's generalizability on two out-of-domain tasks: Telemarketing (FTC Telemarketing Sales Rule) and SARA Entailment (U.S. Federal Tax Law).

Key Insights and Ideas

  • Code as a Reusable Reasoning Path: Instead of forcing an LLM to reason dynamically through text at runtime, compiling the law into code creates a deterministic, verifiable, and reusable decision tree.
  • Kelsen's Spheres as a Semantic Bridge: Fact-checking legal compliance fails when LLMs collapse multi-dimensional obligations into a single sequential path. Forcing the model to explicitly evaluate the Personal, Material, Temporal, and Spatial dimensions ensures that critical nuances—like the exact timing of a data breach notification—are never overlooked.
  • Robustness to Model Scale: Because the complex legal reasoning path is externalized into code, the runtime model only needs to evaluate simple, atomic factual questions. As a result, Code-as-Auditor remains remarkably stable even when scaling down to smaller, edge-deployable models (1.5B and 0.5B parameters), where traditional logic baselines completely break down.

Key Results

  • State-of-the-Art Performance: Using Qwen2.5-7B as the backbone, Code-as-Auditor achieved the highest F1-scores across all primary frameworks, outperforming the second-best baseline methods by 3.1 points on the EU AI Act, 3.4 points on GDPR, and a massive 12.3 points on the structurally complex PIPA dataset.
  • Out-of-Domain Generalization: On the LegalBench benchmarks, Code-as-Auditor surpassed state-of-the-art reasoning models like GPT-5 and Claude 4.5, achieving 92.0% accuracy on Telemarketing and 82.7% on SARA.
  • Ablation Verification: Removing the checklist refinement caused recall to drop substantially (−18.65 on GDPR, −37.91 on PIPA), proving that Kelsen's spheres are vital for bridging the text-to-fact gap. Removing the self-verification loop resulted in syntactically invalid code (zero scores across the board).

Limitations and Future Work

  • Meaning Preservation: While the self-verification loop ensures the code is syntactically valid and logically complete, it does not formally guarantee that the generated code perfectly preserves the semantic intent of the original statutory text.
  • Ambiguity in Missing Evidence: The framework uses ternary logic (None) for missing information, but it cannot currently distinguish between a genuine silence in the case record versus an extraction failure by the model.
  • Dataset Smoothing: The case descriptions in the newly introduced PIPA dataset are GPT-5 summaries of adjudicated decisions, which might inadvertently smooth out the messy distractors and borderline facts found in raw legal records.

Summary updated

BibTeX
@misc{kim2026code,
  author = {Jisoo Kim and Taeyoon Kwack and Jinwoo Jang and Woo Kyung Kim and Honguk Woo},
  title = {{Code-as-Auditor: Executable Compliance Reasoning via Regulation-to-Code}},
  year = {2026},
  eprint = {2609.19199},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.19199},
}
Figure