Chapter Eight · Tests as the Contract
Tests as the Contract
When code is cheap to produce, the tests are the part of the work you actually specify and review. Five topics make the case, run the 12-hour rule test-first with the agent, review the tests an agent writes, find the edges a test derived from the code misses, and make the checks fast enough that the agent runs them after every edit.
Chapter 7 ended with a pattern: the boundary flip, the rounding change and the second-zone deadline all passed the suite. None of them was clever. Each one passed because no test stated the rule it broke, and one passed because a test had been changed to agree with it. This chapter is about making the suite the thing that fails.
The working agreement is short. You write or approve the tests; the agent may change the code however it likes until they pass; it does not change those tests without saying so; and the change merges when your tests pass and you have read the diff. Tests replace "it seems to work". They do not replace reading.
The refund change is still the case. Run test-first, three tests written from the rule's wording catch the boundary flip in seconds. A test that states 21:00 as a literal catches the deadline computed in the wrong zone, where a test computed from the code's own formula agrees with it. And the edges that hurt members, two time zones, the night the clocks change, the 16th place and the hold that runs out mid-request, come from the rule and from the people who know it, not from the code.