BEHAVIOR LAB / MOCK 06

Golden-Master Modernization

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.

30 MINUTES16 INTERVIEWER TURNSFULL Q & AINTERACTIVE LAB

The problem on the whiteboard

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.
Central design thesis

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.

Scope before components

These are supplied mock numbers for sizing and follow-ups. Say your assumptions before using them.

History30M labeled calls spanning 8 years; three observable inputs + decimal output
Traffic50k requests/day · 40 RPS peak · p99 < 120 ms
Parity≥99.99% exact-cent match on in-scope traffic before cutover
MoneyNo floating point; replayable calculation and immutable decision ledger
Migration12-week oracle window; shadow → canary → route by cohort → retire

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

Functional scope

  • Historical profiling and golden-master corpus
  • Boundary and metamorphic test generation
  • Versioned deterministic reimbursement evaluation
  • Shadow comparison, mismatch triage and replay
  • Effective-dated corrections and staged routing

Explicitly out

  • Inventing missing employee/department inputs
  • Using future claims to answer past requests
  • Automatic policy changes from a model
  • General travel booking
  • Destructive big-bang cutover

A traceable end-to-end path

Name the authoritative state, derived projections, asynchronous boundaries and the exact point where a business decision becomes durable.

Golden-Master Modernization reference architectureSix stage architecture from Request edge through Shadow compare.Request edgeidempotencyNormalizerdecimal + datePolicy routereffective versionDeterministic engineexplainable rulesDecision ledgerimmutable centsShadow comparelegacy vs newaudit · policy · metrics · lineage
01Request edgeidempotency
02Normalizerdecimal + date
03Policy routereffective version
04Deterministic engineexplainable rules
05Decision ledgerimmutable cents
06Shadow comparelegacy vs new

Keys that preserve history

The table is logical, not a mandate for one database. Choose physical stores after access patterns, transactions, retention and rebuildability are clear.

EntityPrimary / unique keyImportant 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

200
POST /v1/policies/{id}/versions

Create draft effective-dated rule bundle

201 {version}
POST /v1/appeals

Reference original decision; never mutate it

201 {appealId}

The complete mock interview

Answers are written in a speakable first-person style. Turn on Practice Mode to hide them, answer aloud, then reveal one at a time.

INTERVIEWER

Design the replacement.

CANDIDATE

I would explicitly separate two products: a compatibility engine that reproduces observed legacy behavior, and a governed policy engine for intentional future changes. First freeze the observable contract: three inputs, decimal output, date/context and error behavior. Build a stratified golden-master corpus from history plus oracle probes, create a deterministic evaluator, shadow every request, and ledger both outcomes. Only after measured parity do we route cohorts. I would ask whether output alone or exceptions/timing are contract behavior too.

INTERVIEWER

Clarify requirements and unknowns.

CANDIDATE

We need exact-cent output, input validation parity, idempotent API, effective-dated policy choice, explanation, appeal linkage, differential testing and safe rollback. The only observable features are days, miles, receipts and request date; employee or department stories are untestable and must not leak into the model. I want the historical sampling process, whether the oracle changed over time, and the legal meaning of retroactive correction. I exclude travel booking, probabilistic production decisions and silently rewriting past outcomes.

  • Unknown behavior is an explicit coverage gap.
  • A corrected policy version does not mutate historical decisions.
  • Request date and policy effective date are distinct concepts.
INTERVIEWER

Estimate scale and the parity claim.

CANDIDATE

Fifty thousand/day averages 0.58 RPS, so the 40 RPS peak and availability dominate compute sizing. Thirty million compact cases at roughly 100 bytes are 3 GB before indexes—easy to store; repeated evaluation is CPU-bound but parallel. A 99.99% target allows one mismatch per 10,000. Seeing zero errors in only 30,000 random tests gives a rough 95% upper error bound of 3/n = 0.01%, but random samples miss rare boundaries. I need millions of stratified and generated boundary cases, not one aggregate percentage.

50,000 / 86,400 ≈ 0.58 RPS average
99.99% ⇒ ≤ 1 mismatch / 10,000
Rule of three: zero failures in n ⇒ upper rate ≈ 3/n
INTERVIEWER

How do you construct a golden master?

CANDIDATE

Deduplicate exact input triples but preserve frequency metadata and time buckets. Stratify by days, miles/day, receipt ranges, decimal endings, extreme ratios, historical epoch and observed discontinuities. Detect output step changes and cluster local neighborhoods. Sample both traffic-weighted cases for business impact and uniform/boundary cases for rule discovery. While the oracle is available, actively probe just below/at/above candidate thresholds and create metamorphic pairs such as +1 mile or +1 cent. Every corpus version is immutable and records selection code, source hashes and expected oracle version.

  • Training/discovery and certification sets are separated.
  • Hold out entire strata and time ranges to detect overfit.
  • Golden examples include errors and invalid inputs.
INTERVIEWER

Data model and API semantics?

CANDIDATE

