@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.
Files changed (149) hide show
  1. package/dist/config/index.cjs +85 -0
  2. package/dist/config/index.cjs.map +1 -1
  3. package/dist/config/index.d.cts +94 -4
  4. package/dist/config/index.d.ts +94 -4
  5. package/dist/config/index.js +81 -1
  6. package/dist/config/index.js.map +1 -1
  7. package/dist/constants/index.cjs +456 -181
  8. package/dist/constants/index.cjs.map +1 -1
  9. package/dist/constants/index.d.cts +1 -1
  10. package/dist/constants/index.d.ts +1 -1
  11. package/dist/constants/index.js +453 -169
  12. package/dist/constants/index.js.map +1 -1
  13. package/dist/cvcs/index.cjs +15331 -801
  14. package/dist/cvcs/index.cjs.map +1 -1
  15. package/dist/cvcs/index.d.cts +18167 -2208
  16. package/dist/cvcs/index.d.ts +18167 -2208
  17. package/dist/cvcs/index.js +15282 -801
  18. package/dist/cvcs/index.js.map +1 -1
  19. package/dist/{index-Zu_mOJRn.d.cts → index-CoVr1jIV.d.cts} +1 -1
  20. package/dist/{index-CDoqrfc1.d.ts → index-I-DiX9eQ.d.ts} +1 -1
  21. package/dist/index.cjs +17070 -1056
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +1638 -12
  24. package/dist/index.d.ts +1638 -12
  25. package/dist/index.js +16969 -1043
  26. package/dist/index.js.map +1 -1
  27. package/dist/models/index.d.cts +2 -2
  28. package/dist/models/index.d.ts +2 -2
  29. package/dist/mongo/index.cjs +384 -0
  30. package/dist/mongo/index.cjs.map +1 -0
  31. package/dist/mongo/index.d.cts +221 -0
  32. package/dist/mongo/index.d.ts +221 -0
  33. package/dist/mongo/index.js +352 -0
  34. package/dist/mongo/index.js.map +1 -0
  35. package/dist/{platform-auth-XVB9aHqR.d.cts → platform-auth-v53r3BhN.d.cts} +19 -75
  36. package/dist/{platform-auth-XVB9aHqR.d.ts → platform-auth-v53r3BhN.d.ts} +19 -75
  37. package/dist/schemas/index.cjs +25 -156
  38. package/dist/schemas/index.cjs.map +1 -1
  39. package/dist/schemas/index.d.cts +25 -25
  40. package/dist/schemas/index.d.ts +25 -25
  41. package/dist/schemas/index.js +25 -156
  42. package/dist/schemas/index.js.map +1 -1
  43. package/dist/services/index.cjs +0 -3
  44. package/dist/services/index.cjs.map +1 -1
  45. package/dist/services/index.js +0 -3
  46. package/dist/services/index.js.map +1 -1
  47. package/dist/types/index.d.cts +2 -2
  48. package/dist/types/index.d.ts +2 -2
  49. package/package.json +9 -1
  50. package/src/__sot__/README.md +56 -0
  51. package/src/__sot__/coreIndicators.pin.json +215 -0
  52. package/src/__sot__/cvcIndex.pin.json +268 -0
  53. package/src/__sot__/scoringEmits.pin.json +176 -0
  54. package/src/__tests__/__snapshots__/cvc-sot.snap +227 -35
  55. package/src/__tests__/cvc-136-scoring-invariant.test.ts +323 -0
  56. package/src/__tests__/cvc-drift-gate.test.ts +603 -0
  57. package/src/__tests__/cvc-sot-snapshot.test.ts +122 -11
  58. package/src/__tests__/cvc-structural.test.ts +56 -1
  59. package/src/__tests__/mongo-verifier.test.ts +502 -0
  60. package/src/__tests__/runtime-contract-validator.test.ts +325 -1
  61. package/src/config/index.ts +197 -6
  62. package/src/constants/ic.ts +512 -206
  63. package/src/constants/service-catalog.ts +4 -2
  64. package/src/cvcs/activityType.v1.0.0.json +143 -0
  65. package/src/cvcs/adminRoles.v1.0.0.json +153 -0
  66. package/src/cvcs/administeringJurisdiction.v1.0.0.json +40 -40
  67. package/src/cvcs/ageBinReporting.v1.0.0.json +40 -40
  68. package/src/cvcs/assertionDomain.v1.1.0.json +629 -0
  69. package/src/cvcs/{checkInPhase.v1.0.0.json → checkInPhase.v1.1.0.json} +20 -2
  70. package/src/cvcs/childChangeType.v1.0.0.json +152 -0
  71. package/src/cvcs/citizenship.v1.0.0.json +3062 -0
  72. package/src/cvcs/contactInfoTypes.v1.0.0.json +40 -40
  73. package/src/cvcs/contactLinkType.v1.0.0.json +89 -0
  74. package/src/cvcs/coreDhState.v1.0.0.json +113 -0
  75. package/src/cvcs/coreFunctions.v1.0.0.json +746 -0
  76. package/src/cvcs/coreIndicators.v1.0.0.json +2840 -0
  77. package/src/cvcs/coreReferralOutcome.v1.0.0.json +71 -0
  78. package/src/cvcs/employmentStatus.v1.0.0.json +60 -60
  79. package/src/cvcs/exploitationType.v1.0.0.json +106 -0
  80. package/src/cvcs/facilitatorEntityType.v1.0.0.json +40 -40
  81. package/src/cvcs/highestEducationLevelCompleted.v1.0.0.json +55 -46
  82. package/src/cvcs/hivStatus.v1.0.0.json +71 -0
  83. package/src/cvcs/hmisCurrentLivingSituation.v1.0.0.json +409 -0
  84. package/src/cvcs/hmisRelationshipToHoh.v1.0.0.json +104 -0
  85. package/src/cvcs/homelessStatus.v1.0.0.json +27 -27
  86. package/src/cvcs/housingSubsidyTypes.v1.0.0.json +161 -0
  87. package/src/cvcs/htType.v1.0.0.json +87 -0
  88. package/src/cvcs/identificationStatus.v1.0.0.json +18 -0
  89. package/src/cvcs/immigrationLegalStatusChangeType.v1.0.0.json +143 -0
  90. package/src/cvcs/incarcerationEpisodeType.v1.0.0.json +106 -0
  91. package/src/cvcs/incidentInvolvementRoles.v1.0.0.json +40 -40
  92. package/src/cvcs/incidentParticipationRoles.v1.0.0.json +40 -40
  93. package/src/cvcs/incomeBenefitsSources.v1.0.0.json +31 -2
  94. package/src/cvcs/index.ts +106 -1
  95. package/src/cvcs/juvenileJusticeEpisodeType.v1.0.0.json +28 -18
  96. package/src/cvcs/juvenileJusticeInvolvementStatus.v1.0.0.json +32 -32
  97. package/src/cvcs/livingSituation.v1.0.0.json +213 -0
  98. package/src/cvcs/mentalHealthStatus.v1.0.0.json +71 -0
  99. package/src/cvcs/militaryBranch.v1.0.0.json +20 -20
  100. package/src/cvcs/militaryStatus.v1.0.0.json +20 -20
  101. package/src/cvcs/nameType.v1.0.0.json +40 -40
  102. package/src/cvcs/needsAssessmentChangeType.v1.0.0.json +134 -0
  103. package/src/cvcs/offenderStatus.v1.0.0.json +40 -40
  104. package/src/cvcs/offenderStatusFamily.v1.0.0.json +36 -36
  105. package/src/cvcs/poPetitionBasis.v1.0.0.json +96 -0
  106. package/src/cvcs/poStatus.v1.0.0.json +144 -0
  107. package/src/cvcs/poViolationStatus.v1.0.0.json +76 -0
  108. package/src/cvcs/programEnrollmentChangeType.v1.0.0.json +134 -0
  109. package/src/cvcs/provenanceSourceId.v1.0.0.json +134 -0
  110. package/src/cvcs/radiusBucket.v1.0.0.json +110 -0
  111. package/src/cvcs/recencyBand.v1.0.0.json +104 -39
  112. package/src/cvcs/referralEntityCategory.v1.0.0.json +40 -40
  113. package/src/cvcs/relationshipConcern.v1.0.0.json +114 -0
  114. package/src/cvcs/riskCategory.v1.0.0.json +134 -0
  115. package/src/cvcs/riskSeverityBand.v1.0.0.json +139 -0
  116. package/src/cvcs/roiMethod.v1.0.0.json +107 -0
  117. package/src/cvcs/roiScope.v1.0.0.json +296 -0
  118. package/src/cvcs/roiStatus.v1.0.0.json +106 -0
  119. package/src/cvcs/romanticRelationshipChangeType.v1.0.0.json +162 -0
  120. package/src/cvcs/serviceAudience.v1.0.0.json +96 -0
  121. package/src/cvcs/serviceCategories.v1.0.0.json +44 -44
  122. package/src/cvcs/serviceDeliveryChannel.v1.0.0.json +147 -0
  123. package/src/cvcs/serviceMechanisms.v1.0.0.json +36 -36
  124. package/src/cvcs/serviceStates.v1.0.0.json +55 -33
  125. package/src/cvcs/sessionNoteVisibility.v1.0.0.json +80 -0
  126. package/src/cvcs/sessionTemplate.v1.0.0.json +261 -0
  127. package/src/cvcs/sexProviderSubrole.v1.0.0.json +35 -28
  128. package/src/cvcs/smtType.v1.0.0.json +40 -40
  129. package/src/cvcs/sourceCategory.v1.1.0.json +8 -1
  130. package/src/cvcs/sourceInstrument.v1.0.0.json +458 -0
  131. package/src/cvcs/sourceSubtype.v1.1.0.json +36 -0
  132. package/src/cvcs/sourceSystem.v1.0.0.json +203 -0
  133. package/src/cvcs/specialNeedsDisabilities.v1.0.0.json +143 -0
  134. package/src/cvcs/suggestionSource.v1.0.0.json +71 -0
  135. package/src/cvcs/traffickingRelevantRole.v1.0.0.json +104 -0
  136. package/src/cvcs/userRoles.v1.0.0.json +203 -0
  137. package/src/cvcs/verificationMethod.v1.0.0.json +18 -0
  138. package/src/cvcs/victimAbuseTypes.v1.0.0.json +276 -0
  139. package/src/cvcs/victimStatusFamily.v1.0.0.json +40 -40
  140. package/src/cvcs/whyNots.v1.0.0.json +385 -0
  141. package/src/generated/cvc-enums.ts +1729 -7
  142. package/src/mongo/catalog.ts +65 -0
  143. package/src/mongo/contract.ts +157 -0
  144. package/src/mongo/index.ts +343 -0
  145. package/src/mongo/similarity.ts +133 -0
  146. package/src/mongo/uri.ts +53 -0
  147. package/src/services/cvcRegistryService.ts +1 -1
  148. package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-BCj1OWqL.d.cts} +8 -8
  149. package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-BCj1OWqL.d.ts} +8 -8
