**Not quite ready to start tomorrow, but close.** The overall shape is sound: reserve stock, then charge outside the transaction, with reconciliation as the backstop. It is also sized right for 2,000 orders a day. But there are five gaps, each of which would produce a real bug or leak if you built to the document as written. Each is a few lines of design to fix, so an hour of edits should do it.

## Must fix before building

**1. Status changes aren't guarded, so the request and the reconciler can contradict each other.**
- Example: the charge succeeds slowly and the handler is about to mark the order `PAID`. At the same moment the reconciler, which saw it as `PENDING`, gets "unknown" from the provider and marks it `FAILED` and restores stock.
- The result is a paid order that is `FAILED`, with stock released for an item the customer owns.
- The same race exists between two reconciler runs on your two instances. Both can settle the same order and restore stock twice.
- Fix: every transition is `UPDATE ... SET status=:new WHERE id=:id AND status='PENDING'`, and stock is restored only if that update changed a row. The reconciler should claim rows with `FOR UPDATE SKIP LOCKED`.

**2. Step 6 doesn't say what to do when the provider has no record of the charge.**
- Example: the service crashes right after the step 2 commit, before any charge call. The order is `PENDING`, and the reconciler asks the provider about order X. The answer is "not found".
- The design doesn't say whether that means `FAILED` plus stock restore, or a re-charge.
- You also need to confirm how long the provider keeps idempotency keys and status history. If it's 24 hours, reconciliation after a long outage can get a wrong answer.

**3. The idempotency key is unique globally, not per customer.**
- Example: customer A sends key `abc`, and customer B's client later generates `abc`. B gets A's order back, including A's items and total.
- Fix: make the constraint `(customer_id, idempotency_key)`.
- Also decide what happens when the same key comes with a different cart. Return `422` rather than silently returning the old order.
- The unique constraint also doesn't appear in the schema table. Spell out the concurrent case: two simultaneous requests with the same key. The loser hits the constraint, rolls back (which also undoes its stock reservation), then reads and returns the winner's order.

**4. The module rule contradicts step 2.**
- "No module reads another module's tables" conflicts with one transaction that updates `stock` (inventory) and inserts into `orders`.
- Pick one approach and write it down. For example, `OrderCheckout` owns the transaction and passes it into the inventory and orders modules, or inventory exposes `reserve(tx, items)`.
- Without this, whoever builds it first will decide it by accident.

**5. Unit prices and totals have no stated source.**
- The client sends "the cart". If it includes prices, a customer can buy anything for 1 cent.
- Say that the server looks up prices and computes `total`. The design has no price table, so either add one or state where prices come from.

## Should fix (decide now, build later is fine)

- **Deadlocks on multi-item carts.** Example: one cart has SKUs A, B and another has B, A. They lock rows in opposite order and one transaction is killed. Reserve in sorted SKU order.
- **Schema gaps.**
  - No primary keys: `orders.id`, `stock.sku`, and `order_items(order_id, sku)`.
  - No `CHECK (available >= 0)` as a backstop.
  - No index for the reconciler (`status, created_at`).
  - No foreign key from `order_items` to `orders`.
- **Provider error classes.** Step 3 treats outcomes as success, decline, or unknown. A 400 or 401 (bad request, bad credentials) is none of these. Retrying it three times and then returning `202` hides a misconfiguration. Classify these as non-retryable and alert.
- **Email after commit can be lost.** If the process dies between the `PAID` commit and the enqueue, no email is ever sent. Write an outbox row in the same transaction as the `PAID` update. The queue technology also isn't named.
- **Worst-case request time.** Four attempts at 5 s plus backoff is roughly 25 to 30 s. Check your load balancer's timeout. If it's 30 s, clients will see 502s instead of the `202`.
- **No authentication or authorization.** The design doesn't say where `customer_id` comes from. It must come from the auth token, never the request body.

## Test plan gaps

The list covers the happy paths but misses what will actually break:
- the reconciler (all of it, including provider "not found")
- concurrent `POST` with the same key
- reconciler racing the request handler (needs a real Postgres, not mocks)
- crash between commit and charge
- non-retryable provider errors
- email enqueue failure
- a multi-item deadlock case

Given your TDD standard, items 1 and 2 are exactly where I'd write the failing tests first.

## What's good

Charging outside the transaction is correct. Using the order id as the provider idempotency key is correct. The conditional stock `UPDATE` is the right way to avoid overselling. The `PENDING` alert is a good safety net. None of that needs to change.

Fix items 1 to 5, add the schema keys, and extend the test list. Then build.

VERDICT: READY WITH CHANGES
