@htilabs/platform-common-models 0.12.3 → 0.13.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htilabs/platform-common-models",
3
- "version": "0.12.3",
3
+ "version": "0.13.0",
4
4
  "description": "Shared constants, types, and models for HTI Labs applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -156,7 +156,7 @@
156
156
  },
157
157
  "location_type": {
158
158
  "count": 17,
159
- "hash": "72d6fd6e89c8ffd2f2ab1682a3ed2ea52d73cfb41c635f7af6334078c0f4b959"
159
+ "hash": "18375cd14466851a6bcbd9bf3c37c28568d77cf6e26dc9ec76fa297900e9fbe6"
160
160
  },
161
161
  "referral_entity_category": {
162
162
  "count": 43,
@@ -491,8 +491,8 @@
491
491
  "hash": "93b7a0f327edbc77553c7ebee01f3ac59e1fe9b939cc930588d88704efd8274f"
492
492
  },
493
493
  "victim_abuse_types": {
494
- "count": 29,
495
- "hash": "03ce0a04e8a2ea49b39aaa45a7b11a2a9feb457637c6c6620a46fcb83e041442"
494
+ "count": 30,
495
+ "hash": "43ae622bb332e730aa3c8d9a6ba3d563d7f472b286bb21478c52509b881e64c6"
496
496
  },
497
497
  "ht_type": {
498
498
  "count": 8,
@@ -703,8 +703,8 @@
703
703
  "hash": "9d8972c65373a9981aab6b8749661659ecc632004e67bc9c2b3c88aa76f30977"
704
704
  },
705
705
  "core_information_scope": {
706
- "count": 71,
707
- "hash": "30fbeeefc9515e5efbfff6dded12fafb554fe47590d217ccc5b51aef83eafaf9"
706
+ "count": 72,
707
+ "hash": "9269401b4bcefccfffc490899bcd4c6faf021383ec6c5a0fda5680ed888eaf49"
708
708
  }
709
709
  }
710
710
  }
@@ -5,7 +5,7 @@
5
5
  * Two vocabularies describe the same thing at different grains:
6
6
  *
7
7
  * `roi_scope` flat item vocabulary, 27 substantive keys, no category axis
8
- * `core_information_scope` 12 policy-grain CATEGORIES + 55 authorization-grain UNITS
8
+ * `core_information_scope` 12 policy-grain CATEGORIES + 56 authorization-grain UNITS
9
9
  *
10
10
  * PAVE and Thread are both pinned to `roi_scope` today, and both persist stored
11
11
  * ROIs against it. Migrating them to this domain is safe for exactly one reason:
