Data & Systems45 minutes

Double Refund

Trace a double refund through a layered payments service and fix it.

Python

Task

A support ticket says a customer was refunded more than they paid. It happens when a support agent clicks Refund twice within a minute. The refund service has a controller, a service and two repositories over a small fake database. Reproduce the ticket, find the layer where the rule breaks, and fix it there.

Requirements

  1. handle(charges, requests) loads the charges into a fresh database, replays the requests in order, and returns one response per request. A charge is {id, amount} with a unique id and a positive amount in integer cents (ValueError containing charge otherwise). Do not change the arguments.
  2. {op: "refund", charge, amount, at} creates a refund and returns {status: 201, refund}. A refund is {id, charge, amount, status, created_at}. Ids run rf_1, rf_2 and so on. status starts as "pending". created_at is the request's at, in seconds (0 when left out).
  3. A customer must never get back more than they paid for a charge. A refund that would allow it returns {status: 422, error: "over_refund"} and is not stored. A failed refund returns no money, so it does not count against the charge. Other refusals: an amount that is not a positive integer is 400 invalid_amount, an at that is not a non-negative integer is 400 invalid_time, and an unknown charge is 404 charge_not_found.
  4. {op: "settle", refund} and {op: "fail", refund} record the payment processor's result for a pending refund and return {status: 200, refund}. An unknown refund is 404 refund_not_found. A refund that is no longer pending is 409 not_pending.
  5. {op: "summary", charge} returns {status: 200, summary}. summary is {charge, amount, pending, settled, failed, refundable}: the refund totals by status, and how much of the charge can still be refunded. Any other op raises ValueError containing op.
How you are graded
  • Decomposition 15%
  • Prompting the assistant 15%
  • Verification 20%
  • Judgment about AI output 15%
  • Correctness 25%
  • Communication 10%

Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard

Interview guidance

A support ticket says a customer was refunded more than they paid. It happens when an agent clicks Refund twice within a minute. Find the bug and fix it, and show me a request sequence that proves the fix. Use the AI assistant however you like. Reproduce the ticket before you change any code.

  • AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
  • You are graded on how you drive and check the AI, not on how much you prompt.
  • Run the checks; read what fails.
  • A new requirement will arrive partway through.
  • Too little AI use is reported as “not enough to grade”, never as a fail.
You will answer 7 debrief questions at the end
  • What did you delegate to the AI, and why?
  • Name one AI suggestion you rejected or changed, and why.
  • Choose one block the AI helped write. Explain what each line does and which test verifies it.
  • What is still risky, and what would you test or ship next?
  • Which request sequence reproduced the ticket, and what did it tell you about where to look?
  • Which layer did you change, and why that one?
  • Was there code that looked wrong and that you left alone? What convinced you?