1pub use crate::types::*;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct RuntimeConfig {
9 pub profiles: ProfileConfig,
10 pub attention: AttentionConfig,
11 pub presence: PresenceConfig,
12 pub coupling: CouplingConfig,
13 pub commitment: CommitmentConfig,
14 pub temporal: TemporalConfig,
15 pub scheduling: SchedulingConfig,
16 pub registry: RegistryConfig,
17 pub invariants: InvariantConfig,
18 pub safety: SafetyConfig,
19 pub telemetry: TelemetryConfig,
20}
21
22impl Default for RuntimeConfig {
23 fn default() -> Self {
24 Self {
25 profiles: ProfileConfig::default(),
26 attention: AttentionConfig::default(),
27 presence: PresenceConfig::default(),
28 coupling: CouplingConfig::default(),
29 commitment: CommitmentConfig::default(),
30 temporal: TemporalConfig::default(),
31 scheduling: SchedulingConfig::default(),
32 registry: RegistryConfig::default(),
33 invariants: InvariantConfig::default(),
34 safety: SafetyConfig::default(),
35 telemetry: TelemetryConfig::default(),
36 }
37 }
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct ProfileConfig {
43 pub default_profile: ResonatorProfile,
44 pub allowed_profiles: Vec<ResonatorProfile>,
45 pub human_profiles_allowed: bool,
46 pub allow_ibank_profiles: bool,
47}
48
49impl Default for ProfileConfig {
50 fn default() -> Self {
51 Self {
52 default_profile: ResonatorProfile::Coordination,
53 allowed_profiles: vec![
54 ResonatorProfile::Human,
55 ResonatorProfile::World,
56 ResonatorProfile::Coordination,
57 ],
58 human_profiles_allowed: true,
59 allow_ibank_profiles: false,
60 }
61 }
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct PresenceConfig {
67 pub min_signal_interval_ms: u64,
68 pub enable_gradient_updates: bool,
69}
70
71impl Default for PresenceConfig {
72 fn default() -> Self {
73 Self {
74 min_signal_interval_ms: 1000,
75 enable_gradient_updates: true,
76 }
77 }
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct RegistryConfig {
83 pub enable_persistence: bool,
84 pub persistence_path: Option<String>,
85}
86
87impl Default for RegistryConfig {
88 fn default() -> Self {
89 Self {
90 enable_persistence: false,
91 persistence_path: None,
92 }
93 }
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98pub struct InvariantConfig {
99 pub enabled: bool,
100 pub strict_mode: bool,
101}
102
103impl Default for InvariantConfig {
104 fn default() -> Self {
105 Self {
106 enabled: true,
107 strict_mode: true,
108 }
109 }
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct SafetyConfig {
115 pub human_agency_protection: bool,
116 pub commitment_accountability: bool,
117 pub strict_invariants: bool,
118 pub coercion_detection: bool,
119 pub emotional_exploitation_prevention: bool,
120 pub audit_all_commitments: bool,
121 pub risk_bounded_consequences: bool,
122 pub reversibility_preference: ReversibilityPreference,
123}
124
125impl Default for SafetyConfig {
126 fn default() -> Self {
127 Self {
128 human_agency_protection: true,
129 commitment_accountability: true,
130 strict_invariants: true,
131 coercion_detection: false,
132 emotional_exploitation_prevention: false,
133 audit_all_commitments: false,
134 risk_bounded_consequences: false,
135 reversibility_preference: ReversibilityPreference::None,
136 }
137 }
138}
139
140#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
141pub enum ReversibilityPreference {
142 None,
143 PreferReversible,
144 RequireReversible,
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149pub struct SchedulingConfig {
150 pub max_queue_size: usize,
151 pub enable_circuit_breakers: bool,
152 pub circuit_breaker_threshold: u32,
153 pub worker_count: usize,
154}
155
156impl Default for SchedulingConfig {
157 fn default() -> Self {
158 Self {
159 max_queue_size: 10000,
160 enable_circuit_breakers: true,
161 circuit_breaker_threshold: 5,
162 worker_count: 4,
163 }
164 }
165}
166
167#[derive(Debug, Clone, Serialize, Deserialize)]
169pub struct TelemetryConfig {
170 pub enabled: bool,
171 pub metrics_enabled: bool,
172 pub tracing_enabled: bool,
173 pub detailed_metrics: bool,
174}
175
176impl Default for TelemetryConfig {
177 fn default() -> Self {
178 Self {
179 enabled: true,
180 metrics_enabled: true,
181 tracing_enabled: true,
182 detailed_metrics: false,
183 }
184 }
185}
186
187pub fn mapleverse_runtime_config() -> RuntimeConfig {
193 RuntimeConfig {
194 profiles: ProfileConfig {
195 default_profile: ResonatorProfile::Coordination,
196 allowed_profiles: vec![ResonatorProfile::Coordination, ResonatorProfile::World],
197 human_profiles_allowed: false,
199 allow_ibank_profiles: false,
200 },
201 attention: AttentionConfig {
202 default_capacity: 10000,
203 allow_unlimited: false,
204 exhaustion_behavior: ExhaustionBehavior::GracefulDegrade,
205 enable_rebalancing: true,
206 },
207 safety: SafetyConfig {
208 human_agency_protection: false,
210 commitment_accountability: true,
211 strict_invariants: true,
212 coercion_detection: false,
213 emotional_exploitation_prevention: false,
214 audit_all_commitments: false,
215 risk_bounded_consequences: false,
216 reversibility_preference: ReversibilityPreference::None,
217 },
218 ..Default::default()
219 }
220}
221
222pub fn finalverse_runtime_config() -> RuntimeConfig {
224 RuntimeConfig {
225 profiles: ProfileConfig {
226 default_profile: ResonatorProfile::World,
227 allowed_profiles: vec![
228 ResonatorProfile::Human,
229 ResonatorProfile::World,
230 ResonatorProfile::Coordination,
231 ],
232 human_profiles_allowed: true,
233 allow_ibank_profiles: false,
234 },
235 safety: SafetyConfig {
236 human_agency_protection: true,
238 commitment_accountability: true,
239 strict_invariants: true,
240 coercion_detection: true,
242 emotional_exploitation_prevention: true,
243 audit_all_commitments: false,
244 risk_bounded_consequences: true,
245 reversibility_preference: ReversibilityPreference::PreferReversible,
246 },
247 ..Default::default()
248 }
249}
250
251pub fn ibank_runtime_config() -> RuntimeConfig {
253 RuntimeConfig {
254 profiles: ProfileConfig {
255 default_profile: ResonatorProfile::IBank,
256 allowed_profiles: vec![ResonatorProfile::IBank],
257 human_profiles_allowed: false,
259 allow_ibank_profiles: true,
260 },
261 safety: SafetyConfig {
262 human_agency_protection: false, commitment_accountability: true, strict_invariants: true,
265 coercion_detection: false,
266 emotional_exploitation_prevention: false,
267 audit_all_commitments: true,
269 risk_bounded_consequences: true,
270 reversibility_preference: ReversibilityPreference::PreferReversible,
271 },
272 commitment: CommitmentConfig {
273 require_audit_trail: true,
275 require_risk_assessment: true,
276 max_consequence_value: Some(MonetaryValue::new(1_000_000)), allow_revocation: true,
278 require_consent_for_revocation: true,
279 },
280 ..Default::default()
281 }
282}