The design is sound and close to ready. Fix four things before you start. Each is a few lines of design and a few tests, so you can still start tomorrow if you add them to the doc first.

The core choices are right and I wouldn't change them: the conditional stock decrement, the unique idempotency key, calling the payment provider outside any transaction, using the order id as the provider's idempotency key, sending email only after commit, and running reconciliation with an alert.

## Fix before building

**1. Two writers can settle the same order and restore stock twice.** Both service instances can run the reconciliation job, and the request path and the job can also overlap. Steps 5 and 6 don't say what happens if two of them settle the same order.
- Example: an order holds 2 units of SKU A, so stock goes 10 → 8. The charge times out and the order stays `PENDING`. At the next run, the job on both instances asks the provider, both hear "declined", and both mark the order `FAILED` and restore stock. Stock ends at 12 when it should be 10.
- Fix: every status change is a guarded update, `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Only restore stock if that update changed exactly one row. Also decide where the job runs: on one instance, or on both with `FOR UPDATE SKIP LOCKED`. Write that decision down.

```mermaid
stateDiagram-v2
    [*] --> PENDING: POST /orders (stock reserved)
    PENDING --> PAID: charge succeeded (request path or reconciliation job)
    PENDING --> FAILED: declined, or no charge found (stock restored)
    PAID --> [*]
    FAILED --> [*]
```
Each arrow out of `PENDING` must happen at most once, whichever writer gets there first.

**2. The reconciliation job has no rule for "the provider has no record of this charge."** The process can crash after step 2 commits but before step 3 sends the charge. The provider then never saw the order, and the job can't settle it as `PAID` or `FAILED`. It stays `PENDING` with stock held until the 30-minute alert fires, and it keeps firing.
- Fix: "not found" for an order older than 2 minutes means `FAILED` and stock restored, using the same guarded update. Also state that the job restores stock when it settles `FAILED`. The doc only says that for step 5.

**3. Idempotency key scope and concurrent duplicates aren't specified.**
- If the unique constraint is on `idempotency_key` alone, a key collision between two customers returns customer A's order to customer B. Make it unique on `(customer_id, idempotency_key)`.
- Two identical `POST`s that arrive at the same moment both decrement stock. The second one's insert then fails on the unique constraint. That failure must roll back and return the existing order, not a `500`. Say so.
- Decide what happens when a repeated key arrives with a different cart. Either return the original order or return `422`. Write down which.

**4. The test plan doesn't cover the riskiest code.** Reconciliation and concurrency have no tests listed. Add:
- The reconciliation job settles a `PENDING` order as `PAID`, as `FAILED` (with stock restored), and as "not found" (`FAILED`, stock restored).
- Two reconciliation runs at once on the same order restore stock exactly once.
- A decline in the request path restores stock.
- Two concurrent buyers of the last unit: one succeeds, one gets `409`, and stock ends at 0.
- Two concurrent `POST`s with the same idempotency key produce one order and one stock decrement.

## Worth stating, not blocking

- **Deadlocks:** two carts that share SKUs, updated in different orders, can deadlock each other. Update SKUs in sorted order.
- **Prices:** say that `unit_price` and `total` come from the server's catalog and not from the client's cart.
- **Confirmation emails:**
  - Orders the reconciliation job settles as `PAID` need a confirmation email too. The doc only covers the request path.
  - If the process crashes between the `PAID` commit and queuing the email, the email is lost. If the queue lives in Postgres, enqueue inside the same transaction to close that gap. Otherwise, write the gap down as accepted.
- **Shared transactions:** step 2 changes `stock` and `orders` in one transaction, and so does step 5. That means "no module reads another module's tables" really means the inventory module's functions accept the caller's transaction. State that so nobody "fixes" it into two transactions later.
- **Client polling:** a client that got `202` needs a `GET /orders/{id}` to learn the outcome. It isn't in the doc.
- **Schema:** make `sku` the primary key on `stock`, add `CHECK (available >= 0)`, and give `order_items` a primary key.

At 2,000 orders a day, load isn't a concern. Two instances and one Postgres database are plenty.

VERDICT: READY WITH CHANGES
