Raxol.Harness.EventBoundary (Raxol v2.8.0)

View Source

Normalizes a live session event into the shape Raxol.Harness.Projection.project/2 reads. raxol_agent 2.7.0 calls normalize/1; nothing in this repository does.

The input is an atom-keyed map or struct whose payload may hold atom keys and atom values. The output has atom top-level fields and a payload with string keys and JSON-shaped values, as Jason.encode!/1 |> Jason.decode!/1 would give.

The event comes from another process and is treated as untrusted:

  • No atom is created. Strings stay strings, and atoms in the payload become strings.
  • Only :id, :turn_id, :ts, :family, :type, :tier, :scope, :provenance and :payload are kept.
  • :provenance.trust is :trusted or :tainted; any other value becomes :tainted.
  • :tier must be :durable or :ephemeral; anything else is {:error, :invalid_event}.

:type and :family pass through unchanged, atom or not.

Summary

Functions

Normalize a live event into the fixture wire shape.

Functions

normalize(event)

@spec normalize(map()) :: {:ok, map()} | {:error, :invalid_event}

Normalize a live event into the fixture wire shape.

Accepts any map, including a struct (fields are read via Map.get/2, never struct pattern matching, so any atom-keyed struct works). Returns {:ok, map} on success; {:error, :invalid_event} when :id, :ts, :payload, or :tier fail their respective shape checks (see moduledoc).