deanphillips.dev

Building with AI · October 2026

My new rules lasted one hour before my AI found a way around them

I turned on branch rules that make my approval the only way a risky change can merge. Within the hour, a routine pull request showed a way around them. Here's how it was found, and why the fix needed fixing.

SeriesPart 2 of 2
  1. Overview From trust to enforcement
  2. Part 1 A threat model for the pipeline
  3. Part 2 Finding a hole in its own rules

This is the last of three posts on governing an AI delivery pipeline. The first covers the rules GitHub now enforces, and the second the threat model behind them. This one is about the afternoon they went live, and the three bugs hiding in the rules themselves.

How a risky change merges now

For the riskiest changes (anything touching the agents’ own rules, the data on the phone, or permissions), the flow ends with me. The review agent reads the change and, if it finds no blockers, turns on GitHub’s auto-merge, pinned to the exact commit it reviewed. Then it asks me. I tap Approve in the GitHub app on my phone, and the change merges itself.

The pin is the whole promise. When I approve, I’m approving something the reviewer already read.

Bug one: a merge that would never happen

The pull request that added these rules went through review first, like any other. The review agent sent it back with one blocker.

The ruleset pull request, round 1GitHub pull request, on my phone
  1. ReviewerBlocker: if turning on auto-merge fails, nobody is told. The review bot doesn't have the permission auto-merge needs, and the repo has auto-merge switched off until the rules are applied. The owner approves, nothing merges, and no run ever starts to notice.
  2. Build agentFixed: the step that turns on auto-merge now uses the builder bot, which has the permission. The script waits until GitHub shows auto-merge as on, and if it never does, the owner is asked to merge by hand instead.
  3. ReviewerFixed. Owner decides.
Shortened from the real review.

That would have been a quiet failure. Every risky change would sit approved and unmerged, and I’d have assumed the agents were slow.

Bug two: a commit nobody reviewed

The rules went live, and the first risky change merged itself on my approval, as designed. Then the agents opened the next one: the governance page that lists every control and its evidence. The review passed with two wording nits. A build agent fixed them and pushed one more commit.

Auto-merge stayed on.

Step through it to see why that matters.

  1. After the review

    Everything lines up

    • ReviewedA
    • Pull request is atA
    • Auto-mergeOn

    The reviewer read commit A, found only two wording nits, and turned on auto-merge pinned to A. Now it waits for me.

  2. Then

    One more commit

    • ReviewedA
    • Pull request is atB
    • Auto-mergeStill on

    A build agent fixes the nits and pushes commit B. Nobody has reviewed B.

  3. If I had tapped Approve

    B merges, unreviewed

    • ReviewedA
    • MergedB
    • Reviewed byNobody

    GitHub checks the pinned commit only when auto-merge is turned on. A later push from anyone with write access doesn't switch it off. So my approval would have merged code the reviewer never read.

  4. Now

    A push turns it off

    • Pull request is atB
    • Auto-mergeOff
    • NextNew review

    A small workflow watches for pushes. It turns auto-merge off, takes the pull request out of my queue, and says it needs a new review.

Commit A was reviewed. Commit B wasn't.

Here it was a two-line wording fix, and I’d have been approving what was on my screen anyway. But the promise was that I only ever approve reviewed code, and a push after review broke it without any warning.

The pattern:

a check that runs once, when something is switched on, isn’t the same as a check that holds. If the thing it guards can change afterward, something has to watch for the change.

Bug three: the fix needed fixing

That new workflow went through review too, and the reviewer found a problem in it. Here’s a simplified version of the step it flagged. Can you spot it before the reviewer did?

Tap the line that lets an unreviewed commit sneak through.

Line 3 shrugs off every error, so the step reports success and posts 'Auto-merge is off' even when it isn't. A permission change or a GitHub outage would look exactly like success, and the unreviewed commit could still ride the old auto-merge in. Now the step only shrugs when auto-merge was already off. Otherwise it fails loudly.

if ! disable_auto_merge "$PR"; then
  if [ "$AUTO_MERGE_WAS_ON" = "true" ]; then
    echo "Couldn't turn auto-merge off" >&2
    exit 1
  fi
fi

I’d let the step shrug off an error because auto-merge might already be off, which is a perfectly normal case. The reviewer’s note was blunt: “a failed disable is reported as success.” It was right.

Both pull requests merged that afternoon, each on my approval.

What I took from it

My favorite part is still the last one. The review bot caught a bug in the code that guards its own reviews.