@htilabs/platform-common-models 0.12.1 → 0.12.3

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 (55) hide show
  1. package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-ctHTp2df.d.cts} +36 -36
  2. package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-ctHTp2df.d.ts} +36 -36
  3. package/dist/cvcs/index.cjs +245 -4
  4. package/dist/cvcs/index.cjs.map +1 -1
  5. package/dist/cvcs/index.d.cts +533 -274
  6. package/dist/cvcs/index.d.ts +533 -274
  7. package/dist/cvcs/index.js +244 -4
  8. package/dist/cvcs/index.js.map +1 -1
  9. package/dist/enums/index.cjs +17 -0
  10. package/dist/enums/index.cjs.map +1 -1
  11. package/dist/enums/index.d.cts +24 -3
  12. package/dist/enums/index.d.ts +24 -3
  13. package/dist/enums/index.js +16 -0
  14. package/dist/enums/index.js.map +1 -1
  15. package/dist/{index-CDoqrfc1.d.ts → index-4DiJrn7y.d.ts} +1 -1
  16. package/dist/{index-Zu_mOJRn.d.cts → index-qreOzXYS.d.cts} +1 -1
  17. package/dist/index.cjs +317 -11
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -6
  20. package/dist/index.d.ts +6 -6
  21. package/dist/index.js +310 -11
  22. package/dist/index.js.map +1 -1
  23. package/dist/models/index.d.cts +2 -2
  24. package/dist/models/index.d.ts +2 -2
  25. package/dist/schemas/index.cjs +41 -7
  26. package/dist/schemas/index.cjs.map +1 -1
  27. package/dist/schemas/index.d.cts +116 -12
  28. package/dist/schemas/index.d.ts +116 -12
  29. package/dist/schemas/index.js +38 -7
  30. package/dist/schemas/index.js.map +1 -1
  31. package/dist/{cvc-Cp4uWnAa.d.cts → team-C4LJ5Tex.d.cts} +36 -1
  32. package/dist/{cvc-Cp4uWnAa.d.ts → team-C4LJ5Tex.d.ts} +36 -1
  33. package/dist/validation/index.cjs +155 -0
  34. package/dist/validation/index.cjs.map +1 -1
  35. package/dist/validation/index.d.cts +1 -1
  36. package/dist/validation/index.d.ts +1 -1
  37. package/dist/validation/index.js +153 -0
  38. package/dist/validation/index.js.map +1 -1
  39. package/package.json +27 -26
  40. package/src/__tests__/__snapshots__/cvc-sot.snap +8 -0
  41. package/src/__tests__/core-information-scope-invariant.test.ts +125 -2
  42. package/src/__tests__/cvc-drift-gate.test.ts +18 -0
  43. package/src/__tests__/cvc-sot-snapshot.test.ts +17 -0
  44. package/src/__tests__/cvc-structural.test.ts +5 -0
  45. package/src/__tests__/share-response-reason-invariant.test.ts +167 -0
  46. package/src/__tests__/team-directory-fields.test.ts +252 -0
  47. package/src/cvcs/coreInformationScope.v1.0.0.json +21 -4
  48. package/src/cvcs/index.ts +4 -0
  49. package/src/cvcs/shareResponseReason.v1.0.0.json +220 -0
  50. package/src/generated/cvc-enums.ts +25 -2
  51. package/src/index.ts +7 -0
  52. package/src/schemas/index.ts +8 -0
  53. package/src/schemas/team.ts +118 -0
  54. package/src/validation/index.ts +1 -0
  55. package/src/validation/team.ts +48 -0
