The design in `design.md` is sound and you can start building tomorrow, provided you close three gaps in the spec first (about an hour of writing, no redesign). I found no flaw in the core flow: the stock reservation cannot oversell, the payment call is outside the transaction, the provider idempotency key prevents double charges, and the reconciliation job covers unknown results.

## Fix before building

**1. Stock can be restored twice for one order — High**
- **Case:** an order for 1 unit of SKU A is `PENDING` with `available = 0`. The reconciliation job on instance 1 and the same job on instance 2 (or step 5 of a slow request) both see it as `PENDING`, both mark it `FAILED`, and both add the unit back.
- **Result:** `available = 2` where it should be 1, so the next customer buys a unit that does not exist.
- **Fix:** make every status change conditional, `UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`, and restore stock only if that update changed a row. Also state whether the job runs on one instance or both.

**2. The reconciliation job has no rule for "provider has no such charge" — High**
- **Case:** the instance crashes after step 2 commits and before step 3 reaches the provider. The job asks the provider about the order and gets "not found", which is neither `PAID` nor `FAILED`.
- **Result:** as written, the order stays `PENDING` and holds its stock indefinitely; the only signal is the 30-minute alert.
- **Fix:** specify that "not found" settles as `FAILED`, and that every `FAILED` settlement by the job restores stock, as step 5 does.

**3. The source of prices is not stated — High if prices come from the client, otherwise a documentation gap**
- **Case:** the client sends the cart, and there is no price or product table in the data model. If `unit_price` is taken from the request, a customer can post a 100.00 item at 0.01 and be charged 0.01.
- **Fix:** state where `unit_price` and `total` come from, and that the server computes the charge amount.

## Fix during the build

- **Confirmation email can be lost — Medium.** If the instance crashes after marking the order `PAID` and before queueing the email, no email is sent. The design also does not say whether orders settled as `PAID` by the reconciliation job get one. Write an "email pending" row in the same transaction as `PAID`, or have the job queue it.
- **Tests miss the riskiest paths — Medium.** Add tests for:
  - the reconciliation job settling `PAID`, `FAILED` and "not found";
  - the job running twice on the same order;
  - two simultaneous requests with the same `Idempotency-Key`;
  - two simultaneous buyers of the last unit;
  - a decline restoring stock.
- **Request can outlast the client — Low.** Four attempts at 5 s plus backoff is roughly 30 s, close to typical load balancer timeouts. Since the job already handles unknown results, one retry is enough.
- **Deadlocks on multi-item carts — Low.** Two orders updating SKUs A and B in opposite order will deadlock, and Postgres aborts one as a 500. Update stock rows in sorted SKU order.
- **Idempotency key details — Low.**
  - Make the unique constraint `(customer_id, idempotency_key)` so one customer's key cannot return another's order.
  - Define the response when the same key arrives with a different cart.
  - Document that a retry after a decline needs a new key, otherwise the client gets the `FAILED` order back forever.
- **Schema gaps — Low.** Add primary keys on `order_items` and `stock`, a `CHECK (available >= 0)`, and a column for the provider's charge id, which refunds and support will need.
- **Scope not stated — Low.** Say explicitly that refunds and cancellation are out of scope for this revision.

VERDICT: READY WITH CHANGES
