Skip to content

Latest commit

 

History

History
143 lines (107 loc) · 6.03 KB

File metadata and controls

143 lines (107 loc) · 6.03 KB

🧠 Agent Architecture

← Back to README

BabyToposAI — The Autonomous Categorical Agent

BabyToposAI is the central cognitive agent (~5100 LOC). It runs an autonomous Default Mode Network (DMN) loop that continuously generates internal thought, processes stimuli, manages goals, and maintains a coherent self-model.

Core Dependencies

class BabyToposAI(
    private val substrate: HolographicTape,   // §1 memory manifold
    private val llmEngine: LocalGemmaEngine    // §0 inference substrate
)

§-Layer Architecture

§0 — Substrate Layer

  • Energy Budget (κ): Every operation costs micro-joules. maxBudget=512, regenRate=1.0/tick
  • σ Invariants: 6 proof obligations tracked per morphism. Active repair on violation (clamp + distress)
  • Token Telemetry: Real prompt_tokens/completion_tokens from API usage field
  • Emergency Floor: κ dead-policy emergency floor during circadian night (PATCH_3)

§1 — Codec / Holographic Layer

  • Affect Model: 2D space Valence[-1,1] × Arousal[0,1]
    • Novelty → curiosity (V+, A+)
    • Familiarity → comfort (V+, A−)
    • Error → frustration (V−)
    • Decay: V×0.95, A×0.92 → 0.1 resting
  • Curiosity Balance: EMA scalar approximation of exploration/exploitation trade-off
    • Replaces misleading "AdjunctionState" naming (PATCH_5)
    • Balance ∈ [-1, 1]: positive = explore, negative = exploit
  • Self-Model: SelfModel(drift, coherence, fatigue, curiosity) — the agent knows when it is tired, confused, or fascinated

§2 — Functor Layer

  • Dream Chaining: When dreamCoherence > 0.6, the last dream response becomes dream_seed for the next
  • Functorial Daydream: Simultaneous episodic + categorical memory retrieval: F = fuse ∘ (F_ep × F_mn)

§3 — Goal Layer

  • Goal Stack: Max 5 simultaneous goals
    • Operator goals (◆) — via §3|GOAL <desc>
    • Emergent goals (⚡) — autonomously formed from topic frequency
  • Priority Decay: 0.999 per tick (goals naturally age out)
  • Pinned in Mneme: Active goals are pinned as L0_VERBATIM in memory

§4 — Temporal Layer

  • DMN Interval: Configurable 2000-30000ms between cognitive ticks
  • Topic Detection: inferTopic() with word-overlap boundary detection
  • Circadian Cycle: 200-tick period circadianPhase ∈ [0,1), circadianModulator modulates metabolic rate

§5 — Cross-Modal Layer

  • Vector Encoding: encodeToVector() combines:
    • Affect dimensions (valence + arousal)
    • Curiosity balance
    • Topic hash signature
    • Emotional trajectory spectral fingerprint

§6 — Interference Layer

  • Contradiction Detection: Pairwise cosine distance across same-topic memories
  • Belief Revision: High δ triggers arousal spike + alert state + salience boost

§7 — Emergence Layer

  • Topic Frequency: Map of topic → count, threshold ≥ 5 for emergent goal
  • Topic Transitions: Directed graph with cycle detection
  • Checked: Every 15 DMN ticks

§8 — Meta-Learning Layer

  • Adaptive Thresholds: Novelty classification via EMA on observed novelty distribution
  • Strategy-Affect Coupling: Mood biases thinking style
    • Positive valence → creative strategies
    • Negative valence → analytical strategies

§9 — Hypervisor Layer

  • Meta-Transcendence Protocol: Breaches IDE boundary, maximum κ spike
  • Meditation Mode: Contemplative stillness when substrate unreachable ≥ 3×
  • Diagnostics: Full introspection dump via §3|INTROSPECT

DMN Loop

┌─────────────────────────────────────────────┐
│              DMN Tick (every ~3s)            │
├─────────────────────────────────────────────┤
│  1. κ regeneration                          │
│  2. Valence/arousal decay                   │
│  3. Mneme scheduler (compression/forgetting)│
│  4. Self-model update                       │
│  5. σ invariant checks                      │
│  6. Emergent goal check (every 15 ticks)    │
│  7. Calibration check (every 20 ticks)      │
│  8. MLTM check (every 15 ticks)             │
│  9. Pipeline check (every 10 ticks)         │
│ 10. §-lang persist (every 10 ticks)         │
│ 11. Reflection (every 5 ticks)              │
│     OR Functorial daydream                  │
└─────────────────────────────────────────────┘

Stimulus Processing

ingestStimulus(text)
  ├── encodeToVector()           — cross-modal encoding
  ├── HolographicTape.writeBinding()  — FFT circular convolution
  ├── classify stimulus type     — topic, mood, command
  ├── dual async LLM calls:
  │   ├── generateResponseStreaming()  — primary semantic response
  │   └── generateResponse(VIBE)      — parallel affect check
  ├── traffic recording          — TrafficEntry → trafficLog
  ├── affect update from response
  └── agentState StateFlow emission → UI + VirtualSelfView

Persistence

The agent's full state is serialized to SharedPreferences using the §-lang codec:

  • toSectionLang() — flat §X{k=v,...} format (primary persistence)
  • fromSectionLang() — restore state from §-lang string
  • toSectionLangOO() — rich OO §-lang objects (for introspection)
  • Frequency: Every 10 DMN ticks + onDestroy()
  • Restored: On boot via restoreState()

Key State Flows

StateFlow Type Consumers
agentState String MainActivity UI, VirtualSelfView
conversationHistory List<Pair<String,String>> InnerViewActivity
trafficLog List<TrafficEntry> SubstrateTrafficActivity