Anything I publish on ModelBrain.net goes live when someone pushes to main. There is no staging step between that push and the public site. So the question of who can push to main is really the question of who can publish.

I let an AI agent do most of the work in that repository, so I had to answer it on purpose.

The rule, and where it lives

My ops toolset is a small server that gives the agent a short list of operations on my machine, including a git push. For the three ModelBrain repositories that tool refuses main outright, and has since 9 October 2026. It also refuses a dirty working tree and never force-pushes. Branch pushes are allowed.

So the agent can stage, commit, branch and push a branch. It cannot publish.

The usual advice agrees with this in spirit. An AWS Security Blog post from 30 July 2026 says agent runs should be sandboxed so they cannot push directly to protected branches, with the merge decision staying with a human. I agree with every word. The difference is where my refusal sits. It lives one layer earlier, in the tool, so the agent gets a plain explanation and a different path instead of a rejected push from a server.

The bug that taught me to fail closed

The tool's source carries a comment about a mistake I made in its first version. The dirty-tree check was written as “if the status call worked and shows changes, refuse.” When git itself errored or timed out, that condition was false, and the push went ahead. A control I had documented as applying to every repository disappeared at exactly the moment git was misbehaving.

The fix was one line of logic: if the tool cannot determine the state, it refuses. A permission check that fails open is not a check. It is a default that happens to work on good days.

What the human step looked like today

On Saturday the agent finished two new articles and handed me one command. It fetches, confirms that main is an ancestor of the branch, and only then pushes. I ran it and it printed nothing.

Nothing had been pushed. Main had moved since the agent built its commits, so the ancestry check failed and the chain stopped. The agent rebuilt the commits on the new main, I ran the command again, and it went through.

A silent no-op is an ugly interface. It is also a safe failure, and I will take safe over friendly on the one step that cannot be undone.

What this does not cover

The refusal lives in my tooling, not at the git host. It stops this agent through this tool. It does not stop anyone holding a credential and a terminal, and I am one of those people on purpose, because I am the control. Treat a tool-level refusal as the usability layer. The enforcement layer is a protected-branch rule at the host, and anyone copying this should have both.

The principle

Enforce the rule where the agent's hands are. Make every check fail closed. Keep exactly one irreversible step for a named person. It is the same separation of duties I would ask of a human contractor, applied to something that works faster and never gets tired of asking for access.

Frequently asked questions

Should an AI coding agent be allowed to push to main?

In my setup, no. The agent can stage, commit, branch, and push branches, but the tool refuses main, so a person keeps the one irreversible step. On this site a push to main publishes, so that step is the publish decision.

What does fail closed mean for an agent permission check?

If the check cannot determine the state, because git errored or timed out, it refuses instead of proceeding. My first version failed open on a git error, which silently disabled the control at exactly the moment git was misbehaving.

Is a tool-level refusal enough to protect main?

No. It stops this agent through this tool, not anyone holding a credential and a terminal. Treat it as the usability layer and add a protected-branch rule at the git host as the enforcement layer.