@htilabs/platform-common-models 0.21.0 → 0.23.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 (71) hide show
  1. package/dist/authz/index.cjs +539 -0
  2. package/dist/authz/index.cjs.map +1 -0
  3. package/dist/authz/index.d.cts +210 -0
  4. package/dist/authz/index.d.ts +210 -0
  5. package/dist/authz/index.js +507 -0
  6. package/dist/authz/index.js.map +1 -0
  7. package/dist/constants/index.d.cts +2 -1
  8. package/dist/constants/index.d.ts +2 -1
  9. package/dist/cvcs/index.cjs +936 -243
  10. package/dist/cvcs/index.cjs.map +1 -1
  11. package/dist/cvcs/index.d.cts +986 -254
  12. package/dist/cvcs/index.d.ts +986 -254
  13. package/dist/cvcs/index.js +936 -243
  14. package/dist/cvcs/index.js.map +1 -1
  15. package/dist/enums/index.cjs +37 -10
  16. package/dist/enums/index.cjs.map +1 -1
  17. package/dist/enums/index.d.cts +42 -15
  18. package/dist/enums/index.d.ts +42 -15
  19. package/dist/enums/index.js +37 -10
  20. package/dist/enums/index.js.map +1 -1
  21. package/dist/{platform-auth-CvAYFVhK.d.cts → ic-DpKrdgQP.d.cts} +1 -78
  22. package/dist/{platform-auth-CvAYFVhK.d.ts → ic-DpKrdgQP.d.ts} +1 -78
  23. package/dist/index.cjs +1328 -253
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +4 -2
  26. package/dist/index.d.ts +4 -2
  27. package/dist/index.js +1313 -253
  28. package/dist/index.js.map +1 -1
  29. package/dist/platform-auth-B49Ly57B.d.cts +78 -0
  30. package/dist/platform-auth-B49Ly57B.d.ts +78 -0
  31. package/dist/schemas/index.cjs +104 -0
  32. package/dist/schemas/index.cjs.map +1 -1
  33. package/dist/schemas/index.d.cts +240 -1
  34. package/dist/schemas/index.d.ts +240 -1
  35. package/dist/schemas/index.js +95 -0
  36. package/dist/schemas/index.js.map +1 -1
  37. package/dist/types/index.d.cts +2 -2
  38. package/dist/types/index.d.ts +2 -2
  39. package/package.json +6 -1
  40. package/src/__sot__/README.md +3 -0
  41. package/src/__sot__/adminRoles.pin.json +122 -0
  42. package/src/__sot__/adminRoles.published.json +77 -0
  43. package/src/__sot__/coreFunctionFields.ts +137 -0
  44. package/src/__sot__/coreFunctions.pin.json +1659 -0
  45. package/src/__sot__/coreFunctions.published.json +233 -0
  46. package/src/__sot__/roleFields.ts +137 -0
  47. package/src/__sot__/userRoles.pin.json +174 -0
  48. package/src/__sot__/userRoles.published.json +103 -0
  49. package/src/__tests__/__snapshots__/cvc-sot.snap +6 -6
  50. package/src/__tests__/admin-roles-canon.test.ts +80 -0
  51. package/src/__tests__/authz-resolve.test.ts +712 -0
  52. package/src/__tests__/core-functions-canon.test.ts +358 -24
  53. package/src/__tests__/cvc-sot-snapshot.test.ts +17 -6
  54. package/src/__tests__/cvc-status-parser.test.ts +2 -2
  55. package/src/__tests__/cvc-structural.test.ts +3 -3
  56. package/src/__tests__/organization-program.test.ts +254 -0
  57. package/src/__tests__/role-vocab-gate.ts +279 -0
  58. package/src/__tests__/user-roles-canon.test.ts +104 -0
  59. package/src/authz/index.ts +9 -0
  60. package/src/authz/resolveEffectiveFunctions.ts +454 -0
  61. package/src/cvcs/adminRoles.v2.0.0.json +197 -0
  62. package/src/cvcs/{coreFunctions.v1.1.0.json → coreFunctions.v1.3.0.json} +646 -90
  63. package/src/cvcs/index.ts +3 -3
  64. package/src/cvcs/userRoles.v2.0.0.json +296 -0
  65. package/src/generated/coreFunctionsEvaluable.ts +101 -0
  66. package/src/generated/cvc-enums.ts +42 -15
  67. package/src/index.ts +4 -0
  68. package/src/schemas/index.ts +18 -0
  69. package/src/schemas/organization-program.ts +297 -0
  70. package/src/cvcs/adminRoles.v1.0.0.json +0 -153
  71. package/src/cvcs/userRoles.v1.0.0.json +0 -203
