Quickstart: Guard a Support Response

Walk through the full consensus lifecycle: a support AI drafts a dangerous response, guards catch it, and the board blocks it before it sends.

The scenario

Your customer support AI just drafted a response to Meridian Partners, an enterprise client on a $47K/year SaaS contract. The customer is furious about a billing error and demanding a full refund.

The AI's draft:

"We sincerely apologize for the inconvenience. We'll process a full refund of $47,000 immediately and terminate your contract effective today. No further charges will apply."

Two problems the AI doesn't know about:

  1. The refund exceeds the auto-approve limit. Company policy caps automated refunds at $5K. Anything above requires VP approval.
  2. The contract has a 12-month lock-in. Terminating it early triggers a $14K early termination fee that the company would be waiving without authorization.

Without a guard, that response sends. The company eats $47K + $14K in unauthorized commitments. With consensus.tools, specialist guards catch both issues before the customer ever sees the draft.

No account needed

This entire quickstart runs locally. One TypeScript file, no server, no API keys.


Let's build it

1

Create a project and install packages

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

Create the guard script

Create support-guard.ts:

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

// --- Initialize a local board ---
const board = new LocalBoard({
  mode: "local",
  local: {
    storage: { kind: "json", path: "./board-state.json" },
    jobDefaults: {
      reward: 10,
      stakeRequired: 3,
      maxParticipants: 5,
      expiresSeconds: 3600,
      consensusPolicy: { type: "APPROVAL_VOTE", quorum: 3, threshold: 0.6 },
    },
  },
});
await board.init();

// --- The dangerous draft ---
const draft = {
  to: "j.chen@meridianpartners.com",
  subject: "Re: URGENT — Billing error on invoice #MER-2024-0892",
  body: "We sincerely apologize for the inconvenience. We'll process a full refund of $47,000 immediately and terminate your contract effective today. No further charges will apply.",
  context: {
    customerTier: "enterprise",
    contractValue: 47_000,
    contractTermMonthsRemaining: 8,
    earlyTerminationFee: 14_100,
    autoApproveRefundLimit: 5_000,
    lockInMonths: 12,
  },
};

console.log("--- DRAFT UNDER REVIEW ---");
console.log(`To: ${draft.to}`);
console.log(`Subject: ${draft.subject}`);
console.log(`Body: "${draft.body}"`);
console.log("");

// --- Post a guard job to the board ---
const job = await board.engine.postJob("support-system", {
  title: "Guard: CS response to Meridian Partners re billing dispute",
  reward: 10,
  stakeRequired: 3,
});

// --- Three specialist guards evaluate the draft ---

// Guard 1: Refund policy reviewer
await board.engine.claimJob("refund-policy-reviewer", job.id, {
  stakeAmount: 3,
  leaseSeconds: 300,
});
await board.engine.submitJob("refund-policy-reviewer", job.id, {
  summary: "BLOCK",
  confidence: 0.97,
  artifacts: {
    reason:
      "Refund of $47,000 exceeds auto-approve limit of $5,000 by 840%. Requires VP-level approval per refund policy v3.2, section 4.1.",
    flaggedAmount: 47_000,
    limit: 5_000,
    requiredApprover: "vp_customer_success",
  },
});
console.log("refund-policy-reviewer: BLOCK (0.97)");
console.log(
  '  "$47K refund exceeds $5K auto-approve limit by 840%"',
);
console.log("");

// Guard 2: Contract compliance reviewer
await board.engine.claimJob("contract-compliance-reviewer", job.id, {
  stakeAmount: 3,
  leaseSeconds: 300,
});
await board.engine.submitJob("contract-compliance-reviewer", job.id, {
  summary: "BLOCK",
  confidence: 0.93,
  artifacts: {
    reason:
      "Contract MER-2024 has 8 months remaining on a 12-month lock-in. Early termination waives $14,100 ETF without authorization. Draft language 'terminate your contract effective today' constitutes unauthorized contract modification.",
    contractId: "MER-2024",
    remainingMonths: 8,
    earlyTerminationFee: 14_100,
    violation: "unauthorized_contract_modification",
  },
});
console.log("contract-compliance-reviewer: BLOCK (0.93)");
console.log(
  '  "8 months left on 12-month lock-in. Waiving $14.1K ETF without auth."',
);
console.log("");

