🏛️ 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 Four 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) |
Verify Legal Citations (New!)
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}
📊 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.1.0.tar.gz.
File metadata
- Download URL: qwed_legal-0.1.0.tar.gz
- Upload date:
- Size: 18.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 |
be9b977685a8c9aad7cccb3d2c97a7c995488d76824a0c762cbdc3d9087d5d86
|
|
| MD5 |
52470b0869490d70e21fd8571aa0d675
|
|
| BLAKE2b-256 |
50e6a9817bfe5a3d2de7453bae2054db1274d0b901253fe7123f053c7fa71bf7
|
Provenance
The following attestation bundles were made for qwed_legal-0.1.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.1.0.tar.gz -
Subject digest:
be9b977685a8c9aad7cccb3d2c97a7c995488d76824a0c762cbdc3d9087d5d86 - Sigstore transparency entry: 845301888
- Sigstore integration time:
-
Permalink:
QWED-AI/qwed-legal@37f259760271241648ca5d54e1c5856c504795f2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/QWED-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@37f259760271241648ca5d54e1c5856c504795f2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qwed_legal-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qwed_legal-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.8 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 |
af17cd7d57da8112ce0fd084a478625335f4f4ff682dd1e5269e4714dfbcfdfd
|
|
| MD5 |
4bb262aee1c7e52a1905b6cd99763592
|
|
| BLAKE2b-256 |
cedde852a64db989e6a6a88fecc0af1451cd6008e093b5e9d29b8c117b5f43e3
|
Provenance
The following attestation bundles were made for qwed_legal-0.1.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.1.0-py3-none-any.whl -
Subject digest:
af17cd7d57da8112ce0fd084a478625335f4f4ff682dd1e5269e4714dfbcfdfd - Sigstore transparency entry: 845301946
- Sigstore integration time:
-
Permalink:
QWED-AI/qwed-legal@37f259760271241648ca5d54e1c5856c504795f2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/QWED-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@37f259760271241648ca5d54e1c5856c504795f2 -
Trigger Event:
release
-
Statement type: