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
//! 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;
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;