maple_runtime/runtime_core/
profile_manager.rs1use crate::config::ProfileConfig;
4use crate::runtime_core::ResonatorSpec;
5use crate::types::*;
6
7pub struct ProfileManager {
9 config: ProfileConfig,
10}
11
12impl ProfileManager {
13 pub fn new(config: &ProfileConfig) -> Self {
14 Self {
15 config: config.clone(),
16 }
17 }
18
19 pub fn validate_spec(&self, spec: &ResonatorSpec) -> Result<(), String> {
21 if !self.config.allowed_profiles.contains(&spec.profile) {
23 return Err(format!("Profile {:?} not allowed", spec.profile));
24 }
25
26 if !self.config.human_profiles_allowed && spec.profile.requires_agency_protection() {
28 return Err("Human profiles not allowed in this configuration".to_string());
29 }
30
31 match spec.profile {
33 ResonatorProfile::Human => {
34 if spec.attention.total_capacity == 0 {
36 return Err("Human profiles require non-zero attention capacity".to_string());
37 }
38 }
39 ResonatorProfile::IBank => {
40 if !self.config.allow_ibank_profiles {
42 return Err("IBank profiles not allowed".to_string());
43 }
44 }
45 _ => {}
46 }
47
48 Ok(())
49 }
50
51 pub fn can_couple(&self, profile_a: &ResonatorProfile, profile_b: &ResonatorProfile) -> bool {
53 profile_a.can_couple_with(profile_b)
54 }
55}