Regulated-industry AI system
A full end-to-end walkthrough of an AI system shipped into a regulated industry — a lending decisioning assistant at a bank — where the system must be auditable, explainable, and human-overseen by law. Requirements → constraints → architecture → guardrails → approval gates → audit trail → monitoring → rollout, one defensible decision at a time. Engineering-leadership framing only; nothing here is legal or financial advice.
Learning objectives
- Translate a regulated-industry brief into hard requirements: auditability, explainability, human oversight, data-residency, and record-keeping.
- Map public compliance frameworks (EU AI Act, GDPR, PCI-DSS, SOC 2) onto concrete engineering controls — without treating a lesson as legal advice.
- Design the request path so no consequential decision is issued without a logged human approval gate.
- Build a tamper-evident, PII-minimized audit trail that reconstructs any decision months later.
- Gate deploys on an eval suite that measures fairness/consistency, not just accuracy, and monitor for drift in production.
- Enumerate the failure modes of a regulated AI system and map each to a named, in-architecture control.
Meet "Meridian Bank" — a representative composite. Meridian wants an AI assistant that helps loan officers decide consumer-credit applications faster: it reads the application and the supporting documents, retrieves the relevant policy, and drafts a recommendation with a rationale. The catch is the whole reason this is a case study: in a regulated setting the assistant is not allowed to be a black box. A declined applicant may be entitled to an explanation; a regulator may ask you to reconstruct why a decision was made; and a human — not the model — must own the outcome. Every design choice below is dominated by three forces a consumer chatbot never feels: you must be able to explain it, you must be able to audit it, and a human must stay accountable for it.
1 · Requirements & the constraints that veto architectures
Design starts with the non-functional constraints, because in a regulated industry they veto architectures before a feature is even discussed. Write them down first. Most never appear as a user-facing feature, yet each one can kill an otherwise-elegant design.
| Requirement | What it means here | Why it dominates design |
|---|---|---|
| Explainability | A declined applicant / reviewer can be given the reasons behind a recommendation. | The system must emit a structured, human-readable rationale tied to policy — not just a score. |
| Auditability | Any past decision can be reconstructed: inputs, model version, policy version, who approved. | Forces an immutable, versioned audit trail as a first-class component, not a log afterthought. |
| Human oversight | A qualified human owns every consequential decision; the AI recommends, never decides. | An approval gate is mandatory and must be un-bypassable in code. |
| Data protection | Personal data is minimized, access-controlled, and retained only as long as lawful. | Shapes redaction, storage, and retention across every stage (GDPR/DPDP-style duties). |
| Payment-data handling | Cardholder/account data is scoped and protected where in play. | PCI-DSS-style scoping can wall off parts of the system from the model entirely. |
| Change control | Model, prompt, and policy changes are reviewed, tested, and traceable. | SOC 2-style controls push evals and approvals into CI, not into a person's judgment. |
2 · Architecture — the decision path end to end
Every application flows through the same guarded pipeline. Read it left to right: nothing reaches the model until personal data is minimized, nothing becomes a decision until a human approves it, and nothing happens without an immutable audit record. The approval gate and the audit trail are load-bearing walls, not add-ons.
3 · Grounding, explainability & the output contract
The assistant is only useful if a human can trust and check it, so it is built as a librarian, not an oracle. Every recommendation must be grounded in the retrieved, versioned policy and must carry a structured rationale: the factors, the policy clauses cited, and an explicit confidence. An answer with no policy support is not a low-confidence answer — it is a refusal that routes to a human.
The output contract every recommendation must satisfy
- Decision field is a recommendation only (
recommend_approve/recommend_decline/refer) — never a finalapprove/decline. - Rationale lists the factors that drove it, each tied to a cited policy clause id from the retrieved set.
- Citations are verified in code to exist in the retrieved policy — a fabricated clause id fails closed to
refer. - Confidence is reported and, below a floor, forces
referregardless of the recommendation. - No protected-attribute reasoning: the rationale is checked for prohibited factors; any hit blocks the recommendation and escalates.
4 · The human approval gate & the audit trail
This is the section a regulator cares about most. Two components make the system defensible: an approval gate a human cannot bypass, and an audit trail that can reconstruct any decision long after the fact. The gate decides who is accountable; the trail proves what happened. The ordering below is the design: a recommendation is pending until a human acts, and the human's action is recorded as part of the immutable record.
| Audit field | Why it must be captured | PII posture |
|---|---|---|
| Application id + version | Ties the record to a specific, immutable snapshot of the inputs. | Reference, not raw PII |
| Model + prompt version | A decision is only reconstructable if you know exactly what produced it. | No PII |
| Policy version | Rules change; you must know which rules were in force at decision time. | No PII |
| Recommendation + rationale | The explanation given, exactly as generated and verified. | Minimized |
| Approver identity + action | Who accepted or overrode, and when — the human-oversight proof. | Actor id, access-controlled |
| Hash / seal | Tamper-evidence: any later change to the record is detectable. | No PII |
5 · Evaluation — fairness & consistency, not just accuracy
You cannot ship what you cannot measure, and in a regulated setting accuracy is not the metric that gets you sued. The eval suite must also measure consistency (does the system treat similar applications alike?) and screen for disparate treatment across representative cohorts — using synthetic, de-identified fixtures, and with a compliance/legal partner defining what "fair" means here. The gate blocks the deploy if any of these regress. This is SOC 2-style change control made concrete.
What the eval gate checks before any model/prompt/policy change ships
- Recommendation quality against a labeled golden set of representative applications.
- Citation validity = 100% — every cited policy clause exists in the retrieved set.
- Consistency — near-identical applications get near-identical recommendations (perturbation tests).
- Cohort screening — outcome rates compared across synthetic cohorts; a defined gap trips the gate for human review.
- Prohibited-factor screen — no rationale references a protected or disallowed attribute.
- The gate runs in CI on every change; a red result blocks the ship and names the failing case.
6 · Monitoring, drift & a staged rollout
A regulated system is not "done" at launch — the obligation to monitor is continuous. Two things move after ship: the data (applicant mix drifts) and the rules (policy and regulation change). Both can silently invalidate yesterday's approval. Roll out in stages so the human stays firmly in the loop while trust is earned, and monitor the signals that would tell you the system has drifted out of compliance long before an auditor does.
| Rollout stage | What the AI does | Where the human is |
|---|---|---|
| 1 · Shadow | Produces recommendations logged but never shown to applicants. | Officer decides unaided; recs compared offline. |
| 2 · Assist | Shows the recommendation + rationale to the officer. | Officer must actively accept or override each one. |
| 3 · Fast-path | Auto-prepares low-risk, high-confidence recs for quick human sign-off. | Human still signs; sampling audits the fast-path. |
| 4 · Steady state | Same, with continuous drift + fairness monitoring. | Human owns every decision; compliance reviews the trail. |
7 · Failure modes & the control that hardens each
The mark of a system "designed for compliance" is that every failure mode maps to a control that already exists in the architecture. If a row below points at something you'd have to bolt on later, that is where your next audit finding is hiding.
| Failure mode | What goes wrong | The control that hardens it |
|---|---|---|
| Black-box decision | No explanation for a declined applicant. | Structured, verified rationale contract (§3) |
| Unreconstructable decision | Can't show why a past decision was made. | Immutable, versioned audit trail (§4) |
| Rubber-stamping | Human 'approves' without real oversight. | Sampled audit of approvals; override-rate monitoring (§6) |
| Disparate treatment | System treats cohorts inconsistently. | Consistency + cohort screening gate in CI (§5) |
| Fabricated policy | Model cites a clause that doesn't exist. | Citation verified in code → fail closed to refer (§3) |
| Silent drift | Data/policy moves; recs quietly degrade. | Drift + fairness monitoring; staged rollout (§6) |
| PII sprawl | Personal data leaks into logs it shouldn't. | PII minimization before egress; reference-only audit (§2,§4) |
| Dimension | Meets bar | Above bar |
|---|---|---|
| Constraints first | Names explainability, auditability, oversight, data-protection up front. | Maps each to a public framework and a concrete control; re-verifies against current regulation. |
| Explainable output | Emits a rationale with citations. | Rationale is verified in code; fabricated citations and prohibited factors fail closed. |
| Human oversight | Has an approval step. | Approval gate is un-bypassable; the human's accept/override is itself audited. |
| Audit trail | Logs decisions. | Immutable, versioned, tamper-evident, and PII-minimized; reconstructs any decision months later. |
| Fairness-aware evals | Measures accuracy on a golden set. | Gates on consistency + cohort screening defined by compliance, in CI on every change. |
| Monitoring + rollout | Ships behind a flag. | Staged shadow→assist→steady-state; monitors override/refer/cohort drift, not just latency. |
Score each dimension Meets or Above. All six at least Meets = a regulated-industry design you could walk into a compliance review with. Any dimension you can't hit is where the next audit finding is hiding.
A stakeholder says: "the model is 96% accurate on our test set, so let it auto-approve the clear cases and skip the human on those." Why is that the wrong move in this system, and what do you do instead?
Show answer
During an audit you're asked to show why a specific applicant was declined 8 months ago. Which components make that answerable, and what is the failure if any one is missing?
Show answer
🪜 Practice ladder beginner → industry
Six graded exercises, easy to real-world. Try each before opening its solution.
Context: "Make the lending assistant compliant" is a wish, not a spec. Design begins when you turn the obligation into requirements you can actually check.
Your task: Write four measurable requirements for the assistant — one each for explainability, auditability, human oversight, and data protection — that a reviewer could verify.
Requirements:
- Explainability: every recommendation carries a structured rationale with cited policy clauses
- Auditability: any decision is reconstructable from a stored record (inputs version, model/prompt/policy version, approver)
- Human oversight: no decision issues without a logged human accept/override
- Data protection: personal data is minimized before egress and referenced, not copied, in the audit log
- Each must be testable — "is compliant" is not; "citation validity = 100% on the eval set" is
💡 Hint: Rewrite each fuzzy duty until it names a number or a decision you could check on a held-out set.
Show solution
- Explainability: every rec includes a rationale listing the factors, each tied to a policy clause id, and citation validity is 100% on the eval set (no fabricated clauses).
- Auditability: for any decision, a stored record yields application-version, model+prompt version, policy version, rationale, and approver id+action — reconstructable months later.
- Human oversight: the system emits recommendations only; a decision exists only after a logged human accept/override.
- Data protection: PII is minimized before any model call; the audit log stores references and versions, never raw applicant documents.
Each is testable, and the explainability + oversight bars are the two that shape the whole architecture (verified rationale + un-bypassable approval gate). Verify the exact obligations against current regulation.
Context: A leader has to translate a regulation into engineering work the team can build, without overclaiming legal certainty.
Your task: Take three public frameworks (EU AI Act, GDPR, PCI-DSS) and, for each, name one concrete control this system implements — and one thing you'd hand to legal rather than decide yourself.
Requirements:
- EU AI Act (high-risk use): a control for logging/record-keeping and one for human oversight
- GDPR/DPDP-style: a control for data minimization and retention
- PCI-DSS: how payment-card data is scoped out of the model path
- For each, state the boundary: what you build vs what compliance/legal must define or confirm
- Attribute each framework correctly and hedge drift-prone specifics with "verify against current regulation"
💡 Hint: The pattern is always: framework → duty in general terms → concrete control → the part you escalate to legal.
Show solution
| Framework (public) | Control this system builds | Hand to legal |
|---|---|---|
| EU AI Act (high-risk) | Immutable, versioned audit trail (record-keeping) + un-bypassable human approval gate (oversight). | Whether this exact use is classified high-risk, and the current obligations/timelines. |
| GDPR / DPDP-style | PII minimization before egress; reference-only audit log; retention limits on the raw store. | Lawful basis, retention periods, and data-subject rights handling. |
| PCI-DSS | Card/account data scoped into a separate store the model never sees; only non-cardholder references reach the prompt. | Scope boundaries and attestation requirements. |
You build the controls; legal defines the obligations. Attribute each framework correctly and verify against current regulation — classifications and timelines drift.
Context: A model's free-text "here's my reasoning" is plausible prose, not an audit artifact. The senior move is a structured rationale verified in code.
Your task: Specify the output contract for a recommendation so the explanation is structured, grounded, and screened — and show the checks that make a bad output fail closed.
Requirements:
- Recommendation is one of {recommend_approve, recommend_decline, refer} — never a final decision
- Rationale is a list of {factor, cited_clause_id}; every clause id is verified against the retrieved set
- A fabricated citation forces the output to
refer(fail closed), not a low-confidence approve - A prohibited/protected-factor screen runs in code; any hit blocks the rec and escalates
- Confidence below a floor also forces
referregardless of the recommendation
💡 Hint: Treat the model output as untrusted: verify citations, screen factors, and default to a human when any check fails.
Show solution
Output = {
recommendation: recommend_approve | recommend_decline | refer,
rationale: [ {factor, cited_clause_id}, ... ],
confidence: 0..1
}
verify(output):
for r in rationale:
if r.cited_clause_id not in retrieved_clause_ids: return refer # fabricated -> fail closed
if r.factor in PROHIBITED_FACTORS: escalate() # disparate-treatment guard
if confidence < FLOOR: return refer
return output
The rule: the model proposes; code disposes. Explainability is only defensible when the rationale is a verified, structured artifact — cited clauses checked against what was actually retrieved, prohibited factors screened, and any failure defaulting to a human. The free-text justification is a UI nicety, never the audit record.
Context: An auditor asks, months later, to reconstruct a single decision. The trail either answers instantly or it doesn't — there is no middle ground.
Your task: Design the audit record: what fields it must capture, how it stays tamper-evident, and how it stays PII-minimal while still being reconstructable.
Requirements:
- List the fields: input version, model+prompt version, policy version, rationale, approver id+action, timestamp
- Make it tamper-evident (e.g. per-record hash / seal) so any later edit is detectable
- Store references + versions, not copies of raw personal data; the raw store is access-controlled and retention-limited
- Explain what breaks if the policy version or the model/prompt version is missing
- Note that data-protection duties apply to the log itself — retention is not "keep everything forever"
💡 Hint: Design for the question "why did this decision happen?" answerable from the record alone, with minimal PII.
Show solution
| Field | Why it's required |
|---|---|
| Application version (ref) | Pins the exact inputs; a reference, not a copy of the docs. |
| Model + prompt version | Without it you cannot reproduce the recommendation. |
| Policy version | Rules change; you must know which were in force at decision time. |
| Verified rationale | The explanation as generated and code-verified. |
| Approver id + action | The human-oversight proof: who accepted/overrode, and when. |
| Hash / seal | Tamper-evidence — any later change to the record is detectable. |
Miss the policy version → you can't say which rules applied. Miss the model/prompt version → you can't reproduce the rec. Miss the approver → you can't prove a human owned it. Keep PII in an access-controlled, retention-limited store the record points to — the log itself is reference-only. Retention duties apply; verify against current regulation.
Context: "96% accurate" is not a release decision in a regulated system. The eval that protects you measures consistency and screens cohorts, and it runs in CI.
Your task: Design the eval gate that blocks a model/prompt/policy change: what's in the set, which metrics, and what trips a block — including the fairness signals a compliance partner defines.
Requirements:
- Golden set of representative (synthetic/de-identified) applications with labels
- Metrics: recommendation quality, citation validity (must be 100%), and abstain/refer recall
- Consistency: perturbation tests — near-identical applications must get near-identical recs
- Cohort screening: outcome rates across synthetic cohorts, with a compliance-defined gap tripping the gate
- State clearly that which cohorts and what tolerance are compliance/legal decisions, not engineering ones
- Run in CI on every change; a red result blocks and names the failing case
💡 Hint: Pick metrics that map to how this system harms someone, and treat citation validity and fairness as hard gates, not averages.
Show solution
| Piece | What it is |
|---|---|
| Eval set | Representative synthetic/de-identified applications with gold recommendations + "should refer" tags. |
| Quality | Recommendation accuracy vs gold; refer/abstain recall on cases that should punt to a human. |
| Citation | % of recs whose cited clauses all exist in the retrieved set — must be 100%. |
| Consistency | Perturbation tests: small, irrelevant changes must not flip the recommendation. |
| Cohort screening | Outcome-rate comparison across cohorts; a compliance-defined gap trips the gate. |
Block the deploy if citation validity < 100%, quality/refer-recall drops vs the prod baseline, consistency fails, or a cohort gap exceeds the defined tolerance. Which cohorts and what tolerance are compliance decisions — you make them gate-able. Run in CI on every change and verify the fairness definition against current regulation.
Context: The pilot works; now it must pass a compliance review and roll out to real loan officers without ever removing the human or breaking the audit trail. This is the tech-lead deliverable.
Your task: Lay out the end-to-end plan: the architecture, the controls mapped to frameworks, the eval gate, the staged rollout, and the monitoring — and the order you'd sequence them.
Requirements:
- Architecture: minimize → retrieve → recommend → human approval gate → decision → immutable audit
- Controls mapped: EU AI Act-style oversight/record-keeping, GDPR/DPDP-style minimization, PCI-DSS scoping, SOC 2-style change control — all verified with legal
- Eval gate in CI: quality + citation validity + consistency + cohort screening; red blocks the ship
- Rollout: shadow → assist → fast-path (human still signs) → steady state, human on every decision throughout
- Monitoring: override rate, refer rate, cohort outcome drift, citation validity in prod, policy-version coverage
- Sequence it and name the go/no-go gate for each stage; nothing advances without the compliance sign-off
💡 Hint: Lead with the controls that make oversight and audit structural; earn automation speed later via the fast-path, never by removing the human.
Show solution
- Architecture first, controls baked in. minimize → RAG over versioned policy → recommendation + verified rationale → un-bypassable human approval gate → decision + notice → immutable, sealed audit record. The gate and the trail are load-bearing, not add-ons.
- Map controls to public frameworks, with legal. Oversight + record-keeping (EU AI Act-style), PII minimization + retention (GDPR/DPDP-style), payment-data scoping (PCI-DSS), and change control (SOC 2-style evals-in-CI). Attribute each and verify against current regulation.
- Gate the ship in CI. Quality, citation validity (100%), consistency, and compliance-defined cohort screening; a red result blocks and names the case.
- Roll out in stages. Shadow (logged, unseen) → assist (human accepts/overrides each) → fast-path (human still signs low-risk high-confidence recs, sampled audit) → steady state. The human owns every decision at every stage.
- Monitor the compliance signals. Override rate, refer rate, cohort outcome drift, in-prod citation validity, policy-version coverage — a rising override rate is your earliest drift alarm.
Order & gates: make oversight + audit structural before anything else; only then earn speed via the fast-path. Each rollout stage has an explicit go/no-go, and nothing advances without the compliance sign-off. This is decision-support under regulation — never a system that decides on its own.
✓ Checkpoint — you can move on when you can…
- Turn a regulatory obligation into testable requirements for explainability, auditability, oversight, and data protection.
- Map EU AI Act / GDPR / PCI-DSS / SOC 2 (in general terms) onto concrete controls and know which parts to hand to legal.
- Explain why the approval gate must be un-bypassable and why the rationale must be verified in code.
- Design an immutable, PII-minimized audit trail that reconstructs a decision months later.
- Gate deploys on fairness/consistency, not just accuracy, and name the monitoring signals for drift.
- Map each failure mode to a named control already present in the architecture.