Skip to main content

s2_kit/validate/
rules.rs

1//! The rule catalogue.
2//!
3//! One table, from which `cargo xtask render-rules` writes the published catalogue.
4//! Every rule
5//! quotes the sentence it implements, so a disagreement with another implementation can
6//! be settled by reading rather than by arguing.
7//!
8//! **Severity is a judgement about the specification, not about the message.** A rule is
9//! an `Error` when the standard states the requirement plainly, and a `Warning` when the
10//! text is ambiguous, silent, or contradicts itself — with the issue number or the `E`
11//! number in the citation. That is what keeps this crate
12//! from refusing traffic that another conforming implementation is entitled to send.
13
14use super::{RuleId, Severity};
15
16/// One entry of the catalogue.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub struct Rule {
19    /// Its stable identifier, which travels in `ReceptionStatus.diagnostic_label`.
20    pub id: RuleId,
21    /// Whether breaking it makes a message invalid or merely suspect.
22    pub severity: Severity,
23    /// What the rule checks.
24    pub summary: &'static str,
25    /// Where it comes from, quoted where the standard states it.
26    pub source: &'static str,
27    /// Whether the rule needs more than the message in front of it.
28    pub needs_context: bool,
29}
30
31macro_rules! rules {
32    ($(
33        $konst:ident = $id:literal, $severity:ident, $context:literal, $summary:literal, $source:literal;
34    )*) => {
35        $(
36            #[doc = $summary]
37            ///
38            #[doc = $source]
39            pub const $konst: RuleId = RuleId($id);
40        )*
41
42        /// Every rule, in identifier order.
43        pub static RULES: &[Rule] = &[$(
44            Rule {
45                id: RuleId($id),
46                severity: Severity::$severity,
47                summary: $summary,
48                source: $source,
49                needs_context: $context,
50            },
51        )*];
52    };
53}
54
55rules![
56    // --- identifiers and numbers -----------------------------------------
57    DUPLICATE_ID = "S2-ID-001", Error, false,
58        "Identifiers must be unique within the scope the standard names",
59        "`S2J`: \"Must be unique in the scope of the Resource Manager, for at least the duration of the session\", and per actuator for FRBC and DDBC operation modes.";
60    NON_FINITE = "S2-NUM-001", Error, false,
61        "Every number must be finite",
62        "JSON has no spelling for NaN or infinity, so a non-finite value cannot be sent at all.";
63    RANGE_ORDER = "S2-NUM-002", Error, false,
64        "A range's start must not be after its end",
65        "`S2J schemas/PEBC.AllowedLimitRange.range_boundary`: \"The start of the range shall be smaller or equal than the end of the range.\"";
66    RANGE_STRICT_ORDER = "S2-NUM-003", Error, false,
67        "A fill-level band's start must be strictly below its end",
68        "`S2J schemas/FRBC.OperationModeElement.fill_level_range`: \"The start of the NumberRange shall be smaller than the end of the NumberRange.\"";
69    FACTOR_RANGE = "S2-NUM-004", Error, false,
70        "An operation-mode factor must be within [0, 1]",
71        "`S2J`: \"The factor should be greater than or equal to 0 and less or equal to 1.\"";
72
73    // --- message shape ----------------------------------------------------
74    ARRAY_BOUNDS = "S2-MSG-001", Error, false,
75        "An array must respect the schema's minItems and maxItems",
76        "Generated from `schema/s2-json`; the bounds are the schema's own.";
77    DUPLICATE_MESSAGE_ID = "S2-MSG-002", Warning, true,
78        "A message_id should not repeat within a session",
79        "Implied rather than stated: nothing in S2 JSON requires uniqueness, but a repeated id makes reception statuses ambiguous. A warning for that reason.";
80    TIMESTAMP_SKEW = "S2-MSG-003", Warning, true,
81        "A timestamp is further from the local clock than its meaning allows",
82        "No rule in the standard; a peer whose clock is wrong by hours will plan against the wrong quarter hour. Two thresholds, because S2 timestamps mean two things: one that says when something *happened* (`measurement_timestamp`, `transition_timestamp`, `InstructionStatusUpdate.timestamp`) must not be in the future by more than the configured skew tolerance, while one that says when something *will* happen (`valid_from`, `start_time`, `execution_time`) is expected to be in the future and is only remarked on beyond a year. Never an error: two conforming implementations with different clocks must still be able to talk, and nothing is ever reported for a timestamp in the past, which the standard says means \"already\".";
83
84
85    // The three below are raised by the session engines rather than by `Validate`: they
86    // describe how a message *arrived*, which no amount of looking at a decoded message
87    // can tell you. They are rules all the same, because the point of a rule identifier
88    // is that a `diagnostic_label` is greppable across a fleet — and "the frame did not
89    // decode", "the frame carried a property the schema does not define" and "this
90    // device cannot act on it right now" are three different things an operator needs to
91    // be able to count separately.
92    DECODE_FAILED = "S2-MSG-004", Error, false,
93        "The frame could not be decoded into an S2 message",
94        "`S2J schemas/ReceptionStatusValues`: INVALID_DATA is \"Message not understood (e.g. not valid JSON, no message_id found)\" and INVALID_MESSAGE is \"Message was not according to schema\". Which of the two is chosen is `DecodeError::status_value`; this identifier is what carries it into the diagnostic label.";
95    UNKNOWN_PROPERTY = "S2-MSG-005", Warning, false,
96        "A property the schema does not define was removed before decoding",
97        "`S2J` sets `additionalProperties: false` on every object, so a strict endpoint refuses such a message outright. A proxy reading in `Strictness::Lenient` forwards it instead and says what it dropped — a warning, because the proxy is not the party entitled to refuse.";
98    APPLICATION_REFUSED = "S2-MSG-006", Error, false,
99        "The receiving application refused the message through its inbound policy",
100        "`S2J schemas/ReceptionStatusValues`: TEMPORARY_ERROR is \"Receiver encountered an error ... try to send the message again\" and PERMANENT_ERROR \"an error which it cannot recover from\". Neither is a judgement about the message, so no other rule can express it; it is the one status a `Validate` implementation could never choose.";
101
102    ROLE_REQUIRED_FIELD = "S2-MSG-007", Error, false,
103        "A field that is optional in general is mandatory for this sender's role",
104        "`S2J messages/Handshake.supported_protocol_versions`: \"This field is mandatory for the RM, but optional for the CEM.\" The schema cannot express a requirement that depends on another field's value, so it lists the property as optional and says the rest in prose.";
105
106    // --- measurements and forecasts --------------------------------------
107    ONE_VALUE_PER_QUANTITY = "S2-PM-001", Error, false,
108        "At most one value per CommodityQuantity",
109        "`S2J messages/PowerMeasurement.values`: \"at most one item per 'commodity_quantity'\", and the same for every PowerRange and PowerForecastValue array.";
110    PHASE_EXCLUSIVITY = "S2-PM-002", Warning, false,
111        "Per-phase and three-phase-symmetric quantities should not be mixed",
112        "Undocumented; `[s2-json #25]` asks for the exclusivity to be written down (erratum E12). A warning until it is.";
113    PERCENTILE_ORDER = "S2-PM-003", Warning, false,
114        "Confidence bands should be ordered from the lower limit to the upper",
115        "Inferred from the percentile semantics: a 68 % band lies inside a 95 % band. Not stated, so a warning.";
116    MEASUREMENT_NOT_OFFERED = "S2-PM-004", Error, true,
117        "A measurement may only use a quantity the resource said it provides",
118        "`S2J messages/ResourceManagerDetails.provides_power_measurement_types`: \"Array of all CommodityQuantities that this Resource Manager can provide measurements for.\"";
119    FORECAST_NOT_OFFERED = "S2-PM-005", Error, true,
120        "A forecast may only be sent by a resource that said it provides forecasts",
121        "`S2J messages/ResourceManagerDetails.provides_forecast`: \"Indicates whether the ResourceManager is able to provide PowerForecasts.\"";
122
123    // --- resource manager details ----------------------------------------
124    CONTROL_TYPE_NOT_OFFERED = "S2-RMD-001", Error, true,
125        "The CEM may only select a control type the resource offers",
126        "`S2J messages/SelectControlType.control_type`: \"Must be one of the available ControlTypes as defined in the ResourceManagerDetails.\"";
127    CURRENCY_REQUIRED = "S2-RMD-002", Warning, true,
128        "A resource that publishes costs should declare a currency",
129        "`S2J messages/ResourceManagerDetails.currency`: \"Mandatory if cost information is published.\" Not stated is what counts as publishing it: the standard\'s own heat-pump walkthrough sends running_costs and transition_costs of zero while saying \"This heat pump does not define any costs related parameters, so no currency needs to be provided\" (erratum E17). Refusing that example would make this crate stricter than the documentation it implements, so it is a warning.";
130    DUPLICATE_ROLE = "S2-RMD-003", Warning, false,
131        "A resource should declare one role per commodity",
132        "Not stated. Two roles for the same commodity leave a CEM with no way to choose between them.";
133    NO_SELECTION_OFFERED = "S2-RMD-004", Warning, false,
134        "NO_SELECTION is not something a resource can offer",
135        "`S2J schemas/ControlType`: NO_SELECTION is \"to be used if no control type is or has been selected\" — a state, not a capability.";
136
137    // --- session state ----------------------------------------------------
138    NOT_ALLOWED_IN_STATE = "S2-STATE-001", Error, true,
139        "The message is not allowed in the session's current state",
140        "`S2C §State of communication`, the normative table of what may be sent when.";
141    NOT_ALLOWED_FOR_ROLE = "S2-STATE-002", Error, true,
142        "The message is not allowed from this role",
143        "`S2C §State of communication`: the table has a column per role.";
144    HANDSHAKE_UNDER_CONNECT = "S2-STATE-003", Warning, true,
145        "Handshake messages are redundant under S2 Connect",
146        "`S2C §Communication - JSON messages`: \"the Handshake and HandshakeResponse messages can not be sent. They are redundant by the pairing and session initiation process.\"";
147
148    // --- actuator descriptions --------------------------------------------
149    // Both FRBC and DDBC describe actuators with a `supported_commodities` list, so
150    // these are one pair of rules rather than two.
151    COMMODITY_WITHOUT_POWER_RANGE = "S2-ACT-001", Warning, false,
152        "Every operation mode should publish a power range for each commodity the actuator supports",
153        "The schema does not require it, but `s2-python` — the reference implementation — refuses an FRBC.ActuatorDescription whose operation mode elements do not cover every entry of `supported_commodities`, so a message without them will not reach a peer built on it. A warning rather than an error because this crate refuses only what the standard refuses; the point of the rule is that the gap is worth seeing before a field trial finds it.";
154    DUPLICATE_SUPPORTED_COMMODITY = "S2-ACT-002", Warning, false,
155        "An actuator should list each supported commodity once",
156        "The schema bounds the array at four but does not say the items are distinct. `s2-python` rejects a repeat; a duplicate carries no information either way, so this crate reports rather than refuses.";
157
158    // --- operation mode statuses ------------------------------------------
159    PREVIOUS_MODE_MISSING = "S2-STATUS-001", Warning, true,
160        "A status after the first for the same actuator should name the previous mode",
161        "`S2J messages/FRBC.ActuatorStatus.previous_operation_mode_id`: \"This value shall always be provided, unless the active FRBC.OperationMode is the first FRBC.OperationMode the Resource Manager is aware of.\" OMBC.Status and DDBC.ActuatorStatus carry the same field with the same sentence, so this is one rule rather than three — and \"the first the Resource Manager is aware of\" is per actuator, not per session.";
162
163    // --- instructions -----------------------------------------------------
164    DUPLICATE_INSTRUCTION_ID = "S2-INST-001", Error, true,
165        "An instruction identifier must not be reused within a session",
166        "`S2J`: \"Must be unique in the scope of the Resource Manager, for at least the duration of the session between Resource Manager and CEM.\"";
167    UNKNOWN_INSTRUCTION = "S2-INST-002", Error, true,
168        "An InstructionStatusUpdate must name an instruction that was sent",
169        "`S2J messages/InstructionStatusUpdate.instruction_id`: \"ID of this instruction (as provided by the CEM)\".";
170    STATUS_REGRESSION = "S2-INST-003", Warning, true,
171        "An instruction's status should not move backwards",
172        "The order statuses may take is undocumented (`[s2-json #26]`, erratum E11), so going from SUCCEEDED back to STARTED is a warning rather than an error.";
173    ABNORMAL_ONLY = "S2-INST-004", Error, true,
174        "An abnormal-condition-only mode, transition or range needs abnormal_condition",
175        "`S2J`: \"Indicates if this ... may only be used during an abnormal condition.\"";
176    BLOCKED_BY_TIMER = "S2-INST-005", Warning, true,
177        "The instructed transition is blocked by a timer that has not finished",
178        "`S2J schemas/Transition.blocking_timers`: \"List of IDs of Timers that block this Transition from initiating while at least one of these Timers is not yet finished.\" A warning because the CEM's view of a timer is always slightly stale.";
179    NO_SUCH_TRANSITION = "S2-INST-006", Warning, true,
180        "No transition is described from the active operation mode to the instructed one",
181        "the S2 documentation, *Operation modes*: \"a RM can activate another Operation Mode without the CEM requesting it, and it is even allowed to activate an Operation Mode even if there is no transition\" — so this is advice, not a refusal.";
182
183    // --- revocation -------------------------------------------------------
184    REVOKE_ROLE_MISMATCH = "S2-REV-001", Warning, true,
185        "The revoked object type is not one this sender owns",
186        "`S2C §State of communication` lists RevokeObject only for the RM, while `S2J schemas/RevokableObjects` contains every instruction type, which only a CEM sends (erratum E6).";
187    REVOKE_UNKNOWN = "S2-REV-002", Warning, true,
188        "The revoked object was never published on this session",
189        "Not stated. Revoking something the peer never saw is harmless but almost always a bug.";
190
191    // --- FRBC -------------------------------------------------------------
192    FRBC_ELEMENTS_CONTIGUOUS = "S2-FRBC-001", Error, false,
193        "An operation mode's fill-level bands must be contiguous",
194        "`S2J schemas/FRBC.OperationMode.elements`: \"The fill_level_ranges of the items in the Array must be contiguous.\"";
195    FRBC_LEAKAGE_CONTIGUOUS = "S2-FRBC-002", Error, false,
196        "Leakage bands must be contiguous",
197        "`S2J messages/FRBC.LeakageBehaviour.elements`: \"The fill_level_ranges of the elements must be contiguous.\"";
198    FRBC_UNKNOWN_ACTUATOR = "S2-FRBC-003", Error, true,
199        "An instruction must name an actuator the system description declares",
200        "`S2J messages/FRBC.Instruction.actuator_id`: \"ID of the actuator this instruction belongs to.\"";
201    FRBC_UNKNOWN_MODE = "S2-FRBC-004", Error, true,
202        "An instruction must name an operation mode that actuator has",
203        "`S2J messages/FRBC.Instruction.operation_mode`: \"ID of the FRBC.OperationMode that should be activated.\"";
204    FRBC_TRANSITION_REFERENCES = "S2-FRBC-005", Error, false,
205        "A transition must name operation modes and timers of its own actuator",
206        "`S2J schemas/Transition`: the ids are \"unique in the scope of the ... FRBC.ActuatorDescription in which it is used\".";
207    FRBC_NOT_OFFERED = "S2-FRBC-006", Error, true,
208        "Leakage, usage forecast and target profile may only be sent if the storage offers them",
209        "`S2J schemas/FRBC.StorageDescription`: the three `provides_*` flags.";
210    FRBC_FILL_LEVEL_OUT_OF_RANGE = "S2-FRBC-007", Warning, true,
211        "The reported fill level is outside the range the storage described",
212        "`S2J schemas/FRBC.StorageDescription.fill_level_range`: \"When the fill_level is not within this range, the Resource Manager can ignore instructions from the CEM.\" Reported so a CEM knows why it is being ignored.";
213
214    // --- PEBC -------------------------------------------------------------
215    PEBC_BOTH_LIMITS = "S2-PEBC-001", Error, false,
216        "Power constraints need at least one upper and one lower allowed range",
217        "`S2J messages/PEBC.PowerConstraints.allowed_limit_ranges`: \"There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT and at least one AllowedLimitRange for the LOWER_LIMIT.\"";
218    PEBC_VALIDITY_WINDOW = "S2-PEBC-002", Error, false,
219        "valid_from must precede valid_until",
220        "`S2J messages/PEBC.PowerConstraints`: a window that ends before it starts is never in force.";
221    PEBC_ENVELOPE_LIMIT_ORDER = "S2-PEBC-003", Error, false,
222        "An envelope element's lower limit must not exceed its upper limit",
223        "`S2J schemas/PEBC.PowerEnvelopeElement.upper_limit`: \"The lower_limit must be smaller or equal to the upper_limit.\"";
224    PEBC_ONE_ENVELOPE_PER_QUANTITY = "S2-PEBC-004", Error, false,
225        "At most one envelope per CommodityQuantity",
226        "`S2J messages/PEBC.Instruction.power_envelopes`: \"at most one PEBC.PowerEnvelope for each CommodityQuantity.\"";
227    PEBC_UNKNOWN_CONSTRAINTS = "S2-PEBC-005", Error, true,
228        "An instruction must reference power constraints that are published and in force",
229        "`S2J messages/PEBC.Instruction.power_constraints_id`: \"Identifier of the PEBC.PowerConstraints this PEBC.Instruction was based on.\"";
230    PEBC_OUTSIDE_ALLOWED = "S2-PEBC-006", Error, true,
231        "An envelope limit must lie within an allowed range for its quantity",
232        "`S2J schemas/PEBC.PowerEnvelopeElement.upper_limit`: \"shall be in accordance with the constraints provided by the Resource Manager through any PEBC.AllowedLimitRange with limit_type UPPER_LIMIT.\"";
233    PEBC_ENERGY_ORDER = "S2-PEBC-007", Error, false,
234        "The lower average power must not exceed the upper",
235        "`S2J messages/PEBC.EnergyConstraint`: the description of `lower_average_power` repeats the line above it by mistake and says \"greater than or equal to lower_average_power\"; it means at most `upper_average_power` (erratum E3).";
236
237    // --- PPBC -------------------------------------------------------------
238    PPBC_WINDOW = "S2-PPBC-001", Error, false,
239        "A profile's start must not be after its end",
240        "`S2J messages/PPBC.PowerProfileDefinition`: `start_time` is \"the first possible time the first PPBC.PowerSequence could start\" and `end_time` when the last \"shall be finished at the latest\".";
241    PPBC_UNKNOWN_SEQUENCE = "S2-PPBC-002", Error, true,
242        "An instruction must resolve profile, container and sequence together",
243        "`S2J messages/PPBC.ScheduleInstruction`: the three ids name a profile, a container within it, and a sequence within that.";
244    PPBC_NOT_INTERRUPTIBLE = "S2-PPBC-003", Error, true,
245        "Only a sequence that says it is interruptible may be interrupted",
246        "`S2J schemas/PPBC.PowerSequence.is_interruptible`: \"Indicates whether the option of pausing a sequence is available.\"";
247    PPBC_STATUS_COVERAGE = "S2-PPBC-004", Error, true,
248        "A profile status must cover every container of the profile",
249        "`S2J messages/PPBC.PowerProfileStatus.sequence_container_status`: \"Array with status information for all PPBC.PowerSequenceContainers in the PPBC.PowerProfileDefinition.\"";
250    PPBC_PROGRESS = "S2-PPBC-005", Error, false,
251        "Progress must be present exactly when a sequence has been selected and started",
252        "`S2J schemas/PPBC.PowerSequenceContainerStatus.progress`: \"A value must be provided, unless no sequence has been selected or the selected sequence hasn't started yet.\"";
253    PPBC_WINDOW_TOO_SHORT = "S2-PPBC-006", Warning, false,
254        "The window is shorter than the shortest sequence offered",
255        "Implied by the two together: a task that cannot finish inside its own window is one no CEM can schedule.";
256
257    // --- OMBC -------------------------------------------------------------
258    OMBC_UNKNOWN_MODE = "S2-OMBC-001", Error, true,
259        "An instruction must name an operation mode the system description declares",
260        "`S2J messages/OMBC.Instruction.operation_mode_id`: \"ID of the OMBC.OperationMode that should be activated.\"";
261    OMBC_TRANSITION_REFERENCES = "S2-OMBC-002", Error, false,
262        "A transition must name operation modes and timers of its own description",
263        "`S2J schemas/Transition`: the ids are \"unique in the scope of the OMBC.SystemDescription ... in which it is used\".";
264
265    // --- DDBC -------------------------------------------------------------
266    DDBC_UNKNOWN_ACTUATOR = "S2-DDBC-001", Error, true,
267        "An instruction must name an actuator the system description declares",
268        "`S2J messages/DDBC.Instruction.actuator_id`: \"ID of the actuator this Instruction belongs to.\"";
269    DDBC_UNKNOWN_MODE = "S2-DDBC-002", Error, true,
270        "An instruction must name an operation mode that actuator has",
271        "`S2J messages/DDBC.Instruction.operation_mode_id`: \"ID of the DDBC.OperationMode\".";
272    DDBC_TRANSITION_REFERENCES = "S2-DDBC-003", Error, false,
273        "A transition must name operation modes and timers of its own actuator",
274        "`S2J schemas/Transition`: the ids are \"unique in the scope of the ... DDBC.ActuatorDescription in which it is used\".";
275    DDBC_FORECAST_NOT_OFFERED = "S2-DDBC-004", Error, true,
276        "A demand forecast may only be sent if the system description offers one",
277        "`S2J messages/DDBC.SystemDescription.provides_average_demand_rate_forecast`: \"Indicates whether the Resource Manager could provide a demand rate forecast.\"";
278];
279
280impl Rule {
281    /// The rule with this identifier.
282    #[must_use]
283    pub fn find(id: RuleId) -> Option<&'static Rule> {
284        RULES.iter().find(|r| r.id == id)
285    }
286}
287
288#[cfg(test)]
289mod tests {
290    use super::*;
291    use alloc::vec::Vec;
292
293    #[test]
294    fn identifiers_are_unique_and_well_formed() {
295        let mut ids: Vec<&str> = RULES.iter().map(|r| r.id.as_str()).collect();
296        let count = ids.len();
297        ids.sort_unstable();
298        ids.dedup();
299        assert_eq!(ids.len(), count, "duplicate rule identifier");
300
301        for rule in RULES {
302            let id = rule.id.as_str();
303            let mut parts = id.split('-');
304            assert_eq!(parts.next(), Some("S2"), "{id}");
305            let area = parts.next().unwrap_or_default();
306            assert!(
307                !area.is_empty() && area.chars().all(char::is_uppercase),
308                "{id}"
309            );
310            let number = parts.next().unwrap_or_default();
311            assert_eq!(number.len(), 3, "{id} should end in three digits");
312            assert!(number.chars().all(|c| c.is_ascii_digit()), "{id}");
313            assert_eq!(parts.next(), None, "{id}");
314        }
315    }
316
317    #[test]
318    fn the_table_really_is_in_identifier_order() {
319        // The doc comment on `RULES` says so, the rendered catalogue inherits the order,
320        // and a reader looking for `S2-MSG-005` should find it between 004 and 006.
321        let mut previous: Option<(&str, u32)> = None;
322        for rule in RULES {
323            let id = rule.id.as_str();
324            let mut parts = id.split('-').skip(1);
325            let area = parts.next().unwrap_or_default();
326            let number: u32 = parts.next().unwrap_or_default().parse().unwrap_or(0);
327            if let Some((previous_area, previous_number)) = previous
328                && previous_area == area
329            {
330                assert!(
331                    number > previous_number,
332                    "{id} follows S2-{previous_area}-{previous_number:03}"
333                );
334            }
335            previous = Some((area, number));
336        }
337    }
338
339    #[test]
340    fn every_rule_cites_a_source_and_says_what_it_checks() {
341        for rule in RULES {
342            assert!(rule.summary.len() > 20, "{} has no summary", rule.id);
343            assert!(rule.source.len() > 30, "{} has no citation", rule.id);
344        }
345    }
346
347    #[test]
348    fn ambiguity_is_a_warning_and_a_plain_requirement_is_an_error() {
349        // The rules that exist because the standard is unclear must not refuse traffic.
350        for rule in RULES {
351            let cites_ambiguity = rule.source.contains("Not stated")
352                || rule.source.contains("not stated")
353                || rule.source.contains("Undocumented")
354                || rule.source.contains("undocumented")
355                || rule.source.contains("Inferred")
356                || rule.source.contains("Implied");
357            if cites_ambiguity {
358                assert_eq!(
359                    rule.severity,
360                    Severity::Warning,
361                    "{} rests on an ambiguity and must not be an error",
362                    rule.id
363                );
364            }
365        }
366    }
367
368    #[test]
369    fn lookup_works() {
370        assert_eq!(Rule::find(FRBC_UNKNOWN_MODE).unwrap().id, FRBC_UNKNOWN_MODE);
371        assert!(Rule::find(RuleId("S2-NOPE-001")).is_none());
372    }
373}