@htilabs/platform-common-models 0.8.16 → 0.8.18

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 (51) hide show
  1. package/dist/constants/index.cjs +3 -1
  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 +3 -1
  6. package/dist/constants/index.js.map +1 -1
  7. package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-DaDrEuTa.d.cts} +44 -44
  8. package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-DaDrEuTa.d.ts} +44 -44
  9. package/dist/cvcs/index.cjs +4348 -17
  10. package/dist/cvcs/index.cjs.map +1 -1
  11. package/dist/cvcs/index.d.cts +10835 -6179
  12. package/dist/cvcs/index.d.ts +10835 -6179
  13. package/dist/cvcs/index.js +8776 -4447
  14. package/dist/cvcs/index.js.map +1 -1
  15. package/dist/{index-CDoqrfc1.d.ts → index-C0J3f169.d.ts} +1 -1
  16. package/dist/{index-Zu_mOJRn.d.cts → index-EPjPjR0z.d.cts} +1 -1
  17. package/dist/index.cjs +4690 -20
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +353 -8
  20. package/dist/index.d.ts +353 -8
  21. package/dist/index.js +4686 -20
  22. package/dist/index.js.map +1 -1
  23. package/dist/models/index.d.cts +2 -2
  24. package/dist/models/index.d.ts +2 -2
  25. package/dist/{platform-auth-AsfnIXfK.d.cts → platform-auth-CvQkzOy1.d.cts} +1 -1
  26. package/dist/{platform-auth-AsfnIXfK.d.ts → platform-auth-CvQkzOy1.d.ts} +1 -1
  27. package/dist/schemas/index.cjs.map +1 -1
  28. package/dist/schemas/index.d.cts +35 -35
  29. package/dist/schemas/index.d.ts +35 -35
  30. package/dist/schemas/index.js.map +1 -1
  31. package/dist/types/index.d.cts +2 -2
  32. package/dist/types/index.d.ts +2 -2
  33. package/package.json +26 -25
  34. package/src/__sot__/README.md +36 -1
  35. package/src/__sot__/coreIndicatorFields.ts +331 -0
  36. package/src/__sot__/coreIndicators.pin.json +1931 -2
  37. package/src/__sot__/cvcIndex.pin.json +8 -4
  38. package/src/__tests__/__snapshots__/cvc-sot.snap +8 -4
  39. package/src/__tests__/core-information-scope-invariant.test.ts +134 -0
  40. package/src/__tests__/cvc-136-scoring-invariant.test.ts +7 -5
  41. package/src/__tests__/cvc-181-182-country-parity.test.ts +163 -0
  42. package/src/__tests__/cvc-drift-gate.test.ts +392 -9
  43. package/src/__tests__/cvc-sot-snapshot.test.ts +17 -4
  44. package/src/__tests__/cvc-structural.test.ts +2 -0
  45. package/src/constants/ic.ts +88 -4
  46. package/src/cvcs/coreIndicators.v1.0.0.json +18 -5
  47. package/src/cvcs/coreInformationScope.v1.0.0.json +1165 -0
  48. package/src/cvcs/countries.v1.0.0.json +3077 -0
  49. package/src/cvcs/index.ts +4 -0
  50. package/src/cvcs/sharePurpose.v1.0.0.json +80 -12
  51. package/src/generated/cvc-enums.ts +352 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sourceRepo": "htilabstech/prototype",
3
3
  "sourceFile": "Final CVCs/CVC_INDEX.md",
