The design is sound enough to start building tomorrow, provided you fix one real defect and write down four unspecified behaviours first. All of it is an hour or two of edits to design.md, not a redesign.

The core is right: stock is reserved with a conditional update, the charge happens outside any transaction with the order id as the provider idempotency key, and a reconciliation job settles unknown outcomes.

## Must fix before building

**1. Stock can be restored twice for one failed order.**
Nothing in steps 5 and 6 says settling an order is conditional on it still being `PENDING`, or that only one copy of the reconciliation job runs.

- **Failing case:** an order for 3 units of a SKU is declined, and the job runs on both instances (the design doesn't say where it runs). Both copies see the order as `PENDING`, both mark it `FAILED`, and both add 3 back.
- **Wrong result:** `available` goes up by 6 instead of 3, and you later sell stock you don't have.
- **Same race elsewhere:** a slow request handler and the job can also settle the same order, although the 2-minute age filter makes that rare.
- **Fix:** make every settle `UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`, and restore stock in the same transaction only if that update changed a row. Add a test that settles the same order twice.

**2. The reconciliation job has no rule for "provider has no record of this charge".**
Step 6 only allows `PAID` or `FAILED`.

- **Failing case:** an instance crashes after step 2 commits and before step 3 calls the provider. The order is `PENDING`, stock is held, and no charge exists.
- **Wrong result:** as written, the job has no defined outcome, so the order stays `PENDING` and holds stock until the 30-minute alert.
- **Fix:** state that "not found" settles as `FAILED` with stock restored, and that "still processing" leaves the order `PENDING`. Also say explicitly that the job's `FAILED` path restores stock, as step 5 does.

**3. The idempotency key is unique on its own, not per customer.**
- **Failing case:** two customers send the same key, and the second gets the first customer'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`).
  - That a customer retrying after a decline must send a new key; otherwise they get the `FAILED` order back forever.

**4. The source of prices is not stated.**
The cart comes from the client and there is no price table. Say where `unit_price` and `total` come from; they must be computed server-side, never taken from the request.

**5. The test plan misses the riskiest paths.**
Add these to the list:
- Reconciliation job: paid, declined, not found, and provider unreachable.
- Two concurrent buyers for the last unit.
- Two concurrent `POST /orders` with the same key.
- A crash between steps 2 and 3, and between the charge and marking `PAID`.

## Worth fixing, but can follow in week one

- **Deadlocks on multi-item orders.** Two orders reserving the same two SKUs in opposite order will deadlock, and Postgres will abort one. Reserve SKUs in sorted order.
- **Confirmation email can be lost.** A crash between committing `PAID` and queueing the email drops it silently. Either write the email job in the same transaction as `PAID`, or accept the loss and say so in the design.
- **Schema gaps.**
  - No primary keys or foreign keys are listed.
  - There is no `CHECK (available >= 0)` on `stock`.
  - There is no column for the provider's charge id, which you will want for support and refunds.
- **The `202` path has no follow-up.** The client needs a `GET /orders/{id}` to poll, and it isn't in the design.
- **Scope.** Cancellation and refunds are absent. That is fine, but state that they are out of scope, since they will add statuses later.

VERDICT: READY WITH CHANGES
