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
//! The two value types the dimension axes are built from: a set of names
//! compared as a set, and a scalar label compared exactly.
//!
//! Four dimensions need a value and only two comparison rules sit between
//! them. `organism` and `source_set` are both "which of these things is the
//! data about", where order is noise and a missing member is the whole
//! point; `release` and `subject` are both "one label, and a different label
//! is a different thing". So there are two types and four aliases, rather
//! than four types that each re-derive the same `PartialEq`.
//!
//! Decision D36 forbids *one dimension* carrying *two* comparison rules,
//! because that is how a pipeline ends up passing `check()` under one rule
//! and failing under another. It says nothing against *two dimensions*
//! sharing *one* rule, and the rule is the thing worth having exactly once.
//! The wording an error uses still differs per dimension, because that
//! lives on `Dimension::leading_question`, not on the value.
use fmt;
/// An ordered set of names, compared as a set.
///
/// Members are compared case-insensitively and ignoring surrounding space,
/// and order never matters. "Case-insensitively" means ASCII case only
/// (`eq_ignore_ascii_case`): `HIV-1` and `hiv-1` are one name, but no Unicode
/// folding is attempted. That is immaterial for Latin binomials and worth
/// knowing before a set holds arbitrary labels. A host–pathogen dataset about
/// `HIV-1` and `Homo sapiens` is the same dataset however the two were
/// listed. There is no alias table — equating "human" with "Homo sapiens"
/// would mean guessing, and a wrong guess passes `check()` silently. Declare
/// one spelling and use it.
///
/// Insertion order is kept (so a message can echo what the user wrote) but
/// is not part of the identity, and a name given twice is recorded once in
/// its first spelling. Blank names are dropped rather than stored, since an
/// empty member would compare equal to every other empty member and mean
/// nothing.
///
/// # An empty set must never be a known dimension
///
/// An empty set is a legal *value*: it is what [`NameSet::of`] returns for
/// no names, and `Display` renders it as an empty string. It must never reach
/// a `Dim::known`, because two known empty sets compare equal, and that is a
/// false agreement, the thing this engine exists to refuse. The type does not
/// enforce this; the loaders do, by building the dimension through
/// `load::organism`, which turns an empty declaration into an unknown one
/// with a reason. A new loader of a set-valued dimension must go through that
/// path (or an equivalent that checks [`NameSet::is_empty`] first), and
/// `tests/declared_dimensions.rs` fails if one does not.
/// Join names as English does: `a`, `a and b`, `a, b and c`.
///
/// Shared with the error text in `check`, which lists the members one input
/// has and the other lacks. Defining the join once means a set and the
/// difference between two sets can never be punctuated differently.
pub
/// The organisms the data is about.
pub type Organism = NameSet;
/// The sources a dataset was assembled from.
///
/// Shares [`NameSet`]'s ASCII-case-insensitive dedup for now, and **must
/// stop doing so when a kind first applies this axis**. No kind applies it
/// yet: M10 settled what the split is, M8 and M12 each declined the axis
/// with reasons, and `KnowledgeGraph` in v0.3 is the first kind the feature
/// spec gives it — so that is where the split lands, together with this
/// axis's `check::compare` and `graph::propagate` arms (D36).
///
/// # The rule, and why it is not this one
///
/// The two failures are not symmetric. Folding case *drops* a member, which
/// turns two sets that differ into two sets that agree — a false agreement,
/// which is the thing this engine exists to refuse. Not folding it can only
/// *add* a member, which turns agreement into a refusal: loud, legible, and
/// fixed by declaring one spelling. This project has taken that trade twice
/// already, in D37's refusal to equate `human` with `Homo sapiens` and in
/// D38's refusal of an alias table.
///
/// The folding is also the unusual rule rather than the default. [`Release`],
/// [`Subject`] and [`IdentifierNamespace`] are all [`Label`] and compared
/// case-sensitively, because a label is a name the user chose. [`Organism`]
/// folds because Latin binomials are a closed conventional vocabulary where
/// `HIV-1` and `hiv-1` are one organism by convention. Sources are not that:
/// `s3://bucket/A.vcf` and `s3://bucket/a.vcf` are two objects *by
/// specification*, and a URL path is case-sensitive wherever it is served.
/// `GSE12345` matching `gse12345` is real but is the minority case, and it
/// costs a user one consistent spelling.
///
/// It is not split *now* because nothing would exercise it: until a kind
/// applies the axis, `joined_on` filters it out and `check_step` never
/// reaches its arms, which is the condition M7's standing requirement exists
/// to prevent.
pub type SourceSet = NameSet;
/// A scalar label, compared exactly.
///
/// Only surrounding space is forgiven. Case is not: `hgnc 2026-09` and
/// `HGNC 2026-09` may well be different releases, and a label is a name the
/// user chose, not a free-text description to be fuzzily matched.
;
/// The release of an annotation or database the data is on.
pub type Release = Label;
/// Who or what the data is about, when that is one named thing.
pub type Subject = Label;
/// Which identifier space a set of entities is named in.
///
/// A [`Label`] because the rule is the same as `release`'s: one name, and a
/// different name is a different space. It is deliberately not a closed set
/// of the namespaces the engine recognises — a curated list's own spelling
/// is a namespace too, and refusing it would make the dimension unusable for
/// exactly the in-house truth sets that most need it
/// ([`KnownNamespace`](crate::dim::KnownNamespace) is what inference reads,
/// not what a declaration is checked against).
pub type IdentifierNamespace = Label;