🏛️ Verification guards for legal contracts - Date calculations, clause consistency, liability verification
Project description
🏛️ QWED-Legal
Verification Guards for Legal Contracts
Catch AI hallucinations before they become lawsuits.
Don't trust AI with legal analysis. Verify it.
Deadline math • Clause contradictions • Liability calculations
🚨 The Problem
Lawyers are using AI to review contracts. AI makes mistakes.
| Case | What Happened | Impact |
|---|---|---|
| Mata v. Avianca (2023) | ChatGPT cited 6 fake legal cases | $5,000 fine, sanctions |
| Contract Review Errors | LLMs miss contradictory clauses | Disputes, litigation |
| Date Calculation Bugs | "30 business days" miscalculated | Missed deadlines, defaults |
⚡ Quick Start
Installation
pip install qwed-legal
Verify a Deadline Calculation
from qwed_legal import DeadlineGuard
guard = DeadlineGuard()
result = guard.verify(
signing_date="2026-01-15",
term="30 business days",
claimed_deadline="2026-02-14" # LLM claimed this
)
print(result.verified) # False!
print(result.computed_deadline) # 2026-02-27 (correct)
print(result.message)
# ❌ ERROR: Deadline mismatch. Expected 2026-02-27, but LLM claimed 2026-02-14.
Verify a Liability Cap
from qwed_legal import LiabilityGuard
guard = LiabilityGuard()
result = guard.verify_cap(
contract_value=5_000_000,
cap_percentage=200,
claimed_cap=15_000_000 # LLM said 15M
)
print(result.verified) # False!
print(result.computed_cap) # 10,000,000 (200% of 5M)
# ❌ ERROR: 200% of $5M = $10M, not $15M
Detect Contradictory Clauses
from qwed_legal import ClauseGuard
guard = ClauseGuard()
result = guard.check_consistency([
"Seller may terminate with 30 days notice",
"Neither party may terminate before 90 days",
"Seller may terminate immediately upon breach"
])
print(result.consistent) # False!
# ⚠️ WARNING: Clauses 1 and 2 may conflict (days 30-90)
🛡️ The Six Guards
| Guard | What It Verifies |
|---|---|
| DeadlineGuard | Date calculations, business days, leap years |
| LiabilityGuard | Cap percentages, tiered liability, indemnity limits |
| ClauseGuard | Clause contradictions, termination conflicts |
| CitationGuard | Legal citations (Bluebook format, case names, reporters) |
| JurisdictionGuard | Choice of law, forum selection, cross-border conflicts |
| StatuteOfLimitationsGuard | Claim periods by jurisdiction and claim type |
Verify Legal Citations
from qwed_legal import CitationGuard
guard = CitationGuard()
result = guard.verify("Brown v. Board of Education, 347 U.S. 483 (1954)")
print(result.valid) # True
print(result.parsed_components)
# {'plaintiff': 'Brown', 'defendant': 'Board of Education', 'volume': 347, 'reporter': 'U.S.', 'page': 483, 'year': 1954}
Verify Jurisdiction (New in v0.2.0!)
from qwed_legal import JurisdictionGuard
guard = JurisdictionGuard()
result = guard.verify_choice_of_law(
parties_countries=["US", "UK"],
governing_law="Delaware",
forum="London"
)
print(result.conflicts) # ['Governing law Delaware (US state) but forum London is non-US...']
Check Statute of Limitations (New in v0.2.0!)
from qwed_legal import StatuteOfLimitationsGuard
guard = StatuteOfLimitationsGuard()
result = guard.verify(
claim_type="breach_of_contract",
jurisdiction="California",
incident_date="2020-01-15",
filing_date="2026-06-01"
)
print(result.verified) # False - 4 year limit exceeded!
print(result.message) # ❌ EXPIRED: Statute of limitations expired...
📦 TypeScript/JavaScript (npm)
npm install @qwed-ai/legal
import { DeadlineVerifier, JurisdictionVerifier } from '@qwed-ai/legal';
const deadline = new DeadlineVerifier();
const result = await deadline.verify("2026-01-15", "30 days", "2026-02-14");
console.log(result.verified);
📊 Audit Log: Real Hallucinations Caught
| Contract Input | LLM Claim | QWED Verdict |
|---|---|---|
| "Net 30 Business Days from Dec 20" | Jan 19 | 🛑 BLOCKED (Actual: Feb 2, 2026) |
| "Liability Cap: 2x Fees ($50k)" | $200,000 | 🛑 BLOCKED (Actual: $100,000) |
| "Seller may terminate with 30 days notice" + "Neither party may terminate before 90 days" | "Clauses are consistent" | 🛑 BLOCKED (Conflict detected) |
| "Smith v. Jones, 999 FAKE 123" | Valid citation | 🛑 BLOCKED (Unknown reporter) |
🏦 All-in-One Guard
from qwed_legal import LegalGuard
guard = LegalGuard()
# All verification methods in one object
guard.verify_deadline(...)
guard.verify_liability_cap(...)
guard.check_clause_consistency(...)
🌍 Jurisdiction Support
DeadlineGuard supports jurisdiction-specific holidays:
from qwed_legal import DeadlineGuard
# US holidays (default)
us_guard = DeadlineGuard(country="US")
# UK holidays
uk_guard = DeadlineGuard(country="GB")
# California-specific holidays
ca_guard = DeadlineGuard(country="US", state="CA")
🔗 Related QWED Packages
| Package | Purpose |
|---|---|
| qwed-verification | Core verification engine |
| qwed-finance | Banking & financial verification |
| qwed-ucp | E-commerce transaction verification |
| qwed-mcp | Claude Desktop integration |
📄 License
Apache 2.0 - See LICENSE
"In law, precision isn't optional. QWED makes it verifiable."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qwed_legal-0.2.0.tar.gz.
File metadata
- Download URL: qwed_legal-0.2.0.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c617699c36336dae0d7647a7566afcb950c7843ac67ad06e633e346681309a1
|
|
| MD5 |
5c0abfdd046a9c4dfd6f2d093ad0bd45
|
|
| BLAKE2b-256 |
f59a129383d9f34f72be3e42414e58e4d1ba9fed477c60fb5e380d03a69e3119
|
Provenance
The following attestation bundles were made for qwed_legal-0.2.0.tar.gz:
Publisher:
publish.yml on QWED-AI/qwed-legal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwed_legal-0.2.0.tar.gz -
Subject digest:
9c617699c36336dae0d7647a7566afcb950c7843ac67ad06e633e346681309a1 - Sigstore transparency entry: 846186706
- Sigstore integration time:
-
Permalink:
QWED-AI/qwed-legal@fcf2e52cddced5dc6474a5bf2bee3ff3ce747ad3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/QWED-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fcf2e52cddced5dc6474a5bf2bee3ff3ce747ad3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qwed_legal-0.2.0-py3-none-any.whl.
File metadata
- Download URL: qwed_legal-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8a9de7a7d7e467ef37d914f3a2feeb8a986691a48d44a829529fc73b820da28
|
|
| MD5 |
fbdc5721286abccdfac8d3e6911eba36
|
|
| BLAKE2b-256 |
e0df7c637d67f684322ad7f31e5d94835cf3483bd4f519471ee8a041e8187bd2
|
Provenance
The following attestation bundles were made for qwed_legal-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on QWED-AI/qwed-legal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwed_legal-0.2.0-py3-none-any.whl -
Subject digest:
a8a9de7a7d7e467ef37d914f3a2feeb8a986691a48d44a829529fc73b820da28 - Sigstore transparency entry: 846186727
- Sigstore integration time:
-
Permalink:
QWED-AI/qwed-legal@fcf2e52cddced5dc6474a5bf2bee3ff3ce747ad3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/QWED-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fcf2e52cddced5dc6474a5bf2bee3ff3ce747ad3 -
Trigger Event:
release
-
Statement type: