Neuroscience Foundation
Relevant source files
The following files were used as context for generating this wiki page:
CORTEX implements a cognitive architecture for AI agents based on the hippocampal-cortical circuit of the mammalian brain. It replaces standard vector search with living memory systems that perform pattern separation, novelty detection, and sleep-dependent consolidation. The system uses these biological blueprints to manage memory decay, prioritize salient information, and update agent beliefs over time.
Sources: README.md:5-15, paper/drafts/cortex-v2-4-technical-note.md:20-25
Hippocampal Subsystems
The core memory architecture replicates three primary regions of the hippocampus to manage how information is encoded and retrieved.
Dentate Gyrus (DG) - Pattern Separation
The Dentate Gyrus converts dense vector embeddings into sparse, high-dimensional representations. It projects 1024-dimensional input into a 4096-dimensional space with 5% sparsity (~205 active indices). This process ensures that similar inputs remain distinct, preventing the "every meeting looks the same" problem common in standard cosine similarity search.
Sources: README.md:85-90, REFERENCES.md:15-20, paper/drafts/cortex-v2-4-technical-note.md:44-50
CA1 - Novelty Detection
The CA1 region acts as a predictive-coding comparator. It compares incoming sparse codes against existing memories to calculate a surprise signal. High novelty results in a higher resonance floor and prioritized encoding, while redundant information receives lower priority.
Sources: paper/drafts/cortex-v2-4-technical-note.md:52-56, benchmarks/cogbench/tasks/novelty-detection.ts:8-13
CA3 - Autoassociative Recall
The CA3 region performs pattern completion. During retrieval, an initial activation set is pulled via sparse overlap, followed by recurrent activation spread through the synapse graph. This allows the system to converge on full patterns even with partial cues.
Sources: REFERENCES.md:38-45, paper/drafts/cortex-v2-4-technical-note.md:58-63
The diagram shows the flow of information from ingestion through hippocampal subregions to final recall.
Sources: README.md:70-83, paper/drafts/cortex-v2-4-technical-note.md:40-65
Memory Consolidation (Dream Cycle)
CORTEX uses a two-phase "Dream Cycle" to maintain the memory graph, inspired by Slow-Wave Sleep (SWS) and Rapid Eye Movement (REM) sleep.
Slow-Wave Sleep (SWS)
Phase 1 and 2 focus on global maintenance:
- Resonance Analysis: Calculates decay using an Ebbinghaus stability-adjusted forgetting curve. Frequently accessed or highly connected memories resist decay.
- Adaptive Pruning: Deletes or archives memories based on percentile resonance thresholds (e.g., bottom 5% deleted, bottom 15% archived).
- Consolidation: Clusters high-resonance memories and generates abstractive summaries via LLM to form new cognitive insights.
Sources: src/dream/dream-cycle.ts:31-40, REFERENCES.md:78-85, README.md:162-170
Rapid Eye Movement (REM)
Phase 3 and 4 focus on creative association:
- Free Association: Randomly activates memory nodes to discover novel connections in both dense and sparse space.
- Synthesis: Generates new insights from weak synapses formed during free association.
Sources: src/dream/dream-cycle.ts:42-45, src/dream/dream-cycle.ts:470-485, README.md:172-175
Ebbinghaus Decay Logic
Memory resonance is calculated using the following variables to simulate biological forgetting:
| Component | Biological Basis | Implementation |
|---|---|---|
| Stability | Repetition/Mastery | 1 + (0.3 * ln(access_count + 1)) + (0.2 * connectivity) |
| Decay | Time-based loss | exp(-0.023 * days_old / stability) |
| Pruning | Synaptic Homeostasis | Percentile-based (P5/P15) deletion and archiving. |
| Sources: src/dream/dream-cycle.ts:160-175, REFERENCES.md:118-125, src/dream/dream-cycle.ts:220-235 |
Emotional Valence and Salience
Every memory is tagged with a six-dimensional emotional vector. These values modulate how memories are prioritized for recall and how well they resist decay during dream cycles.
- Dimensions: Valence, Arousal, Dominance, Certainty, Relevance, Urgency.
- Recall Boost: Emotional memories receive a scoring weight in the hybrid search (0.10 weighting).
- Pruning Protection: Memories with high decay resistance (intensity/valence) are shielded from the pruning phase of the dream cycle.
Sources: README.md:95-98, REFERENCES.md:144-150, src/mcp/server.ts:395-410, src/ingestion/ingest-markdown.ts:141-155
Reconsolidation and Labile Windows
Retrieving a memory opens a "labile window" (typically one hour). During this period, the memory is malleable and can be updated with new information. This process replicates how the brain updates beliefs rather than simply appending new data.
- Recall: A memory is accessed, triggering
markLabile(). - Window: The memory remains modifiable for 60 minutes.
- Update:
reconsolidate()updates the content, timestamps the old version asvalid_until, and creates a newvalid_fromentry.
Sources: REFERENCES.md:98-105, src/mcp/server.ts:605-620, README.md:100-105
The sequence shows how the reconsolidation process manages belief updates within a time-gated window.
Sources: REFERENCES.md:108-112, src/mcp/server.ts:622-640
Procedural Memory
Based on the ACT-R framework and basal ganglia function, CORTEX separates episodic "events" from procedural "skills."
- Skill Compilation: Recurring patterns detected during the dream cycle are promoted to procedural memory.
- Proficiency Tracking: Skills track execution count and success rate. Proficiency improves with repeated successful application.
- Retrieval: Procedural memories are retrieved via
cortex_skill_retrieveto guide agent workflows before task execution.
Sources: README.md:108-112, REFERENCES.md:162-168, src/mcp/server.ts:705-725
CORTEX integrates these biological mechanisms to ensure AI agents maintain long-term identity, improve skills through experience, and manage information volume through naturalistic forgetting and consolidation.