**design.md is close, but it has a few gaps to close before you build. The two that matter most are stock leaking after reconciliation and the reconciliation job having no defined behavior.** The overall shape fits the scale of 200 to 2,000 orders a day, one Postgres database and four people. The reserve, then charge, then settle ordering and the use of the order id as the provider's idempotency key are both sound.

## Fix before building

1. **Stock is never restored when reconciliation settles an order as `FAILED` (step 6).** Step 5 restores stock on a decline, but step 6 doesn't. Example: a charge times out on every attempt, the order stays `PENDING` with 1 unit reserved, and reconciliation later finds the charge was declined. The order becomes `FAILED` and the unit is never returned. Route both paths through one shared "fail order and restore stock" operation.

2. **Status changes need to be conditional.** The request path (steps 4 and 5) and the reconciliation job can both act on the same order. The job runs on two instances, so it can also collide with itself. Use `UPDATE ... SET status = :new WHERE id = :id AND status = 'PENDING'`, and only restore stock if that update changed a row. Without this you can restore stock twice or flip a `PAID` order to `FAILED`. For the job, either use `FOR UPDATE SKIP LOCKED` or take an advisory lock.

3. **"Provider has no record of this charge" is not defined (step 6).** If the provider reports no charge and the job marks the order `FAILED`, a retry still in flight or delayed on the provider's side could create the charge afterward. The customer is charged and the order is `FAILED`. Decide what the job does here. I'd suggest re-issuing the charge with the same idempotency key, or leaving the order `PENDING` until the provider returns a definite answer.

4. **The confirmation email can be lost (step 4).** If the process crashes between the `PAID` commit and the queue write, no email is sent. Orders settled as `PAID` by reconciliation also aren't mentioned. Either write an outbox row in the same transaction that marks the order `PAID`, or state that losing the email in a crash is acceptable. The design also doesn't say what the queue is, and the Context section lists none.

5. **Add the reconciliation job to the test list.** It is the most dangerous code path and has no tests. Add cases for: settles to `PAID`, settles to `FAILED` with stock restored, no record at the provider, two job runs at once, and the job racing a live request. Also add:
   - a decline test that asserts stock is restored
   - two simultaneous requests with the same key
   - an email failure that doesn't fail the order

## Smaller gaps (can be settled while building)

- **Concurrent duplicate keys:** the second insert hits the unique constraint. Say that you catch the violation and return the existing order. Also decide whether the key is unique per customer or global, and what happens when the same key arrives with a different cart.
- **Pricing:** the design doesn't say where `unit_price` and `total` come from. They should be computed server-side, not taken from the client's cart.
- **Schema:** it lists no primary keys, no `UNIQUE` on `idempotency_key` (the flow depends on it), no index on `(status, created_at)` for the job, no `CHECK` on `status`, and no `UNIQUE` or primary key on `stock.sku`.
- **Module boundary:** step 2 writes `stock` and `orders` in one transaction, but "no module reads another module's tables" says otherwise. Name how inventory takes part in the caller's transaction, for example by passing in the transaction.
- **Responses:** only `409` and `202` are specified. Define the success code and the body for `409` (out of stock) versus a replayed key.
- **Request length:** worst case is about 4 attempts × 5 s plus backoff, so a request can run for 25 s or more. Check that this is within the client and load balancer timeouts.

None of these require a redesign. Items 1 to 3 are changes to the flow text, and item 5 is a longer test list.

VERDICT: READY WITH CHANGES