InputCase stores normalized integers: days, miles and receipt cents. OracleObservation is append-only because the same input may return differently across legacy epochs. GoldenExample pins corpus and oracle version. PolicyVersion is immutable after approval, with non-overlapping effective intervals enforced per policy line. Decision is keyed by tenant/request ID and stores input hash, selected policy, cents and explanation hash. A correction creates a new version; an appeal references the old decision and any adjustment is a second decision. POST requires an idempotency key and effective context.

INTERVIEWER

Walk the production architecture.

CANDIDATE

The edge authenticates and dedupes request ID. A strict normalizer parses decimal strings to integer cents, validates units and canonicalizes the input hash. The policy router selects the one approved version whose effective interval contains the decision date, and snapshots that choice. A deterministic rules engine evaluates a compiled decision table, producing output cents and rule trace. In one transaction, the service writes Decision plus an outbox response event; retries return the same decision. During shadow, an asynchronous adapter invokes or reads the legacy outcome and writes ShadowComparison. Dashboards aggregate deltas, but the immutable ledger remains the investigation source.

  • Hot path does not depend on the legacy oracle.
  • Policy bundle is cached by immutable hash.
  • Shadow comparison cannot change customer response.
INTERVIEWER

Deep dive: infer behavior without overfitting.

CANDIDATE

Start with interpretable hypotheses from discontinuity plots and interviews, but certify only against held-out observations. A decision-table/rule DSL encodes tiers, caps, bonuses and interactions with explicit rounding after each stage if observations require it. Use active learning to query cases that distinguish competing hypotheses. Metamorphic tests find nonmonotonic zones but do not assume monotonicity globally. Keep an exception table only for genuinely isolated known legacy defects; a giant lookup/memorization model would fail unseen combinations and be impossible to govern.

  • Measure exact match, absolute-cent delta and weighted financial delta.
  • Slice by every discovered boundary and historical epoch.
  • An inferred rule carries evidence cases and confidence, but production code is deterministic.
INTERVIEWER

Deep dive: effective dates and intentional corrections.

CANDIDATE

Each approved PolicyVersion has transaction time and valid effective interval. The router resolves using the business decision date, not deploy time. A correction proposal includes rationale, impacted golden strata, simulated financial delta, approvals and intended effective date. If retroactive recalculation is allowed, generate adjustment decisions referencing originals; never mutate ledger rows. Overlap constraints prevent two active versions for the same cohort/date. The golden suite has two lanes: compatibility tests expected to match legacy and policy tests expected to differ by an approved correction ID.

  • Bitemporal metadata distinguishes what was believed when from when policy applies.
  • Rollback routes new requests to prior bundle; already issued decisions remain traceable.
  • A deliberate mismatch is labeled, budgeted and reviewed.
INTERVIEWER

Consistency, idempotency and failure semantics?

CANDIDATE

Strong consistency covers request dedupe, policy interval publication and decision ledger. Corpus evaluation and comparison analytics are eventual. Idempotency key maps to canonical input hash; reusing a key with different input returns 409. Decision plus outbox commits atomically, so downstream payment sees one effect despite at-least-once delivery. If policy selection or ledger is unavailable, fail closed rather than guess money. Shadow adapter failures do not fail customer requests; they create a comparison gap metric and retry with bounded age.

INTERVIEWER

Failure injection: the oracle produces different cents for the same inputs after a weekend release.

CANDIDATE

OracleObservation already includes observed time and environment, so we detect a multimodal output for one fingerprint. Freeze certification against the pre-change oracle version, stop active promotion, and create a new epoch. Probe a stratified panel before and after to localize affected regions. Ask policy owners whether it is an intended policy change or defect. Do not blend observations and learn an average. The shadow comparator labels legacy epoch, and routing remains on the last approved new-engine policy until a reviewed version models the intended change.

INTERVIEWER

How do shadow traffic and cutover work?

CANDIDATE

Phase zero replays frozen history. Phase one mirrors live requests asynchronously while legacy remains authoritative. Phase two makes the new engine authoritative for internal/test accounts, then low-risk cohorts selected by stable hash—not per request—to avoid inconsistent employee outcomes. Every phase has parity, financial-delta, latency, error and appeal guardrails with an automatic routing kill switch. Keep dual computation long enough to cover monthly boundaries. At full cutover, retain a read-only legacy adapter and replay capability until retention and audit requirements expire.

  • Shadow observes production distribution without double-paying.
  • Cohort routing and policy version are recorded in Decision.
  • Rollback changes future routing; it does not delete decisions.
INTERVIEWER

Failure injection: mismatches concentrate on receipts ending .49 and .99.

CANDIDATE

Pause cohort expansion because aggregate 99.99% can hide a material slice. Create a dedicated boundary stratum around those endings and inspect each arithmetic stage. This likely indicates decimal parsing, rounding order or a threshold keyed to cents. Replace any floating-point path with integer/rational arithmetic, encode rounding mode at the exact legacy stage, and add metamorphic cases ±1 cent. Backfill comparisons to calculate total financial impact. Promotion requires slice-specific zero unexplained mismatches, not only global parity.

INTERVIEWER

Security and privacy?

CANDIDATE

