@htilabs/platform-common-models 0.13.0 → 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 (58) 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-ctHTp2df.d.cts → cvcEntry-0BIB9sen.d.cts} +36 -36
  8. package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-0BIB9sen.d.ts} +36 -36
  9. package/dist/cvcs/index.cjs +466 -107
  10. package/dist/cvcs/index.cjs.map +1 -1
  11. package/dist/cvcs/index.d.cts +489 -110
  12. package/dist/cvcs/index.d.ts +489 -110
  13. package/dist/cvcs/index.js +466 -107
  14. package/dist/cvcs/index.js.map +1 -1
  15. package/dist/enums/index.cjs +15 -1
  16. package/dist/enums/index.cjs.map +1 -1
  17. package/dist/enums/index.d.cts +21 -7
  18. package/dist/enums/index.d.ts +21 -7
  19. package/dist/enums/index.js +15 -1
  20. package/dist/enums/index.js.map +1 -1
  21. package/dist/{index-4DiJrn7y.d.ts → index-CDoqrfc1.d.ts} +1 -1
  22. package/dist/{index-qreOzXYS.d.cts → index-Zu_mOJRn.d.cts} +1 -1
  23. package/dist/index.cjs +554 -108
  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 +550 -108
  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 +11 -11
  36. package/dist/schemas/index.d.ts +11 -11
  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 +9 -9
  43. package/src/__tests__/cvc-drift-gate.test.ts +16 -5
  44. package/src/__tests__/cvc-sot-snapshot.test.ts +18 -11
  45. package/src/__tests__/cvc-structural.test.ts +7 -7
  46. package/src/__tests__/incident-participation-roles-canon.test.ts +424 -0
  47. package/src/__tests__/referral-entity-category-canon.test.ts +383 -0
  48. package/src/constants/ic.ts +158 -0
  49. package/src/cvcs/{highestEducationLevelCompleted.v1.0.0.json → highestEducationLevelCompleted.v1.1.0.json} +1 -1
  50. package/src/cvcs/incidentParticipationRoles.v1.1.0.json +433 -0
  51. package/src/cvcs/{incomeBenefitsSources.v1.0.0.json → incomeBenefitsSources.v1.1.0.json} +1 -1
  52. package/src/cvcs/index.ts +7 -7
  53. package/src/cvcs/{referralEntityCategory.v1.0.0.json → referralEntityCategory.v1.1.0.json} +192 -54
  54. package/src/cvcs/{serviceStates.v1.0.0.json → serviceStates.v1.1.0.json} +1 -1
  55. package/src/cvcs/{sourceSubtype.v1.1.0.json → sourceSubtype.v1.2.0.json} +1 -1
  56. package/src/cvcs/{verificationMethod.v1.0.0.json → verificationMethod.v1.1.0.json} +1 -1
  57. package/src/generated/cvc-enums.ts +21 -7
  58. package/src/cvcs/incidentParticipationRoles.v1.0.0.json +0 -212
