@htilabs/platform-common-models 0.21.0 → 0.22.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/cvcs/index.cjs +449 -50
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +491 -55
- package/dist/cvcs/index.d.ts +491 -55
- package/dist/cvcs/index.js +449 -50
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +36 -1
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +37 -2
- package/dist/enums/index.d.ts +37 -2
- package/dist/enums/index.js +36 -1
- package/dist/enums/index.js.map +1 -1
- package/dist/index.cjs +589 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +580 -51
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +104 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +240 -1
- package/dist/schemas/index.d.ts +240 -1
- package/dist/schemas/index.js +95 -0
- package/dist/schemas/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__sot__/README.md +1 -0
- package/src/__sot__/coreFunctionFields.ts +121 -0
- package/src/__sot__/coreFunctions.pin.json +1546 -0
- package/src/__sot__/coreFunctions.published.json +233 -0
- package/src/__tests__/__snapshots__/cvc-sot.snap +2 -2
- package/src/__tests__/core-functions-canon.test.ts +308 -24
- package/src/__tests__/cvc-sot-snapshot.test.ts +7 -4
- package/src/__tests__/cvc-status-parser.test.ts +1 -1
- package/src/__tests__/cvc-structural.test.ts +1 -1
- package/src/__tests__/organization-program.test.ts +254 -0
- package/src/cvcs/{coreFunctions.v1.1.0.json → coreFunctions.v1.2.0.json} +446 -47
- package/src/cvcs/index.ts +1 -1
- package/src/generated/cvc-enums.ts +37 -2
- package/src/schemas/index.ts +18 -0
- package/src/schemas/organization-program.ts +297 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "Every key @htilabs/platform-common-models has ever published for core_functions, with its segment-1 prefix. APPEND-ONLY: a published key never moves and is never removed (a key canon drops stays here as a tombstone). Written by scripts/gen-core-functions.py; read by it and by GATE I (src/__tests__/core-functions-canon.test.ts). Do not hand-edit.",
|
|
3
|
+
"prefixes": {
|
|
4
|
+
"account_suspend": 1,
|
|
5
|
+
"aggregate_data_query_generate": 2,
|
|
6
|
+
"api_key_manage": 3,
|
|
7
|
+
"assessments_conduct": 4,
|
|
8
|
+
"audit_anomaly_review": 5,
|
|
9
|
+
"audit_log_view_member": 6,
|
|
10
|
+
"audit_log_view_team": 7,
|
|
11
|
+
"auth_model_manage_platform": 8,
|
|
12
|
+
"break_glass": 9,
|
|
13
|
+
"case_assign_reassign": 10,
|
|
14
|
+
"case_claim": 11,
|
|
15
|
+
"case_collaborator_add": 12,
|
|
16
|
+
"case_edit": 13,
|
|
17
|
+
"case_needs_action_flag_manage": 14,
|
|
18
|
+
"case_outcomes_edit": 15,
|
|
19
|
+
"case_purge": 16,
|
|
20
|
+
"case_reopen": 17,
|
|
21
|
+
"case_side_panel_use": 18,
|
|
22
|
+
"case_transfer_bulk": 19,
|
|
23
|
+
"case_view": 20,
|
|
24
|
+
"ci_periodic_review": 21,
|
|
25
|
+
"ci_record_purge_or_retire": 22,
|
|
26
|
+
"ci_record_validate": 23,
|
|
27
|
+
"ci_to_evidence_export_authorize": 24,
|
|
28
|
+
"dashboard_approve_shared": 25,
|
|
29
|
+
"data_qa_workflow_run": 26,
|
|
30
|
+
"deconfliction_alert_acknowledge": 27,
|
|
31
|
+
"determination_perform": 28,
|
|
32
|
+
"disclose_external": 29,
|
|
33
|
+
"disclose_external_request": 30,
|
|
34
|
+
"export_deidentified": 31,
|
|
35
|
+
"export_disclosure_log_review": 32,
|
|
36
|
+
"export_template_config_manage": 33,
|
|
37
|
+
"gov_data_quality_review": 34,
|
|
38
|
+
"idb_record_create": 35,
|
|
39
|
+
"incident_response_remediate": 36,
|
|
40
|
+
"investigation_create_claim": 37,
|
|
41
|
+
"investigative_database_search": 38,
|
|
42
|
+
"lead_create": 39,
|
|
43
|
+
"lead_publish": 40,
|
|
44
|
+
"magic_link_share_send": 41,
|
|
45
|
+
"member_account_report_generate": 42,
|
|
46
|
+
"member_onboarding_support": 43,
|
|
47
|
+
"open_source_search": 44,
|
|
48
|
+
"outbound_share_followup_review": 45,
|
|
49
|
+
"person_association_update": 46,
|
|
50
|
+
"platform_perm_modify": 47,
|
|
51
|
+
"platform_policy_enforcement_manage": 48,
|
|
52
|
+
"record_print": 49,
|
|
53
|
+
"referral_receive_external": 50,
|
|
54
|
+
"referral_receive_internal": 51,
|
|
55
|
+
"referral_send_external": 52,
|
|
56
|
+
"referral_send_internal": 53,
|
|
57
|
+
"reporting_dashboard_config_manage": 54,
|
|
58
|
+
"retention_compliance_review": 55,
|
|
59
|
+
"roi_submit_manage": 56,
|
|
60
|
+
"role_assign": 57,
|
|
61
|
+
"roles_accounts_toggle": 58,
|
|
62
|
+
"sandbox_environment_manage": 59,
|
|
63
|
+
"screening_conduct": 60,
|
|
64
|
+
"screening_view": 61,
|
|
65
|
+
"security_restrict_apply": 62,
|
|
66
|
+
"session_create": 63,
|
|
67
|
+
"share_approve": 64,
|
|
68
|
+
"share_config": 65,
|
|
69
|
+
"share_rule_approve_cross_agency": 66,
|
|
70
|
+
"share_vsp_to_le": 67,
|
|
71
|
+
"support_ticket_triage": 68,
|
|
72
|
+
"system_diagnostics_view": 69,
|
|
73
|
+
"team_config_manage": 70,
|
|
74
|
+
"team_membership_manage": 71,
|
|
75
|
+
"team_workflow_config_manage": 72,
|
|
76
|
+
"thread_share_accept": 73,
|
|
77
|
+
"thread_share_send": 74,
|
|
78
|
+
"training_content_upload": 75,
|
|
79
|
+
"training_gate_manage": 76,
|
|
80
|
+
"usr_manage": 77,
|
|
81
|
+
"note_open_departed_author": 78,
|
|
82
|
+
"agency_info_manage": 79,
|
|
83
|
+
"srl_manage": 80,
|
|
84
|
+
"mandatory_report_send": 81,
|
|
85
|
+
"indicator_manual_add": 82,
|
|
86
|
+
"message_send": 83,
|
|
87
|
+
"workgroup_manage": 84,
|
|
88
|
+
"message_moderate": 85,
|
|
89
|
+
"announcement_publish": 86,
|
|
90
|
+
"supervisee_thread_view": 87,
|
|
91
|
+
"case_status_manage": 88,
|
|
92
|
+
"enrollment_manage": 89,
|
|
93
|
+
"exit_discharge_conduct": 90,
|
|
94
|
+
"goals_plan_manage": 91,
|
|
95
|
+
"lead_triage_manage": 92,
|
|
96
|
+
"milestone_log": 93,
|
|
97
|
+
"needs_priorities_conduct": 94,
|
|
98
|
+
"profile_domain_edit": 95,
|
|
99
|
+
"record_activity_view": 96,
|
|
100
|
+
"service_log_manage": 97,
|
|
101
|
+
"case_close": 98,
|
|
102
|
+
"case_visibility_manage": 99,
|
|
103
|
+
"person_merge_manage": 100,
|
|
104
|
+
"investigation_session_run": 101,
|
|
105
|
+
"lead_route_assign": 102,
|
|
106
|
+
"onboarding_config_sign_off": 103,
|
|
107
|
+
"hmis_export_generate": 104,
|
|
108
|
+
"team_share_narrowing": 105,
|
|
109
|
+
"viewing_config_manage": 106,
|
|
110
|
+
"network_corpus_access": 107,
|
|
111
|
+
"viewing_level_1_search": 108,
|
|
112
|
+
"viewing_level_2_autocomplete": 109,
|
|
113
|
+
"viewing_level_3_components": 110,
|
|
114
|
+
"investigative_request_send": 111,
|
|
115
|
+
"deconfliction_unmask": 112,
|
|
116
|
+
"share_revoke": 113
|
|
117
|
+
},
|
|
118
|
+
"since": {
|
|
119
|
+
"account_suspend": "1.0.0",
|
|
120
|
+
"aggregate_data_query_generate": "1.0.0",
|
|
121
|
+
"api_key_manage": "1.0.0",
|
|
122
|
+
"assessments_conduct": "1.0.0",
|
|
123
|
+
"audit_anomaly_review": "1.0.0",
|
|
124
|
+
"audit_log_view_member": "1.0.0",
|
|
125
|
+
"audit_log_view_team": "1.0.0",
|
|
126
|
+
"auth_model_manage_platform": "1.0.0",
|
|
127
|
+
"break_glass": "1.0.0",
|
|
128
|
+
"case_assign_reassign": "1.0.0",
|
|
129
|
+
"case_claim": "1.0.0",
|
|
130
|
+
"case_collaborator_add": "1.0.0",
|
|
131
|
+
"case_edit": "1.0.0",
|
|
132
|
+
"case_needs_action_flag_manage": "1.0.0",
|
|
133
|
+
"case_outcomes_edit": "1.0.0",
|
|
134
|
+
"case_purge": "1.0.0",
|
|
135
|
+
"case_reopen": "1.0.0",
|
|
136
|
+
"case_side_panel_use": "1.0.0",
|
|
137
|
+
"case_transfer_bulk": "1.0.0",
|
|
138
|
+
"case_view": "1.0.0",
|
|
139
|
+
"ci_periodic_review": "1.0.0",
|
|
140
|
+
"ci_record_purge_or_retire": "1.0.0",
|
|
141
|
+
"ci_record_validate": "1.0.0",
|
|
142
|
+
"ci_to_evidence_export_authorize": "1.0.0",
|
|
143
|
+
"dashboard_approve_shared": "1.0.0",
|
|
144
|
+
"data_qa_workflow_run": "1.0.0",
|
|
145
|
+
"deconfliction_alert_acknowledge": "1.0.0",
|
|
146
|
+
"determination_perform": "1.0.0",
|
|
147
|
+
"disclose_external": "1.0.0",
|
|
148
|
+
"disclose_external_request": "1.0.0",
|
|
149
|
+
"export_deidentified": "1.0.0",
|
|
150
|
+
"export_disclosure_log_review": "1.0.0",
|
|
151
|
+
"export_template_config_manage": "1.0.0",
|
|
152
|
+
"gov_data_quality_review": "1.0.0",
|
|
153
|
+
"idb_record_create": "1.0.0",
|
|
154
|
+
"incident_response_remediate": "1.0.0",
|
|
155
|
+
"investigation_create_claim": "1.0.0",
|
|
156
|
+
"investigative_database_search": "1.0.0",
|
|
157
|
+
"lead_create": "1.0.0",
|
|
158
|
+
"lead_publish": "1.0.0",
|
|
159
|
+
"magic_link_share_send": "1.0.0",
|
|
160
|
+
"member_account_report_generate": "1.0.0",
|
|
161
|
+
"member_onboarding_support": "1.0.0",
|
|
162
|
+
"open_source_search": "1.0.0",
|
|
163
|
+
"outbound_share_followup_review": "1.0.0",
|
|
164
|
+
"person_association_update": "1.0.0",
|
|
165
|
+
"platform_perm_modify": "1.0.0",
|
|
166
|
+
"platform_policy_enforcement_manage": "1.0.0",
|
|
167
|
+
"record_print": "1.0.0",
|
|
168
|
+
"referral_receive_external": "1.0.0",
|
|
169
|
+
"referral_receive_internal": "1.0.0",
|
|
170
|
+
"referral_send_external": "1.0.0",
|
|
171
|
+
"referral_send_internal": "1.0.0",
|
|
172
|
+
"reporting_dashboard_config_manage": "1.0.0",
|
|
173
|
+
"retention_compliance_review": "1.0.0",
|
|
174
|
+
"roi_submit_manage": "1.0.0",
|
|
175
|
+
"role_assign": "1.0.0",
|
|
176
|
+
"roles_accounts_toggle": "1.0.0",
|
|
177
|
+
"sandbox_environment_manage": "1.0.0",
|
|
178
|
+
"screening_conduct": "1.0.0",
|
|
179
|
+
"screening_view": "1.0.0",
|
|
180
|
+
"security_restrict_apply": "1.0.0",
|
|
181
|
+
"session_create": "1.0.0",
|
|
182
|
+
"share_approve": "1.0.0",
|
|
183
|
+
"share_config": "1.0.0",
|
|
184
|
+
"share_rule_approve_cross_agency": "1.0.0",
|
|
185
|
+
"share_vsp_to_le": "1.0.0",
|
|
186
|
+
"support_ticket_triage": "1.0.0",
|
|
187
|
+
"system_diagnostics_view": "1.0.0",
|
|
188
|
+
"team_config_manage": "1.0.0",
|
|
189
|
+
"team_membership_manage": "1.0.0",
|
|
190
|
+
"team_workflow_config_manage": "1.0.0",
|
|
191
|
+
"thread_share_accept": "1.0.0",
|
|
192
|
+
"thread_share_send": "1.0.0",
|
|
193
|
+
"training_content_upload": "1.0.0",
|
|
194
|
+
"training_gate_manage": "1.0.0",
|
|
195
|
+
"usr_manage": "1.0.0",
|
|
196
|
+
"note_open_departed_author": "1.1.0",
|
|
197
|
+
"agency_info_manage": "1.2.0",
|
|
198
|
+
"srl_manage": "1.2.0",
|
|
199
|
+
"mandatory_report_send": "1.2.0",
|
|
200
|
+
"indicator_manual_add": "1.2.0",
|
|
201
|
+
"message_send": "1.2.0",
|
|
202
|
+
"workgroup_manage": "1.2.0",
|
|
203
|
+
"message_moderate": "1.2.0",
|
|
204
|
+
"announcement_publish": "1.2.0",
|
|
205
|
+
"supervisee_thread_view": "1.2.0",
|
|
206
|
+
"case_status_manage": "1.2.0",
|
|
207
|
+
"enrollment_manage": "1.2.0",
|
|
208
|
+
"exit_discharge_conduct": "1.2.0",
|
|
209
|
+
"goals_plan_manage": "1.2.0",
|
|
210
|
+
"lead_triage_manage": "1.2.0",
|
|
211
|
+
"milestone_log": "1.2.0",
|
|
212
|
+
"needs_priorities_conduct": "1.2.0",
|
|
213
|
+
"profile_domain_edit": "1.2.0",
|
|
214
|
+
"record_activity_view": "1.2.0",
|
|
215
|
+
"service_log_manage": "1.2.0",
|
|
216
|
+
"case_close": "1.2.0",
|
|
217
|
+
"case_visibility_manage": "1.2.0",
|
|
218
|
+
"person_merge_manage": "1.2.0",
|
|
219
|
+
"investigation_session_run": "1.2.0",
|
|
220
|
+
"lead_route_assign": "1.2.0",
|
|
221
|
+
"onboarding_config_sign_off": "1.2.0",
|
|
222
|
+
"hmis_export_generate": "1.2.0",
|
|
223
|
+
"team_share_narrowing": "1.2.0",
|
|
224
|
+
"viewing_config_manage": "1.2.0",
|
|
225
|
+
"network_corpus_access": "1.2.0",
|
|
226
|
+
"viewing_level_1_search": "1.2.0",
|
|
227
|
+
"viewing_level_2_autocomplete": "1.2.0",
|
|
228
|
+
"viewing_level_3_components": "1.2.0",
|
|
229
|
+
"investigative_request_send": "1.2.0",
|
|
230
|
+
"deconfliction_unmask": "1.2.0",
|
|
231
|
+
"share_revoke": "1.2.0"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -575,8 +575,8 @@
|
|
|
575
575
|
"hash": "8f650b786261619b2468eb3982c6146c21fa2ee3b1aa4504aa1084ad82543548"
|
|
576
576
|
},
|
|
577
577
|
"core_functions": {
|
|
578
|
-
"count":
|
|
579
|
-
"hash": "
|
|
578
|
+
"count": 117,
|
|
579
|
+
"hash": "f48450ecf050adca244c7264f0f2acdbbd7d174dc3b13e81038882cc1f78c44e"
|
|
580
580
|
},
|
|
581
581
|
"needs_assessment_change_type": {
|
|
582
582
|
"count": 13,
|
|
@@ -1,53 +1,337 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CORE FUNCTIONS (CVC-133) —
|
|
2
|
+
* CORE FUNCTIONS (CVC-133) — GATE I: the SOT restates canon, whole
|
|
3
|
+
* =================================================================
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* `src/cvcs/coreFunctions.v1.2.0.json` is GENERATED from the canonical CVC-133
|
|
6
|
+
* registry (`htilabstech/prototype` `data/cvcs/core_functions.yaml`) by
|
|
7
|
+
* `scripts/gen-core-functions.py`. This test is the hermetic enforcer: it
|
|
8
|
+
* asserts the shipped SOT conforms to `src/__sot__/coreFunctions.pin.json`
|
|
9
|
+
* (the canon snapshot `scripts/sot-pins.ts` takes at a SHA), on every PR, with
|
|
10
|
+
* no cross-repo auth. `npm run sot:pins:check` is the detector that notices
|
|
11
|
+
* when canon itself has moved.
|
|
12
|
+
*
|
|
13
|
+
* History it closes: the 1.0.0 port ("ported verbatim from the Notion
|
|
14
|
+
* codebook") and the 1.1.0 append validated the file against itself. By
|
|
15
|
+
* 2026-10-11 it carried 78 of canon's 113 functions (the 2026-08-13 overhaul's
|
|
16
|
+
* 35 rows — the `case_edit` split, the Communication family, the viewing
|
|
17
|
+
* ladder, `share_revoke`, `person_merge_manage` … — were "a separate absorb,
|
|
18
|
+
* not taken here"), `case_view` still read `Platform: PAVE` (re-scoped to all
|
|
19
|
+
* three apps 08-13), the CI family still read `(not v1)` (flipped to v1 08-13),
|
|
20
|
+
* and `case_claim` still carried its pre-rename label. Nothing failed.
|
|
21
|
+
*
|
|
22
|
+
* Append-only contract (`consumers gate on the key`): every code 1.0.0 / 1.1.0
|
|
23
|
+
* published stays where it was; new canon keys are appended after the highest
|
|
24
|
+
* published prefix. The ledger of published codes (`src/__sot__/coreFunctions.published.json`)
|
|
25
|
+
* is written by the generator and asserted here, pair by pair.
|
|
9
26
|
*/
|
|
10
|
-
|
|
11
27
|
import { readFileSync } from "node:fs";
|
|
12
28
|
import path from "node:path";
|
|
13
29
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
|
|
15
30
|
import { describe, it, expect } from "vitest";
|
|
16
31
|
|
|
17
32
|
import { CoreFunctionsKeys } from "../generated/cvc-enums.js";
|
|
33
|
+
import { expectedDefinition } from "../__sot__/coreFunctionFields.js";
|
|
34
|
+
import type { ProjectedFunctionFields } from "../__sot__/coreFunctionFields.js";
|
|
18
35
|
|
|
19
36
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
20
37
|
const cvcDir = path.join(here, "..", "cvcs");
|
|
38
|
+
const sotDir = path.join(here, "..", "__sot__");
|
|
39
|
+
|
|
40
|
+
const SOT_FILE = "coreFunctions.v1.2.0.json";
|
|
41
|
+
const SOT_VERSION = "1.2.0";
|
|
42
|
+
const SUPERSEDED_FILE = "coreFunctions.v1.1.0.json";
|
|
21
43
|
|
|
22
44
|
interface Entry {
|
|
23
45
|
code: string;
|
|
24
46
|
key: string;
|
|
25
47
|
title: string;
|
|
26
48
|
selectable: boolean;
|
|
49
|
+
parentCode: string | null;
|
|
50
|
+
childCodes: string[];
|
|
27
51
|
definition: string;
|
|
28
52
|
}
|
|
53
|
+
interface Envelope {
|
|
54
|
+
domain: string;
|
|
55
|
+
version: string;
|
|
56
|
+
_status: string;
|
|
57
|
+
_source: string;
|
|
58
|
+
_supersedes: {
|
|
59
|
+
version: string;
|
|
60
|
+
appended: string[];
|
|
61
|
+
refreshed: string[];
|
|
62
|
+
tombstoned: string[];
|
|
63
|
+
};
|
|
64
|
+
entries: Entry[];
|
|
65
|
+
}
|
|
66
|
+
interface Pin {
|
|
67
|
+
sourceRepo: string;
|
|
68
|
+
sourceFile: string;
|
|
69
|
+
sourceSha: string;
|
|
70
|
+
keys: string[];
|
|
71
|
+
fields: Record<string, ProjectedFunctionFields>;
|
|
72
|
+
functionCount: number;
|
|
73
|
+
v1Count: number;
|
|
74
|
+
}
|
|
29
75
|
|
|
30
76
|
const sot = JSON.parse(
|
|
31
|
-
readFileSync(path.join(cvcDir,
|
|
32
|
-
) as
|
|
77
|
+
readFileSync(path.join(cvcDir, SOT_FILE), "utf8"),
|
|
78
|
+
) as Envelope;
|
|
79
|
+
const pin = JSON.parse(
|
|
80
|
+
readFileSync(path.join(sotDir, "coreFunctions.pin.json"), "utf8"),
|
|
81
|
+
) as Pin;
|
|
82
|
+
const ledger = JSON.parse(
|
|
83
|
+
readFileSync(path.join(sotDir, "coreFunctions.published.json"), "utf8"),
|
|
84
|
+
) as { prefixes: Record<string, number>; since: Record<string, string> };
|
|
85
|
+
|
|
86
|
+
const MISSINGNESS = /^133-000-/;
|
|
87
|
+
const FLAT = /^133-(\d{3})-000-000-000-000-000$/;
|
|
88
|
+
const functions = sot.entries.filter((e) => !MISSINGNESS.test(e.code));
|
|
89
|
+
const byKey = new Map(functions.map((e) => [e.key, e] as const));
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Completeness of the SOT against the pin, aware of the generator's
|
|
93
|
+
* `RETIREMENTS` path. A key the package once PUBLISHED (it is in the ledger)
|
|
94
|
+
* that canon has since dropped ENTIRELY (not even as `retired: true`) is kept
|
|
95
|
+
* in the SOT as a ledger-coded tombstone — the ledger test below demands it
|
|
96
|
+
* stay. Such a key is a "canon drop", not an invention, and it is counted on
|
|
97
|
+
* top of canon's own function count. Only a key in NEITHER the pin NOR the
|
|
98
|
+
* ledger is invented.
|
|
99
|
+
*/
|
|
100
|
+
function completeness(
|
|
101
|
+
sotKeys: readonly string[],
|
|
102
|
+
canonKeys: readonly string[],
|
|
103
|
+
publishedKeys: readonly string[],
|
|
104
|
+
): { missing: string[]; invented: string[]; canonDrops: string[] } {
|
|
105
|
+
const inSot = new Set(sotKeys);
|
|
106
|
+
const inCanon = new Set(canonKeys);
|
|
107
|
+
const published = new Set(publishedKeys);
|
|
108
|
+
return {
|
|
109
|
+
missing: canonKeys.filter((k) => !inSot.has(k)),
|
|
110
|
+
invented: sotKeys.filter((k) => !inCanon.has(k) && !published.has(k)),
|
|
111
|
+
canonDrops: [...published].filter((k) => !inCanon.has(k)).sort(),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function compareSemver(a: string, b: string): number {
|
|
116
|
+
const [pa, pb] = [a, b].map((v) => v.split(".").map(Number));
|
|
117
|
+
for (let i = 0; i < 3; i++) {
|
|
118
|
+
const d = (pa![i] ?? 0) - (pb![i] ?? 0);
|
|
119
|
+
if (d !== 0) return Math.sign(d);
|
|
120
|
+
}
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const { canonDrops } = completeness(
|
|
125
|
+
[...byKey.keys()],
|
|
126
|
+
pin.keys,
|
|
127
|
+
Object.keys(ledger.prefixes),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
describe("core_functions — GATE I: the SOT restates canon (CVC-133 @ the pin)", () => {
|
|
131
|
+
it("is the generated file, at its version, superseding 1.1.0 (which is gone)", () => {
|
|
132
|
+
expect(sot.domain).toBe("core_functions");
|
|
133
|
+
expect(sot.version).toBe(SOT_VERSION);
|
|
134
|
+
expect(sot._status).toMatch(/^CANONICAL — /);
|
|
135
|
+
expect(sot._status).toContain("GENERATED");
|
|
136
|
+
expect(sot._source).toContain(pin.sourceFile);
|
|
137
|
+
expect(sot._supersedes.version).toBe("1.1.0");
|
|
138
|
+
expect(() => readFileSync(path.join(cvcDir, SUPERSEDED_FILE))).toThrow();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("pins canon's own counts", () => {
|
|
142
|
+
expect(pin.sourceRepo).toBe("htilabstech/prototype");
|
|
143
|
+
expect(pin.sourceFile).toBe("data/cvcs/core_functions.yaml");
|
|
144
|
+
expect(pin.keys).toHaveLength(pin.functionCount);
|
|
145
|
+
expect(Object.keys(pin.fields).sort()).toEqual(pin.keys);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("carries EVERY canon function and NOTHING canon does not (the 35-row gap is closed)", () => {
|
|
149
|
+
const { missing, invented } = completeness(
|
|
150
|
+
[...byKey.keys()].sort(),
|
|
151
|
+
pin.keys,
|
|
152
|
+
Object.keys(ledger.prefixes),
|
|
153
|
+
);
|
|
154
|
+
expect(missing, "canon keys the SOT does not carry").toEqual([]);
|
|
155
|
+
expect(
|
|
156
|
+
invented,
|
|
157
|
+
"SOT keys neither canon nor the published ledger carries",
|
|
158
|
+
).toEqual([]);
|
|
159
|
+
expect(functions).toHaveLength(pin.functionCount + canonDrops.length);
|
|
160
|
+
expect(sot.entries).toHaveLength(pin.functionCount + canonDrops.length + 4);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("keeps a key canon DROPPED (the generator's RETIREMENTS path) as a ledger-coded tombstone, never an invention", () => {
|
|
164
|
+
// Today no published key has left canon (RETIREMENTS is empty), so this is
|
|
165
|
+
// vacuous on the real SOT — but it must not contradict the ledger test the
|
|
166
|
+
// day RETIREMENTS is first used.
|
|
167
|
+
for (const k of canonDrops) {
|
|
168
|
+
const e = byKey.get(k);
|
|
169
|
+
expect(e, `${k}: dropped by canon but absent from the SOT`).toBeDefined();
|
|
170
|
+
expect(e!.selectable, `${k}: a canon drop must not be selectable`).toBe(
|
|
171
|
+
false,
|
|
172
|
+
);
|
|
173
|
+
expect(
|
|
174
|
+
e!.definition,
|
|
175
|
+
`${k}: a canon drop carries the [RETIRED marker`,
|
|
176
|
+
).toMatch(/^\[RETIRED/);
|
|
177
|
+
expect(
|
|
178
|
+
sot._supersedes.tombstoned,
|
|
179
|
+
`${k}: listed as tombstoned`,
|
|
180
|
+
).toContain(k);
|
|
181
|
+
}
|
|
182
|
+
// The rule itself, on a synthetic drop: remove one published key from canon
|
|
183
|
+
// while the SOT keeps it as a tombstone. It is a canon drop (counted), not
|
|
184
|
+
// missing and not invented — and a key in neither canon nor the ledger is.
|
|
185
|
+
const dropped = pin.keys[0]!;
|
|
186
|
+
const canonAfterDrop = pin.keys.filter((k) => k !== dropped);
|
|
187
|
+
const r = completeness(
|
|
188
|
+
[...byKey.keys(), "not_published_anywhere"],
|
|
189
|
+
canonAfterDrop,
|
|
190
|
+
Object.keys(ledger.prefixes),
|
|
191
|
+
);
|
|
192
|
+
expect(r.missing).toEqual([]);
|
|
193
|
+
expect(r.canonDrops).toEqual([...canonDrops, dropped].sort());
|
|
194
|
+
expect(r.invented).toEqual(["not_published_anywhere"]);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("restates every canon field: label as title, canon's definition + posture suffix as definition, retired as a tombstone", () => {
|
|
198
|
+
const bad: string[] = [];
|
|
199
|
+
for (const key of pin.keys) {
|
|
200
|
+
const f = pin.fields[key]!;
|
|
201
|
+
const e = byKey.get(key)!;
|
|
202
|
+
if (e.title !== f.label)
|
|
203
|
+
bad.push(
|
|
204
|
+
`${key}: title ${JSON.stringify(e.title)} != canon label ${JSON.stringify(f.label)}`,
|
|
205
|
+
);
|
|
206
|
+
if (e.definition !== expectedDefinition(f))
|
|
207
|
+
bad.push(
|
|
208
|
+
`${key}: definition is not canon's body + posture suffix (expected ${JSON.stringify(expectedDefinition(f))})`,
|
|
209
|
+
);
|
|
210
|
+
if (e.selectable !== !f.retired)
|
|
211
|
+
bad.push(
|
|
212
|
+
`${key}: selectable ${e.selectable} but canon retired=${f.retired}`,
|
|
213
|
+
);
|
|
214
|
+
if (f.retired && !e.definition.includes("[RETIRED"))
|
|
215
|
+
bad.push(`${key}: retired in canon but no [RETIRED tombstone marker`);
|
|
216
|
+
}
|
|
217
|
+
expect(bad).toEqual([]);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("is flat and append-only: every function at a flat 133-NNN code, contiguous from 001, each key once", () => {
|
|
221
|
+
const prefixes = functions.map((e) => {
|
|
222
|
+
const m = FLAT.exec(e.code);
|
|
223
|
+
expect(
|
|
224
|
+
m,
|
|
225
|
+
`${e.key} at ${e.code} is not a flat segment-1 code`,
|
|
226
|
+
).not.toBeNull();
|
|
227
|
+
expect(e.parentCode).toBeNull();
|
|
228
|
+
expect(e.childCodes).toEqual([]);
|
|
229
|
+
return Number(m![1]);
|
|
230
|
+
});
|
|
231
|
+
expect(prefixes).toEqual(prefixes.map((_, i) => i + 1));
|
|
232
|
+
expect(new Set(functions.map((e) => e.key)).size).toBe(functions.length);
|
|
233
|
+
});
|
|
33
234
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
235
|
+
it("keeps every published code where it was — the append-only ledger (consumers gate on the key)", () => {
|
|
236
|
+
// src/__sot__/coreFunctions.published.json is written by the generator and read here, so CI
|
|
237
|
+
// enforces the contract without the prototype checkout: a published key never moves.
|
|
238
|
+
const pairs = Object.entries(ledger.prefixes);
|
|
239
|
+
expect(pairs.length).toBeGreaterThanOrEqual(113);
|
|
240
|
+
const bad: string[] = [];
|
|
241
|
+
for (const [key, prefix] of pairs) {
|
|
242
|
+
const e = byKey.get(key);
|
|
243
|
+
const want = `133-${String(prefix).padStart(3, "0")}-000-000-000-000-000`;
|
|
244
|
+
if (!e)
|
|
245
|
+
bad.push(
|
|
246
|
+
`${key}: published at ${want} but absent from the SOT (a dropped key must stay as a tombstone)`,
|
|
247
|
+
);
|
|
248
|
+
else if (e.code !== want)
|
|
249
|
+
bad.push(`${key}: published at ${want}, SOT has ${e.code}`);
|
|
250
|
+
if ((CoreFunctionsKeys as Record<string, string>)[key] !== want)
|
|
251
|
+
bad.push(`${key}: generated enum != ${want}`);
|
|
252
|
+
}
|
|
253
|
+
for (const e of functions)
|
|
254
|
+
if (!(e.key in ledger.prefixes))
|
|
255
|
+
bad.push(`${e.key}: in the SOT but not in the ledger`);
|
|
256
|
+
expect(bad).toEqual([]);
|
|
257
|
+
// The two ends of the 1.0.0 port, the 1.1.0 append, and where the 1.2.0 append lands.
|
|
258
|
+
expect(ledger.prefixes["account_suspend"]).toBe(1);
|
|
259
|
+
expect(ledger.prefixes["usr_manage"]).toBe(77);
|
|
260
|
+
expect(ledger.prefixes["note_open_departed_author"]).toBe(78);
|
|
261
|
+
expect(sot._supersedes.appended).toHaveLength(35);
|
|
262
|
+
expect(ledger.prefixes[sot._supersedes.appended[0]!]).toBe(79);
|
|
263
|
+
expect(ledger.prefixes[sot._supersedes.appended.at(-1)!]).toBe(
|
|
264
|
+
pin.functionCount + canonDrops.length,
|
|
265
|
+
);
|
|
266
|
+
expect(functions.at(-1)?.key).toBe(sot._supersedes.appended.at(-1));
|
|
37
267
|
});
|
|
38
268
|
|
|
39
|
-
it("
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
expect(
|
|
269
|
+
it("stamps every published key with the version that introduced it, and `since` agrees with the envelope", () => {
|
|
270
|
+
// `since` is what the generator reads to recompute `_supersedes.appended`
|
|
271
|
+
// on a --check re-run; asserting it here keeps the gate self-contained
|
|
272
|
+
// even where the generator's --check does not run (it needs the prototype).
|
|
273
|
+
const ledgerKeys = Object.keys(ledger.prefixes).sort();
|
|
274
|
+
expect(
|
|
275
|
+
Object.keys(ledger.since).sort(),
|
|
276
|
+
"since keys == ledger keys",
|
|
277
|
+
).toEqual(ledgerKeys);
|
|
278
|
+
for (const [k, v] of Object.entries(ledger.since))
|
|
279
|
+
expect(v, `${k}: since is a semver`).toMatch(/^\d+\.\d+\.\d+$/);
|
|
280
|
+
// The keys introduced in THIS version, in ledger (= code) order, are exactly
|
|
281
|
+
// what the envelope says was appended, in the same order.
|
|
282
|
+
const introducedHere = Object.keys(ledger.prefixes)
|
|
283
|
+
.filter((k) => ledger.since[k] === SOT_VERSION)
|
|
284
|
+
.sort((a, b) => ledger.prefixes[a]! - ledger.prefixes[b]!);
|
|
285
|
+
expect(
|
|
286
|
+
introducedHere,
|
|
287
|
+
`since === "${SOT_VERSION}" == _supersedes.appended`,
|
|
288
|
+
).toEqual(sot._supersedes.appended);
|
|
289
|
+
// ...and no key claims a version newer than the SOT.
|
|
290
|
+
const newer = Object.entries(ledger.since).filter(
|
|
291
|
+
([, v]) => compareSemver(v, SOT_VERSION) > 0,
|
|
292
|
+
);
|
|
293
|
+
expect(newer, "since newer than the SOT version").toEqual([]);
|
|
45
294
|
});
|
|
46
295
|
|
|
47
|
-
it("
|
|
48
|
-
|
|
49
|
-
expect(
|
|
50
|
-
|
|
51
|
-
|
|
296
|
+
it("absorbed the 2026-08-13 overhaul the 1.1.0 file had missed (spot checks against the pin)", () => {
|
|
297
|
+
// Re-scope: case_view PAVE -> PAVE, LEADS, THREAD.
|
|
298
|
+
expect(pin.fields["case_view"]!.platform_relevance).toEqual(
|
|
299
|
+
expect.arrayContaining(["PAVE", "LEADS", "THREAD"]),
|
|
300
|
+
);
|
|
301
|
+
expect(byKey.get("case_view")!.definition).toContain(
|
|
302
|
+
"Platform: PAVE, LEADS, THREAD.",
|
|
303
|
+
);
|
|
304
|
+
// v1 flip: the CI family is built, so it is no longer "(not v1)".
|
|
305
|
+
for (const k of [
|
|
306
|
+
"ci_record_validate",
|
|
307
|
+
"ci_periodic_review",
|
|
308
|
+
"ci_record_purge_or_retire",
|
|
309
|
+
"ci_to_evidence_export_authorize",
|
|
310
|
+
]) {
|
|
311
|
+
expect(byKey.get(k)!.definition, k).not.toContain("(not v1)");
|
|
312
|
+
}
|
|
313
|
+
// The case_edit split (D13) and the Communication family (D14) exist.
|
|
314
|
+
for (const k of [
|
|
315
|
+
"enrollment_manage",
|
|
316
|
+
"exit_discharge_conduct",
|
|
317
|
+
"service_log_manage",
|
|
318
|
+
"goals_plan_manage",
|
|
319
|
+
"needs_priorities_conduct",
|
|
320
|
+
"profile_domain_edit",
|
|
321
|
+
"message_send",
|
|
322
|
+
"message_moderate",
|
|
323
|
+
"announcement_publish",
|
|
324
|
+
"share_revoke",
|
|
325
|
+
"person_merge_manage",
|
|
326
|
+
"viewing_level_1_search",
|
|
327
|
+
"viewing_level_2_autocomplete",
|
|
328
|
+
"viewing_level_3_components",
|
|
329
|
+
]) {
|
|
330
|
+
expect(byKey.has(k), k).toBe(true);
|
|
331
|
+
expect(
|
|
332
|
+
(CoreFunctionsKeys as Record<string, string>)[k],
|
|
333
|
+
`${k} in the generated enum`,
|
|
334
|
+
).toBe(byKey.get(k)!.code);
|
|
335
|
+
}
|
|
52
336
|
});
|
|
53
337
|
});
|
|
@@ -645,10 +645,13 @@ const SOT_SPECS: readonly SotSpec[] = [
|
|
|
645
645
|
// fall-through floor, so the count is 5, NOT the 4 numeric BandCutoffs
|
|
646
646
|
// fields) + 4 missingness = 9
|
|
647
647
|
// ─── 0.8.12 vocabulary batch ───
|
|
648
|
-
// CANONICAL Notion CVC-133 `core - functions
|
|
649
|
-
//
|
|
650
|
-
//
|
|
651
|
-
|
|
648
|
+
// CANONICAL Notion CVC-133 `core - functions`, GENERATED from the prototype
|
|
649
|
+
// repo's data/cvcs/core_functions.yaml by scripts/gen-core-functions.py
|
|
650
|
+
// (SOT v1.2.0, 2026-10-12, additive): 113 canon functions (the 78 the 1.0.0
|
|
651
|
+
// port + 1.1.0 append published, at their codes, + 35 appended at
|
|
652
|
+
// 133-079 … 133-113 — the 2026-08-13 overhaul's rows the port never
|
|
653
|
+
// absorbed) + 4 missingness = 117
|
|
654
|
+
{ file: "coreFunctions.v1.2.0.json", domain: "core_functions", expectedCount: 117 },
|
|
652
655
|
// 9 fine-grained Needs-Assessment CAR change types (@pave/domain
|
|
653
656
|
// NEEDS_ASSESSMENT_CHANGE_TYPES, casing normalized to lower_snake) + 4 = 13
|
|
654
657
|
{ file: "needsAssessmentChangeType.v1.0.0.json", domain: "needs_assessment_change_type", expectedCount: 13 },
|
|
@@ -78,7 +78,7 @@ describe("parseCvcStatus", () => {
|
|
|
78
78
|
expect(result.sourcePath).toBeNull();
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
it("flags the self-contradictory core_functions case as ambiguous, generically — not a special case for this one domain (src/cvcs/coreFunctions.v1.1.0.json)", () => {
|
|
81
|
+
it("flags the self-contradictory core_functions case as ambiguous, generically — not a special case for this one domain (the historical src/cvcs/coreFunctions.v1.1.0.json `_status`, superseded by the generated 1.2.0)", () => {
|
|
82
82
|
const result = parseCvcStatus({
|
|
83
83
|
_status:
|
|
84
84
|
"DRAFTED — NEEDS REVIEW: canonical Notion CVC-133 (core - functions), verified v1.0, " +
|
|
@@ -182,7 +182,7 @@ const SOT_FILES: readonly SotFile[] = [
|
|
|
182
182
|
// ─── Risk taxonomy (names-only projection of the @hti/scoring SOT) ───
|
|
183
183
|
{ file: "riskCategory.v1.0.0.json", expectedDomain: "risk_category" },
|
|
184
184
|
// ─── 0.8.12 vocabulary batch ───
|
|
185
|
-
{ file: "coreFunctions.v1.
|
|
185
|
+
{ file: "coreFunctions.v1.2.0.json", expectedDomain: "core_functions" },
|
|
186
186
|
{ file: "needsAssessmentChangeType.v1.0.0.json", expectedDomain: "needs_assessment_change_type" },
|
|
187
187
|
{ file: "roiScope.v1.4.0.json", expectedDomain: "roi_scope" },
|
|
188
188
|
{ file: "roiStatus.v1.0.0.json", expectedDomain: "roi_status" },
|