Skip to main content

hydr_structures/structures/control/
capabilities.rs

1//! Capability declaration of sampled operating controls.
2
3use super::{OPERATING_CONTROL_CONTRACT_VERSION, OPERATING_CONTROL_SNAPSHOT_SCHEMA};
4use hydr_core::capability::{
5    ArithmeticRequirement, ComponentCapabilities, ComponentId, Limit, Precision, RuntimeKind,
6    RuntimeStatus, RuntimeSupport, Summary, Unsupported, UnsupportedReason,
7};
8
9/// Path of the guide that defines thresholds, samples, qualification and limits.
10const CONTROL_DOC: &str = "docs/operating-controls.md";
11
12const fn unsupported(
13    id: &'static str,
14    reason: UnsupportedReason,
15    summary: &'static str,
16    doc: &'static str,
17) -> Unsupported {
18    Unsupported {
19        id,
20        reason,
21        summary,
22        doc,
23    }
24}
25
26static OPERATING_CONTROL: ComponentCapabilities = ComponentCapabilities {
27    component: ComponentId::OperatingControl,
28    contract: Some(OPERATING_CONTROL_CONTRACT_VERSION),
29    snapshot_schema: Some(OPERATING_CONTROL_SNAPSHOT_SCHEMA),
30    precision: &[Precision::F64],
31    arithmetic: &[
32        ArithmeticRequirement::F64Ieee754Basic,
33        ArithmeticRequirement::NearestEvenGradualUnderflow,
34        ArithmeticRequirement::FusedMulAdd,
35        ArithmeticRequirement::CorrectlyRoundedElementary,
36    ],
37    runtimes: &[
38        RuntimeSupport {
39            runtime: RuntimeKind::Cpu,
40            status: RuntimeStatus::Reference,
41            evidence: "endpoint_commands_apply_to_the_right_interval_only",
42        },
43        RuntimeSupport {
44            runtime: RuntimeKind::Cuda,
45            status: RuntimeStatus::Executed,
46            evidence: "selected_cuda_client_executes_operating_control_relay_and_complete_restart",
47        },
48        RuntimeSupport {
49            runtime: RuntimeKind::Wgpu,
50            status: RuntimeStatus::RejectedLacksF64,
51            evidence: "selected_wgpu_rejects_operating_control_f64_without_fallback",
52        },
53    ],
54    endpoints: &[],
55    regimes: &[],
56    sources: &[],
57    options: &[],
58    nested: &[],
59    attachable_to: &[
60        ComponentId::ControlledGate,
61        ComponentId::ControlledPump,
62        ComponentId::SurfaceChannels,
63    ],
64    unsupported: &[
65        unsupported(
66            "inverted-thresholds",
67            UnsupportedReason::RejectedByAdmission,
68            "A lower stage at or above the upper stage, or a negative delay, rejects.",
69            CONTROL_DOC,
70        ),
71        unsupported(
72            "law-incompatible-command",
73            UnsupportedReason::RejectedByAdmission,
74            "A command outside the controlled device's law, speed policy or opening range rejects.",
75            CONTROL_DOC,
76        ),
77        unsupported(
78            "missing-sample",
79            UnsupportedReason::RejectedByAdmission,
80            "A decision without one ordered sample per controller, or a sample between decisions, rejects.",
81            CONTROL_DOC,
82        ),
83        unsupported(
84            "foreign-sample",
85            UnsupportedReason::RejectedByAdmission,
86            "A sample whose controller, signal, support or datum differs from the declaration rejects.",
87            CONTROL_DOC,
88        ),
89        unsupported(
90            "nonfinite-sample",
91            UnsupportedReason::RejectedByAdmission,
92            "A sample with a nonfinite stage, observation or availability time rejects.",
93            CONTROL_DOC,
94        ),
95        unsupported(
96            "stale-sample",
97            UnsupportedReason::RejectedByAdmission,
98            "A sample observed before its decision rejects; no last-value hold applies.",
99            CONTROL_DOC,
100        ),
101        unsupported(
102            "future-sample",
103            UnsupportedReason::RejectedByAdmission,
104            "A sample observed after its decision, or available after its observation, rejects.",
105            CONTROL_DOC,
106        ),
107        unsupported(
108            "minimum-dwell",
109            UnsupportedReason::OutsideModel,
110            "No minimum on/off dwell.",
111            CONTROL_DOC,
112        ),
113        unsupported(
114            "continuous-event-localization",
115            UnsupportedReason::OutsideModel,
116            "No continuous threshold history or localization of crossings between samples.",
117            CONTROL_DOC,
118        ),
119        unsupported(
120            "rule-grammar-and-pid",
121            UnsupportedReason::OutsideModel,
122            "No generic rule grammar or PID control.",
123            CONTROL_DOC,
124        ),
125        unsupported(
126            "native-swmm-rules",
127            UnsupportedReason::OutsideModel,
128            "No native SWMM rule execution.",
129            CONTROL_DOC,
130        ),
131        unsupported(
132            "device-response",
133            UnsupportedReason::NotAttached,
134            "Commands request operation only; controlled gates and pumps supply actual response.",
135            CONTROL_DOC,
136        ),
137        unsupported(
138            "gpu-numerical-qualification",
139            UnsupportedReason::Unqualified,
140            "CUDA runs execute, but only the CPU reference qualifies numerical accuracy.",
141            CONTROL_DOC,
142        ),
143        unsupported(
144            "measured-event-accuracy",
145            UnsupportedReason::Unqualified,
146            "No measured-event assessment establishes field accuracy.",
147            "docs/acceptance.md",
148        ),
149    ],
150    limits: &[
151        Limit {
152            id: "gate-blocked-range",
153            summary: "A blocked gate admits target commands up to its blocked maximum opening; a larger command rejects, never clamps.",
154            doc: CONTROL_DOC,
155        },
156        Limit {
157            id: "sampled-qualification",
158            summary: "Qualification persists across supplied samples only, never across unobserved excursions.",
159            doc: CONTROL_DOC,
160        },
161        Limit {
162            id: "original-timestamp-timers",
163            summary: "Timers age from original timestamps through TwoSum elapsed time, never repeated interval sums.",
164            doc: CONTROL_DOC,
165        },
166        Limit {
167            id: "simultaneous-update",
168            summary: "All controllers read one original sample batch and update simultaneously.",
169            doc: CONTROL_DOC,
170        },
171    ],
172    summary: Summary {
173        equations: "two-threshold hysteresis relay with high and low qualification delays",
174        method: "sampled decisions on an original calendar, TwoSum timer ages, immutable trials",
175        assessment: "pinned original-bit reference histories; field accuracy remains unestablished",
176    },
177};
178
179/// Returns the sampled operating control's declared scope, independent of application eligibility.
180///
181/// Execution success establishes no field accuracy.
182pub fn operating_control_capabilities() -> &'static ComponentCapabilities {
183    &OPERATING_CONTROL
184}