**Not quite ready to build as written, but the gaps are small. Settle the four "fix first" items below before you start and you can begin tomorrow.** The core design is sound. It reserves stock and creates the order in one transaction, calls the provider outside any transaction, uses the order id as the provider's idempotency key, and has a reconciliation job as a backstop. The problems are in the paths around that core.

## Fix before starting

| # | Severity | Problem | Concrete case | Fix |
|---|---|---|---|---|
| 1 | High | The reconciliation job (step 6) has no rule for "the provider has no charge for this order". | The service crashes after step 2 commits and before the charge call. The order stays `PENDING`, and the provider has never heard of it. The job asks for the charge status, gets "not found", and the design doesn't say what happens. The stock stays reserved forever and the alert fires at 30 minutes. | State that "not found" after the provider's idempotency-retention window means `FAILED` plus restore stock. Before that window, leave the order alone. |
| 2 | High | There are two service instances, and both will run the reconciliation job. Steps 5 and 6 also don't say that the stock restore happens only once. | Both instances pick up the same `PENDING` order. Both mark it `FAILED` and both add the stock back, so `available` is now too high and you can oversell. | Make every status change conditional (`UPDATE … SET status=… WHERE id=:id AND status='PENDING'`). Restore stock only if that update changed a row. Say which path (decline or reconciler) does the restore. Use an advisory lock or `FOR UPDATE SKIP LOCKED` in the job. |
| 3 | High | The design doesn't say where prices come from. | The client sends a cart with `unit_price` or `total`, and the service trusts it. A customer posts a price of 0.01. | Say that the server looks up prices itself. There is no price or catalog table or service in the doc, so name the source. |
| 4 | Medium | The tests skip the hardest part. | Nothing covers the reconciler: no test for a pending order settling as `PAID`, as `FAILED`, or as "not found", for two instances running at once, or for a crash between steps 2 and 3. | Add those to the integration test list before writing the job. This matches your tests-first rule. |

## Fix during the build

| # | Severity | Problem | Fix |
|---|---|---|---|
| 5 | Medium | Two requests with the same key arrive at the same time. The second one hits the unique constraint, rolls back (stock included), and the doc doesn't say it then returns the first order. The key is also global rather than per customer, and a reused key with a different cart isn't detected. | On a unique violation, load and return the existing order. Scope the key to `customer_id`. Return `422` if the cart differs. |
| 6 | Medium | Step 2 updates several SKUs in one transaction, in cart order. | Two carts with SKUs A,B and B,A can deadlock. Sort SKUs before updating. |
| 7 | Medium | The orders and inventory modules can't touch each other's tables, yet step 2 needs one transaction across both. | Pick one approach and write it down: inventory exposes `reserve(tx, items)` and takes the caller's transaction, or `OrderCheckout` owns the transaction. |
| 8 | Low | The confirmation email is queued after the `PAID` commit. A crash in between loses the email. | Accept it and note it, or write an outbox row in the same transaction as `PAID`. |
| 9 | Low | A request can hold the connection for about 25 s or more (4 attempts × 5 s, plus backoff). | Check this against the load balancer and client timeouts. Consider returning `202` earlier. |
| 10 | Low | The data model has no keys or constraints. | Add primary keys, `UNIQUE(customer_id, idempotency_key)`, `CHECK (available >= 0)`, an index on `(status, created_at)` for the job, and a foreign key from `order_items` to `orders`. |
| 11 | Low | The only alert is for orders stuck in `PENDING`. | Also alert when the reconciliation job fails or stops running. |

Nothing here is a scale concern. 2,000 orders a day on one Postgres database is comfortable.

VERDICT: READY WITH CHANGES
