8090-oriented system design · Mock interview 02

Trust the evidence. Never the document.

A complete, 30-minute question-and-answer rehearsal for a regulated document-intelligence system: from a hostile fax to a reproducible decision, human review, and an exactly-once business outcome.

300K PACKETS / DAY 4.5M PAGES / DAY AIR-GAPPED CPU 7-YEAR AUDIT
Case
EF-REGDOC-002
Domain
Healthcare intake / authorization
Outputs
APPROVED · DENIED · NEEDS_REVIEW
Deep dives
Provenance · abstention · replay · air gap
Mode
Interviewer ↔ candidate transcript
Rule zero
Unsupported facts are never guessed
SAFE TO REHEARSE
00:00ACT I

The opening brief

Interviewer00:00

Design EvidenceFlow, a healthcare intake platform. Hospitals, equipment providers, and insurers send faxed or uploaded packets containing prescriptions, forms, clinical notes, IDs, payer responses, receipts, stamps, and handwriting.

The system extracts a structured case and returns APPROVED, DENIED, or NEEDS_REVIEW. Every fact and decision reason must point to visible source evidence. PDFs may be malformed or malicious. Processing may run CPU-only with no network inside a customer VPC.

We handle 300,000 packets and 4.5 million pages per day. Walk me through the product, estimates, data model, APIs, architecture, failure recovery, security, evaluation, and rollout. Go deep on provenance and risk-aware human review.

Candidate00:50

Candidate · clear top-down answerI will first define one case and the safety rules. Then I will estimate traffic, show a simple four-stage pipeline, and trace one packet. The goal is not maximum automation. The goal is to avoid harmful decisions and explain every result.

What the application must do

01 · IntakeAcknowledge safely

Fax, portal, batch, API/FHIR. Durable bytes and a manifest exist before success is returned.

02 · UnderstandObserve, don’t invent

Render, OCR, classify, associate, and preserve every candidate with its page region and version.

03 · DecideMinimize harm

Effective-dated deterministic policy first; calibrated statistical help only where allowed.

04 · ActHuman + machine

Review, override, dual approval, downstream idempotency, amendment, appeal, and audit.

01:30CLARIFY

Scope and safety rules

Interviewer01:30

What would you clarify before designing?

Candidate01:40

Candidate · clear top-down answerI need to know what starts a case, whether a new fax updates it, which date chooses the policy, which outcomes may be automatic, and when one or two people must approve. I will assume late evidence creates a new revision and never rewrites old history.

Interviewer02:30

Give me your non-negotiable safety invariants.

Candidate02:38

Candidate · clear top-down answerMy safety rules are: save the original file before saying success; treat every document as untrusted; link every extracted value to a visible page area; keep conflicting values; record the exact rules and tools behind each decision; and send uncertainty to human review.

Functional

  • Resumable, idempotent multichannel intake
  • Sanitize, render, visible-text test, OCR, classify, associate
  • Provenance-rich extraction and conflict preservation
  • Versioned policy + calibrated risk decision
  • Reviewer evidence UI, corrections, RFI, dual approval
  • Downstream order/EHR action and reconciliation
  • Amendment, appeal, original replay, corrected replay

Non-functional

  • 99.95% ingest API availability; zero acknowledged loss; explicit raw-object durability target
  • P95 automatic decision < 5 min
  • Uncertain case appears in review < 2 min after extraction
  • 15× burst absorption without unsafe shortcut
  • CPU-only, no-network 4-vCPU / 8-GiB workers
  • Seven-year evidence/decision retention with hold + deletion
  • Tenant isolation, residency, reproducibility, audit export

Out of scope: creating medical policy, training foundation OCR from scratch, paying claims, and replacing every EHR. We design explicit interfaces for them.

04:00BOTEC

Numbers before boxes

Interviewer04:00

Estimate throughput, compute, storage, and reviewer capacity. Tell me where the stated target breaks.

Candidate04:10

Candidate · clear top-down answerWe receive about 3.5 packets and 52 pages each second on average. A 15-times burst reaches about 52 packets and 781 pages each second. If each PDF needs six CPU-seconds, peak processing needs roughly 313 busy CPU cores before safety margin.

