Agentic.Storage.Backend behaviour (agentic v0.2.2)

Copy Markdown

Behaviour for storage backend implementations.

Formalizes the implicit 8-function contract that Storage.Local already implements. Storage.Context delegates to a backend module resolved by atom.

Summary

Callbacks

dir?(config, path)

@callback dir?(config :: map(), path :: String.t()) :: boolean()

exists?(config, path)

@callback exists?(config :: map(), path :: String.t()) :: boolean()

ls(config, path)

@callback ls(config :: map(), path :: String.t()) ::
  {:ok, [String.t()]} | {:error, term()}

materialize_local(config, path)

@callback materialize_local(config :: map(), path :: String.t()) ::
  {:ok, String.t()} | {:error, term()}

mkdir_p(config, path)

@callback mkdir_p(config :: map(), path :: String.t()) :: :ok | {:error, term()}

read(config, path)

@callback read(config :: map(), path :: String.t()) ::
  {:ok, String.t()} | {:error, term()}

rm_rf(config, path)

@callback rm_rf(config :: map(), path :: String.t()) :: :ok

write(config, path, content)

@callback write(config :: map(), path :: String.t(), content :: String.t()) ::
  :ok | {:error, term()}