**design.md is sound at its core and you can start building tomorrow, but three gaps should be closed in the doc first because each one can corrupt stock or leak an order.** I'd keep the overall shape: reserve stock in a transaction, charge outside it, and settle unknown results with a reconciliation job.

## Fix before building

1. **Reconciliation has no rule for "the provider has never heard of this order".**
   - **Case:** an instance crashes after step 2 commits but before the charge call in step 3. The order is `PENDING` with stock reserved, and the provider answers "no such charge".
   - **Wrong outcome:** step 6 only allows `PAID` or `FAILED` from a charge status, so the order stays `PENDING` forever, the stock stays locked, and the 30-minute alert fires.
   - **Expected:** the order becomes `FAILED` and the stock is restored.
   - **Fix:** treat "not found" as `FAILED` once the order is older than the worst-case retry window. State that window in the doc, because the backoff values in step 3 are unspecified and the 2-minute cutoff depends on them.

2. **Settling an order is not guarded, so stock can be restored twice.**
   - **Case:** there are two instances, and the doc doesn't say the job runs on only one. Both pick up the same declined `PENDING` order in the same tick and both run "mark `FAILED` + restore stock".
   - **Wrong outcome:** a 1-unit order puts 2 units back, and you later oversell.
   - **Expected:** 1 unit is restored.
   - **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 changed a row. This also covers the job racing with a slow request handler.

3. **The idempotency key is unique globally, not per customer.**
   - **Case:** customer B sends a key that customer A already used.
   - **Wrong outcome:** B gets A's order back.
   - **Expected:** B gets their own new order.
   - **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`.

## Smaller changes, each a line or two in the doc

- **Email on the reconciliation path:** step 4 queues the email only in the request path. An order settled as `PAID` by the job, or a crash between the commit and the queueing, sends no confirmation. Route both through one settle function that queues the email.
- **Deadlocks on stock:** two orders containing SKUs A and B in opposite order can deadlock in step 2. Update the stock rows in sorted SKU order.
- **Where prices come from:** the doc doesn't say who sets `unit_price` and `total`. They must be computed server-side, not taken from the cart, and there is no price source in the data model.
- **Constraints:** add primary keys on `stock.sku` and `order_items (order_id, sku)`, plus `CHECK (available >= 0)` and a check on `status`.
- **Client behaviour:**
  - After a `202`, the client needs a way to learn the outcome, such as `GET /orders/{id}`.
  - After a `FAILED` order, a retry needs a new idempotency key, or it gets the failed order back forever.
  - The request can run about 30 seconds in the worst case, so check that the load balancer timeout is longer.
- **Module rule:** step 2 writes `stock` and `orders` in one transaction, which bends "no module reads another module's tables". Say that `OrderCheckout` owns the transaction and calls each module's own functions inside it.

## Tests to add to the plan

The current list never exercises the reconciliation job or concurrency. Add:

- Reconciliation settling as `PAID`, as `FAILED`, and on "not found".
- The job running twice on the same order, with stock restored once.
- Two simultaneous buyers of the last unit, with exactly one winning.
- Two simultaneous `POST /orders` with the same key.
- The same key from two different customers.
- A crash after the reserve but before the charge.

VERDICT: READY WITH CHANGES
