use crate::config::ProfileConfig;
use crate::runtime_core::ResonatorSpec;
use crate::types::*;
pub struct ProfileManager {
config: ProfileConfig,
}
impl ProfileManager {
pub fn new(config: &ProfileConfig) -> Self {
Self {
config: config.clone(),
}
}
pub fn validate_spec(&self, spec: &ResonatorSpec) -> Result<(), String> {
if !self.config.allowed_profiles.contains(&spec.profile) {
return Err(format!("Profile {:?} not allowed", spec.profile));
}
if !self.config.human_profiles_allowed && spec.profile.requires_agency_protection() {
return Err("Human profiles not allowed in this configuration".to_string());
}
match spec.profile {
ResonatorProfile::Human => {
if spec.attention.total_capacity == 0 {
return Err("Human profiles require non-zero attention capacity".to_string());
}
}
ResonatorProfile::IBank => {
if !self.config.allow_ibank_profiles {
return Err("IBank profiles not allowed".to_string());
}
}
_ => {}
}
Ok(())
}
pub fn can_couple(&self, profile_a: &ResonatorProfile, profile_b: &ResonatorProfile) -> bool {
profile_a.can_couple_with(profile_b)
}
}