Canonical Doctrine

The 4-Layer Agent
Runtime Architecture

Why agentic systems fail — and the compositional runtime model that prevents it. Identity × Skill × Tool × Environment, compiled into deterministic execution.

Designed for Claude Code • Cursor • Windsurf • Cline • Roo Code • Codex • Antigravity

The Runtime Cognition Formula

Agent Runtime Intelligence =

( Identity Layer × Skill Layer × Tool Layer × Environment Layer )

Runtime Compiler

Constrained Execution

State Mutation

This is the actual architecture. Not prompts. Not workflows. Runtime infrastructure.

Why Agentic Systems Fail

Not because “LLMs hallucinate.” Not because “AI is imperfect.” They fail because runtime boundaries are absent.

Identity boundaries collapse

Agent exceeds authority, ignores rules

Skill recursion becomes unstable

Infinite retry loops, patch chains

Tool permissions leak

Data exfiltration, credential exposure

Environments mutate unpredictably

Repository drift, ghost dependencies

State continuity corrupts

Context rot, instruction amnesia

Runtime compilation is absent

No orchestration, no containment

The 4 Runtime Governance Layers

Layer 1

Identity Layer

Govern Cognition

Defines the agent's mission, principles, heuristics, risk tolerance, escalation logic, and failure boundaries. Without identity governance, the agent has no operational constraints — it will hallucinate freely, fabricate state, and exceed authority.

Governs
  • Mission & principles
  • Risk tolerance
  • Escalation logic
  • Communication style
  • Failure boundaries
Governance Systems
  • + Deterministic Agentic Engineering
  • + Autonomous Execution Safety
  • + Agentic Change Management
Risk Without Governance

Agent operates without constraints. System prompt instructions are ignored under pressure. Authority boundaries are theoretical.

Layer 2

Skill Layer

Govern Procedures

Skills are executable workflows — not prompts. They define procedural cognition: how the agent reasons through specific operational tasks with structured inputs, required context, authorized tools, and output contracts.

Governs
  • Executable workflows
  • Procedural cognition
  • Required context
  • Output contracts
  • Trigger conditions
Governance Systems
  • + Context Rot Prevention
  • + Retry Inflation Control
  • + Orchestration Entropy
  • + Verification Burden Collapse
  • + Hallucination Debt Reduction
Risk Without Governance

Agent enters recursive patch loops. Context degrades silently. Retry chains burn unlimited tokens. Multi-agent systems collapse into agreement loops.

Layer 3

Tool Layer

Govern Actuation

Tools are controlled reality interfaces — not capabilities embedded in skills. They define what the agent can touch: permissions, execution boundaries, schemas, APIs, retries, rate limits, side effects, and transactional safety.

Governs
  • Permissions & boundaries
  • API access control
  • Side effect containment
  • Transactional safety
  • Rate limiting
Governance Systems
  • + Runtime Governance
  • + MCP Governance
  • + Tool Permission Governance
Risk Without Governance

Agent reads .env files containing AWS keys. Executes rm -rf. Installs malicious packages. Capability escalation through tool chaining.

Layer 4

Environment Layer

Govern Semantic Terrain

The environment is the persistent semantic world state — memory, relationships, projects, active state, ontology, and unresolved workflows. The agent inhabits it. Without governance, environments mutate unpredictably.

Governs
  • Repository state
  • Context windows
  • Financial budgets
  • Memory continuity
  • Active project state
Governance Systems
  • + Repository Drift Prevention
  • + Context Window Compression
  • + AI Cost Containment
  • + AI Engineering Economics
Risk Without Governance

Repository diverges from agent's model. Context windows overflow. API costs explode. Ghost dependencies reach production.

Runtime Compilation Flow

1

Trigger Detection

Cheap routing. No LLM. Classify the incoming request.

2

Skill Resolution

Read skill metadata. Determine required context, authorized tools, output schema.

3

Tool Authorization

Load ONLY approved tools. Enforce least-privilege access.

4

Context Assembly

Inject identity + active state + environment slice + episodic memory. NOT the entire environment.

5

Runtime Compilation

Assemble immutable, constrained payload.

6

Constrained Execution

LLM performs bounded reasoning within deterministic guardrails.

7

State Mutation

Update memory, environment, and active state. This creates continuity safely.

Skills Define

HOW to think

Procedural cognition. Executable workflows. Reasoning artifacts.

Tools Define

WHAT can be touched

Controlled reality interfaces. Permissions. Side effects. APIs.

Deploy Runtime Governance Infrastructure

15 deployable runtime infrastructure modules across all 4 governance layers. Each contains deterministic TypeScript middleware, YAML policy manifests, Mermaid architecture diagrams, financial models, and operational playbooks.