Raxol.Harness.Fixture.Session (Raxol v2.6.1)

View Source

A fully-loaded fixture: header + the ordered, upcasted envelope list. Helpers here are read-only projections over that list — the real journal-fold projection (T7) is a separate, not-yet-built module; these helpers exist so tests (and the bless task) don't hand-roll Enum pipelines over envelopes everywhere.

Two axes — never conflate them

Every envelope carries two orthogonal positions:

  • body.id — the event's monotonic per-session id, i.e. the journal offset. This is the seek/identity axis: attach/seek commands, replay identity, and dedup/ordering semantics all key off it. Query it with by_id/2.
  • offset — the 1-based physical line in the fixture file. This is the diagnostic axis: where in the recorded stream a thing sits, what a DecodeError points at, what pathologies/1 indexes. Query it with from_offset/2/range/3.

In a well-formed stream they move in lockstep; in an adversarial one they deliberately diverge — id-reorder and duplicate-id corruptions are detectable precisely because the two axes disagree. A test that treats one as the other destroys that signal.

Summary

Functions

Envelopes whose body.id (journal offset — the seek/identity axis) equals id. Returns a list: in a well-formed stream it has at most one element, but adversarial streams carry duplicate ids on purpose, and surfacing both is exactly how a dedup test sees the corruption.

Envelopes at or after the given 1-based line offset (inclusive).

The fixture's machine-readable corruption index (adversarial fixtures only; [] otherwise): a list of %{class: String.t(), offset: pos_integer()} read from the header's pathologies field. Downstream tests seek named corruptions instead of hardcoding line numbers

Envelopes within the inclusive physical-line window from..until (the diagnostic axis — see the moduledoc).

Types

t()

@type t() :: %Raxol.Harness.Fixture.Session{
  envelopes: [Raxol.Harness.Fixture.Envelope.t()],
  header: Raxol.Harness.Fixture.Header.t(),
  path: Path.t()
}

Functions

adversarial?(session)

@spec adversarial?(t()) :: boolean()

by_family(session, family)

by_id(session, id)

Envelopes whose body.id (journal offset — the seek/identity axis) equals id. Returns a list: in a well-formed stream it has at most one element, but adversarial streams carry duplicate ids on purpose, and surfacing both is exactly how a dedup test sees the corruption.

by_type(session, type)

@spec by_type(t(), atom()) :: [Raxol.Harness.Fixture.Envelope.t()]

durable(session)

@spec durable(t()) :: [Raxol.Harness.Fixture.Envelope.t()]

ephemeral(session)

@spec ephemeral(t()) :: [Raxol.Harness.Fixture.Envelope.t()]

from_offset(session, offset)

@spec from_offset(t(), pos_integer()) :: [Raxol.Harness.Fixture.Envelope.t()]

Envelopes at or after the given 1-based line offset (inclusive).

golden?(session)

@spec golden?(t()) :: boolean()

pathologies(session)

@spec pathologies(t()) :: [Raxol.Harness.Fixture.Header.pathology()]

The fixture's machine-readable corruption index (adversarial fixtures only; [] otherwise): a list of %{class: String.t(), offset: pos_integer()} read from the header's pathologies field. Downstream tests seek named corruptions instead of hardcoding line numbers:

offset = Session.pathologies(session)
         |> Enum.find(&(&1.class == "late_delta_after_seal")).offset

range(session, from, until)

Envelopes within the inclusive physical-line window from..until (the diagnostic axis — see the moduledoc).