Skip to content

Runs as first-class rows: per-run conditions and measurements, per-run judgements on Cards, a run projection #24

Closed
9 of 9 issues completed

Description

@ynishi

Problem

A producer that evaluates in a loop wants to do this entirely inside evalhub:

  1. add each run to an Eval as it finishes, privately;
  2. attach the run's measurements (tokens, wall time, cost, …) to that run;
  3. later attach a grader's judgement to each run (a Card);
  4. read a per-run projection (run × measurements × judgements) and the per-condition aggregate (the Card's results) with evalhub's own API;
  5. make the Eval public by name.

Today only the two ends exist. An Eval's runs[] is embedded in the record body, and a Card's results[] is one number per metric. The rows in between — each run's measurements and judgement — have nowhere to live except an attachment the hub never opens, so the projection has to be built outside the hub from downloaded files. Steps 1, 2 and 4 are not possible at all.

Evidence

All on main (0c96b4a):

  • Writing is only POST /evals/{ns}/{name} with the whole body; adding one run means posting a new version of the whole Eval (crates/evalhub-server/src/api/records.rs, crates/evalhub-store/src/records.rs ingest steps 1–9).
  • Run is run_id / started_at / ended_at / outcome / calls / artifacts with deny_unknown_fields and no ext, so a run cannot carry measurements (crates/evalhub-schema/src/eval.rs).
  • runs has no side table and is deliberately absent from the query path table (crates/evalhub-query/src/typecheck.rs, "runs is deliberately absent").
  • A Card's per-run rows exist only inside the attachment named by results[].samples_ref; the hub checks that the path exists and nothing else (crates/evalhub-schema/src/card.rs).
  • Run.outcome is pass | fail | error | skipped, which contradicts "Grading belongs to the Card" in the same module; nothing in the hub reads it.
  • Conditions (model, generation, …) exist only once per Eval, so a session that changes model between runs cannot be recorded as one Eval.
  • "runs required when eval_kind is run_set" and "run_id unique within the Eval" are stated in docs but checked nowhere (crates/evalhub-core/src/validate.rs rule table).
  • No request body limit is configured anywhere (only axum's extractor default).

Proposal

An architecture change. Runs leave the Eval body and become rows of their own; the storage split is internal, and the domain meaning — an Eval's material is its header plus its runs — is kept and made verifiable by hash.

Eval and Run

  • An Eval is a versioned header plus a set of runs that belongs to the record, not to a version. Adding or changing a run does not append a header version.
  • Run { run_id, status, error?, skip_reason?, started_at?, ended_at?, model / task / harness / generation / trial / env, calls?, artifacts[], attachments[], metrics{}, ext, meta? }, unique per (Eval, run_id).
  • Conditions are per run. A run carries the six Eval facets. The header's facets are defaults: a facet the run omits is copied from the latest header at write time and stored with the run, so a later header change never rewrites a run's conditions. Fingerprints are computed per run with the existing rule; comparison groups and filters on run fingerprints.
  • A run has no verdict. status is execution state only: ok; error (ran and failed — budget exhausted, timeout, crash, API error) with required error: { kind, message?, log? }; skipped (deliberately not run) with required skip_reason. Pass / fail belongs to the Card.
  • metrics: { "{ns}/{name}": number } holds values measured from the run itself (tokens, time, cost, exit code, output length, and basic statistics within the run). Anything that depends on a grader's choice is the Card's.
  • A run's files are its own attachments[]; calls / artifacts[] / error.log point into them.
  • meta is a free field the hub never interprets.
  • No separate sample type. A run's call log (prompt in / out) is the material; a set of tasks is an Eval whose runs have empty outputs, linked to run sets with the existing Eval→Eval relations. Repeated attempts (trial.k, re-runs after an error) are separate runs.
  • Any eval_kind may have runs; a new header may have zero runs.

Judgements on the Card

  • Card.run_results[] { eval, run_id, metric, value?, label?, by?, from? }. The Card is the layer that derives judgements from runs' measurements and logs; from optionally names the run metrics used. Re-grading appends a Card version, as today.
  • The runs a Card used (its used set, per uses_eval) are attrs.runs when present, otherwise every run that is neither archived nor deleted when the Card is posted. run_results must stay inside the used set. A run id with no row is 422 run_unknown; archived and deleted runs still count as rows, so a judgement outlives the run it judged.
  • The hub records the used set with each run's content hash at posting time.

Hashes

Hash Over Changes when
header content_hash header body (as today, RFC 8785 + SHA-256) a header version is appended
run content_hash the run, including copied facets the run is overwritten
runs_hash sorted (run_id, content_hash) of every run, archived and deleted included a run is added or overwritten
used-set hash the same, over a Card's used set a run the Card used is overwritten

Archive and delete do not change hashes (as a version tombstone keeps its hash). A Card can therefore report, per run, which runs changed since it was posted (changed_since_card). The formula is documented and exposed as a public function in evalhub-core so clients can verify it.

API (under /api/v1)

  • POST /evals/{ns}/{name} with runs in the body → 422 runs_moved, naming the run endpoints.
  • GET /evals/{ns}/{name} returns the header plus runs: { count, by_status, archived, deleted, runs_hash }.
  • PUT /evals/{ns}/{name}/runs/{run_id} — create (201), overwrite (200, updated), identical content (200, no-op). 409 run_deleted for a deleted run id; 409 attachment_missing as for records.
  • POST /evals/{ns}/{name}/runs:batch — all or nothing in one transaction; on failure nothing is written and every failing element is reported.
  • GET /evals/{ns}/{name}/runs — the per-run projection, joined with the chosen Cards' run_results (cards=), filterable and sortable on status, error.kind, run facets and fingerprints, metrics.* and results.{card}.{metric}.*, keyset-paged with the existing signed cursor.
  • GET …/runs/{run_id}, PATCH …/runs/{run_id} (archived), DELETE …/runs/{run_id} (tombstone with reason).
  • The comparison view's same_harness / same_model compare the Card with every run in its used set.
  • Visibility stays per Eval. Runs follow their Eval, run_results follow their Card. A reader who cannot see an Eval is never shown its run ids or judgements: Card responses withhold those run_results entries and say so in the envelope, and writes that reference runs of an Eval the writer cannot see answer exactly as for a run that does not exist.
  • Run writes lock the record row, as the ingest path does, so runs_hash always matches the rows.

Limits (configurable): request body 16 MiB; runs:batch 1,000 runs; run_results 100,000 per Card version; read pages 1–200 as today.

Migration (no compatibility window)

evalhub migrate runs the SQL migration and then a one-shot data migration, recorded so it never runs twice:

  • For each Eval, runs are collected from every live version by run_id (highest seq wins) and become rows. pass / fail → ok, error → error, skipped → skipped. Missing error kinds and skip reasons become unrecorded rather than guesses. The dropped outcome is kept verbatim as meta: { "v0.2.0_migration": { "outcome": … } }. The header's facets are copied onto each run.
  • runs is removed from every live version body and the header content_hash is recomputed; old and new hashes are written to the audit log.
  • Existing Cards get their used set from the Eval version they point at, so a run that has since changed shows as changed immediately.

This breaks the public API of evalhub-schema (0.1.x → 0.2.0).

Out of scope: queries across Evals at run level; splitting judgements into a separate layer from the Card.

Acceptance

  • Crate docs (evalhub-schema eval / card / common / facet, evalhub-core hash and validation, evalhub-query, evalhub-store, evalhub-server) describe the model above; README lists the new endpoints and limits.
  • PUT a run, GET …/runs returns it with its metrics; a Card with run_results for it appears in the projection under cards=; overwriting the run makes it appear in that Card's changed_since_card.
  • A runs:batch with one invalid element writes nothing and returns every failing element.
  • POST /evals/… with runs returns 422 runs_moved.
  • A public Card whose run_results point at a private Eval returns no run id or judgement for that Eval to a reader outside its namespace, and the envelope says entries were withheld.
  • After evalhub migrate on a database with 0.1.x Evals: no version body contains runs; each old run is a row with the expected status and meta; the audit log has the old and new header hashes; existing Cards' comparison rows still resolve.
  • cargo test -p for all five crates, cargo insta test -p evalhub-schema with updated schemas, cargo sqlx prepare --check, the OpenAPI snapshot and the regenerated web/ client, just e2e, and just semver-check reporting the expected minor bump.

Sub-issues

Sub-issues

9 of 9 Issues completed
Loading 9 sub-issues

Activity

  1. added
    enhancement
    on Sep 24, 2026
  2. ynishi commented on Sep 24, 2026

    @ynishi
    OwnerAuthor

    Order of work: the privacy boundary this issue relies on is already broken for relations[] (reads return the Card body verbatim; resolution ignores visibility). That is fixed first in #25, released as 0.1.x. This issue then applies the same visibility rule and withheld envelope to run_results, and ships as 0.2.0.

  3. ynishi commented on Sep 25, 2026

    @ynishi
    OwnerAuthor

    Plan: nine sub-issues, one branch, one release

    Verified again on main at c262373 (0.1.4, after #26): every Evidence bullet above still holds. What changed since the issue was written, and what the sub-issues assume:

    • Relations: a reader or writer learns nothing of a version it may not see (0.1.4) #26 landed the visibility predicate as relations::visible_to, the withheld envelope on GET and POST /cards/query (export returns no body), and no UI for it yet. run_results redaction plugs into the same two paths.
    • evalhub-schema's own versioning rule makes removing runs a major bump of the record schema (evalhub.eval/2.0) and adding run_results a minor one (evalhub.card/1.1, 1.0 still accepted). The crate doc promises the previous major is accepted for one release, and that promise is public, so the "no compatibility window" line above is amended: 0.2.0 accepts a evalhub.eval/1.0 body with runs and converts it at ingest into a 2.0 header plus run rows (same transaction, same conversion function as the data migration, Deprecation header on the response); 0.3.0 removes that path and answers runs_moved. Two lines above therefore read differently now: the "Migration (no compatibility window)" heading, and the Acceptance bullet "POST /evals/… with runs returns 422 runs_moved", which holds for a body declaring evalhub.eval/2.0; a evalhub.eval/1.0 body with runs is accepted and converted, with a Deprecation header. Stored 0.1.x bodies are still migrated to 2.0 in 0.2.0, which is the one exception to the store's write-once rule for versions.
    • The one reader of Run.outcome is the web Eval page.
    • sqlx runs each SQL migration in its own transaction, so the data step is its own transaction and serve's start-up gate has to look at data_migrations too. 0.1.x attrs.runs were never checked, so the migration skips a used run_id with no row and writes an audit row instead of failing.
    • RecordKind is matched exhaustively in six places; run validation is a separate entry point, not a third kind.
    • The current effective request body cap is axum's 2 MiB default; 16 MiB raises it.
    • Projection paths take the bracket form the query already uses for its one parameterised path: metrics[{id}], results[{card}][{metric}].value.

    Additions that are not in the text above, each one forced by it: the schema-id bump, the one-release acceptance of evalhub.eval/1.0, and GET /schemas/eval-2 / GET /schemas/run; the used_set_hash exposed on the comparison view and the projection (the table above lists it); cards= restricted to Cards the caller can see; the grammar doc that still lists runs; rendering withheld in the UI (needed once it carries run_results).

    Order (each stage is green for the crates it touches and their dependants before the next starts):

    Stage Crate Sub-issue
    1 schema Run type, run_results, schema ids, eval::v1, error codes, fixtures, OpenAPI snapshot
    2 core run validation, schema dispatch by id, runs_moved, split_v1, materialise, hashes
    3 query run projection target
    4 store tables, run writes, 1.0 ingest conversion, runs_hash, audit, GC
    5 store used set, run_results, projection SQL, hidden Evals, comparison
    6 store + server data migration, the serve gate, the deploy runbook
    7 server endpoints, batch, limits, redaction, OpenAPI
    8 web + deploy Eval page on /runs, withheld, Fly smoke
    9 release README, docs, semver, bump 0.2.0

    Branch feat/run-rows from main; one PR to main, reviewed commit by commit, each commit naming the sub-issue it completes. This departs from "one branch per issue, one issue per pull request" on purpose: no intermediate stage is releasable (the schema loses runs in stage 1 and the data that replaces it arrives in stage 6), so main must receive all nine at once. The PR closes this issue and releases 0.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions