Not quite ready to build as written. The overall shape is sound: you reserve stock and create the order in one transaction, call the payment provider outside the transaction with the order id as its idempotency key, and run a reconciliation job for unknown results. But four gaps can cause lost stock, double stock restores, or one customer seeing another customer's order. Each needs a few lines added to the design, not a redesign, so you can fix them today and start tomorrow.

## What the order statuses need to look like

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved, order inserted
    PENDING --> PAID: charge succeeded (request or reconciliation)
    PENDING --> FAILED: declined, or provider has no charge (request or reconciliation)
    note right of FAILED: every path into FAILED must restore stock exactly once
```

Every arrow above must be a conditional update: `UPDATE orders SET status = :new WHERE id = :id AND status = 'PENDING'`. Only the caller that actually changed the row goes on to restore stock or queue the email.

## Problems, by severity

**High**

1. **Status changes aren't guarded, so stock can be restored twice.** The request's decline path, the reconciliation job, and a second instance running the same job can all settle the same order. Example: the request gets "declined" at the same moment the reconciler sees the order is over 2 minutes old. Both mark it `FAILED` and both add the quantity back, so a 1-unit order puts `available` up by 2. The fix is the conditional update above. Also say whether the reconciler runs on one instance or both. If both, the conditional update makes that safe, but say so in the design.
2. **When reconciliation marks an order `FAILED`, nothing restores the stock.** Step 5 restores it, but step 6 only says "settles them as `PAID` or `FAILED`". Every timed-out order that turns out to be declined keeps its units reserved forever. Route both paths through one shared "fail order" operation.
3. **There's no rule for when the provider has never seen the charge.** If the instance crashes after step 2 commits but before step 3 runs, the order is `PENDING` and the provider has nothing under that order id. Reconciliation asks, gets "not found", and the design has no outcome for that, so the order stays `PENDING` forever and the 30-minute alert fires every time. Decide: either mark it `FAILED` and restore stock (safe, because 2 minutes is well beyond the ~25 s maximum retry window), or retry the charge.
4. **The idempotency key is unique across all customers.** Clients generate the keys, so two customers can collide, and the second one gets the first one's order back. Make the constraint `UNIQUE (customer_id, idempotency_key)`. Also, if the same key comes back with a different cart, return `422`; don't silently return the old order.

**Medium**

5. **Prices may come from the client.** The client "sends the cart", and the design never says where `unit_price` and `total` come from. If they come from the request, a client can set its own price. State that prices are looked up on the server, and name the module that owns them (no table for prices exists yet).
6. **The confirmation email can be lost.** "Commits, and then queues the email": if the instance crashes between those two steps, no email is ever sent. The reconciliation path to `PAID` doesn't mention the email at all. Write the email job in the same transaction that sets `PAID` (an outbox table), on both paths.
7. **Two orders reserving several SKUs at once can deadlock.** If two orders lock the same SKUs in opposite order, Postgres kills one of them. Lock SKUs in sorted order and merge duplicate SKUs in the cart before the updates.
8. **The tests leave out the riskiest paths.** Add:
   - reconciliation settling to `PAID`, to `FAILED` (stock restored), and for a charge the provider has never seen
   - two concurrent requests with the same key
   - two buyers racing for the last unit
   - a decline racing the reconciler (the order is settled, and its stock restored, only once)
   - a reused key with a different cart
   - a price sent by the client being ignored

**Low**

9. **One transaction writes both `stock` and `orders`, but modules don't read each other's tables.** Both can hold if the inventory module offers a reserve/release call that runs inside a transaction the caller passes in. Write that down so nobody uses the rule as a reason to split the transaction.
10. **The schema is missing constraints.** Add a primary key on `stock.sku`, `CHECK (available >= 0)`, a primary key on `order_items`, and a `CHECK` on `status`.
11. **The `202` path is slow and unclear for the client.** A client can wait about 25–30 s (four 5 s attempts plus backoff) before getting `202`. Check that this is under the load balancer's timeout. Also say how the client learns the final result: a `GET /orders/{id}` endpoint, or re-sending the same `POST`.

The scale (2,000 orders a day), the single database, and the module split all fit a team of four. I don't see any architecture-level change needed.

VERDICT: READY WITH CHANGES
