Sleep Consolidation: Inside the ReflectDaemon Housekeeping Daemon

When we sleep, our brains replay the day's experiences, transferring them from the volatile hippocampus (episodic memory) to the neocortex (semantic memory) while consolidating and distilling redundant details.

Spector replicates this biological housekeeping cycle using a background process called the ReflectDaemon.


The Consolidation Loop

The ReflectDaemon triggers automatically during periods of low agent activity. It executes four primary stages:

[Episodic Partition] -> [DBSCAN Clustering] -> [Pattern Extraction] -> [Semantic Promotion]
  1. Semantic Clustering: Scans episodic partitions and groups related memories using dense vector clustering (e.g. cosine distance DBSCAN).
  2. Fact Distillation: Summarizes specific episodes (e.g. "User debugged CORS on port 8080", "User debugged CORS on port 3000") into general semantic facts ("User works with CORS configurations regularly").
  3. Graph Pruning: Trims weak Hebbian edges that fell below the decay threshold, reclaiming unused off-heap memory slots.
  4. Permastore Promotion: Commits the distilled facts to long-term Semantic Memory (Tier 3), freeing up Episodic Memory (Tier 2) buffers.

This keeps the memory footprint lean and guarantees that the agent retains generalized understanding while freeing up volatile buffers.