@htilabs/platform-common-models 0.24.0 → 0.25.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/README.md +65 -0
- package/dist/{index-Dr6GBCoY.d.ts → index-ClTjjJ_S.d.ts} +1 -1
- package/dist/{index-BTqHP4DM.d.cts → index-Pt82NxQg.d.cts} +1 -1
- package/dist/index.cjs +457 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +437 -2
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.d.cts +3 -350
- package/dist/information-scope/index.d.ts +3 -350
- package/dist/informationScopeResolver-BzYu97DE.d.cts +351 -0
- package/dist/informationScopeResolver-BzYu97DE.d.ts +351 -0
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/dist/services/index.d.cts +2 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/sharing-ceiling/index.cjs +497 -0
- package/dist/sharing-ceiling/index.cjs.map +1 -0
- package/dist/sharing-ceiling/index.d.cts +318 -0
- package/dist/sharing-ceiling/index.d.ts +318 -0
- package/dist/sharing-ceiling/index.js +451 -0
- package/dist/sharing-ceiling/index.js.map +1 -0
- package/package.json +7 -1
- package/src/__sot__/README.md +1 -0
- package/src/__sot__/sharingStarter.pin.json +229 -0
- package/src/__tests__/sharing-starter-canon.test.ts +178 -0
- package/src/generated/sharingPlatformStarter.ts +165 -0
- package/src/index.ts +5 -0
- package/src/sharingCeiling/__tests__/sharingCeiling.test.ts +678 -0
- package/src/sharingCeiling/chain.ts +269 -0
- package/src/sharingCeiling/coverage.ts +346 -0
- package/src/sharingCeiling/index.ts +14 -0
- package/src/sharingCeiling/starter.ts +89 -0
- package/dist/{cvcEntry-BqAGctqK.d.cts → cvcEntry-Asg7mxjB.d.cts} +8 -8
- package/dist/{cvcEntry-BqAGctqK.d.ts → cvcEntry-Asg7mxjB.d.ts} +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/sharingPlatformStarter.ts","../../src/sharingCeiling/starter.ts","../../src/sharingCeiling/chain.ts","../../src/services/informationScopeResolver.ts","../../src/sharingCeiling/coverage.ts"],"sourcesContent":["/**\n * @htilabs/platform-common-models — the platform sharing starter (co-2sx)\n *\n * AUTO-GENERATED FILE — DO NOT EDIT BY HAND.\n * Regenerate with:\n * `python3 scripts/gen-sharing-starter.py <prototype root> <platform-prototype root>`.\n *\n * Canon (read from git objects at origin/main):\n * - htilabstech/prototype HTI-LEADS-PAVE-Thread-prototype.html @ d85f05b7\n * `HTI_SHARE_PLATFORM_STARTER` L326475-L326543\n * (scopeVersion · scopeByPurpose · counterpartyOverrides);\n * - htilabstech/platform-prototype src/data.js @ a6f1f3a5 (the contract of\n * record, GDR § 5.79): `data.sharing.scopeByPurpose` /\n * `counterpartyOverrides` L38170-L38190, and the\n * platform purpose rows `sharing.purposes[].enabled`\n * L32450-L32531;\n * - htilabstech/prototype docs/share-roi/information_scope_v4.fields.csv @ d85f05b7: the distinct\n * `row_v4` homes of its 517 fields (`fieldHomeRows`; the sentinel\n * \"rides with its record\" is not a row and is left out).\n * The two starter copies are equal (the generator refuses otherwise). GATE M\n * (`src/__tests__/sharing-starter-canon.test.ts`) holds this module equal to\n * `src/__sot__/sharingStarter.pin.json` and every code to a live, non-floor\n * CVC-236 v4 row.\n *\n * CANON GAP: `counterpartyOverrides` is keyed by canon's DEMONSTRATION partner\n * ids (palomar, okcpd, legal_aid_ok). No registry agency carries them, so the\n * seeded-partner rung binds on no real data until the platform maps them.\n */\n\n/** Where this data was taken from (provenance, not compared by `--check`). */\nexport const SHARING_PLATFORM_STARTER_SOURCE = {\n \"monolith\": {\n \"repo\": \"htilabstech/prototype\",\n \"file\": \"HTI-LEADS-PAVE-Thread-prototype.html\",\n \"sha\": \"d85f05b7\",\n \"lines\": [\n 326475,\n 326543\n ]\n },\n \"mirror\": {\n \"repo\": \"htilabstech/platform-prototype\",\n \"file\": \"src/data.js\",\n \"sha\": \"a6f1f3a5\",\n \"starterLines\": [\n 38170,\n 38190\n ],\n \"purposeLines\": [\n 32450,\n 32531\n ]\n },\n \"fieldPlacements\": {\n \"repo\": \"htilabstech/prototype\",\n \"file\": \"docs/share-roi/information_scope_v4.fields.csv\",\n \"sha\": \"d85f05b7\"\n }\n} as const;\n\n// <generated-data>\nexport const SHARING_PLATFORM_STARTER_DATA = {\n scopeVersion: 4,\n scopeByPurpose: {\n \"referral\": [\"identifying\", \"contact\", \"services\", \"system\", \"summary_needs_assessment\"],\n \"case_collaboration\": [\"identifying\", \"risk\", \"contact\", \"services\", \"notes\", \"system\", \"summary_initial_screen\", \"summary_lap\", \"summary_danger_assessment\", \"summary_stalking_assessment\", \"summary_injury_and_strangulation\", \"summary_ae_intake\", \"summary_tra\", \"summary_needs_assessment\"],\n \"deconfliction\": [\"identifying\", \"system\"],\n \"mandatory_reporting\": [\"identifying\", \"risk\", \"contact\", \"services\", \"notes\", \"system\", \"summary_initial_screen\", \"summary_lap\", \"summary_danger_assessment\", \"summary_stalking_assessment\", \"summary_injury_and_strangulation\", \"summary_ae_intake\", \"summary_tra\", \"summary_needs_assessment\", \"offenders.identifying\", \"offenders.risk\", \"relationships_household\", \"family\"],\n \"discretionary_share\": [\"identifying\", \"system\"],\n \"authority_reporting\": [\"identifying\", \"risk\", \"system\", \"summary_initial_screen\", \"summary_lap\", \"summary_danger_assessment\", \"summary_stalking_assessment\", \"summary_injury_and_strangulation\", \"summary_ae_intake\", \"summary_tra\", \"offenders.identifying\", \"offenders.risk\", \"relationships_household\", \"family\"],\n \"automatic_account_share\": [\"identifying\", \"system\"],\n \"records_request\": [\"identifying\", \"system\"],\n },\n counterpartyOverrides: {\n \"palomar\": {\n \"case_collaboration\": [\"identifying\", \"risk\", \"contact\", \"services\", \"notes\", \"health_accommodation\", \"system\", \"summary_initial_screen\", \"summary_lap\", \"summary_danger_assessment\", \"summary_stalking_assessment\", \"summary_injury_and_strangulation\", \"summary_ae_intake\", \"summary_tra\", \"summary_mental_health_screen\", \"summary_behavioral_health_intake\", \"summary_trauma_and_coping_screen\", \"summary_needs_assessment\"],\n },\n \"okcpd\": {\n \"mandatory_reporting\": [\"identifying\", \"risk\", \"contact\", \"services\", \"notes\", \"system\", \"summary_initial_screen\", \"summary_lap\", \"summary_danger_assessment\", \"summary_stalking_assessment\", \"summary_injury_and_strangulation\", \"summary_ae_intake\", \"summary_tra\", \"summary_needs_assessment\", \"offenders.identifying\", \"offenders.risk\", \"relationships_household\", \"family\"],\n \"referral\": [\"identifying\", \"contact\", \"services\", \"system\", \"summary_needs_assessment\"],\n },\n \"legal_aid_ok\": {\n \"referral\": [\"identifying\", \"contact\", \"services\", \"notes\", \"system\", \"summary_needs_assessment\"],\n },\n },\n purposeEnabled: {\n \"referral\": true,\n \"case_collaboration\": true,\n \"deconfliction\": true,\n \"mandatory_reporting\": true,\n \"discretionary_share\": true,\n \"authority_reporting\": true,\n \"automatic_account_share\": true,\n \"records_request\": false,\n },\n fieldHomeRows: [\n \"accommodation_needs\",\n \"ad_content\",\n \"additional_ids\",\n \"addresses\",\n \"case_attachments\",\n \"case_determinations\",\n \"case_lifecycle\",\n \"case_notes\",\n \"commercial_activity\",\n \"contact_info\",\n \"demographics\",\n \"derived_risk_signals\",\n \"dob\",\n \"encounter_location\",\n \"family.health_accommodation\",\n \"family.identifying\",\n \"family.risk\",\n \"full_ae_intake\",\n \"full_behavioral_health_intake\",\n \"full_danger_assessment\",\n \"full_findings\",\n \"full_hope_scale\",\n \"full_ida\",\n \"full_initial_screen\",\n \"full_injury_and_strangulation\",\n \"full_lap\",\n \"full_mental_health_screen\",\n \"full_needs_assessment\",\n \"full_stalking_assessment\",\n \"full_tra\",\n \"full_trauma_and_coping_screen\",\n \"health_status\",\n \"identifying\",\n \"immigration_applications\",\n \"immigration_status\",\n \"instruments\",\n \"names\",\n \"network_membership\",\n \"object_identity_attributes\",\n \"offenders.risk\",\n \"others.risk\",\n \"persona_links\",\n \"phone_identifiers\",\n \"plans_goals\",\n \"priorities_safety\",\n \"relationships_household\",\n \"screen_indicators\",\n \"service_history\",\n \"session_summary\",\n \"summary_ae_intake\",\n \"summary_behavioral_health_intake\",\n \"summary_danger_assessment\",\n \"summary_findings\",\n \"summary_hope_scale\",\n \"summary_ida\",\n \"summary_initial_screen\",\n \"summary_injury_and_strangulation\",\n \"summary_lap\",\n \"summary_mental_health_screen\",\n \"summary_needs_assessment\",\n \"summary_stalking_assessment\",\n \"summary_tra\",\n \"summary_trauma_and_coping_screen\",\n \"system\",\n \"system_involvement\",\n \"victimization\",\n ],\n} as const;\n// </generated-data>\n","/**\n * The platform sharing starter — what governs a share before an account has\n * authored anything (co-2sx).\n *\n * The data is GENERATED from canon (`scripts/gen-sharing-starter.py` →\n * `src/generated/sharingPlatformStarter.ts`) and held equal to canon by GATE M\n * (`src/__tests__/sharing-starter-canon.test.ts`, against\n * `src/__sot__/sharingStarter.pin.json`). This module types it and freezes it.\n *\n * Canon: prototype `HTI-LEADS-PAVE-Thread-prototype.html` @ d85f05b7\n * `HTI_SHARE_PLATFORM_STARTER` L326475-L326543 (scopeVersion ·\n * scopeByPurpose · counterpartyOverrides); platform-prototype `src/data.js`\n * @ a6f1f3a `data.sharing.scopeByPurpose` / `counterpartyOverrides`\n * L38170-L38190 (the contract of record, GDR § 5.79) and the platform\n * purpose rows `sharing.purposes[].enabled` L32450-L32531 (`records_request`\n * ships `enabled: false`, L32527); prototype\n * `docs/share-roi/information_scope_v4.fields.csv` @ d85f05b7 (where each\n * field is homed, `row_v4`).\n */\n\nimport {\n SHARING_PLATFORM_STARTER_DATA,\n SHARING_PLATFORM_STARTER_SOURCE,\n} from \"../generated/sharingPlatformStarter.js\";\n\n/** The tree version every starter list and every stored ceiling list is stamped with. */\nexport const SHARING_CEILING_SCOPE_VERSION = 4 as const;\n\n/** purpose code (CVC-84 key) → v4 information-scope row codes. */\nexport type SharingPurposeLists = Readonly<Record<string, readonly string[]>>;\n\nexport interface SharingPlatformStarter {\n readonly scopeVersion: typeof SHARING_CEILING_SCOPE_VERSION;\n /** The platform per-purpose default — canon's last rung. A purpose with no row has no platform ceiling. */\n readonly scopeByPurpose: SharingPurposeLists;\n /** Platform-seeded partner rules: partner id → purpose → v4 row codes. */\n readonly counterpartyOverrides: Readonly<Record<string, SharingPurposeLists>>;\n}\n\nfunction freezeLists(lists: Readonly<Record<string, readonly string[]>>): SharingPurposeLists {\n const out: Record<string, readonly string[]> = {};\n for (const [purpose, codes] of Object.entries(lists)) out[purpose] = Object.freeze([...codes]);\n return Object.freeze(out);\n}\n\n/**\n * The platform's own sharing rules (canon's `HTI_SHARE_PLATFORM_STARTER`,\n * minus the demo-agency relationship / policy seeds). Deep-frozen.\n *\n * CANON GAP: `counterpartyOverrides` is keyed by canon's DEMONSTRATION partner\n * ids (`palomar`, `okcpd`, `legal_aid_ok`). No registry agency carries them,\n * so the seeded-partner rung binds on no real data until the platform maps\n * them. They ship as canon has them.\n */\nexport const HTI_SHARE_PLATFORM_STARTER: SharingPlatformStarter = Object.freeze({\n scopeVersion: SHARING_CEILING_SCOPE_VERSION,\n scopeByPurpose: freezeLists(SHARING_PLATFORM_STARTER_DATA.scopeByPurpose),\n counterpartyOverrides: Object.freeze(\n Object.fromEntries(\n Object.entries(SHARING_PLATFORM_STARTER_DATA.counterpartyOverrides).map(([cp, lists]) => [\n cp,\n freezeLists(lists),\n ]),\n ),\n ),\n});\n\n/**\n * The platform purpose rows' `enabled` flag (data.js `sharing.purposes`). The\n * contract of record disables a purpose whose platform row is `enabled:\n * false` unless the account overrides it `true` (data.js clamp 1,\n * L51352-L51354). `records_request` ships disabled.\n */\nexport const HTI_SHARE_PLATFORM_PURPOSE_ENABLED: Readonly<Record<string, boolean>> = Object.freeze({\n ...SHARING_PLATFORM_STARTER_DATA.purposeEnabled,\n});\n\n/**\n * The v4 rows at least one field is HOMED on (canon's field placements,\n * `information_scope_v4.fields.csv` `row_v4`). The ceiling coverage rule\n * reads it: a row with fields homed directly on it and no rest row is within\n * a ceiling only when it or an ancestor is listed.\n */\nexport const INFORMATION_SCOPE_FIELD_HOME_ROWS: ReadonlySet<string> = new Set(\n SHARING_PLATFORM_STARTER_DATA.fieldHomeRows,\n);\n\n/** Where the starter data was taken from (canon repo, file, SHA, line ranges). */\nexport const HTI_SHARE_PLATFORM_STARTER_SOURCE = SHARING_PLATFORM_STARTER_SOURCE;\n","/**\n * The Inter-Agency Sharing ceiling read chain (co-2sx): the account's stored\n * ceiling CELLS folded into canon's `sharingScopeEdits`, and the ONE chain\n * that turns them, the platform starter and the purpose switches into the\n * list a share for one recipient × purpose may carry.\n *\n * Pure, total on stored data, no I/O. Throws only on a caller's programming\n * error (a missing / reserved row key, a missing purpose).\n *\n * Canon — prototype `HTI-LEADS-PAVE-Thread-prototype.html` @ d85f05b7:\n * - `shareEffectiveCeiling` L327966-L328090; the per-purpose rung\n * L328040-L328082, the chain itself L328053-L328058:\n *\n * const rowKey = r.__external ? \"__external__\" : r.id;\n * const per = edits[rowKey] && edits[rowKey][opts.purposeCode];\n * const seeded = (starter.counterpartyOverrides[rowKey] || {})[opts.purposeCode];\n * const def = edits.__default__ && edits.__default__[opts.purposeCode];\n * const platformDefault = starter.scopeByPurpose[opts.purposeCode];\n * const allowed = per || seeded || def || platformDefault || null;\n *\n * - the purpose switch L327999-L328005 (an explicit `false` only).\n * Platform prototype `src/data.js` @ a6f1f3a — the contract of record\n * (GDR § 5.79), `HTI_SHARE_POLICY_API.effectiveCeiling` L51324ff:\n * - clamp 1 L51352-L51354: a purpose is off when the account switched it\n * off, OR when its platform row is `enabled: false` and the account has\n * not switched it on (`records_request`, L32527). This module follows the\n * contract of record; the monolith reads only the explicit `false`.\n * - clamp 5 L51516-L51525: the same chain as the monolith.\n * - `EXTERNAL_RECIPIENT_KEY = \"__external__\"` L50434: an off-platform\n * recipient resolves through the same chain under that key, so an\n * un-authored off-platform purpose follows the account default, then the\n * platform default (L50427-L50430).\n *\n * One JavaScript detail of canon's `||` chain is kept: an EMPTY authored\n * list is truthy, so it BINDS (it lets nothing but System metadata leave).\n *\n * STRICTER THAN CANON (ruling, co-2sx review): a purpose with no rung at all\n * fails CLOSED — `allowed: []`, rung `none` — where canon's `|| null` reads\n * no ceiling (`if (allowed && …)`, L328059). Every one of the eight core\n * CVC-84 purposes has a platform row, so `none` can only come from a caller\n * error (a misspelled purpose, a LEADS-wing purpose on a core share, a\n * replaced starter missing a row); an unknown purpose must never mean\n * \"anything may leave\".\n */\n\nimport {\n HTI_SHARE_PLATFORM_PURPOSE_ENABLED,\n HTI_SHARE_PLATFORM_STARTER,\n SHARING_CEILING_SCOPE_VERSION,\n type SharingPlatformStarter,\n} from \"./starter.js\";\n\n/** The account default row key — canon `sharingScopeEdits.__default__` (L328056; data.js L51519). */\nexport const SHARING_CEILING_DEFAULT_ROW_KEY = \"__default__\" as const;\n\n/** The off-platform / unspecified recipients row key (canon L328053; data.js `EXTERNAL_RECIPIENT_KEY`, L50434). */\nexport const SHARING_CEILING_EXTERNAL_ROW_KEY = \"__external__\" as const;\n\n/** rowKey (partner id · `__default__` · `__external__`) → purpose → v4 row codes. */\nexport type SharingScopeEdits = Readonly<\n Record<string, Readonly<Record<string, readonly string[]>>>\n>;\n\n/** The fields of one stored ceiling cell this read looks at (cells keyed agencyId × rowKey × purpose). */\nexport interface SharingCeilingCellLike {\n readonly rowKey?: unknown;\n readonly purpose?: unknown;\n readonly scopeVersion?: unknown;\n readonly informationScope?: unknown;\n}\n\nconst own = <V>(record: unknown, key: string): V | undefined =>\n record !== null &&\n typeof record === \"object\" &&\n Object.prototype.hasOwnProperty.call(record, key)\n ? ((record as Record<string, V>)[key] as V)\n : undefined;\n\nconst isStringList = (v: unknown): v is readonly string[] =>\n Array.isArray(v) && v.every((c) => typeof c === \"string\");\n\n/**\n * The list one PRESENT cell carries. A cell is a rule by being there: stamped\n * 4 with an array of strings → that list (a copy); anything else (unstamped,\n * a v3 stamp, a missing list, a non-array, a non-string entry) → `[]`, which\n * binds and covers nothing. A malformed rule never widens a share by falling\n * through to a broader rung.\n */\nexport function sharingCeilingCellList(cell: SharingCeilingCellLike): string[] {\n if (cell.scopeVersion === SHARING_CEILING_SCOPE_VERSION && isStringList(cell.informationScope)) {\n return [...cell.informationScope];\n }\n return [];\n}\n\nconst sameSet = (a: readonly string[], b: readonly string[]): boolean => {\n const sa = new Set(a);\n const sb = new Set(b);\n return sa.size === sb.size && [...sa].every((c) => sb.has(c));\n};\n\n/**\n * Fold ONE sending account's ceiling cells into canon's `sharingScopeEdits`.\n *\n * - A cell is present or absent; there is no status. An ABSENT cell is no\n * rule, and the chain falls through.\n * - A present cell binds with {@link sharingCeilingCellList}: `[]` binds; an\n * unstamped, v3-stamped or malformed list reads as `[]`.\n * - A cell without a string `rowKey` and `purpose` cannot be attributed to a\n * cell and is skipped (it is not a rule for any cell).\n * - Two cells for the same (rowKey, purpose) — the store's key forbids it —\n * keep the list when they agree as sets, else read `[]` (fail closed).\n *\n * The caller passes one account's cells; the fold does not filter by agency.\n */\nexport function sharingScopeEditsFromCells(\n cells: Iterable<SharingCeilingCellLike | null | undefined> | null | undefined,\n): SharingScopeEdits {\n const byRow = new Map<string, Map<string, string[]>>();\n if (cells === null || cells === undefined || typeof (cells as Iterable<unknown>)[Symbol.iterator] !== \"function\") {\n return {};\n }\n for (const cell of cells) {\n if (cell === null || typeof cell !== \"object\") continue;\n const { rowKey, purpose } = cell;\n if (typeof rowKey !== \"string\" || rowKey === \"\" || typeof purpose !== \"string\" || purpose === \"\") continue;\n const list = sharingCeilingCellList(cell);\n const row = byRow.get(rowKey) ?? new Map<string, string[]>();\n const prior = row.get(purpose);\n row.set(purpose, prior === undefined || sameSet(prior, list) ? list : []);\n byRow.set(rowKey, row);\n }\n // Object.fromEntries defines OWN properties, so a row key such as\n // `__proto__` is a key, never the prototype.\n return Object.fromEntries([...byRow].map(([k, row]) => [k, Object.fromEntries(row)]));\n}\n\n/** Which rung of the chain answered. */\nexport type SharingCeilingRung =\n | \"purpose_disabled\"\n | \"partner_rule\"\n | \"seeded_partner_rule\"\n | \"account_default\"\n | \"platform_default\"\n | \"none\";\n\nexport interface EffectiveSharingCeiling {\n /**\n * The v4 row codes a share may carry (read with `scopeRowWithinCeiling`).\n * `[]` when the purpose is disabled, and when no rung exists for the\n * purpose (rung `none` — fails closed; see the module header).\n */\n readonly allowed: string[];\n readonly rung: SharingCeilingRung;\n /** The purpose is switched off for the account (`allowed` is then `[]`). */\n readonly disabled: boolean;\n}\n\nexport interface EffectiveSharingCeilingInputs {\n /** The sending account's authored lists ({@link sharingScopeEditsFromCells}). */\n readonly edits: SharingScopeEdits | null | undefined;\n /** Defaults to {@link HTI_SHARE_PLATFORM_STARTER}. */\n readonly starter?: SharingPlatformStarter;\n /** The account's Share Purposes switches: `false` disables, `true` re-enables a platform-disabled purpose. */\n readonly purposeOverrides?: Readonly<Record<string, boolean | undefined>> | null;\n /**\n * Platform purpose `enabled` flags, merged OVER\n * {@link HTI_SHARE_PLATFORM_PURPOSE_ENABLED} (a purpose the map does not\n * name keeps the platform row). `null` / `undefined` = the platform rows.\n */\n readonly purposeEnabled?: Readonly<Record<string, boolean | undefined>> | null;\n}\n\n/**\n * One rung's list as the chain reads it: absent (`undefined` / `null`) falls\n * through, a list of strings binds (copied), anything else binds as `[]`.\n */\nfunction rungList(value: unknown): string[] | undefined {\n if (value === undefined || value === null) return undefined;\n return isStringList(value) ? [...value] : [];\n}\n\n/**\n * Is `purpose` switched off? The contract of record (data.js clamp 1,\n * L51352-L51354): the account's explicit `false`, or a platform row\n * `enabled: false` the account has not overridden `true`. `purposeEnabled`\n * is merged over the platform rows (a purpose it does not name, or names\n * with a non-boolean, keeps the platform row); `null` = the platform rows.\n */\nexport function isSharingPurposeDisabled(\n purpose: string,\n purposeOverrides?: Readonly<Record<string, boolean | undefined>> | null,\n purposeEnabled?: Readonly<Record<string, boolean | undefined>> | null,\n): boolean {\n const override = own<unknown>(purposeOverrides, purpose);\n if (override === false) return true;\n const callerRow = own<unknown>(purposeEnabled, purpose);\n const enabled =\n typeof callerRow === \"boolean\"\n ? callerRow\n : own<unknown>(HTI_SHARE_PLATFORM_PURPOSE_ENABLED, purpose);\n return enabled === false && override !== true;\n}\n\n/**\n * The ceiling row key for one recipient: `__external__` for an off-platform\n * recipient, else its partner id (canon L328053). Throws on a non-external\n * recipient with no id, or whose id is a reserved row key.\n */\nexport function sharingCeilingRowKey(recipient: {\n readonly external?: boolean;\n readonly id?: string | null;\n}): string {\n if (recipient.external === true) return SHARING_CEILING_EXTERNAL_ROW_KEY;\n const id = recipient.id;\n if (typeof id !== \"string\" || id === \"\") {\n throw new TypeError(\"sharing ceiling: an on-platform recipient needs a partner id\");\n }\n if (id === SHARING_CEILING_DEFAULT_ROW_KEY || id === SHARING_CEILING_EXTERNAL_ROW_KEY) {\n throw new RangeError(`sharing ceiling: \"${id}\" is a reserved row key, not a partner id`);\n }\n return id;\n}\n\n/**\n * The ceiling for one recipient row and one purpose, by canon's chain:\n *\n * purpose disabled (clamp 1) → [] (purpose_disabled)\n * edits[rowKey][purpose] (partner_rule)\n * || starter.counterpartyOverrides[rowKey][purpose] (seeded_partner_rule)\n * || edits.__default__[purpose] (account_default)\n * || starter.scopeByPurpose[purpose] (platform_default)\n * || [] (none — fails closed)\n *\n * `rowKey` is a partner id or `__external__` ({@link sharingCeilingRowKey});\n * `__default__` is refused (it is the account default, not a recipient).\n */\nexport function effectiveCeiling(\n rowKey: string,\n purpose: string,\n inputs: EffectiveSharingCeilingInputs,\n): EffectiveSharingCeiling {\n if (typeof rowKey !== \"string\" || rowKey === \"\") {\n throw new TypeError(\"sharing ceiling: rowKey must be a partner id or __external__\");\n }\n if (rowKey === SHARING_CEILING_DEFAULT_ROW_KEY) {\n throw new RangeError(\"sharing ceiling: __default__ is the account default, not a recipient row key\");\n }\n if (typeof purpose !== \"string\" || purpose === \"\") {\n throw new TypeError(\"sharing ceiling: purpose must be a share purpose code\");\n }\n const starter = inputs.starter ?? HTI_SHARE_PLATFORM_STARTER;\n if (isSharingPurposeDisabled(purpose, inputs.purposeOverrides, inputs.purposeEnabled)) {\n return { allowed: [], rung: \"purpose_disabled\", disabled: true };\n }\n const edits = inputs.edits;\n const rungs: readonly [SharingCeilingRung, unknown][] = [\n [\"partner_rule\", own(own(edits, rowKey), purpose)],\n [\"seeded_partner_rule\", own(own(starter.counterpartyOverrides, rowKey), purpose)],\n [\"account_default\", own(own(edits, SHARING_CEILING_DEFAULT_ROW_KEY), purpose)],\n [\"platform_default\", own(starter.scopeByPurpose, purpose)],\n ];\n for (const [rung, value] of rungs) {\n const allowed = rungList(value);\n if (allowed !== undefined) return { allowed, rung, disabled: false };\n }\n // Stricter than canon's `|| null` (module header): fail closed.\n return { allowed: [], rung: \"none\", disabled: false };\n}\n","/**\n * @htilabs/platform-common-models — Information scope resolver (CVC-236 v4)\n *\n * The ONE implementation of how a stored information-scope selection reads\n * against the v4 tree, so Thread and PAVE (preview and send, picker and door)\n * cannot disagree. Pure and dependency-free: no imports, no I/O, never\n * mutates its inputs. Browser-safe entry: `@htilabs/platform-common-models/information-scope`.\n *\n * Spec (canon, read-only): htilabstech/prototype\n * docs/share-roi/INFOSCOPE_V4_DEV_HANDOFF_2026-10-09.md\n * @ 7ca7e586ae487c608da657d426598a65d5b06111 (merge of the SIGNED-GRAIN\n * content commit e86dd89cdba5cbb39ccfc7fb35aff8cbf0774790, which amends\n * § 3 only and re-labels the migrations CSV; § 2, § 7, § 8 and the rows CSV\n * are unchanged from 6dab8a95 / 00179edc)\n * - § 2 rules 1–7 (\"the resolver contract — build exactly this, nothing\n * cleverer\") — every behaviour below cites its rule;\n * - § 3 the migration rules (identity · row · category · subtract ·\n * retired before v4) and `scopeVersion`; a signed release keeps its list\n * as signed and its current reading is DERIVED at read time; a retired\n * code \"stays recognisable in stored data forever\";\n * - § 7 row 6 a branch-grain pick is expanded to the ceiling's grain\n * before clamping; a sender can never widen;\n * - § 8 the enums.\n * Release grain (Crysta, 2026-10-09; SOT v2.1.0 `migrations.ruling`, quoted\n * verbatim there): \"a SIGNED RELEASE keeps the grain it was signed at ...\n * Policies and presets (agency-authored, not consent) take the merged\n * successor with a dated version row.\" Canon carries it since SIGNED-GRAIN\n * (prototype e86dd89c: `signed_release_grain: keep` on the nine `rows` merge\n * folds; handoff § 3 amended). So `readSelection` takes WHOSE list it is\n * (`subject`): a release or a share (frozen at send, § 3) naming a code on a\n * `releaseReading: \"retain\"` line at scopeVersion 3 is NOT mapped — the code\n * comes back under `retained` with its v3 field membership, for the builder\n * to deliver read-only; a policy takes the successor (`widened`) and the\n * reading says a dated version row is due. The widening identity line canon\n * leaves unmarked (`immigration_status`, `releaseReading: \"successor\"`) reads\n * as itself for every subject.\n * Reference implementation of rule-1 kind-row resolution:\n * tools/infoscope/phase4_stress_test.py `resolve_home` (same SHA).\n *\n * WHAT A SELECTION STORES. `information_scope: string[]` holds canon's scope\n * codes as canon spells them — `names`, `identifying.other`,\n * `offenders.risk` (handoff § 8: \"lowercase snake, or `<kind>.<row>`\") —\n * NOT the package's SOT keys (`offenders__risk`) and NOT seven-segment wire\n * codes (`236-016-001-002-…`). `ScopeRow.scopeCode` / `parentScopeCode` are\n * in that space; `scopeRowsFromSot` maps the SOT into it.\n *\n * ALWAYS COVERED. `system_info` and its ancestor `system` (\"System metadata —\n * always included, never a choice\", handoff § 1; the field placements home\n * the system fields on `system`) are covered by every selection.\n *\n * Two kinds of call:\n * - READS (`isCovered`, `isIncludedOnShare`, `shareVerdict`,\n * `isVisibleAtLevel`, `readSelection`, `readRestriction`,\n * `expandBranchPickToGrain`, `clampToCeiling`) are total: they never\n * throw on stored data. An unknown code, a null list or an unsupported\n * `scopeVersion` (absent, 2, or anything but 3 / 4) includes nothing\n * (fail closed). `readSelection`'s `subject` is the caller's, not stored\n * data: a missing or unknown one throws (no silent default).\n * - PICKER WRITES (`selectAll`, `deselectChild`, `expandSelectAll`), the\n * build-time `rowForSubject`, and the constructor throw on programming\n * errors (an unknown or non-selectable code, a malformed tree).\n */\n\n// ─── Constants ───────────────────────────────────────────────────────────────\n\n/** The tree version this resolver reads to (handoff § 3: \"today 3, after this round 4\"). */\nexport const INFORMATION_SCOPE_VERSION = 4 as const;\n\n/**\n * The `scopeVersion` stamps a stored list may carry and still be read: 3\n * (through the v3 → v4 table) and 4. A 2 list, and an UNSTAMPED list (which\n * is v2-era), must go through canon's conjunctive v2 → v3 table first (SOT\n * v2.1.0 `migrations.readAt` / `migrations.unstamped`: the `retired before\n * v4` lines name \"the flattened v3 reading, not an unconditional one\"); this\n * package ships no v2 → v3 table, so those lists are unsupported and include\n * nothing (fail closed). None was ever persisted (`migrations.unstamped`).\n */\nexport const INFORMATION_SCOPE_READABLE_VERSIONS: readonly number[] = Object.freeze([3, 4]);\n\n/** Required on every stored selection and always included (handoff § 2 rule 1; § 6). */\nexport const INFORMATION_SCOPE_SYSTEM_INFO = \"system_info\" as const;\n\n// ─── Row and migration input shapes ─────────────────────────────────────────\n\n/** A kind of other named person (handoff § 1; § 8 `kind_branch`). */\nexport type ScopePersonKind = \"offenders\" | \"family\" | \"others\";\n\n/** Whose record a record is: the client, or another named person's kind (rule 1). */\nexport type ScopeSubjectKind = \"client\" | ScopePersonKind;\n\n/** `kind_branch` (§ 8); `null` on System and Notes rows (blank in the CSV). */\nexport type ScopeKindBranch = ScopeSubjectKind | \"leads\" | null;\n\n/**\n * `row_type` (§ 8). The tree also carries `branch` (`primary_client`,\n * `other_named_persons`) and the LEADS spelling `sub-category`, which § 8's\n * list omits; both are accepted as written.\n */\nexport type ScopeRowType =\n | \"branch\"\n | \"category\"\n | \"subcategory\"\n | \"sub-category\"\n | \"person_type\"\n | \"category_rest\"\n | \"instrument row\";\n\n/** `status` (§ 8). */\nexport type ScopeRowStatus = \"as_today\" | \"new\" | \"retired\";\n\n/** `special_data_type` (§ 8, plus `evidence`, which the tree carries on `case_attachments`). */\nexport type ScopeSpecialDataType =\n | \"none\"\n | \"survivor_confidential\"\n | \"criminal_intelligence\"\n | \"evidence\";\n\n/** The three app-relevance columns (§ 4). */\nexport type ScopeApp = \"pave\" | \"thread\" | \"leads\";\nexport type ScopeApps = Readonly<Record<ScopeApp, boolean>>;\n\n/**\n * One tree row, in the selection-code space (see header). Bind the SOT with\n * `scopeRowsFromSot`. Extra fields on a caller's row type are carried through\n * (`row(code)` returns the caller's row).\n */\nexport interface ScopeRow {\n /** The code a selection stores (canon's spelling: `offenders.risk`). */\n scopeCode: string;\n parentScopeCode: string | null;\n rowType: ScopeRowType;\n kindBranch: ScopeKindBranch;\n /** On a per-kind row (`offenders.risk`): the client row it copies (`risk`). Required there. */\n kindRow?: string;\n /** App relevance (§ 4). Informational: no resolver decision reads it. */\n apps: ScopeApps;\n selectable: boolean;\n /** `shareable_default = on` (rule 4: `false` = off by default). */\n shareableDefault: boolean;\n platformFloor: boolean;\n levelFloor: 1 | 3;\n specialDataType: ScopeSpecialDataType;\n /** A `retired` row is never covered, offered or written. */\n status: ScopeRowStatus;\n replacesV3?: readonly string[];\n}\n\n/** The four migration rules of handoff § 3, plus the pre-v4 retirement reading. */\nexport type ScopeMigrationRule = \"identity\" | \"row\" | \"category\" | \"subtract\" | \"retired before v4\";\n\n/** One from-to line (selection-code space); `to` is empty for \"(nothing)\". */\nexport interface ScopeMigration {\n from: string;\n to: readonly string[];\n rule: ScopeMigrationRule;\n note?: string;\n /** The line reads WIDER than v3 did (SOT `widens: true`). A policy takes it; see `releaseReading`. */\n widens?: boolean;\n /**\n * On every `widens` line (SOT; ruling 2026-10-09, canon SIGNED-GRAIN).\n * `retain` — canon's nine merge folds (`signed_release_grain: keep`): a\n * release or share at scopeVersion 3 keeps the code at its v3 grain instead\n * of reading `to`; requires exactly one `to` and `v3Fields` / `v3Domains`.\n * `successor` — a widening identity line canon leaves unmarked\n * (`immigration_status`): every subject reads `to` (`releaseReadingNote`).\n * Absent: `to` is every subject's reading.\n */\n releaseReading?: \"retain\" | \"successor\";\n /** Why a widening line is read as its successor by a release too. */\n releaseReadingNote?: string;\n /** `successor` (SOT, on every `widens` line): a policy or preset reads `to`. */\n policyReading?: \"successor\";\n /** A `retired before v4` line (ruling 2): a stated reading only a v2-era list can need. */\n informational?: boolean;\n /**\n * On a `retain` line: the fields whose v3 home was the `from` unit (canon\n * field placements `home_unit_today`) — what a retained release delivers,\n * read-only. Field ids (`capture.hiv_status`), not scope codes. Empty = the\n * unit homed no field, so a release retaining it delivers nothing.\n */\n v3Fields?: readonly string[];\n /**\n * On a `retain` line: the distinct `assertion_domain` of `v3Fields`. CATEGORY\n * grain in v3 (`access_accommodations`, `immigration_legal_status` each span\n * every unit of their category): the field family, NOT the unit's membership.\n * Deliver by `v3Fields`.\n */\n v3Domains?: readonly string[];\n /** On a `retain` line: why the membership is what it is (an empty unit; a derivation under veto). */\n v3FieldsNote?: string;\n}\n\n// ─── Output shapes ───────────────────────────────────────────────────────────\n\n/** How one stored code was read. `unknown` = no row, no table line: it includes nothing. */\nexport type ScopeReadingRule = ScopeMigrationRule | \"unknown\";\n\nexport interface ScopeCodeReading {\n readonly from: string;\n readonly rule: ScopeReadingRule;\n /** The v4 codes it reads as; empty for a retained code (see `ScopeReading.retained`). */\n readonly reads: readonly string[];\n /** It read through a line flagged as wider than v3 (never true for a retained code). */\n readonly widens: boolean;\n /** A release or share kept it at its v3 grain (`releaseReading: \"retain\"`). */\n readonly retained: boolean;\n}\n\n/**\n * Whose stored list is being read (handoff § 3; ruling 2026-10-09):\n * - `release` — a signed ROI / release;\n * - `share` — a share, which freezes the list it was sent with AND the\n * `scopeVersion` of the release it was composed under (handoff § 3: \"A\n * share freezes the list it was sent with ... and its version\"), so it\n * reads like a release: a share frozen under a v3 release is a stamp-3\n * list and retains;\n * - `policy` — everything agency-authored: a policy, a PRESET or a PARTNER\n * RULE (canon SIGNED-GRAIN: \"policies / presets / partner rules take the\n * successor whole\"), migrated with a dated version row.\n */\nexport type ScopeReadingSubject = \"release\" | \"share\" | \"policy\";\n\nexport interface ScopeReadOptions {\n subject: ScopeReadingSubject;\n}\n\n/**\n * A stored code a release or share keeps at the grain it was signed at\n * (ruling 2026-10-09): not mapped to `successor`, not in `informationScope`.\n * The builder delivers exactly `v3Fields`, read-only — never offered, never\n * widened, never narrowed — until the survivor re-signs on v4.\n *\n * Only a STAMP-3 list retains. A v4-stamped release or share can only hold\n * live v4 codes (the picker never offers a tombstone); if one nonetheless\n * names a code on a `retain` line, that code is recognised as retired and\n * includes NOTHING (fail closed) — never its successor, and not retained.\n */\nexport interface ScopeRetainedReading {\n readonly code: string;\n /** The fields the code delivered in v3 (field ids). Empty: it delivers nothing (`note`). */\n readonly v3Fields: readonly string[];\n /** Their assertion domains — CATEGORY grain in v3, the field family; deliver by `v3Fields`. */\n readonly v3Domains: readonly string[];\n /** What a policy reads it as, and what a v4 re-signature would name. */\n readonly successor: string;\n /** Present when the membership needs explaining (an empty unit; a derivation under veto). */\n readonly note?: string;\n}\n\n/**\n * The current (v4) reading of a stored list. `stored` and `storedVersion` are\n * the list as signed, copied, never rewritten (§ 3: \"a signed release keeps\n * its list as signed, at the version signed; its current reading is derived\n * through the table at read time\").\n */\nexport interface ScopeReading {\n /** The stamp as stored; `null` when it was absent or not a number. */\n readonly storedVersion: number | null;\n readonly stored: readonly string[];\n readonly version: typeof INFORMATION_SCOPE_VERSION;\n /** The stamp is not in `INFORMATION_SCOPE_READABLE_VERSIONS`: every code reads `unknown`. */\n readonly unsupportedVersion: boolean;\n /**\n * The derived v4 list: unique, in tree order. A selection reading always\n * contains `system_info`; a restriction reading contains only what it restricts.\n */\n readonly informationScope: readonly string[];\n /** One entry per distinct stored code, in stored order. */\n readonly codes: readonly ScopeCodeReading[];\n /** Stored codes that are retired (read by `row`, `subtract` or `retired before v4`). */\n readonly retired: readonly string[];\n /** Stored codes with no live row and no table line; they include nothing. */\n readonly unknown: readonly string[];\n /** Stored codes whose reading is wider than v3's (`widens`): surface, never hide. */\n readonly widened: readonly string[];\n /** `readSelection`'s subject; `null` on a restriction reading. */\n readonly subject: ScopeReadingSubject | null;\n /** Release / share codes kept at v3 grain, in stored order (always empty for a policy). */\n readonly retained: readonly ScopeRetainedReading[];\n /**\n * A policy read across versions (stamp 3) — `readSelection` with subject\n * `policy`, and every `readRestriction` (a restriction is a policy's):\n * handoff § 3 — \"a policy is migrated with a new version row on the record,\n * dated\" — so the app writes that dated row before acting on\n * `informationScope`. `false` otherwise.\n */\n readonly versionRowRequired: boolean;\n /** Says why, when `versionRowRequired`; otherwise `null`. */\n readonly note: string | null;\n}\n\nexport type ScopeShareVerdict =\n | { readonly included: true; readonly reason: \"included\" }\n | { readonly included: false; readonly reason: \"not_covered\" | \"platform_floor\" | \"unknown_code\" }\n | {\n readonly included: false;\n readonly reason: \"off_by_default\";\n /** The off-by-default rows in the chain the account has not enabled. */\n readonly notEnabled: readonly string[];\n };\n\nexport type ScopeShareReason = ScopeShareVerdict[\"reason\"];\n\nexport interface ScopeShareOptions {\n /** The off-by-default rows the account's policy has enabled for sharing (rule 4). */\n enabledOffByDefault?: ReadonlySet<string> | readonly string[];\n}\n\nexport interface CreateInformationScopeResolverInput<R extends ScopeRow> {\n rows: readonly R[];\n migrations?: readonly ScopeMigration[];\n}\n\n/** A stored list as it may arrive from storage (reads are total). */\nexport type StoredScopeList = readonly string[] | null | undefined;\n\nexport interface InformationScopeResolver<R extends ScopeRow = ScopeRow> {\n readonly version: typeof INFORMATION_SCOPE_VERSION;\n /** Every row in input order. */\n readonly rows: readonly R[];\n row(code: string): R | undefined;\n /** The live (non-retired) children of `code`, in input order (a copy). */\n childrenOf(code: string): string[];\n /** `code` first, then its parent, up to the root (a copy). Empty for an unknown code. */\n ancestorsOf(code: string): string[];\n\n /** Rules 2 + 3. */\n isCovered(selection: StoredScopeList, code: string): boolean;\n /** Rules 2–5. */\n isIncludedOnShare(selection: StoredScopeList, code: string, options?: ScopeShareOptions): boolean;\n /** `isIncludedOnShare` with the reason, for \"held back and counted\". */\n shareVerdict(\n selection: StoredScopeList,\n code: string,\n options?: ScopeShareOptions,\n ): ScopeShareVerdict;\n /** Rule 7 (the viewing side). */\n isVisibleAtLevel(level: number, code: string): boolean;\n\n /** Rules 3 + 6: the codes a picker writes when it expands `code` (its live children, rest row included). */\n expandSelectAll(code: string): string[];\n /** Rule 6: select-all at `code` (the code itself is stored; its now-redundant descendants drop). */\n selectAll(selection: readonly string[], code: string): string[];\n /** Rules 3 + 6: de-select one child; every selected ancestor is replaced by its other children. */\n deselectChild(selection: readonly string[], childCode: string): string[];\n\n /**\n * § 3: the current v4 reading of a stored selection, for its `subject`\n * (required; throws when missing or unknown). A release or share keeps a\n * `retain` code at its v3 grain (`retained`); a policy reads the successor.\n */\n readSelection(\n list: StoredScopeList,\n scopeVersion: number | null | undefined,\n options: ScopeReadOptions,\n ): ScopeReading;\n /**\n * § 3 `subtract`: the current v4 reading of a stored RESTRICTION. A\n * restriction is a policy's, so a stamp-3 one sets `versionRowRequired`.\n */\n readRestriction(list: StoredScopeList, scopeVersion: number | null | undefined): ScopeReading;\n\n /** Rule 1: the row a record is included under, given its field's home row and its subject. */\n rowForSubject(homeRow: string, kind: ScopeSubjectKind): string;\n\n /** § 7 row 6: expand every pick that sits above the ceiling's grain into its children. */\n expandBranchPickToGrain(selection: StoredScopeList, ceiling: StoredScopeList): string[];\n /** § 7 row 6: expand, then keep only what the ceiling covers. A sender can never widen. */\n clampToCeiling(selection: StoredScopeList, ceiling: StoredScopeList): string[];\n}\n\n// ─── Pure row guards ─────────────────────────────────────────────────────────\n\n/** A row a picker offers as a choice (§ 8 `selectable`; never a retired row). */\nexport const isSelectableScopeRow = (row: ScopeRow | undefined): boolean =>\n row !== undefined && row.selectable && row.status !== \"retired\";\n\n/** The `category_rest` row (rule 3): never offered, covered with its category. */\nexport const isScopeRestRow = (row: ScopeRow | undefined): boolean =>\n row !== undefined && row.rowType === \"category_rest\";\n\n/** One of the 28 `summary_<x>` / `full_<x>` rows (§ 8 `instrument row`). */\nexport const isScopeInstrumentRow = (row: ScopeRow | undefined): boolean =>\n row !== undefined && row.rowType === \"instrument row\";\n\n// ─── Person kind (rule 1, Phase 3 D5) ───────────────────────────────────────\n\n/**\n * Which kind of other named person someone is (handoff § 2 rule 1; § 8; Phase\n * 3 D5): \"This person caused harm\" wins; \"Eligible family member\" (asserted\n * by the advocate, never derived from the relationship) otherwise; neither →\n * `others`. A person with both switches is listed under `offenders`; the\n * caller keeps the family-member VAWA handling, which rides `efmAsserted` on\n * the person, not the kind.\n */\nexport function kindForPerson(person: {\n causedHarm: boolean;\n efmAsserted: boolean;\n}): ScopePersonKind {\n if (person.causedHarm) return \"offenders\";\n if (person.efmAsserted) return \"family\";\n return \"others\";\n}\n\n// ─── The resolver ────────────────────────────────────────────────────────────\n\nconst PERSON_KINDS: ReadonlySet<string> = new Set<ScopePersonKind>([\"offenders\", \"family\", \"others\"]);\nconst SPECIAL_DATA_TYPES: ReadonlySet<string> = new Set<ScopeSpecialDataType>([\n \"none\",\n \"survivor_confidential\",\n \"criminal_intelligence\",\n \"evidence\",\n]);\nconst MIGRATION_RULES: ReadonlySet<string> = new Set<ScopeMigrationRule>([\n \"identity\",\n \"row\",\n \"category\",\n \"subtract\",\n \"retired before v4\",\n]);\nconst RETIRED_RULES: ReadonlySet<ScopeReadingRule> = new Set<ScopeReadingRule>([\n \"row\",\n \"subtract\",\n \"retired before v4\",\n]);\n\n/** Reading precedence per code (§ 3): a stated category line, then identity, row, pre-v4. */\nconst SELECTION_PRECEDENCE: readonly ScopeMigrationRule[] = [\n \"category\",\n \"identity\",\n \"row\",\n \"retired before v4\",\n];\nconst RESTRICTION_PRECEDENCE: readonly ScopeMigrationRule[] = [\n \"subtract\",\n ...SELECTION_PRECEDENCE,\n];\n\nconst READING_SUBJECTS: ReadonlySet<string> = new Set<ScopeReadingSubject>([\n \"release\",\n \"share\",\n \"policy\",\n]);\n\n/** The `note` on a policy reading across versions (handoff § 3). */\nexport const INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE =\n \"Handoff § 3: a policy is migrated with a new version row on the record, dated, so a Member \" +\n \"Admin sees a change in history, not a silent rewrite. Write that row before acting on this \" +\n \"reading; the stored list itself is never rewritten.\";\n\nconst asList = (list: StoredScopeList): readonly string[] => (Array.isArray(list) ? list : []);\n\n/**\n * Bind the resolver to one tree (and its migration table). Throws on a\n * malformed tree: a duplicate code, a parent that is not a row, a cycle, no\n * `system_info` row, a live row whose `specialDataType` is missing or not in\n * § 8 (rule 1 routes on it — absence fails closed by refusing to bind), a\n * per-kind row without a `kindRow` that names a row, an unknown migration\n * rule, a migration successor that is not a live row, two different\n * readings for the same code and rule, or a `releaseReading: \"retain\"` line\n * without exactly one successor and its `v3Fields` / `v3Domains`.\n */\nexport function createInformationScopeResolver<R extends ScopeRow>(\n input: CreateInformationScopeResolverInput<R>,\n): InformationScopeResolver<R> {\n const rows = Object.freeze([...input.rows]);\n const byCode = new Map<string, R>();\n const order = new Map<string, number>();\n for (const r of rows) {\n if (byCode.has(r.scopeCode)) {\n throw new Error(`information scope: duplicate code \"${r.scopeCode}\"`);\n }\n byCode.set(r.scopeCode, r);\n order.set(r.scopeCode, order.size);\n }\n const isLive = (code: string): boolean => {\n const r = byCode.get(code);\n return r !== undefined && r.status !== \"retired\";\n };\n const children = new Map<string, string[]>();\n for (const r of rows) {\n if (r.status !== \"retired\" && !SPECIAL_DATA_TYPES.has(r.specialDataType)) {\n throw new Error(\n `information scope: \"${r.scopeCode}\" has specialDataType ${JSON.stringify(r.specialDataType)}`,\n );\n }\n if (r.parentScopeCode === null || r.parentScopeCode === \"\") continue;\n if (!byCode.has(r.parentScopeCode)) {\n throw new Error(\n `information scope: \"${r.scopeCode}\" names unknown parent \"${r.parentScopeCode}\"`,\n );\n }\n if (r.status === \"retired\") continue;\n const list = children.get(r.parentScopeCode) ?? [];\n list.push(r.scopeCode);\n children.set(r.parentScopeCode, list);\n }\n const ancestorCache = new Map<string, readonly string[]>();\n const ancestors = (code: string): readonly string[] => {\n const hit = ancestorCache.get(code);\n if (hit) return hit;\n const out: string[] = [];\n let cur: string | null = code;\n while (cur !== null && cur !== \"\") {\n const r = byCode.get(cur);\n if (!r) break;\n if (out.includes(cur)) throw new Error(`information scope: cycle at \"${cur}\"`);\n out.push(cur);\n cur = r.parentScopeCode;\n }\n ancestorCache.set(code, out);\n return out;\n };\n for (const r of rows) ancestors(r.scopeCode);\n if (!isLive(INFORMATION_SCOPE_SYSTEM_INFO)) {\n throw new Error(`information scope: the tree has no \"${INFORMATION_SCOPE_SYSTEM_INFO}\" row`);\n }\n /** `system_info` and its ancestors (`system`): covered by every selection. */\n const alwaysCovered: ReadonlySet<string> = new Set(ancestors(INFORMATION_SCOPE_SYSTEM_INFO));\n\n const kids = (code: string): readonly string[] => children.get(code) ?? [];\n const descendantsOf = (code: string): string[] => {\n const out: string[] = [];\n const stack = [...kids(code)];\n while (stack.length > 0) {\n const c = stack.pop() as string;\n out.push(c);\n stack.push(...kids(c));\n }\n return out;\n };\n const restRowOf = (code: string): string | undefined =>\n kids(code).find((c) => isScopeRestRow(byCode.get(c)));\n\n // Rule 1 kind rows, read off the tree: each kind's `person_type` root, and\n // each per-kind row by (kind, the client row it copies).\n const kindRoot = new Map<string, string>();\n const perKindRow = new Map<string, string>();\n for (const r of rows) {\n if (r.status === \"retired\" || r.kindBranch === null || !PERSON_KINDS.has(r.kindBranch)) continue;\n if (r.rowType === \"person_type\") {\n kindRoot.set(r.kindBranch, r.scopeCode);\n continue;\n }\n if (r.kindRow === undefined || !isLive(r.kindRow)) {\n throw new Error(\n `information scope: per-kind row \"${r.scopeCode}\" has no live kindRow (${String(r.kindRow)})`,\n );\n }\n perKindRow.set(`${r.kindBranch}\\u0000${r.kindRow}`, r.scopeCode);\n }\n\n // Migration table, indexed by code then rule.\n const migrations = new Map<string, Map<ScopeMigrationRule, ScopeMigration>>();\n for (const m of input.migrations ?? []) {\n if (!MIGRATION_RULES.has(m.rule)) {\n throw new Error(`information scope: unknown migration rule \"${m.rule}\" on \"${m.from}\"`);\n }\n for (const to of m.to) {\n if (!isLive(to)) {\n throw new Error(\n `information scope: migration \"${m.from}\" (${m.rule}) reads as \"${to}\", not a live row`,\n );\n }\n }\n if (\n m.releaseReading !== undefined &&\n m.releaseReading !== \"retain\" &&\n m.releaseReading !== \"successor\"\n ) {\n throw new Error(`information scope: \"${m.from}\" has releaseReading \"${String(m.releaseReading)}\"`);\n }\n if (m.policyReading !== undefined && m.policyReading !== \"successor\") {\n throw new Error(`information scope: \"${m.from}\" has policyReading \"${String(m.policyReading)}\"`);\n }\n if (\n m.releaseReading === \"retain\" &&\n (m.to.length !== 1 || !Array.isArray(m.v3Fields) || !Array.isArray(m.v3Domains))\n ) {\n throw new Error(\n `information scope: retained line \"${m.from}\" needs one successor and its v3Fields / v3Domains`,\n );\n }\n const perCode = migrations.get(m.from) ?? new Map<ScopeMigrationRule, ScopeMigration>();\n const prior = perCode.get(m.rule);\n if (prior && prior.to.join(\" \") !== m.to.join(\" \")) {\n throw new Error(`information scope: two \"${m.rule}\" readings for \"${m.from}\"`);\n }\n // The resolver reads only `to`, `widens` and a `retain` line's v3 membership;\n // the other line fields stay on the caller's `ScopeMigration` / the SOT.\n const retain = m.releaseReading === \"retain\" ? m : prior?.releaseReading === \"retain\" ? prior : null;\n perCode.set(m.rule, {\n from: m.from,\n rule: m.rule,\n to: Object.freeze([...m.to]),\n widens: m.widens === true || prior?.widens === true,\n ...(retain === null\n ? {}\n : {\n releaseReading: \"retain\" as const,\n v3Fields: Object.freeze([...(retain.v3Fields ?? [])]),\n v3Domains: Object.freeze([...(retain.v3Domains ?? [])]),\n ...(retain.v3FieldsNote === undefined ? {} : { v3FieldsNote: retain.v3FieldsNote }),\n }),\n });\n migrations.set(m.from, perCode);\n }\n\n /**\n * Unique, tree order for known codes, unknown codes kept after in first-seen\n * order; a selection always carries `system_info` (a restriction does not).\n */\n const normalize = (codes: Iterable<string>, withSystemInfo = true): string[] => {\n const seen = new Set<string>();\n const known: string[] = [];\n const unknown: string[] = [];\n const all = withSystemInfo ? [INFORMATION_SCOPE_SYSTEM_INFO, ...codes] : [...codes];\n for (const c of all) {\n if (seen.has(c)) continue;\n seen.add(c);\n (byCode.has(c) ? known : unknown).push(c);\n }\n known.sort((a, b) => (order.get(a) as number) - (order.get(b) as number));\n return [...known, ...unknown];\n };\n\n const requirePickable = (code: string, op: string): void => {\n if (!byCode.has(code)) throw new RangeError(`information scope ${op}: unknown code \"${code}\"`);\n if (!isSelectableScopeRow(byCode.get(code))) {\n throw new RangeError(`information scope ${op}: \"${code}\" is not selectable`);\n }\n };\n\n // Rule 2 (self or any ancestor in the flat list) + rule 3 (a record homed on a\n // category is covered when the category OR its rest row is). `system_info` and\n // `system` are always covered (header).\n const isCovered = (selection: StoredScopeList, code: string): boolean => {\n if (!isLive(code)) return false;\n if (alwaysCovered.has(code)) return true;\n const sel = new Set(asList(selection));\n if (ancestors(code).some((a) => sel.has(a))) return true;\n const rest = restRowOf(code);\n return rest !== undefined && sel.has(rest);\n };\n\n const shareVerdict = (\n selection: StoredScopeList,\n code: string,\n options: ScopeShareOptions = {},\n ): ScopeShareVerdict => {\n if (!isLive(code)) return { included: false, reason: \"unknown_code\" };\n if (!isCovered(selection, code)) return { included: false, reason: \"not_covered\" };\n const chain = ancestors(code).map((c) => byCode.get(c) as R);\n // Rule 5: the floor (or a floor ancestor) never leaves, whatever the list says.\n if (chain.some((r) => r.platformFloor)) return { included: false, reason: \"platform_floor\" };\n // Rule 4: every off-by-default row in the chain must be enabled by the account\n // (the reference runner's `included`: enabling an ancestor does not enable an\n // off-by-default child of it).\n const enabled = new Set(options.enabledOffByDefault ?? []);\n const notEnabled = chain\n .filter((r) => !r.shareableDefault && !enabled.has(r.scopeCode))\n .map((r) => r.scopeCode);\n if (notEnabled.length > 0) return { included: false, reason: \"off_by_default\", notEnabled };\n return { included: true, reason: \"included\" };\n };\n\n const expandSelectAll = (code: string): string[] => {\n if (!byCode.has(code)) throw new RangeError(`information scope expand: unknown code \"${code}\"`);\n return [...kids(code)];\n };\n\n const selectAll = (selection: readonly string[], code: string): string[] => {\n requirePickable(code, \"selectAll\");\n const drop = new Set(descendantsOf(code));\n return normalize([...selection.filter((c) => !drop.has(c)), code]);\n };\n\n const deselectChild = (selection: readonly string[], childCode: string): string[] => {\n requirePickable(childCode, \"deselectChild\");\n if (alwaysCovered.has(childCode)) {\n throw new RangeError(`information scope deselectChild: \"${childCode}\" is always included`);\n }\n const sel = new Set(selection);\n const path = ancestors(childCode); // [child, parent, …, root]\n let top = 0;\n for (let i = 1; i < path.length; i += 1) if (sel.has(path[i])) top = i;\n // Replace every selected ancestor by its OTHER children, all the way down the\n // path (rule 3: the rest row is one of those children, so it is written too).\n for (let i = 1; i <= top; i += 1) {\n sel.delete(path[i]);\n for (const c of kids(path[i])) if (c !== path[i - 1]) sel.add(c);\n }\n sel.delete(childCode);\n for (const d of descendantsOf(childCode)) sel.delete(d);\n return normalize(sel);\n };\n\n const readOne = (\n from: string,\n scopeVersion: number,\n precedence: readonly ScopeMigrationRule[],\n keepsGrain: boolean,\n ): ScopeCodeReading => {\n // A v4 list names live codes as written.\n if (scopeVersion === INFORMATION_SCOPE_VERSION && isLive(from)) {\n return { from, rule: \"identity\", reads: [from], widens: false, retained: false };\n }\n // Every other code reads through the table — including a retired code in a\n // v4 list (§ 3 (c): it \"stays recognisable in stored data forever\").\n const lines = migrations.get(from);\n if (lines) {\n for (const rule of precedence) {\n if (scopeVersion === INFORMATION_SCOPE_VERSION && (rule === \"identity\" || rule === \"category\")) {\n continue; // a v4 code that is not live has no identity reading\n }\n const line = lines.get(rule);\n if (!line) continue;\n // Ruling 2026-10-09: a release / share signed at v3 keeps the v3 grain.\n if (keepsGrain && line.releaseReading === \"retain\") {\n // A v4-stamped release / share cannot legitimately hold this tombstone\n // (never offered): recognised as retired, includes nothing — never the\n // successor (see `ScopeRetainedReading`).\n return scopeVersion === 3\n ? { from, rule, reads: [], widens: false, retained: true }\n : { from, rule, reads: [], widens: false, retained: false };\n }\n return { from, rule, reads: [...line.to], widens: line.widens === true, retained: false };\n }\n }\n return { from, rule: \"unknown\", reads: [], widens: false, retained: false };\n };\n\n const retainedOf = (c: ScopeCodeReading): ScopeRetainedReading => {\n const line = migrations.get(c.from)?.get(c.rule as ScopeMigrationRule) as ScopeMigration;\n return {\n code: c.from,\n v3Fields: [...(line.v3Fields ?? [])],\n v3Domains: [...(line.v3Domains ?? [])],\n successor: line.to[0],\n ...(line.v3FieldsNote === undefined ? {} : { note: line.v3FieldsNote }),\n };\n };\n\n const read = (\n list: StoredScopeList,\n scopeVersion: number | null | undefined,\n precedence: readonly ScopeMigrationRule[],\n subject: ScopeReadingSubject | null,\n ): ScopeReading => {\n const isRestriction = subject === null;\n const keepsGrain = subject === \"release\" || subject === \"share\";\n // A restriction is a policy's (handoff § 3 `subtract`: \"a policy that forbids\n // a code\"), so it carries the same dated-version-row signal.\n const isPolicyLike = subject === \"policy\" || isRestriction;\n const stored = [...asList(list)];\n const supported =\n typeof scopeVersion === \"number\" && INFORMATION_SCOPE_READABLE_VERSIONS.includes(scopeVersion);\n const versionRowRequired =\n isPolicyLike && supported && scopeVersion !== INFORMATION_SCOPE_VERSION;\n const codes: ScopeCodeReading[] = [];\n const seen = new Set<string>();\n for (const from of stored) {\n if (seen.has(from)) continue;\n seen.add(from);\n codes.push(\n supported\n ? readOne(from, scopeVersion as number, precedence, keepsGrain)\n : { from, rule: \"unknown\", reads: [], widens: false, retained: false },\n );\n }\n return {\n storedVersion: typeof scopeVersion === \"number\" ? scopeVersion : null,\n stored,\n version: INFORMATION_SCOPE_VERSION,\n unsupportedVersion: !supported,\n informationScope: normalize(\n codes.flatMap((c) => c.reads),\n !isRestriction,\n ),\n codes,\n retired: codes.filter((c) => RETIRED_RULES.has(c.rule)).map((c) => c.from),\n unknown: codes.filter((c) => c.rule === \"unknown\").map((c) => c.from),\n widened: codes.filter((c) => c.widens).map((c) => c.from),\n subject,\n retained: codes.filter((c) => c.retained).map(retainedOf),\n versionRowRequired,\n note: versionRowRequired ? INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE : null,\n };\n };\n\n const readSelection = (\n list: StoredScopeList,\n scopeVersion: number | null | undefined,\n options: ScopeReadOptions,\n ): ScopeReading => {\n const subject = (options as Partial<ScopeReadOptions> | undefined)?.subject;\n if (subject === undefined || !READING_SUBJECTS.has(subject)) {\n throw new TypeError(\n `information scope readSelection: options.subject must be \"release\", \"share\" or \"policy\" ` +\n `(got ${JSON.stringify(subject)}) — there is no default`,\n );\n }\n return read(list, scopeVersion, SELECTION_PRECEDENCE, subject);\n };\n\n const rowForSubject = (homeRow: string, kind: ScopeSubjectKind): string => {\n const home = byCode.get(homeRow);\n if (!home) throw new RangeError(`information scope rowForSubject: unknown home \"${homeRow}\"`);\n if (kind === \"client\") return homeRow;\n const chain = ancestors(homeRow);\n // System, Notes and the LEADS groups sit under no `branch` row: the record stays home.\n if (byCode.get(chain[chain.length - 1])?.rowType !== \"branch\") return homeRow;\n // A criminal-intelligence row under the client (`derived_risk_signals`) stays home:\n // every per-kind row is survivor_confidential, so re-branching would move CI\n // content across a handling class. The reference keeps it home the same way\n // (`resolve_home` / `leads_codes`).\n if (home.specialDataType === \"criminal_intelligence\") return homeRow;\n const root = kindRoot.get(kind);\n if (!root) throw new RangeError(`information scope rowForSubject: the tree has no \"${kind}\" kind`);\n if (chain.includes(root)) return homeRow;\n // The deepest row the kind defines for the home (D15).\n for (const anc of chain) {\n const perKind = perKindRow.get(`${kind}\\u0000${anc}`);\n if (perKind !== undefined) return perKind;\n }\n return root;\n };\n\n const expandBranchPickToGrain = (\n selection: StoredScopeList,\n ceiling: StoredScopeList,\n ): string[] => {\n const ceil = asList(ceiling);\n const ceilSet = new Set(ceil);\n const isWithin = (c: string): boolean => ancestors(c).some((a) => ceilSet.has(a));\n const isAbove = (c: string): boolean => ceil.some((k) => k !== c && ancestors(k).includes(c));\n const out: string[] = [];\n const stack = [...asList(selection)];\n while (stack.length > 0) {\n const c = stack.pop() as string;\n if (isLive(c) && !isWithin(c) && isAbove(c)) stack.push(...kids(c));\n else out.push(c);\n }\n return normalize(out);\n };\n\n const clampToCeiling = (selection: StoredScopeList, ceiling: StoredScopeList): string[] => {\n const ceil = new Set(asList(ceiling));\n return normalize(\n expandBranchPickToGrain(selection, ceiling).filter(\n (c) => isLive(c) && ancestors(c).some((a) => ceil.has(a)),\n ),\n );\n };\n\n return {\n version: INFORMATION_SCOPE_VERSION,\n rows,\n row: (code) => byCode.get(code),\n childrenOf: (code) => [...kids(code)],\n ancestorsOf: (code) => [...ancestors(code)],\n isCovered,\n isIncludedOnShare: (selection, code, options) =>\n shareVerdict(selection, code, options).included,\n shareVerdict,\n // Rule 7: the lowest internal viewing level that sees the row. Level 2\n // (autocomplete) sees the level-1 stub (§ 5). Sharing ignores this.\n isVisibleAtLevel: (level, code) =>\n typeof level === \"number\" && isLive(code) && level >= (byCode.get(code) as R).levelFloor,\n expandSelectAll,\n selectAll,\n deselectChild,\n readSelection,\n readRestriction: (list, scopeVersion) => read(list, scopeVersion, RESTRICTION_PRECEDENCE, null),\n rowForSubject,\n expandBranchPickToGrain,\n clampToCeiling,\n };\n}\n","/**\n * THE ceiling coverage rule (co-2sx): ONE answer to \"does this ceiling list\n * let this v4 row leave?\", read the same way by the composer's mask\n * ({@link rowsOutsideCeiling} / {@link rowsExpandedByCeiling} /\n * {@link maskSelectionToCeiling}) and by the send door\n * ({@link rowsOverCeiling}), so the list a composer masks to is the list a\n * door accepts (pinned by a property test over every live row × generated\n * ceilings).\n *\n * A row `code` is WITHIN a ceiling list when\n * 1. it or an ANCESTOR is listed — canon's dumb read, `scopeListCovers`\n * (prototype `HTI-LEADS-PAVE-Thread-prototype.html` @ d85f05b7\n * L327953-L327964); or\n * 2. it carries no content of its own (below), has at least one coverage\n * child, and EVERY coverage child is within (recursively) — canon's door\n * expands a branch / kind pick to the grain the ceiling is written at\n * before clamping (`shareItemsWithinCeiling`, L328204-L328230), so a\n * ceiling naming every child of `identifying` but not `identifying`\n * permits the `identifying` pick.\n *\n * OWN CONTENT (ruling, strict rule 2): a row with fields HOMED directly on it\n * (canon's field placements, {@link INFORMATION_SCOPE_FIELD_HOME_ROWS}; a\n * per-kind row reads its `kindRow`, since rule 1 routes another person's\n * record there) and NO rest row is within ONLY when it or an ancestor is\n * listed — listing its children does not carry its own fields. Examples:\n * `instruments` (`capture.assessment*`) and `commercial_activity`. A row with\n * a rest row (`identifying` + `identifying.other`) keeps rule 2: its own\n * fields are its rest row's.\n *\n * A COVERAGE child is live, not under the platform safety floor (never\n * shared) and not System metadata (always rides). A row is LIVE when it and\n * every row on its ancestor path are non-retired; a code outside the tree, or\n * not live, is never within.\n *\n * Deliberately NOT the resolver's `isCovered`, under which a listed rest row\n * (`identifying.other`) would cover its whole category.\n *\n * `allowed`: a list (or set) of v4 row codes; `null` is NO ceiling (canon\n * `if (allowed && …)`), under which every live row is within. Any other value\n * reads as `[]` (fail closed). `effectiveCeiling` never answers `null`.\n *\n * The tree arrives as an information-scope resolver (or anything with its\n * four read methods), so this module carries no SOT and no I/O.\n */\n\nimport {\n INFORMATION_SCOPE_SYSTEM_INFO,\n type InformationScopeResolver,\n} from \"../services/informationScopeResolver.js\";\nimport { INFORMATION_SCOPE_FIELD_HOME_ROWS } from \"./starter.js\";\n\n/** What the coverage rule reads of a tree. */\nexport type SharingCeilingScope = Pick<\n InformationScopeResolver,\n \"rows\" | \"row\" | \"childrenOf\" | \"ancestorsOf\"\n>;\n\n/** A ceiling list as callers hold it; `null` = no ceiling. */\nexport type SharingCeilingAllowed = readonly string[] | ReadonlySet<string> | null;\n\ninterface TreeFacts {\n readonly isLive: (code: string) => boolean;\n readonly isSystem: (code: string) => boolean;\n readonly underFloor: (code: string) => boolean;\n readonly isCoverageRow: (code: string) => boolean;\n readonly coverageChildren: (code: string) => readonly string[];\n readonly hasOwnContent: (code: string) => boolean;\n}\n\nconst factsCache = new WeakMap<object, TreeFacts>();\n\nfunction memoize<V>(fn: (code: string) => V): (code: string) => V {\n const memo = new Map<string, V>();\n return (code) => {\n if (memo.has(code)) return memo.get(code) as V;\n const out = fn(code);\n memo.set(code, out);\n return out;\n };\n}\n\nfunction treeFacts(scope: SharingCeilingScope): TreeFacts {\n const hit = factsCache.get(scope);\n if (hit) return hit;\n const systemPath = scope.ancestorsOf(INFORMATION_SCOPE_SYSTEM_INFO);\n const systemRoot = systemPath.length > 0 ? systemPath[systemPath.length - 1] : undefined;\n const isLive = memoize(\n (code) =>\n scope.row(code) !== undefined &&\n scope.ancestorsOf(code).every((c) => scope.row(c)?.status !== \"retired\"),\n );\n const isSystem = memoize(\n (code) => systemRoot !== undefined && scope.ancestorsOf(code).includes(systemRoot),\n );\n const underFloor = memoize((code) =>\n scope.ancestorsOf(code).some((c) => scope.row(c)?.platformFloor === true),\n );\n const isCoverageRow = memoize((code) => isLive(code) && !isSystem(code) && !underFloor(code));\n const coverageChildren = memoize((code) =>\n Object.freeze(scope.childrenOf(code).filter(isCoverageRow)),\n );\n const hasOwnContent = memoize((code) => {\n const row = scope.row(code);\n if (row === undefined) return false;\n const homed =\n INFORMATION_SCOPE_FIELD_HOME_ROWS.has(code) ||\n (row.kindRow !== undefined && INFORMATION_SCOPE_FIELD_HOME_ROWS.has(row.kindRow));\n if (!homed) return false;\n // A rest row stands for the row's own fields; then rule 2 still applies.\n return !scope\n .childrenOf(code)\n .some((c) => scope.row(c)?.rowType === \"category_rest\" && isLive(c));\n });\n const facts: TreeFacts = {\n isLive,\n isSystem,\n underFloor,\n isCoverageRow,\n coverageChildren,\n hasOwnContent,\n };\n factsCache.set(scope, facts);\n return facts;\n}\n\nfunction asCeilingSet(allowed: unknown): ReadonlySet<string> | null {\n if (allowed === null) return null;\n if (allowed instanceof Set) return allowed as ReadonlySet<string>;\n if (Array.isArray(allowed)) {\n return new Set(allowed.filter((c): c is string => typeof c === \"string\"));\n }\n return new Set(); // malformed: covers nothing\n}\n\n/**\n * Does the coverage rule require `code` for its parent to be covered? Live,\n * not under the platform floor, not System metadata.\n */\nexport function isCeilingCoverageRow(scope: SharingCeilingScope, code: string): boolean {\n return treeFacts(scope).isCoverageRow(code);\n}\n\n/**\n * Does `code` carry content of its own that children-only coverage cannot\n * carry (fields homed directly on it, no rest row)? See the module header.\n */\nexport function hasOwnScopeContent(scope: SharingCeilingScope, code: string): boolean {\n return treeFacts(scope).hasOwnContent(code);\n}\n\n/**\n * The coverage of ONE ceiling list, memoised per row — build it once and ask\n * it about many rows. See the module header for the rule.\n */\nexport function ceilingCoverage(\n scope: SharingCeilingScope,\n allowed: SharingCeilingAllowed,\n): (code: string) => boolean {\n const facts = treeFacts(scope);\n const set = asCeilingSet(allowed);\n const memo = new Map<string, boolean>();\n const within = (code: string): boolean => {\n const hit = memo.get(code);\n if (hit !== undefined) return hit;\n let out: boolean;\n if (!facts.isLive(code)) out = false;\n else if (set === null) out = true;\n else if (scope.ancestorsOf(code).some((c) => set.has(c))) out = true;\n else if (facts.hasOwnContent(code)) out = false;\n else {\n const kids = facts.coverageChildren(code);\n out = kids.length > 0 && kids.every(within);\n }\n memo.set(code, out);\n return out;\n };\n return within;\n}\n\n/** THE coverage rule for one row (see the module header). */\nexport function scopeRowWithinCeiling(\n scope: SharingCeilingScope,\n allowed: SharingCeilingAllowed,\n code: string,\n): boolean {\n return ceilingCoverage(scope, allowed)(code);\n}\n\n/**\n * The DOOR reader: the codes of a declared list the ceiling does not let\n * leave, in list order, each once. `system_info` and every System-metadata\n * row ride regardless (canon L327974), and rows under the platform floor are\n * never included on any share, so neither is reported. A code outside the\n * tree, or not live, is reported (fail closed).\n */\nexport function rowsOverCeiling(\n scope: SharingCeilingScope,\n declared: readonly string[] | null | undefined,\n allowed: SharingCeilingAllowed,\n): string[] {\n const facts = treeFacts(scope);\n const within = ceilingCoverage(scope, allowed);\n const out: string[] = [];\n for (const code of new Set(Array.isArray(declared) ? declared : [])) {\n if (code === INFORMATION_SCOPE_SYSTEM_INFO) continue;\n if (!facts.isLive(code)) {\n out.push(code);\n continue;\n }\n if (facts.isSystem(code) || facts.underFloor(code)) continue;\n if (!within(code)) out.push(code);\n }\n return out;\n}\n\ninterface CeilingWalk {\n /** Rows wholly outside the ceiling, each at its highest such grain. */\n readonly outside: string[];\n /** Own-content rows not within that hold within rows: a pick of one is its children. */\n readonly expanded: string[];\n}\n\n/** One top-down walk of the live tree against a ceiling (System metadata skipped). */\nfunction walkCeiling(scope: SharingCeilingScope, allowed: SharingCeilingAllowed): CeilingWalk {\n const facts = treeFacts(scope);\n if (asCeilingSet(allowed) === null) return { outside: [], expanded: [] };\n const within = ceilingCoverage(scope, allowed);\n const holdsMemo = new Map<string, boolean>();\n const holdsWithin = (code: string): boolean => {\n const hit = holdsMemo.get(code);\n if (hit !== undefined) return hit;\n // Only a coverage row counts as content held beneath: a listed FLOOR row\n // (never included) does not make its parent partly permitted.\n const out = scope\n .childrenOf(code)\n .some((c) => (facts.isCoverageRow(c) && within(c)) || holdsWithin(c));\n holdsMemo.set(code, out);\n return out;\n };\n const outside: string[] = [];\n const expanded: string[] = [];\n const visit = (code: string): void => {\n if (!facts.isLive(code) || within(code)) return;\n if (!holdsWithin(code)) {\n outside.push(code);\n return;\n }\n if (facts.hasOwnContent(code)) expanded.push(code);\n for (const child of scope.childrenOf(code)) visit(child);\n };\n for (const r of scope.rows) {\n if (r.parentScopeCode !== null && r.parentScopeCode !== \"\") continue;\n if (facts.isSystem(r.scopeCode)) continue;\n visit(r.scopeCode);\n }\n return { outside, expanded };\n}\n\n/**\n * The COMPOSER-MASK reader: the rows a ceiling restricts, each at the\n * highest grain that is wholly outside it — a row not within and holding no\n * within coverage row beneath. A row that is not within but holds one that\n * is, is not restricted itself; its children are walked. System metadata is\n * never restricted. `null` (no ceiling) restricts nothing.\n */\nexport function rowsOutsideCeiling(\n scope: SharingCeilingScope,\n allowed: SharingCeilingAllowed,\n): string[] {\n return walkCeiling(scope, allowed).outside;\n}\n\n/**\n * The rows with content of their own (strict rule 2) that are not within the\n * ceiling but hold rows that are: the row itself cannot be sent, so a pick of\n * it reads as a pick of its children (then masked). Top-down order.\n */\nexport function rowsExpandedByCeiling(\n scope: SharingCeilingScope,\n allowed: SharingCeilingAllowed,\n): string[] {\n return walkCeiling(scope, allowed).expanded;\n}\n\n/** `system_info` first, then each code once, in order. */\nfunction withSystemInfo(codes: readonly string[]): string[] {\n return [...new Set([INFORMATION_SCOPE_SYSTEM_INFO, ...codes])];\n}\n\n/**\n * Take one row out of a selection at its own grain: drop it and everything\n * beneath it, and replace each selected ancestor by its other children, all\n * the way down the path (a category's rest row is one of those children, so\n * it is written too).\n */\nfunction subtractRow(\n scope: SharingCeilingScope,\n selection: readonly string[],\n code: string,\n): string[] {\n const path = scope.ancestorsOf(code); // code first, then up to the root\n let sel = selection.filter((c) => !scope.ancestorsOf(c).includes(code));\n for (;;) {\n const coverAt = path.findIndex((c, i) => i > 0 && sel.includes(c));\n if (coverAt === -1) break;\n sel = sel.filter((c) => c !== path[coverAt]);\n for (let i = coverAt; i >= 1; i -= 1) {\n const parent = path[i] as string;\n const onPath = path[i - 1];\n for (const child of scope.childrenOf(parent)) {\n if (child !== onPath && !sel.includes(child)) sel.push(child);\n }\n }\n }\n return sel;\n}\n\n/**\n * The COMPOSER MASK: a selection with every row the ceiling restricts taken\n * out at its own grain. First each covered own-content row the ceiling does\n * not permit ({@link rowsExpandedByCeiling}) is replaced by its children,\n * then every row wholly outside ({@link rowsOutsideCeiling}) is subtracted.\n * Only live rows survive (plus `system_info`, always first). A row within\n * the ceiling is never removed, and {@link rowsOverCeiling} accepts every\n * result.\n */\nexport function maskSelectionToCeiling(\n scope: SharingCeilingScope,\n selection: readonly string[] | null | undefined,\n allowed: SharingCeilingAllowed,\n): string[] {\n const facts = treeFacts(scope);\n const { outside, expanded } = walkCeiling(scope, allowed);\n let sel = (Array.isArray(selection) ? selection : []).filter(\n (c): c is string => typeof c === \"string\" && facts.isLive(c),\n );\n for (const code of expanded) {\n if (!scope.ancestorsOf(code).some((c) => sel.includes(c))) continue;\n sel = subtractRow(scope, sel, code);\n for (const child of scope.childrenOf(code)) if (!sel.includes(child)) sel.push(child);\n }\n for (const code of outside) sel = subtractRow(scope, sel, code);\n // Siblings put back by subtractRow / the expansion come from childrenOf,\n // which a caller's tree may populate with retired rows: keep live ones only.\n return withSystemInfo(sel.filter((c) => facts.isLive(c)));\n}\n"],"mappings":";AA8BO,IAAM,kCAAkC;AAAA,EAC7C,YAAY;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,gBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,IACA,gBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,mBAAmB;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;AAGO,IAAM,gCAAgC;AAAA,EAC3C,cAAc;AAAA,EACd,gBAAgB;AAAA,IACd,YAAY,CAAC,eAAe,WAAW,YAAY,UAAU,0BAA0B;AAAA,IACvF,sBAAsB,CAAC,eAAe,QAAQ,WAAW,YAAY,SAAS,UAAU,0BAA0B,eAAe,6BAA6B,+BAA+B,oCAAoC,qBAAqB,eAAe,0BAA0B;AAAA,IAC/R,iBAAiB,CAAC,eAAe,QAAQ;AAAA,IACzC,uBAAuB,CAAC,eAAe,QAAQ,WAAW,YAAY,SAAS,UAAU,0BAA0B,eAAe,6BAA6B,+BAA+B,oCAAoC,qBAAqB,eAAe,4BAA4B,yBAAyB,kBAAkB,2BAA2B,QAAQ;AAAA,IAChX,uBAAuB,CAAC,eAAe,QAAQ;AAAA,IAC/C,uBAAuB,CAAC,eAAe,QAAQ,UAAU,0BAA0B,eAAe,6BAA6B,+BAA+B,oCAAoC,qBAAqB,eAAe,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SAAS,KAAK,EAAG,KAAI,KAAK,KAAK;AAAA,EACtF;AACA,aAAW,QAAQ,QAAS,OAAM,YAAY,OAAO,KAAK,IAAI;AAG9D,SAAO,eAAe,IAAI,OAAO,CAAC,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC;AAC1D;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htilabs/platform-common-models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Shared constants, types, and models for HTI Labs applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -71,6 +71,11 @@
|
|
|
71
71
|
"types": "./dist/authz/index.d.ts",
|
|
72
72
|
"import": "./dist/authz/index.js",
|
|
73
73
|
"require": "./dist/authz/index.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./sharing-ceiling": {
|
|
76
|
+
"types": "./dist/sharing-ceiling/index.d.ts",
|
|
77
|
+
"import": "./dist/sharing-ceiling/index.js",
|
|
78
|
+
"require": "./dist/sharing-ceiling/index.cjs"
|
|
74
79
|
}
|
|
75
80
|
},
|
|
76
81
|
"files": [
|
|
@@ -100,6 +105,7 @@
|
|
|
100
105
|
"seed:cvc:all": "tsx scripts/seed-all-cvcs.ts",
|
|
101
106
|
"test:seed": "node --import tsx --test scripts/seed-cvc.test.ts",
|
|
102
107
|
"test:guard": "node --import tsx --test scripts/lib/confirmTargetDb.test.ts",
|
|
108
|
+
"test:js-literal": "node --import tsx --test scripts/lib/jsLiteral.test.ts",
|
|
103
109
|
"prepublishOnly": "npm run build"
|
|
104
110
|
},
|
|
105
111
|
"keywords": [
|
package/src/__sot__/README.md
CHANGED
|
@@ -13,6 +13,7 @@ live in other repos:
|
|
|
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
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
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`. |
|
|
16
|
+
| `sharingStarter.pin.json` | `htilabstech/prototype` · `HTI-LEADS-PAVE-Thread-prototype.html` `HTI_SHARE_PLATFORM_STARTER` **and** `htilabstech/platform-prototype` · `src/data.js` `data.sharing.*` | The **platform sharing starter** (co-2sx): `scopeByPurpose` (the platform per-purpose ceiling) and `counterpartyOverrides` (the seeded partner rules), from BOTH canon copies — the derivation refuses when they differ — plus the platform purpose rows' `enabled` flag (`purposeEnabled`, data.js only) and the distinct field homes of canon's v4 field placements (`fieldHomeRows`, prototype `docs/share-roi/information_scope_v4.fields.csv` `row_v4` — read by the ceiling's strict coverage rule 2). `GATE M` (`sharing-starter-canon.test.ts`) asserts the generated `src/generated/sharingPlatformStarter.ts` equals it and that every code is a live, non-floor CVC-236 v4 row. **Refreshing this pin is half a step:** regenerate the module with `scripts/gen-sharing-starter.py <prototype root> <platform-prototype root>` in the same change (the pin reads the working trees, the generator reads `origin/main` — keep them equal). Set `PLATFORM_PROTOTYPE_DIR` for the pin. |
|
|
16
17
|
| `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
18
|
| `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. |
|
|
18
19
|
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sourceRepo": "htilabstech/prototype",
|
|
3
|
+
"sourceFile": "HTI-LEADS-PAVE-Thread-prototype.html",
|
|
4
|
+
"sourceSha": "d85f05b",
|
|
5
|
+
"mirror": {
|
|
6
|
+
"sourceRepo": "htilabstech/platform-prototype",
|
|
7
|
+
"sourceFile": "src/data.js",
|
|
8
|
+
"sourceSha": "a6f1f3a"
|
|
9
|
+
},
|
|
10
|
+
"scopeVersion": 4,
|
|
11
|
+
"scopeByPurpose": {
|
|
12
|
+
"referral": [
|
|
13
|
+
"identifying",
|
|
14
|
+
"contact",
|
|
15
|
+
"services",
|
|
16
|
+
"system",
|
|
17
|
+
"summary_needs_assessment"
|
|
18
|
+
],
|
|
19
|
+
"case_collaboration": [
|
|
20
|
+
"identifying",
|
|
21
|
+
"risk",
|
|
22
|
+
"contact",
|
|
23
|
+
"services",
|
|
24
|
+
"notes",
|
|
25
|
+
"system",
|
|
26
|
+
"summary_initial_screen",
|
|
27
|
+
"summary_lap",
|
|
28
|
+
"summary_danger_assessment",
|
|
29
|
+
"summary_stalking_assessment",
|
|
30
|
+
"summary_injury_and_strangulation",
|
|
31
|
+
"summary_ae_intake",
|
|
32
|
+
"summary_tra",
|
|
33
|
+
"summary_needs_assessment"
|
|
34
|
+
],
|
|
35
|
+
"deconfliction": [
|
|
36
|
+
"identifying",
|
|
37
|
+
"system"
|
|
38
|
+
],
|
|
39
|
+
"mandatory_reporting": [
|
|
40
|
+
"identifying",
|
|
41
|
+
"risk",
|
|
42
|
+
"contact",
|
|
43
|
+
"services",
|
|
44
|
+
"notes",
|
|
45
|
+
"system",
|
|
46
|
+
"summary_initial_screen",
|
|
47
|
+
"summary_lap",
|
|
48
|
+
"summary_danger_assessment",
|
|
49
|
+
"summary_stalking_assessment",
|
|
50
|
+
"summary_injury_and_strangulation",
|
|
51
|
+
"summary_ae_intake",
|
|
52
|
+
"summary_tra",
|
|
53
|
+
"summary_needs_assessment",
|
|
54
|
+
"offenders.identifying",
|
|
55
|
+
"offenders.risk",
|
|
56
|
+
"relationships_household",
|
|
57
|
+
"family"
|
|
58
|
+
],
|
|
59
|
+
"discretionary_share": [
|
|
60
|
+
"identifying",
|
|
61
|
+
"system"
|
|
62
|
+
],
|
|
63
|
+
"authority_reporting": [
|
|
64
|
+
"identifying",
|
|
65
|
+
"risk",
|
|
66
|
+
"system",
|
|
67
|
+
"summary_initial_screen",
|
|
68
|
+
"summary_lap",
|
|
69
|
+
"summary_danger_assessment",
|
|
70
|
+
"summary_stalking_assessment",
|
|
71
|
+
"summary_injury_and_strangulation",
|
|
72
|
+
"summary_ae_intake",
|
|
73
|
+
"summary_tra",
|
|
74
|
+
"offenders.identifying",
|
|
75
|
+
"offenders.risk",
|
|
76
|
+
"relationships_household",
|
|
77
|
+
"family"
|
|
78
|
+
],
|
|
79
|
+
"automatic_account_share": [
|
|
80
|
+
"identifying",
|
|
81
|
+
"system"
|
|
82
|
+
],
|
|
83
|
+
"records_request": [
|
|
84
|
+
"identifying",
|
|
85
|
+
"system"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"counterpartyOverrides": {
|
|
89
|
+
"palomar": {
|
|
90
|
+
"case_collaboration": [
|
|
91
|
+
"identifying",
|
|
92
|
+
"risk",
|
|
93
|
+
"contact",
|
|
94
|
+
"services",
|
|
95
|
+
"notes",
|
|
96
|
+
"health_accommodation",
|
|
97
|
+
"system",
|
|
98
|
+
"summary_initial_screen",
|
|
99
|
+
"summary_lap",
|
|
100
|
+
"summary_danger_assessment",
|
|
101
|
+
"summary_stalking_assessment",
|
|
102
|
+
"summary_injury_and_strangulation",
|
|
103
|
+
"summary_ae_intake",
|
|
104
|
+
"summary_tra",
|
|
105
|
+
"summary_mental_health_screen",
|
|
106
|
+
"summary_behavioral_health_intake",
|
|
107
|
+
"summary_trauma_and_coping_screen",
|
|
108
|
+
"summary_needs_assessment"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"okcpd": {
|
|
112
|
+
"mandatory_reporting": [
|
|
113
|
+
"identifying",
|
|
114
|
+
"risk",
|
|
115
|
+
"contact",
|
|
116
|
+
"services",
|
|
117
|
+
"notes",
|
|
118
|
+
"system",
|
|
119
|
+
"summary_initial_screen",
|
|
120
|
+
"summary_lap",
|
|
121
|
+
"summary_danger_assessment",
|
|
122
|
+
"summary_stalking_assessment",
|
|
123
|
+
"summary_injury_and_strangulation",
|
|
124
|
+
"summary_ae_intake",
|
|
125
|
+
"summary_tra",
|
|
126
|
+
"summary_needs_assessment",
|
|
127
|
+
"offenders.identifying",
|
|
128
|
+
"offenders.risk",
|
|
129
|
+
"relationships_household",
|
|
130
|
+
"family"
|
|
131
|
+
],
|
|
132
|
+
"referral": [
|
|
133
|
+
"identifying",
|
|
134
|
+
"contact",
|
|
135
|
+
"services",
|
|
136
|
+
"system",
|
|
137
|
+
"summary_needs_assessment"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
"legal_aid_ok": {
|
|
141
|
+
"referral": [
|
|
142
|
+
"identifying",
|
|
143
|
+
"contact",
|
|
144
|
+
"services",
|
|
145
|
+
"notes",
|
|
146
|
+
"system",
|
|
147
|
+
"summary_needs_assessment"
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"purposeEnabled": {
|
|
152
|
+
"referral": true,
|
|
153
|
+
"case_collaboration": true,
|
|
154
|
+
"deconfliction": true,
|
|
155
|
+
"mandatory_reporting": true,
|
|
156
|
+
"discretionary_share": true,
|
|
157
|
+
"authority_reporting": true,
|
|
158
|
+
"automatic_account_share": true,
|
|
159
|
+
"records_request": false
|
|
160
|
+
},
|
|
161
|
+
"fieldHomeRows": [
|
|
162
|
+
"accommodation_needs",
|
|
163
|
+
"ad_content",
|
|
164
|
+
"additional_ids",
|
|
165
|
+
"addresses",
|
|
166
|
+
"case_attachments",
|
|
167
|
+
"case_determinations",
|
|
168
|
+
"case_lifecycle",
|
|
169
|
+
"case_notes",
|
|
170
|
+
"commercial_activity",
|
|
171
|
+
"contact_info",
|
|
172
|
+
"demographics",
|
|
173
|
+
"derived_risk_signals",
|
|
174
|
+
"dob",
|
|
175
|
+
"encounter_location",
|
|
176
|
+
"family.health_accommodation",
|
|
177
|
+
"family.identifying",
|
|
178
|
+
"family.risk",
|
|
179
|
+
"full_ae_intake",
|
|
180
|
+
"full_behavioral_health_intake",
|
|
181
|
+
"full_danger_assessment",
|
|
182
|
+
"full_findings",
|
|
183
|
+
"full_hope_scale",
|
|
184
|
+
"full_ida",
|
|
185
|
+
"full_initial_screen",
|
|
186
|
+
"full_injury_and_strangulation",
|
|
187
|
+
"full_lap",
|
|
188
|
+
"full_mental_health_screen",
|
|
189
|
+
"full_needs_assessment",
|
|
190
|
+
"full_stalking_assessment",
|
|
191
|
+
"full_tra",
|
|
192
|
+
"full_trauma_and_coping_screen",
|
|
193
|
+
"health_status",
|
|
194
|
+
"identifying",
|
|
195
|
+
"immigration_applications",
|
|
196
|
+
"immigration_status",
|
|
197
|
+
"instruments",
|
|
198
|
+
"names",
|
|
199
|
+
"network_membership",
|
|
200
|
+
"object_identity_attributes",
|
|
201
|
+
"offenders.risk",
|
|
202
|
+
"others.risk",
|
|
203
|
+
"persona_links",
|
|
204
|
+
"phone_identifiers",
|
|
205
|
+
"plans_goals",
|
|
206
|
+
"priorities_safety",
|
|
207
|
+
"relationships_household",
|
|
208
|
+
"screen_indicators",
|
|
209
|
+
"service_history",
|
|
210
|
+
"session_summary",
|
|
211
|
+
"summary_ae_intake",
|
|
212
|
+
"summary_behavioral_health_intake",
|
|
213
|
+
"summary_danger_assessment",
|
|
214
|
+
"summary_findings",
|
|
215
|
+
"summary_hope_scale",
|
|
216
|
+
"summary_ida",
|
|
217
|
+
"summary_initial_screen",
|
|
218
|
+
"summary_injury_and_strangulation",
|
|
219
|
+
"summary_lap",
|
|
220
|
+
"summary_mental_health_screen",
|
|
221
|
+
"summary_needs_assessment",
|
|
222
|
+
"summary_stalking_assessment",
|
|
223
|
+
"summary_tra",
|
|
224
|
+
"summary_trauma_and_coping_screen",
|
|
225
|
+
"system",
|
|
226
|
+
"system_involvement",
|
|
227
|
+
"victimization"
|
|
228
|
+
]
|
|
229
|
+
}
|