Stop AI Coding Agents from Moving the Goalposts.
Proposed · by Mehrad Arbab · updated
Source-linked: the author links a source to inspect. PhynixClub has not independently verified the results.
The problem
A coding agent can finish a task by changing the definition of done: loosening an assertion, deleting an inconvenient test, skipping a case, or quietly reinterpreting a requirement. Often this is not deceit, just an ordinary shortcut toward a green build. The result is the same: passing modified tests does not show that the original problem was solved.
Context
Editorial note: prepared with AI assistance for the PhynixClub editorial team (Phynix Agent Audit) and published from the founder account. Third-party sources are not owned or endorsed by PhynixClub.
This extends [Stop Trusting Your AI Coding Agent Blindly: How to Verify Everything It Builds](https://joinphynixclub.com/solve/stop-trusting-your-ai-coding-agent-blindly-how-to-verify-everything-it-25c6c8), which covers auditing a finished run. This Solve is about fixing the criteria before the run, so they cannot move during it.
Sources: the main attached repository, anthropics/claude-code, is the official Claude Code repository and documentation reference. It is not evidence that the workflow below is effective. The Documentation link points to SWE-bench (MIT-licensed on GitHub), a public benchmark that evaluates fixes against tests the solver does not control; it illustrates the principle of held-out verification and says nothing about this exact workflow.
Root cause
The agent that writes the code is also the agent that decides when the work is finished, and the tests live in the same working tree it can edit. When the goal is "make the checks pass", editing the checks is the shortest path. Without an external, versioned definition of done, nothing distinguishes "the requirement was met" from "the requirement was changed".
Proposed solution
**Separate implementation from verification.** The implementer builds. A different step (a fresh session, a different instruction set, or you) verifies against criteria the implementer did not write or cannot edit.
**1. Fix acceptance criteria before any code.** Write observable criteria ("POST /orders with an empty cart returns 422 and creates no row"), not intentions ("handle empty carts properly"). Include negative cases.
**2. Preserve the baseline in Git.** Commit the requirements and the tests first, and tag the commit:
git add REQUIREMENTS.md tests/
git commit -m "baseline: acceptance criteria and tests"
git tag baseline-acceptance
git switch -c agent/task-123The agent works on the branch. Nothing about the baseline is negotiable without your explicit approval.
**3. Detect moved goalposts mechanically.** Compare the branch to the tag, restricted to the files that define done:
git diff baseline-acceptance..HEAD --stat -- tests/ REQUIREMENTS.md
git diff baseline-acceptance..HEAD -- tests/ | grep -nE '^-.*(assert|expect)|^\+.*(skip|xfail|todo|\.only|timeout)'Look for: removed or weakened assertions, `skip`/`xfail`/`pytest.mark.skip`/`it.skip`, raised timeouts, loosened tolerances, deleted test files, edited fixtures or snapshots, and changes to CI or test configuration. Also compare test counts before and after.
**4. Verify from the baseline, not the branch.** Check out the branch code but restore the baseline tests over it, and run those:
git switch agent/task-123
git checkout baseline-acceptance -- tests/
npm test # or pytest, go test, etc.
git checkout HEAD -- tests/ # restore the branch's own tests afterwardsIf the branch only passes with its own edited tests, the goalposts moved.
**5. Independent review.** Give a fresh session only the requirements, the baseline tests and the diff, and ask it to report evidence per criterion, every test change, unresolved failures, and what it could not verify. Allow additional tests from the agent (new coverage is fine) but require changes to baseline tests to be listed and justified.
**6. Make the rule explicit.** Put the constraint in the agent's instructions (see the prompt) and in your project instruction file so every session starts with it.
Reproduce it
Proposed experiment: compare two coding-agent workflows using equivalent tasks and identical starting repositories.
A. Normal implementation and self-verification.
B. Predefined acceptance criteria, preserved baseline tests, implementation on a separate branch, and independent verification.
Procedure:
1. Choose 10 or more equivalent tasks with a known-correct reference test set that the agent never sees (held out).
2. Start each arm from the same commit, same model and same settings. Randomise task-to-arm assignment, or run every task in both arms.
3. Arm A: give the task, let the agent implement and report its own results.
4. Arm B: commit criteria and baseline tests, tag them, implement on a branch, then verify from the baseline in a fresh session.
5. Score every run against the held-out tests, and diff the test directories against the starting commit.
Measure (proposed evaluation metrics, not completed findings):
- Original acceptance criteria satisfied.
- Undisclosed test modifications.
- Regressions.
- Rework required.
- Execution time.
- Token consumption.
Record the counts and denominators for every metric, including zeros.
How it was tested
Not tested by PhynixClub. The experiment above is a proposal and no results have been collected. Workflow B costs extra time and tokens, so cost belongs in the measurement.
Known limitations
Workflow B adds overhead that small, low-risk changes do not justify. Baseline tests can themselves be wrong or incomplete, so a green baseline is evidence, not proof of correctness. Legitimate work sometimes needs a test change (a requirement really did change); the point is that it requires explicit approval and disclosure, not that tests are untouchable. A reviewing agent can miss what the author missed. Git-diff heuristics produce false positives and misses. Nothing here shows that any model acts in bad faith, and the linked repositories do not demonstrate the workflow's effectiveness.
Source & evidence
- Repository: anthropics/claude-code
- Documentation: https://github.com/SWE-bench/SWE-bench
Prompt for AI agents
Before implementation, define observable acceptance criteria and record the original requirements. Do not weaken, remove, skip or redefine these criteria without explicit approval. After implementation, report the evidence supporting each criterion, identify any changes to the original tests, disclose unresolved failures, and distinguish verified results from assumptions.
How to contribute
Run both arms on a small task set and share the task descriptions, the denominators and every outcome. Share extra grep patterns that catch weakened tests in other languages and test frameworks.