Logistiki.Audit.AuditEvent (logistiki v0.1.0)

Copy Markdown View Source

A persisted audit event.

Every important action in the accounting pipeline records an audit event so that, later, one can answer why a posting exists, which business event caused it, which rules fired, which policy was selected, which template was used, which accounts were selected, who initiated it, and how the balance was derived.

Fields

  • idinteger() — primary key (e.g. 1)
  • actor_idString.t() | nil — who initiated the action (e.g. "user_789")

  • event_idString.t() | nil — the originating business event id (e.g. "evt_001")

  • journal_idinteger() | nil — the related journal id (e.g. 5)

  • actionString.t() — the pipeline stage action (e.g. "journal_posted", "business_event_received")
  • resource_typeString.t() | nil — the type of resource (e.g. "journal", "event")

  • resource_idString.t() | nil — the resource id (e.g. "1")

  • beforemap() | nil — state before the action (for updates)

  • aftermap() | nil — state after the action (for updates)

  • explanationmap() | nil — structured explanation (e.g. %{policy: :cash_deposit})

  • metadatamap() — extensible metadata (default %{})
  • inserted_atDateTime.t() | nil — set on insert (no updated_at; e.g. ~U[2026-07-07 12:00:00Z])

Captured actions

business_event_received, event_normalized, facts_generated, business_rules_evaluated, no_accounting_impact, policy_selected, template_selected, journal_built, invariant_validation_succeeded, invariant_validation_failed, journal_posted, journal_reversed, projection_generated, audit_event_written.

Example

%Logistiki.Audit.AuditEvent{
  id: 1,
  event_id: "evt_001",
  journal_id: 5,
  action: "journal_posted",
  resource_type: "journal",
  resource_id: "5",
  explanation: %{policy: :cash_deposit, backend: Logistiki.Ledger.Simulation},
  inserted_at: ~U[2026-07-07 12:00:00Z]
}

Summary

Types

t()

The AuditEvent struct type — a persisted record of a pipeline stage.

Types

t()

@type t() :: %Logistiki.Audit.AuditEvent{
  __meta__: term(),
  action: String.t() | nil,
  actor_id: String.t() | nil,
  after: map() | nil,
  before: map() | nil,
  event_id: String.t() | nil,
  explanation: map() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  journal_id: integer() | nil,
  metadata: map() | nil,
  resource_id: String.t() | nil,
  resource_type: String.t() | nil
}

The AuditEvent struct type — a persisted record of a pipeline stage.

Fields

  • idinteger() | nil — primary key

  • actor_idString.t() | nil — e.g. "user_789"

  • event_idString.t() | nil — originating event id (e.g. "evt_001")

  • journal_idinteger() | nil — related journal id

  • actionString.t() | nil — e.g. "journal_posted"

  • resource_typeString.t() | nil — e.g. "journal", "event"

  • resource_idString.t() | nil — e.g. "5"

  • beforemap() | nil — state before the action

  • aftermap() | nil — state after the action

  • explanationmap() | nil — structured explanation

  • metadatamap() | nil — extensible metadata

  • inserted_atDateTime.t() | nil — set on insert (no updated_at)

Example

%Logistiki.Audit.AuditEvent{
  id: 1, event_id: "evt_001", action: "journal_posted",
  explanation: %{policy: :cash_deposit}
}