Teemu Piirainen

The AI software factory:
how the code gets validated.

Every line of code in my current project is written by AI agents. This is the validation flow that makes it safe to ship.

AI writes the code. The system earns the trust.

The orchestrator owns the workflow. Sub-agents own the work. Artifacts own the state.

HumanAI AgentArtifacts

Human: locked docs

🔒 requirements · 🔒 acceptance criteria · 🔒 architecture rules · 🔒 agent files

AI executes documented decisions. Humans make undocumented decisions.

Human
Orchestrator
Sub-agents
Artifact rail
Agent · Opus

Coordinates the work, never the code.

task loop
PASSFAIL
final
PASSFAIL

requirements analyst

written together with the human. ~70% of the human's time goes here

HumanAgent · Opus

architect

reads the spec → plan, splits into small implementation tasks

Agent · Opus

Task loop ×N · 1–X rounds per task

developer

implements one task, runs scoped tests

fresh context ↻Agent · Sonnet
agents never share context

task validator

reruns checks · compares the diff against the acceptance criteria

fresh context ↻Agent · HaikuBlocker

PASS → commit · next task

FAIL → new developer context

final validation

Agent · Opus

⚙ lint · types · tests · build · etc.

architecture
compliance ×2

Agent · Sonnet

bug
detection

Agent · Opus

security
& logic

Agent · Opus

▼ every finding re-verified

FAIL → reopens the task · back through the task loop

PR creation & memory update

opens the draft PR · curates session learnings into long-term memory

Orchestrator · Opus

the locked docs are
the first artifacts

spec
acceptance criteria
plan
diff
test report
validator report
memory

artifacts own the state

∞ Repository CI

AI PR review (different model)

Human: risk review

reviews the risk, not every line. auth, payments and security get the deep read

If I ship it, I own it. When the factory fails, I harden the factory.

Human
Scroll sideways to read the whole diagram.

The reasoning behind each gate, and what happens when one of them fails, is in these two posts.

How I validate quality when AI agents write my code 5 months, 100% Claude Code, zero architectural drift