The 7 Stages of Securing the Agentic Software Factory
How to secure the stages of an agentic software factory, with lean manufacturing analogs.

The Toyota Production System (TPS) is the approach to manufacturing that inspired lean manufacturing. It's been studied in schools and applied to many disciplines outside of automobiles. Of course, one of these disciplines is software. For decades, teams have applied and experimented with these approaches and shared them in various publications. Some of the more notable works include the Lean Software Development books by the Poppendiecks. In Implementing Lean Software Development: From Concept to Cash (Addison-Wesley, 2006), they cover the following principles as applied to software:
- Eliminate waste
- Build quality in
- Create knowledge
- Defer commitment
- Deliver fast
- Respect people
- Optimize the whole
With agentic engineering gaining adoption, businesses are starting to build software factories that are powered by these coding agents. At Anthropic, merged code changes went from around 2,500 a day in May 2026 to over 30,000 a day by September.
In the early days of my career, one thing appealed to me about the daily build, continuous integration, and, eventually, continuous delivery. You had a system double-check all of your work before it got to users. To me, it's like running your code through a checklist that runs the same way every time. These were often "boring" activities such as running the build, static analysis, tests, deploy, and release. In those days, developers were still writing the code by hand. Even with all of this automation, most teams relied on human approval on every code change before it got to production. Now, with agentic engineering and its ability to generate thousands of daily changes based on intent, that human review has become a bottleneck that we can no longer ignore.
In 2024, I got the opportunity to see the TPS in action at the Toyota plant in Georgetown, KY. Here, I saw how they build quality in (jidoka) by detecting errors early in the process. I also saw how workers can stop the line when an issue is detected (andon), and how humans and robots work side by side (cobot). At this one plant, they are able to produce about 2,000 cars in a single day.
In this post, I cover how to secure the stages of an agentic software factory, along with their lean manufacturing analogs. This is the introduction to a series of posts I will be doing on securing agentic engineering.
1. Engineering: signed spec
| Scope | Where work comes from: customer conversations, email, Slack, production signals Turning intent into a spec with unambiguous acceptance criteria Everything that enters before it can drive work: issues, docs, URLs, dependencies. |
|---|---|
| Key controls | The engineer owns capturing customer intent, and AI can help draft it. Intent gets recorded as an artifact. A human signs the spec. Criteria are described in markdown and traced to tests. The agent can propose spec changes but can't loosen its own guardrails. Untrusted text never starts work. Suspect input gets quarantined. Inputs carry provenance. |
| Threats it counters | Intent lost in translation between customer and engineer, criteria too vague to check, spec tampering, prompt injection, data poisoning |
In this stage, you capture customer intent. This might start with having direct customer conversations, reviewing communications, or looking for trends in customer behavior. Builders will capture this intent in specifications and acceptance tests, working side by side with AI much like Toyota's workers and cobots. On some teams, this may be product owners and on others, it might be engineers wearing the product owner hat. Because inputs to the specs can come in many forms, you want to assume all input is suspect until you apply controls to increase your trust. Restricting how issues are written and read, using packages from an allowlist, and quarantining data are some of the controls for managing untrusted input. Once the intent - with its specs and acceptance tests - is validated with the customer, it will move to the next stage.
2. Head of the line: sandboxed agent
| Scope | Where and how the agent writes code |
|---|---|
| Key controls | The team defines the sandbox, not each developer. Cloud-based, egress allow-listed. No keys, no authority, no write access to specs, the factory, or main. |
| Threats it counters | Excessive agency, exfiltration after an injection |
Using the acceptance criteria that have been versioned and signed by the customer and builders, you launch 1-n agents in a secure sandbox. Ideally, this should be cloud-based and egress allow-listed. The agents generate code in this sandbox based on read-only access to the specs and acceptance criteria. Deterministic hooks run to self-correct along the way.
3. Stations: pipeline checks
| Scope | All verification, from seconds at the station to minutes in CI |
|---|---|
| Key controls | Keep: SCA, secret scanning, SAST, build, tests, DAST. Add: AST hooks with agent fixes, an independent validator against acceptance criteria, mutation and property testing, agent reviewers. The validator and agent reviewers can never pass on their own, only fail. Dependencies come only from an approved stockroom (an allow-listed artifact repo). |
| Threats it counters | Hollow tests, the agent grading its own work, supply chain attacks, slopsquatting |
When I was at AWS, we built the Deployment Pipeline Reference Architecture. While it was based on the work of Amazon and AWS deploying tens of millions of changes to production annually, the pipeline works in any environment. In a factory driven by agents, you keep doing all of these deterministic actions - including build, static analysis, tests, and deployments. Each check is a station that builds quality in (jidoka) and can stop the line when an issue is detected (andon). The pipeline includes all of the checks you'd expect the best human engineer to check but does it on every single change. What you add is AI agent reviews, mutation and property testing, independent validators against acceptance criteria, and more. Once it passes all of the deterministic checks and none of the non-deterministic checks fail it, it moves to the next stage.
4. Traceability: the receipt
| Scope | The evidence the checks produce |
|---|---|
| Key controls | Checks the agent can't touch sign a receipt covering intent, inputs, results, and the artifact digest. Mutation score counts as evidence; coverage doesn't. |
| Threats it counters | Unverifiable claims, tampered evidence |
Before a change moves to production, you need to establish evidence that it is okay to deliver to users. This evidence establishes that you built the right thing and that you built the thing right. Building the right thing focuses on the intent and acceptance criteria. The thing right includes mutation, property, and validation tests, digital attestations, and provenance.
5. Shipping dock: production admission
| Scope | What reaches production, and who holds the credentials |
|---|---|
| Key controls | Admission verifies the receipt before anything runs. The deploy step holds no signing key. The pipeline holds the keys, and no agent or human has standing production access. A human approves only where policy says so, such as irreversible actions. |
| Threats it counters | Excessive agency, agent-to-agent escalation |
Recently, I did a talk at AI DevCon in NYC called "Who Gets the Keys in a Software Factory?" The basic argument was that now that we're talking in terms of software factories, which actions do we allow coding agents to perform? My main argument is that you don't give humans or the coding agents the ability to deploy to production; you only give the pipeline that capability. I also argue that the pipeline largely consists of deterministic actions. Those pipeline actions may have been generated by agents but signed off by humans.
Since the pipeline holds the keys to deploy to production, it needs to be the most protected thing in your system. What's more, in order to deploy to production, it must check against signed digital evidence. That evidence shows that all of the required actions have been run and that it built the right thing based on the acceptance criteria.
6. Field service: telemetry feedback
| Scope | What happens after release, and how it comes back as work |
|---|---|
| Key controls | Telemetry is redacted and read-only. The agent diagnoses inside the sandbox. Findings return through a defined schema into Engineering, and pass Plant security again. Every failure gets a new check or a tighter spec, never another reviewer. |
| Threats it counters | Sensitive data in logs, agent-written issues turning into injections when re-read |
Once changes are deployed to production and in the hands of users, you observe the systems and user behavior, and get direct feedback from customers. By observing how the users are using the system, you can make improvements and add new features. This closes the loop by generating new issues and running stage 1 again.
7. Plant security: watching the pipeline
| Scope | Changes to production, the pipeline, or specs that bypass the factory pipeline |
|---|---|
| Key controls | Detection runs in a separate security account the pipeline can't touch. Pipeline and spec changes go through the factory pipeline, and loosening a check goes to a human. |
| Threats it counters | Pipeline tampering, stolen deploy credentials, out-of-band production changes, spec tampering |
Since the application pipeline is the most protected thing in your factory system, you need to guard against any potential attacks on it. This involves creating a factory pipeline from a separate security account to which the application pipeline does not have access. The factory pipeline is responsible for making changes to the application pipeline. A monitor in the same account watches for any change that bypasses the factory pipeline. Approvals to the factory are based on risk. Since changes to the application pipeline are high risk, you might require 1-2 human approvals on these changes while the factory pipeline itself is still fully automated.
Wrapping Up
Start with one.
- Verify intent before code exists. The customer confirms the acceptance criteria before any code for that change exists. Every change carries a spec ID back to them.
- Take the keys away from the agent. Run agents in a sandbox with no prod keys or long-lived credentials.
- Make one control machine-checkable. Take the review comment your team repeats most, and make it a check.
- Let evidence authorize every deploy. Do not deploy without evidence.
In future posts, I will cover each of the aspects of the agentic software factory in more detail. Stay tuned.