**The design is sound and can be built from tomorrow, provided two gaps in how orders get settled are closed first.** Both are small additions to the design rather than rework. The core choices are right: stock reserved atomically, the charge made outside any transaction, the order id as the provider's idempotency key, and a reconciliation job for unknown outcomes.

## Fix before building

**1. High: stock can be restored twice for one failed order.**
The design never says the move out of `PENDING` happens only once. With two instances, the reconciliation job runs on both, and the request handler can also settle the same order.
- **Input:** an order for 1 unit of a SKU is `PENDING` with `available = 0`. Both instances' reconciliation runs pick it up and both learn the charge was declined.
- **Wrong output:** both run step 5, so `available` becomes 2. One unit that does not exist can now be sold.
- **Expected:** `available = 1`.
- **Fix:** make every transition conditional, `UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`. Restore stock or queue the email only if that update changed a row.

**2. Medium: reconciliation has no rule for "the provider has never heard of this order".**
- **Input:** the instance crashes after step 2 commits but before the charge call reaches the provider.
- **Wrong output:** step 6 only allows `PAID` or `FAILED`, so the order stays `PENDING` and holds its stock until the 30-minute alert brings in a person.
- **Expected:** the order is marked `FAILED` and stock is restored.
- **Fix:** state that "no charge found" settles as `FAILED` through the same code path as step 5. Do the same for step 6's other `FAILED` outcome, which does not currently mention restoring stock.

**3. Medium: the test plan does not cover the reconciliation job or concurrency.**
Add integration tests for:
- reconciliation settling to `PAID`, to `FAILED`, and on "no charge found";
- two reconciliation runs on the same order (finding 1);
- two simultaneous buyers of the last unit;
- two simultaneous `POST /orders` with the same key.

## Fix during the build

**4. Low–medium: two carts with the same SKUs in different order can deadlock in step 2.**
Postgres will abort one, and the customer sees a 500 rather than an order. Update stock rows in sorted SKU order.

**5. Low: simultaneous duplicate `POST /orders` is unspecified.**
The second insert will hit the unique constraint. The design should say this is caught, rolled back, and answered with the existing order. Also scope the constraint to `(customer_id, idempotency_key)` so one client's key cannot collide with another's.

**6. Low: the confirmation email can be lost.**
If the instance crashes between the `PAID` commit and queuing the email in step 4, the email is never sent. Either write an "email pending" row in the same transaction as `PAID`, or accept and document the risk.

**7. Low: the data model omits keys and constraints.**
- Primary keys on all three tables.
- Foreign key from `order_items` to `orders`.
- `CHECK (available >= 0)` on `stock`.
- A column for the provider's charge reference, which support and refunds will need.

## Questions the design should answer

- **Prices:** where do `unit_price` and `total` come from? If they come from the client's cart, a customer can set their own price. The design names no server-side price source.
- **Refunds and cancellations:** there is no state beyond `PAID`. This is fine if they are out of scope for this release, but the design should say so.

VERDICT: READY WITH CHANGES
