You have to change a ten-year-old billing module with no tests, and the person who wrote it has left. Walk me through how you make the change safely.

Answer it out loud before you open anything. The value of the flags below is in comparing them to what you actually said — including whether you named a cost, or only a principle.

The situation behind the question

The module is 4,000 lines across three files. It computes invoices, applies discounts, handles proration and writes to two tables. Finance depends on its output being byte-identical for existing customers. The requested change is to add a new discount type.

React to this

Say what you would change, what you would leave alone, and what you would need to know first.

The code, or the design, as it stands
The core of the module looks like this:

```ts
function generateInvoice(customerId: string) {
  const c = db.query('select * from customers where id = ?', customerId)
  const items = db.query('select * from line_items where customer = ?', customerId)
  let total = 0
  for (const i of items) {
    if (i.startsAt < new Date() && i.plan === 'annual') total += proRate(i, new Date())
    else total += i.amount
  }
  if (c.tier === 'gold') total *= 0.9
  db.execute('insert into invoices ...', total)
  mailer.send(c.email, renderInvoice(total))
}
```

What is the first seam you would open, and what does the first test you write assert?

What it is really testing

Whether the candidate has a *loop* — understand behaviour, pin it down, change in small verified steps — rather than a plan that starts with cleaning up. The strongest signal is that they treat the absence of tests as the problem to solve first, and that they know how to get a test around code that was not written to be tested.

Where the mechanism is taught