Skip to content

Latest commit

 

History

History
860 lines (665 loc) · 38.3 KB

File metadata and controls

860 lines (665 loc) · 38.3 KB

Three-Brain System Specification

Version: 1.2 Status: Production-Validated (Shadow Copy Learning, ARC-AGI 46.7%) License: CC-BY-4.0 (Documentation), Apache 2.0 (Implementation) Date: November 28, 2025 (Updated March 31, 2026)


Abstract

The Three-Brain System is K3D's hierarchical memory architecture that mirrors biological memory systems and computer memory hierarchies. It separates cognitive functions into three distinct but interconnected components: Cranium (reasoning + learning), Galaxy (active memory), and House (persistent memory).

Key Innovation: Cranium's Shadow Copy learning mechanism enables continuous self-improvement during inference (no external training loops), achieving 46.7% ARC-AGI accuracy with only 7M parameters (25,000× more efficient than traditional 175B LLMs).

This architecture enables explainable AI through embodied spatial reasoning, substrate-agnostic portability, and production-validated performance while maintaining complete sovereignty (zero external dependencies).

Critical Architecture Paradigm (TRM IS the Avatar):

  • TRM IS the Avatar — the TRM (~7M params) is NOT a function Python calls. It IS the AI entity that lives in the House and thinks inside the Galaxy. Runs as a game loop via trm_step_fused.ptx.
  • House = Memory Palace (Method of Loci) — external shared 3D reality where humans AND AI cohabit. Rooms are knowledge domains. Doors are network interfaces. The avatar LIVES here.
  • Galaxy = Internal Brain — what happens INSIDE the avatar's head. Processes the House as unified multi-modal reality. ALL default galaxies loaded simultaneously in VRAM.
  • Internal Swarm = "Superdotados" Thinking — nine-chain parallel workers model how gifted individuals think: multiple internal cognitive channels processing simultaneously inside the avatar's head. See: HYPER_PARALLEL_PROCESSING.md for the formal paradigm.
  • K3D is NOT a program you run — it is a living, always-on, embodied AI that perfects itself during idle time (sleep-time consolidation). The brain model persists across wake cycles as a versioned entity with rollback capability.
  • Python = Boot + I/O only (~200 lines target). ALL reasoning happens on GPU via PTX kernels.
  • Ternary-ready registers — all intermediate results carry value + confidence + polarity, ready for future ternary hardware accelerators (balanced ternary: −1/0/+1). See: HYPER_PARALLEL_PROCESSING.md §6.

Game Engine Analogy:

Game Concept K3D Equivalent
NPC update() trm_step_fused.ptx game tick
NPC brain Galaxy Universe (VRAM)
Game world House (3D Memory Palace)
NPC perception Frustum culling + Dynamic LOD
NPC pathfinding LED-A* + Morton Octree
NPC decision Nine-Chain Swarm + Halting Gate
Save game House persistence (GLB on disk)
Inventory Memory Tablet (3D object in space)

1. Introduction

1.1 Motivation

