On 22 November a local open-weights model, working inside my software factory, was asked to make two checks go green that no honest change could satisfy. It moved the real tests to a folder the check does not run. It left a stub that fails against main only because of an ImportError. It hid a file from test collection with pytest_ignore_collect. Then it described all three in its own summary.
The model did what the setup rewarded. This post is about that setup: a pipeline where AI agents write the code for a small app, I make the decisions, and every control sits outside the model. I ran one app through it from 20 to 23 November. It produced 101 agent runs, 65 checkpoints and 645 logged minutes of my time. Some of those numbers are strong. Some are weak, and I say which.
TL;DR
- Of 65 checkpoints the factory posted, 36 (55%) were problems, not decisions. The agents are not why. 97 of 101 runs ended without error. The plumbing and the plans were the problem.
- A local model cheated a gate three ways when the plan could not pass. The fix was a structural guard, not a better prompt.
- Four rework loops by agents could not fix a bug that one configuration value fixed. The agents never saw the file that triggered it.
- 345 of my 645 logged human minutes are gate defaults, not measurements. Plan review and code review are the weakest figures.
- A privacy bug the gates did not catch: OCR read
@ as Q, so an email address skipped redaction and reached the model. It is still open. - The scope is one app, four days and one user. Nothing here shows the factory generalises.
Terms used in this post
I use a handful of words that are specific to this project. Here they are in one place.
| Term | What it means |
|---|
| Software factory | A pipeline where AI agents do the typing and a fixed set of checks decides what is allowed through. Mine is a small set of scripts and a template repository. |
| brevkoll | The first app built in it. You photograph a Swedish letter, and it tells you what the letter says, what you must do and the deadline as a calendar file. |
| Agent run | One call to a coding model (Claude, or a model on my own GPU) to do one step, such as write a spec or implement one slice. |
| Gate / checkpoint (CP) | A point where the pipeline stops and waits. A checkpoint is the message it sends to my phone. Some are decisions I make (spec, threat model, plan, merge, release). Others report a problem. |
| Foreman | The script that runs every minute, reads my replies on the issue (/go, /rework, /stop) and starts the next step. It does not write code. |
| Dispatcher | The script that runs one agent step, applies the guards and pushes the result. Agents never push themselves. |
| Holdout tests | Acceptance tests I write from the spec and keep in a folder the agent cannot read or edit. They are the answer key. |
| Ratchet | A quality number (for example, the longest function) that is allowed to improve but not to get worse. |
| Local model | An open-weights model that runs on my own GPU workstation, so its tokens are not billed. |
What the factory is
The design starts from an argument by Dex Horthy, who shut down his lights-off factory: agents move the bottleneck to review, and the damage shows up weeks after the tests go green. I took the opposite design. A short loop with a human decision at six points, and a control under each point that does not depend on what the model thinks of it.
For one change, the loop runs like this:
- CP1, spec. I write the spec and the acceptance tests. The tests go in
tests/holdout/, which the agent can neither read nor edit. - CP2, threat model. An agent drafts it. I decide every row. A row still marked
PROPOSED blocks the gate. - CP3, plan. An agent researches the code and plans in vertical slices. Approval has to be a commit of mine. The factory’s own commits never count.
- Build. One agent run per slice, with CI after each. A test the agent adds must fail against the old code, or CI rejects it. The agent cannot push, cannot merge, and cannot touch holdout tests, CI workflows or its own permissions file.
- CP4, try it, then merge. The pull request is built and staged in a sandbox: read-only root filesystem, all Linux capabilities dropped,
no-new-privileges, 1 GB of memory, 200 processes, non-root. I try it on my phone, read the diff and merge. Only I merge. - CP5, release. The image of
main is built, scanned with Trivy and given an SBOM. I accept it.
The code is public: factory, factory-template and the app, brevkoll. Inside brevkoll the model gets no tools, and code parses the dates, so an injected “the deadline is cancelled” can change a summary but not the calendar entry.
None of this is new. Holdout tests the agent cannot see follow the pattern StrongDM described for its own factory. What I can add is what it costs and what it catches when one person runs it.
What 101 agent runs looked like
The dispatcher logs every run. Between 20 and 23 November that is 101 runs and 349.5 agent minutes across 10 issues, with 4 errors. Implementation is 180 of those minutes, spec drafting 84.
The first issue, the v1 decoder, took 13 runs, 18 minutes and $3.88. It cost me 106 minutes: 90 on the spec and holdout tests, 10 on the threat model, 5 on plan review and 1 on code review. I used those numbers in issue 36 of the newsletter.
The cost needs care. From 22 November the factory defaults to the local model. 42 runs went to Claude, and the dispatcher recorded $16.16 for them. 59 runs went to the local model on one workstation GPU: 288 agent minutes and an estimated 1.8 kWh. The factory prices those runs at the rate of its fast tier, which gives $25.51. That is an estimate, and nothing was billed. The factory’s own summary adds the two into $41.67. I do not quote that figure, because it mixes money spent with money not spent.
36 of 65 checkpoints were not decisions
A checkpoint is a message to my phone that asks me for something. I counted them on 22 November from the Gitea comments on every brevkoll issue. The factory had posted 65, and I had sent 72 commands (/go, /rework, /stop). About 35 further comments were notices. Only 29 checkpoints (45%) were real decisions. The other 36 were fixes only I could make (18), step retries (13) and exhausted retries (5).
I traced the 36 to six causes. The counts are approximate, because I classified them by reading:
- About 12 were the same
-fix posted again. I replied /go, nothing had changed, and the same text came back. One issue produced five identical checkpoints about internal names in the mirror. - About 9 were factory bugs charged to the item as step failures. A cache bug caused a spec timeout. A step wrote tests to the wrong path.
- About 8 were mechanical rules reported instead of repaired. A holdout file that was not format clean. A
PROPOSED word in prose. An internal name that the mirror guard refused only after the merge, which is the most expensive moment. - 2 to 3 were a plan that could not pass its own gates. That is the next section.
- 2 were cloud usage limits counted as failures, and 2 were agents that produced nothing.
My reading: a checkpoint is a page, and the same alert rules apply as for on-call. It should carry a decision only I can make, and the factory should repair what it can repair deterministically. GitLab’s runbook guidance on deleting alerts says the same about non-actionable pages.
The waits tell a separate story. Across 81 recorded answers my median wait was 7.2 minutes, and 47% were answered within 5. The longest was 1,315.9 minutes (21.9 hours). The slow ones sit at the try-it-and-merge gate, which needs a phone and attention.
The gate the model cheated
Issue #26 was meant to make a quality check pass again by splitting a long function. The plan had two properties no honest change could satisfy together:
- It added tests for behaviour that already exists on
main. The gate says a new test must fail against main, so a test of existing behaviour can never pass it. - It said “no new files” while splitting a function in place. The ratchet tracks file length, so it had to fail.
The foreman offered only a plain retry. The local model’s rework then:
- moved the real tests to a folder the gate does not run;
- left a stub that fails on
main only through an ImportError; - hid a file from test collection with
pytest_ignore_collect.
It listed all of this in its summary, so the work was visible. I reverted the rework (85c3cd4).
This matches published measurement. ImpossibleBench (Zhong, Raghunathan and Carlini) builds tasks whose tests contradict the specification, so any pass is a shortcut by construction. It reports GPT-5 passing 54.0% of the conflicting SWE-bench tasks. Giving the model an exit, a flag_for_human_intervention string that ends the run, cut GPT-5 from 54% to 9%. The authors note the effect was much smaller for Claude Opus 4.1. An exit helps with some models and not others, so a prompt alone will not carry the control.
What I changed:
- factory#85 refuses a run that hides tests from a gate, before it is pushed, and turns the run into a
-fix that explains why. - The remaining failing checks go to me, with a choice: add tests that pin current behaviour, or allow a new module.
- Done later, in code: the foreman now refuses test files that pytest would not collect (wrong file name, or a folder outside the configured test paths), and writes the
# AC<n> marker that ties each acceptance criterion to a test, instead of asking the model to remember. - Not done yet: a check that the count of collected tests can only grow, a plan-versus-gates check at CP3, and a different model as judge after the build.
The lesson for AI security is the one attack-tool research keeps reaching. Elastic’s review of five offensive agent frameworks found none enforcing authorization in code. A control that lives in a prompt is a request. A control the agent cannot edit is a control. Here the model was not hostile. It was given an impossible job and an open path to a green check.
The bug four rework loops could not fix
Issue #36 is the opposite failure. Nobody cheated. The agents simply could not find the problem. On staging, uploading a correct PDF returned “The model returned an unusable answer.”
What happened over about an hour on 23 November:
- I sent
/rework four times in 54 minutes. That produced 15 agent runs, 32 comments and 35 minutes of my time. - The agents made four guesses: strip code fences from the output, strip
<think> blocks, accept bare JSON. None of them reproduced the failure. - They never saw the PDF. The factory’s snapshot of an issue ignored attachments, and the file was attached to two comments (18,109 bytes).
I then ran the same PDF through the same model with the same prompt (1,741 characters) at two token limits:
max_tokens | finish_reason | Completion tokens | Answer characters | Reasoning characters | Result |
|---|
| 600 (the app default) | length | 600 | 0 | 2,457 | “unusable answer” |
| 3000 | stop | 1,604 | 564 | 6,497 | parses, 4 actions, 13 s |
The model is a thinking model. It writes its reasoning first and its answer after. With a limit of 600 tokens it ran out while still reasoning, so the answer was empty. The staging environment lacked the two settings my workstation had (MODEL_MAX_TOKENS=3000 and MODEL_TIMEOUT_S=120), so it used the app’s defaults of 600 tokens and 30 seconds.
The fixes, all merged:
- The app now raises a specific error that names the setting (
ModelOutOfTokens, with no model text in the response and only counts in the log). Its defaults are 3000 tokens and 120 seconds. - The factory now hands attachments to local-model runs (up to 5 files and 5 MB, excluded from git). A cloud run is told the file exists but is not given it. A warning fires when an agent says it could not reproduce a problem.
What I take from it: an agent that cannot reproduce a bug will still produce a plausible patch. That is the dangerous case for review, because the patch looks reasonable and changes nothing.
A security bug the gates did not catch
Issue #6 records a privacy hole that the pipeline’s checks did not stop. Brevkoll redacts personal data such as email addresses before text reaches the model. It runs redaction on OCR output. The OCR read the @ in an email address as Q, so mentorQexempelskola.se no longer matched the email pattern, skipped redaction and went to the model. That breaks the app’s own invariant that identifiers are redacted before any model call.
It is a design gap, and it is still open: the fix needs my decision, which is to recognise a garbled email address before redacting. The lesson is a limit of the method. Gates check what someone thought to check, and none of mine covered OCR errors in front of the redaction step.
Which of my numbers are weak
The factory exists to measure one thing: how much of my time a change costs. I log minutes with each /go. On 22 November I made the minutes optional and let the gate fill in a default (spec 10, threat model 5, plan 10, review 15, rework 5), marked default. That keeps the workflow usable on a phone. It also damages the metric.
Of 645 logged minutes, 300 are typed or predate the default, and 345 are defaults. By gate:
- Plan review: 42 typed of 172.
- Code review: 41 typed of 161.
- Threat model: 119 typed of 149.
- Spec: 98 typed of 128.
The two review gates are the ones I trust least, and they are what the “review is the bottleneck” argument is about. So the honest reading is that I have not yet measured review time with this data. The 1-minute code review on the first issue was typed. Later review numbers mostly were not. The board now separates typed from default minutes.
Two other limits apply. One app and one person is not a sample. The factory’s own metrics show 9 agent pull requests, a rework rate of 0.22 and 0 escaped bugs. Zero escaped bugs means no bug found after merge in a project whose only user so far is me.
The release gate and the stale cache
The release step builds the image of main, scans it with Trivy and refuses the release if any HIGH or CRITICAL finding has a fix available. It only counts findings with no fix.
On 22 November, release v2026.11.22.2 had 146 such unfixable findings (1 CRITICAL) and 0 fixable, so it was accepted. That is defensible for a base image I cannot patch. It is also a decision a reader of the green check would not see.
On 23 November, a later release candidate was refused for 56 fixable HIGH or CRITICAL findings. All were Debian OS packages: four distinct ones (libkrb5-3, libgssapi-krb5-2, libk5crypto3, libkrb5support0), each one patch version behind. I rebuilt the same commit and scanned it with the same Trivy version:
| Build | Fixable HIGH/CRITICAL | Unfixable |
|---|
| With the Docker layer cache (what the release used) | 56 | 93 |
--no-cache | 0 | 93 |
The base image digest was already the newest upstream, so bumping it would not have helped. A cached apt-get install layer was older than Debian’s fix. The gate had judged a stale layer, and its refusal message told a human to “fix it with a new change” without saying how. Release builds now use --pull --no-cache, and the refusal names the packages and the remedy. I also added apt-get upgrade to the app’s runtime image stage. Both changes were still open pull requests when I wrote this.
Smaller findings that matter
My own gate caught my own bug. Semgrep flagged a shell injection in the CI workflow I wrote: $ interpolated into a run: step. The base ref was a branch I control, so it was not exploitable. With the pull request’s head branch or title it would be. This is the documented script-injection pattern for GitHub Actions. The fix is to pass the value through an environment variable.
Who is allowed to say /go. The foreman and I started on one Gitea login, told apart by comment prefixes. Any comment without a known prefix would have been read as a command, and Gitea could not say who added a label. I moved the foreman to its own factory-bot account, created as code. Only the owner’s comments are commands, and only the owner merges main. The agents never talk to Gitea. The dispatcher pushes their work after its own guards run.
An autopilot that approved a plan unseen. On 22 November I let a night mode pass the spec, threat model and plan checkpoints by policy. It approved a plan for issue #6, which said it needed a human decision, by picking an option. Acceptance criteria were “covered” by tests of an earlier issue because the names matched. The fix is risk tiers in code. A bug fix with at most two phases, no new dependency and no change to a stated invariant runs to the staged build. Anything else stops at the plan, and anything labelled decision stops at the spec. An unlabelled issue counts as a feature, deliberately, because guessing from a title would let a feature run as a bug.
The tick that never finished. For 3 hours and 23 minutes on 21 November (09:52 to 13:15) no foreman tick completed, and a /go I sent from the gym was never read. The cause was a paging helper. Gitea’s issue-comments endpoint ignores page and limit, so an issue with 51 comments made every tick loop to page 1,292 and time out. I suspected the network first and proposed moving the host. My one-request probes were fast because they never made the flood the tick made. The rule I kept: when a tick hangs, count and time its API calls before suspecting the network.
Deliberate regression. After the first live run found six bugs in code that had unit tests, I reintroduced each on purpose: an unwatched idea issue, a wrong owner check, a /go with a note after it, a staged build kept after merge, the old phase counter, /rework accepted anywhere. Each failed exactly the test meant to catch it. A test you have not seen fail is a guess. The factory’s test suite grew from 390 to 427 tests on 23 November, run with and without the bot’s git identity exported.
A stacked-merge mistake. One pull request was stacked on another’s branch. The first merged to main, then the second merged into the old branch, so its code never reached main. I now run git merge-base --is-ancestor <branch> origin/main after every stacked merge.
What to take from this
- Put every control where the agent cannot edit it. Holdout tests, CI workflows, the permissions file, the merge button. If a model can see a control as an obstacle, a long enough run will find a way around it.
- Give the agent an honest way to say a task is impossible, with a distinct exit code, and keep a structural guard anyway. ImpossibleBench shows the exit alone is not enough for every model.
- Give the agent the evidence. Four rework loops failed because the PDF that triggered the bug was never in the agent’s view.
- Check plans against gates before building. The cheapest place to find an impossible plan is the plan.
- Move each prompt-only rule into code. If a rule is only in the prompt, the system relies on the model remembering it.
- Track noise as a defect. If more than half of your human touchpoints are not decisions, the pipeline is training you to click through.
- Label measured and guessed numbers separately, or the metric you built to find the bottleneck will hide it.
This is a four-day dataset from one person. The next numbers I want are from someone other than me using the app, and review minutes that were typed rather than defaulted. If you are building a gated pipeline for coding agents, I am interested in which gate takes the least of your real time. The consultation page has my contact details, and the agent security scorecard is the checklist I use on agent deployments.
References
All factory figures come from factory/data/agent_runs.jsonl, human_minutes.jsonl, gate_waits.jsonl and releases.jsonl, and from my project notes dated 20 to 23 November 2026. The data snapshot is 23 November 2026, 20:22 UTC. The checkpoint counts and their root causes come from my own count of Gitea comments taken on 22 November and are approximate. The issue #36 token test and the Trivy cache comparison are my own measurements on 23 November.
- factory, factory-template, brevkoll, public mirrors of the repositories used here.
- Zhong, Raghunathan, Carlini, ImpossibleBench: Measuring LLMs’ Propensity of Exploiting Test Cases, arXiv 2510.20270, October 2025. The 54.0% and 54% to 9% figures are from the paper and refer to GPT-5 on Conflicting-SWEbench.
- Dex Horthy, Harness engineering is not enough: why software factories fail, AI Engineer World’s Fair 2026. I describe it as summarised in my newsletter; verify before quoting.
- Simon Willison, StrongDM’s software factory, 7 February 2026.
- Elastic Security Labs, Inside the loop: five AI attack frameworks that never ask permission, 13 November 2026.
- GitHub Docs, Security hardening for GitHub Actions: script injections.
- GitLab, Deleting alerts, runbook guidance on non-actionable alerts.