Skip to content

feat(core): trace diffing — diffTraces() API#99

Merged
sepehr-safari merged 1 commit into
mainfrom
feat/core-trace-diffing
Jul 9, 2026
Merged

feat(core): trace diffing — diffTraces() API#99
sepehr-safari merged 1 commit into
mainfrom
feat/core-trace-diffing

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

Summary

Implements diffTraces() — a new core API for comparing two parsed traces and surfacing differences at multiple levels:

API

export function diffTraces(a: ParseResult, b: ParseResult): TraceDiff;

TraceDiff Output

  • onlyInA / onlyInB — Events present in only one trace (by messageId)
  • modified — Field-level differences for events present in both:
    • timestamp, direction, action, payload (deep equality), errorCode
  • failuresOnlyInA / failuresOnlyInB — Failures detected in one but not the other
  • summaryDiff — Session summary differences (event count, failure count, duration, status, transaction ID)

Implementation Details

  • Events matched by messageId (OCPP UniqueId)
  • Handles Call + CallResult pairs sharing the same messageId (position-based comparison)
  • Deep equality for payload comparison (JSON-serializable data only)
  • Pure function — no I/O, no side effects, browser-safe
  • Exported from @ocpp-debugkit/toolkit/core and root barrel

Files Changed

  • packages/toolkit/src/core/diff.ts — new module (implementation + types)
  • packages/toolkit/src/core/diff.test.ts — 13 unit tests
  • packages/toolkit/src/core/index.ts — export diffTraces + types
  • packages/toolkit/src/index.ts — re-export from root barrel
  • .changeset/v03-trace-diffing.md — minor bump changeset
  • CURRENT_STATE.md — updated with v0.3.0 progress

Closes #85

Checklist

  • diffTraces() implemented with full TraceDiff return type
  • Events matched by messageId, with field-level diff for modified events
  • Failures diffed by code
  • Summary diffed with human-readable difference strings
  • Unit tests: identical, completely different, partially different, missing events, modified payloads, timestamp differences
  • Pure function — no I/O, no side effects, browser-safe
  • Exported from @ocpp-debugkit/toolkit/core and root barrel
  • Changeset added
  • CURRENT_STATE.md updated
  • Lint, typecheck, test, format all pass (322 tests)

@sepehr-safari sepehr-safari merged commit 8f765f9 into main Jul 9, 2026
2 checks passed
@sepehr-safari sepehr-safari deleted the feat/core-trace-diffing branch July 9, 2026 00:13
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(core): trace diffing

1 participant