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
// SPDX-License-Identifier: Apache-2.0
//! An instance: one check, applied to one target, with one outcome.
//!
//! [Spec 12](../../../../docs/spec/12-check-layer.md#instances-and-why-coverage-needs-them)
//! says a check is a template and the engine instantiates it per target, and
//! that coverage then follows with no added mechanism: "each run records, per
//! document, which instances were created, which ran, which were served from
//! cache, and which were skipped with a reason."
//!
//! Three of those four are here, and the fourth is deliberately not. Whether
//! an instance was served from a cache is a fact about a disk rather than
//! about a corpus, and [`crate::cache`] states why no report carries it.
//!
//! # A read is a path and a content hash
//!
//! [Spec 12](../../../../docs/spec/12-check-layer.md#the-read-set-and-what-a-merge-does-to-a-verdict)
//! fixes what the read set of a run is: "the content hash of every document
//! and edge that an instance read". Coverage needs the path, because it counts
//! per document. A cache key needs the hash, because a key that omits an input
//! is a correctness bug rather than a performance bug. Both are one field, so
//! no second pass can produce a read set that disagrees with the first.
//!
//! The hash is the census's, of the bytes it read. An [`Input`] whose digest
//! is absent is a document that the walk never read, and [`crate::cache`]
//! refuses to key on it rather than substitute a value.
//!
//! # An instance is accounted to every document it read
//!
//! Coverage is per document, and an instance of a Graph-origin check has an
//! edge for a target rather than a document. Spec 12 fixes what an edge-scoped
//! instance reads: "one relation instance **and both endpoints**". So an
//! instance names every document it read, and coverage counts it against each
//! of them.
//!
//! Attributing it to one end instead would be the silent pass one level up. A
//! document at the receiving end of a reciprocity pair *is* checked — the rule
//! reads it, and it fires when that document is the one missing its half — and
//! a coverage report that called it unchecked would send its author to look for
//! a shelf pattern that is already right.
//!
//! A finding carries its own path, which is a different question: what a check
//! read, and where the author who can act on it is looking.
//!
//! # Reading is not routing, and coverage counts the second one
//!
//! The paragraph above is about the three grains whose target is a document or
//! an edge between two. A corpus-grained instance reads every document and is
//! routed to none of them, so [`crate::coverage`] counts it against none. The
//! grain is on the instance for that one question, and
//! [`crate::Grain::routes`] is where the answer is written down.
use crateFinding;
use crateGrain;
/// One check, applied to one target.
/// One in-scope input: a document, and the hash of the bytes it holds.
/// What became of one instance. Closed, and matched exhaustively.