**You can start building tomorrow, but settle four things in the design first. They all concern the reconciliation job and its race with the request path, and they take about an hour to write down.** The core design is sound for 200 to 2,000 orders a day. Stock is reserved atomically, the charge happens outside the transaction, the provider gets an idempotency key, and an unknown outcome stays `PENDING` and is reconciled later. The tests also target the right risks.

## Fix before you build

**1. Reconciliation and the request path can settle the same order twice (high).**
- Evidence: step 5 marks `FAILED` and restores stock, and step 6's job also settles orders. Nothing makes either update conditional on `status = 'PENDING'`.
- Example: a request times out, then the job learns the charge was declined. Meanwhile a late retry in the original request also sees the decline. Both restore stock, so `available` goes up by 2 instead of 1 and you oversell.
- Fix: write "mark `FAILED` and restore stock only if the row is still `PENDING`, in one transaction" into steps 5 and 6. The same condition applies to `PAID`.

**2. Step 6 never says a job-settled `FAILED` restores stock (high).**
- Evidence: step 5 restores stock, but step 6 only says "settles them as `PAID` or `FAILED`".
- Example: a charge times out on every attempt, the job later finds it declined, and the order becomes `FAILED` with its stock still reserved. That stock is lost until someone fixes it by hand.
- Fix: state that all `FAILED` transitions go through one shared function that restores stock.

**3. Two instances both run the 5-minute job (medium).**
- Evidence: the context says two instances behind a load balancer, and the job has no locking.
- Fix: claim rows with `SELECT … FOR UPDATE SKIP LOCKED`, or use an advisory lock. With fix 1 this is safe but wasteful, so it's a small addition.

**4. "Provider has no record of this charge" is undefined (medium).**
- Evidence: step 3 commits the order and only then calls the provider. If the instance dies in between, a `PENDING` order exists with no charge. Step 6 doesn't say what to do when the provider returns "not found".
- Example: the process crashes after the step 2 commit. The job asks the provider about the order id and gets "not found". Pick a rule, such as "not found after 10 minutes means `FAILED` and restore stock".

## Fix during the build

**5. No way for the client to learn the result after a `202` (medium).** There is no `GET /orders/{id}`, and the response bodies aren't specified. A client that gets `202` has nothing to poll. This is a small endpoint, but the contract should be fixed before the client is built.

**6. Stock updates can deadlock (medium).**
- Evidence: step 2 updates each SKU in cart order.
- Example: order 1 updates SKU A then B, while order 2 updates B then A. Postgres aborts one with a deadlock error.
- Fix: sort SKUs before updating.

**7. The confirmation email can be lost (low-medium).** In step 4, the order commits as `PAID` and only then is the email queued. A crash between the two means no email and no retry. Either write the email to an outbox table in the same transaction, or accept the loss and say so.

**8. Tests miss the riskiest paths (medium).**
- The reconciliation job has no test at all: not `PAID`, not `FAILED`, not "not found".
- There is no test for a decline restoring stock.
- There is no test for two jobs or a job plus a request racing.
- "Buying the last unit" should be two concurrent buyers of one unit, with exactly one `409`.

**9. Module boundaries versus shared transactions (low).**
- Steps 2 and 5 need orders and inventory to commit together, yet "no module reads another module's tables".
- Choose how this works, for example by passing a transaction handle into the inventory module. Name the choice in `OrderCheckout`.

**10. Smaller gaps (low).**
- The schema lists no primary keys, no `CHECK (available >= 0)`, and no unique constraint on `idempotency_key`. Step 1 relies on that unique constraint.
- It doesn't say whether `unit_price` comes from the server or the client cart. It should come from the server.
- It doesn't say which provider errors are retried. Retry 5xx and timeouts, not declines.
- A worst case of 4 attempts at 5 s plus backoff is about 25 s before the client sees `202`. Check that this fits under your load balancer timeout.
- The alert only covers `PENDING` orders. Add one for the reconciliation job failing to run.

## Not worth acting on yet (speculative)
- If the provider is slow, long requests could exhaust the worker pool. At this volume that is unlikely, so watch it rather than design for it.
- Refunds and cancellation aren't covered. That is fine if they are out of scope, but I couldn't confirm that, since the design lists no requirements beyond volume.

VERDICT: READY WITH CHANGES
