@htilabs/platform-common-models 0.8.24 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.cjs +81 -0
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +79 -4
- package/dist/config/index.d.ts +79 -4
- package/dist/config/index.js +79 -1
- package/dist/config/index.js.map +1 -1
- package/dist/constants/index.cjs +2 -18
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +2 -18
- package/dist/constants/index.js.map +1 -1
- package/dist/{cvcEntry-ctHTp2df.d.cts → cvcEntry-BCj1OWqL.d.cts} +44 -44
- package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-BCj1OWqL.d.ts} +44 -44
- package/dist/cvcs/index.cjs +217 -6674
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +8057 -15024
- package/dist/cvcs/index.d.ts +8057 -15024
- package/dist/cvcs/index.js +217 -6662
- package/dist/cvcs/index.js.map +1 -1
- package/dist/{index-qreOzXYS.d.cts → index-CoVr1jIV.d.cts} +1 -1
- package/dist/{index-4DiJrn7y.d.ts → index-I-DiX9eQ.d.ts} +1 -1
- package/dist/index.cjs +230 -7217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -588
- package/dist/index.d.ts +26 -588
- package/dist/index.js +230 -7193
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/mongo/index.cjs +1 -0
- package/dist/mongo/index.cjs.map +1 -1
- package/dist/mongo/index.js +2 -1
- package/dist/mongo/index.js.map +1 -1
- package/dist/{platform-auth-91Hcl8F8.d.cts → platform-auth-v53r3BhN.d.cts} +3 -4
- package/dist/{platform-auth-91Hcl8F8.d.ts → platform-auth-v53r3BhN.d.ts} +3 -4
- package/dist/schemas/index.cjs +1 -5
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +35 -35
- package/dist/schemas/index.d.ts +35 -35
- package/dist/schemas/index.js +1 -5
- 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/dist/validation/index.cjs +0 -58
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +283 -82
- package/dist/validation/index.d.ts +283 -82
- package/dist/validation/index.js +0 -57
- package/dist/validation/index.js.map +1 -1
- package/package.json +22 -26
- package/src/__sot__/README.md +1 -36
- package/src/__sot__/coreIndicators.pin.json +2 -1936
- package/src/__sot__/cvcIndex.pin.json +4 -8
- package/src/__tests__/__snapshots__/cvc-sot.snap +13 -41
- package/src/__tests__/cvc-136-scoring-invariant.test.ts +3 -8
- package/src/__tests__/cvc-drift-gate.test.ts +12 -445
- package/src/__tests__/cvc-sot-snapshot.test.ts +11 -73
- package/src/__tests__/cvc-structural.test.ts +0 -14
- package/src/__tests__/runtime-contract-validator.test.ts +325 -1
- package/src/config/index.ts +189 -4
- package/src/constants/ic.ts +3 -120
- package/src/cvcs/assertionDomain.v1.1.0.json +1 -19
- package/src/cvcs/coreIndicators.v1.0.0.json +5 -83
- package/src/cvcs/incidentParticipationRoles.v1.0.0.json +1 -11
- package/src/cvcs/index.ts +0 -32
- package/src/cvcs/personRelationships.v1.0.0.json +2 -67
- package/src/cvcs/relationshipConcern.v1.0.0.json +19 -28
- package/src/cvcs/sessionTemplate.v1.0.0.json +0 -22
- package/src/cvcs/sharePurpose.v1.0.0.json +12 -80
- package/src/generated/cvc-enums.ts +20 -606
- package/src/validation/index.ts +0 -1
- package/dist/cvc-C7qdsXYK.d.cts +0 -298
- package/dist/cvc-C7qdsXYK.d.ts +0 -298
- package/src/__sot__/coreIndicatorFields.ts +0 -331
- package/src/__tests__/core-information-scope-invariant.test.ts +0 -134
- package/src/__tests__/cvc-181-182-country-parity.test.ts +0 -163
- package/src/__tests__/cvc-status-parser.test.ts +0 -150
- package/src/cvcs/assertionStatus.v1.0.0.json +0 -80
- package/src/cvcs/carCorrectionReason.v1.0.0.json +0 -89
- package/src/cvcs/caseShareState.v1.0.0.json +0 -62
- package/src/cvcs/coreInformationScope.v1.0.0.json +0 -1165
- package/src/cvcs/countries.v1.0.0.json +0 -3077
- package/src/cvcs/createdBySystem.v1.0.0.json +0 -89
- package/src/cvcs/criminalOrgCategory.v1.0.0.json +0 -116
- package/src/cvcs/determinationHelperCategories.v1.0.0.json +0 -1166
- package/src/cvcs/minorAdultStatus.v1.0.0.json +0 -80
- package/src/cvcs/referralOrigin.v1.0.0.json +0 -26
- package/src/cvcs/riskIdentificationMilestone.v1.0.0.json +0 -109
- package/src/cvcs/subjectType.v1.0.0.json +0 -80
- package/src/validation/cvcStatus.ts +0 -209
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"domain": "minor_adult_status",
|
|
3
|
-
"name": "Minor / Adult Status (age band at event)",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"_status": "PROVISIONAL — GDR §10.1 confirmed-CVC name is `core - minor_adult_status`, and the canonical index DOES number this concept (Final CVCs/CVC_INDEX.md @ a596eb9: CVC-61 `minor_adult_status`) — but the CVC-61 Notion codebook has 0 entries anywhere, and ADR-CVC-0.8.13-canonical-alignment §Deliberately-NOT-authored (NARRATIVE_ONLY) deliberately declined to author at 61 to avoid manufacturing canonical drift. This vocabulary therefore parks in the provisional 900-block; RENUMBER 988 → 61 when the CVC-61 Notion codebook gains substantive entries (and reconcile membership at that point). Substantive values sourced verbatim from the PAVE @pave/domain `AGE_BANDS_AT_EVENT` enum (D10 GDR §10.1 bulk publish, bead pv-pgdr-cvc-source-gdr-10-1-bulk-publish): PAVE's `minor` / `adult` / `indeterminate` stay substantive; PAVE's fourth member `unknown` maps to the canonical missingness `unknown` sentinel (same realignment shape as the ROLE_CONTEXTS 0.7.0 bind), so every PAVE member remains expressible. Distinct from the numeric IC constant MINOR_ADULT_STATUS in constants/ic.ts (IC layer, 1/2/99) — that is a different encoding layer, not a parallel CVC.",
|
|
6
|
-
"_source": "pave-2.0/packages/domain/src/enums.ts AGE_BANDS_AT_EVENT",
|
|
7
|
-
"levels": {
|
|
8
|
-
"0": "Unknown or Missing",
|
|
9
|
-
"1": "Minor / adult status at event"
|
|
10
|
-
},
|
|
11
|
-
"entries": [
|
|
12
|
-
{
|
|
13
|
-
"code": "988-000-000-000-000-000-000",
|
|
14
|
-
"key": "missingness_root",
|
|
15
|
-
"title": "Unknown, Redacted, or Missing",
|
|
16
|
-
"selectable": false,
|
|
17
|
-
"parentCode": null,
|
|
18
|
-
"childCodes": [
|
|
19
|
-
"988-000-000-000-000-000-001",
|
|
20
|
-
"988-000-000-000-000-000-002",
|
|
21
|
-
"988-000-000-000-000-000-003"
|
|
22
|
-
],
|
|
23
|
-
"definition": "Root group for values indicating absent, withheld, or uncollected data."
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"code": "988-000-000-000-000-000-001",
|
|
27
|
-
"key": "unknown",
|
|
28
|
-
"title": "Unknown",
|
|
29
|
-
"selectable": true,
|
|
30
|
-
"parentCode": "988-000-000-000-000-000-000",
|
|
31
|
-
"childCodes": [],
|
|
32
|
-
"definition": "The age band is unknown — not assessed or not recorded (missingness sentinel). Carries PAVE's `unknown` member of AGE_BANDS_AT_EVENT."
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"code": "988-000-000-000-000-000-002",
|
|
36
|
-
"key": "anonymous",
|
|
37
|
-
"title": "Anonymous / declined to answer",
|
|
38
|
-
"selectable": true,
|
|
39
|
-
"parentCode": "988-000-000-000-000-000-000",
|
|
40
|
-
"childCodes": [],
|
|
41
|
-
"definition": "Value is intentionally withheld, declined, or redacted."
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"code": "988-000-000-000-000-000-003",
|
|
45
|
-
"key": "data_not_collected",
|
|
46
|
-
"title": "Data not collected",
|
|
47
|
-
"selectable": true,
|
|
48
|
-
"parentCode": "988-000-000-000-000-000-000",
|
|
49
|
-
"childCodes": [],
|
|
50
|
-
"definition": "No attempt was made to collect the value."
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"code": "988-001-000-000-000-000-000",
|
|
54
|
-
"key": "minor",
|
|
55
|
-
"title": "Minor (under 18)",
|
|
56
|
-
"selectable": true,
|
|
57
|
-
"parentCode": null,
|
|
58
|
-
"childCodes": [],
|
|
59
|
-
"definition": "The subject was under 18 when the asserted event occurred."
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"code": "988-002-000-000-000-000-000",
|
|
63
|
-
"key": "adult",
|
|
64
|
-
"title": "Adult (18+)",
|
|
65
|
-
"selectable": true,
|
|
66
|
-
"parentCode": null,
|
|
67
|
-
"childCodes": [],
|
|
68
|
-
"definition": "The subject was 18 or older when the asserted event occurred."
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"code": "988-003-000-000-000-000-000",
|
|
72
|
-
"key": "indeterminate",
|
|
73
|
-
"title": "Indeterminate",
|
|
74
|
-
"selectable": true,
|
|
75
|
-
"parentCode": null,
|
|
76
|
-
"childCodes": [],
|
|
77
|
-
"definition": "The age band cannot be determined from the available evidence — a positive determination of indeterminacy (e.g. conflicting or insufficient evidence), distinct from the `unknown` missingness sentinel (not assessed / not recorded)."
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"domain": "referral_origin",
|
|
3
|
-
"name": "Core Referral Origin",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"levels": { "1": "Origin" },
|
|
6
|
-
"entries": [
|
|
7
|
-
{
|
|
8
|
-
"code": "909-001-000-000-000-000-000",
|
|
9
|
-
"key": "internal",
|
|
10
|
-
"title": "Internal",
|
|
11
|
-
"selectable": true,
|
|
12
|
-
"parentCode": null,
|
|
13
|
-
"childCodes": [],
|
|
14
|
-
"definition": "A referral whose sending and receiving parties sit within the same agency or account boundary, so completing it involves no disclosure of client information across an organizational boundary."
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"code": "909-002-000-000-000-000-000",
|
|
18
|
-
"key": "external",
|
|
19
|
-
"title": "External",
|
|
20
|
-
"selectable": true,
|
|
21
|
-
"parentCode": null,
|
|
22
|
-
"childCodes": [],
|
|
23
|
-
"definition": "A referral whose receiving party is a different agency, making acceptance a cross-agency disclosure of client information. Where an implementation cannot positively determine the origin, it must treat the referral as external, so that the stronger disclosure controls apply by default rather than the weaker ones."
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"domain": "risk_identification_milestone",
|
|
3
|
-
"name": "Core Risk Identification Milestone (CVC-267)",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"_status": "CANONICAL -- ratified 2026-08-29 (Crysta knock-out walk). The identification-FUNNEL rung value set: the vocabulary `assertion_value_code` resolves against when `assertion_domain` is `signal_identification` (CVC-159 159-066) or, for `determined`, `investigative_legal` (159-067). Homes the `identification_rung_reached` CAR (Crysta-named 2026-08-23) minted once per subject per rung first reached, deterministic id `ast-t1r-<sid>-<rung>`, retroactively over the derived corpus. The rung CAR is a sibling EVENT record joined to the derived milestone row via `pm_ref`: the derived row remains derived and re-derives, and a milestone row never IS the CAR (spine 5.5). The 2026-05-11 no-CAR ruling STAYS IN FORCE for Track-3 rollups -- this is a carve-out for rung events, not a new default. Modelled as its OWN vocabulary rather than as Level-2 rows inside CVC-159: `AssertionDomainKeys` is consumed as the set of DOMAINS, and folding values into it breaks that contract downstream. Naming guard (Crysta 2026-06-30): identification FUNNEL / pipeline rungs -- never 'identification ladder', a retired synonym for the identity-CONFIDENCE axis `identity_status`.",
|
|
6
|
-
"_source": "htilabstech/prototype Final CVCs core - risk_identification_milestone (CVC-267) + data/cvcs/core_assertion_domain_extensions_signal_identification.yaml (PR #519); Notion 'Signal / identification question' (2026-08-29)",
|
|
7
|
-
"levels": {
|
|
8
|
-
"0": "Unknown or Missing",
|
|
9
|
-
"1": "Identification funnel rung"
|
|
10
|
-
},
|
|
11
|
-
"entries": [
|
|
12
|
-
{
|
|
13
|
-
"code": "267-000-000-000-000-000-000",
|
|
14
|
-
"key": "missingness_root",
|
|
15
|
-
"title": "Unknown, Redacted, or Missing",
|
|
16
|
-
"selectable": false,
|
|
17
|
-
"parentCode": null,
|
|
18
|
-
"childCodes": [
|
|
19
|
-
"267-000-000-000-000-000-001",
|
|
20
|
-
"267-000-000-000-000-000-002",
|
|
21
|
-
"267-000-000-000-000-000-003"
|
|
22
|
-
],
|
|
23
|
-
"definition": "Root group for values indicating absent, withheld, or uncollected data. Variant: 3-value (unknown, anonymous, data_not_collected) under the workspace standard ANON semantic."
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"code": "267-000-000-000-000-000-001",
|
|
27
|
-
"key": "unknown",
|
|
28
|
-
"title": "Unknown",
|
|
29
|
-
"selectable": true,
|
|
30
|
-
"parentCode": "267-000-000-000-000-000-000",
|
|
31
|
-
"childCodes": [],
|
|
32
|
-
"canonicalCode": "UNK",
|
|
33
|
-
"definition": "Unknown or cannot be determined from the available information. NOT a safe default. Distinct from having reached NO rung: a subject who has reached no rung has NO rows at all. The milestone-symmetry `NO_IDENTIFICATION` row is deliberately NOT part of this value set (ruling 2026-08-29, OR2) -- absence of rung CARs IS the no-state, and minting a 'none' assertion would re-assert a derived status."
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"code": "267-000-000-000-000-000-002",
|
|
37
|
-
"key": "anonymous",
|
|
38
|
-
"title": "Anonymous / declined to answer",
|
|
39
|
-
"selectable": true,
|
|
40
|
-
"parentCode": "267-000-000-000-000-000-000",
|
|
41
|
-
"childCodes": [],
|
|
42
|
-
"definition": "Value is intentionally withheld or redacted. Combines declined-to-answer and redacted/anonymous semantics under the workspace standard ANON sentinel."
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"code": "267-000-000-000-000-000-003",
|
|
46
|
-
"key": "data_not_collected",
|
|
47
|
-
"title": "Data not collected",
|
|
48
|
-
"selectable": true,
|
|
49
|
-
"parentCode": "267-000-000-000-000-000-000",
|
|
50
|
-
"childCodes": [],
|
|
51
|
-
"definition": "No attempt was made to collect the value. System-only sentinel per GLOBAL_DESIGN_RULES."
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"code": "267-001-000-000-000-000-000",
|
|
55
|
-
"key": "on_radar",
|
|
56
|
-
"title": "On radar",
|
|
57
|
-
"selectable": true,
|
|
58
|
-
"parentCode": null,
|
|
59
|
-
"childCodes": [],
|
|
60
|
-
"ordinal": 1,
|
|
61
|
-
"assertionDomain": "signal_identification",
|
|
62
|
-
"definition": "Rung 1. The subject is known to the system at all. EVERY new person record counts, with the origin kind carried on the derived milestone row (ruling 2026-08-20, confirmed x3). Stored `assertion_domain`: `signal_identification`."
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"code": "267-002-000-000-000-000-000",
|
|
66
|
-
"key": "screened",
|
|
67
|
-
"title": "Screened",
|
|
68
|
-
"selectable": true,
|
|
69
|
-
"parentCode": null,
|
|
70
|
-
"childCodes": [],
|
|
71
|
-
"ordinal": 2,
|
|
72
|
-
"assertionDomain": "signal_identification",
|
|
73
|
-
"definition": "Rung 2. A screening instrument was administered. A CLEAN screening still counts -- the rung measures REACH, not result; results are row data (ruling 2026-08-20, confirmed x3). Stored `assertion_domain`: `signal_identification`."
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"code": "267-003-000-000-000-000-000",
|
|
77
|
-
"key": "at_risk",
|
|
78
|
-
"title": "At risk",
|
|
79
|
-
"selectable": true,
|
|
80
|
-
"parentCode": null,
|
|
81
|
-
"childCodes": [],
|
|
82
|
-
"ordinal": 3,
|
|
83
|
-
"assertionDomain": "signal_identification",
|
|
84
|
-
"definition": "Rung 3. Satisfiable by EITHER an upward risk-band crossing OR a screening `recommended_followup` -- both count, and `satisfied_by` is carried on every row so analysis can separate the sources (ruling 2026-08-20 R1). Stored `assertion_domain`: `signal_identification`."
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"code": "267-004-000-000-000-000-000",
|
|
88
|
-
"key": "assessed",
|
|
89
|
-
"title": "Assessed",
|
|
90
|
-
"selectable": true,
|
|
91
|
-
"parentCode": null,
|
|
92
|
-
"childCodes": [],
|
|
93
|
-
"ordinal": 4,
|
|
94
|
-
"assertionDomain": "signal_identification",
|
|
95
|
-
"definition": "Rung 4. A full assessment was completed. Stored `assertion_domain`: `signal_identification`."
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"code": "267-005-000-000-000-000-000",
|
|
99
|
-
"key": "determined",
|
|
100
|
-
"title": "Determined",
|
|
101
|
-
"selectable": true,
|
|
102
|
-
"parentCode": null,
|
|
103
|
-
"childCodes": [],
|
|
104
|
-
"ordinal": 5,
|
|
105
|
-
"assertionDomain": "investigative_legal",
|
|
106
|
-
"definition": "Rung 5. A determination was reached in a safe setting. A NO-INDICATION determination still counts -- the rung measures reaching a conclusion, not which conclusion (ruling 2026-08-20, confirmed x3). STORED `assertion_domain` is `investigative_legal` (159-067) because CVC-267 TRAFFICKING_STATUS carries that domain; DOCUMENTED under `signal_identification` too (filed-under-both ruling 2026-08-29) without changing what is stored. Cross-population caveat: most determinations on file predate the screening rail, so a subject can legitimately show `determined` with no `screened` above it -- correct, not a broken chain."
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"domain": "subject_type",
|
|
3
|
-
"name": "Subject Type",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"_status": "PROVISIONAL — GDR §10.1 confirmed-CVC name is `core - subject_type`, but Final CVCs/CVC_INDEX.md @ a596eb9 carries no number for it, so it parks in the provisional 900-block pending canonical Notion authoring + steward ratification. Substantive values sourced verbatim from the PAVE @pave/domain `SUBJECT_TYPES` enum (D10 GDR §10.1 bulk publish, bead pv-pgdr-cvc-source-gdr-10-1-bulk-publish). The PAVE enum enumerates only the substantive entity kinds, so the missingness quadruplet is added per SOT convention.",
|
|
6
|
-
"_source": "pave-2.0/packages/domain/src/enums.ts SUBJECT_TYPES",
|
|
7
|
-
"levels": {
|
|
8
|
-
"0": "Unknown or Missing",
|
|
9
|
-
"1": "Assertion subject type"
|
|
10
|
-
},
|
|
11
|
-
"entries": [
|
|
12
|
-
{
|
|
13
|
-
"code": "987-000-000-000-000-000-000",
|
|
14
|
-
"key": "missingness_root",
|
|
15
|
-
"title": "Unknown, Redacted, or Missing",
|
|
16
|
-
"selectable": false,
|
|
17
|
-
"parentCode": null,
|
|
18
|
-
"childCodes": [
|
|
19
|
-
"987-000-000-000-000-000-001",
|
|
20
|
-
"987-000-000-000-000-000-002",
|
|
21
|
-
"987-000-000-000-000-000-003"
|
|
22
|
-
],
|
|
23
|
-
"definition": "Root group for values indicating absent, withheld, or uncollected data."
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"code": "987-000-000-000-000-000-001",
|
|
27
|
-
"key": "unknown",
|
|
28
|
-
"title": "Unknown",
|
|
29
|
-
"selectable": true,
|
|
30
|
-
"parentCode": "987-000-000-000-000-000-000",
|
|
31
|
-
"childCodes": [],
|
|
32
|
-
"definition": "The subject type is unknown at time of entry (missingness sentinel)."
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"code": "987-000-000-000-000-000-002",
|
|
36
|
-
"key": "anonymous",
|
|
37
|
-
"title": "Anonymous / declined to answer",
|
|
38
|
-
"selectable": true,
|
|
39
|
-
"parentCode": "987-000-000-000-000-000-000",
|
|
40
|
-
"childCodes": [],
|
|
41
|
-
"definition": "Value is intentionally withheld, declined, or redacted."
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"code": "987-000-000-000-000-000-003",
|
|
45
|
-
"key": "data_not_collected",
|
|
46
|
-
"title": "Data not collected",
|
|
47
|
-
"selectable": true,
|
|
48
|
-
"parentCode": "987-000-000-000-000-000-000",
|
|
49
|
-
"childCodes": [],
|
|
50
|
-
"definition": "No attempt was made to collect the value."
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"code": "987-001-000-000-000-000-000",
|
|
54
|
-
"key": "person",
|
|
55
|
-
"title": "Person",
|
|
56
|
-
"selectable": true,
|
|
57
|
-
"parentCode": null,
|
|
58
|
-
"childCodes": [],
|
|
59
|
-
"definition": "The assertion is about a person; `subject_id` resolves to a person record. Emitting systems typically default to this value (e.g. PAVE's assertion factory defaults `subjectType: \"person\"`)."
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"code": "987-002-000-000-000-000-000",
|
|
63
|
-
"key": "relationship",
|
|
64
|
-
"title": "Relationship",
|
|
65
|
-
"selectable": true,
|
|
66
|
-
"parentCode": null,
|
|
67
|
-
"childCodes": [],
|
|
68
|
-
"definition": "The assertion is about a relationship between people; `subject_id` resolves to a relationship record."
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"code": "987-003-000-000-000-000-000",
|
|
72
|
-
"key": "case",
|
|
73
|
-
"title": "Case",
|
|
74
|
-
"selectable": true,
|
|
75
|
-
"parentCode": null,
|
|
76
|
-
"childCodes": [],
|
|
77
|
-
"definition": "The assertion is about a case; `subject_id` resolves to a case record."
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @htilabs/platform-common-models — CVC `_status`/`_source` provenance parser
|
|
3
|
-
*
|
|
4
|
-
* Problem this solves: `_status` on a SOT envelope (`src/cvcs/*.json`) is
|
|
5
|
-
* unvalidated free text (115 of 179 domains carry it; the rest predate the
|
|
6
|
-
* convention). A consumer that wants to know "is this actually a draft?" has
|
|
7
|
-
* had to eyeball a string like
|
|
8
|
-
*
|
|
9
|
-
* "DRAFT — TEMPORARY: net-new value-CVC not yet in Notion; provisional
|
|
10
|
-
* 900+ numbering; codes from prototype/data/cvcs/core_accommodation_type
|
|
11
|
-
* .yaml; PENDING canonical Notion authoring (PAVE Auditability backlog)."
|
|
12
|
-
*
|
|
13
|
-
* and get it right past two real traps observed across the current
|
|
14
|
-
* population:
|
|
15
|
-
* - A leading `"CANONICAL — …"` marker is a PROVENANCE note on an
|
|
16
|
-
* ALREADY-ratified file, not a maturity warning — it must not be lumped
|
|
17
|
-
* in with `"DRAFT"`/`"PROVISIONAL"`.
|
|
18
|
-
* - `core_functions` is self-contradictory: it leads
|
|
19
|
-
* `"DRAFTED — NEEDS REVIEW"` but the same string continues
|
|
20
|
-
* `"…Canonical numbering (133), NOT provisional."` A naive
|
|
21
|
-
* leading-word reader silently picks one side; this parser flags it.
|
|
22
|
-
*
|
|
23
|
-
* This module is a pure, additive, standalone export. It does NOT touch
|
|
24
|
-
* `CvcEnvelopeSchema` (`./cvc.ts`) — `_status`/`_source` are intentionally
|
|
25
|
-
* outside that Zod schema (see its module header), and adding them there
|
|
26
|
-
* would risk changing parse behavior for every existing consumer. Callers
|
|
27
|
-
* pass the RAW parsed JSON object (before or instead of
|
|
28
|
-
* `CvcEnvelopeSchema.parse()`), not the Zod-inferred `CvcEnvelope`.
|
|
29
|
-
*
|
|
30
|
-
* Classification rule (leading token of `_status`, case-insensitive):
|
|
31
|
-
* - contains "draft" → `maturity: "draft"`
|
|
32
|
-
* - contains "provisional" → `maturity: "provisional"`
|
|
33
|
-
* - contains "canonical" → `maturity: "canonical"` (a provenance note on
|
|
34
|
-
* an already-ratified file, NOT a maturity flag — kept distinct from
|
|
35
|
-
* `"final"` below so a caller can tell "explicitly marked ratified"
|
|
36
|
-
* apart from "predates the convention entirely")
|
|
37
|
-
* - `_status` absent entirely → `maturity: "final"` (legacy/unmarked)
|
|
38
|
-
*
|
|
39
|
-
* One real domain (`share_purpose` — "Synced verbatim from canonical
|
|
40
|
-
* CVC-84…") has a present `_status` whose LEADING token ("Synced") is none
|
|
41
|
-
* of the three convention words. Rather than mis-file it as `"final"` (which
|
|
42
|
-
* per the rule above is reserved for an ABSENT field) this parser falls back
|
|
43
|
-
* to scanning the full string for a single unambiguous keyword family before
|
|
44
|
-
* giving up — see `detectMaturity` below.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
// ─── Public shape ───────────────────────────────────────────────────────────
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* The subset of a raw (pre-validation) SOT envelope this parser reads.
|
|
51
|
-
* Deliberately NOT the Zod-inferred `CvcEnvelope` from `./cvc.ts` — that type
|
|
52
|
-
* is the *parsed* shape, which does not declare `_status`/`_source` at all
|
|
53
|
-
* (they live outside the locked envelope schema on purpose). Pass the raw
|
|
54
|
-
* `JSON.parse()` result of a `src/cvcs/*.json` file here.
|
|
55
|
-
*/
|
|
56
|
-
export interface RawCvcEnvelopeProvenance {
|
|
57
|
-
_status?: unknown;
|
|
58
|
-
_source?: unknown;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** The four observed maturity states. See module header for the rule. */
|
|
62
|
-
export type CvcMaturity = "draft" | "provisional" | "canonical" | "final";
|
|
63
|
-
|
|
64
|
-
export interface CvcStatusInfo {
|
|
65
|
-
/** One of the four states; see module header for the classification rule. */
|
|
66
|
-
maturity: CvcMaturity;
|
|
67
|
-
/**
|
|
68
|
-
* The text this parser classified. For a string `_status` this is that
|
|
69
|
-
* string verbatim. For the 11 domains authored with a structured
|
|
70
|
-
* `_status` object (`{ vocabStatus, authoredBy, evidence, … }` — e.g.
|
|
71
|
-
* `citizenship`, `core_functions`'s sibling `countries`), this is
|
|
72
|
-
* `_status.vocabStatus` — the field those envelopes use for exactly this
|
|
73
|
-
* purpose — not the whole object. `null` iff `_status` is absent.
|
|
74
|
-
*/
|
|
75
|
-
rawStatus: string | null;
|
|
76
|
-
/** True iff `_source` cites a `prototype/data/cvcs/*.yaml` path. */
|
|
77
|
-
sourceIsPrototype: boolean;
|
|
78
|
-
/** The cited `prototype/data/cvcs/*.yaml` path, or `null` if none. */
|
|
79
|
-
sourcePath: string | null;
|
|
80
|
-
/**
|
|
81
|
-
* True when the classification is a judgment call rather than a clean
|
|
82
|
-
* read: either the leading token disagrees with a later
|
|
83
|
-
* "NOT draft"/"NOT provisional"/"NOT canonical" qualifier in the same
|
|
84
|
-
* string (the `core_functions` shape — generic, not special-cased, so any
|
|
85
|
-
* future domain authored in the same self-contradictory shape is also
|
|
86
|
-
* caught), or the string carries more than one maturity keyword family
|
|
87
|
-
* with no leading token to arbitrate between them.
|
|
88
|
-
*/
|
|
89
|
-
ambiguous: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ─── Implementation ─────────────────────────────────────────────────────────
|
|
93
|
-
|
|
94
|
-
const MATURITY_KEYWORDS: ReadonlyArray<{
|
|
95
|
-
keyword: string;
|
|
96
|
-
maturity: Exclude<CvcMaturity, "final">;
|
|
97
|
-
}> = [
|
|
98
|
-
{ keyword: "draft", maturity: "draft" },
|
|
99
|
-
{ keyword: "provisional", maturity: "provisional" },
|
|
100
|
-
{ keyword: "canonical", maturity: "canonical" },
|
|
101
|
-
];
|
|
102
|
-
|
|
103
|
-
/** Matches a `prototype/data/cvcs/<file>.yaml` citation anywhere in `_source`. */
|
|
104
|
-
const PROTOTYPE_SOURCE_RE = /(prototype\/data\/cvcs\/[A-Za-z0-9_.-]+\.yaml)/;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* A maturity keyword explicitly negated ("NOT provisional.") anywhere in the
|
|
108
|
-
* string — the self-contradiction signal. Deliberately scans the WHOLE
|
|
109
|
-
* string (not just past the leading token): the qualifier that disagrees
|
|
110
|
-
* with the leading word is, by construction, never the leading word itself.
|
|
111
|
-
*/
|
|
112
|
-
const NEGATED_MATURITY_RE = /\bnot\s+(draft|provisional|canonical)\b/i;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Extract the text this parser classifies against, from either `_status`
|
|
116
|
-
* shape observed in the current SOT population:
|
|
117
|
-
* - `string` (104 of 115 status-bearing domains) → the string itself.
|
|
118
|
-
* - `{ vocabStatus: string, … }` (11 domains — a richer, hand-authored
|
|
119
|
-
* provenance record) → `vocabStatus`, the field those envelopes use for
|
|
120
|
-
* exactly this classification (values seen: `"canonical"` and
|
|
121
|
-
* `"provisional-pending-notion-ratification"`).
|
|
122
|
-
* - Anything else present but shapeless (unseen in the current 179-domain
|
|
123
|
-
* population) → `JSON.stringify` as a last resort, so a future oddity
|
|
124
|
-
* still gets a best-effort classification instead of silently vanishing.
|
|
125
|
-
* - Absent → `null`.
|
|
126
|
-
*/
|
|
127
|
-
function extractClassificationText(status: unknown): string | null {
|
|
128
|
-
if (typeof status === "string") return status;
|
|
129
|
-
if (status !== null && typeof status === "object") {
|
|
130
|
-
const vocabStatus = (status as Record<string, unknown>).vocabStatus;
|
|
131
|
-
if (typeof vocabStatus === "string") return vocabStatus;
|
|
132
|
-
return JSON.stringify(status);
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** The first "word" of a status string, lowercased, for the leading-token rule. */
|
|
138
|
-
function leadingToken(text: string): string {
|
|
139
|
-
return (text.trim().split(/[\s—–:-]+/, 1)[0] ?? "").toLowerCase();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Classify a present, non-null `_status` text into a maturity + ambiguity
|
|
144
|
-
* flag. Isolated from {@link parseCvcStatus} so the fallback path (the
|
|
145
|
-
* `share_purpose` shape) and the negation check are each unit-testable in
|
|
146
|
-
* isolation.
|
|
147
|
-
*/
|
|
148
|
-
function detectMaturity(text: string): { maturity: Exclude<CvcMaturity, "final">; ambiguous: boolean } {
|
|
149
|
-
const lead = leadingToken(text);
|
|
150
|
-
const leadMatch = MATURITY_KEYWORDS.find(({ keyword }) => lead.includes(keyword));
|
|
151
|
-
|
|
152
|
-
let maturity: Exclude<CvcMaturity, "final">;
|
|
153
|
-
if (leadMatch) {
|
|
154
|
-
maturity = leadMatch.maturity;
|
|
155
|
-
} else {
|
|
156
|
-
// The leading token is none of the three convention words. Observed once
|
|
157
|
-
// in the current population: `share_purpose`'s
|
|
158
|
-
// "Synced verbatim from canonical CVC-84…" — "Synced" leads, but the
|
|
159
|
-
// string is unambiguously describing an already-ratified vocabulary.
|
|
160
|
-
// Fall back to scanning the WHOLE string for maturity keyword families
|
|
161
|
-
// rather than defaulting to "final": the field IS present, and "final"
|
|
162
|
-
// per the module-header rule is reserved for an ABSENT `_status`.
|
|
163
|
-
const foundFamilies = MATURITY_KEYWORDS.filter(({ keyword }) =>
|
|
164
|
-
new RegExp(`\\b${keyword}\\w*\\b`, "i").test(text),
|
|
165
|
-
);
|
|
166
|
-
const distinctFamilies = new Set(foundFamilies.map((f) => f.maturity));
|
|
167
|
-
if (distinctFamilies.size === 1) {
|
|
168
|
-
// Single unambiguous family found in the body — safe to accept.
|
|
169
|
-
maturity = foundFamilies[0].maturity;
|
|
170
|
-
return { maturity, ambiguous: false };
|
|
171
|
-
}
|
|
172
|
-
if (distinctFamilies.size > 1) {
|
|
173
|
-
// Multiple families present with no leading token to arbitrate.
|
|
174
|
-
// Report the first-occurring family as a best-effort primary and let
|
|
175
|
-
// the caller see `ambiguous: true` — never silently pick a winner.
|
|
176
|
-
maturity = foundFamilies[0].maturity;
|
|
177
|
-
return { maturity, ambiguous: true };
|
|
178
|
-
}
|
|
179
|
-
// No maturity keyword anywhere in a present `_status` string. Unseen in
|
|
180
|
-
// the current 179-domain population; treat conservatively as
|
|
181
|
-
// "provisional" (the least-committal non-final bucket) rather than
|
|
182
|
-
// silently promoting an unrecognized status to a settled one, and flag
|
|
183
|
-
// it for human attention.
|
|
184
|
-
return { maturity: "provisional", ambiguous: true };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return { maturity, ambiguous: NEGATED_MATURITY_RE.test(text) };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Parse a SOT envelope's `_status`/`_source` provenance fields into a
|
|
192
|
-
* structured, typed result. Pure function — no filesystem access, no
|
|
193
|
-
* dependency on `CvcEnvelopeSchema`. See module header for the full rule and
|
|
194
|
-
* the two known traps it exists to catch.
|
|
195
|
-
*/
|
|
196
|
-
export function parseCvcStatus(envelope: RawCvcEnvelopeProvenance): CvcStatusInfo {
|
|
197
|
-
const source = typeof envelope._source === "string" ? envelope._source : null;
|
|
198
|
-
const protoMatch = source?.match(PROTOTYPE_SOURCE_RE) ?? null;
|
|
199
|
-
const sourceIsPrototype = protoMatch !== null;
|
|
200
|
-
const sourcePath = protoMatch?.[1] ?? null;
|
|
201
|
-
|
|
202
|
-
const text = extractClassificationText(envelope._status);
|
|
203
|
-
if (text === null) {
|
|
204
|
-
return { maturity: "final", rawStatus: null, sourceIsPrototype, sourcePath, ambiguous: false };
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const { maturity, ambiguous } = detectMaturity(text);
|
|
208
|
-
return { maturity, rawStatus: text, sourceIsPrototype, sourcePath, ambiguous };
|
|
209
|
-
}
|