hydr_structures/structures/control/receipts.rs
1//! Finite original-time witnesses and bounded decision diagnostics.
2
3use super::{ControlCommandOutput, ControlLatch, ControlSample, ControlState};
4
5/// Exact finite two-component elapsed-time expansion.
6#[derive(Clone, Copy, Debug, PartialEq)]
7pub struct ControlTimeExpansion {
8 /// Rounded high component in seconds.
9 pub high_s: f64,
10 /// Exact residual component in seconds.
11 pub low_s: f64,
12}
13/// Original timer operands and checked readiness/lateness witnesses.
14#[derive(Clone, Debug, PartialEq)]
15pub struct ControlTimerWitness {
16 /// Original timer start in seconds.
17 pub started_at_s: f64,
18 /// Original decision time in seconds.
19 pub evaluated_at_s: f64,
20 /// Original directional qualification delay in seconds.
21 pub delay_s: f64,
22 /// Rounded elapsed high in seconds.
23 pub elapsed_high_s: f64,
24 /// Exact elapsed residual in seconds.
25 pub elapsed_low_s: f64,
26 /// Exact elapsed time reaches the original delay.
27 pub ready: bool,
28 /// Exact finite delay-plus-lateness expansion, absent on positive high overflow.
29 pub allowed_elapsed: Option<ControlTimeExpansion>,
30 /// Positive rounded overflow of the allowed elapsed threshold.
31 pub allowed_elapsed_overflow: bool,
32 /// Elapsed time fits the declared lateness allowance.
33 pub within_lateness: bool,
34}
35/// Complete retained last transition without recursive prior-state history.
36#[derive(Clone, Debug, PartialEq)]
37pub struct ControlTransitionReceipt {
38 /// Original scheduled decision index.
39 pub decision_index: usize,
40 /// Original decision time in seconds.
41 pub time_s: f64,
42 /// Prior latch.
43 pub from: ControlLatch,
44 /// Resulting opposing latch.
45 pub to: ControlLatch,
46 /// Original causal observation.
47 pub sample: ControlSample,
48 /// Complete qualification witness.
49 pub timer: ControlTimerWitness,
50}
51/// One simultaneous decision's original before-state and computed after-state.
52#[derive(Clone, Debug, PartialEq)]
53pub struct ControlDecisionReceipt {
54 /// Complete structure-batch index.
55 pub element: usize,
56 /// Original controller identity.
57 pub controller_id: String,
58 /// Complete immediate before-state without a prior-step link.
59 pub before: ControlState,
60 /// Original causal observation.
61 pub sample: ControlSample,
62 /// Current sample meets the opposing threshold.
63 pub qualifies: bool,
64 /// Used qualification timer, absent when the predicate is false.
65 pub timer: Option<ControlTimerWitness>,
66 /// This decision changes the latch.
67 pub transitioned: bool,
68 /// Complete resulting continuation.
69 pub after: ControlState,
70}
71/// Complete last interval diagnostics with bounded retained state.
72#[derive(Clone, Debug, PartialEq)]
73pub struct ControlStepDiagnostics {
74 /// Accepted interval start in seconds.
75 pub start_s: f64,
76 /// Accepted interval end in seconds.
77 pub end_s: f64,
78 /// Original decision index, absent for a non-decision interval.
79 pub decision_index: Option<usize>,
80 /// Commands applying to the interval beginning at its start.
81 pub left_commands: Vec<ControlCommandOutput>,
82 /// Commands applying to the interval beginning at its end.
83 pub right_commands: Vec<ControlCommandOutput>,
84 /// Simultaneous decision receipts, empty without a decision.
85 pub decisions: Vec<ControlDecisionReceipt>,
86}