Skip to content

feat(engine): protocol & transaction detection rules#24

Merged
sepehr-safari merged 1 commit into
mainfrom
feat/engine-detection-protocol
Jul 11, 2026
Merged

feat(engine): protocol & transaction detection rules#24
sepehr-safari merged 1 commit into
mainfrom
feat/engine-detection-protocol

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

What & why

Second slice of S2 — Detection + conformance: contract rules 4–10, the
protocol & transaction batch. Mirrors the toolkit's core/detection.ts — the
same thresholds and OCPP 1.6 status / reason / firmware vocabularies.

Rules added

Code Fires when
TIMEOUT_NO_HEARTBEAT no Heartbeat within the expected interval after Boot (interval from the Boot response, else 60 s), and only if the trace runs past that point
METER_VALUE_GAP a completed transaction (Start + Stop) with no MeterValues
INVALID_STOP_REASON StopTransaction reason outside the OCPP 1.6 set
UNEXPECTED_START StartTransaction with no preceding BootNotification or Authorize
STATUS_TRANSITION_VIOLATION an illegal connector status transition per the OCPP 1.6 state model
DIAGNOSTICS_FAILURE DiagnosticsStatusNotification UploadFailed / DiagnosisFailed
FIRMWARE_UPDATE_FAILURE FirmwareStatusNotification DownloadFailed / DownloadPaused / InstallFailed / InstallRebootingFailed

detectFailures now runs rules 1–10 in contract order.

Testing

  • native test -Dplatform=null43/43 pass (6 new tests: each rule on its
    trigger and its silent case, driven through the real pipeline — including the
    heartbeat threshold's "not enough trace to judge" boundary).
  • native check --strict and zig fmt --check clean.

Closes #20

Add contract rules 4-10 to the detection engine, mirroring the toolkit's
`core/detection.ts` thresholds and OCPP 1.6 vocabularies.

- TIMEOUT_NO_HEARTBEAT — no Heartbeat within 2x the expected interval
  (Boot response, else 60s default), only when the trace runs past it.
- METER_VALUE_GAP — a completed transaction with no MeterValues.
- INVALID_STOP_REASON — StopTransaction reason outside the OCPP 1.6 set.
- UNEXPECTED_START — StartTransaction with no preceding Boot or Authorize.
- STATUS_TRANSITION_VIOLATION — illegal connector state-model transition.
- DIAGNOSTICS_FAILURE / FIRMWARE_UPDATE_FAILURE — failure statuses.

Each rule is tested on its trigger and its silent case. detectFailures now
runs rules 1-10; the timing & anomaly batch and the conformance harness follow.

Closes #20
@sepehr-safari sepehr-safari added type:feature New capability area:engine Pure Zig OCPP engine priority:high labels Jul 11, 2026
@sepehr-safari sepehr-safari merged commit d8a6cb5 into main Jul 11, 2026
3 checks passed
@sepehr-safari sepehr-safari deleted the feat/engine-detection-protocol branch July 11, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:engine Pure Zig OCPP engine priority:high type:feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(engine): protocol & transaction detection rules

1 participant