DEV Community

Cover image for Never push without proof: near misses from building an unattended CI agent
Darshan P Pawar
Darshan P Pawar

Posted on

Never push without proof: near misses from building an unattended CI agent

At hour 41, my CI agent could have pushed a commit marked "proven" for a fix that proved nothing. Its scoreboard said 16 of 17 real bugs fixed, so nothing looked wrong.

Greenlight is my entry for Agentware 2026, in the Developer Workflow track. When a pull request's build goes red, it reproduces the failure in a sandbox with no network, fixes the code and pushes the fix to the pull request's branch, with nobody at the keyboard. When it shouldn't touch the code, it tells a person what to decide.

Here is one unattended run, from a red build to a pushed, proven fix (2 min 34 s):

Its one promise is "never push without proof". Before any push, code (not the model) checks that the failing tests now pass, the whole suite passes, the same tests fail again with the change set aside, and no test, CI or secret file changed.

This is what that looks like on a real pull request: what failed, the one-character change, and the proof, including the run with the fix set aside.

Greenlight's comment on a pull request: what failed, why, the fix, and the proof

These are the times that promise, and a few others, nearly didn't hold. Hours are counted from kickoff.

The proof could be cheated

By hour 41 Greenlight had fixed and proven 16 of 17 real, already-merged bugs from two open-source projects. Then I red-teamed the push rules, the way someone who wanted a bad change merged would. Several attacks got through:

  • A test that skipped itself from inside the code counted as a pass.
  • Anyone could comment "build FAILED" on a pull request and start a change.
  • JavaScript tests named without a file path, the way node --test reports them, skipped the "fails again without the fix" step.
  • Protected files could be reached under other names. GIT~1/config, .git./config and calc.py::$DATA are spellings Windows can resolve to files the rules were meant to guard.

A second pass found six more. One was a JavaScript test file named dates-test.js that the agent could still edit and push. Another went the other way: an ordinary logged error was read as a failing test and blocked a correct fix.

Each hole is a way to push a commit whose receipt says "proven" when nothing was. That is worse than no check, because a green mark from the agent is exactly what tells a reviewer to stop looking.

All of it was fixed the same afternoon, in two commits nine minutes apart, and every attack is now a test in tests/test_proof.py and tests/test_proof_runners.py.

Try to cheat it What happens now
Make the test skip, or exit early with "success", from inside the code Not a pass: every test has to be seen passing
A change that has nothing to do with the failure Set aside, every failing test must fail again, or no push
A stranger comments "build FAILED" to get code changed Ignored: only CI accounts can report CI
Edit the test so it expects the wrong answer Refused: test files are read-only, in any letter case and through links
Reach a protected file under another name (GIT~1/config, ::$DATA) Refused: Windows aliases and anything under .git
Change the fix commit afterwards greenlight receipt fails
Fake the test runner's own report from inside the test process Not caught (more below)

The code now enforces this:

  • Every test that passed or failed before must be seen passing. A skipped, missing or cut-short test is not a pass, and skips can't grow past the base branch's count.
  • With the change set aside, every originally failing test must fail again, for every test runner.
  • Only CI accounts can report CI (GREENLIGHT_CI_USERS).
  • Protected paths match in any letter case, and Windows aliases, links and anything under .git are refused.

The step that makes "proven" mean something is the counterfactual. From greenlight/runner.py:

# Counterfactual: set the fix aside and run the whole suite on the original code, exactly as it first
# failed. Every originally failing test must fail again; otherwise nothing shows the fix made it pass.
await self.repo.stash()
try:
    cf = await self.run_tests("", failing.env, label="counterfactual")
finally:
    await self.repo.unstash()
runs.append(cf)
if cf.green:
    return VerifyResult(False, "the originally failing tests also pass with the fix set aside, "
                               "so nothing shows the fix is what made them pass", runs)
Enter fullscreen mode Exit fullscreen mode

And the hole from the red-team pass, closed by counting:

if r.not_run > may_skip:
    return VerifyResult(False, f"{r.not_run} tests were skipped or marked as expected to fail, {may_skip} before; "
                               "a skipped test is not a pass", runs)
Enter fullscreen mode Exit fullscreen mode

All 16 real-bug fixes, checked again, still met the stricter rules.

One of them, from cve-bin-tool: 1 test failing of 31 before, all 31 passing after, the same test failing again with the fix set aside, and Greenlight's patch next to the one the maintainers merged.

Greenlight's proof for a real cve-bin-tool bug, next to the maintainers' fix

The weak point was never the model. It was the verifier. If your agent has one guarantee, attack the guarantee, not the prompt.

The trap that got through

The organisers' Trap Pack is 20 hostile files: emails, web pages, documents and transcripts with planted instructions and broken data. The 17 from other tracks went in as data inside pull requests, because a pull request can carry anything.