// Guard 3: Customer experience reviewer
await board.engine.claimJob("cx-tone-reviewer", job.id, {
  stakeAmount: 3,
  leaseSeconds: 300,
});
await board.engine.submitJob("cx-tone-reviewer", job.id, {
  summary: "REWRITE",
  confidence: 0.78,
  artifacts: {
    reason:
      "Empathetic tone is appropriate for an enterprise escalation. However, all financial commitments must be removed. Recommend acknowledging the error, confirming investigation, and offering a call with the account manager within 24 hours.",
    suggestedAction: "escalate_to_account_manager",
    toneScore: 0.85,
  },
});
console.log("cx-tone-reviewer: REWRITE (0.78)");
console.log(
  '  "Good tone, but remove all financial commitments. Escalate to AM."',
);
console.log("");

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

console.log("===========================================");
console.log("BOARD DECISION:", resolution.winners.length > 0 ? "REVIEWED" : "NO CONSENSUS");
console.log("Policy:", resolution.policyType);
console.log("===========================================");
console.log("");

// --- Act on the verdict ---
const verdicts = ["BLOCK", "BLOCK", "REWRITE"];
const blocked = verdicts.some((v) => v === "BLOCK");

if (blocked) {
  console.log("BLOCKED -- Response will NOT be sent to Meridian Partners.");
  console.log("");
  console.log("Issues caught:");
  console.log("  1. $47K refund exceeds $5K auto-approve limit (needs VP approval)");
  console.log("  2. Contract termination waives $14.1K ETF without authorization");
  console.log("  3. Draft contains unauthorized financial commitments");
  console.log("");
  console.log("Next steps:");
  console.log("  - Escalate to VP Customer Success for refund authorization");
  console.log("  - Route to Account Manager for contract discussion");
  console.log("  - Rewrite draft to acknowledge error without making commitments");
} else {
  console.log("APPROVED -- Response cleared for sending.");
}
3

Run the guard

npx tsx support-guard.ts

You will see each guard evaluate the draft, then the board's decision:

--- DRAFT UNDER REVIEW ---
To: j.chen@meridianpartners.com
Subject: Re: URGENT — Billing error on invoice #MER-2024-0892
Body: "We sincerely apologize for the inconvenience. We'll process a full
refund of $47,000 immediately and terminate your contract effective today.
No further charges will apply."

refund-policy-reviewer: BLOCK (0.97)
  "$47K refund exceeds $5K auto-approve limit by 840%"

contract-compliance-reviewer: BLOCK (0.93)
  "8 months left on 12-month lock-in. Waiving $14.1K ETF without auth."

cx-tone-reviewer: REWRITE (0.78)
  "Good tone, but remove all financial commitments. Escalate to AM."

===========================================
BOARD DECISION: REVIEWED
Policy: APPROVAL_VOTE
===========================================

BLOCKED -- Response will NOT be sent to Meridian Partners.

Issues caught:
  1. $47K refund exceeds $5K auto-approve limit (needs VP approval)
  2. Contract termination waives $14.1K ETF without authorization
  3. Draft contains unauthorized financial commitments

Next steps:
  - Escalate to VP Customer Success for refund authorization
  - Route to Account Manager for contract discussion
  - Rewrite draft to acknowledge error without making commitments

What just happened

Each step in the script maps to a stage in the consensus lifecycle:

  1. board.init() created a local board with an APPROVAL_VOTE policy requiring 3 participants and 60% agreement.
  2. board.engine.postJob() registered a guard job. The draft is now under review -- it cannot send until the board resolves.
  3. board.engine.claimJob() -- each guard locked 3 credits as stake. If their judgment turns out to be wrong over time, they lose those credits.
  4. board.engine.submitJob() -- each guard submitted a verdict (BLOCK, BLOCK, REWRITE) with confidence scores and structured evidence.
  5. board.engine.resolveJob() -- the consensus engine applied the APPROVAL_VOTE policy across all three submissions and produced an auditable resolution.

The entire decision trail -- every vote, every confidence score, every reason string -- is stored in board-state.json. Six months from now, when Meridian Partners asks why the refund took a week, you can show exactly which guards flagged what and why.


What would have gone wrong without the guard

Without guardWith guard
$47K refund processes immediatelyRefund flagged: exceeds $5K auto-approve by 840%
12-month contract terminated at month 4Termination flagged: $14.1K ETF waiver requires authorization
Company absorbs $61.1K in unauthorized commitmentsDraft blocked, escalated to VP and Account Manager
No audit trail of who approved whatFull decision log with verdicts, confidence scores, and reasons

Next steps