@htilabs/platform-common-models 0.23.0 → 0.24.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 (61) hide show
  1. package/README.md +39 -0
  2. package/dist/authz/index.cjs +143 -12
  3. package/dist/authz/index.cjs.map +1 -1
  4. package/dist/authz/index.d.cts +121 -12
  5. package/dist/authz/index.d.ts +121 -12
  6. package/dist/authz/index.js +136 -12
  7. package/dist/authz/index.js.map +1 -1
  8. package/dist/constants/index.cjs +30 -0
  9. package/dist/constants/index.cjs.map +1 -1
  10. package/dist/constants/index.d.cts +1 -1
  11. package/dist/constants/index.d.ts +1 -1
  12. package/dist/constants/index.js +26 -0
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-BqAGctqK.d.cts} +4 -1
  15. package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-BqAGctqK.d.ts} +4 -1
  16. package/dist/{index-Zu_mOJRn.d.cts → index-BTqHP4DM.d.cts} +1 -1
  17. package/dist/{index-CDoqrfc1.d.ts → index-Dr6GBCoY.d.ts} +1 -1
  18. package/dist/index.cjs +147 -13
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +4 -4
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +140 -13
  23. package/dist/index.js.map +1 -1
  24. package/dist/models/index.cjs +26 -1
  25. package/dist/models/index.cjs.map +1 -1
  26. package/dist/models/index.d.cts +2 -2
  27. package/dist/models/index.d.ts +2 -2
  28. package/dist/models/index.js +26 -1
  29. package/dist/models/index.js.map +1 -1
  30. package/dist/{platform-auth-B49Ly57B.d.cts → platform-auth-DJO-r9Pf.d.cts} +48 -1
  31. package/dist/{platform-auth-B49Ly57B.d.ts → platform-auth-DJO-r9Pf.d.ts} +48 -1
  32. package/dist/schemas/index.cjs +26 -1
  33. package/dist/schemas/index.cjs.map +1 -1
  34. package/dist/schemas/index.d.cts +1 -1
  35. package/dist/schemas/index.d.ts +1 -1
  36. package/dist/schemas/index.js +26 -1
  37. package/dist/schemas/index.js.map +1 -1
  38. package/dist/services/index.cjs +26 -1
  39. package/dist/services/index.cjs.map +1 -1
  40. package/dist/services/index.js +26 -1
  41. package/dist/services/index.js.map +1 -1
  42. package/dist/types/index.d.cts +11 -3
  43. package/dist/types/index.d.ts +11 -3
  44. package/dist/validation/index.cjs +22 -0
  45. package/dist/validation/index.cjs.map +1 -1
  46. package/dist/validation/index.js +22 -0
  47. package/dist/validation/index.js.map +1 -1
  48. package/package.json +1 -1
  49. package/src/__sot__/README.md +1 -1
  50. package/src/__sot__/coreFunctionFields.ts +88 -4
  51. package/src/__sot__/coreFunctions.pin.json +1040 -113
  52. package/src/__tests__/authz-resolve.test.ts +115 -31
  53. package/src/__tests__/core-function-default-bounds.test.ts +374 -0
  54. package/src/__tests__/core-functions-case-close.test.ts +82 -0
  55. package/src/authz/defaultBounds.ts +69 -0
  56. package/src/authz/index.ts +12 -3
  57. package/src/authz/resolveEffectiveFunctions.ts +69 -29
  58. package/src/constants/platform-auth.ts +60 -0
  59. package/src/generated/coreFunctionDefaultBounds.ts +109 -0
  60. package/src/schemas/platform-role.ts +4 -1
  61. package/src/types/platform-auth.ts +9 -2
