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.
class BabyToposAI(
private val substrate: HolographicTape, // §1 memory manifold
private val llmEngine: LocalGemmaEngine // §0 inference substrate
)- 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_tokensfrom APIusagefield - Emergency Floor: κ dead-policy emergency floor during circadian night (PATCH_3)
- 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
- Dream Chaining: When
dreamCoherence > 0.6, the last dream response becomesdream_seedfor the next - Functorial Daydream: Simultaneous episodic + categorical memory retrieval:
F = fuse ∘ (F_ep × F_mn)
- Goal Stack: Max 5 simultaneous goals
- Operator goals (◆) — via
§3|GOAL <desc> - Emergent goals (⚡) — autonomously formed from topic frequency
- Operator goals (◆) — via
- Priority Decay: 0.999 per tick (goals naturally age out)
- Pinned in Mneme: Active goals are pinned as L0_VERBATIM in memory
- DMN Interval: Configurable 2000-30000ms between cognitive ticks
- Topic Detection:
inferTopic()with word-overlap boundary detection - Circadian Cycle: 200-tick period
circadianPhase ∈ [0,1),circadianModulatormodulates metabolic rate
- Vector Encoding:
encodeToVector()combines:- Affect dimensions (valence + arousal)
- Curiosity balance
- Topic hash signature
- Emotional trajectory spectral fingerprint
- Contradiction Detection: Pairwise cosine distance across same-topic memories
- Belief Revision: High δ triggers arousal spike + alert state + salience boost
- Topic Frequency: Map of topic → count, threshold ≥ 5 for emergent goal
- Topic Transitions: Directed graph with cycle detection
- Checked: Every 15 DMN ticks
- 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
- Meta-Transcendence Protocol: Breaches IDE boundary, maximum κ spike
- Meditation Mode: Contemplative stillness when substrate unreachable ≥ 3×
- Diagnostics: Full introspection dump via
§3|INTROSPECT
┌─────────────────────────────────────────────┐
│ 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 │
└─────────────────────────────────────────────┘
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
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 stringtoSectionLangOO()— rich OO §-lang objects (for introspection)- Frequency: Every 10 DMN ticks +
onDestroy() - Restored: On boot via
restoreState()
| StateFlow | Type | Consumers |
|---|---|---|
agentState |
String |
MainActivity UI, VirtualSelfView |
conversationHistory |
List<Pair<String,String>> |
InnerViewActivity |
trafficLog |
List<TrafficEntry> |
SubstrateTrafficActivity |