Jido.Composer.ApprovalGate (Jido Composer v0.6.0)

Copy Markdown View Source

Typed sub-state for tracking approval gates in the Orchestrator.

Replaces flat gated_node_names, approval_policy, rejection_policy, and gated_calls fields in Orchestrator Strategy.

Summary

Functions

Stores gated call entries in the gate state.

Retrieves a gated call entry by request_id.

Returns true when there are pending gated calls.

Creates a new ApprovalGate from options.

Partitions tool calls into ungated (ready to dispatch) and gated (need approval).

Removes a gated call by request_id. Returns updated gate.

Checks whether a tool call requires approval based on static gating and the dynamic approval policy.

Types

t()

@type t() :: %Jido.Composer.ApprovalGate{
  approval_policy: (map(), map() -> :require_approval | term()) | nil,
  gated_calls: %{
    required(String.t()) => %{
      request: Jido.Composer.HITL.ApprovalRequest.t(),
      call: map()
    }
  },
  gated_node_names: MapSet.t(),
  rejection_policy: :abort_iteration | :cancel_siblings | :continue_siblings
}

Functions

gate_calls(gate, gated_entries)

@spec gate_calls(t(), map()) :: t()

Stores gated call entries in the gate state.

get(gate, request_id)

@spec get(t(), String.t()) :: map() | nil

Retrieves a gated call entry by request_id.

has_pending?(approval_gate)

@spec has_pending?(t()) :: boolean()

Returns true when there are pending gated calls.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new ApprovalGate from options.

partition_calls(gate, calls, context)

@spec partition_calls(t(), [map()], Jido.Composer.Context.t()) ::
  {:ok, [map()], %{required(String.t()) => map()}} | {:error, term()}

Partitions tool calls into ungated (ready to dispatch) and gated (need approval).

Returns {ungated_calls, gated_entries_map} where gated_entries_map is %{request_id => %{request: ApprovalRequest, call: call}}.

remove(gate, request_id)

@spec remove(t(), String.t()) :: t()

Removes a gated call by request_id. Returns updated gate.

requires_approval?(gate, call, context)

@spec requires_approval?(t(), map(), Jido.Composer.Context.t()) :: boolean()

Checks whether a tool call requires approval based on static gating and the dynamic approval policy.