
Why the next generation of software factories needs to know when to stop.
There's been a lot of discussion lately about software factories. A. LOT.
The idea is pretty straightforward. Instead of having a dev manually coordinate every stage of software development, we build systems capable of taking a requirement and moving it through planning, implementation, testing, review, and delivery.
Agents write the code. Other agents review it. Automated systems run tests, check requirements, and decide whether the work can move forward.
And ideally, the entire process can operate with very little human intervention.
I think we're going to see a lot more of this.
But there's something about the current conversation that I think deserves more attention.
What happens when the factory produces something wrong?
Not just code that fails a test. I'm talking about an agent misunderstanding a requirement, modifying something outside its scope, introducing a security issue, or making a decision that causes problems several steps later.
What happens when one agent's mistake becomes the starting point for five other agents?
How does the factory recognize that something has gone wrong?
And more importantly, does it know when to stop?
These questions have been on my mind while building Kujo and working on autonomous software factories.
They've also brought me back to a concept from manufacturing that I've discussed before, but haven't revisited in a while.
It's called Jidoka.
And I think it's going to become increasingly important as software factories move from interesting experiments into systems we actually depend on.
What is Jidoka?
Jidoka is one of the foundational principles of the Toyota Production System.
It's often described as automation with a human touch, although I think that translation can make the concept sound simpler than it actually is.
The basic idea is that a machine or production process should be capable of detecting an abnormal condition and stopping before the problem continues through the production line.
Rather than allowing defective work to move forward and relying entirely on inspections at the end, quality controls become part of the production process itself.
Imagine a manufacturing line producing thousands of components.
One machine begins producing parts with an incorrect measurement.
Without Jidoka, those parts might continue moving through the factory. Other machines assemble them into larger components, workers install them into finished products, and eventually an inspector discovers the problem.
Now the factory has hundreds of defective parts, wasted materials, and potentially a much larger problem to correct.
With Jidoka, the abnormal condition can be detected where it occurs.
The process stops, the problem becomes visible, and someone can investigate before production continues.
This is closely associated with another Toyota concept called the andon, a system used to signal problems and call attention to conditions requiring intervention.
The objective is to prevent defects from continuing downstream and establish a process that can reliably produce quality work.
Jidoka doesn't mean a human needs to personally inspect every component. The system should handle normal operations automatically and involve people when something requires their judgment.
That's a solid model for autonomous software development.
Software factories have the same problem
Think about what happens when a developer gives an autonomous software factory a task.
"Add support for a new payment provider."
The factory receives the request, creates a plan, assigns implementation work, runs tests, reviews the results, and prepares a pull request.
Maybe the process involves five agents. Maybe twenty.
Some agents work in parallel while others depend on the results produced by the earlier stages.
Now imagine the first agent misunderstands part of the requirement.
It assumes the new payment provider should replace an existing integration instead of operating alongside it.
The agent writes the code, runs a few tests, and reports that its work is complete.
A second agent reviews the implementation, but it receives the same incorrect interpretation of the requirement. Then a third agent updates the documentation. And another agent prepares the release.
By the time someone notices the mistake, the factory has successfully completed several stages of work around an incorrect assumption.
Each agent might have performed its assigned task reasonably well, but the overall result is still wrong.
This is one of the problems I think we should be careful about as we build increasingly autonomous systems.
An error early in a workflow can become an accepted assumption throughout the rest of the workflow.
And because agents can operate quickly, the problem can spread much faster than it would in a traditional dev process.
More agents don't automatically mean better software. Sometimes they just mean we can produce more incorrect work in less time.
That's where I think Jidoka becomes appropriate.
Build the ability to stop into the factory
If we're going to borrow the idea of a factory from manufacturing, I think we should also borrow some of the engineering principles that made those factories reliable.
A software factory shouldn't be designed solely around completing tasks.
It should also be designed around detecting abnormal conditions, containing failures, and deciding whether work is authorized to continue.
Consider a workflow where an agent is implementing a feature.
Before the work begins, the factory has an approved spec describing what needs to change, which parts of the repo are in scope, and what conditions must be satisfied.
Then the agent begins implementing the feature.
During execution, it attempts to modify a file outside its authorized workspace. That should be an abnormal condition.
The execution environment should enforce the boundary, and the workflow should record the attempted violation.
Depending on the policy, the affected work might stop immediately or require approval before proceeding.
Now consider another situation.
The implementation is complete, but an independent eval finds that the acceptance criteria hasn't been satisfied.
The factory shouldn't simply accept the implementing agent's explanation that everything is fine.
It should recognize that the work hasn't met the required standard.
- Maybe the agent gets another attempt
- Maybe the task is returned for replanning
- Maybe the failure requires human review
But the decision should be made according to rules established outside the agent's own judgment.
And this is where Jidoka becomes more interesting than simply adding another testing stage.
The ability to detect problems and interrupt work needs to exist throughout the process.
During planning, execution, verification, and release preparation. And whenever work moves between agents.
If we only inspect the final output, we've already allowed potential problems to travel through the factory.
Autonomy needs boundaries
One of the things I don't want from autonomous software factories is a system that constantly asks me for permission.
If I need to approve every command, inspect every file change, and personally decide whether every step can proceed, I haven't gained much from the automation.
I've just given myself a different job.
But I also don't want a system where agents have unlimited authority to decide what should happen next.
There needs to be something between those two extremes.
I want agents to perform the work they're authorized to perform, while the surrounding system enforces the boundaries we've established.
A normal operation should proceed without interruption, while an expected failure might trigger a bounded retry.
An unexpected condition should be recorded and evaluated, and a condition that exceeds the factory's authority should stop the affected work until it can be resolved.
Think about an agent responsible for updating a database migration.
It might be authorized to create migration files, run tests against an isolated db, and inspect the resulting schema.
But that doesn't mean it should be authorized to execute the migration against prod.
Those are different levels of authority. The agent can autonomously perform the work within its assigned boundaries. The factory should prevent it from exceeding those boundaries, regardless of how confident the agent is that the next action would be useful.
That's a practical application of Jidoka.
The system continues operating while conditions are acceptable and interrupts the process when they aren't.
And the interruption needs to be enforceable because simply telling an agent to stop when something looks wrong isn't enough.
The factory needs independent ways to recognize problems
There's another complication with applying Jidoka to software agents.
In a traditional manufacturing environment, many abnormal conditions can be measured directly.
- A component is too large
- A machine exceeds its operating temperature
- A sensor detects that a part is missing.
Software development is rarely straightforward. An implementation can compile successfully while violating the original requirements.
A test suite can pass while missing an important edge case or a security issue can exist in code that behaves exactly as expected under normal conditions.
And an agent can confidently explain why its implementation is correct while overlooking the same problem that caused it to make the mistake in the first place.
That means software factories need several different ways to recognize abnormal conditions.
- We need to examine whether the work satisfies the specification
- We need to verify that execution stayed within authorized boundaries
- We need to check whether the repository is actually ready for release
- We need records that allow us to understand what happened during execution.
This is a a main focus for what I'm building with Kujo. I've been building separate tools that handle different responsibilities within accountable agentic workflows.
Spec establishes the requirements, scope, and acceptance criteria before work begins.
Dispatch coordinates execution across agents and workflow stages, including dependencies, failure handling, and controlled progression.
Workcell provides isolated execution environments with defined filesystem, network, runtime, and resource boundaries.
Eval examines results against defined criteria rather than relying entirely on the implementing agent's assessment.
ShipCheck examines release readiness and identifies conditions that should prevent software from shipping.
Watchdog provides execution observability so we can inspect failures, resource consumption, and workflow behavior.
RunLedger preserves structured records of execution attempts, results, and supporting evidence.
These tools have different responsibilities, but they become especially useful when they're working together.
Imagine a factory receives a feature request.
Spec establishes what success looks like. Dispatch coordinates the implementation and review stages. Workcell constrains where the agents can operate.
Eval checks the implementation against the requirements. ShipCheck determines whether the repository meets its release conditions. Watchdog provides visibility into what happened during execution.
And RunLedger preserves the results so they can be inspected later.
If something goes wrong, the factory has information it can use to determine what happened and which work should be allowed to continue.
That's how I'm building Kujo's software factories.
The agents perform the work, but the surrounding tooling provides controls that don't depend entirely on those agents making the right decisions.
Stopping is only half the problem
There's an important part of Jidoka that I think could easily get overlooked when applying it to AI.
What happens after a problem is spotted and stops the process?
Imagine a software factory with twenty agents working on different parts of an application.
One agent discovers that a shared API contract is incorrect, while several other agents have already started implementing features based on that contract.
Should the entire factory stop? Should only the affected tasks stop? What happens to work that has already been completed?
And how do we prevent the agents from continuing to use the same incorrect information when execution resumes?
These are workflow design problems.
A factory needs to understand dependencies between tasks and determine which results may have been affected by a failure.
If a shared requirement changes, downstream work may need to be invalidated or evaluated again.
If a security check fails, the affected implementation shouldn't proceed toward release.
If an agent exceeds its retry budget, the workflow needs to stop attempting the same operation indefinitely.
And if a human approves a corrective action, that approval should apply to the specific work and conditions being reviewed.
Otherwise, the factory can end up with another problem I've seen discussed more frequently lately.
Agents that endlessly review and correct each other's work.
One agent finds a problem while another agent fixes it.
The first agent finds something else, and the second agent changes it again. Then the process continues until someone manually interrupts it or the system runs out of resources.
That's not a depedable production process.
A factory needs bounded retries, explicit failure states, and clear rules for when work can continue.
It also needs to preserve enough information for the next attempt to understand what failed.
This is where structured execution records become valuable.
If a task fails three times, I want to know what happened during each attempt.
- Which checks failed?
- What changed between attempts?
- Did the same failure repeat?
- Was the original requirement still being followed?
- What evidence supports the decision to retry, stop, or proceed?
Without that information, stopping a workflow doesn't necessarily make it safer. It might just delay the same mistake until the next execution.
Quality needs to be built into the process
One of the reasons I keep coming back to manufacturing concepts is that software development has a tendency to treat quality as something we check after the work has been completed.
We write code, run tests, review the implementation, and decide whether it's acceptable.
That process can work well when devs are actively supervising the work, but autonomous software factories change the economics of software production.
Agents can generate implementations quickly, they can work in parallel, they can continue operating while developers are doing something else, snd they can produce an enormous amount of work before a human ever examines the results.
That makes downstream inspection increasingly expensive.
Imagine a factory producing fifty pull requests overnight.
If every pull request requires a developer to reconstruct the original requirements, inspect the agent's reasoning, determine which tests actually ran, and investigate unexpected changes, the factory may have saved implementation time while creating a massive review burden.
- The factory needs to make quality part of its operating process
- Requirements should be established before implementation
- Execution boundaries should be enforced while work happens
- Verification should occur at meaningful points throughout the workflow
- Failures should prevent affected work from progressing when required.
- Results should be recorded in a way that makes later inspection possible.
None of this guarantees that every defect will be discovered.
A poorly defined specification can still lead to the wrong implementation, an incomplete evaluation can still miss a bug, and a factory can consistently enforce the wrong policy if that policy was incorrectly designed.
Jidoka doesn't eliminate the need for engineering judgment.
It gives us a better way to incorporate that judgment into the process and decide when additional human attention is necessary.
Humans should handle the exceptions
There's another reason I think Jidoka fits the direction we're all heading in.
The goal of autonomous software factories is to reduce the amount of manual coordination required to produce reliable software.
But the amount of human involvement shouldn't necessarily be the same for every task.
Consider two different assignments.
- The first is updating documentation for an existing API
- The second is modifying the authentication system used by thousands of customers
Both tasks can involve autonomous agents, and they can use automated testing and verification. But the consequences of an incorrect implementation are very different.
The doc task might proceed automatically if its checks pass.
The auth change might require additional security eval, independent review, and explicit approval before release.
The factory should be able to apply different levels of control depending on the work being performed.
And ideally, the developer should spend their time examining the decisions that actually require human judgment.
I don't need to personally watch an agent rename a function, or know when an agent attempts to change the scope of an approved task. I don't need to approve every test execution, or want to examine a security failure that prevents a release. And I don't need to read every message exchanged between agents.
I want enough recorded evidence to understand the work, investigate problems, and make informed decisions when something needs my attention.
The factory handles normal operations, the controls identify conditions requiring intervention, and the developer retains authority over decisions that shouldn't be delegated.
A software factory should be able to explain why it stopped
I've talked quite a bit about execution records and accountability in previous articles, and I think they're especially important here.
Imagine a factory stops a workflow because an agent attempted to access an unauthorized directory.
What should the developer see?
Ideally, something more useful than a generic failure message.
I want to know which task was executing, which agent was responsible, what operation was attempted, which boundary was violated, and what happened as a result.
I want to know whether any changes were made before the failure, I want to see which work was blocked and whether any dependent tasks were affected, and I want to know what options are available to resolve the problem.
- Maybe the task needs a revised scope
- Maybe the agent attempted something unnecessary
- Maybe the execution policy was configured incorrectly
Those situations require different responses.
The same applies to verification failures as well.
If an evaluation fails, the factory should identify the failed criteria and preserve the supporting results.
If a release is blocked, it should identify the conditions preventing it from proceeding.
If an execution budget is exhausted, the factory should preserve the attempts and their outcomes.
The system needs to make its decisions inspectable.
That's where the relationship between Jidoka and accountability becomes especially important.
A factory that stops when something goes wrong is helpful.
A factory that can show what happened, why it stopped, and what needs to change before work resumes is much more useful.
And when those records survive beyond the individual agent sessions, they become valuable for future work too.
Another agent can inspect the failure, a human can compare execution attempts, a dev team can identify recurring problems in its workflows, and the factory can use those findings to improve its operating procedures.
What I'm building toward with Kujo
I've been spending a lot of time recently working on Kujo's software factories and the tooling that supports them.
The main idea is to make it possible for agents to coordinate increasingly complex work without requiring a dev to personally supervise every action.
That includes planning, implementation, independent review, testing, controlled execution, approvals, and preserving evidence of what happened.
But I don't think the number of agents a factory can run is a good measure of its quality.
A factory coordinating a thousand agents might look impressive (agents go brrr).
If those agents can make unchecked decisions, repeatedly fail the same tasks, or propagate incorrect assumptions throughout the workflow, the number of agents becomes part of the problem.
I'm much more interested in how much work the factory can complete reliably.
- Can it recognize when requirements aren't satisfied?
- Can it enforce execution boundaries?
- Can it prevent failed work from being treated as successful?
- Can it stop affected tasks without unnecessarily interrupting unrelated work?
- Can it preserve enough evidence for someone to understand what happened?
- Can it resume safely once the underlying problem has been addressed?
Those are the capabilities that make autonomous software factories worth depending on.
The Toyota Production System was developed in a very different environment, but the underlying lesson remains valuable.
When production becomes automated, the ability to recognize abnormal conditions and prevent defects from continuing becomes an essential part of the system.
I think the same principle applies to AI-generated software.
We're going to build factories capable of producing more software, with more agents, in less time than we've ever seen before.
But producing software faster is only benificial if we can trust the process producing it.
And that trust needs to be supported by more than the agents telling us everything went according to plan.
A good software factory knows how to keep working, and a reliable one also knows when to stop.
That's why I think Jidoka deserves a place in the conversation about autonomous software factories.
And it's one of the principles influencing how I'm building Kujo.
Trust at the Speed of AI.
Learn more at kujolang.ai
