-
-
Notifications
You must be signed in to change notification settings - Fork 0
Memory Amygdala
Package:
com.spectrayan.spector.memory.amygdalaBiological Analog: The amygdala is the brain's emotional processor. It assigns emotional significance to experiences — fear, joy, anger, relief — which profoundly influences how memories are encoded, stored, and retrieved. Emotionally charged memories are remembered more vividly and last longer.
Every memory in Spector carries a valence score — a single byte (-128 to +127) representing its emotional coloring:
| Range | Meaning | Examples |
|---|---|---|
-128 to -50
|
Strongly negative | Critical errors, data loss, security breaches |
-50 to -10
|
Mildly negative | Warnings, slow performance, minor bugs |
-10 to +10
|
Neutral | Factual information, routine operations |
+10 to +50
|
Mildly positive | Successful deployments, optimizations |
+50 to +127
|
Strongly positive | Major breakthroughs, user praise, goals achieved |
The ValenceTracker manages emotional coloring of memories:
public final class ValenceTracker {
/**
* Computes valence from text content analysis.
* Uses keyword-based sentiment detection with configurable weights.
*/
public byte computeValence(String text, MemorySource source) {
float score = 0f;
// Source-based bias
if (source == MemorySource.PROCEDURAL) score += 0.1f; // Rules are slightly positive
if (source == MemorySource.OBSERVED && containsError(text)) score -= 0.5f;
// Content-based sentiment
score += sentimentScore(text);
// Clamp and convert to byte range
return (byte) Math.max(-128, Math.min(127, (int)(score * 127)));
}
}The most powerful use of valence is in recall filtering. The RecallOptions builder supports valence range filtering:
// Recall only negative-outcome memories (for debugging)
List<CognitiveResult> errors = memory.recall("database connection",
RecallOptions.builder()
.topK(10)
.maxValence((byte) -10) // Only negative memories
.build());
// Recall only positive outcomes (for best practices)
List<CognitiveResult> successes = memory.recall("deployment strategy",
RecallOptions.builder()
.topK(5)
.minValence((byte) 10) // Only positive memories
.build());Valence filtering happens at Phase 3 of the scoring pipeline — before the expensive SIMD vector math:
// Phase 3: Valence Filter (~2 cycles)
byte valence = segment.get(LAYOUT_VALENCE, offset + OFFSET_VALENCE);
if (valence < minValence || valence > maxValence) continue;Cost: 2 CPU cycles — a single byte read and two comparisons. Records outside the valence range are eliminated before Phase 5's ~200-cycle SIMD computation.
An agent can filter for negative-valence memories when debugging:
// "Show me only memories associated with failures"
memory.recall("connection timeout",
RecallOptions.builder()
.maxValence((byte) -10)
.synapticFilter("database", "error")
.build());// "Show me successful approaches"
memory.recall("deployment strategy",
RecallOptions.builder()
.minValence((byte) 10)
.synapticFilter("deployment")
.build());By default, no valence filter is applied — the agent sees the full emotional spectrum. The valence still influences recall indirectly because the FlashbulbPolicy pins emotionally intense memories at higher importance.
Valence is stored in the 32-byte synaptic header at offset 30 as a single signed byte:
Offset 30: [1B valence] — signed byte [-128 to +127]
This costs exactly 1 byte per memory — negligible overhead for a powerful filtering dimension.
- :material-link: [[Hebbian — Association Learning|Memory--Hebbian]] — "neurons that fire together wire together"
- :material-head-cog: [[Dopamine — Surprise Detection|Memory--Dopamine]] — auto-importance scoring
- :material-lightning-bolt: [[6-Phase Scoring Pipeline|Memory--Scoring-Pipeline]] — where valence filtering happens
- Home
- About
- Getting Started
-
Architecture
- System Overview
- Core Concepts
- MCP Integration
- Ingestion Pipeline
- RAG Pipeline
- Distributed Mode
- GPU Acceleration
- Test Framework & LLM Judge
-
Modules
- Overview
- spector-core
- spector-commons
- spector-config
- spector-storage
- spector-embed-api
- spector-embed-ollama
- spector-index
- spector-query
- spector-gpu
- spector-rag
- spector-engine
- spector-ingestion
- spector-memory
- spector-runtime
- spector-node
- spector-mcp
- spector-cli
- spector-client
- spector-spring
- spector-test-support
- spector-metrics
- spector-events
- spector-bench
- spector-dist
- spector-cortex
- Deep Dives
-
🧠 Cognitive Memory
- Overview
- Getting Started
- Architecture
-
Biological Systems
- Overview
- Cortex — Tier Stores
- Hippocampus — Sleep Consolidation
- Synapse — Tags & Scoring
- Dopamine — Surprise Detection
- Amygdala — Emotional Valence
- 3-Layer Cognitive Graph
- Habituation — Anti-Filter Bubble
- Inhibition — Suppression
- Interference — Deduplication
- Prospective — Future Intents
- Metamemory — Self-Reflection
- Sync — Persistence & Replication
- Advanced Profiles
- Deep Dives
- API Reference
- 🧬 Cortex Dashboard
- Reference
- Operations
- FAQ
- Roadmap
- 🔬 Labs