1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! 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);
//! ```
// Keep only the types glob re-export (EvolutionEvent variants are used via pattern matching).
pub use *;
/// Events emitted from the evolution loop to the TUI/caller.
///
/// Follows Collet's existing `AgentEvent` pattern from `agent/loop.rs`.