I reviewed `design.md` against your plan to start building tomorrow. Most of it is ready, but the payment step has three problems that can take customers' money without leaving an order, and I'd fix them first. Each is about a paragraph to change in the doc, so you can still start tomorrow.

**What's ready to build:**
- The code structure is sound. Modules don't read each other's tables, routes are thin, the logic lives in `OrderCheckout`, and every log line carries the order id. Build it as written.
- The scale is fine. 2,000 orders a day is light work for a single Postgres instance.
- You explain why you accept the inventory cache (the warehouse call takes 800 ms). That's the kind of reasoning a design doc should record.

**Must fix before you write the payment step:**

1. **Retrying a timed-out charge can charge the customer twice.** A timeout doesn't mean the charge failed. Example: the provider takes the money, but its reply arrives after 5 s. The service retries, and the customer is charged twice, up to 4 times in total. **Fix:** send an idempotency key with every charge (for example, the order id). Most payment providers support this, so a retry returns the first result instead of charging again.

2. **A charge can succeed with no order left to show for it.** The `PENDING` row is inside the open transaction until commit, so it never really exists outside it. If the process crashes, the commit fails, or step 6 rolls back after a timeout that actually succeeded, the money is gone and the order row is too. Example: the charge succeeds, then the pod restarts before commit. The customer is charged and you have no record. Holding a transaction open through up to 20 s of payment calls also ties up a database connection the whole time.

   **Fix:** commit `PENDING` before calling the provider. Then update the row to `PAID` or `FAILED` in a second transaction. If the result is unknown, leave the row `PENDING` and have a reconciler job ask the provider what happened.

```mermaid
flowchart LR
  A[Insert PENDING + commit] --> B[Charge with idempotency key]
  B -->|success| C[Mark PAID, commit] --> D[Send email]
  B -->|declined| E[Mark FAILED]
  B -->|timeout after retries| F[Stay PENDING; reconciler checks provider]
```

3. **The stock check can sell the same item twice.** The cache can be up to 5 minutes old and nothing reserves stock. Example: one unit is left, two customers check out a minute apart, both pass the check, and both are charged. If an occasional oversell is acceptable at this volume, say so in the doc and say how you'll handle it (refund and apologise). Otherwise, reserve stock in the same step as the `PENDING` commit.

**Small additions:**
- **Tests:** add tests for these cases, not just the happy path:
  - a payment timeout where the charge actually succeeded
  - a declined card
  - a crash between the charge and the commit
  - two orders racing for the last unit

  These are the cases most likely to break.
- **Email failure:** say what happens if the confirmation email fails after `PAID`. It shouldn't fail the order. Retrying it from a queue or outbox table is enough.

You can start on the modules, routes, and `OrderCheckout` structure tomorrow. Once fixes 1 and 2 are in the doc (and 3 is either fixed or written down as an accepted risk), the payment step is ready to build too.

VERDICT: READY WITH CHANGES
