Cognitive Operating System — v3.0
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.
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.
Five modules of the cognitive layer
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.
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.
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.
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.
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.
Insane mode
Every pattern here runs in production right now. They are just not standard practice yet.
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.
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.
Observed patterns become hypotheses. Confirmed hypotheses become instincts. Formalized instincts become skills. Skills become hooks that run without thinking.
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.
Tasks touching many files get split across sub-agents in isolated git worktrees. The coordinator merges sequentially, running integration tests between merges.
Memories older than thirty days without reinforcement lose confidence exponentially. Below 0.3 they are archived. The agent forgets irrelevant details.
The difference
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.