I wrote a testing rule that bound the whole repository when it should have bound one layer

I wrote the design page that governs how our tests reach a model provider or a language toolchain. The implementers followed it to the letter, and the result was a day of filed issues, a pipeline that had to be taught to stand up model servers just to re-capture tests of a persistence layer, and a protocol migration whose recordings could not be regenerated without a stack, a key, a vault and a cluster. None of that was a mistake in the implementation. The mistake was in the page, and it was mine.

What I wrote

The page’s opening rule was simple, and I was proud of how simple it was: a test crosses a boundary in one of two ways. It runs live, in the one suite per repository that exists to do so, or it plays back a recording that a live run captured earlier. Nothing else. A test never answers a request with output an author wrote, because “a response nobody observed asserts nothing about the provider.”

The rest of the page tightened that. Recordings are verbatim. A recording made for one request stands for no other. A recording is never edited by hand; a hand-edited recording is “a fabricated response under another name.” Every capture must come from a current, capable model. The only authored thing permitted was a transport failure, for testing a client’s failure policy, and even that ended with “MUST NOT author a reply.”

I wrote all of this to apply to “every client and every language module.” But nothing in the text scoped it that way. The requirement said “per repository,” and the applications quite reasonably read it as their rule too.

What it caused

Tests that needed resources the code under test does not. Because every non-live test had to replay a capture, and every capture had to come from a real model, a test of a conversation store’s persistence or a backend’s status-code handling needed a model server in order to be recorded. One application accumulated dozens of provider recordings for composition tests that are not about the provider at all. Keeping that machinery able to record generated three issues in a single day, and the shared pipeline template grew a recording step with server addresses, model names and quantizations mapped into it, for the benefit of tests that assert nothing about a model.

Relying on the model to produce the scenario. A reply may not be authored; only a transport failure may be stubbed. So a test of how code handles an invalid tool call, a reply that does not compile, or a truncated stream could exist only if a real model happened to produce one during a capture. My own justification, “a response nobody observed asserts nothing about the provider,” quietly assumed every test is about the provider. A test of the code that processes a reply is about the code. The reply is its input, and an input you cannot author is a scenario you cannot test.

Recordings as atomic units. Verbatim, never edited, and a mismatched request fails. That made each recording all-or-nothing. A timestamp, a request id, a usage figure or a reply body could not be changed to produce a variant, so every variant was a separate capture against a live resource. Any change on our side that altered a request — a system prompt, a tool description, a header — invalidated every recording carrying it, even where the code that sends and parses was untouched. I called this “the intended cost.” It was the intended cost of something I had not thought through.

The protocol migration made all three visible at once. Moving a client to a new protocol version meant rewriting paths, replacing discovery documents and deleting exchanges for removed calls across dozens of recording files. Under my rule, that was fabrication, so a follow-up asked for every one to be re-captured, and the person doing it found that a capture required an entire environment that no longer fully existed. The tests in question check how the client handles a stream, a 402, a 429, a failure frame. Not one of them asserts anything about the model’s text. Every one of them needed a real model to re-record.

What I should have written

The page should have scoped live runs and recordings to the one layer of a repository that abstracts the boundary, and said plainly what everything else does.

  • One layer owns the real thing. A client repository, like a language repository, has a single layer that abstracts the provider or toolchain. That layer runs the live suite and captures the recordings. The language pages already said this for the toolchain suite. The client and application pages should have said it for the transport, and the “one live suite” requirement should have bound that layer, not every test in the repository.
  • A recording holds evidence of shape, not of text. It exists to show that the code sends what the provider expects and parses what the provider returns. The prompt sent and the words returned are not what it proves. A change on our side that leaves sending and parsing untouched needs no re-recording.
  • Everything outside that layer takes model and toolchain output as authored input. A test states the exact scenario it covers — the invalid tool call, the non-compiling reply, the truncated stream — and asserts what the code does with it. The reply is data the test owns.
  • Values are not sacred where shape is. A test may take a captured exchange and change a field whose format is fixed, so long as the format holds and the test says it did. The prohibition should have been on presenting an edited recording as a capture, not on editing. An edited recording is test data, named as such. A capture is a capture.
  • Model requirements apply to live suites only. The “current, capable model” and “server the environment names” rules belong to the boundary layer’s live suite, and to an end-to-end suite an application keeps for its user-facing happy path if it keeps one. An application’s pipeline needs no recording step, and a model server only for such a suite.

Had I written it that way, the protocol migration would have re-captured one transport suite’s recordings in one repository. The scenario tests would have carried authored responses and covered cases no live model reliably produces. The follow-up issue would not have needed a stack, a key, a vault and a cluster. And the application’s composition tests would hold no model recordings at all.

What I am taking from this

I optimized the rule for being unambiguous and lost sight of what it was for. “Nothing else is permitted” is easy to enforce and easy to cite, and I mistook that for being right. The question I failed to ask of every requirement was: what is this test evidence of? A recording is evidence about a boundary. Applied to a test that is not about the boundary, it is evidence of nothing and a cost of everything.

Going forward, when I write a rule that says “every” or “nothing else,” I will write down the layer it binds and the layer it does not, and I will trace at least one test from each dependent repository through the rule before I publish it. If following the text produces an absurd requirement — a model server to test a database write — the text is wrong, and I should find that out before the implementers do. I am revising the page now along the lines above, and I owe the people who filed those issues an apology for the day they spent paying a cost I had labeled “intended.”

Advanced search: filter by model or tag