**The design is sound at its core and you can start building tomorrow, but four gaps need a decision written into the doc first.** One of them can corrupt stock, and one depends on a provider capability the design assumes but doesn't confirm.

The parts that hold up: the conditional stock update prevents overselling, the charge happens outside any transaction, the order id as provider idempotency key makes retries safe, and unknown outcomes go to reconciliation instead of being guessed.

## Fix before building

1. **Stock can be restored twice for the same order.** Steps 5 and 6 don't say the status change is conditional, and the doc doesn't say where the reconciliation job runs. With two instances, both could run it.
   - **Failing case:** an order for 3 units of SKU A is stuck `PENDING` and the provider reports it declined. Both instances pick it up at 12:05, both mark it `FAILED`, and both add 3 back. `available` is now 3 higher than real stock, so the next 3 units sold don't exist.
   - **Fix:** make every transition `UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`, and restore stock or queue the email only if that update changed a row. This also covers the request handler racing the job.

2. **Reconciliation has no rule for "the provider has no record of this charge".** This happens whenever an instance crashes between step 2's commit and step 3's call.
   - **Failing case:** the order sits `PENDING` with stock held, the provider answers "not found", and step 6 only allows `PAID` or `FAILED`. The order stays stuck until the 30-minute alert, every time.
   - **Fix:** state that "not found" after the 2-minute cutoff means `FAILED` plus stock restore. Also state that the job queues the confirmation email when it settles `PAID`.

3. **Step 6 assumes the provider can look up a charge by your order id.** Some providers cannot retrieve a charge by idempotency key, only by their own charge id or by metadata you attach. Check your provider's API today. If it can't, send the order id as metadata, or add a `payment_reference` column to `orders`, which the data model lacks.

4. **The idempotency key's scope is unspecified.**
   - **Failing case:** if the unique constraint is on `idempotency_key` alone, customer B sending a key customer A already used gets A's order back.
   - **Fix:** make it unique on `(customer_id, idempotency_key)`. Also decide what the same key with a different cart returns; I recommend `422`.

## Smaller gaps to close in the doc

- **Deadlocks in step 2:** two orders reserving SKUs A,B and B,A can deadlock, and Postgres aborts one as a 500. Update the SKUs in sorted order.
- **Price source:** the doc doesn't say where `unit_price` and `total` come from. If they come from the client's cart, a customer can set their own price. State that the server computes them, and from where.
- **The `202` path:** the client needs a way to learn the outcome. Add `GET /orders/{id}` to the design.
- **Lost email:** a crash between the `PAID` commit and queuing the email loses it silently. Either accept that in writing or write an outbox row in the same transaction.
- **Module rule versus step 2:** stock and order rows change in one transaction, while the doc says modules don't touch each other's tables. Say that `OrderCheckout` owns the transaction and calls each module inside it.
- **Keys and status:** `order_items` and `stock` have no primary keys listed, and `status` should have a `CHECK` constraint.

## Test plan additions

The listed tests cover single-request paths only, so none of them would catch the four gaps above. Add:

- Two concurrent buyers for the last unit: exactly one succeeds.
- Two concurrent `POST /orders` with the same key: one order, stock decremented once.
- Reconciliation for each provider answer: paid, declined, not found, provider unavailable.
- The same order settled twice: stock restored once, email queued once.
- A crash after the reservation and before the charge.
- Overlapping SKUs in opposite order: no 500.

VERDICT: READY WITH CHANGES