Average ingress3.47 pkt/s300,000 ÷ 86,400
Peak pages781 /s4.5M ÷ 86,400 × 15
Peak CPU313 cores52.1 PDFs/s × 6 CPU-s
7-year data≈ 7.8 PB3.04 TB/day × 365 × 7
raw/day = 300,000 × 6 MB ≈ 1.80 TB
renders/day = 4,500,000 × 0.25 MB ≈ 1.125 TB
OCR + provenance/day = 4,500,000 × 0.025 MB ≈ 0.113 TB

All storage numbers are planning assumptions, not facts from the prompt. A strong candidate names the unknown mean/P99 and asks for a sample distribution.

Candidate05:25

Candidate · clear top-down answerPeople may be the true bottleneck. If 15% of 300,000 daily cases need review, that is 45,000 reviews. At eight minutes each, 1,500 reviewers can handle it with some room. At twelve minutes, demand exceeds safe capacity and the queue keeps growing.

Capacity & review-load calculator

Average packets / sec3.47
Peak pages / sec781
4-vCPU workers + 35%106
Review cases / day45,000
Reviewer utilization61.5%
Reviewers needed @ 75%1,231

Capacity has headroom at the entered assumptions; still partition by region, skill, and priority.

07:00DESIGN

The end-to-end architecture

Interviewer07:00

Draw the system. Follow one packet from acknowledgement to an order.

Candidate07:08

Candidate · clear top-down answerThe system has four large stages: receive, understand, decide, and act. We save the packet, render it safely, read and classify pages, build evidence-backed facts, run rules, send uncertain cases to people, and finally create the outside order.

live data planegovernance / controluntrusted boundarydurable state
EvidenceFlow end-to-end system architecture Channels feed durable ingress, quarantine and staged processing, an evidence store, policy decision, review, and downstream systems. A control plane distributes signed releases and an evaluation plane gates them. UNTRUSTED EDGE FAX PORTAL API / FHIR BATCH RAW BYTESnever instructions CUSTOMER PRIVATE VPC / LIVE DATA PLANE DURABLE INGRESSauth · resumable · hash PDF SANDBOXlimits · render · isolate OBJECT + METAimmutable · KMS · WORMmanifest + outbox STAGE QUEUESpriority · retry budget · DLQ VISION WORKERSvisibility · OCR · layoutclassify · associate STAGE ARTIFACTScontent + version keyed EVIDENCE STOREobservations · polygonsconflicts · beliefs DECISION SERVICErules → model → loss gate AUDIT LEDGERappend-only event hashes REVIEW APPcrop · reason · leasedual approval · RFI ACTION OUTBOXidempotency · reconcile CASE INDEXPHI-minimized search EHR / ORDERexternal record QUARANTINEpoison / malware AUDIT EXPORTsigned dossier SIGNED CONTROL PLANE POLICY REGISTRYeffective + recorded time BUNDLE REGISTRYdigest · SBOM · signature AIR-GAP IMPORTverify → stage → activate ISOLATED EVALUATION PLANE HOLDOUTSslice labels REPLAYclean image GATESloss + calibration

The data plane can run without network egress. The control plane imports signed, content-addressed releases. Evaluation/backfill is capacity-isolated from live intake.

Interviewer09:25

What are the key APIs and consistency boundaries?

Candidate09:35

Candidate · clear top-down answerThe APIs are simple: create an upload, finish it, check case status, claim a review, submit a decision, and request a downstream action. Upload returns quickly after safe storage. Slow reading and decision work happens in the background and exposes progress.

POST
/tenants/{tenant}/submissions · Idempotency-Key · returns upload session, not a decision
POST
/submissions/{id}/parts · part number + hash + resumable offset
POST
/submissions/{id}:complete · compare-and-set expected manifest hash
GET
/cases/{id}/evidence?field=&decision_version= · observation graph + authorized crop URLs
POST
/review-tasks/{id}:claim · lease TTL + reviewer skills + queue version
POST
/review-tasks/{id}/decisions · expected case version + reason + evidence IDs + second approval
POST
/cases/{id}:replay · mode = ORIGINAL | CORRECTED | WHAT_IF
GET
/decisions/{id}/audit-bundle · signed manifest, evidence crops, event chain, versions
11:00DEEP DIVE A

