## Is design.md ready to build from?

Mostly, yes. Revision 3 is a strong design. Stock is reserved atomically, the payment call happens outside any transaction, retries reuse one idempotency key, the unknown-payment case gets a `202` plus a reconciliation job, and a failed email never fails the order. You could build most of it tomorrow. One state-change bug needs fixing in the doc first, and three small gaps should be settled before you code the parts they affect.

### Must fix before building: an order can be settled twice

Steps 4, 5 and 6 change status ("mark the order `PAID`/`FAILED`") without checking that the order is still `PENDING`. You run two instances, and the doc doesn't say the reconciliation job runs on only one of them. So both instances can pick up the same order.

**Concrete case:** order X holds 2 units of SKU `A` and is stuck `PENDING`. The provider reports the charge as declined. Both instances' reconciliation jobs read X as `PENDING`, and both run step 5.

```mermaid
sequenceDiagram
    participant R1 as Reconciler (instance 1)
    participant R2 as Reconciler (instance 2)
    participant DB as Postgres
    R1->>DB: read PENDING orders → X
    R2->>DB: read PENDING orders → X
    R1->>DB: mark X FAILED, stock A +2
    R2->>DB: mark X FAILED, stock A +2
    Note over DB: available is 2 too high → later oversell
```

Expected result: stock goes up by 2 once. Actual result: it goes up by 4. The same race exists between the request path and the job, and it could also flip an order from `PAID` to `FAILED`.

**Fix (one line in the doc):** every status change is conditional, e.g. `UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`. Restore stock or queue the email only if that update changed exactly one row. Add a test: "two reconcilers settle the same order concurrently → stock restored once."

### Gaps to settle before coding the parts they affect

1. **Reconciliation never sends a confirmation email.** Step 4 queues the email, but step 6 only says "settles them as `PAID`". A customer whose payment timed out and later succeeded would never get an email. Have both paths call one shared "mark paid" function.
2. **The client has no way to see the final status after a `202`.** No read endpoint is defined. Add `GET /orders/{id}`, or state that the client retries `POST` with the same idempotency key to get the current state.
3. **The provider's answers aren't mapped.** Check that your provider supports looking up a charge by your idempotency key; some only let you replay the original request. Then define what reconciliation does when the provider says "no such charge" (most likely `FAILED`) or "still processing" (leave it `PENDING`, and the 30-minute alert covers it).

### Worth naming in the doc
- **Module boundary:** step 2 and step 5 each write to `orders` and `stock` in one transaction, which seems to conflict with "no module reads another module's tables". That's fine if the inventory module exposes reserve/release functions that take the caller's transaction. Say so in the doc so nobody "fixes" it later by splitting the transaction.
- **Tests to add:** the reconciliation job (settles `PAID`, settles `FAILED`, provider says not found), two concurrent `POST`s with the same key, and the double-settle case above.

None of these change the overall shape of the design. They're a few sentences each, and the core flow can go ahead tomorrow.

VERDICT: READY WITH CHANGES
