dive_model/symmetry/liveness.rs
1//! Whole-run policy for declarations combined with genuine temporal obligations.
2
3/// How a configured `SYMMETRY` interacts with genuine temporal properties.
4/// The TLC-equivalent request is [`Self::Tlc`]; its quotient checking remains
5/// unsupported. Safety-only roles retain their existing reduction in every mode.
6///
7/// ```
8/// use dive_model::SymmetryLiveness;
9/// assert_eq!(SymmetryLiveness::Unreduced.as_str(), "unreduced");
10/// assert_eq!(SymmetryLiveness::Tlc.as_str(), "tlc");
11/// ```
12#[derive(Clone, Copy, Debug, PartialEq, Eq)]
13pub enum SymmetryLiveness {
14 /// Disable reduction for the entire run that checks temporal properties.
15 Unreduced,
16 /// Refuse the combination before graph capture.
17 Refuse,
18 /// Request TLC's quotient semantics; currently a named refusal.
19 Tlc,
20}
21impl SymmetryLiveness {
22 /// Stable CLI/report spelling.
23 #[must_use]
24 pub const fn as_str(self) -> &'static str {
25 match self {
26 Self::Unreduced => "unreduced",
27 Self::Refuse => "refuse",
28 Self::Tlc => "tlc",
29 }
30 }
31}
32
33/// A policy resolved after successful binding of the actual configured roles.
34/// Presence is not evidence of exploration or completion. The declaration is
35/// retained even when the whole temporal run ignores its reduction.
36///
37/// ```
38/// # fn example(model: &dive_model::Model) {
39/// let policy = model.symmetry_liveness();
40/// if policy.unreduced() {
41/// assert!(policy.declared().is_some());
42/// assert!(policy.genuine_temporal());
43/// assert_eq!(policy.effective(), "unreduced");
44/// }
45/// # }
46/// ```
47#[derive(Clone, Debug, PartialEq, Eq)]
48pub struct SymmetryLivenessResolution {
49 requested: SymmetryLiveness,
50 declared: Option<String>,
51 temporal: bool,
52}
53impl SymmetryLivenessResolution {
54 pub(crate) fn new(
55 requested: SymmetryLiveness,
56 declared: Option<String>,
57 temporal: bool,
58 ) -> Self {
59 Self {
60 requested,
61 declared,
62 temporal,
63 }
64 }
65 /// The requested policy, independent of whether it applies.
66 #[must_use]
67 pub const fn requested(&self) -> SymmetryLiveness {
68 self.requested
69 }
70 /// The original configured declaration, never erased by this policy.
71 #[must_use]
72 pub fn declared(&self) -> Option<&str> {
73 self.declared.as_deref()
74 }
75 /// Whether actual bound roles include at least one temporal property.
76 #[must_use]
77 pub const fn genuine_temporal(&self) -> bool {
78 self.temporal
79 }
80 /// Whether reduction is disabled for the entire temporal check.
81 #[must_use]
82 pub fn unreduced(&self) -> bool {
83 self.declared.is_some() && self.temporal && self.requested == SymmetryLiveness::Unreduced
84 }
85 /// Stable effective policy; `not-applicable` says nothing about safety
86 /// reduction, which is prepared separately by an ordinary safety checker.
87 #[must_use]
88 pub fn effective(&self) -> &'static str {
89 if self.declared.is_none() || !self.temporal {
90 return "not-applicable";
91 }
92 match self.requested {
93 SymmetryLiveness::Unreduced => "unreduced",
94 SymmetryLiveness::Refuse => "refused",
95 SymmetryLiveness::Tlc => "unsupported-tlc-quotient",
96 }
97 }
98}