**The design is sound at its core and you can start building tomorrow, but five gaps should be closed in the doc first (about an hour of decisions, no redesign).** Three of them sit in the reconciliation job, which is the least specified part of the flow.

What already holds up: the conditional stock update prevents overselling, the charge runs outside any transaction, using the order id as the provider idempotency key prevents double charges, and a crash after a successful charge is recovered by reconciliation. The scale (2,000 orders a day) is no concern for this architecture.

## Fix before building

**1. Stock can be restored twice for one failed order (High).**
- **Evidence:** Context says "two service instances"; step 6 does not say where the reconciliation job runs. Nothing in steps 4–6 says a status change only applies if the order is still `PENDING`.
- **Failing case:** Both instances run the job at the same time and both see order A as `PENDING` with a declined charge. Both mark it `FAILED` and each adds the quantity back. An order for 1 unit leaves `stock.available` 1 higher than reality, and you later oversell.
- **Fix:** Make every transition `UPDATE orders SET status = ... WHERE id = ... AND status = 'PENDING'`, and restore stock or queue the email only if that update changed a row. This also covers the request path and the job overlapping.

**2. Reconciliation has no rule for "provider has no record of this charge" (High).**
- **Evidence:** Step 6 says the job settles orders "as `PAID` or `FAILED`", which covers only those two provider answers.
- **Failing case:** The instance crashes after step 2 commits and before step 3 calls the provider. The order is `PENDING`, stock is reserved, and no charge exists. The order stays `PENDING` until the 30-minute alert, and someone fixes it by hand.
- **Fix:** State that "not found" on an order older than 2 minutes means `FAILED` plus stock restore.

**3. Reconciliation does not say it restores stock or sends the email (Medium).**
- **Evidence:** Steps 4 and 5 specify the email and the stock restore; step 6 specifies neither.
- **Fix:** Have the job call the same two "mark paid" and "mark failed" operations in `OrderCheckout` that the request path uses, so the side effects cannot drift.

**4. The scope of the idempotency key's unique constraint is not stated (Medium).**
- **Evidence:** Step 1 says the key is "under a unique constraint" and "a repeated key returns the existing order". The key is client-generated.
- **Failing case:** If the constraint is on `idempotency_key` alone, customer B sending a key customer A already used gets customer A's order back.
- **Fix:** Make it unique on `(customer_id, idempotency_key)`. Also decide what the same key with a different cart returns (suggest `422`).

**5. The design does not say where prices come from (Medium, open question).**
- **Evidence:** The client "sends the cart"; there is no price or catalog table, and no step computes `unit_price` or `total`.
- **Risk:** If the service trusts prices in the request, a client can set its own.
- **Fix:** Name the server-side price source and state that `total` is computed by the service.

## Minor, fix as you build

- **Deadlocks on multi-item orders.** Two orders reserving the same two SKUs in opposite order can deadlock in step 2, and Postgres aborts one. Update stock rows in sorted SKU order.
- **Concurrent duplicate `POST /orders`.** The second request hits the unique violation rather than finding an existing row. State that it catches the violation and returns the existing order.
- **Retry conditions.** Step 3 does not say what is retried. Retry only timeouts and 5xx, never declines.
- **Worst-case request time.** Four attempts at 5 s plus backoff is about 30 s. Check that it fits under the load balancer's timeout.
- **Lost confirmation email.** In step 4, a crash after the commit and before queueing loses the email. Accept and note it, or queue it in the same transaction.
- **No way to learn the outcome after a `202`.** The design has no `GET /orders/{id}` or other route for the client.
- **Retry after a decline.** The same idempotency key returns the `FAILED` order, so the client needs a new key for a new card. Document it.
- **Data model.** No primary keys are listed for `order_items` or `stock`, there is no `CHECK (available >= 0)`, and no column stores the provider's charge id (needed for support and refunds).
- **Test plan.** It has no tests for the reconciliation job, which is where the highest-risk logic lives. Add cases for:
  - paid, declined, not found and still unknown;
  - two job runs on the same order;
  - a crash between steps 2 and 3;
  - concurrent duplicate posts;
  - a multi-item order where one item is out of stock.

## Speculative, verify rather than fix

- **Provider lookup by order id.** Step 6 assumes the provider can return a charge's status given your order id. Some providers only look up by their own charge id or by metadata; check before building the job.
- **Cancel and refund.** There is no cancelled or refunded status. That is fine if it is out of scope for this revision, but say so in the doc.

VERDICT: READY WITH CHANGES
