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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
//! `metadata.json` — the retained-evidence schema every bake-off level must
//! carry (#5441).
//!
//! Why: #5441's gate contract requires each retained L1-L3 level to state
//! tokens, cache use, cost, turns, duration, status, and build provenance. The
//! first independent qualification attempt failed on exactly that: the runner
//! kept raw artifacts but recorded neither the candidate commit, the binary
//! hash, the challenge/runner revision, nor the instruction/agent/skill source
//! digests, so nobody could prove which binary produced the numbers. Declaring
//! the schema HERE — in the crate under test, not in the external runner —
//! makes the runner conform to the gate rather than the gate infer the
//! runner's shape.
//! What: [`LevelMetadata`] and its parts, plus [`LevelMetadata::provenance_gaps`],
//! which names every field a run left empty, `"unknown"`, or zero. Deserialization
//! fails CLOSED: an unrecognised `evidence_mode` string becomes
//! [`EvidenceMode::Unknown`], which the preflight rejects exactly as it rejects
//! a declared mock.
//! Test: `bakeoff::tests::metadata_round_trips_the_documented_shape`,
//! `bakeoff::tests::provenance_gaps_names_every_missing_field`,
//! `bakeoff::tests::unknown_evidence_mode_is_not_real`.
use ;
/// Whether a level's artifacts came from a real model run or a plumbing-only
/// mock.
///
/// Why: #5441 permits offline/mock runs to validate plumbing but states they
/// "do not satisfy the exit gate". A boolean would let an absent field default
/// to the permissive value; an explicit enum with a catch-all makes an
/// unrecognised or missing declaration fail closed.
/// What: `real` and `mock` deserialize from those literals; anything else
/// (including a typo or a future variant) becomes `Unknown`, which
/// [`EvidenceMode::is_real`] reports as not-real.
/// Test: `bakeoff::tests::unknown_evidence_mode_is_not_real`.
/// Which bake-off runner produced the level, and at what revision.
///
/// Why: #5441's preflight must reject "stale runner paths". A path alone
/// cannot establish that: the same path holds a different runner after a pull.
/// Recording path, revision, and whether that checkout was dirty makes the
/// claim checkable — a dirty runner checkout means the recorded revision does
/// not identify what actually ran, which is precisely how the first
/// qualification attempt's evidence was disqualified.
/// What: plain strings plus a `dirty` flag; no path is resolved or touched by
/// this crate, which never runs the runner.
/// Test: `bakeoff::tests::dirty_runner_checkout_is_rejected`.
/// Model, provider, and timeout the level was invoked with.
///
/// Why: #5441 requires one reproducible invocation; a rerun that silently
/// changed model or timeout is a different experiment, not a comparison.
/// What: the three fields that change a run's outcome independently of the
/// candidate build.
/// Test: `bakeoff::tests::provenance_gaps_names_every_missing_field`.
/// Which `tcode` binary produced the level.
///
/// Why: "results produced by a different Trusty Code build" is one of the five
/// rejections #5441 names. `version`/`commit`/`commit_date` mirror
/// [`crate::build_info::provenance_json`] so the metadata can be cross-checked
/// against the level's own `tcode_report.json` rather than trusted; the binary
/// hash is what survives when the source tree is gone.
/// What: the three report fields plus a SHA-256 of the invoked binary and a
/// `dirty` flag for the candidate checkout.
/// Test: `bakeoff::tests::report_build_mismatch_is_rejected`.
/// Digests of the canonical instruction/agent/skill sources the run consumed.
///
/// Why: #5441's R1 note is explicit that the compatibility runner still writes
/// `.claude/agents` and `.claude/skills`, and that R1 "must record the
/// compatibility-source digests it actually used". Recording digests keeps the
/// evidence honest across the #5425/#5426 source convergence without this gate
/// having to know which layout was canonical on the day.
/// What: three opaque digest strings; this crate compares them across levels
/// and never interprets their algorithm.
/// Test: `bakeoff::tests::source_digest_drift_across_levels_is_rejected`.
/// Token counts for one level, mirroring `tcode_report.json`'s `usage` block.
///
/// Why: #5441 asks for tokens AND cache use separately — a cost change driven
/// by a collapsed cache read is a different finding from one driven by more
/// completion tokens.
/// What: the same four counters `run_task::report` renders.
/// Test: `bakeoff::tests::token_regression_beyond_tolerance_needs_a_disposition`.
/// What the level's run actually did.
///
/// Why: #5441 requires terminal status, turns, duration, and cost retained per
/// level so the next milestone can compare against them.
/// What: `status` uses `run_task::report`'s own vocabulary (`success`,
/// `partial`, `deadline_exceeded`, …) so it can be cross-checked against the
/// level's `tcode_report.json` rather than trusted.
/// Test: `bakeoff::tests::metadata_status_must_match_the_run_report`.
/// The verifier's verdict for one level.
///
/// Why: verifier pass rate is the first thing #5441's comparison names, and a
/// correctness regression blocks milestone closure outright.
/// What: two counters; `checks_total == 0` means the verifier produced no
/// correctness evidence at all, which the preflight treats as mock evidence.
/// Test: `bakeoff::tests::zero_verifier_checks_is_mock_evidence`.
/// One level's complete `metadata.json`.
///
/// Why: this is the retained-evidence contract #5441's gate reads. Everything
/// the gate decides comes from this document plus the sibling raw artifacts;
/// nothing is inferred from the filesystem or from a live process.
/// What: level number, evidence mode, runner/challenge/build/source provenance,
/// the invocation, run telemetry, and the verifier verdict.
/// Test: `bakeoff::tests::metadata_round_trips_the_documented_shape`.
/// Whether a recorded provenance string actually identifies anything.
///
/// Why: `build_info` emits the literal `"unknown"` rather than an absent key
/// outside a git checkout, so an emptiness test alone would accept it.
/// What: false for empty, whitespace-only, and case-insensitive `"unknown"`.
/// Test: `bakeoff::tests::provenance_gaps_names_every_missing_field`.