**Mostly. The core flow is sound: stock is reserved atomically, the charge happens outside the transaction, and the provider gets a stable idempotency key. But the recovery paths have gaps that would cause real bugs, and they should be fixed in the doc before you code against it.**

## Must fix before building

1. **The reconciler can't tell "never charged" from "charge in flight".**
   - Case: the service crashes after step 2 commits but before step 3 calls the provider. The order sits `PENDING` and the provider has no record of it.
   - Step 6 says to "ask the provider for the status" but not what "not found" means.
   - Fix: say what the reconciler does on "not found". The safest rule is to retry the charge with the same order-id key, or to fail the order only once the provider's idempotency window makes a late charge impossible.
   - Also state how long the provider keeps idempotency keys. Your whole retry story depends on that.

2. **Stock restoration isn't specified for the reconciler.**
   - Step 5 restores stock on a decline. Step 6 settles orders as `FAILED` but doesn't say it restores stock.
   - Case: a timed-out order is later settled `FAILED`, and its units stay lost from `stock.available` permanently.

3. **Status transitions aren't guarded.**
   - The request path and the reconciler can both act on the same order.
   - Case: both see `PENDING`, both mark it `FAILED`, and stock is restored twice, so you oversell.
   - Fix: require every transition to be `UPDATE orders SET status=… WHERE id=… AND status='PENDING'`, and restore stock only if that update changed a row.

4. **The reconciler will run on both instances.** You have two instances behind a load balancer and nothing says only one runs the job. Use `SELECT … FOR UPDATE SKIP LOCKED` or an advisory lock.

5. **Deadlocks in step 2.** A multi-item cart updates several `stock` rows in cart order.
   - Case: cart A is [X, Y] and cart B is [Y, X]. They deadlock.
   - Fix: sort items by `sku` before updating.

6. **The module rules contradict the single transaction.**
   - "No module reads another module's tables" conflicts with one transaction spanning inventory and orders.
   - Decide how `OrderCheckout` passes a shared transaction to both modules (a unit-of-work object, for example) and write it down. Otherwise whoever builds this will decide it ad hoc.

7. **The reconciler has no tests.** It is the riskiest code in the design. Add these cases:
   - settle as `PAID`, settle as `FAILED` with stock restored, and provider "not found";
   - the request path and the reconciler racing on the same order;
   - a crash between the step 2 commit and the charge.

## Should fix (small)

- **Idempotency key scope.**
  - The key is unique globally, not per customer. Make it unique on `(customer_id, idempotency_key)`.
  - Define what happens when the same key arrives with a different cart. The usual answer is `422`.
  - Say that two concurrent requests with the same key resolve through the unique-violation path, which rolls back the stock reservation.
- **The email is a dual write.** A crash between the commit and the enqueue loses the confirmation email. At 2,000 orders a day, either accept that and say so, or add an outbox row written in the same transaction as `PAID`.
- **Schema gaps.** No primary keys or foreign keys are stated (`orders.id`, `stock.sku`, and `order_items(order_id, sku)` with an FK). No `CHECK (available >= 0)` backstops the `UPDATE`.
- **Who computes `total`?** State that the server computes it from current prices. A client-supplied total would be a pricing hole.
- **Undefined details:** auth and ownership of orders, what `GET /orders/{id}` returns so clients can poll after a `202`, and which queue technology you'll use.
- **Test wording.** "Buying the last unit" should be two concurrent buyers of one unit, where exactly one wins.

## What's good

- Idempotent charge key, charge outside the transaction, `202` plus reconciliation, and an alert on stuck orders are the right shape.
- The tests use a fake provider and cover timeout-then-success.
- The design is sized sensibly for 2,000 orders a day, so there is no over-engineering to cut.

Items 1 to 6 are about an hour of editing the doc, not a redesign. Do them tomorrow morning and then start.

VERDICT: READY WITH CHANGES
