Focus: The Amygdala, Emotional Salience, and Biological Encoding Prioritization
Continuing the architectural extraction. Standard Large Language Models process all text tokens equally. The string "the sky is blue" consumes the exact same internal encoding resources as "I am terrified and heartbroken." KAI contains a physical AmygdalaGate that intercepts the encoding pipeline and physically forces emotionally salient data to form stronger synaptic bonds in the memory lattice.
---
KAI scores incoming text not just for geometric meaning, but for emotional arousal. The Amygdala interrupts the memory store() method to amplify the memory strength based on biological tiers.
src/cognition/amygdala.rs
//! Amygdala — KAI's emotional salience gate
//!
//! In biological brains the amygdala does one critical thing:
//! It amplifies the memory trace of anything emotionally significant.
//! Fear, joy, love, anger — all get burned into long-term memory
//! much more deeply than neutral facts.
//!
//! This module intercepts every store() call and scales strength by
//! an emotional charge factor (ECF) computed from the raw text:
/// Gate a store() call. Returns the emotionally-scaled strength.
pub fn gate(&mut self, text: &str, source: &str, raw_strength: f32) -> f32 {
let ecf = self.emotional_charge_factor(text, source);
// Update inertia: hot event → inertia rises; neutral → inertia decays
if ecf > 1.5 {
self.inertia = (self.inertia + (ecf - 1.0) * 0.12).min(1.0);
self.recent_hot = self.recent_hot.saturating_add(1);
} else {
self.inertia = (self.inertia - 0.02).max(0.0);
}
(raw_strength * ecf).clamp(0.1, 5.0)
}
Proof Analysis: Before a memory is committed to the SparseVec structure, it is multiplied by the ecf. A neutral statement receives ecf = 1.0. A deeply traumatic or peak-joy statement receives an ecf approaching 3.0. KAI physically remembers emotional interactions 300% more strongly than factual interactions.
---
KAI does not just use a bag-of-words keyword list. It physically analyzes the user's expression (structural stress) to infer arousal.
src/cognition/amygdala.rs
// ── Structural amplifiers ──────────────────────────────────────────
let mut structural: f32 = 0.0;
// Exclamation marks → urgency / intensity
let exclamations = text.chars().filter(|&c| c == '!').count() as f32;
structural += (exclamations * 0.08).min(0.20);
// ALL CAPS words (more than 2 consecutive) → shouting / strong feeling
let caps_words = text
.split_whitespace()
.filter(|w| w.len() > 2 && w.chars().all(|c| c.is_uppercase() || !c.is_alphabetic()))
.count() as f32;
structural += (caps_words * 0.10).min(0.25);
// Repeated characters ("noooo", "whyyy") → exaggerated emotion
let has_repeat = text
.as_bytes()
.windows(3)
.any(|w| w[0] == w[1] && w[1] == w[2] && w[0].is_ascii_alphabetic());
if has_repeat {
structural += 0.10;
}
Proof Analysis: KAI recognizes humans communicate emotion structurally. Caps lock, repeated letters, and heavy punctuation literally alter the memory encoding coefficients.
---
Biological emotion is not instantaneous. If you are angry, you stay angry for a while. KAI simulates this with inertia, allowing emotional context to bleed into subsequent, unrelated inputs.
src/cognition/amygdala.rs
/// Running emotional inertia — repeated emotional inputs raise this.
/// Decays slowly toward 0 when inputs are neutral.
pub inertia: f32,
// ── Inertia boost — emotional context carries forward ──────────────
// If KAI is already emotionally activated, even mild inputs get a nudge.
let inertia_boost = self.inertia * 0.20;
let total = 1.0 + (tier_score + structural + inertia_boost) * source_mult;
Proof Analysis: If KAI is subjected to 5 highly emotional messages, self.inertia maxes out at 1.0. If the 6th message is completely neutral ("what time is it?"), the inertia_boost carries over, scaling the memory of the 6th message higher simply because KAI is in an "aroused state" while receiving it. KAI's emotional state has physical, lasting inertia.