4
- "sourceSha": "a596eb9",
4
+ "sourceSha": "622410b",
5
5
  "numbers": {
6
6
  "1": [
7
7
  "core - name_type"
@@ -59,6 +59,12 @@
59
59
  "85": [
60
60
  "core - share_cadence"
61
61
  ],
62
+ "93": [
63
+ "core - child_welfare_involvement_status"
64
+ ],
65
+ "95": [
66
+ "core - juvenile_justice_involvement_status"
67
+ ],
62
68
  "96": [
63
69
  "core - homeless_status"
64
70
  ],
@@ -187,7 +193,6 @@
187
193
  "core - frequency : cadence"
188
194
  ],
189
195
  "177": [
190
- "core - administering jurisdiction",
191
196
  "core - administering_jurisdiction"
192
197
  ],
193
198
  "179": [
@@ -219,8 +224,7 @@
219
224
  "core collection context"
220
225
  ],
221
226
  "196": [
222
- "core child welfare cvc",
223
- "core child welfare episode type CVC"
227
+ "core - child_welfare_episode_type"
224
228
  ],
225
229
  "197": [
226
230
  "core - juvenile_justice_episode_type"
@@ -99,8 +99,8 @@
99
99
  "hash": "c3fcaec7ef08f185748463adc1e73dc6a1ff196601f16a6453f737577f3dfd90"
100
100
  },
101
101
  "share_purpose": {
102
- "count": 8,
103
- "hash": "ccefed1af82759ca59ad45e3850119db87e3411db57d9ce3039d874474498422"
102
+ "count": 12,
103
+ "hash": "a3ecb1ffab4f32c5cd19afbc43278f0de0538c608464ae434595a7ff98552f65"
104
104
  },
105
105
  "facilitator_entity_type": {
106
106
  "count": 14,
@@ -599,8 +599,8 @@
599
599
  "hash": "90aec290aa586a9bbc098c0c8a19536e06b705b054e4444ff6461a9913340a5c"
600
600
  },
601
601
  "core_indicators": {
602
- "count": 219,
603
- "hash": "b389bf68c84985e66445ac9a42b5c98ca36f10592dc820f909fc4e71c7f421bc"
602
+ "count": 220,
603
+ "hash": "634ba69f31273bace3c3be9509aba41f4c348086210905e42a6f97d393c64fbb"
604
604
  },
605
605
  "risk_severity_band": {
606
606
  "count": 9,
@@ -666,6 +666,10 @@
666
666
  "count": 253,
667
667
  "hash": "83962425a6a987b46bd89f596feefe5758f25993137010bb417823b83c4ae31f"
668
668
  },
669
+ "countries": {
670
+ "count": 254,
671
+ "hash": "21525c56d5bac7f218bcb9a5dc048eea4b9132cfaf4a6a7439ebbf7dd34ebcde"
672
+ },
669
673
  "trafficking_relevant_role": {
670
674
  "count": 8,
671
675
  "hash": "1a4ea2992cc501179adafd192d7a2f1733ffe48c1ba26e1e61a3c757b2d62b32"
@@ -0,0 +1,134 @@
1
+ /**
2
+ * CORE INFORMATION SCOPE (CVC-236) — the invariants adoption depends on
3
+ * ==================================================================
4
+ *
5
+ * Two vocabularies describe the same thing at different grains:
6
+ *
7
+ * `roi_scope` flat item vocabulary, 27 substantive keys, no category axis
8
+ * `core_information_scope` 12 policy-grain CATEGORIES + 54 authorization-grain UNITS
9
+ *
10
+ * PAVE and Thread are both pinned to `roi_scope` today, and both persist stored
11
+ * ROIs against it. Migrating them to this domain is safe for exactly one reason:
12
+ * every substantive `roi_scope` key survives here, spelled identically, so a
13
+ * stored ROI keeps its exact recorded meaning. That is not a nice-to-have — an
14
+ * ROI whose meaning widens is a CONSENT change wearing a data change's clothes,
15
+ * and one already shipped on the CaseShare lane when a coarse->granular table
16
+ * expanded `caseNotes` to include screening notes the survivor never authorized.
17
+ *
18
+ * So the subset property below is the whole basis for calling adoption additive.
19
+ * If it ever fails, adoption stops being a migration and becomes a re-consent.
20
+ *
21
+ * The grain invariants matter for a different reason: canon states that
22
+ * categories are the POLICY grain and units are the AUTHORIZATION grain. A
23
+ * selectable category would let a policy row be cited as if it were consent.
24
+ */
25
+
26
+ import { readFileSync } from "node:fs";
27
+ import path from "node:path";
28
+ import { fileURLToPath } from "node:url";
29
+
30
+ import { describe, it, expect } from "vitest";
31
+
32
+ const here = path.dirname(fileURLToPath(import.meta.url));
33
+ const cvcDir = path.join(here, "..", "cvcs");
34
+
35
+ interface Entry {
36
+ code: string;
37
+ key: string;
38
+ selectable: boolean;
39
+ parentCode: string | null;
40
+ childCodes: string[];
41
+ shareableDefault?: boolean;
42
+ required?: boolean;
43
+ platformFloor?: boolean;
44
+ }
45
+
46
+ const read = (f: string): { entries: Entry[]; levels: Record<string, string> } =>
47
+ JSON.parse(readFileSync(path.join(cvcDir, f), "utf8")) as {
48
+ entries: Entry[];
49
+ levels: Record<string, string>;
50
+ };
51
+
52
+ const scope = read("coreInformationScope.v1.0.0.json");
53
+ const roi = read("roiScope.v1.0.0.json");
54
+
55
+ const byCode = new Map(scope.entries.map((e) => [e.code, e]));
56
+ const MISSINGNESS = new Set([
57
+ "missingness_root",
58
+ "unknown",
59
+ "anonymous",
60
+ "data_not_collected",
61
+ ]);
62
+
63
+ const isMissingness = (e: Entry): boolean =>
64
+ MISSINGNESS.has(e.key) ||
65
+ (e.parentCode !== null && byCode.get(e.parentCode)?.key === "missingness_root");
66
+
67
+ const categories = scope.entries.filter(
68
+ (e) => e.parentCode === null && !isMissingness(e),
69
+ );
70
+ const units = scope.entries.filter(
71
+ (e) => e.parentCode !== null && !isMissingness(e),
72
+ );
73
+
74
+ describe("core_information_scope — adoption invariants", () => {
75
+ it("carries every substantive roi_scope key, spelled identically", () => {
76
+ const roiSubstantive = roi.entries
77
+ .map((e) => e.key)
78
+ .filter((k) => !MISSINGNESS.has(k));
79
+ const unitKeys = new Set(units.map((u) => u.key));
80
+ const missing = roiSubstantive.filter((k) => !unitKeys.has(k));
81
+
82
+ // A failure here means a stored ROI can no longer be expressed in the new
83
+ // vocabulary — re-consent, not migration.
84
+ expect(missing).toEqual([]);
85
+ expect(roiSubstantive.length).toBe(27);
86
+ });
87
+
88
+ it("is a strict superset — the additions are additions, not renames", () => {
89
+ expect(units.length).toBeGreaterThan(27);
90
+ expect(units).toHaveLength(54);
91
+ });
92
+
93
+ it("keeps the two grains distinct: categories decide policy, units carry consent", () => {
94
+ expect(categories).toHaveLength(12);
95
+ expect(categories.every((c) => c.selectable === false)).toBe(true);
96
+ expect(units.every((u) => u.selectable === true)).toBe(true);
97
+ });
98
+
99
+ it("wires every unit to exactly one category, reciprocally", () => {
100
+ for (const u of units) {
101
+ const parent = byCode.get(u.parentCode as string);
102
+ expect(parent, `unit ${u.key} has a dangling parent`).toBeDefined();
103
+ expect(parent?.selectable, `unit ${u.key} hangs off a selectable row`).toBe(
104
+ false,
105
+ );
106
+ expect(parent?.childCodes, `category ${parent?.key} disowns ${u.key}`).toContain(
107
+ u.code,
108
+ );
109
+ }
110
+ expect(categories.flatMap((c) => c.childCodes)).toHaveLength(units.length);
111
+ });
112
+
113
+ it("publishes the posture sets as data, so they stop being literals", () => {
114
+ const of = (p: (u: Entry) => boolean): string[] =>
115
+ units.filter(p).map((u) => u.key).sort();
116
+
117
+ // shareable_default:false — the picker must not pre-check these.
118
+ expect(of((u) => u.shareableDefault === false)).toEqual([
119
+ "federal_protection_applications",
120
+ "hiv_status",
121
+ "immigration_status",
122
+ "le_report_status",
123
+ "safe_locations",
124
+ "tvap_enrollment",
125
+ "uscis_alien_number",
126
+ ]);
127
+
128
+ // The platform safety floor — enforceable BELOW the scope layer.
129
+ expect(of((u) => u.platformFloor === true)).toEqual(["safe_locations"]);
130
+
131
+ // Always included; currently a hardcoded string in both apps.
132
+ expect(of((u) => u.required === true)).toEqual(["system_info"]);
133
+ });
134
+ });
@@ -261,12 +261,14 @@ describe("CVC-136 core_indicators", () => {
261
261
  ]);
262
262
  });
