Domain · Codegen (COC)
Proof it works.
Cognitive Orchestration for Codegen is the first and most mature domain application — the five-layer architecture that ends vibe coding. It is not a theory: every figure below is drawn from the published, peer-shareable COC thesis (CC BY 4.0). This is what the methodology looks like when it is actually running.
§ · Why vibe coding fails
Three fault lines. One root cause.
AI coding assistants fail in production three predictable ways. The root cause is not model capability — the models are remarkably capable. It is the absence of institutional knowledge. No amount of model improvement fixes it, because the missing knowledge is yours.
- F1
Amnesia
As a session grows, your conventions compete for context space and lose. You say “use our ORM for all database work.” It does — for three files. By the fifth it has silently switched to raw SQL. No error. Just drift.
- F2
Convention drift
Your team's hard-won patterns — idempotent migrations, the API shape that avoids a race under load — aren't in the model's training. When your conventions conflict with the internet's, the AI follows the internet.
- F3
Safety blindness
The model takes the shortest path to a working result. The shortest path is almost never the secure one — and it has no knowledge of the incident that taught your team otherwise.
§ · The five layers, instantiated
Each layer closes one fault line — and it's real.
- 1 · Intent
Route each task to the right specialist instead of one generalist. A security reviewer doesn't write frontend; a database specialist doesn't design UIs.
in the reference implementation 29 agent specializations, each with curated domain knowledge and a model tier matched to its cognitive load.
- 2 · Context
Write down what the team knows in progressive disclosure — a master directive every session, quick-reference indexes, deep files pulled only when needed.
in the reference implementation 100+ knowledge files across 25 skill directories; the AI loads the minimum for the task and pulls deeper only when required.
- 3 · Guardrails
Two tiers of enforcement. Tier 1 (rules): directives the AI interprets. Tier 2 (hooks): deterministic scripts that run on every tool call, outside the model's context, blocking violations before they land.
in the reference implementation 8 rule files + 8 hook scripts, including the anti-amnesia hook; a blocked action exits with code 2.
- 4 · Instructions
A structured workflow with approval gates the AI cannot skip, and evidence-based completion — every claim needs file-and-line proof, which kills the confident hallucination.
in the reference implementation A seven-phase workflow with quality gates at four points; 12 slash commands drive it.
- 5 · Learning
Observe what works, capture recurring patterns, and evolve them into artifacts — but only on human approval. No pattern becomes canon without a human deciding it should.
in the reference implementation An observe → capture → evolve pipeline; new teammates inherit the distilled judgment of everyone before them.
§ · The single most important mechanism
The anti-amnesia hook.
One script fires on every single user message — not every file write, not every session start, every message — and re-injects the critical rules fresh into the AI's context.
It survives context-window compression because it runs outside the model's memory. The window can fill, old instructions can be evicted, and the rules still hold — because they do not depend on the model remembering them. Critical rules use defense in depth: five to eight independent enforcement layers, so if any four fail, the fifth catches the violation.
This is the direct answer to amnesia — the most damaging failure mode.
§ · Why this is the right bet
The industry shipped the primitives. COC is the architecture on top.
The major coding tools independently converged on the same building blocks — agents, context files, rules, hooks, commands, memory. That convergence doesn't threaten the methodology; it validates it. Primitives are not a system. COC is what turns the blocks into a discipline: structured workflows with quality gates, an observe-capture-evolve loop with human-gated formalization, defense in depth, and anti-amnesia as an architectural pattern rather than a single feature. The tools are commoditizing. The architecture on top is the durable advantage.
Figures from the published Cognitive Orchestration and COC theses (Hong, 2026), CC BY 4.0. The reference implementation's artifact harness is terrene-foundation/loom; the Kailash SDK is one build target among several, not the methodology. Specification of record at terrene.foundation.