Skip to content

feat(engine): semantic trace diff#49

Merged
sepehr-safari merged 1 commit into
mainfrom
feat/trace-diff
Jul 11, 2026
Merged

feat(engine): semantic trace diff#49
sepehr-safari merged 1 commit into
mainfrom
feat/trace-diff

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

What

feat(engine): semantic trace diff (S4 #43) — compare two parsed traces.

Closes #43.

Changes

  • src/ocpp/diff.zigdiffTraces(a, b) mirroring the toolkit's
    core/diff.ts:
    • Events matched by OCPP UniqueId (message_id); only_in_a / only_in_b
      partition the unmatched.
    • Shared ids compared positionally → an EventDiff per differing field
      (timestamp / direction / action / payload / error_code).
    • Failure-set delta by code; first-session summary comparison with the
      toolkit's exact difference lines (event/failure count, status, duration,
      transaction id).
  • Recursive JSON deep-equality (numbers compare by value across
    representations, matching JS ===) and a compact-JSON renderer for changed
    payload values.
  • Wired into ocpp.zig; CURRENT_STATE updated.

Notes

  • Result borrows from the input traces' arena + gpa (arena-oriented, like the
    rest of the engine).
  • EventDiff values are rendered to display strings (Zig has no unknown); the
    diff is a reporting artifact consumed by the CLI (feat(cli): headless CLI subcommands + parity table #45).
  • Deterministic ordering: A is walked in document order, matching the k-th
    occurrence of each id to B's k-th.

Tests

109/109 headless tests pass (native test -Dplatform=null); native check --strict clean; zig fmt clean. New coverage: identical → empty diff,
added/removed partitioning, each modified field with rendered values, nested
deep-equal vs nested-different payloads, and a failure-set + summary delta over
failed-auth vs normal-session.

Add src/ocpp/diff.zig: compare two parsed traces, mirroring the toolkit's
core/diff.ts. Match events by OCPP UniqueId; report field-level differences
(timestamp / direction / action / payload / errorCode) for shared ids,
added/removed events, a failure-set delta by code, and a first-session summary
comparison with human-readable difference lines.

Includes a recursive JSON deep-equality check (numbers compare by value across
representations, as in the toolkit) and a compact-JSON renderer for the changed
payload values. Pure and headless; the result borrows from the input traces'
arena.

Closes #43.
@sepehr-safari
sepehr-safari merged commit e955acc into main Jul 11, 2026
3 checks passed
@sepehr-safari
sepehr-safari deleted the feat/trace-diff branch July 11, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(engine): semantic trace diff

1 participant