Skip to main content
Each guard verifies a specific aspect of legal output. Guards are labeled DETERMINISTIC, MIXED, or PARTIAL / HEURISTIC to indicate the strength of the underlying check.
  • DETERMINISTIC guards return reproducible, provable results for supported, structured inputs.
  • MIXED guards run a deterministic computation (date arithmetic, Z3 SAT/UNSAT) over parsed inputs. The computation is provable; the parsed lookup that feeds it is not authority proof.
  • PARTIAL / HEURISTIC guards 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.
When a claim falls outside a guard’s supported boundary, the guard fails closed: it rejects or marks the claim unverified rather than accepting it.

Verification traces and evidence types

As of v0.4.0, every guard returns a verification_trace — an ordered list of VerificationStep records. Each step is tagged with an evidence_type, and VerificationStep.is_proven() returns True only for DETERMINISTIC steps.
Use trace_to_dict() to export a trace into audit logs. Non-serializable input values are stringified (no silent data loss).

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

str
required
The date the contract was signed (ISO format or natural language).
str
required
The term description (e.g., “30 days”, “30 business days”, “2 weeks”, “3 months”, “1 year”).
str
required
The deadline claimed by the LLM.
int
default:"0"
Allow +/- this many days when verifying the deadline. Useful for accommodating minor rounding differences.

Response fields

Fail-closed behavior on ambiguous terms

DeadlineGuard does not invent deadlines from vague legal language. If the term cannot be parsed into a deterministic (quantity, unit) pair, the guard returns a fail-closed result with verified=False, is_computable=False, and computed_deadline=None. A term is treated as UNVERIFIABLE when either:
  • It contains no numeric quantity (e.g., "forthwith", "promptly after notice", "within a reasonable period", "as soon as practicable", "without undue delay").
  • It contains a number but no recognized time unit (e.g., "30" alone, "15 intervals").
Recognized time units are day/calendar, week, month, and year, with optional business/working/work qualifiers for business-day arithmetic.
Always check result.is_computable before relying on computed_deadline or difference_days. Ambiguous legal language requires human legal interpretation and is never silently coerced into a 30-day default.
Date parsing failures are also fail-closed: if signing_date or claimed_deadline cannot be parsed, the guard returns verified=False and is_computable=False.

Features

Fail-closed behavior on ambiguous terms

DeadlineGuard only computes a deadline when the term contains both an explicit numeric quantity and a recognized time unit (day, business day, calendar day, week, month, year). When either is missing, the guard fails closed: it returns verified=False, is_computable=False, and a computed_deadline of None instead of guessing a default. This protects against silent acceptance of subjective legal language such as "within a reasonable period", "promptly", "as soon as practicable", "without undue delay", or "forthwith". Resolving these terms requires human legal interpretation.
Always check is_computable before relying on computed_deadline or difference_days. When is_computable is False, route the contract clause to a human reviewer.

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 5M=5M = 15M” ❌ (Should be $10M)
  • Float precision errors on large amounts
  • Tiered liability miscalculations

Constructor parameters

float
default:"0.01"
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

float
required
Total value of the contract.
float
required
Liability cap as a percentage (e.g., 200 for 200%).
float
required
The cap amount claimed by the LLM.

Response fields

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”
These clauses conflict for days 30-90!

The solution

The primary check_consistency() method uses text heuristics to detect conflicts. For formal logic verification, use verify_using_z3().

Detection types

Z3-based verification

When you need to define precise logical constraints, verify_using_z3() only accepts explicit Z3 BoolRef expressions — it does not parse free-form text. You must model the legal meaning yourself.

Fail-closed behavior

verify_using_z3() is fail-closed: it returns consistent=False for any input it cannot prove satisfiable. The following inputs are rejected as UNVERIFIABLE rather than silently passing:
Passing raw strings or other non-Z3 values is rejected. The guard reports the 1-based position of each invalid constraint so callers can identify the offending entries.

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

CitationGuard checks format only. result.verified is always False, and a format-valid citation has status="unverifiable_authority". A well-formatted citation can still refer to a case that does not exist — confirming authority requires an external legal database, which this guard does not have. Use format_valid to check shape; never treat it as proof of authority.