@@ -0,0 +1,383 @@
1
+ /**
2
+ * REFERRAL ENTITY CATEGORY (CVC-48 / IC-58) — the canon v1.3 row pin
3
+ * ==================================================================
4
+ *
5
+ * platform-common's CVC-48 mirror shipped STALE through 0.13.0:
6
+ * referralEntityCategory v1.0.0 predated canon's 2026-08-20 full audit, so it
7
+ * lacked three leaves (Adult Protective Services, School / academic
8
+ * institution, Legal services provider), had Education selectable and Law
9
+ * enforcement / Police not, and carried the pre-audit MDT / Coalition wording.
10
+ * Nothing failed, because every gate here checks a SOT file against ITSELF.
11
+ *
12
+ * The CANON table below is TRANSCRIBED from canon — htilabstech/prototype
13
+ * `data/cvcs/core_referral_entity_category.yaml` v1.3 @ 9a10f480 (`entries:`,
14
+ * 46 rows) and the live Notion codebook
15
+ * `collection://3181ef14-abcd-8081-95b5-000bc30a73bd` (46 rows, compared
16
+ * 2026-10-05) — NOT derived from the JSON.
17
+ *
18
+ * It also pins the compatibility contract (consumers persist these KEYS):
19
+ * every v1.0.0 key is still an entry at its v1.0.0 positional code, and the
20
+ * three new leaves exist.
21
+ *
22
+ * And it pins the ONE canon row deliberately not carried: `02-02-01-00`
23
+ * Hotline (see `HELD` in scripts/gen-referral-entity-category.py). If that row
24
+ * is ever carried, this test must be changed on purpose.
25
+ */
26
+
27
+ import { readFileSync } from "node:fs";
28
+ import path from "node:path";
29
+ import { fileURLToPath } from "node:url";
30
+
31
+ import { describe, it, expect } from "vitest";
32
+
33
+ import { ReferralEntityCategoryKeys } from "../generated/cvc-enums.js";
34
+
35
+ const here = path.dirname(fileURLToPath(import.meta.url));
36
+ const FILE = path.join(here, "..", "cvcs", "referralEntityCategory.v1.1.0.json");
37
+
38
+ interface Entry {
39
+ code: string;
40
+ key: string;
41
+ title: string;
42
+ selectable: boolean;
43
+ parentCode: string | null;
44
+ childCodes: string[];
45
+ definition: string | null;
46
+ canonicalCode?: string;
47
+ }
48
+ interface Envelope {
49
+ domain: string;
50
+ version: string;
51
+ _status: string;
52
+ _source: string;
53
+ _supersedes: { version: string; keyMap: Record<string, string | null>; retiredCodes: unknown[] };
54
+ _notCarried: { canonicalCode: string; name: string; reason: string }[];
55
+ entries: Entry[];
56
+ }
57
+
58
+ const env = JSON.parse(readFileSync(FILE, "utf-8")) as Envelope;
59
+ const byKey = new Map(env.entries.map((e) => [e.key, e]));
60
+ const byCode = new Map(env.entries.map((e) => [e.code, e]));
61
+ const get = (key: string): Entry => {
62
+ const e = byKey.get(key);
63
+ if (!e) throw new Error(`no entry with key ${key}`);
64
+ return e;
65
+ };
66
+
67
+ /**
68
+ * Canon's rows that this package carries (45 of 46), in canon code order:
69
+ * [canon code, package key, canon name, canon Selectable]. For the three
70
+ * Level-0 rows canon's name is a bare slug and the package keeps its house
71
+ * missingness title, so the title is not compared there (`null`).
72
+ */
73
+ const CANON: readonly (readonly [string, string, string | null, boolean])[] = [
74
+ ["00-00-01-00", "unknown", null, true],
75
+ ["00-00-02-00", "anonymous", null, true],
76
+ ["00-00-03-00", "data_not_collected", null, true],
77
+ ["01-00-01-00", "self_referred", "Self-referred", true],
78
+ ["01-00-02-00", "family_guardian_friend", "Family/guardian/friend/foster parent", true],
79
+ ["01-00-03-00", "peer", "Peer / another client", true],
80
+ ["01-00-04-00", "other_individual", "Other individual", true],
81
+ ["02-01-00-00", "housing_shelter_continuum", "Housing / Shelter continuum", false],
82
+ ["02-01-01-00", "outreach_project", "Outreach Project", true],
83
+ ["02-01-02-00", "temporary_shelter", "Temporary Shelter", true],
84
+ ["02-01-03-00", "residential_project", "Residential Project", true],
85
+ ["02-02-00-00", "hotlines", "Hotlines", false],
86
+ ["02-02-01-01", "national_hotline", "National hotline", true],
87
+ ["02-02-01-02", "local_other_hotline", "Local/other hotline", true],
88
+ ["02-03-00-00", "justice_protective_systems", "Justice & Protective Systems", false],
89
+ ["02-03-01-00", "child_welfare_cps", "Child Welfare / CPS", true],
90
+ ["02-03-02-00", "juvenile_justice", "Juvenile Justice", true],
91
+ ["02-03-03-00", "law_enforcement", "Law enforcement / Police", true],
92
+ ["02-03-03-01", "local_law_enforcement", "Local law enforcement", true],
93
+ ["02-03-03-02", "state_law_enforcement", "State law enforcement", true],
94
+ ["02-03-03-03", "federal_law_enforcement", "Federal law enforcement", true],
95
+ ["02-03-03-04", "tribal_law_enforcement", "Tribal law enforcement", true],
96
+ ["02-03-03-05", "other_law_enforcement", "Other/ unknown LE", true],
97
+ ["02-03-04-00", "courts_prosecution", "Courts or prosecution", true],
98
+ ["02-03-05-00", "correction_probation", "Correction / probation", true],
99
+ // Notion label; the yaml port omits "(APS)".
100
+ ["02-03-06-00", "adult_protective_services", "Adult Protective Services (APS)", true],
101
+ ["02-04-00-00", "health_behavioral_health", "Health / behavioral health", false],
102
+ ["02-04-01-00", "inpatient_psychiatric_facility", "Inpatient psychiatric facility", true],
103
+ [
104
+ "02-04-02-00",
105
+ "healthcare_provider",
106
+ "Healthcare provider (non-inpatient psychiatric)",
107
+ true,
108
+ ],
109
+ ["02-05-00-00", "education", "Education", false],
110
+ ["02-05-01-00", "school_academic_institution", "School / academic institution", true],
111
+ [
112
+ "02-06-00-00",
113
+ "victim_community_service_providers",
114
+ "Victim + Community service providers",
115
+ false,
116
+ ],
117
+ ["02-06-01-00", "child_advocacy_center", "Child Advocacy Center (CAC)", true],
118
+ [
119
+ "02-06-02-00",
120
+ "victim_service_provider",
121
+ "Victim service provider / advocacy program",
122
+ true,
123
+ ],
124
+ [
125
+ "02-06-03-00",
126
+ "community_based_service_provider",
127
+ "Community-based service provider (general social services)",
128
+ true,
129
+ ],
130
+ ["02-06-04-00", "legal_services_provider", "Legal services provider", true],
131
+ ["02-07-00-00", "coordination_governance", "Coordination & Governance", false],
132
+ ["02-07-01-00", "mdt", "Multidisciplinary team (MDT)", true],
133
+ ["02-07-02-00", "coalition", "Coalition (state/regional coalition)", true],
134
+ ["02-08-00-00", "internal", "Internal", false],
135
+ ["02-08-01-00", "own_agency_internal", "Own agency / internal referral", true],
136
+ ["02-09-00-00", "other_entity", "Other", false],
137
+ ["02-09-01-00", "employer", "Employer", true],
138
+ ["02-09-02-00", "benefits_public_assistance_office", "Benefits/public assistance office", true],
139
+ ["02-09-03-00", "other_organization", "Other Organization", true],
140
+ ];
141
+
142
+ /**
143
+ * Canon's definition for each carried row, VERBATIM: the yaml port
144
+ * (`data/cvcs/core_referral_entity_category.yaml` @ 9a10f480) except the
145
+ * definition cells where the live Notion codebook wording is used instead
146
+ * (generator `NOTION_WORDING`). `null` where canon has no definition (headings
147
+ * and the Level-0 rows). Transcribed, not derived from the JSON.
148
+ */
149
+ const CANON_DEFINITIONS: Readonly<Record<string, string | null>> = {
150
+ "00-00-01-00": "Referral entity category unknown.",
151
+ "00-00-02-00": "Referral entity category withheld or redacted.",
152
+ "00-00-03-00": "Referral entity category not collected or no signal captured.",
153
+ "01-00-01-00": "Client initiated contact or presented for services without a third-party referrer.",
154
+ "01-00-02-00": "A caregiver, family member, or close personal support person initiated the referral.",
155
+ "01-00-03-00": "Another current or former client initiated or encouraged the referral.",
156
+ "01-00-04-00": "A non-family individual initiated the referral (e.g., neighbor, community member, clergy).",
157
+ "02-01-00-00": "Primary function is outreach engagement, emergency shelter, or residential shelter/housing programs.",
158
+ "02-01-01-00": "Street/community outreach program that engaged the client prior to enrollment.",
159
+ "02-01-02-00": "Emergency/crisis shelter or short-term temporary housing program.",
160
+ "02-01-03-00": "Longer-term residential or transitional living program.",
161
+ "02-02-00-00": "Crisis lines or call centers that connect a person to services.",
162
+ "02-02-01-01": "National-level hotline network.",
163
+ "02-02-01-02": "Local/regional hotline or non-national hotline.",
164
+ "02-03-00-00": null,
165
+ "02-03-01-00": "Government child protection agency responsible for investigating child abuse/neglect and ensuring child safety.",
166
+ "02-03-02-00": "Juvenile probation/detention/court-related juvenile justice system initiated the referral.",
167
+ "02-03-03-00": "Law enforcement agency initiated the referral (local/state/federal).",
168
+ "02-03-03-01": "City/county police or sheriff.",
169
+ "02-03-03-02": "State-level law enforcement agency (e.g., state police/highway patrol/state bureau of investigation) acting in an official capacity.",
170
+ "02-03-03-03": "Federal law enforcement agency (e.g., FBI, DHS/ICE).",
171
+ "02-03-03-04": "Tribal police.",
172
+ "02-03-03-05": "Other law enforcement entity, or law enforcement type is unknown.",
173
+ "02-03-04-00": "Court or prosecution entity (not law enforcement).",
174
+ "02-03-05-00": "Corrections, probation, parole, or community supervision entity (not law enforcement).",
175
+ "02-03-06-00": "Government adult protection agency responsible for investigating abuse, neglect, self-neglect, or exploitation of vulnerable or older adults and ensuring their safety. Adult analog of Child Welfare / CPS.",
176
+ "02-04-00-00": "Hospitals and healthcare providers (including mental health inpatient facilities).",
177
+ "02-04-01-00": "Inpatient psychiatric hospital or psychiatric facility.",
178
+ "02-04-02-00": "Any non-inpatient healthcare provider (clinic, hospital, outpatient provider, behavioral health clinic, SANE program, substance abuse clinic, etc.).",
179
+ "02-05-00-00": "Parent category for education-related institutions.",
180
+ "02-05-01-00": "School system or educational institution.",
181
+ "02-06-00-00": "Parent category for victim service providers and community-based service providers.",
182
+ "02-06-01-00": "A child-centered multidisciplinary center coordinating investigation and services (forensic interview, coordination, referrals, sometimes medical or therapy) for child victims.",
183
+ "02-06-02-00": "Organization whose primary mission is to provide services to victims/survivors of crime (VOCA-aligned breadth: rape crisis centers, DV/dating-violence/stalking programs, anti-trafficking programs, child victim centers, homicide-survivor organizations, and similar). Whether the organization is specifically a DV/SA victim service provider — the fact HMIS 2.01 needs (Comparable Database) — is a separate per-organization attribute, self-attested by the organization at onboarding (Platform survey / Agency Hub “My agency info”), not part of this category.",
184
+ "02-06-03-00": "The residual community-based provider (“other community-based service provider”): a non-VSP offering practical support services, navigation, or stabilization resources that is not primarily a VSP, a legal services provider, a housing/shelter project, a government justice agency, a healthcare provider, a school, a hotline, or a public benefits office. (Ex: youth drop-in center; food pantry; reentry program.)",
185
+ "02-06-04-00": "Civil legal aid organization, immigration attorneys, victim-rights law clinic, or similar provider of legal help to the client. Distinct from Courts or prosecution (the justice-system entity itself): this is getting a lawyer's help, not being referred into proceedings.",
186
+ "02-07-00-00": "Parent category for coordination and governance bodies (e.g., MDTs, coalitions).",
187
+ "02-07-01-00": "A case-level team: professionals from multiple agencies (law enforcement, child welfare, medical, advocacy) who review and coordinate individual cases together; referrals arise out of case review. (E.g., a county trafficking MDT or a CAC-based team.)",
188
+ "02-07-02-00": "A state or regional membership body of organizations coordinating at the system level — training, standards, policy, funding — not individual cases; referrals from a coalition are typically warm handoffs to a member organization.",
189
+ "02-08-00-00": "Parent category for internal referrals within the same umbrella agency.",
190
+ "02-08-01-00": "Client was referred from another program or unit within the same umbrella agency.",
191
+ "02-09-00-00": "Parent category for other organizations not captured by the primary sectors.",
192
+ "02-09-01-00": "Employer, HR, or employee assistance program initiated the referral.",
193
+ "02-09-02-00": "Government office administering public benefits or eligibility and enrollment (e.g., SNAP, TANF, Medicaid, SSA).",
194
+ "02-09-03-00": "Other organization not otherwise captured by the listed categories.",
195
+ };
196
+
197
+ /** The canon row deliberately NOT carried (generator `HELD`). */
198
+ const HELD_CANON_CODE = "02-02-01-00";
199
+
200
+ const code = (...segs: number[]): string =>
201
+ [48, ...segs, ...Array(6 - segs.length).fill(0)]
202
+ .map((n) => String(n).padStart(3, "0"))
203
+ .join("-");
204
+
205
+ /** Every key v1.0.0 published (platform-common <= 0.13.0), with its code. */
206
+ const V1_0_0: Readonly<Record<string, string>> = {
207
+ missingness_root: "048-000-000-000-000-000-000",
208
+ unknown: "048-000-000-000-000-000-001",
209
+ anonymous: "048-000-000-000-000-000-002",
210
+ data_not_collected: "048-000-000-000-000-000-003",
211
+ self_referred: code(1),
212
+ family_guardian_friend: code(2),
213
+ peer: code(3),
214
+ other_individual: code(4),
215
+ housing_shelter_continuum: code(5),
216
+ outreach_project: code(5, 1),
217
+ temporary_shelter: code(5, 2),
218
+ residential_project: code(5, 3),
219
+ hotlines: code(6),
220
+ national_hotline: code(6, 1),
221
+ local_other_hotline: code(6, 2),
222
+ justice_protective_systems: code(7),
223
+ child_welfare_cps: code(7, 1),
224
+ juvenile_justice: code(7, 2),
225
+ law_enforcement: code(7, 3),
226
+ local_law_enforcement: code(7, 3, 1),
227
+ state_law_enforcement: code(7, 3, 2),
228
+ federal_law_enforcement: code(7, 3, 3),
229
+ tribal_law_enforcement: code(7, 3, 4),
230
+ other_law_enforcement: code(7, 3, 5),
231
+ courts_prosecution: code(7, 4),
232
+ correction_probation: code(7, 5),
233
+ health_behavioral_health: code(8),
234
+ inpatient_psychiatric_facility: code(8, 1),
235
+ healthcare_provider: code(8, 2),
236
+ education: code(9),
237
+ victim_community_service_providers: code(10),
238
+ child_advocacy_center: code(10, 1),
239
+ victim_service_provider: code(10, 2),
240
+ community_based_service_provider: code(10, 3),
241
+ coordination_governance: code(11),
242
+ mdt: code(11, 1),
243
+ coalition: code(11, 2),
244
+ internal: code(12),
245
+ own_agency_internal: code(12, 1),
246
+ other_entity: code(13),
247
+ employer: code(13, 1),
248
+ benefits_public_assistance_office: code(13, 2),
249
+ other_organization: code(13, 3),
250
+ };
251
+
252
+ /** Leaves added in v1.1.0: [key, minted positional code, parent key]. */
253
+ const ADDED: readonly (readonly [string, string, string])[] = [
254
+ ["adult_protective_services", code(7, 6), "justice_protective_systems"],
255
+ ["school_academic_institution", code(9, 1), "education"],
256
+ ["legal_services_provider", code(10, 4), "victim_community_service_providers"],
257
+ ];
258
+
259
+ /** Canon's parent of a canon code, read off the code itself. */
260
+ function canonParent(c: string): string | null {
261
+ const [a, b, y, z] = c.split("-");
262
+ if (a !== "02") return null;
263
+ if (z !== "00") return `${a}-${b}-${y}-00`;
264
+ if (y !== "00") return `${a}-${b}-00-00`;
265
+ return null;
266
+ }
267
+
268
+ describe("CVC-48 referral_entity_category — canon v1.3 mirror", () => {
269
+ it("is v1.1.0 of the referral_entity_category domain, pinned to its canon source", () => {
270
+ expect(env.domain).toBe("referral_entity_category");
271
+ expect(env.version).toBe("1.1.0");
272
+ expect(env._source).toMatch(/core_referral_entity_category\.yaml @ [0-9a-f]{8} /);
273
+ expect(env._source).toContain("yaml v1.3");
274
+ expect(env._status.startsWith("CANONICAL")).toBe(true);
275
+ });
276
+
277
+ it("carries exactly the 45 canon codes in the table, each once (+ missingness_root)", () => {
278
+ const carried = env.entries
279
+ .filter((e) => e.canonicalCode !== undefined)
280
+ .map((e) => e.canonicalCode);
281
+ expect([...carried].sort()).toEqual(CANON.map((r) => r[0]).sort());
282
+ expect(new Set(carried).size).toBe(45);
283
+ expect(env.entries.filter((e) => e.canonicalCode === undefined).map((e) => e.key)).toEqual([
284
+ "missingness_root",
285
+ ]);
286
+ expect(env.entries.length).toBe(46);
287
+ });
288
+
289
+ for (const [canonCode, key, name, selectable] of CANON) {
290
+ it(`${canonCode} ${key}: name, Selectable, definition and parent match canon`, () => {
291
+ const e = get(key);
292
+ expect(e.canonicalCode).toBe(canonCode);
293
+ if (name !== null) expect(e.title).toBe(name);
294
+ expect(e.selectable).toBe(selectable);
295
+ expect(e.definition, "canon definition").toBe(CANON_DEFINITIONS[canonCode]);
296
+ const parent = e.parentCode === null ? null : byCode.get(e.parentCode) ?? null;
297
+ const want = canonParent(canonCode);
298
+ if (canonCode.startsWith("00-")) {
299
+ expect(parent?.key).toBe("missingness_root");
300
+ } else if (want === HELD_CANON_CODE) {
301
+ // Canon parent is the held Hotline row: sits under ITS parent instead.
302
+ expect(parent?.canonicalCode).toBe(canonParent(HELD_CANON_CODE));
303
+ } else {
304
+ expect(parent?.canonicalCode ?? null).toBe(want);
305
+ }
306
+ });
307
+ }
308
+
309
+ it("a non-selectable heading always has at least one leaf to record instead", () => {
310
+ for (const e of env.entries) {
311
+ if (!e.selectable) expect(e.childCodes.length, e.key).toBeGreaterThan(0);
312
+ }
313
+ });
314
+
315
+ it("Education is a heading; School / academic institution is its only leaf", () => {
316
+ expect(get("education").selectable).toBe(false);
317
+ expect(get("education").childCodes).toEqual([get("school_academic_institution").code]);
318
+ });
319
+
320
+ it("Law enforcement / Police is selectable and keeps its five optional children", () => {
321
+ expect(get("law_enforcement").selectable).toBe(true);
322
+ expect(get("law_enforcement").childCodes.length).toBe(5);
323
+ });
324
+
325
+ it("canon Hotline (02-02-01-00) is HELD: not carried, and recorded as such", () => {
326
+ expect(env.entries.some((e) => e.canonicalCode === HELD_CANON_CODE)).toBe(false);
327
+ expect(byKey.has("hotline")).toBe(false);
328
+ expect(env._notCarried.map((r) => r.canonicalCode)).toEqual([HELD_CANON_CODE]);
329
+ expect(env._notCarried[0]?.name).toBe("Hotline");
330
+ // Its two canon children stay where v1.0.0 published them.
331
+ expect(get("national_hotline").parentCode).toBe(get("hotlines").code);
332
+ expect(get("local_other_hotline").parentCode).toBe(get("hotlines").code);
333
+ expect(get("hotlines").childCodes).toEqual([
334
+ get("national_hotline").code,
335
+ get("local_other_hotline").code,
336
+ ]);
337
+ });
338
+ });
339
+
340
+ describe("CVC-48 v1.1.0 is ADDITIVE — stored v1.0.0 keys stay readable", () => {
341
+ it("v1.0.0 published 43 keys", () => {
342
+ expect(Object.keys(V1_0_0).length).toBe(43);
343
+ });
344
+
345
+ it("every v1.0.0 key is still an entry, at its v1.0.0 positional code", () => {
346
+ for (const [key, c] of Object.entries(V1_0_0)) {
347
+ expect(byKey.has(key), `v1.0.0 key removed: ${key}`).toBe(true);
348
+ expect(get(key).code, key).toBe(c);
349
+ }
350
+ });
351
+
352
+ it("every v1.0.0 key is still in the generated ReferralEntityCategoryKeys map", () => {
353
+ const generated = ReferralEntityCategoryKeys as Record<string, string>;
354
+ for (const [key, c] of Object.entries(V1_0_0)) expect(generated[key], key).toBe(c);
355
+ expect(Object.keys(generated).length).toBe(46);
356
+ });
357
+
358
+ for (const [key, c, parentKey] of ADDED) {
359
+ it(`${key} is added at ${c}, a selectable leaf under ${parentKey}`, () => {
360
+ const e = get(key);
361
+ expect(e.code).toBe(c);
362
+ expect(e.selectable).toBe(true);
363
+ expect(e.childCodes).toEqual([]);
364
+ expect(e.parentCode).toBe(get(parentKey).code);
365
+ expect(e.definition).toBeTruthy();
366
+ expect(Object.values(V1_0_0), `${key} reuses a v1.0.0 code`).not.toContain(c);
367
+ expect((ReferralEntityCategoryKeys as Record<string, string>)[key]).toBe(c);
368
+ });
369
+ }
370
+
371
+ it("the entry set is exactly v1.0.0's 43 keys plus the 3 added leaves", () => {
372
+ expect([...byKey.keys()].sort()).toEqual(
373
+ [...Object.keys(V1_0_0), ...ADDED.map((r) => r[0])].sort(),
374
+ );
375
+ });
376
+
377
+ it("_supersedes maps every v1.0.0 key to itself — nothing was renamed or retired", () => {
378
+ expect(env._supersedes.version).toBe("1.0.0");
379
+ expect(Object.keys(env._supersedes.keyMap).sort()).toEqual(Object.keys(V1_0_0).sort());
380
+ for (const [k, v] of Object.entries(env._supersedes.keyMap)) expect(v, k).toBe(k);
381
+ expect(env._supersedes.retiredCodes).toEqual([]);
382
+ });
383
+ });
@@ -1973,6 +1973,13 @@ export const USER_STATUS_LABELS: Record<UserStatusValue, string> = {
1973
1973
 
1974
1974
  // ─── CVC-69: Incident Participation Role ────────────────────────────
1975
1975
  // Multi-valued: 0+ per person per session. Describes session participation.
1976
+ //
1977
+ // Legacy view of the SOT `src/cvcs/incidentParticipationRoles.v1.1.0.json`
1978
+ // (canon CVC-69 v1.0, audited 2026-09-10). Canon renamed five keys on
1979
+ // 2026-08-13; the old keys are KEPT here (marked `@deprecated`) because
1980
+ // consumers persist these keys on documents — a stored old key still validates
1981
+ // and still has a label. New writes should use the successor: see
1982
+ // `INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY` below.
1976
1983
 
1977
1984
  export const INCIDENT_PARTICIPATION_ROLE = {
1978
1985
  CLIENT_SUBJECT: "client_subject", // Exactly 1 per session
@@ -1981,12 +1988,32 @@ export const INCIDENT_PARTICIPATION_ROLE = {
1981
1988
  REPORTER: "reporter",
1982
1989
  FAMILY_MEMBER_OR_GUARDIAN: "family_member_or_guardian",
1983
1990
  FRIEND_OR_PEER: "friend_or_peer",
1991
+ /** @deprecated Superseded by `VSP_STAFF` (canon CVC-69, 2026-08-13). Read-only. */
1984
1992
  SERVICE_PROVIDER_STAFF: "service_provider_staff",
1993
+ /** @deprecated Superseded by `HEALTHCARE_PROVIDER_STAFF` (canon CVC-69, 2026-08-13). Read-only. */
1985
1994
  MEDICAL_PROVIDER_STAFF: "medical_provider_staff",
1995
+ /** @deprecated Superseded by `DATA_ENTRY_STAFF` (canon CVC-69, 2026-08-13). Read-only. */
1986
1996
  DATA_ENTRY: "data_entry",
1997
+ /** @deprecated Superseded by `OTHER_RESPONSE_PERSONNEL` (canon CVC-69, 2026-08-13). Read-only. */
1987
1998
  OTHER_INCIDENT_RESPONDER: "other_incident_responder",
1999
+ /** @deprecated Superseded by `LAW_ENFORCEMENT_PERSONNEL` (canon CVC-69, 2026-08-13). Read-only. */
1988
2000
  RESPONDING_OFFICER: "responding_officer",
1989
2001
  LEGAL_PROFESSIONAL: "legal_professional",
2002
+ // Canon CVC-69 v1.0 — the five renamed codes + task_force.
2003
+ VSP_STAFF: "vsp_staff",
2004
+ HEALTHCARE_PROVIDER_STAFF: "healthcare_provider_staff",
2005
+ LAW_ENFORCEMENT_PERSONNEL: "law_enforcement_personnel",
2006
+ OTHER_RESPONSE_PERSONNEL: "other_response_personnel",
2007
+ DATA_ENTRY_STAFF: "data_entry_staff",
2008
+ TASK_FORCE: "task_force",
2009
+ // Canon Level-2 sub-items (LEADS investigative wing). A sub-item implies its
2010
+ // parent: the first four sit under LAW_ENFORCEMENT_PERSONNEL, PROSECUTOR
2011
+ // under LEGAL_PROFESSIONAL.
2012
+ LEAD_INVESTIGATOR: "lead_investigator",
2013
+ INVESTIGATOR: "investigator",
2014
+ ANALYST: "analyst",
2015
+ LE_OFFICER: "le_officer",
2016
+ PROSECUTOR: "prosecutor",
1990
2017
  UNKNOWN: "unknown",
1991
2018
  ANONYMOUS: "anonymous",
1992
2019
  DATA_NOT_COLLECTED: "data_not_collected",
@@ -2008,11 +2035,29 @@ export const INCIDENT_PARTICIPATION_ROLE_VALUES = [
2008
2035
  INCIDENT_PARTICIPATION_ROLE.OTHER_INCIDENT_RESPONDER,
2009
2036
  INCIDENT_PARTICIPATION_ROLE.RESPONDING_OFFICER,
2010
2037
  INCIDENT_PARTICIPATION_ROLE.LEGAL_PROFESSIONAL,
2038
+ INCIDENT_PARTICIPATION_ROLE.VSP_STAFF,
2039
+ INCIDENT_PARTICIPATION_ROLE.HEALTHCARE_PROVIDER_STAFF,
2040
+ INCIDENT_PARTICIPATION_ROLE.LAW_ENFORCEMENT_PERSONNEL,
2041
+ INCIDENT_PARTICIPATION_ROLE.OTHER_RESPONSE_PERSONNEL,
2042
+ INCIDENT_PARTICIPATION_ROLE.DATA_ENTRY_STAFF,
2043
+ INCIDENT_PARTICIPATION_ROLE.TASK_FORCE,
2044
+ INCIDENT_PARTICIPATION_ROLE.LEAD_INVESTIGATOR,
2045
+ INCIDENT_PARTICIPATION_ROLE.INVESTIGATOR,
2046
+ INCIDENT_PARTICIPATION_ROLE.ANALYST,
2047
+ INCIDENT_PARTICIPATION_ROLE.LE_OFFICER,
2048
+ INCIDENT_PARTICIPATION_ROLE.PROSECUTOR,
2011
2049
  INCIDENT_PARTICIPATION_ROLE.UNKNOWN,
2012
2050
  INCIDENT_PARTICIPATION_ROLE.ANONYMOUS,
2013
2051
  INCIDENT_PARTICIPATION_ROLE.DATA_NOT_COLLECTED,
2014
2052
  ] as const;
2015
2053
 
2054
+ // Labels for the fifteen keys 0.13.0 shipped are kept exactly as shipped: they
2055
+ // are title-cased and several differ from the SOT titles and canon (e.g.
2056
+ // "Legal Professional" vs canon "Legal professional", "Not Collected" vs
2057
+ // "Data not collected"). Consumers display these strings, so re-casing them is a
2058
+ // visible change on repin and belongs in its own announced change, not in this
2059
+ // additive re-mirror. Labels for the eleven keys added in v1.1.0 are the canon
2060
+ // codebook `Acceptable name`, verbatim.
2016
2061
  export const INCIDENT_PARTICIPATION_ROLE_LABELS: Record<
2017
2062
  IncidentParticipationRoleValue,
2018
2063
  string
@@ -2033,6 +2078,22 @@ export const INCIDENT_PARTICIPATION_ROLE_LABELS: Record<
2033
2078
  "VSP or Other Incident Responder",
2034
2079
  [INCIDENT_PARTICIPATION_ROLE.RESPONDING_OFFICER]: "LE Responding Officer",
2035
2080
  [INCIDENT_PARTICIPATION_ROLE.LEGAL_PROFESSIONAL]: "Legal Professional",
2081
+ // Added in v1.1.0: the canon codebook `Acceptable name`, verbatim.
2082
+ [INCIDENT_PARTICIPATION_ROLE.VSP_STAFF]: "Victim Service provider staff",
2083
+ [INCIDENT_PARTICIPATION_ROLE.HEALTHCARE_PROVIDER_STAFF]:
2084
+ "Healthcare provider staff",
2085
+ [INCIDENT_PARTICIPATION_ROLE.LAW_ENFORCEMENT_PERSONNEL]:
2086
+ "Law enforcement personnel",
2087
+ [INCIDENT_PARTICIPATION_ROLE.OTHER_RESPONSE_PERSONNEL]:
2088
+ "Other Response Personnel",
2089
+ [INCIDENT_PARTICIPATION_ROLE.DATA_ENTRY_STAFF]: "Data Entry / Editor",
2090
+ [INCIDENT_PARTICIPATION_ROLE.TASK_FORCE]: "Task Force Partner",
2091
+ [INCIDENT_PARTICIPATION_ROLE.LEAD_INVESTIGATOR]: "Lead Investigator",
2092
+ [INCIDENT_PARTICIPATION_ROLE.INVESTIGATOR]: "Investigator / Detective",
2093
+ [INCIDENT_PARTICIPATION_ROLE.ANALYST]: "Analyst",
2094
+ [INCIDENT_PARTICIPATION_ROLE.LE_OFFICER]: "LE Officer",
2095
+ [INCIDENT_PARTICIPATION_ROLE.PROSECUTOR]: "Prosecutor",
2096
+ // Level 0, as 0.13.0 shipped them (canon: Unknown / Anonymous / Data not collected).
2036
2097
  [INCIDENT_PARTICIPATION_ROLE.UNKNOWN]: "Unknown",
2037
2098
  [INCIDENT_PARTICIPATION_ROLE.ANONYMOUS]: "Anonymous",
2038
2099
  [INCIDENT_PARTICIPATION_ROLE.DATA_NOT_COLLECTED]: "Not Collected",
@@ -2041,6 +2102,12 @@ export const INCIDENT_PARTICIPATION_ROLE_LABELS: Record<
2041
2102
  /**
2042
2103
  * Participation role category groupings for UI organization.
2043
2104
  *
2105
+ * NOT YET RE-KEYED: `SYSTEM_PROFESSIONAL` (and
2106
+ * `DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY.PERSONNEL` below) still name the
2107
+ * superseded `SERVICE_PROVIDER_STAFF` / `MEDICAL_PROVIDER_STAFF` keys. They are
2108
+ * deliberately left as-is: flipping them changes what a consumer WRITES on a
2109
+ * version bump, so that switch belongs to each consumer's own migration.
2110
+ *
2044
2111
  * Note: UNKNOWN, ANONYMOUS, and DATA_NOT_COLLECTED are intentionally excluded.
2045
2112
  * These are data quality states, not selectable participation roles.
2046
2113
  * Handle them via separate UI controls (e.g., "Unknown" / "Anonymous" buttons).
@@ -2070,6 +2137,91 @@ export const CALLER_IS_VICTIM_ROLES: IncidentParticipationRoleValue[] = [
2070
2137
  INCIDENT_PARTICIPATION_ROLE.REPORTER,
2071
2138
  ];
2072
2139
 
2140
+ /**
2141
+ * The five CVC-69 keys canon superseded on 2026-08-13, each mapped to its
2142
+ * canonical successor (SOT `incidentParticipationRoles.v1.1.0.json`:
2143
+ * `deprecated: true` + `supersededBy`).
2144
+ *
2145
+ * A superseded key is still a VALID STORED VALUE: it stays in
2146
+ * `INCIDENT_PARTICIPATION_ROLE_VALUES`, keeps its label, and still resolves in
2147
+ * the seeded registry — nothing persisted has to be rewritten. It is only no
2148
+ * longer offered for NEW writes (`selectable: false` in the SOT;
2149
+ * `ACTIVE_INCIDENT_PARTICIPATION_ROLE_VALUES` below).
2150
+ *
2151
+ * The mapping is canon's rename ruling, not a guarantee of identical meaning:
2152
+ * `other_incident_responder` was labelled "VSP or Other Incident Responder",
2153
+ * while `other_response_personnel` excludes VSP staff. Normalising for display
2154
+ * or grouping is safe; a one-way data migration should review that key.
2155
+ */
2156
+ export const INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY = {
2157
+ [INCIDENT_PARTICIPATION_ROLE.SERVICE_PROVIDER_STAFF]:
2158
+ INCIDENT_PARTICIPATION_ROLE.VSP_STAFF,
2159
+ [INCIDENT_PARTICIPATION_ROLE.MEDICAL_PROVIDER_STAFF]:
2160
+ INCIDENT_PARTICIPATION_ROLE.HEALTHCARE_PROVIDER_STAFF,
2161
+ [INCIDENT_PARTICIPATION_ROLE.DATA_ENTRY]:
2162
+ INCIDENT_PARTICIPATION_ROLE.DATA_ENTRY_STAFF,
2163
+ [INCIDENT_PARTICIPATION_ROLE.OTHER_INCIDENT_RESPONDER]:
2164
+ INCIDENT_PARTICIPATION_ROLE.OTHER_RESPONSE_PERSONNEL,
2165
+ [INCIDENT_PARTICIPATION_ROLE.RESPONDING_OFFICER]:
2166
+ INCIDENT_PARTICIPATION_ROLE.LAW_ENFORCEMENT_PERSONNEL,
2167
+ } as const satisfies Partial<
2168
+ Record<IncidentParticipationRoleValue, IncidentParticipationRoleValue>
2169
+ >;
2170
+
2171
+ export type DeprecatedIncidentParticipationRoleValue =
2172
+ keyof typeof INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY;
2173
+
2174
+ /** `true` iff `role` is a superseded (read-only) CVC-69 key. */
2175
+ export function isDeprecatedIncidentParticipationRole(
2176
+ role: unknown,
2177
+ ): role is DeprecatedIncidentParticipationRoleValue {
2178
+ return (
2179
+ typeof role === "string" &&
2180
+ Object.prototype.hasOwnProperty.call(
2181
+ INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY,
2182
+ role,
2183
+ )
2184
+ );
2185
+ }
2186
+
2187
+ /**
2188
+ * The canonical CVC-69 key for a stored value: the successor of a superseded
2189
+ * key, otherwise the value unchanged. Pure; never validates — an unknown
2190
+ * string is returned as-is.
2191
+ */
2192
+ export function canonicalIncidentParticipationRole<T extends string>(
2193
+ role: T,
2194
+ ): T | IncidentParticipationRoleValue {
2195
+ return isDeprecatedIncidentParticipationRole(role)
2196
+ ? INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY[role]
2197
+ : role;
2198
+ }
2199
+
2200
+ /** A CVC-69 value that may be written fresh: any value except the five superseded keys. */
2201
+ export type ActiveIncidentParticipationRoleValue = Exclude<
2202
+ IncidentParticipationRoleValue,
2203
+ DeprecatedIncidentParticipationRoleValue
2204
+ >;
2205
+
2206
+ /**
2207
+ * Every CVC-69 value that may be WRITTEN fresh:
2208
+ * `INCIDENT_PARTICIPATION_ROLE_VALUES` minus the five superseded keys. Use
2209
+ * `INCIDENT_PARTICIPATION_ROLE_VALUES` to VALIDATE stored values.
2210
+ *
2211
+ * This is not a picker list as it stands. It still contains ANONYMOUS and
2212
+ * DATA_NOT_COLLECTED, which canon never offers in a picker: ANONYMOUS is set
2213
+ * by a decline affordance and DATA_NOT_COLLECTED only by the system. The SOT
2214
+ * marks both `neverPickable`, but that flag lives in the JSON only (the
2215
+ * `cvc_entities` schema does not persist it), so a picker built from this
2216
+ * list must drop the two itself.
2217
+ */
2218
+ export const ACTIVE_INCIDENT_PARTICIPATION_ROLE_VALUES = Object.freeze(
2219
+ INCIDENT_PARTICIPATION_ROLE_VALUES.filter(
2220
+ (role): role is ActiveIncidentParticipationRoleValue =>
2221
+ !isDeprecatedIncidentParticipationRole(role),
2222
+ ),
2223
+ );
2224
+
2073
2225
  // ─── Person Display Category ────────────────────────────────────────
2074
2226
  // 5 UI groupings for displaying persons based on involvement role.
2075
2227
 
@@ -2206,6 +2358,12 @@ export function getDisplayCategoryForRole(
2206
2358
 
2207
2359
  // ─── Default Participation Roles by Display Category ───────────────
2208
2360
  // When toggling "Involved" on, these are the default participation roles.
2361
+ //
2362
+ // NOT YET RE-KEYED: PERSONNEL still defaults to the superseded
2363
+ // `SERVICE_PROVIDER_STAFF` (canonical successor `VSP_STAFF`). Deliberate: a
2364
+ // default decides what a consumer WRITES, so changing it here would change
2365
+ // consumer writes on a version bump. Each consumer switches to `VSP_STAFF` in
2366
+ // its own repin. Same for `PARTICIPATION_ROLE_CATEGORIES.SYSTEM_PROFESSIONAL`.
2209
2367
 
2210
2368
  export const DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY: Record<
2211
2369
  PersonDisplayCategoryValue,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "domain": "highest_education_level_completed",
3
3
  "name": "Core Highest Education Level Completed",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "levels": {
6
6
  "0": "Unknown or Missing",
7
7
  "1": "Education level"