Skip to content

Living Dynamics

How memories decay, accumulate noise, respond to emotion, and evolve over time.

Overview

Cerememory's defining feature is that memories are alive. They change over time through six mechanisms: decay, noise accumulation, emotional modulation, reactivation, reconsolidation, and consolidation. This page documents the mathematical models behind each.

Fidelity Decay (Power-Law Model)

Memory fidelity decreases over time following a modified power-law formula:

plaintext
F(t) = F_0 * (1 + t/S)^(-d) * E_mod
ParameterSymbolDefaultDescription
Initial fidelityF_01.0Starting fidelity score (0.0 to 1.0)
Elapsed timet--Seconds since last access or last decay tick
StabilityS1.0Stability constant; increases with each retrieval
Decay exponentd0.3Controls decay speed (per-record, stored in decay_rate)
Emotional modulationE_mod1.0Scales fidelity; > 1.0 for emotional memories

The power-law curve means memories decay rapidly at first and then slowly approach zero -- never quite disappearing, but becoming increasingly unreliable. This matches empirical findings in cognitive science.

Noise Accumulation

As fidelity drops, memories accumulate noise -- random distortions that represent interference from other memories:

plaintext
N(t) = N_0 + interference_rate * sqrt(t) * (1 - F(t))
ParameterDefaultDescription
N_00.0Initial noise level
interference_rate0.1Rate of noise accumulation

Key properties:

  • Noise grows with the square root of time (sub-linear, bounded)
  • Noise is inversely proportional to fidelity -- more decayed memories are noisier
  • Both fidelity and noise are clamped to the [0.0, 1.0] interval
  • In human recall mode, noise is applied to retrieved content; in perfect mode, it is bypassed

Emotional Modulation

Emotional intensity modulates the decay rate through the E_mod factor:

plaintext
E_mod = 1.0 + emotion_intensity * 0.5

The EmotionVector uses Plutchik's 8-dimensional model with an overall intensity field (0.0 to 1.0) and a valence field (-1.0 to +1.0).

At maximum emotional intensity (1.0), E_mod = 1.5, meaning the effective fidelity is 50% higher than a neutral memory at the same age. This causes emotional memories to persist significantly longer.

rust
pub struct EmotionVector {
    pub joy: f64,          // 0.0 to 1.0
    pub trust: f64,
    pub fear: f64,
    pub surprise: f64,
    pub sadness: f64,
    pub disgust: f64,
    pub anger: f64,
    pub anticipation: f64,
    pub intensity: f64,    // overall emotional intensity
    pub valence: f64,      // -1.0 (negative) to 1.0 (positive)
}

Reactivation (Retrieval Boost)

When a memory is recalled, its stability constant increases, making future decay slower:

plaintext
S_new = S_old * (1 + retrieval_boost * S_old^(-0.2))
ParameterDefaultDescription
retrieval_boost1.5Multiplicative boost factor

This implements a spaced repetition effect: the more a memory is accessed, the more stable it becomes. The boost diminishes with higher stability (the S^(-0.2) term), modeling the psychological observation that well-established memories benefit less from additional rehearsal.

Reconsolidation

When a memory is recalled (and reconsolidate: true is set in the query), the engine:

  1. Increments the record's access_count
  2. Updates last_accessed_at to the current timestamp
  3. Boosts the stability constant via the retrieval boost formula
  4. Persists these changes back to the store

This means every recall operation strengthens the retrieved memory, just as biological reconsolidation does. Memories that are never recalled will naturally decay and eventually be pruned.

Consolidation

Consolidation migrates mature episodic memories into the semantic store as distilled knowledge. It runs on-demand via the lifecycle.consolidate CMP operation.

1

Select candidates -- Episodic memories that exceed configurable thresholds for age (min_age_hours) and access count (min_access_count) are selected.

2

Summarize -- If an LLM provider is configured, candidate memories are summarized into concise semantic knowledge. Without an LLM, content is truncated.

3

Create semantic records -- Summarized content is stored as new semantic memory records with appropriate associations to the source episodic memories.

4

Prune originals -- Depending on the consolidation strategy (full, incremental, or selective), the original episodic records may be pruned or left in place.

Per-Store Decay Defaults

The evolution engine initializes each store with distinct decay parameters tuned to its role:

StoreDecay Exponent (d)Retrieval BoostInterference RatePrune Threshold
Episodic0.31.50.10.01
Semantic0.152.00.050.005
Procedural0.12.50.020.001
Emotional0.21.80.080.01
Working0.81.00.30.1

These parameters are adaptively tuned by the evolution engine over time (see Evolution Engine below).

Spreading Activation

The association engine uses weighted breadth-first search (BFS) to propagate activation through the cross-store association graph. When a memory is recalled, related memories are also activated with diminishing strength.

ParameterDefaultDescription
decay_factor0.5Activation strength multiplier per hop
threshold0.05Minimum activation to continue spreading
default_depth2Maximum traversal depth

Activation at each hop is computed as parent_activation * edge_weight * decay_factor. Nodes below the threshold are not expanded.

Evolution Engine

The evolution engine autonomously tunes decay parameters based on usage patterns. It applies three rules:

  1. Low fidelity rule -- If median fidelity drops below 0.3, reduce decay_exponent by 10% (memories are decaying too fast)
  2. Low recall hit rate -- If recall hit rate drops below 0.2 (minimum 5 observations), increase retrieval_boost by 10%
  3. Excessive pruning -- If more than 50% of records are in the lowest fidelity bucket, reduce prune_threshold by 10%

All parameter adjustments are capped at ±50% of the original value to prevent runaway tuning.

Pruning

Records whose fidelity falls below the prune threshold (default: 0.01) are flagged for deletion during decay ticks. This automatic cleanup prevents unbounded storage growth while ensuring that only truly forgotten memories are removed.

Background Decay

In server mode, the engine runs a background decay task on a configurable interval (default: 3600 seconds). Each tick:

  1. Collects all records from all persistent stores
  2. Runs the decay engine in parallel across all records
  3. Writes updated fidelity states back to each store
  4. Prunes records that fall below the threshold

The background task is started with engine.start_background_decay() and stopped gracefully during shutdown.

Next Steps

Data Model

Explore MemoryRecord, FidelityState, and other core types

Lifecycle Operations

Learn the CMP operations that control these dynamics