1use serde::{Deserialize, Serialize};
5
6#[derive(Clone, Debug, Default)]
7pub struct HmsConfig {
8 pub ivf: IVFConfig,
9 pub nsg: NSGConfig,
10 pub shard: ShardConfig,
11 pub query: QueryConfig,
12 pub concepts: ConceptsConfig,
13 pub diffusion: DiffusionConfig,
14 pub security: SecurityConfig,
15 pub privacy: PrivacyConfig,
16 pub meaning: MeaningConfig,
17 pub cognition: CognitionConfig,
18}
19
20#[derive(Clone, Debug)]
21pub struct MeaningConfig {
22 pub enabled: bool,
23 pub beta: f64,
24 pub algebraic_max_fanout: usize,
25 pub auto_decompose: bool,
26 pub max_hop_depth: usize,
27 pub max_rule_depth: usize,
28 pub idf_clip_factor: f64,
29}
30
31impl Default for MeaningConfig {
32 fn default() -> Self {
33 Self {
34 enabled: false,
35 beta: 24.0,
36 algebraic_max_fanout: 40,
37 auto_decompose: false,
38 max_hop_depth: 10,
39 max_rule_depth: 10,
40 idf_clip_factor: 3.0,
41 }
42 }
43}
44
45#[derive(Clone, Debug, Default)]
46pub struct SecurityConfig {
47 pub signing_enabled: bool,
48 pub key_path: Option<String>,
49 pub encryption_enabled: bool,
50 pub encryption_passphrase: Option<String>,
51 pub audit_enabled: bool,
52}
53
54#[derive(Clone, Debug)]
55pub struct PrivacyConfig {
56 pub dp_enabled: bool,
58 pub epsilon: f64,
61}
62
63impl Default for PrivacyConfig {
64 fn default() -> Self {
65 Self {
66 dp_enabled: false,
67 epsilon: 1.0,
68 }
69 }
70}
71
72#[derive(Clone, Debug)]
73pub struct QueryConfig {
74 pub component_similarity_threshold: f64,
75 pub component_max_neighbors: u32,
76}
77
78impl Default for QueryConfig {
79 fn default() -> Self {
80 Self {
81 component_similarity_threshold: 0.05,
82 component_max_neighbors: 20,
83 }
84 }
85}
86
87#[derive(Clone, Debug)]
88pub struct ConceptsConfig {
89 pub similarity_threshold: f64,
90 pub min_cluster_size: usize,
91}
92
93impl Default for ConceptsConfig {
94 fn default() -> Self {
95 Self {
96 similarity_threshold: 0.3,
97 min_cluster_size: 3,
98 }
99 }
100}
101
102#[derive(Clone, Debug)]
103pub struct DiffusionConfig {
104 pub steps: usize,
105 pub sigma_max: f64,
106 pub sigma_min: f64,
107 pub step_size: f64,
108 pub n_langevin: usize,
109}
110
111impl Default for DiffusionConfig {
112 fn default() -> Self {
113 Self {
114 steps: 10,
115 sigma_max: 0.5,
116 sigma_min: 0.01,
117 step_size: 0.1,
118 n_langevin: 5,
119 }
120 }
121}
122
123#[derive(Clone, Debug)]
124pub struct ShardConfig {
125 pub enabled: bool,
126 pub shard_count: usize,
127 pub auto_threshold: usize,
128 pub target_shard_size: usize,
129}
130
131impl Default for ShardConfig {
132 fn default() -> Self {
133 Self {
134 enabled: false,
135 shard_count: 0,
136 auto_threshold: 1_000_000,
137 target_shard_size: 250_000,
138 }
139 }
140}
141
142#[derive(Clone, Debug, Serialize, Deserialize)]
143pub struct NSGConfig {
144 pub max_degree: usize,
145 pub ef_construction: usize,
146 pub auto_threshold: usize,
147 pub seed: u64,
148}
149
150impl Default for NSGConfig {
151 fn default() -> Self {
152 Self {
153 max_degree: 32,
154 ef_construction: 128,
155 auto_threshold: 10_000,
156 seed: 42,
157 }
158 }
159}
160
161#[derive(Clone, Debug)]
162pub struct IVFConfig {
163 pub enabled: bool,
165 pub n_clusters: usize,
166 pub n_landmarks: usize,
167 pub d_reduced: usize,
168 pub n_probe: usize,
169 pub auto_threshold: usize,
170}
171
172impl Default for IVFConfig {
173 fn default() -> Self {
174 Self {
175 enabled: false,
176 n_clusters: 256,
177 n_landmarks: 1024,
178 d_reduced: 128,
179 n_probe: 8,
180 auto_threshold: 10_000,
181 }
182 }
183}
184
185#[derive(Clone, Debug)]
186pub struct CognitionConfig {
187 pub enabled: bool,
188 pub interval_secs: u64,
189 pub min_pattern_freq: usize,
190 pub min_abstraction_members: usize,
191 pub min_shared_relations: usize,
192 pub min_peer_coverage: f64,
193 pub hypothesis_beta: f64,
194 pub min_hypothesis_confidence: f64,
195 pub min_analogy_relations: usize,
196 pub governor_duplicate_threshold: f64,
197 pub governor_max_scan_size: usize,
198 pub governor_forget_unreferenced: bool,
199 pub refine_atoms: bool,
200}
201
202impl Default for CognitionConfig {
203 fn default() -> Self {
204 Self {
205 enabled: false,
206 interval_secs: 60,
207 min_pattern_freq: 3,
208 min_abstraction_members: 3,
209 min_shared_relations: 2,
210 min_peer_coverage: 0.5,
211 hypothesis_beta: 24.0,
212 min_hypothesis_confidence: 0.3,
213 min_analogy_relations: 2,
214 governor_duplicate_threshold: 0.95,
215 governor_max_scan_size: 1000,
216 governor_forget_unreferenced: false,
217 refine_atoms: false,
218 }
219 }
220}