Skip to content

feat(engine): timing & anomaly detection rules#25

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

feat(engine): timing & anomaly detection rules#25
sepehr-safari merged 1 commit into
mainfrom
feat/engine-detection-timing

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

What & why

Third slice of S2 — Detection + conformance: contract rules 11–16, the
timing & anomaly batch — completing the full 16-rule taxonomy. Mirrors the
toolkit's core/detection.ts thresholds exactly.

Rules added

Code Fires when
SUSPICIOUS_SESSION_DURATION a transaction session shorter than 60 s or longer than 24 h
SLOW_RESPONSE a Call→matching-response gap over 10 s
HEARTBEAT_INTERVAL_VIOLATION a consecutive heartbeat gap deviating >50% from the expected interval (Boot response, else 60 s)
METER_VALUE_ANOMALY a negative or non-monotonic (decreasing) meter reading within a transaction
UNRESPONSIVE_CSMS a Call with no matching CallResult / CallError
REPEATED_BOOT_NOTIFICATION 2+ BootNotification Calls within a 5 min window

detectFailures now runs all 16 rules in contract order.

Testing

  • native test -Dplatform=null49/49 pass (6 new tests, each firing on its
    threshold boundary and staying silent otherwise, driven through the real
    pipeline — isolated so only the rule under test can fire).
  • native check --strict and zig fmt --check clean.

The conformance harness (#22) will lock all 16 rules against the 15 shared
scenario goldens.

Closes #21

Add contract rules 11-16, completing the 16-rule taxonomy. Mirrors the
toolkit's `core/detection.ts` thresholds.

- SUSPICIOUS_SESSION_DURATION — transaction session < 60s or > 24h.
- SLOW_RESPONSE — Call→matching-response gap over 10s.
- HEARTBEAT_INTERVAL_VIOLATION — consecutive heartbeat gap deviating >50%
  from the expected interval.
- METER_VALUE_ANOMALY — negative or non-monotonic meter readings.
- UNRESPONSIVE_CSMS — a Call with no matching CallResult/CallError.
- REPEATED_BOOT_NOTIFICATION — 2+ BootNotifications within 5 minutes.

detectFailures now runs all 16 rules in contract order; each rule is tested
at its threshold boundary. The conformance harness over the 15 shared
scenarios lands next.

Closes #21
@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 4625e45 into main Jul 11, 2026
3 checks passed
@sepehr-safari sepehr-safari deleted the feat/engine-detection-timing branch July 11, 2026 11:51
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): timing & anomaly detection rules

1 participant