# `ToolCall.Approval`

Approval policies and pending approval requests.

A policy is a module implementing `check/3`; `use ToolCall, approval: Policy`
installs it for every tool in the module, and `run/4` with `approval:` can
override it per call. The module option also accepts `:granted` or `:denied`
as a module-wide decision. `check/3` receives the tool IR, the raw argument map
and the caller's context, and answers:

  * `:approve` - invoke the tool;
  * `{:deny, reason}` - `{:error, {:approval_denied, reason}}`;
  * `{:required, reason}` - `{:pending, %ToolCall.Approval.Request{}}`.

This is a mechanism, not a workflow: the application persists the request,
shows it to a human, and resumes with
`ToolCall.run(request.module, request.tool, request.args, approval: :granted,
context: request.context)`. It must use the stored arguments — never model
output for an already approved call. There is no storage, timeout, retry or
double-execution guard here; the agent runtime or application owns those.

# `decision`

```elixir
@type decision() :: :approve | {:deny, term()} | {:required, term()}
```

# `check`

```elixir
@callback check(ToolCall.IR.Tool.t(), map(), term()) :: decision()
```

# `request`

```elixir
@spec request(module(), ToolCall.IR.Tool.t(), map(), term(), term()) ::
  ToolCall.Approval.Request.t()
```

Builds a pending approval request.

The runner calls this when a policy answers `{:required, reason}`. A custom
dispatcher can use it to build the same serializable shape.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
