@htilabs/platform-common-models 0.12.4 → 0.13.1

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.
Files changed (63) hide show
  1. package/dist/constants/index.cjs +73 -0
  2. package/dist/constants/index.cjs.map +1 -1
  3. package/dist/constants/index.d.cts +1 -1
  4. package/dist/constants/index.d.ts +1 -1
  5. package/dist/constants/index.js +69 -0
  6. package/dist/constants/index.js.map +1 -1
  7. package/dist/{cvcEntry-DaDrEuTa.d.cts → cvcEntry-0BIB9sen.d.cts} +44 -44
  8. package/dist/{cvcEntry-DaDrEuTa.d.ts → cvcEntry-0BIB9sen.d.ts} +44 -44
  9. package/dist/cvcs/index.cjs +1065 -236
  10. package/dist/cvcs/index.cjs.map +1 -1
  11. package/dist/cvcs/index.d.cts +1337 -484
  12. package/dist/cvcs/index.d.ts +1337 -484
  13. package/dist/cvcs/index.js +1065 -236
  14. package/dist/cvcs/index.js.map +1 -1
  15. package/dist/enums/index.cjs +32 -17
  16. package/dist/enums/index.cjs.map +1 -1
  17. package/dist/enums/index.d.cts +38 -23
  18. package/dist/enums/index.d.ts +38 -23
  19. package/dist/enums/index.js +32 -17
  20. package/dist/enums/index.js.map +1 -1
  21. package/dist/{index-C0J3f169.d.ts → index-CDoqrfc1.d.ts} +1 -1
  22. package/dist/{index-EPjPjR0z.d.cts → index-Zu_mOJRn.d.cts} +1 -1
  23. package/dist/index.cjs +1170 -253
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +3 -3
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +1166 -253
  28. package/dist/index.js.map +1 -1
  29. package/dist/models/index.d.cts +2 -2
  30. package/dist/models/index.d.ts +2 -2
  31. package/dist/{platform-auth-Dv5fu0Fh.d.cts → platform-auth-64U8jjuw.d.cts} +71 -2
  32. package/dist/{platform-auth-Dv5fu0Fh.d.ts → platform-auth-64U8jjuw.d.ts} +71 -2
  33. package/dist/schemas/index.cjs +62 -0
  34. package/dist/schemas/index.cjs.map +1 -1
  35. package/dist/schemas/index.d.cts +35 -35
  36. package/dist/schemas/index.d.ts +35 -35
  37. package/dist/schemas/index.js +62 -0
  38. package/dist/schemas/index.js.map +1 -1
  39. package/dist/types/index.d.cts +2 -2
  40. package/dist/types/index.d.ts +2 -2
  41. package/package.json +26 -27
  42. package/src/__tests__/__snapshots__/cvc-sot.snap +12 -12
  43. package/src/__tests__/core-information-scope-invariant.test.ts +28 -0
  44. package/src/__tests__/cvc-drift-gate.test.ts +16 -5
  45. package/src/__tests__/cvc-sot-snapshot.test.ts +24 -14
  46. package/src/__tests__/cvc-structural.test.ts +8 -8
  47. package/src/__tests__/incident-participation-roles-canon.test.ts +424 -0
  48. package/src/__tests__/referral-entity-category-canon.test.ts +383 -0
  49. package/src/__tests__/victim-abuse-types-canon.test.ts +301 -0
  50. package/src/constants/ic.ts +158 -0
  51. package/src/cvcs/coreInformationScope.v1.0.0.json +3 -3
  52. package/src/cvcs/{highestEducationLevelCompleted.v1.0.0.json → highestEducationLevelCompleted.v1.1.0.json} +1 -1
  53. package/src/cvcs/incidentParticipationRoles.v1.1.0.json +433 -0
  54. package/src/cvcs/{incomeBenefitsSources.v1.0.0.json → incomeBenefitsSources.v1.1.0.json} +1 -1
  55. package/src/cvcs/index.ts +8 -8
  56. package/src/cvcs/{referralEntityCategory.v1.0.0.json → referralEntityCategory.v1.1.0.json} +192 -54
  57. package/src/cvcs/{serviceStates.v1.0.0.json → serviceStates.v1.1.0.json} +1 -1
  58. package/src/cvcs/{sourceSubtype.v1.1.0.json → sourceSubtype.v1.2.0.json} +1 -1
  59. package/src/cvcs/{verificationMethod.v1.0.0.json → verificationMethod.v1.1.0.json} +1 -1
  60. package/src/cvcs/victimAbuseTypes.v1.1.0.json +744 -0
  61. package/src/generated/cvc-enums.ts +38 -23
  62. package/src/cvcs/incidentParticipationRoles.v1.0.0.json +0 -212
  63. package/src/cvcs/victimAbuseTypes.v1.0.0.json +0 -276