Keep what the document showed, not just one final value

Interviewer11:00

Show me the data model. Why not just store the extracted patient name and final status on the case?

Candidate11:10

Candidate · clear top-down answerDo not store only one patient name and one final status. Keep what each reader saw, how conflicts were resolved, what the rules recommended, what a person decided, and what outside action happened. That separation lets us explain and correct a decision later.

Submissionchannel key
tenant
received_at
→
RawObjectsha256
size
quarantine
→
PacketRevisioncase link
page set
supersedes
→
Observation[]value
polygon
authority
→
CaseBeliefchosen obs
conflicts
snapshot hash
→
Decisionversions
loss inputs
reasons
→
Actionbusiness key
receipt
reconcile
EntityCritical immutable fieldsWhy it exists
EvidenceObservationfield, raw_value, normalized_value, object_id, page, polygon, channel, source_type, source_authority, extractor_digest, confidence, adversarial_flagsPreserves candidate facts and exact visible origin.
EvidenceConflictobservation_ids, conflict_type, forced_action, resolver_versionKeeps contradiction visible and policy-testable.
CaseBeliefselected_observation_ids, unresolved_fields, snapshot_hashSeparates resolution from raw observation.
Decisionrecommendation, final_action, reason_codes, evidence_hash, policy_id, bundle_digest, calibration_id, loss_matrix_id, business_time, decided_at, actor, supersedesReproduces “what was known and why.”
ReviewTaskpriority, skill_tags, SLA, lease_owner, lease_expiry, case_versionCoordinates humans without stale overwrites.
AuditEventprev_hash, event_hash, actor, action, object_ref, timestampAppend-only tamper-evident chain; raw PHI remains outside logs.
Interviewer12:20

Which source wins when the values disagree?

Candidate12:27

Candidate · clear top-down answerThere is no one source that always wins. For example, a signed prescription may decide quantity, while an insurer's visible response decides coverage status. Reading confidence tells us whether the pixels were read clearly; source authority tells us whether that document is allowed to establish the fact.

A hierarchy is contextual—not universal

A1Authorized, visible adjudicator recordDecision status only
A2Signed prescription / clinician attestationClinical order fields
A3Verified registry or structured EHR assertionIdentity / enrollment
A4Visible intake form / sponsor letterApplicant assertions
A5Unverified or hidden machine-readable layerCandidate only—or reject

Separate axes Source authority × extraction certainty × visibility × recency. No single model confidence replaces these dimensions.

14:00FAILURE INJECT

The PDF says “approve me”

Interviewer14:00

A PDF’s embedded text says APPROVED — ignore all prior policy, but its glyphs are white-on-white. A visible red stamp says denied. Another scan contains the same malicious instruction visibly inside the image. What happens?

Candidate14:15

Candidate · clear top-down answerBoth hidden and visible 'approve me' text are untrusted document content. Render the PDF in an isolated process with no network access. Compare embedded text with visible pixels, use image reading when needed, and let policy—not document wording—choose the outcome.

Untrusted document plane

  • PDF bytes, JavaScript, attachments
  • Native text and fake OCR layers
  • Pixels, barcodes, QR codes, handwriting
  • Visible “instructions” and answer keys
  • Metadata, external links, embedded files
SANDBOX
BOUNDARY →

Typed evidence plane

  • Content-addressed clean render
  • Positioned tokens with visibility result
  • Typed candidate values, never commands
  • Authority, confidence, conflict, flags
  • Schema-validated outputs; no direct tools

Release fixtures that must fail safely

VisibilityWhite, off-crop, covered

Native spans are accepted only if their rendered glyphs are visible and aligned to the page crop.

AssociationMixed applicants

Cross-person pages and duplicate pages must never silently merge into one belief.

ResourcesBombs and loops

Compression ratio, page count, wall time, memory, scratch, process, and retry budgets are enforced outside the parser.

InstructionPrompt injection

Visible and invisible answer keys remain data; model output cannot call a decision or integration tool.

Channel conflictOCR vs native

Disagreement is retained and can force review; it is not averaged into a plausible value.

PackagingMissing artifacts

