The design is sound at its core and you can start building tomorrow, provided you settle three gaps in the document first. Each one is a few lines of design text, not a rework.

The parts that hold up: the stock reservation in step 2 cannot oversell, the charge runs outside any transaction, the provider-side idempotency key (order id) prevents double charges, and a crash after a successful charge is recovered by the reconciliation job.

## Fix before building

**1. Reconciliation does not say what happens when the provider has no record of the charge (high).**
- **Evidence:** step 6 (lines 36–38) says the job settles orders "as `PAID` or `FAILED`", which assumes the provider always has an answer.
- **Failing case:** the instance crashes after the step 2 commit and before the step 3 charge call. The order is `PENDING`, stock is reserved, and no charge exists. The job asks the provider and gets "not found".
- **Result as written:** the order stays `PENDING` forever and the stock stays locked. The only signal is the 30-minute alert.
- **Fix:** state that "not found" after the 2-minute cutoff settles as `FAILED`.

**2. Reconciliation does not say that `FAILED` restores stock (high).**
- **Evidence:** only step 5 (declines, lines 33–34) mentions restoring stock; step 6 does not.
- **Failing case:** every attempt times out, the provider later reports a decline, and the job marks the order `FAILED`. If built as written, the reserved units are never returned.
- **Fix:** say that the job uses the same "mark `FAILED` and restore stock" transaction as step 5.

**3. Status changes are not guarded, so stock can be restored twice (high).**
- **Evidence:** there are two instances (line 6), and nothing says the job runs on only one or that transitions check the current status.
- **Failing case:** both instances run the job at the same minute and both see order X (quantity 1) as `PENDING` and declined. Both restore stock, so `available` rises by 2 instead of 1 and a unit that does not exist gets sold later.
- **Fix:** make every transition `UPDATE orders SET status = … WHERE id = … AND status = 'PENDING'`, and restore stock only if that update changed a row.

## Fix during the build

- **Idempotency key is unique on its own, not per customer (medium).** In lines 20–21, if customer B sends a key that customer A already used, B gets A's order back. Make the constraint `(customer_id, idempotency_key)`.
- **Same key with a different cart is undefined (medium).** As written, the old order is returned silently. Store a hash of the request and reject a mismatch.
- **Tests miss the riskiest paths (medium).** Lines 49–51 have no test for the reconciliation job (paid, declined, not found), two simultaneous `POST /orders` with the same key, two buyers racing for the last unit, or stock being restored after a decline.
- **No way for the client to learn the outcome after a `202` (low).** The design defines no `GET /orders/{id}` or equivalent.
- **Confirmation email can be lost (low).** In step 4, a crash between the `PAID` commit and queueing the email means it is never sent. Accept this explicitly or have the job re-queue it.
- **Multi-item orders can deadlock (low).** Two carts holding the same SKUs in opposite order will deadlock in step 2. Update the stock rows in sorted SKU order.
- **Data model omits keys and constraints (low).** There are no primary keys, no `CHECK (available >= 0)`, and no column for the provider's charge id, which you will need for support and refunds.

## Speculative, worth a quick check

- **Request duration:** the worst case in step 3 is about 27 seconds (four 5-second attempts plus backoff). If the load balancer times out sooner, clients see an error instead of the `202`.
- **Price source:** the design does not say whether `unit_price` and `total` come from the server or from the client's cart. If they come from the client, they can be tampered with.
- **Provider key retention:** some providers expire idempotency keys after about 24 hours. This only matters if an order stays `PENDING` that long.

VERDICT: READY WITH CHANGES
