AgentHarness.Store.Memory (AgentHarness v0.2.0)

Copy Markdown View Source

Supervised, process-owned in-memory implementation of AgentHarness.Store.

The GenServer is the sole owner and writer of its state. Data does not belong to, and is not automatically removed with, the SessionServer process that wrote it. delete_session/2 is the only operation that purges a session and it cascades to that session's turns, events, and requests.

State is intentionally lost if this store process terminates. It is suitable for tests and local ephemeral use; durable adapters can implement the same behaviour without changing SessionServer.

One SessionServer should serialize event writes for a given session. Exact retries are idempotent, while conflicting or out-of-order writes are rejected. Sequence gaps are allowed because callers may choose not to persist every high-volume delta.

Summary

Functions

Reads events in ascending sequence order.

Lists requests deterministically, optionally filtering by turn and status.

Starts an empty store.

Types

option()

@type option() :: {:name, GenServer.name()} | {:id, term()}

Functions

events(owner, session_id, opts \\ [])

@spec events(GenServer.server(), String.t(), keyword()) ::
  {:ok, [AgentHarness.Event.t()]} | {:error, term()}

Reads events in ascending sequence order.

:after is exclusive. :limit defaults to :infinity. Passing :turn_id selects that turn through the Store's per-turn index before applying the cursor and limit.

list_requests(owner, session_id, opts \\ [])

@spec list_requests(GenServer.server(), String.t(), keyword()) ::
  {:ok, [AgentHarness.Request.t()]} | {:error, term()}

Lists requests deterministically, optionally filtering by turn and status.

start_link(opts \\ [])

@spec start_link([option()]) :: GenServer.on_start()

Starts an empty store.

Pass name: MyStore when the store will be addressed by a supervised name.