Patterns · working with agents

Merge and deploy, nobody watching.

What does it take to let an agent merge and deploy with nobody watching? A lane so narrow that every step is code or a gate: only dependency bumps, a scope check on the diff, a deploy key that can do one thing, and a breaker that stops it after the first failure.

The flow

Unattended fixes: a scheduled run, a chain of gates, and what waits for me Three lanes, read left to right. A daily run reads the scanner findings. A classifier, in plain code, sorts them: what is in the lane goes on to the fixer, which opens a pull request on a fix branch; everything else is handed to me. CI and the scope check verify the diff, the lane merges when every check is green, and the deploy gate deploys. Smoke and a security check then run after the deploy: if both pass, one summary mail goes out; if either fails, the breaker stops the lane until I reset it. in the lane all green merged passes not in the lane: handed to me either fails I reset it 1 Daily run reads findings 2 Classifier plain code 3 Fix and PR fix branch 4 Scope check CI, on the diff 5 Merge all checks green 6 Deploy gate one command 7 Smoke and security 8 Summary mail one per run 9 Breaker stops the lane 10 I take over handoffs, reset I DECIDE AN AGENT ACTS A GATE CHECKS
  • I decide
  • An agent acts
  • A gate checks

Numbers match the steps below.

Steps

  1. Scheduled runReads the scanner’s findings

    Once a day a job fetches read-only findings from the security scanner, which runs on its own schedule. Every field is checked against a strict pattern and free text is dropped, so a hostile finding cannot carry instructions. Deploys from the previous run are checked against the newer scan first.

  2. ClassifierSorts each finding, in plain code

    No model is involved. Each finding becomes one of four things: in the lane, a handoff to me, skip (no fix exists), or wait (a release cooldown). To be in the lane a finding needs high or critical severity, a fix within the same major version, a release old enough to have survived its first days, a service the deploy gate knows, a path that is not protected, a closed breaker and budget left. There is a hard cap on lane deploys per day.

  3. FixerFixes only what the lane allows

    Ordinary code does the clone, push, pull request, merge, deploy and mail. A fixer edits one lockfile, pin or image line in a throwaway worktree. For the rare lockfile an ordinary update cannot move, a Claude model is a fallback, with a fixed prompt, a deny-by-default tool list and a spend cap, and its result is re-verified. The lane then pushes a fix branch and opens the pull request.

  4. CI + scope checkProves the diff is only an allowed kind of change

    CI runs a scope check on fix branches. Allowed: lockfile changes, exact version pins, a base-image tag or digest, package version pins, and an image pin for the same repository. Anything else fails with a violation line, whatever the fixer meant to do. The lane also needs every other check to be green.

  5. The laneMerges, only if every check is green

    The merge is pinned to the head commit that was checked, so nothing can slip in afterward. A skipped check counts only if it is on a short named list. A pull request still pending after a time limit becomes a handoff instead of waiting forever.

  6. Deploy gateDeploys through a key that can do only that

    The deploy key runs one forced command that allows exactly a status check or a deploy of a named service from a short list. It refuses unless the checkout is clean, on the main branch, and a fast-forward. The edge, the platform and the rest of the monitoring stack are refused by name.

  7. Smoke + securityFails the deploy if either fails

    Both run inside the deploy, and a non-zero exit is a failed deploy. A deploy that never reports the security check passing is reported as not verified, never as shipped. The next run checks the fix against a newer scan: the finding must be gone and the running image changed, or it is handed off and not retried.

  8. The laneSends one summary mail

    A short list: shipped, for me, waiting on upstream. It is sent only when something shipped or something new needs me, so an unchanged list mails nothing.

  9. BreakerStops the lane after a failure

    A failed deploy reverts through a pull request, redeploys the old state, opens the breaker and sends a rollback mail. A merge that never deployed opens it too. While it is open nothing merges or deploys, though the summary mail keeps going.

  10. MeReset the breaker and take the handoffs

    I look first, with a status check on the service, then reset the breaker. I also take everything classified as a handoff: the lane never merges those.

Guardrails

What stops it

A narrow lane

  • Decisions are plain code, not a model. The model fallback edits one lockfile with no source-control, remote or network tools.
  • A release cooldown, same-major fixes only, and a daily cap on deploys.
  • The scope check makes the diff a dependency bump or nothing, and the lane will not merge without it green.
  • The deploy key runs one forced command and cannot reach the edge, the platform or a shell.

What waits for me

Not in the lane

  • Edge components: a pull request may be prepared, never merged by the lane.
  • Sensitive paths: workflows, deploy scripts, exposure config, and the label that releases them.
  • Major version bumps, auth and data changes, and the database engine packages.
  • Anything with no clear fix, or a repository outside the gate.

What happens on failure

Revert, stop, tell me

  • A failed deploy: revert pull request, CI, merge, redeploy, then the breaker opens and a rollback mail goes out.
  • A merge that never deployed also opens it. I reset it after looking.
  • A crash mails and leaves the success marker stale, so a dead-man alert fires when a day goes by without a run.

What this does not claim

The lane is deliberately small. It handles dependency security fixes and nothing else, and everything outside its definition becomes a handoff rather than a judgement call by an agent. Some parts of it are still to prove in production, notably the model fallback, which a normal run never exercises. Making the scope check a required check on the repositories is my decision, and the lane does not make it for me.

The idea

Autonomy is safe when the lane is narrower than the agent’s capability. Put the decision in code you can read, prove the diff is the kind of change you allowed, give the deploy key one verb, and stop everything after the first failure. Then the worst thing an unattended run can do is bounded by the design, not by the agent’s good behaviour, and what does not fit the lane simply arrives on the human’s desk.

Copied