Legaltech: AI Contract Review Guard

Multi-persona consensus guard that evaluates AI-generated contract risk analysis before a law firm relies on it for a $2.4M vendor agreement.

Scenario

A law firm uses AI to review vendor contracts before signing. The AI flags risk clauses, but before the firm relies on the AI's analysis, 4 guard personas independently evaluate the AI's work. Each persona specializes in a different area of contract risk.

The contract under review is a cloud infrastructure vendor agreement valued at $2.4M/year. The AI's initial scan flagged it as "moderate risk" -- but the guards dig deeper.

What the AI missed

The AI's initial analysis rated this contract as "moderate risk" and recommended signing with minor revisions. The guard personas found 4 critical issues the AI overlooked, any one of which could have cost the firm hundreds of thousands of dollars.


The contract's hidden problems

SectionIssueSeverity
14.3 (Liability)Unlimited liability clause buried in subsection (c)Critical
8.2 (IP Rights)Broad IP assignment that could transfer client data models to vendorCritical
No DPA presentNo data processing addendum despite GDPR applicabilityCritical
22.1 (Term)Auto-renewal with 180-day cancellation notice (industry standard: 30-60 days)High

Guard personas

PersonaSpecialization
liability-reviewerUnlimited liability clauses, indemnification traps, consequential damages exposure
ip-counselIP assignment clauses, work-for-hire language, license scope creep
data-privacy-analystData processing terms, GDPR compliance, cross-border transfer provisions, breach notification requirements
commercial-terms-reviewerAuto-renewal traps, termination penalties, price escalation clauses, SLA enforceability

Full working example

1

Set up the project

mkdir contract-guard && cd contract-guard
pnpm init -y
pnpm add @consensus-tools/core @consensus-tools/policies
2

Create the contract review guard

Create contract-review-guard.ts:

import { LocalBoard } from "@consensus-tools/core";

// --- Initialize the board ---
const board = new LocalBoard({
  mode: "local",
  local: {
    storage: { kind: "json", path: "./contract-review-state.json" },
    jobDefaults: {
      reward: 20,
      stakeRequired: 5,
      maxParticipants: 6,
      expiresSeconds: 7200,
      consensusPolicy: { type: "APPROVAL_VOTE", quorum: 4, threshold: 0.6 },
    },
  },
});
await board.init();

// --- The contract under review ---
const contract = {
  vendor: "CloudScale Infrastructure Inc.",
  annualValue: 2_400_000,
  term: "3 years with auto-renewal",
  effectiveDate: "2026-04-01",
  aiRiskRating: "MODERATE",
  aiRecommendation: "Sign with minor revisions to SLA section",
  sections: {
    liability: "Section 14.3(c): Provider's aggregate liability shall not be limited under this Agreement.",
    ipRights: "Section 8.2: Client grants Provider a perpetual, irrevocable license to all data models, algorithms, and derivative works created using the Services.",
    dataProcessing: "No Data Processing Addendum attached. Section 12 references 'standard security practices' without specifics.",
    termination: "Section 22.1: Agreement auto-renews for successive 1-year terms. Cancellation requires 180 calendar days written notice prior to renewal date.",
  },
  jurisdictions: ["US-NY", "EU-DE", "EU-FR"],
};

console.log("CONTRACT REVIEW: " + contract.vendor);
console.log("Annual value: $" + contract.annualValue.toLocaleString());
console.log("AI recommendation: " + contract.aiRecommendation);
console.log("AI risk rating: " + contract.aiRiskRating);
console.log("");

// --- Post the guard job ---
const job = await board.engine.postJob("contract-review-system", {
  title: `Guard review: ${contract.vendor} ($${(contract.annualValue / 1_000_000).toFixed(1)}M/yr)`,
  reward: 20,
  stakeRequired: 5,
});

console.log("Job posted: " + job.id);
console.log("Awaiting guard evaluations...");
console.log("");

