**Not quite ready to build tomorrow.** The overall shape is sound and well sized for 2,000 orders a day, but there are four gaps in the money and stock paths. Close them in the doc first, which is about half a day of decisions and not a redesign.

## Must fix before building

**1. Reconciliation can't tell "never charged" from "charge unknown" (step 6).**
- Case: the instance crashes after step 2 commits but before step 3 calls the provider. The order is `PENDING` and no charge exists. Five minutes later the job asks the provider about it and gets "not found".
- The doc doesn't say what happens next. If the job settles it `FAILED` and releases the stock, that's fine in this case. But a charge that timed out in flight can still land at the provider afterwards. The customer is then charged for a `FAILED` order and the stock has been re-sold.
- Decide one rule. I'd suggest re-sending the charge with the same order-id idempotency key and treating the provider's answer as final. Alternatively, cancel at the provider before marking `FAILED`.

**2. Stock restore isn't safe to run twice (steps 5 and 6).**
- Case: the request thread gets a decline and starts step 5. At the same time the reconciliation job, or the other instance's job, settles the same order `FAILED`. Stock is restored twice and `available` is now higher than reality.
- Fix: make the transition conditional with `UPDATE orders SET status='FAILED' WHERE id=:id AND status='PENDING'`. Restore stock only if one row changed, and do both in the same transaction. Apply the same guard to `PAID`.
- Two instances will both run the job, so this guard is required.

**3. The confirmation email can be lost (step 4).**
- Case: the process dies between the `PAID` commit and the enqueue. The order is paid and no email is ever sent.
- The doc also doesn't say what the queue is. Nothing in Context besides Postgres exists.
- Fix: write an `outbox` row in the same transaction that marks the order `PAID`, and have a worker send from it. That removes the need for a separate queue.

**4. The duplicate-key race isn't specified (step 1).**
- Case: two identical requests arrive at once. Both pass any existence check, and the second insert fails the unique constraint. That failure rolls back its stock reservation (good), but the doc doesn't say it returns the existing order instead of a `500`.
- Also decide whether the key is unique per `customer_id` or global. A global key lets one customer collide with another's. Decide too what happens when the same key arrives with a different cart, which should be `422`.

## Should fix (cheap now, painful later)

- **Deadlocks:** reserve stock in sorted `sku` order. Two carts holding the same two SKUs in opposite order will otherwise deadlock.
- **Schema gaps:**
  - No primary keys, foreign keys or indexes are named.
  - `stock.sku` must be a primary key, with `CHECK (available >= 0)`.
  - Reconciliation needs an index on `(status, created_at)`.
  - Nothing stores the provider's charge id, so refunds and support lookups have no handle.
- **Price trust:** say where `unit_price` and `total` come from. If the client sends them, the client sets its own price. Compute them server-side from a catalog.
- **Retry budget:** 4 attempts × 5 s plus backoff is roughly 25–30 s while the request is held open. Check that this is below the load balancer's timeout, or the client sees a gateway error while the charge proceeds.
- **Retry rules:** state which provider errors are retried (timeouts and 5xx) and which are final (4xx such as a declined card).
- **Alert vs. action:** the 30-minute alert pages someone, but stock stays held until reconciliation settles the order. Say that this is intended.
- **Scope:** there is no cancel, refund or authentication story. If these are out of scope, say so in the doc.

## Tests to add
The current list covers the happy paths well. These are missing, and each maps to a gap above:
- Crash between the stock commit and the charge, then reconciliation.
- Concurrent duplicate `POST /orders` with the same key.
- A decline racing with reconciliation, asserting stock is restored exactly once.
- A multi-SKU cart where the second SKU is out of stock, asserting the first reservation is rolled back.
- A `PAID` commit followed by an email failure or crash, asserting the email is still sent.
- Reconciliation itself: `PAID`, `FAILED`, "not found", and provider unavailable.

## What's good
Charging outside the transaction, using the order id as the provider idempotency key, a conditional stock `UPDATE`, a reconciliation backstop, and no cross-module table reads are all the right calls. Two instances and one Postgres is the correct size for this load.

VERDICT: READY WITH CHANGES
