The design is mostly ready. The flow, the idempotency approach and the failure handling are sound. Make three small fixes before you build, because each one is cheaper to put in the design than to retrofit later. None of them changes the architecture.

## Must fix before building

**1. A declined order can get its stock back twice.** Step 5 and the reconciliation job both mark an order `FAILED` and restore stock. Nothing stops two of these from acting on the same order. You run two instances, so by default the reconciliation job runs twice every 5 minutes.
- **Example:** an order for the last unit of a SKU stays `PENDING`. Both instances' jobs see it, the provider says "declined", and both restore stock. `available` ends at 2 when it should be 1, so you oversell.
- **Fix:** make every status change conditional, e.g. `UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`. Only restore stock or queue the email if that update changed one row. Also give the job a single runner: either a Postgres advisory lock, or `SELECT … FOR UPDATE SKIP LOCKED`.

```mermaid
stateDiagram-v2
    [*] --> PENDING: POST /orders (stock reserved)
    PENDING --> PAID: charge succeeded (request or reconciliation)
    PENDING --> FAILED: charge declined (request or reconciliation), stock restored once
    PAID --> [*]
    FAILED --> [*]
```
Allow only these moves, and only out of `PENDING`. Whichever process changes the row first does the side effects (restoring stock, queuing the email).

**2. An order can be paid but the customer never gets a confirmation email.** Step 4 commits `PAID` and then queues the email as a separate step.
- **Example:** the instance crashes between the commit and the enqueue, so the order is `PAID` with no email. Or the charge succeeds but the instance crashes before marking `PAID`. Reconciliation then marks it `PAID`, but the design never says reconciliation sends the email.
- **Fix:** write the email job into an outbox table in the same transaction that sets `PAID`, and use that same path in both the request and reconciliation.

**3. Reconciliation has no rule for when the provider has no record of the charge.** This happens when every attempt timed out before reaching the provider.
- **Fix:** decide whether that case becomes `FAILED` (and restores stock) or gets one more charge attempt using the same idempotency key. Also write down the invariant that keeps reconciliation and the request from racing: the 2-minute threshold must be longer than the longest possible retry window (4 attempts × 5 s plus backoff, about 30 s). Then no request can still be charging once reconciliation acts.

## Add to the test plan
The plan has no tests for reconciliation at all. Add these:
- Reconciliation settles an order as `PAID` (and queues the email) and as `FAILED` (and restores stock).
- Reconciliation finds no charge at the provider.
- Two reconciliation runs at once restore stock exactly once.
- Two concurrent `POST /orders` with the same key produce one order and one stock reservation. The second request should hit the unique constraint and get the existing order back, not a 500.
- A crash after the charge succeeds but before `PAID` is recorded still ends as `PAID` with an email sent.

## Worth clarifying (not blocking)
- **Module boundaries vs. the shared transaction:** steps 2 and 5 update `stock` and `orders` in one transaction, which seems to conflict with "no module reads another module's tables". State that inventory exposes `reserve` and `release` functions that join the caller's transaction, so orders never touches `stock` directly.
- **After a `202`, how does the client find out the result?** There's no `GET /orders/{id}` in the design. Add one, or say how the client learns the outcome.
- **Same `Idempotency-Key` with a different cart:** decide whether that returns the original order or `422`. Storing a hash of the request body makes the check cheap.

The volume (about 2,000 orders a day) is no concern for this setup. The 30-minute alert backed by a 5-minute reconciliation job is a good safety net.

VERDICT: READY WITH CHANGES