@@ -0,0 +1,167 @@
1
+ /**
2
+ * SHARE RESPONSE REASON (CVC-306) — the per-context picker contract
3
+ * ==================================================================
4
+ *
5
+ * CVC-306 is ONE codebook whose rows are selectable per CONTEXT — `field_review`
6
+ * (a delivered field not brought in), `decline_share` (refusing a share before
7
+ * engaging it) and `reject_share` (refusing it after review). A consumer builds
8
+ * each context's picker by filtering on `entry.contexts`, so the context lists
9
+ * ARE the product contract: a reason that leaks into the wrong picker changes
10
+ * what a recipient can claim about a share.
11
+ *
12
+ * The canon rulings this pins (Crysta 2026-08-23, recorded in the prototype's
13
+ * `data/cvcs/core_share_response_reason.yaml` and the Notion codebook export):
14
+ *
15
+ * - The per-context columns, row for row, as canon publishes them.
16
+ * - Missingness is canon v1.1's shape (SHARING-FAMILY-AUDIT 2026-09-14): ONE
17
+ * ingestion-only sentinel, UNK, NEVER a picker chip (Selectable NO in every
18
+ * context), so it is `selectable: false` and belongs to no context. The
19
+ * codebook's DNC row is [ARCHIVED] ("Not a value; never emit") and must not
20
+ * be minted here — the first export did exactly that from stale canon.
21
+ * - The turned-away guard rail (R15): a person who was reached and chose no
22
+ * services is an ACCEPT + CVC-219 why-nots, never a decline — so
23
+ * `not_our_client` stays decline-only and no field-review or reject reason
24
+ * can stand in for it.
25
+ *
26
+ * The expected table below is transcribed from canon, NOT derived from the JSON,
27
+ * so a regenerated JSON that drifts from canon fails here rather than silently
28
+ * updating its own expectation.
29
+ */
30
+
31
+ import { readFileSync } from "node:fs";
32
+ import path from "node:path";
33
+ import { fileURLToPath } from "node:url";
34
+
35
+ import { describe, it, expect } from "vitest";
36
+
37
+ const here = path.dirname(fileURLToPath(import.meta.url));
38
+ const FILE = path.join(here, "..", "cvcs", "shareResponseReason.v1.0.0.json");
39
+
40
+ interface Entry {
41
+ code: string;
42
+ key: string;
43
+ selectable: boolean;
44
+ parentCode: string | null;
45
+ canonicalCode?: string;
46
+ contexts?: string[];
47
+ tobyRetention?: { class: string };
48
+ }
49
+ interface Envelope {
50
+ domain: string;
51
+ contexts: Record<string, string>;
52
+ entries: Entry[];
53
+ }
54
+
55
+ const env = JSON.parse(readFileSync(FILE, "utf8")) as Envelope;
56
+ const substantive = env.entries.filter((e) => e.code.split("-")[1] !== "000");
57
+ const missingness = env.entries.filter((e) => e.code.split("-")[1] === "000");
58
+
59
+ const CONTEXTS = ["field_review", "decline_share", "reject_share"] as const;
60
+
61
+ /** Canon's per-context selectability, in codebook row order. */
62
+ const CANON: Record<string, readonly string[]> = {
63
+ information_incorrect: ["field_review"],
64
+ not_relevant_for_client: ["field_review"],
65
+ duplicate_already_have: ["field_review", "decline_share"],
66
+ client_declined_recording: ["field_review"],
67
+ wrong_agency_service_area: ["decline_share"],
68
+ not_our_client: ["decline_share"],
69
+ sent_in_error: ["decline_share", "reject_share"],
70
+ no_capacity: ["decline_share"],
71
+ cannot_verify_conflicts: ["reject_share"],
72
+ wrong_person: ["reject_share"],
73
+ };
74
+
75
+ /** Canon's retention class vocabulary (yaml § TOBY RETENTION COLUMN). */
76
+ const RETENTION_CLASSES = new Set([
77
+ "supersede",
78
+ "tombstone_retain",
79
+ "purge_with_flags",
80
+ "inclusion_register",
81
+ "negative_constraint",
82
+ "retain_event",
83
+ ]);
84
+
85
+ describe("CVC-306 share_response_reason — per-context picker contract", () => {
86
+ it("declares exactly canon's three contexts", () => {
87
+ expect(env.domain).toBe("share_response_reason");
88
+ expect(Object.keys(env.contexts)).toEqual([...CONTEXTS]);
89
+ });
90
+
91
+ it("published codes are FROZEN: each key keeps its exact code (append-only)", () => {
92
+ // Enforced here independently of the generator's FROZEN list. Once published,
93
+ // a code's meaning is stored on live shares: a key may never move to another
94
+ // code, and a code may never be reused for another key. New reasons append at
95
+ // 306-011+, so this table only ever grows.
96
+ const FROZEN_CODES: Record<string, string> = {
97
+ information_incorrect: "306-001-000-000-000-000-000",
98
+ not_relevant_for_client: "306-002-000-000-000-000-000",
99
+ duplicate_already_have: "306-003-000-000-000-000-000",
100
+ client_declined_recording: "306-004-000-000-000-000-000",
101
+ wrong_agency_service_area: "306-005-000-000-000-000-000",
102
+ not_our_client: "306-006-000-000-000-000-000",
103
+ sent_in_error: "306-007-000-000-000-000-000",
104
+ no_capacity: "306-008-000-000-000-000-000",
105
+ cannot_verify_conflicts: "306-009-000-000-000-000-000",
106
+ wrong_person: "306-010-000-000-000-000-000",
107
+ };
108
+ const byKey = new Map(env.entries.map((e) => [e.key, e.code]));
109
+ for (const [key, code] of Object.entries(FROZEN_CODES)) {
110
+ expect(byKey.get(key), `${key} must keep ${code}`).toBe(code);
111
+ }
112
+ const frozen = new Set(Object.values(FROZEN_CODES));
113
+ for (const e of substantive) {
114
+ if (frozen.has(e.code)) expect(FROZEN_CODES[e.key], `${e.code} reused`).toBe(e.code);
115
+ else expect(Number(e.code.split("-")[1]), `${e.key} must append`).toBeGreaterThan(10);
116
+ }
117
+ });
118
+
119
+ it("carries exactly canon's 10 reasons, in codebook row order, all selectable", () => {
120
+ expect(substantive.map((e) => e.key)).toEqual(Object.keys(CANON));
121
+ for (const e of substantive) expect(e.selectable, e.key).toBe(true);
122
+ });
123
+
124
+ it("each reason is selectable in exactly the contexts canon gives it", () => {
125
+ for (const e of substantive) expect(e.contexts, e.key).toEqual(CANON[e.key]);
126
+ });
127
+
128
+ it("every context's picker is non-empty and matches canon", () => {
129
+ for (const ctx of CONTEXTS) {
130
+ const picker = substantive.filter((e) => e.contexts?.includes(ctx)).map((e) => e.key);
131
+ const want = Object.keys(CANON).filter((k) => CANON[k]!.includes(ctx));
132
+ expect(picker.length, ctx).toBeGreaterThan(0);
133
+ expect(picker, ctx).toEqual(want);
134
+ }
135
+ });
136
+
137
+ it("missingness is canon v1.1's single UNK sentinel, never a picker chip", () => {
138
+ expect(missingness.map((e) => e.key)).toEqual(["missingness_root", "unknown"]);
139
+ const unk = missingness.find((e) => e.key === "unknown")!;
140
+ expect(unk.code).toBe("306-000-000-000-000-000-001");
141
+ expect(unk.canonicalCode).toBe("UNK");
142
+ for (const e of missingness) {
143
+ expect(e.selectable, e.key).toBe(false);
144
+ expect(e.contexts ?? [], e.key).toEqual([]);
145
+ }
146
+ });
147
+
148
+ it("the archived DNC sentinel is not minted", () => {
149
+ const keys = env.entries.map((e) => e.key);
150
+ expect(keys).not.toContain("data_not_collected");
151
+ expect(env.entries.map((e) => e.canonicalCode)).not.toContain("DNC");
152
+ expect(env.entries.map((e) => e.code)).not.toContain("306-000-000-000-000-000-003");
153
+ });
154
+
155
+ it("R15 turned-away guard rail: not_our_client is decline-only", () => {
156
+ const e = substantive.find((x) => x.key === "not_our_client")!;
157
+ expect(e.contexts).toEqual(["decline_share"]);
158
+ });
159
+
160
+ it("every entry's tobyRetention class is in canon's class vocabulary", () => {
161
+ for (const e of env.entries) {
162
+ if (e.key === "missingness_root") continue;
163
+ expect(e.tobyRetention, e.key).toBeDefined();
164
+ expect(RETENTION_CLASSES.has(e.tobyRetention!.class), e.key).toBe(true);
165
+ }
166
+ });
167
+ });
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Team directory fields: the Mongoose fragment and the Zod schema behind the
3
+ * Thread→PAVE "Refer to intake" preset (canon: kickoff § 2.8 L254-257 at
4
+ * prototype `c658d6f7`; Thread ADR-THREAD-PAVE-CASESHARE-CONVERGENCE D1).
5
+ *
6
+ * The load-bearing guarantee is backward compatibility: an existing team
7
+ * document, in either the legacy PAVE shape or Thread's mirror shape, must
8
+ * validate unchanged and must not gain new keys when it is re-saved.
9
+ *
10
+ * No database is needed. Each test compiles models on a private Mongoose
11
+ * instance and calls `validateSync()` / `toObject()`.
12
+ */
13
+
14
+ import { describe, expect, it } from "vitest";
15
+ import mongoose, { Schema, Types } from "mongoose";
16
+
17
+ import {
18
+ PLATFORM_TOOL,
19
+ TEAM_MODEL_NAME,
20
+ TeamAppSchema,
21
+ TeamDirectoryFieldsSchema,
22
+ addTeamDirectoryFields,
23
+ teamDirectorySchemaDefinition,
24
+ type TeamDirectoryFields,
25
+ } from "../index.js";
26
+ import * as validationBarrel from "../validation/index.js";
27
+ import { z } from "zod";
28
+
29
+ // ─── Fixtures ────────────────────────────────────────────────────────
30
+
31
+ /** The legacy PAVE `teams` shape (screening-tools `models/teamModel.js`). */
32
+ function legacyPaveTeamSchema(): Schema {
33
+ return new Schema({
34
+ agencyId: { type: Schema.Types.ObjectId, index: true },
35
+ defaultTeam: { type: Boolean, default: false },
36
+ members: [{ type: Schema.Types.ObjectId }],
37
+ multiAgencyTeam: { type: Boolean, default: false },
38
+ name: { type: String, required: true },
39
+ numUsersEstimate: Number,
40
+ sharingPolicyId: { type: Schema.Types.ObjectId },
41
+ summary: String,
42
+ trainingModules: [String],
43
+ roles: [String],
44
+ });
45
+ }
46
+
47
+ /** Thread's mirror (`packages/db/src/models/platform/Team.ts`). */
48
+ function threadMirrorTeamSchema(): Schema {
49
+ return new Schema(
50
+ {
51
+ _schemaVersion: { type: Number, required: true, default: 1 },
52
+ createdUser: { type: Schema.Types.ObjectId, required: true },
53
+ updatedUser: { type: Schema.Types.ObjectId },
54
+ name: { type: String, required: true },
55
+ agencyId: { type: Schema.Types.ObjectId, required: true, ref: "Agency" },
56
+ defaultTeam: { type: Boolean, default: false },
57
+ status: { type: Number, required: true },
58
+ },
59
+ { timestamps: { createdAt: "createdTime", updatedAt: "updatedTime" } },
60
+ );
61
+ }
62
+
63
+ let modelSeq = 0;
64
+ function compile(schema: Schema) {
65
+ const m = new mongoose.Mongoose();
66
+ modelSeq += 1;
67
+ return m.model(`${TEAM_MODEL_NAME}${modelSeq}`, schema, "teams");
68
+ }
69
+
70
+ const LEGACY_DOC = {
71
+ agencyId: new Types.ObjectId(),
72
+ defaultTeam: true,
73
+ members: [new Types.ObjectId()],
74
+ multiAgencyTeam: false,
75
+ name: "Crisis Contact Team",
76
+ numUsersEstimate: 12,
77
+ summary: "",
78
+ trainingModules: [],
79
+ roles: [],
80
+ };
81
+
82
+ const THREAD_DOC = {
83
+ createdUser: new Types.ObjectId(),
84
+ name: "Crisis Contact Team",
85
+ agencyId: new Types.ObjectId(),
86
+ defaultTeam: true,
87
+ status: 1,
88
+ };
89
+
90
+ // ─── Mongoose fragment ───────────────────────────────────────────────
91
+
92
+ describe("teamDirectorySchemaDefinition (Mongoose)", () => {
93
+ it("validates an existing legacy PAVE team doc unchanged and adds no keys", () => {
94
+ const Team = compile(addTeamDirectoryFields(legacyPaveTeamSchema()));
95
+ const doc = new Team(LEGACY_DOC);
96
+
97
+ expect(doc.validateSync()).toBeUndefined();
98
+ const obj = doc.toObject();
99
+ expect(obj).not.toHaveProperty("apps");
100
+ expect(obj).not.toHaveProperty("canReferTo");
101
+ });
102
+
103
+ it("validates an existing Thread-mirror team doc unchanged and adds no keys", () => {
104
+ const Team = compile(addTeamDirectoryFields(threadMirrorTeamSchema()));
105
+ const doc = new Team(THREAD_DOC);
106
+
107
+ expect(doc.validateSync()).toBeUndefined();
108
+ const obj = doc.toObject();
109
+ expect(obj).not.toHaveProperty("apps");
110
+ expect(obj).not.toHaveProperty("canReferTo");
111
+ });
112
+
113
+ it("hydrates a stored doc without the fields and leaves it unmodified", () => {
114
+ const Team = compile(addTeamDirectoryFields(legacyPaveTeamSchema()));
115
+ const hydrated = Team.hydrate({ _id: new Types.ObjectId(), ...LEGACY_DOC });
116
+
117
+ expect(hydrated.isModified()).toBe(false);
118
+ expect(hydrated.get("apps")).toBeUndefined();
119
+ expect(hydrated.get("canReferTo")).toBeUndefined();
120
+ });
121
+
122
+ it("accepts PLATFORM_TOOL app codes and keeps canReferTo in order", () => {
123
+ const Team = compile(addTeamDirectoryFields(legacyPaveTeamSchema()));
124
+ const shelter = new Types.ObjectId();
125
+ const nonResidential = new Types.ObjectId();
126
+ const doc = new Team({
127
+ ...LEGACY_DOC,
128
+ apps: [PLATFORM_TOOL.THREAD],
129
+ canReferTo: [shelter.toHexString(), nonResidential],
130
+ });
131
+
132
+ expect(doc.validateSync()).toBeUndefined();
133
+ const obj = doc.toObject() as unknown as { apps: string[]; canReferTo: Types.ObjectId[] };
134
+ expect(obj.apps).toEqual(["THREAD"]);
135
+ expect(obj.canReferTo.map(String)).toEqual([String(shelter), String(nonResidential)]);
136
+ expect(obj.canReferTo[0]).toBeInstanceOf(Types.ObjectId);
137
+ });
138
+
139
+ it("keeps a declared-empty list distinct from an absent one", () => {
140
+ const Team = compile(addTeamDirectoryFields(legacyPaveTeamSchema()));
141
+ const doc = new Team({ ...LEGACY_DOC, apps: [], canReferTo: [] });
142
+
143
+ expect(doc.validateSync()).toBeUndefined();
144
+ expect(doc.toObject()).toMatchObject({ apps: [], canReferTo: [] });
145
+ });
146
+
147
+ it("rejects an app outside PLATFORM_TOOL, including canon's lowercase 'pave'", () => {
148
+ const Team = compile(addTeamDirectoryFields(legacyPaveTeamSchema()));
149
+ const err = new Team({ ...LEGACY_DOC, apps: ["PAVE", "pave"] }).validateSync();
150
+
151
+ expect(err?.errors["apps.1"]).toBeDefined();
152
+ expect(err?.errors["apps.0"]).toBeUndefined();
153
+ });
154
+
155
+ it("rejects a canReferTo entry that is not an ObjectId", () => {
156
+ const Team = compile(addTeamDirectoryFields(legacyPaveTeamSchema()));
157
+ const err = new Team({ ...LEGACY_DOC, canReferTo: ["prog-spring-crisis-shelter"] })
158
+ .validateSync();
159
+
160
+ expect(err).toBeDefined();
161
+ expect(Object.keys(err?.errors ?? {}).some((k) => k.startsWith("canReferTo"))).toBe(true);
162
+ });
163
+
164
+ it("refs canReferTo at the Team model", () => {
165
+ const schema = addTeamDirectoryFields(legacyPaveTeamSchema());
166
+ const element = schema.path("canReferTo.$") as unknown as { options?: { ref?: string } };
167
+ expect(element.options?.ref).toBe(TEAM_MODEL_NAME);
168
+ expect(TEAM_MODEL_NAME).toBe("Team");
169
+ });
170
+
171
+ it("returns the same schema and adds no indexes", () => {
172
+ const schema = legacyPaveTeamSchema();
173
+ const before = JSON.stringify(schema.indexes());
174
+ const result = addTeamDirectoryFields(schema);
175
+
176
+ expect(result).toBe(schema);
177
+ expect(JSON.stringify(schema.indexes())).toBe(before);
178
+ });
179
+
180
+ it("infers TeamDirectoryFields as optional app codes and ObjectIds (compile-time)", () => {
181
+ // `tsc --noEmit` (npm run typecheck) is the real assertion here.
182
+ const declared: TeamDirectoryFields = {
183
+ apps: [PLATFORM_TOOL.PAVE],
184
+ canReferTo: [new Types.ObjectId()],
185
+ };
186
+ const absent: TeamDirectoryFields = {};
187
+ // @ts-expect-error canon's lowercase app id is not a PlatformToolValue
188
+ const lowercase: TeamDirectoryFields = { apps: ["pave"] };
189
+ // @ts-expect-error a program id string is not an ObjectId
190
+ const programId: TeamDirectoryFields = { canReferTo: ["prog-spring-crisis-shelter"] };
191
+
192
+ expect([declared, absent, lowercase, programId]).toHaveLength(4);
193
+ });
194
+
195
+ it("declares exactly the two directory fields", () => {
196
+ expect(Object.keys(teamDirectorySchemaDefinition).sort()).toEqual(["apps", "canReferTo"]);
197
+ });
198
+ });
199
+
200
+ // ─── Zod ─────────────────────────────────────────────────────────────
201
+
202
+ describe("TeamDirectoryFieldsSchema (Zod)", () => {
203
+ const idA = new Types.ObjectId().toHexString();
204
+ const idB = new Types.ObjectId().toHexString();
205
+
206
+ it("accepts a payload without the fields", () => {
207
+ expect(TeamDirectoryFieldsSchema.parse({})).toEqual({});
208
+ });
209
+
210
+ it("accepts apps and an ordered canReferTo", () => {
211
+ const parsed = TeamDirectoryFieldsSchema.parse({ apps: ["THREAD", "PAVE"], canReferTo: [idA, idB] });
212
+ expect(parsed).toEqual({ apps: ["THREAD", "PAVE"], canReferTo: [idA, idB] });
213
+ });
214
+
215
+ it("rejects canon's lowercase app id", () => {
216
+ expect(TeamAppSchema.safeParse("pave").success).toBe(false);
217
+ expect(TeamDirectoryFieldsSchema.safeParse({ apps: ["pave"] }).success).toBe(false);
218
+ });
219
+
220
+ it("rejects a repeated app or target team", () => {
221
+ expect(TeamDirectoryFieldsSchema.safeParse({ apps: ["PAVE", "PAVE"] }).success).toBe(false);
222
+ expect(
223
+ TeamDirectoryFieldsSchema.safeParse({ canReferTo: [idA, idA.toUpperCase()] }).success,
224
+ ).toBe(false);
225
+ });
226
+
227
+ it("rejects a non-ObjectId target", () => {
228
+ expect(
229
+ TeamDirectoryFieldsSchema.safeParse({ canReferTo: ["prog-spring-crisis-shelter"] }).success,
230
+ ).toBe(false);
231
+ });
232
+
233
+ it("merges into a consumer's team schema without touching existing fields", () => {
234
+ const ConsumerTeam = z
235
+ .object({ name: z.string(), defaultTeam: z.boolean().optional() })
236
+ .merge(TeamDirectoryFieldsSchema);
237
+
238
+ expect(ConsumerTeam.parse({ name: "Crisis Shelter", defaultTeam: false })).toEqual({
239
+ name: "Crisis Shelter",
240
+ defaultTeam: false,
241
+ });
242
+ expect(ConsumerTeam.parse({ name: "Crisis Shelter", apps: ["PAVE"] })).toEqual({
243
+ name: "Crisis Shelter",
244
+ apps: ["PAVE"],
245
+ });
246
+ });
247
+
248
+ it("is exported from the /validation barrel", () => {
249
+ expect(validationBarrel.TeamDirectoryFieldsSchema).toBe(TeamDirectoryFieldsSchema);
250
+ expect(validationBarrel.TeamAppSchema).toBe(TeamAppSchema);
251
+ });
252
+ });
@@ -2,8 +2,8 @@
2
2
  "domain": "core_information_scope",