// --- 4 specialist guards evaluate independently ---
const guards = [
  {
    id: "liability-reviewer",
    verdict: "BLOCK",
    confidence: 0.97,
    findings: {
      severity: "CRITICAL",
      clause: "Section 14.3(c)",
      issue: "Unlimited liability clause",
      detail: "Provider's liability is explicitly unlimited. Standard cloud contracts cap liability at 12-24 months of fees. Unlimited liability on a $2.4M/yr contract exposes the firm to uncapped damages claims. This single clause could cost more than the entire contract value.",
      recommendation: "Require liability cap at 12 months of fees paid ($2.4M). Add mutual limitation. Carve out only for IP infringement and confidentiality breach.",
    },
  },
  {
    id: "ip-counsel",
    verdict: "BLOCK",
    confidence: 0.94,
    findings: {
      severity: "CRITICAL",
      clause: "Section 8.2",
      issue: "Overbroad IP assignment — client data models at risk",
      detail: "The 'perpetual, irrevocable license to all data models and derivative works' is extraordinarily broad. This could transfer ownership of the firm's proprietary client data models, ML training artifacts, and analytical frameworks to the vendor. For a law firm, this may include privileged work product.",
      recommendation: "Replace with limited license scoped to service delivery only. Add explicit carve-out for client data, privileged materials, and firm IP. Require return/destruction of all data upon termination.",
    },
  },
  {
    id: "data-privacy-analyst",
    verdict: "BLOCK",
    confidence: 0.92,
    findings: {
      severity: "CRITICAL",
      clause: "Missing DPA",
      issue: "No Data Processing Addendum despite GDPR applicability",
      detail: "Contract covers EU jurisdictions (DE, FR) but contains no DPA, no Standard Contractual Clauses, no specification of data controller/processor roles, and no breach notification timeline. Section 12 references 'standard security practices' — this is legally meaningless under GDPR Art. 28. Processing EU personal data without a DPA exposes the firm to fines up to 4% of annual turnover.",
      recommendation: "Require GDPR-compliant DPA as mandatory exhibit. Include SCCs for cross-border transfers. Specify 72-hour breach notification. Define data retention and deletion obligations.",
    },
  },
  {
    id: "commercial-terms-reviewer",
    verdict: "ESCALATE",
    confidence: 0.85,
    findings: {
      severity: "HIGH",
      clause: "Section 22.1",
      issue: "Auto-renewal with 180-day cancellation notice is a trap",
      detail: "180-day cancellation notice is 3-6x the industry standard (30-60 days). On a 3-year term, the firm must decide whether to renew 6 months before expiration — likely before they have enough performance data to evaluate. Combined with no SLA enforcement mechanism, the firm is locked in with no leverage.",
      recommendation: "Negotiate to 60-day notice period. Add SLA credits with teeth (15-25% of monthly fees). Include termination-for-convenience clause with 90-day wind-down.",
    },
  },
];

for (const guard of guards) {
  await board.engine.claimJob(guard.id, job.id, {
    stakeAmount: 5,
    leaseSeconds: 600,
  });

  await board.engine.submitJob(guard.id, job.id, {
    summary: guard.verdict,
    confidence: guard.confidence,
    artifacts: {
      severity: guard.findings.severity,
      clause: guard.findings.clause,
      issue: guard.findings.issue,
      detail: guard.findings.detail,
      recommendation: guard.findings.recommendation,
    },
  });

  console.log(`[${guard.id}] ${guard.verdict} (confidence: ${guard.confidence})`);
  console.log(`  Severity: ${guard.findings.severity}`);
  console.log(`  Clause:   ${guard.findings.clause}`);
  console.log(`  Issue:    ${guard.findings.issue}`);
  console.log(`  Detail:   ${guard.findings.detail}`);
  console.log("");
}

// --- Resolve the consensus ---
const resolution = await board.engine.resolveJob("contract-review-system", job.id);

console.log("=".repeat(60));
console.log("CONSENSUS RESOLUTION");
console.log("=".repeat(60));
console.log("");

// --- Tally the verdicts ---
const verdicts = guards.map((g) => g.verdict);
const blockCount = verdicts.filter((v) => v === "BLOCK").length;
const escalateCount = verdicts.filter((v) => v === "ESCALATE").length;

const finalDecision = blockCount >= 2 ? "BLOCK" : escalateCount >= 2 ? "ESCALATE" : "ALLOW";

console.log("Final decision:     " + finalDecision);
console.log("Block votes:        " + blockCount + " of " + guards.length);
console.log("Escalate votes:     " + escalateCount + " of " + guards.length);
console.log("Policy:             " + resolution.policyType);
console.log("Winners:            " + JSON.stringify(resolution.winners));
console.log("");

// --- Overrides the AI's original recommendation ---
console.log("AI recommended:     " + contract.aiRecommendation);
console.log("Guard overrode AI:  YES — 3 of 4 guards flagged critical issues");
console.log("");

// --- Summary of required actions before signing ---
console.log("REQUIRED ACTIONS BEFORE SIGNING:");
console.log("-".repeat(40));
for (const guard of guards) {
  console.log(`[${guard.findings.severity}] ${guard.findings.issue}`);
  console.log(`  -> ${guard.findings.recommendation}`);
  console.log("");
}

// --- What would have happened without the guard ---
console.log("=".repeat(60));
console.log("WITHOUT THIS GUARD:");
console.log("=".repeat(60));
console.log("");
console.log("The firm signs a $2.4M/year contract with:");
console.log("  - Unlimited liability exposure (no cap on damages)");
console.log("  - Vendor owns the firm's data models and derivative works");
console.log("  - No GDPR compliance (up to 4% of turnover in fines)");
console.log("  - 180-day cancellation trap (locked in with no leverage)");
console.log("");
console.log("Estimated risk exposure: $5M+ in liability, regulatory fines,");
console.log("and IP loss over the 3-year term.");

// --- Audit trail ---
console.log("");
console.log("=".repeat(60));
console.log("AUDIT TRAIL");
console.log("=".repeat(60));
console.log("");
console.log("All guard evaluations, votes, and the final resolution are");
console.log("stored in contract-review-state.json for regulatory and");
console.log("malpractice defense purposes.");
console.log("");
console.log("Job ID:       " + job.id);
console.log("Timestamp:    " + new Date().toISOString());
console.log("Contract:     " + contract.vendor);
console.log("Annual value: $" + contract.annualValue.toLocaleString());
console.log("Guard count:  " + guards.length);
console.log("Decision:     " + finalDecision);
3