The three numeric inputs are low sensitivity alone, but production requests may carry employee and tenant identity. Minimize the evaluator input, tokenize actor identity, encrypt ledgers with tenant keys and isolate test corpora from raw PII. Policy authors, approvers and deployers have separated roles. Golden datasets are access-controlled and exports watermarked/audited. Signed bundle hashes and append-only decisions detect tampering. The oracle adapter uses least-privilege credentials and cannot issue payment. Explanations redact internal anti-fraud thresholds when policy requires.

  • No model call is needed in the money path.
  • Test data preserves boundary behavior without exposing names.
  • Appeal evidence has stricter retention and access.
INTERVIEWER

Observability and evaluation?

CANDIDATE

Service SLIs: p99 latency, availability, dedupe conflicts, policy-cache miss, ledger commit and outbox lag. Correctness: exact-cent parity, absolute delta, signed financial delta, mismatch rate by stratum/epoch/policy/cohort and validation-error parity. Migration: shadow coverage, legacy adapter gap age, cohort size and rollback readiness. Product: appeals, overturn rate, investigator time and unexplained mismatch age. Every release publishes a matrix over frozen corpora; online monitors compare distributions and run synthetic boundary canaries.

  • Alert on cents, not only request counts.
  • Reconcile Decision outbox with downstream payment ledger.
  • Retain the exact executable rule bundle for replay.
INTERVIEWER

Trade-offs and traps?

CANDIDATE

Interpretability may take more engineering than a flexible model but is required for exact money and corrections. Mirroring the legacy bug maximizes compatibility while policy cleanup improves outcomes; keeping separate compatibility and correction lanes resolves that tension. Traps are random-only sampling, leakage from history into certification, floats, assuming calendar/person inputs that do not exist, one global parity metric, mutating old decisions, and big-bang cutover.

INTERVIEWER

Give me your one-minute close.

CANDIDATE

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.

Two places to earn the strong hire

These mechanisms are the interview’s differentiators. Be able to redraw each from memory and defend its failure behavior.

01

Deep dive A · Golden-master matrix

Traffic-weighted examples protect business impact; boundary and counterfactual probes protect rare rule edges. Both are required.

  1. Historical frequency sample
  2. Time-epoch stratification
  3. Threshold ±1 probes
  4. Decimal-ending strata
  5. Held-out certification corpus
02

Deep dive B · Policy time

Immutable decisions reference one immutable rule bundle. New rules alter future or explicit adjustment decisions, never history in place.

  1. Transaction vs valid time
  2. Non-overlapping approved intervals
  3. Correction impact simulation
  4. Adjustment links original
  5. Rollback affects future routing

Revise, do not hand-wave

When the interviewer injects a fault, restate the violated assumption, change state or protocol, and name the new invariant.

InjectionRecovery mechanismTempting wrong answer
01Oracle changesVersion observations by epochBlend incompatible labels
02Duplicate requestIdempotency key + input hashDouble payment
03Floating roundingInteger cents/rational intermediateTolerance hides cents
04Shadow adapter downCustomer path succeeds; retry/coverage gapCouple availability
05Boundary mismatchSlice gate and active probesAggregate parity
06Policy overlapSerializable interval constraintAmbiguous version

Calculate before you provision

Use orders of magnitude to expose the bottleneck. State what this simple model omits.

Parity confidence lab

With zero observed mismatches, estimate the rough 95% upper error bound. Stratification is still required.

Rule-of-three upper mismatch rateChange an input to recalculate.
History
Boundary
Held-out
Shadow

Prove quality in production

A system is incomplete without observable user outcomes, staged deployment, rollback and an answer to “how will we know?”

Scoreboard

  • Exact-cent match by stratum
  • Signed financial delta
  • Shadow coverage/gap age
  • Appeal overturn rate
  • Decision replay success
  • Cohort rollback readiness

Rollout ladder

  1. 01Profile and freeze historical data
  2. 02Active oracle boundary probing
  3. 03Offline differential certification
  4. 04100% asynchronous shadow
  5. 05Stable low-risk canary cohorts
  6. 06Progressive authority + retained replay

Corrections worth memorizing

Use these as flash cards. The right column is the compact sentence you want available under pressure.

TrapBetter move
Random split onlyHold out strata, time and boundaries.
Tolerance for centsRequire exact money semantics.
Unobservable featuresUse only contract inputs/context.
One parity numberSlice by epoch, boundary and impact.
Rewrite past resultAppend adjustment decision.
Big-bang migrationShadow and route stable cohorts.

Vocabulary without fog

Define the term, then connect it to a concrete invariant in this design. Avoid dropping vocabulary as a substitute for reasoning.

Golden master
Frozen inputs and expected outputs defining observed compatibility.
Oracle
Legacy system queried to observe behavior without seeing implementation.
Metamorphic test
Related inputs whose output relationship reveals boundaries or invariants.
Characterization test
Test recording what a legacy system does, even before why is known.
Bitemporal
Tracking both valid business time and knowledge/transaction time.
Shadow traffic
Run candidate beside production without using its result.
Differential test
Execute two implementations on the same input and compare.
Rule of three
With zero failures in n trials, rough 95% upper failure rate is 3/n.

Close with a decision, not a component list

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