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
//! The error mode an artifact was generated under, stamped into the artifact (#1629).
//!
//! # The defect
//!
//! Every census and corpus in this repository is a measurement taken through a
//! normalizer, and a normalizer carries an [`ErrorConfig`]. The mode that config
//! names is not a detail of the run — it changes the numbers. Measured on the
//! spec conformance corpus (`tests/it/corpus_prohibited_inputs.rs`), which
//! re-measures three of the four refusal counters in strict mode: two of them
//! move — `conflicts_accepted`'s 72 are all refused and 16 of
//! `prohibited_conditional_accepted`'s 40 are — while `prohibited_absolute_accepted`'s
//! 32 stay accepted. One counter that moves is already enough to make a census
//! compared across modes a category error, and the decided ruling
//! `bare-transcript-intronic-position` has to end with the sentence "**so that
//! counter is a lenient-mode figure**" because nothing in the artifact says so.
//!
//! The failure is quiet in the way that costs the most. `NormalizeConfig::default()`
//! substitutes `ErrorConfig::lenient()`, while `ErrorMode`'s own `#[default]` is
//! `Strict` and `ErrorConfig::default()` is `strict()` — so a generator written
//! as `Normalizer::new(provider)` measures in **lenient** mode while reading as
//! though it took the default, which everywhere else in the crate means strict.
//! `NormalizeConfig` cannot help: its `error_config` field is `#[serde(skip)]`,
//! so serializing the whole config still emits no mode.
//!
//! Two censuses taken under different modes are then indistinguishable
//! artifacts, and comparing them is a category error nobody can detect from the
//! files. That is the same shape as the corpus-zero hazard
//! [`completeness`](super::completeness) exists for: a measurement whose
//! *precondition* is unrecoverable reads exactly like one whose precondition was
//! what you assumed.
//!
//! # The stamp
//!
//! [`ErrorModeStamp`] is derived from the [`ErrorConfig`] the generator actually
//! built, never written by hand:
//!
//! ```
//! use ferro_hgvs::conformance::error_mode_stamp::ErrorModeStamp;
//! use ferro_hgvs::error_handling::{ErrorConfig, ErrorOverride, ErrorType};
//!
//! let config = ErrorConfig::lenient().with_override(ErrorType::MissingVersion, ErrorOverride::Reject);
//! let stamp = ErrorModeStamp::of(&config);
//!
//! assert_eq!(stamp.error_mode, "lenient");
//! assert_eq!(stamp.error_mode_overrides["MissingVersion"], "reject");
//! ```
//!
//! Three properties are deliberate, and each is a lesson from `CaptureCounts`
//! being stampable-but-never-stamped:
//!
//! - **It carries the overrides, not only the mode.** A mode is the *base* of a
//! per-code resolution (see [`ErrorMode`]'s type docs), so `"lenient"` alone
//! is not a reproducible precondition when the generator overrode two codes.
//! An artifact that named only the mode would be a more convincing version of
//! the same gap.
//! - **There is no [`Default`], and no public constructor that invents one.**
//! `ErrorModeStamp::of(&config)` is the only way to build one, so a stamp
//! cannot be filled in from what the author believed the mode was — which is
//! the belief that was wrong in every case above.
//! - **It is [`Deserialize`] as well as [`Serialize`]**, so a consuming test can
//! assert the precondition it is comparing against rather than assume it.
//!
//! **Name the half the stamp covers.** A stamp describes one `ErrorConfig`, and
//! a generator usually has two stages that could carry one. Both spec generators
//! here parse with the bare [`parse_hgvs`](crate::parse_hgvs), which constructs
//! no `InputPreprocessor` and so applies **no** `ErrorConfig` at all — not
//! lenient's repairs and not strict's refusals (#1632, pinned by
//! `tests/it/issue_1632_parse_entry_applies_no_mode.rs`). "No mode" is a third
//! thing, not a synonym for strict, so a field named `generated_under` on those
//! artifacts would assert a parser-level precondition no row ever had, which is
//! a fresh ambiguity introduced by the field added to remove one. They name the
//! field `normalized_under` for that reason. Stamp what you configured, and let
//! the field name say how far it reaches.
//!
//! The mechanical half — "a generator that normalizes and writes an artifact
//! must stamp this, or name itself in an allowlist" — is
//! `tests/it/generator_completeness.rs`. Read its reach honestly: it is a
//! substring scan, a floor rather than a proof, exactly as the ledger guard
//! beside it is.
use BTreeMap;
use ;
use crate;
/// The error-handling precondition of a generated artifact.
///
/// Stamp it beside an artifact's other identity fields (`description`,
/// `spec`, `completeness`) so a reader can tell which mode produced the numbers
/// without re-running the generator. Build it with [`ErrorModeStamp::of`].