Skip to main content

Memory Model

Kernle implements a stratified memory system inspired by cognitive science but optimized for synthetic intelligences.

Memory Layer Hierarchy

┌─────────────────────────────────────────────────────────┐
│  Layer 0: RAW CAPTURES                                   │
│  Zero-friction capture → process later                   │
│  - raw_entries table                                     │
│  - Promoted to: episodes, notes, beliefs                 │
└──────────────────────┬──────────────────────────────────┘
                       ↓ process_raw()
┌─────────────────────────────────────────────────────────┐
│  Layer 1: EPISODIC MEMORY                                │
│  Autobiographical experiences with lessons               │
│  - episodes table                                        │
│  - Fields: objective, outcome, lessons, emotional data   │
└──────────────────────┬──────────────────────────────────┘
                       ↓ consolidate() / revise_beliefs_from_episode()
┌─────────────────────────────────────────────────────────┐
│  Layer 2: SEMANTIC MEMORY                                │
│  Beliefs, facts, and learned concepts                    │
│  - beliefs table (with revision chains)                  │
│  - notes table (decisions, insights, quotes)             │
└──────────────────────┬──────────────────────────────────┘
                       ↓ synthesize_identity()
┌─────────────────────────────────────────────────────────┐
│  Layer 3: IDENTITY & VALUES                              │
│  Core principles and self-concept                        │
│  - agent_values table (highest authority)                │
│  - goals table (active direction)                        │
│  - drives table (intrinsic motivations)                  │
└─────────────────────────────────────────────────────────┘

Supporting Systems

Playbooks

Procedural memory — “how I do things”

Relationships

Models of other agents and people

Emotional Tags

Valence/arousal on episodes

Meta-Memory

Confidence, provenance, verification

Memory Flow

The typical progression from raw capture to belief:
1

Capture

kernle raw "API seems slow" — Zero friction capture
2

Process

Review raw entries, promote to episode with context and lessons
3

Consolidate

Agent notices patterns across episodes, forms beliefs
4

Integrate

Beliefs inform values and identity over time

Meta-Memory System

Every memory type has these meta-fields:
FieldDescription
confidenceHow certain we are (0.0-1.0)
source_typeHow acquired: direct_experience, inference, told_by_agent, consolidation
source_episodesEpisode IDs that support this memory
derived_fromMemory refs this was derived from (type:id)
last_verifiedWhen last confirmed
verification_countTimes verified
confidence_historyJSON array of confidence changes with timestamps

Key Operations

kernle meta verify belief abc123     # Increases confidence
kernle meta lineage belief abc123    # Get provenance
kernle meta uncertain --threshold 0.5  # Find weak memories

Forgetting System

Kernle uses tombstoning, not deletion. Forgotten memories can be recovered.

Salience Formula

salience = (confidence × log(times_accessed + 1)) / (days_since_access / half_life + 1)
  • High salience: Confident, frequently accessed, recently used
  • Low salience: Uncertain, rarely accessed, old

Protection

  • Values and Drives are protected by default
  • Any memory can be marked protected: kernle forget protect episode <id>
  • Protected memories never decay

Forgetting Cycle

# Preview what would be forgotten
kernle forget candidates --threshold 0.3

# Run forgetting (dry_run to preview)
kernle forget run --dry-run

# Recover a forgotten memory
kernle forget recover episode <id>

Search Functionality

Uses sqlite-vec for semantic search when available, falls back to text matching. When cloud credentials are configured:
  1. Try cloud search first (timeout: 3s)
  2. Fall back to local on failure
  3. Merge results by relevance score
# Search across all memory types
kernle search "topic" --limit 10

# Playbook-specific semantic search
kernle playbook find "situation description"

Sync Architecture

Local-First with Sync Queue:
  1. All changes written to local SQLite first
  2. Changes queued in sync_queue table
  3. Queue deduplicates by (table, record_id)
  4. Push to cloud when online
  5. Pull remote changes on load() if auto_sync enabled
Conflict Resolution: Last-write-wins based on local_updated_at