The design is sound at its core and you can start building tomorrow, but three gaps in the reconciliation path (the 5-minute job in step 6) need closing in the doc first. The stock reservation, the charge outside the transaction, and the idempotency keys on both sides are all correct and I would not change them.

## Fix before building the reconciliation path

1. **An order that was never charged has no defined outcome.**
   - **Case:** an instance dies, for example during a deploy, after step 2 commits and before step 3 reaches the provider. The job asks the provider about the order and gets "no such charge".
   - **Now:** step 6 only allows `PAID` or `FAILED`, so the order stays `PENDING` and holds stock until the 30-minute alert.
   - **Expected:** "no charge found" settles the order as `FAILED` and restores the stock.

2. **Stock can be restored twice.**
   - **Case:** if the job runs on both instances, both pick up the same `PENDING` order for 1 unit and both see a decline.
   - **Now:** both mark it `FAILED` and both restore, so `available` rises by 2 and you oversell.
   - **Expected:** every status change is `UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`, and stock is restored only if that changed a row. Apply the same guard in steps 4 and 5.

3. **Some paid orders never get a confirmation email.**
   - **Case:** the charge times out, the client gets `202`, and the job later settles the order as `PAID`.
   - **Now:** only step 4 queues the email, so this customer gets none. A crash between the step 4 commit and the queue call loses it too.
   - **Expected:** write an "email owed" row in the same transaction that sets `PAID`, on both paths, and send from that table.

## Smaller changes

- **Deadlocks:** two carts holding the same two SKUs in opposite order can deadlock in step 2. Update stock in sorted SKU order.
- **Pricing:** the doc does not say where `unit_price` and `total` come from. State that the server prices the cart and ignores client-sent prices.
- **Idempotency key scope:** make the unique constraint `(customer_id, idempotency_key)`. Decide what a repeated key with a different cart returns; I would return `422`.
- **Constraints:** add primary keys, `CHECK (available >= 0)` on `stock`, and a check on `status`. Add a column for the provider's charge id.
- **Request duration:** four attempts at 5 s plus backoff can hold the request for around 30 s. Check that this is below the load balancer timeout, or cut the retries to one or two and lean on the job.
- **Module rule:** step 2 writes `stock` and `orders` in one transaction. Say that `OrderCheckout` owns the transaction and passes it into the inventory module, so the "no cross-module table access" rule still holds.

## Tests to add to the plan

- **Reconciliation job:** provider says paid, declined, no charge found, and still unknown.
- **Two job runs on the same order:** stock is restored once.
- **Crash between step 2 and step 3:** the order ends `FAILED` with stock restored.
- **Two concurrent buyers for the last unit:** one `201`, one `409`.
- **Two concurrent `POST /orders` with the same key:** one order is created.
- **Email after reconciliation:** exactly one is queued.

VERDICT: READY WITH CHANGES
