Welcome to the team that promises stock to orders. A catalog of SKUs, physical on-hand inventory, and a reservation book combine into an availability view: what can still be promised is the on-hand count minus what is al…
Welcome to the team that promises stock to orders. A catalog of SKUs, physical on-hand inventory, and a reservation book combine into an availability view: what can still be promised is the on-hand count minus what is already reserved.
This repository has three reported problems, listed below as tickets. Fix as many tickets as you can in 45 minutes. Each ticket is checked separately, and you are not expected to finish every one.
You may use the AI assistant and normal repository tools. Treat the assistant like a junior developer: establish a plan, inspect its work, run the tests, and retain ownership of the result.
fulfillment/
models.py domain types (Sku, Reservation)
errors.py ValidationError, UnknownSku, OutOfStock
catalog.py the SKU catalog (add / exists / require)
inventory.py physical on-hand counts per SKU
reservations.py the reservation book (place / release / reserved)
service.py FulfillmentService: available(), reserve(), release()
tests/visible/ shipped regression tests
conftest.py puts the repository root on the import path for pytest
The same stock is being promised twice. available(sku) returns the physical on-hand count and ignores reservations that are already holding some of it, so two orders can each be told the stock is free.
available(sku) equals on-hand minus active reservations for that SKU.Do not change the inventory or catalog modules as part of this ticket.
A reservation larger than what is available succeeds and drives availability negative. Warehouses are getting orders they cannot fill.
available(sku) raises OutOfStock.Do not change the reservation-release path as part of this ticket.
release does not actually free a reservation, so availability never recovers after a hold is cancelled. Stock stays locked away from new orders.
release, the reservation no longer counts toward reserved or available.Do not change the oversell check as part of this ticket.
pytest tests/visible. Every shipped test fails on the starter code and passes once the bugs it covers are fixed.fulfillment/ are submitted; the shipped tests in tests/visible run as they are.Adapted from treasure567/bloomberg-practice (round-2/drift @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
stock-reservations-double-promises-oversells-and-stuck-holds
Changes under src/ are evaluated.