Stage-Gate-Loop: Three-Layer Governance for AI-Native Software
AI agents build at machine speed. Governance must operate at three different speeds simultaneously — or it becomes either a bottleneck that kills productivity or a rubber stamp that kills quality. Stage-Gate-Loop separates governance into three layers, each running at the cadence its decisions require.
The insight is that not all decisions are equal. Some require human wisdom and carry legal accountability. Some require expert judgment but can be exercised by AI with appropriate knowledge. Some are purely mechanical and benefit from speed rather than deliberation. Forcing all three through the same process wastes the expensive resource (human attention) on cheap problems, and rushes the expensive problems (compliance, architecture) through cheap processes.
Layer 1: Human — Intent, Accountability, Decisions
The human layer is where authorization originates. Humans decide what to build, why it matters, and accept accountability for the outcomes. This layer operates on a meeting cadence — days to weeks — because the decisions it makes are consequential, often irreversible, and carry regulatory or contractual weight.
What lives here:
- Project goals and priorities
- Architecture direction and technology choices
- Compliance commitments and regulatory interpretations
- Hiring, budget, and organizational decisions
- Release authorization for production deployments
- Escalation resolution when gates or loops surface ambiguity
Operating speed: Days to weeks. These decisions benefit from reflection, discussion, and multi-stakeholder input.
Example: "We will support CMS MIPS measures for the 2025 reporting year, prioritizing the 15 measures with highest patient volume across our client base."
Layer 2: Gate — Architecture, Domain Expertise, Security, Adversarial Judgment
The gate layer exercises judgment that requires expertise but not executive authority. It evaluates whether proposed work aligns with human-layer decisions, whether implementations are architecturally sound, whether domain-specific logic is correct, and whether security properties are maintained. Gates can approve, reject, or escalate to the human layer.
What lives here:
- Adversarial review (B-Team critic, Zero-Context auditor)
- Domain expert personas (clinical quality, security, compliance)
- Architecture review and design approval
- Security scanning and vulnerability assessment
- Intent drift detection — "Is this still what was authorized?"
- Effort estimation and risk assessment
Operating speed: Minutes to hours. Fast enough to not block development flow, slow enough to apply genuine judgment rather than rubber-stamping.
Example: The B-Team reviewer examines a proposed measure engine implementation and identifies that the denominator exclusion logic doesn't handle patients with multiple qualifying encounters correctly. It rejects the implementation with specific remediation guidance, without needing human escalation because the error is clearly within the specification.
Layer 3: Loop — Build, Test, Verify, Deploy, Optimize
The loop layer handles execution that is mechanical, repeatable, and verifiable. AI agents operate autonomously within this layer, generating code, running tests, verifying output against specifications, deploying artifacts, and optimizing performance. The loop runs continuously — seconds to minutes per iteration — with no human intervention unless verification fails and escalation is triggered.
What lives here:
- Code generation and implementation
- Test execution and coverage verification
- Independent verifiers comparing output to source of truth
- Build, package, and deployment automation
- Performance optimization within defined boundaries
- Data pipeline execution and materialized view refresh
- Pattern discovery and promotion
Operating speed: Seconds to minutes. Continuous execution. Hundreds of iterations per hour when needed.
Example: An agent implements 15 quality measure engines overnight, running each through a verification loop: generate SQL, execute against test patients, compare results to hand-calculated expected values, retry on failure, promote successful patterns to templates. By morning, 14 pass verification and 1 is escalated to the gate layer with a specific ambiguity identified.
Cross-Cutting Concerns
Two systems operate across all three layers:
Primum (Intent Integrity) — monitors whether execution still accomplishes what was authorized, regardless of which layer produced the work. Operates as a continuous background check that catches drift between authorization and behavior. Named for primum non nocere — first, do no harm.
Quill (Organizational Memory) — captures decisions, reasoning, and outcomes across all three layers into persistent documentation. Produces the narrative that explains why the system works the way it does, preventing comprehension debt from accumulating faster than humans can read.
Why Three Layers, Not Two
Most governance models are binary: either humans approve everything (safe but slow) or automation handles everything (fast but dangerous). The three-layer model recognizes that between "requires human wisdom" and "purely mechanical" lies a substantial category of work that requires expert judgment but not executive authority.
The gate layer is this middle ground. It's where adversarial reviewers challenge assumptions, domain experts validate clinical logic, and security specialists assess threat models. These judgments require knowledge and reasoning but not organizational authority. They can be exercised by AI with appropriate expertise, escalating to humans only when they encounter genuine ambiguity.
Without the gate layer, organizations face a binary choice: either every security check waits for a human (killing velocity) or security runs as an automated scan that catches syntax but misses logic (killing quality). The gate layer provides judgment at speed — not human speed, but not blind automation either.
The Numbers
In practice, the ratio between layers is dramatic:
- Loop layer: Tens of thousands of automated executions per year (measures × clients × refresh cycles)
- Gate layer: Hundreds of judgment decisions per year (reviews, escalations, assessments)
- Human layer: Dozens of strategic decisions per year (architecture pivots, compliance commitments, release authorizations)
At scale, the system delivers thousands of automated executions per human decision. That's the leverage — not replacing human judgment, but reserving it for decisions that actually require it.