Repository navigation
Description
Problem
A producer that evaluates in a loop wants to do this entirely inside evalhub:
- add each run to an Eval as it finishes, privately;
- attach the run's measurements (tokens, wall time, cost, …) to that run;
- later attach a grader's judgement to each run (a Card);
- read a per-run projection (run × measurements × judgements) and the per-condition aggregate (the Card's
results) with evalhub's own API; - 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.rsingest steps 1–9). Runisrun_id / started_at / ended_at / outcome / calls / artifactswithdeny_unknown_fieldsand noext, so a run cannot carry measurements (crates/evalhub-schema/src/eval.rs).runshas no side table and is deliberately absent from the query path table (crates/evalhub-query/src/typecheck.rs, "runsis 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.outcomeispass | 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.
- "
runsrequired wheneval_kindisrun_set" and "run_idunique within the Eval" are stated in docs but checked nowhere (crates/evalhub-core/src/validate.rsrule 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.
statusis execution state only:ok;error(ran and failed — budget exhausted, timeout, crash, API error) with requirederror: { kind, message?, log? };skipped(deliberately not run) with requiredskip_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.logpoint into them. metais 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_kindmay 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;fromoptionally names the run metrics used. Re-grading appends a Card version, as today.- The runs a Card used (its used set, per
uses_eval) areattrs.runswhen present, otherwise every run that is neither archived nor deleted when the Card is posted.run_resultsmust stay inside the used set. A run id with no row is422 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}withrunsin the body →422 runs_moved, naming the run endpoints.GET /evals/{ns}/{name}returns the header plusruns: { 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_deletedfor a deleted run id;409 attachment_missingas 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 onstatus,error.kind, run facets and fingerprints,metrics.*andresults.{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_modelcompare the Card with every run in its used set. - Visibility stays per Eval. Runs follow their Eval,
run_resultsfollow their Card. A reader who cannot see an Eval is never shown its run ids or judgements: Card responses withhold thoserun_resultsentries 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_hashalways 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(highestseqwins) and become rows.pass/fail→ok,error→error,skipped→skipped. Missing error kinds and skip reasons becomeunrecordedrather than guesses. The droppedoutcomeis kept verbatim asmeta: { "v0.2.0_migration": { "outcome": … } }. The header's facets are copied onto each run. runsis removed from every live version body and the headercontent_hashis 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-schemaeval / card / common / facet,evalhub-corehash and validation,evalhub-query,evalhub-store,evalhub-server) describe the model above; README lists the new endpoints and limits. PUTa run,GET …/runsreturns it with its metrics; a Card withrun_resultsfor it appears in the projection undercards=; overwriting the run makes it appear in that Card'schanged_since_card.- A
runs:batchwith one invalid element writes nothing and returns every failing element. POST /evals/…withrunsreturns422 runs_moved.- A public Card whose
run_resultspoint 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 migrateon a database with 0.1.x Evals: no version body containsruns; each old run is a row with the expectedstatusandmeta; the audit log has the old and new header hashes; existing Cards' comparison rows still resolve. cargo test -pfor all five crates,cargo insta test -p evalhub-schemawith updated schemas,cargo sqlx prepare --check, the OpenAPI snapshot and the regeneratedweb/client,just e2e, andjust semver-checkreporting the expected minor bump.
Activity
ynishi commentedon Sep 24, 2026
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 andwithheldenvelope torun_results, and ships as 0.2.0.runsin an Eval body, check run_results, fingerprint a run, publish the run hash formulas #28GET /evals/{ns}/{name}/runs#29ynishi commentedon Sep 25, 2026
Plan: nine sub-issues, one branch, one release
Verified again on
mainatc262373(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::visible_to, thewithheldenvelope onGETandPOST /cards/query(export returns no body), and no UI for it yet.run_resultsredaction plugs into the same two paths.evalhub-schema's own versioning rule makes removingrunsa major bump of the record schema (evalhub.eval/2.0) and addingrun_resultsa minor one (evalhub.card/1.1,1.0still 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 aevalhub.eval/1.0body withrunsand converts it at ingest into a 2.0 header plus run rows (same transaction, same conversion function as the data migration,Deprecationheader on the response); 0.3.0 removes that path and answersruns_moved. Two lines above therefore read differently now: the "Migration (no compatibility window)" heading, and the Acceptance bullet "POST /evals/…withrunsreturns422 runs_moved", which holds for a body declaringevalhub.eval/2.0; aevalhub.eval/1.0body withrunsis accepted and converted, with aDeprecationheader. 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.Run.outcomeis the web Eval page.serve's start-up gate has to look atdata_migrationstoo. 0.1.xattrs.runswere never checked, so the migration skips a usedrun_idwith no row and writes an audit row instead of failing.RecordKindis matched exhaustively in six places; run validation is a separate entry point, not a third kind.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, andGET /schemas/eval-2/GET /schemas/run; theused_set_hashexposed 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 listsruns; renderingwithheldin the UI (needed once it carriesrun_results).Order (each stage is green for the crates it touches and their dependants before the next starts):
run_results, schema ids,eval::v1, error codes, fixtures, OpenAPI snapshotruns_moved,split_v1, materialise, hashesruns_hash, audit, GCrun_results, projection SQL, hidden Evals, comparison/runs,withheld, Fly smokeBranch
feat/run-rowsfrommain; one PR tomain, 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 losesrunsin stage 1 and the data that replaces it arrives in stage 6), somainmust receive all nine at once. The PR closes this issue and releases 0.2.0.