# `ReqManagedAgents.Provisioner`
[🔗](https://github.com/cash-mckeeman/req_managed_agents/blob/v0.16.0/req_managed_agents/lib/req_managed_agents/provisioner.ex#L1)

Hash-keyed provision cache. `ensure/3` returns a cached provider `handle` for a given
`{provider, spec}`, plus the `:environment` digest and `:cache_scope` when given, calling
`provider.provision/2` only on a miss. The handle is the durable artifact; where the
`{hash → handle}` mapping lives is pluggable via the `ReqManagedAgents.Provisioner.Store`
behaviour (`:store` option) — in-process ETS by default, or a persistent store (e.g.
`Store.File`) for reuse across OS processes.

# `ensure`

```elixir
@spec ensure(module(), ReqManagedAgents.Provider.spec(), keyword()) ::
  {:ok, ReqManagedAgents.Provider.handle()} | {:error, term()}
```

Returns the cached handle for `spec`, provisioning it on a miss. The cache key
covers `{provider, spec}`, the `:environment` digest when given, and
`:cache_scope` when given.

`:cache_scope` is an optional non-empty string naming the authority a handle
belongs to, such as the account and endpoint whose credentials provision it,
so the same spec provisioned under two accounts is never shared between them.
Pass a reference rather than a credential, and change it when the authority
changes. Any other value returns `{:error, {:invalid_opts, :cache_scope}}`
without reading the store or calling the provider.

# `ensure_agent`

# `ensure_environment`

# `evict`

```elixir
@spec evict(
  ReqManagedAgents.Provider.handle(),
  keyword()
) :: :ok
```

Drop any cache entry whose value is `handle` (called after teardown). With a
persistent store (e.g. `Store.File`) the handle must be JSON-encodable —
same constraint as `ensure/3`'s store writes; non-encodable values raise.

# `prune_agents`

# `prune_environments`

# `resolve`

# `resolve_agent`

# `tag`

# `tag_agent`

---

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