@htilabs/platform-common-models 0.8.23 → 0.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cvc-C7qdsXYK.d.cts +298 -0
- package/dist/cvc-C7qdsXYK.d.ts +298 -0
- package/dist/cvcs/index.cjs +93 -0
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +2286 -2182
- package/dist/cvcs/index.d.ts +2286 -2182
- package/dist/cvcs/index.js +92 -0
- package/dist/cvcs/index.js.map +1 -1
- package/dist/index.cjs +105 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.cts +24 -24
- package/dist/schemas/index.d.ts +24 -24
- package/dist/validation/index.cjs +58 -0
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +82 -283
- package/dist/validation/index.d.ts +82 -283
- package/dist/validation/index.js +57 -0
- package/dist/validation/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/cvc-sot.snap +4 -0
- package/src/__tests__/cvc-sot-snapshot.test.ts +5 -0
- package/src/__tests__/cvc-status-parser.test.ts +150 -0
- package/src/cvcs/carCorrectionReason.v1.0.0.json +89 -0
- package/src/cvcs/index.ts +2 -0
- package/src/generated/cvc-enums.ts +18 -0
- package/src/validation/cvcStatus.ts +209 -0
- package/src/validation/index.ts +1 -0
|
@@ -1,298 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
export { C as CvcCode, a as CvcCodeSchema, b as CvcDomain, c as CvcEntry, d as CvcEntrySchema, e as CvcEnvelope, f as CvcEnvelopeSchema, g as CvcKey, h as CvcKeySchema, i as CvcValidationError, P as PrimaryLanguageEntry, j as PrimaryLanguageEntrySchema, S as ServiceCategoryEntry, k as ServiceCategoryEntrySchema, l as getCvcLevel, v as validateCvc } from '../cvc-C7qdsXYK.js';
|
|
2
|
+
import 'zod';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
* @htilabs/platform-common-models —
|
|
5
|
+
* @htilabs/platform-common-models — CVC `_status`/`_source` provenance parser
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Problem this solves: `_status` on a SOT envelope (`src/cvcs/*.json`) is
|
|
8
|
+
* unvalidated free text (115 of 179 domains carry it; the rest predate the
|
|
9
|
+
* convention). A consumer that wants to know "is this actually a draft?" has
|
|
10
|
+
* had to eyeball a string like
|
|
8
11
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - Downstream consumers that need to validate CVC payloads.
|
|
12
|
+
* "DRAFT — TEMPORARY: net-new value-CVC not yet in Notion; provisional
|
|
13
|
+
* 900+ numbering; codes from prototype/data/cvcs/core_accommodation_type
|
|
14
|
+
* .yaml; PENDING canonical Notion authoring (PAVE Auditability backlog)."
|
|
13
15
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* and get it right past two real traps observed across the current
|
|
17
|
+
* population:
|
|
18
|
+
* - A leading `"CANONICAL — …"` marker is a PROVENANCE note on an
|
|
19
|
+
* ALREADY-ratified file, not a maturity warning — it must not be lumped
|
|
20
|
+
* in with `"DRAFT"`/`"PROVISIONAL"`.
|
|
21
|
+
* - `core_functions` is self-contradictory: it leads
|
|
22
|
+
* `"DRAFTED — NEEDS REVIEW"` but the same string continues
|
|
23
|
+
* `"…Canonical numbering (133), NOT provisional."` A naive
|
|
24
|
+
* leading-word reader silently picks one side; this parser flags it.
|
|
16
25
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* - Missingness entries are embedded per-domain (synthetic `missingness_root`
|
|
24
|
-
* at `<prefix>-000-000-000-000-000-000` plus three values at segment 7 =
|
|
25
|
-
* `001`/`002`/`003`). The shared `missingness.v1.0.0.json` file was
|
|
26
|
-
* retired in favor of per-domain missingness.
|
|
27
|
-
* - Envelope `missingness` field and the C7 invariant have been removed; the
|
|
28
|
-
* shared-merge pathway no longer exists.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 7-segment positional CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (three digits
|
|
33
|
-
* per segment). Segment 1 is the Notion-aligned domain prefix. Remaining
|
|
34
|
-
* hierarchy segments are filled left-to-right as levels deepen; unused
|
|
35
|
-
* segments remain `000`. See locked spec §3 (format v2).
|
|
36
|
-
*/
|
|
37
|
-
declare const CvcCodeSchema: z.ZodString;
|
|
38
|
-
/**
|
|
39
|
-
* Stable machine key for a CVC entry. Must start with a lowercase letter and
|
|
40
|
-
* contain only lowercase alphanumerics or underscores. Used as a cross-CVC
|
|
41
|
-
* reference target (e.g. `relevantMechanisms` pointing at mechanism keys).
|
|
42
|
-
* See locked spec §3.2.
|
|
43
|
-
*/
|
|
44
|
-
declare const CvcKeySchema: z.ZodString;
|
|
45
|
-
/**
|
|
46
|
-
* Base entry shape shared by every CVC domain. Domain-specific extensions
|
|
47
|
-
* (e.g. `ServiceCategoryEntrySchema`) should use `.extend()` to add fields.
|
|
48
|
-
* See locked spec §9.2.
|
|
26
|
+
* This module is a pure, additive, standalone export. It does NOT touch
|
|
27
|
+
* `CvcEnvelopeSchema` (`./cvc.ts`) — `_status`/`_source` are intentionally
|
|
28
|
+
* outside that Zod schema (see its module header), and adding them there
|
|
29
|
+
* would risk changing parse behavior for every existing consumer. Callers
|
|
30
|
+
* pass the RAW parsed JSON object (before or instead of
|
|
31
|
+
* `CvcEnvelopeSchema.parse()`), not the Zod-inferred `CvcEnvelope`.
|
|
49
32
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
key: z.ZodString;
|
|
59
|
-
title: z.ZodString;
|
|
60
|
-
selectable: z.ZodBoolean;
|
|
61
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
62
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
63
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
64
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
65
|
-
code: z.ZodString;
|
|
66
|
-
key: z.ZodString;
|
|
67
|
-
title: z.ZodString;
|
|
68
|
-
selectable: z.ZodBoolean;
|
|
69
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
70
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
71
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
72
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
73
|
-
code: z.ZodString;
|
|
74
|
-
key: z.ZodString;
|
|
75
|
-
title: z.ZodString;
|
|
76
|
-
selectable: z.ZodBoolean;
|
|
77
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
78
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
79
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
80
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
81
|
-
/**
|
|
82
|
-
* Service-category-specific entry. Adds `relevantMechanisms` — a cross-CVC
|
|
83
|
-
* reference into the `service_mechanisms` domain via entry keys. `null` means
|
|
84
|
-
* "not applicable" (e.g. structural L1 topic rows). See locked spec §9.2.
|
|
85
|
-
*/
|
|
86
|
-
declare const ServiceCategoryEntrySchema: z.ZodObject<{
|
|
87
|
-
code: z.ZodString;
|
|
88
|
-
key: z.ZodString;
|
|
89
|
-
title: z.ZodString;
|
|
90
|
-
selectable: z.ZodBoolean;
|
|
91
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
92
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
93
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
94
|
-
} & {
|
|
95
|
-
relevantMechanisms: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
97
|
-
code: z.ZodString;
|
|
98
|
-
key: z.ZodString;
|
|
99
|
-
title: z.ZodString;
|
|
100
|
-
selectable: z.ZodBoolean;
|
|
101
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
102
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
103
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
104
|
-
} & {
|
|
105
|
-
relevantMechanisms: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
106
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
107
|
-
code: z.ZodString;
|
|
108
|
-
key: z.ZodString;
|
|
109
|
-
title: z.ZodString;
|
|
110
|
-
selectable: z.ZodBoolean;
|
|
111
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
112
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
113
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
114
|
-
} & {
|
|
115
|
-
relevantMechanisms: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
116
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
117
|
-
/**
|
|
118
|
-
* Primary-language-specific entry. Adds:
|
|
119
|
-
* - `iso6391Code` — the ISO 639-1 alpha-2 code for the language, or `null`
|
|
120
|
-
* for entries without an ISO 639-1 code (missingness entries, Chinese
|
|
121
|
-
* varieties Mandarin/Cantonese, `other_language`). ASL is stored as
|
|
122
|
-
* `"ase"` (ISO 639-3) per Notion's convention; the CVC header documents
|
|
123
|
-
* this caveat.
|
|
124
|
-
* - `priority` — `true` for front-end short-list entries (14 total in
|
|
125
|
-
* CVC-122: 13 L1 languages plus the canonical `unknown` missingness
|
|
126
|
-
* entry). See locked spec §9.2.
|
|
127
|
-
*/
|
|
128
|
-
declare const PrimaryLanguageEntrySchema: z.ZodObject<{
|
|
129
|
-
code: z.ZodString;
|
|
130
|
-
key: z.ZodString;
|
|
131
|
-
title: z.ZodString;
|
|
132
|
-
selectable: z.ZodBoolean;
|
|
133
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
134
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
135
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
136
|
-
} & {
|
|
137
|
-
iso6391Code: z.ZodNullable<z.ZodString>;
|
|
138
|
-
priority: z.ZodBoolean;
|
|
139
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
140
|
-
code: z.ZodString;
|
|
141
|
-
key: z.ZodString;
|
|
142
|
-
title: z.ZodString;
|
|
143
|
-
selectable: z.ZodBoolean;
|
|
144
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
145
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
146
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
147
|
-
} & {
|
|
148
|
-
iso6391Code: z.ZodNullable<z.ZodString>;
|
|
149
|
-
priority: z.ZodBoolean;
|
|
150
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
151
|
-
code: z.ZodString;
|
|
152
|
-
key: z.ZodString;
|
|
153
|
-
title: z.ZodString;
|
|
154
|
-
selectable: z.ZodBoolean;
|
|
155
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
156
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
157
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
158
|
-
} & {
|
|
159
|
-
iso6391Code: z.ZodNullable<z.ZodString>;
|
|
160
|
-
priority: z.ZodBoolean;
|
|
161
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
162
|
-
/**
|
|
163
|
-
* Top-level SOT JSON envelope. One envelope per (domain, version) pair.
|
|
164
|
-
*
|
|
165
|
-
* `levels` is a positional map from level number (`"0"`, `"1"`, …) to a human
|
|
166
|
-
* label describing the level. Missingness entries are embedded in `entries`
|
|
167
|
-
* (per-domain) rather than merged in from a shared SOT file; see module
|
|
168
|
-
* header for the v2 format summary.
|
|
169
|
-
*/
|
|
170
|
-
declare const CvcEnvelopeSchema: z.ZodObject<{
|
|
171
|
-
domain: z.ZodString;
|
|
172
|
-
name: z.ZodString;
|
|
173
|
-
version: z.ZodString;
|
|
174
|
-
levels: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
175
|
-
entries: z.ZodArray<z.ZodObject<{
|
|
176
|
-
code: z.ZodString;
|
|
177
|
-
key: z.ZodString;
|
|
178
|
-
title: z.ZodString;
|
|
179
|
-
selectable: z.ZodBoolean;
|
|
180
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
181
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
182
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
183
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
184
|
-
code: z.ZodString;
|
|
185
|
-
key: z.ZodString;
|
|
186
|
-
title: z.ZodString;
|
|
187
|
-
selectable: z.ZodBoolean;
|
|
188
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
189
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
190
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
191
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
192
|
-
code: z.ZodString;
|
|
193
|
-
key: z.ZodString;
|
|
194
|
-
title: z.ZodString;
|
|
195
|
-
selectable: z.ZodBoolean;
|
|
196
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
197
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
198
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
199
|
-
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
200
|
-
}, "strip", z.ZodTypeAny, {
|
|
201
|
-
name: string;
|
|
202
|
-
version: string;
|
|
203
|
-
entries: z.objectOutputType<{
|
|
204
|
-
code: z.ZodString;
|
|
205
|
-
key: z.ZodString;
|
|
206
|
-
title: z.ZodString;
|
|
207
|
-
selectable: z.ZodBoolean;
|
|
208
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
209
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
210
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
211
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
212
|
-
domain: string;
|
|
213
|
-
levels: Record<string, string>;
|
|
214
|
-
}, {
|
|
215
|
-
name: string;
|
|
216
|
-
version: string;
|
|
217
|
-
entries: z.objectInputType<{
|
|
218
|
-
code: z.ZodString;
|
|
219
|
-
key: z.ZodString;
|
|
220
|
-
title: z.ZodString;
|
|
221
|
-
selectable: z.ZodBoolean;
|
|
222
|
-
parentCode: z.ZodNullable<z.ZodString>;
|
|
223
|
-
childCodes: z.ZodArray<z.ZodString, "many">;
|
|
224
|
-
definition: z.ZodNullable<z.ZodString>;
|
|
225
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
226
|
-
domain: string;
|
|
227
|
-
levels: Record<string, string>;
|
|
228
|
-
}>;
|
|
229
|
-
type CvcCode = z.infer<typeof CvcCodeSchema>;
|
|
230
|
-
type CvcKey = z.infer<typeof CvcKeySchema>;
|
|
231
|
-
type CvcEntry = z.infer<typeof CvcEntrySchema>;
|
|
232
|
-
type ServiceCategoryEntry = z.infer<typeof ServiceCategoryEntrySchema>;
|
|
233
|
-
type PrimaryLanguageEntry = z.infer<typeof PrimaryLanguageEntrySchema>;
|
|
234
|
-
type CvcEnvelope = z.infer<typeof CvcEnvelopeSchema>;
|
|
235
|
-
/**
|
|
236
|
-
* SOT family identifier (e.g. `"service_categories"`, `"service_states"`,
|
|
237
|
-
* `"service_mechanisms"`, `"missingness"`). The canonical list of domains is
|
|
238
|
-
* enumerated by the SOT JSON files in `src/cvcs/`. Typed as `string` rather
|
|
239
|
-
* than a closed union so adding a new SOT file does not require touching this
|
|
240
|
-
* type. See locked spec §2.
|
|
241
|
-
*/
|
|
242
|
-
type CvcDomain = string;
|
|
243
|
-
/**
|
|
244
|
-
* Derive an entry's level from its 7-segment code per locked spec §3.3.
|
|
33
|
+
* Classification rule (leading token of `_status`, case-insensitive):
|
|
34
|
+
* - contains "draft" → `maturity: "draft"`
|
|
35
|
+
* - contains "provisional" → `maturity: "provisional"`
|
|
36
|
+
* - contains "canonical" → `maturity: "canonical"` (a provenance note on
|
|
37
|
+
* an already-ratified file, NOT a maturity flag — kept distinct from
|
|
38
|
+
* `"final"` below so a caller can tell "explicitly marked ratified"
|
|
39
|
+
* apart from "predates the convention entirely")
|
|
40
|
+
* - `_status` absent entirely → `maturity: "final"` (legacy/unmarked)
|
|
245
41
|
*
|
|
246
|
-
*
|
|
247
|
-
* -
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
42
|
+
* One real domain (`share_purpose` — "Synced verbatim from canonical
|
|
43
|
+
* CVC-84…") has a present `_status` whose LEADING token ("Synced") is none
|
|
44
|
+
* of the three convention words. Rather than mis-file it as `"final"` (which
|
|
45
|
+
* per the rule above is reserved for an ABSENT field) this parser falls back
|
|
46
|
+
* to scanning the full string for a single unambiguous keyword family before
|
|
47
|
+
* giving up — see `detectMaturity` below.
|
|
251
48
|
*/
|
|
252
|
-
declare function getCvcLevel(code: string): number;
|
|
253
49
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
50
|
+
* The subset of a raw (pre-validation) SOT envelope this parser reads.
|
|
51
|
+
* Deliberately NOT the Zod-inferred `CvcEnvelope` from `./cvc.ts` — that type
|
|
52
|
+
* is the *parsed* shape, which does not declare `_status`/`_source` at all
|
|
53
|
+
* (they live outside the locked envelope schema on purpose). Pass the raw
|
|
54
|
+
* `JSON.parse()` result of a `src/cvcs/*.json` file here.
|
|
258
55
|
*/
|
|
259
|
-
interface
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
56
|
+
interface RawCvcEnvelopeProvenance {
|
|
57
|
+
_status?: unknown;
|
|
58
|
+
_source?: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** The four observed maturity states. See module header for the rule. */
|
|
61
|
+
type CvcMaturity = "draft" | "provisional" | "canonical" | "final";
|
|
62
|
+
interface CvcStatusInfo {
|
|
63
|
+
/** One of the four states; see module header for the classification rule. */
|
|
64
|
+
maturity: CvcMaturity;
|
|
65
|
+
/**
|
|
66
|
+
* The text this parser classified. For a string `_status` this is that
|
|
67
|
+
* string verbatim. For the 11 domains authored with a structured
|
|
68
|
+
* `_status` object (`{ vocabStatus, authoredBy, evidence, … }` — e.g.
|
|
69
|
+
* `citizenship`, `core_functions`'s sibling `countries`), this is
|
|
70
|
+
* `_status.vocabStatus` — the field those envelopes use for exactly this
|
|
71
|
+
* purpose — not the whole object. `null` iff `_status` is absent.
|
|
72
|
+
*/
|
|
73
|
+
rawStatus: string | null;
|
|
74
|
+
/** True iff `_source` cites a `prototype/data/cvcs/*.yaml` path. */
|
|
75
|
+
sourceIsPrototype: boolean;
|
|
76
|
+
/** The cited `prototype/data/cvcs/*.yaml` path, or `null` if none. */
|
|
77
|
+
sourcePath: string | null;
|
|
78
|
+
/**
|
|
79
|
+
* True when the classification is a judgment call rather than a clean
|
|
80
|
+
* read: either the leading token disagrees with a later
|
|
81
|
+
* "NOT draft"/"NOT provisional"/"NOT canonical" qualifier in the same
|
|
82
|
+
* string (the `core_functions` shape — generic, not special-cased, so any
|
|
83
|
+
* future domain authored in the same self-contradictory shape is also
|
|
84
|
+
* caught), or the string carries more than one maturity keyword family
|
|
85
|
+
* with no leading token to arbitrate between them.
|
|
86
|
+
*/
|
|
87
|
+
ambiguous: boolean;
|
|
264
88
|
}
|
|
265
89
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
* Invariants (locked spec §4):
|
|
271
|
-
* - **C1** Code format + uniqueness (§4.1). Format v2 uses 3-digit segments.
|
|
272
|
-
* - **C2** Key format + uniqueness (§4.2).
|
|
273
|
-
* - **C3** Tree: every `parentCode` resolves to an existing entry or null; no
|
|
274
|
-
* cycles (§4.3).
|
|
275
|
-
* - **C4** `childCodes` are the exact bidirectional inverse of `parentCode`
|
|
276
|
-
* (§4.3).
|
|
277
|
-
* - **C5** Selectability is a boolean (§4.4).
|
|
278
|
-
* - **C6** Cross-CVC `relevantMechanisms` references resolve against a
|
|
279
|
-
* provided `service_mechanisms` key set (§4.5, §7). Only checked when the
|
|
280
|
-
* caller supplies `options.mechanismKeys`.
|
|
281
|
-
* - **C7** _Retired in format v2_ (envelope no longer carries the shared
|
|
282
|
-
* `missingness` field; missingness is per-domain and embedded in
|
|
283
|
-
* `entries`). The invariant slot is intentionally left empty to preserve
|
|
284
|
-
* the numbering of C1/C2/C3/C4/C5/C6/C8 in historical references.
|
|
285
|
-
* - **C8** No entry anywhere contains a key `'provided'` (legacy Thread UI
|
|
286
|
-
* label guard; not a canonical state).
|
|
287
|
-
*
|
|
288
|
-
* @param envelope Parsed envelope (typically from `CvcEnvelopeSchema.parse()`).
|
|
289
|
-
* @param options.mechanismKeys Optional set of valid `service_mechanisms`
|
|
290
|
-
* entry keys. If provided and the envelope entries have `relevantMechanisms`
|
|
291
|
-
* fields, each referenced key must be in this set (C6).
|
|
292
|
-
* @returns An array of {@link CvcValidationError}. An empty array means valid.
|
|
90
|
+
* Parse a SOT envelope's `_status`/`_source` provenance fields into a
|
|
91
|
+
* structured, typed result. Pure function — no filesystem access, no
|
|
92
|
+
* dependency on `CvcEnvelopeSchema`. See module header for the full rule and
|
|
93
|
+
* the two known traps it exists to catch.
|
|
293
94
|
*/
|
|
294
|
-
declare function
|
|
295
|
-
mechanismKeys?: ReadonlySet<string>;
|
|
296
|
-
}): CvcValidationError[];
|
|
95
|
+
declare function parseCvcStatus(envelope: RawCvcEnvelopeProvenance): CvcStatusInfo;
|
|
297
96
|
|
|
298
|
-
export { type
|
|
97
|
+
export { type CvcMaturity, type CvcStatusInfo, type RawCvcEnvelopeProvenance, parseCvcStatus };
|
package/dist/validation/index.js
CHANGED
|
@@ -213,6 +213,62 @@ function validateCvc(envelope, options = {}) {
|
|
|
213
213
|
}
|
|
214
214
|
return errors;
|
|
215
215
|
}
|
|
216
|
+
|
|
217
|
+
// src/validation/cvcStatus.ts
|
|
218
|
+
var MATURITY_KEYWORDS = [
|
|
219
|
+
{ keyword: "draft", maturity: "draft" },
|
|
220
|
+
{ keyword: "provisional", maturity: "provisional" },
|
|
221
|
+
{ keyword: "canonical", maturity: "canonical" }
|
|
222
|
+
];
|
|
223
|
+
var PROTOTYPE_SOURCE_RE = /(prototype\/data\/cvcs\/[A-Za-z0-9_.-]+\.yaml)/;
|
|
224
|
+
var NEGATED_MATURITY_RE = /\bnot\s+(draft|provisional|canonical)\b/i;
|
|
225
|
+
function extractClassificationText(status) {
|
|
226
|
+
if (typeof status === "string") return status;
|
|
227
|
+
if (status !== null && typeof status === "object") {
|
|
228
|
+
const vocabStatus = status.vocabStatus;
|
|
229
|
+
if (typeof vocabStatus === "string") return vocabStatus;
|
|
230
|
+
return JSON.stringify(status);
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
function leadingToken(text) {
|
|
235
|
+
return (text.trim().split(/[\s—–:-]+/, 1)[0] ?? "").toLowerCase();
|
|
236
|
+
}
|
|
237
|
+
function detectMaturity(text) {
|
|
238
|
+
const lead = leadingToken(text);
|
|
239
|
+
const leadMatch = MATURITY_KEYWORDS.find(({ keyword }) => lead.includes(keyword));
|
|
240
|
+
let maturity;
|
|
241
|
+
if (leadMatch) {
|
|
242
|
+
maturity = leadMatch.maturity;
|
|
243
|
+
} else {
|
|
244
|
+
const foundFamilies = MATURITY_KEYWORDS.filter(
|
|
245
|
+
({ keyword }) => new RegExp(`\\b${keyword}\\w*\\b`, "i").test(text)
|
|
246
|
+
);
|
|
247
|
+
const distinctFamilies = new Set(foundFamilies.map((f) => f.maturity));
|
|
248
|
+
if (distinctFamilies.size === 1) {
|
|
249
|
+
maturity = foundFamilies[0].maturity;
|
|
250
|
+
return { maturity, ambiguous: false };
|
|
251
|
+
}
|
|
252
|
+
if (distinctFamilies.size > 1) {
|
|
253
|
+
maturity = foundFamilies[0].maturity;
|
|
254
|
+
return { maturity, ambiguous: true };
|
|
255
|
+
}
|
|
256
|
+
return { maturity: "provisional", ambiguous: true };
|
|
257
|
+
}
|
|
258
|
+
return { maturity, ambiguous: NEGATED_MATURITY_RE.test(text) };
|
|
259
|
+
}
|
|
260
|
+
function parseCvcStatus(envelope) {
|
|
261
|
+
const source = typeof envelope._source === "string" ? envelope._source : null;
|
|
262
|
+
const protoMatch = source?.match(PROTOTYPE_SOURCE_RE) ?? null;
|
|
263
|
+
const sourceIsPrototype = protoMatch !== null;
|
|
264
|
+
const sourcePath = protoMatch?.[1] ?? null;
|
|
265
|
+
const text = extractClassificationText(envelope._status);
|
|
266
|
+
if (text === null) {
|
|
267
|
+
return { maturity: "final", rawStatus: null, sourceIsPrototype, sourcePath, ambiguous: false };
|
|
268
|
+
}
|
|
269
|
+
const { maturity, ambiguous } = detectMaturity(text);
|
|
270
|
+
return { maturity, rawStatus: text, sourceIsPrototype, sourcePath, ambiguous };
|
|
271
|
+
}
|
|
216
272
|
export {
|
|
217
273
|
CvcCodeSchema,
|
|
218
274
|
CvcEntrySchema,
|
|
@@ -221,6 +277,7 @@ export {
|
|
|
221
277
|
PrimaryLanguageEntrySchema,
|
|
222
278
|
ServiceCategoryEntrySchema,
|
|
223
279
|
getCvcLevel,
|
|
280
|
+
parseCvcStatus,
|
|
224
281
|
validateCvc
|
|
225
282
|
};
|
|
226
283
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/cvc.ts"],"sourcesContent":["/**\n * @htilabs/platform-common-models — Controlled Vocabulary (CVC) Validation\n *\n * Zod schemas for validating CVC Source-of-Truth (SOT) JSON files and\n * individual CVC entries. Implements the locked spec §9.2 shapes.\n *\n * Used by:\n * - CI structural tests that parse every committed SOT file.\n * - The generalized seed CLI (`seedCvc`) prior to persistence.\n * - Downstream consumers that need to validate CVC payloads.\n *\n * Canonical spec:\n * /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md\n *\n * Format v2 (2026-04-15):\n * - Positional 7-segment codes `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (3 digits per\n * segment). Segment 1 is the Notion-aligned domain prefix:\n * `022` service_categories (CVC-22)\n * `025` service_mechanisms (CVC-25)\n * `049` service_states (CVC-49)\n * - Missingness entries are embedded per-domain (synthetic `missingness_root`\n * at `<prefix>-000-000-000-000-000-000` plus three values at segment 7 =\n * `001`/`002`/`003`). The shared `missingness.v1.0.0.json` file was\n * retired in favor of per-domain missingness.\n * - Envelope `missingness` field and the C7 invariant have been removed; the\n * shared-merge pathway no longer exists.\n */\n\nimport { z } from \"zod\";\n\n// ─── Primitive schemas ───────────────────────────────────────────────────────\n\n/**\n * 7-segment positional CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (three digits\n * per segment). Segment 1 is the Notion-aligned domain prefix. Remaining\n * hierarchy segments are filled left-to-right as levels deepen; unused\n * segments remain `000`. See locked spec §3 (format v2).\n */\nexport const CvcCodeSchema = z.string().regex(/^\\d{3}(-\\d{3}){6}$/);\n\n/**\n * Stable machine key for a CVC entry. Must start with a lowercase letter and\n * contain only lowercase alphanumerics or underscores. Used as a cross-CVC\n * reference target (e.g. `relevantMechanisms` pointing at mechanism keys).\n * See locked spec §3.2.\n */\nexport const CvcKeySchema = z.string().regex(/^[a-z][a-z0-9_]*$/);\n\n// ─── Entry schemas ───────────────────────────────────────────────────────────\n\n/**\n * Base entry shape shared by every CVC domain. Domain-specific extensions\n * (e.g. `ServiceCategoryEntrySchema`) should use `.extend()` to add fields.\n * See locked spec §9.2.\n *\n * Uses `.passthrough()` so that domain-specific fields (like\n * `relevantMechanisms` on service-category entries) survive base parsing\n * unmodified. This keeps cross-CVC reference validation honest: the §4.5\n * structural validator needs to see the raw referenced keys, and a strip-by-\n * default schema would silently hide them.\n */\nexport const CvcEntrySchema = z\n .object({\n code: CvcCodeSchema,\n key: CvcKeySchema,\n title: z.string().min(1),\n selectable: z.boolean(),\n parentCode: CvcCodeSchema.nullable(),\n childCodes: z.array(CvcCodeSchema),\n definition: z.string().nullable(),\n })\n .passthrough();\n\n/**\n * Service-category-specific entry. Adds `relevantMechanisms` — a cross-CVC\n * reference into the `service_mechanisms` domain via entry keys. `null` means\n * \"not applicable\" (e.g. structural L1 topic rows). See locked spec §9.2.\n */\nexport const ServiceCategoryEntrySchema = CvcEntrySchema.extend({\n relevantMechanisms: z.array(CvcKeySchema).nullable(),\n});\n\n/**\n * Primary-language-specific entry. Adds:\n * - `iso6391Code` — the ISO 639-1 alpha-2 code for the language, or `null`\n * for entries without an ISO 639-1 code (missingness entries, Chinese\n * varieties Mandarin/Cantonese, `other_language`). ASL is stored as\n * `\"ase\"` (ISO 639-3) per Notion's convention; the CVC header documents\n * this caveat.\n * - `priority` — `true` for front-end short-list entries (14 total in\n * CVC-122: 13 L1 languages plus the canonical `unknown` missingness\n * entry). See locked spec §9.2.\n */\nexport const PrimaryLanguageEntrySchema = CvcEntrySchema.extend({\n iso6391Code: z.string().nullable(),\n priority: z.boolean(),\n});\n\n// ─── Envelope schema ─────────────────────────────────────────────────────────\n\n/**\n * Top-level SOT JSON envelope. One envelope per (domain, version) pair.\n *\n * `levels` is a positional map from level number (`\"0\"`, `\"1\"`, …) to a human\n * label describing the level. Missingness entries are embedded in `entries`\n * (per-domain) rather than merged in from a shared SOT file; see module\n * header for the v2 format summary.\n */\nexport const CvcEnvelopeSchema = z.object({\n domain: z.string().min(1),\n name: z.string().min(1),\n version: z.string().min(1),\n levels: z.record(z.string(), z.string()),\n entries: z.array(CvcEntrySchema),\n});\n\n// ─── Inferred types ──────────────────────────────────────────────────────────\n\nexport type CvcCode = z.infer<typeof CvcCodeSchema>;\nexport type CvcKey = z.infer<typeof CvcKeySchema>;\nexport type CvcEntry = z.infer<typeof CvcEntrySchema>;\nexport type ServiceCategoryEntry = z.infer<typeof ServiceCategoryEntrySchema>;\nexport type PrimaryLanguageEntry = z.infer<typeof PrimaryLanguageEntrySchema>;\nexport type CvcEnvelope = z.infer<typeof CvcEnvelopeSchema>;\n\n/**\n * SOT family identifier (e.g. `\"service_categories\"`, `\"service_states\"`,\n * `\"service_mechanisms\"`, `\"missingness\"`). The canonical list of domains is\n * enumerated by the SOT JSON files in `src/cvcs/`. Typed as `string` rather\n * than a closed union so adding a new SOT file does not require touching this\n * type. See locked spec §2.\n */\nexport type CvcDomain = string;\n\n// ─── Structural validator (locked spec §4 / §9.3) ───────────────────────────\n\n/**\n * Derive an entry's level from its 7-segment code per locked spec §3.3.\n *\n * - Segment 7 non-zero → level 0 (missingness value entry, e.g. `unknown`).\n * - Otherwise return the index (1..5) of the last non-zero hierarchy segment.\n * - Hierarchy segments 2..7 all zero → level 0 (per-domain missingness root,\n * e.g. `022-000-000-000-000-000-000`). Segment 1 carries the domain prefix\n * and is intentionally not consulted by the level derivation.\n */\nexport function getCvcLevel(code: string): number {\n const segments = code.split(\"-\");\n // segments[6] is the missingness slot (positional segment 7).\n if (segments[6] !== \"000\") return 0;\n // Walk hierarchy segments 6..2 (indices 5..1) looking for the deepest\n // populated level.\n for (let i = 5; i >= 1; i -= 1) {\n if (segments[i] !== \"000\") return i;\n }\n return 0;\n}\n\n/**\n * Error collected by {@link validateCvc}. Each error names the invariant it\n * violates (`C1`..`C8`, skipping the retired `C7`) so CI output points\n * straight at the locked spec rule that failed. `code` or `key` narrow the\n * error to a specific entry when the violation is entry-scoped.\n */\nexport interface CvcValidationError {\n invariant: \"C1\" | \"C2\" | \"C3\" | \"C4\" | \"C5\" | \"C6\" | \"C8\";\n message: string;\n code?: string;\n key?: string;\n}\n\n/**\n * Structural invariants to enforce on every committed SOT file per locked spec\n * §4. Zod's schema `parse()` guarantees the *shape* of the envelope; this\n * function enforces the cross-entry *semantics* that Zod cannot express.\n *\n * Invariants (locked spec §4):\n * - **C1** Code format + uniqueness (§4.1). Format v2 uses 3-digit segments.\n * - **C2** Key format + uniqueness (§4.2).\n * - **C3** Tree: every `parentCode` resolves to an existing entry or null; no\n * cycles (§4.3).\n * - **C4** `childCodes` are the exact bidirectional inverse of `parentCode`\n * (§4.3).\n * - **C5** Selectability is a boolean (§4.4).\n * - **C6** Cross-CVC `relevantMechanisms` references resolve against a\n * provided `service_mechanisms` key set (§4.5, §7). Only checked when the\n * caller supplies `options.mechanismKeys`.\n * - **C7** _Retired in format v2_ (envelope no longer carries the shared\n * `missingness` field; missingness is per-domain and embedded in\n * `entries`). The invariant slot is intentionally left empty to preserve\n * the numbering of C1/C2/C3/C4/C5/C6/C8 in historical references.\n * - **C8** No entry anywhere contains a key `'provided'` (legacy Thread UI\n * label guard; not a canonical state).\n *\n * @param envelope Parsed envelope (typically from `CvcEnvelopeSchema.parse()`).\n * @param options.mechanismKeys Optional set of valid `service_mechanisms`\n * entry keys. If provided and the envelope entries have `relevantMechanisms`\n * fields, each referenced key must be in this set (C6).\n * @returns An array of {@link CvcValidationError}. An empty array means valid.\n */\nexport function validateCvc(\n envelope: CvcEnvelope,\n options: { mechanismKeys?: ReadonlySet<string> } = {},\n): CvcValidationError[] {\n const errors: CvcValidationError[] = [];\n const { entries } = envelope;\n\n // ── C1: code format + uniqueness ──────────────────────────────────────────\n const codeRe = /^\\d{3}(-\\d{3}){6}$/;\n const seenCodes = new Set<string>();\n for (const entry of entries) {\n if (!codeRe.test(entry.code)) {\n errors.push({\n invariant: \"C1\",\n message: `code does not match /^\\\\d{3}(-\\\\d{3}){6}$/`,\n code: entry.code,\n key: entry.key,\n });\n }\n if (seenCodes.has(entry.code)) {\n errors.push({\n invariant: \"C1\",\n message: `duplicate code`,\n code: entry.code,\n key: entry.key,\n });\n }\n seenCodes.add(entry.code);\n }\n\n // ── C2: key format + uniqueness ───────────────────────────────────────────\n const keyRe = /^[a-z][a-z0-9_]*$/;\n const seenKeys = new Set<string>();\n for (const entry of entries) {\n if (!keyRe.test(entry.key)) {\n errors.push({\n invariant: \"C2\",\n message: `key does not match /^[a-z][a-z0-9_]*$/`,\n code: entry.code,\n key: entry.key,\n });\n }\n if (seenKeys.has(entry.key)) {\n errors.push({\n invariant: \"C2\",\n message: `duplicate key`,\n code: entry.code,\n key: entry.key,\n });\n }\n seenKeys.add(entry.key);\n }\n\n // Build a lookup by code for the remaining tree checks. Skip entries whose\n // code we already know is malformed — their index would be meaningless.\n const byCode = new Map<string, CvcEntry>();\n for (const entry of entries) {\n if (codeRe.test(entry.code)) byCode.set(entry.code, entry);\n }\n\n // ── C3: tree — parents resolve, no cycles ─────────────────────────────────\n for (const entry of entries) {\n if (entry.parentCode === null) continue;\n if (!byCode.has(entry.parentCode)) {\n errors.push({\n invariant: \"C3\",\n message: `parentCode ${entry.parentCode} does not resolve to any entry in this CVC`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n\n // Cycle detection: walk parent chain from each entry, bail if we revisit.\n for (const entry of entries) {\n const visited = new Set<string>();\n let cursor: CvcEntry | undefined = entry;\n while (cursor && cursor.parentCode !== null) {\n if (visited.has(cursor.code)) {\n errors.push({\n invariant: \"C3\",\n message: `cycle detected in parentCode chain starting from ${entry.code}`,\n code: entry.code,\n key: entry.key,\n });\n break;\n }\n visited.add(cursor.code);\n cursor = byCode.get(cursor.parentCode);\n }\n }\n\n // ── C4: childCodes are exact inverse of parentCode ────────────────────────\n // Build the set of (parent, child) edges from parentCode, then from\n // childCodes, and require they match exactly.\n const parentToChildrenFromParent = new Map<string, Set<string>>();\n for (const entry of entries) {\n if (entry.parentCode !== null) {\n let set = parentToChildrenFromParent.get(entry.parentCode);\n if (!set) {\n set = new Set();\n parentToChildrenFromParent.set(entry.parentCode, set);\n }\n set.add(entry.code);\n }\n }\n\n for (const entry of entries) {\n const declared = new Set(entry.childCodes);\n const derived = parentToChildrenFromParent.get(entry.code) ?? new Set();\n\n for (const child of declared) {\n if (!derived.has(child)) {\n errors.push({\n invariant: \"C4\",\n message: `entry lists ${child} in childCodes but that entry's parentCode is not ${entry.code}`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n for (const child of derived) {\n if (!declared.has(child)) {\n errors.push({\n invariant: \"C4\",\n message: `entry ${child} has parentCode ${entry.code} but is missing from its childCodes`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n }\n\n // ── C5: selectability per §4.4 ────────────────────────────────────────────\n // Zod already enforces `selectable: boolean`; we make the invariant explicit\n // at validator level so a future schema loosening cannot silently bypass it.\n for (const entry of entries) {\n if (typeof entry.selectable !== \"boolean\") {\n errors.push({\n invariant: \"C5\",\n message: `selectable must be a boolean, got ${typeof entry.selectable}`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n\n // ── C6: cross-CVC refs — `relevantMechanisms` resolves against provided set\n if (options.mechanismKeys) {\n for (const entry of entries) {\n const raw = (entry as unknown as Record<string, unknown>)[\n \"relevantMechanisms\"\n ];\n if (raw === undefined || raw === null) continue;\n if (!Array.isArray(raw)) {\n errors.push({\n invariant: \"C6\",\n message: `relevantMechanisms must be an array or null`,\n code: entry.code,\n key: entry.key,\n });\n continue;\n }\n for (const mechKey of raw) {\n if (\n typeof mechKey !== \"string\" ||\n !options.mechanismKeys.has(mechKey)\n ) {\n errors.push({\n invariant: \"C6\",\n message: `relevantMechanisms references unknown service_mechanisms key: ${String(mechKey)}`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n }\n }\n\n // ── C8: legacy `'provided'` key guard ─────────────────────────────────────\n // Walk every property of every entry (including nested arrays) looking for\n // a key named `'provided'`. It is a Thread UI label, not a canonical state.\n const walkForProvided = (value: unknown, entry: CvcEntry): void => {\n if (value === null || value === undefined) return;\n if (Array.isArray(value)) {\n for (const item of value) walkForProvided(item, entry);\n return;\n }\n if (typeof value === \"object\") {\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"provided\") {\n errors.push({\n invariant: \"C8\",\n message: `entry contains forbidden legacy key 'provided' (see locked spec §4)`,\n code: entry.code,\n key: entry.key,\n });\n }\n walkForProvided(v, entry);\n }\n }\n };\n for (const entry of entries) {\n walkForProvided(entry, entry);\n // Also guard against a literal string value of 'provided' appearing as an\n // entry's `key`, which would be an obvious smuggling attempt.\n if (entry.key === \"provided\") {\n errors.push({\n invariant: \"C8\",\n message: `entry key must not be the legacy label 'provided'`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n\n return errors;\n}\n"],"mappings":";AA4BA,SAAS,SAAS;AAUX,IAAM,gBAAgB,EAAE,OAAO,EAAE,MAAM,oBAAoB;AAQ3D,IAAM,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB;AAezD,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACvB,YAAY,EAAE,QAAQ;AAAA,EACtB,YAAY,cAAc,SAAS;AAAA,EACnC,YAAY,EAAE,MAAM,aAAa;AAAA,EACjC,YAAY,EAAE,OAAO,EAAE,SAAS;AAClC,CAAC,EACA,YAAY;AAOR,IAAM,6BAA6B,eAAe,OAAO;AAAA,EAC9D,oBAAoB,EAAE,MAAM,YAAY,EAAE,SAAS;AACrD,CAAC;AAaM,IAAM,6BAA6B,eAAe,OAAO;AAAA,EAC9D,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ;AACtB,CAAC;AAYM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACxB,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAAA,EACvC,SAAS,EAAE,MAAM,cAAc;AACjC,CAAC;AA+BM,SAAS,YAAY,MAAsB;AAChD,QAAM,W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ACF;AAAA,EACF;AAKA,QAAM,kBAAkB,CAAC,OAAgB,UAA0B;AACjE,QAAI,UAAU,QAAQ,UAAU,OAAW;AAC3C,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,iBAAW,QAAQ,MAAO,iBAAgB,MAAM,KAAK;AACrD;AAAA,IACF;AACA,QAAI,OAAO,UAAU,UAAU;AAC7B,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAgC,GAAG;AACrE,YAAI,MAAM,YAAY;AACpB,iBAAO,KAAK;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YACT,MAAM,MAAM;AAAA,YACZ,KAAK,MAAM;AAAA,UACb,CAAC;AAAA,QACH;AACA,wBAAgB,GAAG,KAAK;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACA,aAAW,SAAS,SAAS;AAC3B,oBAAgB,OAAO,KAAK;AAG5B,QAAI,MAAM,QAAQ,YAAY;AAC5B,aAAO,KAAK;AAAA,QACV,WAAW;AAAA,QACX,SAAS;AAAA,QACT,MAAM,MAAM;AAAA,QACZ,KAAK,MAAM;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/validation/cvc.ts","../../src/validation/cvcStatus.ts"],"sourcesContent":["/**\n * @htilabs/platform-common-models — Controlled Vocabulary (CVC) Validation\n *\n * Zod schemas for validating CVC Source-of-Truth (SOT) JSON files and\n * individual CVC entries. Implements the locked spec §9.2 shapes.\n *\n * Used by:\n * - CI structural tests that parse every committed SOT file.\n * - The generalized seed CLI (`seedCvc`) prior to persistence.\n * - Downstream consumers that need to validate CVC payloads.\n *\n * Canonical spec:\n * /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md\n *\n * Format v2 (2026-04-15):\n * - Positional 7-segment codes `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (3 digits per\n * segment). Segment 1 is the Notion-aligned domain prefix:\n * `022` service_categories (CVC-22)\n * `025` service_mechanisms (CVC-25)\n * `049` service_states (CVC-49)\n * - Missingness entries are embedded per-domain (synthetic `missingness_root`\n * at `<prefix>-000-000-000-000-000-000` plus three values at segment 7 =\n * `001`/`002`/`003`). The shared `missingness.v1.0.0.json` file was\n * retired in favor of per-domain missingness.\n * - Envelope `missingness` field and the C7 invariant have been removed; the\n * shared-merge pathway no longer exists.\n */\n\nimport { z } from \"zod\";\n\n// ─── Primitive schemas ───────────────────────────────────────────────────────\n\n/**\n * 7-segment positional CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (three digits\n * per segment). Segment 1 is the Notion-aligned domain prefix. Remaining\n * hierarchy segments are filled left-to-right as levels deepen; unused\n * segments remain `000`. See locked spec §3 (format v2).\n */\nexport const CvcCodeSchema = z.string().regex(/^\\d{3}(-\\d{3}){6}$/);\n\n/**\n * Stable machine key for a CVC entry. Must start with a lowercase letter and\n * contain only lowercase alphanumerics or underscores. Used as a cross-CVC\n * reference target (e.g. `relevantMechanisms` pointing at mechanism keys).\n * See locked spec §3.2.\n */\nexport const CvcKeySchema = z.string().regex(/^[a-z][a-z0-9_]*$/);\n\n// ─── Entry schemas ───────────────────────────────────────────────────────────\n\n/**\n * Base entry shape shared by every CVC domain. Domain-specific extensions\n * (e.g. `ServiceCategoryEntrySchema`) should use `.extend()` to add fields.\n * See locked spec §9.2.\n *\n * Uses `.passthrough()` so that domain-specific fields (like\n * `relevantMechanisms` on service-category entries) survive base parsing\n * unmodified. This keeps cross-CVC reference validation honest: the §4.5\n * structural validator needs to see the raw referenced keys, and a strip-by-\n * default schema would silently hide them.\n */\nexport const CvcEntrySchema = z\n .object({\n code: CvcCodeSchema,\n key: CvcKeySchema,\n title: z.string().min(1),\n selectable: z.boolean(),\n parentCode: CvcCodeSchema.nullable(),\n childCodes: z.array(CvcCodeSchema),\n definition: z.string().nullable(),\n })\n .passthrough();\n\n/**\n * Service-category-specific entry. Adds `relevantMechanisms` — a cross-CVC\n * reference into the `service_mechanisms` domain via entry keys. `null` means\n * \"not applicable\" (e.g. structural L1 topic rows). See locked spec §9.2.\n */\nexport const ServiceCategoryEntrySchema = CvcEntrySchema.extend({\n relevantMechanisms: z.array(CvcKeySchema).nullable(),\n});\n\n/**\n * Primary-language-specific entry. Adds:\n * - `iso6391Code` — the ISO 639-1 alpha-2 code for the language, or `null`\n * for entries without an ISO 639-1 code (missingness entries, Chinese\n * varieties Mandarin/Cantonese, `other_language`). ASL is stored as\n * `\"ase\"` (ISO 639-3) per Notion's convention; the CVC header documents\n * this caveat.\n * - `priority` — `true` for front-end short-list entries (14 total in\n * CVC-122: 13 L1 languages plus the canonical `unknown` missingness\n * entry). See locked spec §9.2.\n */\nexport const PrimaryLanguageEntrySchema = CvcEntrySchema.extend({\n iso6391Code: z.string().nullable(),\n priority: z.boolean(),\n});\n\n// ─── Envelope schema ─────────────────────────────────────────────────────────\n\n/**\n * Top-level SOT JSON envelope. One envelope per (domain, version) pair.\n *\n * `levels` is a positional map from level number (`\"0\"`, `\"1\"`, …) to a human\n * label describing the level. Missingness entries are embedded in `entries`\n * (per-domain) rather than merged in from a shared SOT file; see module\n * header for the v2 format summary.\n */\nexport const CvcEnvelopeSchema = z.object({\n domain: z.string().min(1),\n name: z.string().min(1),\n version: z.string().min(1),\n levels: z.record(z.string(), z.string()),\n entries: z.array(CvcEntrySchema),\n});\n\n// ─── Inferred types ──────────────────────────────────────────────────────────\n\nexport type CvcCode = z.infer<typeof CvcCodeSchema>;\nexport type CvcKey = z.infer<typeof CvcKeySchema>;\nexport type CvcEntry = z.infer<typeof CvcEntrySchema>;\nexport type ServiceCategoryEntry = z.infer<typeof ServiceCategoryEntrySchema>;\nexport type PrimaryLanguageEntry = z.infer<typeof PrimaryLanguageEntrySchema>;\nexport type CvcEnvelope = z.infer<typeof CvcEnvelopeSchema>;\n\n/**\n * SOT family identifier (e.g. `\"service_categories\"`, `\"service_states\"`,\n * `\"service_mechanisms\"`, `\"missingness\"`). The canonical list of domains is\n * enumerated by the SOT JSON files in `src/cvcs/`. Typed as `string` rather\n * than a closed union so adding a new SOT file does not require touching this\n * type. See locked spec §2.\n */\nexport type CvcDomain = string;\n\n// ─── Structural validator (locked spec §4 / §9.3) ───────────────────────────\n\n/**\n * Derive an entry's level from its 7-segment code per locked spec §3.3.\n *\n * - Segment 7 non-zero → level 0 (missingness value entry, e.g. `unknown`).\n * - Otherwise return the index (1..5) of the last non-zero hierarchy segment.\n * - Hierarchy segments 2..7 all zero → level 0 (per-domain missingness root,\n * e.g. `022-000-000-000-000-000-000`). Segment 1 carries the domain prefix\n * and is intentionally not consulted by the level derivation.\n */\nexport function getCvcLevel(code: string): number {\n const segments = code.split(\"-\");\n // segments[6] is the missingness slot (positional segment 7).\n if (segments[6] !== \"000\") return 0;\n // Walk hierarchy segments 6..2 (indices 5..1) looking for the deepest\n // populated level.\n for (let i = 5; i >= 1; i -= 1) {\n if (segments[i] !== \"000\") return i;\n }\n return 0;\n}\n\n/**\n * Error collected by {@link validateCvc}. Each error names the invariant it\n * violates (`C1`..`C8`, skipping the retired `C7`) so CI output points\n * straight at the locked spec rule that failed. `code` or `key` narrow the\n * error to a specific entry when the violation is entry-scoped.\n */\nexport interface CvcValidationError {\n invariant: \"C1\" | \"C2\" | \"C3\" | \"C4\" | \"C5\" | \"C6\" | \"C8\";\n message: string;\n code?: string;\n key?: string;\n}\n\n/**\n * Structural invariants to enforce on every committed SOT file per locked spec\n * §4. Zod's schema `parse()` guarantees the *shape* of the envelope; this\n * function enforces the cross-entry *semantics* that Zod cannot express.\n *\n * Invariants (locked spec §4):\n * - **C1** Code format + uniqueness (§4.1). Format v2 uses 3-digit segments.\n * - **C2** Key format + uniqueness (§4.2).\n * - **C3** Tree: every `parentCode` resolves to an existing entry or null; no\n * cycles (§4.3).\n * - **C4** `childCodes` are the exact bidirectional inverse of `parentCode`\n * (§4.3).\n * - **C5** Selectability is a boolean (§4.4).\n * - **C6** Cross-CVC `relevantMechanisms` references resolve against a\n * provided `service_mechanisms` key set (§4.5, §7). Only checked when the\n * caller supplies `options.mechanismKeys`.\n * - **C7** _Retired in format v2_ (envelope no longer carries the shared\n * `missingness` field; missingness is per-domain and embedded in\n * `entries`). The invariant slot is intentionally left empty to preserve\n * the numbering of C1/C2/C3/C4/C5/C6/C8 in historical references.\n * - **C8** No entry anywhere contains a key `'provided'` (legacy Thread UI\n * label guard; not a canonical state).\n *\n * @param envelope Parsed envelope (typically from `CvcEnvelopeSchema.parse()`).\n * @param options.mechanismKeys Optional set of valid `service_mechanisms`\n * entry keys. If provided and the envelope entries have `relevantMechanisms`\n * fields, each referenced key must be in this set (C6).\n * @returns An array of {@link CvcValidationError}. An empty array means valid.\n */\nexport function validateCvc(\n envelope: CvcEnvelope,\n options: { mechanismKeys?: ReadonlySet<string> } = {},\n): CvcValidationError[] {\n const errors: CvcValidationError[] = [];\n const { entries } = envelope;\n\n // ── C1: code format + uniqueness ──────────────────────────────────────────\n const codeRe = /^\\d{3}(-\\d{3}){6}$/;\n const seenCodes = new Set<string>();\n for (const entry of entries) {\n if (!codeRe.test(entry.code)) {\n errors.push({\n invariant: \"C1\",\n message: `code does not match /^\\\\d{3}(-\\\\d{3}){6}$/`,\n code: entry.code,\n key: entry.key,\n });\n }\n if (seenCodes.has(entry.code)) {\n errors.push({\n invariant: \"C1\",\n message: `duplicate code`,\n code: entry.code,\n key: entry.key,\n });\n }\n seenCodes.add(entry.code);\n }\n\n // ── C2: key format + uniqueness ───────────────────────────────────────────\n const keyRe = /^[a-z][a-z0-9_]*$/;\n const seenKeys = new Set<string>();\n for (const entry of entries) {\n if (!keyRe.test(entry.key)) {\n errors.push({\n invariant: \"C2\",\n message: `key does not match /^[a-z][a-z0-9_]*$/`,\n code: entry.code,\n key: entry.key,\n });\n }\n if (seenKeys.has(entry.key)) {\n errors.push({\n invariant: \"C2\",\n message: `duplicate key`,\n code: entry.code,\n key: entry.key,\n });\n }\n seenKeys.add(entry.key);\n }\n\n // Build a lookup by code for the remaining tree checks. Skip entries whose\n // code we already know is malformed — their index would be meaningless.\n const byCode = new Map<string, CvcEntry>();\n for (const entry of entries) {\n if (codeRe.test(entry.code)) byCode.set(entry.code, entry);\n }\n\n // ── C3: tree — parents resolve, no cycles ─────────────────────────────────\n for (const entry of entries) {\n if (entry.parentCode === null) continue;\n if (!byCode.has(entry.parentCode)) {\n errors.push({\n invariant: \"C3\",\n message: `parentCode ${entry.parentCode} does not resolve to any entry in this CVC`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n\n // Cycle detection: walk parent chain from each entry, bail if we revisit.\n for (const entry of entries) {\n const visited = new Set<string>();\n let cursor: CvcEntry | undefined = entry;\n while (cursor && cursor.parentCode !== null) {\n if (visited.has(cursor.code)) {\n errors.push({\n invariant: \"C3\",\n message: `cycle detected in parentCode chain starting from ${entry.code}`,\n code: entry.code,\n key: entry.key,\n });\n break;\n }\n visited.add(cursor.code);\n cursor = byCode.get(cursor.parentCode);\n }\n }\n\n // ── C4: childCodes are exact inverse of parentCode ────────────────────────\n // Build the set of (parent, child) edges from parentCode, then from\n // childCodes, and require they match exactly.\n const parentToChildrenFromParent = new Map<string, Set<string>>();\n for (const entry of entries) {\n if (entry.parentCode !== null) {\n let set = parentToChildrenFromParent.get(entry.parentCode);\n if (!set) {\n set = new Set();\n parentToChildrenFromParent.set(entry.parentCode, set);\n }\n set.add(entry.code);\n }\n }\n\n for (const entry of entries) {\n const declared = new Set(entry.childCodes);\n const derived = parentToChildrenFromParent.get(entry.code) ?? new Set();\n\n for (const child of declared) {\n if (!derived.has(child)) {\n errors.push({\n invariant: \"C4\",\n message: `entry lists ${child} in childCodes but that entry's parentCode is not ${entry.code}`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n for (const child of derived) {\n if (!declared.has(child)) {\n errors.push({\n invariant: \"C4\",\n message: `entry ${child} has parentCode ${entry.code} but is missing from its childCodes`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n }\n\n // ── C5: selectability per §4.4 ────────────────────────────────────────────\n // Zod already enforces `selectable: boolean`; we make the invariant explicit\n // at validator level so a future schema loosening cannot silently bypass it.\n for (const entry of entries) {\n if (typeof entry.selectable !== \"boolean\") {\n errors.push({\n invariant: \"C5\",\n message: `selectable must be a boolean, got ${typeof entry.selectable}`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n\n // ── C6: cross-CVC refs — `relevantMechanisms` resolves against provided set\n if (options.mechanismKeys) {\n for (const entry of entries) {\n const raw = (entry as unknown as Record<string, unknown>)[\n \"relevantMechanisms\"\n ];\n if (raw === undefined || raw === null) continue;\n if (!Array.isArray(raw)) {\n errors.push({\n invariant: \"C6\",\n message: `relevantMechanisms must be an array or null`,\n code: entry.code,\n key: entry.key,\n });\n continue;\n }\n for (const mechKey of raw) {\n if (\n typeof mechKey !== \"string\" ||\n !options.mechanismKeys.has(mechKey)\n ) {\n errors.push({\n invariant: \"C6\",\n message: `relevantMechanisms references unknown service_mechanisms key: ${String(mechKey)}`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n }\n }\n\n // ── C8: legacy `'provided'` key guard ─────────────────────────────────────\n // Walk every property of every entry (including nested arrays) looking for\n // a key named `'provided'`. It is a Thread UI label, not a canonical state.\n const walkForProvided = (value: unknown, entry: CvcEntry): void => {\n if (value === null || value === undefined) return;\n if (Array.isArray(value)) {\n for (const item of value) walkForProvided(item, entry);\n return;\n }\n if (typeof value === \"object\") {\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"provided\") {\n errors.push({\n invariant: \"C8\",\n message: `entry contains forbidden legacy key 'provided' (see locked spec §4)`,\n code: entry.code,\n key: entry.key,\n });\n }\n walkForProvided(v, entry);\n }\n }\n };\n for (const entry of entries) {\n walkForProvided(entry, entry);\n // Also guard against a literal string value of 'provided' appearing as an\n // entry's `key`, which would be an obvious smuggling attempt.\n if (entry.key === \"provided\") {\n errors.push({\n invariant: \"C8\",\n message: `entry key must not be the legacy label 'provided'`,\n code: entry.code,\n key: entry.key,\n });\n }\n }\n\n return errors;\n}\n","/**\n * @htilabs/platform-common-models — CVC `_status`/`_source` provenance parser\n *\n * Problem this solves: `_status` on a SOT envelope (`src/cvcs/*.json`) is\n * unvalidated free text (115 of 179 domains carry it; the rest predate the\n * convention). A consumer that wants to know \"is this actually a draft?\" has\n * had to eyeball a string like\n *\n * \"DRAFT — TEMPORARY: net-new value-CVC not yet in Notion; provisional\n * 900+ numbering; codes from prototype/data/cvcs/core_accommodation_type\n * .yaml; PENDING canonical Notion authoring (PAVE Auditability backlog).\"\n *\n * and get it right past two real traps observed across the current\n * population:\n * - A leading `\"CANONICAL — …\"` marker is a PROVENANCE note on an\n * ALREADY-ratified file, not a maturity warning — it must not be lumped\n * in with `\"DRAFT\"`/`\"PROVISIONAL\"`.\n * - `core_functions` is self-contradictory: it leads\n * `\"DRAFTED — NEEDS REVIEW\"` but the same string continues\n * `\"…Canonical numbering (133), NOT provisional.\"` A naive\n * leading-word reader silently picks one side; this parser flags it.\n *\n * This module is a pure, additive, standalone export. It does NOT touch\n * `CvcEnvelopeSchema` (`./cvc.ts`) — `_status`/`_source` are intentionally\n * outside that Zod schema (see its module header), and adding them there\n * would risk changing parse behavior for every existing consumer. Callers\n * pass the RAW parsed JSON object (before or instead of\n * `CvcEnvelopeSchema.parse()`), not the Zod-inferred `CvcEnvelope`.\n *\n * Classification rule (leading token of `_status`, case-insensitive):\n * - contains \"draft\" → `maturity: \"draft\"`\n * - contains \"provisional\" → `maturity: \"provisional\"`\n * - contains \"canonical\" → `maturity: \"canonical\"` (a provenance note on\n * an already-ratified file, NOT a maturity flag — kept distinct from\n * `\"final\"` below so a caller can tell \"explicitly marked ratified\"\n * apart from \"predates the convention entirely\")\n * - `_status` absent entirely → `maturity: \"final\"` (legacy/unmarked)\n *\n * One real domain (`share_purpose` — \"Synced verbatim from canonical\n * CVC-84…\") has a present `_status` whose LEADING token (\"Synced\") is none\n * of the three convention words. Rather than mis-file it as `\"final\"` (which\n * per the rule above is reserved for an ABSENT field) this parser falls back\n * to scanning the full string for a single unambiguous keyword family before\n * giving up — see `detectMaturity` below.\n */\n\n// ─── Public shape ───────────────────────────────────────────────────────────\n\n/**\n * The subset of a raw (pre-validation) SOT envelope this parser reads.\n * Deliberately NOT the Zod-inferred `CvcEnvelope` from `./cvc.ts` — that type\n * is the *parsed* shape, which does not declare `_status`/`_source` at all\n * (they live outside the locked envelope schema on purpose). Pass the raw\n * `JSON.parse()` result of a `src/cvcs/*.json` file here.\n */\nexport interface RawCvcEnvelopeProvenance {\n _status?: unknown;\n _source?: unknown;\n}\n\n/** The four observed maturity states. See module header for the rule. */\nexport type CvcMaturity = \"draft\" | \"provisional\" | \"canonical\" | \"final\";\n\nexport interface CvcStatusInfo {\n /** One of the four states; see module header for the classification rule. */\n maturity: CvcMaturity;\n /**\n * The text this parser classified. For a string `_status` this is that\n * string verbatim. For the 11 domains authored with a structured\n * `_status` object (`{ vocabStatus, authoredBy, evidence, … }` — e.g.\n * `citizenship`, `core_functions`'s sibling `countries`), this is\n * `_status.vocabStatus` — the field those envelopes use for exactly this\n * purpose — not the whole object. `null` iff `_status` is absent.\n */\n rawStatus: string | null;\n /** True iff `_source` cites a `prototype/data/cvcs/*.yaml` path. */\n sourceIsPrototype: boolean;\n /** The cited `prototype/data/cvcs/*.yaml` path, or `null` if none. */\n sourcePath: string | null;\n /**\n * True when the classification is a judgment call rather than a clean\n * read: either the leading token disagrees with a later\n * \"NOT draft\"/\"NOT provisional\"/\"NOT canonical\" qualifier in the same\n * string (the `core_functions` shape — generic, not special-cased, so any\n * future domain authored in the same self-contradictory shape is also\n * caught), or the string carries more than one maturity keyword family\n * with no leading token to arbitrate between them.\n */\n ambiguous: boolean;\n}\n\n// ─── Implementation ─────────────────────────────────────────────────────────\n\nconst MATURITY_KEYWORDS: ReadonlyArray<{\n keyword: string;\n maturity: Exclude<CvcMaturity, \"final\">;\n}> = [\n { keyword: \"draft\", maturity: \"draft\" },\n { keyword: \"provisional\", maturity: \"provisional\" },\n { keyword: \"canonical\", maturity: \"canonical\" },\n];\n\n/** Matches a `prototype/data/cvcs/<file>.yaml` citation anywhere in `_source`. */\nconst PROTOTYPE_SOURCE_RE = /(prototype\\/data\\/cvcs\\/[A-Za-z0-9_.-]+\\.yaml)/;\n\n/**\n * A maturity keyword explicitly negated (\"NOT provisional.\") anywhere in the\n * string — the self-contradiction signal. Deliberately scans the WHOLE\n * string (not just past the leading token): the qualifier that disagrees\n * with the leading word is, by construction, never the leading word itself.\n */\nconst NEGATED_MATURITY_RE = /\\bnot\\s+(draft|provisional|canonical)\\b/i;\n\n/**\n * Extract the text this parser classifies against, from either `_status`\n * shape observed in the current SOT population:\n * - `string` (104 of 115 status-bearing domains) → the string itself.\n * - `{ vocabStatus: string, … }` (11 domains — a richer, hand-authored\n * provenance record) → `vocabStatus`, the field those envelopes use for\n * exactly this classification (values seen: `\"canonical\"` and\n * `\"provisional-pending-notion-ratification\"`).\n * - Anything else present but shapeless (unseen in the current 179-domain\n * population) → `JSON.stringify` as a last resort, so a future oddity\n * still gets a best-effort classification instead of silently vanishing.\n * - Absent → `null`.\n */\nfunction extractClassificationText(status: unknown): string | null {\n if (typeof status === \"string\") return status;\n if (status !== null && typeof status === \"object\") {\n const vocabStatus = (status as Record<string, unknown>).vocabStatus;\n if (typeof vocabStatus === \"string\") return vocabStatus;\n return JSON.stringify(status);\n }\n return null;\n}\n\n/** The first \"word\" of a status string, lowercased, for the leading-token rule. */\nfunction leadingToken(text: string): string {\n return (text.trim().split(/[\\s—–:-]+/, 1)[0] ?? \"\").toLowerCase();\n}\n\n/**\n * Classify a present, non-null `_status` text into a maturity + ambiguity\n * flag. Isolated from {@link parseCvcStatus} so the fallback path (the\n * `share_purpose` shape) and the negation check are each unit-testable in\n * isolation.\n */\nfunction detectMaturity(text: string): { maturity: Exclude<CvcMaturity, \"final\">; ambiguous: boolean } {\n const lead = leadingToken(text);\n const leadMatch = MATURITY_KEYWORDS.find(({ keyword }) => lead.includes(keyword));\n\n let maturity: Exclude<CvcMaturity, \"final\">;\n if (leadMatch) {\n maturity = leadMatch.maturity;\n } else {\n // The leading token is none of the three convention words. Observed once\n // in the current population: `share_purpose`'s\n // \"Synced verbatim from canonical CVC-84…\" — \"Synced\" leads, but the\n // string is unambiguously describing an already-ratified vocabulary.\n // Fall back to scanning the WHOLE string for maturity keyword families\n // rather than defaulting to \"final\": the field IS present, and \"final\"\n // per the module-header rule is reserved for an ABSENT `_status`.\n const foundFamilies = MATURITY_KEYWORDS.filter(({ keyword }) =>\n new RegExp(`\\\\b${keyword}\\\\w*\\\\b`, \"i\").test(text),\n );\n const distinctFamilies = new Set(foundFamilies.map((f) => f.maturity));\n if (distinctFamilies.size === 1) {\n // Single unambiguous family found in the body — safe to accept.\n maturity = foundFamilies[0].maturity;\n return { maturity, ambiguous: false };\n }\n if (distinctFamilies.size > 1) {\n // Multiple families present with no leading token to arbitrate.\n // Report the first-occurring family as a best-effort primary and let\n // the caller see `ambiguous: true` — never silently pick a winner.\n maturity = foundFamilies[0].maturity;\n return { maturity, ambiguous: true };\n }\n // No maturity keyword anywhere in a present `_status` string. Unseen in\n // the current 179-domain population; treat conservatively as\n // \"provisional\" (the least-committal non-final bucket) rather than\n // silently promoting an unrecognized status to a settled one, and flag\n // it for human attention.\n return { maturity: \"provisional\", ambiguous: true };\n }\n\n return { maturity, ambiguous: NEGATED_MATURITY_RE.test(text) };\n}\n\n/**\n * Parse a SOT envelope's `_status`/`_source` provenance fields into a\n * structured, typed result. Pure function — no filesystem access, no\n * dependency on `CvcEnvelopeSchema`. See module header for the full rule and\n * the two known traps it exists to catch.\n */\nexport function parseCvcStatus(envelope: RawCvcEnvelopeProvenance): CvcStatusInfo {\n const source = typeof envelope._source === \"string\" ? envelope._source : null;\n const protoMatch = source?.match(PROTOTYPE_SOURCE_RE) ?? null;\n const sourceIsPrototype = protoMatch !== null;\n const sourcePath = protoMatch?.[1] ?? null;\n\n const text = extractClassificationText(envelope._status);\n if (text === null) {\n return { maturity: \"final\", rawStatus: null, sourceIsPrototype, sourcePath, ambiguous: false };\n }\n\n const { maturity, ambiguous } = detectMaturity(text);\n return { maturity, rawStatus: text, sourceIsPrototype, sourcePath, ambiguous };\n}\n"],"mappings":";AA4BA,SAAS,SAAS;AAUX,IAAM,gBAAgB,EAAE,OAAO,EAAE,MAAM,oBAAoB;AAQ3D,IAAM,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB;AAezD,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACvB,YAAY,EAAE,QAAQ;AAAA,EACtB,YAAY,cAAc,SAAS;AAAA,EACnC,YAAY,EAAE,MAAM,aAAa;AAAA,EACjC,YAAY,EAAE,OAAO,EAAE,SAAS;AAClC,CAAC,EACA,YAAY;AAOR,IAAM,6BAA6B,eAAe,OAAO;AAAA,EAC9D,oBAAoB,EAAE,MAAM,YAAY,EAAE,SAAS;AACrD,CAAC;AAaM,IAAM,6BAA6B,eAAe,OAAO;AAAA,EAC9D,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ;AACtB,CAAC;AAYM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACxB,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAAA,EACvC,SAAS,EAAE,MAAM,cAAc;AACjC,CAAC;AA+BM,SAAS,YAAY,MAAsB;AAChD,QAAM,WAAW,KAAK,MAAM,GAAG;AAE/B,MAAI,SAAS,CAAC,MAAM,MAAO,QAAO;AAGlC,WAAS,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG;AAC9B,QAAI,SAAS,CAAC,MAAM,MAAO,QAAO;AAAA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|
},
|
|
685
|
+
"car_correction_reason": {
|
|
686
|
+
"count": 8,
|
|
687
|
+
"hash": "6ad10301ca7759bbda822b44a251208826b8880dff8d085ce501bc1faedc69d8"
|
|
688
|
+
},
|
|
685
689
|
"created_by_system": {
|
|
686
690
|
"count": 8,
|
|
687
691
|
"hash": "35ea022a704b4eee7b493ea3c9a8a5d2ffa41c4cacbe9f899cc1336e73808fc2"
|
|
@@ -704,6 +704,11 @@ const SOT_SPECS: readonly SotSpec[] = [
|
|
|
704
704
|
// @pave/domain verbatim; bead pv-pgdr-cvc-source-gdr-10-1-bulk-publish). ───
|
|
705
705
|
// 3 lifecycle states (@pave/domain ASSERTION_STATUSES) + 4 missingness = 7
|
|
706
706
|
{ file: "assertionStatus.v1.0.0.json", domain: "assertion_status", expectedCount: 7 },
|
|
707
|
+
// 4 correction/retraction reasons (@pave/domain CAR_CORRECTION_REASONS —
|
|
708
|
+
// entered_in_error, duplicate, superseded_externally — plus
|
|
709
|
+
// removed_by_recipient_curation for the CaseShare curation lane) + 4
|
|
710
|
+
// missingness = 8
|
|
711
|
+
{ file: "carCorrectionReason.v1.0.0.json", domain: "car_correction_reason", expectedCount: 8 },
|
|
707
712
|
// 4 actor classes (@pave/domain CREATED_BY_SYSTEMS) + 4 missingness = 8
|
|
708
713
|
{ file: "createdBySystem.v1.0.0.json", domain: "created_by_system", expectedCount: 8 },
|
|
709
714
|
// 3 entity kinds (@pave/domain SUBJECT_TYPES) + 4 missingness = 7
|