adk_eval_store behaviour (erlang_adk v0.10.0)

View Source

Durable-storage contract for evaluation sets, jobs, results, and baselines.

Stores are always scoped to an exact application. Eval-set revisions are immutable: writing the same canonical revision is idempotent, while trying to replace it with different content fails. Job transitions use an expected-phase list so adapters can enforce lifecycle changes atomically.

Summary

Types

handle/0

-type handle() :: term().

job/0

-type job() :: map().

phase/0

-type phase() :: queued | running | completed | failed | timed_out | cancelled.

scope/0

-type scope() :: {app, binary()}.

Callbacks

capabilities/1

-callback capabilities(Handle :: handle()) -> map().

create_evaluation/4

-callback create_evaluation(Handle :: handle(), Scope :: scope(), Set :: map(), Job :: job()) ->
                               {ok, map()} | {error, term()}.

create_job/3

-callback create_job(Handle :: handle(), Scope :: scope(), Job :: job()) ->
                        {ok, job()} | {error, already_exists | term()}.

get_baseline/3

-callback get_baseline(Handle :: handle(), Scope :: scope(), Name :: binary()) ->
                          {ok, map()} | {error, not_found | term()}.

get_job/3

-callback get_job(Handle :: handle(), Scope :: scope(), JobId :: binary()) ->
                     {ok, job()} | {error, not_found | term()}.

get_set/4

-callback get_set(Handle :: handle(), Scope :: scope(), Id :: binary(), Version :: binary()) ->
                     {ok, map()} | {error, not_found | term()}.

list_jobs/3

-callback list_jobs(Handle :: handle(), Scope :: scope(), Options :: map()) -> {ok, map()} | {error, term()}.

list_sets/3

-callback list_sets(Handle :: handle(), Scope :: scope(), Options :: map()) -> {ok, map()} | {error, term()}.

ownership_identity/1

-callback ownership_identity(ConfigOrHandle :: term()) -> {ok, term()} | defer | {error, term()}.

prune/3

-callback prune(Handle :: handle(), Scope :: scope(), Options :: map()) -> {ok, map()} | {error, term()}.

put_baseline/4

-callback put_baseline(Handle :: handle(), Scope :: scope(), Name :: binary(), JobId :: binary()) ->
                          {ok, map()} | {error, not_found | job_not_completed | term()}.

put_set/3

-callback put_set(Handle :: handle(), Scope :: scope(), Set :: map()) -> {ok, map()} | {error, term()}.

recover_active/2

-callback recover_active(Handle :: handle(), Reason :: binary()) ->
                            {ok, non_neg_integer()} | {error, term()}.

transition_job/6

-callback transition_job(Handle :: handle(),
                         Scope :: scope(),
                         JobId :: binary(),
                         Expected :: [phase()],
                         Phase :: phase(),
                         Patch :: map()) ->
                            {ok, job()} | {error, not_found | stale_phase | term()}.

Functions

digest(Value)

-spec digest(term()) -> binary().

prepare_metadata(Metadata0)

-spec prepare_metadata(term()) -> {ok, map()} | {error, term()}.

prepare_set(Set0)

-spec prepare_set(term()) -> {ok, map(), binary(), binary(), binary()} | {error, term()}.

public_job(Job)

-spec public_job(job()) -> job().

terminal_phase(_)

-spec terminal_phase(term()) -> boolean().

valid_job_id(Value)

-spec valid_job_id(term()) -> boolean().

valid_name(Value)

-spec valid_name(term()) -> boolean().

validate_scope(Scope)

-spec validate_scope(term()) -> ok | {error, invalid_eval_scope}.