The design is sound in its overall shape and you can start tomorrow, but three gaps can corrupt stock or strand orders and should be closed in the doc first. I only read `design.md`; nothing was run.

## Fix before building

1. **Settling an order is not guarded against happening twice, so stock can be restored twice.**
   - **Failing case:** both instances run the reconciliation job. Each sees order A (`PENDING`, 1 unit of SKU X) as declined, and each marks it `FAILED` and adds 1 back. `available` ends at 2 when it should be 1, and you later oversell.
   - **Fix:** make every status change conditional (`UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`) and restore stock or queue the email only if that update changed a row. Also say whether the job runs on one instance or takes a lock.

2. **Reconciliation has no outcome for "the provider has never heard of this order".**
   - **Failing case:** the instance crashes after step 2 commits and before step 3 sends the charge. The provider answers "not found", which is neither `PAID` nor `FAILED`. The order stays `PENDING` with its stock held, and the 30-minute alert fires with no defined action.
   - **Fix:** treat "not found" as `FAILED`. Also state that reconciliation restores stock when it settles `FAILED`; step 6 doesn't say so.

3. **The idempotency key is unique globally, not per customer.**
   - **Failing case:** customer B sends a key that customer A already used. The expected result is a new order for B; the design returns A's order to B.
   - **Fix:** make the constraint unique on `(customer_id, idempotency_key)`. Also decide what happens when the same key arrives with a different cart; I'd return `422`.

## Clarify in the doc (small, can be done as you build)

- **Prices:** the doc doesn't say where `unit_price` and `total` come from. They must be computed server-side, not taken from the client's cart.
- **Lock order:** two orders reserving the same SKUs in opposite order can deadlock in step 2. Update the stock rows in sorted SKU order.
- **Request duration:** four attempts at 5 s plus backoff can hold the request for around 30 s. Check that this is under the load balancer's timeout, or cut the retries and lean on the `202` path.
- **Lost email:** a crash between the `PAID` commit and queueing the email in step 4 loses the email. Either write an outbox row in the same transaction, or accept the loss and say so.
- **After a `202`:** the client has no documented way to learn the outcome. Add `GET /orders/{id}`.
- **Constraints:** the data model lists no primary keys. Add them, plus `CHECK (available >= 0)` on `stock` and a foreign key from `order_items` to `orders`.

## Tests to add to the plan

- Two reconciliation runs settle the same declined order, and stock is restored once.
- A crash after the reservation, before any charge is sent, ends with the order `FAILED` and the stock restored.
- Two simultaneous `POST /orders` with the same key produce one order and one reservation.
- Two simultaneous buyers of the last unit get one success and one `409`.
- The same key from a different customer creates a separate order.

VERDICT: READY WITH CHANGES
