**Not ready to build tomorrow.** The happy path is solid, but the design doesn't say how an order ends up in a wrong state, and money and stock go wrong in exactly those cases. The fixes are roughly a half-day revision of the document, not a redesign. The scale and the single Postgres are fine, and nothing here needs more infrastructure.

## Blockers (decide these before writing code)

1. **A crash between steps 2 and 3 leaves an order that never gets charged.**
   - Case: the instance dies after the commit in step 2. There is a `PENDING` order holding stock, and the provider has never heard of it.
   - Step 6 says the reconciler "asks the provider for the charge status", but the design never says what to do when the provider answers "no such charge".
   - Decide the rule. For example, treat "not found" after N minutes as `FAILED` and restore the stock. If you do that, you must also be sure the original request has stopped retrying, or the reconciler races it.

2. **A charge can succeed after the order was marked `FAILED`, and there's no refund path.**
   - Case: the provider times out on all 4 attempts but processes the charge anyway. The reconciler sees "not found" or "pending" and marks the order `FAILED`. The customer is charged for an order that is `FAILED`, and the stock has been resold.
   - You need either a refund/void step for this case or a rule that the reconciler never goes to `FAILED` on anything except an explicit decline.

3. **Stock restore can run twice.**
   - Case: the request handler (step 5) and the reconciler (step 6) both settle the same order as `FAILED`. Each adds the quantity back, so stock inflates and you oversell.
   - Every status change must be a conditional update (`... WHERE status = 'PENDING'`). Restore stock only if that update changed a row, inside the same transaction.
   - The same rule stops the handler and the reconciler overwriting each other's result.

4. **The reconciler runs on both instances, and the design doesn't say how it avoids duplicate work.**
   - There are two instances behind the load balancer. Both will run the job every 5 minutes.
   - Use `SELECT ... FOR UPDATE SKIP LOCKED` or an advisory lock, and say which.

5. **The module rule contradicts the flow.**
   - Code structure says "no module reads another module's tables". Steps 2 and 5 require one transaction that touches `stock` and `orders` together.
   - This is a structural decision that needs a name. The simplest choice is that `OrderCheckout` owns the transaction and passes it into the inventory and orders modules. Say that explicitly.

## Serious gaps (fix in the document; each is small)

- **Concurrent duplicate `POST`s.** If two requests with the same key arrive together, the second hits the unique-constraint error. The design should say that it catches the error, rolls back (which returns its stock), and returns the existing order.
- **Idempotency key scope.** The key isn't scoped to a customer. The design also doesn't say what happens when the same key arrives with a different cart. Return `422`, not the old order.
- **Overloaded `409`.** Out of stock and idempotency conflicts both look like 409. Use distinct error codes.
- **Deadlocks.** A cart with SKUs A,B and another with B,A can deadlock on the stock updates. Sort the SKUs before reserving. Merge duplicate SKU lines in a cart as well.
- **Request time.** 4 attempts at 5 s each plus backoff means a request can be open for 20 s or more. Check this against the load balancer and client timeouts. Also check how long the provider remembers idempotency keys. The reconciler may query much later than that.
- **Schema.**
  - Primary keys are missing on `orders`, `order_items` and `stock`.
  - There are no foreign keys, and no `CHECK (available >= 0)` as a backstop.
  - There is no `CHECK` on `status`.
  - The unique index on `idempotency_key` isn't actually declared.
  - The reconciler needs an index on `(status, created_at)`.
- **Where prices come from.** The design doesn't say who sets `unit_price` and `total`. If the client's cart supplies them, that's a trust bug. State that the server prices the order from the catalog. Customer authentication is also unmentioned.
- **Email after commit.** A crash between the commit and the enqueue silently loses the confirmation email. At 200 orders a day an outbox table is cheap, but whichever you pick, name the tradeoff. The queue technology isn't stated either.
- **The 30-minute alert.** It has no owner and no runbook. The design doesn't say what a person does when it fires.

## Test plan gaps

The listed integration tests cover only the happy and sequential cases. Add these:

- Two concurrent requests with the same key.
- Two concurrent buyers for the last unit. "Buying the last unit" as written may be sequential.
- A crash after the step 2 commit, followed by reconciliation.
- The reconciler against each provider answer: paid, declined, not found, still pending.
- Double settlement (handler and reconciler) restoring stock only once.
- A late success after `FAILED`.

There are currently no reconciler tests at all, and that's where the dangerous logic is.

## What's good

- Charging outside the transaction is correct.
- Using the order id as the provider's idempotency key is correct.
- The conditional `UPDATE ... WHERE available >= :qty` is the right way to reserve stock.
- Keeping `PENDING` instead of guessing the outcome is correct.
- Plain Postgres and a reconciliation job suit the scale.

## Fastest path to ready

Write a short "settlement rules" section in the doc. It should be a table of `PENDING` plus each provider answer, giving the next status, the stock action and the refund action. Add the transaction-ownership decision and the schema constraints. Then add the concurrency and reconciler tests to the plan. That is the half-day of revision.

VERDICT: NOT READY
