ReqManagedAgents.Artifacts behaviour (ReqManagedAgents v0.4.0)

Copy Markdown View Source

One artifacts vocabulary over provider-native session storage: list/2, fetch/3, put/4, delete/3 — name-keyed and session-scoped, because a file's NAME is the only identity the model can ever reference.

A store is {impl_module, store_term}; build the store_term with the impl's constructor:

Error normalization across impls: a missing name is {:error, :not_found}; when duplicate names exist (re-runs accumulate on CMA), list/2 returns all and fetch/delete act on the newest.

Summary

Types

store()

@type store() :: {module(), term()}

Callbacks

delete(store_term, name, opts)

@callback delete(store_term :: term(), name :: String.t(), opts :: keyword()) ::
  :ok | {:error, term()}

fetch(store_term, name, opts)

@callback fetch(store_term :: term(), name :: String.t(), opts :: keyword()) ::
  {:ok, binary()} | {:error, term()}

list(store_term, opts)

@callback list(store_term :: term(), opts :: keyword()) ::
  {:ok, [ReqManagedAgents.Artifact.t()]} | {:error, term()}

put(store_term, name, contents, opts)

@callback put(
  store_term :: term(),
  name :: String.t(),
  contents :: binary(),
  opts :: keyword()
) ::
  :ok | {:error, term()}

Functions

delete(arg, name, opts \\ [])

@spec delete(store(), String.t(), keyword()) :: :ok | {:error, term()}

fetch(arg, name, opts \\ [])

@spec fetch(store(), String.t(), keyword()) :: {:ok, binary()} | {:error, term()}

list(arg, opts \\ [])

@spec list(
  store(),
  keyword()
) :: {:ok, [ReqManagedAgents.Artifact.t()]} | {:error, term()}

put(arg, name, contents, opts \\ [])

@spec put(store(), String.t(), binary(), keyword()) :: :ok | {:error, term()}