memrec_common/types/
config.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct MemoryConfig {
5 pub soft_delete_recovery_days: u32,
6 pub hard_delete_importance: f32,
7 pub hard_delete_inactive_days: u32,
8 pub compression_importance: f32,
9 pub max_storage_gb: usize,
10 pub high_watermark: f32,
11 pub low_watermark: f32,
12}
13
14impl Default for MemoryConfig {
15 fn default() -> Self {
16 Self {
17 soft_delete_recovery_days: 30,
18 hard_delete_importance: 0.1,
19 hard_delete_inactive_days: 90,
20 compression_importance: 0.3,
21 max_storage_gb: 10,
22 high_watermark: 0.9,
23 low_watermark: 0.7,
24 }
25 }
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct ImportanceConfig {
30 pub lambda: f32,
31 pub frequency_normalize: f32,
32 pub weight_recency: f32,
33 pub weight_frequency: f32,
34 pub weight_semantic: f32,
35 pub weight_explicit: f32,
36}
37
38impl Default for ImportanceConfig {
39 fn default() -> Self {
40 Self {
41 lambda: 0.05,
42 frequency_normalize: 10.0,
43 weight_recency: 0.3,
44 weight_frequency: 0.2,
45 weight_semantic: 0.2,
46 weight_explicit: 0.3,
47 }
48 }
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct ServerConfig {
53 pub socket_path: String,
54 pub data_dir: String,
55}
56
57impl Default for ServerConfig {
58 fn default() -> Self {
59 Self {
60 socket_path: "~/.memrec/memrecd.sock".to_string(),
61 data_dir: "~/.memrec/data".to_string(),
62 }
63 }
64}
65
66#[cfg(test)]
67mod tests {
68 use super::*;
69
70 #[test]
71 fn test_memory_config_defaults() {
72 let config = MemoryConfig::default();
73
74 assert_eq!(config.soft_delete_recovery_days, 30);
75 assert_eq!(config.hard_delete_importance, 0.1);
76 assert_eq!(config.max_storage_gb, 10);
77 assert_eq!(config.high_watermark, 0.9);
78 }
79
80 #[test]
81 fn test_importance_config_defaults() {
82 let config = ImportanceConfig::default();
83
84 assert_eq!(config.lambda, 0.05);
85 assert_eq!(config.weight_recency, 0.3);
86 }
87
88 #[test]
89 fn test_config_serde() {
90 let config = MemoryConfig::default();
91 let json = serde_json::to_string(&config).unwrap();
92 let parsed: MemoryConfig = serde_json::from_str(&json).unwrap();
93
94 assert_eq!(config.soft_delete_recovery_days, parsed.soft_delete_recovery_days);
95 }
96}