fix(ocpp): make METER_VALUE_ANOMALY and STATUS_TRANSITION_VIOLATION per connector#90
Merged
Merged
Conversation
…er connector Mirrors the toolkit fixes shiv3 found from the ocpp-cp-simulator integration (toolkit#127 and toolkit#128). METER_VALUE_ANOMALY (rule 14) flattened every sampledValue across measurand, phase, unit, location and connector into one series and asserted monotonicity, but only cumulative Energy.*.Register measurands are monotonic and non-negative per OCPP 1.6 section 7.28. Readings are now bucketed by (connectorId, measurand, phase, unit, location) and the checks apply only to cumulative energy registers (absent measurand defaults to Energy.Active.Import.Register). std.StringArrayHashMap was removed in Zig 0.16, so insertion order is kept explicitly via a key-to-index map. STATUS_TRANSITION_VIOLATION (rule 8) tracked a single previous status across all connectors; it now tracks previous status per connectorId (connectorId 0, the whole charge point, forms its own series). Both fixes preserve the conformance goldens (the 15 fixtures are single-connector). Adds a payloadInt helper and two regression tests. Reported by shiv3.
sepehr-safari
added a commit
that referenced
this pull request
Jul 22, 2026
Detection correctness fix (per-connector METER_VALUE_ANOMALY and STATUS_TRANSITION_VIOLATION, #90), at parity with toolkit 0.4.1/0.4.2. Bumps app.zon to 0.5.3, finalizes the CHANGELOG, and updates CURRENT_STATE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the two connector-blindness bugs shiv3 found from the ocpp-cp-simulator integration, mirroring the toolkit fixes (ocpp-debugkit/toolkit#127 and ocpp-debugkit/toolkit#128, released as toolkit 0.4.1 and 0.4.2). Studio shares the toolkit's 16-rule detection contract, so it had the same two defects in
src/ocpp/detection.zig.METER_VALUE_ANOMALY (rule 14)
The rule flattened every
sampledValueacross measurand, phase, unit, location and connector into one series and asserted monotonicity, but only cumulativeEnergy.*.Registermeasurands are monotonic and non-negative per OCPP 1.6 section 7.28. Readings are now bucketed by(connectorId, measurand, phase, unit, location)and the checks apply only to cumulative energy registers (an absentmeasuranddefaults toEnergy.Active.Import.Register).std.StringArrayHashMapwas removed in Zig 0.16, so insertion order is kept explicitly with a key-to-index map.STATUS_TRANSITION_VIOLATION (rule 8)
The rule tracked a single previous status across all connectors; it now tracks the previous status per
connectorId(connectorId 0, the whole charge point, forms its own series).Conformance
Both fixes preserve the 15 conformance goldens (the fixtures are single-connector), so the two-implementation contract still holds.
native test -Dplatform=nullis 167/167 (two new regression tests),native buildcompiles clean, and both touched scenarios pass the CLI gate. Adds apayloadInthelper.Reported by shiv3.