@@ -90,7 +90,7 @@ describe("core_information_scope — adoption invariants", () => {
90
90
 
91
91
  it("is a strict superset — the additions are additions, not renames", () => {
92
92
  expect(units.length).toBeGreaterThan(27);
93
- expect(units).toHaveLength(55);
93
+ expect(units).toHaveLength(56);
94
94
  });
95
95
 
96
96
  it("keeps the two grains distinct: categories decide policy, units carry consent", () => {
@@ -168,7 +168,7 @@ const PUBLISHED: ReadonlyArray<readonly [string, readonly string[]]> = [
168
168
  "derived_risk_signals",
169
169
  ],
170
170
  ],
171
- ["contact", ["contact_info", "safe_locations", "priorities_safety"]],
171
+ ["contact", ["contact_info", "safe_locations", "priorities_safety", "encounter_location"]],
172
172
  ["services", ["contact_history", "service_history", "plans_goals"]],
173
173
  ["notes", ["screen_notes", "case_notes", "background"]],
174
174
  [
@@ -255,3 +255,85 @@ describe("core_information_scope — priorities_safety (2026-09-29)", () => {
255
255
  expect(unit?.appRelevance).toEqual(["PAVE", "Thread"]);
256
256
  });
257
257
  });
258
+
259
+ /**
260
+ * `encounter_location` — canon CVC-236 amendment 2026-10-01
261
+ * (LOCATION-TYPE-LOGIC, Crysta R2; prototype `data/cvcs/
262
+ * core_information_scope.yaml` @ 55088d44). The session's own location
263
+ * entries — where the advocate met the survivor, or where the incident
264
+ * happened (CVC-191 reasons MEET_LOC + INCIDENT) — belonged to no person, so no
265
+ * share could reach them, and Thread was sending every session location under
266
+ * the `addresses` pick. They now ride this one unit.
267
+ */
268
+ describe("core_information_scope — encounter_location (2026-10-01)", () => {
269
+ const unit = byKey.get("encounter_location");
270
+
271
+ it("is ONE selectable unit under Contact & safety, appended at the next contact slot", () => {
272
+ expect(unit).toBeDefined();
273
+ expect(unit?.code).toBe("236-003-004-000-000-000-000");
274
+ expect(unit?.selectable).toBe(true);
275
+ expect(unit?.parentCode).toBe(byKey.get("contact")?.code);
276
+ // Appended after priorities_safety: no published contact code moved.
277
+ expect(byKey.get("contact")?.childCodes).toEqual([
278
+ "236-003-001-000-000-000-000",
279
+ "236-003-002-000-000-000-000",
280
+ "236-003-003-000-000-000-000",
281
+ "236-003-004-000-000-000-000",
282
+ ]);
283
+ // R2: one new unit. No second "residence" unit — residence vs. incident
284
+ // is already split by the CVC-191 reason.
285
+ expect(
286
+ scope.entries.filter((e) => e.key.includes("encounter")).map((e) => e.key),
287
+ ).toEqual(["encounter_location"]);
288
+ });
289
+
290
+ it("carries canon's posture: shareable by default, never the platform floor", () => {
291
+ // R2: where the survivor was found or met is the safety fact the next
292
+ // advocate needs, so the picker pre-checks it.
293
+ expect(unit?.shareableDefault).toBe(true);
294
+ // The floor stays on safe_locations alone; a shelter address picked as an
295
+ // encounter location is still caught by the floor, not by this unit.
296
+ expect(unit?.platformFloor).toBeUndefined();
297
+ expect(unit?.required).toBeUndefined();
298
+ expect(unit?.levelFloor).toBe(3);
299
+ expect(unit?.specialDataType).toBe("survivor_confidential");
300
+ expect(unit?.appRelevance).toEqual(["PAVE", "Thread"]);
301
+ });
302
+
303
+ it("leaves addresses where it was: the survivor's own whereabouts keep riding it", () => {
304
+ // R3: addresses keeps its code and posture; only its definition gains the
305
+ // type-grain routing note.
306
+ const addresses = byKey.get("addresses");
307
+ expect(addresses?.code).toBe("236-001-003-000-000-000-000");
308
+ expect(addresses?.shareableDefault).toBe(true);
309
+ expect(addresses?.platformFloor).toBeUndefined();
310
+ });
311
+ });
312
+
313
+ /**
314
+ * `safe_locations` — RATIFIED 2026-09-08 (CVC236-AUDIT R1, Crysta; prototype
315
+ * `data/cvcs/core_information_scope.yaml` @ 46a60114, lines 72-75 + 310-311).
316
+ * The id and label are canon and the row is minted in the Notion codebook, so
317
+ * the PROVISIONAL marker the package published from 2026-08-18 is retired.
318
+ * The code, label and posture did not change: only the wording did.
319
+ */
320
+ describe("core_information_scope — safe_locations ratified (2026-09-08)", () => {
321
+ const raw = JSON.parse(
322
+ readFileSync(path.join(cvcDir, "coreInformationScope.v1.0.0.json"), "utf8"),
323
+ ) as { _status: string; entries: (Entry & { title: string; definition: string })[] };
324
+ const unit = raw.entries.find((e) => e.key === "safe_locations");
325
+
326
+ it("keeps its published code, label and platform-floor posture", () => {
327
+ expect(unit?.code).toBe("236-003-002-000-000-000-000");
328
+ expect(unit?.title).toBe("Safe & confidential locations");
329
+ expect(unit?.platformFloor).toBe(true);
330
+ expect(unit?.shareableDefault).toBe(false);
331
+ });
332
+
333
+ it("no longer reads as provisional, in its definition or in the domain status", () => {
334
+ expect(unit?.definition).not.toMatch(/PROVISIONAL vocabulary/);
335
+ expect(unit?.definition).toContain("RATIFIED 2026-09-08 (CVC236-AUDIT R1, Crysta)");
336
+ expect(raw._status).not.toMatch(/`safe_locations` is PROVISIONAL/);
337
+ expect(raw._status).toContain("`safe_locations` is CANON");
338
+ });
339
+ });
@@ -573,9 +573,12 @@ const SOT_SPECS: readonly SotSpec[] = [
573
573
  // missingness root + 3 canonical missingness children = 9. Entries carry
574
574
  // an `hmisCode` passthrough field (HMIS numerics 1/2/3/4/5/99).
575
575
  { file: "hmisRelationshipToHoh.v1.0.0.json", domain: "hmis_relationship_to_hoh", expectedCount: 9 },
576
- // CVC-73 victim_abuse_types — 25 non-HT VOCA abuse types + 1 missingness
577
- // root + 3 canonical missingness children = 29.
578
- { file: "victimAbuseTypes.v1.0.0.json", domain: "victim_abuse_types", expectedCount: 29 },
576
+ // CVC-73 victim_abuse_types — canon v1.1's 30 victimization / abuse types
577
+ // and NO missingness (canon: "MISSINGNESS: deliberately none"; its gate G3
578
+ // fails on UNK/ANON/DNC). v1.1.0 supersedes the stale 29-entry v1.0.0
579
+ // (25 funder-dialect types + 4 missingness); see
580
+ // victim-abuse-types-canon.test.ts for the key-set pin.
581
+ { file: "victimAbuseTypes.v1.1.0.json", domain: "victim_abuse_types", expectedCount: 30 },
579
582
  // CVC-72 ht_type — 4 substantive types (sex, labor, sex_and_labor, none;
580
583
  // `none` = negative determination, canonical per Crysta directive 2026-05-27)
581
584
  // + 1 missingness root + 3 canonical missingness children = 8.
@@ -724,14 +727,15 @@ const SOT_SPECS: readonly SotSpec[] = [
724
727
  // 3 substantive age bands (@pave/domain AGE_BANDS_AT_EVENT minus `unknown`,
725
728
  // which maps to the missingness sentinel) + 4 missingness = 7
726
729
  { file: "minorAdultStatus.v1.0.0.json", domain: "minor_adult_status", expectedCount: 7 },
727
- // CVC-236 — 12 policy-grain categories + 55 authorization-grain units
728
- // (priorities_safety, 236-003-003, added 2026-09-29) + 1 missingness root + 3
729
- // workspace-standard missingness children = 71. Generated by
730
+ // CVC-236 — 12 policy-grain categories + 56 authorization-grain units
731
+ // (priorities_safety, 236-003-003, added 2026-09-29; encounter_location,
732
+ // 236-003-004, added 2026-10-01) + 1 missingness root + 3
733
+ // workspace-standard missingness children = 72. Generated by
730
734
  // scripts/gen-core-information-scope.py; codes are FROZEN there.
731
735
  {
732
736
  file: "coreInformationScope.v1.0.0.json",
733
737
  domain: "core_information_scope",
734
- expectedCount: 71,
738
+ expectedCount: 72,
735
739
  },
736
740
  ] as const;
737
741
 
@@ -174,7 +174,7 @@ const SOT_FILES: readonly SotFile[] = [
174
174
  { file: "livingSituation.v1.0.0.json", expectedDomain: "living_situation" },
175
175
  { file: "serviceAudience.v1.0.0.json", expectedDomain: "service_audience" },
176
176
  { file: "hmisRelationshipToHoh.v1.0.0.json", expectedDomain: "hmis_relationship_to_hoh" },
177
- { file: "victimAbuseTypes.v1.0.0.json", expectedDomain: "victim_abuse_types" },
177
+ { file: "victimAbuseTypes.v1.1.0.json", expectedDomain: "victim_abuse_types" },
178
178
  { file: "htType.v1.0.0.json", expectedDomain: "ht_type" },
179
179
  { file: "relationshipConcern.v1.0.0.json", expectedDomain: "relationship_concern" },
180
180
  { file: "recencyBand.v1.0.0.json", expectedDomain: "recency_band" },
@@ -0,0 +1,202 @@
1
+ /**
2
+ * LOCATION TYPE (CVC-191) — the location reason carries the share routing
3
+ * ======================================================================
4
+ *
5
+ * Canon amendment 2026-10-01 (LOCATION-TYPE-LOGIC, Crysta R1–R4; prototype
6
+ * `data/cvcs/core_location_type.yaml` + the `Final CVCs/Location (IC-4)`
7
+ * codebook extracts @ 55088d44). Every location reason declares five columns:
8
+ * tier · anchors · anchor default · the CVC-236 unit it rides on a share ·
9
+ * safety default. Share routing for the address family moved from the
10
+ * assertion-domain grain (every location under `addresses`) to the TYPE grain:
11
+ * a stored location is delivered under the unit its reason names, and a reason
12
+ * that names nothing is never delivered.
13
+ *
14
+ * That makes `shareUnit` a consent fact. A reason that silently starts riding a
15
+ * broader unit sends a location the survivor never authorized for that pick, so
16
+ * the full routing table is pinned here, not just its shape.
17
+ *
18
+ * `scripts/gen-location-type.py` OVERLAYS these columns on the rows published
19
+ * 2026-04-22. It never adds, removes, re-keys or renumbers a row. Canon's eight
20
+ * rows the package does not publish (the trafficking, birthplace and legal
21
+ * reasons ratified 2026-08-28) are reported by that script, not absorbed.
22
+ */
23
+
24
+ import { readFileSync } from "node:fs";
25
+ import path from "node:path";
26
+ import { fileURLToPath } from "node:url";
27
+
28
+ import { describe, it, expect } from "vitest";
29
+
30
+ const here = path.dirname(fileURLToPath(import.meta.url));
31
+ const cvcDir = path.join(here, "..", "cvcs");
32
+
33
+ interface Entry {
34
+ code: string;
35
+ key: string;
36
+ selectable: boolean;
37
+ parentCode: string | null;
38
+ tier?: string;
39
+ anchors?: string[];
40
+ anchorDefault?: string | null;
41
+ shareUnit?: string | null;
42
+ safetyDefault?: string | null;
43
+ }
44
+
45
+ const read = (f: string): { entries: Entry[]; _source?: string } =>
46
+ JSON.parse(readFileSync(path.join(cvcDir, f), "utf8")) as {
47
+ entries: Entry[];
48
+ _source?: string;
49
+ };
50
+
51
+ const lt = read("locationType.v1.0.0.json");
52
+ const scope = read("coreInformationScope.v1.0.0.json");
53
+ const byKey = new Map(lt.entries.map((e) => [e.key, e]));
54
+ const scopeByKey = new Map(scope.entries.map((e) => [e.key, e]));
55
+ const reasons = lt.entries.filter((e) => e.key !== "missingness_root");
56
+
57
+ const SENTINELS = ["unknown", "anonymous", "data_not_collected"];
58
+
59
+ /**
60
+ * The published rows, at their frozen positional codes. The overlay may not
61
+ * move them; a new canon row joins only by appending, in its own change.
62
+ */
63
+ const PUBLISHED: ReadonlyArray<readonly [string, string]> = [
64
+ ["191-000-000-000-000-000-000", "missingness_root"],
65
+ ["191-000-000-000-000-000-001", "unknown"],
66
+ ["191-000-000-000-000-000-002", "anonymous"],
67
+ ["191-000-000-000-000-000-003", "data_not_collected"],
68
+ ["191-001-000-000-000-000-000", "current_residence"],
69
+ ["191-002-000-000-000-000-000", "service_delivery_location"],
70
+ ["191-003-000-000-000-000-000", "current_client_location"],
71
+ ["191-004-000-000-000-000-000", "meet_contact_location"],
72
+ ["191-005-000-000-000-000-000", "prior_residence"],
73
+ ["191-006-000-000-000-000-000", "jurisdiction_routing_location"],
74
+ ["191-007-000-000-000-000-000", "ad_location_derived"],
75
+ ["191-008-000-000-000-000-000", "travel_stop_visit"],
76
+ ["191-009-000-000-000-000-000", "work_school_business"],
77
+ ["191-010-000-000-000-000-000", "ip_derived_location"],
78
+ ["191-011-000-000-000-000-000", "program_project_location"],
79
+ ["191-012-000-000-000-000-000", "other"],
80
+ ["191-013-000-000-000-000-000", "incident"],
81
+ ];
82
+
83
+ /**
84
+ * Canon's routing for every published reason (the codebook's "Rides on a share
85
+ * (CVC-236)" column, R1). `null` = never delivered on a share.
86
+ */
87
+ const ROUTING: Record<string, string | null> = {
88
+ unknown: null,
89
+ anonymous: null,
90
+ data_not_collected: null,
91
+ current_residence: "addresses",
92
+ prior_residence: "addresses",
93
+ current_client_location: "addresses",
94
+ jurisdiction_routing_location: "addresses",
95
+ travel_stop_visit: "addresses",
96
+ work_school_business: "addresses",
97
+ other: "addresses",
98
+ meet_contact_location: "encounter_location",
99
+ incident: "encounter_location",
100
+ service_delivery_location: "service_history",
101
+ program_project_location: null,
102
+ ad_location_derived: "commercial_activity",
103
+ ip_derived_location: "commercial_activity",
104
+ };
105
+
106
+ describe("location_type — published rows never move", () => {
107
+ it("keeps every published row at its frozen code, and adds none", () => {
108
+ expect(lt.entries.map((e) => [e.code, e.key])).toEqual(PUBLISHED);
109
+ });
110
+
111
+ it("pins the overlay's provenance to canon, and names what it did not absorb", () => {
112
+ expect(lt._source).toContain("data/cvcs/core_location_type.yaml @ 55088d44");
113
+ expect(lt._source).toContain("NOT absorbed: 8 canon rows");
114
+ });
115
+ });
116
+
117
+ describe("location_type — every reason declares the five logic columns", () => {
118
+ it("carries all five columns on every reason, and none on the missingness root", () => {
119
+ for (const e of reasons) {
120
+ for (const f of ["tier", "anchors", "anchorDefault", "shareUnit", "safetyDefault"]) {
121
+ expect(e, `${e.key} lacks ${f}`).toHaveProperty(f);
122
+ }
123
+ }
124
+ expect(byKey.get("missingness_root")).not.toHaveProperty("tier");
125
+ });
126
+
127
+ it("draws each column from canon's closed value sets", () => {
128
+ const TIERS = ["residence", "encounter", "trafficking", "legal", "service", "derived", "sentinel"];
129
+ const ANCHORS = ["person", "session", "event", "service_instance", "agency_program"];
130
+ for (const e of reasons) {
131
+ expect(TIERS, e.key).toContain(e.tier);
132
+ for (const a of e.anchors ?? []) expect(ANCHORS, e.key).toContain(a);
133
+ expect([null, "ask", "unsafe", "safe"], e.key).toContain(e.safetyDefault);
134
+ }
135
+ });
136
+
137
+ it("lands a bare pick on one of the reason's own anchors", () => {
138
+ for (const e of reasons) {
139
+ if (e.anchorDefault === null) continue;
140
+ expect(e.anchors, e.key).toContain(e.anchorDefault);
141
+ }
142
+ });
143
+
144
+ it("treats the missingness sentinels as carrying no place", () => {
145
+ for (const k of SENTINELS) {
146
+ const e = byKey.get(k);
147
+ expect(e?.tier).toBe("sentinel");
148
+ expect(e?.anchors).toEqual([]);
149
+ expect(e?.anchorDefault).toBeNull();
150
+ expect(e?.shareUnit).toBeNull();
151
+ expect(e?.safetyDefault).toBeNull();
152
+ }
153
+ });
154
+ });
155
+
156
+ describe("location_type — share routing at type grain (R1/R2)", () => {
157
+ it("routes every published reason exactly as canon declares", () => {
158
+ expect(Object.fromEntries(reasons.map((e) => [e.key, e.shareUnit]))).toEqual(ROUTING);
159
+ });
160
+
161
+ it("names only CVC-236 keys the package publishes", () => {
162
+ for (const e of reasons) {
163
+ if (e.shareUnit === null) continue;
164
+ expect(scopeByKey.has(e.shareUnit as string), `${e.key} -> ${e.shareUnit}`).toBe(true);
165
+ }
166
+ });
167
+
168
+ it("names an authorization-grain UNIT, except canon's two LEADS-only derived reasons", () => {
169
+ // Canon's column names the category `commercial_activity` (not one of its
170
+ // units) for the two machine-derived reasons. Carried verbatim; a consumer
171
+ // authorizing at unit grain must resolve it as the category.
172
+ const isCategory = (k: string): boolean => scopeByKey.get(k)?.selectable === false;
173
+ const atCategory = reasons
174
+ .filter((e) => e.shareUnit !== null && isCategory(e.shareUnit as string))
175
+ .map((e) => e.key)
176
+ .sort();
177
+ expect(atCategory).toEqual(["ad_location_derived", "ip_derived_location"]);
178
+ });
179
+
180
+ it("sends only the session/event encounter reasons under encounter_location", () => {
181
+ const enc = reasons.filter((e) => e.shareUnit === "encounter_location");
182
+ expect(enc.map((e) => e.key).sort()).toEqual(["incident", "meet_contact_location"]);
183
+ // Meet / contact is the session card's Meetup role: session-anchored by default.
184
+ expect(byKey.get("meet_contact_location")?.anchorDefault).toBe("session");
185
+ expect(byKey.get("incident")?.anchorDefault).toBe("event");
186
+ expect(scopeByKey.get("encounter_location")?.selectable).toBe(true);
187
+ });
188
+
189
+ it("never delivers the agency's own program site, and presets it safe (R3)", () => {
190
+ const prog = byKey.get("program_project_location");
191
+ expect(prog?.shareUnit).toBeNull();
192
+ expect(prog?.anchors).toEqual(["agency_program"]);
193
+ expect(prog?.safetyDefault).toBe("safe");
194
+ });
195
+
196
+ it("keeps the survivor's own whereabouts on addresses", () => {
197
+ for (const k of ["current_client_location", "travel_stop_visit", "current_residence"]) {
198
+ expect(byKey.get(k)?.shareUnit, k).toBe("addresses");
199
+ expect(byKey.get(k)?.anchorDefault, k).toBe("person");
200
+ }
201
+ });
202
+ });