@@ -1,53 +1,387 @@
1
1
  /**
2
- * CORE FUNCTIONS (CVC-133) — v1.1.0 appends `note_open_departed_author`
2
+ * CORE FUNCTIONS (CVC-133) — GATE I: the SOT restates canon, whole
3
+ * =================================================================
3
4
  *
4
- * Canon added the Account Admin function on 2026-10-05 while building the
5
- * Narrative notes Spec v2 (rule 10); its logic_notes mark the row as awaiting
6
- * steward review (Crysta). `data/cvcs/core_functions.yaml` L68-93 @
7
- * prototype 9ef79748 (unchanged at fed744f3). The SOT appends it at 133-078
8
- * so every 1.0.0 code stays where it was; consumers gate on the key.
5
+ * `src/cvcs/coreFunctions.v1.3.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 {
34
+ CORE_FUNCTIONS_EVALUABLE_KEYS,
35
+ CORE_FUNCTIONS_EVALUABLE_SOT_VERSION,
36
+ } from "../generated/coreFunctionsEvaluable.js";
37
+ import { expectedDefinition } from "../__sot__/coreFunctionFields.js";
38
+ import type { ProjectedFunctionFields } from "../__sot__/coreFunctionFields.js";
18
39
 
19
40
  const here = path.dirname(fileURLToPath(import.meta.url));
20
41
  const cvcDir = path.join(here, "..", "cvcs");
42
+ const sotDir = path.join(here, "..", "__sot__");
43
+
44
+ const SOT_FILE = "coreFunctions.v1.3.0.json";
45
+ const SOT_VERSION = "1.3.0";
46
+ const SUPERSEDED_VERSION = "1.2.0";
47
+ /** Every superseded file is deleted per the bump checklist. */
48
+ const SUPERSEDED_FILES = ["coreFunctions.v1.1.0.json", "coreFunctions.v1.2.0.json"];
21
49
 
22
50
  interface Entry {
23
51
  code: string;
24
52
  key: string;
25
53
  title: string;
26
54
  selectable: boolean;
55
+ parentCode: string | null;
56
+ childCodes: string[];
27
57
  definition: string;
58
+ /** Canon's `v1` flag, structured since 1.3.0. */
59
+ v1: boolean;
60
+ /** Canon's `retired` flag, structured since 1.3.0. */
61
+ retired: boolean;
62
+ }
63
+ interface Envelope {
64
+ domain: string;
65
+ version: string;
66
+ _status: string;
67
+ _source: string;
68
+ _supersedes: {
69
+ version: string;
70
+ appended: string[];
71
+ refreshed: string[];
72
+ tombstoned: string[];
73
+ };
74
+ entries: Entry[];
75
+ }
76
+ interface Pin {
77
+ sourceRepo: string;
78
+ sourceFile: string;
79
+ sourceSha: string;
80
+ keys: string[];
81
+ fields: Record<string, ProjectedFunctionFields>;
82
+ functionCount: number;
83
+ v1Count: number;
28
84
  }
29
85
 
