zeph_common/config/memory.rs
1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Shared runtime configuration structs for memory subsystems.
5//!
6//! These are plain (no serde) structs used as runtime parameters. They are separate from the
7//! serde-annotated config types in `zeph-config` which own the deserialization concerns.
8
9/// Runtime config for Kumiho belief revision passed into resolver methods.
10#[derive(Debug, Clone)]
11pub struct BeliefRevisionConfig {
12 pub similarity_threshold: f32,
13}
14
15/// Runtime config for A-MEM dynamic note linking.
16#[derive(Debug, Clone)]
17pub struct NoteLinkingConfig {
18 pub enabled: bool,
19 pub similarity_threshold: f32,
20 pub top_k: usize,
21 pub timeout_secs: u64,
22}
23
24impl Default for NoteLinkingConfig {
25 fn default() -> Self {
26 Self {
27 enabled: false,
28 similarity_threshold: 0.85,
29 top_k: 10,
30 timeout_secs: 5,
31 }
32 }
33}
34
35/// Runtime config for the consolidation sweep loop.
36#[derive(Debug, Clone)]
37pub struct ConsolidationConfig {
38 pub enabled: bool,
39 pub confidence_threshold: f32,
40 pub sweep_interval_secs: u64,
41 pub sweep_batch_size: usize,
42 pub similarity_threshold: f32,
43}
44
45/// Runtime config for the forgetting sweep (#2397).
46#[derive(Debug, Clone)]
47pub struct ForgettingConfig {
48 /// Enable the forgetting sweep.
49 pub enabled: bool,
50 /// Per-sweep decay rate applied to importance scores. Range: (0.0, 1.0).
51 pub decay_rate: f32,
52 /// Importance floor below which memories are pruned. Range: [0.0, 1.0].
53 pub forgetting_floor: f32,
54 /// How often the forgetting sweep runs, in seconds.
55 pub sweep_interval_secs: u64,
56 /// Maximum messages to process per sweep.
57 pub sweep_batch_size: usize,
58 /// Hours: messages accessed within this window get replay protection.
59 pub replay_window_hours: u32,
60 /// Messages with `access_count` >= this get replay protection.
61 pub replay_min_access_count: u32,
62 /// Hours: never prune messages accessed within this window.
63 pub protect_recent_hours: u32,
64 /// Never prune messages with `access_count` >= this.
65 pub protect_min_access_count: u32,
66}
67
68impl Default for ForgettingConfig {
69 fn default() -> Self {
70 Self {
71 enabled: false,
72 decay_rate: 0.1,
73 forgetting_floor: 0.05,
74 sweep_interval_secs: 7200,
75 sweep_batch_size: 500,
76 replay_window_hours: 24,
77 replay_min_access_count: 3,
78 protect_recent_hours: 24,
79 protect_min_access_count: 3,
80 }
81 }
82}