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
//! [`CeremonyOutcome`] — the terminal result of a ceremony run.
//!
//! A ceremony driven to a stop ends in exactly one of these. Unlike a
//! step's [`StepStatus`](super::StepStatus), this names *why the whole
//! ceremony stopped*: it completed, a step failed, no transition could
//! fire, the safety iteration cap was hit, or the instance already
//! existed. Adapter-shaped aborts (persistence/transport errors) are not
//! outcomes — they surface as errors, not as a recorded end-state.
/// How a ceremony run terminated.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CeremonyOutcome {
/// Reached a terminal state — the ceremony finished.
Completed,
/// A step did not complete successfully and aborted the run.
StepFailed,
/// No transition out of the current state was satisfiable (a guard
/// deadlock or a missing event).
NoTransition,
/// The transition safety cap was hit without reaching a terminal
/// state.
IterationLimit,
/// An instance with the same id already existed; the run was rejected.
AlreadyExists,
}
impl CeremonyOutcome {
/// Stable, low-cardinality label value for metrics exposition. Part of
/// the metric contract; dashboards and alerts match on it.
#[must_use]
pub const fn as_label(self) -> &'static str {
match self {
Self::Completed => "completed",
Self::StepFailed => "step_failed",
Self::NoTransition => "no_transition",
Self::IterationLimit => "iteration_limit",
Self::AlreadyExists => "already_exists",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn labels_are_distinct_and_stable() {
let all = [
CeremonyOutcome::Completed,
CeremonyOutcome::StepFailed,
CeremonyOutcome::NoTransition,
CeremonyOutcome::IterationLimit,
CeremonyOutcome::AlreadyExists,
];
let labels: std::collections::BTreeSet<&str> =
all.iter().map(|outcome| outcome.as_label()).collect();
assert_eq!(labels.len(), all.len());
}
}