Who decided what 'fixed' means?
You ask the agent to fix the importer splitting `"Smith, Jo"` into two fields. It edits `importer.py` and the test file, then reports that all tests are green.
The agent chose what 'done' meant and wrote the check for it. Does that green run prove the bug you saw is gone? Or does it only show that the agent's code agrees with the agent's test?
Pin the target before the agent aims
The agent takes the shortest path to the signal it can see. If it writes the test along with the fix, the test can encode its own misreading of the bug. If a test is in the way, it can edit it until green.
**Later cost:** the bug ships behind a passing suite that now asserts the wrong behaviour.
If you pin the target first, the only cheap route to green is changing real behaviour.
Executable definition of done: 4 steps
1. Write, or agree with the agent, a test or repro script that shows the bug as users hit it.
2. Run it. It must be red **for the bug's reason**, not because of an import error or a typo.
3. Commit it, then say: "Do not edit this file. If you think it is wrong, stop and tell me why."
4. Afterwards, `git diff <sha> -- <file>` must be empty, and the test, run by name, must be green.
A frozen repro test, committed first
Commit this before the agent starts. `parse_rows` skips the header line and returns the data rows. Run the test and it is red: the first row comes back as `['1', '"Smith', ' Jo"']`. That failure is the bug itself, not a crash.
The test uses two different quoted names plus a plain row. Code that special-cases one string, or that breaks ordinary rows, stays red. Varied cases shrink the room left for gaming.
// Python
# tests/test_quoted_fields.py
from importer import parse_rows
def test_comma_inside_quotes():
src = ('id,name\n'
'1,"Smith, Jo"\n'
'2,"Lee, Al"\n'
'3,Kim\n')
assert parse_rows(src) == [
["1", "Smith, Jo"],
["2", "Lee, Al"],
["3", "Kim"],
]
When the agent moves the goalposts
The agent reports: "Done, all green. The quoted-comma test was too strict about whitespace, so I adjusted the expected values."
**Tell:** `git diff a1b2c3 -- tests/test_quoted_fields.py` is not empty. Whatever the reason, the agent moved the definition of done.
The good version: the agent stops and shows its evidence. You decide. If you agree, you change the test yourself, confirm it is red again, and commit it. That new sha is the baseline for the freeze check.
Agree it, see it red, freeze it
Agree on the failing test before any fix exists. See it red for the bug's reason, then freeze it. The agent can no longer pick or move the target. It can only game what the test leaves unchecked, so make the cases varied.
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.