Contract-conformance tests for a Nous.Eval.Store implementation.
Like Nous.Memory.Store.Conformance, this is a test-time kit shipped in
lib/ so a backend implemented outside Nous is held to the battery Nous
runs against its own stores:
defmodule MyApp.Eval.Store.PostgresConformanceTest do
use Nous.Eval.Store.Conformance,
store: MyApp.Eval.Store.Postgres,
# Hypothetical options of your store: `init/1` creates a schema
# with a fresh unique name on every call.
init_opts: [url: System.fetch_env!("EVAL_TEST_DATABASE_URL"), schema: :unique]
endAn isolated, empty store per test
init/1 runs once per test with the same options, and the store it
returns must be empty and isolated from every other test's store,
including tests of the same module running concurrently (the suite is
async: true) and earlier runs of the suite. The kit asserts exact
list_runs/2 results and baseline histories, :not_found for labels it
never set, and that stores refuse to re-put a run id, so a store that
reopens the same database fails from the second test on. Use :tmp_dir
for a file-backed store; for a database server, have init/1 (or a
test-only wrapper module around your store) create a fresh schema or
database per call. Tests whose assertions do not depend on the rest of
the store use run ids unique per test.
Options
:store- the module under test (required):init_opts- keyword list passed toinit/1(see above):tag- a module tag, e.g.:sqlite, so a suite needing a native dependency runs only where it is installed:tmp_dir- give every test a fresh directory (ExUnit's:tmp_dir) and pass it toinit/1::rootsetsroot: dir;{:path, file}setspath: Path.join(dir, file). With it each test gets an empty store, and the suite also checks that records survive re-opening the store.use Nous.Eval.Store.Conformance, store: Nous.Eval.Store.File, tmp_dir: :root
What it covers
The put_run/2 → get_run/2 round trip of a run with a full trace
(messages, tool calls, guard verdicts), :not_found, immutability of a
stored run, list_runs/2 ordering, filters, limit and filter validation,
run id and label validation (path traversal included), and baselines:
a label needs a stored run, is append-only with its history kept, and is
:not_found when never set even though runs exist. For a store that
implements the optional calibration callbacks: the
put_calibration/3 → get_calibration/2 round trip, :not_found, the
latest result per fingerprint winning, and key validation. For a store
that implements the optional profile callbacks: round trips by id,
version and label, per-name version numbering, idempotent re-puts, name
conflicts, unnamed profiles, :not_found without fallback, append-only
label history, and validation of names, labels, ids, refs and the
profile itself. For a store that implements delete_runs_before/3: only
the task's runs started strictly before the cutoff go (other tasks and
runs without started_at stay), the count it returns, retention winning
over a baseline label, argument validation, and durability.
run_fixture/2 is the realistic run the suite stores,
calibration_fixture/2 the judge calibration and profile_fixture/3 the
profile; use them in your own tests too.
Summary
Functions
A Nous.Eval.JudgeCalibration.Result for fingerprint_id: a Likert
judge measured on 40 holdout cases with one judge error, every field set.
A sealed-looking Nous.Profile named name (nil for an unnamed one)
whose texts all contain tag: instructions with a safety rule, a tool
description and a parameter description, a manifest of fixed base hashes,
and optimizer provenance. Distinct tags give distinct ids.
A realistic Nous.Eval.Run with id id: two samples, one passing with a
full trace (run start, model start with the request messages, model stop
with an assistant Nous.Message requesting a tool, tool-call start/stop
with outcome atoms, guard verdicts, run stop), one with a scorer error.
Functions
@spec calibration_fixture(String.t(), keyword()) :: Nous.Eval.JudgeCalibration.Result.t()
A Nous.Eval.JudgeCalibration.Result for fingerprint_id: a Likert
judge measured on 40 holdout cases with one judge error, every field set.
overrides replaces top-level Nous.Eval.JudgeCalibration.Result fields.
@spec profile_fixture(String.t() | nil, String.t(), keyword()) :: Nous.Profile.t()
A sealed-looking Nous.Profile named name (nil for an unnamed one)
whose texts all contain tag: instructions with a safety rule, a tool
description and a parameter description, a manifest of fixed base hashes,
and optimizer provenance. Distinct tags give distinct ids.
overrides replaces top-level Nous.Profile fields after the id is
computed (only the unhashed name, version, parent_id and
provenance keep the id valid).
@spec run_fixture(String.t(), keyword()) :: Nous.Eval.Run.t()
A realistic Nous.Eval.Run with id id: two samples, one passing with a
full trace (run start, model start with the request messages, model stop
with an assistant Nous.Message requesting a tool, tool-call start/stop
with outcome atoms, guard verdicts, run stop), one with a scorer error.
overrides replaces top-level Nous.Eval.Run fields.