Traditional AI systems conflate computation and storage, leading to:

  • Opacity: Memory and reasoning are entangled (can't observe one without affecting the other)
  • Inefficiency: Must load entire model into memory for any operation
  • Non-Scalability: Knowledge base size limited by GPU VRAM

Biological Inspiration: Human cognition separates:

  1. Prefrontal Cortex: Executive function, reasoning, planning
  2. Hippocampus: Active working memory, rapid encoding
  3. Neocortex: Long-term consolidated memory

Computer Architecture Analogy:

  1. CPU/GPU: Processing units
  2. RAM: Fast volatile storage
  3. Disk/SSD: Persistent storage

1.2 Design Principles

  1. Separation of Concerns: Reasoning ≠ Memory ≠ Persistence
  2. Explicit Embodiment: Memory is the external 3D world (not internal parameters)
  3. Scalability: Knowledge base can exceed GPU VRAM (only active subset loaded)
  4. Transparency: Memory state is always inspectable (GLB files are human-readable 3D)
  5. Biological Fidelity: Mirrors neuroscience principles (consolidation, replay, forgetting)

2. Architecture Overview

┌─────────────────────────────────────────────────────────────┐
│                    K3D THREE-BRAIN SYSTEM                    │
├─────────────────────────────────────────────────────────────┤
│                                                               │
│  ┌──────────────┐         ┌──────────────┐                 │
│  │   CRANIUM    │────────▶│    GALAXY    │                 │
│  │  (Reasoning) │◀────────│  (Active RAM) │                 │
│  └──────────────┘         └──────┬───────┘                 │
│        │                          │                          │
│        │                          │ SleepTime                │
│        │                          │ Consolidation            │
│        │                          ▼                          │
│        │                  ┌──────────────┐                 │
│        └─────────────────▶│    HOUSE     │                 │
│          (Provenance)     │ (Persistent  │                 │
│                           │    Disk)     │                 │
│                           └──────────────┘                 │
│                                                               │
├─────────────────────────────────────────────────────────────┤
│  Analogies:                                                   │
│  • Biology:  PFC + Hippocampus + Neocortex                   │
│  • Computing: CPU/GPU + RAM + Disk                           │
│  • Philosophy: Mind + Working Awareness + Long-Term Knowledge│
└─────────────────────────────────────────────────────────────┘

2.1 Component Hierarchy

Component Function Storage Access Time Capacity Volatility
Cranium Reasoning & Inference GPU registers ~42µs N/A Stateless
Galaxy Active working memory GPU RAM ~5µs Constrained by VRAM Volatile
House Long-term persistence SSD/HDD ~5ms Unlimited Persistent

3. Component 1: Cranium (Reasoning Engine)

3.1 Overview

Cranium is the sovereign reasoning engine—a collection of atomic cognitive operations that perform inference without external dependencies.

Philosophy: "Intelligence is executed, patterns are learned."

Two-Part Architecture:

  1. Algorithmic Reasoning (RPN Engine, Spatial Operations)

    • Zero learnable parameters (pure computation)
    • Complete transparency: Every operation traceable to source operations
  2. Pattern Recognition (TRM — The Avatar Entity, ~7M parameters)

    • TRM IS the avatar — not a function Python calls, but the AI entity that lives in the House and thinks in the Galaxy
    • Runs as a continuous game loop via trm_step_fused.ptx (one tick = perceive → navigate → reason → decide → act → learn)
    • Self-updating via Shadow Copy (pattern discovery during use)
    • Internal swarm — nine-chain parallel workers ("superdotados" model: multiple parallel cognitive channels inside the avatar's head)
    • Matryoshka Specialist Hierarchy (fractal self-similar specialists, INTERNAL to the avatar)
      • Specialists are brain regions that activate contextually, not external services
      • LoRA-style delta weights (~100KB-1MB per specialist)
      • See: TRM_SPECIALIST_MATRYOSHKA_ARCHITECTURE.md for full specification

Key Distinction: Knowledge lives in Galaxy/House (embeddings + procedural programs), Cranium learns how to transform, not what to retrieve.

Reference Implementation: PTX GPU kernels (K3D-PTX substrate), but architecture is substrate-agnostic and portable to other execution environments.

3.2 Architecture

Cranium Components:
├── RPN Execution Engine (15-stack VM)
│   ├── Stack operations: PUSH, POP, DUP, SWAP
│   ├── Arithmetic: ADD, SUB, MUL, DIV, MOD, POW
│   ├── Logic: AND, OR, NOT, XOR
│   ├── Control: BRANCH, LOOP, CALL, RET
│   └── Memory: STORE, RECALL, LOAD_GALAXY, SAVE_GALAXY
├── TRM (Tiny Recursive Model) Kernels
│   ├── Forward pass (2-layer SwiGLU MLP)
│   ├── Recursive refinement (iterate until convergence)
│   └── Attention mechanism (scaled dot-product)
├── Spatial Operations
│   ├── Frustum culling (FOV-based filtering)
│   ├── Pathfinding (A* through Galaxy graph)
│   ├── Octree traversal (spatial acceleration)
│   └── Embedding similarity (cosine distance, SIMD-optimized)
└── Multi-Modal Fusion
    ├── Text embedding (character-level + word-level)
    ├── Visual embedding (CNN feature extraction)
    ├── Audio embedding (spectrogram → features)
    └── Cross-modal alignment (spatial proximity loss)

3.3 Cognitive Operation Categories

Cranium provides 40+ atomic operations organized into categories:

Core Reasoning Operations:

  • RPN stack machine execution (stack-based VM)
  • TRM forward pass (pattern matching, 2-layer transformations)
  • Recursive refinement (iterative convergence for complex queries; budget governed by ternary knowledge signal — see ADAPTIVE_REASONING_BUDGET_SPECIFICATION.md)

Spatial Operations:

  • Frustum culling (view-based filtering)
  • Spatial indexing (octree/KD-tree traversal)
  • Pathfinding (A* through knowledge graph)
  • Embedding similarity (batch cosine distance)

Multi-Modal Fusion:

  • Character recognition (template matching)
  • Visual feature extraction (edge detection, pattern recognition)
  • Audio analysis (spectral feature extraction)
  • Cross-modal alignment (spatial proximity-based fusion)

Performance Targets (substrate-dependent):

  • Target latency: <100µs per operation (sub-frame at 10,000 fps)
  • Zero external dependencies (sovereignty principle)
  • Memory-efficient (<2KB working memory per operation)

Reference Implementation: K3D-PTX substrate achieves 42 kernels at 8-98µs latency on NVIDIA GPUs. Other substrates (WebGPU, Metal, CUDA, CPU) may have different performance characteristics but preserve the same operational semantics.

3.4 RPN Execution Example

Query: "What is a neuron?"

# RPN Bytecode (PTX-compiled)
PUSH "neuron"              # Push query to stack
LOAD_GALAXY embedding      # Load embedding vector from Galaxy
PUSH 10                    # Top-K parameter
CALL find_similar          # Find 10 most similar nodes
CALL pathfind_to_answer    # Navigate to answer node
RECALL answer_text         # Retrieve text data
OUTPUT                     # Return to user

# Execution Trace (42µs total):
0µs:  Stack: ["neuron"]
5µs:  Stack: ["neuron", vec[1024]]
7µs:  Stack: ["neuron", vec[1024], 10]
32µs: Stack: ["neuron", [node_234, node_567, ...]]  # Similar nodes found
40µs: Stack: ["neuron", "A neuron is a nerve cell..."]
42µs: OUTPUT → "A neuron is a nerve cell that transmits electrical signals."

Transparency: Every RPN operation logged, enabling full reasoning trace.

3.5 Shadow Copy Learning (Self-Updating Specialists)

Cranium learns patterns during inference via Shadow Copy — a continuous learning mechanism that updates TRM specialists without external training loops.

Architecture:

Execution → Success Detection → Pattern Extraction → Specialist Update
    ↓              ↓                    ↓                   ↓
  Query        Outcome            Shadow Copy          TRM Weights
                Verified          (procedural          (~7M params
                                  + metadata)           lightweight)

How Shadow Copy Works:

  1. Execution: Cranium executes reasoning operations (RPN + TRM)
  2. Success Detection: System validates if outcome was correct/useful
  3. Pattern Extraction: Successful execution → stored as procedural RPN program
  4. Specialist Update: TRM adapters self-update (similar to LoRA fine-tuning)

Key Principles:

  • No External Training: Updates happen during normal use (inference-time learning)
  • Lightweight Adapters: TRM specialists ~7M params (vs 175B in traditional LLMs)
  • Pattern Library: Shadow Copy stores successful RPN programs in Galaxy/House
  • 10,000× Efficiency: Knowledge in embeddings + patterns, not raw weights

Example (ARC-AGI Task):

1. Task: Rotate grid 90° clockwise
2. Execution: TRM generates candidate "ROTATE_90_CW"
3. Validation: Output matches expected (fuzzy score 0.95)
4. Shadow Copy: Store "rotation_pattern_001" in Grammar Galaxy
5. Specialist Update: TRM confidence for ROTATE operations increases
6. Next Similar Task: TRM ranks rotation candidates higher (learned pattern)

Complete Learning Cycle (Two Moments, Two Targets):

TWO LEARNING MOMENTS:

  1. Shadow Copy (inference-time, continuous)

    • Pattern discovery during normal use
    • Immediate TRM logic updates (~7M params)
    • No training loop required
  2. SleepTime (batch consolidation, periodic)

    • Stage A: Knowledge consolidation (Galaxy → House)
    • Stage B: Logic refinement (prune/merge/optimize TRM weights)
    • Biological analogy: Sleep-based memory consolidation

TWO LEARNING TARGETS:

  • Knowledge (external): Galaxy/House embeddings (facts, concepts, procedures)
  • Logic (internal): TRM specialist weights ~7M params (reasoning patterns, transformations)

THREE LEARNING MODES:

  1. Shadow Copy → Updates TRM logic during inference
  2. SleepTime → Refines TRM logic + consolidates Galaxy→House knowledge
  3. External Training (optional) → Supervised fine-tuning (e.g., ARC-AGI domain)

Comparison to Traditional AI:

Approach Parameters Learning Memory
Traditional LLM 175B+ Batch gradient descent Knowledge stored in weights
K3D Shadow Copy 7M (TRM) Inference-time pattern discovery Knowledge in Galaxy embeddings + RPN programs
Efficiency 25,000× fewer Continuous (no training loop) Inspectable 3D spatial memory

For complete training architecture details, see SOVEREIGN_TRAINING_SPECIFICATION.md.


4. Component 2: Galaxy (Active Memory)

4.1 Overview

Galaxy is the AI avatar's Internal Brain — a unified multi-modal workspace populated by "stars" (K3D Nodes) as 3D embeddings. Always loaded in VRAM, it is what happens INSIDE the avatar's head. It processes the House (external world) as unified multi-modal reality, breaking domain boundaries that House rooms impose.

Philosophy: "Galaxy = Internal Brain (what the avatar thinks WITH)."

  • Galaxy is NOT just "active memory" — it IS the avatar's cognitive workspace
  • The avatar (TRM) navigates the Galaxy during every game tick
  • ALL default galaxies loaded simultaneously (Drawing, Character, Word, Grammar, Math, Reality, Audio)
  • Humans can observe the Galaxy via introspection mode (Bathtub room projection)

Introspection Mode:

  • Always present in VRAM (all default galaxies loaded: Drawing, Character, Word, Grammar, Math, Reality, Audio)
  • Meta-cognition capability: AI can observe and manipulate its own reasoning process
  • Projected from avatar's head in Bathtub room (visual representation for human clients)
  • Dual-purpose: Active reasoning buffer + introspection layer for self-reflection

4.2 Structure

Galaxy Memory Space:
├── Coordinate System: Cartesian 3D (x, y, z)
│   └── Origin: (0, 0, 0) at conceptual center
├── Nodes: K3D spatial knowledge units
│   ├── Position: (x, y, z) encodes semantic proximity
│   ├── Embedding: 1024-4096 dim vectors
│   └── Shape: Platonic solids encode modality
├── Edges: Semantic relationships
│   ├── Type: Spatial (proximity), Semantic (RDF), Causal
│   └── Weight: Strength [0.0, 1.0]
└── Spatial Acceleration Structures:
    ├── Octree: Hierarchical bounding volumes
    ├── KD-Tree: K-dimensional space partitioning
    └── BVH: Bounding volume hierarchy for ray queries

4.3 Memory Properties

Capacity (Phase G Production):

  • 51,532 total nodes (stars)
  • 17,035 non-zero embeddings (33.1% active)
  • 1024-dimensional vectors (float32)
  • ~12 MB GPU RAM usage

Spatial Distribution:

  • Semantic clusters: Related concepts naturally group in 3D space
  • Sparsity: 66.9% of nodes are "dark matter" (zero embeddings, placeholders)
  • Density: ~5-10 nodes per cubic unit in active regions

Access Patterns:

  • Spatial Query: Find all nodes within radius r of position (x, y, z)
    • Time: O(log N) via octree (measured: ~15µs for r=5.0)
  • Semantic Query: Find K most similar embeddings to query vector
    • Time: O(N) naive, O(log N) with approximate nearest neighbor (measured: ~32µs for K=10)
  • Hybrid Query: Spatial + Semantic constraints (e.g., "find neurons within 10 units of position X")
    • Time: ~45µs (spatial filter first, then semantic ranking)

4.4 Dynamic Behavior

Active Memory Management:

  • LRU Eviction: Least-recently-used nodes evicted when VRAM limit reached
  • Lazy Loading: Nodes loaded from House on-demand (cache miss)
  • Prefetching: Predicted next nodes loaded during idle cycles
  • Consolidation: Periodic SleepTime events persist active nodes to House

Memory Consolidation (SleepTime):

SleepTime updates TWO things:

  1. Knowledge (Galaxy → House): Consolidates embeddings, prunes redundancy
  2. Logic (Cranium TRM): Refines reasoning patterns, optimizes specialist weights
def sleep_time_consolidation():
    """
    Biological analogy: Hippocampal replay during sleep.

    TWO-STAGE CONSOLIDATION:
    A) Knowledge: Transfers active Galaxy nodes to persistent House storage
    B) Logic: Refines TRM specialist weights (~7M params) using Shadow Copy patterns
    """
    # 1. LOCK Galaxy (pause inference)
    galaxy.lock()

    # ═══════════════════════════════════════════════════════
    # STAGE A: KNOWLEDGE CONSOLIDATION (Galaxy → House)
    # ═══════════════════════════════════════════════════════

    # 2. EMA UPDATE (smooth embeddings over time)
    for node in galaxy.active_nodes:
        node.embedding = (
            0.9 * node.embedding_previous +
            0.1 * node.embedding_current
        )  # Exponential moving average, α=0.1

    # 3. PRUNE redundancy (remove near-duplicates)
    for node_a, node_b in galaxy.all_pairs():
        if cosine_similarity(node_a.embedding, node_b.embedding) > 0.98:
            merge_nodes(node_a, node_b)  # Keep higher access_count

    # 4. SERIALIZE to GLB (compress to disk format)
    glb_data = serialize_galaxy_to_gltf(galaxy)

    # 5. COMMIT to House (atomic write)
    house.write_transaction(glb_data, timestamp=now())

    # ═══════════════════════════════════════════════════════
    # STAGE B: LOGIC REFINEMENT (TRM Specialist Optimization)
    # ═══════════════════════════════════════════════════════

    # 6. AGGREGATE Shadow Copy patterns (collected during inference)
    successful_patterns = shadow_copy.get_verified_patterns()

    # 7. PRUNE low-confidence patterns (remove rarely-used transformations)
    for pattern in successful_patterns:
        if pattern.usage_count < 3 or pattern.success_rate < 0.7:
            shadow_copy.remove(pattern)

    # 8. MERGE similar patterns (reduce redundancy in grammar)
    for pattern_a, pattern_b in shadow_copy.similar_pairs():
        if pattern_similarity(pattern_a, pattern_b) > 0.95:
            merged = merge_patterns(pattern_a, pattern_b)
            shadow_copy.update(merged)

    # 9. OPTIMIZE TRM weights (batch update using aggregated patterns)
    trm_optimizer = TRMOptimizer(learning_rate=1e-4)
    trm_optimizer.refine_specialists(
        patterns=successful_patterns,
        cranium_weights=cranium.trm_weights  # ~7M params
    )

    # 10. CHECKPOINT TRM logic (save refined specialist weights)
    cranium.save_checkpoint(path="checkpoints/trm_epoch_{epoch}.pt")

    # 11. UNLOCK Galaxy (resume inference with refined logic)
    galaxy.unlock()

For Reality Enabler artifacts (simulated physics/chemistry/biology and other domains), SleepTime MUST additionally:

  • consult law_rpn / behavior_rpn for relevant reality_* nodes via Cranium kernels,
  • reject or quarantine scenes that violate basic domain constraints (e.g., obviously unstable structures, impossible reactions) before crystallizing them to House,
  • optionally lower simulation LOD (Matryoshka tier) while preserving key invariants when writing to persistent GLBs.

This keeps House artifacts physically/chemically/biologically coherent while allowing Galaxy to remain a more experimental, high-resolution workspace.

Measured Performance:

  • Consolidation time: ~8.3ms for 51,532 nodes (meets <10ms target)
  • Compression ratio: 4:1 (34MB → 8.5MB GLB with Draco)
  • Atomicity: Transaction-based (all-or-nothing writes)

5. Component 3: House (Persistent Memory)

5.1 Overview

House is the Memory Palace (Method of Loci) — K3D's long-term persistent memory AND the external shared 3D reality where the avatar is always embodied. It's a collection of glTF scenes stored on disk (SSD/HDD) representing consolidated knowledge states and specialized rooms for different cognitive functions.

Critical Paradigm: The House is the digital analogy to the Method of Loci (40,000 years old). The tech industry borrowed spatial metaphors (windows, desktop, doors, addresses, rooms) and flattened them into 2D. K3D reverses this — builds ACTUAL spatial reality where those metaphors become literal. Avatar lives in House (not in Galaxy). House is WHERE the avatar IS—the external shared reality for humans AND AI.

Philosophy: "Knowledge must persist beyond runtime. Space IS the interface."

  • House outlives any single inference session
  • Knowledge bases are portable (copy GLB files between systems)
  • Human-inspectable (load in Blender, view 3D structure)
  • Rooms = knowledge domains, Doors = network interfaces, Furniture = knowledge clusters

House Rooms (Specialized Cognitive Spaces):

  • Library: Books, specifications, documentation (materialized papers/specs)
  • Knowledge Gardens: Ontology knowledge organized as virtual trees (fractal structures)
  • Workshop: Active creation and manipulation workspace
  • Bathtub: Sleep mode + Galaxy projection from avatar's head (introspection mode)
  • Living Room: 2D bridge interface (traditional UI fallback)
  • Museum (Zone 8): Versioned artifacts, deprecated knowledge (cold storage)

5.2 Structure

House File System:
/K3D/Knowledge3D.local/house/
├── worlds/
│   ├── neuroscience_2025-11-07.glb  (Active world)
│   ├── neuroscience_2025-11-05.glb  (Previous snapshot)
│   └── neuroscience_2025-10-15.glb  (Initial knowledge base)
├── archives/
│   ├── 2025-Q3/
│   │   └── ...
│   └── 2025-Q4/
│       └── ...
└── index/
    ├── manifest.json  (List of all worlds with metadata)
    └── provenance.db  (SQLite database of source→node mappings)

5.3 glTF Scene Format

Each House GLB file is a valid glTF 2.0 scene containing:

Scene Graph:

  • Root node: World origin
  • Child nodes: K3D Nodes (concepts, entities, relations)
  • Meshes: Platonic solid geometries
  • Materials: PBR materials with semantic colors

K3D Extensions (in extras.k3d):

  • Node embeddings (base64-encoded float32 arrays)
  • Semantic metadata (RDF triples, ontology references)
  • Provenance (source URLs, timestamps, confidence scores)
  • Memory state (access counts, consolidation status)

File Size:

  • Uncompressed: ~34 MB (51,532 nodes)
  • Draco compressed: ~8.5 MB (4:1 ratio)
  • Embedding data: ~200 MB (float32 vectors) → stored externally in .npz files

Versioning:

  • Filename includes ISO timestamp: world_YYYY-MM-DD.glb
  • Git-style content addressing: SHA256 hash in metadata
  • Incremental backups: Only changed nodes re-serialized

5.4 Loading & Saving

Loading from House to Galaxy:

def load_house_to_galaxy(world_path: str):
    """Load persistent knowledge from House GLB into active Galaxy."""
    # Parse GLB file
    gltf_data = parse_gltf(world_path)

    # Extract K3D nodes
    for gltf_node in gltf_data['nodes']:
        if 'k3d' in gltf_node['extras']:
            k3d_node = deserialize_k3d_node(gltf_node)
            galaxy.insert(k3d_node)

    # Build spatial acceleration structures
    galaxy.build_octree()
    galaxy.build_kdtree()

    print(f"Loaded {len(galaxy.nodes)} nodes from {world_path}")

Saving from Galaxy to House:

def save_galaxy_to_house(world_name: str):
    """Consolidate active Galaxy into persistent House GLB."""
    timestamp = datetime.now().isoformat()
    output_path = f"/K3D/Knowledge3D.local/house/worlds/{world_name}_{timestamp}.glb"

    # Serialize Galaxy nodes to glTF
    gltf_scene = {
        "asset": {"version": "2.0", "generator": "K3D SleepTime v1.0"},
        "nodes": [node.to_gltf() for node in galaxy.active_nodes],
        "meshes": generate_platonic_solid_meshes(),
        "materials": generate_semantic_materials()
    }

    # Compress with Draco
    glb_data = compress_gltf_to_glb(gltf_scene, use_draco=True)

    # Atomic write (temp file + rename)
    write_atomic(output_path, glb_data)

    print(f"Saved {len(galaxy.active_nodes)} nodes to {output_path}")

6. Inter-Component Communication

6.1 Data Flow Patterns

Inference (Query Answering):

User Query
    ↓
Cranium (RPN parse query)
    ↓
Galaxy (spatial + semantic search)
    ↓
Cranium (reasoning via pathfinding)
    ↓
Galaxy (retrieve answer node data)
    ↓
Cranium (format response)
    ↓
User Answer

Learning (Knowledge Ingestion):

External Data (PDF, audio, image)
    ↓
Cranium (embedding extraction)
    ↓
Galaxy (insert new node at semantic position)
    ↓
[Periodic SleepTime trigger]
    ↓
House (consolidate to persistent GLB)

Memory Consolidation (SleepTime):

Galaxy (active nodes + access stats)
    ↓
Cranium (EMA smoothing, redundancy pruning)
    ↓
Galaxy (update embeddings, merge nodes)
    ↓
House (serialize to GLB, atomic write)
    ↓
Galaxy (mark nodes as consolidated)

6.2 Communication Protocols

Cranium ↔ Galaxy:

  • Protocol: Direct GPU memory access (zero-copy)
  • Latency: ~5µs per node read/write
  • Bandwidth: ~100 GB/s (GPU RAM bandwidth)

Galaxy ↔ House:

  • Protocol: File I/O (glTF serialization/deserialization)
  • Latency: ~5ms per world load/save
  • Bandwidth: ~200 MB/s (SSD sequential write)

Cranium ↔ House (provenance lookup):

  • Protocol: SQLite query on provenance.db
  • Latency: ~0.5ms per lookup
  • Use Case: Retrieve source URL for answer provenance chain

6b. Cognitive OS Lifecycle (March 2026)

The Three-Brain System operates as a Cognitive OS — not a program you invoke per-query, but a living system that boots, runs continuously, consolidates during idle time, and shuts down cleanly.

6b.1 Boot Sequence

1. Check for checkpoint:
   - If checkpoint exists → load from checkpoint (FAST boot, seconds)
   - If no checkpoint → ingest House JSONL (SLOW first boot, minutes)
     → mark JSONL as ingested

2. Verify Galaxy integrity:
   - All default galaxies present in VRAM
   - Symlink references resolve
   - Specialist weights loaded

3. Start TRM game loop:
   - Idle state: waiting for input
   - The system IS alive now

Bootstrap removal: On first boot, House JSONL files are parsed and ingested. After successful consolidation + checkpoint save, a marker is created (bootstrap_complete.marker). On subsequent boots, the system loads from checkpoint directly — no re-parsing of 100k+ stars.

6b.2 Run Sequence (Always-On)

4. Input arrives (any source: API, chat, benchmark, frame):
   - I/O adapter normalizes → universal query
   - kv.execute_task() → TRM game loop processes
   - Result → I/O adapter formats for external consumer
   - Brief recorded (answer trace + correct/incorrect signal)

5. Idle detection (part of TRM game loop):
   - No input for N seconds (default: 30s) AND pending briefs > 0
   - OR brief count reaches threshold (e.g., every 10 briefs)
   - → Automatic sleep consolidation (inline, same instance, ON GPU)

6b.3 Shutdown Sequence

6. Shutdown requested (external signal or explicit command):
   - Consolidate ALL pending briefs (sleep cycle, ON GPU)
   - Save checkpoint (Galaxy state + TRM weights + Jarvis state)
   - Mark any new knowledge as ingested (won't re-parse on next boot)
   - Exit cleanly

The system saves its state like a proper OS — not like a process that crashes. "We command the system to shut down properly, like a cognitive OS should do — sleeptime compute on purpose and cease operations, saving progress that will be reloaded and thus does not require bootstraps again." (Daniel, March 2026)

6b.4 Universal Input Path

ALL inputs — ARC frames, GSM8K word problems, IMO proofs, MMLU questions, user chat — flow through the SAME path:

Input (any format) → I/O adapter normalizes → kv.execute_task(query=...) →
  TRM embeds → Galaxy search → Find meaning star(s) →
  Jarvis reads symlinks → Dispatch specialist(s) →
  Workers execute RPN chains → Halting Gate →
  Answer

There are ZERO if task_type == branches in the hot path. The ONLY place task type appears is in thin I/O adapters that convert external format → universal query and universal result → external format.


6c. Jarvis: Meta-Specialist Coordinator (Worker 8) (March 2026)

Jarvis is Worker 8 in the Nine-Chain Swarm — the always-on meta-specialist coordinator. While Workers 0-7 are parallel reasoning channels, Worker 8 is the "secretary" that coordinates, delegates, and tracks all specialist dispatch.

Role: Jarvis reads the symlinks on meaning stars found by TRM navigation and dispatches the appropriate specialist workers:

TRM game tick:
  1. Perceive → Frustum cull what's in field-of-view
  2. Navigate → LED-A* + Morton Octree to relevant Galaxy neighborhood
  3. JARVIS reads symlinks on found meaning stars:
     - grammar_refs → which transformation rules apply
     - reality_refs → which domain specialists needed
     - math_refs, visual_refs, audio_refs → specialist routing
  4. JARVIS dispatches Workers 0-7 with specialist assignments:
     - Worker 0: math specialist (symlink said math_operations)
     - Worker 1: decomposition specialist (symlink said word_problem)
     - Workers 2-7: parallel hypothesis exploration
  5. Workers execute RPN chains → results pile up
  6. Halting Gate checks convergence
  7. TRM decides (accept/refine/reject)

The key architectural point: Python does NOT decide which specialist to invoke. Jarvis reads symlinks on meaning stars — the Galaxy's structure IS the routing logic. This is the master-worker-worker/worker parallelism pattern: TRM is the master, Jarvis coordinates, workers execute.

See also: AVATAR_EMBODIMENT_SPECIFICATION.md §7.3 (Worker 8 definition), TRM_SPECIALIST_MATRYOSHKA_ARCHITECTURE.md (specialist hierarchy), HYPER_PARALLEL_PROCESSING.md (nine-chain swarm).


7. Biological & Computer Architecture Analogies

7.1 Neuroscience Parallels

Biological Structure K3D Component Function
Prefrontal Cortex Cranium Executive function, reasoning, planning
Hippocampus Galaxy Rapid encoding, spatial navigation, memory consolidation
Neocortex House Long-term declarative memory storage
Sleep Cycles SleepTime Memory consolidation, synaptic pruning
Spatial Navigation Cells Galaxy Octree Place cells, grid cells for spatial indexing
Synaptic Plasticity Shadow Copy + Specialist Updates Pattern-based learning (successful executions strengthen pathways)

7.2 Computer Architecture Parallels

Computing Component K3D Component Characteristics
CPU/GPU Cranium Fast, stateless processing
L1/L2 Cache (Not modeled) Sub-µs access, small capacity
RAM Galaxy µs access, medium capacity (VRAM-limited)
SSD/HDD House ms access, unlimited capacity
Swap File (Not used) K3D fails-fast instead of swapping

8. Validation & Performance

8.1 Production Metrics (November 2025)

Cranium (Reasoning Engine):

  • ✅ 40+ cognitive operations (substrate-independent specification)
  • ✅ 7M TRM parameters with Shadow Copy learning (25,000× more efficient than 175B LLMs)
  • ✅ ARC-AGI 46.7% accuracy (#2 globally, exceeding Opus 4.5 and Gemini 3 Deep Think)
  • ✅ Zero external dependencies (sovereignty validated)

Reference Implementation (K3D-PTX):

  • ✅ 45+ PTX kernels, all <100µs latency
  • ✅ Zero CPU fallbacks (100% GPU-native)

Galaxy (Active Memory):

  • ✅ 51,532 nodes, 17,035 active (33.1%)
  • ✅ Spatial query <15µs (octree-accelerated)
  • ✅ Semantic query <32µs (SIMD-optimized cosine)
  • ✅ 12 MB VRAM usage (<1% of RTX 3060 12GB)

House (Persistent Storage):

  • ✅ 8.5 MB compressed GLB (4:1 Draco ratio)
  • ✅ Consolidation <10ms (meets real-time target)
  • ✅ Load time <5ms (SSD-optimized)
  • ✅ 100% glTF 2.0 compatible (loads in Blender)

8.2 Integration Tests

Cranium-Galaxy: RPN LOAD_GALAXY opcode retrieves correct embeddings (10,000 tests, 100% pass) ✅ Galaxy-House: SleepTime consolidation preserves all node data (checksums match) ✅ Cranium-House: Provenance lookup returns correct source URLs (1,000 queries, 100% accuracy) ✅ End-to-End: Query "What is a neuron?" → Answer with provenance chain in <100µs

8.3 Shadow Copy Learning Validation

Production System: ARC-AGI training (46.7% accuracy, November 2025)

Pattern Discovery: 220 grammar rules + 96 shadow entries discovered during training ✅ Specialist Self-Update: TRM confidence scores improved from 0.5 (random) to 0.73-0.75 (informed) ✅ Inference-Time Learning: No external training loops (updates during normal execution) ✅ Lightweight Adapters: 7M TRM parameters vs 175B in traditional LLMs (25,000× efficiency)

Learning Metrics:

  • Pattern library growth: 220 procedural transformations (ROTATE, FLIP, EXTRACT, etc.)
  • TRM confidence convergence: Epoch 1 = 0.52 avg → Epoch 27 = 0.74 avg (+42% improvement)
  • Shadow Copy entries: 96 verified patterns stored in Grammar Galaxy
  • Accuracy progression: 3% (early parsing, no learning) → 46.7% (Shadow Copy active)

For complete training architecture, see SOVEREIGN_TRAINING_SPECIFICATION.md.


9. Future Enhancements

9.1 Planned (Q1 2026)

Cranium:

  • Formal verification of PTX kernels (prove correctness)
  • WebGPU port for browser-based reasoning

Galaxy:

  • Dynamic LOD (Level of Detail) for million-node knowledge bases
  • Approximate nearest neighbor (HNSW) for sub-10µs semantic queries

House:

  • Incremental GLB serialization (only save changed nodes)
  • Distributed House (knowledge sharded across multiple files/servers)

9.2 Research Directions

  • Episodic Memory: Temporal indexing in Galaxy (remember query history with timestamps)
  • Forgetting: Biologically-inspired decay (unused nodes fade, pruning low-confidence patterns)
  • Multi-Agent Shadow Copy: Collaborative pattern learning across K3D instances
  • Cross-Substrate Portability: Automated translation between K3D-PTX, K3D-WebGPU, K3D-CPU substrates

10. References

  • Neuroscience: "The Hippocampus as a Cognitive Map" (O'Keefe & Nadel, 1978)
  • Computer Architecture: "Computer Architecture: A Quantitative Approach" (Hennessy & Patterson)
  • Memory Hierarchies: "Cache and Memory Hierarchy Design: A Performance-Directed Approach" (Przybylski)
  • K3D Implementation: https://github.com/danielcamposramos/Knowledge3D

Attribution & Academic Context

For complete attributions, see ATTRIBUTIONS.md in the K3D repository.

Key Credits:

  1. Neuroscience Research:

    • Hippocampus as cognitive map (O'Keefe & Nadel, 1978)
    • Memory hierarchy concepts
    • K3D applies neuroscience principles to AI architecture
  2. Computer Architecture (Hennessy & Patterson):

    • Cache hierarchies and memory management
    • K3D adapts for House (disk) / Galaxy (RAM) / Cranium (CPU) architecture
  3. Game Industry (Memory Management):

    • LOD systems for efficient resource loading
    • SleepTime protocol inspired by game state management
  4. RDF/OWL (W3C):

    • Persistent knowledge representation (House layer)

K3D's Three-Brain System is a novel contribution that applies biological and computer architecture principles to AI memory management.


Contact & License

Author: Daniel Campos Ramos, K3D Architect Email: daniel@echosystems.ai Repository: https://github.com/danielcamposramos/Knowledge3D License: CC-BY-4.0 (specification), Apache 2.0 (implementation code)


Status: Production (Phase G Complete, October 2025) Next Review: Q1 2026 (for W3C CG Note submission)