@htilabs/platform-common-models 0.13.1 → 0.15.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/dist/constants/index.cjs +33 -0
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +29 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-DaDrEuTa.d.cts} +44 -44
- package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-DaDrEuTa.d.ts} +44 -44
- package/dist/cvcs/index.cjs +212 -38
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +224 -41
- package/dist/cvcs/index.d.ts +224 -41
- package/dist/cvcs/index.js +212 -38
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +8 -1
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +11 -4
- package/dist/enums/index.d.ts +11 -4
- package/dist/enums/index.js +8 -1
- package/dist/enums/index.js.map +1 -1
- package/dist/{index-CDoqrfc1.d.ts → index-C0J3f169.d.ts} +1 -1
- package/dist/{index-Zu_mOJRn.d.cts → index-EPjPjR0z.d.cts} +1 -1
- package/dist/index.cjs +253 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +249 -39
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/{platform-auth-64U8jjuw.d.cts → platform-auth-CrF5U_JH.d.cts} +43 -2
- package/dist/{platform-auth-64U8jjuw.d.ts → platform-auth-CrF5U_JH.d.ts} +43 -2
- package/dist/schemas/index.cjs +234 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +35 -35
- package/dist/schemas/index.d.ts +35 -35
- package/dist/schemas/index.js +234 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +27 -26
- package/src/__sot__/coreIndicatorFields.ts +4 -4
- package/src/__sot__/coreIndicators.pin.json +62 -2
- package/src/__sot__/scoringEmits.pin.json +9 -4
- package/src/__tests__/__snapshots__/cvc-sot.snap +4 -4
- package/src/__tests__/core-information-scope-invariant.test.ts +204 -15
- package/src/__tests__/cvc-136-scoring-invariant.test.ts +89 -28
- package/src/__tests__/cvc-drift-gate.test.ts +149 -27
- package/src/__tests__/cvc-sot-snapshot.test.ts +14 -8
- package/src/__tests__/cvc-structural.test.ts +2 -2
- package/src/__tests__/location-type-routing-invariant.test.ts +1 -1
- package/src/constants/ic.ts +163 -3
- package/src/cvcs/{coreIndicators.v1.0.0.json → coreIndicators.v1.1.0.json} +93 -10
- package/src/cvcs/{coreInformationScope.v1.0.0.json → coreInformationScope.v1.1.0.json} +113 -22
- package/src/cvcs/index.ts +2 -2
- package/src/generated/cvc-enums.ts +11 -4
|
@@ -5,7 +5,8 @@
|
|
|
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 +
|
|
8
|
+
* `core_information_scope` 12 policy-grain CATEGORIES + 55 authorization-grain UNITS
|
|
9
|
+
* (+ 2 RETIRED tombstones, 2026-10-05)
|
|
9
10
|
*
|
|
10
11
|
* PAVE and Thread are both pinned to `roi_scope` today, and both persist stored
|
|
11
12
|
* ROIs against it. Migrating them to this domain is safe for exactly one reason:
|
|
@@ -44,6 +45,7 @@ interface Entry {
|
|
|
44
45
|
levelFloor?: number;
|
|
45
46
|
appRelevance?: string[];
|
|
46
47
|
specialDataType?: string;
|
|
48
|
+
retired?: boolean;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
const read = (f: string): { entries: Entry[]; levels: Record<string, string> } =>
|
|
@@ -52,7 +54,7 @@ const read = (f: string): { entries: Entry[]; levels: Record<string, string> } =
|
|
|
52
54
|
levels: Record<string, string>;
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
const scope = read("coreInformationScope.v1.
|
|
57
|
+
const scope = read("coreInformationScope.v1.1.0.json");
|
|
56
58
|
const roi = read("roiScope.v1.0.0.json");
|
|
57
59
|
|
|
58
60
|
const byCode = new Map(scope.entries.map((e) => [e.code, e]));
|
|
@@ -70,16 +72,22 @@ const isMissingness = (e: Entry): boolean =>
|
|
|
70
72
|
const categories = scope.entries.filter(
|
|
71
73
|
(e) => e.parentCode === null && !isMissingness(e),
|
|
72
74
|
);
|
|
73
|
-
|
|
75
|
+
/** Every L2 row: live units AND retired tombstones. */
|
|
76
|
+
const allUnits = scope.entries.filter(
|
|
74
77
|
(e) => e.parentCode !== null && !isMissingness(e),
|
|
75
78
|
);
|
|
79
|
+
/** Live, authorizable units — what a picker offers. */
|
|
80
|
+
const units = allUnits.filter((e) => e.retired !== true);
|
|
81
|
+
/** Retired tombstones — resolvable by code, include nothing, never offered. */
|
|
82
|
+
const tombstones = allUnits.filter((e) => e.retired === true);
|
|
76
83
|
|
|
77
84
|
describe("core_information_scope — adoption invariants", () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
const roiSubstantive = roi.entries
|
|
86
|
+
.map((e) => e.key)
|
|
87
|
+
.filter((k) => !MISSINGNESS.has(k));
|
|
88
|
+
|
|
89
|
+
it("resolves every substantive roi_scope key, spelled identically", () => {
|
|
90
|
+
const unitKeys = new Set(allUnits.map((u) => u.key));
|
|
83
91
|
const missing = roiSubstantive.filter((k) => !unitKeys.has(k));
|
|
84
92
|
|
|
85
93
|
// A failure here means a stored ROI can no longer be expressed in the new
|
|
@@ -88,19 +96,39 @@ describe("core_information_scope — adoption invariants", () => {
|
|
|
88
96
|
expect(roiSubstantive.length).toBe(27);
|
|
89
97
|
});
|
|
90
98
|
|
|
99
|
+
it("retires exactly the two roi_scope keys canon retired, and no other", () => {
|
|
100
|
+
// NARRATIVE-NOTES 2026-10-05 (signed Spec v2 rule 5): screen_notes and
|
|
101
|
+
// background are retired. A stored ROI naming one still RESOLVES (to a
|
|
102
|
+
// tombstone that includes nothing) — it narrows, it never widens, and
|
|
103
|
+
// canon records that only demo data named them. Any OTHER roi_scope key
|
|
104
|
+
// landing on a tombstone would be an unruled narrowing of stored consent.
|
|
105
|
+
const live = new Set(units.map((u) => u.key));
|
|
106
|
+
expect(roiSubstantive.filter((k) => !live.has(k)).sort()).toEqual([
|
|
107
|
+
"background",
|
|
108
|
+
"screen_notes",
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
|
|
91
112
|
it("is a strict superset — the additions are additions, not renames", () => {
|
|
92
113
|
expect(units.length).toBeGreaterThan(27);
|
|
93
|
-
expect(units).toHaveLength(
|
|
114
|
+
expect(units).toHaveLength(55);
|
|
115
|
+
expect(tombstones).toHaveLength(2);
|
|
94
116
|
});
|
|
95
117
|
|
|
96
118
|
it("keeps the two grains distinct: categories decide policy, units carry consent", () => {
|
|
97
119
|
expect(categories).toHaveLength(12);
|
|
98
120
|
expect(categories.every((c) => c.selectable === false)).toBe(true);
|
|
99
121
|
expect(units.every((u) => u.selectable === true)).toBe(true);
|
|
122
|
+
// A tombstone is never authorizable — selectable would let a retired
|
|
123
|
+
// code be cited as consent again.
|
|
124
|
+
expect(tombstones.every((t) => t.selectable === false)).toBe(true);
|
|
100
125
|
});
|
|
101
126
|
|
|
102
|
-
it("wires every unit to exactly one category, reciprocally", () => {
|
|
103
|
-
|
|
127
|
+
it("wires every unit — tombstones included — to exactly one category, reciprocally", () => {
|
|
128
|
+
// Tombstones stay in their category's childCodes: the locked spec §4 C4
|
|
129
|
+
// invariant makes childCodes the exact inverse of parentCode. Pickers
|
|
130
|
+
// offer only selectable children.
|
|
131
|
+
for (const u of allUnits) {
|
|
104
132
|
const parent = byCode.get(u.parentCode as string);
|
|
105
133
|
expect(parent, `unit ${u.key} has a dangling parent`).toBeDefined();
|
|
106
134
|
expect(parent?.selectable, `unit ${u.key} hangs off a selectable row`).toBe(
|
|
@@ -110,7 +138,7 @@ describe("core_information_scope — adoption invariants", () => {
|
|
|
110
138
|
u.code,
|
|
111
139
|
);
|
|
112
140
|
}
|
|
113
|
-
expect(categories.flatMap((c) => c.childCodes)).toHaveLength(
|
|
141
|
+
expect(categories.flatMap((c) => c.childCodes)).toHaveLength(allUnits.length);
|
|
114
142
|
});
|
|
115
143
|
|
|
116
144
|
it("publishes the posture sets as data, so they stop being literals", () => {
|
|
@@ -170,7 +198,9 @@ const PUBLISHED: ReadonlyArray<readonly [string, readonly string[]]> = [
|
|
|
170
198
|
],
|
|
171
199
|
["contact", ["contact_info", "safe_locations", "priorities_safety", "encounter_location"]],
|
|
172
200
|
["services", ["contact_history", "service_history", "plans_goals"]],
|
|
173
|
-
|
|
201
|
+
// screen_notes (-001) and background (-003) are RETIRED tombstones since
|
|
202
|
+
// 2026-10-05 — they keep their codes; session_summary APPENDED at -004.
|
|
203
|
+
["notes", ["screen_notes", "case_notes", "background", "session_summary"]],
|
|
174
204
|
[
|
|
175
205
|
"health_accommodation",
|
|
176
206
|
[
|
|
@@ -209,7 +239,7 @@ const byKey = new Map(scope.entries.map((e) => [e.key, e]));
|
|
|
209
239
|
|
|
210
240
|
describe("core_information_scope — published codes never move", () => {
|
|
211
241
|
it("keeps every published category and unit at its frozen positional code", () => {
|
|
212
|
-
const actual = [...categories, ...
|
|
242
|
+
const actual = [...categories, ...allUnits].map((e): [string, string] => [e.key, e.code]);
|
|
213
243
|
const expected = PUBLISHED.flatMap(([cat, us], ci): [string, string][] => [
|
|
214
244
|
[cat, codeOf(ci + 1)],
|
|
215
245
|
...us.map((u, ui): [string, string] => [u, codeOf(ci + 1, ui + 1)]),
|
|
@@ -319,7 +349,7 @@ describe("core_information_scope — encounter_location (2026-10-01)", () => {
|
|
|
319
349
|
*/
|
|
320
350
|
describe("core_information_scope — safe_locations ratified (2026-09-08)", () => {
|
|
321
351
|
const raw = JSON.parse(
|
|
322
|
-
readFileSync(path.join(cvcDir, "coreInformationScope.v1.
|
|
352
|
+
readFileSync(path.join(cvcDir, "coreInformationScope.v1.1.0.json"), "utf8"),
|
|
323
353
|
) as { _status: string; entries: (Entry & { title: string; definition: string })[] };
|
|
324
354
|
const unit = raw.entries.find((e) => e.key === "safe_locations");
|
|
325
355
|
|
|
@@ -337,3 +367,162 @@ describe("core_information_scope — safe_locations ratified (2026-09-08)", () =
|
|
|
337
367
|
expect(raw._status).toContain("`safe_locations` is CANON");
|
|
338
368
|
});
|
|
339
369
|
});
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Narrative notes — canon CVC-236 amendment 2026-10-05 (NARRATIVE-NOTES,
|
|
373
|
+
* signed Spec v2 rule 5, Crysta; prototype `data/cvcs/
|
|
374
|
+
* core_information_scope.yaml` @ 9ef79748, lines 445-467). The category now
|
|
375
|
+
* offers two units, Session summary and Session & case notes; `screen_notes`
|
|
376
|
+
* and `background` are listed in `retired_units`. Canon lists session_summary
|
|
377
|
+
* FIRST, but codes follow the generator's frozen ledger, so no published
|
|
378
|
+
* ordinal moves and no retired ordinal is reused.
|
|
379
|
+
*/
|
|
380
|
+
describe("core_information_scope — narrative notes (2026-10-05)", () => {
|
|
381
|
+
const raw = JSON.parse(
|
|
382
|
+
readFileSync(path.join(cvcDir, "coreInformationScope.v1.1.0.json"), "utf8"),
|
|
383
|
+
) as { entries: (Entry & { title: string; definition: string })[] };
|
|
384
|
+
const rawByKey = new Map(raw.entries.map((e) => [e.key, e]));
|
|
385
|
+
const notes = byKey.get("notes");
|
|
386
|
+
|
|
387
|
+
it("keeps screen_notes and background as RETIRED tombstones at their published codes", () => {
|
|
388
|
+
for (const [key, code, title] of [
|
|
389
|
+
["screen_notes", "236-005-001-000-000-000-000", "Screen notes"],
|
|
390
|
+
["background", "236-005-003-000-000-000-000", "Background information"],
|
|
391
|
+
] as const) {
|
|
392
|
+
const t = rawByKey.get(key);
|
|
393
|
+
expect(t?.code, key).toBe(code);
|
|
394
|
+
expect(t?.title, key).toBe(title);
|
|
395
|
+
expect(t?.retired, key).toBe(true);
|
|
396
|
+
expect(t?.selectable, key).toBe(false);
|
|
397
|
+
expect(t?.parentCode, key).toBe(notes?.code);
|
|
398
|
+
expect(t?.childCodes, key).toEqual([]);
|
|
399
|
+
expect(t?.definition, key).toMatch(/^RETIRED 2026-10-05 /);
|
|
400
|
+
expect(t?.definition, key).toContain("includes nothing");
|
|
401
|
+
// Nothing left to share or view: no decision attributes a picker or a
|
|
402
|
+
// share builder could act on.
|
|
403
|
+
for (const attr of [
|
|
404
|
+
"shareableDefault",
|
|
405
|
+
"levelFloor",
|
|
406
|
+
"appRelevance",
|
|
407
|
+
"specialDataType",
|
|
408
|
+
"platformFloor",
|
|
409
|
+
"required",
|
|
410
|
+
] as const) {
|
|
411
|
+
expect(t?.[attr], `${key}.${attr}`).toBeUndefined();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it("keeps case_notes at 236-005-002 under canon's new label", () => {
|
|
417
|
+
const u = rawByKey.get("case_notes");
|
|
418
|
+
expect(u?.code).toBe("236-005-002-000-000-000-000");
|
|
419
|
+
expect(u?.title).toBe("Session & case notes");
|
|
420
|
+
expect(u?.selectable).toBe(true);
|
|
421
|
+
expect(u?.retired).toBeUndefined();
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it("APPENDS session_summary at 236-005-004 — never at a retired slot", () => {
|
|
425
|
+
const u = rawByKey.get("session_summary");
|
|
426
|
+
expect(u?.code).toBe("236-005-004-000-000-000-000");
|
|
427
|
+
expect(u?.title).toBe("Session summary");
|
|
428
|
+
expect(u?.selectable).toBe(true);
|
|
429
|
+
expect(u?.parentCode).toBe(notes?.code);
|
|
430
|
+
expect(u?.shareableDefault).toBe(true);
|
|
431
|
+
expect(u?.levelFloor).toBe(3);
|
|
432
|
+
expect(u?.specialDataType).toBe("survivor_confidential");
|
|
433
|
+
expect(u?.appRelevance).toEqual(["PAVE", "Thread"]);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it("lists the category's children in code order, tombstones included, two of them live", () => {
|
|
437
|
+
expect(notes?.childCodes).toEqual([
|
|
438
|
+
"236-005-001-000-000-000-000",
|
|
439
|
+
"236-005-002-000-000-000-000",
|
|
440
|
+
"236-005-003-000-000-000-000",
|
|
441
|
+
"236-005-004-000-000-000-000",
|
|
442
|
+
]);
|
|
443
|
+
const liveKids = (notes?.childCodes ?? [])
|
|
444
|
+
.map((c) => byCode.get(c))
|
|
445
|
+
.filter((e) => e?.selectable === true)
|
|
446
|
+
.map((e) => e?.key);
|
|
447
|
+
expect(liveKids).toEqual(["case_notes", "session_summary"]);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it("tombstones only what canon retired — no other unit in the domain is retired", () => {
|
|
451
|
+
expect(tombstones.map((t) => t.key).sort()).toEqual(["background", "screen_notes"]);
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* OFFENDER-SYSTEM-UNITS-THREAD — canon CVC-236 amendment 2026-10-01 (Crysta
|
|
457
|
+
* R1; prototype `data/cvcs/core_information_scope.yaml` @ 0247b654, carried
|
|
458
|
+
* by the 9ef79748 regeneration at lines 407-410). Thread captures perpetrator
|
|
459
|
+
* records and protection orders, so both risk units now list Thread. Codes
|
|
460
|
+
* and posture are unchanged; only app relevance and wording moved.
|
|
461
|
+
*/
|
|
462
|
+
describe("core_information_scope — Thread joins offender + system units (2026-10-01)", () => {
|
|
463
|
+
it("lists Thread on offender_facilitator and system_involvement, codes unchanged", () => {
|
|
464
|
+
const off = byKey.get("offender_facilitator");
|
|
465
|
+
const sys = byKey.get("system_involvement");
|
|
466
|
+
expect(off?.code).toBe("236-002-015-000-000-000-000");
|
|
467
|
+
expect(off?.appRelevance).toEqual(["PAVE", "Thread", "LEADS"]);
|
|
468
|
+
expect(sys?.code).toBe("236-002-016-000-000-000-000");
|
|
469
|
+
expect(sys?.appRelevance).toEqual(["PAVE", "Thread"]);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* SOT v1.1.0 supersedes v1.0.0 (ADR-CVC-0.8.13 Addendum 2026-10-05): the
|
|
475
|
+
* narrative-notes change is not additive — two published units lost
|
|
476
|
+
* `selectable` and `case_notes` was narrowed — so it cannot reuse 1.0.0
|
|
477
|
+
* under the seeder's §9.1.2 content-drift guard. `_supersedes` is the house
|
|
478
|
+
* shape (victimAbuseTypes / incidentParticipationRoles v1.1.0).
|
|
479
|
+
*/
|
|
480
|
+
describe("core_information_scope — v1.1.0 supersedes v1.0.0", () => {
|
|
481
|
+
const env = JSON.parse(
|
|
482
|
+
readFileSync(path.join(cvcDir, "coreInformationScope.v1.1.0.json"), "utf8"),
|
|
483
|
+
) as {
|
|
484
|
+
version: string;
|
|
485
|
+
_supersedes: {
|
|
486
|
+
version: string;
|
|
487
|
+
keyMap: Record<string, string>;
|
|
488
|
+
retiredCodes: unknown[];
|
|
489
|
+
notes: Record<string, string>;
|
|
490
|
+
};
|
|
491
|
+
entries: Entry[];
|
|
492
|
+
};
|
|
493
|
+
const sup = env._supersedes;
|
|
494
|
+
|
|
495
|
+
it("is version 1.1.0, superseding 1.0.0, with no code withdrawn", () => {
|
|
496
|
+
expect(env.version).toBe("1.1.0");
|
|
497
|
+
expect(sup.version).toBe("1.0.0");
|
|
498
|
+
// Tombstones keep their codes, so nothing is withdrawn.
|
|
499
|
+
expect(sup.retiredCodes).toEqual([]);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it("maps every v1.0.0 key to itself — every key but the one added", () => {
|
|
503
|
+
const keys = env.entries.map((e) => e.key);
|
|
504
|
+
expect(Object.keys(sup.keyMap)).toEqual(keys.filter((k) => k !== "session_summary"));
|
|
505
|
+
expect(Object.keys(sup.keyMap)).toHaveLength(72);
|
|
506
|
+
for (const [from, to] of Object.entries(sup.keyMap)) expect(to, from).toBe(from);
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
it("notes each retirement and the case_notes narrowing", () => {
|
|
510
|
+
expect(Object.keys(sup.notes).sort()).toEqual([
|
|
511
|
+
"background",
|
|
512
|
+
"case_notes",
|
|
513
|
+
"screen_notes",
|
|
514
|
+
"summary",
|
|
515
|
+
]);
|
|
516
|
+
for (const k of ["screen_notes", "background"]) {
|
|
517
|
+
expect(sup.notes[k], k).toContain("NO successor key");
|
|
518
|
+
expect(sup.notes[k], k).toContain("includes nothing");
|
|
519
|
+
}
|
|
520
|
+
expect(sup.notes["case_notes"]).toContain("reads NARROWER");
|
|
521
|
+
expect(sup.notes["case_notes"]).toContain("no longer includes the session summary");
|
|
522
|
+
expect(sup.notes["summary"]).toContain("`session_summary` (236-005-004)");
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
it("leaves no v1.0.0 file behind for the registry to resolve", () => {
|
|
526
|
+
expect(() => readFileSync(path.join(cvcDir, "coreInformationScope.v1.0.0.json"))).toThrow();
|
|
527
|
+
});
|
|
528
|
+
});
|
|
@@ -18,20 +18,25 @@
|
|
|
18
18
|
* THE PIN
|
|
19
19
|
* -------
|
|
20
20
|
* `SCORING_EMITS_BY_CODE` is the key set of `emits_by_code` in
|
|
21
|
-
* `weights/risk.weights.json` at htilabstech/hti-scoring@
|
|
21
|
+
* `weights/risk.weights.json` at htilabstech/hti-scoring@9c209cf (174 codes).
|
|
22
22
|
* It is a COMMITTED PIN, not a live read - platform-common must not take a
|
|
23
23
|
* build-time dependency on the scoring repo. When @hti/scoring starts emitting
|
|
24
24
|
* a new code, bumping this list is a deliberate, reviewable commit that forces
|
|
25
25
|
* the matching CVC-136 entry to be authored in the same PR.
|
|
26
26
|
*
|
|
27
|
-
* SCORING IS AHEAD OF THE CODEBOOK
|
|
28
|
-
*
|
|
29
|
-
* `coercive_debt_pressure_youth` and
|
|
30
|
-
* by @hti/scoring but
|
|
31
|
-
* `data/core_indicators.yaml
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
27
|
+
* SCORING IS NO LONGER AHEAD OF THE CODEBOOK (0 CODES)
|
|
28
|
+
* ----------------------------------------------------
|
|
29
|
+
* From 0.8.13 through the 622410b refresh, `coercive_debt_pressure_youth` and
|
|
30
|
+
* `debt_terms_deceptive_youth` were emitted by @hti/scoring (9b5d654) but
|
|
31
|
+
* were NOT in the prototype's canonical `data/core_indicators.yaml`. They were
|
|
32
|
+
* KEPT and flagged `pendingUpstreamAdoption: true` because dropping a code
|
|
33
|
+
* scoring emits would break the scoring contract — that is the trap this test
|
|
34
|
+
* exists to prevent. hti-scoring 9c209cf retired both emits in favour of the
|
|
35
|
+
* canonical `coercive_debt_pressure` / `debt_terms_deceptive` (whose upstream
|
|
36
|
+
* rows carry the `_youth` names as `legacy_aliases`), and the catalog never
|
|
37
|
+
* adopted them, so at c53378f / 9c209cf they are WITHDRAWN: no emitter, no
|
|
38
|
+
* catalog row, nothing left to protect. `PENDING_UPSTREAM_ADOPTION` is kept as
|
|
39
|
+
* an EMPTY list so the next genuinely-ahead emit has a named place to land.
|
|
35
40
|
*/
|
|
36
41
|
|
|
37
42
|
import { readFileSync } from "node:fs";
|
|
@@ -49,12 +54,19 @@ const SOT_FILE = path.resolve(
|
|
|
49
54
|
__dirname,
|
|
50
55
|
"..",
|
|
51
56
|
"cvcs",
|
|
52
|
-
"coreIndicators.v1.
|
|
57
|
+
"coreIndicators.v1.1.0.json",
|
|
53
58
|
);
|
|
54
59
|
|
|
55
60
|
/**
|
|
56
61
|
* `Object.keys(RISK_WEIGHTS.emits_by_code)` at
|
|
57
|
-
* htilabstech/hti-scoring@
|
|
62
|
+
* htilabstech/hti-scoring@9c209cf (weights/risk.weights.json). 174 codes.
|
|
63
|
+
* 9b5d654 -> 9c209cf: +8 (`child_welfare_system_involvement`,
|
|
64
|
+
* `clients_unaware_of_third_party_coordination`,
|
|
65
|
+
* `constraints_due_to_legal_status`,
|
|
66
|
+
* `depends_on_spouse_or_family_for_immigration_status`,
|
|
67
|
+
* `does_not_control_housing`, `juvenile_justice_system_involvement`,
|
|
68
|
+
* `oppressive_home_life`, `recent_separation`) / -3 (`living_with_abuser`,
|
|
69
|
+
* `coercive_debt_pressure_youth`, `debt_terms_deceptive_youth`).
|
|
58
70
|
* PINNED - see the module header before editing.
|
|
59
71
|
*/
|
|
60
72
|
const SCORING_EMITS_BY_CODE: readonly string[] = [
|
|
@@ -80,24 +92,27 @@ const SCORING_EMITS_BY_CODE: readonly string[] = [
|
|
|
80
92
|
"branding_or_unusual_tattoos_tied_to_control",
|
|
81
93
|
"cannot_stop_working_or_freely_leave",
|
|
82
94
|
"child_not_abusers_in_household",
|
|
95
|
+
"child_welfare_system_involvement",
|
|
96
|
+
"clients_unaware_of_third_party_coordination",
|
|
83
97
|
"coerced_to_misrepresent_identity_or_activity",
|
|
84
98
|
"coercive_debt_pressure",
|
|
85
|
-
"coercive_debt_pressure_youth",
|
|
86
99
|
"coercive_migration_or_forced_travel",
|
|
87
100
|
"cognitive_or_functional_impairment_affecting_consent",
|
|
88
101
|
"commercial_sex_association_words_or_places",
|
|
89
102
|
"concerning_mannerisms_anxious_fearful_depressed",
|
|
90
103
|
"concerning_sexual_behavior_pattern",
|
|
104
|
+
"constraints_due_to_legal_status",
|
|
91
105
|
"control_quota_required",
|
|
92
106
|
"cs_activity_criminal_org_connection",
|
|
93
107
|
"cs_industry_related_criminal_history",
|
|
94
108
|
"current_injuries_from_abuser",
|
|
95
109
|
"currently_minor_in_commercial_sex",
|
|
96
110
|
"debt_terms_deceptive",
|
|
97
|
-
"debt_terms_deceptive_youth",
|
|
98
111
|
"denied_basic_needs",
|
|
99
112
|
"depends_on_employer_for_immigration_status",
|
|
113
|
+
"depends_on_spouse_or_family_for_immigration_status",
|
|
100
114
|
"does_not_control_finances_or_earnings",
|
|
115
|
+
"does_not_control_housing",
|
|
101
116
|
"does_not_control_identity_documents",
|
|
102
117
|
"employer_keeps_pay_or_pays_less_than_expected",
|
|
103
118
|
"engages_in_commercial_sex_act",
|
|
@@ -135,11 +150,11 @@ const SCORING_EMITS_BY_CODE: readonly string[] = [
|
|
|
135
150
|
"inability_to_account_for_self",
|
|
136
151
|
"intimate_partner_violence_reported_to_law_enforcement",
|
|
137
152
|
"juvenile_justice_or_child_welfare_involvement",
|
|
153
|
+
"juvenile_justice_system_involvement",
|
|
138
154
|
"labor_services_activity_recorded",
|
|
139
155
|
"limited_english_proficiency",
|
|
140
156
|
"limited_independence",
|
|
141
157
|
"lives_or_sleeps_at_place_of_work",
|
|
142
|
-
"living_with_abuser",
|
|
143
158
|
"meets_or_has_sex_with_internet_contacts",
|
|
144
159
|
"monitored_or_isolated_by_controlling_party",
|
|
145
160
|
"much_older_intimate_partner",
|
|
@@ -148,6 +163,7 @@ const SCORING_EMITS_BY_CODE: readonly string[] = [
|
|
|
148
163
|
"new_to_commercial_sex_industry",
|
|
149
164
|
"non_consensual_photography_or_recording",
|
|
150
165
|
"not_in_control_of_immigration_documentation",
|
|
166
|
+
"oppressive_home_life",
|
|
151
167
|
"other_instability_or_vulnerability_factors",
|
|
152
168
|
"owes_money_and_cannot_pay_off",
|
|
153
169
|
"paid_or_owes_fee_to_arrange_travel_to_us",
|
|
@@ -164,6 +180,7 @@ const SCORING_EMITS_BY_CODE: readonly string[] = [
|
|
|
164
180
|
"prior_victimization_or_abuse_history",
|
|
165
181
|
"promise_of_work_different_than_current_work",
|
|
166
182
|
"received_things_of_value_while_missing_from_care",
|
|
183
|
+
"recent_separation",
|
|
167
184
|
"recruited_by_third_party_into_cs_industry",
|
|
168
185
|
"relies_on_temporary_resources_for_basic_needs",
|
|
169
186
|
"reports_physical_harm_by_employer_or_partner",
|
|
@@ -229,11 +246,11 @@ const SCORING_EMITS_BY_CODE: readonly string[] = [
|
|
|
229
246
|
"youth_watched_filmed_or_photographed_sexually_explicit",
|
|
230
247
|
];
|
|
231
248
|
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
];
|
|
249
|
+
/**
|
|
250
|
+
* Codes @hti/scoring emits that upstream `core_indicators.yaml` has not yet
|
|
251
|
+
* adopted. EMPTY as of c53378f / 9c209cf — see the module header.
|
|
252
|
+
*/
|
|
253
|
+
const PENDING_UPSTREAM_ADOPTION: readonly string[] = [];
|
|
237
254
|
|
|
238
255
|
const envelope = CvcEnvelopeSchema.parse(
|
|
239
256
|
JSON.parse(readFileSync(SOT_FILE, "utf-8")),
|
|
@@ -244,6 +261,8 @@ const substantive = envelope.entries.filter(
|
|
|
244
261
|
(e) => e.code.split("-")[1] !== "000",
|
|
245
262
|
);
|
|
246
263
|
const substantiveKeys = new Set(substantive.map((e) => e.key));
|
|
264
|
+
const isDeprecated = (e: object): boolean =>
|
|
265
|
+
(e as { deprecated?: unknown }).deprecated === true;
|
|
247
266
|
|
|
248
267
|
describe("CVC-136 core_indicators", () => {
|
|
249
268
|
it("is numbered 136 in segment 1 of every code", () => {
|
|
@@ -261,14 +280,22 @@ describe("CVC-136 core_indicators", () => {
|
|
|
261
280
|
]);
|
|
262
281
|
});
|
|
263
282
|
|
|
264
|
-
it("has exactly
|
|
283
|
+
it("has exactly 222 substantive codes (220 canonical + 0 scoring-ahead + 2 deprecated)", () => {
|
|
265
284
|
// 0.8.14 refreshed the catalog pin a596eb9 (208) -> 84a1b67 (213):
|
|
266
285
|
// +5 upstream mints, 0 withdrawn.
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
|
|
271
|
-
|
|
286
|
+
// 622410b refresh: 84a1b67 (213) -> 622410b (214): +1 upstream mint
|
|
287
|
+
// (`active_protective_order`, minted 2026-08-08), 0 withdrawn.
|
|
288
|
+
// c53378f refresh: 622410b (214) -> c53378f (220): +6 upstream mints
|
|
289
|
+
// (`disclosed_fear_at_intake`, `does_not_control_housing`,
|
|
290
|
+
// `oppressive_home_life`, `recent_separation`, `survival_sex`,
|
|
291
|
+
// `unable_to_speak_freely`), 0 withdrawn upstream; the 2 scoring-ahead
|
|
292
|
+
// `_youth` codes leave the allowlist (scoring 9c209cf no longer emits
|
|
293
|
+
// them) and become DEPRECATED read-only rows — kept because PAVE 2.0
|
|
294
|
+
// `develop` still writes both from the IDA (see the drift gate's
|
|
295
|
+
// `CVC136_DEPRECATED`). SOT version 1.0.0 -> 1.1.0 in the same change.
|
|
296
|
+
expect(substantive.length).toBe(222);
|
|
297
|
+
expect(substantive.filter((e) => !isDeprecated(e)).length).toBe(220);
|
|
298
|
+
expect(envelope.entries.length).toBe(226);
|
|
272
299
|
});
|
|
273
300
|
|
|
274
301
|
it("has no duplicate keys", () => {
|
|
@@ -277,8 +304,8 @@ describe("CVC-136 core_indicators", () => {
|
|
|
277
304
|
});
|
|
278
305
|
|
|
279
306
|
describe("CVC-136 <-> @hti/scoring emits_by_code invariant", () => {
|
|
280
|
-
it("pins exactly
|
|
281
|
-
expect(new Set(SCORING_EMITS_BY_CODE).size).toBe(
|
|
307
|
+
it("pins exactly 174 emitted codes", () => {
|
|
308
|
+
expect(new Set(SCORING_EMITS_BY_CODE).size).toBe(174);
|
|
282
309
|
});
|
|
283
310
|
|
|
284
311
|
it("EVERY code @hti/scoring emits exists in CVC-136", () => {
|
|
@@ -295,7 +322,9 @@ describe("CVC-136 <-> @hti/scoring emits_by_code invariant", () => {
|
|
|
295
322
|
expect(missing).toHaveLength(0);
|
|
296
323
|
});
|
|
297
324
|
|
|
298
|
-
it("the
|
|
325
|
+
it("the scoring-ahead list is EMPTY; any entry must be present and flagged pendingUpstreamAdoption", () => {
|
|
326
|
+
// Guard the escape hatch: scoring is not ahead of the catalog at 9c209cf.
|
|
327
|
+
expect(PENDING_UPSTREAM_ADOPTION).toEqual([]);
|
|
299
328
|
for (const code of PENDING_UPSTREAM_ADOPTION) {
|
|
300
329
|
const entry = substantive.find((e) => e.key === code);
|
|
301
330
|
expect(entry, `${code} must be present in CVC-136`).toBeDefined();
|
|
@@ -317,6 +346,38 @@ describe("CVC-136 <-> @hti/scoring emits_by_code invariant", () => {
|
|
|
317
346
|
expect(substantiveKeys.has("unusual_work_circumstances_general")).toBe(false);
|
|
318
347
|
expect(substantiveKeys.has("unusual_work_circumstances")).toBe(true);
|
|
319
348
|
});
|
|
349
|
+
|
|
350
|
+
it("the former `_youth` scoring-ahead codes are DEPRECATED (read-only, superseded), never live; their canonical rows ship", () => {
|
|
351
|
+
// hti-scoring 9c209cf retired these emits and the catalog never adopted
|
|
352
|
+
// them — but PAVE 2.0 `develop` @ 07f3ccd still writes both from the IDA
|
|
353
|
+
// (`IDA-syn-missing_care-4i`/`-4ii`), so the keys stay resolvable here as
|
|
354
|
+
// deprecated rows pointing at their canonical successors.
|
|
355
|
+
for (const [key, successor] of [
|
|
356
|
+
["coercive_debt_pressure_youth", "coercive_debt_pressure"],
|
|
357
|
+
["debt_terms_deceptive_youth", "debt_terms_deceptive"],
|
|
358
|
+
] as const) {
|
|
359
|
+
const row = substantive.find((e) => e.key === key) as
|
|
360
|
+
| (typeof substantive)[number] & { deprecated?: unknown; supersededBy?: unknown }
|
|
361
|
+
| undefined;
|
|
362
|
+
expect(row, `${key} must still resolve`).toBeDefined();
|
|
363
|
+
expect(row!.selectable).toBe(false);
|
|
364
|
+
expect(row!.deprecated).toBe(true);
|
|
365
|
+
expect(row!.supersededBy).toBe(successor);
|
|
366
|
+
expect(SCORING_EMITS_BY_CODE, `${key} is not emitted`).not.toContain(key);
|
|
367
|
+
expect(substantiveKeys.has(successor)).toBe(true);
|
|
368
|
+
expect(SCORING_EMITS_BY_CODE, `${successor} is emitted`).toContain(successor);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it("the hardcoded emit set is identical to scoringEmits.pin.json (one SoT, pinned twice on purpose)", () => {
|
|
373
|
+
// Two declarations of the 174-code emit set exist — this hand-pinned list
|
|
374
|
+
// (so a pin-file edit alone cannot move the invariant) and the generated
|
|
375
|
+
// pin — and they must never drift apart.
|
|
376
|
+
const pin = JSON.parse(
|
|
377
|
+
readFileSync(path.resolve(__dirname, "..", "__sot__", "scoringEmits.pin.json"), "utf8"),
|
|
378
|
+
) as { codes: string[] };
|
|
379
|
+
expect([...SCORING_EMITS_BY_CODE].sort()).toEqual([...pin.codes].sort());
|
|
380
|
+
});
|
|
320
381
|
});
|
|
321
382
|
|
|
322
383
|
describe("CVC-136 SOT JSON <-> hand-coded ic.ts array", () => {
|