**You can start building tomorrow, but first make a handful of small edits to design.md.** The core design is sound: the reservation is atomic, the charge happens outside a transaction, the order id is used as the provider's idempotency key, and the reconciliation job is the right safety net. The gaps below are mostly missing sentences, not rework. Items 1 to 3 are worth settling before you write the order-state code.

## Needs a decision before building

**1. No rule for who may change an order's status (High).**
- *Evidence:* Steps 4, 5 and 6 all change status. Step 6 runs on a timer, and there are two instances (Context).
- *Failing case:* An order has been `PENDING` for 2 minutes and 10 seconds. The request path gets a late "declined" while the reconciliation job finds the charge succeeded. One marks it `FAILED` and restores stock, the other marks it `PAID`. The result is a paid order with its stock returned and sold again.
- *Fix:* State that every transition is `UPDATE ... WHERE status = 'PENDING'`. Only the caller that changed a row may restore stock.

**2. The reconciliation job runs on both instances (High).**
- *Evidence:* The design doesn't say which instance runs the job, so both would.
- *Fix:* Pick one way to stop duplicate runs, for example `SELECT ... FOR UPDATE SKIP LOCKED` on the pending orders, or a Postgres advisory lock. Item 1's guard makes this safe. This item stops the wasted duplicate provider calls.

**3. The reconciliation job has no test (High).**
- *Evidence:* The test list covers the request path only. The job is the safety net for every "unknown" outcome.
- *Fix:* Add tests for:
  - settling a `PENDING` order as `PAID` and as `FAILED`
  - the provider having no record of the charge, for example a crash between steps 2 and 3. Decide this case explicitly: I'd say `FAILED` plus a stock restore.
  - the race in item 1

**4. Clients have no way to follow up on a `202` (Medium).**
- *Evidence:* Step 6 returns `202` and settles up to 5 minutes later, but no `GET /orders/{id}` exists in the design.
- *Fix:* Add the endpoint, or state that the client waits for the confirmation email.

**5. Where the price comes from isn't stated (Medium).**
- *Evidence:* The client sends "the cart", and `order_items.unit_price` and `orders.total` are stored.
- *Fix:* Say that the server looks up prices and computes the total, not the client.

**6. The modules can't both own their tables and share a transaction (Medium).**
- *Evidence:* "No module reads another module's tables" conflicts with step 2, which updates `stock` and inserts into `orders` in one transaction. Step 5 does the same with a status update and a stock restore.
- *Fix:* Choose how the transaction is shared. I'd have `OrderCheckout` open it and pass it to the inventory and orders modules.

## Smaller items, all cheap

- **Concurrent duplicate requests (Low).** Two simultaneous requests with the same key will have the second hit the unique constraint, which rolls back its stock reservation, so stock stays correct. Say that the service catches the violation and returns the existing order.
- **Idempotency key scope (Low).** The key is unique across all customers. Make it unique on `(customer_id, idempotency_key)`. Also decide what happens when the same key arrives with a different cart.
- **Possible deadlocks (Low).** Reserving several SKUs in one transaction can deadlock if two orders take them in different orders. Sort the SKUs before updating.
- **Lost confirmation email (Low).** A crash between the commit and "queue the email" loses the email. Either accept that or write the email row in the same transaction as `PAID`. The design also never says what the queue is, and nothing in Context provides one.
- **Schema gaps (Low).** Missing:
  - a primary key on `stock.sku`
  - `CHECK (available >= 0)`
  - a primary key and foreign key on `order_items`
  - a `status` check constraint
  - an index on `(status, created_at)` for the job

  The unique index on `idempotency_key` is already implied.
- **Missing tests (Low).** Add tests for the `409` rollback with several items, one of which is short, and for email failure not failing the order.

## Speculative, so verify rather than act

- **Provider's idempotency window.** Confirm how long the provider remembers idempotency keys. Confirm too that charge status can be looked up by that key. The reconciliation job depends on both.
- **Request time.** Four attempts at 5 s each plus backoff can hold a request for about 25 to 30 s. Check this against the load balancer timeout.
- **Scope.** Refunds, cancellation and authentication aren't mentioned. That's fine if they are out of scope, but a line saying so would help.

At 2,000 orders a day, one Postgres database and two instances are plenty, so I'd add nothing on scale.

The edits are about an hour of writing, and items 1 to 3 give you the tests to start with.

VERDICT: READY WITH CHANGES
