Actors
- Employee or upstream expense system
- Finance reviewer investigating mismatch
- Policy owner approving correction
- Migration engineer running differential tests
- Auditor replaying a decision
- Support operator handling appeal
BEHAVIOR LAB / MOCK 06
Reconstruct an opaque reimbursement engine from observed inputs and outputs, preserve money behavior, add effective-dated corrections, and cut over without a big-bang bet.
OPENING PROMPT
Read this once, then begin aloud. Spend the first two minutes establishing contract, actors, risk and what must remain authoritative.
Design ReimburseX, a replacement for a black-box reimbursement binary. The legacy interface accepts trip days, miles traveled and receipt amount and returns an exact monetary reimbursement. You have 30 million historical request/response pairs and temporary access to the legacy oracle, but no source code. The replacement must reproduce current behavior, support reviewed effective-dated corrections, shadow safely, explain divergences and cut over incrementally.
Separate behavior preservation from policy improvement. A golden-master corpus and differential harness certify compatibility; a versioned policy engine introduces deliberate corrections only through explicit, effective-dated change records.
REQUIREMENTS
These are supplied mock numbers for sizing and follow-ups. Say your assumptions before using them.
HIGH-LEVEL DESIGN
Name the authoritative state, derived projections, asynchronous boundaries and the exact point where a business decision becomes durable.
STORAGE + ACCESS
The table is logical, not a mandate for one database. Choose physical stores after access patterns, transactions, retention and rebuildability are clear.
| Entity | Primary / unique key | Important fields and purpose |
|---|---|---|
| InputCase |
(case_id)
|
days, miles, receipt_cents, observed_at, source, fingerprint |
| OracleObservation |
(case_id, oracle_version)
|
output_cents, called_at, environment, response_hash |
| GoldenExample |
(corpus_version, example_id)
|
case_id, stratum, boundary_tags, expected_cents |
| PolicyVersion |
(policy_id, version)
|
effective_from/to, rule_bundle_hash, state, approvers |
| Decision |
(tenant_id, request_id)
|
input_hash, policy_version, output_cents, explanation_hash, state |
| ShadowComparison |
(request_id, candidate_version)
|
legacy_cents, candidate_cents, delta, mismatch_class |
| Correction |
(correction_id)
|
rationale, affected_domain, effective_date, approvals, rollout_state |
| Appeal |
(appeal_id)
|
decision_id, claimant_reason, evidence, resolution, adjusted_decision_id |
POST /v1/reimbursements
Idempotency-Key + observed/effective date + three inputs
200 {decisionId,amountCents,policyVersion}GET /v1/decisions/{id}
Replay inputs, rule trace and hashes subject to role
200 {explanation}POST /v1/corpora/{id}/evaluate
Run candidate bundle against frozen golden set
202 {evaluationRun}GET /v1/comparisons?class=&delta=&cursor=
Mismatch workbench with sampled cases
200POST /v1/policies/{id}/versions
Create draft effective-dated rule bundle
201 {version}POST /v1/appeals
Reference original decision; never mutate it
201 {appealId}00:00 → 30:00
Answers are written in a speakable first-person style. Turn on Practice Mode to hide them, answer aloud, then reveal one at a time.
Candidate · clear top-down answerI would build two things. A compatibility engine matches what the old system does today. A policy engine handles intentional changes later. Keeping them separate lets us migrate safely without treating every old bug as a forever rule.
Why this mattersThis gives the interviewer a map before any boxes appear, and it makes the system's most important trust decision explicit.
Candidate · clear top-down answerThe API takes days, miles, receipt amount, and decision date. It must return the exact amount, validation result, policy version, and explanation. The same request ID must never create two payments. We need to learn how old cases were sampled before trusting the data.
Why this mattersA narrow first release keeps the design realistic. It also shows which tempting features can wait without weakening the core product.
Candidate · clear top-down answerTraffic is small, so servers are easy to size. Correctness is hard. A 99.99% target means at most one wrong result in 10,000, but observing zero errors in only 10,000 samples does not prove that target. A rough zero-failure confidence rule needs about 30,000 independent examples for a 0.01% upper error bound. Even then, random tests can miss rare money and date boundaries, so we need risk-based slices as well as a global number.
Why this mattersThe calculation is not about perfect forecasting. It identifies the part most likely to run out of capacity or delay users.
Candidate · clear top-down answerA golden master is a trusted set of inputs and old-system outputs. I would include common cases, rare cases, values near thresholds, date periods, and error cases. We keep both traffic-weighted samples and evenly spread boundary samples.
Why this mattersA random sample mostly proves common behavior. Boundary and risk slices make rare but expensive rules visible before the replacement handles money.
Candidate · clear top-down answerThe main records are normalized input, old-system observation, golden example, approved policy version, decision, comparison result, and appeal. Money is stored as integer cents. A decision points to the exact input and policy version. The API uses a request key so a retry returns the same decision; reusing that key with different input is an error rather than a second payment.
Why this mattersThe API follows the user journey and makes slow work visible. A client should never hold one request open for a long job.
Candidate · clear top-down answerA request is authenticated, normalized, and checked for a duplicate key. We choose the approved policy for the business date, run fixed rules, and save the decision, explanation, and pending payment message in one database transaction. A worker sends payment afterward. If the receiver times out, we look up the business key before retrying, because a timeout does not tell us whether money moved.
Why this mattersTracing one real request proves the boxes connect. It also exposes where we acknowledge success and where a retry may begin.
Candidate · clear top-down answerWe start with readable rule guesses, test them on cases that were not used to create the guess, and actively query examples that separate competing rules. Related-value tests check properties such as “more miles should not reduce payment” unless evidence proves an exception. I keep a private final test set so repeated tuning cannot slowly overfit the benchmark.
Why this mattersThe deep dive starts only after the basic path is clear. Use one concrete example, then state the speed-versus-correctness choice.
Candidate · clear top-down answerEach policy says when it applies. A correction is a new approved version with an impact report, not an edit to old history. If the business allows retroactive changes, we create adjustment decisions that point to the old decision.
Why this mattersBusiness date and decision time are different. New versions and explicit adjustments preserve what was paid, why it was paid, and what changed later.
Candidate · clear top-down answerThe request key maps to one normalized input. Reusing it with different input is an error. Saving the decision and its outgoing message together prevents a crash from losing payment work or creating a second logical payment.
Why this mattersUse immediate agreement only for decisions that cannot be ambiguous. Let rebuildable views catch up and always show their freshness.
Candidate · clear top-down answerIf the old system changes, we create a new observed era instead of mixing outputs. We freeze promotion, compare before and after on a carefully chosen panel, and ask owners whether the change was intentional or a regression.
Why this mattersA failure answer should name the uncertain state first. Then explain how the system learns the truth before it repeats an action.
Candidate · clear top-down answerFirst replay old cases. Then mirror live traffic while the old system remains the only payment authority. Next enable small stable user groups, compare every result and side effect, and expand only while slice-level money and error checks pass. One route switch sends a group back to the old system. We keep that rollback path until in-flight work is settled and the agreed retention window ends.
Why this mattersOnly one system may move money for a request. Shadowing compares safely; cohort cutover and one route switch make expansion and retreat controlled.
Candidate · clear top-down answerA high overall match can hide a bad group. If mismatches cluster around .49 and .99, stop rollout, test those endings closely, inspect rounding order, and use integer cents everywhere. Fix the rule and rerun both the boundary group and the full suite.
Why this mattersA global percentage can hide a systematic financial bug. Slice-level gates turn the suspicious endings into a release blocker instead of averaging them away.
Candidate · clear top-down answerSend only the needed numeric inputs into the rules engine and keep employee identity outside when possible. Encrypt each customer's records with separate keys, separate policy authors from approvers, restrict golden datasets, and log every policy change and export. Test files use masked or synthetic data, and support tools must not reveal receipts or identities to people without case-level permission.
Why this mattersSecurity belongs in keys, tokens, workers, and logs. It is not a single box added to the diagram at the end.
Candidate · clear top-down answerMeasure latency and availability, but also exact-cent match, total financial difference, errors by boundary group and policy era, appeals, and rollback readiness. Alert on a bad slice even when the global number still looks good.
Why this mattersMetrics should cover user speed, system safety, and result quality. Rollout starts read-only and earns stronger automation with evidence.
Candidate · clear top-down answerReadable rules take more work than a flexible model, but money needs exact and explainable behavior. The core trade-off is matching old behavior versus fixing it; separate compatibility and correction lanes make that choice explicit.
Why this mattersEvery design choice has a cost. Name the simpler alternative and explain which requirement makes the added complexity worth it.
Candidate · clear top-down answerIn short: learn old behavior from a carefully chosen golden set, run deterministic integer-money rules, choose one approved policy by business date, and save one repeat-safe decision. Shadow traffic and slice-level checks make cutover safe.
Why this mattersThe recap should repeat the user flow, the main trust rule, the hardest failure, and the most important trade-off—not every component.
DOMAIN DEPTH
These mechanisms are the interview’s differentiators. Be able to redraw each from memory and defend its failure behavior.
Traffic-weighted examples protect business impact; boundary and counterfactual probes protect rare rule edges. Both are required.
Immutable decisions reference one immutable rule bundle. New rules alter future or explicit adjustment decisions, never history in place.
FAILURE MATRIX
When the interviewer injects a fault, restate the violated assumption, change state or protocol, and name the new invariant.
| Injection | Recovery mechanism | Tempting wrong answer |
|---|---|---|
| 01Oracle changes | Version observations by epoch | Blend incompatible labels |
| 02Duplicate request | Idempotency key + input hash | Double payment |
| 03Floating rounding | Integer cents/rational intermediate | Tolerance hides cents |
| 04Shadow adapter down | Customer path succeeds; retry/coverage gap | Couple availability |
| 05Boundary mismatch | Slice gate and active probes | Aggregate parity |
| 06Policy overlap | Serializable interval constraint | Ambiguous version |
BOTEC
Use orders of magnitude to expose the bottleneck. State what this simple model omits.
INTERACTIVE SCENARIO
With zero observed mismatches, estimate the rough 95% upper error bound. Stratification is still required.
OPERATIONS + DELIVERY
A system is incomplete without observable user outcomes, staged deployment, rollback and an answer to “how will we know?”
INTERVIEWER TRAPS
Use these as flash cards. The right column is the compact sentence you want available under pressure.
| Trap | Better move |
|---|---|
| Random split only | Hold out strata, time and boundaries. |
| Tolerance for cents | Require exact money semantics. |
| Unobservable features | Use only contract inputs/context. |
| One parity number | Slice by epoch, boundary and impact. |
| Rewrite past result | Append adjustment decision. |
| Big-bang migration | Shadow and route stable cohorts. |
DEFINITIONS
Define the term, then connect it to a concrete invariant in this design. Avoid dropping vocabulary as a substitute for reasoning.
FINAL MINUTE
ReimburseX learns with evidence but runs deterministically. Immutable, stratified golden corpora capture observed legacy epochs, boundaries, errors and metamorphic probes. A compiled, integer-money policy engine selects an approved effective-dated bundle and writes an immutable idempotent decision plus explanation. Shadow comparison is asynchronous and sliced by risk; deliberate corrections have their own approvals and expected mismatches. We progress from replay to shadow to stable cohorts with financial guardrails and rollback. Historical decisions remain untouched; appeals and adjustments form a traceable ledger.
Rehearse again