# `MingaAgent.EventLog`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/event_log.ex#L1)

Durable append-only event log for agent sessions.

Agent sessions call `record/3`, which is a cast to this writer process, so session execution never waits on SQLite I/O. Readers open their own connections through `open_read_connection/1` and query by cursor with `events_after/4`; WAL mode lets those reads proceed without blocking the writer.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `db_path`

```elixir
@spec db_path(keyword()) :: String.t()
```

Returns the configured event-log database path.

# `events_after`

```elixir
@spec events_after(
  MingaAgent.EventLog.Store.db(),
  String.t(),
  non_neg_integer(),
  pos_integer()
) ::
  {:ok, [MingaAgent.EventLog.EventRecord.t()]} | {:error, term()}
```

Queries events for a session after the given cursor.

# `latest_id`

```elixir
@spec latest_id(MingaAgent.EventLog.Store.db(), String.t()) ::
  {:ok, non_neg_integer()} | {:error, term()}
```

Returns the latest event id for a session.

# `open_read_connection`

```elixir
@spec open_read_connection(keyword()) ::
  {:ok, MingaAgent.EventLog.Store.db()} | {:error, term()}
```

Opens a read connection to the agent event database.

# `record`

```elixir
@spec record(
  String.t(),
  MingaAgent.EventLog.EventRecord.event_type(),
  map(),
  GenServer.server()
) :: :ok
```

Records an agent event asynchronously.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts the event log writer.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
