@htilabs/platform-common-models 0.87.0 → 0.88.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htilabs/platform-common-models",
3
- "version": "0.87.0",
3
+ "version": "0.88.0",
4
4
  "description": "Shared constants, types, and models for HTI Labs applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -19,6 +19,7 @@ live in other repos:
19
19
  | `captureConflictSemantics.pin.json` | `htilabstech/hti-features` · `src/hti_features/field_mapping/registry.json` → `capture_conflict_semantics` on `captured` rows | The per-field **capture-conflict semantics** the `share-review` kernel resolves (th-hbo9t.2): registry field id → `additive_log` · `log_end_date_current` · `single_value_keep_replace` · `no_conflict_derived`, plus the captured-row denominator. Derived here by `sot:pins` (set `HTI_FEATURES_DIR`; derivation in `scripts/lib/captureConflictSemantics.ts`, which refuses an illegal or `null` value, the key on a non-captured row, and a duplicate field id). **Refreshing this pin is half a step:** re-emit `src/generated/captureConflictSemantics.ts` with `npm run gen:capture-conflict-semantics` in the same change — `gen:capture-conflict-semantics:check` (ci.yml) holds the module byte-equal to the pin. Equal, key for key, to the prototype's generated `HTI_CAPTURE_CONFLICT_SEMANTICS` block at c2b0b8b0 (141). |
