Stock checked, never held
Checkout reads the stock count, takes payment, and only then subtracts.
Impact: Two shoppers paying at once can both buy the last skillet.
All problemsData & Systems
Build a stock reservation service for checkout from a one-page spec.
Your mission · Build from a spec
In the October sale Copperpot sold 214 units it did not have and cancelled 163 orders, at about $18 each in refunds, support and coupons. Shoppers who left carts also blocked stock for hours. The Winter Sale starts December 12, and checkout needs real holds before then.
Checkout reads the stock count, takes payment, and only then subtracts.
Impact: Two shoppers paying at once can both buy the last skillet.
The cart table holds units until a nightly job clears it.
Impact: Items show sold out for hours while nobody is buying them.
Every reserve, confirm and tick fails with NotImplementedError.
Impact: Checkout cannot switch to holds before the sale.
Edit the components marked “Your work”. The other components show where your changes fit.
| Field | Type | Notes |
|---|---|---|
hold | integer >= 1 | Minutes a hold lasts. Copperpot: 15. |
stock | {sku: integer >= 0} | Units on hand for each SKU at minute 0. |
| Field | Type | Notes |
|---|---|---|
op | "reserve" | |
order | non-empty string | Checkout order id, for example "CP-10421". |
items | {sku, qty}[] | At least one line; qty is a whole number of 1 or more. |
| Field | Type | Notes |
|---|---|---|
sku | string | Rows are sorted by SKU. |
on_hand | integer | Units in the warehouse, including held ones. |
held | integer | Units held for orders being paid. |
available | integer | on_hand - held: what the next shopper can hold. |
config/checkout.yaml Production settings: a 15-minute hold, a tick every minute, and the Winter Sale start time.# Checkout reservation settings (production). warehouse: reno hold_minutes: 15 # payment page timeout plus 5 minutes scheduler: tick_every_seconds: 60 sale: name: winter-sale-2026 starts: "2026-12-12T08:00:00-08:00" expected_orders_first_hour: 14000
samples/checkout-rush.json Four orders in the first quarter hour of a sale, one of them retried. Arguments for Preview.[
{
"hold": 15,
"stock": {
"DUTCH-5": 2,
"KNIFE-8": 3,
"SKILLET-10": 4
}
},
[
{
"op": "reserve",
"order": "CP-10421",
"items": [
{
"sku": "SKILLET-10",
"qty": 2
},
{
"sku": "KNIFE-8",
"qty": 1
}
]
},
{
"op": "reserve",
"order": "CP-10422",
"items": [
{
"sku": "DUTCH-5",
"qty": 2
}
]
},
{
"op": "reserve",
"order": "CP-10423",
"items": [
{
"sku": "SKILLET-10",
"qty": 3
}
]
},
{
"op": "tick",
"minutes": 4
},
{
"op": "confirm",
"order": "CP-10421"
},
{
"op": "reserve",
"order": "CP-10424",
"items": [
{
"sku": "DUTCH-5",
"qty": 1
},
{
"sku": "KNIFE-8",
"qty": 2
}
]
},
{
"op": "tick",
"minutes": 11
},
{
"op": "reserve",
"order": "CP-10424",
"items": [
{
"sku": "DUTCH-5",
"qty": 1
},
{
"sku": "KNIFE-8",
"qty": 2
}
]
},
{
"op": "confirm",
"order": "CP-10422"
},
{
"op": "stock"
}
]
]samples/checkout-rush-expected.json What the spec says that rush returns, event by event. CP-10422 expires while its payment is still going.[
{"order": "CP-10421", "state": "held", "expires": 15},
{"order": "CP-10422", "state": "held", "expires": 15},
{"order": "CP-10423", "state": "rejected", "short": ["SKILLET-10"]},
{"time": 4, "expired": []},
{"order": "CP-10421", "state": "confirmed"},
{"order": "CP-10424", "state": "rejected", "short": ["DUTCH-5"]},
{"time": 15, "expired": ["CP-10422"]},
{"order": "CP-10424", "state": "held", "expires": 30},
{"order": "CP-10422", "state": "expired"},
{"time": 15, "stock": [{"sku": "DUTCH-5", "on_hand": 2, "held": 1, "available": 1}, {"sku": "KNIFE-8", "on_hand": 2, "held": 2, "available": 0}, {"sku": "SKILLET-10", "on_hand": 2, "held": 0, "available": 2}]}
]logs/checkout-2026-10-17.log Two shoppers buy the last skillet in the same second, and the nightly job frees 1,904 units from abandoned carts.2026-10-17T08:00:03-07:00 checkout stock_check sku=SKILLET-10 on_hand=1 order=CP-88102 ok 2026-10-17T08:00:03-07:00 checkout stock_check sku=SKILLET-10 on_hand=1 order=CP-88107 ok 2026-10-17T08:00:41-07:00 payments charge order=CP-88107 amount=89.00 status=captured 2026-10-17T08:00:52-07:00 payments charge order=CP-88102 amount=89.00 status=captured 2026-10-17T08:00:52-07:00 checkout decrement sku=SKILLET-10 on_hand=-1 order=CP-88102 2026-10-17T09:14:20-07:00 warehouse pick_failed order=CP-88102 sku=SKILLET-10 reason=no_stock 2026-10-18T02:00:00-07:00 cart_cleanup released_units=1,904 carts=611
metrics/oversells-2026.csv Units oversold and orders cancelled in each sale this year, with the cost.event,orders,units_oversold,orders_cancelled,cost_usd spring-sale,9840,61,48,864 summer-sale,11205,97,70,1260 october-sale,13930,214,163,2934
TASK-201 Read docs/spec.md and decide the data model Reported by Imani (checkout)
Expected NOTES.md says what the inventory stores for each SKU and each order, and why that is enough to never oversell and to expire holds on time.
Actual Inventory has on_hand, held and an orders table, but reserve, confirm and advance are stubs and nothing says what an order record holds.
TASK-202 Core: hold an order whole or reject it, with the stock report Reported by Imani (checkout)
Expected The stock report lists every SKU. CP-10421 and CP-10422 are held until minute 15 and CP-10423 is rejected, short on SKILLET-10.
Actual The stock report works, but every reserve fails with NotImplementedError: "Implement Inventory.reserve using the request contract".
TASK-203 Then confirm, then the clock and expiry Reported by Luis (payments)
Expected Every result matches the expected file: CP-10422 expires at minute 15 and its late confirm sells nothing.
Actual The first tick fails with NotImplementedError: "Implement Inventory.advance using the request contract".
TASK-204 Write down anything you chose to leave out or would do next Reported by Grace (head of e-commerce)
Expected A short list of what the service does not handle yet and what you would build next, with a reason for each.
Actual NOTES.md has no entry.
Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard
Build the service that holds stock while a shopper pays. Checkout reserves an order, then confirms or releases it, and a hold expires after a fixed time. The one rule that matters most: never sell a unit twice. The spec is one page. Start with a working core and grow it. Use the AI assistant however you like, and tell me your data model before you ask it for code.