**The design is sound enough to start building tomorrow, but two gaps can lose money or stock and should be fixed in the doc first.** The core is right: the idempotency key on `POST /orders`, the conditional stock decrement, the charge outside the transaction, and reconciliation for unknown results. The fixes are about an hour of design edits, not a rework.

## Fix before building

**1. Reconciliation has no answer for "the provider has never heard of this order".**
- **Case:** the instance crashes after step 2 commits and before step 3 calls the provider. The order is `PENDING` with stock reserved, and no charge exists.
- **What happens now:** step 6 only settles as `PAID` or `FAILED`, so this order stays `PENDING` forever. The stock stays locked and the 30-minute alert fires every time.
- **Fix:** treat "no charge found" as `FAILED` and restore stock. If the provider says the charge is still processing, leave the order `PENDING`.

**2. Status changes are not guarded, so stock can be restored twice.**
- **Case:** both instances run the reconciliation job at the same tick and both see order X as `PENDING` and declined. Each marks it `FAILED` and adds the stock back.
- **Result:** an order for 1 unit returns 2 units to `available`, and you later oversell. It should return 1.
- **Fix:** make every transition conditional, `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`, and only restore stock or queue the email if a row changed. Put this in one settle function used by steps 4, 5 and 6.

## Decide while building

- **Confirmation email:** step 4 queues it after the commit, so a crash in between loses it. The doc also does not say whether orders settled as `PAID` by reconciliation get one. The shared settle function fixes the second; an outbox row written in the same transaction fixes the first.
- **Price source:** there is no product or price table, and the doc does not say where `unit_price` and `total` come from. They must be computed server-side, never taken from the cart.
- **Idempotency key details:**
  - Scope the unique constraint to `(customer_id, idempotency_key)`, not global.
  - Say what happens when the same key arrives with a different cart; rejecting with `422` is the usual choice.
  - Two simultaneous requests with the same key: the loser hits the unique violation and must return the existing order, not a `500`.
- **Deadlocks in step 2:** two orders reserving SKUs A,B and B,A can deadlock. Update stock in sorted SKU order.
- **Request duration:** four attempts at 5 s plus backoff is roughly 30 s. Check that the load balancer timeout is longer.
- **After a `202`:** the client needs a `GET /orders/{id}` to poll, and the doc does not mention one.
- **Module boundary:** step 2 changes `stock` and `orders` in one transaction, which conflicts with "no module reads another module's tables". State that inventory exposes a reserve/restore function that takes the caller's transaction.
- **Schema gaps:**
  - Primary keys on `order_items` and `stock`.
  - A check constraint `available >= 0`.
  - A column for the provider's charge id.
  - An index on `(status, created_at)` for the reconciliation query.

## Tests to add to the plan

The current list covers the request path well but leaves the reconciliation job untested. Add:

- Reconciliation settling to `PAID`, to `FAILED`, and for a charge the provider has no record of.
- Two reconciliation runs on the same order, with stock restored once.
- A crash between reserve and charge.
- Two concurrent buyers for the last unit, giving one success and one `409`.
- Two concurrent `POST /orders` with the same key.
- The same key with a different cart.

VERDICT: READY WITH CHANGES
