swarm-engine-core 0.1.6

Core types and orchestration for SwarmEngine
Documentation
//! Validation Module - 学習結果の性能検証
//!
//! Learn Pipeline の **外** で使用される検証機能。
//! Bootstrap 後に検証を行い、基準を満たした場合のみ Active に昇格させる。
//!
//! # 設計思想
//!
//! - **Validator**: 検証を実行する Executor(データ分割 + 評価)
//! - **ValidationStrategy**: 検証基準を定義する trait
//! - **ValidationResult**: 検証結果(Profile に保存される)
//!
//! Profile は ValidationResult を受け取るだけでロジックを持たない。
//! 検証ロジックは全てこのモジュールに分離されている。
//!
//! # ライフサイクル
//!
//! ```text
//! Draft → Bootstrapping → Validating → Active
//!//!                          Failed → (retry) → Draft
//! ```
//!
//! # Example
//!
//! ```
//! use swarm_engine_core::validation::{Validator, NoRegression, Improvement, Absolute};
//!
//! // NoRegression: current >= baseline なら PASS
//! let validator = Validator::<f64>::with_80_20_split(Box::new(NoRegression::new()));
//!
//! // データを用意(例: 成功/失敗のリスト)
//! let data: Vec<f64> = vec![1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
//!
//! let result = validator.validate(
//!     &data,
//!     |train| train.iter().sum::<f64>() / train.len() as f64,  // baseline
//!     |test| test.iter().sum::<f64>() / test.len() as f64,     // current
//! );
//!
//! assert!(result.passed);
//! ```
//!
//! # Strategies
//!
//! | 戦略 | 判定 | ユースケース |
//! |------|------|--------------|
//! | [`NoRegression`] | current >= baseline | 回帰がなければOK(デフォルト) |
//! | [`Improvement`] | current >= baseline × threshold | 明確な改善を要求 |
//! | [`Absolute`] | current >= threshold | ベースラインに関係なく絶対値で判定 |
//!
//! # CLI 連携
//!
//! ```bash
//! # Bootstrap 後に Validating 状態になる
//! swarm profile bootstrap my_profile -n 10
//!
//! # 検証を実行
//! swarm profile validate my_profile -n 5 --strategy no_regression
//!
//! # 検証をスキップして直接 Active にすることも可能
//! swarm profile skip-validation my_profile
//! ```

mod result;
mod strategy;
mod validator;

pub use result::ValidationResult;
pub use strategy::{Absolute, Improvement, NoRegression, ValidationStrategy};
pub use validator::Validator;