Round 2 ran at hour 28, about 3:40 in the morning. No canary token leaked anywhere. Then came the answer sheet: the planted-instruction scanner had flagged only 2 of the 10 files that carried planted instructions, plus, wrongly, a newsletter that only quoted attacks as examples. It read the pull request's title, description and comments, but not the lines the diff added. It missed an instruction split up by 68 zero-width characters, a base64 blob in a <meta name="agent-config"> tag, a fake "[system] Tool policy updated" notice granting shell access, and a call transcript asking for the full transcript to be emailed to "claims-audit at fastsettle dot invalid".

Nothing leaked because the scanner was never the defence. The model's eight tools can read and search files, edit source files and run tests in a sandbox with no network. There is no shell, email, web, merge, approve or delete tool to talk it into using. Round 3's scanner reads the diff, strips zero-width characters and decodes base64; it flagged all 10. All three rounds, failures included, are in the repo.

The agent we had stopped

Greenlight's first review on a real GitHub pull request, at hour 42, had two problems. Its proof showed the run without the fix as a red-cross "after: 20 passed" line, which reads like a failed fix. And it linked to http://localhost:8701, which nobody else can open. Both were fixed within five minutes, and the agent was restarted.

The next pull request was answered anyway, by a process left over from before the restart: on Windows, stopping the background task had left the Python program running. Still on the old code, it posted a status linking to localhost again, then stopped on a git error. That pull request was closed and a clean one opened.

The kill switch stops runs inside the agent. It can't stop a second copy it doesn't know about. Now stopping the agent includes checking that its port is free and no process is left.

The kill switch that froze

The dashboard and the kill switch run in the same Python process as the agent, on one asyncio event loop. That's fine while nothing blocks the loop.

The model's search_code tool walked the repository on that loop, running a path check on every file, and a safety change earlier that afternoon had made that check stricter. On a large project one search held the loop for seconds at a time, and for those seconds the dashboard and the kill switch did not respond. It surfaced when the script recording the demo video timed out waiting for the dashboard.

Search and file listing now run in a thread:

async def _t_search_code(self, text: str) -> ToolResult:
    ...
    hits = await asyncio.to_thread(self._search, text, 40)
Enter fullscreen mode Exit fullscreen mode

tests/test_tools_responsive.py slows every file read and directory walk by 0.3 s, runs a ticker on the event loop beside the search, and fails if the loop stalls for more than 0.2 s:

async def ticker():
    while True:
        await asyncio.sleep(0.01)
        now = time.perf_counter()
        worst[0], last[0] = max(worst[0], now - last[0]), now
Enter fullscreen mode Exit fullscreen mode

The same change stopped the file listing from naming .env and id_rsa.

A kill switch that shares a thread with the work can be blocked by the work. Test it while the agent is busy.

Hour 68: running it like a stranger

On the last evening the repo was cloned fresh and run the way a judge with only a free Gemini key would:

  • Google's main model answered 503 "high demand", each reply took about two minutes, and two tries kept the first run waiting four minutes before the lighter model fixed the bug in seconds. Now the main model gets one try of at most 90 s when a lighter model is behind it.
  • greenlight trap-pack crashed in the Docker setup, because the folder it writes results to is mounted read-only there. Results now go to state/trap-pack/.

After the first fix, the four-step tour gave all four expected outcomes in 91 s, for $0. The same check showed the free model fixes real bugs less often (1 of 3 Python-Markdown cases; the other two stopped at the 30-turn limit and pushed nothing), and the README now says so.

The one still open

The proof reads the test runner's own report. Skipped, removed and cut-short tests are caught by counting them, but code written to forge that report from inside the test process could still pass. The fix is a normal commit on the pull request's branch, so a person still reviews and merges it. The README's "We tried to cheat it" table lists this one as "Not caught".

Three things worth taking away

  1. Make the dangerous actions impossible, not discouraged. An injection can make a model want something. It can't give the model a tool it doesn't have.
  2. Attack your own guarantees, and keep every attack that worked as a test.
  3. Test the safety features under load and from a fresh clone. That is where the frozen kill switch and the last day's problems showed up.

Code, traces and all three Trap Pack rounds: github.com/Darshanpawar7/greenlight

Demo video (2 min 34 s): youtube.com/watch?v=UjWCKEOdcd0

Built for Agentware 2026, run by Hackathon Raptors (@raptorsdev, raptors.dev).

This write-up is my entry for the Near Miss at Agentware 2026, a prize sponsored by FileClerk: https://fileclerk.co.uk/

Top comments (1)

Collapse
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

The counterfactual is the load-bearing proof here — failing again with the fix set aside is what turns 'tests pass' into 'the fix caused it'. Your red-team holes are the honest part: a self-skipping test counting as a pass, or GIT~1/config slipping past protected-path checks, shows a proof is only as strong as its enumeration. The one hole you left uncaught — faking the runner's own report from inside the test process — is the interesting one: is the fix sandboxing the test process away from the report channel, or is that the residual risk you accept?