Browse documentation
Python API
View Markdown
On this page

gvn.evals

Measuring how well a version of a harness does its job: cases, criteria, judges, trials, reports and comparisons.

The ideas behind it are explained in Evals, Writing the project. This page is generated from the source, so it lists every public name with its signature and docstring. Python API has the other packages and an index of every name.

Modules

Module What it holds Names
gvn.evals.cases Cases and datasets: the examples an eval runs Case, Dataset
gvn.evals.comparison Comparison: is the candidate better than the baseline, worse, or can't we tell? Incomparable, Comparison, Verdict
gvn.evals.criteria Criteria: the rules that say whether a trial was good code_identity, Ask, Criterion, Checked, Answer, EnvironmentHolds, Spends, Named, Criteria
gvn.evals.evidence Evidence and scores: what a criterion reads, and what it answers Score, Judgement, Evidence
gvn.evals.judging Criteria judged by a model (Judge) or by a person (Review) shown, Judge, Review, Agreement
gvn.evals.ports The ports of the evals layer: what running an eval needs from outside Subject, Environment, Environments, StandIn, ManifestMismatch, Results
gvn.evals.report Report: what an eval run found, for people and for gates Report
gvn.evals.running Running an eval: every case, as many trials as asked, each in a fresh environment Eval, OverBudget, Runner
gvn.evals.stand_ins Stand-ins ready to use: who answers, in a trial, what a person answers in production Approving
gvn.evals.statistics Statistics for evals: rates with honest intervals, and paired differences stability, Interval, Rate, Difference

gvn.evals.cases

Cases and datasets: the examples an eval runs.

A Case is one example job (its brief) and what a good result looks like (its expect), with tags to select by. A Dataset is a named, ordered set of Cases; its fingerprint is a hex sha256 over the cases' content, so two reports over equal cases compare.

Case

from gvn.evals.cases import Case
Case(
    case_id: str,
    brief: dict[str, typing.Any],
    expect: dict[str, typing.Any] | None = None,
    tags: Iterable[str] = (),
) -> None

One example job and what a good result looks like. Immutable; equal by content.

case_id: a name of [A-Za-z0-9][A-Za-z0-9_-]* (it becomes part of a run id), unique in its dataset. brief: the plain JSON dict a run of the harness is started with. expect: None or a plain JSON dict of reference data that criteria may read and the harness under evaluation never sees. tags: distinct non-empty strs (kept sorted). TypeError / ValueError otherwise. Everything returned is a copy.

No expect and an empty one are the same: expect() and the plain form give {} for both. Tuples in the brief or the expect are held as lists.

Case.case_id

case_id() -> str

Case.brief

brief() -> dict[str, typing.Any]

Case.expect

expect() -> dict[str, typing.Any]

The reference data; {} when none was given.

Case.tags

tags() -> tuple[str, ...]

Case.tagged

tagged(tag: str) -> bool

Case.to_plain

to_plain() -> dict[str, typing.Any]

{"case_id", "brief", "expect", "tags"} as plain JSON.

Case.from_plain

from_plain(plain: object) -> typing.Self

The Case of a to_plain dict (expect and tags may be absent). ValueError naming what is wrong otherwise: plain data is untrusted.

Case.to_dto

to_dto() -> Dto

A Dto capturing the complete internal state. Does not mutate the object.

Case.from_dto

from_dto(dto: Dto) -> typing.Self

Dataset

from gvn.evals.cases import Dataset
Dataset(name: str, cases: Iterable[Case]) -> None

A named, ordered set of Cases with distinct ids. Immutable; equal by content.

name: non-empty str. cases: a non-text iterable of Case, at least one. Two cases with one id are a ValueError naming it. Equality counts the name and the order of the cases; the fingerprint counts neither.

Dataset.name

name() -> str

Dataset.cases

cases() -> tuple[Case, ...]

Dataset.case

case(case_id: str) -> Case

KeyError naming the id when absent.

Dataset.fingerprint

fingerprint() -> str

A hex digest of the cases' content in a canonical form (sorted keys; the order of the cases and the dataset's name do not count). Equal content, equal fingerprint: it is what makes two reports comparable.

Dataset.tagged

tagged(tag: str) -> Dataset

The cases carrying tag, under the name "<name>[<tag>]". ValueError when none does.

Dataset.without

without(tag: str) -> Dataset

The cases not carrying tag, under "<name>[-<tag>]". ValueError when none is left.

Dataset.to_plain

to_plain() -> dict[str, typing.Any]

{"name", "cases": [case plain, ...]}.

Dataset.from_plain

from_plain(plain: object) -> typing.Self

The Dataset of a to_plain dict. ValueError naming what is wrong otherwise: plain data is untrusted.

gvn.evals.comparison

Comparison: is the candidate better than the baseline, worse, or can't we tell?

The verdict comes from the paired difference in pass rate over the cases both eval runs judged (gvn.evals.statistics.Difference) and its interval, and only once every case was judged in both runs and enough cases were: until then there is not enough data to tell, and the comparison says why. Verdict is the kernel Decision over a Comparison, so a workflow routes on it.

Constants: UNJUDGED, BETTER, NO_BETTER, WORSE, INCONCLUSIVE, VERDICTS, IN_WORDS.

Incomparable

from gvn.evals.comparison import Incomparable

Two eval runs cannot be compared: they ran different cases or other criteria.

Comparison

from gvn.evals.comparison import Comparison
Comparison(
    baseline: Mapping[str, Mapping[str, Sequence[bool | None]]],
    candidate: Mapping[str, Mapping[str, Sequence[bool | None]]],
    margin: float = 0.0,
    confidence: float = 0.95,
    seed: int = 0,
    min_cases: int = 6,
) -> None

A candidate eval run against a baseline over the same cases. Immutable.

baseline / candidate: mappings of criterion name -> (case id -> sequence of bool | None per trial); the special name "passed" holds whether each trial passed overall and must be present in both (ValueError otherwise). The cases are every case id either side lists for "passed" (Report.compare lists every case of the cases file, run or not). margin: a float >= 0, the smallest difference in pass rate that matters (default 0.0). min_cases: an int >= 1, the fewest cases judged in both runs before a verdict other than INCONCLUSIVE is given (default 6: the fewest pairs over which a two-sided sign test can reach 95%; TypeError for a non-int, ValueError below 1). Only criteria present in both, and judged in both on at least one same case, are compared, in the order candidate lists them (Report.compare lists the must-pass criteria before the measured ones). Incomparable when the two share no judged case for "passed".

The verdict, read from the Difference of "passed": INCONCLUSIVE, with a reason(), when a case was not judged in either run (a case with no judged trial on one side) or fewer than min_cases cases were judged in both; otherwise from its interval: BETTER when the whole interval lies above margin; WORSE when it lies below -margin; NO_BETTER when it lies within [-margin, margin] (for margin 0: when it is exactly [0, 0]); INCONCLUSIVE otherwise. Every other compared criterion gets its own verdict by the same rule, over its own cases.

Comparison.verdict

verdict(criterion: str = 'passed') -> str

