Nous.Eval.Store.File (nous v0.21.1)

Copy Markdown View Source

The default Nous.Eval.Store: a directory of JSON files, no dependencies.

{:ok, store} = Nous.Eval.Store.File.init(root: "priv/eval")

Layout

<root>/runs/<run id>.json   one run, as Nous.Eval.Codec.encode_run_json/1 text
<root>/manifest.jsonl       one run summary per line, in insertion order
<root>/baselines.jsonl      one baseline entry per line, in insertion order
<root>/calibrations/sha256-<hex>.json
                            the latest judge calibration for a fingerprint id,
                            as Nous.Eval.Codec.encode_calibration_json/1 text
<root>/profiles/sha256-<hex>.json
                            one profile, as Nous.Eval.Codec.encode_profile_json/1 text
<root>/profiles.jsonl       one line per named profile: name, version, id
<root>/profile_labels.jsonl one profile label entry per line, in insertion order

list_runs/2 reads only the manifest, so listing never decodes a trace. Every file is replaced atomically (written to a temporary file in the same directory, synced, then renamed over the target), so a reader never sees a half-written run or a torn manifest line.

A run's file is written before its manifest line, and a named profile's file before its profiles.jsonl line. If the process dies in between, the record is readable by id but not listed, and putting the same run or profile again completes the write instead of failing with :already_exists or assigning another version.

Run ids, labels and profile names are checked with Nous.Eval.Store.validate_run_id/1 / validate_label/1 / validate_profile_name/1, and profile ids with validate_profile_id/1, before any path is built, so none can escape the root. The store assumes one writer per root: two processes appending to the manifest at the same moment can lose one line.

delete_runs_before/3 rewrites the manifest without the expired runs before it removes their files, so a crash in between leaves unlisted orphan files rather than a listed run that cannot be read.

Options

  • :root - the directory (required); created if missing