Skip to content

fix(ocpp): make METER_VALUE_ANOMALY and STATUS_TRANSITION_VIOLATION per connector#90

Merged
sepehr-safari merged 1 commit into
mainfrom
fix/detection-per-connector
Jul 22, 2026
Merged

fix(ocpp): make METER_VALUE_ANOMALY and STATUS_TRANSITION_VIOLATION per connector#90
sepehr-safari merged 1 commit into
mainfrom
fix/detection-per-connector

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

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 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 (an absent measurand defaults to Energy.Active.Import.Register). std.StringArrayHashMap was 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=null is 167/167 (two new regression tests), native build compiles clean, and both touched scenarios pass the CLI gate. Adds a payloadInt helper.

Reported by shiv3.

…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
sepehr-safari merged commit 54a729f into main Jul 22, 2026
4 checks passed
@sepehr-safari
sepehr-safari deleted the fix/detection-per-connector branch July 22, 2026 13:35
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant