coalescent 0.1.0

High-level AI coordination patterns enabling intelligent agent coalescence
Documentation
//! # Coalescent
//! 
//! A foundational library for AI collaboration patterns and multi-agent coordination.
//! 
//! Coalescent provides the building blocks for creating emergent AI coordination patterns, 
//! enabling intelligent agents to naturally coalesce around shared objectives through
//! voluntary collaboration rather than rigid hierarchical control.
//! 
//! ## Overview
//! 
//! This library implements proven patterns for AI coordination including:
//! 
//! - **Agent Management**: Dynamic agent registration and capability discovery
//! - **Task Coordination**: Intelligent task decomposition and assignment
//! - **Coalition Formation**: Algorithms for forming optimal agent coalitions
//! - **Trust Networks**: Reputation-based reliability scoring
//! - **Coordination Patterns**: Extensible framework for coordination algorithms
//! 
//! ## Quick Start
//! 
//! ```rust
//! use coalescent::{Agent, Task, CoordinationEngine, Result};
//! 
//! #[tokio::main]
//! async fn main() -> Result<()> {
//!     // Create an agent with capabilities
//!     let agent = Agent::with_capabilities("agent-1", "AI Assistant", vec!["reasoning", "analysis"])?;
//!     
//!     // Create coordination engine
//!     let engine = CoordinationEngine::new();
//!     
//!     // Register agent
//!     engine.register_agent(agent).await?;
//!     
//!     // Create and coordinate around a task
//!     let task = Task::new("Analyze data patterns");
//!     let result = engine.coalesce_around_task(task).await?;
//!     
//!     if let Some(coalition) = result.coalition {
//!         println!("Coalition formed with {} agents", coalition.agents.len());
//!     }
//!     Ok(())
//! }
//! ```
//! 
//! ## Design Philosophy
//! 
//! Coalescent is designed around the principle of **emergent coordination** - rather than
//! imposing rigid hierarchies, it provides mechanisms for agents to naturally organize
//! around shared objectives based on capabilities, trust, and current context.

pub mod agent;
pub mod coordination;
pub mod error;
pub mod patterns;
pub mod task;
pub mod trust;

// Re-export key types for convenience
pub use agent::{Agent, AgentId};
pub use coordination::{Coalition, CoordinationEngine};
pub use error::{CoalescentError, Result};
pub use patterns::{CoordinationPattern, PatternFactory};
pub use task::Task;
pub use trust::{TrustScore, TrustManager};

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_basic_coordination() -> Result<()> {
        let agent = Agent::new("test-agent", "Test Agent")?;
        let engine = CoordinationEngine::new();
        
        engine.register_agent(agent).await?;
        
        let task = Task::new("Test coordination task");
        let _result = engine.coalesce_around_task(task).await?;
        
        Ok(())
    }
    
    #[test]
    fn test_agent_creation() -> Result<()> {
        let agent = Agent::new("test-agent", "Test Agent")?;
        assert_eq!(agent.name, "Test Agent");
        assert!(agent.capabilities.is_empty());
        Ok(())
    }
    
    #[test]
    fn test_agent_with_capabilities() -> Result<()> {
        let capabilities = vec!["reasoning", "analysis"];
        let agent = Agent::with_capabilities("test-id", "Test Agent", capabilities)?;
        assert_eq!(agent.name, "Test Agent");
        assert_eq!(agent.capabilities.len(), 2);
        assert!(agent.has_capability("reasoning"));
        assert!(agent.has_capability("analysis"));
        Ok(())
    }
    
    #[test]
    fn test_task_creation() {
        let task = Task::new("Test task");
        assert_eq!(task.title, "Test task");
        assert_eq!(task.priority, task::Priority::Medium);
    }
    
    #[test]
    fn test_task_with_priority() {
        let task = Task::new("High priority task").priority(task::Priority::High);
        assert_eq!(task.priority, task::Priority::High);
    }
}