Reconsolidation & Temporal Validity
Relevant source files
The following files were used as context for generating this wiki page:
Reconsolidation and Temporal Validity represent the CORTEX mechanisms for evolving agent beliefs and tracking the lifespan of information. Unlike standard vector databases that treat memories as static and immutable, CORTEX implements a neuroscience-grounded approach where retrieved memories enter a malleable (labile) state. This allows the system to update, expand, or correct existing knowledge when new evidence arrives rather than simply appending redundant data.
Temporal Validity ensures the agent maintains a chronological understanding of its knowledge base. By tracking when a memory was true and identifying when it was superseded, the system avoids the "identity drift" common in LLM agents and provides a structured audit trail of cognitive evolution.
Sources: src/reconsolidation/index.ts:3-23, README.md:99-105
Memory Reconsolidation
Memory reconsolidation is the process where a retrieved memory becomes temporarily modifiable before restabilizing. This mechanism allows the agent to update beliefs, correct errors, and integrate new information into existing nodes.
The Labile Window
When a memory is retrieved via search or recall, the system marks it as "labile" by updating its last_recalled_at timestamp. A memory remains in this modifiable state for a fixed duration of one hour. If a reconsolidation attempt occurs after this window closes, the system rejects the update to ensure stability.
Sources: src/reconsolidation/index.ts:25-30, src/reconsolidation/index.ts:46-55
Update Logic and Re-encoding
The reconsolidate() function executes the transition from old to new content. The process involves several steps to ensure the updated memory remains integrated with the cognitive architecture:
- Verification: Confirms the memory exists, is active, and the labile window is still open.
- Temporal Marking: Sets the
valid_untilfield of the current state to the present time. - Artifact Creation: Stores the original content as a "cognitive artifact" for auditing.
- Re-encoding: Generates new embeddings, sparse codes (via Dentate Gyrus), and novelty scores (via CA1).
- Persistence: Updates the memory node with the new content, new vectors, and a resonance boost.
Sources: src/reconsolidation/index.ts:98-175, src/mcp/server.ts:634-659
Reconsolidation Process Flow
The following diagram illustrates the lifecycle of a memory from retrieval through reconsolidation.
The diagram shows how the system gates updates behind a temporal window and re-indexes content to maintain cognitive integrity.
Sources: src/reconsolidation/index.ts:46-175
Temporal Validity and Supersession
Temporal validity tracks the period during which a memory was considered current. This allows agents to reason about past beliefs and changes in their environment.
Data Model Fields
Temporal logic is enforced through specific metadata fields in the memory_nodes table:
| Field | Type | Description |
|---|---|---|
valid_from | Timestamp | The time when the memory or updated belief became active. |
valid_until | Timestamp | The time when the memory was superseded or became invalid. |
superseded_by | Integer (ID) | Reference to the new memory node that replaced this information. |
last_recalled_at | Timestamp | Used to determine if a memory is currently labile. |
Sources: README.md:103-105, src/reconsolidation/index.ts:143-157, benchmarks/cogbench/dataset/cogbench-v1.json:15-25
Temporal Search
CORTEX can perform "temporal-aware" searches. This filter ensures that only memories valid at a specific point in time are returned to the agent, preventing the inclusion of outdated or future-dated information in the current context.
Sources: benchmarks/cogbench/client.ts:219-253
Cognitive Artifacts and Audit Trails
To maintain transparency, CORTEX preserves every version of a reconsolidated memory. When a memory is updated, the original content is encapsulated in a cognitiveArtifact.
Artifact Structure
Artifacts of the correction type include specific metadata to track the evolution of the memory:
memoryId: The ID of the original node.originalContent: The text before the update.newContent: The text after the update.reason: The justification for the change (e.g.,career_change,tech_migration).reconsolidatedAt: ISO timestamp of the operation.
Sources: src/reconsolidation/index.ts:121-137, benchmarks/cogbench/tasks/reconsolidation.ts:40-45
Sequence of Belief Updating
This sequence diagram shows the interaction between the Agent, the Reconsolidation module, and the Database.
The sequence ensures that the labile state is checked before any permanent changes are written to the memory store.
Sources: src/reconsolidation/index.ts:70-175, src/mcp/server.ts:634-659
Configuration and Implementation
Core Constants
The reconsolidation system uses the following defaults:
| Constant | Value | Description |
|---|---|---|
LABILE_WINDOW_MS | 3,600,000 ms | One hour window for modifiability. |
RESONANCE_BOOST | 1.5 | The score increase granted to reconsolidated memories. |
MAX_RESONANCE | 10.0 | The upper limit for memory resonance scores. |
Sources: src/reconsolidation/index.ts:32, src/reconsolidation/index.ts:153-158
Procedural Implementation Example
The following snippet from the reconsolidation logic demonstrates how the system handles the database update while ensuring the memory remains valid.
// Sources: [src/reconsolidation/index.ts:143-157]
await db.execute(sql`
UPDATE memory_nodes
SET content = ${newContent},
embedding = ${`[${newEmbedding.join(",")}]`}::vector,
resonance_score = ${newResonance},
novelty_score = ${noveltyResult.noveltyScore},
entities = ${entitiesLiteral}::text[],
semantic_tags = ${tagsLiteral}::text[],
valid_from = NOW(),
valid_until = NULL,
updated_at = NOW(),
last_recalled_at = NULL
WHERE id = ${memoryId}
`);
Summary
Reconsolidation and Temporal Validity allow CORTEX to model memory as a living, evolving system rather than a flat log. By enforcing a labile window for updates, maintaining a strict temporal metadata schema, and archiving old states as cognitive artifacts, the system enables agents to adapt to new information without losing their historical context or cognitive stability.
Sources: REFERENCES.md:120-134, README.md:99-105