This design is close to ready. You can start building tomorrow if you first settle four points in the doc, each about an hour of design work. Revision 3 already gets the hard parts right: stock is reserved in one transaction with a guarded `UPDATE`, the payment call happens outside any transaction, the order id is reused as the provider's idempotency key, email can't fail an order, and a reconciliation job plus a 30-minute alert catch stuck orders. The layering (thin routes, an `OrderCheckout` service, separate modules) is also sound.

## Fix before building

**1. Guard every status change so an order can only be settled once.** Two things can settle the same order: the request path (steps 4–5) and the reconciliation job. The job may also run on both instances. Without a guard, the stock gets restored twice.
- *Example:* SKU `A` has 0 units available and order X (1 unit) is `PENDING`. Both instances' reconciliation jobs ask the provider about X, both hear "declined", and both run "mark FAILED and restore stock". `available` becomes 2 when it should be 1, so you can oversell by one unit.
- *Fix:* every transition is `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Only touch stock if that update changed exactly one row. That one rule covers both instances, the request path, and retries.

```mermaid
stateDiagram-v2
    [*] --> PENDING: POST /orders (stock reserved)
    PENDING --> PAID: charge succeeded (request path or reconciliation)
    PENDING --> FAILED: declined, or no charge found (stock restored once)
    PAID --> [*]
    FAILED --> [*]
```

**2. Decide what reconciliation does when the provider has no charge.** If the instance crashes after step 2 commits but before step 3 sends the charge, the order is `PENDING` and the provider has never heard of it. Step 6 only covers `PAID` or `FAILED` answers.
- *Example:* order Y is committed, the instance restarts, and reconciliation asks the provider about Y. The answer is "not found", and the design doesn't say what happens next. Y sits there until the 30-minute alert fires, with its stock held the whole time.
- *Fix:* say explicitly that "not found" after the 2-minute grace period means `FAILED` plus restoring the stock, through the same guarded path as in point 1. Alternatively, retry the charge with the same idempotency key. Pick one and write it down.

**3. Say where prices come from.** The client sends "the cart", and there is no product or price table. If `unit_price` and `total` come from the request body, a client can set its own price.
- *Example:* a client posts `{sku: "A", quantity: 1, unit_price: 0.01}` and gets charged $0.01.
- *Fix:* state that the server looks up prices from a named source (a catalog service or a table) and computes `total` itself.

**4. Scope the idempotency key to the customer.** A unique constraint on `idempotency_key` alone means a repeated key from a *different* customer returns someone else's order.
- *Fix:* make the constraint unique on `(customer_id, idempotency_key)`. If the same key arrives with a different cart, return `422` rather than the old order.

## Small additions (worth doing, not blockers)
- **Lock SKUs in a fixed order.** Sort SKUs before the `UPDATE`s in step 2. Otherwise, two carts with `[A, B]` and `[B, A]` can deadlock each other in Postgres.
- **Email can be lost on a crash.** "Commit, then queue" drops the email if the process dies between the two steps. Writing the email job in the same transaction as `PAID` (an outbox row) closes that gap. If you'd rather accept the risk at this volume, write that down in the doc.
- **Module boundary in step 2.** Orders and inventory share one transaction. Say in the doc that inventory exposes a `reserve(tx, items)` function instead of orders writing to `stock` directly, so the "no module reads another module's tables" rule holds.

## Tests to add to the plan
The list is good. Add these cases, because they cover the risky paths above:
- reconciliation settles `PAID`, `FAILED`, and "not found"
- two settlers racing on one order: stock is restored exactly once
- two concurrent duplicate `POST /orders` with the same key: one order, stock reserved once
- a client-supplied price is ignored
- the same key from a different customer, and the same key with a different cart

Write tests 1–2 first, since they lock in the fix for point 1.

VERDICT: READY WITH CHANGES
