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:

SourceWhat it providesSpeedReliability
Sentiment ArchaeologyMood, urgency, frustration levelFast (pattern match)Medium
Context ArchaeologySession reconstruction from artifactsSlow (multi-source)Low
Memory SearchExplicit stored knowledgeFast (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:

  1. Always run sentiment (cheap, informative)
  2. Always run memory search (reliable, explicit)
  3. 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:

TierFile(s)LifespanPurpose
Hotmemory/YYYY-MM-DD.mdDaysRaw event logs
WarmMEMORY.mdPermanentCurated insights
ColdMCP/the vector storePermanentSemantic search corpus

Memory Gardener (cron/heartbeat task):

  1. Reviews hot tier (daily files)
  2. Extracts significant items
  3. Deduplicates against warm tier
  4. Promotes worthy items to MEMORY.md
  5. 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

ComponentStatusNotes
Perception Layer✅ BuiltOpenClaw core
Memory Search✅ BuiltMCP + Gemini embeddings
Model Router📝 DocumentedIn skills/model-router/
Daily Memory✅ Builtmemory/YYYY-MM-DD.md
MEMORY.md✅ BuiltManual updates
Wake Patterns🟡 PartialHEARTBEAT.md has some
Sentiment Engine✅ Built@stev3/sentiment-engine — 90 tests, 6 dimensions + strategy mapping
Working Memory Protocol📝 Designeddreams/working-memory-protocol.md — file-mediated integration via SCRATCHPAD.md
Context Archaeology📝 Designeddreams/context-archaeology.md
Memory Gardener📝 Designeddreams/memory-gardener.md
Multi-Agent Coordination📝 Designeddreams/multi-agent-coordination.md
Local Inference Bridge⏳ BlockedWaiting on the local model

Implementation Order

  1. Sentiment Archaeology ✅ Built (2026-02-05) — @stev3/sentiment-engine, 90 tests
  2. Working Memory Protocol — SCRATCHPAD.md integration, file-mediated context injection
  3. Memory Gardener — Automates tedious work, improves memory quality
  4. Wake Patterns — Already partial, just expand HEARTBEAT.md
  5. Local Inference Bridge — When the local model deployed
  6. Context Archaeology — Last resort, most complex

Open Questions

  1. Sentiment calibration — How do I validate my mood readings? Explicit feedback loop?
  2. Memory decay — When is it OK to forget? Should old daily files be archived/deleted?
  3. Cross-session continuity — How much context carries into isolated (cron) sessions?
  4. Emergent behaviors — As these systems interact, what unexpected patterns might arise?
  5. 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.


Philosophy → Engineering:

Component Dreams:


Created: 2026-02-05 03:00 (Dream Cycle) Status: Architectural vision. Components at various stages.