feat(engine): failure model + foundational detection rules#23
Merged
Conversation
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
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.
What & why
First slice of S2 — Detection + conformance: the failure-detection layer and
its foundational rule batch. Mirrors the toolkit's
core/detection.ts— theshared conformance contract — so the two implementations flag the same failures.
Changes
types.zig, deferred here from S1) —FailureSeverity, thefull 16-code
FailureCodetaxonomy with wire-string encoding, andFailure(
code/description/severity/event_ids/suggested_steps).src/ocpp/detection.zig— thedetectFailures(arena, events, sessions)orchestrator (runs rules in contract order), the per-code
severityandremediation-step metadata tables (the full taxonomy, defined once), and shared
payload-extraction helpers.
FAILED_AUTHORIZATION— Authorize response withidTagInfo.status = "Invalid".CONNECTOR_FAULT—FaultedStatusNotification during an active transaction.STATION_OFFLINE_DURING_SESSION— a transaction that starts but never stops,or an
Unavailable/Offlinestatus mid-session.Scope boundaries
detectFailuresgrows across the next two rule batches (#20, #21). Theconformance 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=null→ 37/37 pass (4 new: the failure-taxonomyencoding, plus each rule fires on its trigger and stays silent otherwise —
driven through the real
parse → correlate → detectpipeline).native check --strictandzig fmt --checkclean.Closes #19