Jidoka.ApprovalPredicate behaviour (Jidoka v0.9.0)

Copy Markdown View Source

Module contract for dynamic operation approval predicates.

Approval predicates receive a Jidoka.Context and return whether an approval policy should apply to the current operation call. They are intentionally module-based rather than anonymous functions so agent specs and snapshots stay durable.

Summary

Callbacks

Returns whether approval is required for the operation context.

Functions

Defines a reusable approval predicate module.

Evaluates a predicate module against a runtime context.

Validates that a module implements the approval predicate contract.

Types

result()

@type result() :: boolean() | {:ok, boolean()} | {:error, term()}

Callbacks

call(t)

@callback call(Jidoka.Context.t()) :: result()

Returns whether approval is required for the operation context.

Functions

__using__(opts \\ [])

(macro)
@spec __using__(keyword()) :: Macro.t()

Defines a reusable approval predicate module.

evaluate(module, context)

@spec evaluate(module() | nil, Jidoka.Context.t()) ::
  {:ok, boolean()} | {:error, term()}

Evaluates a predicate module against a runtime context.

validate_module(module)

@spec validate_module(module() | nil) :: :ok | {:error, term()}

Validates that a module implements the approval predicate contract.