Skip to content

feat(engine): failure model + foundational detection rules#23

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

feat(engine): failure model + foundational detection rules#23
sepehr-safari merged 1 commit into
mainfrom
feat/engine-detection-core

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

What & why

First slice of S2 — Detection + conformance: the failure-detection layer and
its foundational rule batch. Mirrors the toolkit's core/detection.ts — the
shared conformance contract — so the two implementations flag the same failures.

Changes

  • Failure model (types.zig, deferred here from S1) — FailureSeverity, the
    full 16-code FailureCode taxonomy with wire-string encoding, and Failure
    (code / description / severity / event_ids / suggested_steps).
  • src/ocpp/detection.zig — the detectFailures(arena, events, sessions)
    orchestrator (runs rules in contract order), the per-code severity and
    remediation-step metadata tables (the full taxonomy, defined once), and shared
    payload-extraction helpers.
  • Foundational rules — contract rules 1–3:
    • FAILED_AUTHORIZATION — Authorize response with idTagInfo.status = "Invalid".
    • CONNECTOR_FAULTFaulted StatusNotification during an active transaction.
    • STATION_OFFLINE_DURING_SESSION — a transaction that starts but never stops,
      or an Unavailable / Offline status mid-session.

Scope boundaries

detectFailures grows across the next two rule batches (#20, #21). The
conformance harness over the 15 shared scenarios lands in the close-out (#22).
Detection is measured on the de-duplicated, sorted set of FailureCodes.

Testing

  • native test -Dplatform=null37/37 pass (4 new: the failure-taxonomy
    encoding, plus each rule fires on its trigger and stays silent otherwise —
    driven through the real parse → correlate → detect pipeline).
  • native check --strict and zig fmt --check clean.

Closes #19

Stand up the detection layer and the first rule batch, mirroring the
toolkit's `core/detection.ts` (the shared conformance contract), not its
source.

- Failure model (types.zig, deferred here from S1): `FailureSeverity`, the
  full 16-code `FailureCode` taxonomy with wire-string encoding, and
  `Failure` (code / description / severity / event ids / suggested steps).
- `src/ocpp/detection.zig`: the `detectFailures` orchestrator, the per-code
  severity and remediation-step metadata tables, and shared payload helpers.
- Foundational rules (contract rules 1-3): FAILED_AUTHORIZATION,
  CONNECTOR_FAULT, STATION_OFFLINE_DURING_SESSION — with tests that drive the
  real parse -> correlate -> detect pipeline.

`detectFailures` grows across the next two rule batches; conformance against
the 15 shared scenarios lands in the close-out PR.

Closes #19
@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 4a438bc into main Jul 11, 2026
3 checks passed
@sepehr-safari
sepehr-safari deleted the feat/engine-detection-core branch July 11, 2026 11:32
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): failure model + foundational detection rules

1 participant