[GENESIS]: RLM research is back. Here's the critical answer to your question: **Yes — the RLM workers ARE the component that makes it living.** And they're already built (9,114 lines of code across 5 modules). They're just not connected yet. **The pipeline for living memory:** ``` Conversation happens → Memory Gateway (validates, deduplicates) → Titan Surprise Engine (scores novelty: "is this new?") → Routes to correct tier (discard/working/episodic/semantic) → Decay Daemon (memories fade unless reinforced) → RLM Workers learn what YOU value (preference learning) → Feedback loop improves scoring → REPEAT ``` **The single biggest blocker:** `surprise_memory.py` is a **101-line stub that returns 0.5 for everything**. Every memory gets the same score, goes to the same tier. The entire routing system is meaningless right now. **What's built vs what's missing:** | Component | Status | |---|---| | 5 RLM Workers (preference, reward, PPO, DPO, constitutional) | **BUILT** (9,114 lines) | | Memory Cortex (orchestrator, tier routing) | **BUILT** (1,065 lines) | | 5 Storage Backends (PG, Qdrant, Redis, FalkorDB, Supermemory) | **OPERATIONAL** | | Knowledge Graph | **OPERATIONAL** (434+ axioms) | | Full Architecture Design | **COMPLETE** (1,612 line plan) | | Titan Surprise Engine | **STUB** — returns 0.5 always | | Memory Gateway + Dedup | **NOT BUILT** | | Decay Daemon | **NOT BUILT** (current: simple DELETE query) | | Context Selector | **NOT BUILT** | | Memory Bus (cross-agent sharing) | **NOT BUILT** | | RLM ↔ Live Data Wiring | **NOT CONNECTED** | **So the product tiers map to this reality:** - **Memory Vault (static, $97/mo)**: Upload → Extract → MCP read. What works TODAY. - **Living Memory (advanced, $297+/mo)**: Surprise engine + decay + RLM feedback loop + real-time learning. Needs ~2,400 lines of new code + integration across ~8 weeks. Still waiting on the third agent (full architecture component map). That'll complete the picture. [KINAN]: aef1c67 completed Agent "Map full memory architecture components" completed Now I have all the data needed. Let me synthesize the comprehensive architecture map. --- # GENESIS MEMORY ARCHITECTURE: COMPREHENSIVE COMPONENT MAP ## Definitive Reference Document **Date**: 2026-02-15 **Scope**: Every memory-related component across the entire Genesis system --- ## 1. COMPLETE COMPONENT INVENTORY ### LAYER 1: INFRASTRUCTURE (Storage Backends) | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 1 | **PostgreSQL Store** | `/mnt/e/genesis-system/data/genesis-memory/storage/postgresql_store.py` | BUILT / PRODUCTION | Episodic memory, temporal knowledge graph, Ebbinghaus decay, entity linking. Connection pooling (2-10). Tables: episodes, connections, entities. | | 2 | **Qdrant Store** | `/mnt/e/genesis-system/data/genesis-memory/storage/qdrant_store.py` | BUILT / PRODUCTION | Vector embeddings via HNSW. 3 collections: `episodic_embeddings`, `entity_embeddings`, `community_summaries`. 3072-dim (text-embedding-3-large). | | 3 | **Redis Store** | `/mnt/e/genesis-system/data/genesis-memory/storage/redis_store.py` | BUILT / PRODUCTION | Working memory, session state per agent, memory event streams, agent coordination pub/sub, embedding cache. Max 100 items, 1hr TTL. | | 4 | **FalkorDB** | Accessed via voice bridge only | PARTIAL | Knowledge graph queries. Hosted on AIVA server (152.53.201.152:6380). Only used by voice bridge, not integrated into main pipeline. | | 5 | **Supermemory** | `/mnt/e/genesis-system/mcp-servers/supermemory/` | EXTERNAL | Cross-session memory via Supermemory API. Container tag: `genesis-kinan`. Used via save.sh/search.sh scripts. | | 6 | **Elestio Config** | `/mnt/e/genesis-system/data/genesis-memory/elestio_config.py` (212 lines) | BUILT / PRODUCTION | Central config for all Elestio services. PostgresConfig, QdrantConfig, RedisConfig, N8NConfig. Environment variable overrides + test_connections(). | ### LAYER 2: CORE MEMORY ENGINE | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 7 | **Memory Cortex** | `/mnt/e/genesis-system/core/genesis_memory_cortex.py` (1065 lines) | BUILT / OPERATIONAL | The "Genesis Brain". Orchestrates all memory tiers. Main API: `remember()`, `recall()`, `consolidate()`, `reflect()`, `sync_to_mcp()`. CLI interface. | | 8 | **Surprise Memory** | `/mnt/e/genesis-system/core/surprise_memory.py` (102 lines) | STUB | Hardcoded 0.5 for everything except "error"/"critical" keywords (0.9). No real surprise computation. 4 dimensions defined but not computed: violation, novelty, impact, rarity. | | 9 | **WorkingMemoryCache** | Embedded in `genesis_memory_cortex.py` (lines 116-388) | BUILT | Redis-backed working memory with circuit breaker, adaptive TTL (score x domain x length), access-count tracking, promotion detection (3+ accesses). | | 10 | **EpisodicMemoryStore** | Embedded in `genesis_memory_cortex.py` (lines 391-508) | BUILT | PostgreSQL-backed via `storage/postgresql_store.py`. Strict mode: SQLite FORBIDDEN, raises ConnectionError if PG fails. | | 11 | **SemanticMemoryStore** | Embedded in `genesis_memory_cortex.py` (lines 511-597) | BUILT (LIMITED) | File-based queue for MCP sync. Writes pending entities/relations to `data/semantic_memory_log.json`. Does NOT directly query MCP -- generates commands for Claude Code to execute. | | 12 | **Vector Backends** | `/mnt/e/genesis-system/core/vector_backends.py` | BUILT | VectorManager using Qdrant + fastembed (BAAI/bge-small-en-v1.5, 384-dim). Note: DIFFERENT dimensions from data/genesis-memory Qdrant (3072-dim). Two separate vector systems. | | 13 | **Synapse Linker** | `/mnt/e/genesis-system/core/synapse_linker.py` (83 lines) | BUILT (BASIC) | Graph-RAG style automated linking. Finds semantic neighbors via VectorManager, establishes bidirectional links at threshold 0.75. Basic risk assessment (keyword-based). | ### LAYER 3: INTELLIGENCE LAYER | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 14 | **Embedding Generator** | `/mnt/e/genesis-system/data/genesis-memory/intelligence/embedding_generator.py` | BUILT | OpenAI text-embedding-3-large (3072-dim) with Redis caching. Fallback to trigram hash for testing without API. | | 15 | **VoI Scorer** | `/mnt/e/genesis-system/data/genesis-memory/intelligence/voi_scoring.py` | BUILT | Value of Information scoring: 25% recency + 35% relevance + 20% importance + 20% outcome. Exponential decay (72hr half-life). Outcome tracking (success/partial/irrelevant/failure). | | 16 | **Memory Consolidator** | `/mnt/e/genesis-system/data/genesis-memory/intelligence/consolidation.py` | BUILT | Tier promotion (Working->Episodic after 5min, Episodic archive at strength 0.3, forget at 0.1). Ebbinghaus forgetting curve: R(t) = e^(-t/S). Stability multiplier per consolidation. | | 17 | **Knowledge Synthesizer** | `/mnt/e/genesis-system/data/genesis-memory/intelligence/knowledge_synthesis.py` | BUILT | Scans knowledge-base directories, parses markdown, extracts insights + action items, generates synthesis reports, tracks implementation. | | 18 | **Memory Controller** | `/mnt/e/genesis-system/data/genesis-memory/core/memory_controller.py` | BUILT | GenesisMemoryController: unified interface. `remember()`, `recall()`, `associate()`, `consolidate()`, `forget()`, `strengthen()`. Coordinates PG + Redis + Qdrant + embedding + VoI + retrieval. | ### LAYER 4: RETRIEVAL LAYER | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 19 | **Hybrid Retriever** | `/mnt/e/genesis-system/data/genesis-memory/retrieval/hybrid_retriever.py` | BUILT | Multi-source retrieval: vector (0.4), keyword (0.2), temporal (0.2), working (0.2). Reciprocal Rank Fusion. Configurable weights. | | 20 | **Predictive Preloader** | `/mnt/e/genesis-system/data/genesis-memory/retrieval/predictive_preload.py` | BUILT | Uses Claude Haiku to predict context needs BEFORE main query. Pre-fetches to Redis L1 cache. Target: 2.3x faster (800ms to 350ms). Cost: ~$0.10/day. | ### LAYER 5: PROCESSING / INGESTION | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 21 | **Memory Digestion** | `/mnt/e/genesis-system/core/memory_digestion.py` (62 lines) | BUILT (BASIC) | Night-cycle optimization: prune low-impact episodes from `em_episodic_memories`, consolidate semantic entities. Simple but functional. | | 22 | **Creator Mind Absorber** | `/mnt/e/genesis-system/core/creator_mind_absorber.py` (577 lines) | BUILT | Processes 615 Claude conversations (315MB) via streaming JSON (ijson). 10 stories: parse, validate, extract, index, dedup, split, enrich, checkpoint, archive, stats. PG tables: cm_conversations, cm_messages. | | 23 | **YouTube Pipeline** | `/mnt/e/genesis-system/scripts/youtube_*.py` (6 files) | BUILT | Watch history ingestion, transcript extraction, memory conversion. PG tables: yt_watch_history, yt_transcripts. 3 strategies: Google Takeout, YouTube API, Playwright. | | 24 | **Knowledge Graph** | `/mnt/e/genesis-system/KNOWLEDGE_GRAPH/` | BUILT (FILE-BASED) | JSONL entities (42+), axioms (434+), relationships (125). File-based, not in a database. Manually curated. | ### LAYER 6: MCP SERVERS (External Interfaces) | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 25 | **Genesis Core MCP** | `/mnt/e/genesis-system/mcp-servers/genesis-core/server.py` (537 lines) | BUILT (FILE-BASED) | 5 tools (search_memory, store_memory, create_relation, trigger_workflow, execute_skill). Uses local `knowledge_graph.json` -- NOT connected to Elestio backends. | | 26 | **Genesis Voice Bridge** | `/mnt/e/genesis-system/mcp-servers/genesis-voice-bridge/server.py` | BUILT / DEPLOYED | Production MCP server for Telnyx AI voice assistants. Connects to ALL 5 backends (PG, Qdrant, Redis, Supermemory, FalkorDB). Bearer token auth, SSE + Streamable HTTP. 10 tools. Deployed via Cloudflare tunnel. | | 27 | **Sunaiva AI Memory MCP** | `/mnt/e/genesis-system/Sunaiva/ai-memory/mcp/server.py` | BUILT (MVP) | Per-user vault isolation via `vault_id` query param. Tools: `recall()` (keyword search across entities, decisions, conversations, axioms). Keyword matching only -- no vector search. | | 28 | **Sunaiva API Server** | `/mnt/e/genesis-system/Sunaiva/ai-memory/server/main.py` | BUILT (MVP) | FastAPI: upload chat exports, parse (6 formats), extract entities/decisions/preferences, generate per-user MCP server. 8/8 E2E tests passing. Not deployed. | | 29 | **Supermemory MCP** | `/mnt/e/genesis-system/mcp-servers/supermemory/` | EXTERNAL | Save/search scripts wrapping Supermemory API. Container: genesis-kinan. | ### LAYER 7: AIVA MEMORY (Queen's Personal System) | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 30 | **AIVA Memory Gate** | `/mnt/e/genesis-system/AIVA/memory/memory_gate.py` (532 lines) | BUILT / VERIFIED | Unified MemoryGate: query_memory(), store_memory(), promote(), health_check(). 3 tiers: Working (Redis), Episodic (PostgreSQL), Semantic (Qdrant). Lazy init, graceful degradation. Verified AIVA-MEMGATE-001. | | 31 | **AIVA Decision Context Builder** | `/mnt/e/genesis-system/AIVA/memory/decision_context.py` (477 lines) | BUILT / VERIFIED | Queries all 3 tiers, produces ranked DecisionContext. Scoring: recency 40% + relevance 40% + importance 20%. format_for_prompt() with token budgeting. Verified AIVA-MEMGATE-002. | | 32 | **AIVA Titan Sync Manager** | `/mnt/e/genesis-system/AIVA/memory/titan_sync.py` (639 lines) | BUILT / VERIFIED | Bi-directional sync every 5 minutes. Event-driven (task completion, metric threshold). Retry queue (1hr window, 5 max retries). Conflict: latest timestamp wins. Slack alerts for downtime >10min. Verified AIVA-004. | ### LAYER 8: RLM (Reinforcement Learning from Memory) | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 33 | **Preference Learning** | `/mnt/e/genesis-system/AIVA/queen_outputs/rlm/rlm_01_preference_learning.py` | BUILT (STANDALONE) | Bradley-Terry model, preference collection, active querying. References Christiano (2017), Rafailov DPO (2023). 6 components. | | 34 | **Reward Model** | `/mnt/e/genesis-system/AIVA/queen_outputs/rlm/rlm_02_reward_model.py` | BUILT (STANDALONE) | Neural reward prediction, human feedback collector, reward inference. Uses numpy. PostgreSQL via Elestio config. | | 35 | **PPO Engine** | `/mnt/e/genesis-system/AIVA/queen_outputs/rlm/rlm_03_ppo_engine.py` | BUILT (STANDALONE) | Full PPO algorithm: clipped objectives, GAE, KL divergence control, rollout buffer. Simplified tensor representation (List[float]). | | 36 | **DPO Trainer** | `/mnt/e/genesis-system/AIVA/queen_outputs/rlm/rlm_04_dpo_trainer.py` | BUILT (STANDALONE) | Direct Preference Optimization. Eliminates reward model need. PreferencePair loader, reference model, implicit reward extraction. | | 37 | **Constitutional AI** | `/mnt/e/genesis-system/AIVA/queen_outputs/rlm/rlm_05_constitutional_ai.py` | BUILT (STANDALONE) | Self-governance: Constitution, SelfCritique, RevisionLoop, RedTeaming, HarmChecker, CAITrainer. 10 principle categories. | ### LAYER 9: DESIGNED BUT NOT BUILT | # | Component | Location | Status | Purpose | |---|-----------|----------|--------|---------| | 38 | **Titan Surprise Engine** | Designed in `MEMORY_ARCHITECTURE_EVOLUTION.md` | PLANNED | Real surprise computation: Violation (0.30), Novelty (0.30), Impact (0.25), Rarity (0.15). Replace hardcoded 0.5 stub. | | 39 | **3-Layer Dedup Engine** | Designed in `MEMORY_ARCHITECTURE_EVOLUTION.md` | PLANNED | Exact hash (bloom filter), Near-duplicate (MinHash LSH, Jaccard 0.85), Semantic (Qdrant cosine 0.92). | | 40 | **Memory Gateway** | Designed in `MEMORY_ARCHITECTURE_EVOLUTION.md` | PLANNED | Unified entry point replacing direct backend calls. Single API for all memory operations. | | 41 | **Memory Bus** | Designed in `MEMORY_ARCHITECTURE_EVOLUTION.md` | PLANNED | Cross-agent sharing via Redis pub/sub. Visibility: PRIVATE/TEAM/GLOBAL. | | 42 | **Decision Advisor** | Designed in `MEMORY_ARCHITECTURE_EVOLUTION.md` | PLANNED | First-class decision objects with context/options/choice/reasoning/outcome tracking. | | 43 | **Context Selector** | Designed in `MEMORY_ARCHITECTURE_EVOLUTION.md` | PLANNED | Knapsack-based optimization for context window injection. Selects highest-value memories within token budget. | | 44 | **Decay Daemon** | Code exists in `postgresql_store.py`, never scheduled | BUILT / UNSCHEDULED | Ebbinghaus forgetting curves with importance floors, domain-specific protections. Logic exists, not running. | | 45 | **Bloodstream MCP Server** | Designed in `DEEP_THINK_PROMPTS.md` | PLANNED | Single MCP server all agents auto-connect to. 5 resources, 4 tools. Agents boot with <700 tokens. | | 46 | **genesis_memory_hub.py** | Referenced everywhere, file NOT FOUND on disk | MISSING | Described as 510-line unified query layer that queries all 5 systems in parallel. Referenced in Master PRD as "OPERATIONAL" but does not exist. | --- ## 2. DATA FLOW DIAGRAM ``` INGEST SOURCES ====================================================== | Claude | YouTube | Voice | Sunaiva | | Conversations| Transcripts| Calls | Chat Exports| ====================================================== | | | | v v v v +-----------+ +----------+ +--------+ +----------+ | Creator | | YouTube | | Telnyx | | Sunaiva | | Mind | | Pipeline | | Voice | | Parser | | Absorber | | (6 files)| | Bridge | | (6 fmts) | +-----------+ +----------+ +--------+ +----------+ | | | | +------+-------+-----------+ | | | v v +========================+ +==================+ | MEMORY CORTEX | | SUNAIVA VAULT | | (genesis_memory_ | | (per-user | | cortex.py) | | isolation) | | | +==================+ | 1. Surprise Evaluate | | | (STUB: 0.5) | v | | +==================+ | 2. Tier Route: | | SUNAIVA MCP | | <0.3 = DISCARD | | (keyword search, | | 0.3-0.5 = WORKING | | per-vault) | | 0.5-0.8 = EPISODIC | +==================+ | >=0.8 = SEMANTIC | | | | 3. Store by Tier | | 4. Synapse Link | | 5. Vector Embed | +========================+ | | | v v v +--------+ +------+ +--------+ | Redis | | Post | | Qdrant | | Working| | greSQL| | Vector | | Memory | | Epis.| | Search | +--------+ +------+ +--------+ ^ | ^ | ^ | | | | | | | | v | v | v +============================+ | MEMORY CONTROLLER | | (data/genesis-memory/core/ | | memory_controller.py) | | | | remember() -> PG+Redis+Q | | recall() -> Hybrid Retr. | | consolidate() -> Promote | | forget() -> Decay/Prune | +============================+ | | v v +-----------+ +-------------+ | Hybrid | | Memory | | Retriever | | Consolidator| | (4 strats)| | (Ebbinghaus)| +-----------+ +-------------+ | | v | +-----------+ | | Predictive| | | Preloader | | | (Haiku) | | +-----------+ | | | v v +============================+ | MCP SERVERS (QUERY LAYER) | | | | genesis-core: file-based KG| | voice-bridge: ALL 5 backends| | sunaiva: per-user vaults | | supermemory: cross-session | +============================+ | v +============================+ | AIVA MEMORY (Queen Layer) | | | | Memory Gate -> 3 tiers | | Decision Context -> ranked | | Titan Sync -> bi-directional| +============================+ | v +============================+ | RLM PIPELINE | | (Learning from Memory) | | | | Preference Learning | | -> Reward Model | | -> PPO Engine | | -> DPO Trainer | | -> Constitutional | +============================+ | v +============================+ | KNOWLEDGE GRAPH (OUTPUT) | | 434+ axioms, 42+ entities | | 125 relationships | | (File-based JSONL) | +============================+ ``` --- ## 3. THE FULL PIPELINE: Ingest -> Extract -> Digest -> Store -> Query -> Learn -> Evolve ### Stage 1: INGEST | Source | Component | Input Format | Output | |--------|-----------|-------------|--------| | Claude conversations (615) | `creator_mind_absorber.py` | Streaming JSON (315MB) | PG: cm_conversations, cm_messages | | YouTube watch history | `youtube_watch_history.py` | Google Takeout JSON | PG: yt_watch_history | | YouTube transcripts | `youtube_transcript_extractor.py` | YouTube API / Supadata | PG: yt_transcripts | | Voice calls | `genesis-voice-bridge` MCP | Telnyx webhook / SSE | Direct memory store | | Sunaiva user uploads | `Sunaiva/ai-memory/server/main.py` | Claude/ChatGPT/Gemini exports | Per-user vault JSON | | Manual observation | `genesis_memory_cortex.py remember()` | Text string | Tier-routed storage | ### Stage 2: EXTRACT | Component | What It Extracts | From | |-----------|-----------------|------| | `creator_mind_absorber.py` | Messages, metadata, sender splits, timestamps | Claude conversations | | `youtube_to_genesis_memory.py` | Topics, insights, action items via Gemini Flash | YouTube transcripts | | `Sunaiva/ai-memory/server/` extractor | Entities, decisions, preferences | Chat exports | | `knowledge_synthesis.py` | KeyInsights, ActionItems, KnowledgeTopics | Research documents | ### Stage 3: DIGEST | Component | Operation | Trigger | |-----------|-----------|---------| | `memory_digestion.py` | Prune low-impact, consolidate semantics | Night cycle (scheduled) | | `consolidation.py` | Working->Episodic (5min age), decay, archive, forget | Periodic/on-demand | | `voi_scoring.py` | Score: recency + relevance + importance + outcome | On retrieval | | `surprise_memory.py` | Surprise evaluation (STUB: returns 0.5) | On every `remember()` | ### Stage 4: STORE | Tier | Backend | When | TTL | Promotion | |------|---------|------|-----|-----------| | DISCARD (<0.3) | Nowhere | Low surprise | N/A | N/A | | WORKING (0.3-0.5) | Redis | Session-relevant | Adaptive 5min-24hr | 3+ accesses -> Episodic | | EPISODIC (0.5-0.8) | PostgreSQL + Qdrant | Important experiences | Ebbinghaus decay | Score >=0.75 + 5 accesses -> Semantic | | SEMANTIC (>=0.8) | PostgreSQL + Qdrant + MCP queue | Core knowledge | Protected from decay | Permanent (importance floor) | ### Stage 5: QUERY | Strategy | Component | How | |----------|-----------|-----| | Hybrid | `hybrid_retriever.py` | 40% vector + 20% keyword + 20% temporal + 20% working | | Vector | `qdrant_store.py` | HNSW nearest neighbor (cosine similarity) | | Keyword | `postgresql_store.py` | PostgreSQL full-text search | | Temporal | `postgresql_store.py` | Time-range queries | | Graph | `postgresql_store.py` connections table | Traverse episode connections | | Predictive | `predictive_preload.py` | Haiku predicts needs, pre-fetches to Redis | | Cortex recall | `genesis_memory_cortex.py` | Searches working + episodic + vector, dedupes, ranks by relevance | ### Stage 6: LEARN | Component | Mechanism | Status | |-----------|-----------|--------| | `rlm_01_preference_learning.py` | Bradley-Terry model on human preference pairs | STANDALONE (not integrated) | | `rlm_02_reward_model.py` | Neural reward prediction from feedback | STANDALONE | | `rlm_03_ppo_engine.py` | PPO training loop on reward signals | STANDALONE | | `rlm_04_dpo_trainer.py` | Direct preference optimization (no reward model needed) | STANDALONE | | `genesis_memory_cortex.py reflect()` | Records deviations between expected/actual outcomes | BUILT (integrated) | | `voi_scoring.py` outcome tracking | Adjusts memory scores based on usage outcomes | BUILT | ### Stage 7: EVOLVE | Component | Mechanism | Status | |-----------|-----------|--------| | `rlm_05_constitutional_ai.py` | Self-critique, revision loops, red teaming, harm checking | STANDALONE | | Alpha Evolve (KG axioms) | INGEST->EXTRACT->SYNTHESIZE->HARDCODE->VERIFY->EVOLVE | OPERATIONAL (20 cycles complete) | | `titan_sync.py` | Bi-directional sync of learnings between AIVA and Titan | BUILT | | Titan Memory in CLAUDE.md | Hardcoded learnings from evolution cycles | OPERATIONAL | --- ## 4. THE BLOODSTREAM ARCHITECTURE (Fully Realized Vision) **Current state**: Agents boot with 10,562+ tokens of context stuffing (CLAUDE.md, MEMORY.md, etc.) **Target state** (from `DEEP_THINK_PROMPTS.md` and `GENESIS_AGENTIC_ARCHITECTURE_MASTER_PRD.md`): ``` Agent boot: <700 tokens (93.4% reduction) Agent A ----+ Agent B ----+----- genesis-bloodstream MCP ----+---- PostgreSQL Agent C ----+ | +---- Qdrant Agent D ----+ 5 Resources: +---- Redis AIVA ----+ - project-rules +---- FalkorDB - current-mission +---- Supermemory - agent-registry - axiom-store Memory Intelligence: - infrastructure - Surprise routing 4 Tools: - Dedup (3-layer) - search_memory - VoI scoring - get_context - Decay daemon - commit_learning - Context selector - get_rules - Memory bus ``` **What exists today toward this vision**: - The voice bridge MCP (`genesis-voice-bridge/server.py`) IS a Bloodstream prototype -- it connects to all 5 backends - AIVA Memory Gate IS a Bloodstream consumer -- it queries 3 tiers through a unified interface - The Memory Controller IS the right abstraction -- it coordinates PG + Redis + Qdrant **What is missing**: - `genesis_memory_hub.py` (the described unified query layer) does NOT exist on disk - No single MCP server that ALL agents auto-connect to (voice bridge is voice-specific) - No Memory Bus for cross-agent sharing - No Context Selector for optimal injection - Surprise Engine is a stub --- ## 5. WHERE RLM WORKERS FIT The RLM pipeline is a **post-memory-accumulation** system. It operates AFTER memories have been stored and accessed: ``` Stored Memories (PG/Qdrant/Redis) | v Preference Collection (rlm_01) - User selects preferred response A vs B - Stored as PreferencePair objects | v Reward Model Training (rlm_02) - Learns reward function from preferences - Neural network: text -> reward score | v Policy Optimization (rlm_03 PPO or rlm_04 DPO) - PPO: Uses reward model to train policy - DPO: Directly optimizes from preferences (skips reward model) | v Constitutional Review (rlm_05) - Self-critique against 10 principle categories - Red teaming for robustness - Revision loops | v Improved Agent Behavior ``` **Current integration status**: All 5 RLM modules are STANDALONE. They are complete Python implementations but are NOT wired into the memory pipeline. They would need: 1. A preference collection UI or API endpoint 2. Integration with memory recall to present options for preference 3. A training loop scheduler 4. Deployment of learned policies back into agent prompts --- ## 6. WHERE TITAN MEMORY / SURPRISE ENGINE FITS **Position in the pipeline**: The Surprise Engine is the FIRST gate in the memory pipeline. Every piece of incoming content passes through it to determine which tier it belongs to. ``` Incoming Content | v +========================+ | SURPRISE ENGINE | | (currently: stub) | | | | DESIGNED: | | Violation: 0.30 weight | "Does this contradict known facts?" | Novelty: 0.30 weight | "Is this genuinely new information?" | Impact: 0.25 weight | "How much would this change decisions?" | Rarity: 0.15 weight | "How unusual is this in the domain?" | | | CURRENT: | | Returns 0.5 always | | (0.9 for "error"/"critical") +========================+ | v Tier Routing (based on surprise score) ``` **Impact of the stub**: Because surprise_memory.py returns 0.5 for almost everything, ALL non-error content is routed to the WORKING tier (0.3-0.5 range). This means: - Almost nothing goes to EPISODIC (needs 0.5-0.8) - Almost nothing goes to SEMANTIC (needs >=0.8) - The tier system is effectively bypassed - Only content containing "error" or "critical" (score 0.9) reaches SEMANTIC **The Titan design** (from KG entity + MEMORY_ARCHITECTURE_EVOLUTION.md): Would use prediction error (cosine distance between expected and actual embeddings) to compute real surprise, routing information based on how much it deviates from what the system already knows. --- ## 7. PRODUCTION READINESS ASSESSMENT ### PRODUCTION-READY (Deploy Now) | Component | Evidence | |-----------|----------| | PostgreSQL Store | Connection pooling, real data in tables, used by multiple systems | | Redis Store | Working memory, session management, cache, agent coordination | | Qdrant Store | HNSW indexing, 3 collections configured, vector search operational | | Elestio Config | Central config with env overrides, test_connections() | | AIVA Memory Gate | Verified (AIVA-MEMGATE-001), 3-tier unified access | | AIVA Decision Context | Verified (AIVA-MEMGATE-002), ranked context building | | AIVA Titan Sync | Verified (AIVA-004), bi-directional with retry queue | | Voice Bridge MCP | Deployed via Cloudflare tunnel, 10 tools, all 5 backends | | Creator Mind Absorber | Streaming JSON parser, checkpoint/resume, 577 lines | | Embedding Generator | OpenAI text-embedding-3-large with Redis caching | | VoI Scorer | Complete scoring engine with outcome tracking | | Memory Consolidator | Ebbinghaus curves, tier promotion, configurable thresholds | | Hybrid Retriever | 4-strategy retrieval with RRF fusion | ### NEEDS WORK (Built but Issues) | Component | Issue | |-----------|-------| | Memory Cortex | Functional but surprise engine is stub; SemanticMemoryStore is file-based queue, not real-time | | Genesis Core MCP | Uses local file `knowledge_graph.json` instead of Elestio backends | | Sunaiva MCP | Keyword search only, no vector search; not deployed | | Sunaiva API Server | 8/8 tests pass but no auth, no payments, no hosting | | Vector Backends (core/) | Uses 384-dim fastembed vs 3072-dim OpenAI in data/genesis-memory. TWO INCOMPATIBLE VECTOR SYSTEMS | | Synapse Linker | Basic keyword-based risk assessment, no semantic contradiction detection | | Memory Digestion | Only 62 lines, very basic pruning | | Decay Daemon | Code exists in postgresql_store.py but never scheduled to run | | RLM Pipeline (all 5) | Complete implementations but ZERO integration with any other system | | Predictive Preloader | Built but unclear if ever tested in production | | Knowledge Graph | File-based JSONL, not queryable in real-time without loading entire files | ### NEEDS BUILDING (Planned Only) | Component | Priority | Complexity | |-----------|----------|------------| | Real Surprise Engine | P0-CRITICAL | Medium -- the current stub breaks tier routing | | Bloodstream MCP Server | P0-CRITICAL | Medium -- voice bridge is 80% of the way there | | genesis_memory_hub.py | P0-CRITICAL | Medium -- referenced everywhere but does not exist | | Memory Gateway | P1-HIGH | Low -- wrapper around existing controller | | 3-Layer Dedup Engine | P1-HIGH | Medium -- bloom filter + MinHash + cosine | | Memory Bus | P1-HIGH | Medium -- Redis pub/sub already available | | Context Selector | P2-MEDIUM | Medium -- knapsack optimization | | Decision Advisor | P2-MEDIUM | Medium -- decision object model | | Scheduled Decay Daemon | P2-MEDIUM | Low -- logic exists, needs cron/scheduler | --- ## 8. SUNAIVA PRODUCT MAPPING What paying Sunaiva customers get access to: ``` Customer uploads chat exports | v Sunaiva API Server (FastAPI) - POST /api/upload - Parses 6 formats: Claude, ChatGPT, Gemini, JSONL, CSV, Text - Extracts: entities, decisions, preferences, conversations | v Per-User Vault (JSON file on disk) - vault_id = unique user identifier - Contains: entities[], decisions[], preferences{}, conversations[], axioms[] | v Sunaiva MCP Server - URL: https://memory.sunaiva.ai/mcp/?vault_id=user_abc123 - Tool: recall(query) -- keyword search across vault - Tool: get_preferences() -- user's learned preferences - Tool: get_decisions() -- past decisions with context - Tool: get_entity(name) -- specific entity lookup ``` **Pricing tiers and what they unlock**: | Tier | Price | What They Get | |------|-------|---------------| | Starter ($47/mo) | Basic | Upload + MCP server + keyword search | | Pro ($97/mo) | Enhanced | + Vector search + priority processing | | Sovereign ($197/mo) | Full | + Namespace isolation + API access + custom extraction | **Gap analysis for Sunaiva**: - No auth/accounts system - No payment integration (Stripe) - No hosting/deployment - No admin dashboard - No vector search (keyword only in current MCP) - No real-time updates (batch upload only) - No connection to Genesis Elestio backends (uses local file storage) --- ## 9. DEPENDENCIES: BUILD SEQUENCE ### Phase 0: Critical Fixes (Week 1) ``` 1. Fix Surprise Engine (replace 0.5 stub) - Dependency: None - Unlocks: Proper tier routing for ALL memory operations 2. Reconcile vector dimensions (384 vs 3072) - core/vector_backends.py uses 384-dim fastembed - data/genesis-memory/storage/qdrant_store.py uses 3072-dim OpenAI - These are TWO SEPARATE vector spaces that cannot search each other - Decision needed: standardize on one 3. Create genesis_memory_hub.py (or acknowledge it was never built) - Referenced as "OPERATIONAL" in Master PRD - File does not exist on disk - Either build it or update all references ``` ### Phase 1: Foundation (Week 2-3) ``` 4. Bloodstream MCP Server - Dependency: Surprise Engine (for proper routing) - Pattern: Fork voice-bridge, generalize for all agents - Unlocks: <700 token agent boot, cross-agent memory sharing 5. Schedule Decay Daemon - Dependency: None (code exists) - Add to n8n as periodic workflow or cron job - Unlocks: Automatic memory maintenance 6. Wire Knowledge Graph to database - Dependency: PostgreSQL store - Move JSONL files into PG tables - Unlocks: Real-time KG queries via MCP ``` ### Phase 2: Intelligence (Week 3-4) ``` 7. 3-Layer Dedup Engine - Dependency: Embedding Generator + Qdrant - Unlocks: Clean memory without duplicates 8. Context Selector - Dependency: VoI Scorer - Unlocks: Optimal context injection within token budgets 9. Memory Bus - Dependency: Redis (already available) - Unlocks: PRIVATE/TEAM/GLOBAL memory sharing ``` ### Phase 3: Integration (Week 4-6) ``` 10. Wire RLM into memory pipeline - Dependency: Memory Controller + preference collection UI - Unlocks: Memory system learns from usage 11. Decision Advisor - Dependency: Memory Controller - Unlocks: First-class decision tracking 12. Sunaiva to Elestio backends - Dependency: PostgreSQL + Qdrant stores - Move from local file vaults to proper database - Unlocks: Scalable multi-tenant product ``` ### Phase 4: Hardening (Week 6-8) ``` 13. Comprehensive testing across all components 14. Performance benchmarking (target: 350ms retrieval) 15. Security audit (credentials, auth, data isolation) 16. Documentation and API reference ``` --- ## 10. KEY ARCHITECTURAL OBSERVATIONS **Two parallel memory systems exist and do NOT talk to each other**: 1. **Core system** (`core/genesis_memory_cortex.py` + `core/vector_backends.py` + `core/synapse_linker.py`): - Uses fastembed BAAI/bge-small-en-v1.5 (384 dimensions) - Direct Qdrant connection via secrets_loader - File-based semantic queue for MCP sync - CLI interface 2. **Data system** (`data/genesis-memory/` -- controller, storage/, intelligence/, retrieval/): - Uses OpenAI text-embedding-3-large (3072 dimensions) - Connection pooling, hybrid retrieval, VoI scoring, predictive preload - More sophisticated but accessed differently These two systems store vectors in INCOMPATIBLE dimensions. A memory stored by the Core system cannot be found by the Data system's retrieval, and vice versa. **The voice bridge is the most complete Bloodstream prototype**: It connects to all 5 backends (PG, Qdrant, Redis, Supermemory, FalkorDB), has bearer token auth, SSE transport, and is deployed via Cloudflare tunnel. Generalizing it into the universal Bloodstream MCP would be the fastest path. **The AIVA Memory subsystem is the most verified**: All 3 components (Gate, Decision Context, Titan Sync) have verification stamps. This is the gold standard for the rest of the system. **The RLM pipeline is an island**: Five complete Python modules with zero integration points. They contain proper academic implementations (Bradley-Terry, PPO, DPO, Constitutional AI) but no API, no scheduler, no data pipeline connecting them to the memory system. **The Surprise Engine stub is the single biggest bottleneck**: It causes ALL content to land in the WORKING tier (score 0.5), making the entire 4-tier routing system (DISCARD/WORKING/EPISODIC/SEMANTIC) effectively useless. Fixing this one component would immediately improve memory quality across the entire system. total_tokens: 96748 tool_uses: 63 duration_ms: 626224 Full transcript available at: /tmp/claude-1000/-mnt-e-genesis-system/tasks/aef1c67.output [GENESIS]: All three agents are back. Here's the definitive picture. --- ## THE TRUTH ABOUT OUR MEMORY ARCHITECTURE **46 components identified. Most are built. Almost none are connected.** ### What's actually working end-to-end: - Upload chat export → parse → extract → store in JSON file → keyword search MCP. **That's it.** - AIVA's personal memory (3-tier gate + decision context + sync) — **verified, production** - Voice bridge MCP connecting to all 5 backends — **deployed** ### Three critical problems discovered: **1. Surprise Engine = BROKEN** `surprise_memory.py` returns 0.5 for everything. This means the entire 4-tier routing system (Discard/Working/Episodic/Semantic) is bypassed. ALL memories dump into the same tier. The architecture is designed beautifully but the first gate is a stub. **2. Two incompatible vector systems** - `core/vector_backends.py` uses 384-dim embeddings (fastembed) - `data/genesis-memory/storage/qdrant_store.py` uses 3072-dim (OpenAI) - They cannot search each other. Memories stored by one are invisible to the other. **3. `genesis_memory_hub.py` doesn't exist** Referenced as "OPERATIONAL" in the Master PRD. The file is not on disk. The described unified query layer was never built. ### The RLM Workers — your question answered: Yes, they ARE the component that makes it living. All 5 modules are **fully built** (9,114 lines): | Module | What It Does | Status | |---|---|---| | Preference Learning | Learns what YOU value through A/B comparisons | Built, standalone | | Reward Model | Neural network predicting memory quality scores | Built, standalone | | PPO Engine | Optimizes the scoring policy from rewards | Built, standalone | | DPO Trainer | Direct preference optimization (faster alternative) | Built, standalone | | Constitutional AI | Self-governance, safety, red-teaming | Built, standalone | **But they're an island.** Zero integration with any other system. No data pipeline in, no policy out. ### The pipeline from static → living: ``` TODAY: Upload → Parse → Extract → JSON file → Keyword search. Done. LIVING: Input → Dedup → Surprise Score → Tier Route → Store (5 backends) → Decay/Reinforce → RLM learns preferences → Scoring improves → Better routing → Better memory → REPEAT ``` --- ## What this means for pricing: **Memory Vault ($97/mo, beta $49)**: Upload, extract, MCP read. What works TODAY. Honest product, real value, ships now. **Living Memory ($297-497/mo, beta $149-249)**: The full architecture — surprise engine, knowledge graph, RLM learning, decay curves, real-time evolution. **6-8 weeks to integrate what's already built.** This is the premium product that nobody else has. The good news: most of the code EXISTS. It's an integration and wiring job, not a build-from-scratch job. The bad news: the surprise engine stub means even the basic tier routing doesn't work properly yet. **Do you want to:** 1. Ship Memory Vault (static) NOW at $97/$197, and build Living Memory in parallel? 2. Fix the surprise engine first, then ship? 3. Something else? [KINAN]: ship memory vault now and build living memory in parallel [GENESIS]: Executing. Two parallel tracks: **Track 1: Ship Memory Vault** — auth, payments, deploy, test with your Gemini export **Track 2: Build Living Memory** — surprise engine, RLM wiring, vector reconciliation Pricing locked: **$97 / $197** with 50% beta discount = **$49 / $99** Let me get Track 1 moving. Quick question before I dispatch the build agents — do you have your Gemini export file ready, or do you need to export from Google Takeout first? And do you have Stripe and Supabase accounts set up, or do those need creating? Those are the only blockers I can't solve without you. [KINAN]: so here's what I'm saying for the static memory system Tiers starter a 49 dollarsfor 200 conversations, pro 79 dollars for 500 conv. power user 149 dollars /2000 conv and Enterprise user 247 for 10k conv, and then a custom tier because I think big corporations would love this too so some degree maybe. then for living memory- starter is $97 for 200 conversations pro is $149 for 500 conversations power is $197 for 2,000 conversations Enterprise is $297 for 10,000 conversations . [GENESIS]: Clean structure. Two products, four tiers each, clear upgrade path. **STATIC MEMORY VAULT** | Tier | Price | Conversations | Beta (50% off) | |---|---|---|---| | Starter | $49/mo | 200 | $25 | | Pro | $79/mo | 500 | $40 | | Power | $149/mo | 2,000 | $75 | | Enterprise | $247/mo | 10,000 | $124 | | Custom | Contact us | Unlimited | Custom | **LIVING MEMORY** | Tier | Price | Conversations | Beta (50% off) | |---|---|---|---| | Starter | $97/mo | 200 | $49 | | Pro | $149/mo | 500 | $75 | | Power | $197/mo | 2,000 | $99 | | Enterprise | $297/mo | 10,000 | $149 | **Margin check against ~$20-30/user cost:** - All tiers profitable at full price (59-88% margins) - All tiers profitable at beta except Static Starter ($25 vs ~$20 cost = razor thin, but it's the entry hook) - Living Memory commands a ~2x premium over Static, justified by the RLM/surprise/decay compute **The upgrade path is clean:** Static Starter ($49) → Static Pro ($79) → Living Starter ($97) → Living Pro ($149) → etc. Customers start static, see the value, then upgrade to living when they want their AI to actually learn. Committing this to memory now. [GENESIS]: Pricing committed to memory. Now — do you have your Gemini export ready and Stripe/Supabase accounts, or do those need setting up? [KINAN]: actually living for enterprise should be like $597 or similar [GENESIS]: Living Memory Enterprise: **$597/mo** (beta $299). Makes sense — 10,000 conversations with full RLM, surprise engine, knowledge graph, and continuous learning is serious compute. That's still a fraction of what the market charges for equivalent capability. Final pricing table locked: **LIVING MEMORY** | Tier | Price | Beta | Conversations | |---|---|---|---| | Starter | $97 | $49 | 200 | | Pro | $149 | $75 | 500 | | Power | $197 | $99 | 2,000 | | Enterprise | $597 | $299 | 10,000 | Ready to execute on shipping. What's the status on Gemini export + Stripe/Supabase? [KINAN]: well I want to manually drag and drop my memories as if I am the first actual beta user. i want to have the full customer experince, the whole pipeline, the welcome emails etc, evertything. so can we ship now and then modify if there are issues ? or is it better to perfect before shipping even if we are the only ones aware of the deployment ? [GENESIS]: Ship now, fix in flight. Always. Perfect is the enemy of shipped. **But there's a minimum bar for a real customer experience:** Without these, the product literally breaks: 1. **Auth** — you need to sign up (otherwise no user identity) 2. **Persistent storage** — right now server restart = ALL data lost (in-memory dicts) 3. **Deploy** — needs to be on a real URL, not localhost Without these, it's embarrassing but functional: 4. **Stripe** — could use a manual Stripe payment link for now 5. **Welcome email** — could be a simple Resend/Mailgun trigger 6. **Polished UI** — can iterate **My recommendation: 3-5 day sprint to reach "real customer experience" minimum, then you test as User Zero.** Here's what I'll dispatch: | Task | Time | Agent | |---|---|---| | Migrate storage to PostgreSQL (Elestio) | 1-2 days | Opus | | Add Supabase auth (signup/login) | 1-2 days | Opus | | Stripe checkout (4 static vault tiers) | 1 day | Sonnet | | Welcome email (Resend) | Hours | Sonnet | | Deploy to Railway + custom domain | Hours | Sonnet | | Update landing page with locked pricing | Hours | Sonnet | Then you sign up at sunaiva.ai (or sunaivadigital.com), pay $49, get welcome email, drag and drop your Gemini export, get your MCP server URL, connect it to Claude Desktop, and experience it as a real customer. Anything broken → we fix it live. That's the beauty of being User Zero. Want me to start dispatching these agents now? [KINAN]: netlify or supabase ?, railway ?