Skip to content

docs: protocol scope + trace-format design spike - #19

Merged
sepehr-safari merged 1 commit into
mainfrom
docs/protocol-design-spike
Jul 7, 2026
Merged

docs: protocol scope + trace-format design spike#19
sepehr-safari merged 1 commit into
mainfrom
docs/protocol-design-spike

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

Summary

Resolves all foundational design decisions before core implementation (Milestone 0.5 — Protocol & Trace-Format Design Phase).

This is a research/spike phase — no published packages. Only design documents, ADRs, synthetic fixtures, and the proposed type definitions.

Closes #18

Deliverables

Architecture Decision Records (docs/adr/)

9 ADRs covering every design decision from the M0.5 checklist:

ADR Title
ADR-0001 OCPP Version Scope — 1.6 JSON Primary
ADR-0002 Input Trace Formats — JSON Object + JSONL
ADR-0003 Canonical Internal Event Model
ADR-0004 Message Direction Representation
ADR-0005 Timestamp Normalization
ADR-0006 Session Correlation Strategy
ADR-0007 Malformed Trace Handling
ADR-0008 Browser-Local Processing & Privacy
ADR-0009 Future Protocol-Version Extensibility

Trace Format Specification (docs/trace-format-spec.md)

Full specification of accepted trace formats (JSON Object, JSONL, bare array), OCPP 1.6 message structure, size/count limits, timestamp formats, and direction values.

Synthetic Trace Fixtures (packages/core/src/__fixtures__/)

3 fixtures — all fully synthetic (no real station IDs, transaction IDs, or idTags):

  1. normal-session.json — complete charging session: boot → authorize → start transaction → meter values → stop transaction. No failures expected.
  2. failed-auth.json — failed authorization: idTag rejected 3×, connector transitions to Faulted. Expects FAILED_AUTHORIZATION.
  3. connector-fault.json — connector fault during active session: ConnectorLockFailure mid-charging, stop with Faulted reason. Expects CONNECTOR_FAULT.

Proposed Canonical Types (packages/core/src/types.ts)

Type definitions for Event, Trace, TraceEventInput, Session, Direction, MessageType, ParseResult, ParseWarning — the foundation for v0.1.0 implementation.

Validation Tests (packages/core/src/fixtures.test.ts)

28 tests proving all 3 fixtures conform to the proposed event model:

  • Trace shape validation (events array, metadata)
  • Per-event shape validation (message array, message type IDs, field types)
  • Call/CallResult correlation by messageId
  • Session flow validation (BootNotification → Authorize → StartTransaction → MeterValues → StopTransaction)
  • Transaction ID consistency
  • Chronological timestamp ordering
  • Synthetic data policy enforcement (SYNTHETIC markers, no UUID patterns)
  • OCPP version declaration

Design Decisions Summary

  • OCPP 1.6 JSON primary; 2.0.1 deferred but architecturally supported
  • Two trace formats: JSON Object (metadata + events) and JSONL (one event per line)
  • Canonical Event with id, messageId, timestamp (epoch ms or null), direction, messageType, action, payload, rawMessage
  • Direction inferred from OCPP action name when not explicitly provided
  • Timestamps normalized to epoch ms; out-of-order events flagged, not silently reordered
  • Sessions derived from transactionId correlation
  • Malformed traces: structural errors fail-fast; event errors skip-and-flag; 10MB / 10K event limits
  • Browser-local: all processing client-side, no auto-upload, no trace telemetry
  • Extensibility: version-aware dispatch, no premature plugin abstraction

Verification

  • pnpm lint — clean
  • pnpm typecheck — clean
  • pnpm test — 29 tests pass (1 smoke + 28 fixture validation)
  • pnpm format:check — clean

Security Review

  • No secrets, tokens, or credentials in committed files
  • No real station IDs, transaction IDs, or idTags — all synthetic (CS-SYNTHETIC-*, SYNTHETIC-TAG-*)
  • No eval(), Function(), or dynamic code execution
  • No personal or sensitive information in committed artifacts
  • .hermes/ directory is gitignored and not committed
  • No maintainer email in any committed file

Checklist

  • ADRs written for each design decision
  • Trace format spec documented with examples
  • 3 synthetic fixtures validate against the proposed event model
  • No real station IDs, transaction IDs, or personal data in fixtures
  • Living docs updated (CURRENT_STATE.md, AGENTS.md)
  • CI expected green (lint, typecheck, test, format)
  • Maintainer approves the design before core implementation begins

Resolve all foundational design decisions before core implementation
(Milestone 0.5 — Protocol & Trace-Format Design Phase).

Deliverables:
- 9 Architecture Decision Records (docs/adr/):
  - ADR-0001: OCPP version scope (1.6 JSON primary)
  - ADR-0002: Input trace formats (JSON Object + JSONL)
  - ADR-0003: Canonical internal event model
  - ADR-0004: Message direction representation
  - ADR-0005: Timestamp normalization
  - ADR-0006: Session correlation strategy
  - ADR-0007: Malformed trace handling
  - ADR-0008: Browser-local processing & privacy
  - ADR-0009: Future protocol-version extensibility
- Trace format specification (docs/trace-format-spec.md)
- 3 synthetic trace fixtures (packages/core/src/__fixtures__/):
  - normal-session.json (complete session, no failures)
  - failed-auth.json (failed authorization)
  - connector-fault.json (connector fault during session)
- Proposed canonical types (packages/core/src/types.ts)
- 28 validation tests proving fixtures conform to the proposed event model
- Updated AGENTS.md with design decisions summary
- Updated CURRENT_STATE.md with M0.5 progress

Closes #18
@sepehr-safari sepehr-safari added type:docs Documentation improvements package:core @ocpp-debugkit/core priority:high Important for current milestone labels Jul 7, 2026
@sepehr-safari
sepehr-safari merged commit 4038713 into main Jul 7, 2026
1 check passed
@sepehr-safari
sepehr-safari deleted the docs/protocol-design-spike branch July 7, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:core @ocpp-debugkit/core priority:high Important for current milestone type:docs Documentation improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: protocol scope + trace-format design spike

1 participant