Supported citation patterns

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[str]
required
List of ISO country codes for contract parties (e.g., ["US", "UK"]).
str
required
The stated governing law — can be a country code or US state name/abbreviation (e.g., "Delaware", "DE", "UK").
str
The stated forum or venue for dispute resolution.
JurisdictionType
default:"JurisdictionType.EXCLUSIVE"
Type of jurisdiction clause. Accepts JurisdictionType.EXCLUSIVE, JurisdictionType.NON_EXCLUSIVE, or JurisdictionType.HYBRID.

Features

Verify forum selection

Use verify_forum_selection to validate a forum independently, with optional contract value threshold checks for US federal court diversity jurisdiction:

Convention check


6. StatuteOfLimitationsGuard

Status: MIXED Purpose: Compute claim limitation periods for supported jurisdictions and claim types using rule tables. The limitation-period lookup is PARSED; the date arithmetic over it (expiration, days remaining) is DETERMINISTIC. 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

Fail-closed behavior

StatuteOfLimitationsGuard is fail-closed: it never fabricates a limitation period for jurisdictions or claim types that are not in its rule tables.
  • Exact match only. Jurisdiction lookup uses exact string equality (case-insensitive, trimmed). Partial matches such as "CALIF" for "CALIFORNIA" or "NEW" for "NEW YORK" are rejected.
  • Unknown jurisdiction → unverifiable. If the jurisdiction is not in the supported list, verify() returns verified=False with jurisdiction_matched=False, all date and period fields set to None, and a message listing the supported jurisdictions.
  • Unknown claim type → unverifiable. If the jurisdiction is supported but the claim type is not modeled for it, verify() returns verified=False with claim_type_matched=False, and a message listing the supported claim types for that jurisdiction.

Parameters

str
required
Type of legal claim (e.g., "breach_of_contract", "negligence", "fraud"). Must exactly match one of the supported claim types for the given jurisdiction; unknown values produce an unverifiable result.
str
required
State or country name (e.g., "California", "New York", "UK"). Matched case-insensitively against the supported jurisdictions list — partial or substring matches are not accepted.
str
required
Date the incident occurred (ISO format).
str
required
Date the claim was or will be filed (ISO format).
bool
Optional LLM claim to verify. When provided, the guard checks whether the LLM’s assertion (within/outside period) matches the computed result.

StatuteResult fields

bool
True only when the jurisdiction and claim type are recognized and the filing falls within the limitation period (and matches claimed_within_period, if supplied).
str
The claim type passed in (echoed back).
str
The jurisdiction passed in (echoed back).
Optional[datetime]
Parsed incident date, or None if date parsing failed.
Optional[datetime]
Parsed filing date, or None if date parsing failed.
Optional[float]
Limitation period applied, or None if the jurisdiction or claim type is unknown.
Optional[datetime]
Computed expiration date, or None if no limitation period could be determined.
Optional[int]
Days between filing date and expiration (negative if expired), or None if no limitation period could be determined.
str
Human-readable result. Unverifiable results are prefixed with ⚠️ UNVERIFIABLE: and list the supported jurisdictions or claim types.
bool
default:"True"
False when the jurisdiction is not in the supported list.
bool
default:"True"
False when the claim type is not modeled for the given jurisdiction.

Supported jurisdictions

12 jurisdictions are supported with periods for 10 claim types.

Supported claim types

breach_of_contract, breach_of_warranty, negligence, professional_malpractice, fraud, personal_injury, property_damage, employment, product_liability, defamation

Fail-closed on unknown jurisdictions and claim types

StatuteOfLimitationsGuard only computes limitation periods for the jurisdictions and claim types it has explicit rules for. Anything outside that table fails closed instead of returning a fabricated period.
  • Exact jurisdiction match only. Inputs are uppercased and trimmed before lookup. Substring matches like "CALIF" no longer resolve to "CALIFORNIA", and a misspelled or unsupported jurisdiction never falls back to a generic default rule table.
  • Exact claim type match only. Claim types are lowercased with spaces converted to underscores before lookup. Unknown claim types no longer silently default to a 3-year period.
  • UNVERIFIABLE result. When either lookup fails, verify() returns a StatuteResult with verified=False, all date and period fields set to None, and a message that begins with ⚠️ UNVERIFIABLE and lists the supported values.
  • New flags. StatuteResult exposes jurisdiction_matched: bool and claim_type_matched: bool so callers can distinguish “claim is time-barred” from “we cannot determine the limit”.
