**The design is sound enough to start building tomorrow, but four gaps need closing in the doc first.** The core is right: stock is reserved atomically, the charge happens outside any transaction with the order id as the provider idempotency key, and unknown results are reconciled. None of the four changes the architecture; together they are about an hour of doc edits.

## Fix before building

1. **Stock can be restored twice for one failed order.** Steps 5 and 6 don't say the `PENDING → FAILED` change is conditional, and the doc doesn't say whether the reconciliation job runs on one instance or both.
   - **Failing case:** an order for 1 unit of SKU A is stuck `PENDING`. The job on both instances picks it up, both hear "declined", and both mark `FAILED` and restore stock. `available` goes up by 2 instead of 1, and you later oversell.
   - **Fix:** make every status change `UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`, and touch stock or queue the email only if a row changed. This also covers a slow request handler racing the job.

2. **The reconciliation job has no rule for "provider has no record of this charge".** This happens whenever an instance crashes between the step 2 commit and the step 3 call, or when no attempt ever reached the provider.
   - **Failing case:** the order is `PENDING`, and the provider answers "not found", which is neither `PAID` nor `FAILED`. As written, the order sits there holding stock until the 30-minute alert fires.
   - **Fix:** state that "not found" after the 2-minute cutoff means `FAILED` plus stock restore. Also state what happens if the provider says "still processing" (leave it for the next run).

3. **The idempotency key is globally unique, not scoped to the customer.**
   - **Failing case:** customer B sends a key that customer A already used, and gets A's order back.
   - **Fix:** make the constraint unique on `(customer_id, idempotency_key)`. Also decide what a repeated key with a different cart returns; I'd return `422` rather than silently returning the old order.

4. **The doc doesn't say where `unit_price` and `total` come from.** If they come from the cart the client sends, a client can set its own price. State that the server looks prices up and computes the total, and name the source, since there is no price table in the data model.

## Smaller items, can be fixed as you build

- **Deadlocks in step 2:** two orders containing SKUs A and B, updated in opposite order, can deadlock. Update stock rows in sorted SKU order.
- **Lost confirmation email:** a crash after the `PAID` commit but before the email is queued loses it. At 200 orders a day this is acceptable debt, but say so in the doc, or write the email job in the same transaction as `PAID`.
- **Keys:** the data model lists no primary keys. `stock.sku` and `order_items (order_id, sku)` need them.
- **Missing tests:** add these to the integration list:
  - two reconciliation runs on the same order;
  - a crash before the charge (provider says "not found");
  - concurrent duplicate `POST /orders`;
  - two buyers racing for the last unit;
  - the same key with a different cart.

VERDICT: READY WITH CHANGES