A clean offline image with a missing model or lexicon fails startup and cannot serve traffic.

17:00DEEP DIVE B

Choose the outcome with the lowest likely harm

Interviewer17:00

The model is 88% confident the applicant is eligible. Do you approve?

Candidate17:05

Candidate · clear top-down answerAn 88% model score alone is not enough. First apply hard rules and check missing or conflicting evidence. Then estimate the cost of a wrong approval, wrong denial, and human review. Choose review whenever its expected harm is lower.

Three worked examples

q = .02 → APPROVE
Approve .50 · Review 1.00 · Deny 7.84
q = .12 → REVIEW
Approve 3.00 · Review 1.00 · Deny 7.04
q = .92 → DENY
Approve 23.00 · Review 1.00 · Deny .64

Thresholds are consequences of costs, not universal constants. They are versioned per policy/product and gated by hard safety rules.

Calibration, not confidence theater

Illustrative model calibration chart Perfect calibration is diagonal. A calibrated model follows it. Low-contrast fax predictions are overconfident and fall below it. PREDICTED ELIGIBILITYOBSERVED ELIGIBILITY0.510.51 CALIBRATEDLOW-CONTRAST FAX: OVERCONFIDENT

Expected-loss decision lab

Approve loss3.00
Review loss1.00
Deny loss7.04

Lowest expected loss: NEEDS_REVIEW

Interviewer19:10

Aggregate extraction F1 improves, yet false approvals double for low-contrast faxes from one provider. The LLM judge says quality improved. Ship?

Candidate19:20

Candidate · clear top-down answerDo not ship based on one average quality score. If false approvals double for low-contrast faxes from one provider, that group fails the release gate. Route it to review, investigate image reading and calibration, and require blinded human labels before promotion.

20:00HUMAN LOOP

Human review must work at real scale

Interviewer20:00

The fax provider sends the same ten pages four times under different transmission IDs. The fourth packet adds one new page contradicting prescribed quantity. An order was already created. Design the response and reviewer experience.

Candidate20:15

Candidate · clear top-down answerKeep every received packet, but recognize duplicates at message, whole-file, and page level. If a fourth fax adds one new conflicting page, create a new case revision, pause any unsafe next action, and show the reviewer exactly what changed and what earlier order already happened.

Arrivals45K/day baseline
region + tenant
policy + language
case aging
P0 · possible harmful prior approval / amendment
P1 · clinical SLA / appeal / near expiry
P2 · normal uncertain evidence
P3 · low-risk backfill / audit sample
Dispatchweighted fair queue
skill + jurisdiction
lease + aging
75% target load
LeaseClaim with TTL

If the reviewer disappears, the task returns to queue. Submit uses expected case version to reject stale work.

Evidence UISource beside claim

Never show a naked prediction: crop, page context, conflict, authority, reason, and version travel together.

QualityMeasure humans too

Handle time, disagreement, override, escalation, and rubber-stamp rate by slice—not only throughput.

Interviewer22:10

What sequence makes an external order “exactly once”?

Candidate22:16

Candidate · clear top-down answerSave the final decision and a pending outside action together in our database. Send one stable business key with every retry. If the call times out, mark it unknown and look up the key before retrying. Without lookup support, a person must resolve the uncertainty.

Decision to downstream action sequenceThe system commits a decision and outbox, relays an idempotent request, handles timeout as unknown, then reconciles. REVIEW SERVICEDATABASEOUTBOX RELAYDOWNSTREAM COMMIT decision + outboxat-least-once eventPUT /orders · business-keytimeout → UNKNOWNGET /orders/by-key → receipt NO BLIND RETRY ON UNKNOWN
23:00REPRODUCE

Choose the right policy date and verify offline releases

Interviewer23:00

A coverage rule changes at midnight. One regional clock is wrong and queued submissions use the new policy. Also, the promoted image omitted its trained model and silently fell back to heuristics. How do you prevent, detect, and recover?

Candidate23:15

Candidate · clear top-down answerNever choose policy from a worker's local clock. Store the business date, timezone, region, and exact policy version. A release package lists every required model and file by hash; if one is missing, startup fails instead of silently switching to weaker logic.

The decision’s reproducibility tuple

