adk_memory_service behaviour (erlang_adk v0.7.0)
View SourceVersioned contract for cross-session long-term memory.
Version 2 makes the application/user authority explicit. Implementations must never infer a principal from caller supplied metadata. The old add/search/delete/session callbacks remain as compatibility entry points; new runtime code should feature-detect contract_version => 2 and use the scoped operations.
Summary
Types
-type call_options() :: #{timeout_ms => pos_integer()}.
-type entry_input() :: #{content := binary(), metadata => map(), provenance => provenance()}.
-type filter() :: map().
-type handle() :: term().
-type ingest_result() :: #{added := non_neg_integer(), duplicates := non_neg_integer(), skipped := non_neg_integer()}.
-type query() :: binary().
Callbacks
-callback add_entry(Handle :: handle(), Scope :: scope(), Input :: entry_input(), Opts :: map(), CallOptions :: call_options()) -> {ok, entry()} | {error, term()}.
-callback add_events(Handle :: handle(), Scope :: scope(), SessionId :: binary(), Events :: [adk_event:event()], Opts :: map()) -> {ok, ingest_result()} | {error, term()}.
-callback add_events(Handle :: handle(), Scope :: scope(), SessionId :: binary(), Events :: [adk_event:event()], Opts :: map(), CallOptions :: call_options()) -> {ok, ingest_result()} | {error, term()}.
-callback add_session_to_memory(Handle :: handle(), SessionId :: binary(), Events :: [adk_event:event()]) -> ok | {error, term()}.
-callback add_session_to_memory(Handle :: handle(), Scope :: scope(), SessionId :: binary(), Events :: [adk_event:event()], Opts :: map()) -> {ok, ingest_result()} | {error, term()}.
-callback delete_entry(Handle :: handle(), Scope :: scope(), Id :: binary(), CallOptions :: call_options()) -> ok | {error, not_found | term()}.
-callback delete_session(Handle :: handle(), Scope :: scope(), SessionId :: binary(), CallOptions :: call_options()) -> ok | {error, not_found | term()}.
-callback delete_user(Handle :: handle(), Scope :: scope(), CallOptions :: call_options()) -> ok | {error, not_found | term()}.