**The design is sound at its core and you can start building tomorrow, but fix two gaps in the doc first: one can corrupt stock counts, the other can show one customer another customer's order.** Both are edits to the doc, not redesigns.

## Must fix before building

**1. Stock can be restored twice for the same failed order.**
Nothing in the design says a status change only applies if the order is still `PENDING`, and the reconciliation job runs on both instances.
- **Case:** an order for 1 unit of SKU A times out and stays `PENDING`. Both instances' jobs pick it up, both learn the charge was declined, and both run "mark `FAILED` and restore stock".
- **Wrong result:** `available` goes up by 2, and you later sell a unit you do not have.
- **Expected:** `available` goes up by 1.
- **Fix:** make every transition conditional (`UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`) and restore stock only if that update changed a row. This applies to steps 4, 5 and 6.

**2. The idempotency key is unique globally, not per customer.**
- **Case:** customer B sends a key that customer A already used, by a weak client generator or deliberately.
- **Wrong result:** B receives A's order.
- **Expected:** B gets their own new order.
- **Fix:** make the unique constraint `(customer_id, idempotency_key)`. Also say what happens when the same key arrives with a different cart; I recommend `422`.

**3. Reconciliation has no rule for "the provider has never heard of this charge".**
- **Case:** the instance crashes after step 2 commits but before the charge call. The order is `PENDING` and the stock is reserved, but the provider has no record.
- **Wrong result:** step 6 only allows `PAID` or `FAILED` from a provider answer, so the order stays `PENDING` and the stock stays locked until the 30-minute alert fires and someone fixes it by hand.
- **Expected:** "not found" for an order older than 2 minutes settles as `FAILED` and restores the stock.

## Should fix, cheap to add now

- **Confirmation email on the reconciliation path.** Step 4 queues the email only in the request path. An order settled as `PAID` by the job gets no email, and neither does one where the instance dies between the commit and the queue call. Have both paths go through one "mark paid" function, and ideally write the email job in the same transaction as the status change.
- **Deadlocks on multi-item carts.** Two carts containing SKUs A and B, updated in opposite order, can deadlock in step 2. Update stock rows in sorted SKU order.
- **Where prices come from.** The doc does not say whether `unit_price` and `total` are computed server-side. If they come from the client's cart, a customer can set their own price.
- **How the client learns the outcome after a `202`.** There is no `GET /orders/{id}` or other mechanism described.
- **Data model omissions.** No primary keys on `order_items` or `stock`, no `CHECK (available >= 0)`, and no column for the provider's charge reference, which you will want for support and refunds.

## Test plan gaps

The listed tests cover the sequential paths but not the concurrent ones, which is where this design can break. Add:
- Two simultaneous buyers for the last unit: exactly one succeeds, one gets `409`.
- Two simultaneous `POST /orders` with the same key: one order, one stock reservation.
- The reconciliation job, which currently has no tests: settles as paid, settles as declined, charge not found, and two jobs running on the same order.
- A crash between the stock reservation and the charge call.

## What holds up

The atomic stock reservation, the charge call outside any transaction, the order id as the provider idempotency key, and the 2-minute reconciliation threshold (worst-case in-request retries finish in about 30 seconds) are all correct. One Postgres and two instances is plenty for 2,000 orders a day.

VERDICT: READY WITH CHANGES
