Case story · Gated dev looppetekaik · portfolio

Gated
autonomy

An agent writes the fix. Plain code decides whether it ships. Every 15 minutes a loop on a Mac checks the scheduled jobs on a home server, files an issue for a failure, and sets a sandboxed coding agent to work. The agent writes a diff; the loop tests it, opens the pull request, waits for CI, merges, deploys and checks production. If the check fails, it rolls back. After three failed attempts in a row, it stops.

One model call, everything else plain code

The loop replaces an earlier self-repair component that ran inside the same container on the home server. That one stopped working and nobody noticed. The loop runs on a separate machine, so a broken job container cannot take the repair with it. Its gates follow the gated autonomy table in the public README.

  1. P1Detect

    Plain code, no model

    The loop polls the scheduled jobs on the home server and files a GitHub issue for each failure it finds.

  2. P2Choose

    Plain code

    It picks the issue by label, priority and age, and only ever works on the owner's issues.

  3. P3Classify

    One model call

    A single model call classifies the issue. A routing table then picks a model tier for the job.

  4. P4Write

    Agent in a sandbox

    A coding agent writes the fix in a throwaway git worktree, inside an OS sandbox with no network and no credentials.

  5. P5Reject

    Plain code

    A diff is rejected if it touches a protected path, matches a secret pattern, exceeds the token cap or tampers with git metadata.

  6. P6Ship

    Plain code

    The loop tests the diff, commits, opens the pull request, waits for CI and merges.

  7. P7Verify

    Plain code

    It deploys and checks production. If the check fails, it rolls back and opens a revert pull request.

The agent cannot push, merge, deploy or reach production. It cannot edit the loop, the CI, the deploy script, the job definitions, the config or the secret scanner. The one model call classifies; the routing table and every gate around it are Python that can be read and tested.

Nineteen runs, ten merges, one rollback

Every run between 7 and 9 November 2026, from the loop's local run log. The log is not published, so these figures are marked as such; pull requests are cited by number because their repository is private.

The loop merged 10 issue-fix pull requests and 9 stayed. Those were PRs #35, #38, #39, #40 and #42 to #47.

The one that did not stay was reverted by the loop itself: PR #36 reverted #35. The fix was fine. The loop's own production check used the wrong Python. It was fixed by hand in #37, and the same issue was re-shipped as #39. The loop itself was written in PR #32 with Claude Code. Its bugs were fixed outside the loop, in #33, #34 and #37.

Of the nine deployed fixes, 8 came from deepseek-v4.1-flash via Ollama and 1 from Claude, as a forced escalation test. Local run log, not published

The stop rule is why it is off

The threshold is in the public devloop/devloop.py: three consecutive failed attempts halt the loop until a person clears it.

It reached that threshold on 9 November 2026 and has been halted since. It is not running now. The stop is the rule working as designed, not a failure of the loop.

What the loop maintains

The jobs it watches are a real system, not a test fixture.

28 scheduled jobs are documented in docs/jobs.md. 19 modules, 7 core and 12 optional, are documented in docs/modules.md. The public repository holds 85 tests in devloop/test_devloop.py, run in public CI.

The public repository is github.com/petekaik/rainer-devloop, MIT licensed and one commit. The project it maintains is private, which is why the run figures above carry numbers rather than links.

Who did what

Agents wrote the loop and the fixes; a person set the limits.

AI agents wrote the loop and the fixes. Petteri set the limits: what the agent may never touch, the stop rule and the gates. He reviewed the loop's code, and he decides when the halt is cleared.

The point is not that an agent can write a fix. It is that plain code decides whether the fix ships, and that the same plain code can stop the whole thing.