Expand description
Forgetting sweep — SleepGate (#2397).
Inspired by sleep-dependent memory consolidation: a background sweep periodically
downscales all non-consolidated message importance scores (synaptic downscaling),
restores recently-accessed messages (selective replay), then prunes messages whose
scores fall below forgetting_floor (targeted forgetting).
§Algorithm
- Synaptic downscaling — multiply all active, non-consolidated importance scores
by
(1.0 - decay_rate)in a single batch UPDATE. - Selective replay — undo the current sweep’s decay for messages accessed within
replay_window_hoursor withaccess_count >= replay_min_access_count. - Targeted forgetting — soft-delete messages below
forgetting_floorthat are not protected by recent access or high access count.
All three phases run inside a single SQLite transaction to prevent intermediate state
from being visible to concurrent readers (WAL readers see the pre-transaction snapshot
until commit).
§Interaction with consolidation
Forgetting only targets non-consolidated messages (consolidated = 0). Consolidation
merge transactions re-check deleted_at IS NULL before writing, so messages deleted
by forgetting are safely skipped during the next consolidation sweep.
§No LLM calls
Pure SQL arithmetic — no *_provider field needed.
Structs§
- Forgetting
Config - Runtime config for the forgetting sweep (#2397).
- Forgetting
Result - Outcome of a single forgetting sweep.
Functions§
- run_
forgetting_ sweep - Execute one full forgetting sweep (
SleepGate). - start_
forgetting_ loop - Start the background forgetting loop (
SleepGate).