You can start building tomorrow: the core of the design is sound, but four gaps in `design.md` need a decision written into it before you build the parts they touch. None requires restructuring; each is a few lines of spec plus a test.

The parts that hold up are the conditional stock update, charging outside the transaction, using the order id as the provider idempotency key, and the `202` plus reconciliation path for unknown outcomes.

## Fix before building the affected part

**1. Stock can be restored twice for one failed order (high).**
- **Evidence:** There are two instances (line 6), and the design does not say where the reconciliation job runs or that status changes are conditional (lines 33–38).
- **Failing case:** Both instances run the job and see the same `PENDING` order with a declined charge. Each marks it `FAILED` and adds the quantity back, so `available` rises by 2 for 1 unit and you oversell.
- **Fix:** Make every transition `UPDATE orders SET status = … WHERE id = … AND status = 'PENDING'`, and restore stock only if that changed a row. This also covers a slow request racing the job.

**2. Reconciliation does not cover an order that was never charged (high).**
- **Evidence:** Step 6 settles orders as `PAID` or `FAILED` from the provider's charge status and names no other outcome.
- **Failing case:** An instance crashes after the step 2 commit and before the step 3 call. The provider has no record of the charge, so the order stays `PENDING` and holds its stock indefinitely; the 30-minute alert is the only signal.
- **Fix:** Specify "no charge found" as `FAILED` with stock restored. Also state that the reconciliation `FAILED` path restores stock, since only step 5 says so today.

**3. Idempotency key scope and the concurrent duplicate are undefined (medium).**
- **Evidence:** Line 20 says "a unique constraint" on a client-generated key, with no scope.
- **Failing case, scope:** If the constraint is global, customer B sending a key that customer A already used gets customer A's order back.
- **Failing case, concurrency:** Two simultaneous requests with the same key both pass the lookup. The second hits the unique violation after decrementing stock and returns an error instead of the existing order.
- **Fix:** Make it unique on `(customer_id, idempotency_key)`, and on a unique violation roll back and return the existing order. Also decide what the same key with a different cart returns; `422` is the usual choice.

**4. Reconciliation assumes the provider can look up a charge by order id (medium, verify today).**
- **Evidence:** Step 6 "asks the provider for the charge status", but `orders` has no column for a provider charge reference.
- **Risk:** Some providers cannot look a charge up by idempotency key, and after a timeout you never received their charge id.
- **Fix:** Confirm your provider supports lookup by your own reference, such as metadata or a merchant reference. If it doesn't, step 6 needs a different mechanism.

## Minor, fold in as you go

- **Deadlock on multi-item orders:** Two orders updating SKUs A then B and B then A can deadlock in step 2, and Postgres aborts one. Update the SKUs in sorted order.
- **Confirmation email can be lost:** In step 4 the email is queued after the commit, so a crash in between means a paid order with no email. The design also doesn't say the reconciliation `PAID` path queues one. Either write the email job in the same transaction or have reconciliation send it.
- **Retry rules are incomplete:** Step 3 covers only timeouts and step 5 only declines. Provider 5xx, rate limits and invalid-request errors have no defined handling.
- **Missing constraints in the data model:** No primary keys are stated for `order_items` or `stock`, there is no `CHECK (available >= 0)`, and `status` is free `text`.
- **Test plan gaps (lines 47–51):** There are no tests for the reconciliation job (paid, declined, no charge found, run twice), a crash between steps 2 and 3, two concurrent buyers for the last unit, or concurrent duplicate `POST /orders`.

## Speculative, worth a quick check

- **Request duration:** The worst case is 4 attempts × 5 s plus backoff, so over 20 s. If the load balancer or client times out sooner, the client never sees the `202`; a retry with the same key recovers, so this is tolerable.
- **Price source:** The design doesn't say where `unit_price` and `total` come from. If they come from the client's cart, they can be tampered with.
- **Retry after a decline:** The same key returns the `FAILED` order, so the client must generate a new key to try another card. This is worth stating in the API contract.

VERDICT: READY WITH CHANGES