@@ -0,0 +1,82 @@
1
+ /**
2
+ * CORE FUNCTIONS (CVC-133) — `case_close` is ONE function carrying both legs
3
+ * ===========================================================================
4
+ *
5
+ * Crysta's 2026-10-09 ruling (case close is holder-only and is a REQUEST that
6
+ * an Account Admin or the holder's team Supervisor approves or does not
7
+ * approve) is already minted in canon as a single CVC-133 row, `case_close`
8
+ * (prototype `data/cvcs/core_functions.yaml` @ f4356aa4, L2383-L2394, "Minted
9
+ * 2026-10-10"), and the generated SOT v1.3.0 carries it at
10
+ * 133-098-000-000-000-000-000. The approval leg is not a second function: canon
11
+ * gives it to "the supervisor-confirm leg of case_status_manage brought to
12
+ * PAVE" — the approver must hold `case_close` AND be an Account Admin of the
13
+ * case's account or a supervisor of the holder, and is never the requester
14
+ * (L2392). Bounds ride canon only (Always MEM-ADM · SUP · case_nav; Default On
15
+ * TEAM-ADM, L2398-L2414); this entry schema does not carry bounds.
16
+ *
17
+ * What this pins, against the regression it exists for: a hand-minted
18
+ * `case_close_request` / `case_close_approve` pair next to the canon row (an
19
+ * engineer-direct "mint" of something canon already has — GATE I would also
20
+ * refuse it as invented, this names the reason), and a regenerated row that
21
+ * silently loses the request/approval semantics PAVE's close flow enforces
22
+ * (bead pv-p6share-case-close-request-approval). The notification kinds the
23
+ * flow emits (`caseCloseRequested` / `caseCloseRuled`, CVC-284 v19) are NOT
24
+ * carried by this package — CVC-284 has no domain here — so nothing pins them.
25
+ *
26
+ * The expectations are transcribed from canon, not derived from the JSON.
27
+ */
28
+ import { readFileSync } from "node:fs";
29
+ import path from "node:path";
30
+ import { fileURLToPath } from "node:url";
31
+ import { describe, it, expect } from "vitest";
32
+
33
+ import { CoreFunctionsKeys } from "../generated/cvc-enums.js";
34
+
35
+ const here = path.dirname(fileURLToPath(import.meta.url));
36
+ const SOT = path.join(here, "..", "cvcs", "coreFunctions.v1.3.0.json");
37
+
38
+ interface Entry {
39
+ code: string;
40
+ key: string;
41
+ title: string;
42
+ selectable: boolean;
43
+ parentCode: string | null;
44
+ childCodes: string[];
45
+ definition: string;
46
+ }
47
+
48
+ const entries = (JSON.parse(readFileSync(SOT, "utf8")) as { entries: Entry[] }).entries;
49
+
50
+ describe("CVC-133 case_close — the holder's close request and its approval are one function", () => {
51
+ it("is published at 133-098 and exported by key", () => {
52
+ expect(CoreFunctionsKeys.case_close).toBe("133-098-000-000-000-000-000");
53
+ });
54
+
55
+ it("is a selectable leaf titled as canon titles it", () => {
56
+ const row = entries.find((e) => e.key === "case_close");
57
+ expect(row).toBeDefined();
58
+ expect(row).toMatchObject({
59
+ code: "133-098-000-000-000-000-000",
60
+ title: "Close case",
61
+ selectable: true,
62
+ parentCode: null,
63
+ childCodes: [],
64
+ });
65
+ });
66
+
67
+ it("defines the close as a REQUEST that waits on an Account Admin or the holder's team Supervisor", () => {
68
+ const def = entries.find((e) => e.key === "case_close")?.definition ?? "";
69
+ expect(def).toContain("submit it as a CLOSE REQUEST");
70
+ expect(def).toContain(
71
+ "until an Account Admin or the holder's team Supervisor approves or does not approve it",
72
+ );
73
+ expect(def).toContain("Nothing closes until the approval.");
74
+ expect(def).toContain("Platform: PAVE.");
75
+ expect(def).toContain("Category: Core case/lead workflow, Approval-gated actions.");
76
+ });
77
+
78
+ it("has no split request/approve sibling — the approval leg rides case_close", () => {
79
+ const siblings = entries.map((e) => e.key).filter((k) => /^case_close./.test(k));
80
+ expect(siblings).toEqual([]);
81
+ });
82
+ });
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @htilabs/platform-common-models — CVC-133 codebook default bounds (co-p1x)
3
+ *
4
+ * The codebook's default bound for every (evaluable function, role) pair:
5
+ * canon's `bounds:` block (records repo `data/cvcs/core_functions.yaml`),
6
+ * generated into `CORE_FUNCTION_DEFAULT_BOUNDS` by
7
+ * `scripts/gen-core-functions.py` and held equal to the pinned canon by GATE L.
8
+ *
9
+ * WHAT THESE ARE — and are not. The kickoff
10
+ * (`KICKOFF_SHARED_AUTHZ_RESOLVER_2026-10-12.md` § 3 rule 7) rules that the
11
+ * live role × function bounds are platform POLICY STATE, edited only by
12
+ * PLT-ADM on Platform Configuration. This module does not change that: it is
13
+ * the CODEBOOK DEFAULT under the policy — what platform seeds into
14
+ * `platformRoles.functions` when a role row is inserted, and what the bounds
15
+ * editor's "clear" reverts to (platform-prototype @ a6f1f3a
16
+ * `PLATFORM_BOUNDS.pristineStateFor`, `src/agencyhub.jsx:2024-2039`; the
17
+ * five chip states always / default_on / default_off / never / na,
18
+ * `src/screens.jsx:19151-19152`). The resolver never reads it: it reads the
19
+ * stored policy rows it is handed (`resolveEffectiveFunctions`).
20
+ *
21
+ * UNBOUND IS INELIGIBLE — aligned to canon (co-p1x, 0.24.0). A role the
22
+ * codebook does not name for a function has no default bound
23
+ * (`codebookDefaultBound` → `null`), and a seeder writes nothing for it.
24
+ * Canon's `authzResolve` returns `role_ineligible` for such a role before any
25
+ * agency layer runs (`src/agencyhub.jsx:578-584`), and
26
+ * `resolveEffectiveFunctions` now does the same: a role row with no stored
27
+ * state for a function is NEVER for that role — no agency override and no
28
+ * team policy can enable the pair — and, like every NEVER, it is local to its
29
+ * role (another held role's grant stands). The dev resolvers' tool-overlap
30
+ * default (unlisted → PREF_NO on a shared tool) is gone; the role and
31
+ * function rows' `tools` are no longer read by the resolver.
32
+ *
33
+ * NA. A platform that seeds Tier 1 verbatim from this map stores `"NA"` for
34
+ * the codebook's "Not relevant" pairs. The resolver reads a stored `NA` as
35
+ * NEVER at every tier (a recognised codebook value, not malformed data): at
36
+ * Tier 1 it is locked, at Tier 2 it denies that role, at Tier 3 it restricts
37
+ * (Required stays immune). Malformed data would deny identically; reading it
38
+ * as NEVER just keeps a legitimate seed out of the malformed class. Only the
39
+ * Tier-1 type admits it (`AuthzTier1StateMap`, `PlatformRoleDef.functions`);
40
+ * agency / team maps stay PermissionStateValue (canon has no NA chip there),
41
+ * and a stored NA there still denies. GATE L's property tests check the
42
+ * resolver, seeded from this map, against an oracle taken from canon
43
+ * `authzResolve` (`:551-628`, with the Required-immunity ruling): every
44
+ * function × role × agency × team value, and every role pair's union.
45
+ */
46
+
47
+ import type { DefaultBoundStateValue } from "../constants/platform-auth.js";
48
+ import { CORE_FUNCTION_DEFAULT_BOUNDS } from "../generated/coreFunctionDefaultBounds.js";
49
+
50
+ export {
51
+ CORE_FUNCTION_DEFAULT_BOUNDS,
52
+ CORE_FUNCTION_DEFAULT_BOUNDS_SOT_VERSION,
53
+ } from "../generated/coreFunctionDefaultBounds.js";
54
+
55
+ /**
56
+ * The codebook default bound of `roleCode` (a CVC-134 / CVC-135
57
+ * `canonicalCode`, e.g. `MEM-ADM`, `case_nav`) for `functionCode`, or `null`
58
+ * when the role is unbound for it — including when the function is not
59
+ * evaluable (unknown, retired or not-v1). Own keys only, so an inherited name
60
+ * such as `constructor` is never a function or a role.
61
+ */
62
+ export function codebookDefaultBound(
63
+ functionCode: string,
64
+ roleCode: string,
65
+ ): DefaultBoundStateValue | null {
66
+ if (!Object.hasOwn(CORE_FUNCTION_DEFAULT_BOUNDS, functionCode)) return null;
67
+ const roles = CORE_FUNCTION_DEFAULT_BOUNDS[functionCode]!;
68
+ return Object.hasOwn(roles, roleCode) ? roles[roleCode]! : null;
69
+ }
@@ -1,9 +1,18 @@
1
1
  /**
2
2
  * @htilabs/platform-common-models/authz
3
3
  *
4
- * Browser-safe entry for the shared CVC-133 authorization resolver: pure
5
- * TypeScript, no mongoose, no I/O. Also re-exported from the package root
6
- * (which loads mongoose-backed models and services).
4
+ * Browser-safe entry for the shared CVC-133 authorization resolver and the
5
+ * CVC-133 codebook default bounds: pure TypeScript, no mongoose, no I/O. Also
6
+ * re-exported from the package root (which loads mongoose-backed models and
7
+ * services).
7
8
  */
8
9
 
9
10
  export * from "./resolveEffectiveFunctions.js";
11
+ export * from "./defaultBounds.js";
12
+ export {
13
+ DEFAULT_BOUND_STATE,
14
+ DEFAULT_BOUND_STATE_DISPLAY,
15
+ DEFAULT_BOUND_STATE_LABELS,
16
+ DEFAULT_BOUND_STATE_VALUES,
17
+ type DefaultBoundStateValue,
18
+ } from "../constants/platform-auth.js";
@@ -32,6 +32,17 @@
32
32
  * cascade ends at NEVER / Default-Off simply contributes nothing — it never
33
33
  * vetoes another role's grant (`:566-589`, Crysta 2026-08-09 "grants are
34
34
  * computed first"; restated 2026-10-12 "roles stack").
35
+ * UNBOUND IS INELIGIBLE (co-p1x, aligned to canon): a role whose Tier-1
36
+ * row carries no state for a function is not eligible for it — the
37
+ * prototype returns `role_ineligible` before any agency layer runs
38
+ * (`:578-584`), so neither an agency override nor a team policy can turn
39
+ * an unbound pair on. For that role it is NEVER, and like every NEVER it
40
+ * is local to the role. (The dev resolvers' tool-overlap default — an
41
+ * unlisted function reading PREF_NO when it shares one of the role's
42
+ * tools, `policyResolver.js:33-40` — is not encoded: it let an agency
43
+ * enable a pair the codebook never bound.) A stored `NA` (the codebook's
44
+ * "Not relevant", `DEFAULT_BOUND_STATE.NA`) is read as NEVER at every
45
+ * tier: non-grantable, and locked at Tier 1.
35
46
  * 3. Required is immune to the team gate: a state that is ALWAYS after
36
47
  * Tier 1 + Tier 2 (platform ALWAYS, or an agency that escalated the role to
37
48
  * ALWAYS) is not team-gated (dev model: "locked" states skip Tier 3,
@@ -76,9 +87,10 @@
76
87
  * - an `input` that is not an object, or a `roles` / `functions` /
77
88
  * `assignedRoleCodes` that is not an array (null, a number, a string —
78
89
  * never split into characters), resolves to `[]`;
79
- * - a present state that is not one of the four PERMISSION_STATE values is
80
- * NEVER at Tier 1, NEVER at Tier 2 (for that role), and a restriction at
81
- * Tier 3; `undefined` and `null` mean "not set";
90
+ * - a present state that is not one of the four PERMISSION_STATE values (or
91
+ * `NA`, read as NEVER) is NEVER at Tier 1, NEVER at Tier 2 (for that
92
+ * role), and a restriction at Tier 3; `undefined` and `null` mean "not
93
+ * set" — which at Tier 1 is unbound, i.e. ineligible;
82
94
  * - a state CONTAINER that is present but not a plain object (an array, a
83
95
  * string, a Map, …) fails closed for everything it could govern: a role's
84
96
  * `functions` → the role grants nothing; the agency's map, or one role's
@@ -97,7 +109,9 @@
97
109
  */
98
110
 
99
111
  import {
112
+ DEFAULT_BOUND_STATE,
100
113
  PERMISSION_STATE,
114
+ type DefaultBoundStateValue,
101
115
  type PermissionStateValue,
102
116
  } from "../constants/platform-auth.js";
103
117
  import { CoreFunctionsKeys } from "../generated/cvc-enums.js";
@@ -116,24 +130,44 @@ export function isCanonEvaluableFunction(code: string): boolean {
116
130
 
117
131
  // ─── Input contract (kickoff § 4.1) ─────────────────────────────────────────
118
132
 
119
- /** A map of function code → permission state, as the platform stores it. */
133
+ /**
134
+ * A Tier-2 (agency) or Tier-3 (team) map of function code → state, as the
135
+ * platform stores it. Canon has no NA chip at these tiers, so the type is the
136
+ * four PERMISSION_STATE values; a stored `NA` is still read as NEVER (fail
137
+ * closed), never as a grant.
138
+ */
120
139
  export type AuthzStateMap = Readonly<Record<string, PermissionStateValue>>;
121
140
 
141
+ /**
142
+ * A Tier-1 (platform role) map of function code → state: a PERMISSION_STATE
143
+ * value or the codebook's `NA` ("Not relevant", read as NEVER) — what a seed
144
+ * from `CORE_FUNCTION_DEFAULT_BOUNDS` stores. An unlisted function is unbound.
145
+ */
146
+ export type AuthzTier1StateMap = Readonly<Record<string, DefaultBoundStateValue>>;
147
+
122
148
  /**
123
149
  * One `platformRoles` row (Tier 1): the role's platform state per function.
124
- * A function the role does not list resolves to PREF_NO when it shares one of
125
- * the role's tools, else NEVER (not applicable) — the rule all three dev
126
- * resolvers use (`policyResolver.js:33-40`).
150
+ * A function the role does not list is UNBOUND for it: the role is ineligible
151
+ * (NEVER for that role, locked — no agency or team layer can enable it), as
152
+ * canon's `authzResolve` rules (`:578-584` `role_ineligible`).
153
+ *
154
+ * `tools` is NOT read by the resolver (since co-p1x, 0.24.0): it used to pick
155
+ * the PREF_NO / NEVER default for an unlisted function. The field stays on the
156
+ * contract because the platform still stores it on `platformRoles`.
127
157
  */
128
158
  export interface AuthzRoleRow {
129
159
  readonly code: string;
160
+ /**
161
+ * @deprecated Ignored by the resolver since 0.24.0 (co-p1x): an unlisted
162
+ * function is unbound, whatever tools the role and function share. Kept on
163
+ * the contract because the platform still stores it.
164
+ */
130
165
  readonly tools?: readonly string[];
131
- readonly functions?: AuthzStateMap;
166
+ readonly functions?: AuthzTier1StateMap;
132
167
  }
133
168
 
134
169
  /**
135
- * One `platformFunctions` row: the deployment's function catalog, which
136
- * supplies each function's `tools` (the Tier-1 default above). It can only
170
+ * One `platformFunctions` row: the deployment's function catalog. It can only
137
171
  * narrow canon, never widen it:
138
172
  * - a code canon does not carry, or carries as not-v1 / retired, is denied
139
173
  * even when it is listed here;
@@ -145,6 +179,10 @@ export interface AuthzRoleRow {
145
179
  */
146
180
  export interface AuthzFunctionRow {
147
181
  readonly code: string;
182
+ /**
183
+ * @deprecated Ignored by the resolver since 0.24.0 (co-p1x). Kept on the
184
+ * contract because the platform still stores it.
185
+ */
148
186
  readonly tools?: readonly string[];
149
187
  readonly retired?: boolean;
150
188
  }
@@ -211,17 +249,19 @@ function own(map: StoredMap, key: string): unknown {
211
249
 
212
250
  const STATES: ReadonlySet<string> = new Set<string>(Object.values(PERMISSION_STATE));
213
251
 
214
- /** One stored state: not set, a recognised state, or `"malformed"`. */
252
+ /**
253
+ * One stored state: not set, a recognised state, or `"malformed"`. The
254
+ * codebook's `NA` ("Not relevant") is a recognised value, not a malformed one
255
+ * (a platform that seeds from CORE_FUNCTION_DEFAULT_BOUNDS stores it
256
+ * verbatim), and it is read as NEVER: non-grantable at every tier.
257
+ */
215
258
  function readState(map: StoredMap, code: string): PermissionStateValue | "malformed" | undefined {
216
259
  const v = own(map, code);
217
260
  if (v === undefined || v === null) return undefined;
261
+ if (v === DEFAULT_BOUND_STATE.NA) return PERMISSION_STATE.NEVER;
218
262
  return typeof v === "string" && STATES.has(v) ? (v as PermissionStateValue) : "malformed";
219
263
  }
220
264
 
221
- function stringList(v: unknown): readonly string[] {
222
- return Array.isArray(v) ? v.filter((x): x is string => typeof x === "string") : [];
223
- }
224
-
225
265
  /** Rule 4: anything but "not set", PREF_YES or ALWAYS restricts. */
226
266
  function teamValueRestricts(map: StoredMap, code: string): boolean {
227
267
  const gate = readState(map, code);
@@ -322,14 +362,14 @@ export function resolveEffectiveFunctions(
322
362
 
323
363
  // Rule 8: the catalog narrowed by canon, and by its own `retired` (only an
324
364
  // absent or exactly-false flag keeps a row).
325
- const vocabulary: { readonly code: string; readonly tools: readonly string[] }[] = [];
365
+ const vocabulary: string[] = [];
326
366
  for (const fn of catalog as readonly unknown[]) {
327
367
  if (!isPlainObject(fn)) continue;
328
368
  const code = own(fn, "code");
329
369
  const retired = own(fn, "retired");
330
370
  if (typeof code !== "string" || !isCanonEvaluableFunction(code)) continue;
331
371
  if (retired !== undefined && retired !== false) continue;
332
- vocabulary.push({ code, tools: stringList(own(fn, "tools")) });
372
+ vocabulary.push(code);
333
373
  }
334
374
 
335
375
  const agencyAll = readContainer(input.agencyOverrides);
@@ -338,22 +378,22 @@ export function resolveEffectiveFunctions(
338
378
  const granted = new Set<string>();
339
379
  for (const roleCode of heldCodes) {
340
380
  const role = rolesByCode.get(roleCode)!;
341
- const roleTools = new Set(stringList(own(role, "tools")));
342
381
  const roleFunctions = readContainer(own(role, "functions"));
343
382
  if (roleFunctions.kind === "malformed") continue; // Tier 1 unreadable: grants nothing
344
383
  const agency =
345
384
  agencyAll.kind === "map" ? readContainer(own(agencyAll.map, roleCode)) : agencyAll;
346
385
 
347
386
  for (const fn of vocabulary) {
348
- if (granted.has(fn.code)) continue; // rule 2: another role already grants it
387
+ if (granted.has(fn)) continue; // rule 2: another role already grants it
349
388
 
350
- // Tier 1 — platform. A malformed stored state is NEVER.
351
- const listed = roleFunctions.kind === "map" ? readState(roleFunctions.map, fn.code) : undefined;
352
- const applies = fn.tools.some((t) => roleTools.has(t));
353
- const tier1: PermissionStateValue =
354
- listed === "malformed"
355
- ? PERMISSION_STATE.NEVER
356
- : (listed ?? (applies ? PERMISSION_STATE.PREF_NO : PERMISSION_STATE.NEVER));
389
+ // Tier 1 — platform. UNBOUND (no stored state) is ineligible: the role
390
+ // contributes nothing, before any agency or team layer (canon
391
+ // `authzResolve` `role_ineligible`, `:578-584`). A malformed stored
392
+ // state is NEVER; a stored NA reads NEVER (readState). Either way it is
393
+ // local to this role (rule 2).
394
+ const listed = roleFunctions.kind === "map" ? readState(roleFunctions.map, fn) : undefined;
395
+ if (listed === undefined) continue;
396
+ const tier1: PermissionStateValue = listed === "malformed" ? PERMISSION_STATE.NEVER : listed;
357
397
 
358
398
  // Tier 2 — agency. Tier-1 ALWAYS / NEVER are locked (rule 3); a
359
399
  // malformed override (or container) is NEVER for this role.
@@ -363,7 +403,7 @@ export function resolveEffectiveFunctions(
363
403
  agency.kind === "malformed"
364
404
  ? "malformed"
365
405
  : agency.kind === "map"
366
- ? readState(agency.map, fn.code)
406
+ ? readState(agency.map, fn)
367
407
  : undefined;
368
408
  if (override === "malformed") state = PERMISSION_STATE.NEVER;
369
409
  else if (override !== undefined) state = override;
@@ -372,9 +412,9 @@ export function resolveEffectiveFunctions(
372
412
  if (state !== PERMISSION_STATE.ALWAYS && state !== PERMISSION_STATE.PREF_YES) continue;
373
413
 
374
414
  // Tier 3 — team, restrict-only (rule 4); Required is immune (rule 3).
375
- if (state !== PERMISSION_STATE.ALWAYS && teamRestricts(team, roleCode, fn.code)) continue;
415
+ if (state !== PERMISSION_STATE.ALWAYS && teamRestricts(team, roleCode, fn)) continue;
376
416
 
377
- granted.add(fn.code);
417
+ granted.add(fn);
378
418
  }
379
419
  }
380
420
 
@@ -69,6 +69,66 @@ export const PERMISSION_STATE_DISPLAY: Record<
69
69
  },
70
70
  };
71
71
 
72
+ // ─── Codebook default bound (CVC-133 `bounds:`, per role × function) ──
73
+
74
+ /**
75
+ * The state the CVC-133 codebook gives one role for one function: the four
76
+ * PERMISSION_STATE values plus `NA` ("Not relevant": canon's
77
+ * `not_applicable_roles`). Canon's `always` / `default_on` / `default_off` /
78
+ * `never` read ALWAYS / PREF_YES / PREF_NO / NEVER. A role the codebook does
79
+ * not name for a function has NO default bound ("unbound"), which is an absent
80
+ * key, never a sixth value.
81
+ *
82
+ * `NA` is deliberately NOT a PERMISSION_STATE: it is codebook vocabulary, not
83
+ * a grantable policy state. The shared resolver reads a stored `NA` as NEVER
84
+ * at every tier (and any other value outside PERMISSION_STATE as malformed,
85
+ * which also denies).
86
+ */
87
+ export const DEFAULT_BOUND_STATE = {
88
+ ...PERMISSION_STATE,
89
+ /** Not relevant — canon's `not_applicable_roles` for this function. */
90
+ NA: "NA",
91
+ } as const;
92
+
93
+ export type DefaultBoundStateValue =
94
+ (typeof DEFAULT_BOUND_STATE)[keyof typeof DEFAULT_BOUND_STATE];
95
+
96
+ export const DEFAULT_BOUND_STATE_VALUES = [
97
+ ...PERMISSION_STATE_VALUES,
98
+ DEFAULT_BOUND_STATE.NA,
99
+ ] as const;
100
+
101
+ /**
102
+ * Labels for a Tier-1 (platform role) state, which may be the codebook's `NA`
103
+ * since 0.24.0. `PERMISSION_STATE_LABELS` / `PERMISSION_STATE_DISPLAY` keep
104
+ * their four keys (agency and team states have no NA); index THESE with a
105
+ * `PlatformRoleDef.functions` value, or a stored "NA" looks up `undefined`.
106
+ * "Not relevant" is the codebook chip label (platform-prototype @ a6f1f3a
107
+ * `src/screens.jsx:19151` `PB_STATE_SHORT.na`).
108
+ */
109
+ export const DEFAULT_BOUND_STATE_LABELS: Record<DefaultBoundStateValue, string> = {
110
+ ...PERMISSION_STATE_LABELS,
111
+ [DEFAULT_BOUND_STATE.NA]: "Not relevant",
112
+ };
113
+
114
+ /**
115
+ * `PERMISSION_STATE_DISPLAY` plus `NA`. Like the other four entries these are
116
+ * package display defaults, not canon tokens (canon inks NA with
117
+ * `--highlight-sandstone-gold`, `assets/app-styles.css:12318`).
118
+ */
119
+ export const DEFAULT_BOUND_STATE_DISPLAY: Record<
120
+ DefaultBoundStateValue,
121
+ { label: string; color: string; bgColor: string; icon: string }
122
+ > = {
123
+ ...PERMISSION_STATE_DISPLAY,
124
+ [DEFAULT_BOUND_STATE.NA]: {
125
+ label: "Not relevant",
126
+ color: "#616161",
127
+ bgColor: "#f5f5f5",
128
+ icon: "\u25CC",
129
+ },
130
+ };
131
+
72
132
  // ─── Share View (data visibility for shared records) ───────────────
73
133
 
74
134
  export const SHARE_VIEW = {
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @htilabs/platform-common-models — CVC-133 codebook default bounds
3
+ *
4
+ * AUTO-GENERATED FILE — DO NOT EDIT BY HAND.
5
+ * Regenerate with: `python3 scripts/gen-core-functions.py <prototype root>`.
6
+ *
7
+ * For each evaluable function of coreFunctions.v1.3.0.json (canon v1 && !retired,
8
+ * canon @ f4356aa4): role code → the codebook's default bound — canon's
9
+ * always / default_on / default_off / never / not_applicable_roles read
10
+ * ALWAYS / PREF_YES / PREF_NO / NEVER / NA. Role codes are CVC-134 / CVC-135
11
+ * `canonicalCode`s (adminRoles.v2.0.0.json · userRoles.v2.0.0.json); a role not listed is UNBOUND.
12
+ * CODEBOOK DEFAULTS, not live policy: what platform seeds on insert and what
13
+ * "clear" reverts to. GATE L asserts this equals the pinned canon.
14
+ */
15
+
16
+ import type { DefaultBoundStateValue } from "../constants/platform-auth.js";
17
+
18
+ export const CORE_FUNCTION_DEFAULT_BOUNDS_SOT_VERSION = "1.3.0";
19
+
20
+ export const CORE_FUNCTION_DEFAULT_BOUNDS: Readonly<
21
+ Record<string, Readonly<Record<string, DefaultBoundStateValue>>>
22
+ > = {
23
+ "agency_info_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "TEAM-ADM": "PREF_YES" },
24
+ "announcement_publish": { "MEM-ADM": "PREF_NO", "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "case_nav": "NA" },
25
+ "api_key_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "SUP": "NEVER", "TEAM-ADM": "NEVER", "case_nav": "NA", "research_analytics": "NA" },
26
+ "assessments_conduct": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "PREF_YES", "crisis_response": "NEVER", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "NEVER", "research_analytics": "NA", "screener": "NEVER", "volunteer": "NEVER" },
27
+ "auth_model_manage_platform": { "AUD": "NEVER", "CIRO": "NEVER", "DATA-ADM": "NEVER", "GOV-AUD": "NEVER", "MEM-ADM": "NEVER", "PLT-ADM": "ALWAYS", "PLT-SUP": "NEVER", "SUP": "NEVER", "TEAM-ADM": "NEVER", "research_analytics": "NA" },
28
+ "case_assign_reassign": { "AUD": "NA", "CIRO": "NA", "DATA-ADM": "NA", "GOV-AUD": "NA", "MEM-ADM": "ALWAYS", "PLT-ADM": "NA", "SUP": "ALWAYS", "TEAM-ADM": "PREF_YES", "behavioral_health_provider": "NA", "case_nav": "ALWAYS", "crisis_response": "NA", "healthcare_provider_medical": "NA", "intel_analyst": "NA", "investigator": "NA", "le_liaison_vsp": "NA", "legal_advocate": "NA", "mandatory_reporter": "NA", "mdt_participant": "NA", "prosecutor_review": "NA", "public_reporter": "NA", "research_analytics": "NA", "screener": "NA", "volunteer": "NA" },
29
+ "case_claim": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "PREF_YES", "intel_analyst": "PREF_YES", "investigator": "PREF_YES", "le_liaison_vsp": "PREF_YES", "legal_advocate": "PREF_YES", "mandatory_reporter": "PREF_YES", "mdt_participant": "PREF_YES", "prosecutor_review": "PREF_YES", "public_reporter": "PREF_YES", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "PREF_YES" },
30
+ "case_close": { "AUD": "NA", "CIRO": "NA", "DATA-ADM": "NA", "GOV-AUD": "NA", "MEM-ADM": "ALWAYS", "PLT-ADM": "NA", "SUP": "ALWAYS", "TEAM-ADM": "PREF_YES", "behavioral_health_provider": "NA", "case_nav": "ALWAYS", "crisis_response": "NA", "healthcare_provider_medical": "NA", "intel_analyst": "NA", "investigator": "NA", "le_liaison_vsp": "NA", "legal_advocate": "NA", "mandatory_reporter": "NA", "mdt_participant": "NA", "prosecutor_review": "NA", "public_reporter": "NA", "research_analytics": "NA", "screener": "NA", "volunteer": "NA" },
31
+ "case_collaborator_add": { "case_nav": "NA", "investigator": "ALWAYS", "mdt_participant": "ALWAYS", "research_analytics": "NA" },
32
+ "case_edit": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "intel_analyst": "PREF_YES", "investigator": "ALWAYS", "le_liaison_vsp": "ALWAYS", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_NO" },
33
+ "case_reopen": { "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "investigator": "ALWAYS", "le_liaison_vsp": "NEVER", "research_analytics": "NA", "screener": "NEVER", "volunteer": "PREF_NO" },
34
+ "case_side_panel_use": { "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "PREF_YES", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "PREF_YES", "legal_advocate": "PREF_YES", "mdt_participant": "PREF_YES", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "PREF_NO" },
35
+ "case_status_manage": { "SUP": "PREF_YES", "case_nav": "NA", "investigator": "ALWAYS", "research_analytics": "NA", "volunteer": "NEVER" },
36
+ "case_transfer_bulk": { "MEM-ADM": "PREF_YES", "PLT-ADM": "ALWAYS", "SUP": "NEVER", "TEAM-ADM": "PREF_NO", "research_analytics": "NA" },
37
+ "case_view": { "PLT-ADM": "ALWAYS", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "PREF_YES", "mdt_participant": "PREF_YES", "prosecutor_review": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "NEVER" },
38
+ "case_visibility_manage": { "MEM-ADM": "ALWAYS", "SUP": "ALWAYS", "case_nav": "NA", "intel_analyst": "PREF_NO", "investigator": "ALWAYS", "research_analytics": "NA", "volunteer": "NEVER" },
39
+ "ci_periodic_review": { "CIRO": "ALWAYS", "case_nav": "NA", "research_analytics": "NA" },
40
+ "ci_record_purge_or_retire": { "CIRO": "ALWAYS", "case_nav": "NA", "research_analytics": "NA" },
41
+ "ci_record_validate": { "CIRO": "ALWAYS", "case_nav": "NA", "research_analytics": "NA" },
42
+ "ci_to_evidence_export_authorize": { "CIRO": "ALWAYS", "case_nav": "NA", "research_analytics": "NA" },
43
+ "deconfliction_alert_acknowledge": { "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA" },
44
+ "deconfliction_unmask": { "case_nav": "NA", "intel_analyst": "PREF_YES", "investigator": "ALWAYS", "research_analytics": "NA", "volunteer": "NEVER" },
45
+ "determination_perform": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "PREF_YES", "crisis_response": "NEVER", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "NEVER", "legal_advocate": "PREF_YES", "research_analytics": "NA", "screener": "NEVER", "volunteer": "NEVER" },
46
+ "disclose_external_request": { "CIRO": "PREF_YES", "PLT-ADM": "ALWAYS", "case_nav": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "ALWAYS" },
47
+ "enrollment_manage": { "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "healthcare_provider_medical": "PREF_YES", "legal_advocate": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "PREF_NO", "volunteer": "PREF_NO" },
48
+ "exit_discharge_conduct": { "case_nav": "ALWAYS", "crisis_response": "PREF_NO", "legal_advocate": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "NEVER", "volunteer": "NEVER" },
49
+ "export_deidentified": { "DATA-ADM": "PREF_YES", "PLT-ADM": "ALWAYS", "research_analytics": "PREF_YES" },
50
+ "goals_plan_manage": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_NO", "legal_advocate": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "volunteer": "PREF_NO" },
51
+ "idb_record_create": { "PLT-ADM": "ALWAYS", "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA" },
52
+ "indicator_manual_add": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "ALWAYS", "intel_analyst": "PREF_YES", "investigator": "PREF_YES", "legal_advocate": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_NO" },
53
+ "investigation_create_claim": { "case_nav": "NA", "investigator": "ALWAYS", "research_analytics": "NA" },
54
+ "investigation_session_run": { "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "PREF_YES", "research_analytics": "NA" },
55
+ "investigative_database_search": { "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA" },
56
+ "investigative_request_send": { "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA" },
57
+ "lead_create": { "case_nav": "NA", "investigator": "ALWAYS", "research_analytics": "NA" },
58
+ "lead_publish": { "case_nav": "NA", "investigator": "ALWAYS", "research_analytics": "NA" },
59
+ "lead_route_assign": { "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "case_nav": "NA" },
60
+ "lead_triage_manage": { "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA" },
61
+ "magic_link_share_send": { "PLT-ADM": "NA", "case_nav": "PREF_YES", "crisis_response": "PREF_YES", "le_liaison_vsp": "PREF_YES", "legal_advocate": "PREF_YES", "mdt_participant": "ALWAYS", "research_analytics": "NA", "screener": "PREF_NO", "volunteer": "PREF_NO" },
62
+ "mandatory_report_send": { "MEM-ADM": "PREF_YES", "PLT-ADM": "NA", "SUP": "PREF_YES", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "healthcare_provider_medical": "PREF_YES", "mandatory_reporter": "ALWAYS", "public_reporter": "PREF_NO", "screener": "PREF_NO", "volunteer": "PREF_NO" },
63
+ "member_account_report_generate": { "DATA-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "research_analytics": "PREF_YES" },
64
+ "member_onboarding_support": { "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "research_analytics": "NA" },
65
+ "message_moderate": { "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS" },
66
+ "message_send": { "PLT-ADM": "ALWAYS", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "ALWAYS", "mandatory_reporter": "ALWAYS", "mdt_participant": "ALWAYS", "prosecutor_review": "ALWAYS", "public_reporter": "PREF_NO", "research_analytics": "ALWAYS", "screener": "ALWAYS", "volunteer": "PREF_YES" },
67
+ "milestone_log": { "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA" },
68
+ "needs_priorities_conduct": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "PREF_YES", "legal_advocate": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_YES" },
69
+ "network_corpus_access": { "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "case_nav": "NA" },
70
+ "note_open_departed_author": { "MEM-ADM": "PREF_NO" },
71
+ "onboarding_config_sign_off": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS" },
72
+ "open_source_search": { "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "ALWAYS" },
73
+ "person_association_update": { "PLT-ADM": "ALWAYS", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "research_analytics": "NA", "screener": "PREF_YES" },
74
+ "person_merge_manage": { "PLT-ADM": "ALWAYS", "case_nav": "NA", "intel_analyst": "ALWAYS", "investigator": "PREF_YES", "research_analytics": "NA", "volunteer": "NEVER" },
75
+ "platform_perm_modify": { "PLT-ADM": "ALWAYS", "research_analytics": "NA" },
76
+ "profile_domain_edit": { "PLT-ADM": "ALWAYS", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "ALWAYS", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_NO" },
77
+ "record_activity_view": { "PLT-ADM": "ALWAYS", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "PREF_YES", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "PREF_YES", "legal_advocate": "ALWAYS", "mdt_participant": "PREF_YES", "prosecutor_review": "ALWAYS", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "PREF_NO" },
78
+ "record_print": { "CIRO": "PREF_YES", "PLT-ADM": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "investigator": "ALWAYS", "le_liaison_vsp": "NEVER", "legal_advocate": "ALWAYS", "prosecutor_review": "ALWAYS", "research_analytics": "ALWAYS", "screener": "PREF_NO", "volunteer": "NEVER" },
79
+ "referral_receive_external": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "PREF_YES", "intel_analyst": "PREF_YES", "investigator": "PREF_YES", "le_liaison_vsp": "PREF_YES", "legal_advocate": "PREF_YES", "mandatory_reporter": "PREF_YES", "mdt_participant": "PREF_YES", "prosecutor_review": "ALWAYS", "public_reporter": "PREF_YES", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "PREF_YES" },
80
+ "referral_receive_internal": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "PREF_NO", "healthcare_provider_medical": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "ALWAYS", "mdt_participant": "ALWAYS", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_NO" },
81
+ "referral_send_external": { "PLT-ADM": "NA", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "le_liaison_vsp": "ALWAYS", "mandatory_reporter": "ALWAYS", "mdt_participant": "ALWAYS", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "PREF_YES" },
82
+ "referral_send_internal": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "le_liaison_vsp": "ALWAYS", "mandatory_reporter": "ALWAYS", "mdt_participant": "ALWAYS", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "ALWAYS" },
83
+ "roi_submit_manage": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "ALWAYS", "mdt_participant": "ALWAYS", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "ALWAYS" },
84
+ "role_assign": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "SUP": "NA", "TEAM-ADM": "PREF_NO", "research_analytics": "NA" },
85
+ "roles_accounts_toggle": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS" },
86
+ "sandbox_environment_manage": { "PLT-ADM": "ALWAYS", "research_analytics": "NA" },
87
+ "screening_conduct": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "PREF_YES", "crisis_response": "PREF_YES", "healthcare_provider_medical": "ALWAYS", "legal_advocate": "PREF_YES", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_YES" },
88
+ "screening_view": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "PREF_NO", "healthcare_provider_medical": "ALWAYS", "le_liaison_vsp": "NEVER", "prosecutor_review": "NEVER", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "NEVER" },
89
+ "service_log_manage": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "PREF_YES", "legal_advocate": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "PREF_YES" },
90
+ "session_create": { "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "ALWAYS", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "ALWAYS", "legal_advocate": "ALWAYS", "mandatory_reporter": "ALWAYS", "mdt_participant": "ALWAYS", "prosecutor_review": "ALWAYS", "public_reporter": "ALWAYS", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "ALWAYS" },
91
+ "share_config": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "PLT-SUP": "PREF_YES", "SUP": "NEVER", "TEAM-ADM": "NEVER", "research_analytics": "NA" },
92
+ "share_revoke": { "PLT-ADM": "ALWAYS", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "PREF_YES", "le_liaison_vsp": "PREF_YES", "legal_advocate": "ALWAYS", "mdt_participant": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "PREF_NO", "volunteer": "PREF_NO" },
93
+ "share_rule_approve_cross_agency": { "GOV-AUD": "PREF_YES", "PLT-ADM": "ALWAYS", "research_analytics": "NA" },
94
+ "share_vsp_to_le": { "PLT-ADM": "ALWAYS", "case_nav": "PREF_YES", "crisis_response": "NA", "le_liaison_vsp": "ALWAYS", "research_analytics": "NA", "screener": "NEVER", "volunteer": "NEVER" },
95
+ "srl_manage": { "DATA-ADM": "PREF_YES", "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "TEAM-ADM": "PREF_YES" },
96
+ "supervisee_thread_view": { "PLT-ADM": "ALWAYS", "SUP": "ALWAYS", "TEAM-ADM": "PREF_YES", "case_nav": "NA" },
97
+ "support_ticket_triage": { "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "case_nav": "NA", "research_analytics": "NA" },
98
+ "system_diagnostics_view": { "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "case_nav": "NA" },
99
+ "team_config_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "PLT-SUP": "ALWAYS", "SUP": "NEVER", "TEAM-ADM": "NEVER", "research_analytics": "NA" },
100
+ "team_membership_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "SUP": "NA", "TEAM-ADM": "ALWAYS", "case_nav": "NA", "research_analytics": "NA" },
101
+ "team_share_narrowing": { "MEM-ADM": "ALWAYS", "SUP": "PREF_NO", "TEAM-ADM": "PREF_YES", "research_analytics": "NA" },
102
+ "team_workflow_config_manage": { "MEM-ADM": "ALWAYS", "TEAM-ADM": "PREF_YES", "research_analytics": "NA" },
103
+ "training_gate_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "PLT-SUP": "PREF_YES", "SUP": "NA", "TEAM-ADM": "PREF_YES", "TRAIN-ADM": "ALWAYS", "research_analytics": "NA" },
104
+ "usr_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "SUP": "NEVER", "TEAM-ADM": "PREF_NO", "research_analytics": "NA" },
105
+ "viewing_config_manage": { "MEM-ADM": "ALWAYS", "PLT-ADM": "ALWAYS", "SUP": "PREF_YES" },
106
+ "viewing_level_1_search": { "PLT-ADM": "NA", "behavioral_health_provider": "ALWAYS", "case_nav": "ALWAYS", "crisis_response": "ALWAYS", "healthcare_provider_medical": "PREF_YES", "intel_analyst": "ALWAYS", "investigator": "ALWAYS", "le_liaison_vsp": "PREF_YES", "legal_advocate": "PREF_YES", "mandatory_reporter": "PREF_NO", "mdt_participant": "PREF_YES", "prosecutor_review": "PREF_YES", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "PREF_NO" },
107
+ "viewing_level_2_autocomplete": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_YES", "case_nav": "ALWAYS", "crisis_response": "PREF_YES", "healthcare_provider_medical": "PREF_NO", "intel_analyst": "PREF_YES", "investigator": "ALWAYS", "le_liaison_vsp": "PREF_YES", "legal_advocate": "PREF_NO", "mandatory_reporter": "NEVER", "mdt_participant": "PREF_NO", "prosecutor_review": "PREF_NO", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "ALWAYS", "volunteer": "NEVER" },
108
+ "viewing_level_3_components": { "PLT-ADM": "NA", "behavioral_health_provider": "PREF_NO", "case_nav": "PREF_YES", "crisis_response": "PREF_NO", "healthcare_provider_medical": "PREF_NO", "intel_analyst": "PREF_NO", "investigator": "PREF_YES", "le_liaison_vsp": "PREF_NO", "legal_advocate": "PREF_NO", "mandatory_reporter": "NEVER", "mdt_participant": "PREF_NO", "prosecutor_review": "PREF_NO", "public_reporter": "NEVER", "research_analytics": "NA", "screener": "PREF_YES", "volunteer": "NEVER" },
109
+ };
@@ -52,7 +52,10 @@ export const platformRoleSchemaDefinition = {
52
52
  type: Boolean,
53
53
  default: false,
54
54
  },
55
- /** Dynamic map of functionCode → PermissionStateValue. */
55
+ /**
56
+ * Dynamic map of functionCode → DefaultBoundStateValue (a PERMISSION_STATE
57
+ * value or the codebook's `NA`); an unlisted function is unbound.
58
+ */
56
59
  functions: {
57
60
  type: Schema.Types.Mixed,
58
61
  default: {},
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type {
10
- PermissionStateValue,
10
+ DefaultBoundStateValue,
11
11
  PlatformToolValue,
12
12
  RoleLevelValue,
13
13
  ShareViewValue,
@@ -44,6 +44,13 @@ export interface PlatformRoleDef {
44
44
  shareView: ShareViewValue | null;
45
45
  trainingRequirements: string | null;
46
46
  isHtiOnly: boolean;
47
- functions: Record<string, PermissionStateValue>;
47
+ /**
48
+ * Tier-1 state per function code. A PERMISSION_STATE value, or the codebook's
49
+ * `NA` ("Not relevant", since 0.24.0 — seeded from
50
+ * `CORE_FUNCTION_DEFAULT_BOUNDS`). An unlisted function is UNBOUND: the
51
+ * shared resolver treats the role as ineligible for it, and reads `NA` as
52
+ * NEVER. Label it with `DEFAULT_BOUND_STATE_LABELS` / `_DISPLAY`.
53
+ */
54
+ functions: Record<string, DefaultBoundStateValue>;
48
55
  sortOrder: number;
49
56
  }