Rule catalogue
All 65 semantic validation rules s2-kit enforces on S2 messages — 45 errors and 20 warnings, each quoting the sentence of the standard it implements.
This page is generated from the crate itself, so it cannot disagree with the code.
Generated from s2_kit::validate::rules::RULES — do not edit.
Every rule quotes the sentence it implements. An error is a requirement the standard states plainly; a warning is one it leaves ambiguous, silent or self-contradictory, and never refuses traffic. The identifier travels in the diagnostic_label of every failing ReceptionStatus this crate sends.
65 rules: 45 errors, 20 warnings.
| Rule | Severity | Needs session | Checks | Source |
|---|---|---|---|---|
S2-ID-001 | error | no | Identifiers must be unique within the scope the standard names | 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. |
S2-NUM-001 | error | no | Every number must be finite | JSON has no spelling for NaN or infinity, so a non-finite value cannot be sent at all. |
S2-NUM-002 | error | no | A range’s start must not be after its end | S2J schemas/PEBC.AllowedLimitRange.range_boundary: “The start of the range shall be smaller or equal than the end of the range.” |
S2-NUM-003 | error | no | A fill-level band’s start must be strictly below its end | S2J schemas/FRBC.OperationModeElement.fill_level_range: “The start of the NumberRange shall be smaller than the end of the NumberRange.” |
S2-NUM-004 | error | no | An operation-mode factor must be within [0, 1] | S2J: “The factor should be greater than or equal to 0 and less or equal to 1.” |
S2-MSG-001 | error | no | An array must respect the schema’s minItems and maxItems | Generated from schema/s2-json; the bounds are the schema’s own. |
S2-MSG-002 | warning | yes | A message_id should not repeat within a session | Implied rather than stated: nothing in S2 JSON requires uniqueness, but a repeated id makes reception statuses ambiguous. A warning for that reason. |
S2-MSG-003 | warning | yes | A timestamp is further from the local clock than its meaning allows | 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”. |
S2-MSG-004 | error | no | The frame could not be decoded into an S2 message | 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. |
S2-MSG-005 | warning | no | A property the schema does not define was removed before decoding | 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. |
S2-MSG-006 | error | no | The receiving application refused the message through its inbound policy | 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. |
S2-MSG-007 | error | no | A field that is optional in general is mandatory for this sender’s role | 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. |
S2-MSG-008 | error | yes | A field must be present exactly when the negotiated wire profile defines it | S2C §Versioning of JSON Schema files: the negotiated version selects which schema the messages are read against, and the two tagged versions of S2 JSON differ in one field — DDBC.SystemDescription.present_demand_rate is required in v0.0.2-beta and was removed in v1.0.0, where DDBC.PresentDemandStatus carries it instead (erratum E13). The decoder already refuses the wrong shape on the way in; this is the same rule applied on the way out, so an endpoint learns at the call site rather than from the peer’s INVALID_MESSAGE. |
S2-PM-001 | error | no | At most one value per CommodityQuantity | S2J messages/PowerMeasurement.values: “at most one item per ‘commodity_quantity’”, and the same for every PowerRange and PowerForecastValue array. |
S2-PM-002 | warning | no | Per-phase and three-phase-symmetric quantities should not be mixed | Undocumented; [s2-json #25] asks for the exclusivity to be written down (erratum E12). A warning until it is. |
S2-PM-003 | warning | no | Confidence bands should be ordered from the lower limit to the upper | Inferred from the percentile semantics: a 68 % band lies inside a 95 % band. Not stated, so a warning. |
S2-PM-004 | error | yes | A measurement may only use a quantity the resource said it provides | S2J messages/ResourceManagerDetails.provides_power_measurement_types: “Array of all CommodityQuantities that this Resource Manager can provide measurements for.” |
S2-PM-005 | error | yes | A forecast may only be sent by a resource that said it provides forecasts | S2J messages/ResourceManagerDetails.provides_forecast: “Indicates whether the ResourceManager is able to provide PowerForecasts.” |
S2-RMD-001 | error | yes | The CEM may only select a control type the resource offers | S2J messages/SelectControlType.control_type: “Must be one of the available ControlTypes as defined in the ResourceManagerDetails.” |
S2-RMD-002 | warning | yes | A resource that publishes costs should declare a currency | 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. |
S2-RMD-003 | warning | no | A resource should declare each role once per commodity | S2J messages/ResourceManagerDetails.roles is “one or more energy Roles” bounded at maxItems: 3 — exactly the number of RoleType values, while Commodity has four. A cap of three cannot be counting commodities, so it is counting role types, and a battery that is storage, load and generator for electricity is saying so in the only way the schema allows (erratum E30). What this rule reports is therefore the narrow case the schema still cannot express: the same (role, commodity) pair twice, which carries no information either way. A warning rather than an error, for the same reason as S2-ACT-002 — the schema does not say the items are distinct. |
S2-RMD-004 | warning | no | NO_SELECTION is not something a resource can offer | S2J schemas/ControlType: NO_SELECTION is “to be used if no control type is or has been selected” — a state, not a capability. |
S2-STATE-001 | error | yes | The message is not allowed in the session’s current state | S2C §State of communication, the normative table of what may be sent when. |
S2-STATE-002 | error | yes | The message is not allowed from this role | S2C §State of communication: the table has a column per role. |
S2-STATE-003 | warning | yes | Handshake messages are redundant under S2 Connect | S2C §Communication - JSON messages: “the Handshake and HandshakeResponse messages can not be sent. They are redundant by the pairing and session initiation process.” |
S2-ACT-001 | warning | no | Every operation mode should publish a power range for each commodity the actuator supports | 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. |
S2-ACT-002 | warning | no | An actuator should list each supported commodity once | 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. |
S2-STATUS-001 | warning | yes | A status after the first for the same actuator should name the previous mode | 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. |
S2-STATUS-002 | error | yes | A timer status must name a timer the description declares | S2J schemas/Timer.id: an identifier is “unique in the scope of the OMBC.SystemDescription, FRBC.ActuatorDescription or DDBC.ActuatorDescription in which it is used”, so a *.TimerStatus naming a timer no description declares refers to nothing. Its own identifier rather than the transition rule’s, because a diagnostic_label is worth having only if one identifier means one condition (D28) — and “this transition points at a timer that does not exist” and “you are reporting on a timer that does not exist” are two conditions an operator counts separately. |
S2-INST-001 | error | yes | An instruction identifier must not be reused within a session | S2J: “Must be unique in the scope of the Resource Manager, for at least the duration of the session between Resource Manager and CEM.” |
S2-INST-002 | error | yes | An InstructionStatusUpdate must name an instruction that was sent | S2J messages/InstructionStatusUpdate.instruction_id: “ID of this instruction (as provided by the CEM)”. |
S2-INST-003 | warning | yes | An instruction’s status should not move backwards | 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. |
S2-INST-004 | error | yes | An abnormal-condition-only mode, transition or range needs abnormal_condition | S2J: “Indicates if this … may only be used during an abnormal condition.” |
S2-INST-005 | warning | yes | The instructed transition is blocked by a timer that has not finished | 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. |
S2-INST-006 | warning | yes | No transition is described from the active operation mode to the instructed one | 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. |
S2-REV-001 | warning | yes | The revoked object type is not one this sender owns | 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). |
S2-REV-002 | warning | yes | The revoked object was never published on this session | Not stated. Revoking something the peer never saw is harmless but almost always a bug. |
S2-FRBC-001 | error | no | An operation mode’s fill-level bands must be contiguous | S2J schemas/FRBC.OperationMode.elements: “The fill_level_ranges of the items in the Array must be contiguous.” |
S2-FRBC-002 | error | no | Leakage bands must be contiguous | S2J messages/FRBC.LeakageBehaviour.elements: “The fill_level_ranges of the elements must be contiguous.” |
S2-FRBC-003 | error | yes | An instruction must name an actuator the system description declares | S2J messages/FRBC.Instruction.actuator_id: “ID of the actuator this instruction belongs to.” |
S2-FRBC-004 | error | yes | An instruction must name an operation mode that actuator has | S2J messages/FRBC.Instruction.operation_mode: “ID of the FRBC.OperationMode that should be activated.” |
S2-FRBC-005 | error | no | A transition must name operation modes and timers of its own actuator | S2J schemas/Transition: the ids are “unique in the scope of the … FRBC.ActuatorDescription in which it is used”. |
S2-FRBC-006 | error | yes | Leakage, usage forecast and target profile may only be sent if the storage offers them | S2J schemas/FRBC.StorageDescription: the three provides_* flags. |
S2-FRBC-007 | warning | yes | The reported fill level is outside the range the storage described | 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. |
S2-PEBC-001 | error | no | Power constraints need at least one upper and one lower allowed range | 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.” |
S2-PEBC-002 | error | no | valid_from must precede valid_until | S2J messages/PEBC.PowerConstraints: a window that ends before it starts is never in force. |
S2-PEBC-003 | error | no | An envelope element’s lower limit must not exceed its upper limit | S2J schemas/PEBC.PowerEnvelopeElement.upper_limit: “The lower_limit must be smaller or equal to the upper_limit.” |
S2-PEBC-004 | error | no | At most one envelope per CommodityQuantity | S2J messages/PEBC.Instruction.power_envelopes: “at most one PEBC.PowerEnvelope for each CommodityQuantity.” |
S2-PEBC-005 | error | yes | An instruction must reference power constraints that are published and in force | S2J messages/PEBC.Instruction.power_constraints_id: “Identifier of the PEBC.PowerConstraints this PEBC.Instruction was based on.” |
S2-PEBC-006 | error | yes | An envelope limit must lie within an allowed range for its quantity | 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.” |
S2-PEBC-007 | error | no | The lower average power must not exceed the upper | 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). |
S2-PPBC-001 | error | no | A profile’s start must not be after its end | 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”. |
S2-PPBC-002 | error | yes | An instruction must resolve profile, container and sequence together | S2J messages/PPBC.ScheduleInstruction: the three ids name a profile, a container within it, and a sequence within that. |
S2-PPBC-003 | error | yes | Only a sequence that says it is interruptible may be interrupted | S2J schemas/PPBC.PowerSequence.is_interruptible: “Indicates whether the option of pausing a sequence is available.” |
S2-PPBC-004 | error | yes | A profile status must cover every container of the profile | S2J messages/PPBC.PowerProfileStatus.sequence_container_status: “Array with status information for all PPBC.PowerSequenceContainers in the PPBC.PowerProfileDefinition.” |
S2-PPBC-005 | error | no | A status for a sequence that has started must report its progress | S2J schemas/PPBC.PowerSequenceContainerStatus.progress: “A value must be provided, unless no sequence has been selected or the selected sequence hasn’t started yet.” This is the half the sentence states plainly: once the selected sequence is running, the CEM is told how far in it is. |
S2-PPBC-006 | warning | no | The window is shorter than the shortest sequence offered | Implied by the two together: a task that cannot finish inside its own window is one no CEM can schedule. |
S2-PPBC-007 | warning | no | Progress was reported for a sequence that has not started | The converse of S2-PPBC-005, and it is not stated. S2J schemas/PPBC.PowerSequenceContainerStatus.progress says a value “must be provided, unless no sequence has been selected or the selected sequence hasn’t started yet” — which grants permission to omit it, and does not forbid sending it. A progress of zero beside a SCHEDULED status is redundant rather than wrong, and refusing it would make this crate stricter than the standard (D4). A warning, so a peer that means something by it is still heard. |
S2-PPBC-008 | error | no | A status that says a sequence was selected must name which one | S2J schemas/PPBC.PowerSequenceContainerStatus.selected_sequence_id: “When no ID is given, no sequence was selected yet.” Read the other way round, which is the way a receiver reads it: a status whose status is anything but NOT_SCHEDULED asserts that a sequence was selected, and a CEM that is not told which one cannot match the progress to a duration. |
S2-OMBC-001 | error | yes | An instruction must name an operation mode the system description declares | S2J messages/OMBC.Instruction.operation_mode_id: “ID of the OMBC.OperationMode that should be activated.” |
S2-OMBC-002 | error | no | A transition must name operation modes and timers of its own description | S2J schemas/Transition: the ids are “unique in the scope of the OMBC.SystemDescription … in which it is used”. |
S2-DDBC-001 | error | yes | An instruction must name an actuator the system description declares | S2J messages/DDBC.Instruction.actuator_id: “ID of the actuator this Instruction belongs to.” |
S2-DDBC-002 | error | yes | An instruction must name an operation mode that actuator has | S2J messages/DDBC.Instruction.operation_mode_id: “ID of the DDBC.OperationMode”. |
S2-DDBC-003 | error | no | A transition must name operation modes and timers of its own actuator | S2J schemas/Transition: the ids are “unique in the scope of the … DDBC.ActuatorDescription in which it is used”. |
S2-DDBC-004 | error | yes | A demand forecast may only be sent if the system description offers one | S2J messages/DDBC.SystemDescription.provides_average_demand_rate_forecast: “Indicates whether the Resource Manager could provide a demand rate forecast.” |