ToolCall.PolicyValidation (ToolCall v0.4.0)

Copy Markdown

A one-shot supervision-tree child that validates module-level policies at application startup.

Add it before the processes that dispatch tool calls:

children = [
  {ToolCall.PolicyValidation, [MyApp.Tools]},
  # ...
]

Each module is checked with ToolCall.validate_policies!/1. The child returns :ignore, so it does not stay in the supervision tree. An invalid policy fails application startup with ArgumentError.

The child id is ToolCall.PolicyValidation: use one child per supervisor with the complete module list. Validation runs synchronously during supervisor start, before later children start; it is not repeated by supervisor restarts.

Summary

Functions

Returns the one-shot child specification.

Validates each module and returns :ignore.

Functions

child_spec(modules)

@spec child_spec([module()] | module()) :: %{
  id: module(),
  start: {module(), :start_link, [term()]},
  restart: :temporary,
  type: :worker
}

Returns the one-shot child specification.

The id is fixed (ToolCall.PolicyValidation); use one child per supervisor with the complete module list.

start_link(modules)

@spec start_link([module()] | module()) :: :ignore

Validates each module and returns :ignore.

This runs synchronously during the supervisor's child start. An invalid policy raises ArgumentError.