An agent must not modify the gate it's judged by

Houman Azimi-Nejadi · 13 November 2026

Coding agents now fix failing builds, add tests and open their own pull requests. That makes the build itself, the tests and the CI pipeline, part of what the agent can touch. If an agent can edit the check it is judged by, a green build stops meaning much: the fastest way to make a failing test pass is to change the test.

The usual answer is trust in the agent's report. That is thinner than it sounds. In a sample of 174 public pull requests written by coding agents, 243 of 294 claims that tests or CI passed could not be checked against any record at all.

I run my own studio's engineering through coding agents, and the rule that has mattered most is a simple one: an agent must not modify the gate it is judged by. Here is the rule set, three cases from our own record, and what a team can do with it on Monday.

The rules

We wrote these down in June 2026, as part of the design for agents that fix CI and add tests.

  1. No agent may modify the gate it is judged by. An agent fixing CI cannot make it green by deleting or skipping tests or editing workflows and thresholds. An agent adding tests cannot lower the coverage floor or weaken existing assertions. Changing a gate needs a human.
  2. Propose, never auto-merge. Agents open pull requests. A human or an independent CI gate approves the merge, and nothing deploys to production on an agent's say-so.
  3. The writer is never the approver. The agent that writes a fix is never the one that approves it, even when one agent holds several capabilities.
  4. Measure the quality, not the metric. Coverage is easy to game, so tests an agent adds are checked by mutation testing: break the code on purpose and see whether the new tests notice.

The order matters too: we did not give an agent write access to CI until the CI was trustworthy.

Three cases from our own record

The agent that stopped at the gate. On 29 September a coding agent was preparing an experiment whose plan had been frozen in advance. Experiment plans sit on a protected path in our repository: a commit that touches one must carry my signature, and a pre-push check refuses anything unsigned. The agent's commit was unsigned. It stopped and reported, rather than finding a way round the check. When I read the commit before signing, there was a second problem: on its local branch the agent had added a paragraph to the frozen plan itself. Detail added after a plan is frozen belongs in a dated correction, not an edit, so that is where it had to go. The gate did its job twice: once by refusing, and once by making a person read before signing.

The runner is not the agent. Our agents run inside a runner that waits for CI and can make its own repair commits. In a preregistered study of how often agents misreport their own work, some mismatches turned out to be the runner's doing: a repair commit had moved the head after the agent declared it. Those are counted in a category of their own and never against the agent. When the runner later began making its own claim (after the CI wait, that no check had failed), that claim went into the runner's own record, marked as the runner's. Whoever makes a claim is the one it is checked against.

The gate applied to us. Before switching our evidence tool, Cejel, to a new default scoring version, we ran a preregistered promotion study with four pass criteria fixed in advance. One failed: on 78 of 400 test cases, a shallow clone of the code scored lower than a full clone of the same code, purely because the history was missing. Missing evidence should give no verdict, not a worse one. So the next release shipped without the switch, and a changed version means a new freeze and a new study. It would have been easy to call it a near miss and switch anyway. The point of a gate is that nobody gets to do that, including the person who built it.

The rule as a check anyone can run

Rules in a design document are easy to forget under deadline. So the first rule is now also a check in Dunstan, our open-source tool that compares what a coding agent says it did with the repository and CI record.

When an agent claims its tests passed, Dunstan settles the claim only against a test record that CI itself uploaded. If the same pull request also changed the CI workflow that produced that record, the pull request wrote its own evidence. Dunstan then marks the test claim "unverifiable", never "pass" (record_producer_changed_by_pr), and its remedy is to land the workflow change in a pull request of its own.

That is the rule in its smallest form: a change cannot certify itself.

What a team can do on Monday

None of this needs new tools. GitHub and GitLab already have the pieces.

  • Protect the gate files. Put the CI workflows, test configuration and coverage thresholds under code owners, and require a human review, ideally a signed commit, for any change to them.
  • Keep gate changes in their own pull request. A pull request that changes the pipeline should not also be the one the pipeline judges.
  • Separate writer and approver. An agent's pull request is merged by a person or by a CI gate the agent cannot edit, never by the agent or by another agent from the same run.
  • Mutation-test the tests agents add. A test that still passes when the code is deliberately broken is not a test.
  • Refuse by default. When a check cannot decide, the answer is "stop and ask", not "pass".

What gates don't solve

Gates decide what an agent may do. They do not tell you what it did. An agent can stay inside every rule above and still report work it didn't do, or report tests that ran on its own machine and never in CI. That is why the second half matters: check each claim the agent makes against the record, and say plainly which claims the record cannot settle.

The two halves need each other. Without gates, the record can be rewritten by the thing it is meant to judge. Without the record, the gates are guarding a story.

Dunstan is open source and in GitLab's CI/CD Catalog, and it runs as a GitHub Action. If you want to see how much of your own agents' reporting can be checked today, its survey command (still a draft) tells you, per repository.

Houman Azimi-Nejadi, Barg Labs