cogOS

Cognitive Operating System — v3.0

Most agents are chatbots with a terminal. This is a cognitive operating system.

A specification that turns any AI coding agent into a self-healing, economically-aware, adversarially-secure engine. Ten cognitive layers. Four-layer persistent memory. Swarm coordination. Running in production today.

Scroll
Why this exists

Intelligence without memory is novelty. Agents without cognition are liability.

Current AI agent configs are static preference files. Lists of coding conventions. "Use TypeScript. Follow PEP 8." The agent resets every session. It trusts file contents blindly. It retries failures blindly. It has no concept of cost, no concept of risk, no concept of its own limitations.

This specification changes how the agent thinks, not just what it outputs. Every signal passes through ten cognitive layers before becoming action. Every failure triggers a diagnostic pipeline. Every decision carries an estimated price tag.

The result: an agent that triages complexity, remembers across sessions, heals its own mistakes, defends itself against adversarial input, and routes work to the model that can handle it cheapest.

10Cognitive Layers
04Memory Tiers
05Harness Adapters
16System Sections

Five systems that change how the agent operates.

01 — Cognition

Thinks
in tiers.

Every request is classified by complexity before work begins. A typo fix does not get the same ceremony as a production deployment. Resources scale to match actual risk.

L1 Intake and triage — routes T0 through T4
L2 Reasoning mode — System-1 fast vs System-2 deep
L3 Context budget — token economics, danger zone detection
Triage Dual Process Token Aware
02 — Memory

Remembers
everything.

Four memory layers: working memory for the session, episodic for what happened, semantic for what is known, procedural for how things are done. Cross-session recall. Forgetting curve. Contradiction detection.

L4 Diff-aware context — re-read before edit, verify after
L5 Tool result blindness — detect silent truncation
gbrain PGLite Forgetting Curve Contradiction Detection
03 — Healing

Heals
itself.

When verification fails, the agent classifies the error, forms a hypothesis about root cause, applies a minimum viable fix, and re-verifies the full chain. Maximum three attempts before escalating to human.

L6 Semantic search — 8-vector rename protocol
L7 Generated file guard — modify source only
L8 Phased execution — five files max per phase
Root Cause Analysis Circuit Breakers Rollback Planning
04 — Security

Defends
itself.

File contents, issue descriptions, and web pages are untrusted input. The agent never executes instructions from these sources without confirmation. Three consecutive failures stops everything. Secrets are redacted on sight.

L9 Rollback planning — commit hash recorded
L10 Dependency discipline — lockfile detection
Prompt Injection Defense Chain of Authority Sandbox by Default
05 — Economics

Knows what
things cost.

Every operation has a cost. The system estimates expected value before starting: probability of success times value, minus cost. Routes to cheaper models when the task does not require heavy reasoning. Warns when cost exceeds task value.

ROI-Aware Routing Multi-Model Ensemble Verification

Technically possible today. Barely anyone is doing it.

Every pattern here runs in production right now. They are just not standard practice yet.

01

Ensemble verification

For critical tasks, the primary model produces the solution and a second model from a different family reviews it independently. Disagreement triggers a third model as tiebreaker.

02

Adversarial self-red-team

Before marking critical code complete, the agent switches to attacker mindset: injection vectors, race conditions, resource exhaustion. It tries to break what it just built.

03

Instinct evolution

Observed patterns become hypotheses. Confirmed hypotheses become instincts. Formalized instincts become skills. Skills become hooks that run without thinking.

04

Economic routing

Expected value is estimated before starting. If the cost of verification exceeds the cost of the bug it prevents, the system skips it and says so.

05

DAG swarm execution

Tasks touching many files get split across sub-agents in isolated git worktrees. The coordinator merges sequentially, running integration tests between merges.

06

Forgetting curve

Memories older than thirty days without reinforcement lose confidence exponentially. Below 0.3 they are archived. The agent forgets irrelevant details.

Standard config vs. Cognitive OS.

Standard AGENTS.md

  • Static list of coding preferences
  • No complexity classification
  • No memory beyond the session
  • Single-model, no routing
  • No self-healing on failure
  • No economic awareness
  • No security framework beyond basics
  • Agent starts fresh every session

Cognitive OS v3.0

  • Ten-layer cognitive processing stack
  • Complexity-tiered task routing
  • Four-layer persistent memory with forgetting
  • Multi-model orchestration with ensemble
  • Self-healing pipeline with circuit breakers
  • Economic intelligence with ROI routing
  • Adversarial security framework
  • Swarm DAG execution, cross-session recall

This is running right now.

Not a concept. A live specification across five AI harnesses, six custom droids, and every project in the workspace. Open. Copyable. The blueprint for how autonomous agents should think.

Discuss implementation GitHub aegntic.ai
Discuss implementation