BeamAgent.Audit (beam_agent_ex v0.1.0)

Copy Markdown View Source

Canonical BeamAgent audit records.

Audit entries are persisted through the durable journal and can be listed or fetched independently from the live event bus.

Use this module when you need durable evidence of policy decisions or higher-level actions taken by control, routing, routines, memory, and orchestration flows.

Summary

Types

action()

@type action() :: atom() | binary()

audit_event()

@type audit_event() :: %{
  :event_id => binary(),
  :event_type => atom() | binary(),
  :payload => map(),
  :sequence => pos_integer(),
  :tags => [atom() | binary()],
  :timestamp => integer(),
  optional(:run_id) => binary(),
  optional(:session_id) => binary(),
  optional(:thread_id) => binary()
}

audit_filter()

@type audit_filter() :: %{
  optional(:event_id) => binary(),
  optional(:session_id) => binary(),
  optional(:thread_id) => binary(),
  optional(:run_id) => binary(),
  optional(:category) => category(),
  optional(:action) => action(),
  optional(:decision) => atom() | binary(),
  optional(:profile_id) => binary(),
  optional(:since) => integer(),
  optional(:limit) => pos_integer()
}

category()

@type category() :: atom() | binary()

listed_audit_event()

@type listed_audit_event() :: %{
  :event_id => binary(),
  :event_type => atom() | binary(),
  :payload => map(),
  :sequence => pos_integer(),
  :tags => [term()],
  :timestamp => integer(),
  optional(:run_id) => binary(),
  optional(:session_id) => binary(),
  optional(:thread_id) => binary()
}

Functions

get_event(event_id)

@spec get_event(binary()) :: {:ok, audit_event()} | {:error, :not_found}

See :beam_agent_audit.get_event/1.

list_events()

@spec list_events() :: {:ok, [listed_audit_event()]}

See :beam_agent_audit.list_events/0.

list_events(filter)

@spec list_events(audit_filter()) ::
  {:ok, [listed_audit_event()]}
  | {:error,
     {:invalid_filter,
      :event_id
      | :event_type
      | :limit
      | :run_id
      | :session_id
      | :since
      | :tag
      | :thread_id}
     | {:unsupported_audit_filter, atom()}
     | {:unsupported_audit_scope_key, atom()}}

See :beam_agent_audit.list_events/1.