The design is solid and you can start tomorrow, but a handful of gaps need a decision first. The most important ones are about what happens when two things touch the same order at once, and fixing them takes a few lines of text, not a redesign. The failure-handling in steps 3 and 6 is already well thought out: the idempotent charge, no transaction held open during the payment call, and a reconciler as a safety net.

I haven't run anything. This is a read-through of `design.md`.

## High: decide these before writing code

1. **Two things can settle the same order at once.** The request path (steps 4 and 5) and the reconciler (step 6) can both act on one `PENDING` order. For example, a slow request finishes at 2m10s while the reconciler picks up the same order. With nothing guarding the status change, a stock restore can run twice, or an order can flip from `PAID` to `FAILED`. Make every settle an `UPDATE ... WHERE status = 'PENDING'`. Only restore stock or queue the email if that update changed a row.

2. **Reconciled `FAILED` orders may never get their stock back.** Step 5 restores stock on a decline, but step 6 only says "settles as `PAID` or `FAILED`". As written, an order that times out and then turns out to be declined keeps its stock reserved forever. State that the `FAILED` settle path is the same code as step 5. Also say whether the reconciler queues the confirmation email for orders it settles as `PAID`.

3. **A crash between step 2 and step 3 leaves an order the provider has never heard of.** The order is committed as `PENDING` but no charge was sent. When the reconciler asks the provider about it, the answer is "not found". The design doesn't say what to do. I'd settle it as `FAILED` and restore the stock, but the choice is yours. The same question applies if the provider reports a charge that is still in progress.

4. **The idempotency key is unique across all customers.** Step 1 puts the unique constraint on `idempotency_key` alone. Two customers whose clients generate the same key would collide. Make it unique on `(customer_id, idempotency_key)`.

5. **Concurrent duplicate requests aren't specified.** Two identical `POST`s that arrive together both pass the "does this key exist" check. The loser then fails on the unique constraint, and its stock reservation rolls back, which is correct. But the design should say the loser catches that error and returns the winner's order, not a 500 or a `409`. Also decide what happens when the same key arrives with a different cart.

6. **Nothing says where `unit_price` and `total` come from.** If the client's cart carries prices, the client controls what it pays. There is no catalog or price table in the data model. Say that the server looks up prices and computes the total, and name the module that owns the prices.

## Medium

7. **Reconciler on two instances.** Both instances will run the job and handle the same orders. Use `SELECT ... FOR UPDATE SKIP LOCKED` or an advisory lock. The status guard in item 1 makes this safe, but it still wastes provider calls.

8. **The confirmation email can be lost.** Step 4 commits `PAID` and then queues the email. A crash between the two drops the email silently. The simple fix is to write an outbox row in the same transaction as the `PAID` update. The design also doesn't name the queue technology.

9. **Deadlocks when reserving stock.** Two carts containing the same SKUs in different orders will lock stock rows in opposite order. Sort the SKUs before updating. Also merge duplicate SKUs within a cart.

10. **The client request can stay open too long.** Five attempts at 5 s each plus backoff is roughly 30 s or more before the `202` comes back. That may exceed the load balancer or client timeout. Either shorten the budget or state the timeouts. Also say which failures are retried: network errors and 5xx should be, declines should not.

11. **Transaction boundary across modules.** Step 2 changes `stock` (inventory) and `orders` in one transaction, but the rule says modules don't touch each other's tables. Say that `OrderCheckout` owns the transaction and passes it to both modules.

12. **Missing tests for the risky parts.** The test list covers the main paths but nothing for:
    - the reconciler (settling to paid, to failed, and "not found");
    - a decline restoring stock;
    - a partial reservation rolling back;
    - the same order settled by the request and the reconciler together;
    - two concurrent requests for the last unit.

    Run the integration tests against real Postgres, since the locking behaviour is the point.

## Low

13. **Schema is missing basics.** The tables have no primary keys, foreign keys, or indexes. `stock.sku` and `order_items` need keys. `orders` needs an index on `(status, created_at)` for the reconciler. Add `CHECK (available >= 0)`, a check constraint on `status`, and `quantity > 0`.

14. **The API contract isn't written down.** The design doesn't specify:
    - the response for a decline (I'd expect `402`);
    - the response for invalid input (`400`);
    - the success status and body;
    - how the customer is identified.

15. **A missing SKU looks like out of stock.** A SKU with no `stock` row also changes no row, so it returns the same `409`. That's probably fine, but decide whether you want a distinct error.

16. **Reconciler timing uses `created_at` against "now".** Use the database clock, not the app server's, so the two instances can't disagree.

17. **Only one alert.** The 30-minute `PENDING` alert is good. Consider also alerting on the email queue backing up and on the reconciler not running.

18. **Dead-end `PENDING` handling is undefined.** If the provider keeps saying "unknown", the order sits `PENDING` until the alert fires. That's acceptable, but say who handles it.

Items 1 to 6 are the only ones I'd want written into the doc before you start, and most are one or two sentences each. The rest can be settled as you build.

VERDICT: READY WITH CHANGES
