**Yes, you can start tomorrow, but first add two short rules to the doc.** The design is strong. The stock reservation (one `UPDATE` that also checks availability), the idempotency key in both places, making the payment call outside the transaction, and settling unknown charges in a reconciliation job are all the right calls. At this volume the shape won't need rework. What's missing is the reconciliation job's edge cases, and if nothing is written down, it's easy to build them wrong.

## Must fix before coding (each is a line or two in the doc)

**1. Only settle an order if it is still `PENDING`.** Both instances run the reconciliation job every 5 minutes, and the doc doesn't say an order can only be settled once. Example: a charge is declined and the order is still `PENDING`. Both instances' jobs pick it up at the same moment, and each marks it `FAILED` and adds the stock back. Stock for that SKU goes up by 2× the quantity, so you sell units you don't have. The same thing can happen between the job and a slow request still on step 4 or 5.

```mermaid
sequenceDiagram
    participant A as Instance A job
    participant DB as Postgres
    participant B as Instance B job
    A->>DB: read PENDING orders (sees order X)
    B->>DB: read PENDING orders (sees order X)
    A->>DB: mark X FAILED, add stock back
    B->>DB: mark X FAILED, add stock back again
    Note over DB: stock is now too high
```

Fix: every settle is `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Only add stock back if that update changed a row. The same rule covers steps 4 and 5, so one helper handles all three.

**2. Say what the job does when the provider has no record of the charge.** Example: an instance crashes right after step 2 commits. The order is `PENDING` with stock held, and the charge API was never called. The job asks the provider and gets "not found", which the doc doesn't cover. Right now the order sits there until the 30-minute alert fires, with stock held the whole time. Fix: "not found" for an order older than 2 minutes means `FAILED` and the stock goes back. That's safe because the longest possible charge attempt (4 × 5 s plus backoff) finishes well inside 2 minutes. Also state that the job adds stock back the same way step 5 does.

## Should fix (cheap now, annoying later)

- **Lock SKUs in sorted order in step 2.** Example: order A has SKUs X then Y, and order B has Y then X. If they run at the same time, Postgres can deadlock them, and one customer gets a 500 instead of a 409. Updating rows sorted by `sku` prevents this.
- **Same key sent twice at once.** If two requests with the same key arrive together, the second one hits the unique constraint while inserting. Say that this error rolls back that request's stock changes and returns the existing order, not a 500. Your duplicate-POST test should send the two requests at the same time, not one after the other.
- **Name the email gap as a known tradeoff.** If the service crashes after the `PAID` commit and before the email is queued, the confirmation is lost and nothing retries it. That's acceptable at 200 orders a day, but write it down. The later fix is to write the email request to an outbox table in the same transaction as `PAID`.

## Tests to add

- Reconciliation: charge is paid, charge is declined, charge not found, and two jobs settling the same order.
- Two buyers going for the last unit at the same time (only one should succeed).
- Two orders with overlapping SKUs in opposite order (no deadlock).

## Minor (fine to decide while building)

- **Idempotency key scope.** The key is unique across all customers. Scoping it per customer (`customer_id`, `idempotency_key`) is safer.
- **One transaction across two modules.** Step 2 changes inventory's `stock` table and orders' `orders` table in one transaction. To keep the rule that no module reads another's tables, have the inventory module expose a reserve function that runs inside the caller's transaction.

VERDICT: READY WITH CHANGES
