use async_trait::async_trait;
use crate::types::{
Intelligence, IntelligenceId, IntelligenceStatus,
Memory, MemoryId, MemoryTier, MemoryQuery,
TemporalLoop, LoopId, LoopType, LoopCycle, CycleInput, CycleOutput,
Capability, Architecture,
};
use std::error::Error;
#[async_trait]
pub trait IntelligenceManager: Send + Sync {
async fn create_intelligence(
&mut self,
name: String,
architecture: Architecture,
) -> Result<Intelligence, Box<dyn Error>>;
async fn get_intelligence(
&self,
id: &IntelligenceId,
) -> Result<Option<Intelligence>, Box<dyn Error>>;
async fn update_status(
&mut self,
id: &IntelligenceId,
status: IntelligenceStatus,
) -> Result<(), Box<dyn Error>>;
async fn add_capability(
&mut self,
id: &IntelligenceId,
capability: Capability,
) -> Result<(), Box<dyn Error>>;
async fn list_intelligences(&self) -> Result<Vec<Intelligence>, Box<dyn Error>>;
async fn delete_intelligence(&mut self, id: &IntelligenceId) -> Result<(), Box<dyn Error>>;
}
#[async_trait]
pub trait MemoryManager: Send + Sync {
async fn store_memory(&mut self, memory: Memory) -> Result<MemoryId, Box<dyn Error>>;
async fn get_memory(&self, id: &MemoryId) -> Result<Option<Memory>, Box<dyn Error>>;
async fn query_memories(&self, query: MemoryQuery) -> Result<Vec<Memory>, Box<dyn Error>>;
async fn update_memory(&mut self, id: &MemoryId, memory: Memory)
-> Result<(), Box<dyn Error>>;
async fn delete_memory(&mut self, id: &MemoryId) -> Result<(), Box<dyn Error>>;
async fn consolidate_memories(
&mut self,
from_tier: MemoryTier,
to_tier: MemoryTier,
) -> Result<usize, Box<dyn Error>>;
async fn prune_expired(&mut self) -> Result<usize, Box<dyn Error>>;
async fn get_tier_stats(&self, tier: MemoryTier) -> Result<MemoryTierStats, Box<dyn Error>>;
}
#[derive(Debug, Clone)]
pub struct MemoryTierStats {
pub tier: MemoryTier,
pub total_memories: usize,
pub total_size_bytes: usize,
pub average_importance: f64,
pub average_confidence: f64,
pub oldest_memory: Option<String>,
pub newest_memory: Option<String>,
}
#[async_trait]
pub trait LoopManager: Send + Sync {
async fn create_loop(
&mut self,
loop_type: LoopType,
name: String,
description: String,
) -> Result<TemporalLoop, Box<dyn Error>>;
async fn get_loop(&self, id: &LoopId) -> Result<Option<TemporalLoop>, Box<dyn Error>>;
async fn start_cycle(
&mut self,
loop_id: &LoopId,
input: CycleInput,
) -> Result<String, Box<dyn Error>>;
async fn complete_cycle(
&mut self,
loop_id: &LoopId,
output: CycleOutput,
) -> Result<(), Box<dyn Error>>;
async fn get_current_cycle(
&self,
loop_id: &LoopId,
) -> Result<Option<LoopCycle>, Box<dyn Error>>;
async fn get_loop_history(
&self,
loop_id: &LoopId,
limit: Option<usize>,
) -> Result<Vec<LoopCycle>, Box<dyn Error>>;
async fn list_loops(&self) -> Result<Vec<TemporalLoop>, Box<dyn Error>>;
async fn delete_loop(&mut self, id: &LoopId) -> Result<(), Box<dyn Error>>;
}
#[async_trait]
pub trait EvolutionEngine: Send + Sync {
async fn evaluate_fitness(&self, intelligence: &Intelligence) -> Result<f64, Box<dyn Error>>;
async fn generate_variations(
&self,
architecture: &Architecture,
count: usize,
) -> Result<Vec<Architecture>, Box<dyn Error>>;
async fn select_best(
&self,
population: Vec<Intelligence>,
count: usize,
) -> Result<Vec<Intelligence>, Box<dyn Error>>;
async fn crossover(
&self,
parent1: &Architecture,
parent2: &Architecture,
) -> Result<Architecture, Box<dyn Error>>;
async fn mutate(&self, architecture: &Architecture) -> Result<Architecture, Box<dyn Error>>;
}
#[async_trait]
pub trait CapabilityDiscovery: Send + Sync {
async fn discover_capabilities(&self) -> Result<Vec<Capability>, Box<dyn Error>>;
async fn is_compatible(
&self,
capability: &Capability,
architecture: &Architecture,
) -> Result<bool, Box<dyn Error>>;
async fn integrate_capability(
&mut self,
intelligence_id: &IntelligenceId,
capability: Capability,
) -> Result<(), Box<dyn Error>>;
async fn remove_capability(
&mut self,
intelligence_id: &IntelligenceId,
capability_id: &str,
) -> Result<(), Box<dyn Error>>;
}