8000 Server: run endpoints, runs:batch, request limits, run_results redaction, the Eval runs summary, comparison counts, OpenAPI by ynishi · Pull Request #42 · ynishi/evalhub · GitHub
[go: up one dir, main page]

Skip to content

Server: run endpoints, runs:batch, request limits, run_results redaction, the Eval runs summary, comparison counts, OpenAPI - #42

Merged
ynishi merged 1 commit into
mainfrom
feat/server-runs
Sep 26, 2026
Merged

ynishi merged 1 commit into
mainfrom
feat/server-runs

Conversation

@ynishi
@ynishi ynishi commented Sep 25, 2026
Copy link
Copy Markdown
Owner

Stage 7 of 9 of #24 (Runs as first-class rows), on top of stages 1–6 (#36–#41). evalhub-server: the run endpoints and everything the API exposes of the run rows. Mergeable on its own; the UI is stage 8 (#34), the version bump stage 9 (#35).

What changed

  • Run routes under /api/v1/evals/{ns}/{name} (api/runs.rs, new), write scope write on the namespace:
    • PUT /runs/{run_id} → 201 created, 200 updated, 200 unchanged; body { run_id, content_hash, status, runs_hash, result } (result added so a 200 says which it was); 409 run_deleted / attachment_missing; 422 validation incl. run_id_mismatch (the body must carry run_id, as run.json requires).
    • POST /runs:batch { runs: [ { run_id, …Run } ] } → all or nothing; 413 batch_too_large; a refusal lists every failing element at /runs/{i}/…, 409 when every entry is a conflict, else 422; success 200 { runs: [ { run_id, content_hash, result } ], runs_hash }.
    • GET /runs → the projection: repeatable cards= ({ns}/{name}), where (filter JSON), repeatable sort ({path}[:asc|:desc]), limit 1–200 default 50 (clamped, as the listings), cursor, include=archived,deleted (honoured for members, ignored otherwise); rows carry metrics and per-Card judgements; the envelope carries per Card used_set_hash and changed_since_card (a list of run ids). The cursor is signed with the existing CursorSigner over { k: "runs", e: record_id, s: sort, c: RunCursor }, so a cursor from another Eval, another sort, or a record listing / query is 400 (tested in all directions).
    • GET /runs/{run_id} → the run; archived → 404 for non-members; tombstoned → { run_id, content_hash, tombstone }. PATCH /runs/{run_id} { archived }; DELETE /runs/{run_id} { reason, note? }.
    • Every run route of an Eval the caller cannot see, or with no live header, is 404 with the same empty body as a missing Eval, decided before card parsing, where, cursor or body validation (visible but no write → 403). A Card in cards= the caller cannot see, that does not exist, or that does not use this Eval, and a malformed card ref, are the same empty 404.
  • POST /evals/{ns}/{name}: a 2.0 body with runs → 422 with the single runs_moved error ahead of schema errors. A 1.0 body is accepted this release: Deprecation: @1790294400 (RFC 9745; 2026-09-25T00:00:00Z, the day 2.0 replaced 1.0) on the 201 and the 200, envelope converted_from: evalhub.eval/1.0 and converted_runs { runs, runs_hash, duplicate_run_ids? } shaped like the batch response; the stored 2.0 header's content_hash. README and the crate doc say 0.3.0 removes this.
  • GET /evals/{ns}/{name}[@seq|@label] envelope gains runs: { count, by_status, archived, deleted, runs_hash }, archived / deleted for members only, on every version incl. tombstoned ones (runs belong to the record).
  • POST /cards/{ns}/{name}: run_results counted on the parsed body, 422 too_many_run_results at /run_results above the limit, before validation and the store.
  • Limits (config.rs [limits]): body_bytes 16 MiB (replaces axum's 2 MiB default; no route streams a body, uploads are presigned), batch_runs 1,000, run_results 100,000; in entries() and the documented keys. DefaultBodyLimit on the router; a non-JSON 413 is rewritten into the body_too_large envelope, handlers' own JSON 413 passes through.
  • Redaction (api/relations.rs, api/records.rs, api/query.rs): Withheld { relations, run_results: u64 }, both always present; withhold(body, hidden_targets, hidden_evals) removes run_results[] entries whose Eval the caller cannot see, on GET and on POST /cards/query; the trigger is any hidden relation or hidden Eval. Export unchanged (no body projection of run_results).
  • may_download: a reference from an archived run counts only for a member; tombstoned runs have none.
  • Comparison DTO: runs_used, used_set_hash, changed_since_card. Audit: run.* and migration.* read back from GET /audit. Schemas: eval-2, run, eval served.
  • Errors (error.rs): ApiError::Conflict (409 envelope), ApiError::TooLarge (413 envelope), runs_rejected (409 iff every entry is run_deleted / attachment_missing), CardRunsRejected → 422, RunNotFound → 404, RunDeleted → 409 at /run_id, RunCardsUnknown → empty 404, store QueryUnsupported from the projection → 422 type_mismatch at /where, Canonical → 500. A 1.0 body whose runs[].run_id fails the run format is now 422 (was the stage-4 interim 500). 413 is documented on every operation that takes a request body.
  • Crate doc (lib.rs): API table, run lifecycle, limits, comparability; the migration named as the exception to a version's immutability.
  • Fixture defect from stage 1: crates/evalhub-schema/fixtures/card-run-results.json had counts attempted 2 < completed 2 + failed 1. The server test that posts it was written first and failed with counts_inconsistent at /counts (422 vs 201), then completed was set to 1. cargo test -p evalhub-schema unchanged (20).
  • Contracts: OpenAPI snapshot regenerated; web/src/lib/api/schema.d.ts regenerated (diffed against a fresh generator run in review: identical). No .svelte change.
  • README: limits table, schema list, Runs endpoint table, the 1.0 deprecation paragraph, Records POST / GET and comparison rows.
  • Tests: tests/runs.rs (18) covers every Server: run endpoints, runs:batch, request limits, run_results redaction, the Eval runs summary, comparison counts, OpenAPI #33 Acceptance bullet: PUT → GET /runs with metrics → Card under cards= → overwrite in changed_since_card; batch all-or-nothing listing every failure; 409-only-for-conflicts and mixed 422 batches; attachment_missing on PUT; 2.0 runs_moved ahead of unknown_key; 1.0 conversion with Deprecation, converted_from, runs on GET /runs, re-post unchanged; public Card citing a private Eval redacted on GET and POST /cards/query with withheld.run_results; every run route (GET / PUT / PATCH / DELETE / batch / list) 404 for an outsider incl. after PATCH …/settings; private Card in cards= → 404; 413 envelope for body and batch; too_many_run_results; archived runs members-only incl. attachment download; tombstoned read shape; runs summary; cursor paging with cross-Eval / cross-endpoint replay → 400; audit entries incl. a real migration.runs_split row. tests/boot.rs +1 (schemas served). tests/common/mod.rs: EVAL_V1, RUN, CARD_RUN_RESULTS, start_with_config, call_full, put_run, post_card_with_runs.

Verified

Command Outcome
cargo fmt --check clean
cargo clippy --workspace --all-targets -- -D warnings clean
cargo test -p evalhub-server (Docker) 82 passed (runs 18, boot 7 incl. snapshot)
cargo test -p evalhub-schema 20 passed
cargo test -p evalhub-store (Docker) 96 passed (unchanged crate)
cargo doc --no-deps -p evalhub-server 0 warnings
corepack pnpm check (web) 194 files, 0 errors
.snap.new none

Not run: cargo deny check (no dependency change), just e2e (the web build is stage 8; the API surface is covered by the server tests), core / query tests (untouched).

Decisions recorded here

Refs #33

…ion, the Eval runs summary, comparison counts, OpenAPI

Stage 7 of #24. The run rows of stages 4 and 5 get their API.

Under /api/v1/evals/{ns}/{name}: PUT /runs/{run_id} (201 created,
200 updated or unchanged, 409 run_deleted / attachment_missing, 422
validation with run_id_mismatch when the body disagrees with the
path), POST /runs:batch (all or nothing, 413 batch_too_large, a
refusal lists every failing element at /runs/{i}/..., 409 only when
every entry is a conflict, else 422), GET /runs (the projection:
repeatable cards=, where, sort, limit 1-200, a signed cursor bound
to the Eval and the sort so a cursor from another Eval, another sort
or a record listing is 400, include=archived,deleted for members;
rows carry metrics and per-Card judgements, the envelope carries
each Card's used_set_hash and changed_since_card), GET /runs/{run_id}
(a tombstoned run answers { run_id, content_hash, tombstone }),
PATCH { archived } and DELETE { reason, note? }. Every run route of
an Eval the caller cannot see, or with no live header, is 404 with
the same empty body as a missing Eval, checked before anything that
depends on the body; a Card named in cards= that the caller cannot
see, that does not exist or that does not use this Eval is the same
404.

POST /evals: a 2.0 body carrying runs gets the single runs_moved
error ahead of schema errors. A 1.0 body is accepted for this
release: the store converts it, the response carries a Deprecation
header and the envelope says converted_from with the per-run results
as runs:batch returns them; README and the crate doc say 0.3.0
removes this. GET /evals/{ns}/{name}[@seq] gains runs { count,
by_status, archived, deleted, runs_hash }, the last two for members.
POST /cards refuses more than the configured run_results with 422
too_many_run_results before validation.

[limits] body_bytes (16 MiB, up from axum's 2 MiB default),
batch_runs (1,000) and run_results (100,000) in config; the body
limit sits on the router and a non-JSON 413 is rewritten into the
body_too_large envelope. Redaction: withhold also drops run_results
entries whose Eval is in hidden_evals, on GET and on POST
/cards/query, and Withheld counts them. may_download counts an
archived run's reference only for a member. The comparison DTO
carries runs_used, used_set_hash and changed_since_card. run.* and
migration.* actions read back from GET /audit. The server crate doc
names the migration as the exception to a version's immutability.

The stage-1 fixture card-run-results.json had counts that core
rejects as counts_inconsistent; this stage posts it, so the test
was written first, seen fail on exactly that code, and completed
set to 1.

OpenAPI snapshot and the web client regenerated in this commit;
413 is documented on operations that take a request body.

Verified: cargo fmt --check; cargo clippy --workspace --all-targets
-D warnings; cargo test -p evalhub-server (82 passed, Docker; runs
18, boot 7); cargo test -p evalhub-schema (20); cargo test
-p evalhub-store (96, Docker); cargo doc --no-deps -p evalhub-server
(0 warnings); corepack pnpm check (0 errors); the regenerated client
diffed against a fresh generator run, identical.

Refs #33

Signed-off-by: Yutaka Nishimura <ytk.nishimura@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0