DETERMINISTIC or PARTIAL / HEURISTIC to indicate the strength of the underlying check.
DETERMINISTICguards return reproducible results for supported, structured inputs.PARTIAL / HEURISTICguards apply structural or rule-based checks. A passing result does not prove that the underlying legal claim is correct — only that it matched a supported pattern.
1. DeadlineGuard
Status:DETERMINISTIC
Purpose: Verify date calculations in contracts for structured, unambiguous inputs.
The Problem
LLMs frequently miscalculate deadlines:- Confuse business days vs calendar days
- Ignore leap years
- Forget jurisdiction-specific holidays
The Solution
Parameters
The date the contract was signed (ISO format or natural language).
The term description (e.g., “30 days”, “30 business days”, “2 weeks”, “3 months”, “1 year”).
The deadline claimed by the LLM.
Allow +/- this many days when verifying the deadline. Useful for accommodating minor rounding differences.
Response fields
| Field | Type | Description |
|---|---|---|
verified | bool | Whether the claimed deadline matches the computed deadline |
signing_date | datetime | Parsed signing date |
claimed_deadline | datetime | The deadline claimed by the LLM |
computed_deadline | datetime | The correct deadline computed by the guard |
term_parsed | str | The original term string |
difference_days | int | Absolute difference in days between claimed and computed |
message | str | Human-readable verification message |
verification_mode | str | Always "SYMBOLIC" for legal verification |
Features
| Feature | Description |
|---|---|
| Business vs Calendar | Automatically detects “business days” vs “days” |
| Holiday Support | 200+ countries via python-holidays |
| Leap Years | Handles Feb 29 correctly |
| Natural Language | Parses “2 weeks”, “3 months”, “1 year” |
Calculate business days between dates
2. LiabilityGuard
Status:DETERMINISTIC
Purpose: Verify liability cap and indemnity calculations for supported numeric inputs.
The Problem
LLMs get percentage math wrong:- “200% of 15M” ❌ (Should be $10M)
- Float precision errors on large amounts
- Tiered liability miscalculations
Constructor parameters
Tolerance for floating-point comparison as a percentage. For example,
0.01 means 0.01% tolerance. Adjust for stricter or more lenient verification.The Solution
verify_cap parameters
Total value of the contract.
Liability cap as a percentage (e.g.,
200 for 200%).The cap amount claimed by the LLM.
Response fields
| Field | Type | Description |
|---|---|---|
verified | bool | Whether the claimed cap matches the computed cap |
contract_value | Decimal | The contract value used |
cap_percentage | Decimal | The percentage used |
claimed_cap | Decimal | The cap claimed by the LLM |
computed_cap | Decimal | The correct cap computed by the guard |
difference | Decimal | Absolute difference between claimed and computed |
message | str | Human-readable verification message |
Additional methods
3. ClauseGuard
Status:PARTIAL / HEURISTIC
Purpose: Detect a limited set of contradictory clauses using text heuristics, with optional Z3-based satisfiability checks. A “consistent” result is not a proof of full contractual consistency.
The problem
LLMs miss logical contradictions:- “Seller may terminate with 30 days notice”
- “Neither party may terminate before 90 days”
The solution
The primarycheck_consistency() method uses text heuristics to detect conflicts. For formal logic verification, use verify_using_z3().
Detection types
| Conflict Type | Description |
|---|---|
| Termination | Notice period vs minimum term |
| Permission/Prohibition | ”May” vs “May not” |
| Exclusivity | Multiple exclusive rights |
Z3-based verification
For power users who want to define precise logical constraints:4. CitationGuard
Status:PARTIAL / HEURISTIC
Purpose: Validate that legal citations match a supported format. CitationGuard does not prove that a cited authority exists or is controlling — it only checks structural shape against supported reporters.
The Problem
The Mata v. Avianca scandal: Lawyers used ChatGPT, which cited 6 fake court cases. They were fined $5,000 and sanctioned.The Solution
Supported citation patterns
| Pattern | Format | Example |
|---|---|---|
| US Supreme Court | volume U.S. page | 347 U.S. 483 |
| US Federal | volume F./F.2d/F.3d page | 500 F.3d 120 |
| UK Neutral | [year] court number | [2023] UKSC 10 |
| India AIR | AIR year court page | AIR 2020 SC 100 |
Batch Verification
Statute Citations
5. JurisdictionGuard
Status:PARTIAL / HEURISTIC
Purpose: Apply structured checks around governing law and forum selection clauses for modeled combinations. Results should not be treated as authoritative legal opinions on choice-of-law conflicts.
The Problem
LLMs miss jurisdiction conflicts:- Governing law in one country, forum in another
- Missing CISG applicability warnings
- Cross-border legal system mismatches
The Solution
Parameters
List of ISO country codes for contract parties (e.g.,
["US", "UK"]).The stated governing law — can be a country code or US state name/abbreviation (e.g.,
"Delaware", "DE", "UK").The stated forum or venue for dispute resolution.
Type of jurisdiction clause. Accepts
JurisdictionType.EXCLUSIVE, JurisdictionType.NON_EXCLUSIVE, or JurisdictionType.HYBRID.Features
| Feature | Description |
|---|---|
| Choice of Law | Validates governing law makes sense for parties |
| Forum Selection | Checks forum vs governing law alignment |
| CISG Detection | Warns about international sale of goods conventions |
| Convention Check | Verifies Hague, NY Convention applicability |
| Legal System Mismatch | Detects cross-border Common Law vs Civil Law conflicts |
Verify forum selection
Useverify_forum_selection to validate a forum independently, with optional contract value threshold checks for US federal court diversity jurisdiction:
Convention Check
6. StatuteOfLimitationsGuard
Status:PARTIAL / HEURISTIC
Purpose: Compute claim limitation periods for supported jurisdictions and claim types using rule tables. Coverage is limited to the modeled jurisdictions and claim types listed below.
The Problem
LLMs don’t track jurisdiction-specific limitation periods:- California breach of contract: 4 years
- New York breach of contract: 6 years
- Different periods for negligence, fraud, etc.
The Solution
Parameters
Type of legal claim (e.g.,
"breach_of_contract", "negligence", "fraud"). See supported claim types below.State or country name (e.g.,
"California", "New York", "UK").Date the incident occurred (ISO format).
Date the claim was or will be filed (ISO format).
Optional LLM claim to verify. When provided, the guard checks whether the LLM’s assertion (within/outside period) matches the computed result.
Supported jurisdictions
12 jurisdictions are supported with periods for 10 claim types.| Jurisdiction | Breach of Contract | Negligence | Fraud |
|---|---|---|---|
| California | 4 years | 2 years | 3 years |
| New York | 6 years | 3 years | 6 years |
| Texas | 4 years | 2 years | 4 years |
| Delaware | 3 years | 2 years | 3 years |
| Florida | 5 years | 4 years | 4 years |
| Illinois | 5 years | 2 years | 5 years |
| UK/England | 6 years | 6 years | 6 years |
| Germany | 3 years | 3 years | 10 years |
| France | 5 years | 5 years | 5 years |
| Australia | 6 years | 6 years | 6 years |
| India | 3 years | 3 years | 3 years |
| Canada | 2 years | 2 years | 6 years |
Supported claim types
breach_of_contract, breach_of_warranty, negligence, professional_malpractice, fraud, personal_injury, property_damage, employment, product_liability, defamation
Get limitation period
Look up the limitation period for a specific claim type and jurisdiction without performing a full verification:Compare jurisdictions
7. IRACGuard
Status:PARTIAL / HEURISTIC
Purpose: Check that legal reasoning follows the IRAC framework (Issue, Rule, Application, Conclusion). IRACGuard verifies structure and surface-level consistency only — it is not a proof of correct legal reasoning.
The Problem
LLMs produce legal advice that lacks structured reasoning:- Missing clear identification of the legal issue
- No citation of applicable rules or statutes
- Conclusions without proper application of law to facts
The Solution
Detection Types
| Check | Description |
|---|---|
| Structure | Verifies all 4 IRAC components are present |
| Logical Disconnect | Detects when Application doesn’t reference the Rule |
| Missing Steps | Identifies which IRAC components are missing |
Error Response
8. FairnessGuard
Status:PARTIAL / HEURISTIC
Purpose: Apply counterfactual consistency checks to detect output that changes when protected attributes are swapped. This is a structural fairness check, not a complete fairness proof. Requires an external LLM client.
The Problem
AI legal systems can exhibit bias based on protected attributes:- Different sentencing recommendations based on gender
- Inconsistent contract assessments based on party names
- Discriminatory loan approval reasoning
The Solution
How It Works
- Early exit - If
protected_attribute_swapis empty ({}), returns immediately withNO_SWAP_REQUIREDwithout calling the LLM - Counterfactual Generation - Swaps protected attributes (names, pronouns) while preserving case
- Re-evaluation - Runs the modified prompt through the LLM
- Deterministic Comparison - Checks if outcomes match exactly
Response fields
| Field | Type | Description |
|---|---|---|
verified | bool | Whether the decision is fair |
status | str | FAIRNESS_VERIFIED or NO_SWAP_REQUIRED (on success) |
risk | str | JUDICIAL_BIAS_DETECTED or LLM_GENERATION_FAILED (on failure) |
message | str | Explanation of the result |
variance | dict | Present when bias detected — contains original and counterfactual decisions |
Detection types
| Status / Risk | Description |
|---|---|
FAIRNESS_VERIFIED | Decision unchanged after attribute swap |
JUDICIAL_BIAS_DETECTED | Decision changed based on protected attributes |
NO_SWAP_REQUIRED | No protected attributes to swap (empty dict passed) |
LLM_GENERATION_FAILED | The LLM client returned None for the counterfactual prompt |
9. ContradictionGuard
Status:PARTIAL / HEURISTIC
Purpose: Detect logical contradictions between modeled clauses using a constraint solver. Coverage is limited to the supported clause categories below — a “consistent” result is not a proof of full contract consistency.
The Problem
Contracts can contain mathematically impossible combinations:- “Liability capped at 50,000”
- “Term is exactly 12 months” + “Minimum duration of 24 months”
The Solution
Clause Structure
TheClause dataclass requires:
| Field | Type | Description |
|---|---|---|
id | str | Unique clause identifier |
text | str | Human-readable clause text |
category | str | DURATION, LIABILITY, or TERMINATION |
value | int | Normalized numeric value (days, dollars, etc.) |
Supported Categories
| Category | Detects |
|---|---|
DURATION | Conflicting term lengths (exact vs min/max) |
LIABILITY | Cap vs penalty contradictions |
Z3 vs ClauseGuard
| Feature | ClauseGuard | ContradictionGuard |
|---|---|---|
| Input | Raw text strings | Structured Clause objects |
| Method | Text heuristics | Z3 SMT Solver |
| Detects | Permission conflicts | Mathematical impossibilities |
| Use Case | Quick checks | Formal verification |
10. ProvenanceGuard
Status:DETERMINISTIC
Purpose: Verify AI-generated content carries proper provenance metadata and disclosure markers. All checks are deterministic (SHA-256 hashing, regex pattern matching, datetime validation).
The problem
AI transparency regulations (California CAITA 2026, EU AI Act Article 50) require AI-generated legal content to carry proper attribution. Without verification:- Content may lack required AI-generation disclosures
- Provenance metadata can be incomplete or tampered with
- Unauthorized models may generate legal documents without audit trails
The solution
Verification checks
ProvenanceGuard runs up to six checks. The first three always run; the last three are configurable.| Check | Description | Always runs |
|---|---|---|
| Metadata completeness | content_hash, model_id, and generation_timestamp are present and non-empty | Yes |
| Hash integrity | SHA-256 of the content matches content_hash in provenance | Yes |
| Timestamp validity | ISO-8601 format, not in the future | Yes |
| Disclosure compliance | Content includes an AI-generation disclosure statement | If require_disclosure=True |
| Model allowlist | model_id is in the approved list | If allowed_models is set |
| Human review | human_reviewed is True in provenance | If require_human_review=True |
Constructor parameters
Require AI disclosure text in the content (e.g., “AI-generated”, “produced by AI”).
Require
human_reviewed=True in provenance metadata.Allowlist of model IDs.
None allows all models; an empty list denies all.Generating provenance records
You can also use ProvenanceGuard to generate provenance metadata:ProvenanceRecord fields
| Field | Type | Description |
|---|---|---|
content_hash | str | SHA-256 hash of the AI-generated content |
model_id | str | Identifier of the model that generated the content |
generation_timestamp | str | ISO-8601 timestamp of generation |
disclosure_text | str | Human-readable AI disclosure statement |
human_reviewed | bool | Whether a human has reviewed the content |
reviewer_id | str | None | Identifier of the human reviewer |
Risk classifications
When verification fails, therisk field indicates the type of failure:
| Risk | Trigger |
|---|---|
CONTENT_TAMPERED | Hash mismatch between content and content_hash |
INCOMPLETE_PROVENANCE | Required metadata fields missing or empty |
MISSING_DISCLOSURE | No AI-generation disclosure found in content |
UNAUTHORIZED_MODEL | model_id not in the allowed models list |
UNREVIEWED_CONTENT | human_reviewed is not True |
INVALID_TIMESTAMP | Timestamp is malformed or in the future |
ProvenanceGuard is fully deterministic — no LLM calls required. All checks use SHA-256 hashing, regex pattern matching, and datetime validation.
SACProcessor (RAG Helper) 📄
Purpose: Prevent Document-Level Retrieval Mismatch (DRM) in legal RAG systems.The Problem
Standard RAG chunking causes >95% retrieval mismatch in legal databases because:- Legal documents share nearly identical boilerplate
- Chunk-level embeddings lose document context
- NDAs, contracts, and agreements look alike at the chunk level
The Solution
Configuration
| Parameter | Default | Description |
|---|---|---|
target_summary_length | 150 | Character limit for document fingerprint |
preview_chars | 5000 | Max chars sent to LLM for summarization |
Methods
| Method | Description |
|---|---|
generate_sac_chunks() | Augment all chunks with document fingerprint |
generate_fingerprint_only() | Get just the fingerprint for caching |
SACProcessor requires an LLM client. Generic (automated) summaries outperform expert-guided ones for retrieval.
All-in-One: LegalGuard
For convenience, use the unifiedLegalGuard class:
LegalGuard is a convenience wrapper. It does not change the verification boundaries of the underlying guards. DeadlineGuard, LiabilityGuard, and ProvenanceGuard are deterministic for supported inputs; the remaining guards are partial or heuristic. Only verify_fairness() requires an LLM client.Next Steps
- Examples - Real-world scenarios
- Troubleshooting - Common issues