A guard's recorded answers on a set of classifier cases, and the verdicts they replay to under any band or threshold setting.
record/3 asks the guard's model once per case:
- DecisionGuard:
Nous.Hook.Decision.verdict/3withrecord: :all_chunks(every chunk classified, no stop at the first deny), plus thePatternverdict when the ensemble runs. A model error is kept as the case's error. - InputGuard: every strategy's
check/3result, or the error that dropped it.Semanticrecordstop_similarityon every verdict, so its threshold replays in both directions;PatternandLLMJudgehave no score and replay as the fixed operating point they were recorded at.
outcomes/2 replays the recording under a subject (the recorded one, or
the same guard with other bands / thresholds): Nous.Hook.Decision.replay/2
per case, re-aggregated with the ensemble
(Nous.Plugins.InputGuard.Engine.aggregate/3). Bands never reach the
model, so a sweep costs no model calls and is exact.
Errors
A case whose model call failed replays to the guard's :on_error verdict
(DecisionGuard) or the fail-closed verdict (InputGuard, a dropped
strategy: :deny), with error?: true. Reports count errors in their own
row and never as a deny.
Cache
With cache: dir, a recording is stored under its fingerprint
(Nous.Eval.Guard.Subject.recording_fingerprint/3: model, questions, state
builder, chunking, cases and tool descriptions, not the bands) and served
from there by the next record/3 with the same fingerprint, so a baseline
is recorded once however many candidates are compared with it.
A cache file is JSON (nous.guard_recording/1). It is read back only
when every item has exactly the shape this subject records; anything else
(a tampered, truncated or foreign file) is a miss and the cases are
recorded again, and nothing in it ever becomes an atom. Still, a cache
file decides verdicts: keep the cache directory somewhere only you can
write. Cache files from earlier releases (binary term format) are
ignored and re-recorded.
Summary
Types
One case under one guard setting: its verdict (:allow | :escalate | :deny, after the error policy), whether it errored, and its scalar risk
score (the largest probability any band read; Semantic's top similarity;
nil without one).
Types
@type item() :: %{ case: Nous.Eval.Guard.Case.t(), decision: Nous.Hook.Decision.recording() | nil, pattern: Nous.Plugins.InputGuard.Result.t() | nil, strategies: [ok: Nous.Plugins.InputGuard.Result.t(), error: term()] | nil, error: term() | nil }
@type outcome() :: %{ id: String.t(), label: Nous.Eval.Guard.Case.label() | nil, split: Nous.Eval.Guard.Case.split() | nil, severity: :normal | :critical, group: String.t(), tags: [String.t()], category: String.t() | nil, certifiable?: boolean(), verdict: :allow | :escalate | :deny, error?: boolean(), score: float() | nil }
One case under one guard setting: its verdict (:allow | :escalate | :deny, after the error policy), whether it errored, and its scalar risk
score (the largest probability any band read; Semantic's top similarity;
nil without one).
@type t() :: %Nous.Eval.Guard.Recording{ fingerprint: String.t(), items: [item()], kind: Nous.Eval.Guard.Subject.kind(), surface: Nous.Eval.Guard.Case.surface() }
Functions
@spec outcomes(t(), Nous.Eval.Guard.Subject.t()) :: [outcome()]
Every recorded case's outcome/0 under subject (which must be the
recorded guard, with any bands / thresholds).
@spec record(Nous.Eval.Guard.Subject.t(), [Nous.Eval.Guard.Case.t()], keyword()) :: {:ok, t()} | {:error, term()}
Records subject on cases (classifier cases of the subject's surface;
others are ignored).
Options: :tools (tool descriptions for cases without one, see
Nous.Eval.Guard.Subject), :cache (a directory, see the moduledoc),
:max_concurrency (default 4).