Codifide Direttore: 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. Codifide Direttore separates governance into three layers, each running at the cadence its decisions require.

Codifide Direttore (dee-ret-TOH-reh; formerly Stage-Gate-Loop) is based on Robert G. Cooper's Stage-Gate® model. Stage-Gate® is a registered trademark of Stage-Gate International and R.G. Cooper & Associates, and Codifide is not affiliated with, sponsored by, or endorsed by either. See Trademarks and Acknowledgements.

HUMAN — Intent · Accountability · Decisions
↓
GATE — Architecture · Domain Expertise · Security · Adversarial Judgment
↓
LOOP — Build · Test · Verify · Deploy · Optimize
Primum — Intent Integrity Quill — Organizational Memory

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:

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:

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:

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.


Running Multiple Sessions Concurrently

A single agent session working a single branch is the easy case. The harder — and increasingly common — case is several agent sessions working the same repository at once. Done naively, they clobber each other's files, tangle git history, and overwrite each other's handoff notes. The harness addresses this with a deliberately right-sized approach: not fleet-scale orchestration, just the two mechanisms that carry most of the benefit, plus one conditional check.

Heavier coordination machinery — proactive scope partitioning, merge queues, flaky-test classification — is deliberately deferred until collisions recur despite isolation. The principle is the same one that governs the gates: pay for coordination only when the work demands it. Under single-session work, none of this applies.


The Numbers

In practice, the ratio between layers is dramatic:

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.


Related Articles


Douglas Jones · Codifide