3
3
  "name": "Core Information Scope",
4
4
  "version": "1.0.0",
5
- "_status": "DRAFT: canonical number 236, self-declared by the source YAML (`cvc_id: CVC-236`); CVC_INDEX.md carries no row for it yet, so the drift gate classifies it INDEX_ABSENT. Sourced from canonical CVC-236 `core_information_scope` v2 (authored 2026-08-13, restructured 2026-08-14): 12 categories / 54 units. TWO GRAINS, deliberately modelled as hierarchy: L1 categories are the POLICY grain and are NOT selectable; L2 units are the AUTHORIZATION grain and are what an ROI or a share actually authorizes. This is the axis the sibling `roi_scope` domain deliberately omits — `roi_scope` is the flat item vocabulary, and its 27 substantive keys are a strict SUBSET of the 54 units here, with no renames and no collisions. That subset relationship is what makes adopting this domain additive: every stored ROI keeps its exact recorded meaning. `safe_locations` is PROVISIONAL and may be re-keyed by the Notion steward batch — pin the id with the product owner before any consumer treats it as stable. PENDING canonical Notion authoring + steward ratification.",
6
- "_source": "htilabstech/prototype data/cvcs/core_information_scope.yaml (CVC-236 v2, restructured 2026-08-14)",
5
+ "_status": "DRAFT: canonical number 236, self-declared by the source YAML (`cvc_id: CVC-236`); CVC_INDEX.md carries no row for it yet, so the drift gate classifies it INDEX_ABSENT. Sourced from canonical CVC-236 `core_information_scope` v2 (authored 2026-08-13, restructured 2026-08-14): 12 categories / 55 units. TWO GRAINS, deliberately modelled as hierarchy: L1 categories are the POLICY grain and are NOT selectable; L2 units are the AUTHORIZATION grain and are what an ROI or a share actually authorizes. This is the axis the sibling `roi_scope` domain deliberately omits — `roi_scope` is the flat item vocabulary, and its 27 substantive keys are a strict SUBSET of the 55 units here, with no renames and no collisions. That subset relationship is what makes adopting this domain additive: every stored ROI keeps its exact recorded meaning. `safe_locations` is PROVISIONAL and may be re-keyed by the Notion steward batch — pin the id with the product owner before any consumer treats it as stable. PENDING canonical Notion authoring + steward ratification.",
6
+ "_source": "htilabstech/prototype/data/cvcs/core_information_scope.yaml @ 285a9f1d (CVC-236 v2, restructured 2026-08-14, amended 2026-09-29; read from origin/main; structural columns cross-checked against htilabstech/prototype/Final CVCs/System Roles, Permissions, & Account Management (IC-66)/core-information_scope — codebook.csv @ 285a9f1d)",
7
7
  "levels": {
8
8
  "0": "Unknown or Missing",
9
9
  "1": "Category (policy grain, not selectable)",
@@ -470,9 +470,10 @@
470
470
  "parentCode": null,
471
471
  "childCodes": [
472
472
  "236-003-001-000-000-000-000",
473
- "236-003-002-000-000-000-000"
473
+ "236-003-002-000-000-000-000",
474
+ "236-003-003-000-000-000-000"
474
475
  ],
475
- "definition": "Contact & safety — policy-grain category. Units under it are the authorization grain. NARROWED 2026-08-14 (restructure ruling 2): contact/service history moved to the NEW services category. SUPERSEDES the 2026-08-13 deliberate-merge note; legacy `contact` grants resolve via the alias layer (CVC-69 precedent). LEADS flag dropped (no LEADS units — was an empty shell).",
476
+ "definition": "Contact & safety — policy-grain category. Units under it are the authorization grain. NARROWED 2026-08-14 (restructure ruling 2): contact/service history moved to the NEW services category. SUPERSEDES the 2026-08-13 deliberate-merge note; legacy `contact` grants resolve via the alias layer (CVC-69 precedent). LEADS flag dropped (no LEADS units — was an empty shell). | 2026-09-29 (PRIORITIES-SAFETY-SCOPE-UNIT, Crysta R1): third unit priorities_safety — the immediate-needs triage answers, one disclosure decision.",
476
477
  "levelFloor": 3,
477
478
  "appRelevance": [
478
479
  "PAVE",
@@ -514,6 +515,22 @@
514
515
  "specialDataType": "survivor_confidential",
515
516
  "platformFloor": true
516
517
  },
518
+ {
519
+ "code": "236-003-003-000-000-000-000",
520
+ "key": "priorities_safety",
521
+ "title": "Priorities & Safety (immediate needs triage)",
522
+ "selectable": true,
523
+ "parentCode": "236-003-000-000-000-000-000",
524
+ "childCodes": [],
525
+ "definition": "Priorities & Safety (immediate needs triage). Category `contact`. NEW 2026-09-29 (PRIORITIES-SAFETY-SCOPE-UNIT, Crysta R1): the completed Immediate Priorities / Priorities & Safety triage, authorized as ONE disclosure decision — Q1 immediate danger + source of the danger + harm-doer nearby + safe place to go · Q2 health needs · Q3 interpreter · Q4 urgent basic needs · Q5 transportation (method / time / pickup location) · Q6 emergency shelter · Q7 dependents at risk · Q8 other. Instrument-grain unit on the initial_screen / lap precedent (ruling 1, 2026-08-13), homed under Contact & safety because the answers that had no home are safety facts; the service instances the step derives ride services/service_history on their own. Bidirectional Thread Signal ↔ PAVE mirror on Q1 (GDR § 6.9.7) — one unit, both apps. domain_map: priorities_safety → this unit (R3 EXECUTED later the same day, PRIORITIES-SAFETY-RECORD): CVC-159 domain priorities_safety (Level 1) + monolith emitter emitPrioritiesAnswerCAR (one CAR per answered question) + UDD row capture.priorities_safety; production persistence of the answers stays with Nate under RWT-NEW-priorities-safety-record-and-udd-2026-09-29. Minted in the Notion codebook the same day; codebook row re-synced to the record 2026-09-29.",
526
+ "levelFloor": 3,
527
+ "appRelevance": [
528
+ "PAVE",
529
+ "Thread"
530
+ ],
531
+ "shareableDefault": true,
532
+ "specialDataType": "survivor_confidential"
533
+ },
517
534
  {
518
535
  "code": "236-004-000-000-000-000-000",
519
536
  "key": "services",
package/src/cvcs/index.ts CHANGED
@@ -46,6 +46,9 @@ import preferredContactMethodSot from "./preferredContactMethod.v1.0.0.json" wit
46
46
  import sharePurposeSot from "./sharePurpose.v1.0.0.json" with { type: "json" };
47
47
  import referralOriginSot from "./referralOrigin.v1.0.0.json" with { type: "json" };
48
48
  import caseShareStateSot from "./caseShareState.v1.0.0.json" with { type: "json" };
49
+ // CVC-306 — structured reasons for responding to an inbound case share. Generated
50
+ // from prototype canon by scripts/gen-share-response-reason.py; re-run, don't hand-edit.
51
+ import shareResponseReasonSot from "./shareResponseReason.v1.0.0.json" with { type: "json" };
49
52
  import facilitatorEntityTypeSot from "./facilitatorEntityType.v1.0.0.json" with { type: "json" };
50
53
  import facilitatorSubroleSot from "./facilitatorSubrole.v1.0.0.json" with { type: "json" };
51
54
  import maritalStatusLegalSot from "./maritalStatusLegal.v1.0.0.json" with { type: "json" };
@@ -243,6 +246,7 @@ export {
243
246
  sharePurposeSot,
244
247
  referralOriginSot,
245
248
  caseShareStateSot,
249
+ shareResponseReasonSot,
246
250
  facilitatorEntityTypeSot,
247
251
  facilitatorSubroleSot,
248
252
  maritalStatusLegalSot,