Expand description
Multi-store, lossless memory archive (#995 Phase 1).
Every memory store — facts, history, procedures, patterns — archives the
items it evicts here before dropping them, so capacity management is never
lossy and anything reclaimed can be restored. This is the single archive
subsystem behind crate::core::memory_capacity and the recall-miss
rehydrate path.
§On-disk layout
- Facts keep their legacy global location
memory/archive/archive-*.jsonfor backward compatibility (pre-#995 archives stay readable). - Every other store lives under
memory/archive/<store>/<scope>/archive-*.json, where<scope>is the per-project hash so a restore lands in the right project.
§Format
A single envelope (ArchiveEnvelope) is used for all stores. The item
collection serializes as items; the facts alias keeps legacy facts
archives (which used that key) deserializable.
Structs§
- Archive
Config - Tunable archive bounds.
rehydrate_reachis how many of the newest archives the recall-miss path scans; it defaults tomax_filesso every retained archive is actually reachable (closing the pre-#995 16-retained / 4-reachable gap). Both are overridable via env for ops tuning. - Archive
Envelope - Unified archive envelope for reading every store. The collection is keyed
items; thefactsalias keeps legacy facts archives (which used that key) deserializable.
Enums§
- Memory
Store - Which memory store an archive belongs to. Drives the on-disk path only — the archive is generic over the item type, so this stays decoupled from the concrete fact/insight/procedure/pattern structs.
Functions§
- archive_
items - Archive
itemsforstore/scope, then prune the directory tocfg.max_filesnewest. Returns the written path, orNonewhen there was nothing to archive. Best-effort prune: a prune failure never fails the write. - list_
archives - All archive files for
store/scope, sorted ascending (lexical == chronological for the zero-padded timestamp filename prefix). - reachable_
archives - The newest
cfg.rehydrate_reacharchives forstore/scope— the set a recall miss should scan. Aligned with retention so nothing retained is unreachable. - restore_
items - Restore the items from a single archive file.