@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.
- package/dist/authz/index.cjs +539 -0
- package/dist/authz/index.cjs.map +1 -0
- package/dist/authz/index.d.cts +210 -0
- package/dist/authz/index.d.ts +210 -0
- package/dist/authz/index.js +507 -0
- package/dist/authz/index.js.map +1 -0
- package/dist/constants/index.d.cts +2 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/cvcs/index.cjs +936 -243
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +986 -254
- package/dist/cvcs/index.d.ts +986 -254
- package/dist/cvcs/index.js +936 -243
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +37 -10
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +42 -15
- package/dist/enums/index.d.ts +42 -15
- package/dist/enums/index.js +37 -10
- package/dist/enums/index.js.map +1 -1
- package/dist/{platform-auth-CvAYFVhK.d.cts → ic-DpKrdgQP.d.cts} +1 -78
- package/dist/{platform-auth-CvAYFVhK.d.ts → ic-DpKrdgQP.d.ts} +1 -78
- package/dist/index.cjs +1328 -253
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1313 -253
- package/dist/index.js.map +1 -1
- package/dist/platform-auth-B49Ly57B.d.cts +78 -0
- package/dist/platform-auth-B49Ly57B.d.ts +78 -0
- 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/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +6 -1
- package/src/__sot__/README.md +3 -0
- package/src/__sot__/adminRoles.pin.json +122 -0
- package/src/__sot__/adminRoles.published.json +77 -0
- package/src/__sot__/coreFunctionFields.ts +137 -0
- package/src/__sot__/coreFunctions.pin.json +1659 -0
- package/src/__sot__/coreFunctions.published.json +233 -0
- package/src/__sot__/roleFields.ts +137 -0
- package/src/__sot__/userRoles.pin.json +174 -0
- package/src/__sot__/userRoles.published.json +103 -0
- package/src/__tests__/__snapshots__/cvc-sot.snap +6 -6
- package/src/__tests__/admin-roles-canon.test.ts +80 -0
- package/src/__tests__/authz-resolve.test.ts +712 -0
- package/src/__tests__/core-functions-canon.test.ts +358 -24
- package/src/__tests__/cvc-sot-snapshot.test.ts +17 -6
- package/src/__tests__/cvc-status-parser.test.ts +2 -2
- package/src/__tests__/cvc-structural.test.ts +3 -3
- package/src/__tests__/organization-program.test.ts +254 -0
- package/src/__tests__/role-vocab-gate.ts +279 -0
- package/src/__tests__/user-roles-canon.test.ts +104 -0
- package/src/authz/index.ts +9 -0
- package/src/authz/resolveEffectiveFunctions.ts +454 -0
- package/src/cvcs/adminRoles.v2.0.0.json +197 -0
- package/src/cvcs/{coreFunctions.v1.1.0.json → coreFunctions.v1.3.0.json} +646 -90
- package/src/cvcs/index.ts +3 -3
- package/src/cvcs/userRoles.v2.0.0.json +296 -0
- package/src/generated/coreFunctionsEvaluable.ts +101 -0
- package/src/generated/cvc-enums.ts +42 -15
- package/src/index.ts +4 -0
- package/src/schemas/index.ts +18 -0
- package/src/schemas/organization-program.ts +297 -0
- package/src/cvcs/adminRoles.v1.0.0.json +0 -153
- package/src/cvcs/userRoles.v1.0.0.json +0 -203
package/dist/types/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { j as AccommodationValue, m as AgeBinReportingValue, n as AppScopeValue, o as ApparentAgeValue, cw as DataQualityValue, cD as FormStatusValue, cE as FormTypeValue, cF as IC13Category, cH as IC13Value, cI as IC22Value, cJ as IC23Value, cK as IC24Value, cL as IC25Value, cM as IC49ReferralOutcomeValue, cN as IC49ReferralVerificationValue, cO as IC49Value, cP as IC4Value, cR as IC56Value, cS as IC57Value, cU as IC58Value, cV as IC59Value, cW as IC5Value, dM as IncidentInvolvementRoleValue, dN as IncidentParticipationRoleValue, dO as InteractionTypeValue, dR as MinorAdultStatusValue, dZ as PersonDisplayCategoryValue, d_ as PersonRoleValue, d$ as PersonTypeValue, e5 as QuestionFormatValue, e6 as QuickStartTemplateId, ef as RecordStateValue, eh as RelationshipConcernValue, ei as RelationshipDynamicValue, ep as SessionStateValue, eq as SubmissionStateValue, eu as UserStatusValue } from '../ic-DpKrdgQP.cjs';
|
|
2
|
+
import { k as PlatformToolValue, c as FunctionStatusValue, n as RoleLevelValue, q as ShareViewValue, j as PermissionStateValue } from '../platform-auth-B49Ly57B.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @htilabs/platform-common-models — Platform Authorization Types
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { j as AccommodationValue, m as AgeBinReportingValue, n as AppScopeValue, o as ApparentAgeValue, cw as DataQualityValue, cD as FormStatusValue, cE as FormTypeValue, cF as IC13Category, cH as IC13Value, cI as IC22Value, cJ as IC23Value, cK as IC24Value, cL as IC25Value, cM as IC49ReferralOutcomeValue, cN as IC49ReferralVerificationValue, cO as IC49Value, cP as IC4Value, cR as IC56Value, cS as IC57Value, cU as IC58Value, cV as IC59Value, cW as IC5Value, dM as IncidentInvolvementRoleValue, dN as IncidentParticipationRoleValue, dO as InteractionTypeValue, dR as MinorAdultStatusValue, dZ as PersonDisplayCategoryValue, d_ as PersonRoleValue, d$ as PersonTypeValue, e5 as QuestionFormatValue, e6 as QuickStartTemplateId, ef as RecordStateValue, eh as RelationshipConcernValue, ei as RelationshipDynamicValue, ep as SessionStateValue, eq as SubmissionStateValue, eu as UserStatusValue } from '../ic-DpKrdgQP.js';
|
|
2
|
+
import { k as PlatformToolValue, c as FunctionStatusValue, n as RoleLevelValue, q as ShareViewValue, j as PermissionStateValue } from '../platform-auth-B49Ly57B.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @htilabs/platform-common-models — Platform Authorization Types
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htilabs/platform-common-models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Shared constants, types, and models for HTI Labs applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -66,6 +66,11 @@
|
|
|
66
66
|
"types": "./dist/information-scope/index.d.ts",
|
|
67
67
|
"import": "./dist/information-scope/index.js",
|
|
68
68
|
"require": "./dist/information-scope/index.cjs"
|
|
69
|
+
},
|
|
70
|
+
"./authz": {
|
|
71
|
+
"types": "./dist/authz/index.d.ts",
|
|
72
|
+
"import": "./dist/authz/index.js",
|
|
73
|
+
"require": "./dist/authz/index.cjs"
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"files": [
|
package/src/__sot__/README.md
CHANGED
|
@@ -11,7 +11,10 @@ live in other repos:
|
|
|
11
11
|
|---|---|---|
|
|
12
12
|
| `cvcIndex.pin.json` | `htilabstech/prototype` · `Final CVCs/CVC_INDEX.md` | The CVC **number space** — which number belongs to which vocabulary. **Authoritative.** A yaml's self-declared number is not. |
|
|
13
13
|
| `coreIndicators.pin.json` | `htilabstech/prototype` · `data/core_indicators.yaml` | The indicator **catalog** — which indicator codes legitimately exist, **and what the catalog says about each one** (label · definition · family · polarity · severity · is_alert · alert_when, verbatim). |
|
|
14
|
+
| `userRoles.pin.json` | `htilabstech/prototype` · `data/cvcs/core_user_role.yaml` | The CVC-135 **user-role codeset** — which operational roles exist, **what canon says about each one** (label · definition · display_label · platform_tools · flags, verbatim) and canon's **legacy codes** (`legacy_codes`, old → live). `GATE J` (`user-roles-canon.test.ts`) asserts `userRoles.v*.json` restates every one. **Refreshing this pin is half a step:** the SOT JSON is generated from the same yaml by `scripts/gen-user-roles.py <prototype root>` — run it in the same change against the same prototype SHA, bumping the SOT version per `CLAUDE.md`, or GATE J fails (correctly). The generator also maintains `userRoles.published.json`, the append-only ledger of every published key → code, every re-key (`renamed`), every legacy alias (`aliases`) and every withdrawn code (`retired`), which GATE J asserts pair by pair. |
|
|
15
|
+
| `adminRoles.pin.json` | `htilabstech/prototype` · `data/cvcs/core_admin_role.yaml` | The CVC-134 **admin-role codeset** (the control-plane axis) — which admin roles exist, what canon says about each one (label · definition · display_label · required · required_when · reach · scope · plain_language, verbatim) and canon's `legacy_codes`. `GATE K` (`admin-roles-canon.test.ts`) asserts `adminRoles.v*.json` restates every one. Same half-a-step rule as `userRoles`: regenerate with `scripts/gen-admin-roles.py <prototype root>` in the same change; it maintains `adminRoles.published.json`. Both role pins share one projection, `roleFields.ts`, and both generators share one implementation, `scripts/role_vocab.py`; the gates share `role-vocab-gate.ts`. |
|
|
14
16
|
| `scoringEmits.pin.json` | `htilabstech/hti-scoring` · `weights/risk.weights.json` → `emits_by_code` | What the risk pipeline actually **consumes** — what CVC-136 must be able to express. |
|
|
17
|
+
| `coreFunctions.pin.json` | `htilabstech/prototype` · `data/cvcs/core_functions.yaml` | The CVC-133 **function registry** — which permissionable functions exist, **and what canon says about each one** (label · status · category · platform relevance · user/admin relevance · v1 · retired, verbatim; since SOT 1.3.0 `v1` / `retired` are also structured booleans on every SOT entry, read by the shared authorization resolver). The yaml is itself generated there from the Notion export ("the export wins"). `GATE I` (`core-functions-canon.test.ts`) asserts `coreFunctions.v*.json` restates every one; `coreFunctionFields.ts` holds the shared projection + the posture-suffix composition. **Refreshing this pin is half a step:** the SOT JSON is generated from the same yaml by `scripts/gen-core-functions.py <prototype root>` — run it in the same change **against the same prototype checkout at the same SHA** (the pin reads the working tree; the generator reads `origin/main` after a fetch — keep them equal), bumping the SOT version per `CLAUDE.md`, or GATE I fails (correctly). The generator also maintains `coreFunctions.published.json`, the append-only ledger of every published key → code that GATE I asserts pair by pair. |
|
|
15
18
|
|
|
16
19
|
(Notion is the fourth SOT: **ratification**. It has no pin because it is a human
|
|
17
20
|
process. Items awaiting it carry `_status.vocabStatus:
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sourceRepo": "htilabstech/prototype",
|
|
3
|
+
"sourceFile": "data/cvcs/core_admin_role.yaml",
|
|
4
|
+
"sourceSha": "d85f05b",
|
|
5
|
+
"codes": [
|
|
6
|
+
"AUD",
|
|
7
|
+
"CIRO",
|
|
8
|
+
"DATA-ADM",
|
|
9
|
+
"GOV-AUD",
|
|
10
|
+
"MEM-ADM",
|
|
11
|
+
"PLT-ADM",
|
|
12
|
+
"PLT-SUP",
|
|
13
|
+
"SUP",
|
|
14
|
+
"TEAM-ADM",
|
|
15
|
+
"TRAIN-ADM"
|
|
16
|
+
],
|
|
17
|
+
"roleFields": {
|
|
18
|
+
"AUD": {
|
|
19
|
+
"label": "Compliance / Auditor",
|
|
20
|
+
"definition": "Read-only audit + de-identified compliance workflows.",
|
|
21
|
+
"display_label": null,
|
|
22
|
+
"required": null,
|
|
23
|
+
"required_when": null,
|
|
24
|
+
"reach": "account",
|
|
25
|
+
"scope": null,
|
|
26
|
+
"plain_language": null
|
|
27
|
+
},
|
|
28
|
+
"CIRO": {
|
|
29
|
+
"label": "Criminal Intelligence Review Officer",
|
|
30
|
+
"definition": "Control-plane governance designation establishing accountability for CI handling: validation rules, periodic review, purge/retention, oversight. Does NOT imply broad case-content visibility. The CI → evidence export approval FUNCTION is exercised by a CIRO (see cross_references.functions).",
|
|
31
|
+
"display_label": "Intel Review Officer",
|
|
32
|
+
"required": null,
|
|
33
|
+
"required_when": "leads_ci_enabled",
|
|
34
|
+
"reach": "account",
|
|
35
|
+
"scope": null,
|
|
36
|
+
"plain_language": null
|
|
37
|
+
},
|
|
38
|
+
"DATA-ADM": {
|
|
39
|
+
"label": "Data & Reporting Admin",
|
|
40
|
+
"definition": "Echo / reporting admin — grant reporting, data exports, reporting configuration — WITHOUT broader account governance.",
|
|
41
|
+
"display_label": null,
|
|
42
|
+
"required": null,
|
|
43
|
+
"required_when": null,
|
|
44
|
+
"reach": "account",
|
|
45
|
+
"scope": null,
|
|
46
|
+
"plain_language": null
|
|
47
|
+
},
|
|
48
|
+
"GOV-AUD": {
|
|
49
|
+
"label": "Governance Auditor",
|
|
50
|
+
"definition": "Opt-in governance spot checks / QA review; redacted-by-default surfaces.",
|
|
51
|
+
"display_label": null,
|
|
52
|
+
"required": null,
|
|
53
|
+
"required_when": null,
|
|
54
|
+
"reach": "account",
|
|
55
|
+
"scope": null,
|
|
56
|
+
"plain_language": null
|
|
57
|
+
},
|
|
58
|
+
"MEM-ADM": {
|
|
59
|
+
"label": "Account Admin (Member Administrator)",
|
|
60
|
+
"definition": "The member-account administrator (Account Admin / \"Member Administrator\"). Required role — at least one per member account.",
|
|
61
|
+
"display_label": "Account Admin",
|
|
62
|
+
"required": true,
|
|
63
|
+
"required_when": null,
|
|
64
|
+
"reach": "account",
|
|
65
|
+
"scope": null,
|
|
66
|
+
"plain_language": null
|
|
67
|
+
},
|
|
68
|
+
"PLT-ADM": {
|
|
69
|
+
"label": "Platform Owner & Admin",
|
|
70
|
+
"definition": "HTI Labs platform control-plane governance.",
|
|
71
|
+
"display_label": "Platform Admin",
|
|
72
|
+
"required": null,
|
|
73
|
+
"required_when": null,
|
|
74
|
+
"reach": "platform",
|
|
75
|
+
"scope": null,
|
|
76
|
+
"plain_language": null
|
|
77
|
+
},
|
|
78
|
+
"PLT-SUP": {
|
|
79
|
+
"label": "Platform Support Admin",
|
|
80
|
+
"definition": "Routine HTI support / debugging (prefer over PLT-ADM for support).",
|
|
81
|
+
"display_label": "Support Admin",
|
|
82
|
+
"required": null,
|
|
83
|
+
"required_when": null,
|
|
84
|
+
"reach": "platform",
|
|
85
|
+
"scope": null,
|
|
86
|
+
"plain_language": null
|
|
87
|
+
},
|
|
88
|
+
"SUP": {
|
|
89
|
+
"label": "Supervisor",
|
|
90
|
+
"definition": "A role a person holds over the specific people they supervise — the seats whose `supervised_by` names them (Crysta 2026-10-02: \"A supervisor is a role that a user takes on over those users that they supervise\"; it relates to people, not to a team, and it is still a role). Day-to-day case workflow oversight for those people: operational triage, case assignment, the needs-action flags on their work, and the notices about items that belong to one of them (a claimed mandatory-report flag that sits unsent goes to that person's supervisor). WITHOUT account governance powers or destructive enforcement; deliberately NARROWER than TEAM-ADM. Always: manage case escalation / needs-action flags, assign/reassign case ownership. Case-record access is NOT required of the role; an account's Member Admin may enable it (Crysta 2026-10-02). Not relevant to the role (SUPERVISOR-RULING 2026-10-07, off the role): team membership, role assignment, training gates — those are team and account setup (Team Admin · Member Admin), not supervision of people. NEVER: user management, sharing configuration, team structure & scoping, bulk transfer, purge, suspend, API keys, platform authorization model. Not a generalized admin or support role. The people supervised may sit on any team or none; supervision does not follow team or account lines.",
|
|
91
|
+
"display_label": null,
|
|
92
|
+
"required": null,
|
|
93
|
+
"required_when": null,
|
|
94
|
+
"reach": "supervised_people",
|
|
95
|
+
"scope": "people",
|
|
96
|
+
"plain_language": "Oversees the WORK of the people they supervise."
|
|
97
|
+
},
|
|
98
|
+
"TEAM-ADM": {
|
|
99
|
+
"label": "Team Admin",
|
|
100
|
+
"definition": "Delegated, team-scoped admin used to operate one-to-many teams as workflow containers. Always: manage team membership + team workflow configuration. Optional-on: assign/reassign cases, manage training gates. Optional-off (delegable by MEM-ADM): user management, role assignment, bulk transfer. NEVER: team structure & admin scoping — so TEAM-ADM cannot expand or redefine its own scope.",
|
|
101
|
+
"display_label": null,
|
|
102
|
+
"required": null,
|
|
103
|
+
"required_when": null,
|
|
104
|
+
"reach": "team",
|
|
105
|
+
"scope": "team",
|
|
106
|
+
"plain_language": "Runs the team's SETUP."
|
|
107
|
+
},
|
|
108
|
+
"TRAIN-ADM": {
|
|
109
|
+
"label": "Training Admin",
|
|
110
|
+
"definition": "Agency-set role that configures training/certification requirements and gates (which modules a role or team must complete), manages training content, and reports on completion. Case-content posture: NONE. NOTE: the canonical Notion row is an empty stub (owner Ava Monte, created by Lauren DeLuca 2026-04-21) — definition drafted here from the codebook's own role-table entry and the training_gate_manage function bounds. ⚑ Crysta to confirm.",
|
|
111
|
+
"display_label": null,
|
|
112
|
+
"required": null,
|
|
113
|
+
"required_when": null,
|
|
114
|
+
"reach": "account",
|
|
115
|
+
"scope": null,
|
|
116
|
+
"plain_language": null
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"legacyCodes": {
|
|
120
|
+
"ACCT-ADM": "MEM-ADM"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "Every key @htilabs/platform-common-models has ever published for admin_roles (CVC-134), with its segment-1 prefix. APPEND-ONLY: a published code never moves or changes meaning. A canon re-key (legacy_codes, old key published) moves the KEY onto the same prefix and is recorded under `renamed`; a canon legacy code this package never published is recorded under `aliases`; a withdrawn code is recorded under `retired` and never reused. Written by scripts/gen-admin-roles.py; read by it and by GATE K (src/__tests__/admin-roles-canon.test.ts). Do not hand-edit.",
|
|
3
|
+
"prefixes": {
|
|
4
|
+
"plt_adm": 1,
|
|
5
|
+
"plt_sup": 2,
|
|
6
|
+
"mem_adm": 3,
|
|
7
|
+
"team_adm": 4,
|
|
8
|
+
"aud": 5,
|
|
9
|
+
"data_adm": 6,
|
|
10
|
+
"gov_aud": 7,
|
|
11
|
+
"ciro": 8,
|
|
12
|
+
"sup": 9,
|
|
13
|
+
"train_adm": 10
|
|
14
|
+
},
|
|
15
|
+
"since": {
|
|
16
|
+
"plt_adm": "1.0.0",
|
|
17
|
+
"plt_sup": "1.0.0",
|
|
18
|
+
"mem_adm": "1.0.0",
|
|
19
|
+
"team_adm": "1.0.0",
|
|
20
|
+
"aud": "1.0.0",
|
|
21
|
+
"data_adm": "1.0.0",
|
|
22
|
+
"gov_aud": "1.0.0",
|
|
23
|
+
"ciro": "1.0.0",
|
|
24
|
+
"sup": "1.0.0",
|
|
25
|
+
"train_adm": "1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"renamed": {},
|
|
28
|
+
"aliases": {
|
|
29
|
+
"acct_adm": {
|
|
30
|
+
"to": "mem_adm",
|
|
31
|
+
"canonical": "ACCT-ADM",
|
|
32
|
+
"version": "2.0.0"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"retired": {
|
|
36
|
+
"missingness_root": {
|
|
37
|
+
"code": "134-000-000-000-000-000-000",
|
|
38
|
+
"successor": null,
|
|
39
|
+
"reason": "missingness (canon declares none)",
|
|
40
|
+
"version": "2.0.0"
|
|
41
|
+
},
|
|
42
|
+
"unknown": {
|
|
43
|
+
"code": "134-000-000-000-000-000-001",
|
|
44
|
+
"successor": null,
|
|
45
|
+
"reason": "missingness (canon declares none)",
|
|
46
|
+
"version": "2.0.0"
|
|
47
|
+
},
|
|
48
|
+
"anonymous": {
|
|
49
|
+
"code": "134-000-000-000-000-000-002",
|
|
50
|
+
"successor": null,
|
|
51
|
+
"reason": "missingness (canon declares none)",
|
|
52
|
+
"version": "2.0.0"
|
|
53
|
+
},
|
|
54
|
+
"data_not_collected": {
|
|
55
|
+
"code": "134-000-000-000-000-000-003",
|
|
56
|
+
"successor": null,
|
|
57
|
+
"reason": "missingness (canon declares none)",
|
|
58
|
+
"version": "2.0.0"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"supersededKeys": [
|
|
62
|
+
"missingness_root",
|
|
63
|
+
"unknown",
|
|
64
|
+
"anonymous",
|
|
65
|
+
"data_not_collected",
|
|
66
|
+
"plt_adm",
|
|
67
|
+
"plt_sup",
|
|
68
|
+
"mem_adm",
|
|
69
|
+
"team_adm",
|
|
70
|
+
"aud",
|
|
71
|
+
"data_adm",
|
|
72
|
+
"gov_aud",
|
|
73
|
+
"ciro",
|
|
74
|
+
"sup",
|
|
75
|
+
"train_adm"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE FIELD HALF OF THE coreFunctions PIN
|
|
3
|
+
* =======================================
|
|
4
|
+
*
|
|
5
|
+
* `coreFunctions.pin.json` is the snapshot of the canonical CVC-133 registry —
|
|
6
|
+
* `data/cvcs/core_functions.yaml` in `htilabstech/prototype`, itself GENERATED
|
|
7
|
+
* there from the Notion `core - functions` export by
|
|
8
|
+
* `tools/build_core_functions_registry.py` ("the export wins"). The package's
|
|
9
|
+
* `src/cvcs/coreFunctions.v*.json` is downstream of it: regenerated by
|
|
10
|
+
* `scripts/gen-core-functions.py`, never hand-edited.
|
|
11
|
+
*
|
|
12
|
+
* Why a pin at all: the 1.0.0 / 1.1.0 files were hand-absorbed and validated
|
|
13
|
+
* against themselves, and drifted to 78 of canon's 113 rows with stale
|
|
14
|
+
* platform relevance, stale v1 posture and stale labels — the same failure
|
|
15
|
+
* class `coreIndicators.pin.json` closed for CVC-136 (66 missing, 56 invented).
|
|
16
|
+
* With this pin, `core-functions-canon.test.ts` (GATE I) asserts on every PR that
|
|
17
|
+
* the shipped SOT restates every canon function — key, label, and the posture
|
|
18
|
+
* suffix the entry schema folds into `definition` — and nothing canon does not
|
|
19
|
+
* carry; `sot:pins:check` detects when canon moves.
|
|
20
|
+
*
|
|
21
|
+
* The PROJECTION is the set of canon fields the SOT actually restates. Bounds
|
|
22
|
+
* (Always / Default On / Default Off / Never per CVC-134/135 role code) are
|
|
23
|
+
* canon too but the entry schema has no field for them, so they are not
|
|
24
|
+
* projected here; they arrive with the resolver-contract round.
|
|
25
|
+
*
|
|
26
|
+
* Lives in `src/` (not `scripts/`) for the same tsconfig `rootDir` reason as
|
|
27
|
+
* `coreIndicatorFields.ts`.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export const PROJECTED_FUNCTION_FIELDS = [
|
|
31
|
+
"label",
|
|
32
|
+
"definition",
|
|
33
|
+
"status",
|
|
34
|
+
"category",
|
|
35
|
+
"platform_relevance",
|
|
36
|
+
"is_user_relevant",
|
|
37
|
+
"is_admin_relevant",
|
|
38
|
+
"v1",
|
|
39
|
+
"retired",
|
|
40
|
+
] as const;
|
|
41
|
+
|
|
42
|
+
export type ProjectedFunctionField = (typeof PROJECTED_FUNCTION_FIELDS)[number];
|
|
43
|
+
|
|
44
|
+
export interface ProjectedFunctionFields {
|
|
45
|
+
readonly label: string;
|
|
46
|
+
/** Canon's definition body, trimmed; the SOT definition is this + " " + the posture suffix. */
|
|
47
|
+
readonly definition: string;
|
|
48
|
+
readonly status: string;
|
|
49
|
+
readonly category: string;
|
|
50
|
+
/** Canon's `platform_relevance` list, in canon order (the SOT suffix joins it with ", "). */
|
|
51
|
+
readonly platform_relevance: readonly string[];
|
|
52
|
+
readonly is_user_relevant: boolean;
|
|
53
|
+
readonly is_admin_relevant: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Canon's per-row `v1` flag (required on every canon row). Restated as the
|
|
56
|
+
* SOT entry's structured `v1` since 1.3.0; the shared authorization resolver
|
|
57
|
+
* refuses a function unless canon says v1 && !retired.
|
|
58
|
+
*/
|
|
59
|
+
readonly v1: boolean;
|
|
60
|
+
/** Canon's first-class `retired: true` (2026-08-14 Phase 1); a tombstone in the SOT. */
|
|
61
|
+
readonly retired: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Project one canon row (a parsed `functions[]` item of the yaml). */
|
|
65
|
+
export function projectFunctionRow(
|
|
66
|
+
row: Readonly<Record<string, unknown>>,
|
|
67
|
+
): ProjectedFunctionFields {
|
|
68
|
+
const str = (k: string): string => {
|
|
69
|
+
const v = row[k];
|
|
70
|
+
if (typeof v !== "string")
|
|
71
|
+
throw new Error(
|
|
72
|
+
`core_functions.yaml row ${String(row["code"])}: ${k} is not a string`,
|
|
73
|
+
);
|
|
74
|
+
return v;
|
|
75
|
+
};
|
|
76
|
+
const bool = (k: string): boolean => {
|
|
77
|
+
const v = row[k];
|
|
78
|
+
if (v === undefined) return false;
|
|
79
|
+
if (typeof v !== "boolean")
|
|
80
|
+
throw new Error(
|
|
81
|
+
`core_functions.yaml row ${String(row["code"])}: ${k} is not a boolean`,
|
|
82
|
+
);
|
|
83
|
+
return v;
|
|
84
|
+
};
|
|
85
|
+
const requiredBool = (k: string): boolean => {
|
|
86
|
+
const v = row[k];
|
|
87
|
+
if (typeof v !== "boolean")
|
|
88
|
+
throw new Error(
|
|
89
|
+
`core_functions.yaml row ${String(row["code"])}: ${k} is not a boolean`,
|
|
90
|
+
);
|
|
91
|
+
return v;
|
|
92
|
+
};
|
|
93
|
+
const rel = row["platform_relevance"];
|
|
94
|
+
if (!Array.isArray(rel) || !rel.every((x) => typeof x === "string")) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`core_functions.yaml row ${String(row["code"])}: platform_relevance is not a string list`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
label: str("label"),
|
|
101
|
+
definition: str("definition").trim(),
|
|
102
|
+
status: str("status"),
|
|
103
|
+
category: str("category"),
|
|
104
|
+
platform_relevance: [...(rel as string[])],
|
|
105
|
+
is_user_relevant: bool("is_user_relevant"),
|
|
106
|
+
is_admin_relevant: bool("is_admin_relevant"),
|
|
107
|
+
v1: requiredBool("v1"),
|
|
108
|
+
retired: bool("retired"),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The posture suffix the SOT folds into `definition` (the 1.0.0 port's shape,
|
|
114
|
+
* reproduced by `scripts/gen-core-functions.py`). Both halves compose it from
|
|
115
|
+
* the SAME projected fields, so a generator that drifts from this shape fails
|
|
116
|
+
* GATE I rather than shipping.
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* The whole SOT `definition` a canon row must produce: body + " " + suffix, with
|
|
120
|
+
* the tombstone marker ahead of the suffix for a retired row.
|
|
121
|
+
*/
|
|
122
|
+
export function expectedDefinition(f: ProjectedFunctionFields): string {
|
|
123
|
+
const tomb = f.retired
|
|
124
|
+
? "[RETIRED in canon — tombstone: kept so stored policies naming it still parse; " +
|
|
125
|
+
"resolvers refuse it with state 'retired'; never offered in a picker.] "
|
|
126
|
+
: "";
|
|
127
|
+
return `${f.definition} ${tomb}${postureSuffix(f)}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function postureSuffix(f: ProjectedFunctionFields): string {
|
|
131
|
+
const yn = (b: boolean): string => (b ? "yes" : "no");
|
|
132
|
+
return (
|
|
133
|
+
`[Status: ${f.status}. Platform: ${f.platform_relevance.join(", ")}. ` +
|
|
134
|
+
`User-relevant: ${yn(f.is_user_relevant)}. Admin-relevant: ${yn(f.is_admin_relevant)}. ` +
|
|
135
|
+
`Category: ${f.category}.]`
|
|
136
|
+
);
|
|
137
|
+
}
|