AI code review · Self-paced workshop

Workshop booking contract

Practise understanding changes, checking AI findings, and making review decisions you can defend.

Workshop index · Download all examples and lessons

This is a small in-memory service, not a production API. Each call represents a single request against an immutable snapshot of a workshop’s occupancy. Persistence, authentication, cancellation, and concurrent requests are outside this first exercise’s scope.

Inputs are non-negative integer capacity and booked, with booked <= capacity, plus an integer requested. Callers guarantee these input types and occupancy invariants. Booleans, NaN, floating-point quantities, and malformed HTTP input are not valid inputs to this service contract.

  • A request must contain at least one seat. Otherwise return invalid_quantity.
  • If the requested seats exceed the remaining capacity, return sold_out.
  • Otherwise return confirmed and the new booked total.
  • Rejected requests preserve the existing booked total.
  • Validation of quantity takes precedence over capacity checks.
  • Booking exactly the remaining capacity is allowed.

Every result has status and booked. Both languages use the same status strings and JSON fixtures. The small public suite covers common cases; it is not a complete specification.