The verdict of "passed" (the comparison's own), or of another compared criterion. KeyError for a criterion that was not compared.

Comparison.in_words

in_words(criterion: str = 'passed') -> str

IN_WORDS[verdict(criterion)].

Comparison.reason

reason(criterion: str = 'passed') -> str | None

Why there is not enough data to tell, in words, when the verdict was not read from the interval at all: some cases were not judged in one run or both ("9 of 10 cases were not judged in the candidate; run it again to finish them"), or too few cases were judged in both ("only 5 cases were judged in both runs, and telling needs at least 6; add cases and run both versions again"). None when the verdict was read from the interval. KeyError for a criterion that was not compared.

Comparison.min_cases

min_cases() -> int

Comparison.criteria

criteria() -> tuple[str, ...]

The compared criterion names: "passed" first, then the rest in the order the candidate's mapping lists them.

Comparison.difference

difference(criterion: str = 'passed') -> Difference

KeyError for a criterion that was not compared.

Comparison.summary

summary() -> str

Readable text: the verdict in words (with reason() when there is one: "Compared with the baseline: not enough data to tell whether the candidate is better, because 9 of 10 cases were not judged in the candidate; run it again to finish them."), then one line per criterion, in the order of criteria(), with the difference in percentage points, the range it likely lies in and how many cases rose and fell ("passed overall: +5 percentage points (likely between 0 and +15) over 20 cases; 2 did better, 1 did worse"), followed, for a criterion other than "passed" whose reason() differs from the one the first line gives, by "; not enough data to tell, because ..."; and, last, one line naming the confidence level of the likely ranges when it is not 95% ("The likely ranges are 90% intervals.").

Comparison.to_plain

to_plain() -> dict[str, typing.Any]

{"verdict", "in_words", "reason", "margin", "min_cases", "criteria": [{"name", "cases", "mean", "low", "high", "improved": [case ids], "worsened": [case ids], "verdict", "in_words", "reason", "unjudged_in_baseline": [case ids], "unjudged_in_candidate": [case ids]}]}. reason is reason() (null when the verdict was read from the interval); cases counts the cases judged in both runs; the two unjudged_in_... lists name, sorted, the cases with no judged trial on that side.

Verdict

from gvn.evals.comparison import Verdict
Verdict()

The kernel Decision over a Comparison, with outcomes VERDICTS, so a workflow (an improver) routes on whether a candidate did better.

Verdict.outcomes

outcomes() -> Alphabet

The Alphabet of every answer this decision can give. Must not vary over time.

Verdict.judge

judge(comparison: object) -> Symbol

TypeError unless a Comparison.

gvn.evals.criteria

Criteria: the rules that say whether a trial was good.

A criterion is a pure function of recorded Evidence. One that needs a model's or a person's opinion says so through asks; the runner gets that opinion in a journaled run of its own and hands it back inside the Evidence, so scoring stays pure and can be repeated offline.

Constants: ABC.

code_identity

from gvn.evals.criteria import code_identity
code_identity(function: object) -> str

How a function-backed criterion names its function in its fingerprint: module.qualname (of a callable object: of its class) and, where the code can be read, a space and 12 hex characters that change when what that code does is edited: a digest of its parsed source without annotations and docstrings, or of its compiled code where the source cannot be read or parsed. Type hints, docstrings, comments and formatting never change it; a changed constant, name or operator does. It covers that one function or class: not the helpers it calls, not the values it closes over, not the state of a callable object.

Ask

from gvn.evals.criteria import Ask
Ask(
    actor: Actor,
    event: Event,
    model_role: str | None = None,
    person: bool = False,
) -> None

A question a criterion needs answered before it can score: an actor to run and the event that starts it. Immutable.

actor: a fresh Actor named run_id (the name the runner passed to asks). event: the Event that starts it. model_role: None, or the model role its model calls name ("judge"). person: True when the actor parks on a request_input that a person answers (a review), False when it runs to its end on its own (a judge). TypeError / ValueError otherwise. Two Asks are equal when they hold the same actor object and equal parts otherwise.

Ask.actor

actor() -> Actor

Ask.event

event() -> Event

Ask.model_role

model_role() -> str | None

Ask.person

person() -> bool

Criterion

from gvn.evals.criteria import Criterion
Criterion()

Helper class that provides a standard way to create an ABC using inheritance.

Criterion.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Criterion.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Criterion.model_roles

model_roles() -> tuple[str, ...]

The model roles whose models give this criterion's verdicts (("judge",) for a Judge). Default: none. Which model serves a role is part of how the criterion judges: the runner records it in the criterion's scoring identity, so a verdict given by one model is never reused under another.

Criterion.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Criterion.asks

asks(evidence: Evidence, run_id: str) -> Ask | None

None (the default), or the Ask whose answer this criterion needs and the evidence does not hold yet. Pure and deterministic.

Criterion.reads

reads(outcome: Outcome, by: str, run_id: str) -> Judgement

The Judgement in the Outcome of this criterion's finished Ask. Only called for a criterion whose asks returned an Ask. ValueError when the outcome holds no verdict this criterion declared (the judge failed).

Checked

from gvn.evals.criteria import Checked
Checked(check: Check) -> None

A gvn.runtime.evaluation.Check as a criterion: passes when the check finds no problem in the trial's trace; the problems are the explanation (joined with "; "). Name: the check's name. Fingerprint: the name and, where it can be read, a digest of the code of the check's class (as code_identity takes it: not its type hints, docstrings or layout, not the helpers it calls), so editing what the check does changes the fingerprint. A trial with no trace fails, saying the trial has no recorded run. A check that returns anything but a tuple of str is a TypeError; an exception it raises propagates. Two are equal when their checks' names are.

Checked.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Checked.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Checked.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Answer

from gvn.evals.criteria import Answer
Answer(label: str, accepts: Callable[[typing.Any, Case], bool | Score]) -> None

The run finished and accepts(payload, case) is true of its outcome's payload (plain JSON, a copy) and the Case. accepts returns a bool (TypeError otherwise) or a Score. A run that did not finish fails. Name: label.

A Score from accepts is the score as it is; True is Score.passing() and False Score.failing("<label> was not satisfied"). An exception accepts raises propagates. label: a non-empty str; accepts: callable. Fingerprint: "answer <label>: <module>.<qualified name of accepts> <digest>", the digest 12 hex characters of the code of accepts as code_identity takes it (left out where the code cannot be read): editing what accepts does changes it; editing its type hints, docstring, comments or layout, or a helper it calls, does not. Two are equal when their fingerprints are.

Answer.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Answer.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Answer.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

EnvironmentHolds

from gvn.evals.criteria import EnvironmentHolds
EnvironmentHolds(
    label: str,
    accepts: Callable[[dict[str, typing.Any], Case], bool | Score],
) -> None

accepts(observed, case) is true of what the trial's environment reported when the run ended (plain JSON, a copy) and the Case. Returns a bool or a Score. Name: label.

Judged whether or not the run finished. A Score from accepts is the score as it is; True is Score.passing() and False Score.failing("&lt;label> was not satisfied"); anything else is a TypeError, and an exception accepts raises propagates. Fingerprint: "environment holds &lt;label>: &lt;module>.&lt;qualified name of accepts> &lt;digest>", the digest as Answer has it (the code of accepts, not of the helpers it calls). Two are equal when their fingerprints are.

EnvironmentHolds.name

name() -> str

A short str, unique in its Criteria, shown in every report.

EnvironmentHolds.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

EnvironmentHolds.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Spends

from gvn.evals.criteria import Spends
Spends(tokens: int | None = None, calls: int | None = None) -> None

The trial's model calls stayed within limits: tokens (input + output) and calls, each None or an int >= 0, at least one given. Reads Trace.usage(). Name: "spends at most <...>": "spends at most 5000 tokens", "spends at most 3 calls", "spends at most 5000 tokens and 3 calls". Fingerprint: the name. A failure names each limit exceeded; a pass says what was spent. A trial with no trace fails, saying the trial has no recorded run.

Spends.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Spends.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Spends.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Named

from gvn.evals.criteria import Named
Named(name: str, criterion: Criterion | Check) -> None

A criterion shown in reports under another name: Named("polite", criterion), where criterion is a Criterion or a Check (wrapped in Checked). Scores, asks and reads as the criterion does and has its fingerprint. The evidence it hands the criterion holds this name's judgement under the criterion's own name, where a judge or a review looks for it. criterion() is the criterion wrapped. Two are equal when their names and fingerprints are.

Named.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Named.criterion

criterion() -> Criterion

Named.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Named.model_roles

model_roles() -> tuple[str, ...]

The model roles whose models give this criterion's verdicts (("judge",) for a Judge). Default: none. Which model serves a role is part of how the criterion judges: the runner records it in the criterion's scoring identity, so a verdict given by one model is never reused under another.

Named.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Named.asks

asks(evidence: Evidence, run_id: str) -> Ask | None

None (the default), or the Ask whose answer this criterion needs and the evidence does not hold yet. Pure and deterministic.

Named.reads

reads(outcome: Outcome, by: str, run_id: str) -> Judgement

The Judgement in the Outcome of this criterion's finished Ask. Only called for a criterion whose asks returned an Ask. ValueError when the outcome holds no verdict this criterion declared (the judge failed).

Criteria

from gvn.evals.criteria import Criteria
Criteria(
    name: str,
    must_pass: Iterable[Criterion | Check],
    measured: Iterable[Criterion | Check] = (),
) -> None

The criteria of an eval, in two groups. Immutable.

must_pass: a trial passes when every one of these passes. measured: scored and reported, never deciding whether the trial passed. A Check given in either group is wrapped in Checked. At least one criterion in must_pass; names distinct across both groups (ValueError naming the duplicate). name: a non-empty str. A criterion whose name() is not a non-empty str is a TypeError. Equal when the name and both groups, in order, are equal.

Criteria.name

name() -> str

Criteria.must_pass

must_pass() -> tuple[Criterion, ...]

Criteria.measured

measured() -> tuple[Criterion, ...]

Criteria.all

all() -> tuple[Criterion, ...]

must_pass then measured.

Criteria.named

named(name: str) -> Criterion

KeyError when absent.

Criteria.fingerprint

fingerprint() -> str

A hex digest over each criterion's name, group and fingerprint (a hex sha256 of their canonical JSON). The criteria's own name and their order do not count. A criterion whose fingerprint() is not a str is a TypeError naming it.

Criteria.score

score(evidence: Evidence) -> dict[str, Score]

Criterion name -> Score for every criterion, in order. A criterion that raises, or returns something other than a Score, is a TypeError naming it.

Criteria.passed

passed(scores: Mapping[str, Score]) -> bool | None

Whether the trial passed: False when any must-pass criterion failed, else None when any could not judge, else True. scores: a mapping of criterion name -> Score holding every must-pass criterion (ValueError naming one that is missing; other entries are not read).

gvn.evals.evidence

Evidence and scores: what a criterion reads, and what it answers.

Everything here is an immutable value, equal by content, validated by its constructor. Score and Judgement have to_plain / from_plain (that is how a trial record stores them); an Evidence is rebuilt from the journal and the record.

Constants: FINISHED, PARKED, ERRORED, STATUSES.

Score

from gvn.evals.evidence import Score
Score(
    passed: bool | None,
    value: float | None = None,
    label: str = '',
    explanation: str = '',
) -> None

What one criterion says about one trial.

passed: True, False, or None when the criterion could not judge (a review nobody answered yet, a judge that answered "cannot tell"). value: None exactly when passed is None, else a float in [0, 1] (1.0 / 0.0 unless the criterion grades in between). label: a short str (a judge's verdict name; may be empty). explanation: a str for people (may be empty).

Score.passing

passing(explanation: str = '') -> typing.Self

Score.failing

failing(explanation: str) -> typing.Self

Score.unjudged

unjudged(explanation: str) -> typing.Self

Score.passed

passed() -> bool | None

Score.judged

judged() -> bool

Score.value

value() -> float | None

Score.label

label() -> str

Score.explanation

explanation() -> str

Score.to_plain

to_plain() -> dict[str, typing.Any]

{"passed", "value", "label", "explanation"}.

Score.from_plain

from_plain(plain: object) -> typing.Self

The Score of a to_plain dict (every field present). ValueError naming what is wrong otherwise: plain data is untrusted.

Judgement

from gvn.evals.evidence import Judgement
Judgement(verdict: str, reasoning: str, by: str, run_id: str) -> None

The recorded answer of a judge (a model) or a reviewer (a person) to one criterion's question about one trial.

verdict: non-empty str, one of the verdicts the criterion declared. reasoning: str (may be empty). by: non-empty str naming who answered: a model's name for a judge, a principal's subject for a reviewer. run_id: the journaled run in which the question was asked and answered (a non-empty str). TypeError / ValueError otherwise.

Judgement.verdict

verdict() -> str

Judgement.reasoning

reasoning() -> str

Judgement.by

by() -> str

Judgement.run_id

run_id() -> str

Judgement.to_plain

to_plain() -> dict[str, typing.Any]

{"verdict", "reasoning", "by", "run_id"}.

Judgement.from_plain

from_plain(plain: object) -> typing.Self

The Judgement of a to_plain dict (every field present). ValueError naming what is wrong otherwise: plain data is untrusted.

Evidence

from gvn.evals.evidence import Evidence
Evidence(
    case: Case,
    status: str,
    trace: Trace | None,
    observed: Mapping[str, typing.Any] | None = None,
    judgements: Mapping[str, Judgement] | None = None,
) -> None

Everything recorded about one trial: all a criterion may read. No criterion performs I/O; what is not in the evidence cannot be judged.

case: the Case. status: one of STATUSES. trace: the Trace of the trial's run (None only for an ERRORED trial that never began). observed: plain JSON dict, what the trial's environment reported when the run ended ({} when nothing). judgements: mapping of criterion name -> Judgement, the answers recorded so far.

A FINISHED trial's trace is finished and a PARKED trial's is not (ValueError otherwise). TypeError / ValueError for anything else wrong.

Evidence.case

case() -> Case

Evidence.status

status() -> str

Evidence.trace

trace() -> Trace | None

Evidence.outcome

outcome() -> Outcome | None

The run's Outcome when it finished, else None.

Evidence.observed

observed() -> dict[str, typing.Any]

A fresh copy.

Evidence.judgement

judgement(criterion: str) -> Judgement | None

The Judgement recorded for criterion, or None.

Evidence.judgements

judgements() -> dict[str, Judgement]

A fresh dict of criterion name -> Judgement.

Evidence.judged

judged(criterion: str, judgement: Judgement) -> Evidence

A new Evidence that also holds judgement under criterion (in place of any Judgement it held for that criterion).

gvn.evals.judging

Criteria judged by a model (Judge) or by a person (Review).

Neither holds a model or talks to anyone. Each builds an actor (asks) that the runner drives under a Governor in a journaled run of its own, and reads the verdict back (reads); score then reads the Judgement from the Evidence. So who judged, what they were shown and what it cost is in the journal, and a verdict is only ever one of a finite declared set.

Constants: PASS, FAIL, CANNOT_TELL, JUDGE_ROLE.

shown

from gvn.evals.judging import shown
shown(evidence: Evidence) -> str

The default account of a trial given to a judge or a reviewer, as text: the case's brief, how the run ended and its outcome's payload, what the environment reported, and the conversation as recorded (each message's role and text, each tool call's name, arguments and result), bounded in length (the middle is elided, saying so). The case's expect is included under a heading of its own.

Judge

from gvn.evals.judging import Judge
Judge(
    name: str,
    statement: str,
    passes: str | None = None,
    fails: str | None = None,
    verdicts: Mapping[str, float | None] | None = None,
    passing: float = 1.0,
    shows: Callable[[Evidence], str] | None = None,
) -> None

A statement a model judges true or false of a trial.

name: the criterion's name. statement: what must be true of a good trial, in plain words ("The reply is polite and does not blame the customer."). passes / fails: None, or an example (str) of an answer that satisfies / breaks the statement, shown to the judge. verdicts: None for {PASS: 1.0, FAIL: 0.0, CANNOT_TELL: None}, or a mapping of verdict name -> value (a float in [0, 1], or None for "could not judge"): at least two, at least one with a value. passing: the least value that counts as passed (default 1.0). shows: None for shown, or a function evidence -> str choosing what the judge reads.

asks: None once the evidence holds this criterion's Judgement, or when the trial did not finish; otherwise an Ask whose actor asks the model, under the role JUDGE_ROLE, for its reasoning and then one of the verdicts, through the vendor's own structured output (an Agent with answer=; no tools). reads turns that actor's Outcome into a Judgement (ValueError when it did not complete with a declared verdict). score: unjudged while there is no Judgement (and for a verdict whose value is None); otherwise the verdict's value, passed when it is

= passing, with the verdict as label and the reasoning as explanation. A trial that did not finish fails without asking.

fingerprint covers the statement, examples, verdicts and passing.

Judge.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Judge.statement

statement() -> str

Judge.verdicts

verdicts() -> dict[str, float | None]

A fresh dict of verdict name -> value, in the order declared.

Judge.model_roles

model_roles() -> tuple[str, ...]

The model roles whose models give this criterion's verdicts (("judge",) for a Judge). Default: none. Which model serves a role is part of how the criterion judges: the runner records it in the criterion's scoring identity, so a verdict given by one model is never reused under another.

Judge.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Judge.asks

asks(evidence: Evidence, run_id: str) -> Ask | None

None (the default), or the Ask whose answer this criterion needs and the evidence does not hold yet. Pure and deterministic.

Judge.reads

reads(outcome: Outcome, by: str, run_id: str) -> Judgement

The Judgement in the Outcome of this criterion's finished Ask. Only called for a criterion whose asks returned an Ask. ValueError when the outcome holds no verdict this criterion declared (the judge failed).

Judge.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Review

from gvn.evals.judging import Review
Review(
    name: str,
    question: str,
    verdicts: Mapping[str, float | None] | None = None,
    passing: float = 1.0,
    shows: Callable[[Evidence], str] | None = None,
) -> None

A question a person answers about a trial, choosing one of declared verdicts.

Arguments as Judge (question in place of statement; no examples). asks: an Ask with person=True whose actor is a gvn.harness.inquiry.Inquiry showing shows(evidence) and the question, with the verdict names as its choices; it parks until someone answers, and the Judgement's by is the answering principal's subject. Until then the score is unjudged. Unlike a Judge, a Review is asked about a trial that did not finish too.

Review.name

name() -> str

A short str, unique in its Criteria, shown in every report.

Review.question

question() -> str

Review.verdicts

verdicts() -> dict[str, float | None]

A fresh dict of verdict name -> value, in the order declared.

Review.fingerprint

fingerprint() -> str

A str that changes when this criterion would judge differently (for a function-backed one: its label, the function's qualified name and a digest of the function's code).

Review.asks

asks(evidence: Evidence, run_id: str) -> Ask | None

None (the default), or the Ask whose answer this criterion needs and the evidence does not hold yet. Pure and deterministic.

Review.reads

reads(outcome: Outcome, by: str, run_id: str) -> Judgement

The Judgement in the Outcome of this criterion's finished Ask. Only called for a criterion whose asks returned an Ask. ValueError when the outcome holds no verdict this criterion declared (the judge failed).

Review.score

score(evidence: Evidence) -> Score

The Score of one trial. Pure: no I/O, the same evidence gives an equal score. An ERRORED trial is never scored (the runner does not ask).

Agreement

from gvn.evals.judging import Agreement
Agreement(pairs: typing.Sequence[tuple[str, str]]) -> None

How far a judge agrees with people: the comparison of two verdicts given to the same trials (typically a Judge's and a Review's). Immutable.

pairs: a sequence of (verdict_a, verdict_b) strs, at least one.

Agreement.total

total() -> int

Agreement.agreed

agreed() -> int

Agreement.rate

rate() -> float

agreed / total.

Agreement.kappa

kappa() -> float | None

Cohen's kappa: agreement beyond chance; None when chance agreement is 1 (both always gave one same verdict).

Agreement.confusion

confusion() -> dict[tuple[str, str], int]

(verdict_a, verdict_b) -> how many trials.

gvn.evals.ports

The ports of the evals layer: what running an eval needs from outside.

The abstract interfaces of. Fakes and contract suites for them live in gvn.testing.

Constants: ABC.

Subject

from gvn.evals.ports import Subject
Subject()

The version of a harness being evaluated: how to start one run of it.

Subject.name

name() -> str

What reports call this version ("baseline", "shorter-prompt").

Subject.fingerprint

fingerprint() -> str

A str that changes whenever this version would behave differently: its definition's fingerprint together with its settings' (and the instructions and anything else its builder varies). Recorded with every eval run.

Subject.actor_class

actor_class() -> type[Actor]

The Actor subclass of its runs (what Replay and Recovery rebuild).

Subject.start

start(run_id: str, brief: dict[str, typing.Any]) -> tuple[Actor, Event]

(actor, event): a fresh actor named run_id and the Event that starts it. Deterministic. ValueError for a brief it does not admit.

Environment

from gvn.evals.ports import Environment
Environment()

The world of ONE trial: the tools a run acts on, fresh for that trial, and what can be seen of it afterwards. Never shared between trials.

Environment.toolbox

toolbox() -> Toolbox

The tools of this trial, bound to this trial's world.

Environment.policy

policy() -> Decision

The tool policy (outcomes gvn.harness.agent.VERDICTS).

Environment.fulfillers

fulfillers() -> dict[str, Fulfiller]

Extra request kind -> Fulfiller the subject's actors need. Default: none.

Environment.external

external() -> tuple[str, ...]

Extra request kinds answered from outside (by the StandIn). Default: none.

Environment.observe

async def observe() -> dict[str, typing.Any]

What the world looks like now, as plain JSON: the state criteria judge (rows written, files changed, the result of hidden tests). Called once, when the trial's run has ended or parked. Its answer is stored with the trial, so criteria never touch the world.

Environment.close

async def close() -> None

Release what the trial held. Called once, after observe, also when the trial failed.

Environments

from gvn.evals.ports import Environments
Environments()

Opens a fresh Environment for each trial.

Environments.name

name() -> str

Recorded with every eval run.

Environments.open

async def open(case: Case, trial: int) -> Environment

A fresh Environment for trial number trial (0-based) of case, prepared from the case (its brief and expect).

StandIn

from gvn.evals.ports import StandIn
StandIn()

Answers, in a trial, what a person or an outside system would answer in production: approvals, questions, a conversation's next message.

StandIn.name

name() -> str

Recorded with every eval run.

StandIn.answer

async def answer(request: Request, case: Case) -> Event | None

The Event answering request (an external request the run is waiting on), or None to leave it unanswered (the trial then ends parked). Asked again for a request re-issued after a crash, so the same request should get an equal answer where it can.

ManifestMismatch

from gvn.evals.ports import ManifestMismatch

An eval run was opened under a name that already holds a run of something else.

Results

from gvn.evals.ports import Results
Results()

The store of eval runs: for each, what was run (its manifest) and one record per trial. Records and manifests are plain JSON dicts; everything returned is a copy; what a method wrote survives the process once it returns.

It also holds the claims that keep two runners off one trial: whoever is about to run a trial claims it first, for a while, and renews the claim while it works. A claim that is not renewed runs out, so a runner that died blocks nothing for long. Times are seconds as the claimants' clock counts them; the store compares the numbers it is given and reads no clock of its own.

Results.open

async def open(run_name: str, manifest: dict[str, typing.Any]) -> None

Begin the eval run run_name with manifest, or continue it: opening a name that exists with an equal manifest changes nothing; with a different one it raises ManifestMismatch naming the keys that differ, and writes nothing.

Results.amend

async def amend(run_name: str, manifest: dict[str, typing.Any]) -> None

Replace the manifest of the eval run run_name, in one step. LookupError when there is no such run. For scoring a recorded run again under changed criteria; open remains the only way to begin a run.

Results.manifest

async def manifest(run_name: str) -> dict[str, typing.Any] | None

The manifest of run_name, or None when there is no such eval run.

Results.runs

async def runs() -> tuple[str, ...]

The names of every eval run, oldest first.

Results.save_trial

async def save_trial(
    run_name: str,
    case_id: str,
    trial: int,
    record: dict[str, typing.Any],
) -> None

Keep record as trial trial of case_id, replacing an earlier record of that trial. LookupError for an eval run that was not opened.

Results.trials

async def trials(run_name: str) -> tuple[dict[str, typing.Any], ...]

Every trial record of run_name, ordered by the order in which each (case, trial) was first saved. Empty for an unknown run.

Results.claim

async def claim(
    run_name: str,
    case_id: str,
    trial: int,
    owner: str,
    now: float,
    until: float,
) -> bool

Take, or renew, owner's claim on trial trial of case_id until until: True when the trial was unclaimed, its claim had run out (its until <= now) or was owner's already; False when another owner's claim is still live, and then nothing changes. One step: of two owners claiming at once, exactly one gets True. owner: a non-empty str; now and until: finite numbers with until > now (ValueError otherwise). LookupError for an eval run that was not opened.

Results.release

async def release(run_name: str, case_id: str, trial: int, owner: str) -> None

Give up owner's claim on that trial. Changes nothing when owner holds none there (it ran out and another took it, or it was never taken).

Results.claims

async def claims(run_name: str, now: float) -> tuple[tuple[str, int, str], ...]

The claims of run_name still live at now, each (case_id, trial, owner), ordered by case id then trial. Empty for an unknown run.

gvn.evals.report

Report: what an eval run found, for people and for gates.

A Report is a pure reading of an eval run's manifest and trial records (the plain dicts a Results store holds); building one performs no I/O. Stored data is untrusted: the constructor checks both shapes below and copies them.

The trial record (written by gvn.evals.running), plain JSON::

{"case_id": str, "trial": int, "run_id": str,
 "status": "finished" | "parked" | "errored",
 "ended": str | None,            # the state the run ended or parked in
 "error": str | None,            # why an errored trial could not be run
 "observed": {...},              # Environment.observe()
 "judgements": {criterion: Judgement plain},
 "pending": {criterion: run_id}, # reviews (or judges) still unanswered
 "judge_errors": {criterion: str}, # why a judge gave no readable verdict
 "discarded_runs": [run_id, ...],  # question runs whose verdict is not used
 "scores": {criterion: Score plain},
 "graded": {criterion: identity},  # the scoring identity each score was given under
 "passed": bool | None,          # Criteria.passed(scores); None also when errored
 "usage": {...Trace.usage()...}, # every attempt at the trial, its judges, discarded runs
 "cost": float | None,           # by the runner's Rates; None when unpriced
 "at": float}                    # the clock when the trial was recorded

case_id, trial (0-based, below the manifest's trials), run_id, status, pending, scores, passed, usage and cost are required; ended, error, observed, judgements, judge_errors, discarded_runs, graded and at are checked when present. A criterion missing from scores counts as not judged in that trial.

graded says which scoring each score belongs to: for every criterion scored, the scoring identity it was scored under (what the manifest's criteria.fingerprints holds for that criterion). A score whose identity is not the manifest's (the criterion was changed, the judge's model replaced, or the record has no graded at all) is out of date: it counts as not judged, the trial as not passed or failed yet, and the eval run as not complete, until Runner.regrade or Runner.run has scored the trial again. So a manifest and scores that fell out of step (a regrade that was interrupted) can never read as a finished result. A manifest without criteria.fingerprints names no identities, and no score is out of date under it.

usage and cost cover every attempt at the trial the journal holds up to the one recorded in run_id (an attempt abandoned after an error or a crash was paid for all the same), the questions asked about each of them, and the discarded runs.

judge_errors names each criterion whose question was asked and whose run ended without a readable verdict (the judge failed, or answered outside the declared verdicts), with the reason; running the eval again asks it again. Such a judgement is missing, as a pending one is.

discarded_runs lists the question runs whose spending the record still counts although no verdict is read from them: earlier attempts at a question that was asked again, runs of judges that failed, and questions of criteria replaced since (by Runner.regrade). Their usage is in usage and their cost in cost, so what an eval run spent never goes down when a question is asked again or replaced. The list only grows.

The manifest::

{"eval": str, "version": str, "subject": str (fingerprint),
 "dataset": {"name": str, "fingerprint": str, "cases": [case ids]},
 "criteria": {"name": str, "fingerprint": str,
              "must_pass": [names], "measured": [names],
              "fingerprints": {name: fingerprint}},   # optional
 "trials": int, "environments": str, "stand_in": str | None, "models": {role: name},
 "currency": str}                                       # optional

currency, when present, names the currency the costs are in (such as "USD"); without it a cost is a number in whatever currency the runner's rates were written in.

criteria.fingerprints, when present, holds one scoring identity per criterion (every name in must_pass and measured, no other): the criterion's fingerprint together with the model that gives its verdicts, a str that changes whenever its scores could change. When both manifests of a comparison hold it, each criterion is compared unless its identity changed; otherwise individual criteria are compared only when the whole criteria.fingerprint is equal. Whether trials passed is compared only when the two runs decide it the same way: the same must-pass criteria, each under the same identity (without criteria.fingerprints on either side: an equal criteria.fingerprint). Otherwise the two runs are Incomparable: a change to the measurement must never read as a change in what was measured. No criterion may be named "passed": that name means whether a trial passed overall.

Constants: ERRORED, STATUSES, FAILING, FLAKY, SOLID, UNJUDGED.

Report

from gvn.evals.report import Report
Report(
    run_name: str,
    manifest: Mapping[str, typing.Any],
    trials: Sequence[Mapping[str, typing.Any]],
    confidence: float = 0.95,
    seed: int = 0,
    elsewhere: Sequence[tuple[str, int]] = (),
) -> None

run_name: the eval run's name. manifest and trials: as above (ValueError naming what is malformed: stored data is untrusted). elsewhere: (case_id, trial) of each trial another runner holds a claim on right now (Results.claims), with or without a record; none by default. Immutable.

Report.run_name

run_name() -> str

Report.manifest

manifest() -> dict[str, typing.Any]

Report.trials

trials() -> tuple[dict[str, typing.Any], ...]

Report.outdated

outdated() -> tuple[tuple[str, int], ...]

(case_id, trial) of each trial holding a score that is out of date: given under another scoring identity than the manifest's (see graded above), so it waits to be scored again by Runner.regrade or Runner.run. In record order.

Report.elsewhere

elsewhere() -> tuple[tuple[str, int], ...]

(case_id, trial) of each trial another runner holds a claim on: it is being run, or its record scored again, elsewhere, and this report's runner left it alone. What the constructor was given as elsewhere (Runner.report gives the live claims), sorted.

Report.complete

complete() -> bool

Whether every (case, trial) of the manifest has a record, with no answer pending, no judgement missing because a judge failed (judge_failures) and no score out of date (outdated): each is put right by running or regrading the eval again, so the run is not finished.

Report.criteria

criteria() -> tuple[str, ...]

Must-pass names, then measured names, each group in the manifest's order (the runner records each group sorted by name).

Report.rate

rate(criterion: str = 'passed') -> Rate

The Rate of one criterion over the cases ("passed": the trial passed overall). Errored trials are left out entirely. KeyError for an unknown name.

Report.stabilities

stabilities() -> dict[str, str]

Case id -> solid / flaky / failing / unjudged, by "passed".

Report.errored

errored() -> tuple[dict[str, typing.Any], ...]

The records of trials that could not be run.

Report.pending

pending() -> tuple[tuple[str, int, str, str], ...]

(case_id, trial, criterion, run_id) for every answer still awaited, in the order of the records; within each, criteria in the order of criteria() (must-pass before measured).

Report.judge_failures

judge_failures() -> tuple[tuple[str, int, str, str], ...]

(case_id, trial, criterion, reason) for every judgement that is missing because the judge's run ended without a readable verdict, in the order of the records; within each, criteria in the order of criteria() (must-pass before measured). Running the eval again asks these again.

Report.currency

currency() -> str | None

The currency the costs are in, as the manifest names it; None when it names none (the costs are then in the currency of the runner's rates).

Report.usage

usage() -> dict[str, int]

The sum of the trials' usage (every record's, errored ones included), which counts the discarded runs too: it never goes down for the same eval run.

Report.cost

cost() -> float | None

The sum of the trials' cost; None when any counted trial is unpriced. Every record counts except an errored one with no cost (a trial that could not be run, whose spending, if any, was not priced).

Report.compare

compare(baseline: Report, margin: float = 0.0, min_cases: int = 6) -> Comparison

This run as the candidate against baseline. Incomparable unless both ran datasets with the same fingerprint, and unless both name the same must-pass criteria. Besides "passed", a criterion is compared when both runs have it and it did not change: by its own fingerprint where both manifests hold criteria.fingerprints, otherwise only when the whole criteria fingerprint is equal. What is left out is named by differing. Every case of the cases file is given to the Comparison, so a case not judged in either run (no trial run, every trial could not run, or none judged yet) makes the verdict not enough data to tell; min_cases is passed on (see Comparison).

Report.differing

differing(baseline: Report) -> tuple[str, ...]

What differs between the two manifests besides the version, in words (a judge model, a changed criterion, the number of trials, the stand-in): shown beside a comparison so nobody reads a difference as the version's when it may be the measurement's. Criteria whose definition changed are named here and left out of the comparison.

Report.gate

gate(at_least: Mapping[str, float], could_not_run: int = 0) -> tuple[str, ...]

Problems (empty when the gate holds), in this order: for each criterion name -> minimum pass rate, a problem when rate(name).mean() is below it or unjudged, and one when that criterion was judged in fewer trials than ran (a rate over part of the run does not count); a problem when more than could_not_run trials could not run (errored; default 0, none allowed); and one when the run is not complete(). For CI. TypeError for a minimum that is not a number or a could_not_run that is not an int, ValueError for a minimum outside [0, 1] or a negative could_not_run, KeyError for an unknown criterion.

Report.coverage

coverage() -> dict[str, int]

How much of the run the numbers rest on, in trials: {"trials": the manifest's cases times its trials, "ran": trials recorded that could run, "could_not_run": trials recorded as errored, "not_run_yet": trials with no record, "judged": trials whose overall result ("passed") is known}. So ran + could_not_run + not_run_yet == trials and judged <= ran.

Report.summary

summary() -> str

Readable text for a terminal: one headline ("&lt;eval> on &lt;version>: 42 of 50 trials passed, 84% (likely between 72% and 92%)"; "&lt;eval> on &lt;version>: no trial judged yet" before any, followed by "; 10 of 10 trials could not run" when some could not), which says what the rate rests on whenever fewer trials were judged than the manifest asks for ("&lt;eval> on &lt;version>: 1 of 1 judged trials passed, 100% (likely between 21% and 100%); only 1 of 10 trials was judged (9 could not run)", naming also those not run yet and those not judged yet); the solid / flaky / failing case counts (and the cases with no trial run yet, those whose every trial could not run, and those run but not judged yet), one line per criterion (must-pass ones first, then measured, each group in the order of criteria()), errored and pending counts, how many judgements are missing because a judge failed (and that running the same command again asks for them again), cost when priced, with its currency, and, last, one line naming the confidence level of the likely ranges when it is not 95% ("The likely ranges are 90% intervals.", as Comparison.summary ends). The percentage is the mean over cases of each case's share of passing trials (equal to the share of trials when every case was judged as often).

Report.to_plain

to_plain() -> dict[str, typing.Any]

Everything above as plain JSON, for the web page and for export: {"run_name", "manifest", "complete", "headline", "coverage", "criteria": [{"name", "group", "mean", "low", "high", "always", "ever", "trials", "unjudged"}], "cases": [{"case_id", "stability", "trials": [record, ...]}], "errored", "outdated", "elsewhere", "pending", "judge_failures", "usage", "cost", "currency"}.

criteria starts with "passed" (group "overall": whether trials passed overall), then the must-pass criteria (group "must_pass"), then the measured ones ("measured"), each group in the order of criteria(); mean, low, high, always and ever are null when nothing was judged. cases follows the manifest's order of case ids (reading order: case2 before case10), each case's records in trial order (errored ones included). errored is a list of records; outdated (trials waiting to be scored again) and elsewhere (trials another runner holds) are lists of [case_id, trial]; pending a list of [case_id, trial, criterion, run_id]; judge_failures a list of [case_id, trial, criterion, reason]; currency is currency(); coverage is coverage().

gvn.evals.running

Running an eval: every case, as many trials as asked, each in a fresh environment.

A trial is an ordinary run: its actor is driven by a Governor of its own, over the trial's Environment, into the shared Journal. Its run id is "<run_name>.<case_id>.<trial>" for the first attempt and "<run_name>.<case_id>.<trial>.r<n>" for attempt n >= 1. A question a criterion asks (a judge, a review) is a run too: the trial's run id, a dot, a slug of the criterion's name, a dash and the first 8 hex characters of the sha256 of the criterion's scoring identity (its fingerprint and the model that judges it), so a criterion that would judge differently asks a new question. A question whose run ended without a readable verdict is asked again by the next run or regrade, under the same id with .r<n> appended. What a question's run used stays counted in its trial's record after the question is asked again or its criterion is replaced ("discarded_runs", gvn.evals.report).

Nothing about an eval run lives only in memory: the Journal holds every run and the Results store one record per trial, so running the same eval under the same name again continues it. What continuing means is decided by what can be continued truthfully:

  • A trial counts once its record is saved. A trial saved as finished or parked is never run again.
  • A trial that could not run (its record is errored) is run again by the next run, as further attempts under the next run ids, and its record is replaced when the new attempt is saved: by the trial's result, or, when it errors again, by the latest reason. Every earlier attempt stays counted in what the trial used. attempts limits the attempts of one run call, not of the trial's life. regrade runs no trial and leaves errored records as they are.
  • A trial without a record is run afresh, as a new attempt under the next run id the journal does not hold yet. A run that was in flight when the process died is NOT driven on: its environment died with the process, and a fresh one would not hold what the run had already done to the old one. The abandoned run stays in the journal; the record names the run that counted.
  • A question's run needs no environment, so it IS continued: a judge's run found finished in the journal is read, one found unfinished is recovered and driven on, and a review that was asked stays asked.

Scores never outlive the scoring that gave them. Every criterion of a run has a scoring identity: its fingerprint together with the name of the model serving each model role it judges through. The manifest records the identities (criteria.fingerprints) and each record the identity each of its scores was given under ("graded"); a score under another identity than the manifest's is out of date, counts as not judged (gvn.evals.report), and is given again by the next run or regrade. A judgement is reused only for the question its criterion asks now, and the question's run id carries the identity, so neither a changed rubric nor another judge model can pass off old verdicts as its own.

One trial has one owner. Before a runner touches a trial (to run it, or to score its record again) it claims it in the Results store, and gives the claim up when the record is saved. A runner that finds a trial claimed leaves it alone: the Report then lists it as being run elsewhere. A claim lasts claim_seconds and is renewed every third of that while the call lives, so a trial of any length keeps its owner and a runner that died stops blocking its trials claim_seconds later.

What a record says was used is everything the journal shows was spent on its trial: every attempt up to the one that counted (an attempt abandoned after an error or a crash was paid for all the same), the questions asked, and the discarded runs.

Eval

from gvn.evals.running import Eval
Eval(
    name: str,
    dataset: Dataset,
    criteria: Criteria,
    environments: Environments,
    stand_in: StandIn | None = None,
    trials: int = 1,
) -> None

What to measure: cases, criteria, where trials run and who stands in for people. Immutable. It names no version: the same Eval runs against each.

name: [A-Za-z0-9][A-Za-z0-9_-]*. dataset: a Dataset. criteria: a Criteria. environments: an Environments. stand_in: a StandIn, or None for nobody (every external request is left unanswered). trials: how many times each case runs, an int >= 1.

Eval.name

name() -> str

Eval.dataset

dataset() -> Dataset

Eval.criteria

criteria() -> Criteria

Eval.environments

environments() -> Environments

Eval.stand_in

stand_in() -> StandIn | None

Eval.trials

trials() -> int

OverBudget

from gvn.evals.running import OverBudget

The eval run reached its budget; the trials not yet started were not run.

Runner

from gvn.evals.running import Runner
Runner(
    journal: Journal,
    results: Results,
    model: Model,
    clock: Clock,
    model_roles: Mapping[str, Model] | None = None,
    output: Output | None = None,
    per_trial: Allowance | None = None,
    budget: Allowance | None = None,
    rates: Rates | None = None,
    concurrency: int = 4,
    attempts: int = 2,
    currency: str | None = None,
    claim_seconds: float = 300.0,
) -> None

Runs Evals and keeps their results.

journal: where every trial's and every judge's run is journaled. results: the Results store. model: the Model serving the subject's model calls that name no role. model_roles: None or role name -> Model; a Judge needs "judge" (missing: ValueError before anything runs, naming the criterion). clock, output: as a Governor takes (output None: events go nowhere). per_trial: None or the Allowance of each trial's run (a run that reaches it is interrupted by the Governor as usual and the trial is recorded as it stands). budget: None or an Allowance for a whole eval run, counted over its trials' and judges' usage as recorded: once reached, no further trial starts and run raises OverBudget after recording what finished. rates: None or the Rates that price usage (required by a budget or allowance in cost: a budget or per_trial that limits cost without rates is a ValueError here). concurrency: how many trials run at once, an int >= 1 (default 4). attempts: how many times a trial that errored is tried before it is recorded errored (default 2). currency: None, or a non-empty str naming the currency the rates price in (such as "USD"); recorded in the manifest as "currency" only when given, and shown beside every cost. claim_seconds: how long a claim on a trial lasts without being renewed, a finite number > 0 (default 300): how long a runner that died keeps its trials from being run by another.

The manifest names the models by role, and calls model "default": a role named "default" in model_roles is a ValueError here. A model whose name() is None is recorded as "unnamed".

Runner.run

async def run(an_eval: Eval, subject: Subject, run_name: str | None = None) -> Report

Run an_eval against subject and return the Report.

run_name: None for "<eval name>.<subject name>". Opens the eval run in the Results store (ManifestMismatch when that name holds a run of other cases, criteria or another version's fingerprint), then for each (case, trial) without a saved record, and for each whose record is errored (it could not run: it is run again as further attempts, and the record replaced): claims the trial (one another runner holds a live claim on is left to that runner, and the Report lists it under elsewhere), opens an Environment, starts the run under the next unused run id, lets the StandIn answer what it waits on until it finishes or nothing gets an answer (parked; a wake-up nobody waits for parks it too), observes the environment, closes it, has each criterion's question answered (judges run to their end; a review is started and left pending), scores, and saves the record. An exception from the environment or the stand-in, or a model outage the Governor could not absorb, abandons that attempt; after attempts attempts the trial is saved as errored with the last reason. One trial's failure never stops the others. The manifest written is the one gvn.evals.report documents, with "fingerprints": criterion name -> scoring identity under "criteria", and "currency" when the runner was given one. A record whose scores are out of date (an earlier regrade was interrupted) is scored again first.

Runner.regrade

async def regrade(
    an_eval: Eval,
    subject: Subject,
    run_name: str | None = None,
) -> Report

Score a recorded eval run again without running any trial: rebuild each trial's Evidence from the journal and its record, collect answers that have arrived since (finished reviews), ask judges whose answer is missing, score with an_eval's criteria and save. Lets criteria be added or changed after the fact (the stored manifest's criteria, models and currency are replaced; the cases, the version and the number of trials must match, ManifestMismatch otherwise). A judgement is kept only where its criterion's scoring identity is unchanged: a changed statement, or another judge model, asks again. A trial another runner holds a claim on is left as it is: the Report lists it under elsewhere, and its scores read as out of date until it is regraded. Interrupted, it leaves the run not complete, and regrade or run finishes it.

Runner.manifest

manifest(an_eval: Eval, subject: Subject) -> dict[str, typing.Any]

The manifest run would record for an_eval against subject (a fresh dict), with the refusals run makes before anything runs. For telling a person what changed when run raises ManifestMismatch.

Runner.report

async def report(run_name: str) -> Report

The Report of a recorded eval run as stored, with the trials other runners hold a claim on right now as its elsewhere. LookupError when unknown.

Runner.review

async def review(
    an_eval: Eval,
    subject: Subject,
    run_name: str,
    case_id: str,
    trial: int,
    criterion: str,
    verdict: str,
    by: Principal,
    note: str = '',
) -> None

Give a person's verdict to a pending review: answers the parked review run through a Governor (answer(..., by=by); note is the answer's text), reads the Judgement, re-scores that trial and saves it. subject: the version the eval run was of (its actor class rebuilds the trial's Trace, which scoring reads). LookupError when nothing is pending there, and when the criteria have changed since the run was last scored (the question waiting was asked under a scoring identity that is not the criterion's now): regrade first, then answer the question that asks; and when another runner holds the trial (it is being scored right now): try again in a moment. ValueError for a verdict the criterion does not declare.

gvn.evals.stand_ins

Stand-ins ready to use: who answers, in a trial, what a person answers in production.

Approving

from gvn.evals.stand_ins import Approving
Approving()

Approves every approval a run asks for (every call asked about, none denied) and answers nothing else: a question to a person, or any other outside request, is left unanswered, so a trial that needs one ends parked. Name: "approves everything".

For evals of a harness whose risky tools need a person's approval, when what is measured is what the harness does once approved. Immutable; two are equal.

Approving.name

name() -> str

Recorded with every eval run.

Approving.answer

async def answer(request: Request, case: Case) -> Event | None

The Event answering request (an external request the run is waiting on), or None to leave it unanswered (the trial then ends parked). Asked again for a request re-issued after a crash, so the same request should get an equal answer where it can.

gvn.evals.statistics

Statistics for evals: rates with honest intervals, and paired differences.

Standard library only, no I/O, no global random state: every resampling takes a seed and is deterministic for it (cases are resampled in the order of their ids, so the order a mapping lists them in does not count). Trials of one case are not independent of each other, so a case is the unit that is resampled and the unit over which standard errors are taken (cluster by case).

Constants: SOLID, FLAKY, FAILING, UNJUDGED.

stability

from gvn.evals.statistics import stability
stability(trials: Sequence[bool | None]) -> str

How one case did over its trials (None: a trial that could not be judged, left out): SOLID when every judged trial passed, FAILING when none did, FLAKY when some did, UNJUDGED when no trial was judged.

Interval

from gvn.evals.statistics import Interval
Interval(low: float, high: float) -> None

A closed interval [low, high] of floats, low <= high. Immutable value.

Interval.low

low() -> float

Interval.high

high() -> float

Interval.contains

contains(value: float) -> bool

Rate

from gvn.evals.statistics import Rate
Rate(
    by_case: Mapping[str, Sequence[bool | None]],
    confidence: float = 0.95,
    seed: int = 0,
) -> None

How often something passed, over cases that each ran one or more trials.

by_case: mapping of case id -> sequence of bool | None (one per trial; None is a trial that could not be judged and is left out). confidence: in (0, 1), default 0.95. seed: int for the resampling. Immutable.

Rate.cases

cases() -> int

Cases with at least one judged trial.

Rate.trials

trials() -> int

Judged trials.

Rate.unjudged

unjudged() -> int

Rate.mean

mean() -> float | None

The mean over cases of each case's share of judged trials that passed (so every case weighs the same however many of its trials were judged); None when nothing was judged.

Rate.interval

interval() -> Interval | None

The confidence interval of mean(), clipped to [0, 1]. With one judged trial per case: the Wilson score interval over trials. Otherwise: a percentile bootstrap that resamples cases (2,000 resamples, seeded); when every case has the same share (all passed, all failed, or one case only), resampling cannot vary and would give an interval of no width, so the Wilson score interval of that share over the number of cases is used instead, which is as wide as that many cases allow. Where floating point rounding or a skewed resampling would leave mean() just outside, the interval is widened to include it. None when nothing was judged.

Rate.always

always() -> float | None

The share of cases whose every judged trial passed (reliability: "pass^k").

Rate.ever

ever() -> float | None

The share of cases with at least one passing trial (capability: "pass@k").

Rate.stabilities

stabilities() -> dict[str, str]

Case id -> stability of its trials, for every case given.

Difference

from gvn.evals.statistics import Difference
Difference(
    baseline: Mapping[str, Sequence[bool | None]],
    candidate: Mapping[str, Sequence[bool | None]],
    confidence: float = 0.95,
    seed: int = 0,
) -> None

The paired difference between two Rates' underlying results over the SAME cases: candidate minus baseline, case by case.

baseline / candidate: mappings as Rate takes. Only cases judged in both count; ValueError when there is none. Immutable.

Difference.cases

cases() -> int

Difference.mean

mean() -> float

The mean over cases of (candidate's pass share - baseline's pass share).

Difference.interval

interval() -> Interval

The confidence interval of mean(), clipped to [-1, 1] and widened to include mean() where rounding or a skewed resampling would leave it just outside. Usually a percentile bootstrap over cases (2,000 resamples, seeded). When every case changed by the same amount, resampling cannot vary: if that amount is zero the interval is [0, 0] (nothing changed anywhere); otherwise it is read from how many cases there are, as a sign test would: with least the lower end of the Wilson score interval of n out of n, it runs from mean * (2 * least - 1) to mean (for a rise; mirrored for a fall). So one case, or a few, never give a certain-looking interval: at 95%, one case of +1 reads [-0.59, 1], three cases cross zero, twenty read about [0.68, 1].

Difference.improved

improved() -> tuple[str, ...]

Case ids whose pass share rose, sorted.

Difference.worsened

worsened() -> tuple[str, ...]

Case ids whose pass share fell, sorted.