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
//! The three identity rails: what a trial means, which revisions it stood on, and what one execution was keyed by.
use crate::descriptor::{CanonicalRowBytes, RevisionBinding, TrialKey};
use crate::identity::ContentAddress;
use crate::report::{
ByteBudget, CaseBudget, CheckRevisionId, EXECUTION_KEY_TAG, ExecutionKey, ExecutionRevisions,
InvocationProfile, ProfiledTrial, ROW_REVISION_TAG, RowRevisionId, SubjectRevisionId,
TRIAL_IDENTITY_TAG, TargetBinding, TargetTriple, TimeBudget, ToolchainIdentity, TrialId,
TrialProfile, TrialSite, execution_key_preimage, trial_preimage,
};
impl ProfiledTrial {
/// One trial's key under one profile.
///
/// Standing on the key rather than on the whole row is what keeps the execution suite, the roles, and the tags out of a trial's identity.
#[must_use]
pub const fn of_key(key: TrialKey, profile: TrialProfile) -> Self {
Self { key, profile }
}
/// The trial's compact key.
#[must_use]
pub const fn key(self) -> TrialKey {
self.key
}
/// The profile coordinate.
#[must_use]
pub const fn profile(self) -> TrialProfile {
self.profile
}
}
impl TrialId {
/// Derive one trial's semantic identity from its complete preimage.
///
/// Deterministic and total: every key under every profile names a trial.
#[must_use]
pub fn over(profiled: ProfiledTrial) -> Self {
Self(ContentAddress::derived(
TRIAL_IDENTITY_TAG,
&trial_preimage(profiled),
))
}
/// Derive the identity of the trial one descriptor row declares.
#[must_use]
pub fn of_key(key: TrialKey, profile: TrialProfile) -> Self {
Self::over(ProfiledTrial::of_key(key, profile))
}
/// The identity's address, for comparison and for rendering.
#[must_use]
pub const fn address(&self) -> &ContentAddress {
&self.0
}
}
impl TrialSite {
/// Where one trial is written.
#[must_use]
pub const fn located(
module_path: &'static str,
file: &'static str,
line: u32,
name: &'static str,
) -> Self {
Self {
module_path,
file,
line,
name,
}
}
/// The module path the trial is declared under.
#[must_use]
pub const fn module_path(&self) -> &'static str {
self.module_path
}
/// The file the trial is declared in.
#[must_use]
pub const fn file(&self) -> &'static str {
self.file
}
/// The line the trial is declared on.
#[must_use]
pub const fn line(&self) -> u32 {
self.line
}
/// The trial's display name, which is what a person filters on.
#[must_use]
pub const fn name(&self) -> &'static str {
self.name
}
}
impl RowRevisionId {
/// Derive one row revision identity from the row's canonical bytes.
///
/// Total, and typed on the bytes rather than on a slice: holding them is holding everything the derivation needs, so there is nothing left here to refuse.
#[must_use]
pub fn over(canonical_row: &CanonicalRowBytes) -> Self {
Self(ContentAddress::derived(
ROW_REVISION_TAG,
canonical_row.as_bytes(),
))
}
/// The identity's address.
#[must_use]
pub const fn address(&self) -> &ContentAddress {
&self.0
}
}
impl SubjectRevisionId {
/// The subject revision one attachment bound, under this home's name for it.
///
/// The address crosses unchanged; nothing is derived a second time.
#[must_use]
pub const fn of_binding(binding: RevisionBinding) -> Self {
Self(binding.revision())
}
/// The identity's address.
#[must_use]
pub const fn address(&self) -> &ContentAddress {
&self.0
}
}
impl CheckRevisionId {
/// The check revision one attachment bound, under this home's name for it.
#[must_use]
pub const fn of_binding(binding: RevisionBinding) -> Self {
Self(binding.revision())
}
/// The identity's address.
#[must_use]
pub const fn address(&self) -> &ContentAddress {
&self.0
}
}
impl ExecutionRevisions {
/// Bind the differently typed subject and check revision identities into one execution standing.
#[must_use]
pub const fn bound(subject: SubjectRevisionId, check: CheckRevisionId) -> Self {
Self { subject, check }
}
/// The subject revision.
#[must_use]
pub const fn subject(self) -> SubjectRevisionId {
self.subject
}
/// The check revision.
#[must_use]
pub const fn check(self) -> CheckRevisionId {
self.check
}
}
impl TargetTriple {
/// The target triple the run declared.
#[must_use]
pub fn declared(spelling: &str) -> Self {
Self(spelling.to_owned())
}
/// The declared spelling.
#[must_use]
pub fn spelling(&self) -> &str {
&self.0
}
}
impl ToolchainIdentity {
/// The toolchain identity the run declared.
#[must_use]
pub fn declared(spelling: &str) -> Self {
Self(spelling.to_owned())
}
/// The declared spelling.
#[must_use]
pub fn spelling(&self) -> &str {
&self.0
}
}
impl TargetBinding {
/// The target and toolchain one execution ran under.
#[must_use]
pub fn bound(target: TargetTriple, toolchain: ToolchainIdentity) -> Self {
Self { target, toolchain }
}
/// The compilation target.
#[must_use]
pub const fn target(&self) -> &TargetTriple {
&self.target
}
/// The toolchain.
#[must_use]
pub const fn toolchain(&self) -> &ToolchainIdentity {
&self.toolchain
}
}
impl CaseBudget {
/// The case budget the invocation declared.
#[must_use]
pub const fn declared(cases: u32) -> Self {
Self(cases)
}
/// The declared number of cases.
#[must_use]
pub const fn cases(self) -> u32 {
self.0
}
}
impl ByteBudget {
/// The input-byte budget the invocation declared.
#[must_use]
pub const fn declared(bytes: u64) -> Self {
Self(bytes)
}
/// The declared number of bytes.
#[must_use]
pub const fn bytes(self) -> u64 {
self.0
}
}
impl TimeBudget {
/// The time budget the invocation declared, in nanoseconds.
#[must_use]
pub const fn declared(nanoseconds: u64) -> Self {
Self(nanoseconds)
}
/// The declared bound, in nanoseconds.
#[must_use]
pub const fn nanoseconds(self) -> u64 {
self.0
}
}
impl InvocationProfile {
/// The invocation's conclusion-relevant facts.
#[must_use]
pub const fn declared(cases: CaseBudget, bytes: ByteBudget, time: TimeBudget) -> Self {
Self { cases, bytes, time }
}
/// The case budget.
#[must_use]
pub const fn cases(self) -> CaseBudget {
self.cases
}
/// The input-byte budget.
#[must_use]
pub const fn bytes(self) -> ByteBudget {
self.bytes
}
/// The time budget.
#[must_use]
pub const fn time(self) -> TimeBudget {
self.time
}
}
impl ExecutionKey {
/// The key one execution of one trial is looked up under.
///
/// The target binding is taken unconditionally, so a cross-target hit is not a policy the harness applies but a value it cannot construct.
#[must_use]
pub fn over(
trial: TrialId,
subject: SubjectRevisionId,
check: CheckRevisionId,
invocation: InvocationProfile,
target: TargetBinding,
) -> Self {
Self {
trial,
revisions: ExecutionRevisions::bound(subject, check),
invocation,
target,
}
}
/// The trial this key executes.
#[must_use]
pub const fn trial(&self) -> TrialId {
self.trial
}
/// The subject revision it stood on.
#[must_use]
pub const fn subject(&self) -> SubjectRevisionId {
self.revisions.subject()
}
/// The check revision it stood on.
#[must_use]
pub const fn check(&self) -> CheckRevisionId {
self.revisions.check()
}
/// The exact subject and check revision standing.
#[must_use]
pub const fn revisions(&self) -> ExecutionRevisions {
self.revisions
}
/// The invocation profile it ran under.
#[must_use]
pub const fn invocation(&self) -> InvocationProfile {
self.invocation
}
/// The target and toolchain it ran on.
#[must_use]
pub const fn target(&self) -> &TargetBinding {
&self.target
}
/// The key's address, derived from its parts.
#[must_use]
pub fn address(&self) -> ContentAddress {
ContentAddress::derived(
EXECUTION_KEY_TAG,
&execution_key_preimage(
self.trial,
self.revisions.subject(),
self.revisions.check(),
self.invocation,
&self.target,
),
)
}
}