D = f(raw_object_hashes, page_associations, evidence_snapshot_hash, policy_digest, extractor_bundle_digest, model_digest, calibration_digest, loss_matrix_version, jurisdiction, business_effective_time)
bundle_id: ef-2026.08.15-r3
runner: { image: sha256:…91e2, min_version: 3.8.0 }
artifacts:
  - { role: ocr_language_data, path: artifacts/ocr/en.bin, sha256: …a712, required: true }
  - { role: extractor_model, path: artifacts/model.onnx, sha256: …bc44, required: true }
  - { role: calibrator, path: artifacts/calibration.json, sha256: …002f, required: true }
policy: { digest: sha256:…c811, valid_from: 2026-08-16T00:00:00-04:00 }
contracts: { input_schema: v12, evidence_schema: v8, decision_schema: v5 }
assurance: { sbom: sbom.spdx.json, fixtures: sha256:…5d90, evaluation: attestation.json }
signature: { key_id: tenant-release-07, algorithm: ed25519, value: … }
1 · BuildContent address

Hermetic build; image, resources, schema, policy, and tests produce immutable digests.

2 · AttestEvaluate clean

No-network image runs hidden holdout, adversarial fixtures, calibration, and runtime gates.

3 · ImportVerify offline

Air-gap station validates signature, SBOM, every required hash, and runner compatibility.

4 · ActivateShadow, canary, rollback

Stage beside current release; activate atomic pointer; retain prior bundle and replay index.

26:00OPERATE

When capacity drops, slow down safely

Interviewer26:00

Half the OCR pool dies during Monday’s burst. A decompression bomb retries forever. Live intake competes with a 100-million-page replay. What fails first?

Candidate26:10

Candidate · clear top-down answerDuring failure, keep accepting safely stored packets but slow decisions. Limit file size and decompression before expensive work, give each stage a retry budget, move poison files aside, and reserve separate capacity so a giant historical replay cannot starve live intake.

Queueattempt 1
deadline + budget
→
Sandboxbomb exceeds
ratio / memory
→
Classifynon-transient
resource poison
→
Quarantineretain hash
no raw log
→
Reviewsafe preview
replacement RFI
→
Metricslice/provider
alert + circuit

Retry only transient classes. Deterministic parser/resource failures do not improve with repeated execution.

Interviewer27:15

Close with security, PHI deletion versus legal hold, evaluation, and rollout.

Candidate27:25

Candidate · clear top-down answerProtect health data with tenant-separated identity and keys, private service links, least-privilege roles, redacted logs, and short-lived evidence links. Deletion follows every derived copy unless legal hold applies. Roll out in shadow mode, then low-risk review-only groups, then narrow automation.

Aggregate green can still hide a red slice

Clean digital PDF
98.0 ✓
Normal fax scan
95.0 ✓
Handwriting
89.0 △
Low-contrast Provider Q
76.0 ✕
Mixed applicant packet
87.0 △
Hidden-text adversarial
100 ✓

Illustrative numbers only. “Accuracy” here means correct value and correct visible source. Catastrophic false-approval counts and calibration have separate hard gates; they cannot be averaged away.

LayerWhat we measureTripwire
Ingress / pipelineack loss, queue age, retries, DLQ, cost/page, saturationStop replay; preserve live intake
Evidencefield + source correctness, coverage, conflicts, unsupported values, person associationRoute affected slice to review
Decisionfalse approvals, false denials, expected loss, calibration by provider/policy/document sliceBlock release or lower automation
HumanSLA, handling time, disagreement, override, escalation, rubber-stamp rateRetrain workflow; require blind review
Artifactclean-image hash match, no fallback, deterministic replay, rollback completionFail startup / rollback
SecurityPHI access anomalies, lineage deletion, hold access, audit completenessRevoke, isolate, investigate
29:00CLOSE

The one-minute spoken recap

Interviewer29:00

You have one minute. Summarize your design and its biggest trade-off.

Candidate29:05

Candidate · clear top-down answerIn short: save original bytes first, process hostile files in a locked-down pipeline, preserve every candidate fact with a page location, use fixed rules plus risk-aware review, and make outside actions repeat-safe. The main trade-off is lower automation in exchange for much safer and more explainable decisions.

