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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
//! The stamp: the road from one declaration of rows to the seats a test host runs.
//!
//! It lives here, with the vocabulary it reads, because everything it names on the descriptor side is this home's — the table constructor, the binding constructor, the name parsers, and the one refusal family the whole road answers with.
//!
//! Nothing in this file is compiled where it is written.
//! A `macro_rules!` body is a token sequence expanded at the site that invokes it, so this home gains no dependency edge from anything the expansion names — including [`crate::runner`], which sits above it.
//! `$crate` names this crate wherever the expansion lands, whatever a consumer renamed the dependency to.
//!
//! # What the expansion demands of the engine
//!
//! The stamp is the road that instantiates the descriptor vocabulary's two type parameters.
//! A [`Binding`](crate::descriptor::Binding) is generic in its invocation facts and its conclusion because this home may not import a record type; the stamp expands at the engine's instantiation of them, because that is the pair the engine the seats call runs at.
//! A table whose bindings carry another pair is a lawful table and does not go through this stamp.
//!
//! Past `core` and `std` the expansion names the record vocabulary, the clock, and the engine, and no other home — each by name here, with its own home owning what it takes and returns:
//!
//! - [`runner::TrialBinding`](crate::runner::TrialBinding) and [`runner::TrialTable`](crate::runner::TrialTable), the two aliases spelling that instantiation, so no expansion writes the parameters by hand.
//! - [`clock::HarnessClock`](crate::clock::HarnessClock), whose declared road to a reading is a `const`, so a table's clock is stamped as a constant beside its budgets.
//! - [`runner::Invocation`](crate::runner::Invocation), declared once per seat and once per lens, so a report carries the site of the seat that ran it.
//! - [`runner::Selection`](crate::runner::Selection)'s by-suite arm — one aggregate seat names exactly one suite and hands it in as a one-element set.
//! - [`runner::SelectionPlan::of`](crate::runner::SelectionPlan::of), the road that states a run expects its selection to match at least one row.
//! A stamped seat takes it and never the empty-tolerant one: a declared suite that pairs with no row is the vacuity these seats exist to catch.
//! - [`runner::run_all`](crate::runner::run_all) and [`runner::run_one`](crate::runner::run_one), whose accounting has no refusal path after caller-supplied functions return.
//! - [`runner::SeatRefusal`](crate::runner::SeatRefusal), the seats' one refusal type, reached unchanged by every construction refusal on this road.
//! - [`runner::seat_verdict`](crate::runner::seat_verdict) and [`runner::lens_verdict`](crate::runner::lens_verdict) — the engine's own verdict readings, because a fold over a report written into every expansion would be a calculator standing in as many places as there are invocations.
//!
//! # Where a host fact enters
//!
//! A run stands on facts no library here can honestly read: which target it was compiled for, which toolchain built it, and what a nanosecond reading is worth.
//! A triple assembled out of `cfg!` predicates would be a plausible spelling of a fact rather than the fact, and it would enter a cache key, so a wrong one buys a hit nothing verified.
//! So `target:` and `clock:` are declared at the invocation, in the caller's own test target, and the expansion carries them through untouched.
//! Neither clause is optional, and that is the point: the honest answer to "nothing was measured" has a name a person types.
//!
//! The third host-shaped fact, the site, is neither declared nor read: it is where the seat is written, which the expansion already knows.
//!
//! # The refusal channel
//!
//! Every seat the stamp writes is a test function returning a `Result`, and the expansion routes its own fallible constructions and verdict reading through that typed channel.
//! No expansion contains an unwrap, an expectation, an assertion, an explicit panic, or an index.
//! Row expressions and caller-supplied functions keep their own effect and unwind ceilings; the stamp does not turn arbitrary caller code into a panic-free operation.
/// Stamps one complete authored world, one aggregate seat per declared execution suite, and one named lens per row, from a single declaration.
///
/// # The grammar
///
/// Two invocation forms, differing only in the provenance the table states.
/// The unproduced form:
///
/// ```text
/// trial_table! {
/// /// Optional notes, carried onto the stamped module.
/// pub mod <module> named(<namespace literal>, <stem literal>) {
/// provenance: unproduced,
/// invocation: <expression>,
/// target: <expression>,
/// clock: <expression>,
///
/// suite <seat> named(<namespace literal>, <stem literal>) {
/// <row>: <expression>,
/// <row>: <expression>,
/// }
/// }
/// }
/// ```
///
/// The produced form replaces one clause, and nothing else:
///
/// ```text
/// provenance: produced(<namespace literal>, <stem literal>)
/// against <expression>,
/// ```
///
/// - `<module>` is the stamped module's name, and the visibility in front of `mod` is carried onto the module and onto every declaration it holds, so no public road ever ends at a private one.
/// - `named(<namespace>, <stem>)` after `mod` is the authored table's own namespaced name, parsed at run time because a name that states no owner is refused rather than stamped.
/// - `provenance:` is one of the two forms above; the produced form's expression evaluates to `Result<GeneratedSupportSchemaId, TrialTableRefusal>`, which is the shape a producer's own identity road already has.
/// - `invocation:` evaluates to an [`InvocationProfile`](crate::report::InvocationProfile), stamped as a `const` item deliberately: an ambient fact cannot appear in a `const`, so a reading or an environment value in this position is refused by the compiler rather than by a rule somebody follows.
/// - `target:` evaluates to a [`TargetBinding`](crate::report::TargetBinding), and has no default because nothing in this crate derives a triple or a toolchain identity.
/// A consumer that wants them read rather than typed writes a build script in its own crate that emits them.
/// - `clock:` evaluates to a [`HarnessClock`](crate::clock::HarnessClock), stamped as a `const` for the reason the budgets are one: what a clock declares is the road to a reading, never a reading.
/// A table that measures nothing writes [`HarnessClock::unavailable()`](crate::clock::HarnessClock::unavailable), whose reading stays distinct from an observed zero.
/// - `suite <seat> named(<namespace>, <stem>) { … }` declares one aggregate seat: `<seat>` is the test function's name, and the two literals are the [`ExecutionSuite`](crate::descriptor::ExecutionSuite) it selects on.
/// At least one suite group is required, and each group requires at least one row.
/// - `<row>: <expression>` declares one row: `<row>` names its lens, and the expression answers with one [`TrialBinding`](crate::runner::TrialBinding) or refuses in any family that discharges into [`TrialTableRefusal`](crate::descriptor::TrialTableRefusal).
/// The stamp never reads inside the expression: a row's internals are the producer's statement, and a macro that parsed them would be a second authority over this vocabulary.
///
/// Both grammars end their clauses and their rows with a comma.
///
/// # What is stamped
///
/// One module, containing a private `row` module with one function per declared row; a `table` function building the authored world through the public constructors; an `INVOCATION` constant and a `CLOCK` constant; a `target` function; one ordinary `#[test]` per suite group; and one `#[test] #[ignore = "lens"]` per row.
/// Each seat and each lens builds its own invocation, so a report carries the site of the seat that produced it rather than one site the whole table shared.
///
/// # Authority
///
/// Every declared row lands in the one table, whichever group it was declared under.
/// The grouping decides which aggregate seat exists; it never decides which rows the world holds, because a selection narrows a run and never the denominator.
///
/// A group is a seat declaration and not a claim about the rows in it: the selection reads each row's own execution suite, so a row grouped under a seat whose suite is not the row's own is simply not selected by that seat.
/// The stamp cannot check that pairing without reading inside a row expression, and does not pretend to; the engine answers it at run time, because a seat whose selection named no row refuses.
///
/// # Bounds
///
/// A seat's name and a row's name share one namespace, because both are functions in the stamped module, and the stamp takes five spellings in it — `row`, `table`, `target`, `INVOCATION`, and `CLOCK`.
/// A seat or row claiming one is an ordinary duplicate definition with an ordinary diagnostic.
///
/// The seats are `#[test]` functions, so the stamp is invoked where a test harness collects them.
///
/// The `@`-prefixed rule below is the stamp's internal transcription, not an invocation form.
/// The forms above are text rather than compiled examples, because a compiled one needs a subject, a check, and a population, and those live on the challenge side.
};
=> ;
// THE ONE TRANSCRIPTION. Both invocation forms arrive here with their provenance already assembled
// into one expression of one type, so the module below is written once and neither form can drift
// from the other.
=> ;
}