@htilabs/platform-common-models 0.9.0 → 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 +85 -0
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +94 -4
- package/dist/config/index.d.ts +94 -4
- package/dist/config/index.js +81 -1
- package/dist/config/index.js.map +1 -1
- package/dist/constants/index.cjs +456 -181
- 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 +453 -169
- package/dist/constants/index.js.map +1 -1
- package/dist/cvcs/index.cjs +15331 -801
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +18167 -2208
- package/dist/cvcs/index.d.ts +18167 -2208
- package/dist/cvcs/index.js +15282 -801
- package/dist/cvcs/index.js.map +1 -1
- package/dist/{index-Zu_mOJRn.d.cts → index-CoVr1jIV.d.cts} +1 -1
- package/dist/{index-CDoqrfc1.d.ts → index-I-DiX9eQ.d.ts} +1 -1
- package/dist/index.cjs +17070 -1056
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1638 -12
- package/dist/index.d.ts +1638 -12
- package/dist/index.js +16969 -1043
- 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 +384 -0
- package/dist/mongo/index.cjs.map +1 -0
- package/dist/mongo/index.d.cts +221 -0
- package/dist/mongo/index.d.ts +221 -0
- package/dist/mongo/index.js +352 -0
- package/dist/mongo/index.js.map +1 -0
- package/dist/{platform-auth-XVB9aHqR.d.cts → platform-auth-v53r3BhN.d.cts} +19 -75
- package/dist/{platform-auth-XVB9aHqR.d.ts → platform-auth-v53r3BhN.d.ts} +19 -75
- package/dist/schemas/index.cjs +25 -156
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/dist/schemas/index.js +25 -156
- package/dist/schemas/index.js.map +1 -1
- package/dist/services/index.cjs +0 -3
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.js +0 -3
- package/dist/services/index.js.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +9 -1
- package/src/__sot__/README.md +56 -0
- package/src/__sot__/coreIndicators.pin.json +215 -0
- package/src/__sot__/cvcIndex.pin.json +268 -0
- package/src/__sot__/scoringEmits.pin.json +176 -0
- package/src/__tests__/__snapshots__/cvc-sot.snap +227 -35
- package/src/__tests__/cvc-136-scoring-invariant.test.ts +323 -0
- package/src/__tests__/cvc-drift-gate.test.ts +603 -0
- package/src/__tests__/cvc-sot-snapshot.test.ts +122 -11
- package/src/__tests__/cvc-structural.test.ts +56 -1
- package/src/__tests__/mongo-verifier.test.ts +502 -0
- package/src/__tests__/runtime-contract-validator.test.ts +325 -1
- package/src/config/index.ts +197 -6
- package/src/constants/ic.ts +512 -206
- package/src/constants/service-catalog.ts +4 -2
- package/src/cvcs/activityType.v1.0.0.json +143 -0
- package/src/cvcs/adminRoles.v1.0.0.json +153 -0
- package/src/cvcs/administeringJurisdiction.v1.0.0.json +40 -40
- package/src/cvcs/ageBinReporting.v1.0.0.json +40 -40
- package/src/cvcs/assertionDomain.v1.1.0.json +629 -0
- package/src/cvcs/{checkInPhase.v1.0.0.json → checkInPhase.v1.1.0.json} +20 -2
- package/src/cvcs/childChangeType.v1.0.0.json +152 -0
- package/src/cvcs/citizenship.v1.0.0.json +3062 -0
- package/src/cvcs/contactInfoTypes.v1.0.0.json +40 -40
- package/src/cvcs/contactLinkType.v1.0.0.json +89 -0
- package/src/cvcs/coreDhState.v1.0.0.json +113 -0
- package/src/cvcs/coreFunctions.v1.0.0.json +746 -0
- package/src/cvcs/coreIndicators.v1.0.0.json +2840 -0
- package/src/cvcs/coreReferralOutcome.v1.0.0.json +71 -0
- package/src/cvcs/employmentStatus.v1.0.0.json +60 -60
- package/src/cvcs/exploitationType.v1.0.0.json +106 -0
- package/src/cvcs/facilitatorEntityType.v1.0.0.json +40 -40
- package/src/cvcs/highestEducationLevelCompleted.v1.0.0.json +55 -46
- package/src/cvcs/hivStatus.v1.0.0.json +71 -0
- package/src/cvcs/hmisCurrentLivingSituation.v1.0.0.json +409 -0
- package/src/cvcs/hmisRelationshipToHoh.v1.0.0.json +104 -0
- package/src/cvcs/homelessStatus.v1.0.0.json +27 -27
- package/src/cvcs/housingSubsidyTypes.v1.0.0.json +161 -0
- package/src/cvcs/htType.v1.0.0.json +87 -0
- package/src/cvcs/identificationStatus.v1.0.0.json +18 -0
- package/src/cvcs/immigrationLegalStatusChangeType.v1.0.0.json +143 -0
- package/src/cvcs/incarcerationEpisodeType.v1.0.0.json +106 -0
- package/src/cvcs/incidentInvolvementRoles.v1.0.0.json +40 -40
- package/src/cvcs/incidentParticipationRoles.v1.0.0.json +40 -40
- package/src/cvcs/incomeBenefitsSources.v1.0.0.json +31 -2
- package/src/cvcs/index.ts +106 -1
- package/src/cvcs/juvenileJusticeEpisodeType.v1.0.0.json +28 -18
- package/src/cvcs/juvenileJusticeInvolvementStatus.v1.0.0.json +32 -32
- package/src/cvcs/livingSituation.v1.0.0.json +213 -0
- package/src/cvcs/mentalHealthStatus.v1.0.0.json +71 -0
- package/src/cvcs/militaryBranch.v1.0.0.json +20 -20
- package/src/cvcs/militaryStatus.v1.0.0.json +20 -20
- package/src/cvcs/nameType.v1.0.0.json +40 -40
- package/src/cvcs/needsAssessmentChangeType.v1.0.0.json +134 -0
- package/src/cvcs/offenderStatus.v1.0.0.json +40 -40
- package/src/cvcs/offenderStatusFamily.v1.0.0.json +36 -36
- package/src/cvcs/poPetitionBasis.v1.0.0.json +96 -0
- package/src/cvcs/poStatus.v1.0.0.json +144 -0
- package/src/cvcs/poViolationStatus.v1.0.0.json +76 -0
- package/src/cvcs/programEnrollmentChangeType.v1.0.0.json +134 -0
- package/src/cvcs/provenanceSourceId.v1.0.0.json +134 -0
- package/src/cvcs/radiusBucket.v1.0.0.json +110 -0
- package/src/cvcs/recencyBand.v1.0.0.json +104 -39
- package/src/cvcs/referralEntityCategory.v1.0.0.json +40 -40
- package/src/cvcs/relationshipConcern.v1.0.0.json +114 -0
- package/src/cvcs/riskCategory.v1.0.0.json +134 -0
- package/src/cvcs/riskSeverityBand.v1.0.0.json +139 -0
- package/src/cvcs/roiMethod.v1.0.0.json +107 -0
- package/src/cvcs/roiScope.v1.0.0.json +296 -0
- package/src/cvcs/roiStatus.v1.0.0.json +106 -0
- package/src/cvcs/romanticRelationshipChangeType.v1.0.0.json +162 -0
- package/src/cvcs/serviceAudience.v1.0.0.json +96 -0
- package/src/cvcs/serviceCategories.v1.0.0.json +44 -44
- package/src/cvcs/serviceDeliveryChannel.v1.0.0.json +147 -0
- package/src/cvcs/serviceMechanisms.v1.0.0.json +36 -36
- package/src/cvcs/serviceStates.v1.0.0.json +55 -33
- package/src/cvcs/sessionNoteVisibility.v1.0.0.json +80 -0
- package/src/cvcs/sessionTemplate.v1.0.0.json +261 -0
- package/src/cvcs/sexProviderSubrole.v1.0.0.json +35 -28
- package/src/cvcs/smtType.v1.0.0.json +40 -40
- package/src/cvcs/sourceCategory.v1.1.0.json +8 -1
- package/src/cvcs/sourceInstrument.v1.0.0.json +458 -0
- package/src/cvcs/sourceSubtype.v1.1.0.json +36 -0
- package/src/cvcs/sourceSystem.v1.0.0.json +203 -0
- package/src/cvcs/specialNeedsDisabilities.v1.0.0.json +143 -0
- package/src/cvcs/suggestionSource.v1.0.0.json +71 -0
- package/src/cvcs/traffickingRelevantRole.v1.0.0.json +104 -0
- package/src/cvcs/userRoles.v1.0.0.json +203 -0
- package/src/cvcs/verificationMethod.v1.0.0.json +18 -0
- package/src/cvcs/victimAbuseTypes.v1.0.0.json +276 -0
- package/src/cvcs/victimStatusFamily.v1.0.0.json +40 -40
- package/src/cvcs/whyNots.v1.0.0.json +385 -0
- package/src/generated/cvc-enums.ts +1729 -7
- package/src/mongo/catalog.ts +65 -0
- package/src/mongo/contract.ts +157 -0
- package/src/mongo/index.ts +343 -0
- package/src/mongo/similarity.ts +133 -0
- package/src/mongo/uri.ts +53 -0
- package/src/services/cvcRegistryService.ts +1 -1
- package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-BCj1OWqL.d.cts} +8 -8
- package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-BCj1OWqL.d.ts} +8 -8
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE CVC DRIFT GATE
|
|
3
|
+
* ==================
|
|
4
|
+
*
|
|
5
|
+
* platform-common's CVC surface is DOWNSTREAM of three sources of truth:
|
|
6
|
+
*
|
|
7
|
+
* CVC_INDEX.md -> the NUMBER space (which CVC number is whose)
|
|
8
|
+
* core_indicators.yaml -> the indicator CATALOG (what codes legitimately exist)
|
|
9
|
+
* hti-scoring emits_by_code -> what is actually CONSUMED (what must be expressible)
|
|
10
|
+
* Notion -> ratification
|
|
11
|
+
*
|
|
12
|
+
* Before this gate existed, platform-common validated itself against ITSELF. It
|
|
13
|
+
* therefore drifted, silently, in every direction at once. 0.8.13 found:
|
|
14
|
+
*
|
|
15
|
+
* - 66 canonical indicator codes MISSING from CVC-136 — including the entire
|
|
16
|
+
* perpetrator lane, which made facilitator scoring literally unexpressible.
|
|
17
|
+
* - 56 INVENTED codes that existed nowhere upstream and were consumed by nobody.
|
|
18
|
+
* - `housing_subsidy_types` SQUATTING on CVC-233, a number that canonically
|
|
19
|
+
* belongs to `core-DH_state`. The squat did not merely mislabel a domain: it
|
|
20
|
+
* made the slot look OCCUPIED, so the gap analysis never noticed that
|
|
21
|
+
* `dh_state` was missing ENTIRELY. **A wrong number HIDES the absence of the
|
|
22
|
+
* domain that owns that number.** That is the single most valuable thing this
|
|
23
|
+
* gate prevents (assertion C).
|
|
24
|
+
* - A false "CVC-69 is broken" conclusion, caused by comparing an ENTRY count
|
|
25
|
+
* against a SELECTABLE count (assertion F).
|
|
26
|
+
*
|
|
27
|
+
* Every assertion below maps to a real bug that shipped. This test is HERMETIC:
|
|
28
|
+
* it reads only the committed pins in `src/__sot__/`, so it runs on every PR with
|
|
29
|
+
* no cross-repo auth. The pins are refreshed (and upstream drift is detected) by
|
|
30
|
+
* `scripts/sot-pins.ts`, run weekly by `.github/workflows/cvc-sot-drift.yml`.
|
|
31
|
+
*
|
|
32
|
+
* THE TWO HALVES ARE BOTH REQUIRED:
|
|
33
|
+
* - this test = the ENFORCER (does the package match the pins?)
|
|
34
|
+
* - sot-pins = the DETECTOR (have the pins fallen behind upstream?)
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
38
|
+
import path from "node:path";
|
|
39
|
+
import { fileURLToPath } from "node:url";
|
|
40
|
+
|
|
41
|
+
import { describe, it, expect } from "vitest";
|
|
42
|
+
|
|
43
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
44
|
+
const CVCS_DIR = path.resolve(__dirname, "..", "cvcs");
|
|
45
|
+
const SOT_DIR = path.resolve(__dirname, "..", "__sot__");
|
|
46
|
+
|
|
47
|
+
// ─── The committed pins ─────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
interface Pin {
|
|
50
|
+
sourceRepo: string;
|
|
51
|
+
sourceFile: string;
|
|
52
|
+
sourceSha: string;
|
|
53
|
+
}
|
|
54
|
+
const cvcIndexPin = JSON.parse(
|
|
55
|
+
readFileSync(path.join(SOT_DIR, "cvcIndex.pin.json"), "utf-8"),
|
|
56
|
+
) as Pin & { numbers: Record<string, string[]> };
|
|
57
|
+
const coreIndicatorsPin = JSON.parse(
|
|
58
|
+
readFileSync(path.join(SOT_DIR, "coreIndicators.pin.json"), "utf-8"),
|
|
59
|
+
) as Pin & { codes: string[] };
|
|
60
|
+
const scoringEmitsPin = JSON.parse(
|
|
61
|
+
readFileSync(path.join(SOT_DIR, "scoringEmits.pin.json"), "utf-8"),
|
|
62
|
+
) as Pin & { codes: string[] };
|
|
63
|
+
|
|
64
|
+
// ─── The package under test ─────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
interface Entry {
|
|
67
|
+
code: string;
|
|
68
|
+
key: string;
|
|
69
|
+
selectable: boolean;
|
|
70
|
+
parentCode: string | null;
|
|
71
|
+
childCodes: string[];
|
|
72
|
+
}
|
|
73
|
+
interface Envelope {
|
|
74
|
+
domain: string;
|
|
75
|
+
entries: Entry[];
|
|
76
|
+
_status?: unknown;
|
|
77
|
+
}
|
|
78
|
+
interface Domain {
|
|
79
|
+
file: string;
|
|
80
|
+
domain: string;
|
|
81
|
+
cvc: number;
|
|
82
|
+
entries: Entry[];
|
|
83
|
+
env: Envelope;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const DOMAINS: Domain[] = readdirSync(CVCS_DIR)
|
|
87
|
+
.filter((f) => f.endsWith(".json"))
|
|
88
|
+
.sort()
|
|
89
|
+
.map((file) => {
|
|
90
|
+
const env = JSON.parse(
|
|
91
|
+
readFileSync(path.join(CVCS_DIR, file), "utf-8"),
|
|
92
|
+
) as Envelope;
|
|
93
|
+
return {
|
|
94
|
+
file,
|
|
95
|
+
domain: env.domain,
|
|
96
|
+
cvc: Number(env.entries[0]!.code.split("-")[0]),
|
|
97
|
+
entries: env.entries,
|
|
98
|
+
env,
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The provisional block. These are net-new vocabularies that Notion has not
|
|
104
|
+
* numbered yet; they are DELIBERATELY parked at 900+ and are exempt from the
|
|
105
|
+
* CVC_INDEX number check (there is nothing to check them against). This is the
|
|
106
|
+
* sanctioned escape hatch — it is what keeps "we needed a vocabulary" from
|
|
107
|
+
* turning into "we squatted on a canonical number".
|
|
108
|
+
*/
|
|
109
|
+
const PROVISIONAL_FLOOR = 900;
|
|
110
|
+
const isProvisional = (d: Domain): boolean => d.cvc >= PROVISIONAL_FLOOR;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Every canonical-block domain that CVC_INDEX.md DOES have a row for, bound to
|
|
114
|
+
* that row by EXACT STRING. No fuzzy matching: adding a domain forces you to
|
|
115
|
+
* state which index row it is, and a typo fails rather than silently "matching".
|
|
116
|
+
*/
|
|
117
|
+
const CANONICAL_BINDING: Record<string, { cvc: number; indexName: string }> = {
|
|
118
|
+
name_type: { cvc: 1, indexName: "core - name_type" },
|
|
119
|
+
orientation_identity: { cvc: 16, indexName: "core - orientation_identity" },
|
|
120
|
+
gender_identity: { cvc: 17, indexName: "core - gender_identity" },
|
|
121
|
+
victim_status_family: { cvc: 20, indexName: "core - victim_status_family" },
|
|
122
|
+
service_mechanisms: { cvc: 25, indexName: "core service mechanism" },
|
|
123
|
+
service_audience: { cvc: 45, indexName: "core service audience beneficiary" },
|
|
124
|
+
service_delivery_channel: { cvc: 47, indexName: "core service delivery channel" },
|
|
125
|
+
referral_entity_category: { cvc: 48, indexName: "core-referral_entity_category" },
|
|
126
|
+
service_states: { cvc: 49, indexName: "core - service state" },
|
|
127
|
+
age_bin_reporting: { cvc: 51, indexName: "core - age_bin_reporting" },
|
|
128
|
+
incident_participation_roles: { cvc: 69, indexName: "core - incident_participation_role" },
|
|
129
|
+
ht_type: { cvc: 72, indexName: "core - ht_type" },
|
|
130
|
+
victim_abuse_types: { cvc: 73, indexName: "core victim abuse types cvc" },
|
|
131
|
+
race_ethnicity: { cvc: 76, indexName: "core_Race:Ethnicity" },
|
|
132
|
+
share_purpose: { cvc: 84, indexName: "core - share_purpose" },
|
|
133
|
+
homeless_status: { cvc: 96, indexName: "core - homeless_status" },
|
|
134
|
+
military_branch: { cvc: 120, indexName: "core - military branch" },
|
|
135
|
+
military_status: { cvc: 121, indexName: "core - military status" },
|
|
136
|
+
person_relationships: { cvc: 126, indexName: "core person relationship CVC" },
|
|
137
|
+
incident_involvement_roles: { cvc: 130, indexName: "core - incident_involvement_role" },
|
|
138
|
+
user_roles: { cvc: 135, indexName: "core - user roles" },
|
|
139
|
+
core_indicators: { cvc: 136, indexName: "core - indicators" },
|
|
140
|
+
recency_band: { cvc: 137, indexName: "recency_band" },
|
|
141
|
+
determination_level: { cvc: 138, indexName: "core - determination_level" },
|
|
142
|
+
support_strength: { cvc: 139, indexName: "core - support_strength" },
|
|
143
|
+
source_category: { cvc: 140, indexName: "core - source_category" },
|
|
144
|
+
source_subtype: { cvc: 141, indexName: "core - source_subtype" },
|
|
145
|
+
inference_type: { cvc: 142, indexName: "core - inference_type" },
|
|
146
|
+
verification_method: { cvc: 143, indexName: "core - verification_method" },
|
|
147
|
+
quality_flags: { cvc: 144, indexName: "core - quality_flags" },
|
|
148
|
+
relationship_dynamics: { cvc: 145, indexName: "core relationship dynamics cvc" },
|
|
149
|
+
pronouns: { cvc: 147, indexName: "core - pronouns" },
|
|
150
|
+
contact_info_types: { cvc: 149, indexName: "core - contact info types" },
|
|
151
|
+
eye_color: { cvc: 150, indexName: "core - eye_color" },
|
|
152
|
+
hair_color: { cvc: 151, indexName: "core - hair_color" },
|
|
153
|
+
has_tattoos: { cvc: 152, indexName: "core - has_tattoos" },
|
|
154
|
+
smt_type: { cvc: 153, indexName: "core - SMT_type" },
|
|
155
|
+
contact_safety_status: { cvc: 155, indexName: "core-contact_safety_status" },
|
|
156
|
+
marital_status_legal: { cvc: 156, indexName: "core - marital status legal" },
|
|
157
|
+
relationship_status_current: { cvc: 157, indexName: "core - relationship status current" },
|
|
158
|
+
relationship_ties: { cvc: 158, indexName: "relationship ties cvc" },
|
|
159
|
+
assertion_domain: { cvc: 159, indexName: "core - assertion_domain" },
|
|
160
|
+
role_context: { cvc: 160, indexName: "core - role_context" },
|
|
161
|
+
sex_provider_subrole: { cvc: 161, indexName: "core - sex_provider_subrole" },
|
|
162
|
+
facilitator_subrole: { cvc: 162, indexName: "core - facilitator_subrole" },
|
|
163
|
+
offender_status: { cvc: 164, indexName: "core - offender_status" },
|
|
164
|
+
facilitator_entity_type: { cvc: 165, indexName: "core facilitator entity type" },
|
|
165
|
+
facilitator_label_used_in_source: {
|
|
166
|
+
cvc: 166,
|
|
167
|
+
indexName: "core - facilitator_label_used_in_source",
|
|
168
|
+
},
|
|
169
|
+
offender_status_family: { cvc: 167, indexName: "core - offender_status_family" },
|
|
170
|
+
income_benefits_sources: { cvc: 171, indexName: "core - income : benefits sources" },
|
|
171
|
+
time_scope: { cvc: 174, indexName: "core - time_scope" },
|
|
172
|
+
enrollment_application_status: { cvc: 175, indexName: "core - enrollment application status" },
|
|
173
|
+
frequency_cadence: { cvc: 176, indexName: "core - frequency : cadence" },
|
|
174
|
+
administering_jurisdiction: { cvc: 177, indexName: "core - administering jurisdiction" },
|
|
175
|
+
employment_status: { cvc: 179, indexName: "core - employment status" },
|
|
176
|
+
highest_education_level_completed: {
|
|
177
|
+
cvc: 180,
|
|
178
|
+
indexName: "core - highest education level_completed",
|
|
179
|
+
},
|
|
180
|
+
citizenship: { cvc: 182, indexName: "core - citizenship" },
|
|
181
|
+
location_type: { cvc: 191, indexName: "core - location_type" },
|
|
182
|
+
living_situation: { cvc: 192, indexName: "core - living situation" },
|
|
183
|
+
hmis_current_living_situation: { cvc: 193, indexName: "HMIS 4.12 - current living situation" },
|
|
184
|
+
housing_subsidy_types: { cvc: 194, indexName: "core - housing subsidy types" },
|
|
185
|
+
collection_context: { cvc: 195, indexName: "core - collection_context" },
|
|
186
|
+
juvenile_justice_episode_type: { cvc: 197, indexName: "core - juvenile_justice_episode_type" },
|
|
187
|
+
incarceration_episode_type: { cvc: 198, indexName: "core - incarceration episode type" },
|
|
188
|
+
source_system: { cvc: 201, indexName: "core - source_system" },
|
|
189
|
+
exploitation_type: { cvc: 203, indexName: "core - exploitation_type" },
|
|
190
|
+
source_instrument: { cvc: 209, indexName: "core - source_instrument" },
|
|
191
|
+
po_petition_basis: { cvc: 213, indexName: "core - PO_petition_basis CVC" },
|
|
192
|
+
po_status: { cvc: 214, indexName: "core - PO_status CVC" },
|
|
193
|
+
po_violation_status: { cvc: 215, indexName: "core PO violation status CVC" },
|
|
194
|
+
session_template: { cvc: 217, indexName: "core - session templates" },
|
|
195
|
+
languages: { cvc: 223, indexName: "core-languages" },
|
|
196
|
+
dh_state: { cvc: 233, indexName: "core-DH_state" },
|
|
197
|
+
risk_severity_band: { cvc: 238, indexName: "core-risk_severity_band" },
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Canonical-block domains that CVC_INDEX.md has NO row for. They are NOT
|
|
202
|
+
* exempt from the squat check (assertion C3) — they are merely unconstrained by
|
|
203
|
+
* a name, because the index says nothing about their number. Listing them here
|
|
204
|
+
* is the point: an index-absent domain must be a DELIBERATE, visible decision,
|
|
205
|
+
* never a silent one. Each is a Notion reconciliation item.
|
|
206
|
+
*/
|
|
207
|
+
const INDEX_ABSENT: Record<string, { cvc: number; reason: string }> = {
|
|
208
|
+
// CVC_INDEX.md is auto-generated by tools/extract_final_cvcs.py, which emits
|
|
209
|
+
// one row per readable `.md`. This CVC's Notion page body exported as PDF
|
|
210
|
+
// only, so the extractor skips it — the SAME documented gap that CVC_INDEX.md
|
|
211
|
+
// itself records at line 20 for core-DH_state/233. Its canonical codebook
|
|
212
|
+
// `.csv` (+ `.zip`, `.pdf`) IS present in Final CVCs/, and both yamls that
|
|
213
|
+
// mention 235 agree this vocabulary owns it.
|
|
214
|
+
trafficking_relevant_role: { cvc: 235, reason: "extractor gap: Notion body is PDF-only" },
|
|
215
|
+
|
|
216
|
+
// Numbered from the domain's own canonical source (a codebook `.csv`, a
|
|
217
|
+
// `data/cvcs/*.yaml` self-declaration, or a prior platform-common release),
|
|
218
|
+
// but CVC_INDEX.md carries no row. Not a squat (nothing else claims these
|
|
219
|
+
// numbers) — but each needs a Notion index row to become verifiable.
|
|
220
|
+
service_categories: { cvc: 22, reason: "no CVC_INDEX row" },
|
|
221
|
+
// Trunk-only domain: authored on `kl-develop` (80341e0, "promote CVC-17 +
|
|
222
|
+
// CVC-67 to SOT"), which the canonical 0.8.13 line never saw. Its sibling
|
|
223
|
+
// CVC-17 (gender_identity) IS in CVC_INDEX.md and is bound above; 67 is not
|
|
224
|
+
// — CVC_INDEX.md carries no row, Final CVCs/ carries no codebook, and no
|
|
225
|
+
// other domain claims 67, so it is index-absent rather than a squat. Sourced
|
|
226
|
+
// from the HMIS data standard via `CVC_67_HMIS_SEX` in `../constants/ic.ts`.
|
|
227
|
+
hmis_sex: { cvc: 67, reason: "no CVC_INDEX row" },
|
|
228
|
+
juvenile_justice_involvement_status: { cvc: 95, reason: "no CVC_INDEX row" },
|
|
229
|
+
primary_language: { cvc: 122, reason: "no CVC_INDEX row" },
|
|
230
|
+
hmis_relationship_to_hoh: { cvc: 129, reason: "no CVC_INDEX row" },
|
|
231
|
+
core_functions: { cvc: 133, reason: "no CVC_INDEX row" },
|
|
232
|
+
admin_roles: { cvc: 134, reason: "no CVC_INDEX row" },
|
|
233
|
+
tribes: { cvc: 148, reason: "no CVC_INDEX row" },
|
|
234
|
+
contact_info_use_type: { cvc: 154, reason: "no CVC_INDEX row" },
|
|
235
|
+
preferred_contact_method: { cvc: 185, reason: "no CVC_INDEX row" },
|
|
236
|
+
session_state: { cvc: 216, reason: "no CVC_INDEX row" },
|
|
237
|
+
why_nots: { cvc: 219, reason: "no CVC_INDEX row" },
|
|
238
|
+
exit_reasons: { cvc: 220, reason: "no CVC_INDEX row" },
|
|
239
|
+
mid_stay_event_type: { cvc: 221, reason: "no CVC_INDEX row" },
|
|
240
|
+
pet_exit_reason: { cvc: 222, reason: "no CVC_INDEX row" },
|
|
241
|
+
hmis_project_type: { cvc: 225, reason: "no CVC_INDEX row" },
|
|
242
|
+
funder: { cvc: 226, reason: "no CVC_INDEX row" },
|
|
243
|
+
da_incident_severity: { cvc: 228, reason: "no CVC_INDEX row" },
|
|
244
|
+
relationship_concern: { cvc: 231, reason: "no CVC_INDEX row" },
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The ONLY codes CVC-136 may carry that `core_indicators.yaml` does not.
|
|
249
|
+
* @hti/scoring EMITS these two, so dropping them would break the scoring
|
|
250
|
+
* contract — scoring is genuinely AHEAD of the catalog here. They are flagged
|
|
251
|
+
* `pendingUpstreamAdoption: true` in the SOT JSON. Upstream must adopt or
|
|
252
|
+
* deprecate them; until then this list must stay EXACTLY these two.
|
|
253
|
+
*/
|
|
254
|
+
const SCORING_AHEAD_OF_CATALOG: readonly string[] = [
|
|
255
|
+
"coercive_debt_pressure_youth",
|
|
256
|
+
"debt_terms_deceptive_youth",
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
260
|
+
|
|
261
|
+
const CODE_RE = /^\d{3}(-\d{3}){6}$/;
|
|
262
|
+
const KEY_RE = /^[a-z][a-z0-9_]*$/;
|
|
263
|
+
const isMissingness = (e: Entry): boolean => e.code.split("-")[1] === "000";
|
|
264
|
+
const substantiveOf = (d: Domain): Entry[] => d.entries.filter((e) => !isMissingness(e));
|
|
265
|
+
|
|
266
|
+
const cvc136 = DOMAINS.find((d) => d.domain === "core_indicators")!;
|
|
267
|
+
const cvc136Keys = new Set(substantiveOf(cvc136).map((e) => e.key));
|
|
268
|
+
|
|
269
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
270
|
+
// A. SCORING EXPRESSIBILITY
|
|
271
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
272
|
+
describe("GATE A — every code @hti/scoring emits exists in CVC-136", () => {
|
|
273
|
+
it(`all ${scoringEmitsPin.codes.length} emitted codes are expressible`, () => {
|
|
274
|
+
const missing = scoringEmitsPin.codes.filter((c) => !cvc136Keys.has(c));
|
|
275
|
+
if (missing.length > 0) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
`${missing.length} code(s) that @hti/scoring EMITS do not exist in CVC-136.\n` +
|
|
278
|
+
"The risk pipeline would write assertions against codes that resolve to NOTHING.\n" +
|
|
279
|
+
`(This is how the entire perpetrator lane went missing — facilitator scoring\n` +
|
|
280
|
+
" was unexpressible for an entire release.)\n\n" +
|
|
281
|
+
` MISSING: ${missing.join(", ")}\n\n` +
|
|
282
|
+
"TO FIX: add each code to src/cvcs/coreIndicators.v1.0.0.json (sourced from\n" +
|
|
283
|
+
` ${coreIndicatorsPin.sourceRepo}/${coreIndicatorsPin.sourceFile}` +
|
|
284
|
+
` @ ${coreIndicatorsPin.sourceSha}),\n` +
|
|
285
|
+
" then regenerate CVC_136_CORE_INDICATOR_VALUES in src/constants/ic.ts.\n" +
|
|
286
|
+
`PIN: ${scoringEmitsPin.sourceRepo}/${scoringEmitsPin.sourceFile}` +
|
|
287
|
+
` @ ${scoringEmitsPin.sourceSha}`,
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
expect(missing).toEqual([]);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
295
|
+
// B. NO INVENTION
|
|
296
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
297
|
+
describe("GATE B — CVC-136 invents nothing", () => {
|
|
298
|
+
const catalog = new Set(coreIndicatorsPin.codes);
|
|
299
|
+
const allowed = new Set(SCORING_AHEAD_OF_CATALOG);
|
|
300
|
+
|
|
301
|
+
it("every CVC-136 code is in core_indicators.yaml or the annotated allowlist", () => {
|
|
302
|
+
const invented = [...cvc136Keys].filter((k) => !catalog.has(k) && !allowed.has(k)).sort();
|
|
303
|
+
if (invented.length > 0) {
|
|
304
|
+
throw new Error(
|
|
305
|
+
`${invented.length} INVENTED code(s) in CVC-136 — they exist in neither\n` +
|
|
306
|
+
` ${coreIndicatorsPin.sourceFile} @ ${coreIndicatorsPin.sourceSha} ` +
|
|
307
|
+
`(${coreIndicatorsPin.codes.length} codes)\n` +
|
|
308
|
+
" nor the SCORING_AHEAD_OF_CATALOG allowlist.\n" +
|
|
309
|
+
"(0.8.12 shipped 56 of these — `vc_*`, `csi_*`, `csctx_*`, `dv_*`, `net_*`,\n" +
|
|
310
|
+
" `auto_*` rollup prefixes consumed by nobody. They are not indicators.)\n\n" +
|
|
311
|
+
` INVENTED: ${invented.join(", ")}\n\n` +
|
|
312
|
+
"TO FIX: remove them from src/cvcs/coreIndicators.v1.0.0.json — OR, if\n" +
|
|
313
|
+
" @hti/scoring genuinely emits them ahead of the catalog, add them to\n" +
|
|
314
|
+
" SCORING_AHEAD_OF_CATALOG in this file WITH `pendingUpstreamAdoption: true`\n" +
|
|
315
|
+
" on the entry, and raise adoption with the codebook owner.",
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
expect(invented).toEqual([]);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("the scoring-ahead allowlist is EXACTLY the 2 known codes, each flagged", () => {
|
|
322
|
+
// Guard the escape hatch: it must not quietly become a dumping ground.
|
|
323
|
+
expect([...SCORING_AHEAD_OF_CATALOG].sort()).toEqual([
|
|
324
|
+
"coercive_debt_pressure_youth",
|
|
325
|
+
"debt_terms_deceptive_youth",
|
|
326
|
+
]);
|
|
327
|
+
for (const code of SCORING_AHEAD_OF_CATALOG) {
|
|
328
|
+
expect(scoringEmitsPin.codes, `${code} must actually be emitted by scoring`).toContain(code);
|
|
329
|
+
expect(coreIndicatorsPin.codes, `${code} must still be absent upstream`).not.toContain(code);
|
|
330
|
+
const entry = substantiveOf(cvc136).find((e) => e.key === code) as unknown as
|
|
331
|
+
| Record<string, unknown>
|
|
332
|
+
| undefined;
|
|
333
|
+
expect(entry?.["pendingUpstreamAdoption"], `${code} must be flagged`).toBe(true);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
339
|
+
// C. NUMBER <-> NAME AGREEMENT — the squat catcher
|
|
340
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
341
|
+
describe("GATE C — every CVC number matches CVC_INDEX.md", () => {
|
|
342
|
+
it("every domain is bound, index-absent, or provisional — nothing is unclassified", () => {
|
|
343
|
+
const unclassified = DOMAINS.filter(
|
|
344
|
+
(d) => !isProvisional(d) && !CANONICAL_BINDING[d.domain] && !INDEX_ABSENT[d.domain],
|
|
345
|
+
).map((d) => `${d.file} (${d.domain} @ CVC-${d.cvc})`);
|
|
346
|
+
if (unclassified.length > 0) {
|
|
347
|
+
throw new Error(
|
|
348
|
+
"Domain(s) with a canonical-block number (<900) that this gate has never seen:\n" +
|
|
349
|
+
unclassified.map((s) => ` ${s}`).join("\n") +
|
|
350
|
+
"\n\nTO FIX: add each to CANONICAL_BINDING (with the EXACT CVC_INDEX.md row name)\n" +
|
|
351
|
+
" or to INDEX_ABSENT (with a reason) in this file — or park it at 900+ if it is\n" +
|
|
352
|
+
" a net-new vocabulary Notion has not numbered yet.",
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
expect(unclassified).toEqual([]);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it("each bound domain sits on the number CVC_INDEX.md gives its name", () => {
|
|
359
|
+
const bad: string[] = [];
|
|
360
|
+
for (const d of DOMAINS) {
|
|
361
|
+
const bind = CANONICAL_BINDING[d.domain];
|
|
362
|
+
if (!bind) continue;
|
|
363
|
+
if (d.cvc !== bind.cvc) {
|
|
364
|
+
bad.push(
|
|
365
|
+
`${d.file}: ships CVC-${d.cvc} but CANONICAL_BINDING says CVC-${bind.cvc}`,
|
|
366
|
+
);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
const names = cvcIndexPin.numbers[String(bind.cvc)];
|
|
370
|
+
if (!names?.includes(bind.indexName)) {
|
|
371
|
+
bad.push(
|
|
372
|
+
`${d.file}: CVC_INDEX.md row for CVC-${bind.cvc} is ` +
|
|
373
|
+
`${JSON.stringify(names ?? null)}, not "${bind.indexName}"`,
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (bad.length > 0) {
|
|
378
|
+
throw new Error(
|
|
379
|
+
"CVC number/name disagreement with CVC_INDEX.md:\n" +
|
|
380
|
+
bad.map((s) => ` ${s}`).join("\n") +
|
|
381
|
+
`\n\nPIN: ${cvcIndexPin.sourceRepo}/${cvcIndexPin.sourceFile}` +
|
|
382
|
+
` @ ${cvcIndexPin.sourceSha}`,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
expect(bad).toEqual([]);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* THE ONE THAT MATTERS. A domain may not occupy a number that CVC_INDEX.md
|
|
390
|
+
* assigns to a DIFFERENT domain — because a squat does not just mislabel the
|
|
391
|
+
* squatter, it makes the slot look occupied and thereby HIDES the absence of
|
|
392
|
+
* the domain that actually owns the number. `housing_subsidy_types` sat on
|
|
393
|
+
* CVC-233 and that is precisely why nobody noticed `core-DH_state` had never
|
|
394
|
+
* been authored at all.
|
|
395
|
+
*/
|
|
396
|
+
it("NO domain squats on a number CVC_INDEX.md assigns to someone else", () => {
|
|
397
|
+
const squats: string[] = [];
|
|
398
|
+
for (const d of DOMAINS) {
|
|
399
|
+
if (isProvisional(d)) continue;
|
|
400
|
+
const names = cvcIndexPin.numbers[String(d.cvc)];
|
|
401
|
+
if (!names) continue; // index says nothing about this number — no constraint
|
|
402
|
+
const claimed = CANONICAL_BINDING[d.domain]?.indexName;
|
|
403
|
+
if (!claimed || !names.includes(claimed)) {
|
|
404
|
+
squats.push(
|
|
405
|
+
` ${d.file}\n` +
|
|
406
|
+
` domain "${d.domain}" occupies CVC-${d.cvc},\n` +
|
|
407
|
+
` but CVC_INDEX.md assigns CVC-${d.cvc} to ${JSON.stringify(names)}.`,
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (squats.length > 0) {
|
|
412
|
+
throw new Error(
|
|
413
|
+
"CVC NUMBER SQUAT.\n\n" +
|
|
414
|
+
squats.join("\n") +
|
|
415
|
+
"\n\nA wrong number does not merely mislabel a domain — it HIDES THE ABSENCE\n" +
|
|
416
|
+
"of the domain that owns that number. Renumber the squatter to its own\n" +
|
|
417
|
+
"canonical number (or park it at 900+), THEN check whether the rightful\n" +
|
|
418
|
+
"owner of this number has ever been authored at all.\n" +
|
|
419
|
+
`\nPIN: ${cvcIndexPin.sourceRepo}/${cvcIndexPin.sourceFile}` +
|
|
420
|
+
` @ ${cvcIndexPin.sourceSha}`,
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
expect(squats).toEqual([]);
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
428
|
+
// D. NO NUMBER COLLISIONS
|
|
429
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
430
|
+
describe("GATE D — no two domains share a CVC number", () => {
|
|
431
|
+
it("segment-1 numbers are unique across all shipped domains", () => {
|
|
432
|
+
const byNum = new Map<number, string[]>();
|
|
433
|
+
for (const d of DOMAINS) {
|
|
434
|
+
byNum.set(d.cvc, [...(byNum.get(d.cvc) ?? []), d.file]);
|
|
435
|
+
}
|
|
436
|
+
const collisions = [...byNum.entries()].filter(([, files]) => files.length > 1);
|
|
437
|
+
if (collisions.length > 0) {
|
|
438
|
+
throw new Error(
|
|
439
|
+
"CVC number collision — two domains claim the same segment-1 number:\n" +
|
|
440
|
+
collisions
|
|
441
|
+
.map(([n, files]) => ` CVC-${n}: ${files.join(", ")}`)
|
|
442
|
+
.join("\n") +
|
|
443
|
+
"\n\nTO FIX: one of them is wrong. Check CVC_INDEX.md for the rightful owner;\n" +
|
|
444
|
+
" park the other at 900+ if it has no canonical number.",
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
expect(collisions).toEqual([]);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
452
|
+
// E. MISSINGNESS
|
|
453
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
454
|
+
/**
|
|
455
|
+
* NOTE ON SCOPE — this asserts the missingness BLOCK is well-formed and leads
|
|
456
|
+
* the entry list. It deliberately does NOT demand the full quadruplet
|
|
457
|
+
* (missingness_root / unknown / anonymous / data_not_collected) in every domain,
|
|
458
|
+
* because that is NOT TRUE UPSTREAM and forcing it would INVENT codes — the very
|
|
459
|
+
* thing gate B forbids. Verified against the canonical codebooks:
|
|
460
|
+
*
|
|
461
|
+
* share_purpose (CVC-84) ........ 8 rows, ZERO missingness rows
|
|
462
|
+
* military_status (CVC-121) ..... ZERO missingness rows
|
|
463
|
+
* military_branch (CVC-120) ..... ZERO missingness rows
|
|
464
|
+
* person_relationships (CVC-126) DNC + ANON only — deliberately no UNK
|
|
465
|
+
* juvenile_justice_involvement_status (CVC-95)
|
|
466
|
+
* UNK + "Prefer not to answer" + DNC — no ANON
|
|
467
|
+
*
|
|
468
|
+
* Missingness is a per-domain canonical VARIANT, not a universal constant.
|
|
469
|
+
*/
|
|
470
|
+
describe("GATE E — the missingness block is well-formed and leads every domain", () => {
|
|
471
|
+
const CANON_ORDER = ["missingness_root", "unknown", "anonymous", "data_not_collected"];
|
|
472
|
+
|
|
473
|
+
for (const d of DOMAINS) {
|
|
474
|
+
const block = d.entries.filter(isMissingness);
|
|
475
|
+
const firstSubstantiveIdx = d.entries.findIndex((e) => !isMissingness(e));
|
|
476
|
+
|
|
477
|
+
it(`${d.file}: missingness block is contiguous and FIRST`, () => {
|
|
478
|
+
// Every missingness entry must precede every substantive entry.
|
|
479
|
+
const misplaced = d.entries
|
|
480
|
+
.map((e, i) => ({ e, i }))
|
|
481
|
+
.filter(
|
|
482
|
+
({ e, i }) =>
|
|
483
|
+
isMissingness(e) && firstSubstantiveIdx !== -1 && i > firstSubstantiveIdx,
|
|
484
|
+
)
|
|
485
|
+
.map(({ e }) => e.key);
|
|
486
|
+
if (misplaced.length > 0) {
|
|
487
|
+
throw new Error(
|
|
488
|
+
`${d.file}: missingness entries appear AFTER substantive entries: ` +
|
|
489
|
+
`${misplaced.join(", ")}.\n` +
|
|
490
|
+
"TO FIX: move the whole segment-2 == 000 block to the top of `entries`.",
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
expect(misplaced).toEqual([]);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it(`${d.file}: canonical missingness members lead the block, in order`, () => {
|
|
497
|
+
const present = block.map((e) => e.key).filter((k) => CANON_ORDER.includes(k));
|
|
498
|
+
const expected = CANON_ORDER.filter((k) => present.includes(k));
|
|
499
|
+
expect(present, `${d.file}: canonical missingness members out of order`).toEqual(expected);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
if (block.length > 0) {
|
|
503
|
+
it(`${d.file}: missingness_root.childCodes is the exact inverse of parentCode`, () => {
|
|
504
|
+
const root = block.find((e) => e.key === "missingness_root");
|
|
505
|
+
expect(root, `${d.file} has a missingness block but no missingness_root`).toBeDefined();
|
|
506
|
+
const children = block.filter((e) => e.key !== "missingness_root");
|
|
507
|
+
expect(root!.selectable, `${d.file}: missingness_root must not be selectable`).toBe(false);
|
|
508
|
+
expect([...root!.childCodes].sort()).toEqual(children.map((c) => c.code).sort());
|
|
509
|
+
for (const c of children) {
|
|
510
|
+
expect(c.parentCode, `${d.file}: ${c.key}.parentCode`).toBe(root!.code);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
518
|
+
// F. SELECTABLE-AWARE COUNTING
|
|
519
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
520
|
+
/**
|
|
521
|
+
* An ENTRY count is not a SELECTABLE count. A hierarchical CVC also carries
|
|
522
|
+
* non-selectable GROUP rows and a non-selectable missingness_root. Comparing an
|
|
523
|
+
* entry count against a selectable count produces a phantom bug — that is
|
|
524
|
+
* exactly how "CVC-69 is broken" was concluded, when CVC-69 was fine all along.
|
|
525
|
+
*/
|
|
526
|
+
describe("GATE F — entry counts and selectable counts are never conflated", () => {
|
|
527
|
+
it("every domain decomposes exactly: entries = selectable + non-selectable", () => {
|
|
528
|
+
for (const d of DOMAINS) {
|
|
529
|
+
const sel = d.entries.filter((e) => e.selectable).length;
|
|
530
|
+
const non = d.entries.filter((e) => !e.selectable).length;
|
|
531
|
+
expect(sel + non, `${d.file}`).toBe(d.entries.length);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it("CVC-69 regression: 19 entries = 14 selectable + 4 group rows + missingness_root", () => {
|
|
536
|
+
const d = DOMAINS.find((x) => x.domain === "incident_participation_roles")!;
|
|
537
|
+
const selectable = d.entries.filter((e) => e.selectable);
|
|
538
|
+
const groupRows = d.entries.filter((e) => !e.selectable && !isMissingness(e));
|
|
539
|
+
const missRoot = d.entries.filter((e) => !e.selectable && isMissingness(e));
|
|
540
|
+
|
|
541
|
+
expect(d.entries.length, "total entries").toBe(19);
|
|
542
|
+
expect(selectable.length, "selectable").toBe(14);
|
|
543
|
+
expect(groupRows.length, "non-selectable group rows").toBe(4);
|
|
544
|
+
expect(missRoot.length, "non-selectable missingness_root").toBe(1);
|
|
545
|
+
expect(selectable.length + groupRows.length + missRoot.length).toBe(19);
|
|
546
|
+
// If a consumer's boot-check ever asserts `entries.length === 14`, it is the
|
|
547
|
+
// CONSUMER that is wrong, not CVC-69.
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
552
|
+
// G. CODE / KEY FORMAT
|
|
553
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
554
|
+
describe("GATE G — code and key format", () => {
|
|
555
|
+
for (const d of DOMAINS) {
|
|
556
|
+
it(`${d.file}: codes match ${String(CODE_RE)}, segment 1 == CVC-${d.cvc}, keys are slugs`, () => {
|
|
557
|
+
const errs: string[] = [];
|
|
558
|
+
const seen = new Set<string>();
|
|
559
|
+
for (const e of d.entries) {
|
|
560
|
+
if (!CODE_RE.test(e.code)) errs.push(`bad code format: "${e.code}" (${e.key})`);
|
|
561
|
+
const seg1 = Number(e.code.split("-")[0]);
|
|
562
|
+
if (seg1 !== d.cvc) {
|
|
563
|
+
errs.push(
|
|
564
|
+
`"${e.code}" (${e.key}) has segment 1 = ${seg1}, but the domain is CVC-${d.cvc}`,
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
if (!KEY_RE.test(e.key)) errs.push(`bad key: "${e.key}" must match ${String(KEY_RE)}`);
|
|
568
|
+
if (seen.has(e.key)) errs.push(`duplicate key: "${e.key}"`);
|
|
569
|
+
seen.add(e.key);
|
|
570
|
+
if (seen.has(e.code)) errs.push(`duplicate code: "${e.code}"`);
|
|
571
|
+
}
|
|
572
|
+
if (errs.length > 0) {
|
|
573
|
+
throw new Error(`${d.file}:\n${errs.map((s) => ` ${s}`).join("\n")}`);
|
|
574
|
+
}
|
|
575
|
+
expect(errs).toEqual([]);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
581
|
+
// Pin provenance — the pins must say where they came from.
|
|
582
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
583
|
+
describe("SOT pins carry their provenance", () => {
|
|
584
|
+
it("each pin names its repo, file and SHA", () => {
|
|
585
|
+
for (const [name, pin] of [
|
|
586
|
+
["cvcIndex", cvcIndexPin],
|
|
587
|
+
["coreIndicators", coreIndicatorsPin],
|
|
588
|
+
["scoringEmits", scoringEmitsPin],
|
|
589
|
+
] as const) {
|
|
590
|
+
expect(pin.sourceRepo, `${name}.sourceRepo`).toMatch(/^htilabstech\//);
|
|
591
|
+
expect(pin.sourceFile, `${name}.sourceFile`).toBeTruthy();
|
|
592
|
+
expect(pin.sourceSha, `${name}.sourceSha`).toMatch(/^[0-9a-f]{7,40}$/);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
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");
|
|
599
|
+
expect(scoringEmitsPin.sourceSha).toBe("9b5d654");
|
|
600
|
+
expect(coreIndicatorsPin.codes.length).toBe(208);
|
|
601
|
+
expect(scoringEmitsPin.codes.length).toBe(169);
|
|
602
|
+
});
|
|
603
|
+
});
|