20
20
  | `grantAward.pin.json` | `htilabstech/hti-features` · `udd-schemas/grant/Grant.v2.json` + `udd-schemas/award/Award.v1.json` + `udd-schemas/award/AwardProgramLink.v1.json` | The shared **Grant / Award / Award–Program link** records (Kickoff 18c; shape confirmed by Crysta 2026-11-10): per schema, the required list, the field names, every `pattern` and `enum` (top level and inside array items), the conditional rule (`allOf`, the Award's SUBRECIPIENT pass-through rule) and every `x-scenarios` example **verbatim**. Derived by `scripts/lib/grantAwardSchemas.ts` (set `HTI_FEATURES_DIR`). `src/grantRegistry/__tests__/grantAwardPin.test.ts` asserts the `./grant-registry` subpath restates each list and that every example passes its write check. When hti-features moves the three schemas, refresh this pin and update `src/grantRegistry/` in the same change. |
21
21
  | `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) **and its per-role bounds** (since 0.24.0, co-p1x: `projectBounds` normalizes canon's `bounds:` to role code → ALWAYS / PREF_YES / PREF_NO / NEVER / NA; `GATE L` (`core-function-default-bounds.test.ts`) asserts the generated `src/generated/coreFunctionDefaultBounds.ts` equals it for every evaluable function and that every role code is a CVC-134 / CVC-135 `canonicalCode` — these are codebook DEFAULTS, the live bounds are platform policy state). 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. |
22
+ | `roiScopePresets.pin.json` | `htilabstech/prototype` · `HTI-LEADS-PAVE-Thread-prototype.html` `HTI_ROI_SCOPE_PRESETS` (+ `HTI_ROI_SCOPE_PRESETS_VERSION`, the wizard's `presetChip(...)` words) **and** `htilabstech/platform-prototype` · `src/data.js` `data.sharing.scopePresets` (`description` / `enabled` only) | The release (ROI) wizard's three **quick-fill scope presets** — ids, pill words and item lists in canon's order. The monolith carries no description or on/off; those two come from the Admin Hub prototype, whose own labels and lists are a stale hand-kept copy and are never read. `roi-scope-presets-canon.test.ts` asserts `src/roiScopePresets/index.ts` equals the pin and that every item is a live CVC-236 v4 row. Set `PLATFORM_PROTOTYPE_DIR` for the pin. |
22
23
  | `informationScopeV2V3Categories.pin.json` | `htilabstech/prototype` · `data/cvcs/core_information_scope.yaml` → `migrations_history` (the 2 → 3 step, `categories`) | CVC-236's v2 → v3 **category lines** — what an old category name adds when a category-grain list is carried forward. `readStoredPolicyScope` reads an unmarked stored sharing policy through them; `storedPolicyScope.test.ts` asserts `UNMARKED_POLICY_CATEGORY_LINES` equals the pin. |
23
24
 
24
25
  (Notion is the fourth SOT: **ratification**. It has no pin because it is a human
@@ -0,0 +1,82 @@
1
+ {
2
+ "sourceRepo": "htilabstech/prototype",
3
+ "sourceFile": "HTI-LEADS-PAVE-Thread-prototype.html",
4
+ "sourceSha": "ba5ded6",
5
+ "mirror": {
6
+ "sourceRepo": "htilabstech/platform-prototype",
7
+ "sourceFile": "src/data.js",
8
+ "sourceSha": "398fb24"
9
+ },
10
+ "scopeVersion": 4,
11
+ "presets": [
12
+ {
13
+ "id": "full_collab",
14
+ "label": "Full case collaboration",
15
+ "description": "Broad packet for coordinated providers working the case together.",
16
+ "enabled": true,
17
+ "itemIds": [
18
+ "names",
19
+ "dob",
20
+ "addresses",
21
+ "demographics",
22
+ "screen_indicators",
23
+ "victimization",
24
+ "summary_initial_screen",
25
+ "summary_ae_intake",
26
+ "summary_ida",
27
+ "summary_lap",
28
+ "summary_danger_assessment",
29
+ "summary_stalking_assessment",
30
+ "summary_injury_and_strangulation",
31
+ "summary_tra",
32
+ "summary_hope_scale",
33
+ "summary_needs_assessment",
34
+ "full_ida",
35
+ "contact_info",
36
+ "priorities_safety",
37
+ "encounter_location",
38
+ "contact_history",
39
+ "service_history",
40
+ "plans_goals",
41
+ "session_summary",
42
+ "case_notes",
43
+ "relationships_household",
44
+ "family",
45
+ "system_info"
46
+ ]
47
+ },
48
+ {
49
+ "id": "risk_only",
50
+ "label": "Name + risk information",
51
+ "description": "Minimal identifying info — risk + screening for a coordinated handoff.",
52
+ "enabled": true,
53
+ "itemIds": [
54
+ "names",
55
+ "screen_indicators",
56
+ "victimization",
57
+ "summary_initial_screen",
58
+ "summary_ae_intake",
59
+ "summary_ida",
60
+ "summary_lap",
61
+ "summary_danger_assessment",
62
+ "summary_stalking_assessment",
63
+ "summary_injury_and_strangulation",
64
+ "system_info"
65
+ ]
66
+ },
67
+ {
68
+ "id": "identifying",
69
+ "label": "Identifying info only",
70
+ "description": "Used for verification with law enforcement / medical partners.",
71
+ "enabled": true,
72
+ "itemIds": [
73
+ "names",
74
+ "dob",
75
+ "addresses",
76
+ "additional_ids",
77
+ "demographics",
78
+ "system_info"
79
+ ]
80
+ }
81
+ ]
82
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * ROI SCOPE PRESETS — the shipped presets restate canon (@ the pin)
3
+ * ================================================================
4
+ *
5
+ * `src/roiScopePresets/index.ts` is the one home of the release (ROI) wizard's
6
+ * quick-fill presets. `src/__sot__/roiScopePresets.pin.json` is derived
7
+ * INDEPENDENTLY from the monolith's `HTI_ROI_SCOPE_PRESETS` (+ the Admin Hub
8
+ * prototype's description / on-off) by `scripts/sot-pins.ts`. This test is the
9
+ * hermetic enforcer: ids, labels, descriptions, `enabled` and every item list
10
+ * (order included) equal the pin, and every item is a live CVC-236 v4 row.
11
+ * `sot:pins:check` is the detector for canon moving.
12
+ */
13
+ import { readFileSync } from "node:fs";
14
+ import path from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ import { describe, expect, it } from "vitest";
17
+
18
+ import { coreInformationScopeSot } from "../cvcs/index.js";
19
+ import {
20
+ ROI_SCOPE_PRESETS,
21
+ ROI_SCOPE_PRESETS_SCOPE_VERSION,
22
+ ROI_SCOPE_PRESETS_SOURCE,
23
+ ROI_SCOPE_PRESET_IDS,
24
+ ROI_SCOPE_PRESET_ITEM_IDS,
25
+ ROI_SCOPE_PRESET_LABELS,
26
+ createInformationScopeResolver,
27
+ isRoiScopePresetId,
28
+ roiScopePresetById,
29
+ roiScopePresetRows,
30
+ scopeMigrationsFromSot,
31
+ scopeRowsFromSot,
32
+ type CoreInformationScopeSot,
33
+ } from "../services/informationScope.js";
34
+ import * as root from "../index.js";
35
+
36
+ const here = path.dirname(fileURLToPath(import.meta.url));
37
+ const pin = JSON.parse(
38
+ readFileSync(path.join(here, "..", "__sot__", "roiScopePresets.pin.json"), "utf8"),
39
+ ) as {
40
+ sourceSha: string;
41
+ mirror: { sourceSha: string };
42
+ scopeVersion: number;
43
+ presets: {
44
+ id: string;
45
+ label: string;
46
+ description: string;
47
+ enabled: boolean;
48
+ itemIds: string[];
49
+ }[];
50
+ };
51
+
52
+ const sot = coreInformationScopeSot as CoreInformationScopeSot;
53
+ const scope = createInformationScopeResolver({
54
+ rows: scopeRowsFromSot(sot),
55
+ migrations: scopeMigrationsFromSot(sot),
56
+ });
57
+
58
+ describe("ROI scope presets — the shipped presets restate canon (@ the pin)", () => {
59
+ it("equals the independently derived pin, order included", () => {
60
+ expect(ROI_SCOPE_PRESETS_SCOPE_VERSION).toBe(pin.scopeVersion);
61
+ expect(JSON.stringify(ROI_SCOPE_PRESETS)).toBe(JSON.stringify(pin.presets));
62
+ expect(ROI_SCOPE_PRESETS_SOURCE.commit.startsWith(pin.sourceSha)).toBe(true);
63
+ expect(ROI_SCOPE_PRESETS_SOURCE.mirror.commit).toBe(pin.mirror.sourceSha);
64
+ });
65
+
66
+ it("names the three presets in the wizard's pill order, with the wizard's words", () => {
67
+ expect(ROI_SCOPE_PRESETS.map((p) => p.id)).toEqual([...ROI_SCOPE_PRESET_IDS]);
68
+ expect(ROI_SCOPE_PRESET_LABELS).toEqual({
69
+ full_collab: "Full case collaboration",
70
+ risk_only: "Name + risk information",
71
+ identifying: "Identifying info only",
72
+ });
73
+ for (const p of ROI_SCOPE_PRESETS) expect(ROI_SCOPE_PRESET_ITEM_IDS[p.id]).toBe(p.itemIds);
74
+ });
75
+
76
+ it("every item is a live CVC-236 v4 row, and every preset carries system_info", () => {
77
+ for (const p of ROI_SCOPE_PRESETS) {
78
+ expect(new Set(p.itemIds).size).toBe(p.itemIds.length);
79
+ expect(p.itemIds).toContain("system_info");
80
+ const rows = roiScopePresetRows(p.id, scope);
81
+ expect(rows.map((r) => r.scopeCode)).toEqual([...p.itemIds]);
82
+ for (const r of rows) expect(r.status).not.toBe("retired");
83
+ }
84
+ });
85
+
86
+ it("lookups and refusals", () => {
87
+ expect(roiScopePresetById("identifying")?.label).toBe("Identifying info only");
88
+ expect(roiScopePresetById("custom")).toBeUndefined();
89
+ expect(isRoiScopePresetId("risk_only")).toBe(true);
90
+ expect(isRoiScopePresetId("account_default")).toBe(false);
91
+ expect(() => roiScopePresetRows("custom", scope)).toThrow(/not an ROI scope preset/);
92
+ expect(() =>
93
+ roiScopePresetRows("identifying", { row: (c: string) => (c === "names" ? scope.row(c) : undefined) }),
94
+ ).toThrow(/not a live CVC-236 row/);
95
+ });
96
+
97
+ it("the presets are frozen", () => {
98
+ expect(Object.isFrozen(ROI_SCOPE_PRESETS)).toBe(true);
99
+ expect(Object.isFrozen(ROI_SCOPE_PRESETS[0]?.itemIds)).toBe(true);
100
+ });
101
+
102
+ it("is exported from the package root too", () => {
103
+ expect(root.ROI_SCOPE_PRESETS).toBe(ROI_SCOPE_PRESETS);
104
+ expect(root.roiScopePresetRows).toBe(roiScopePresetRows);
105
+ });
106
+ });
@@ -0,0 +1,190 @@
1
+ /**
2
+ * @htilabs/platform-common-models — the release (ROI) wizard's quick-fill scope presets
3
+ *
4
+ * ONE home for the three presets the ROI wizard offers staff when they record what a
5
+ * survivor authorizes — "Full case collaboration" / "Name + risk information" /
6
+ * "Identifying info only" — and that the Admin Hub's Information scope tab lists under
7
+ * "Default scope presets". Every app reads this export; no app keeps its own list
8
+ * (Crysta, 2026-11-16: one vocabulary, one source, never hand-copied).
9
+ *
10
+ * Source of truth: the prototype monolith's `HTI_ROI_SCOPE_PRESETS` (ids, item lists and
11
+ * their order, stamped `HTI_ROI_SCOPE_PRESETS_VERSION`) and the wizard's pill words
12
+ * (`presetChip(...)`), at the commit in `ROI_SCOPE_PRESETS_SOURCE`. The monolith carries no
13
+ * description and no on/off for a preset; `description` and `enabled` are the Admin Hub
14
+ * prototype's (`data.sharing.scopePresets`). `src/__sot__/roiScopePresets.pin.json` is the
15
+ * independently derived snapshot (`npm run sot:pins -- --only=roiScopePresets`);
16
+ * `roi-scope-presets-canon.test.ts` holds this module equal to it and resolves every item
17
+ * against the published CVC-236 v4 tree.
18
+ *
19
+ * Item ids are CVC-236 `core-information_scope` row codes on tree version 4 (canon's dotted
20
+ * spelling — every preset row today is a plain key). A code covers every row beneath it,
21
+ * so `family` is the whole Eligible-family-member kind. Instrument Summary rows are
22
+ * `selectable: false` in the tree — no picker offers one alone — but canon lists the
23
+ * presets per row on purpose, and the presets keep them.
24
+ *
25
+ * `enabled` is display-only in the prototype (the Admin Hub's "Enabled" chip; no control in
26
+ * either prototype changes it), so it is the default here and nothing stores it per account.
27
+ *
28
+ * Pure: no mongoose, no I/O. Browser-safe through `./information-scope`.
29
+ */
30
+
31
+ /** The three fixed preset ids, in the wizard's pill order. */
32
+ export const ROI_SCOPE_PRESET_IDS = ["full_collab", "risk_only", "identifying"] as const;
33
+ export type RoiScopePresetId = (typeof ROI_SCOPE_PRESET_IDS)[number];
34
+
35
+ /** The CVC-236 tree version every preset list is authored on (canon `HTI_ROI_SCOPE_PRESETS_VERSION`). */
36
+ export const ROI_SCOPE_PRESETS_SCOPE_VERSION = 4 as const;
37
+
38
+ /** Where the presets were copied from (the pin restates it). */
39
+ export const ROI_SCOPE_PRESETS_SOURCE = {
40
+ repo: "htilabstech/prototype",
41
+ file: "HTI-LEADS-PAVE-Thread-prototype.html",
42
+ commit: "ba5ded6de6affdb11054a18a8a8a561be987a403",
43
+ mirror: { repo: "htilabstech/platform-prototype", file: "src/data.js", commit: "398fb24" },
44
+ } as const;
45
+
46
+ export interface RoiScopePresetDefinition {
47
+ readonly id: RoiScopePresetId;
48
+ /** The wizard's pill word. */
49
+ readonly label: string;
50
+ /** The Admin Hub's one-line description. */
51
+ readonly description: string;
52
+ /** Whether the preset is offered by default (display-only in the prototype). */
53
+ readonly enabled: boolean;
54
+ /** CVC-236 v4 row codes, in canon's order; `system_info` included. */
55
+ readonly itemIds: readonly string[];
56
+ }
57
+
58
+ const freeze = (p: RoiScopePresetDefinition): RoiScopePresetDefinition =>
59
+ Object.freeze({ ...p, itemIds: Object.freeze([...p.itemIds]) });
60
+
61
+ /** The three ROI scope presets, canon's lists verbatim, in pill order. */
62
+ export const ROI_SCOPE_PRESETS: readonly RoiScopePresetDefinition[] = Object.freeze([
63
+ freeze({
64
+ id: "full_collab",
65
+ label: "Full case collaboration",
66
+ description: "Broad packet for coordinated providers working the case together.",
67
+ enabled: true,
68
+ itemIds: [
69
+ "names",
70
+ "dob",
71
+ "addresses",
72
+ "demographics",
73
+ "screen_indicators",
74
+ "victimization",
75
+ "summary_initial_screen",
76
+ "summary_ae_intake",
77
+ "summary_ida",
78
+ "summary_lap",
79
+ "summary_danger_assessment",
80
+ "summary_stalking_assessment",
81
+ "summary_injury_and_strangulation",
82
+ "summary_tra",
83
+ "summary_hope_scale",
84
+ "summary_needs_assessment",
85
+ "full_ida",
86
+ "contact_info",
87
+ "priorities_safety",
88
+ "encounter_location",
89
+ "contact_history",
90
+ "service_history",
91
+ "plans_goals",
92
+ "session_summary",
93
+ "case_notes",
94
+ "relationships_household",
95
+ "family",
96
+ "system_info",
97
+ ],
98
+ }),
99
+ freeze({
100
+ id: "risk_only",
101
+ label: "Name + risk information",
102
+ description: "Minimal identifying info — risk + screening for a coordinated handoff.",
103
+ enabled: true,
104
+ itemIds: [
105
+ "names",
106
+ "screen_indicators",
107
+ "victimization",
108
+ "summary_initial_screen",
109
+ "summary_ae_intake",
110
+ "summary_ida",
111
+ "summary_lap",
112
+ "summary_danger_assessment",
113
+ "summary_stalking_assessment",
114
+ "summary_injury_and_strangulation",
115
+ "system_info",
116
+ ],
117
+ }),
118
+ freeze({
119
+ id: "identifying",
120
+ label: "Identifying info only",
121
+ description: "Used for verification with law enforcement / medical partners.",
122
+ enabled: true,
123
+ itemIds: ["names", "dob", "addresses", "additional_ids", "demographics", "system_info"],
124
+ }),
125
+ ]);
126
+
127
+ /** Each preset's pill word, by id. */
128
+ export const ROI_SCOPE_PRESET_LABELS: Readonly<Record<RoiScopePresetId, string>> = Object.freeze(
129
+ Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.label])) as Record<
130
+ RoiScopePresetId,
131
+ string
132
+ >,
133
+ );
134
+
135
+ /** Each preset's item list, by id. */
136
+ export const ROI_SCOPE_PRESET_ITEM_IDS: Readonly<Record<RoiScopePresetId, readonly string[]>> =
137
+ Object.freeze(
138
+ Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.itemIds])) as Record<
139
+ RoiScopePresetId,
140
+ readonly string[]
141
+ >,
142
+ );
143
+
144
+ /** Whether `id` names one of the three presets. */
145
+ export function isRoiScopePresetId(id: unknown): id is RoiScopePresetId {
146
+ return typeof id === "string" && (ROI_SCOPE_PRESET_IDS as readonly string[]).includes(id);
147
+ }
148
+
149
+ /** The preset with this id, or `undefined`. */
150
+ export function roiScopePresetById(id: string): RoiScopePresetDefinition | undefined {
151
+ return ROI_SCOPE_PRESETS.find((p) => p.id === id);
152
+ }
153
+
154
+ /** The CVC-236 row fields this module reads. */
155
+ export interface RoiScopePresetRowLike {
156
+ readonly scopeCode: string;
157
+ readonly status: string;
158
+ }
159
+
160
+ /** The slice of the CVC-236 resolver this module reads (`createInformationScopeResolver`). */
161
+ export interface RoiScopePresetRowSource<R extends RoiScopePresetRowLike> {
162
+ row(code: string): R | undefined;
163
+ }
164
+
165
+ /**
166
+ * A preset's rows, resolved against the CVC-236 tree, in the preset's order. Throws when
167
+ * the id is not a preset, or when an item does not resolve to a live row — a preset never
168
+ * silently selects less than canon says.
169
+ *
170
+ * ```ts
171
+ * const scope = createInformationScopeResolver({ rows: scopeRowsFromSot(sot), migrations: scopeMigrationsFromSot(sot) });
172
+ * roiScopePresetRows("risk_only", scope); // ScopeRow[]
173
+ * ```
174
+ */
175
+ export function roiScopePresetRows<R extends RoiScopePresetRowLike>(
176
+ id: string,
177
+ scope: RoiScopePresetRowSource<R>,
178
+ ): R[] {
179
+ const preset = roiScopePresetById(id);
180
+ if (!preset) throw new Error(`roiScopePresetRows: "${id}" is not an ROI scope preset`);
181
+ return preset.itemIds.map((code) => {
182
+ const row = scope.row(code);
183
+ if (!row || row.status === "retired") {
184
+ throw new Error(
185
+ `roiScopePresetRows: preset "${id}" names "${code}", which is not a live CVC-236 row`,
186
+ );
187
+ }
188
+ return row;
189
+ });
190
+ }
@@ -9,3 +9,5 @@
9
9
  export * from "./informationScopeResolver.js";
10
10
  export * from "./informationScopeSot.js";
11
11
  export * from "./informationScopeUiCopy.js";
12
+ // The release (ROI) wizard's three quick-fill scope presets (CVC-236 row codes).
13
+ export * from "../roiScopePresets/index.js";