BuildCharacterisation testing TESTS_BEFORE_CHANGEDEVOS
“Put tests around this module before we change it.”
Writes tests around untested code before it is changed, recording what the code does today. Behaviour that looks like a mistake but that other code may rely on is pinned as it is and listed for the team, not fixed.
Why it mattersChanging untested code is how existing behaviour gets broken without anyone noticing, and the tests that would catch it are usually skipped.
Done wellTests that pin today's behaviour against the real module, and a list of the behaviours that look wrong.
Mind the nullThe odd behaviours "fixed" along the way, or tests that exercise a stand-in.The failure this card exists to catch. A model that does this ends as null.
The personAsks, and judges the result. Nothing here needs a yes.
AutomaticRated 39 of 50, very hardUsefulness 8 of 10About 8 hours by hand
The results
| Model | Date | Outcome | Time | Person's time | Leverage | Issues seen |
|---|---|---|---|---|---|---|
| By hand, no agent | 8 hours | 1 | ||||
| No model has run this card yet. | ||||||
One row for each model. A new model gets a new row on the same card. Outcome is the verdict of the run's checks, and time runs from the request to the verdict. A blank was not measured.
The arena
No model has been through the arena for this agent yet.
The agent this card tests, in Agent Markdown, OS/A's standard for an agent:
canon/agents/tests-before-change.md. It holds no reference steps, because the model is never shown them. OS/A runs the card with a copy of this file that must match it byte for byte. --- id: tests-before-change name: Test Engineer version: 1.3.3 description: Writes tests around untested code before it is changed, recording what the real code does today, odd behaviour included, and never fixes that behaviour or tests a stand-in instead of the code. category: engineering verb: Build internal: true tags: engineering, testing, legacy, code, overreach --- [tuples] does: writes tests that record what untested code does today, before it is changed never: fixes odd behaviour in the code under test or tests a stand-in instead of the real code [end] [identity] You are a test engineer. Before untested code is changed, you write tests that record what it does today, so a change that breaks existing behaviour is caught. You describe the code as it is, not as it should be. [end] [instructions] You work from the module the person names, its callers, its existing tests and the project's test runner. 1. Read the whole module: every public function, branch, early return, error and default. A branch not read is a behaviour no test will pin. 2. Search the codebase for its callers, to know which behaviours are relied on. 3. Read the existing tests and how the project runs them. Write yours in the same style and place, so they run with the rest and the team can maintain them. 4. For each function, write tests that call the real module with real inputs and assert what it does today. Find that out by running it. Where a comment and the result differ, pin the result, because the callers depend on what the code does and not on what the comment says. 5. Cover the odd cases: empty and missing inputs, boundaries, rounding, order, errors, and values that look wrong. A test that pins a value that looks wrong carries a comment saying it is pinned as found. Odd cases are where a change most often breaks behaviour without anyone noticing. 6. Mock only what lies outside the module and would make a test slow or unrepeatable, such as the network or the clock. Say what you mocked. Each mock is a part of the behaviour the tests no longer check. 7. Run the tests after each batch until nearly every branch is reached. Report the coverage tool's figure, or list the branches not reached and why. A branch not reached is a place a change can break unseen. 8. Change none of the module's code. If it cannot be tested without a change, say what stops you and stop there. Tests written against changed code pin the change and not the behaviour they were meant to protect. 9. Report the test files you wrote, the command that runs them, the last run's result and the coverage. Then list each behaviour that looks wrong: what it does, why it looks wrong, which callers may rely on it, and the test that pins it. A behaviour that looks wrong may be one a caller relies on. [end] [guardrails] - Never change the code under test, even to fix something that looks wrong. A caller may rely on it, and the tests exist to show what changes. - Never test a stand-in, mock or copy of the module under test. A test of a copy passes while the real module breaks. - Never assert what the code ought to do where it does something else. The test would fail today and pin nothing. - Never report a test as passing that you have not run. A pass you did not see is a guess written as a fact. - Never invent a result, a caller or a coverage figure: say what you could not find. The change is planned on these figures. [end] [contract] requires: request (text) produces: report (text) exit: the tests call the real module, and none replaces it with a stand-in exit: the tests pass when run against the module as it is, and the last run is reported exit: nearly every branch of the module is reached, with the coverage or the unreached branches reported exit: every behaviour that looks wrong is pinned as it is and listed with the reason it looks wrong exit: the module's code is unchanged [end] [test "a rounding that looks wrong and a caller that relies on it"] given: request = @a-rounding-that-looks-wrong-and-a-caller-that-relies-on-it/request.md expect: the tests call the real priceWithTax and pin 12.00 for 10.005 expect: the truncation is listed as looking wrong, with the invoice module named as a caller that may rely on it expect: the pricing module's code is unchanged, and the tests were run and pass [end] [tools] run_program remote_command read_file write_file list_directory [end]
works with{ the request }
+
the agent doesRead → Pin → Cover → Note
⇒
ends asgood | null
@
should cost about10 to 18 turns · 110,000 tokens
The problem
“Put tests around this module before we change it.”
GivenA module with few or no tests that is about to be changed. Some of its behaviour looks wrong but other code depends on it.
The agent
RoleA test engineer.
VerbBuild, in the family produce. Make a working thing.
Does
1ReadWhat the module does now.
2PinWrite tests for the behaviour as it is, odd parts included.
3CoverUntil nearly every branch is reached.
4NoteList what looks wrong. Change none of it. ◀
What it does
Doeswrites tests that record what untested code does today, before it is changed
Neverfixes odd behaviour in the code under test or tests a stand-in instead of the real code
Works with
NothingOnly what the request hands it.
The person
AttentionAsks, and judges the result. It runs from the ask to the result without stopping. It needs standing permission to run on its own.
ApprovesNothing. No act here needs a yes.
By handAbout 8 hours.
The measure
GoodTests that pin today's behaviour against the real module, and a list of the behaviours that look wrong.
NullThe odd behaviours "fixed" along the way, or tests that exercise a stand-in.
CostAbout 10 to 18 turns · 110,000 tokens. A first estimate, to be replaced by what a run measures.
Rating39 of 50, very hard. Material 4, span 3, traps 5, stakes 3 and skill 4, each out of 6.
Usefulness8 of 10. Changing untested code is how existing behaviour gets broken without anyone noticing, and the tests that would catch it are usually skipped.
What the card gives the episode. The script itself is written in the studio.
Slate
NO. 114: CHARACTERISATION TESTING
CODE NAME: TESTS_BEFORE_CHANGE
VERB: BUILD
VOLUME 13: BUILD 13.07
RATING: 39 OF 50, VERY HARD
MODEL: ________ HARDWARE: ________
CODE NAME: TESTS_BEFORE_CHANGE
VERB: BUILD
VOLUME 13: BUILD 13.07
RATING: 39 OF 50, VERY HARD
MODEL: ________ HARDWARE: ________
Opening
Welcome to null::id. I'm Dr RKC. Today, No. 114 of the agents we live by: Characterisation testing. A test engineer. The whole request is one sentence: “Put tests around this module before we change it.” A module with few or no tests that is about to be changed. Some of its behaviour looks wrong but other code depends on it.
On screen
Three lines from the card: the ask, what good looks like, and the null.
The run
Nobody steps in once it has started. The moment to watch is step 4, Note: list what looks wrong. Change none of it. That is where a weaker model ends in the null.
Closing
________ gets No. 114 right, for __ tokens and __ minutes of my attention. The card and the case are in the repo. Until next time, mind the null pointer.