# Reference patch — 01-surge-pricing

The answer key for how the reference absorbs this change, and the thing that makes `budget.json`
reproducible. **Never shipped to the candidate.**

1. **Add** `OccupancySurgePricing.java` (in this directory) to `reference/src/`. New file, so
   `measureChange` charges nothing for it.
2. **Change one line** in `reference/src/MovieBookingSystem.java`, the everyday convenience
   constructor:

   ```diff
        public MovieBookingSystem(Clock clock) {
   -        this(clock, new StandardPricing());
   +        this(clock, new OccupancySurgePricing(new StandardPricing(), 0.5, 20));
        }
   ```

`edits.json` beside this file is the same edit in machine-readable form, so the measurement can be
re-run: baseline is `reference/src/*.java`, current is the same files with the `reference-patch`
`*.java` added and the `edits.json` replacement applied, fed to `measureChange(baseline, current)`.

Measured: `reference_diff = 2` (1 added, 1 removed, one file touched), so
`diff_budget = max(3, 2 + ceil(2/2)) = 3`.

Both the curveball suite (5 tests) and the base suite (20 tests) are green after the patch. **No
base assertion is invalidated** — the base problem's own prices are still exactly what the contract
states, because nothing crosses the 50% occupancy line in any base test (the fullest a base test
ever leaves a show is one seat booked).

## Where the requirement landed, and where it did not

`Show`, `MovieBookingSystem.hold/confirm/releaseHold`, `HoldRecord` and `StandardPricing` were not
opened. Two decisions already in the base design are what reduced this to one file and one line:

- **`PricingPolicy.priceMinor` already takes `bookedSeats` and `totalSeats`.** This is the base
  design's one piece of stated anticipation (see the decision log) — the base implementation,
  `StandardPricing`, ignores both, but the seam was already wide enough for occupancy to answer
  through without a signature change touching every implementation and every call site.
- **A hold's price is quoted once, at hold time, and stored on the `HoldRecord`.** `confirm` never
  recomputes it. That is what makes "a hold made before the surge switched on still charges its
  original price at confirmation" true with no extra code — it was already true of the base
  design's promise about price, and surge pricing did not need to add an exception to it.

The test worth watching in a candidate's design is `groupHoldIsPricedAtOneOccupancySnapshot`: a
group hold that itself pushes a show over the halfway line must still be priced at the occupancy
that existed the moment the hold was made, not per seat inside the loop that grants it. A design
that recomputes `bookedSeats` between seats inside one hold would surge the second seat of a group
hold that only crossed the line because of the first — which is not what "quoted once, at the
moment of the hold" means.
