WardrikPolicy.Decision (wardrik_policy v0.1.0-rc.1)

Copy Markdown

What a policy decided about a call, and why. Returned by WardrikPolicy.explain/3.

  • :effect - :allow, :ask or :deny.
  • :message - the prompt or refusal. nil for an allow.
  • :rule - the rule that decided, when :cause is :rule or :label.
  • :policy - the name of the policy that decided, if it has one.
  • :cause - what decided. See below.
  • :measurements - what a judge's model call used.

The :cause is one of:

  • :rule - a rule named the call.
  • :no_rule - no rule covered the whole call, so default decided.
  • :judge - the policy's judge decided.
  • :budget - a model call reached the policy's budget.
  • :label - a rule allowed a gated call, but the run had read labelled content.

Summary

Functions

Returns the strictest decision. A deny beats an ask, and an ask beats an allow.

Ranks an effect: 0 for :deny, 1 for :ask, 2 for :allow.

Types

t()

@type t() :: %WardrikPolicy.Decision{
  cause: :rule | :no_rule | :judge | :budget | :label,
  effect: :allow | :ask | :deny,
  measurements: %{optional(term()) => number()},
  message: String.t() | nil,
  policy: String.t() | nil,
  rule: String.t() | nil
}

Functions

strictest(decisions)

@spec strictest([t()]) :: t()

Returns the strictest decision. A deny beats an ask, and an ask beats an allow.

On a tie, a decision from a rule or judge beats one from a default. An empty list allows. The result carries the summed measurements of all of them.

strictness(atom)

@spec strictness(:allow | :ask | :deny) :: 0..2

Ranks an effect: 0 for :deny, 1 for :ask, 2 for :allow.