@@ -0,0 +1,424 @@
1
+ /**
2
+ * INCIDENT PARTICIPATION ROLES (CVC-69) — the canon v1.0 key-set pin
3
+ * ==================================================================
4
+ *
5
+ * platform-common's CVC-69 mirror shipped STALE through 0.13.0:
6
+ * incidentParticipationRoles v1.0.0 still carried the five keys canon renamed
7
+ * on 2026-08-13 and none of `task_force` / the five Level-2 LEADS roles, while
8
+ * canon had been re-keyed (CVC69-CODEBOOK-SYNC) and audited (2026-09-10,
9
+ * CVC69-AUDIT, Status Active, 21 codebook rows). Nothing failed, because every
10
+ * gate in this package checks a SOT file against ITSELF.
11
+ *
12
+ * This test is the knowledge of what canon's codes ARE. The tables below are
13
+ * TRANSCRIBED from canon — htilabstech/prototype
14
+ * `data/cvcs/core_incident_participation_roles.yaml` @ a498581d (`entries:`,
15
+ * 21 rows; RULING RECORD 2026-08-13 for the five renames) and the Notion
16
+ * codebook `collection://3211ef14-abcd-8091-91ca-000be8087673` — NOT derived
17
+ * from the JSON, so a regenerated JSON that drifts from canon fails here.
18
+ *
19
+ * It ALSO pins the compatibility contract that makes v1.1.0 ADDITIVE rather
20
+ * than breaking (consumers persist these KEYS, and Thread's API boot-check
21
+ * hard-exits on any generated key missing from platform-db):
22
+ *
23
+ * - every v1.0.0 key is still an entry, at its v1.0.0 positional code;
24
+ * - the five superseded keys are `deprecated` + `supersededBy`, not
25
+ * selectable, and keep their v1.0.0 titles (READ still resolves);
26
+ * - every canon code exists as a selectable entry (WRITE the new keys);
27
+ * - the `ic.ts` legacy view agrees with the SOT on all of the above.
28
+ */
29
+
30
+ import { readFileSync } from "node:fs";
31
+ import path from "node:path";
32
+ import { fileURLToPath } from "node:url";
33
+
34
+ import { describe, it, expect } from "vitest";
35
+
36
+ import {
37
+ ACTIVE_INCIDENT_PARTICIPATION_ROLE_VALUES,
38
+ INCIDENT_PARTICIPATION_ROLE,
39
+ INCIDENT_PARTICIPATION_ROLE_LABELS,
40
+ INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY,
41
+ INCIDENT_PARTICIPATION_ROLE_VALUES,
42
+ canonicalIncidentParticipationRole,
43
+ isDeprecatedIncidentParticipationRole,
44
+ } from "../constants/ic.js";
45
+ import { IncidentParticipationRoleKeys } from "../generated/cvc-enums.js";
46
+
47
+ const here = path.dirname(fileURLToPath(import.meta.url));
48
+ const FILE = path.join(here, "..", "cvcs", "incidentParticipationRoles.v1.1.0.json");
49
+
50
+ interface Entry {
51
+ code: string;
52
+ key: string;
53
+ title: string;
54
+ selectable: boolean;
55
+ parentCode: string | null;
56
+ childCodes: string[];
57
+ definition: string | null;
58
+ canonicalCode?: string;
59
+ canonicalLevel?: number;
60
+ personnel?: boolean;
61
+ neverPickable?: boolean;
62
+ deprecated?: boolean;
63
+ supersededBy?: string;
64
+ }
65
+ interface Envelope {
66
+ domain: string;
67
+ version: string;
68
+ _status: string;
69
+ _source: string;
70
+ _supersedes: {
71
+ version: string;
72
+ keyMap: Record<string, string | null>;
73
+ retiredCodes: unknown[];
74
+ notes: Record<string, string>;
75
+ };
76
+ levels: Record<string, string>;
77
+ entries: Entry[];
78
+ }
79
+
80
+ const env = JSON.parse(readFileSync(FILE, "utf-8")) as Envelope;
81
+ const byKey = new Map(env.entries.map((e) => [e.key, e]));
82
+ const get = (key: string): Entry => {
83
+ const e = byKey.get(key);
84
+ if (!e) throw new Error(`no entry with key ${key}`);
85
+ return e;
86
+ };
87
+
88
+ /**
89
+ * Canon's Definition for each of the 21 codes, VERBATIM from the Notion
90
+ * codebook export (`Final CVCs/core - incident_participation_role — codebook 2.csv` @ a498581d).
91
+ * Transcribed, not derived from the JSON: a regenerated or hand-edited JSON
92
+ * whose definition drifts from canon fails here.
93
+ */
94
+ const CANON_DEFINITIONS: Readonly<Record<string, string>> = {
95
+ "UNK": "A participation role is in scope but unknown or cannot be determined from the available information.",
96
+ "ANON": "The participation role is intentionally withheld or redacted (privacy / safety / legal), even if known to the reporting party.",
97
+ "DNC": "No attempt was made to collect a participation role for this person.",
98
+ "client_subject": "The person the incident/session is about (the anchor person for the record).",
99
+ "caller_self": "The caller is the same person as the client/subject-of-record.",
100
+ "caller_third_party": "The caller is a different person than the client/subject-of-record.",
101
+ "reporter": "A person who provides information about the incident/session subject, regardless of who benefits from the service.",
102
+ "family_member_or_guardian": "A participant who is in the client/subject’s family or guardianship network (including parent/guardian).",
103
+ "friend_or_peer": "A participant who is a friend, peer, or informal support person to the client/subject.",
104
+ "vsp_staff": "A participant acting in a victim-service capacity (advocate, case manager, shelter staff, crisis response) on behalf of a VSP.",
105
+ "healthcare_provider_staff": "A participant acting formally as medical, mental, behavioral or clinical staff (clinic, hospital, SANE program, behavioral health provider).",
106
+ "law_enforcement_personnel": "A participant acting in a law-enforcement capacity (responding officer, investigator, analyst, detective, SRO).",
107
+ "legal_professional": "A participant acting in a legal capacity (attorney, prosecutor, court personnel).",
108
+ "other_response_personnel": "A responder or professional participant not covered by the VSP, healthcare, law-enforcement or legal codes (e.g. clergy, interpreter, government social services).",
109
+ "data_entry_staff": "Staff person who created or edited the record but did not respond/participate in the incident/session itself.",
110
+ "task_force": "A cross-agency task-force contributor — the community/task-force tier's personnel analogue.",
111
+ "lead_investigator": "The lead of an inquiry. Distinct from the platform case agent, which is the access/ownership singleton on the case object (first claimer, with recorded transfer) — a case names one agent but may name several investigators.",
112
+ "investigator": "A participant working some aspect of the inquiry. This is the need-to-know population for investigation_support shares.",
113
+ "analyst": "An intelligence or analytical contributor.",
114
+ "le_officer": "A responding or patrol officer.",
115
+ "prosecutor": "A prosecution-side contributor.",
116
+ };
117
+
118
+ /**
119
+ * Canon's 21 rows, in yaml row order:
120
+ * [canon code, package key, label, canon level, Type = Personnel, canon parent].
121
+ * The package key IS the canon code except for the Level-0 trio (see the
122
+ * generator header: package keys are lowercase slugs, canon code rides on
123
+ * `canonicalCode`).
124
+ */
125
+ const CANON: readonly (readonly [string, string, string, number, boolean, string | null])[] = [
126
+ ["UNK", "unknown", "Unknown", 0, false, null],
127
+ ["ANON", "anonymous", "Anonymous", 0, false, null],
128
+ ["DNC", "data_not_collected", "Data not collected", 0, false, null],
129
+ ["client_subject", "client_subject", "Client / subject-of-record", 1, false, null],
130
+ ["caller_self", "caller_self", "Caller (self)", 1, false, null],
131
+ ["caller_third_party", "caller_third_party", "Caller (third party)", 1, false, null],
132
+ ["reporter", "reporter", "Reporter / information source", 1, false, null],
133
+ [
134
+ "family_member_or_guardian",
135
+ "family_member_or_guardian",
136
+ "Family member or guardian (participant)",
137
+ 1,
138
+ false,
139
+ null,
140
+ ],
141
+ ["friend_or_peer", "friend_or_peer", "Friend or peer (participant)", 1, false, null],
142
+ ["vsp_staff", "vsp_staff", "Victim Service provider staff", 1, true, null],
143
+ [
144
+ "healthcare_provider_staff",
145
+ "healthcare_provider_staff",
146
+ "Healthcare provider staff",
147
+ 1,
148
+ true,
149
+ null,
150
+ ],
151
+ [
152
+ "law_enforcement_personnel",
153
+ "law_enforcement_personnel",
154
+ "Law enforcement personnel",
155
+ 1,
156
+ true,
157
+ null,
158
+ ],
159
+ ["legal_professional", "legal_professional", "Legal professional", 1, true, null],
160
+ [
161
+ "other_response_personnel",
162
+ "other_response_personnel",
163
+ "Other Response Personnel",
164
+ 1,
165
+ true,
166
+ null,
167
+ ],
168
+ ["data_entry_staff", "data_entry_staff", "Data Entry / Editor", 1, true, null],
169
+ ["task_force", "task_force", "Task Force Partner", 1, true, null],
170
+ [
171
+ "lead_investigator",
172
+ "lead_investigator",
173
+ "Lead Investigator",
174
+ 2,
175
+ true,
176
+ "law_enforcement_personnel",
177
+ ],
178
+ [
179
+ "investigator",
180
+ "investigator",
181
+ "Investigator / Detective",
182
+ 2,
183
+ true,
184
+ "law_enforcement_personnel",
185
+ ],
186
+ ["analyst", "analyst", "Analyst", 2, true, "law_enforcement_personnel"],
187
+ ["le_officer", "le_officer", "LE Officer", 2, true, "law_enforcement_personnel"],
188
+ ["prosecutor", "prosecutor", "Prosecutor", 2, true, "legal_professional"],
189
+ ];
190
+
191
+ /** Every key v1.0.0 published (platform-common <= 0.13.0), with its code. */
192
+ const V1_0_0: Readonly<Record<string, string>> = {
193
+ missingness_root: "069-000-000-000-000-000-000",
194
+ unknown: "069-000-000-000-000-000-001",
195
+ anonymous: "069-000-000-000-000-000-002",
196
+ data_not_collected: "069-000-000-000-000-000-003",
197
+ client_group: "069-001-000-000-000-000-000",
198
+ client_subject: "069-001-001-000-000-000-000",
199
+ caller_reporter_group: "069-002-000-000-000-000-000",
200
+ caller_self: "069-002-001-000-000-000-000",
201
+ caller_third_party: "069-002-002-000-000-000-000",
202
+ reporter: "069-002-003-000-000-000-000",
203
+ support_network_group: "069-003-000-000-000-000-000",
204
+ family_member_or_guardian: "069-003-001-000-000-000-000",
205
+ friend_or_peer: "069-003-002-000-000-000-000",
206
+ system_professional_group: "069-004-000-000-000-000-000",
207
+ service_provider_staff: "069-004-001-000-000-000-000",
208
+ medical_provider_staff: "069-004-002-000-000-000-000",
209
+ data_entry: "069-004-003-000-000-000-000",
210
+ other_incident_responder: "069-004-004-000-000-000-000",
211
+ responding_officer: "069-004-005-000-000-000-000",
212
+ legal_professional: "069-004-006-000-000-000-000",
213
+ };
214
+
215
+ /**
216
+ * Canon's 2026-08-13 renames (yaml RULING RECORD), old -> new, with the
217
+ * v1.0.0 title each old key must keep so stored values still read the same.
218
+ */
219
+ const SUPERSEDED: readonly (readonly [string, string, string])[] = [
220
+ ["service_provider_staff", "vsp_staff", "Service provider staff"],
221
+ ["medical_provider_staff", "healthcare_provider_staff", "Medical provider staff"],
222
+ ["responding_officer", "law_enforcement_personnel", "LE Responding Officer"],
223
+ ["data_entry", "data_entry_staff", "Data Entry / Editor"],
224
+ ["other_incident_responder", "other_response_personnel", "VSP or Other Incident Responder"],
225
+ ];
226
+
227
+ /** Positional codes MINTED for v1.1.0 — frozen from here on. */
228
+ const MINTED: Readonly<Record<string, string>> = {
229
+ vsp_staff: "069-004-007-000-000-000-000",
230
+ healthcare_provider_staff: "069-004-008-000-000-000-000",
231
+ law_enforcement_personnel: "069-004-009-000-000-000-000",
232
+ other_response_personnel: "069-004-010-000-000-000-000",
233
+ data_entry_staff: "069-004-011-000-000-000-000",
234
+ task_force: "069-004-012-000-000-000-000",
235
+ lead_investigator: "069-004-009-001-000-000-000",
236
+ investigator: "069-004-009-002-000-000-000",
237
+ analyst: "069-004-009-003-000-000-000",
238
+ le_officer: "069-004-009-004-000-000-000",
239
+ prosecutor: "069-004-006-001-000-000-000",
240
+ };
241
+
242
+ const GROUP_KEYS = [
243
+ "client_group",
244
+ "caller_reporter_group",
245
+ "support_network_group",
246
+ "system_professional_group",
247
+ ];
248
+
249
+ describe("CVC-69 incident_participation_roles — canon v1.0 mirror", () => {
250
+ it("is v1.1.0 of the incident_participation_roles domain, pinned to its canon source", () => {
251
+ expect(env.domain).toBe("incident_participation_roles");
252
+ expect(env.version).toBe("1.1.0");
253
+ expect(env._source).toMatch(
254
+ /core_incident_participation_roles\.yaml @ [0-9a-f]{8} \+ .*codebook 2\.csv @ [0-9a-f]{8}/,
255
+ );
256
+ expect(env._source).toContain("Notion CVC-69 v1.0");
257
+ expect(env._status.startsWith("CANONICAL")).toBe(true);
258
+ });
259
+
260
+ it("the definition table covers exactly canon's 21 codes", () => {
261
+ expect(Object.keys(CANON_DEFINITIONS).sort()).toEqual(CANON.map((r) => r[0]).sort());
262
+ });
263
+
264
+ it("carries exactly canon's 21 codes, each once", () => {
265
+ const carried = env.entries
266
+ .filter((e) => e.canonicalCode !== undefined)
267
+ .map((e) => e.canonicalCode);
268
+ expect([...carried].sort()).toEqual(CANON.map((r) => r[0]).sort());
269
+ expect(new Set(carried).size).toBe(21);
270
+ });
271
+
272
+ for (const [canonCode, key, label, level, personnel, parent] of CANON) {
273
+ it(`${canonCode}: key, label, level, personnel and parent match canon`, () => {
274
+ const e = get(key);
275
+ expect(e.canonicalCode).toBe(canonCode);
276
+ expect(e.title).toBe(label);
277
+ expect(e.canonicalLevel).toBe(level);
278
+ expect(e.personnel).toBe(personnel);
279
+ expect(e.selectable).toBe(true);
280
+ expect(e.deprecated).toBeUndefined();
281
+ expect(e.definition, "codebook Definition").toBe(CANON_DEFINITIONS[canonCode]);
282
+ const parentEntry = e.parentCode === null ? undefined : env.entries.find(
283
+ (x) => x.code === e.parentCode,
284
+ );
285
+ if (level === 0) {
286
+ expect(parentEntry?.key).toBe("missingness_root");
287
+ } else if (parent === null) {
288
+ // Canon Level 1 has no canon parent; in the package it sits directly
289
+ // under its synthetic Select group row.
290
+ expect(GROUP_KEYS).toContain(parentEntry?.key);
291
+ } else {
292
+ expect(parentEntry?.key).toBe(parent);
293
+ }
294
+ });
295
+ }
296
+
297
+ it("task_force is parentless in canon: directly under its group, with no sub-items", () => {
298
+ const e = get("task_force");
299
+ expect(env.entries.find((x) => x.code === e.parentCode)?.key).toBe(
300
+ "system_professional_group",
301
+ );
302
+ expect(e.childCodes).toEqual([]);
303
+ });
304
+
305
+ it("Level-0 keys keep the package spelling; canon's never-pickable pair is flagged", () => {
306
+ expect(get("unknown").neverPickable).toBeUndefined();
307
+ expect(get("anonymous").neverPickable).toBe(true);
308
+ expect(get("data_not_collected").neverPickable).toBe(true);
309
+ for (const k of ["UNK", "ANON", "DNC", "not_collected"]) expect(byKey.has(k), k).toBe(false);
310
+ });
311
+
312
+ it("the only non-canon entries are the root, the 4 group rows and the 5 superseded keys", () => {
313
+ const nonCanon = env.entries.filter((e) => e.canonicalCode === undefined).map((e) => e.key);
314
+ expect(nonCanon.sort()).toEqual(
315
+ ["missingness_root", ...GROUP_KEYS, ...SUPERSEDED.map((r) => r[0])].sort(),
316
+ );
317
+ expect(env.entries.length).toBe(31);
318
+ });
319
+ });
320
+
321
+ describe("CVC-69 v1.1.0 is ADDITIVE — stored v1.0.0 keys stay readable", () => {
322
+ it("every v1.0.0 key is still an entry, at its v1.0.0 positional code", () => {
323
+ for (const [key, code] of Object.entries(V1_0_0)) {
324
+ expect(byKey.has(key), `v1.0.0 key removed: ${key}`).toBe(true);
325
+ expect(get(key).code, key).toBe(code);
326
+ }
327
+ });
328
+
329
+ it("every v1.0.0 key is still in the generated IncidentParticipationRoleKeys map", () => {
330
+ const generated = IncidentParticipationRoleKeys as Record<string, string>;
331
+ for (const [key, code] of Object.entries(V1_0_0)) expect(generated[key], key).toBe(code);
332
+ });
333
+
334
+ for (const [oldKey, newKey, oldTitle] of SUPERSEDED) {
335
+ it(`${oldKey} is read-only and points at ${newKey}`, () => {
336
+ const old = get(oldKey);
337
+ expect(old.deprecated).toBe(true);
338
+ expect(old.supersededBy).toBe(newKey);
339
+ expect(old.selectable, "a superseded key must not be offered by pickers").toBe(false);
340
+ expect(old.title, "a stored value must keep reading the same").toBe(oldTitle);
341
+ expect(old.definition).toBeTruthy();
342
+ const successor = get(newKey);
343
+ expect(successor.selectable).toBe(true);
344
+ expect(successor.deprecated).toBeUndefined();
345
+ expect(successor.code).not.toBe(old.code);
346
+ });
347
+ }
348
+
349
+ it("exactly the five canon renames are deprecated — nothing else", () => {
350
+ const deprecated = env.entries.filter((e) => e.deprecated).map((e) => e.key);
351
+ expect(deprecated.sort()).toEqual(SUPERSEDED.map((r) => r[0]).sort());
352
+ for (const e of env.entries) {
353
+ expect(e.supersededBy !== undefined, e.key).toBe(e.deprecated === true);
354
+ }
355
+ });
356
+
357
+ it("_supersedes maps EVERY v1.0.0 key to a live key; identity except the five renames", () => {
358
+ const map = env._supersedes.keyMap;
359
+ expect(env._supersedes.version).toBe("1.0.0");
360
+ expect(Object.keys(map).sort()).toEqual(Object.keys(V1_0_0).sort());
361
+ expect(env._supersedes.retiredCodes).toEqual([]);
362
+ const renames = new Map(SUPERSEDED.map((r) => [r[0], r[1]]));
363
+ for (const [oldKey, newKey] of Object.entries(map)) {
364
+ expect(newKey, oldKey).toBe(renames.get(oldKey) ?? oldKey);
365
+ expect(byKey.has(newKey as string), `${oldKey} -> ${String(newKey)}`).toBe(true);
366
+ }
367
+ });
368
+
369
+ it("the eleven new canon keys exist, at their frozen minted codes", () => {
370
+ const generated = IncidentParticipationRoleKeys as Record<string, string>;
371
+ for (const [key, code] of Object.entries(MINTED)) {
372
+ expect(get(key).code, key).toBe(code);
373
+ expect(generated[key], `generated enum: ${key}`).toBe(code);
374
+ expect(Object.values(V1_0_0), `${key} reuses a v1.0.0 code`).not.toContain(code);
375
+ }
376
+ expect(Object.keys(generated).length).toBe(31);
377
+ });
378
+ });
379
+
380
+ describe("CVC-69 — the ic.ts legacy view agrees with the SOT", () => {
381
+ const sotValueKeys = env.entries
382
+ .filter((e) => e.key !== "missingness_root" && !GROUP_KEYS.includes(e.key))
383
+ .map((e) => e.key);
384
+
385
+ it("INCIDENT_PARTICIPATION_ROLE_VALUES is every SOT value key: 21 canon + 5 superseded", () => {
386
+ expect([...INCIDENT_PARTICIPATION_ROLE_VALUES].sort()).toEqual([...sotValueKeys].sort());
387
+ expect(Object.values(INCIDENT_PARTICIPATION_ROLE).sort()).toEqual([...sotValueKeys].sort());
388
+ expect(INCIDENT_PARTICIPATION_ROLE_VALUES.length).toBe(26);
389
+ });
390
+
391
+ it("every value has a label; the new canon keys carry the codebook label verbatim", () => {
392
+ const labels = INCIDENT_PARTICIPATION_ROLE_LABELS as Record<string, string>;
393
+ for (const key of sotValueKeys) expect(labels[key], key).toBeTruthy();
394
+ for (const key of Object.keys(MINTED)) expect(labels[key], key).toBe(get(key).title);
395
+ });
396
+
397
+ it("INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY is exactly the SOT's supersededBy pointers", () => {
398
+ const fromSot = Object.fromEntries(
399
+ env.entries.filter((e) => e.deprecated).map((e) => [e.key, e.supersededBy]),
400
+ );
401
+ expect(INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY).toEqual(fromSot);
402
+ });
403
+
404
+ it("ACTIVE_INCIDENT_PARTICIPATION_ROLE_VALUES is the SOT's selectable set", () => {
405
+ const selectable = env.entries.filter((e) => e.selectable).map((e) => e.key);
406
+ expect([...ACTIVE_INCIDENT_PARTICIPATION_ROLE_VALUES].sort()).toEqual(selectable.sort());
407
+ expect(ACTIVE_INCIDENT_PARTICIPATION_ROLE_VALUES.length).toBe(21);
408
+ });
409
+
410
+ it("a stored superseded key still validates, is flagged, and normalises to canon", () => {
411
+ const values = INCIDENT_PARTICIPATION_ROLE_VALUES as readonly string[];
412
+ for (const [oldKey, newKey] of SUPERSEDED) {
413
+ expect(values, oldKey).toContain(oldKey);
414
+ expect(isDeprecatedIncidentParticipationRole(oldKey)).toBe(true);
415
+ expect(canonicalIncidentParticipationRole(oldKey)).toBe(newKey);
416
+ expect(isDeprecatedIncidentParticipationRole(newKey)).toBe(false);
417
+ expect(canonicalIncidentParticipationRole(newKey)).toBe(newKey);
418
+ }
419
+ expect(canonicalIncidentParticipationRole("client_subject")).toBe("client_subject");
420
+ expect(canonicalIncidentParticipationRole("not_a_role")).toBe("not_a_role");
421
+ expect(isDeprecatedIncidentParticipationRole("toString")).toBe(false);
422
+ expect(isDeprecatedIncidentParticipationRole(undefined)).toBe(false);
423
+ });
424
+ });