1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//! The Run: one execution inside an Eval, as a row of the record.
//!
//! A run is what a harness did once: one attempt at one task (or at a whole
//! session of tasks, if that is the harness's unit), under stated
//! conditions, with its log, what it produced, and what was measured
//! directly from it. Runs belong to the Eval *record*, not to a header
//! version (see [`crate::eval`]): a run is written on its own, keyed by
//! `(record, run_id)`, and writing one does not append a header version.
//!
//! # Shape
//!
//! ```text
//! Run
//! ├── run_id URL segment, unique within the Eval record
//! ├── status ok | error | skipped
//! ├── error { kind, message?, log? } exactly when status = error
//! ├── skip_reason free text exactly when status = skipped
//! ├── started_at / ended_at
//! ├── model / task / harness / generation / trial / env
//! │ the conditions of this run; the header's facets are defaults
//! ├── calls attachments[].path of the model calls
//! ├── artifacts[] attachments[].path of what the run produced
//! ├── attachments[] { path, sha256, size, media_type } this run's own files
//! ├── metrics { "{ns}/{name}": number } measured directly from the run
//! ├── ext { "{ns}/{name}": { ... } } producer-private, namespaced
//! └── meta any JSON never interpreted
//! ```
//!
//! An example:
//!
//! ```json
//! {
//! "run_id": "r1",
//! "status": "ok",
//! "started_at": "2026-09-20T10:00:00Z", "ended_at": "2026-09-20T10:02:11Z",
//! "model": {"id": "qwen3.6-32b"},
//! "generation": {"temperature": 0.0},
//! "calls": "calls/r1.jsonl",
//! "artifacts": ["artifacts/r1/diff.patch"],
//! "attachments": [
//! {"path": "calls/r1.jsonl", "sha256": "…", "size": 90210, "media_type": "application/x-ndjson"},
//! {"path": "artifacts/r1/diff.patch", "sha256": "…", "size": 3311, "media_type": "text/x-diff"}
//! ],
//! "metrics": {"core/tokens_out": 1834, "core/duration_ms": 131000},
//! "ext": {},
//! "meta": {"worker": "gpu-3"}
//! }
//! ```
//!
//! # `run_id`
//!
//! `run_id` is the run's address inside its Eval and appears as one path
//! segment of a URL. It is non-empty, contains no `/`, and is at most 200
//! bytes of UTF-8 (`run_id_invalid` otherwise). Nothing else is imposed:
//! every `run_id` a 0.1.x producer wrote into `runs[]` meets these rules.
//! Writing a run whose `run_id` already exists in the record overwrites it;
//! repeated attempts at the same task are separate runs with separate ids.
//!
//! # `status`, `error`, `skip_reason`
//!
//! `status` is the state of the execution and nothing more:
//!
//! - `ok`: the run went to completion.
//! - `error`: the run was executed and failed along the way (budget
//! exhausted, timeout, crash, an API error). `error` is required and
//! says how.
//! - `skipped`: the producer deliberately did not execute it (left out by a
//! limit, already done when a session resumed). `skip_reason` is
//! required.
//!
//! `error` is present exactly when `status` is `error`, and `skip_reason`
//! exactly when `status` is `skipped` (`run_status_detail` otherwise).
//!
//! A run carries no verdict. Whether it passed depends on a grader and a
//! threshold, and the same run can be graded several ways, so pass and fail
//! are the Card's claim, in [`crate::card::Card::run_results`].
//!
//! `error.kind` is a short slug the producer chooses (`budget_exhausted`,
//! `timeout`, `crash`), of the form `[a-z0-9][a-z0-9._-]*`. It is not an
//! enum: harnesses fail in more ways than a closed list can name, and the
//! value is for grouping and filtering, not for the hub to act on. The
//! value `unrecorded` is reserved in practice for runs converted from
//! `evalhub.eval/1.0`, whose `outcome` said that a run errored or was
//! skipped but not why; the conversion writes `unrecorded` as the
//! `error.kind` or the `skip_reason` rather than guessing.
//!
//! # Facets
//!
//! A run has the six facets of an Eval header, with the same types
//! ([`crate::facet`]). They are the conditions this run was measured
//! under. A facet the run omits is filled from the header's default when
//! the run is written, and stored with the run, so a later change to the
//! header does not change the conditions of a run already written. The
//! fingerprint of each facet is computed per run.
//!
//! # Attachments, `calls`, `artifacts`
//!
//! A run has its own `attachments[]`, of the same type as a record's
//! ([`crate::common::Attachment`]). `calls`, `artifacts[]` and
//! `error.log` name a `path` in *this run's* `attachments[]`, never the
//! header's: a run's files change with the run, and pointing into the
//! header would make adding a run append a header version. The same checks
//! apply as on a record (`attachment_ref_unknown`,
//! `attachment_path_invalid`, `attachment_missing`), per run.
//!
//! # What the hub interprets and what it does not
//!
//! | Key | The hub |
//! | --------------------------- | ---------------------------------------------------------------- |
//! | `run_id` | checks the form; addresses the run by it |
//! | `status`, `error.kind` | checks the status/detail pairing; filters and counts by them |
//! | facets | fills defaults from the header; fingerprints them |
//! | `metrics` | checks each key is `{ns}/{name}`; indexes the numbers |
//! | `attachments[]` and pointers| checks references resolve and the objects are uploaded |
//! | `ext` | stores; searchable, typed once the namespace registers a schema |
//! | `error.message`, `skip_reason`, `started_at`, `ended_at` | stores and returns |
//! | `meta` | stores and returns; never validates, indexes or queries it |
//!
//! `metrics` holds values measured directly from the run: token counts,
//! durations, cost, an exit code, the length of an output, basic statistics
//! within the run. A key is a registry id of the same form as a Card's
//! `results[].metric` (`metric_id_invalid` otherwise); a metric the
//! registry does not know is accepted. A value that depends on how the run
//! is graded does not belong here; it is the Card's, in `run_results`,
//! which may name the metrics it was derived from (`from`).
//!
//! `meta` is the one place the hub never looks into. It is for whatever the
//! producer wants kept with the run and returned verbatim, and it is where
//! the 1.0 conversion keeps the values it had to drop (the old `outcome`).
//! `ext` is different: it is namespaced, and a namespace can register a
//! schema to make its keys typed and queryable.
//!
//! As with a record, the run is the producer's claim and the hub's facts
//! (its content hash, its fingerprints, whether it was archived) are
//! returned beside it, not inside it.
use BTreeMap;
use ;
use JsonSchema;
use ;
use crate;
use crate;
/// One run of an Eval: one execution, its conditions, its files and what
/// was measured directly from it. A run records what happened, never
/// whether it passed; the verdict is a Card's `run_results`.
/// The state of a run's execution. Not a verdict: pass and fail are a Card's.
/// How a run failed.