The design is close, and the core is sound. Stock is reserved before the charge, the charge runs outside the transaction, the provider gets an idempotency key, and reconciliation catches unknown results. The problems below are mostly gaps in the failure paths. The first three need decisions before you write the checkout flow.

I only read the document, so I haven't checked any of this against the payment provider's API.

## Must settle before building

1. **A crash between step 2 and step 3 leaves an order the reconciliation job can't settle.**
   - The case: the instance dies after committing `PENDING` and before calling the provider. The job asks the provider about that order and gets "no such charge". The design doesn't say what happens next, so the stock stays reserved and the 30-minute alert fires.
   - Decide whether "not found" means mark it `FAILED` and restore stock, or charge it now with the same idempotency key. Marking it `FAILED` is simpler.
   - This also assumes the provider can look up a charge by your idempotency key or order id. Please confirm that.

2. **Stock can be restored twice, which means overselling.**
   - The case: a request gets a decline and starts step 5. The reconciliation job picks up the same order and settles it `FAILED` at the same moment. Both restore stock, so 1 unit becomes 2.
   - Every settle needs a guarded update (`UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`). Only the caller who changes a row may restore stock, in the same transaction.
   - Step 6 says "settle as `PAID` or `FAILED`" but never mentions restoring stock or sending the email. Write both out.

3. **The job runs on both instances.**
   - There are two instances, and the design doesn't say which one runs the job. Both running it makes problem 2 more likely. Options are a Postgres advisory lock or `SELECT … FOR UPDATE SKIP LOCKED` on the orders being settled.

## Should fix (correctness and contract)

4. **The module rule contradicts step 2.** Step 2 updates `stock` and inserts into `orders` in one transaction, but "no module reads another module's tables" puts those in different modules. Name the mechanism now, for example a transaction object that `OrderCheckout` passes into both modules. Otherwise this gets decided ad hoc mid-build.

5. **Concurrent duplicate `POST`s.** If two requests arrive with the same key at the same moment, the second hits the unique violation at insert. Today that becomes a 500 unless you catch it, roll back, and return the existing order. Also decide what happens when the key is reused with a different cart. A `422` is the usual answer.

6. **The idempotency key is unique across all customers.** Make it unique on `(customer_id, idempotency_key)`. Otherwise one customer's key can return another customer's order.

7. **Deadlocks in step 2.** If order A reserves `[x, y]` while order B reserves `[y, x]`, they can deadlock. Sort the SKUs before updating.

8. **"Declined" versus "unknown" isn't defined.** Say which provider responses count as a definitive decline (no retry, `FAILED`), which are timeouts or 5xx (retry), and which are 4xx request errors. Without this, a provider 400 could be retried three times or marked as a customer decline.

9. **The confirmation email can be lost.** If the instance dies after the `PAID` commit and before queueing, no email is ever sent. Either write a row to an outbox table in the same transaction as `PAID`, or accept the loss and say so. Your context also lists no queue, so name which one you'll use. Also, the customer's email address isn't in the data model.

10. **Where do prices come from?** `unit_price` and `total` are stored, but the design doesn't say whether the server looks them up or trusts the cart. If the client sends them, that is a pricing hole. State that the server computes the total.

11. **The API contract is thin.**
    - There is no `GET /orders/{id}`, so a client that gets `202` has nothing to poll.
    - Replaying a key should return the original status code.
    - `409` is used for out-of-stock. Say what the body contains, for example which SKU.
    - Authentication and cart validation (empty cart, quantity of 0 or less, unknown SKU) aren't mentioned.

## Schema gaps (cheap to fix now, painful later)

12. No primary keys or foreign keys are listed. `stock.sku` needs a PK and `order_items` needs `(order_id, sku)` as a PK with an FK to `orders`.
13. Add `CHECK (available >= 0)` on `stock` as a backstop against overselling.
14. Add a `CHECK` on `orders.status`, and make `idempotency_key` `NOT NULL`.
15. Add an index on `orders (status, created_at)` for the reconciliation query, and one on `customer_id` if you'll list orders by customer.

## Tests

16. **Reconciliation has no tests listed.** It is the riskiest part of the design. Add cases for:
    - settles as `PAID`
    - settles as `FAILED` with stock restored
    - order never reached the provider
    - the request and the job settling at once, with stock restored exactly once
17. Also missing:
    - concurrent duplicate `POST`s
    - two buyers racing for the last unit (the listed test is single-threaded)
    - multi-SKU orders with a partial failure (stock rolled back)
    - email queue failure not failing the order

## Minor

18. A single request can hold the client for about 20 s or more (four attempts at 5 s plus backoff). Confirm the load balancer and client timeouts allow that, or the client will retry before you answer.
19. Provider idempotency keys usually expire, often after 24 hours. That's fine for 5-minute reconciliation, but note it.
20. Observability stops at the 30-minute alert. Add a metric or log line for reconciliation outcomes and for `409` counts.
21. Nothing covers order cancellation or refunds after `PAID`. That is probably out of scope for v1, but say so.
22. Nothing covers deploys or migrations, for example creating the tables and rolling out two instances while the job runs.
23. Scale is fine. 2,000 orders a day on one Postgres with two instances needs no changes, so I wouldn't add anything for it.

Items 1–3 and 5–9 are an hour or two of writing, not a redesign. Settle them in the doc tomorrow morning and then start building.

VERDICT: READY WITH CHANGES
