The design is mostly ready. Idempotency, the payment-outside-transaction split, and the plan for unknown charge results are all solid. You can start building tomorrow if you first make about four small edits to the doc. All of them are in the reconciliation and failure paths, where bugs are hardest to find later.

## Fix before building

**1. Orders the reconciliation job marks `FAILED` never get their stock back. (High)**
- **Where:** Step 5 (`design.md:33-34`) restores stock on a decline. Step 6 (`design.md:36-38`) only says the job "settles them as PAID or FAILED" and never mentions stock.
- **Example:** A customer buys the last unit, the charge times out, and the job later finds it declined. The order becomes `FAILED`, but `stock.available` stays at 0, so that unit can never be sold.
- **Fix:** State that every path to `FAILED` restores stock in the same transaction as the status change.

**2. Status changes need a "still PENDING" guard. (High)**
- **Why:** There are two instances (`design.md:6`), and nothing says the job runs on only one of them. The doc doesn't say how each step changes the status.
- **Example:** Both instances' jobs pick up the same declined order. Each one marks it `FAILED` and adds the stock back, so `available` goes up by twice the quantity and you oversell.
- **Fix:** Write every status change as `UPDATE orders SET status = … WHERE id = :id AND status = 'PENDING'`. Only touch stock or queue the email if that update changed a row. Also either run the job on one instance (for example with a Postgres advisory lock) or rely on the guard and say so.

**3. The job doesn't say what to do when the provider has no charge for the order. (Medium)**
- **Example:** An instance crashes after step 2 commits but before step 3 calls the provider. The order stays `PENDING`, and the provider replies "no such charge," which is neither PAID nor FAILED.
- **Fix:** Pick one rule. Either mark it `FAILED` and restore stock, or retry the charge with the same idempotency key. Without a rule, the order sits there until the 30-minute alert (`design.md:45`) fires, every time.

**4. The doc doesn't say where prices come from. (Medium)**
- **Where:** The client sends "the cart" (`design.md:19`). `order_items.unit_price` and `orders.total` are stored (`design.md:12-13`), but no table holds prices.
- **Risk:** If the price comes from the client's cart, a client can set its own price.
- **Fix:** State that the server looks up prices and computes the total, and name the source (a catalog service, or a `price` column on some table).

## Smaller edits (fine to fix while building)

- **Deadlocks between concurrent checkouts. (Low-Medium)**
  - **Example:** Order A updates SKU X then Y while order B updates Y then X. Postgres aborts one of them, and that customer gets a 500 instead of a 409.
  - **Fix:** Update SKUs in sorted order (`design.md:22-24`).
- **The email can be lost, and the job never sends one.**
  - **Lost email:** If the process crashes between committing `PAID` and queueing the email (`design.md:30-31`), the email is never sent. Queueing it in the same transaction (a database "outbox" table) fixes this.
  - **No email from the job:** When the job settles an order as `PAID`, nothing says it queues the email.
- **Idempotency key edge cases.** The key should probably be unique per customer, `(customer_id, idempotency_key)`, not across all customers. The doc also doesn't say what happens when the same key arrives with a different cart. A 422 is the usual answer (`design.md:20-21`).
- **One 409 covers two different errors.** "No row changed" (`design.md:24-25`) happens both when the SKU doesn't exist and when there isn't enough stock. Unknown SKUs should get a 400 or 404.
- **No way to check on a 202.** A client that gets a `202` (`design.md:36`) has no endpoint to poll. Add `GET /orders/{id}`.
- **Missing keys and indexes.**
  - Make `stock.sku` the primary key.
  - Give `order_items` a primary key.
  - Add an index on `orders(status, created_at)` for the job's query.
- **One transaction spans two modules.** Step 2 writes `stock` and `orders` in one transaction, but the doc says "no module reads another module's tables" (`design.md:41-42`). This is fine if inventory exposes a reserve function that joins the caller's transaction. Say so, so nobody ends up reaching into another module's tables.
- **Missing tests** (`design.md:49-51`):
  - each reconciliation outcome (PAID, FAILED with stock restored, no charge found)
  - a crash after step 2 but before the charge
  - the job running on both instances at once
  - two concurrent requests racing for the last unit (the current "last unit" test sounds like a single request)
  - a decline on a retry after a timeout

## Possible concerns (not supported by the doc)

- **Which errors get retried.** The doc doesn't say whether a 4xx from the provider is retried. Retries should probably be limited to timeouts and 5xx.
- **Worst-case request time.** With 5 s timeouts, 3 retries and backoff, one request can take about 25–35 s. That fits inside the job's 2-minute threshold, but check it against your load balancer and client timeouts.

Each item in the first section is a sentence or two in the doc, not a redesign, so this shouldn't cost you more than an hour before you start.

VERDICT: READY WITH CHANGES
