Canonical artifact and context store for BeamAgent.
Artifacts are durable runtime outputs such as plans, diffs, reviews, summaries, approval packets, benchmark reports, and transcript snapshots. They are stored independently of live session processes and can be linked to sessions, threads, runs, and other typed references.
This is the Elixir facade over the Erlang :beam_agent_artifacts public
module. The implementation is ETS-backed and process-free, following the same
BeamAgent pattern used by the runs and control stores.
Summary
Types
Canonical artifact record.
Input map accepted by put/1,2.
Source reference stored on an artifact.
Functions
Attach a typed source reference to an existing artifact.
Clear all artifacts.
Delete an artifact by id.
Ensure the artifacts ETS table exists.
Fetch an artifact by id.
List all artifacts without filters.
List artifacts with exact-match filters.
Insert or update an artifact using embedded scope.
Insert or update an artifact with explicit scope.
Search artifacts with a case-insensitive tokenized query.
Search artifacts with a query plus exact-match filters.
Types
@type artifact() :: %{ :artifact_id => binary(), :kind => atom() | binary(), :title => binary(), :body => term(), :format => atom() | binary(), :source_refs => [source_ref()], :metadata => map(), :created_at => integer(), :updated_at => integer(), optional(:session_id) => binary(), optional(:thread_id) => binary(), optional(:run_id) => binary() }
Canonical artifact record.
@type artifact_filter() :: %{ optional(:artifact_id) => binary(), optional(:kind) => atom() | binary(), optional(:format) => atom() | binary(), optional(:title) => binary(), optional(:session_id) => binary(), optional(:thread_id) => binary(), optional(:run_id) => binary(), optional(:source_ref_type) => atom() | binary(), optional(:source_ref_id) => binary(), optional(:limit) => pos_integer(), optional(:since) => integer() }
@type artifact_input() :: %{ optional(:artifact_id) => binary(), optional(:kind) => atom() | binary(), optional(:title) => binary(), optional(:body) => term(), optional(:format) => atom() | binary(), optional(:source_refs) => [source_ref()], optional(:metadata) => map(), optional(:session_id) => binary(), optional(:thread_id) => binary(), optional(:run_id) => binary() }
Input map accepted by put/1,2.
@type scope() :: binary() | %{ optional(:session_id) => binary(), optional(:thread_id) => binary(), optional(:run_id) => binary() }
Scope passed to put/2.
Use either a binary session id or a map containing any of :session_id,
:thread_id, and :run_id.
@type source_ref() :: %{ :type => atom() | binary(), :id => binary(), optional(:metadata) => map() }
Source reference stored on an artifact.
Functions
@spec attach(binary(), atom() | binary(), binary()) :: :ok | {:error, :inconsistent_run_scope | :inconsistent_scope | :not_found | :run_not_found | :session_id_required_for_thread}
Attach a typed source reference to an existing artifact.
@spec clear() :: :ok
Clear all artifacts.
@spec delete(binary()) :: :ok | {:error, :not_found}
Delete an artifact by id.
@spec ensure_tables() :: :ok
Ensure the artifacts ETS table exists.
Fetch an artifact by id.
@spec list() :: {:ok, [artifact()]}
List all artifacts without filters.
@spec list(artifact_filter()) :: {:ok, [artifact()]} | {:error, term()}
List artifacts with exact-match filters.
@spec put(artifact_input()) :: {:ok, artifact()} | {:error, term()}
Insert or update an artifact using embedded scope.
@spec put(scope(), artifact_input()) :: {:ok, artifact()} | {:error, term()}
Insert or update an artifact with explicit scope.
Search artifacts with a case-insensitive tokenized query.
@spec search(binary(), artifact_filter()) :: {:ok, [artifact()]} | {:error, term()}
Search artifacts with a query plus exact-match filters.