Behaviour for a Nous.Plugins.DecisionGuard question pack: the questions a
decision model answers about one surface, the probability bands that turn
the answers into a verdict, and the state the model sees.
Built-in packs:
| Pack | Surface | Event |
|---|---|---|
Nous.Plugins.DecisionGuard.Packs.UserInput | :user_input | plugin before_request/3 |
Nous.Plugins.DecisionGuard.Packs.ToolCall | :tool_call | :pre_tool_use |
Nous.Plugins.DecisionGuard.Packs.ToolResult | :tool_result | :post_tool_use |
Nous.Plugins.DecisionGuard.Packs.ModelOutput | :model_output | :post_response |
Model families
Prompts and thresholds do not transfer between decision-model families
(Red Hat measured a policy tuned for one family costing another several
points). Every pack declares the family it was tuned on (model_family/0,
"clef" for the built-ins, covering Clef and Clef-Flash), and bands/1
refuses to hand out default bands for any other family: pass :bands
for every question instead.
Questions and bands
Questions are an ordered keyword list (Clef decides them jointly, in
order). Every risk question is phrased so that the risky answer reads high
("true" for a :noul). Bands are Nous.Hook.Decision bands:
{allow_below, deny_at}.
Summary
Callbacks
Default bands for questions(opts), keyed by question id. opts[:preset]
selects a preset; opts[:model_family] must equal model_family/0 (see
ensure_family!/2), or this raises ArgumentError.
Optional cross-question rule, run per chunk after the bands. It can only
raise the verdict. See Nous.Hook.Decision (:combine).
The decision-model family the questions and bands were tuned on.
The questions, in order. opts[:include] switches on opt-in groups (see
each pack).
The state the decision model sees: a JSON-framed map whose keys sort with
"untrusted_content" last. payload is the hook payload (%{content: text}
on the user-input surface); env is Nous.Hook.Decision.env/0.
The surface this pack guards.
Functions
Resolves pack's questions, bands and combine rule against user overrides,
as Nous.Hook.Decision.new/1 options (:questions, :bands, :combine).
Raises ArgumentError unless opts[:model_family] is pack's family.
Packs call it from bands/1.
The decision model's family: opts[:model_family] when given, else
"clef" when the model name contains "clef", else nil.
A %Nous.DecisionModel{} from a struct or a Nous.DecisionModel.parse/2
string.
Types
@type surface() :: :user_input | :tool_call | :tool_result | :model_output
@type verdict() :: Nous.Hook.Decision.verdict()
Callbacks
Default bands for questions(opts), keyed by question id. opts[:preset]
selects a preset; opts[:model_family] must equal model_family/0 (see
ensure_family!/2), or this raises ArgumentError.
@callback combine( answers :: %{required(atom()) => Nous.DecisionModel.Answer.t()}, verdict() ) :: verdict()
Optional cross-question rule, run per chunk after the bands. It can only
raise the verdict. See Nous.Hook.Decision (:combine).
@callback model_family() :: String.t()
The decision-model family the questions and bands were tuned on.
The questions, in order. opts[:include] switches on opt-in groups (see
each pack).
The state the decision model sees: a JSON-framed map whose keys sort with
"untrusted_content" last. payload is the hook payload (%{content: text}
on the user-input surface); env is Nous.Hook.Decision.env/0.
@callback surface() :: surface()
The surface this pack guards.
Functions
Resolves pack's questions, bands and combine rule against user overrides,
as Nous.Hook.Decision.new/1 options (:questions, :bands, :combine).
opts:
:questions-nil(the pack's),{:replace, questions}or{:extend, questions}(appended after the pack's).:bands-%{id => band}; wins over the pack's. When every question has one, the pack's defaults are not consulted (so another family works); otherwise they are, andbands/1refuses a foreign family.:preset,:include,:model_family- passed to the pack.
The pack's combine/2 applies only to its own (not replaced) questions on
its own family.
Raises ArgumentError unless opts[:model_family] is pack's family.
Packs call it from bands/1.
@spec model_family(Nous.DecisionModel.t(), keyword()) :: String.t() | nil
The decision model's family: opts[:model_family] when given, else
"clef" when the model name contains "clef", else nil.
@spec resolve_model!(Nous.DecisionModel.t() | String.t()) :: Nous.DecisionModel.t()
A %Nous.DecisionModel{} from a struct or a Nous.DecisionModel.parse/2
string.