An engineer asks an AI coding system to add a feature to a TypeScript application. The agent edits several files and reports that it is done. The code compiles, but does the feature satisfy the request? Did it change unrelated behavior? Did it pass the journey a user actually takes?
This article develops an architecture for answering those questions. It treats code generation, validation, evaluation, and approval as distinct stages, then considers how an orchestrator can move a task through them while preserving evidence and limiting risk.
The goal is not autonomous merging. It is a reviewable pull request that says what changed, what was checked, what remains uncertain, and which commit a human is being asked to approve.
Generated code is an output. A trustworthy change also needs a traceable account of how it was checked.
This is a proposed design, not a description of a deployed software factory. Signal’s repository has an adjacent human-triggered article-generation workflow that formats, lints, type-checks, and opens a pull request. The repository does not currently configure a Playwright end-to-end test suite or an agentic code-generation pipeline. The architecture below should therefore be read as a design exploration, not a claim about existing capabilities.
Code generation is not validation
Code generation answers, “What implementation might satisfy this request?” Validation asks narrower questions: does the code compile, do deterministic tests pass, and does the application behave as expected? Evaluation asks whether the result meets the task’s acceptance criteria. A human reviewer then decides whether the particular change is acceptable to merge.
Those questions are related, but a positive answer to one does not answer the others. A build can pass while the feature is missing; a unit test can pass while a browser journey is broken; and an agent can report success when it has only completed part of the task. Even a green workflow is evidence about the checks that ran—not proof that every requirement or edge case is correct.
A software factory should turn a well-defined task into a traceable execution and a proposed change. Each stage needs an explicit responsibility, an output that can be inspected, and a rule for whether work may proceed. The engineer is not removed from the process; repetitive implementation and verification work is automated while the merge decision remains deliberate.
Give the workflow a domain model
Before adding agents, define the entities the system needs to track. “Task,” “run,” and “approval” should mean the same thing to the product interface, orchestrator, persistence layer, and review process. This shared vocabulary is a form of ubiquitous language: domain terms that engineers and users use consistently rather than redefining in each subsystem.
| Concept | Responsibility |
|---|---|
Task | The requested change, repository and branch context, and acceptance criteria. |
Execution | One attempt to take a task through planning, implementation, and validation. |
AgentRun | A bounded invocation within an execution, such as implementation or failure analysis. |
Artifact | A patch, report, test result, log reference, or other output produced by a stage. |
Evaluation | A structured assessment of an artifact against requirements and quality criteria. |
TestRun | The result of a named validation suite against a specific code revision. |
PullRequest | The proposed change, linked to the commit and evidence being reviewed. |
Approval | A human decision about a specific revision of the proposed change. |
One task may have several execution attempts, for example after a failed validation or a cancellation. Each execution can include multiple agent runs, but those runs should not be confused with the execution as a whole. A review agent’s output is an artifact, not an approval; an implementation agent’s completion message is not a successful evaluation.
Rendering conceptual software factory domain model…
This diagram is a conceptual model, not a final schema. An implementation could store test results as artifacts, or model a pull request as a mutable resource associated with several executions. The important invariants are that an execution can be reconstructed, an evaluation points at the exact output it assessed, and approval identifies the revision being approved.
Move through an explicit pipeline
An end-to-end workflow begins with a task contract: what should change, how success can be observed, and what is out of scope. The orchestrator validates that contract, creates an execution, and delegates bounded work. Changes then pass through static checks, relevant automated tests, requirement-level evaluation, and pull request preparation. Only after the evidence is attached does the process stop for human review.
Rendering proposed ai software factory architecture…
The checks are selected for the task, not applied as a ritual. A documentation correction may need formatting and link checks; a UI change may need browser tests; a database migration may need compatibility and rollback review. Missing evidence should stop progression or create an explicit review state. A retry should carry forward the failure reason and remain within a defined budget.
Opening a pull request is not a quality verdict, and passing CI is not merge authorization. The PR is a review surface for the result and its evidence. The final merge remains subject to repository policy and human judgment.
Keep the orchestrator accountable
The orchestrator owns execution state and progression. It interprets the task contract, decides which bounded unit of work is next, records dependencies, applies timeouts and retry limits, invokes validation, and reports the final state. It should not turn an agent’s natural-language claim into a success state without checking the corresponding artifacts.
Agents can own narrower tasks:
- A codebase analysis run identifies relevant modules and constraints.
- An implementation run changes a scoped set of files.
- A review run checks a patch against stated requirements.
- A failure-analysis run explains a test failure and suggests a repair.
- A test-design run proposes missing regression cases.
The output contract should be explicit: files or patch identifiers, findings, unresolved questions, and a status that distinguishes completion from blockage. Two agents should not independently edit the same files at the same time unless the system has a clear merge and conflict-resolution strategy.
Sequential work is easier to reason about because each stage sees a settled prior output. Parallel work can reduce elapsed time when tasks are genuinely independent, such as examining separate modules or designing tests while implementation proceeds. But parallelism adds coordination cost, stale context, conflicting edits, and more complicated recovery. A hybrid approach—parallel analysis followed by one coordinated implementation and a shared validation stage—is often a safer starting point than maximizing agent count.
Rendering orchestrator, agent, validation, and pull request sequence…
This interaction does not require separate deployable services. It can be implemented as modules within a workflow runner until independent scaling, permissions, or operational ownership justify service boundaries. More agents do not automatically improve correctness or throughput; useful parallelism depends on bounded, independent work and clear integration points.
Evaluate independently from generation
The agent that proposes a change should not be the only mechanism deciding whether it is correct. Generation optimizes for producing a candidate; validation and evaluation need independent criteria and, where possible, deterministic evidence.
The evaluation system has three layers. They answer different questions and should not be collapsed into a single score.
Layer 1 — Deterministic validation. Run the checks appropriate to the repository and task: TypeScript compilation, ESLint, unit and integration tests, build checks, API contract validation, and dependency or security checks where relevant. For user-visible behavior, Playwright can exercise journeys such as submitting a form, navigating to a result, or confirming an error state. A screenshot or trace helps explain a failure; it does not extend coverage beyond the scenarios and assertions the test contains. See the Playwright documentation on traces.
Layer 2 — Requirement evaluation. Assess each original acceptance criterion against the patch and its supporting evidence: does the requested behavior exist, are relevant edge cases and loading or error states handled, are existing contracts preserved, were unrelated files changed, and do the tests exercise the requirement? An independent evaluator can compare criteria with changed files and test results, then return a result and evidence for each criterion. A language-model evaluator may help find omissions, but it should not pass a requirement based only on the implementation agent’s explanation.
Layer 3 — Regression evaluation. Maintain representative engineering tasks and known failure cases, then run them when changing models, prompts, agent instructions, tools, orchestration, or evaluation logic. Compare outcomes across versions to detect regressions in task completion and failure handling. This is not a substitute for unit tests: unit tests check specific program behavior under controlled input, while a task suite checks the end-to-end system across representative requests.
Requirement evaluators can produce both false positives (marking an unmet criterion as satisfied) and false negatives (rejecting a change that does satisfy it). Measure those errors against human-reviewed examples, retain the evaluator and prompt versions, and periodically review disagreements. A high-impact decision should not depend on an LLM score alone; ambiguous or conflicting signals should remain visible for human judgment. Human review is a separate approval boundary, not a fourth automated test layer.
The evaluation should return structured results tied to the exact patch or commit. For example:
type Evaluation = {
revision: string
criteria: Array<{
id: string
outcome: 'pass' | 'fail' | 'not_assessed'
evidence: string[]
}>
scopeCheck: 'pass' | 'fail'
unresolvedRisks: string[]
}
This is illustrative pseudocode, not a production contract. A not_assessed result must not be silently treated as a pass. Requirements should be specific enough to evaluate, and the system should preserve the reason when a criterion fails or cannot be assessed.
Define what “proof” means
“Proof” here does not mean formal verification of arbitrary generated code. It means a traceable set of evidence supporting a decision to advance a particular change. Think of it as a case file: the code is the proposal, and the test results, requirement checks, and review notes are the supporting documents.
For each execution, retain references to:
- The original task, acceptance criteria, repository, branch, and base revision.
- The instructions and agent-run identifiers used for implementation or review.
- Changed files, patch or commit references, and a concise change summary.
- Static checks, tests, browser outcomes, and relevant failure details.
- Evaluation results, unmet criteria, and retry history.
- The pull request URL, current head commit, and approval status.
These are different signals, not one success: true field. An agent’s statement that it finished is a report. A CI job records the outcome of specific checks. An evaluation records whether criteria were met according to a defined method. A human approval authorizes a particular revision to proceed under repository policy.
Model execution state, retries, and recovery
Long-running workflows span agents, CI jobs, and external APIs. Explicit states make it possible to pause, resume, cancel, or explain an execution without inferring status from a sequence of loosely coordinated scripts.
Rendering software factory execution states…
An execution should have a stable identifier and idempotent stage transitions. Before retrying PR creation, check for an existing PR associated with the execution or branch. Before accepting test results, verify that they refer to the current revision rather than a prior commit. Retries need limits and timeouts, and cancellation must prevent later stages from quietly restarting the work.
A transient API timeout may be recoverable with a bounded retry. A patch that repeatedly fails the same requirement, a permission boundary violation, or conflicting changes may require stopping for a person. Recovery should preserve prior artifacts and failure reasons; overwriting them with the latest successful status hides how the system reached its result.
Observe the process, not just its final badge
A green or red CI badge compresses many questions into one bit. Useful observability separates operational health, engineering quality, and AI-system behavior.
| Concern | Examples |
|---|---|
| Operational | Queue time, execution and stage duration, failed runs, timeouts, retries, and resource consumption. |
| Engineering quality | Test pass rate, regression rate, criteria coverage, evaluation outcomes, PR revisions, and reviewer changes. |
| AI evaluation | Model and prompt versions, token use, cost, tool-call failures, evaluator disagreement, and quality by version. |
A dashboard in Grafana or a similar tool can show these signals by task type, stage, model, and prompt version, helping distinguish a weak task description from a slow CI job, brittle tests, or an implementation failure. Metrics need context: a larger number of generated pull requests does not by itself show that engineers shipped more correct or useful work.
Operational logs answer whether a run was slow or failing. Decision traceability answers what output, tests, and evaluation supported a particular PR. A task benchmark estimates behavior across a set of cases. These purposes overlap, but one should not be substituted for another. Do not claim that observability proves correctness; it makes failures and evidence easier to inspect.
Make human approval a versioned boundary
Human approval is a system boundary, not simply a temporary inconvenience on the way to autonomous merging. A useful review surface should present the task and criteria, change summary, exact commit, checks performed, evaluation findings, unresolved risks, and relevant artifacts. Reviewers should not need to reconstruct the workflow from unstructured agent chat.
Approval applies to a revision. If a new commit arrives after review, repository policy should determine whether approval is dismissed, remains valid, or requires another check. A PR that changed after its test run should not present stale evidence as if it applied to the new head.
Automation can prepare, implement, validate, and open a PR while leaving merge permission with the repository’s normal controls. Broader autonomy should follow demonstrated evaluation quality and clear risk controls, not a desire to remove a visible approval step.
Choose storage and infrastructure by responsibility
The workflow needs a place to run jobs, a way to track state, a location for larger artifacts, and a review interface. These can be separate tools or responsibilities within one platform. GitHub Actions can run jobs and CI, Playwright can perform browser checks, Neon or another managed PostgreSQL service can hold structured execution metadata, Cloudflare R2 or another object store can retain larger logs and test artifacts, and GitHub pull requests can support review. Grafana or similar monitoring infrastructure can visualize execution and quality signals. These are practical examples, not mandatory components or a claim that this factory is deployed in the repository.
Structured metadata belongs in a store that supports querying by task, execution, revision, stage, and status. Large logs, screenshots, and traces may be better stored separately with access controls and references from the execution record. Keeping everything in a database can increase storage and query costs; keeping everything as unstructured files makes status and history difficult to query. A dashboard should visualize the records, not replace the versioned evidence associated with each execution.
Retention and access matter as much as storage format. Define how long patches, logs, screenshots, and traces remain available, who can retrieve them, and how they are deleted. The repository’s existing article workflow illustrates a narrower pattern: GitHub Actions generates a content change, runs format/lint/type checks, and opens a PR for review. That is not equivalent to a general-purpose code implementation and browser-evaluation factory.
Treat the agent environment as untrusted
An agent that can edit files and run commands crosses a security boundary. Its environment should receive only the repository access and permissions needed for the task, and test execution should not require unrestricted production credentials. Secrets should be isolated from untrusted code paths and unavailable to runs that do not need them.
Repository files, issue descriptions, generated content, and dependency output can contain instructions or executable behavior. Treat them as data to inspect, not as higher-priority system instructions. Limit network access and command capabilities where practical; isolate concurrent workspaces; and prevent test or review jobs from triggering production deployment without an explicit, separately authorized path.
GitHub Actions provides workflow permission controls; configure permissions to the minimum needed for each job rather than granting broad access by default. See GitHub’s guidance on automatic token authentication. Record privileged operations and keep secrets out of prompts, logs, generated reports, and browser artifacts. Security controls should be part of the workflow design, not a final check after the agent has already received broad access.
Handle failure as a first-class outcome
| Failure | Detection and response |
|---|---|
| Agent changes unrelated files | Compare the patch against task scope; stop progression and request a scoped correction or human review. Keep the original diff and review finding. |
| Tests pass but criteria are unmet | Requirement evaluation should fail independently of test status; retain the unmet criterion and request a targeted revision. |
| Playwright detects a regression | Mark browser validation as failed, attach the relevant trace or screenshot when safe, and send the concrete failure to repair or review. |
| Agents produce conflicting edits | The orchestrator detects overlapping changes or a failed merge; serialize integration and preserve both outputs for resolution. |
| Evaluator disagrees with deterministic checks | Do not collapse the disagreement into success; record each signal and route ambiguous high-impact cases to a person. |
| CI job times out | Mark the stage timed out, retain partial logs, and retry only if the operation is safe and within its budget. |
| PR retry may create a duplicate | Query for an existing PR by execution identity or branch before creating another. |
| PR changes after evaluation | Bind evidence to a commit SHA and rerun required checks for the new head. |
| Agent reports completion with missing work | Verify required artifacts and criteria; treat missing outputs as incomplete rather than trusting the status message. |
Some failures are recoverable: a transient service interruption, a fixable type error, or a test that can be rerun after infrastructure recovery. Others need a human: ambiguous requirements, permissions outside scope, repeated failure, or disagreement about expected behavior. Retrying is not a substitute for deciding which class of failure occurred.
Build the system in stages
Stage 1 — Reliable single-agent pipeline. Take one task through one implementation run, deterministic checks, browser validation where relevant, and a pull request that requires human review. This establishes whether the basic execution path is useful.
Stage 2 — Explicit evaluation. Add structured acceptance criteria, requirement-level checks, regression examples, and recorded failure reasons. This makes “done” measurable beyond an agent’s own report.
Stage 3 — Persistent execution and observability. Track stage state, retry history, artifacts, cost, and latency. This supports recovery and makes the system’s bottlenecks visible.
Stage 4 — Controlled orchestration. Add bounded subagents, explicit dependencies, isolated workspaces, concurrency limits, and execution budgets only where the earlier stages reveal a measurable need.
This order keeps complexity proportional to evidence. A team that has not established reliable single-run validation has little basis for deciding whether parallel agents improve its results.
What this means for builders
An AI software factory is a delivery workflow with explicit contracts, not merely an agent swarm. The task defines intended behavior; the orchestrator controls state and scope; validation checks specific properties; evaluation relates the result to requirements; and the pull request presents the evidence for human review.
The architecture should preserve these distinctions:
- A task is not an execution, and an execution is not an agent run.
- Generated code is separate from tests and evaluation of that code.
- A retry is a new controlled attempt, not an erasure of prior failure.
- A passing check is evidence about that check, not a universal correctness claim.
- Approval belongs to a specific revision and remains within repository policy.
Conclusion
The useful measure of an AI coding workflow is not how quickly it can produce a diff or how many pull requests it opens. It is whether the resulting change is traceable, testable, reviewable, and safe to advance through the delivery process.
Start with clear task contracts, explicit states, independent validation, and least-privilege execution. Add orchestration only when bounded parallel work helps, preserve failures and retries, and keep human approval attached to the exact change being reviewed.
The real achievement is not generating a pull request. It is being able to explain what changed, what was verified, what remains uncertain, and why a human should trust the evidence enough to review it.