@@ -0,0 +1,323 @@
1
+ /**
2
+ * CVC-136 <-> @hti/scoring invariant test (0.8.13)
3
+ *
4
+ * THE INVARIANT
5
+ * -------------
6
+ * Every indicator code that @hti/scoring EMITS must exist in the CVC-136
7
+ * `core_indicators` vocabulary. @hti/scoring is the declared scoring SOT
8
+ * (ADR-CONTRACT-scoring-vocab-model-boundary). If platform-common drops or
9
+ * renames a code that scoring emits, the risk pipeline silently writes
10
+ * assertions against an indicator code that resolves to nothing.
11
+ *
12
+ * That is exactly the class of drift 0.8.13 repaired: 0.8.12 shipped 199
13
+ * hand-coded CVC-136 codes, of which 54 were invented rollup prefixes
14
+ * (`vc_*`, `csi_*`, `csctx_*`, `dv_*`, `net_*`, `auto_*`) that existed nowhere
15
+ * upstream and were consumed by nobody, while 66 real canonical codes were
16
+ * MISSING. This test makes that impossible to reintroduce.
17
+ *
18
+ * THE PIN
19
+ * -------
20
+ * `SCORING_EMITS_BY_CODE` is the key set of `emits_by_code` in
21
+ * `weights/risk.weights.json` at htilabstech/hti-scoring@9b5d654 (169 codes).
22
+ * It is a COMMITTED PIN, not a live read - platform-common must not take a
23
+ * build-time dependency on the scoring repo. When @hti/scoring starts emitting
24
+ * a new code, bumping this list is a deliberate, reviewable commit that forces
25
+ * the matching CVC-136 entry to be authored in the same PR.
26
+ *
27
+ * SCORING IS AHEAD OF THE CODEBOOK ON 2 CODES
28
+ * -------------------------------------------
29
+ * `coercive_debt_pressure_youth` and `debt_terms_deceptive_youth` are emitted
30
+ * by @hti/scoring but are NOT in the prototype's canonical
31
+ * `data/core_indicators.yaml` (208 codes) at HEAD a596eb9. They are KEPT
32
+ * (210 = 208 + 2) and flagged `pendingUpstreamAdoption: true` in the SOT JSON.
33
+ * Dropping them because they are "not in the prototype" would break the
34
+ * scoring contract. That is the trap this test exists to prevent.
35
+ */
36
+
37
+ import { readFileSync } 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
+ import { CVC_136_CORE_INDICATOR_VALUES } from "../constants/ic.js";
44
+ import { CvcEnvelopeSchema } from "../validation/cvc.js";
45
+
46
+ const __filename = fileURLToPath(import.meta.url);
47
+ const __dirname = path.dirname(__filename);
48
+ const SOT_FILE = path.resolve(
49
+ __dirname,
50
+ "..",
51
+ "cvcs",
52
+ "coreIndicators.v1.0.0.json",
53
+ );
54
+
55
+ /**
56
+ * `Object.keys(RISK_WEIGHTS.emits_by_code)` at
57
+ * htilabstech/hti-scoring@9b5d654 (weights/risk.weights.json). 169 codes.
58
+ * PINNED - see the module header before editing.
59
+ */
60
+ const SCORING_EMITS_BY_CODE: readonly string[] = [
61
+ "abuser_evading_legal_consequences",
62
+ "abuser_has_weapon",
63
+ "abuser_substance_use",
64
+ "abuser_threatened_suicide",
65
+ "abuser_unemployed",
66
+ "access_to_vulnerable_individuals",
67
+ "acknowledgement_or_report_of_human_trafficking",
68
+ "adverse_childhood_household_challenges",
69
+ "appears_controlling_relationship",
70
+ "association_commercial_sex",
71
+ "atypical_or_high_risk_payment_method",
72
+ "autonomy_choice_in_clients",
73
+ "autonomy_choice_in_services",
74
+ "autonomy_controls_own_finances",
75
+ "autonomy_organizes_own_travel",
76
+ "autonomy_posts_own_ads",
77
+ "autonomy_sets_own_schedule",
78
+ "autonomy_sets_up_own_dates",
79
+ "battered_while_pregnant_history",
80
+ "branding_or_unusual_tattoos_tied_to_control",
81
+ "cannot_stop_working_or_freely_leave",
82
+ "child_not_abusers_in_household",
83
+ "coerced_to_misrepresent_identity_or_activity",
84
+ "coercive_debt_pressure",
85
+ "coercive_debt_pressure_youth",
86
+ "coercive_migration_or_forced_travel",
87
+ "cognitive_or_functional_impairment_affecting_consent",
88
+ "commercial_sex_association_words_or_places",
89
+ "concerning_mannerisms_anxious_fearful_depressed",
90
+ "concerning_sexual_behavior_pattern",
91
+ "control_quota_required",
92
+ "cs_activity_criminal_org_connection",
93
+ "cs_industry_related_criminal_history",
94
+ "current_injuries_from_abuser",
95
+ "currently_minor_in_commercial_sex",
96
+ "debt_terms_deceptive",
97
+ "debt_terms_deceptive_youth",
98
+ "denied_basic_needs",
99
+ "depends_on_employer_for_immigration_status",
100
+ "does_not_control_finances_or_earnings",
101
+ "does_not_control_identity_documents",
102
+ "employer_keeps_pay_or_pays_less_than_expected",
103
+ "engages_in_commercial_sex_act",
104
+ "entered_commercial_sex_industry_as_minor",
105
+ "entered_cs_due_to_survival_needs",
106
+ "entered_into_network_of_sex_providers_early",
107
+ "exploitative_working_conditions",
108
+ "fled_conflict_violence_or_persecution",
109
+ "forced_to_commit_crimes",
110
+ "forced_to_use_false_documents",
111
+ "foreign_born_or_recently_arrived",
112
+ "foreign_born_risk_factors",
113
+ "frequent_changes_in_residence",
114
+ "frequent_travel_or_location_changes",
115
+ "frequently_at_hotels_or_many_hotel_keys",
116
+ "has_ads_on_commercial_sex_site",
117
+ "has_facilitators_involved",
118
+ "has_management_or_representation",
119
+ "has_no_personal_items_or_possessions",
120
+ "head_injury_history",
121
+ "head_injury_loss_of_consciousness",
122
+ "health_related_vulnerability",
123
+ "hierarchical_management_structure_identified",
124
+ "high_risk_sexual_behavior",
125
+ "high_security_measures_at_work_or_living_location",
126
+ "highly_irregular_school_attendance",
127
+ "history_emotional_abuse",
128
+ "history_of_mental_health_issues",
129
+ "history_of_running_away_or_missing_from_care",
130
+ "history_of_strangulation",
131
+ "history_physical_or_sexual_abuse_or_dv",
132
+ "homeless_or_unstably_housed",
133
+ "immigration_related_exploitation_risk",
134
+ "in_commercial_sex_industry_recorded",
135
+ "inability_to_account_for_self",
136
+ "intimate_partner_violence_reported_to_law_enforcement",
137
+ "juvenile_justice_or_child_welfare_involvement",
138
+ "labor_services_activity_recorded",
139
+ "limited_english_proficiency",
140
+ "limited_independence",
141
+ "lives_or_sleeps_at_place_of_work",
142
+ "living_with_abuser",
143
+ "meets_or_has_sex_with_internet_contacts",
144
+ "monitored_or_isolated_by_controlling_party",
145
+ "much_older_intimate_partner",
146
+ "nervous_about_immigration_documentation",
147
+ "network_multiple_sex_providers_named",
148
+ "new_to_commercial_sex_industry",
149
+ "non_consensual_photography_or_recording",
150
+ "not_in_control_of_immigration_documentation",
151
+ "other_instability_or_vulnerability_factors",
152
+ "owes_money_and_cannot_pay_off",
153
+ "paid_or_owes_fee_to_arrange_travel_to_us",
154
+ "paid_or_owes_recruitment_fee_to_employer",
155
+ "payment_routed_through_third_party",
156
+ "pending_federal_protection",
157
+ "performing_different_work_than_promised",
158
+ "physical_violence_increasing",
159
+ "poverty_or_severe_financial_strain",
160
+ "precarious_immigration_status",
161
+ "pressured_or_forced_sex_act",
162
+ "prior_medical_attention_from_abuse",
163
+ "prior_tvap_disconnection",
164
+ "prior_victimization_or_abuse_history",
165
+ "promise_of_work_different_than_current_work",
166
+ "received_things_of_value_while_missing_from_care",
167
+ "recruited_by_third_party_into_cs_industry",
168
+ "relies_on_temporary_resources_for_basic_needs",
169
+ "reports_physical_harm_by_employer_or_partner",
170
+ "reports_physical_harm_to_others_by_employer_or_partner",
171
+ "restrictive_living_or_working_conditions",
172
+ "restrictive_or_not_understood_contract",
173
+ "risk_factors_commercial_sex",
174
+ "serious_substance_use_or_introduced_to_drugs",
175
+ "several_cell_phones_or_frequent_number_changes",
176
+ "sex_acts_in_own_residence",
177
+ "sexual_exploitation",
178
+ "signs_of_physical_abuse_confinement_or_neglect",
179
+ "signs_of_physical_harm_or_abuse",
180
+ "social_isolation_or_no_supportive_relationships",
181
+ "stalking_property_intrusion",
182
+ "stalking_surveillance",
183
+ "stalking_unwanted_contact",
184
+ "strangulation_acute_symptoms",
185
+ "strangulation_loss_of_consciousness",
186
+ "strangulation_repeated",
187
+ "subject_arrested_dv_sv_cs",
188
+ "subject_has_illegal_weapons",
189
+ "subject_is_sex_offender",
190
+ "subject_legally_barred_weapons",
191
+ "subject_perpetrated_abuse_history",
192
+ "subject_perpetrated_emotional_stalking_current",
193
+ "subject_perpetrated_emotional_stalking_past",
194
+ "subject_perpetrated_ipv_current",
195
+ "subject_perpetrated_ipv_past",
196
+ "subject_perpetrated_physical_abuse_current",
197
+ "subject_perpetrated_physical_abuse_past",
198
+ "subject_perpetrated_sexual_abuse_current",
199
+ "subject_perpetrated_sexual_abuse_past",
200
+ "subject_violent_felony",
201
+ "substance_use_while_working",
202
+ "suicidal_ideation_history",
203
+ "suicidal_ideation_recent",
204
+ "third_party_arranged_commercial_sex_acts",
205
+ "threats_by_employer_or_partner",
206
+ "threats_of_harm",
207
+ "threats_of_legal_trouble_or_deportation",
208
+ "threats_related_to_migration_debt",
209
+ "threats_to_family_friends_or_close_associates",
210
+ "threats_to_kill_victim_or_children",
211
+ "trafficking_experience_past_10plusy",
212
+ "trafficking_experience_past_3to10y",
213
+ "trafficking_experience_past_lt3y",
214
+ "travel_organized_by_third_party",
215
+ "tricked_or_pressured_into_unwanted_acts",
216
+ "unexplained_frequent_travel_or_migration",
217
+ "unsafe_working_conditions_long_hours_inadequate_breaks",
218
+ "unusual_cash_or_unexplained_gifts",
219
+ "unusual_work_circumstances",
220
+ "urgent_medical_referral_needed",
221
+ "victim_believes_abuser_capable_of_killing",
222
+ "victimization_history_composite",
223
+ "violence_or_threats_at_work_site",
224
+ "weapon_used_or_threatened_against_victim",
225
+ "work_frequency_high_volume",
226
+ "workplace_emotional_climate_of_fear",
227
+ "works_across_multiple_cities_or_locations",
228
+ "works_for_little_or_no_pay",
229
+ "youth_watched_filmed_or_photographed_sexually_explicit",
230
+ ];
231
+
232
+ /** Codes @hti/scoring emits that upstream `core_indicators.yaml` has not yet adopted. */
233
+ const PENDING_UPSTREAM_ADOPTION: readonly string[] = [
234
+ "coercive_debt_pressure_youth",
235
+ "debt_terms_deceptive_youth",
236
+ ];
237
+
238
+ const envelope = CvcEnvelopeSchema.parse(
239
+ JSON.parse(readFileSync(SOT_FILE, "utf-8")),
240
+ );
241
+
242
+ /** Substantive (non-missingness) entries: segment 2 of the code is non-zero. */
243
+ const substantive = envelope.entries.filter(
244
+ (e) => e.code.split("-")[1] !== "000",
245
+ );
246
+ const substantiveKeys = new Set(substantive.map((e) => e.key));
247
+
248
+ describe("CVC-136 core_indicators", () => {
249
+ it("is numbered 136 in segment 1 of every code", () => {
250
+ for (const entry of envelope.entries) {
251
+ expect(entry.code.split("-")[0]).toBe("136");
252
+ }
253
+ });
254
+
255
+ it("opens with the mandatory missingness quadruplet", () => {
256
+ expect(envelope.entries.slice(0, 4).map((e) => e.key)).toEqual([
257
+ "missingness_root",
258
+ "unknown",
259
+ "anonymous",
260
+ "data_not_collected",
261
+ ]);
262
+ });
263
+
264
+ it("has exactly 210 substantive codes (208 canonical + 2 scoring-ahead)", () => {
265
+ expect(substantive.length).toBe(210);
266
+ expect(envelope.entries.length).toBe(214);
267
+ });
268
+
269
+ it("has no duplicate keys", () => {
270
+ expect(substantiveKeys.size).toBe(substantive.length);
271
+ });
272
+ });
273
+
274
+ describe("CVC-136 <-> @hti/scoring emits_by_code invariant", () => {
275
+ it("pins exactly 169 emitted codes", () => {
276
+ expect(new Set(SCORING_EMITS_BY_CODE).size).toBe(169);
277
+ });
278
+
279
+ it("EVERY code @hti/scoring emits exists in CVC-136", () => {
280
+ const missing = SCORING_EMITS_BY_CODE.filter(
281
+ (code) => !substantiveKeys.has(code),
282
+ );
283
+ if (missing.length > 0) {
284
+ throw new Error(
285
+ "CVC-136 is missing indicator codes that @hti/scoring EMITS. The risk " +
286
+ "pipeline would write assertions against codes that resolve to nothing.\n" +
287
+ `Missing (${missing.length}): ${missing.join(", ")}`,
288
+ );
289
+ }
290
+ expect(missing).toHaveLength(0);
291
+ });
292
+
293
+ it("the 2 scoring-ahead codes are present and flagged pendingUpstreamAdoption", () => {
294
+ for (const code of PENDING_UPSTREAM_ADOPTION) {
295
+ const entry = substantive.find((e) => e.key === code);
296
+ expect(entry, `${code} must be present in CVC-136`).toBeDefined();
297
+ expect(
298
+ (entry as unknown as Record<string, unknown>)["pendingUpstreamAdoption"],
299
+ ).toBe(true);
300
+ }
301
+ });
302
+
303
+ it("none of the 54 withdrawn invented rollup codes came back", () => {
304
+ const inventedPrefixes = ["vc_", "csi_", "csctx_", "dv_", "net_", "auto_"];
305
+ const resurrected = [...substantiveKeys].filter((key) =>
306
+ inventedPrefixes.some((p) => key.startsWith(p)),
307
+ );
308
+ expect(resurrected).toEqual([]);
309
+ });
310
+
311
+ it("`unusual_work_circumstances_general` stays withdrawn; the canonical code ships", () => {
312
+ expect(substantiveKeys.has("unusual_work_circumstances_general")).toBe(false);
313
+ expect(substantiveKeys.has("unusual_work_circumstances")).toBe(true);
314
+ });
315
+ });
316
+
317
+ describe("CVC-136 SOT JSON <-> hand-coded ic.ts array", () => {
318
+ it("CVC_136_CORE_INDICATOR_VALUES is exactly the SOT substantive key set", () => {
319
+ expect([...CVC_136_CORE_INDICATOR_VALUES].sort()).toEqual(
320
+ [...substantiveKeys].sort(),
321
+ );
322
+ });
323
+ });