**You can start tomorrow, but only after you settle five gaps in the design.** The core flow is sound. The reserve-stock, then charge, then reconcile shape is right, and the provider idempotency key is used correctly. All the gaps are missing rules, not wrong architecture. Each needs a written decision before you code, because each one changes what you build and test.

## Decide before coding

1. **Reconciliation doesn't say what to do when the provider has no charge.**
   - Case: the service crashes after step 2 commits and before step 3 sends the charge. The order sits `PENDING`, and the provider has never heard of it.
   - Step 6 only covers "settle as `PAID` or `FAILED`". It doesn't say whether "no such charge" means fail the order and restore stock, or retry the charge.
   - It also doesn't say what a provider status of "processing" means.
   - Pick the rules and write them down.

2. **Status changes aren't guarded, so stock can be restored twice.**
   - Case: the request thread gets a decline and marks the order `FAILED`. A reconciliation run that read the order as `PENDING` a moment earlier also marks it `FAILED`. Stock is restored twice and `available` is now too high.
   - The same race exists with two instances both running reconciliation.
   - Fix: every transition is `UPDATE ... WHERE status = 'PENDING'`, and the stock restore only happens if that update changed a row. Also decide what happens if the provider later reports a charge as captured on an order already marked `FAILED`.

3. **The confirmation email can be lost.**
   - Step 4 commits `PAID` and then queues the email, so a crash between the two means no email, ever.
   - Orders settled `PAID` by reconciliation never get an email at all, because only step 4 queues one.
   - Fix: write an outbox row in the same transaction as the `PAID` update, in both paths. At 2,000 orders a day, a table polled by a worker is enough. You don't need a broker.

4. **Where `unit_price` and `total` come from isn't stated.**
   - There is no price catalog in the data model.
   - If the client sends prices, a client can send a price of 0.01.
   - State that the server prices the cart, and say from what source.

5. **"No module reads another module's tables" conflicts with step 2.**
   - Step 2 reserves stock (inventory) and inserts the order (orders) in one transaction.
   - Say how that works, for example `OrderCheckout` opens the transaction and passes it into both modules. Otherwise two developers will resolve this differently.

## Fix while building

- **Concurrent same-key requests:** the second one hits a unique-constraint violation inside the transaction. Catch it and return the existing order.
- **Same key, different cart:** return an error. Also scope the key per customer.
- **Deadlocks:** two carts with the same SKUs in different order will deadlock on the `stock` updates. Sort SKUs before updating, and merge duplicate SKUs in one cart.
- **Out-of-stock vs unknown SKU:** both currently return `409`. An unknown SKU should be a `4xx` validation error.
- **Missing schema constraints:**
  - primary keys and foreign keys
  - `CHECK (available >= 0)`
  - a unique index on `idempotency_key`
  - an index on `(status, created_at)` for the reconciliation query
- **Request length:** the charge step can hold the HTTP request open for 20 seconds or more (4 attempts at 5 s each, plus backoff). Check that this is under the load balancer's timeout.
- **30-minute alert:** say who gets it and what they do. A stuck order holds stock and a customer's money.

## Test plan gaps

The plan has no reconciliation tests, even though it's the most failure-prone part. Add tests for:
- reconciliation settling to `PAID`, to `FAILED`, and on "no such charge"
- reconciliation racing the request path, with stock restored exactly once
- two concurrent `POST /orders` with the same key
- a crash after step 2 and before step 3
- an email failure leaving the order `PAID`
- two carts locking SKUs in opposite order

Per your standards, write these as failing tests first.

VERDICT: READY WITH CHANGES
