Runtime that wraps an operation in a list of
Raxol.Agent.Policy structs.
Policies are evaluated outermost-first. The order documented in
Raxol.Agent.Policy:
- Cache (short-circuit on hit)
- RateLimit (deferred; not yet implemented)
- Timeout (wrap in a
Task, abort on wall-clock) - Retry (loop on retriable errors)
- The wrapped operation runs
Telemetry
Emits events under [:raxol, :agent, :policy, :*]:
| Event | Metadata |
|---|---|
:cache_hit | policy_kind: :cache, key, params |
:cache_miss | policy_kind: :cache, key, params |
:retry_attempt | policy_kind: :retry, attempt, reason, backoff_ms |
:retry_exhausted | policy_kind: :retry, attempt, reason |
:timeout | policy_kind: :timeout, wall_ms |
| :applied | the final outcome with :ok | :error tag |
Telemetry is fire-and-forget; consumers attach
Raxol.Agent.PolicyApplier.ThreadLogHandler (a separate
follow-up) to append :policy_result ThreadLog entries from
the events.
Summary
Types
The wrapped operation. Receives params and returns a result().
Either an ok-or-error tuple or :ok.
Functions
Apply a list of policies to fun, threading params through.
Types
Functions
@spec apply([Raxol.Agent.Policy.t()], op(), term()) :: result()
Apply a list of policies to fun, threading params through.
Returns the unwrapped result tuple. On success, the value comes from the cache (if a cache policy hit), from a successful invocation, or from a retry's final attempt. On error, the most recent reason is returned.
An empty policies list invokes fun.(params) directly.