swarm-engine-core 0.1.6

Core types and orchestration for SwarmEngine
Documentation
//! Termination Module - Single Source of Truth for termination decisions
//!
//! This module centralizes all termination-related logic to prevent:
//! - Race conditions between different completion signals
//! - Scattered termination logic across multiple files
//! - String-based action name checks
//! - Inconsistent multi-worker handling
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │                     TerminationJudge                            │
//! │                  (Single Source of Truth)                       │
//! ├─────────────────────────────────────────────────────────────────┤
//! │  Notifications:              Queries:                           │
//! │  - notify_worker_done()      - should_terminate()               │
//! │  - notify_exploration_complete()  - should_skip_guidance()      │
//! │  - notify_error()            - verdict()                        │
//! │  - request_terminate()       - is_environment_done()            │
//! └─────────────────────────────────────────────────────────────────┘
//!                     │                    ▲
//!                     ▼                    │
//! ┌─────────────────────────────────────────────────────────────────┐
//! │                     CompletionState                             │
//! │  - worker_results: HashMap<WorkerId, WorkerResult>              │
//! │  - exploration_done: bool                                       │
//! │  - environment_done: bool                                       │
//! │  - final_verdict: Option<TerminationVerdict>                    │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```ignore
//! // In Orchestrator::new()
//! let judge = TerminationJudge::new(config, worker_count);
//!
//! // In merge phase (when WorkResult::Done received)
//! if let WorkResult::Done { success, message } = result {
//!     judge.notify_worker_done(worker_id, success, message);
//! }
//!
//! // In exploration phase
//! if space.is_exhausted() {
//!     judge.notify_exploration_complete(true);
//! }
//!
//! // In manager phase
//! if judge.should_skip_guidance() {
//!     return; // Don't generate new guidances
//! }
//!
//! // In main loop
//! if judge.should_terminate() {
//!     let verdict = judge.verdict();
//!     break;
//! }
//! ```

mod config;
mod judge;
mod reason;
mod state;

pub use config::{ExhaustedBehavior, MultiWorkerStrategy, TerminationConfig};
pub use judge::{TerminationJudge, TerminationRequest};
pub use reason::{FailureReason, SuccessReason, TerminationVerdict};
pub use state::{CompletionState, WorkerResult};