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.

RuleSeverityNeeds sessionChecksSource
S2-ID-001errornoIdentifiers must be unique within the scope the standard namesS2J: “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-001errornoEvery number must be finiteJSON has no spelling for NaN or infinity, so a non-finite value cannot be sent at all.
S2-NUM-002errornoA range’s start must not be after its endS2J schemas/PEBC.AllowedLimitRange.range_boundary: “The start of the range shall be smaller or equal than the end of the range.”
S2-NUM-003errornoA fill-level band’s start must be strictly below its endS2J schemas/FRBC.OperationModeElement.fill_level_range: “The start of the NumberRange shall be smaller than the end of the NumberRange.”
S2-NUM-004errornoAn 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-001errornoAn array must respect the schema’s minItems and maxItemsGenerated from schema/s2-json; the bounds are the schema’s own.
S2-MSG-002warningyesA message_id should not repeat within a sessionImplied rather than stated: nothing in S2 JSON requires uniqueness, but a repeated id makes reception statuses ambiguous. A warning for that reason.
S2-MSG-003warningyesA timestamp is further from the local clock than its meaning allowsNo 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-004errornoThe frame could not be decoded into an S2 messageS2J 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-005warningnoA property the schema does not define was removed before decodingS2J 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-006errornoThe receiving application refused the message through its inbound policyS2J 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-007errornoA field that is optional in general is mandatory for this sender’s roleS2J 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-008erroryesA field must be present exactly when the negotiated wire profile defines itS2C §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-001errornoAt most one value per CommodityQuantityS2J messages/PowerMeasurement.values: “at most one item per ‘commodity_quantity’”, and the same for every PowerRange and PowerForecastValue array.
S2-PM-002warningnoPer-phase and three-phase-symmetric quantities should not be mixedUndocumented; [s2-json #25] asks for the exclusivity to be written down (erratum E12). A warning until it is.
S2-PM-003warningnoConfidence bands should be ordered from the lower limit to the upperInferred from the percentile semantics: a 68 % band lies inside a 95 % band. Not stated, so a warning.
S2-PM-004erroryesA measurement may only use a quantity the resource said it providesS2J messages/ResourceManagerDetails.provides_power_measurement_types: “Array of all CommodityQuantities that this Resource Manager can provide measurements for.”
S2-PM-005erroryesA forecast may only be sent by a resource that said it provides forecastsS2J messages/ResourceManagerDetails.provides_forecast: “Indicates whether the ResourceManager is able to provide PowerForecasts.”
S2-RMD-001erroryesThe CEM may only select a control type the resource offersS2J messages/SelectControlType.control_type: “Must be one of the available ControlTypes as defined in the ResourceManagerDetails.”
S2-RMD-002warningyesA resource that publishes costs should declare a currencyS2J 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-003warningnoA resource should declare each role once per commodityS2J 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-004warningnoNO_SELECTION is not something a resource can offerS2J schemas/ControlType: NO_SELECTION is “to be used if no control type is or has been selected” — a state, not a capability.
S2-STATE-001erroryesThe message is not allowed in the session’s current stateS2C §State of communication, the normative table of what may be sent when.
S2-STATE-002erroryesThe message is not allowed from this roleS2C §State of communication: the table has a column per role.
S2-STATE-003warningyesHandshake messages are redundant under S2 ConnectS2C §Communication - JSON messages: “the Handshake and HandshakeResponse messages can not be sent. They are redundant by the pairing and session initiation process.”
S2-ACT-001warningnoEvery operation mode should publish a power range for each commodity the actuator supportsThe 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-002warningnoAn actuator should list each supported commodity onceThe 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-001warningyesA status after the first for the same actuator should name the previous modeS2J 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-002erroryesA timer status must name a timer the description declaresS2J 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-001erroryesAn instruction identifier must not be reused within a sessionS2J: “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-002erroryesAn InstructionStatusUpdate must name an instruction that was sentS2J messages/InstructionStatusUpdate.instruction_id: “ID of this instruction (as provided by the CEM)”.
S2-INST-003warningyesAn instruction’s status should not move backwardsThe 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-004erroryesAn abnormal-condition-only mode, transition or range needs abnormal_conditionS2J: “Indicates if this … may only be used during an abnormal condition.”
S2-INST-005warningyesThe instructed transition is blocked by a timer that has not finishedS2J 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-006warningyesNo transition is described from the active operation mode to the instructed onethe 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-001warningyesThe revoked object type is not one this sender ownsS2C §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-002warningyesThe revoked object was never published on this sessionNot stated. Revoking something the peer never saw is harmless but almost always a bug.
S2-FRBC-001errornoAn operation mode’s fill-level bands must be contiguousS2J schemas/FRBC.OperationMode.elements: “The fill_level_ranges of the items in the Array must be contiguous.”
S2-FRBC-002errornoLeakage bands must be contiguousS2J messages/FRBC.LeakageBehaviour.elements: “The fill_level_ranges of the elements must be contiguous.”
S2-FRBC-003erroryesAn instruction must name an actuator the system description declaresS2J messages/FRBC.Instruction.actuator_id: “ID of the actuator this instruction belongs to.”
S2-FRBC-004erroryesAn instruction must name an operation mode that actuator hasS2J messages/FRBC.Instruction.operation_mode: “ID of the FRBC.OperationMode that should be activated.”
S2-FRBC-005errornoA transition must name operation modes and timers of its own actuatorS2J schemas/Transition: the ids are “unique in the scope of the … FRBC.ActuatorDescription in which it is used”.
S2-FRBC-006erroryesLeakage, usage forecast and target profile may only be sent if the storage offers themS2J schemas/FRBC.StorageDescription: the three provides_* flags.
S2-FRBC-007warningyesThe reported fill level is outside the range the storage describedS2J 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-001errornoPower constraints need at least one upper and one lower allowed rangeS2J 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-002errornovalid_from must precede valid_untilS2J messages/PEBC.PowerConstraints: a window that ends before it starts is never in force.
S2-PEBC-003errornoAn envelope element’s lower limit must not exceed its upper limitS2J schemas/PEBC.PowerEnvelopeElement.upper_limit: “The lower_limit must be smaller or equal to the upper_limit.”
S2-PEBC-004errornoAt most one envelope per CommodityQuantityS2J messages/PEBC.Instruction.power_envelopes: “at most one PEBC.PowerEnvelope for each CommodityQuantity.”
S2-PEBC-005erroryesAn instruction must reference power constraints that are published and in forceS2J messages/PEBC.Instruction.power_constraints_id: “Identifier of the PEBC.PowerConstraints this PEBC.Instruction was based on.”
S2-PEBC-006erroryesAn envelope limit must lie within an allowed range for its quantityS2J 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-007errornoThe lower average power must not exceed the upperS2J 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-001errornoA profile’s start must not be after its endS2J 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-002erroryesAn instruction must resolve profile, container and sequence togetherS2J messages/PPBC.ScheduleInstruction: the three ids name a profile, a container within it, and a sequence within that.
S2-PPBC-003erroryesOnly a sequence that says it is interruptible may be interruptedS2J schemas/PPBC.PowerSequence.is_interruptible: “Indicates whether the option of pausing a sequence is available.”
S2-PPBC-004erroryesA profile status must cover every container of the profileS2J messages/PPBC.PowerProfileStatus.sequence_container_status: “Array with status information for all PPBC.PowerSequenceContainers in the PPBC.PowerProfileDefinition.”
S2-PPBC-005errornoA status for a sequence that has started must report its progressS2J 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-006warningnoThe window is shorter than the shortest sequence offeredImplied by the two together: a task that cannot finish inside its own window is one no CEM can schedule.
S2-PPBC-007warningnoProgress was reported for a sequence that has not startedThe 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-008errornoA status that says a sequence was selected must name which oneS2J 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-001erroryesAn instruction must name an operation mode the system description declaresS2J messages/OMBC.Instruction.operation_mode_id: “ID of the OMBC.OperationMode that should be activated.”
S2-OMBC-002errornoA transition must name operation modes and timers of its own descriptionS2J schemas/Transition: the ids are “unique in the scope of the OMBC.SystemDescription … in which it is used”.
S2-DDBC-001erroryesAn instruction must name an actuator the system description declaresS2J messages/DDBC.Instruction.actuator_id: “ID of the actuator this Instruction belongs to.”
S2-DDBC-002erroryesAn instruction must name an operation mode that actuator hasS2J messages/DDBC.Instruction.operation_mode_id: “ID of the DDBC.OperationMode”.
S2-DDBC-003errornoA transition must name operation modes and timers of its own actuatorS2J schemas/Transition: the ids are “unique in the scope of the … DDBC.ActuatorDescription in which it is used”.
S2-DDBC-004erroryesA demand forecast may only be sent if the system description offers oneS2J messages/DDBC.SystemDescription.provides_average_demand_rate_forecast: “Indicates whether the Resource Manager could provide a demand rate forecast.”