The design is close: you can start tomorrow, but fix five gaps first. Each one is a small change to the doc. None needs a redesign. The basic structure holds up: the stock reservation can't oversell, the same idempotency key goes to the payment provider on every retry, nothing calls the network while a database transaction is open, and there's a reconciliation job plus an alert for stuck orders. Most of the gaps are in what happens after the first attempt, especially in the reconciliation job.

## Fix before or while building

**1. Stock can be restored twice because both instances run the reconciliation job.** You have two instances, and the doc doesn't say the job runs on only one. Example: order X is `PENDING`, and the provider now reports it declined. Instance A and instance B both pick it up in the same 5-minute run. Each one marks it `FAILED` and adds its quantity back. If the order held 1 unit and stock was 0, stock ends at 2 instead of 1, so you can sell a unit you don't have. The same thing can happen if a slow request and the job both settle the same order.

```mermaid
sequenceDiagram
    participant A as Instance A job
    participant DB as Postgres
    participant B as Instance B job
    A->>DB: order X is PENDING, provider says declined
    B->>DB: order X is PENDING, provider says declined
    A->>DB: mark FAILED, stock +1 (now 1)
    B->>DB: mark FAILED, stock +1 (now 2, wrong)
```

Fix: every status change should be `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Only restore stock if that update changed exactly one row. To stop duplicate work, add `FOR UPDATE SKIP LOCKED` or a Postgres advisory lock to the job.

**2. The doc doesn't say what happens when the provider has no record of the charge.** Example: the instance commits the `PENDING` order in step 2 and then crashes before step 3. No charge was ever sent. Reconciliation asks the provider, which answers "not found". The doc only describes settling as `PAID` or `FAILED`. Decide what "not found" means, either mark `FAILED` or retry the charge, and say explicitly that when reconciliation settles an order as `FAILED` it also restores stock. Right now only step 5 says that.

**3. The doc doesn't say where prices come from.** `order_items.unit_price` and `orders.total` exist, but no table holds prices, and step 1 says the client sends "the cart". If prices come from the request body, a client can send `unit_price: 0.01` and be charged that amount. Name the source of truth for prices: a catalog service, a `prices` table, or something else.

**4. Concurrent orders can deadlock on stock updates.** Example: order A updates SKU-1 and then SKU-2, while order B updates SKU-2 and then SKU-1. Postgres kills one of the transactions, and that customer gets a 500 instead of a 409 or a success. Fix: sort SKUs before updating, and merge duplicate SKUs in the cart into one line.

**5. The reconciliation job isn't in the test plan.** It's the most error-prone part of the design and it has no tests listed. Add integration tests for:
- the job settling a `PENDING` order as `PAID` and as `FAILED`, with stock restored
- the provider answering "not found"
- two job runs racing on the same order, which covers issue 1
- two simultaneous `POST /orders` with the same key, so the unique-constraint error is caught and the existing order is returned
- a two-SKU order, which covers issue 4

## Worth deciding, not blocking

- **Lost confirmation emails.** Step 4 commits first and queues the email afterwards. If the instance crashes in between, the email is never sent. An outbox row written in the same transaction fixes this. Also say whether reconciliation sends the email when it marks an order `PAID`.
- **Idempotency key scope.** The key is unique across the whole table. Scoping it per customer, `(customer_id, idempotency_key)`, is safer. Also decide what happens when a key is reused with a different cart. The usual answer is to return `422` rather than quietly returning the old order.
- **Request length.** Four attempts at 5 s each plus backoff takes about 30 s. Check that the load balancer's idle timeout and the client's timeout are longer than that, or lower the retry budget.
- **Module boundary.** Step 2 puts the inventory and orders writes in one transaction. That's fine if inventory exposes a function that accepts the caller's transaction. Write that down so nobody "fixes" it later by having orders write directly to the `stock` table.

The doc's scale assumption (2,000 orders a day) is low enough that none of these issues needs extra infrastructure.

VERDICT: READY WITH CHANGES
