Raxol.Agent.Authorization.Hook (Raxol Agent v2.6.0)

Copy Markdown View Source

Composes the ALLOW/ASK/DENY engine into the Raxol.Agent.CommandHook chain.

This is the integration seam: where Raxol.Agent.PermissionHook is deny-only, this hook evaluates the authorization engine at the :tool_call phase for each directive and maps the decision to a hook result:

  • ALLOW -> {:ok, command} (commit labels)
  • DENY -> {:deny, reason} (commit prior-ALLOW labels)
  • ASK -> resolved synchronously via a :prompter (the same pattern PermissionHook uses); on approve {:ok, command} + release escrow, on deny {:deny, {:ask_denied, prompts}}. With no prompter, a pending ASK is denied {:deny, {:requires_approval, prompts}}.

Configure per process (like PermissionHook) with configure/1; the engine State (labels, approvals) is held in the process dictionary and threaded across calls. When not configured, the hook is a neutral no-op so it composes safely with other hooks.

Summary

Functions

Remove the hook configuration for the current process.

Configure the hook for the current process.

The current label snapshot for the configured process (or %{}).

Functions

clear()

@spec clear() :: :ok

Remove the hook configuration for the current process.

configure(opts)

@spec configure(keyword()) :: :ok

Configure the hook for the current process.

Options: :policies, :labels, :monotonic, :route, and :prompter ((decision, context) -> :approve | :deny).

labels()

@spec labels() :: map()

The current label snapshot for the configured process (or %{}).