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
//! One execution's record, and the complete-table census a run is stated over.
use crate::clock::MeasurementReading;
use crate::descriptor::{ClaimRef, TablePosture};
use crate::report::{
ExecutionKey, ExecutionRevisions, Exercise, ForeignText, HostTrialRecord,
InfrastructureFailure, InfrastructureFault, InvocationProfile, NotSelectedReason, OutcomeClass,
ReplayPosture, RowRevisionId, RunAttempt, RunReport, SelectionDisposition,
SelectionExpectation, SelectionOutcome, TargetBinding, TrialAccounting, TrialConclusion,
TrialId, TrialReport, TrialRunStanding, TrialSite,
};
impl InfrastructureFailure {
/// Record one harness-side failure with its normalized class and bounded foreign material.
#[must_use]
pub const fn recorded(fault: InfrastructureFault, foreign: Option<ForeignText>) -> Self {
Self { fault, foreign }
}
/// The normalized harness-side failure class.
#[must_use]
pub const fn fault(&self) -> InfrastructureFault {
self.fault
}
/// The bounded material the failing boundary carried in, where it carried any.
#[must_use]
pub const fn foreign(&self) -> Option<&ForeignText> {
self.foreign.as_ref()
}
}
impl HostTrialRecord {
/// One host's typed input about one selected trial.
#[must_use]
pub fn recorded(trial: TrialId, attempt: RunAttempt, measurement: MeasurementReading) -> Self {
Self {
trial,
attempt,
measurement,
}
}
/// The semantic trial the host says this input belongs to.
#[must_use]
pub const fn trial(&self) -> TrialId {
self.trial
}
/// What the host says became of the attempt.
#[must_use]
pub const fn attempt(&self) -> &RunAttempt {
&self.attempt
}
/// The wall-measurement posture the host recorded.
pub const fn measurement(&self) -> MeasurementReading {
self.measurement
}
/// The three host-authored seats, for the runner join that admits them.
pub(crate) fn into_parts(self) -> (TrialId, RunAttempt, MeasurementReading) {
(self.trial, self.attempt, self.measurement)
}
}
impl TrialRunStanding {
/// The standing the runner derived from one binding and one invocation.
#[must_use]
pub(crate) fn derived(key: ExecutionKey, replay: ReplayPosture) -> Self {
Self { key, replay }
}
/// The exact execution key this trial ran under.
#[must_use]
pub const fn key(&self) -> &ExecutionKey {
&self.key
}
/// The replay ceiling derived from the attachment's revision posture meet.
#[must_use]
pub const fn replay(&self) -> ReplayPosture {
self.replay
}
}
impl TrialReport {
/// One execution's record.
#[must_use]
pub(crate) fn recorded(
standing: TrialRunStanding,
site: TrialSite,
attempt: RunAttempt,
measurement: MeasurementReading,
) -> Self {
Self {
standing,
site,
attempt,
measurement,
}
}
/// The trial's semantic identity.
#[must_use]
pub const fn trial(&self) -> TrialId {
self.standing.key().trial()
}
/// The exact execution standing this report was admitted under.
#[must_use]
pub const fn standing(&self) -> &TrialRunStanding {
&self.standing
}
/// Where the trial is written.
#[must_use]
pub const fn site(&self) -> TrialSite {
self.site
}
/// What became of the attempt.
#[must_use]
pub const fn attempt(&self) -> &RunAttempt {
&self.attempt
}
/// The wall-measurement posture recorded around the attempt.
pub const fn measurement(&self) -> MeasurementReading {
self.measurement
}
}
impl SelectionDisposition {
/// Selected, carrying its execution record.
#[must_use]
pub(crate) fn selected(report: TrialReport) -> Self {
Self::Selected(Box::new(report))
}
/// Not selected, for a stated reason.
#[must_use]
pub(crate) const fn not_selected(trial: TrialId, reason: NotSelectedReason) -> Self {
Self::NotSelected { trial, reason }
}
/// The semantic identity of this census seat.
#[must_use]
pub const fn trial(&self) -> TrialId {
match self {
Self::Selected(report) => report.trial(),
Self::NotSelected { trial, reason: _ } => *trial,
}
}
/// The execution record, where the invocation selected the trial.
#[must_use]
pub fn report(&self) -> Option<&TrialReport> {
match self {
Self::Selected(report) => Some(report.as_ref()),
Self::NotSelected {
trial: _,
reason: _,
} => None,
}
}
/// Whether this row of the denominator was actually exercised.
#[must_use]
pub fn exercise(&self) -> Exercise {
match self {
Self::Selected(report) => match report.attempt() {
RunAttempt::Executed(_) => Exercise::Exercised,
RunAttempt::SkippedWithReason(_)
| RunAttempt::TimedOut
| RunAttempt::InfrastructureFailed(_) => Exercise::Unexercised,
},
Self::NotSelected {
trial: _,
reason: _,
} => Exercise::Unexercised,
}
}
/// The normalized outcome, for a comparison to read.
#[must_use]
pub fn outcome(&self) -> OutcomeClass {
match self {
Self::Selected(report) => match report.attempt() {
RunAttempt::Executed(TrialConclusion::Passed) => OutcomeClass::Passed,
RunAttempt::Executed(TrialConclusion::Refused(finding)) => {
OutcomeClass::Refused(finding.class())
}
RunAttempt::SkippedWithReason(reason) => OutcomeClass::Skipped(*reason),
RunAttempt::TimedOut => OutcomeClass::TimedOut,
RunAttempt::InfrastructureFailed(failure) => {
OutcomeClass::InfrastructureFailed(failure.fault())
}
},
Self::NotSelected { trial: _, reason } => OutcomeClass::NotSelected(*reason),
}
}
}
impl TrialAccounting {
/// One row of the denominator, and what this invocation did about it.
#[must_use]
pub(crate) fn recorded(
row: RowRevisionId,
revisions: ExecutionRevisions,
claim: ClaimRef,
disposition: SelectionDisposition,
) -> Self {
Self {
row,
revisions,
claim,
disposition,
}
}
/// The trial's semantic identity.
#[must_use]
pub const fn trial(&self) -> TrialId {
self.disposition.trial()
}
/// The authored row's revision identity.
#[must_use]
pub const fn row(&self) -> RowRevisionId {
self.row
}
/// The subject and check revisions this row's binding stood on.
#[must_use]
pub const fn revisions(&self) -> ExecutionRevisions {
self.revisions
}
/// The claim the row serves.
#[must_use]
pub const fn claim(&self) -> ClaimRef {
self.claim
}
/// What the invocation did about it.
#[must_use]
pub const fn disposition(&self) -> &SelectionDisposition {
&self.disposition
}
}
impl SelectionOutcome {
/// Read one run's selection against what the run expected of it.
///
/// A total map over two facts the run already holds — how many rows the selection named, and what the caller declared beforehand — so the same pair always reads the same way.
#[must_use]
pub const fn read(expectation: SelectionExpectation, selected: usize) -> Self {
if selected > 0_usize {
return Self::Satisfied;
}
match expectation {
SelectionExpectation::AtLeastOne => Self::UnsatisfiedByEmptySelection,
SelectionExpectation::AllowEmpty(reason) => Self::EmptyAsStated(reason),
}
}
}
impl RunReport {
/// One run's complete-table accounting.
///
/// The census arrives complete, one entry per row of the table the run stood over, because a report that dropped its unselected rows would state a smaller world than the one it ran in.
/// The selection outcome arrives already read, because what a run expected of its selection is the engine's parameter and a census cannot state an expectation.
#[must_use]
pub(crate) fn recorded(
census: Vec<TrialAccounting>,
posture: TablePosture,
selection: SelectionOutcome,
invocation: InvocationProfile,
target: TargetBinding,
) -> Self {
Self {
census,
posture,
selection,
invocation,
target,
}
}
/// What this run's selection matched, read against what it expected.
#[must_use]
pub const fn selection(&self) -> SelectionOutcome {
self.selection
}
/// Every row of the denominator, with its disposition.
#[must_use]
pub fn census(&self) -> &[TrialAccounting] {
&self.census
}
/// How many rows the run was stated over.
#[must_use]
pub fn denominator(&self) -> usize {
self.census.len()
}
/// Which table the run stood over.
#[must_use]
pub const fn posture(&self) -> TablePosture {
self.posture
}
/// The invocation profile the run ran under.
#[must_use]
pub const fn invocation(&self) -> InvocationProfile {
self.invocation
}
/// The target and toolchain this run stood on.
#[must_use]
pub const fn target(&self) -> &TargetBinding {
&self.target
}
}