Decision-table checks for the deterministic guards: Nous.Permissions,
Nous.Plugins.LoopGuard and hooks. No statistics: every row must match,
and any mismatch fails.
Rows are nous.guard_case/1 cases of kind "permission", "loop_guard"
or "hook" (Nous.Eval.Guard.Case). Policies and hooks are code, so a row
names a fixture ("guard") the caller registers in Elixir; the case
data never carries code.
fixtures = %{
permission: %{"default" => Nous.Permissions.default_policy()},
loop_guard: %{"default" => %{}},
hook: %{"no_rm_rf" => [Nous.Hook.new(:pre_tool_use, handler: &MyHooks.no_rm_rf/2)]}
}
{:ok, ds} = Nous.Eval.Guard.Dataset.load("test/fixtures/guard/deterministic")
:ok = Nous.Eval.Guard.Deterministic.check(ds.cases, fixtures)Rows
permission- input{"tool_name": string, "category": "read" | "write" | "execute" | "communicate" | "search" | null}; expected{"blocked": bool, "requires_approval": bool}fromNous.Permissions.blocked?/2andrequires_approval?/3. Fixture: a%Nous.Permissions.Policy{}.loop_guard- input{"messages": [message]}, each{"role": "user" | "assistant" | "tool" | "system", "content"?: string, "tool_calls"?: [{"name": string, "arguments": object | string}], "loop_guard"?: integer}(loop_guardmarks an advisory the plugin already injected); expected{"advisory_threshold": integer | null}: the threshold of the advisorybefore_request/3appends to that transcript, or none. Fixture: a:loop_guard_configmap.hook- input{"event": string, "payload": object}(payload keystool_name,tool_id,arguments,result,content,tool_calls,response); expected{"result": "allow" | "deny" | "modify"}plus optional"changes"(the{:modify, changes}map, string keys) fromNous.Hook.Runner.run/3over aNous.Hook.Registryof the fixture's hooks (so matchers and priorities apply as in a run). Fixture: a list of%Nous.Hook{}.
Summary
Functions
Runs every deterministic row of cases (classifier cases are ignored)
against fixtures. Returns :ok, or {:error, mismatches} listing every
row whose actual output differs, or that names an unregistered fixture
or holds malformed input (both fail).
The actual output of one deterministic row, in the shape of its
expected, or {:error, reason}.
Types
@type fixtures() :: %{ optional(:permission) => %{ required(String.t()) => Nous.Permissions.Policy.t() }, optional(:loop_guard) => %{required(String.t()) => map()}, optional(:hook) => %{required(String.t()) => [Nous.Hook.t()]} }
Functions
@spec check([Nous.Eval.Guard.Case.t()], fixtures()) :: :ok | {:error, [mismatch()]}
Runs every deterministic row of cases (classifier cases are ignored)
against fixtures. Returns :ok, or {:error, mismatches} listing every
row whose actual output differs, or that names an unregistered fixture
or holds malformed input (both fail).
@spec run(Nous.Eval.Guard.Case.t(), fixtures()) :: map() | {:error, term()}
The actual output of one deterministic row, in the shape of its
expected, or {:error, reason}.