This is a breaking change. get_limitation_period() now returns Optional[float] and StatuteResult date and period fields are Optional. Callers that previously assumed a numeric result must handle None and treat unverifiable inputs as a hard failure rather than a passing check. See the changelog entry for migration notes.

Get limitation period

Look up the limitation period for a specific claim type and jurisdiction without performing a full verification. Returns None when the jurisdiction or claim type is not supported:

Compare jurisdictions

compare_jurisdictions() returns Dict[str, Optional[float]]. Unsupported jurisdictions map to None so you can surface them in the UI rather than mixing them with real periods:
Unsupported jurisdictions map to None rather than a default value.

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

result["verified"] is always False for IRACGuard — structural validity is not proof of correct legal reasoning. Branch on structure_valid and status instead, and route unverifiable_reasoning results to a human reviewer.

Detection types

Error response

IRACGuard checks structure and surface-level coherence only. A passing result has status="unverifiable_reasoning" — it confirms the four IRAC sections are present and structurally coherent, not that the cited rule exists or that the reasoning is legally sound. In the verification_trace, structure steps are INFERRED and the reasoning conclusion is UNSUPPORTED — never DETERMINISTIC.

8. FairnessGuard

Status: HEURISTIC / FAIL-CLOSED Purpose: Apply a counterfactual consistency check that flags when output changes after protected attributes are swapped. This is a heuristic signal, not a fairness proof. Requires an external LLM client.
As of v0.4.0, FairnessGuard never returns verified=True (issue #18). Legal fairness cannot be proven by text substitution and string equality, so the guard does not claim it. A consistent outcome is reported as UNVERIFIABLE_FAIRNESS; a differing outcome is a HEURISTIC_BIAS_SIGNAL that warrants human review. This is a breaking change from earlier versions that returned FAIRNESS_VERIFIED.

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
A single counterfactual swap with string-equality comparison cannot prove fairness — equivalent outcomes may differ in wording, and a single swap does not cover all relevant dimensions. So the result is always treated as a signal, never a pass.

The solution

How it works

  1. Input validation — Rejects an empty swap, non-string values, and keys that collide when lowercased (fail-closed ValueError or UNVERIFIABLE_FAIRNESS).
  2. Counterfactual generation — Swaps protected attributes (names, pronouns) in a single pass while preserving case.
  3. Re-evaluation — Runs the modified prompt through the LLM.
  4. Heuristic comparison — Compares outcomes by string equality. Consistency is reported as UNVERIFIABLE_FAIRNESS (not proof); a difference is a HEURISTIC_BIAS_SIGNAL.

Response fields

Outcomes

FairnessGuard requires an LLM client at initialization. Without it, verify_decision_fairness() raises a ValueError. Malformed protected_attribute_swap input (non-string values, case-colliding keys) also raises a ValueError — the guard never silently processes ambiguous input.
Migration from earlier versions: if your code branched on result["verified"] == True or status == "FAIRNESS_VERIFIED", update it to treat the output as a signal. Consume status / risk and route HEURISTIC_BIAS_SIGNAL (and consistent-but-unverifiable) results to a human reviewer.

9. ContradictionGuard

Status: MIXED Purpose: Detect logical contradictions between modeled clauses using a Z3 constraint solver. The SAT/UNSAT result is DETERMINISTIC; clause categorization from text is PARSED. Coverage is limited to the supported clause categories below — a “consistent” result is not a proof of full contract consistency, and unmodeled clauses fail closed.

The problem

Contracts can contain mathematically impossible combinations:
  • “Liability capped at 10,000"+"Minimumpenaltyof10,000" + "Minimum penalty of 50,000”
  • “Term is exactly 12 months” + “Minimum duration of 24 months”
Text-based heuristics (ClauseGuard) miss these formal logic conflicts.

The solution

Clause structure

The Clause dataclass requires:

Supported categories

Z3 vs ClauseGuard


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.

Constructor parameters

bool
default:"True"
Require AI disclosure text in the content (e.g., “AI-generated”, “produced by AI”).
bool
default:"False"
Require human_reviewed=True in provenance metadata.
list[str] | None
default:"None"
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

Risk classifications

When verification fails, the risk field indicates the type of failure:
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

Methods

SACProcessor requires an LLM client. Generic (automated) summaries outperform expert-guided ones for retrieval.

All-in-one: LegalGuard

For convenience, use the unified LegalGuard 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