**The design is sound enough to start building tomorrow, provided you make five small edits to the doc first.** None of them changes the architecture. The core choices hold: stock is reserved with a conditional update, the charge happens outside any transaction, the order id is the provider's idempotency key, and a reconciliation job settles unknown results.

## Fix before building

1. **Stock can be restored twice for one failed order.** Steps 5 and 6 do not say the `FAILED` transition is conditional on the order still being `PENDING`. With two instances, both reconciliation jobs can pick up the same order at the same time.
   - Failing case: an order for 1 unit of SKU X is declined, both jobs mark it `FAILED`, and `available` goes up by 2 instead of 1. You then oversell one unit.
   - Fix: make every status change `UPDATE orders SET status = … WHERE id = … AND status = 'PENDING'`, and only restore stock or queue the email if that update changed a row. Alternatively, have the job claim orders with `SELECT … FOR UPDATE SKIP LOCKED`.

2. **Reconciliation has no rule for "provider has never heard of this charge".** Step 6 only says orders settle as `PAID` or `FAILED`.
   - Failing case: an instance crashes after step 2 commits but before step 3 sends the charge. The order is `PENDING` with stock reserved, and the provider returns "not found".
   - Fix: state that "not found" means `FAILED` plus stock restore, and that "still processing" means leave it for the next run.

3. **The confirmation email can be lost for good.** Step 4 commits `PAID` and then queues the email as a separate step.
   - Failing case: the instance dies between the two. The order is `PAID`, no email is queued, and nothing looks at it again because reconciliation only reads `PENDING` orders. The same gap exists when reconciliation settles an order as `PAID`, since the doc does not say it sends the email.
   - Fix: write an "email pending" row in the same transaction as the `PAID` update and have a worker drain it. An `email_sent_at` column on `orders` that the job sweeps would also work.

4. **Two carts with the same SKUs in a different order can deadlock.**
   - Failing case: cart 1 updates A then B while cart 2 updates B then A. Postgres aborts one and that customer gets a 500 instead of an order.
   - Fix: update stock rows in sorted `sku` order.

5. **The idempotency key's scope and mismatch behaviour are undefined.**
   - Failing case: with a global unique constraint, a customer whose key collides with another customer's gets that customer's order back.
   - Fix: make the constraint unique on `(customer_id, idempotency_key)`. Also say what happens when the same key arrives with a different cart; I'd return `422`.

## Clarify in the doc (not blocking)

- **Where prices come from.** There is no price table in the model. If `unit_price` and `total` come from the client's cart, a customer can set their own price, so state the server-side source.
- **Worst-case request time.** Four attempts at 5 s plus backoff is roughly 25–30 s of open connection. Check that the load balancer and client timeouts exceed that, or cut the retries to one and let reconciliation handle the rest.
- **Keys.** The table lists no primary keys. `stock.sku` and `order_items (order_id, sku)` should be stated.
- **Refunds and cancellation.** There is no state for either. That is fine if out of scope for this revision, but say so.

## Test plan gaps

The listed scenarios cover the request path only. Since you'll write tests first, add these to the list now:

- Reconciliation for each provider answer: paid, declined, not found, still processing.
- Two reconciliation runs on the same order, asserting stock is restored exactly once.
- Two concurrent buyers for the last unit, where the current "last unit" test appears to be sequential.
- Two concurrent `POST /orders` with the same key.
- A crash after the `PAID` commit, asserting the email still goes out.
- The same key with a different cart.

VERDICT: READY WITH CHANGES
