collet 0.1.1

Relentless agentic coding orchestrator with zero-drop agent loops
Documentation
//! Evolution system — self-improving agent loops via LLM-driven workspace mutation.
//!
//! Ported from A-Evolve's Python framework into idiomatic Rust, integrated
//! with Collet's existing skills, soul, session, and swarm systems.
//!
//! # Architecture
//!
//! The evolution system follows A-Evolve's 7-phase cycle:
//!
//! 1. **Solve** — Agent processes a batch of tasks
//! 2. **Observe** — Collect trajectories + feedback into structured logs
//! 3. **Pre-Snapshot** — Git commit before mutation
//! 4. **Engine Step** — Pluggable algorithm analyzes observations & mutates workspace
//! 5. **Post-Snapshot** — Git commit with tagged version (evo-1, evo-2, …)
//! 6. **Record** — Log cycle metrics and metadata
//! 7. **Reload** — Agent reloads from (possibly mutated) workspace
//!
//! # Key abstractions
//!
//! - [`EvolutionEngine`] — Pluggable mutation strategy (trait)
//! - [`AgentWorkspace`] — Typed filesystem API for prompts/skills/memory/tools
//! - [`EvolutionLoop`] — The orchestrator tying everything together
//! - [`Evolvable`] — Trait bridging Collet's agent to the evolution system
//! - [`BenchmarkAdapter`] — Trait for task sources and evaluation
//!
//! # Example
//!
//! ```rust,ignore
//! use collet::evolution::*;
//!
//! let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
//! let trial = TrialRunner::new(agent, benchmark);
//! let config = EvolveConfig::default();
//! let mut evo_loop = EvolutionLoop::new(workspace_root, trial, config, tx)?;
//! let mut engine = engines::SkillforgeEngine::new(config);
//! let result = evo_loop.run(&mut engine, cancel_token).await?;
//! println!("Final score: {:.3}", result.final_score);
//! ```

pub mod adapter;
pub mod auto;
pub mod benchmarks;
pub mod config;
pub mod egl;
pub mod engine;
pub mod engines;
pub mod history;
pub mod r#loop;
pub mod observer;
pub mod trial;
pub mod types;
pub mod versioning;
pub mod workspace;

// Keep only the types glob re-export (EvolutionEvent variants are used via pattern matching).
pub use types::*;

/// Events emitted from the evolution loop to the TUI/caller.
///
/// Follows Collet's existing `AgentEvent` pattern from `agent/loop.rs`.
#[derive(Debug, Clone)]
pub enum EvolutionEvent {
    /// A new cycle has started.
    CycleStarted { cycle: u32, max_cycles: u32 },
    /// The solve phase has begun.
    SolveStarted { task_count: usize },
    /// The solve phase completed with an average score.
    SolveCompleted { score: f64 },
    /// The evolution engine is analyzing observations.
    EngineStepStarted { engine_name: String },
    /// The engine step completed.
    EngineStepCompleted { mutated: bool, summary: String },
    /// A full cycle completed.
    CycleCompleted {
        cycle: u32,
        score: f64,
        mutated: bool,
    },
    /// Score has converged — evolution is stopping early.
    Converged { cycle: u32, final_score: f64 },
    /// An error occurred.
    // Emitted by the evolution engine on failure; not yet matched by callers.
    Error(String),
    /// Evolution run is complete.
    Done(EvolutionResult),
}