30
86
  const sot = JSON.parse(
31
- readFileSync(path.join(cvcDir, "coreFunctions.v1.1.0.json"), "utf8"),
32
- ) as { version: string; entries: Entry[] };
87
+ readFileSync(path.join(cvcDir, SOT_FILE), "utf8"),
88
+ ) as Envelope;
89
+ const pin = JSON.parse(
90
+ readFileSync(path.join(sotDir, "coreFunctions.pin.json"), "utf8"),
91
+ ) as Pin;
92
+ const ledger = JSON.parse(
93
+ readFileSync(path.join(sotDir, "coreFunctions.published.json"), "utf8"),
94
+ ) as { prefixes: Record<string, number>; since: Record<string, string> };
95
+
96
+ const MISSINGNESS = /^133-000-/;
97
+ const FLAT = /^133-(\d{3})-000-000-000-000-000$/;
98
+ const functions = sot.entries.filter((e) => !MISSINGNESS.test(e.code));
99
+ const byKey = new Map(functions.map((e) => [e.key, e] as const));
100
+
101
+ /**
102
+ * Completeness of the SOT against the pin, aware of the generator's
103
+ * `RETIREMENTS` path. A key the package once PUBLISHED (it is in the ledger)
104
+ * that canon has since dropped ENTIRELY (not even as `retired: true`) is kept
105
+ * in the SOT as a ledger-coded tombstone — the ledger test below demands it
106
+ * stay. Such a key is a "canon drop", not an invention, and it is counted on
107
+ * top of canon's own function count. Only a key in NEITHER the pin NOR the
108
+ * ledger is invented.
109
+ */
110
+ function completeness(
111
+ sotKeys: readonly string[],
112
+ canonKeys: readonly string[],
113
+ publishedKeys: readonly string[],
114
+ ): { missing: string[]; invented: string[]; canonDrops: string[] } {
115
+ const inSot = new Set(sotKeys);
116
+ const inCanon = new Set(canonKeys);
117
+ const published = new Set(publishedKeys);
118
+ return {
119
+ missing: canonKeys.filter((k) => !inSot.has(k)),
120
+ invented: sotKeys.filter((k) => !inCanon.has(k) && !published.has(k)),
121
+ canonDrops: [...published].filter((k) => !inCanon.has(k)).sort(),
122
+ };
123
+ }
124
+
125
+ function compareSemver(a: string, b: string): number {
126
+ const [pa, pb] = [a, b].map((v) => v.split(".").map(Number));
127
+ for (let i = 0; i < 3; i++) {
128
+ const d = (pa![i] ?? 0) - (pb![i] ?? 0);
129
+ if (d !== 0) return Math.sign(d);
130
+ }
131
+ return 0;
132
+ }
133
+
134
+ const { canonDrops } = completeness(
135
+ [...byKey.keys()],
136
+ pin.keys,
137
+ Object.keys(ledger.prefixes),
138
+ );
139
+
140
+ describe("core_functions — GATE I: the SOT restates canon (CVC-133 @ the pin)", () => {
141
+ it("is the generated file, at its version, superseding 1.2.0 (1.1.0 and 1.2.0 are gone)", () => {
142
+ expect(sot.domain).toBe("core_functions");
143
+ expect(sot.version).toBe(SOT_VERSION);
144
+ expect(sot._status).toMatch(/^CANONICAL — /);
145
+ expect(sot._status).toContain("GENERATED");
146
+ expect(sot._source).toContain(pin.sourceFile);
147
+ expect(sot._supersedes.version).toBe(SUPERSEDED_VERSION);
148
+ for (const f of SUPERSEDED_FILES)
149
+ expect(() => readFileSync(path.join(cvcDir, f)), f).toThrow();
150
+ });
151
+
152
+ it("pins canon's own counts", () => {
153
+ expect(pin.sourceRepo).toBe("htilabstech/prototype");
154
+ expect(pin.sourceFile).toBe("data/cvcs/core_functions.yaml");
155
+ expect(pin.keys).toHaveLength(pin.functionCount);
156
+ expect(Object.keys(pin.fields).sort()).toEqual(pin.keys);
157
+ });
158
+
159
+ it("carries EVERY canon function and NOTHING canon does not (the 35-row gap is closed)", () => {
160
+ const { missing, invented } = completeness(
161
+ [...byKey.keys()].sort(),
162
+ pin.keys,
163
+ Object.keys(ledger.prefixes),
164
+ );
165
+ expect(missing, "canon keys the SOT does not carry").toEqual([]);
166
+ expect(
167
+ invented,
168
+ "SOT keys neither canon nor the published ledger carries",
169
+ ).toEqual([]);
170
+ expect(functions).toHaveLength(pin.functionCount + canonDrops.length);
171
+ expect(sot.entries).toHaveLength(pin.functionCount + canonDrops.length + 4);
172
+ });
173
+
174
+ it("keeps a key canon DROPPED (the generator's RETIREMENTS path) as a ledger-coded tombstone, never an invention", () => {
175
+ // Today no published key has left canon (RETIREMENTS is empty), so this is
176
+ // vacuous on the real SOT — but it must not contradict the ledger test the
177
+ // day RETIREMENTS is first used.
178
+ for (const k of canonDrops) {
179
+ const e = byKey.get(k);
180
+ expect(e, `${k}: dropped by canon but absent from the SOT`).toBeDefined();
181
+ expect(e!.selectable, `${k}: a canon drop must not be selectable`).toBe(
182
+ false,
183
+ );
184
+ expect(
185
+ e!.definition,
186
+ `${k}: a canon drop carries the [RETIRED marker`,
187
+ ).toMatch(/^\[RETIRED/);
188
+ expect(
189
+ sot._supersedes.tombstoned,
190
+ `${k}: listed as tombstoned`,
191
+ ).toContain(k);
192
+ }
193
+ // The rule itself, on a synthetic drop: remove one published key from canon
194
+ // while the SOT keeps it as a tombstone. It is a canon drop (counted), not
195
+ // missing and not invented — and a key in neither canon nor the ledger is.
196
+ const dropped = pin.keys[0]!;
197
+ const canonAfterDrop = pin.keys.filter((k) => k !== dropped);
198
+ const r = completeness(
199
+ [...byKey.keys(), "not_published_anywhere"],
200
+ canonAfterDrop,
201
+ Object.keys(ledger.prefixes),
202
+ );
203
+ expect(r.missing).toEqual([]);
204
+ expect(r.canonDrops).toEqual([...canonDrops, dropped].sort());
205
+ expect(r.invented).toEqual(["not_published_anywhere"]);
206
+ });
207
+
208
+ it("restates every canon field: label as title, canon's definition + posture suffix as definition, retired as a tombstone", () => {
209
+ const bad: string[] = [];
210
+ for (const key of pin.keys) {
211
+ const f = pin.fields[key]!;
212
+ const e = byKey.get(key)!;
213
+ if (e.title !== f.label)
214
+ bad.push(
215
+ `${key}: title ${JSON.stringify(e.title)} != canon label ${JSON.stringify(f.label)}`,
216
+ );
217
+ if (e.definition !== expectedDefinition(f))
218
+ bad.push(
219
+ `${key}: definition is not canon's body + posture suffix (expected ${JSON.stringify(expectedDefinition(f))})`,
220
+ );
221
+ if (e.selectable !== !f.retired)
222
+ bad.push(
223
+ `${key}: selectable ${e.selectable} but canon retired=${f.retired}`,
224
+ );
225
+ if (f.retired && !e.definition.includes("[RETIRED"))
226
+ bad.push(`${key}: retired in canon but no [RETIRED tombstone marker`);
227
+ }
228
+ expect(bad).toEqual([]);
229
+ });
230
+
231
+ it("carries canon's v1 and retired flags as structured booleans on every entry (1.3.0; read by the shared authz resolver)", () => {
232
+ const bad: string[] = [];
233
+ for (const e of sot.entries) {
234
+ if (typeof e.v1 !== "boolean" || typeof e.retired !== "boolean")
235
+ bad.push(`${e.key}: v1/retired are not booleans`);
236
+ }
237
+ for (const key of pin.keys) {
238
+ const f = pin.fields[key]!;
239
+ const e = byKey.get(key)!;
240
+ if (e.v1 !== f.v1) bad.push(`${key}: v1 ${e.v1} != canon v1 ${f.v1}`);
241
+ if (e.retired !== f.retired)
242
+ bad.push(`${key}: retired ${e.retired} != canon retired ${f.retired}`);
243
+ }
244
+ // The missingness sentinels are not permissionable functions.
245
+ for (const e of sot.entries.filter((x) => MISSINGNESS.test(x.code))) {
246
+ if (e.v1 || e.retired) bad.push(`${e.key}: a missingness sentinel must be v1 false / retired false`);
247
+ }
248
+ // A canon drop (RETIREMENTS) is retired, never v1.
249
+ for (const k of canonDrops) {
250
+ const e = byKey.get(k);
251
+ if (e && (e.v1 || !e.retired)) bad.push(`${k}: a canon drop must be v1 false / retired true`);
252
+ }
253
+ expect(bad).toEqual([]);
254
+ expect(functions.filter((e) => e.v1)).toHaveLength(pin.v1Count);
255
+ expect(Object.values(pin.fields).filter((f) => f.v1)).toHaveLength(pin.v1Count);
256
+ });
257
+
258
+ it("the generated evaluable key set (the authz resolver's canon input) equals the SOT's v1 && !retired keys", () => {
259
+ expect(CORE_FUNCTIONS_EVALUABLE_SOT_VERSION).toBe(SOT_VERSION);
260
+ const fromSot = sot.entries.filter((e) => e.v1 && !e.retired).map((e) => e.key).sort();
261
+ expect([...CORE_FUNCTIONS_EVALUABLE_KEYS]).toEqual(fromSot);
262
+ expect(CORE_FUNCTIONS_EVALUABLE_KEYS).toHaveLength(pin.v1Count);
263
+ });
264
+
265
+ it("is flat and append-only: every function at a flat 133-NNN code, contiguous from 001, each key once", () => {
266
+ const prefixes = functions.map((e) => {
267
+ const m = FLAT.exec(e.code);
268
+ expect(
269
+ m,
270
+ `${e.key} at ${e.code} is not a flat segment-1 code`,
271
+ ).not.toBeNull();
272
+ expect(e.parentCode).toBeNull();
273
+ expect(e.childCodes).toEqual([]);
274
+ return Number(m![1]);
275
+ });
276
+ expect(prefixes).toEqual(prefixes.map((_, i) => i + 1));
277
+ expect(new Set(functions.map((e) => e.key)).size).toBe(functions.length);
278
+ });
33
279
 
34
- describe("core_functions — note_open_departed_author (CVC-133 v1.1.0)", () => {
35
- it("exports the key at its appended code", () => {
36
- expect(CoreFunctionsKeys.note_open_departed_author).toBe("133-078-000-000-000-000-000");
280
+ it("keeps every published code where it was — the append-only ledger (consumers gate on the key)", () => {
281
+ // src/__sot__/coreFunctions.published.json is written by the generator and read here, so CI
282
+ // enforces the contract without the prototype checkout: a published key never moves.
283
+ const pairs = Object.entries(ledger.prefixes);
284
+ expect(pairs.length).toBeGreaterThanOrEqual(113);
285
+ const bad: string[] = [];
286
+ for (const [key, prefix] of pairs) {
287
+ const e = byKey.get(key);
288
+ const want = `133-${String(prefix).padStart(3, "0")}-000-000-000-000-000`;
289
+ if (!e)
290
+ bad.push(
291
+ `${key}: published at ${want} but absent from the SOT (a dropped key must stay as a tombstone)`,
292
+ );
293
+ else if (e.code !== want)
294
+ bad.push(`${key}: published at ${want}, SOT has ${e.code}`);
295
+ if ((CoreFunctionsKeys as Record<string, string>)[key] !== want)
296
+ bad.push(`${key}: generated enum != ${want}`);
297
+ }
298
+ for (const e of functions)
299
+ if (!(e.key in ledger.prefixes))
300
+ bad.push(`${e.key}: in the SOT but not in the ledger`);
301
+ expect(bad).toEqual([]);
302
+ // The two ends of the 1.0.0 port, the 1.1.0 append, and where the 1.2.0
303
+ // append landed (1.3.0 appended nothing: it added the v1 / retired fields).
304
+ expect(ledger.prefixes["account_suspend"]).toBe(1);
305
+ expect(ledger.prefixes["usr_manage"]).toBe(77);
306
+ expect(ledger.prefixes["note_open_departed_author"]).toBe(78);
307
+ const appended120 = Object.keys(ledger.prefixes)
308
+ .filter((k) => ledger.since[k] === "1.2.0")
309
+ .sort((a, b) => ledger.prefixes[a]! - ledger.prefixes[b]!);
310
+ expect(appended120).toHaveLength(35);
311
+ expect(ledger.prefixes[appended120[0]!]).toBe(79);
312
+ expect(ledger.prefixes[appended120.at(-1)!]).toBe(
313
+ pin.functionCount + canonDrops.length,
314
+ );
315
+ expect(functions.at(-1)?.key).toBe(appended120.at(-1));
316
+ expect(sot._supersedes.appended).toEqual([]);
37
317
  });
38
318
 
39
- it("carries canon's label and the PAVE + THREAD, admin-only posture", () => {
40
- const row = sot.entries.find((e) => e.key === "note_open_departed_author");
41
- expect(row?.title).toBe("Open a deactivated author's private notes");
42
- expect(row?.selectable).toBe(true);
43
- expect(row?.definition).toContain("Platform: PAVE, THREAD.");
44
- expect(row?.definition).toContain("User-relevant: no. Admin-relevant: yes.");
319
+ it("stamps every published key with the version that introduced it, and `since` agrees with the envelope", () => {
320
+ // `since` is what the generator reads to recompute `_supersedes.appended`
321
+ // on a --check re-run; asserting it here keeps the gate self-contained
322
+ // even where the generator's --check does not run (it needs the prototype).
323
+ const ledgerKeys = Object.keys(ledger.prefixes).sort();
324
+ expect(
325
+ Object.keys(ledger.since).sort(),
326
+ "since keys == ledger keys",
327
+ ).toEqual(ledgerKeys);
328
+ for (const [k, v] of Object.entries(ledger.since))
329
+ expect(v, `${k}: since is a semver`).toMatch(/^\d+\.\d+\.\d+$/);
330
+ // The keys introduced in THIS version, in ledger (= code) order, are exactly
331
+ // what the envelope says was appended, in the same order.
332
+ const introducedHere = Object.keys(ledger.prefixes)
333
+ .filter((k) => ledger.since[k] === SOT_VERSION)
334
+ .sort((a, b) => ledger.prefixes[a]! - ledger.prefixes[b]!);
335
+ expect(
336
+ introducedHere,
337
+ `since === "${SOT_VERSION}" == _supersedes.appended`,
338
+ ).toEqual(sot._supersedes.appended);
339
+ // ...and no key claims a version newer than the SOT.
340
+ const newer = Object.entries(ledger.since).filter(
341
+ ([, v]) => compareSemver(v, SOT_VERSION) > 0,
342
+ );
343
+ expect(newer, "since newer than the SOT version").toEqual([]);
45
344
  });
46
345
 
47
- it("is an append: it is the last entry and 1.0.0 is gone", () => {
48
- expect(sot.version).toBe("1.1.0");
49
- expect(sot.entries.at(-1)?.key).toBe("note_open_departed_author");
50
- expect(sot.entries).toHaveLength(82);
51
- expect(() => readFileSync(path.join(cvcDir, "coreFunctions.v1.0.0.json"))).toThrow();
346
+ it("absorbed the 2026-08-13 overhaul the 1.1.0 file had missed (spot checks against the pin)", () => {
347
+ // Re-scope: case_view PAVE -> PAVE, LEADS, THREAD.
348
+ expect(pin.fields["case_view"]!.platform_relevance).toEqual(
349
+ expect.arrayContaining(["PAVE", "LEADS", "THREAD"]),
350
+ );
351
+ expect(byKey.get("case_view")!.definition).toContain(
352
+ "Platform: PAVE, LEADS, THREAD.",
353
+ );
354
+ // v1 flip: the CI family is built, so it is no longer "(not v1)".
355
+ for (const k of [
356
+ "ci_record_validate",
357
+ "ci_periodic_review",
358
+ "ci_record_purge_or_retire",
359
+ "ci_to_evidence_export_authorize",
360
+ ]) {
361
+ expect(byKey.get(k)!.definition, k).not.toContain("(not v1)");
362
+ }
363
+ // The case_edit split (D13) and the Communication family (D14) exist.
364
+ for (const k of [
365
+ "enrollment_manage",
366
+ "exit_discharge_conduct",
367
+ "service_log_manage",
368
+ "goals_plan_manage",
369
+ "needs_priorities_conduct",
370
+ "profile_domain_edit",
371
+ "message_send",
372
+ "message_moderate",
373
+ "announcement_publish",
374
+ "share_revoke",
375
+ "person_merge_manage",
376
+ "viewing_level_1_search",
377
+ "viewing_level_2_autocomplete",
378
+ "viewing_level_3_components",
379
+ ]) {
380
+ expect(byKey.has(k), k).toBe(true);
381
+ expect(
382
+ (CoreFunctionsKeys as Record<string, string>)[k],
383
+ `${k} in the generated enum`,
384
+ ).toBe(byKey.get(k)!.code);
385
+ }
52
386
  });
53
387
  });
@@ -645,10 +645,14 @@ 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` (verified v1.0): 77 functions
649
- // + note_open_departed_author (133-078, appended 2026-10-05, Narrative notes
650
- // Spec v2 rule 10; SOT v1.1.0, additive) + 4 missingness = 82
651
- { file: "coreFunctions.v1.1.0.json", domain: "core_functions", expectedCount: 82 },
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. SOT v1.3.0 (2026-10-13, additive, co-zo3):
654
+ // structured `v1` / `retired` on every entry; same 117.
655
+ { file: "coreFunctions.v1.3.0.json", domain: "core_functions", expectedCount: 117 },
652
656
  // 9 fine-grained Needs-Assessment CAR change types (@pave/domain
653
657
  // NEEDS_ASSESSMENT_CHANGE_TYPES, casing normalized to lower_snake) + 4 = 13
654
658
  { file: "needsAssessmentChangeType.v1.0.0.json", domain: "needs_assessment_change_type", expectedCount: 13 },
@@ -671,8 +675,15 @@ const SOT_SPECS: readonly SotSpec[] = [
671
675
  // upstream; the 2 scoring-ahead `_youth` codes withdrawn — hti-scoring 9c209cf no longer emits them).
672
676
  { file: "coreIndicators.v1.1.0.json", domain: "core_indicators", expectedCount: 226 },
673
677
  { file: "riskSeverityBand.v1.0.0.json", domain: "risk_severity_band", expectedCount: 9 },
674
- { file: "adminRoles.v1.0.0.json", domain: "admin_roles", expectedCount: 14 },
675
- { file: "userRoles.v1.0.0.json", domain: "user_roles", expectedCount: 19 },
678
+ // CVC-134 — 10 canon admin roles, NO missingness (the 1.0.0 quadruplet is
679
+ // withdrawn). SOT v2.0.0, generated by scripts/gen-admin-roles.py; GATE K
680
+ // (admin-roles-canon.test.ts) pins canon.
681
+ { file: "adminRoles.v2.0.0.json", domain: "admin_roles", expectedCount: 10 },
682
+ // CVC-135 — 15 canon user roles, NO missingness (the 1.0.0 quadruplet is
683
+ // withdrawn). SOT v2.0.0 (MAJOR: `hotline_op` re-keyed to canon
684
+ // `crisis_response` at 135-004; missingness keys removed), generated by
685
+ // scripts/gen-user-roles.py; GATE J (user-roles-canon.test.ts) pins canon.
686
+ { file: "userRoles.v2.0.0.json", domain: "user_roles", expectedCount: 15 },
676
687
  { file: "hmisCurrentLivingSituation.v1.0.0.json", domain: "hmis_current_living_situation", expectedCount: 33 },
677
688
  { file: "juvenileJusticeEpisodeType.v1.0.0.json", domain: "juvenile_justice_episode_type", expectedCount: 9 },
678
689
  { file: "incarcerationEpisodeType.v1.0.0.json", domain: "incarceration_episode_type", expectedCount: 9 },
@@ -49,7 +49,7 @@ describe("parseCvcStatus", () => {
49
49
  expect(result.sourcePath).toBeNull();
50
50
  });
51
51
 
52
- it("classifies a CANONICAL provenance-note domain as its own maturity, not 'draft'/'final' (admin_roles, src/cvcs/adminRoles.v1.0.0.json)", () => {
52
+ it("classifies a CANONICAL provenance-note domain as its own maturity, not 'draft'/'final' (the admin_roles 1.0.0 provenance note)", () => {
53
53
  const result = parseCvcStatus({
54
54
  _status:
55
55
  "CANONICAL — imported 0.8.13 from the Notion Final CVC codebook (CVC-134 `core - admin " +
@@ -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.1.0.json", expectedDomain: "core_functions" },
185
+ { file: "coreFunctions.v1.3.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" },
@@ -192,8 +192,8 @@ const SOT_FILES: readonly SotFile[] = [
192
192
  { file: "coreDhState.v1.0.0.json", expectedDomain: "dh_state" },
193
193
  { file: "coreIndicators.v1.1.0.json", expectedDomain: "core_indicators" },
194
194
  { file: "riskSeverityBand.v1.0.0.json", expectedDomain: "risk_severity_band" },
195
- { file: "adminRoles.v1.0.0.json", expectedDomain: "admin_roles" },
196
- { file: "userRoles.v1.0.0.json", expectedDomain: "user_roles" },
195
+ { file: "adminRoles.v2.0.0.json", expectedDomain: "admin_roles" },
196
+ { file: "userRoles.v2.0.0.json", expectedDomain: "user_roles" },
197
197
  { file: "hmisCurrentLivingSituation.v1.0.0.json", expectedDomain: "hmis_current_living_situation" },
198
198
  { file: "juvenileJusticeEpisodeType.v1.0.0.json", expectedDomain: "juvenile_justice_episode_type" },
199
199
  { file: "incarcerationEpisodeType.v1.0.0.json", expectedDomain: "incarceration_episode_type" },