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
id—integer()— primary key (e.g.1)actor_id—String.t() | nil— who initiated the action (e.g."user_789")event_id—String.t() | nil— the originating business event id (e.g."evt_001")journal_id—integer() | nil— the related journal id (e.g.5)action—String.t()— the pipeline stage action (e.g."journal_posted","business_event_received")resource_type—String.t() | nil— the type of resource (e.g."journal","event")resource_id—String.t() | nil— the resource id (e.g."1")before—map() | nil— state before the action (for updates)after—map() | nil— state after the action (for updates)explanation—map() | nil— structured explanation (e.g.%{policy: :cash_deposit})metadata—map()— extensible metadata (default%{})inserted_at—DateTime.t() | nil— set on insert (noupdated_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
@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
id—integer() | nil— primary keyactor_id—String.t() | nil— e.g."user_789"event_id—String.t() | nil— originating event id (e.g."evt_001")journal_id—integer() | nil— related journal idaction—String.t() | nil— e.g."journal_posted"resource_type—String.t() | nil— e.g."journal","event"resource_id—String.t() | nil— e.g."5"before—map() | nil— state before the actionafter—map() | nil— state after the actionexplanation—map() | nil— structured explanationmetadata—map() | nil— extensible metadatainserted_at—DateTime.t() | nil— set on insert (noupdated_at)
Example
%Logistiki.Audit.AuditEvent{
id: 1, event_id: "evt_001", action: "journal_posted",
explanation: %{policy: :cash_deposit}
}