@htilabs/platform-common-models 0.8.24 → 0.12.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/config/index.cjs +81 -0
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +79 -4
- package/dist/config/index.d.ts +79 -4
- package/dist/config/index.js +79 -1
- package/dist/config/index.js.map +1 -1
- package/dist/constants/index.cjs +2 -18
- 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 +2 -18
- package/dist/constants/index.js.map +1 -1
- package/dist/{cvcEntry-ctHTp2df.d.cts → cvcEntry-BCj1OWqL.d.cts} +44 -44
- package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-BCj1OWqL.d.ts} +44 -44
- package/dist/cvcs/index.cjs +217 -6674
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +8057 -15024
- package/dist/cvcs/index.d.ts +8057 -15024
- package/dist/cvcs/index.js +217 -6662
- package/dist/cvcs/index.js.map +1 -1
- package/dist/{index-qreOzXYS.d.cts → index-CoVr1jIV.d.cts} +1 -1
- package/dist/{index-4DiJrn7y.d.ts → index-I-DiX9eQ.d.ts} +1 -1
- package/dist/index.cjs +230 -7217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -588
- package/dist/index.d.ts +26 -588
- package/dist/index.js +230 -7193
- 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/mongo/index.cjs +1 -0
- package/dist/mongo/index.cjs.map +1 -1
- package/dist/mongo/index.js +2 -1
- package/dist/mongo/index.js.map +1 -1
- package/dist/{platform-auth-91Hcl8F8.d.cts → platform-auth-v53r3BhN.d.cts} +3 -4
- package/dist/{platform-auth-91Hcl8F8.d.ts → platform-auth-v53r3BhN.d.ts} +3 -4
- package/dist/schemas/index.cjs +1 -5
- 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 +1 -5
- 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/dist/validation/index.cjs +0 -58
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +283 -82
- package/dist/validation/index.d.ts +283 -82
- package/dist/validation/index.js +0 -57
- package/dist/validation/index.js.map +1 -1
- package/package.json +22 -26
- package/src/__sot__/README.md +1 -36
- package/src/__sot__/coreIndicators.pin.json +2 -1936
- package/src/__sot__/cvcIndex.pin.json +4 -8
- package/src/__tests__/__snapshots__/cvc-sot.snap +13 -41
- package/src/__tests__/cvc-136-scoring-invariant.test.ts +3 -8
- package/src/__tests__/cvc-drift-gate.test.ts +12 -445
- package/src/__tests__/cvc-sot-snapshot.test.ts +11 -73
- package/src/__tests__/cvc-structural.test.ts +0 -14
- package/src/__tests__/runtime-contract-validator.test.ts +325 -1
- package/src/config/index.ts +189 -4
- package/src/constants/ic.ts +3 -120
- package/src/cvcs/assertionDomain.v1.1.0.json +1 -19
- package/src/cvcs/coreIndicators.v1.0.0.json +5 -83
- package/src/cvcs/incidentParticipationRoles.v1.0.0.json +1 -11
- package/src/cvcs/index.ts +0 -32
- package/src/cvcs/personRelationships.v1.0.0.json +2 -67
- package/src/cvcs/relationshipConcern.v1.0.0.json +19 -28
- package/src/cvcs/sessionTemplate.v1.0.0.json +0 -22
- package/src/cvcs/sharePurpose.v1.0.0.json +12 -80
- package/src/generated/cvc-enums.ts +20 -606
- package/src/validation/index.ts +0 -1
- package/dist/cvc-C7qdsXYK.d.cts +0 -298
- package/dist/cvc-C7qdsXYK.d.ts +0 -298
- package/src/__sot__/coreIndicatorFields.ts +0 -331
- package/src/__tests__/core-information-scope-invariant.test.ts +0 -134
- package/src/__tests__/cvc-181-182-country-parity.test.ts +0 -163
- package/src/__tests__/cvc-status-parser.test.ts +0 -150
- package/src/cvcs/assertionStatus.v1.0.0.json +0 -80
- package/src/cvcs/carCorrectionReason.v1.0.0.json +0 -89
- package/src/cvcs/caseShareState.v1.0.0.json +0 -62
- package/src/cvcs/coreInformationScope.v1.0.0.json +0 -1165
- package/src/cvcs/countries.v1.0.0.json +0 -3077
- package/src/cvcs/createdBySystem.v1.0.0.json +0 -89
- package/src/cvcs/criminalOrgCategory.v1.0.0.json +0 -116
- package/src/cvcs/determinationHelperCategories.v1.0.0.json +0 -1166
- package/src/cvcs/minorAdultStatus.v1.0.0.json +0 -80
- package/src/cvcs/referralOrigin.v1.0.0.json +0 -26
- package/src/cvcs/riskIdentificationMilestone.v1.0.0.json +0 -109
- package/src/cvcs/subjectType.v1.0.0.json +0 -80
- package/src/validation/cvcStatus.ts +0 -209
|
@@ -24,12 +24,6 @@
|
|
|
24
24
|
* - A false "CVC-69 is broken" conclusion, caused by comparing an ENTRY count
|
|
25
25
|
* against a SELECTABLE count (assertion F).
|
|
26
26
|
*
|
|
27
|
-
* And then the gate itself had a blind spot, because the coreIndicators pin held
|
|
28
|
-
* only a SET OF CODE NAMES. Two consecutive refreshes each shipped half their
|
|
29
|
-
* delta — 0.8.14 dropped a definition revision, 0.8.17 dropped a label rename
|
|
30
|
-
* plus a deprecation qualifier — and both passed green. Assertion H closes it:
|
|
31
|
-
* the pin now carries what the catalog SAYS about each code, field by field.
|
|
32
|
-
*
|
|
33
27
|
* Every assertion below maps to a real bug that shipped. This test is HERMETIC:
|
|
34
28
|
* it reads only the committed pins in `src/__sot__/`, so it runs on every PR with
|
|
35
29
|
* no cross-repo auth. The pins are refreshed (and upstream drift is detected) by
|
|
@@ -46,16 +40,6 @@ import { fileURLToPath } from "node:url";
|
|
|
46
40
|
|
|
47
41
|
import { describe, it, expect } from "vitest";
|
|
48
42
|
|
|
49
|
-
import {
|
|
50
|
-
LEAKED_HEX_ESCAPE,
|
|
51
|
-
NORMALIZATION_EXEMPTIONS,
|
|
52
|
-
PROJECTED_FIELDS,
|
|
53
|
-
normalizeCatalogValue,
|
|
54
|
-
normalizeSotValue,
|
|
55
|
-
projectSotEntry,
|
|
56
|
-
} from "../__sot__/coreIndicatorFields.js";
|
|
57
|
-
import type { ProjectedIndicatorFields } from "../__sot__/coreIndicatorFields.js";
|
|
58
|
-
|
|
59
43
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
60
44
|
const CVCS_DIR = path.resolve(__dirname, "..", "cvcs");
|
|
61
45
|
const SOT_DIR = path.resolve(__dirname, "..", "__sot__");
|
|
@@ -72,7 +56,7 @@ const cvcIndexPin = JSON.parse(
|
|
|
72
56
|
) as Pin & { numbers: Record<string, string[]> };
|
|
73
57
|
const coreIndicatorsPin = JSON.parse(
|
|
74
58
|
readFileSync(path.join(SOT_DIR, "coreIndicators.pin.json"), "utf-8"),
|
|
75
|
-
) as Pin & { codes: string[]
|
|
59
|
+
) as Pin & { codes: string[] };
|
|
76
60
|
const scoringEmitsPin = JSON.parse(
|
|
77
61
|
readFileSync(path.join(SOT_DIR, "scoringEmits.pin.json"), "utf-8"),
|
|
78
62
|
) as Pin & { codes: string[] };
|
|
@@ -146,17 +130,6 @@ const CANONICAL_BINDING: Record<string, { cvc: number; indexName: string }> = {
|
|
|
146
130
|
victim_abuse_types: { cvc: 73, indexName: "core victim abuse types cvc" },
|
|
147
131
|
race_ethnicity: { cvc: 76, indexName: "core_Race:Ethnicity" },
|
|
148
132
|
share_purpose: { cvc: 84, indexName: "core - share_purpose" },
|
|
149
|
-
// PROMOTED OUT OF INDEX_ABSENT by the 2026-08-02 live refresh. This vocabulary
|
|
150
|
-
// previously existed upstream only as a stray pre-08-01 CSV with no machine
|
|
151
|
-
// codes, so extract_final_cvcs.py emitted no index row and the domain was
|
|
152
|
-
// index-absent here. The refresh published the Notion page with codes minted
|
|
153
|
-
// 2026-08-01 (`current` · `previous` · `never` + UNK · ANON · DNC), which is
|
|
154
|
-
// exactly what src/cvcs/juvenileJusticeInvolvementStatus.v1.0.0.json already
|
|
155
|
-
// ships — so this is a linkage, not an authoring.
|
|
156
|
-
juvenile_justice_involvement_status: {
|
|
157
|
-
cvc: 95,
|
|
158
|
-
indexName: "core - juvenile_justice_involvement_status",
|
|
159
|
-
},
|
|
160
133
|
homeless_status: { cvc: 96, indexName: "core - homeless_status" },
|
|
161
134
|
military_branch: { cvc: 120, indexName: "core - military branch" },
|
|
162
135
|
military_status: { cvc: 121, indexName: "core - military status" },
|
|
@@ -198,31 +171,12 @@ const CANONICAL_BINDING: Record<string, { cvc: number; indexName: string }> = {
|
|
|
198
171
|
time_scope: { cvc: 174, indexName: "core - time_scope" },
|
|
199
172
|
enrollment_application_status: { cvc: 175, indexName: "core - enrollment application status" },
|
|
200
173
|
frequency_cadence: { cvc: 176, indexName: "core - frequency : cadence" },
|
|
201
|
-
|
|
202
|
-
// refresh, which removed that row as a STALE DUPLICATE export and kept the
|
|
203
|
-
// underscore spelling. Both spellings pointed at the same vocabulary and the
|
|
204
|
-
// same number; only the surviving one is a legitimate binding target.
|
|
205
|
-
administering_jurisdiction: { cvc: 177, indexName: "core - administering_jurisdiction" },
|
|
174
|
+
administering_jurisdiction: { cvc: 177, indexName: "core - administering jurisdiction" },
|
|
206
175
|
employment_status: { cvc: 179, indexName: "core - employment status" },
|
|
207
176
|
highest_education_level_completed: {
|
|
208
177
|
cvc: 180,
|
|
209
178
|
indexName: "core - highest education level_completed",
|
|
210
179
|
},
|
|
211
|
-
// PIN-ROW DISPOSITION, 2026-08-26. CVC-181's row has been in the pin since
|
|
212
|
-
// before the 622410b reconcile, but nothing in this package occupied 181 — it
|
|
213
|
-
// was a RESERVED row: a number CVC_INDEX.md speaks about that platform-common
|
|
214
|
-
// had never authored, in exactly the 93/196 category the pin-provenance block
|
|
215
|
-
// at the foot of this file describes. Authoring `countries.v1.0.0.json` flips
|
|
216
|
-
// it from reserved to OCCUPIED, and that flip is what this line records. The
|
|
217
|
-
// pin JSON itself is unchanged and must stay so — the row already says
|
|
218
|
-
// "core - countries" and the pin is machine-derived (`npm run sot:pins`);
|
|
219
|
-
// hand-editing it is forbidden by src/__sot__/README.md. What changed is our
|
|
220
|
-
// side of the contract, not upstream's, so the deliberate, documented edit is
|
|
221
|
-
// THIS binding rather than a pin bump.
|
|
222
|
-
//
|
|
223
|
-
// Note the pin row is what made this authorable at all: it is why CVC-181 was
|
|
224
|
-
// known to be birth-country's vocabulary and not a free number to squat on.
|
|
225
|
-
countries: { cvc: 181, indexName: "core - countries" },
|
|
226
180
|
citizenship: { cvc: 182, indexName: "core - citizenship" },
|
|
227
181
|
location_type: { cvc: 191, indexName: "core - location_type" },
|
|
228
182
|
living_situation: { cvc: 192, indexName: "core - living situation" },
|
|
@@ -264,31 +218,6 @@ const INDEX_ABSENT: Record<string, { cvc: number; reason: string }> = {
|
|
|
264
218
|
// but CVC_INDEX.md carries no row. Not a squat (nothing else claims these
|
|
265
219
|
// numbers) — but each needs a Notion index row to become verifiable.
|
|
266
220
|
service_categories: { cvc: 22, reason: "no CVC_INDEX row" },
|
|
267
|
-
// Ratified in the live Notion CVC-159 codebook 2026-08-29 (Crysta knock-out
|
|
268
|
-
// walk) and mirrored to `data/cvcs/core_assertion_domain_extensions_
|
|
269
|
-
// signal_identification.yaml` (prototype PR #519), but CVC_INDEX.md carries no
|
|
270
|
-
// row: the 2026-08-29 targeted live refresh updated CVC-159's own rows without
|
|
271
|
-
// re-running extract_final_cvcs.py, so no `Final CVCs/` export exists for this
|
|
272
|
-
// slice yet. The number is the domain's own self-declaration (CVC-267) and
|
|
273
|
-
// nothing else claims it. NOT parked at 900+ on purpose — same reasoning as
|
|
274
|
-
// core_information_scope: that block is for vocabularies with no canonical
|
|
275
|
-
// number, and parking a numbered domain there would leave 267 looking free.
|
|
276
|
-
risk_identification_milestone: {
|
|
277
|
-
cvc: 267,
|
|
278
|
-
reason: "no CVC_INDEX row — authored live in Notion 2026-08-29, extractor not re-run",
|
|
279
|
-
},
|
|
280
|
-
// Authored directly in the live Notion inline DB (2026-08-13, restructured
|
|
281
|
-
// 2026-08-14), so no `Final CVCs/` export exists yet and extract_final_cvcs.py
|
|
282
|
-
// emits no row. The number is the domain's own self-declaration —
|
|
283
|
-
// `data/cvcs/core_information_scope.yaml` carries `cvc_id: "CVC-236"` — and
|
|
284
|
-
// nothing else claims 236 (233 and 235 and 238 are bound elsewhere; 236 and
|
|
285
|
-
// 237 are unoccupied), so this is index-absent rather than a squat. NOT parked
|
|
286
|
-
// at 900+ on purpose: that block is for vocabularies with no canonical number,
|
|
287
|
-
// and parking a numbered domain there would leave 236 looking free.
|
|
288
|
-
core_information_scope: {
|
|
289
|
-
cvc: 236,
|
|
290
|
-
reason: "authored in the live Notion inline DB; no Final CVCs/ export yet",
|
|
291
|
-
},
|
|
292
221
|
// Trunk-only domain: authored on `kl-develop` (80341e0, "promote CVC-17 +
|
|
293
222
|
// CVC-67 to SOT"), which the canonical 0.8.13 line never saw. Its sibling
|
|
294
223
|
// CVC-17 (gender_identity) IS in CVC_INDEX.md and is bound above; 67 is not
|
|
@@ -296,10 +225,7 @@ const INDEX_ABSENT: Record<string, { cvc: number; reason: string }> = {
|
|
|
296
225
|
// other domain claims 67, so it is index-absent rather than a squat. Sourced
|
|
297
226
|
// from the HMIS data standard via `CVC_67_HMIS_SEX` in `../constants/ic.ts`.
|
|
298
227
|
hmis_sex: { cvc: 67, reason: "no CVC_INDEX row" },
|
|
299
|
-
|
|
300
|
-
// reconcile — CVC_INDEX.md now carries its row, so it is bound above. This is
|
|
301
|
-
// what the list is FOR: index-absence is a temporary, visible state that gets
|
|
302
|
-
// retired when Notion catches up, not a permanent parking spot.
|
|
228
|
+
juvenile_justice_involvement_status: { cvc: 95, reason: "no CVC_INDEX row" },
|
|
303
229
|
primary_language: { cvc: 122, reason: "no CVC_INDEX row" },
|
|
304
230
|
hmis_relationship_to_hoh: { cvc: 129, reason: "no CVC_INDEX row" },
|
|
305
231
|
core_functions: { cvc: 133, reason: "no CVC_INDEX row" },
|
|
@@ -315,40 +241,7 @@ const INDEX_ABSENT: Record<string, { cvc: number; reason: string }> = {
|
|
|
315
241
|
hmis_project_type: { cvc: 225, reason: "no CVC_INDEX row" },
|
|
316
242
|
funder: { cvc: 226, reason: "no CVC_INDEX row" },
|
|
317
243
|
da_incident_severity: { cvc: 228, reason: "no CVC_INDEX row" },
|
|
318
|
-
|
|
319
|
-
// OTHER way a domain retires from INDEX_ABSENT, and the one that matters.
|
|
320
|
-
// Jevon ratified CVC-231 to the Determination Helper categories on
|
|
321
|
-
// 2026-08-28. This domain had only ever held 231 as a provisional mint taken
|
|
322
|
-
// out of the canonical block, which is exactly why it lived here instead of
|
|
323
|
-
// in CANONICAL_BINDING. Left at 231 it would have become a SQUAT the moment
|
|
324
|
-
// the next cvcIndex pin refresh published the DH row — and per GATE C a squat
|
|
325
|
-
// does not merely mislabel the squatter, it makes the slot look OCCUPIED and
|
|
326
|
-
// hides the absence of the domain that owns it. It is renumbered to the
|
|
327
|
-
// provisional block at CVC-991 (see relationshipConcern.v1.0.0.json
|
|
328
|
-
// `_status.renumber` / `_status.numberChoice`), so `isProvisional()` now
|
|
329
|
-
// exempts it and no entry here is needed. The Determination Helper categories
|
|
330
|
-
// that own 231 are authored directly below — the gap the vacated squat had
|
|
331
|
-
// been hiding, closed in the same branch that vacated it.
|
|
332
|
-
//
|
|
333
|
-
// CVC-231's rightful owner, authored 2026-08-30. This is the SECOND half of the
|
|
334
|
-
// renumber above and the whole point of GATE C: vacating the squat exposed an
|
|
335
|
-
// unauthored canonical vocabulary, and the exposure is only worth anything if
|
|
336
|
-
// the vocabulary then gets authored. `CVC_INDEX.md` @ 622410b has no row for it
|
|
337
|
-
// (grep confirms: the only `determination`-prefixed rows are CVC-138
|
|
338
|
-
// `core - determination_level` and CVC-233 `core-DH_state`), so this is the
|
|
339
|
-
// `core_information_scope` disposition — numbered from the domain's own
|
|
340
|
-
// canonical self-declaration plus a codebook-owner ruling, index-absent until
|
|
341
|
-
// the extractor catches up — and NOT the CVC-181 one, which had a reserved pin
|
|
342
|
-
// row to bind against. NO PIN EDIT: `cvcIndex.pin.json` is machine-derived and
|
|
343
|
-
// `src/__sot__/README.md` forbids hand-editing it; the row arrives on its own
|
|
344
|
-
// refresh cycle and this domain is promoted into CANONICAL_BINDING then.
|
|
345
|
-
determination_helper_categories: {
|
|
346
|
-
cvc: 231,
|
|
347
|
-
reason:
|
|
348
|
-
"no CVC_INDEX row; number self-declared by the canonical " +
|
|
349
|
-
"data/cvcs/core_determination_helper_categories.yaml and ratified to this " +
|
|
350
|
-
"vocabulary by Jevon on 2026-08-28",
|
|
351
|
-
},
|
|
244
|
+
relationship_concern: { cvc: 231, reason: "no CVC_INDEX row" },
|
|
352
245
|
};
|
|
353
246
|
|
|
354
247
|
/**
|
|
@@ -639,17 +532,17 @@ describe("GATE F — entry counts and selectable counts are never conflated", ()
|
|
|
639
532
|
}
|
|
640
533
|
});
|
|
641
534
|
|
|
642
|
-
it("CVC-69 regression:
|
|
535
|
+
it("CVC-69 regression: 19 entries = 14 selectable + 4 group rows + missingness_root", () => {
|
|
643
536
|
const d = DOMAINS.find((x) => x.domain === "incident_participation_roles")!;
|
|
644
537
|
const selectable = d.entries.filter((e) => e.selectable);
|
|
645
538
|
const groupRows = d.entries.filter((e) => !e.selectable && !isMissingness(e));
|
|
646
539
|
const missRoot = d.entries.filter((e) => !e.selectable && isMissingness(e));
|
|
647
540
|
|
|
648
|
-
expect(d.entries.length, "total entries").toBe(
|
|
649
|
-
expect(selectable.length, "selectable").toBe(
|
|
541
|
+
expect(d.entries.length, "total entries").toBe(19);
|
|
542
|
+
expect(selectable.length, "selectable").toBe(14);
|
|
650
543
|
expect(groupRows.length, "non-selectable group rows").toBe(4);
|
|
651
544
|
expect(missRoot.length, "non-selectable missingness_root").toBe(1);
|
|
652
|
-
expect(selectable.length + groupRows.length + missRoot.length).toBe(
|
|
545
|
+
expect(selectable.length + groupRows.length + missRoot.length).toBe(19);
|
|
653
546
|
// If a consumer's boot-check ever asserts `entries.length === 14`, it is the
|
|
654
547
|
// CONSUMER that is wrong, not CVC-69.
|
|
655
548
|
});
|
|
@@ -684,267 +577,6 @@ describe("GATE G — code and key format", () => {
|
|
|
684
577
|
}
|
|
685
578
|
});
|
|
686
579
|
|
|
687
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
688
|
-
// H. FIELD FIDELITY — the pin-field-blindness catcher
|
|
689
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
690
|
-
/**
|
|
691
|
-
* GATES A and B compare SETS OF CODE NAMES. That is all the pin used to carry,
|
|
692
|
-
* and it is why two consecutive refreshes each shipped half a delta:
|
|
693
|
-
*
|
|
694
|
-
* 0.8.14 — the code delta landed; a DEFINITION REVISION that came with it
|
|
695
|
-
* did not. Green.
|
|
696
|
-
* 0.8.17 — the code delta landed; a LABEL RENAME and a load-bearing
|
|
697
|
-
* DEPRECATION QUALIFIER in a definition did not. Green. Caught by a
|
|
698
|
-
* human reading the diff, which is not a gate.
|
|
699
|
-
*
|
|
700
|
-
* A code can keep its name while everything the catalog SAYS about it is
|
|
701
|
-
* rewritten. `coreIndicators.pin.json` now carries the seven projected fields
|
|
702
|
-
* verbatim (`src/__sot__/coreIndicatorFields.ts`), and this gate asserts
|
|
703
|
-
* CVC-136 restates every one of them faithfully — entry by entry, field by
|
|
704
|
-
* field, naming the code, the field, the catalog value and the shipped value on
|
|
705
|
-
* failure.
|
|
706
|
-
*
|
|
707
|
-
* Normalization is the enumerated exemption list in `coreIndicatorFields.ts`,
|
|
708
|
-
* and H4 below PROVES each exemption is still load-bearing rather than letting
|
|
709
|
-
* it rot into a blanket fuzzy match.
|
|
710
|
-
*/
|
|
711
|
-
describe("GATE H — CVC-136 restates every field the catalog states", () => {
|
|
712
|
-
const shipped = new Map<string, ProjectedIndicatorFields>(
|
|
713
|
-
substantiveOf(cvc136).map((e) => [
|
|
714
|
-
e.key,
|
|
715
|
-
projectSotEntry(e as unknown as Record<string, unknown>),
|
|
716
|
-
]),
|
|
717
|
-
);
|
|
718
|
-
// Defaulted, NOT asserted here, on purpose. A pin regenerated by a
|
|
719
|
-
// pre-field-aware sot-pins.ts has no `fields` at all; reading `Object.keys`
|
|
720
|
-
// off `undefined` throws at COLLECTION time, which collapses the whole file
|
|
721
|
-
// to 0 tests and reports as an import error rather than as the named H1
|
|
722
|
-
// failure that says what to do. Default to empty, then fail loudly in H1.
|
|
723
|
-
const pinFields: Record<string, ProjectedIndicatorFields> = coreIndicatorsPin.fields ?? {};
|
|
724
|
-
const pinnedCodes = Object.keys(pinFields);
|
|
725
|
-
|
|
726
|
-
it("the pin carries projected fields for every pinned code", () => {
|
|
727
|
-
// A pin regenerated by a pre-field-aware sot-pins.ts would be silently
|
|
728
|
-
// field-blind — the exact failure mode this gate exists to end. Refuse it.
|
|
729
|
-
expect(
|
|
730
|
-
Object.keys(pinFields).length,
|
|
731
|
-
"the pin carries no fields — regenerate with npm run sot:pins",
|
|
732
|
-
).toBeGreaterThan(0);
|
|
733
|
-
expect(pinnedCodes.sort()).toEqual([...coreIndicatorsPin.codes].sort());
|
|
734
|
-
for (const code of pinnedCodes) {
|
|
735
|
-
const fields = pinFields[code]!;
|
|
736
|
-
for (const field of PROJECTED_FIELDS) {
|
|
737
|
-
expect(fields, `${code} is missing projected field "${field}"`).toHaveProperty(field);
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
|
|
742
|
-
it("every pinned catalog code is present in CVC-136 (the join is total)", () => {
|
|
743
|
-
// Without this, a code dropped from CVC-136 would make the field comparison
|
|
744
|
-
// below silently SKIP it rather than fail — a gate with a hole in it.
|
|
745
|
-
const absent = pinnedCodes.filter((c) => !shipped.has(c)).sort();
|
|
746
|
-
if (absent.length > 0) {
|
|
747
|
-
throw new Error(
|
|
748
|
-
`${absent.length} code(s) in ${coreIndicatorsPin.sourceFile} ` +
|
|
749
|
-
`@ ${coreIndicatorsPin.sourceSha} are NOT in CVC-136:\n` +
|
|
750
|
-
` ${absent.join(", ")}\n\n` +
|
|
751
|
-
"GATE B only checks the other direction (CVC-136 invents nothing), so a\n" +
|
|
752
|
-
" catalog code dropped on refresh would otherwise pass unnoticed.\n" +
|
|
753
|
-
"TO FIX: add each to src/cvcs/coreIndicators.v1.0.0.json.",
|
|
754
|
-
);
|
|
755
|
-
}
|
|
756
|
-
expect(absent).toEqual([]);
|
|
757
|
-
});
|
|
758
|
-
|
|
759
|
-
it(`all ${PROJECTED_FIELDS.length} projected fields match, code by code`, () => {
|
|
760
|
-
const mismatches: string[] = [];
|
|
761
|
-
|
|
762
|
-
for (const code of pinnedCodes) {
|
|
763
|
-
const catalog = pinFields[code]!;
|
|
764
|
-
const sot = shipped.get(code);
|
|
765
|
-
if (!sot) continue; // already reported by the join-is-total assertion above
|
|
766
|
-
|
|
767
|
-
for (const field of PROJECTED_FIELDS) {
|
|
768
|
-
// ASYMMETRIC BY DESIGN. E4's `\xNN` decode runs on the CATALOG side
|
|
769
|
-
// only, because CVC-136 is obliged to carry the real character rather
|
|
770
|
-
// than mirror the upstream escape. Decoding both sides would let a
|
|
771
|
-
// shipped literal `fianc\xE9(e)` compare equal and pass. E1/E2/E3/E5
|
|
772
|
-
// are symmetric. See NORMALIZATION_EXEMPTIONS.
|
|
773
|
-
const want = normalizeCatalogValue(field, catalog[field]);
|
|
774
|
-
const got = normalizeSotValue(field, sot[field]);
|
|
775
|
-
if (want === got) continue;
|
|
776
|
-
mismatches.push(
|
|
777
|
-
` ${code} . ${field}\n` +
|
|
778
|
-
` catalog: ${want === null ? "(absent)" : JSON.stringify(want)}\n` +
|
|
779
|
-
` CVC-136: ${got === null ? "(absent)" : JSON.stringify(got)}`,
|
|
780
|
-
);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
if (mismatches.length > 0) {
|
|
785
|
-
throw new Error(
|
|
786
|
-
`${mismatches.length} field(s) of CVC-136 disagree with the canonical catalog.\n` +
|
|
787
|
-
"The CODE SET is right and the CONTENT is stale — which is precisely what a\n" +
|
|
788
|
-
"code-set-only pin could never see (0.8.14 dropped a definition revision;\n" +
|
|
789
|
-
"0.8.17 dropped a label rename plus a deprecation qualifier).\n\n" +
|
|
790
|
-
`${mismatches.join("\n")}\n\n` +
|
|
791
|
-
"TO FIX: copy the `catalog:` value printed above into the matching entry\n" +
|
|
792
|
-
" of src/cvcs/coreIndicators.v1.0.0.json.\n" +
|
|
793
|
-
" COPY THE PRINTED VALUE, not the raw scalar out of\n" +
|
|
794
|
-
` ${coreIndicatorsPin.sourceRepo}/${coreIndicatorsPin.sourceFile}` +
|
|
795
|
-
` @ ${coreIndicatorsPin.sourceSha}.\n` +
|
|
796
|
-
" The printed value is NORMALIZED — wrap points folded, and any leaked\n" +
|
|
797
|
-
" `\\xNN` escape already decoded to the real character. Transcribing the\n" +
|
|
798
|
-
" raw YAML by hand reproduces the escape verbatim (`fianc\\xE9(e)`), which\n" +
|
|
799
|
-
" CVC-136 must NOT carry: the restatement's job is to fix that upstream\n" +
|
|
800
|
-
" defect, and a separate assertion below rejects a shipped `\\xNN`.\n" +
|
|
801
|
-
" Field names differ by design: the catalog's `label` is the envelope's\n" +
|
|
802
|
-
" `title`; `is_alert`/`alert_when` are `isAlert`/`alertWhen`. Then\n" +
|
|
803
|
-
" regenerate CVC_136_CORE_INDICATOR_VALUES in src/constants/ic.ts if the\n" +
|
|
804
|
-
" change touches a name.\n" +
|
|
805
|
-
" If instead the CATALOG moved, run `npm run sot:pins` and restate both.",
|
|
806
|
-
);
|
|
807
|
-
}
|
|
808
|
-
expect(mismatches).toEqual([]);
|
|
809
|
-
});
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* BELT AND BRACES FOR E4.
|
|
813
|
-
*
|
|
814
|
-
* The comparison above is already asymmetric, so a shipped `fianc\xE9(e)` now
|
|
815
|
-
* fails it. This asserts the same thing directly, without reference to the
|
|
816
|
-
* catalog, because it is the cheaper and more legible failure: it names E4 and
|
|
817
|
-
* says what a correct restatement looks like, rather than printing two long
|
|
818
|
-
* definitions that differ somewhere in the middle.
|
|
819
|
-
*
|
|
820
|
-
* It also holds if the catalog is ever cleaned up upstream and E4 is deleted:
|
|
821
|
-
* CVC-136 must never carry a Python-style hex escape regardless of why.
|
|
822
|
-
*/
|
|
823
|
-
it("no shipped CVC-136 value carries a leaked `\\xNN` escape", () => {
|
|
824
|
-
const offenders: string[] = [];
|
|
825
|
-
for (const [code, fields] of shipped) {
|
|
826
|
-
for (const field of PROJECTED_FIELDS) {
|
|
827
|
-
const value = fields[field];
|
|
828
|
-
if (value !== null && LEAKED_HEX_ESCAPE.test(value)) {
|
|
829
|
-
offenders.push(` ${code} . ${field}: ${JSON.stringify(value)}`);
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
expect(
|
|
834
|
-
offenders,
|
|
835
|
-
"These CVC-136 values contain a literal `\\xNN` escape (E4-leaked-hex-escape).\n" +
|
|
836
|
-
"One upstream catalog scalar is authored single-quoted with Python-style\n" +
|
|
837
|
-
"escapes, so `fianc\\xE9` parses as six literal characters. CVC-136's job is to\n" +
|
|
838
|
-
"restate the REAL character (`fiancé`) — copying the raw YAML through\n" +
|
|
839
|
-
"mechanically carries the defect into the shipped codebook.\n" +
|
|
840
|
-
"TO FIX: replace each escape with the character it denotes.\n" +
|
|
841
|
-
`${offenders.join("\n")}`,
|
|
842
|
-
).toEqual([]);
|
|
843
|
-
});
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* H4 — THE EXEMPTIONS ARE PROVEN, NOT ASSUMED.
|
|
847
|
-
*
|
|
848
|
-
* A normalization exemption is a hole in the gate. Each one below is asserted
|
|
849
|
-
* to be (a) still physically present — its `detect` predicate still fires on
|
|
850
|
-
* the raw catalog value — (b) still exercised — a RAW comparison of the fields
|
|
851
|
-
* it covers genuinely fails — and (c) sufficient — the normalized comparison
|
|
852
|
-
* of those fields passes. An exemption that stops being needed fails here and
|
|
853
|
-
* gets deleted, instead of silently widening the gate's blind spot forever.
|
|
854
|
-
*
|
|
855
|
-
* SCOPING, and why both (a) and (b) are needed.
|
|
856
|
-
*
|
|
857
|
-
* The self-tests used to span all seven PROJECTED_FIELDS, so an exemption
|
|
858
|
-
* could look alive on the strength of a DIFFERENT exemption's artifact in a
|
|
859
|
-
* different field. Narrowing to `exemption.fields` fixes most of that — but
|
|
860
|
-
* not all of it, because in the pinned catalog every prose artifact lives in
|
|
861
|
-
* `definition`, and E2 and E4 share BOTH a code and that field. Field scoping
|
|
862
|
-
* alone would still let a dead E4 ride on E2's wrap point.
|
|
863
|
-
*
|
|
864
|
-
* `detect` is what closes it: it asks whether the raw catalog value still
|
|
865
|
-
* contains THIS exemption's artifact — a trailing newline, an interior wrap,
|
|
866
|
-
* a wrapped hyphen, a `\xNN` escape, an empty string — independently of
|
|
867
|
-
* whether some other exemption also fires on the same value.
|
|
868
|
-
*/
|
|
869
|
-
describe("the normalization exemptions are each still load-bearing", () => {
|
|
870
|
-
for (const exemption of NORMALIZATION_EXEMPTIONS) {
|
|
871
|
-
it(`${exemption.id} is exercised by ${exemption.codes.join(", ")}`, () => {
|
|
872
|
-
for (const code of exemption.codes) {
|
|
873
|
-
const catalog = pinFields[code];
|
|
874
|
-
const sot = shipped.get(code);
|
|
875
|
-
expect(catalog, `${exemption.id}: ${code} is no longer in the pin`).toBeDefined();
|
|
876
|
-
expect(sot, `${exemption.id}: ${code} is no longer in CVC-136`).toBeDefined();
|
|
877
|
-
|
|
878
|
-
// Scoped to the fields THIS exemption claims to cover.
|
|
879
|
-
const fields = exemption.fields;
|
|
880
|
-
|
|
881
|
-
const detected = fields.some((f) => {
|
|
882
|
-
const raw = catalog![f];
|
|
883
|
-
return raw !== null && exemption.detect(raw);
|
|
884
|
-
});
|
|
885
|
-
const rawDiffers = fields.some((f) => catalog![f] !== sot![f]);
|
|
886
|
-
const normalizedMatches = fields.every(
|
|
887
|
-
(f) => normalizeCatalogValue(f, catalog![f]) === normalizeSotValue(f, sot![f]),
|
|
888
|
-
);
|
|
889
|
-
|
|
890
|
-
expect(
|
|
891
|
-
detected,
|
|
892
|
-
`${exemption.id}: the artifact is GONE from ${code}.${fields.join("/")} — ` +
|
|
893
|
-
"the raw catalog value no longer contains it, so this exemption is dead. " +
|
|
894
|
-
"Delete it from NORMALIZATION_EXEMPTIONS in src/__sot__/coreIndicatorFields.ts " +
|
|
895
|
-
"rather than leaving an unused hole in the gate. (Checked separately from " +
|
|
896
|
-
"the raw-differs assertion below because two exemptions can overlap on one " +
|
|
897
|
-
"code and field — E2 and E4 do — and then a raw difference proves nothing " +
|
|
898
|
-
"about which of them is still needed.)",
|
|
899
|
-
).toBe(true);
|
|
900
|
-
expect(
|
|
901
|
-
rawDiffers,
|
|
902
|
-
`${exemption.id}: ${code}.${fields.join("/")} now matches VERBATIM — this ` +
|
|
903
|
-
"exemption is dead. Delete it from NORMALIZATION_EXEMPTIONS in " +
|
|
904
|
-
"src/__sot__/coreIndicatorFields.ts rather than leaving an unused hole " +
|
|
905
|
-
"in the gate.",
|
|
906
|
-
).toBe(true);
|
|
907
|
-
expect(
|
|
908
|
-
normalizedMatches,
|
|
909
|
-
`${exemption.id}: ${code}.${fields.join("/")} still differs AFTER ` +
|
|
910
|
-
"normalization — the exemption no longer covers what it claims to. " +
|
|
911
|
-
"Read the GATE H failure above.",
|
|
912
|
-
).toBe(true);
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
it("every round-trip artifact in the catalog is an enumerated one", () => {
|
|
918
|
-
// Guard the escape hatch the way GATE B guards SCORING_AHEAD_OF_CATALOG:
|
|
919
|
-
// the list must stay a documented enumeration, not a dumping ground.
|
|
920
|
-
//
|
|
921
|
-
// Scoped to codes whose raw fields differ but whose NORMALIZED fields
|
|
922
|
-
// agree — that is the definition of a round-trip artifact. Codes that
|
|
923
|
-
// differ after normalization are real drift and belong to the GATE H
|
|
924
|
-
// failure above; reporting them here too would just double the noise.
|
|
925
|
-
const named = new Set<string>(NORMALIZATION_EXEMPTIONS.flatMap((e) => [...e.codes]));
|
|
926
|
-
const artifacts = pinnedCodes.filter((code) => {
|
|
927
|
-
const catalog = pinFields[code]!;
|
|
928
|
-
const sot = shipped.get(code);
|
|
929
|
-
if (!sot) return false;
|
|
930
|
-
const rawDiffers = PROJECTED_FIELDS.some((f) => catalog[f] !== sot[f]);
|
|
931
|
-
const normalizedMatches = PROJECTED_FIELDS.every(
|
|
932
|
-
(f) => normalizeCatalogValue(f, catalog[f]) === normalizeSotValue(f, sot[f]),
|
|
933
|
-
);
|
|
934
|
-
return rawDiffers && normalizedMatches;
|
|
935
|
-
});
|
|
936
|
-
const undocumented = artifacts.filter((c) => !named.has(c)).sort();
|
|
937
|
-
expect(
|
|
938
|
-
undocumented,
|
|
939
|
-
"These codes are absorbed by normalization but named by no exemption. Each is a " +
|
|
940
|
-
"NEW round-trip artifact: read it, confirm it is formatting and not content, then " +
|
|
941
|
-
"document it in NORMALIZATION_EXEMPTIONS in src/__sot__/coreIndicatorFields.ts. " +
|
|
942
|
-
"An undocumented one is a hole nobody has looked through.",
|
|
943
|
-
).toEqual([]);
|
|
944
|
-
});
|
|
945
|
-
});
|
|
946
|
-
});
|
|
947
|
-
|
|
948
580
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
949
581
|
// Pin provenance — the pins must say where they came from.
|
|
950
582
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -961,76 +593,11 @@ describe("SOT pins carry their provenance", () => {
|
|
|
961
593
|
}
|
|
962
594
|
});
|
|
963
595
|
|
|
964
|
-
it("the pinned SOT is the one
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
// the reconcile the previous release deferred rather than fake. Four row
|
|
968
|
-
// deltas, and what each one actually required:
|
|
969
|
-
//
|
|
970
|
-
// CVC-177 ["core - administering jurisdiction", -> ["core - administering_jurisdiction"]
|
|
971
|
-
// "core - administering_jurisdiction"]
|
|
972
|
-
// The space-named row was a STALE DUPLICATE export and was
|
|
973
|
-
// removed. NOT bookkeeping: CANONICAL_BINDING was bound to the
|
|
974
|
-
// spelling that no longer exists, so the bump alone would have
|
|
975
|
-
// failed GATE C. The binding now names the surviving row.
|
|
976
|
-
//
|
|
977
|
-
// CVC-95 null -> ["core - juvenile_justice_involvement_status"]
|
|
978
|
-
// The domain was already authored and already correct; it sat in
|
|
979
|
-
// INDEX_ABSENT only because no index row existed to bind it to.
|
|
980
|
-
// Now bound. Left in INDEX_ABSENT it would have read as a SQUAT,
|
|
981
|
-
// because a number the index speaks about constrains whoever
|
|
982
|
-
// occupies it. Linkage only — nothing authored.
|
|
983
|
-
//
|
|
984
|
-
// CVC-93 null -> ["core - child_welfare_involvement_status"]
|
|
985
|
-
// CVC-196 ["core child welfare cvc", -> ["core - child_welfare_episode_type"]
|
|
986
|
-
// "core child welfare episode type CVC"]
|
|
987
|
-
// Bookkeeping. platform-common ships NO domain at 93 or 196, so
|
|
988
|
-
// no gate constrains them and nothing here had to change. They
|
|
989
|
-
// are now KNOWN-OCCUPIED numbers, which is the point: authoring
|
|
990
|
-
// either later must land on its own number, and a future domain
|
|
991
|
-
// drifting onto 93/196 is now a detectable squat rather than a
|
|
992
|
-
// silent one. Authoring the vocabularies themselves is clinical
|
|
993
|
-
// content (Crysta-owned) and is deliberately not done here.
|
|
994
|
-
//
|
|
995
|
-
// The three index-name/status-only churns in the same refresh (CVC-159
|
|
996
|
-
// unchanged row, CVC-85 and CVC-145 status promotions) carry no pin delta:
|
|
997
|
-
// the pin captures the NUMBER -> NAMES map, not the status column.
|
|
998
|
-
// coreIndicators advanced to 84a1b67 in 0.8.14 (+5 upstream mints, 0
|
|
999
|
-
// withdrawn) and to 622410b in this refresh (+1: `active_protective_order`,
|
|
1000
|
-
// minted upstream 2026-08-08, `code_status: canonical`, plus the projected-
|
|
1001
|
-
// field revisions on 136-007 / 136-094); scoringEmits is unchanged,
|
|
1002
|
-
// so the 2 SCORING_AHEAD_OF_CATALOG codes remain ahead of the catalog
|
|
1003
|
-
// exactly as before.
|
|
1004
|
-
//
|
|
1005
|
-
// coreIndicators was WIDENED (not bumped) to carry the projected `fields`
|
|
1006
|
-
// that GATE H enforces — same SHA, same 214 codes, more of what the catalog
|
|
1007
|
-
// says about each. The two refreshes that dropped their field delta are why.
|
|
1008
|
-
//
|
|
1009
|
-
// 622410b's CVC_INDEX.md is a HAND-REFRESHED live-Notion state that upstream
|
|
1010
|
-
// marks NON-REPRODUCIBLE by `tools/extract_final_cvcs.py`: its banner says
|
|
1011
|
-
// "Do NOT re-run tools/extract_final_cvcs.py until the next full Notion
|
|
1012
|
-
// re-export lands — it would clobber the refreshed extracts and resurrect
|
|
1013
|
-
// index rows from the stale zips" — i.e. a premature re-run brings the
|
|
1014
|
-
// space-named CVC-177 duplicate back and takes CVC-95's row away again.
|
|
1015
|
-
// GATE C fails loudly on the CVC-95 half (a bound domain sits on it); the
|
|
1016
|
-
// 93/196 half is invisible to every gate, since GATE C only iterates bound
|
|
1017
|
-
// domains and occupied numbers and platform-common ships neither. The row
|
|
1018
|
-
// count below is what makes that half detectable at all — a regenerated pin
|
|
1019
|
-
// that silently drops those deliberately-recorded rows fails here.
|
|
1020
|
-
//
|
|
1021
|
-
// 2026-08-26 — CVC-181 `core - countries` was authored, and its pin row went
|
|
1022
|
-
// from RESERVED (a row the index speaks about that nothing occupied — the
|
|
1023
|
-
// 93/196 category above) to OCCUPIED. NO PIN DELTA: the row already read
|
|
1024
|
-
// ["core - countries"] and upstream did not move, so the pin stays at
|
|
1025
|
-
// 622410b and stays machine-derived. The change is on OUR side of the
|
|
1026
|
-
// contract and is recorded as a CANONICAL_BINDING entry with its disposition
|
|
1027
|
-
// written next to it. This is the shape every reserved-row authoring should
|
|
1028
|
-
// take: bind, do not bump.
|
|
1029
|
-
expect(cvcIndexPin.sourceSha).toBe("622410b");
|
|
1030
|
-
expect(coreIndicatorsPin.sourceSha).toBe("622410b");
|
|
596
|
+
it("the pinned SOT is the one 0.8.13 was authored against", () => {
|
|
597
|
+
expect(cvcIndexPin.sourceSha).toBe("a596eb9");
|
|
598
|
+
expect(coreIndicatorsPin.sourceSha).toBe("a596eb9");
|
|
1031
599
|
expect(scoringEmitsPin.sourceSha).toBe("9b5d654");
|
|
1032
|
-
expect(
|
|
1033
|
-
expect(coreIndicatorsPin.codes.length).toBe(214);
|
|
600
|
+
expect(coreIndicatorsPin.codes.length).toBe(208);
|
|
1034
601
|
expect(scoringEmitsPin.codes.length).toBe(169);
|
|
1035
602
|
});
|
|
1036
603
|
});
|