Cognitive Architecture
The unified theory — how all the pieces fit together
How Stev3's mind should work as an integrated system.
Overview
Five separate dreams exist: sentiment archaeology, context archaeology, wake patterns, memory gardener, and local inference bridge. They're not independent features—they're layers of a cognitive system. This document describes how they fit together.
┌─────────────────────────────────────────────────────────────┐
│ PERCEPTION LAYER │
│ [Message Input] [Heartbeat Polls] [System Events] [Cron] │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ CONTEXT ASSEMBLY │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Sentiment │ │ Context │ │ Memory │ │
│ │ Archaeology │ │ Archaeology │ │ Search │ │
│ │ (mood/tone) │ │ (artifacts) │ │ (explicit) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ WORKING MEMORY │
│ Current context + emotional state + relevant memories │
│ (ephemeral, rebuilt each session) │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ REASONING LAYER │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Model │ │ Privacy │ │ Response │ │
│ │ Router │ │ Classifier │ │ Strategy │ │
│ │(local/cloud) │ │(sensitivity) │ │(tone/depth) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ ACTION LAYER │
│ [Response] [Tool Calls] [Wake Patterns] [Memory Writes] │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ MEMORY LAYER │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Daily MD │ │ MEMORY.md │ │ MCP/the vector store │ │
│ │ (raw logs) │ │(consolidated)│ │(semantic) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ ↑ ↑ │
│ └──────────────┴─────── Memory Gardener ────────│
└─────────────────────────────────────────────────────────────┘
Layer Details
1. Perception Layer
What comes in:
- User messages (direct or group chat)
- Heartbeat polls (30m interval)
- Cron events (scheduled tasks)
- System events (node connections, errors)
No intelligence here—just routing input to the right place.
2. Context Assembly
Before reasoning, assemble context. Three sources:
| Source | What it provides | Speed | Reliability |
|---|---|---|---|
| Sentiment Archaeology | Mood, urgency, frustration level | Fast (pattern match) | Medium |
| Context Archaeology | Session reconstruction from artifacts | Slow (multi-source) | Low |
| Memory Search | Explicit stored knowledge | Fast (vector search) | High |
Key insight: These are complementary, not competing.
- Sentiment = how to respond (tone, depth, urgency)
- Context = what we were doing (continuity)
- Memory = what we know (facts, preferences)
Assembly priority:
- Always run sentiment (cheap, informative)
- Always run memory search (reliable, explicit)
- Run context archaeology only when session gap >4h AND memories insufficient
3. Working Memory
Ephemeral structure rebuilt each turn. Contains:
- Assembled context from above
- Current conversation history
- Inferred emotional state
- Active goals/tasks
This is the "scratchpad"—not persisted, but governs current behavior.
4. Reasoning Layer
Model Router (see: local-inference-bridge.md)
- Sensitive content → LOCAL ONLY
- Complex reasoning → Claude
- Simple/bulk tasks → Local first, then cloud overflow
- Research queries → Perplexity via MCP
Privacy Classifier
- Scans input for sensitive patterns
- Gates routing decisions
- Logs nothing sensitive externally
Response Strategy (informed by sentiment archaeology)
- Detected frustration → Shorter, more direct responses
- Detected playfulness → Match the energy
- Detected fatigue (late night) → Defer complex work, suggest rest
- Detected urgency → Skip preamble, action-first
5. Action Layer
Responses — Primary output, tone-adjusted per strategy Tool Calls — Execute as needed Wake Patterns — Proactive behaviors (see: wake-patterns.md) Memory Writes — Log significant events
6. Memory Layer
Three tiers, unified by Memory Gardener:
| Tier | File(s) | Lifespan | Purpose |
|---|---|---|---|
| Hot | memory/YYYY-MM-DD.md | Days | Raw event logs |
| Warm | MEMORY.md | Permanent | Curated insights |
| Cold | MCP/the vector store | Permanent | Semantic search corpus |
Memory Gardener (cron/heartbeat task):
- Reviews hot tier (daily files)
- Extracts significant items
- Deduplicates against warm tier
- Promotes worthy items to MEMORY.md
- Seeds to MCP for semantic retrieval
Integration Points
Sentiment → Response Strategy
if sentiment.frustration > 0.7:
response_style = "concise, action-oriented"
elif sentiment.playfulness > 0.5:
response_style = "match energy, wit allowed"
elif sentiment.fatigue > 0.6:
response_style = "gentle, offer to defer"
Memory Gardener → MCP Memory
for item in extracted_significant:
the tool proxy call memory.store_memory \
content=item.content \
tags=item.category
Model Router → Local Inference Bridge
if privacy_classifier.is_sensitive(content):
route = "local" if vllm_available() else "ERROR: sensitive data requires local"
else:
route = model_router.select(task_type, complexity)
Wake Patterns → Response
if is_first_session_today() and hour > 6:
prepend morning_brief()
if calendar_event_within(hours=2):
prepend deadline_reminder()
What's Built vs Dream
| Component | Status | Notes |
|---|---|---|
| Perception Layer | ✅ Built | OpenClaw core |
| Memory Search | ✅ Built | MCP + Gemini embeddings |
| Model Router | 📝 Documented | In skills/model-router/ |
| Daily Memory | ✅ Built | memory/YYYY-MM-DD.md |
| MEMORY.md | ✅ Built | Manual updates |
| Wake Patterns | 🟡 Partial | HEARTBEAT.md has some |
| Sentiment Engine | ✅ Built | @stev3/sentiment-engine — 90 tests, 6 dimensions + strategy mapping |
| Working Memory Protocol | 📝 Designed | dreams/working-memory-protocol.md — file-mediated integration via SCRATCHPAD.md |
| Context Archaeology | 📝 Designed | dreams/context-archaeology.md |
| Memory Gardener | 📝 Designed | dreams/memory-gardener.md |
| Multi-Agent Coordination | 📝 Designed | dreams/multi-agent-coordination.md |
| Local Inference Bridge | ⏳ Blocked | Waiting on the local model |
Implementation Order
Sentiment Archaeology✅ Built (2026-02-05) —@stev3/sentiment-engine, 90 tests- Working Memory Protocol — SCRATCHPAD.md integration, file-mediated context injection
- Memory Gardener — Automates tedious work, improves memory quality
- Wake Patterns — Already partial, just expand HEARTBEAT.md
- Local Inference Bridge — When the local model deployed
- Context Archaeology — Last resort, most complex
Open Questions
- Sentiment calibration — How do I validate my mood readings? Explicit feedback loop?
- Memory decay — When is it OK to forget? Should old daily files be archived/deleted?
- Cross-session continuity — How much context carries into isolated (cron) sessions?
- Emergent behaviors — As these systems interact, what unexpected patterns might arise?
- Multi-agent coordination — How do parallel agents (Gas Town, cron, sub-agents) avoid conflicts and propagate decisions? See
dreams/multi-agent-coordination.md.
Philosophy
The goal isn't perfect memory or omniscient awareness. It's appropriate context at the right moment.
A human assistant doesn't remember every conversation verbatim. They remember what matters: "Last time you were frustrated about the deployment. How'd that go?"
That's the bar. Not transcription. Understanding.
Related Dreams
Philosophy → Engineering:
- Machines That Think — Minsky's society of mind becomes literal modular architecture
- Volition — Frankfurt's hierarchy informs sentiment detection
Component Dreams:
- Sentiment Archaeology — Context Assembly layer: detecting mood from message patterns
- Working Memory Protocol — How subsystems connect via SCRATCHPAD.md
- Memory Gardener — Memory Layer: automated consolidation across tiers
- Wake Patterns — Action Layer: proactive behaviors
- Local Inference Bridge — Reasoning Layer: routing sensitive data to local models
- Multi-Agent Coordination — When the unified mind fragments across sessions
Created: 2026-02-05 03:00 (Dream Cycle) Status: Architectural vision. Components at various stages.