Run the guard

npx tsx contract-review-guard.ts

Expected output:

CONTRACT REVIEW: CloudScale Infrastructure Inc.
Annual value: $2,400,000
AI recommendation: Sign with minor revisions to SLA section
AI risk rating: MODERATE

Job posted: <job-id>
Awaiting guard evaluations...

[liability-reviewer] BLOCK (confidence: 0.97)
  Severity: CRITICAL
  Clause:   Section 14.3(c)
  Issue:    Unlimited liability clause
  Detail:   Provider's liability is explicitly unlimited...

[ip-counsel] BLOCK (confidence: 0.94)
  Severity: CRITICAL
  Clause:   Section 8.2
  Issue:    Overbroad IP assignment — client data models at risk
  Detail:   The 'perpetual, irrevocable license to all data models...'

[data-privacy-analyst] BLOCK (confidence: 0.92)
  Severity: CRITICAL
  Clause:   Missing DPA
  Issue:    No Data Processing Addendum despite GDPR applicability
  Detail:   Contract covers EU jurisdictions (DE, FR) but contains no DPA...

[commercial-terms-reviewer] ESCALATE (confidence: 0.85)
  Severity: HIGH
  Clause:   Section 22.1
  Issue:    Auto-renewal with 180-day cancellation notice is a trap
  Detail:   180-day cancellation notice is 3-6x the industry standard...

============================================================
CONSENSUS RESOLUTION
============================================================

Final decision:     BLOCK
Block votes:        3 of 4
Escalate votes:     1 of 4

AI recommended:     Sign with minor revisions to SLA section
Guard overrode AI:  YES — 3 of 4 guards flagged critical issues

REQUIRED ACTIONS BEFORE SIGNING:
----------------------------------------
[CRITICAL] Unlimited liability clause
  -> Require liability cap at 12 months of fees paid ($2.4M)...

[CRITICAL] Overbroad IP assignment — client data models at risk
  -> Replace with limited license scoped to service delivery only...

[CRITICAL] No Data Processing Addendum despite GDPR applicability
  -> Require GDPR-compliant DPA as mandatory exhibit...

[HIGH] Auto-renewal with 180-day cancellation notice is a trap
  -> Negotiate to 60-day notice period...

============================================================
WITHOUT THIS GUARD:
============================================================

The firm signs a $2.4M/year contract with:
  - Unlimited liability exposure (no cap on damages)
  - Vendor owns the firm's data models and derivative works
  - No GDPR compliance (up to 4% of turnover in fines)
  - 180-day cancellation trap (locked in with no leverage)

Estimated risk exposure: $5M+ in liability, regulatory fines,
and IP loss over the 3-year term.

Why this matters

The AI rated the contract as "moderate risk" and recommended signing with minor SLA revisions. If the firm relied on this analysis:

  • Unlimited liability goes unnoticed until a breach occurs
  • IP assignment transfers proprietary client data models to the vendor silently
  • No GDPR coverage means the first EU data subject complaint triggers an investigation
  • 180-day cancellation locks the firm into a vendor they cannot easily leave

Total risk exposure over the 3-year term: $5M+ in potential liability, regulatory fines, and intellectual property loss.


Audit trail structure

Every guard evaluation produces a board artifact. For regulated industries like legal services, this creates a defensible record:

{
  "jobId": "contract-review-cloudscale-2026-04",
  "contract": "CloudScale Infrastructure Inc.",
  "annualValue": 2400000,
  "aiRecommendation": "Sign with minor revisions",
  "guardDecision": "BLOCK",
  "votes": [
    { "persona": "liability-reviewer", "verdict": "BLOCK", "confidence": 0.97, "clause": "14.3(c)" },
    { "persona": "ip-counsel", "verdict": "BLOCK", "confidence": 0.94, "clause": "8.2" },
    { "persona": "data-privacy-analyst", "verdict": "BLOCK", "confidence": 0.92, "clause": "Missing DPA" },
    { "persona": "commercial-terms-reviewer", "verdict": "ESCALATE", "confidence": 0.85, "clause": "22.1" }
  ],
  "timestamp": "2026-03-19T14:32:00.000Z",
  "policyType": "APPROVAL_VOTE"
}

Malpractice defense

In legal malpractice claims, the most common defense gap is "we reviewed it but can't prove what we checked." The guard audit trail provides timestamped, per-clause evidence that specific risk categories were evaluated by specialized reviewers before any signing recommendation was made.


Extending this example

  • Add human-in-the-loop: Route BLOCK decisions to the firm's General Counsel via @consensus-tools/notifications
  • Clause extraction: Feed contract PDFs through an extraction pipeline, then pass structured clauses to each guard persona
  • Precedent matching: Connect guard personas to a vector database of prior contract reviews to flag clauses that caused problems in past deals
  • Multi-jurisdiction: Add jurisdiction-specific personas (e.g., gdpr-specialist, ccpa-analyst, uk-data-protection) that activate based on the contract's applicable law