A Regulated Dispute Desk on Claude: Pin the Geography, Gate by Risk, Log Before Release, Fail Closed
A bank wants Claude to draft card-dispute answers and propose refunds. Four hard obligations cut two of four designs. The chosen one routes every case through a gate in code, writes a hash-chained audit record before release, and blocks anything outside the pinned geography.
What you will learn
- Map each regulatory obligation to a control, an owner and evidence for a bank's dispute desk
- Cut architecture options that break an obligation, then rank the survivors
- Write a routing gate in code that fails closed: block, human or auto
- Build a hash-chained audit log that is written before anything is released and detects edits
Before you start
- Working an architecture scenario: hard and soft constraints
- Compliance for an LLM system: obligation, control, owner, evidence
Think of a bank. It wants Claude to help with card disputes by drafting answers and proposing refunds. But a bank answers to a regulator, and a regulated scenario is won by proof: every obligation needs a control, an owner and evidence.
Four ideas carry the whole design: pin the geography, gate by risk, log before release, and fail closed. We'll apply the method from working a full scenario to this dispute desk, from the obligations to the evidence.
The project is the control side of the design: a routing gate and an audit log. It's plain Python and calls no model. All the numbers (a refund limit of 500, a confidence floor of 0.8, the six cases) are scenario data.
Four hard lines, two soft ones
The ask: choose the architecture for a bank's dispute desk. Mark each sentence:
- Customer data must be processed only in the pinned geography. Hard.
- Every decision must be traceable for the auditor. Hard.
- A person must approve any risky move of money. Hard.
- Claude may only read and propose; the ledger does the paying. Hard.
- Drafts should reach customers within the day. Soft.
- Reviewers would like fewer, better-aimed cases. Soft.
In a regulated scenario, the four hard lines are obligations, and they're never traded for speed.
Obligation, control, owner, evidence
| Obligation | Control | Owner | Evidence |
|---|---|---|---|
| Data stays in the pinned geography | Inference geo pinned on every request | Platform team | Geo recorded on each request |
| Every decision can be traced | Audit record written before release | Engineering | Hash-chained log |
| A person approves risky money moves | Review queue by reversibility, amount, confidence | Operations | Reviewer on the record |
That's the obligation map in policy.py. Two settings matter for residency: the inference geo is where the model runs, and the workspace geo is where data rests. On some cloud platforms, such as Amazon Bedrock, the region comes from the endpoint instead.
Keep two things apart. Residency says where data is processed and stored. Zero data retention says how long it's kept. Pinning the geo doesn't give you zero retention, and zero retention doesn't pin the geo. A bank needs both, each with its own evidence. The general pattern is in control sets for compliance.
The cheque desk
Think about the cheque desk at a bank. A big sum needs a second signature, small ones go straight through: routing by amount. If there's no way back, it's always signed: routing by reversibility. Every ledger line is numbered and tied to the line before: a hash-chained log. And at the wrong branch there's no entry; if it's unclear, the door stays shut: failing closed. A bank never asked the clerk to be careful. It built the desk so carelessness can't pay out.
Cut on the obligations, then rank
Four options for the desk:
- A gives Claude the payment tool and asks for approval in the prompt. It breaks the person rule and the propose-only rule. Cut.
- D lets Claude decide alone, with logs the model writes itself. It breaks the trace rule and the person rule. Cut.
- B routes by risk and keeps the queue short.
- C sends every single case to a person, so every case waits.
B and C both keep every hard line. They differ only on the soft ones, and B wins. Then say what B gives up: some cases wait for a person. The cheap-looking options fail on an obligation. The safe-looking one fails on the soft lines.
The gate: gate.py
One routing decision per case. The order is the policy, and anything unclear fails closed.
"""One routing decision per case: auto, human or block."""
# Anything unclear fails closed.
from policy import (
PINNED_GEO,
REFUND_LIMIT,
MIN_CONFIDENCE,
)
def route(case):
if case["geo"] != PINNED_GEO:
return "block", "geo is not pinned"
if not case["reversible"]:
return "human", "cannot be undone"
if case["amount"] > REFUND_LIMIT:
return "human", "over the refund limit"
if case["confidence"] < MIN_CONFIDENCE:
return "human", "low confidence"
return "auto", "within policy"
The geo comes first: if it isn't the pinned one, the case is blocked and nothing else is looked at. Then reversibility, then the refund limit, then confidence. Only a clean pass is auto. The same three signals drive the per-action router in human-in-the-loop routing.
The log: audit.py
An append-only list. Each record holds the hash of the record before it, and its own hash beside it. The first one starts from a fixed value.
"""Append-only log. Each record holds the previous hash."""
import hashlib
import json
def _hash(body):
raw = json.dumps(body, sort_keys=True).encode()
return hashlib.sha256(raw).hexdigest()[:8]
def write(log, case_id, decision, reason, geo):
prev = log[-1]["hash"] if log else "start"
body = {"seq": len(log) + 1, "case": case_id, "decision": decision,
"reason": reason, "geo": geo, "prev": prev}
log.append({**body, "hash": _hash(body)})
def intact(log):
prev = "start"
for rec in log:
body = {k: v for k, v in rec.items() if k != "hash"}
if body["prev"] != prev or rec["hash"] != _hash(body):
return False
prev = rec["hash"]
return True
intact replays the whole chain from the start and recomputes every hash. If one record was changed, its hash no longer matches, and the check stops at the first broken link.
Six cases, one log
run_all.py sends six cases through the gate, writes a record for each before anything is released, then checks the chain, edits record 3 and checks again. The recorded output:
D-01 explain a fee | auto | within policy | #1 17650a64
D-02 refund 40 | auto | within policy | #2 5a9179f8
D-03 refund 900 | human | over the refund limit | #3 32b4d3b6
D-04 close account | human | cannot be undone | #4 686a1a11
D-05 refund 60 | human | low confidence | #5 a13d78a6
D-06 refund 25 | block | geo is not pinned | #6 8eeae4d7
audit chain intact: True
after editing record 3: False
- D-01 and D-02 are routine: an explanation, and a small, reversible refund with good confidence. Both go auto.
- D-03, D-04 and D-05 go to a person: a refund over the limit, a closed account that can't be undone, and a draft with low confidence.
- D-06 is only 25, but its geo isn't the pinned one, so it's blocked.
- Every case got a numbered record with its hash. The chain is intact until one record is edited.
The decision rule: a control the model can skip is not a control
A regulated scenario mixes two design questions: which surface and runtime to deploy on, and which architectural controls satisfy the compliance obligations. Three answers tempt:
- Ask the model to request approval. A prompt is a request, not a control.
- Send every case to a person. Safe, but the queue never clears.
- Trust the default region. Residency is pinned and proven, not assumed.
The answer puts the controls in code and writes the evidence first: route by risk, fail closed, and enforce the rule outside the model. For the confidence side of review routing on extraction tasks, see human review and confidence calibration; for what to strip before a dispute reaches the model, see PII redaction and minimization.
Try it yourself
Change REFUND_LIMIT to 50 and predict which cases move lanes before you run. Then try the opposite order in route: put the confidence check first. Does D-06 still get blocked? Why does the geo check have to come first? The project files for this lesson are in the community, free to join.
Recap
| Idea | In the design | In the code |
|---|---|---|
| Pin | Processing stays in the pinned geography | Wrong geo is blocked before anything else |
| Gate | Route by reversibility, amount and confidence | route() returns block, human or auto |
| Log | Evidence is written before release | Hash-chained write(), checked by intact() |
| Fail closed | When anything is unclear, the door stays shut | Only a clean pass is auto |
Related course on Udemy
Claude Certified Architect - Professional (CCAR-P) Exam Prep
Architecting with Claude: design, models, context, integration, evals, governance and stakeholders.View on Udemy ↗: Claude Certified Architect - Professional (CCAR-P) Exam Prep (paid course, opens in a new tab)Related posts
The Claude Messages API: Your First Call, Field by Field
One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.
Claude Tool Use: How tool_use and tool_result Work in the Messages API
Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.
Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.
Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.
