ASM.Extensions.Policy (ASM v0.9.2)

Copy Markdown View Source

Public policy extension API.

This domain provides lightweight policy evaluation for tool governance and output budget limits with explicit violation actions.

Summary

Types

Violation action taken when a policy rule is triggered.

t()

Types

action()

Violation action taken when a policy rule is triggered.

t()

@type t() :: %ASM.Extensions.Policy{
  disallow_tools: MapSet.t(String.t()),
  max_output_tokens: non_neg_integer() | nil,
  on_budget_violation: action(),
  on_tool_violation: action()
}

Functions

enforcer_plug(policy, opts \\ [])

@spec enforcer_plug(
  t(),
  keyword()
) :: {module(), keyword()}

evaluate(policy, event, ctx)

@spec evaluate(t(), ASM.Event.t(), map()) ::
  {:ok, map()} | {:violation, ASM.Extensions.Policy.Violation.t(), map()}

Pure policy evaluation.

Returns:

  • {:ok, next_ctx} when no rule is violated
  • {:violation, violation, next_ctx} when a rule is violated

new(opts \\ [])

@spec new(keyword()) :: {:ok, t()} | {:error, ASM.Error.t()}

new!(opts \\ [])

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