I reviewed `design.md` (revision 3). The core is sound, so you can start tomorrow, but first write a few decisions into the doc. Most of them are one line each. The most important one: settling an order isn't protected against running twice, and with two instances that can give back the same stock twice.

## What's already right
- Stock is reserved with a single conditional `UPDATE`, in the same transaction as the order insert. This can't oversell.
- The payment call happens outside any database transaction, and the order id is the provider's idempotency key. Retries can't double-charge.
- The email is sent after the commit and can't fail the order.
- When the payment result is unknown, the client gets `202`, a reconciliation job settles the order later, and an alert fires after 30 minutes.
- At 2,000 orders a day, one Postgres database and two instances are plenty.

## Changes to make before building

**1. Each status change must only happen once (must fix).** Both instances will run the reconciliation job, and the job can also race the original request. Nothing in the design stops two of them from settling the same order.
*Example:* an order for the last unit of a SKU gets declined. Instance A and instance B both mark it `FAILED` and both restore stock. `available` goes from 0 to 2 when it should be 1, and the shop then sells a unit it doesn't have.
*Fix:* every status change becomes `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Restore stock only if that update changed a row.

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved, order inserted
    PENDING --> PAID: charge succeeded (only if still PENDING)
    PENDING --> FAILED: declined or no charge exists (only if still PENDING); stock restored once
    PAID --> [*]
    FAILED --> [*]
```

**2. Say what reconciliation does when the provider has no record of the charge (must fix).** If the instance crashes after committing the `PENDING` order but before calling the provider, the provider has no charge to report. Step 6 only covers the two outcomes `PAID` and `FAILED`. Decide which one applies here. I suggest `FAILED` plus restoring the stock. Also write down why that's safe: the longest the request path can keep retrying (4 attempts × 5 s plus backoff) is well under the 2-minute cutoff.

**3. Settle the conflict between the module rule and step 2.** The doc says "no module reads another module's tables", but step 2 writes to both `stock` (inventory) and `orders` in one transaction. Pick how that works. I suggest the inventory module exposes `reserve(tx, items)` and `release(tx, items)`, which take the caller's transaction. Then `OrderCheckout` owns the transaction without touching the `stock` table directly.

**4. Lock stock rows in a fixed order.** If two carts update the same SKUs in different orders, the database can deadlock. Sort the SKUs before updating, and combine duplicate lines for the same SKU.

**5. Give the `202` client a way to get the result.** Add `GET /orders/{id}` so the client can poll for the final status.

**6. Limit which errors get retried.** Retry only timeouts and 5xx responses. A decline or other 4xx response should go straight to step 5.

## Smaller items (can be done while building)
- **Indexes:** `stock.sku` as the primary key, a primary key on `order_items`, the unique index on `idempotency_key`, and an index on `orders(status, created_at)` for the reconciliation query.
- **Reused key with a different cart:** decide what happens when the same idempotency key arrives with a different cart. Usually that's a `422`, not the old order.
- **Lost emails:** a crash between the `PAID` commit and queuing the email loses the email. If that matters, write an "email to send" row in the same transaction as the `PAID` update (an "outbox" table) and send from there. Otherwise, write down that you accept the loss.

## Tests to add to the plan
The current list doesn't test reconciliation at all. Add:
- Reconciliation settles an order as `PAID`, settles it as `FAILED`, and handles "no charge found".
- Two reconciliation runs on the same order restore stock only once.
- Two concurrent `POST /orders` with the same key produce one order.
- Two buyers try for the last unit: one gets the order, the other gets `409`.
- A decline restores stock.

VERDICT: READY WITH CHANGES