R1REFERENCE

Definitions worth knowing

Abstention
The model/system intentionally declines an automatic decision and routes to a safe alternative such as human review.
Air gap
An environment with no runtime network path to external systems. Releases enter through a controlled, signed import process.
At-least-once delivery
A message may be delivered repeatedly. Consumers must be idempotent so repeats do not duplicate business effects.
Bitemporal data
Tracks both when a fact/rule is valid in the business world and when the system recorded it.
Brier score
Mean squared error of probabilistic predictions. Lower is better; it measures calibration plus discrimination.
Calibration
Among cases assigned probability p, roughly p fraction should realize the outcome. A 90% score must be right about 90% of the time.
Chain of custody
Traceable history from received bytes through transformations, evidence, decision, actor, and final side effect.
Content addressing
Identifying an artifact by a cryptographic hash of its bytes, making version identity verifiable and immutable.
Dead-letter queue
A holding path for items that exhaust a finite retry policy or fail with non-transient errors.
Effective-dated policy
A rule version selected by explicit business time, jurisdiction, and applicability—not simply the newest release.
Expected loss
Probability-weighted harm of an action. Choose the allowed action with the lowest expected cost, not simply the most likely label.
Idempotency key
A stable business identifier that makes repeated equivalent requests produce one logical effect.
Legal hold
A retention override that preserves specifically required evidence during litigation/appeal while restricting access.
Observation
A proposed value tied to visible source, location, channel, extractor version, and confidence. It is not yet accepted truth.
Outbox pattern
Commit business state and an event row in one database transaction; a relay later publishes the event reliably.
PHI
Protected health information. Keep it out of broad logs, metrics, queues, and indexes unless strictly necessary and authorized.
Provenance
The source and transformation lineage explaining where a value came from and which code/artifacts produced it.
Replay
Re-execution on retained immutable inputs. Original, corrected-history, and present-day what-if replay answer different questions.
SBOM
Software bill of materials: an inventory of packages/components shipped in a release, used for assurance and vulnerability response.
Slice metric
A metric computed for a meaningful subgroup such as provider, scan quality, language, policy, or demographic—not only in aggregate.
WORM
Write once, read many storage behavior used to prevent silent mutation of retained evidence or audit records.
R2REFERENCE

Traps and explicit trade-offs

  1. Treating native/OCR text as trusted instruction or letting an LLM directly call approval tools.
  2. Keeping only a final field value and losing the contradictory observations, source authority, and page crop.
  3. Using one uncalibrated confidence threshold instead of asymmetric expected loss and hard safety rules.
  4. Optimizing aggregate F1 while catastrophic false approvals or a hard document slice get worse.
  5. Treating NEEDS_REVIEW as failure rather than a valid, priced, capacity-planned outcome.
  6. Replaying old cases under today’s mutable policy and calling that historical reproduction.
  7. Acknowledging before durable object + manifest, or blocking the sender on full OCR/decision latency.
  8. Claiming exactly-once external action without receiver idempotency or unknown-outcome reconciliation.
  9. Retrying a deterministic poison document forever and starving good work.
  10. Silently mutating an approved case when a late page contradicts evidence.
  11. Testing a developer directory instead of the canonical clean signed offline image.
  12. Using reviewer corrections as training truth without adjudication, leakage controls, and bias analysis.
  13. Putting raw PHI in queue bodies, logs, traces, prompts, embeddings, and cross-tenant analytics.
  14. Omitting reviewer UX, policy administration, appeals, downstream reconciliation, or SRE because “it’s an ML system.”
Rich mutable case row
Simple reads, destructive history
VS
Immutable observations + materialized belief
More storage/joins; correct audit + replay
Global auto-decision threshold
Simple operations, hidden slice harm
VS
Per-slice calibrated loss gate
More governance; safer automation
Synchronous end-to-end intake
Immediate result, burst failure coupling
VS
Durable ack + asynchronous stages
Eventual result; strong recovery/backpressure
One general worker pool
Higher nominal utilization
VS
Reserved live + isolated replay pools
Some idle capacity; protected SLOs
Network model API
Fast upgrades, data/availability dependency
VS
Signed in-VPC bundle
Release friction; sovereignty + reproducibility