Workshop index · Download all examples and lessons
Change request: When a confirmed booking is cancelled, use the released capacity to promote waiting bookings in arrival order. Emit a confirmation event for each promoted booking. Keep the existing cancellation response unchanged.
The baseline cancels bookings but does not promote the waitlist. Review candidate/ against baseline/ in your chosen language. A small integration smoke test is provided. The service receives and returns JSON-shaped state; it does not use an external database or send real notifications.
Contract
- State contains a positive integer
capacity,bookings,waitlist, andevents. - Bookings and waitlist entries have a unique string
idand a positive integerseats. IDs are unique across both lists. Confirmed seats never exceed capacity. - Cancelling a confirmed ID removes that booking. Return
{status: "cancelled", state: ...}. - Cancelling an unknown or previously cancelled ID returns
not_foundand leaves state unchanged. It must not produce events or perform promotions. - After a successful cancellation, promote the waitlist in FIFO order, stopping at the first entry that cannot fit. Do not skip that entry to admit a smaller group behind it.
- An entry fits if its seats are less than or equal to available capacity.
- Every promoted entry moves from waitlist to bookings and adds exactly one
{kind: "confirmed", booking_id: ID}event, in promotion order. - Entries that are not promoted remain in their original order.
- The input object must not be mutated. The returned state belongs to the caller.
- Calls are sequential; persistence, delivery of events, and concurrent callers are outside this exercise. Events here are records, not network requests.
Start
From the repository root:
git diff --no-index exercises/08-waitlist/baseline/python/service.py exercises/08-waitlist/candidate/python/service.py
python3 exercises/08-waitlist/smoke.py
# TypeScript alternative
git diff --no-index exercises/08-waitlist/baseline/typescript/service.ts exercises/08-waitlist/candidate/typescript/service.ts
node --test exercises/08-waitlist/smoke.test.ts Read lesson 8 for the submission task. Do not open solutions/08-waitlist/ until you have written your review.