263
263
 
264
- it("has exactly 215 substantive codes (213 canonical + 2 scoring-ahead)", () => {
264
+ it("has exactly 216 substantive codes (214 canonical + 2 scoring-ahead)", () => {
265
265
  // 0.8.14 refreshed the catalog pin a596eb9 (208) -> 84a1b67 (213):
266
- // +5 upstream mints, 0 withdrawn. The 2 scoring-ahead codes are unchanged
267
- // and still absent upstream.
268
- expect(substantive.length).toBe(215);
269
- expect(envelope.entries.length).toBe(219);
266
+ // +5 upstream mints, 0 withdrawn.
267
+ // This refresh took it again 84a1b67 (213) -> 622410b (214): +1 upstream
268
+ // mint (`active_protective_order`, minted 2026-08-08), 0 withdrawn. The 2
269
+ // scoring-ahead codes are unchanged and still absent upstream.
270
+ expect(substantive.length).toBe(216);
271
+ expect(envelope.entries.length).toBe(220);
270
272
  });
271
273
 
272
274
  it("has no duplicate keys", () => {
@@ -0,0 +1,163 @@
1
+ /**
2
+ * CVC-181 `countries` <-> CVC-182 `citizenship` — the country-set parity lock
3
+ * ==========================================================================
4
+ *
5
+ * Two canonical codebooks enumerate the SAME 249 ISO 3166-1 countries:
6
+ *
7
+ * `core - countries` (CVC-181) the neutral entity list. Its own `.md` says it is
8
+ * "designed for use across multiple contexts (e.g.
9
+ * country of citizenship, country of origin, or
10
+ * country of residence)".
11
+ * `core - citizenship` (CVC-182) the citizenship-flavoured list, authored first
12
+ * (0.8.13) because CVC-181 was unpublished.
13
+ *
14
+ * Consumers bound to CVC-182 as a DRAFT stand-in for birth country must be able to
15
+ * re-point at CVC-181 as an import swap with **zero key renames** — that is the whole
16
+ * reason CVC-181 was minted from a key derivation identical to CVC-182's rather than a
17
+ * fresh one. This test is that promise, made falsifiable. If it fails, the re-point is
18
+ * a data migration, not an import swap, and every stored birth-country key is suspect.
19
+ *
20
+ * What it does NOT assert: positional-code parity. `181-NNN` and `182-NNN` disagree on
21
+ * 20 countries because the two upstream exports sort under different collations, and
22
+ * each domain is deliberately minted in ITS OWN codebook's row order so each stays
23
+ * reproducible from its own source. The KEY is the reconciliation axis (consumers
24
+ * persist keys, not wire codes). The last assertion below pins that divergence in place
25
+ * so nobody "fixes" it into a silent renumber, and so nobody writes
26
+ * `"181-" + code.slice(4)` believing the two are interchangeable.
27
+ */
28
+
29
+ import { readFileSync } from "node:fs";
30
+ import path from "node:path";
31
+ import { fileURLToPath } from "node:url";
32
+
33
+ import { describe, it, expect } from "vitest";
34
+
35
+ const here = path.dirname(fileURLToPath(import.meta.url));
36
+ const cvcDir = path.join(here, "..", "cvcs");
37
+
38
+ interface Entry {
39
+ code: string;
40
+ key: string;
41
+ title: string;
42
+ selectable: boolean;
43
+ definition: string | null;
44
+ iso31661Alpha2?: string | null;
45
+ priority?: boolean;
46
+ canonicalLabel?: string | null;
47
+ localExtension?: boolean;
48
+ }
49
+
50
+ const read = (f: string): { domain: string; entries: Entry[] } =>
51
+ JSON.parse(readFileSync(path.join(cvcDir, f), "utf8")) as {
52
+ domain: string;
53
+ entries: Entry[];
54
+ };
55
+
56
+ const countries = read("countries.v1.0.0.json");
57
+ const citizenship = read("citizenship.v1.0.0.json");
58
+
59
+ const isMissingness = (e: Entry): boolean => e.code.split("-")[1] === "000";
60
+ const substantive = (d: { entries: Entry[] }): Entry[] =>
61
+ d.entries.filter((e) => !isMissingness(e));
62
+
63
+ /** The 10 PRIORITY_COUNTRIES of the canonical prototype HTML, by ISO alpha-2. */
64
+ const PRIORITY_ISO = ["CN", "CU", "DO", "GT", "IN", "KR", "MX", "PH", "SV", "VN"];
65
+
66
+ describe("CVC-181 / CVC-182 country parity", () => {
67
+ it("both domains carry the identical 249 country key -> ISO map", () => {
68
+ const map = (d: { entries: Entry[] }): Record<string, string> =>
69
+ Object.fromEntries(
70
+ d.entries
71
+ .filter((e) => e.iso31661Alpha2)
72
+ .map((e) => [e.key, e.iso31661Alpha2!]),
73
+ );
74
+ const a = map(countries);
75
+ const b = map(citizenship);
76
+ expect(Object.keys(a).length, "CVC-181 ISO-coded leaves").toBe(249);
77
+ expect(Object.keys(b).length, "CVC-182 ISO-coded leaves").toBe(249);
78
+ expect(a).toEqual(b);
79
+ });
80
+
81
+ it("CVC-181 adds EXACTLY ONE substantive leaf over CVC-182: non_us_unspecified", () => {
82
+ const a = new Set(substantive(countries).map((e) => e.key));
83
+ const b = new Set(substantive(citizenship).map((e) => e.key));
84
+ const added = [...a].filter((k) => !b.has(k)).sort();
85
+ const dropped = [...b].filter((k) => !a.has(k)).sort();
86
+ expect(added, "substantive keys CVC-181 has that CVC-182 does not").toEqual([
87
+ "non_us_unspecified",
88
+ ]);
89
+ expect(dropped, "substantive keys CVC-182 has that CVC-181 does not").toEqual([]);
90
+ });
91
+
92
+ it("non_us_unspecified is a FLAGGED local extension, not a smuggled canonical value", () => {
93
+ // The escape hatch is guarded the way GATE B guards SCORING_AHEAD_OF_CATALOG:
94
+ // a codebook-absent leaf must announce itself, or the next verification run
95
+ // cannot tell an upstream gap from a platform-common invention.
96
+ const e = countries.entries.find((x) => x.key === "non_us_unspecified");
97
+ expect(e, "non_us_unspecified must exist").toBeDefined();
98
+ expect(e!.localExtension, "must carry localExtension: true").toBe(true);
99
+ expect(e!.definition ?? "").toMatch(/^LOCAL EXTENSION \(not in canonical CVC-181\)\./);
100
+ expect(e!.selectable).toBe(true);
101
+ expect(e!.iso31661Alpha2 ?? null, "a non-country leaf carries no ISO code").toBeNull();
102
+ // It is the ONLY local extension in this domain.
103
+ expect(countries.entries.filter((x) => x.localExtension).map((x) => x.key)).toEqual([
104
+ "non_us_unspecified",
105
+ ]);
106
+ });
107
+
108
+ it("CVC-181 priority flags are EXACTLY the canonical PRIORITY_COUNTRIES, and no sentinel", () => {
109
+ const flagged = countries.entries.filter((e) => e.priority);
110
+ expect(flagged.map((e) => e.iso31661Alpha2).sort()).toEqual([...PRIORITY_ISO].sort());
111
+ // CVC-182 additionally flags `unknown` + `anonymous` because ITS codebook has a
112
+ // Priority column that says Yes on those rows. CVC-181's codebook has no Priority
113
+ // column at all, and PRIORITY_COUNTRIES contains countries only — so flagging a
114
+ // sentinel here would be an invention. The COUNTRY flags must still agree.
115
+ expect(flagged.every((e) => !isMissingness(e)), "no missingness sentinel is priority").toBe(
116
+ true,
117
+ );
118
+ const flaggedCountryKeys = (d: { entries: Entry[] }): string[] =>
119
+ d.entries
120
+ .filter((e) => e.priority && e.iso31661Alpha2)
121
+ .map((e) => e.key)
122
+ .sort();
123
+ expect(flaggedCountryKeys(countries)).toEqual(flaggedCountryKeys(citizenship));
124
+ });
125
+
126
+ it("positional ordinals deliberately DIVERGE on 20 countries — reconcile by key, not by code", () => {
127
+ const ordinals = (d: { entries: Entry[] }): Map<string, string> =>
128
+ new Map(
129
+ d.entries.filter((e) => e.iso31661Alpha2).map((e) => [e.key, e.code.split("-")[1]!]),
130
+ );
131
+ const a = ordinals(countries);
132
+ const b = ordinals(citizenship);
133
+ const divergent = [...a.keys()].filter((k) => a.get(k) !== b.get(k)).sort();
134
+ expect(
135
+ divergent.length,
136
+ "if this changes, one of the two domains was renumbered — that is a wire-format " +
137
+ "change and needs its own decision, not a silent regeneration",
138
+ ).toBe(20);
139
+ // All 20 are adjacent-pair swaps between the two upstream sort collations.
140
+ expect(divergent).toEqual([
141
+ "germany",
142
+ "ghana",
143
+ "isle_of_man",
144
+ "israel",
145
+ "japan",
146
+ "jersey",
147
+ "lao_people_s_democratic_republic",
148
+ "latvia",
149
+ "rwanda",
150
+ "saint_barthelemy",
151
+ "seychelles",
152
+ "sierra_leone",
153
+ "south_sudan",
154
+ "spain",
155
+ "sweden",
156
+ "switzerland",
157
+ "tanzania_united_republic_of",
158
+ "thailand",
159
+ "tuvalu",
160
+ "uganda",
161
+ ]);
162
+ });
163
+ });