Skip to main content

Module decay

Module decay 

Source
Expand description

Memory decay & forgetting (C3, v0.22.1 §S4): TTL + importance-driven consolidation.

Human memory fades; an agent’s memory should too, or stale and weak memories silently pollute every future prompt. C3 layers a lightweight decay policy on top of super::file_memory::FileMemoryStore:

  • Recency wins: every access (remember/recall) stamps last_access_at. A memory that is read frequently stays alive; one that goes idle long enough is forgotten.
  • Importance floor: each memory carries an importance in [0, 1]. Weak memories (importance < min_importance) that have gone quiet past weak_grace are pruned even before the full TTL — they are not earning their keep.
  • Explicit consolidation: decay never happens on a hot read path. The caller runs ForgettingMemory::consolidate (e.g. between turns or on a schedule), which atomically drops expired/weak memories and persists the ledger.

The time source is injected (now: SystemTime), making every rule pure and unit-testable without sleeping. The metadata ledger is persisted as .memory.json inside the store root, so importance and timestamps survive restarts.

Structs§

ForgetConfig
Decay policy configuration.
ForgettingMemory
A decaying, file-backed memory store.