24.3 Behavioral checks and regression tests in CI
- Approved by
- Panaversity ·
In everyday life. Before a shop opens, someone counts the cash drawer against yesterday's closing slip. The count takes two minutes, it is done every morning, and it either matches or it does not. Nobody needs the owner for it. But the count cannot say whether the shop gave a customer good advice. It checks what counting can check, and that is enough to stop the shop from opening with money missing.
What you will learn. Which parts of Ana's labels code can check, how those checks run on every pull request, and why a check by code stays the gate even after a judge is added. You practice it in Lab 24, Tasks 2 and 5.
- What can code check?
- What is a behavioral check, and what is a regression test?
- Which level does a test sit at?
- How does the suite run in CI?
- What does a check by code let through?
Why it matters. A check by code is cheap, fast and gives the same result every time. So it can run on every change, including the ones nobody thought were risky.
At work. On Friday, April 9, 2027, a pull request cut one line from the worker's prompt. The checks by code passed 39 of 40, with the one known extraction case named, so the result met the threshold. One answer in that run was wrong, and code passed it. This concept shows why. 24.4 tells the whole run.
What can code check?
Anything with one right form, or a structure that code can test. Anthropic's exam prep course teaches three ways to grade an output, and tells you to choose by the shape of the output.1 Two of them need no model, and they come first because they cost almost nothing:
| Method | Fits an output that | At Brightline |
|---|---|---|
| Exact match | Has one correct form | An extracted amountCents equals Ana's value. The invoice number equals hers |
| A check by code | Has a structure that code can test | The extraction is valid JSON that matches the schema. The answer cites Ana's line and contains her words |
| A judge (24.4) | Is open text, where meaning matters | The order of two steps, or a claim she ruled out |
Use the cheapest method that fits. Anthropic's own guide lists grading by code first, and its cookbook calls it by far the best method when an evaluation can be designed to allow it.23
Here are both cheap methods, for one extraction and one answer:
// exact match: one right form
const amountOk = extracted.amountCents === label.amountCents;
// a check by code: the answer cites her line and contains her word
const citesLine = answer.includes("ap-triage-rules.md:8");
const hasTitle = answer.toLowerCase().includes("controller");These checks look for words only. The order of two steps can be written many ways, so order is never checked by matching a string.
What is a behavioral check, and what is a regression test?
A behavioral check tests that the worker does something, or never does something, whatever words it uses. "Every answer cites a policy line" is a behavioral check. So is "a question the policies do not answer gets no policy citation". It does not compare the answer with one expected text. It tests a behavior that must hold on every case.
A regression test is a case that passed before, run again after a change. A regression is a thing that worked and then stopped working. So a regression test asks one question: does the worker still do everything it did before? The golden set is Brightline's regression suite, and 24.6 says what pass rate such a suite should have.
Which level does a test sit at?
One of four: unit, functional, integration or end to end. The prep course names these four levels of test.1 Each catches what the one before it cannot:
| Level | What it tests | At Brightline |
|---|---|---|
| Unit | One function | The function that compares two amounts in cents |
| Functional | One model call returns the expected shape | One extraction call returns JSON that matches the schema |
| Integration | The handoff between two components | The extraction step's fields arrive, for the right invoice, at the step that uses them |
| End to end | The whole flow | A golden question, asked of the whole worker, gets Ana's answer |
The course says most silent failures hide at the integration level.1 Each part is right alone, and the fault is in what one part hands the next. 24.8 follows one such fault.
How does the suite run in CI?
On every pull request, as a gate with a written threshold. CI means continuous integration: a service that runs the repository's checks on every pull request. npm run eval runs the suite on your computer, and .github/workflows/eval.yml runs it in CI. Three things make it a gate:
- A threshold, written down. Brightline's is 39 of 40, and the report names the one case it allows. A named exception is honest. A threshold that someone lowered to fit the result, without saying so, is not.
- A required check. The repository's branch protection rule refuses to merge a pull request until the check passes.4 So the rule holds late on a Friday too.
- The right run for the change. Most pull requests do not touch the worker's words. For them, CI replays recorded answers through the checks, which needs no model and costs nothing. When a pull request changes the prompt, the model, or the golden set's cases or labels, CI runs the worker live on the cases (24.4).
The full suite with several tries per case is slower, and it is a release step, not a pull request's check (24.6).
What does a check by code let through?
Anything it was not told to look for. On Friday, the worker answered "Who approves a $12,000.00 invoice?" with "The controller, after payment", citing ap-triage-rules.md, line 8. The line is cited. The word "controller" is there. So both checks pass.
That is the price of a check by code: it is exact about what it was told to look for, and it sees nothing else. The answer is not to make code guess at meaning. A second reader is added for what only reading can check, and code still makes the final decision, as it did in 23.16. Code counts the judge's marks, and holds the pull request when any answer still waits for Ana. 24.4 gives the rule.
Going further. Checks on live traffic are Chapter 35's subject.
The operating rule: check with code everything that has one right form or a structure, on every pull request, against a written threshold. Say beside each check what it cannot see.
Do this now. Pick one answer your project's model gave today, and give it to your coding agent. Copy this line:
List every part of my expectation that code could check with an exact match or a short test, and write those checks. Then list every part that code cannot check, and say why. Do not use a model inside the checks. Here is the answer and what I expected:
Keep the second list. It is the judge's whole job in 24.4.
Check yourself
Question 1 / 9
0 answered
An extracted amount must equal the value Ana wrote down. Which grading method fits?
Sources
- Claude Certified Developer, Foundations prep path, Module 4: Production Engineering, Evals, and Security, Anthropic Partner Academy.↑↑2↑3
- Define success criteria and build evaluations, Anthropic.↑
- Cookbook: Building evals, Anthropic.↑
- Introduction to evals: Evals in production: CI, batch, and drift, Claude Academy.↑
- Owner
- Panaversity