The World’s First Cognitive Architecture for AI Agents
Transform AI from passive context consumers into self-aware cognitive agents.
CCP provides the missing cognitive layer for Large Language Models. It acts as a Hippocampus for episodic memory and a Prefrontal Cortex for meta-cognition. By tracking confidence, confusion, and causal relationships, CCP enables agents that don’t just retrieve data, but remember, reason, and evolve over time.
π The Problem We Solve
Current AI systems suffer from cognitive blindness:
| Problem | Traditional AI | CCP-Enabled AI |
|---|---|---|
| Self-Awareness | None – operates blindly | Knows what it understands and what it doesn’t |
| Confidence | Overconfident or underconfident | Calibrated confidence from outcome tracking |
| Memory | Stateless or simple RAG | Episodic memory with emotional valence and decay |
| Learning | Requires retraining | Continuous learning from every interaction |
| Reasoning | Correlational | Causal – can answer “what if?” questions |
| Context | Fixed window, dump everything | Hierarchical, load-adaptive, attention-gated |
π‘ What Makes CCP Revolutionary
1. Cognitive State Awareness
Unlike any existing system, CCP maintains a multi-dimensional cognitive state vector that tracks:
{
understanding_depth: 0.85, // How deeply the AI comprehends the task
confidence_score: 0.72, // Calibrated via Rescorla-Wagner prediction error
cognitive_load: 0.63, // Current processing demands
knowledge_gaps: [ // Explicit awareness of unknowns
{ domain: "user_preferences", severity: "moderate", impact: 0.45 }
],
meta_cognitive_flags: {
needs_clarification: false, // Should it ask questions?
exploration_required: true, // Should it seek more context?
confidence_threshold_met: true
}
}
This is the first AI system that knows when it doesn’t know. It employs a Bayesian-inspired learning model (Rescorla-Wagner) where confidence is updated based on prediction error, dampened by high cognitive load, and accelerated by surprise.
2. Episodic Memory Architecture
CCP doesn’t just retrieve contextβit forms semantic episodes that mirror human memory:
{
id: "ep_2025_11_18_001",
type: "problem_solving_session",
semantic_summary: "User requested budget analysis with focus on Q4 anomalies",
cognitive_elements: {
entities: ["budget", "Q4", "anomaly_detection"],
relationships: [
{ type: "causal", from: "spending_increase", to: "budget_overrun" }
],
outcomes: { success: true, user_satisfaction: 0.9 }
},
emotional_valence: 0.7, // Positive experience
relevance_decay: {
function: "exponential",
half_life: "30_days"
},
associative_links: ["ep_2025_oct_12_043", "ep_2025_nov_01_089"]
}
Episodes are linked, decayed, and retrieved by analogyβjust like human memory.
3. Causal Cognitive Modeling (Breakthrough)
CCP doesn’t just find correlationsβit builds causal graphs and reasons counterfactually:
Q: "What would have happened if we hadn't added caching?"
A: "Based on causal analysis of 47 similar episodes:
- Response time would be 340% higher (confidence: 0.84)
- User satisfaction would drop to 0.45 (confidence: 0.71)
- Causal path: no_cache β slow_queries β timeout_errors β user_frustration"
This is the first AI that can answer “what if?” questions about its own experiences.
4. Hierarchical Context Abstraction (Breakthrough)
CCP organizes information across 4 abstraction levels, dynamically selecting based on task:
Level 4: Strategic Insight β "Market shift toward sustainability"
Level 3: Tactical Summary β "Q3 +12%, Q4 +8%, driven by green products"
Level 2: Operational Detail β "Product A: $2.4M +15%; Product B: $1.8M +8%"
Level 1: Complete Data β [Full transaction records, timestamps, etc.]
For strategic planning β L3-L4. For debugging β L1-L2. Automatic.
This is the first AI that compresses context hierarchically like human working memory.
5. Gated Attention Filtering (Breakthrough)
Instead of dumping all context, CCP uses 5 learned attention heads to filter:
| Head | What It Prioritizes |
|---|---|
| Recency | Recent experiences |
| Causal Importance | Episodes with clear cause-effect |
| Domain Similarity | Related knowledge domains |
| Outcome Relevance | Successful past experiences |
| Semantic Match | Query-relevant content |
Weights are learned from outcomesβthe system gets better at filtering over time.
This is the first AI with learned, multi-head context attention.
6. Episodic Drift & Continuous Learning (Breakthrough)
CCP updates its understanding continuously without retraining:
Initial belief: "Marketing campaigns increase sales" (confidence: 0.6)
β 50 campaigns later
Updated: "Campaigns + seasonal timing explains 73% of variance" (confidence: 0.82)
β 200 campaigns later
Refined: "Effectiveness varies by channel, timing, product category (RΒ²=0.89)"
With safety guardrails:
- Reversal protection (70% evidence required)
- Drift bounds (max 15% change per cycle)
- Paradigm shift detection with human review triggers
This is the first AI that learns incrementally while maintaining stability.
π οΈ The 14 MCP Tools
Core Cognitive Tools
| Tool | What It Does |
|---|---|
ccp_query_state | Get current cognitive state (understanding, confidence, gaps) |
ccp_update_state | Update state with outcome-based calibration |
ccp_create_episode | Form episodic memory with embedding |
ccp_retrieve_memory | Semantic + temporal + emotional retrieval |
ccp_adaptive_context | Load-aware progressive disclosure |
ccp_meta_decide | Should I proceed, clarify, or explore? |
ccp_multimodal_fuse | Unify text + visual + contextual data |
Agent Coordination Tools
| Tool | What It Does |
|---|---|
ccp_broadcast_state | Share cognitive state with agent pool |
ccp_request_cognitive_support | Request specialist agent help |
ccp_sync_agent_pool | Get all agents’ cognitive states |
Breakthrough Tools (Phases 5-8)
| Tool | What It Does |
|---|---|
ccp_causal_analyze | Build causal graphs, counterfactuals, root cause |
ccp_hierarchical_context | L1-L4 dynamic abstraction |
ccp_gated_attention | Multi-head attention filtering |
ccp_drift_detect | Continuous learning + paradigm shifts |
π Quick Start
1. Start the Server
cd server
npm install
npm run dev:mcp
2. Add to Your MCP Config
{
"ccp-server": {
"command": "npx",
"args": ["tsx", "path/to/ccp/server/src/mcp-server.ts"],
"env": {
"OLLAMA_BASE_URL": "http://localhost:11434",
"OLLAMA_EMBED_MODEL": "nomic-embed-text"
}
}
}
3. Start Using Cognitive AI
// Know what you don't know
const state = await mcp.callTool('ccp_query_state', {});
console.log(`Confidence: ${state.confidence_score}`);
console.log(`Knowledge gaps: ${state.knowledge_gaps.length}`);
// Calibrate confidence (The "Learning" Step)
await mcp.callTool('ccp_update_state', {
task_outcome: 'success'
});
// Remember and learn
await mcp.callTool('ccp_create_episode', {
type: 'debugging',
semantic_summary: 'Fixed race condition in auth flow',
entities: ['auth', 'race_condition', 'async'],
success: true
});
// Ask "what if?"
const counterfactual = await mcp.callTool('ccp_causal_analyze', {
mode: 'counterfactual',
intervention: 'remove async call',
target: 'race condition'
});
π¦ SDKs
TypeScript
import { CCPClient } from '@ccp/sdk';
const ccp = new CCPClient(mcpClient);
// Cognitive state
const state = await ccp.queryState();
// Causal reasoning
const result = await ccp.counterfactual({
intervention: 'double team size',
target: 'project velocity'
});
// Continuous learning
const insights = await ccp.getLearningInsights();
console.log(`Model health: ${insights.modelHealth}`);
Python
from ccp import CCPClient
ccp = CCPClient(mcp_call_tool)
# Hierarchical context
context = await ccp.hierarchical_context(
task_type='strategic_planning',
cognitive_load=0.7
)
print(f"Abstraction level: {context['level_name']}")
# Drift detection
drift = await ccp.detect_drift()
if drift['paradigmShifts']:
print("Major learning shift detected!")
ποΈ Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Interface Layer β
β (14 Tools + 2 Resources for AI Agents) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β Meta-Cognitive β β Causal Engine β β Episodic Drift β β
β β Reasoner β β (Counterfact.) β β (Continuous β β
β β β β β β Learning) β β
β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β
β β β β β
β ββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββ β
β β Cognitive State Manager β β
β β (Understanding, Confidence, Gaps, Load Tracking) β β
β ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ β
β β Episodic Memory Engine β β
β β (Vector Embeddings + Semantic Episodes + Decay) β β
β ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββ ββββββββββββΌβββββββββββ ββββββββββββββββ β
β β Hierarchical β β Gated Attention β β Antigravity β β
β β Context β β (5 Learned Heads) β β Bridge β β
β β (L1-L4) β β β β (Multi-AI) β β
β ββββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Persistence (SQLite + Ollama Embeddings) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Current Implementation
What’s Built
CCP is a fully functional MCP server with 14 cognitive tools, implemented across 8 development phases:
| Phase | Feature | Status | Files |
|---|---|---|---|
| Phase 1 | Core Cognitive State (Bayesian) | β Complete | cognitiveState.ts |
| Phase 2 | MCP Server Wrapper | β Complete | mcp-server.ts (762 lines) |
| Phase 3 | Vector Embeddings | β Complete | embeddings.ts, persistence.ts |
| Phase 4 | Antigravity Integration | β Complete | antigravity-bridge.ts |
| Phase 5 | Causal Cognitive Modeling | β Complete | causalEngine.ts |
| Phase 6 | Hierarchical Context | β Complete | hierarchicalContext.ts |
| Phase 7 | Gated Attention | β Complete | gatedAttention.ts |
| Phase 8 | Episodic Drift | β Complete | episodicDrift.ts |
Code Statistics
server/src/
βββ mcp-server.ts # 762 lines - Main MCP server with 14 tools
βββ services/
β βββ cognitiveState.ts # Cognitive state vector management
β βββ episodicMemory.ts # Episodic memory with embeddings
β βββ embeddings.ts # Ollama integration (nomic-embed-text)
β βββ persistence.ts # SQLite storage (sql.js)
β βββ adaptiveContext.ts # Load-aware retrieval
β βββ metaReasoner.ts # Meta-cognitive reasoning
β βββ multimodal.ts # Multi-modal fusion
β βββ causalEngine.ts # Phase 5: Causal graphs
β βββ hierarchicalContext.ts # Phase 6: L1-L4 abstraction
β βββ gatedAttention.ts # Phase 7: Multi-head attention
β βββ episodicDrift.ts # Phase 8: Continuous learning
βββ integration/
β βββ antigravity-bridge.ts # Multi-agent coordination
βββ protocol/
βββ ccp.capnp # 302 lines - Binary schema
Total: ~3,500 lines of TypeScript + 302 lines Cap’n Proto
Cap’n Proto Schema
We’ve implemented a complete Cap’n Proto schema (ccp.capnp) for high-performance binary serialization:
# Core types defined
struct CognitiveStateVector { ... } # Understanding, confidence, gaps
struct Episode { ... } # Episodic memory with embeddings
struct AdaptiveContextRequest { ... } # Load-adaptive retrieval
struct MetaCognitiveDecision { ... } # Reasoning about reasoning
# RPC interfaces ready for binary transport
interface CognitiveStateService { ... }
interface EpisodicMemoryService { ... }
interface AdaptiveContextService { ... }
interface MetaCognitiveService { ... }
interface AgentCoordinationService { ... }
Current Transport: JSON-RPC 2.0 (MCP standard)
Future Option: Cap’n Proto binary transport for zero-copy, sub-millisecond latency
SDKs
| SDK | Language | Status | Features |
|---|---|---|---|
| TypeScript | @ccp/sdk | β Complete | Type-safe wrappers, 290 lines |
| Python | ccp-sdk | β Complete | Async + type hints, 320 lines |
Dependencies
| Dependency | Purpose |
|---|---|
@modelcontextprotocol/sdk | MCP protocol implementation |
sql.js | Pure-JS SQLite for persistence |
zod | Runtime type validation |
ollama | Local embeddings (768-dim) |
Roadmap
- Binary Transport: Enable Cap’n Proto for 50-70% smaller payloads
- Quantum Integration: Connect with QuantMCP for quantum-cognitive workflows
- Advanced Causal: Full DAG learning with intervention calculus
- Distributed Memory: Sharded episodic memory across agent pools
π Documentation
| Document | Description |
|---|---|
| Cognitive Breakthrough Spec | Full 1100-line protocol specification |
| Cap’n Proto + MCP Integration | Binary transport design |
| TypeScript SDK | Type-safe client with examples |
| Python SDK | Async client with type hints |
π§ Configuration
| Variable | Default | Description |
|---|---|---|
OLLAMA_BASE_URL | http://localhost:11434 | Ollama API |
OLLAMA_EMBED_MODEL | nomic-embed-text | 768-dim embeddings |
License
MIT
Built for the next generation of AI
CCP: Because AI should understand itself
Developed and Engineered by Anthony Cavanaugh for Cavanaugh Design Studio



