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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//! Supervision Trees - Structured Fault Tolerance
//!
//! > *"Arbor supervisio est custos infantum"*
//! > — The supervision tree is the guardian of children. (Neo-Latin)
//!
//! This module provides Erlang-style supervision trees for fault-tolerant systems,
//! integrating with the effect system for structured error handling.
//!
//! # Overview
//!
//! Supervision trees provide a hierarchical structure where parent supervisors
//! manage child workers and sub-supervisors. When a child fails, the supervisor
//! applies a restart strategy to recover.
//!
//! # Scholastic Naming
//!
//! | English | Latin | Etymology |
//! |---------|-------|-----------|
//! | Supervision Tree | Arbor | *arbor* = tree |
//! | Child | Infans | *infans* = child, offspring |
//! | Strategy | Strategia | *strategia* = generalship, strategy |
//! | Restart | Restitutio | *restitutio* = restoration |
//! | Failure | Defectio | *defectio* = failure, defection |
//! | Escalate | Escalare | *escalare* = to climb, escalate |
//!
//! # Supervision Strategies
//!
//! - **`UnusProUno`** (One-for-One): Only the failed child is restarted
//! - **`OmnesProUno`** (All-for-One): All children are restarted when one fails
//! - **`ReliquiProUno`** (Rest-for-One): Failed child and all children started after it are restarted
//!
//! # Example
//!
//! Note: this module models supervision *decisions* — there is no executor
//! that spawns or restarts tasks. You describe the tree, then drive it by
//! reporting failures and applying the returned restart actions yourself.
//!
//! ```rust
//! use ordofp_core::supervision::{Arbor, StrategiaSupervisionis, InfansSpec, ActioRestitutio, SupervisioError};
//! use core::time::Duration;
//!
//! let mut supervisor = Arbor::new("root")
//! .with_strategy(StrategiaSupervisionis::unus_pro_uno(3, Duration::from_secs(60)))
//! .add_child(InfansSpec::worker("worker1"))
//! .add_child(InfansSpec::worker("worker2"));
//!
//! // The tree must be initialized before failures can be reported.
//! supervisor.initialize()?;
//!
//! // When child 0 fails at t=now, ask the tree which restart action to take
//! // (the third argument is `normal_exit`, distinguishing a clean exit from
//! // an abnormal one for `ModusRestitutio::Transiens` children):
//! let now_secs = 1_700_000_000u64;
//! let action = supervisor.handle_failure(0, now_secs, false)?;
//! assert_eq!(action, ActioRestitutio::Restituere);
//! # Ok::<(), SupervisioError>(())
//! ```
pub use *;
pub use *;
pub use *;
use String;
// =============================================================================
// Supervision Error
// =============================================================================
/// Error type for supervision operations.
///
/// # Latin Etymology
/// *Defectio* = failure, defection.
/// Result type for supervision operations.
pub type SupervisioResult<T> = ;
// =============================================================================
// Restart Action
// =============================================================================
/// Action to take after a child failure.
///
/// # Latin Etymology
/// *Actio restitutio* = restart action.
// =============================================================================
// Child Status
// =============================================================================
/// Status of a supervised child.
///
/// # Latin Etymology
/// *Status infantis* = child status.
// =============================================================================
// Tests
// =============================================================================