Rules as Code and Digital Regulatory Infrastructure
Overview
This page explains two concepts that appear throughout this site: "rules as code" and "digital regulatory infrastructure". Understanding these terms will help you make sense of what we're doing and why.
Rules as code
"Rules as code" means creating computational versions of legal rules—expressing requirements from legislation or policy in formats that computers can process.
A simple example:
A law says: "A person is eligible if they are aged 65 or over and have been resident for at least 10 years."
As code, this becomes a calculation: take someone's age and residency years, determine if they're eligible. Software can then check eligibility automatically.
This already happens everywhere:
- Tax calculation software implements tax law
- Benefits calculators implement welfare rules
- Compliance tools implement building codes
- Spreadsheets in government agencies implement policy criteria
The question isn't whether to use rules as code—it's how to do it well.
Digital regulatory infrastructure
We use "digital regulatory infrastructure" to describe something broader than rules as code. It encompasses the entire ecosystem used to implement regulation:
- Natural language documents (legislation, regulations, guidance)
- Structured data (spreadsheets, databases, compliance registers)
- Software systems (calculators, processing tools, monitoring)
- The connections between all of these
Why "infrastructure"?
Just as roads and cables enable economic activity, digital regulatory infrastructure enables the implementation of law. And like physical infrastructure, it requires planning, standards, and maintenance.
The key distinction
- Rules as code focuses on converting specific rules into executable form
- Digital regulatory infrastructure focuses on the foundational systems that make rules as code (and many other applications) possible
We focus on infrastructure—the "roots" from which specific applications grow.
Why natural language law still matters
Some suggest policy could be designed purely in code, eliminating documents entirely. We believe this is dangerous.
Natural language law provides:
- Contestability - People need documents they can read to challenge automated decisions
- Democratic accountability - Legislators and citizens need to understand what laws do
- Judicial review - Courts need interpretable text, not just code
Our approach: digital systems supplement natural language law, they don't replace it. Code and documents work together, with clear connections between them.
Infrastructure for AI-assisted work
Large language models can now generate both documents and code. This creates risks: AI systems may synthesise outputs from training data patterns rather than the specific authoritative sources that should apply. The result can look plausible but diverge from what the law actually requires.
Structured regulatory infrastructure mitigates this risk:
When authoritative natural language documents are available as structured data with granular citations, AI systems can be directed to work from those specific sources. Outputs can include verifiable links back to the exact paragraphs they're based on.
This also supports human oversight:
- Maintenance - When source documents change, downstream code and documents can be updated systematically
- Independent scrutiny - Reviewers can verify AI-generated content against original sources
- Version control - Changes can be tracked through the full stack, from legislation to implementation
The goal isn't to avoid AI—it's to use AI in ways that remain traceable, verifiable, and maintainable over time.
Traceability
If there's one principle unifying our approach, it's traceability—maintaining clear connections between different layers of a regulatory system.
When code implements a regulation, which exact paragraph does it implement? When AI generates content citing law, can those citations be verified? When upstream documents are updated, which downstream systems need to change?
DocRef's granular citation system exists to provide this traceability. Every piece of content links back to its authoritative source.
Further reading
For deeper exploration of these concepts:
- Governing Digital Legal Systems - MIT Computational Law Report
- About DocRef - How the DocRef system provides traceability
- Tools and Technologies - Technical components explained