@htilabs/platform-common-models 0.87.1 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/{index-Bj-s0nZy.d.cts → index-1pWiqEBC.d.cts} +1 -1
- package/dist/{index-DvAypMJV.d.ts → index-uz57Fic9.d.ts} +1 -1
- package/dist/index.cjs +118 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.cjs +118 -0
- package/dist/information-scope/index.cjs.map +1 -1
- package/dist/information-scope/index.d.cts +88 -1
- package/dist/information-scope/index.d.ts +88 -1
- package/dist/information-scope/index.js +109 -0
- package/dist/information-scope/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/schemas/index.d.cts +1 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/services/index.cjs +118 -0
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +109 -0
- package/dist/services/index.js.map +1 -1
- package/dist/validation/index.d.cts +1 -1
- package/dist/validation/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/__sot__/README.md +1 -0
- package/src/__sot__/roiScopePresets.pin.json +82 -0
- package/src/__tests__/roi-scope-presets-canon.test.ts +106 -0
- package/src/roiScopePresets/index.ts +190 -0
- package/src/services/informationScope.ts +2 -0
- package/dist/{agency-CnVTwLeV.d.ts → agency-BHv54o79.d.ts} +4 -4
- package/dist/{agency-8ufZJJDH.d.cts → agency-Djp57S71.d.cts} +4 -4
- package/dist/{cvcEntry-BLeRivoF.d.cts → cvcEntry-DAuhe0cd.d.cts} +16 -16
- package/dist/{cvcEntry-BLeRivoF.d.ts → cvcEntry-DAuhe0cd.d.ts} +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/informationScopeResolver.ts","../../src/services/informationScopeSot.ts","../../src/generated/informationScopeUiCopy.ts","../../src/services/informationScopeUiCopy.ts"],"sourcesContent":["/**\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 * resolver reads no v2 → v3 table, so those lists are unsupported and include\n * nothing (fail closed). The one exception is not here: a stored sharing POLICY\n * list with no stamp is read by `readStoredPolicyScope` (sharing-ceiling),\n * which carries it through canon's v2 → v3 category lines first.\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/**\n * The `category_rest` row (rule 3): it carries the facts filed on its category,\n * and is covered with it. Since canon's re-ruling of 2026-10-18 it is an ORDINARY\n * selectable row (\"Other identifying details\"); the row type is only the marker\n * the send path reads.\n */\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 * @htilabs/platform-common-models — CVC-236 SOT → information-scope resolver binding\n *\n * Maps the `core_information_scope` SOT envelope (`coreInformationScope.v2.1.1.json`,\n * exported as `coreInformationScopeSot` from `/cvcs`) into the resolver's\n * input shapes. Pure and dependency-free: the caller passes the envelope.\n *\n * The SOT keys a row by its package key (`offenders__risk`, `identifying__other`:\n * canon's dotted codes with `.` spelled `__`) and by a seven-segment wire code;\n * a stored selection holds canon's dotted code (`offenders.risk`). The\n * adapter reads every key through the entry's `canonicalCode` (present on the\n * dotted rows) and falls back to `__` → `.` for a key with no entry.\n *\n * Rows: the live v4 tree only (`status` `as_today` / `new`). The retired\n * tombstones are left out — a stored retired code reads through the\n * migration table, which names every tombstone — and so is the CVC\n * missingness group (`missingness_root` and its children), which is not a\n * scope row. A live entry missing a field the resolver needs throws: binding\n * fails closed rather than guess.\n *\n * Migrations: `migrations.table`, with each line's release-grain fields\n * (`releaseReading` / `policyReading` / `informational`, Crysta's ruling of\n * 2026-10-09). A `retain` line carries the v3 field membership of its `from`\n * code, read from that code's ENTRY (`v3Fields` / `v3Domains` /\n * `v3FieldsNote`, on the retired tombstone), so the SOT states it once. A\n * `retain` line whose entry has no `v3Fields` throws: binding fails closed.\n *\n * Usage:\n * ```ts\n * import { coreInformationScopeSot } from \"@htilabs/platform-common-models/cvcs\";\n * import {\n * createInformationScopeResolver, scopeRowsFromSot, scopeMigrationsFromSot,\n * } from \"@htilabs/platform-common-models/information-scope\";\n *\n * const scope = createInformationScopeResolver({\n * rows: scopeRowsFromSot(coreInformationScopeSot),\n * migrations: scopeMigrationsFromSot(coreInformationScopeSot),\n * });\n * ```\n */\n\nimport type {\n ScopeKindBranch,\n ScopeMigration,\n ScopeMigrationRule,\n ScopeRow,\n ScopeRowStatus,\n ScopeRowType,\n ScopeSpecialDataType,\n} from \"./informationScopeResolver.js\";\n\n/** The SOT entry fields the adapter reads (structural, so the JSON import binds). */\nexport interface CoreInformationScopeSotEntry {\n key: string;\n canonicalCode?: string;\n parentKey?: string | null;\n rowType?: string;\n kindBranch?: string | null;\n kindRow?: string;\n apps?: { pave: boolean; thread: boolean; leads: boolean };\n selectable?: boolean;\n shareableDefault?: boolean;\n platformFloor?: boolean;\n levelFloor?: number;\n specialDataType?: string;\n status?: string;\n replacesV3?: readonly string[];\n /** On a tombstone: its RESTRICTION reading; the table's `subtract` line is what binds. */\n restrictionSuccessors?: readonly string[];\n /** On a `releaseReading: \"retain\"` line's `from` entry: its v3 fields (field ids). */\n v3Fields?: readonly string[];\n /** Their assertion domains — v3 CATEGORY grain (the field family), not the unit's membership. */\n v3Domains?: readonly string[];\n v3FieldsNote?: string;\n}\n\nexport interface CoreInformationScopeSotMigrationLine {\n from: string;\n to: readonly string[];\n rule: string;\n note?: string;\n widens?: boolean;\n releaseReading?: string;\n releaseReadingNote?: string;\n policyReading?: string;\n informational?: boolean;\n}\n\nexport interface CoreInformationScopeSot {\n entries: readonly CoreInformationScopeSotEntry[];\n migrations?: { table: readonly CoreInformationScopeSotMigrationLine[] };\n}\n\nconst ROW_TYPES: ReadonlySet<string> = new Set<ScopeRowType>([\n \"branch\",\n \"category\",\n \"subcategory\",\n \"sub-category\",\n \"person_type\",\n \"category_rest\",\n \"instrument row\",\n]);\nconst KIND_BRANCHES: ReadonlySet<string> = new Set([\n \"client\",\n \"offenders\",\n \"family\",\n \"others\",\n \"leads\",\n]);\nconst LIVE: ReadonlySet<string> = new Set<ScopeRowStatus>([\"as_today\", \"new\"]);\nconst MISSINGNESS_ROOT = \"missingness_root\";\n\n/** Package key → canon scope code, through `canonicalCode`. */\nfunction keyReader(sot: CoreInformationScopeSot): (key: string) => string {\n const byKey = new Map(sot.entries.map((e) => [e.key, e.canonicalCode ?? e.key]));\n return (key) => byKey.get(key) ?? key.replace(/__/g, \".\");\n}\n\nfunction fail(key: string, field: string, value: unknown): never {\n throw new TypeError(\n `information scope SOT: live entry \"${key}\" has ${field} ${JSON.stringify(value)}`,\n );\n}\n\n/** The live v4 tree rows of a CVC-236 SOT, in the resolver's selection-code space. */\nexport function scopeRowsFromSot(sot: CoreInformationScopeSot): ScopeRow[] {\n const code = keyReader(sot);\n const missingness = new Set(\n sot.entries\n .filter((e) => e.key === MISSINGNESS_ROOT || e.parentKey === MISSINGNESS_ROOT)\n .map((e) => e.key),\n );\n const rows: ScopeRow[] = [];\n for (const e of sot.entries) {\n if (missingness.has(e.key)) continue;\n if (e.status === \"retired\") continue;\n if (e.status === undefined || !LIVE.has(e.status)) fail(e.key, \"status\", e.status);\n if (e.rowType === undefined || !ROW_TYPES.has(e.rowType)) fail(e.key, \"rowType\", e.rowType);\n const kindBranch = e.kindBranch ?? null;\n if (kindBranch !== null && !KIND_BRANCHES.has(kindBranch)) fail(e.key, \"kindBranch\", kindBranch);\n if (e.apps === undefined) fail(e.key, \"apps\", e.apps);\n for (const b of [\"selectable\", \"shareableDefault\", \"platformFloor\"] as const) {\n if (typeof e[b] !== \"boolean\") fail(e.key, b, e[b]);\n }\n if (e.levelFloor !== 1 && e.levelFloor !== 3) fail(e.key, \"levelFloor\", e.levelFloor);\n if (e.specialDataType === undefined) fail(e.key, \"specialDataType\", e.specialDataType);\n const row: ScopeRow = {\n scopeCode: code(e.key),\n parentScopeCode: e.parentKey ? code(e.parentKey) : null,\n rowType: e.rowType as ScopeRowType,\n kindBranch: kindBranch as ScopeKindBranch,\n apps: { pave: e.apps.pave, thread: e.apps.thread, leads: e.apps.leads },\n selectable: e.selectable as boolean,\n shareableDefault: e.shareableDefault as boolean,\n platformFloor: e.platformFloor as boolean,\n levelFloor: e.levelFloor,\n specialDataType: e.specialDataType as ScopeSpecialDataType,\n status: e.status as ScopeRowStatus,\n replacesV3: [...(e.replacesV3 ?? [])],\n };\n if (e.kindRow !== undefined) row.kindRow = code(e.kindRow);\n rows.push(row);\n }\n return rows;\n}\n\n/** The v3 → v4 from-to table of a CVC-236 SOT (`migrations.table`), in selection codes. */\nexport function scopeMigrationsFromSot(sot: CoreInformationScopeSot): ScopeMigration[] {\n const code = keyReader(sot);\n const byKey = new Map(sot.entries.map((e) => [e.key, e]));\n return (sot.migrations?.table ?? []).map((l) => {\n const m: ScopeMigration = {\n from: code(l.from),\n to: l.to.map(code),\n rule: l.rule as ScopeMigrationRule,\n ...(l.note === undefined ? {} : { note: l.note }),\n ...(l.widens === undefined ? {} : { widens: l.widens }),\n ...(l.informational === undefined ? {} : { informational: l.informational }),\n ...(l.policyReading === undefined\n ? {}\n : { policyReading: l.policyReading as ScopeMigration[\"policyReading\"] }),\n };\n if (l.releaseReading === undefined) return m;\n if (l.releaseReading !== \"retain\") {\n return {\n ...m,\n releaseReading: l.releaseReading as ScopeMigration[\"releaseReading\"],\n ...(l.releaseReadingNote === undefined ? {} : { releaseReadingNote: l.releaseReadingNote }),\n };\n }\n const e = byKey.get(l.from);\n if (e?.v3Fields === undefined || e.v3Domains === undefined) {\n fail(l.from, \"v3Fields / v3Domains (its line is releaseReading retain)\", e?.v3Fields);\n }\n return {\n ...m,\n releaseReading: l.releaseReading as ScopeMigration[\"releaseReading\"],\n v3Fields: [...e.v3Fields],\n v3Domains: [...e.v3Domains],\n ...(e.v3FieldsNote === undefined ? {} : { v3FieldsNote: e.v3FieldsNote }),\n };\n });\n}\n","/**\n * @htilabs/platform-common-models — CVC-236 Information Scope page: UI copy + row order\n *\n * AUTO-GENERATED FILE — DO NOT EDIT BY HAND.\n * Regenerate with:\n * `python3 scripts/gen-information-scope-ui-copy.py <prototype root> <platform-prototype root>`.\n *\n * Canon (read from git objects at origin/main):\n * - ORDER: htilabstech/prototype data/cvcs/core_information_scope.yaml (the CVC-236 tree;\n * a category's `units:`, or its `groupings:`' units in grouping order).\n * - WORDS: htilabstech/platform-prototype src/data.js `sharing.scopeCatalog`\n * `sub` (per category) and `hint` (per row) — presentation text authored there and\n * preserved by id by the records repo's tools/build_information_scope_registry.py.\n * The two copies agree on every category, row and order (the generator refuses otherwise).\n * Keys are package keys (canon `.` spelled `__`), as in `coreInformationScopeSot`.\n * `src/services/__tests__/informationScopeUiCopy.test.ts` holds every key to a live SOT row.\n */\n\n/** Where this data was taken from (provenance, not compared by `--check`). */\nexport const INFORMATION_SCOPE_UI_COPY_SOURCE = {\n \"order\": {\n \"repo\": \"htilabstech/prototype\",\n \"file\": \"data/cvcs/core_information_scope.yaml\",\n \"sha\": \"395bb7aa\"\n },\n \"words\": {\n \"repo\": \"htilabstech/platform-prototype\",\n \"file\": \"src/data.js\",\n \"sha\": \"c324f715\",\n \"line\": 33875\n }\n} as const;\n\n// <data>\n/** Every category, in canon's order (package keys). */\nexport const INFORMATION_SCOPE_CATEGORY_ORDER: readonly string[] = [\n \"system\",\n \"notes\",\n \"identifying\",\n \"contact\",\n \"health_accommodation\",\n \"immigration_legal_status\",\n \"risk\",\n \"services\",\n \"instruments\",\n \"relationships_household\",\n \"offenders__identifying\",\n \"offenders__contact\",\n \"offenders__health_accommodation\",\n \"offenders__immigration_legal_status\",\n \"offenders__risk\",\n \"offenders__services\",\n \"offenders__instruments\",\n \"offenders__relationships_household\",\n \"family__identifying\",\n \"family__contact\",\n \"family__health_accommodation\",\n \"family__immigration_legal_status\",\n \"family__risk\",\n \"family__services\",\n \"family__instruments\",\n \"family__relationships_household\",\n \"others__identifying\",\n \"others__contact\",\n \"others__health_accommodation\",\n \"others__immigration_legal_status\",\n \"others__risk\",\n \"others__services\",\n \"others__instruments\",\n \"others__relationships_household\",\n \"network_associations\",\n \"commercial_activity\",\n \"investigative_work_product\",\n \"object_identifiers\",\n];\n\n/** Per category: the one-line description drawn under its title. */\nexport const INFORMATION_SCOPE_CATEGORY_SUB: Readonly<Record<string, string>> = {\n \"system\": \"Session timestamps, source info — always shared\",\n \"notes\": \"The session summary, and notes written in a session or on the case\",\n \"identifying\": \"Names, DOB, addresses, identifiers, demographics\",\n \"contact\": \"How to reach the person safely: contact info + safety preferences, the Priorities & Safety triage\",\n \"health_accommodation\": \"Health status, accommodation needs\",\n \"immigration_legal_status\": \"Immigration status, immigration applications\",\n \"risk\": \"Indicators, screening outcomes, per-instrument assessment responses, determinations, system involvement — the people who caused harm are their own branch\",\n \"services\": \"Contact history with this agency, service records, service plans + goals — three tiers of sensitivity\",\n \"instruments\": \"Initial Screen, intake screens, assessments, Findings — a Summary & outcome row and a Full questions, narratives & notes row per instrument\",\n \"relationships_household\": \"The client's account of the people around them — each relationship record, the household roster, pets; each entry names the other person as name + kind and carries nothing else about them\",\n \"offenders__identifying\": \"People who caused harm — the person's own record, grouped by kind (identifying information)\",\n \"offenders__contact\": \"People who caused harm — the person's own record, grouped by kind (contact & safety)\",\n \"offenders__health_accommodation\": \"People who caused harm — the person's own record, grouped by kind (health & accommodation)\",\n \"offenders__immigration_legal_status\": \"People who caused harm — the person's own record, grouped by kind (immigration & legal status)\",\n \"offenders__risk\": \"People who caused harm — the person's own record, grouped by kind (risk-related)\",\n \"offenders__services\": \"People who caused harm — the person's own record, grouped by kind (services & case history)\",\n \"offenders__instruments\": \"People who caused harm — the person's own record, grouped by kind (screens & assessments)\",\n \"offenders__relationships_household\": \"People who caused harm — the person's own record, grouped by kind (relationships & household)\",\n \"family__identifying\": \"Eligible family members — the person's own record, grouped by kind (identifying information)\",\n \"family__contact\": \"Eligible family members — the person's own record, grouped by kind (contact & safety)\",\n \"family__health_accommodation\": \"Eligible family members — the person's own record, grouped by kind (health & accommodation)\",\n \"family__immigration_legal_status\": \"Eligible family members — the person's own record, grouped by kind (immigration & legal status)\",\n \"family__risk\": \"Eligible family members — the person's own record, grouped by kind (risk-related)\",\n \"family__services\": \"Eligible family members — the person's own record, grouped by kind (services & case history)\",\n \"family__instruments\": \"Eligible family members — the person's own record, grouped by kind (screens & assessments)\",\n \"family__relationships_household\": \"Eligible family members — the person's own record, grouped by kind (relationships & household)\",\n \"others__identifying\": \"Other people on the case — the person's own record, grouped by kind (identifying information)\",\n \"others__contact\": \"Other people on the case — the person's own record, grouped by kind (contact & safety)\",\n \"others__health_accommodation\": \"Other people on the case — the person's own record, grouped by kind (health & accommodation)\",\n \"others__immigration_legal_status\": \"Other people on the case — the person's own record, grouped by kind (immigration & legal status)\",\n \"others__risk\": \"Other people on the case — the person's own record, grouped by kind (risk-related)\",\n \"others__services\": \"Other people on the case — the person's own record, grouped by kind (services & case history)\",\n \"others__instruments\": \"Other people on the case — the person's own record, grouped by kind (screens & assessments)\",\n \"others__relationships_household\": \"Other people on the case — the person's own record, grouped by kind (relationships & household)\",\n \"network_associations\": \"Personas, network membership, relationships, criminal-org links\",\n \"commercial_activity\": \"Ads, listings, posting activity, pricing, business fronts\",\n \"investigative_work_product\": \"Analyst determinations, dispositions, case briefs\",\n \"object_identifiers\": \"Phone numbers, vehicle identifiers, image hashes, account handles\",\n};\n\n/** Per category: its live rows in canon's order (package keys; empty when it has none). */\nexport const INFORMATION_SCOPE_ROW_ORDER: Readonly<Record<string, readonly string[]>> = {\n \"system\": [\n \"system_info\",\n ],\n \"notes\": [\n \"session_summary\",\n \"case_notes\",\n ],\n \"identifying\": [\n \"names\",\n \"dob\",\n \"addresses\",\n \"additional_ids\",\n \"demographics\",\n \"identifying__other\",\n ],\n \"contact\": [\n \"contact_info\",\n \"safe_locations\",\n \"priorities_safety\",\n \"encounter_location\",\n ],\n \"health_accommodation\": [\n \"health_status\",\n \"accommodation_needs\",\n ],\n \"immigration_legal_status\": [\n \"immigration_status\",\n \"immigration_applications\",\n ],\n \"risk\": [\n \"screen_indicators\",\n \"victimization\",\n \"system_involvement\",\n \"derived_risk_signals\",\n ],\n \"services\": [\n \"contact_history\",\n \"service_history\",\n \"plans_goals\",\n ],\n \"instruments\": [\n \"summary_initial_screen\",\n \"summary_mental_health_screen\",\n \"summary_behavioral_health_intake\",\n \"summary_trauma_and_coping_screen\",\n \"summary_ae_intake\",\n \"summary_ida\",\n \"summary_lap\",\n \"summary_danger_assessment\",\n \"summary_stalking_assessment\",\n \"summary_injury_and_strangulation\",\n \"summary_hope_scale\",\n \"summary_needs_assessment\",\n \"summary_tra\",\n \"summary_findings\",\n \"full_initial_screen\",\n \"full_mental_health_screen\",\n \"full_behavioral_health_intake\",\n \"full_trauma_and_coping_screen\",\n \"full_ae_intake\",\n \"full_ida\",\n \"full_lap\",\n \"full_danger_assessment\",\n \"full_stalking_assessment\",\n \"full_injury_and_strangulation\",\n \"full_hope_scale\",\n \"full_needs_assessment\",\n \"full_tra\",\n \"full_findings\",\n ],\n \"relationships_household\": [],\n \"offenders__identifying\": [],\n \"offenders__contact\": [\n \"offenders__safe_locations\",\n ],\n \"offenders__health_accommodation\": [],\n \"offenders__immigration_legal_status\": [],\n \"offenders__risk\": [],\n \"offenders__services\": [],\n \"offenders__instruments\": [\n \"offenders__instrument_summary\",\n \"offenders__instrument_full\",\n ],\n \"offenders__relationships_household\": [],\n \"family__identifying\": [],\n \"family__contact\": [\n \"family__safe_locations\",\n ],\n \"family__health_accommodation\": [],\n \"family__immigration_legal_status\": [],\n \"family__risk\": [],\n \"family__services\": [],\n \"family__instruments\": [\n \"family__instrument_summary\",\n \"family__instrument_full\",\n ],\n \"family__relationships_household\": [],\n \"others__identifying\": [],\n \"others__contact\": [\n \"others__safe_locations\",\n ],\n \"others__health_accommodation\": [],\n \"others__immigration_legal_status\": [],\n \"others__risk\": [],\n \"others__services\": [],\n \"others__instruments\": [\n \"others__instrument_summary\",\n \"others__instrument_full\",\n ],\n \"others__relationships_household\": [],\n \"network_associations\": [\n \"network_membership\",\n \"persona_links\",\n ],\n \"commercial_activity\": [\n \"ad_content\",\n \"commercial_patterns\",\n ],\n \"investigative_work_product\": [\n \"case_determinations\",\n \"case_lifecycle\",\n \"case_attachments\",\n ],\n \"object_identifiers\": [\n \"phone_identifiers\",\n \"object_identity_attributes\",\n ],\n};\n\n/** Per row (only rows that have one): the hint line drawn under it. */\nexport const INFORMATION_SCOPE_ROW_HINT: Readonly<Record<string, string>> = {\n \"system_info\": \"Always included\",\n \"names\": \"All logged name entries\",\n \"additional_ids\": \"Other IDs entered separately\",\n \"identifying__other\": \"Living situation · work & income · education · languages · citizenship · physical description · vehicle\",\n \"safe_locations\": \"Shelter placements + confidential program addresses\",\n \"encounter_location\": \"The session's meetup / incident location — not the survivor's own addresses (CVC-191 reasons Meet / contact + Incident)\",\n \"immigration_status\": \"Visa type + birth country + relevant flags\",\n \"commercial_patterns\": \"Pricing, schedule, venues\",\n \"case_attachments\": \"Content-dependent — attachment handling flags govern\",\n \"object_identity_attributes\": \"Names, trade names, ages\",\n};\n// </data>\n","/**\n * @htilabs/platform-common-models — CVC-236 Information Scope page: UI copy + row order\n *\n * The words and order the prototype's Information scope page draws that the\n * CVC-236 SOT (`coreInformationScopeSot`) does not carry:\n *\n * - a category's one-line description under its title (`scopeCategorySub`),\n * - the hint line under some rows (`scopeRowHint`),\n * - the rows of a category in canon's order (`scopeRowDisplayOrder`,\n * `sortScopeRows`) — the SOT lists a category's children in code order,\n * which differs from canon's tree order in Narrative notes and Health &\n * accommodation.\n *\n * The data is GENERATED (`src/generated/informationScopeUiCopy.ts`, by\n * `scripts/gen-information-scope-ui-copy.py`): order from the records\n * repo's CVC-236 tree, words from the Platform prototype's\n * `sharing.scopeCatalog` (`sub` / `hint`). Text is carried as written there.\n *\n * Every function takes either spelling of a row: the package key\n * (`offenders__contact`) or the selection code (`offenders.contact`).\n * Additive: nothing that reads the SOT changes.\n */\n\nimport {\n INFORMATION_SCOPE_CATEGORY_ORDER,\n INFORMATION_SCOPE_CATEGORY_SUB,\n INFORMATION_SCOPE_ROW_HINT,\n INFORMATION_SCOPE_ROW_ORDER,\n INFORMATION_SCOPE_UI_COPY_SOURCE,\n} from \"../generated/informationScopeUiCopy.js\";\n\nexport {\n INFORMATION_SCOPE_CATEGORY_ORDER,\n INFORMATION_SCOPE_CATEGORY_SUB,\n INFORMATION_SCOPE_ROW_HINT,\n INFORMATION_SCOPE_ROW_ORDER,\n INFORMATION_SCOPE_UI_COPY_SOURCE,\n};\n\nconst own = (o: object, k: string): boolean => Object.prototype.hasOwnProperty.call(o, k);\n\n/** A selection code or package key → its package key (`.` spelled `__`). */\nfunction toKey(codeOrKey: string): string {\n return codeOrKey.replace(/\\./g, \"__\");\n}\n\n/** A package key → its selection code (`__` read as `.`). */\nfunction toCode(key: string): string {\n return key.replace(/__/g, \".\");\n}\n\n/** The one-line description under a category's title, or `undefined`. */\nexport function scopeCategorySub(category: string): string | undefined {\n const k = toKey(category);\n return own(INFORMATION_SCOPE_CATEGORY_SUB, k) ? INFORMATION_SCOPE_CATEGORY_SUB[k] : undefined;\n}\n\n/** The hint line under a row, or `undefined` when the row has none. */\nexport function scopeRowHint(row: string): string | undefined {\n const k = toKey(row);\n return own(INFORMATION_SCOPE_ROW_HINT, k) ? INFORMATION_SCOPE_ROW_HINT[k] : undefined;\n}\n\n/**\n * A category's live rows in canon's order, as selection codes\n * (`identifying.other`, `offenders.safe_locations`). Empty for an unknown\n * category or one with no rows. For Screens & assessments: the Summary &\n * outcome rows, then the Full rows, each in instrument order.\n */\nexport function scopeRowDisplayOrder(category: string): readonly string[] {\n const k = toKey(category);\n return own(INFORMATION_SCOPE_ROW_ORDER, k) ? INFORMATION_SCOPE_ROW_ORDER[k].map(toCode) : [];\n}\n\n/**\n * `rows` (either spelling, returned as given) sorted into canon's order for\n * `category`. Rows the order does not name keep their relative order and\n * come last. Does not modify `rows`.\n */\nexport function sortScopeRows<T extends string>(category: string, rows: readonly T[]): T[] {\n const k = toKey(category);\n const order = own(INFORMATION_SCOPE_ROW_ORDER, k) ? INFORMATION_SCOPE_ROW_ORDER[k] : [];\n const rank = new Map(order.map((r, i) => [r, i]));\n return rows\n .map((r, i) => ({ r, i, at: rank.get(toKey(r)) ?? order.length }))\n .sort((a, b) => a.at - b.at || a.i - b.i)\n .map((x) => x.r);\n}\n\n/** `categories` (either spelling, returned as given) in canon's order; unknown last. */\nexport function sortScopeCategories<T extends string>(categories: readonly T[]): T[] {\n const rank = new Map(INFORMATION_SCOPE_CATEGORY_ORDER.map((c, i) => [c, i]));\n const n = INFORMATION_SCOPE_CATEGORY_ORDER.length;\n return categories\n .map((c, i) => ({ c, i, at: rank.get(toKey(c)) ?? n }))\n .sort((a, b) => a.at - b.at || a.i - b.i)\n .map((x) => x.c);\n}\n"],"mappings":";AAkEO,IAAM,4BAA4B;AAalC,IAAM,sCAAyD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AAGnF,IAAM,gCAAgC;AAsStC,IAAM,uBAAuB,CAAC,QACnC,QAAQ,UAAa,IAAI,cAAc,IAAI,WAAW;AAQjD,IAAM,iBAAiB,CAAC,QAC7B,QAAQ,UAAa,IAAI,YAAY;AAGhC,IAAM,uBAAuB,CAAC,QACnC,QAAQ,UAAa,IAAI,YAAY;AAYhC,SAAS,cAAc,QAGV;AAClB,MAAI,OAAO,WAAY,QAAO;AAC9B,MAAI,OAAO,YAAa,QAAO;AAC/B,SAAO;AACT;AAIA,IAAM,eAAoC,oBAAI,IAAqB,CAAC,aAAa,UAAU,QAAQ,CAAC;AACpG,IAAM,qBAA0C,oBAAI,IAA0B;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,IAAM,kBAAuC,oBAAI,IAAwB;AAAA,EACvE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,IAAM,gBAA+C,oBAAI,IAAsB;AAA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,EAAE,EACrD,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EACvC,IAAI,CAAC,MAAM,EAAE,CAAC;AACnB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/services/informationScopeResolver.ts","../../src/services/informationScopeSot.ts","../../src/generated/informationScopeUiCopy.ts","../../src/services/informationScopeUiCopy.ts","../../src/roiScopePresets/index.ts"],"sourcesContent":["/**\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 * resolver reads no v2 → v3 table, so those lists are unsupported and include\n * nothing (fail closed). The one exception is not here: a stored sharing POLICY\n * list with no stamp is read by `readStoredPolicyScope` (sharing-ceiling),\n * which carries it through canon's v2 → v3 category lines first.\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/**\n * The `category_rest` row (rule 3): it carries the facts filed on its category,\n * and is covered with it. Since canon's re-ruling of 2026-10-18 it is an ORDINARY\n * selectable row (\"Other identifying details\"); the row type is only the marker\n * the send path reads.\n */\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 * @htilabs/platform-common-models — CVC-236 SOT → information-scope resolver binding\n *\n * Maps the `core_information_scope` SOT envelope (`coreInformationScope.v2.1.1.json`,\n * exported as `coreInformationScopeSot` from `/cvcs`) into the resolver's\n * input shapes. Pure and dependency-free: the caller passes the envelope.\n *\n * The SOT keys a row by its package key (`offenders__risk`, `identifying__other`:\n * canon's dotted codes with `.` spelled `__`) and by a seven-segment wire code;\n * a stored selection holds canon's dotted code (`offenders.risk`). The\n * adapter reads every key through the entry's `canonicalCode` (present on the\n * dotted rows) and falls back to `__` → `.` for a key with no entry.\n *\n * Rows: the live v4 tree only (`status` `as_today` / `new`). The retired\n * tombstones are left out — a stored retired code reads through the\n * migration table, which names every tombstone — and so is the CVC\n * missingness group (`missingness_root` and its children), which is not a\n * scope row. A live entry missing a field the resolver needs throws: binding\n * fails closed rather than guess.\n *\n * Migrations: `migrations.table`, with each line's release-grain fields\n * (`releaseReading` / `policyReading` / `informational`, Crysta's ruling of\n * 2026-10-09). A `retain` line carries the v3 field membership of its `from`\n * code, read from that code's ENTRY (`v3Fields` / `v3Domains` /\n * `v3FieldsNote`, on the retired tombstone), so the SOT states it once. A\n * `retain` line whose entry has no `v3Fields` throws: binding fails closed.\n *\n * Usage:\n * ```ts\n * import { coreInformationScopeSot } from \"@htilabs/platform-common-models/cvcs\";\n * import {\n * createInformationScopeResolver, scopeRowsFromSot, scopeMigrationsFromSot,\n * } from \"@htilabs/platform-common-models/information-scope\";\n *\n * const scope = createInformationScopeResolver({\n * rows: scopeRowsFromSot(coreInformationScopeSot),\n * migrations: scopeMigrationsFromSot(coreInformationScopeSot),\n * });\n * ```\n */\n\nimport type {\n ScopeKindBranch,\n ScopeMigration,\n ScopeMigrationRule,\n ScopeRow,\n ScopeRowStatus,\n ScopeRowType,\n ScopeSpecialDataType,\n} from \"./informationScopeResolver.js\";\n\n/** The SOT entry fields the adapter reads (structural, so the JSON import binds). */\nexport interface CoreInformationScopeSotEntry {\n key: string;\n canonicalCode?: string;\n parentKey?: string | null;\n rowType?: string;\n kindBranch?: string | null;\n kindRow?: string;\n apps?: { pave: boolean; thread: boolean; leads: boolean };\n selectable?: boolean;\n shareableDefault?: boolean;\n platformFloor?: boolean;\n levelFloor?: number;\n specialDataType?: string;\n status?: string;\n replacesV3?: readonly string[];\n /** On a tombstone: its RESTRICTION reading; the table's `subtract` line is what binds. */\n restrictionSuccessors?: readonly string[];\n /** On a `releaseReading: \"retain\"` line's `from` entry: its v3 fields (field ids). */\n v3Fields?: readonly string[];\n /** Their assertion domains — v3 CATEGORY grain (the field family), not the unit's membership. */\n v3Domains?: readonly string[];\n v3FieldsNote?: string;\n}\n\nexport interface CoreInformationScopeSotMigrationLine {\n from: string;\n to: readonly string[];\n rule: string;\n note?: string;\n widens?: boolean;\n releaseReading?: string;\n releaseReadingNote?: string;\n policyReading?: string;\n informational?: boolean;\n}\n\nexport interface CoreInformationScopeSot {\n entries: readonly CoreInformationScopeSotEntry[];\n migrations?: { table: readonly CoreInformationScopeSotMigrationLine[] };\n}\n\nconst ROW_TYPES: ReadonlySet<string> = new Set<ScopeRowType>([\n \"branch\",\n \"category\",\n \"subcategory\",\n \"sub-category\",\n \"person_type\",\n \"category_rest\",\n \"instrument row\",\n]);\nconst KIND_BRANCHES: ReadonlySet<string> = new Set([\n \"client\",\n \"offenders\",\n \"family\",\n \"others\",\n \"leads\",\n]);\nconst LIVE: ReadonlySet<string> = new Set<ScopeRowStatus>([\"as_today\", \"new\"]);\nconst MISSINGNESS_ROOT = \"missingness_root\";\n\n/** Package key → canon scope code, through `canonicalCode`. */\nfunction keyReader(sot: CoreInformationScopeSot): (key: string) => string {\n const byKey = new Map(sot.entries.map((e) => [e.key, e.canonicalCode ?? e.key]));\n return (key) => byKey.get(key) ?? key.replace(/__/g, \".\");\n}\n\nfunction fail(key: string, field: string, value: unknown): never {\n throw new TypeError(\n `information scope SOT: live entry \"${key}\" has ${field} ${JSON.stringify(value)}`,\n );\n}\n\n/** The live v4 tree rows of a CVC-236 SOT, in the resolver's selection-code space. */\nexport function scopeRowsFromSot(sot: CoreInformationScopeSot): ScopeRow[] {\n const code = keyReader(sot);\n const missingness = new Set(\n sot.entries\n .filter((e) => e.key === MISSINGNESS_ROOT || e.parentKey === MISSINGNESS_ROOT)\n .map((e) => e.key),\n );\n const rows: ScopeRow[] = [];\n for (const e of sot.entries) {\n if (missingness.has(e.key)) continue;\n if (e.status === \"retired\") continue;\n if (e.status === undefined || !LIVE.has(e.status)) fail(e.key, \"status\", e.status);\n if (e.rowType === undefined || !ROW_TYPES.has(e.rowType)) fail(e.key, \"rowType\", e.rowType);\n const kindBranch = e.kindBranch ?? null;\n if (kindBranch !== null && !KIND_BRANCHES.has(kindBranch)) fail(e.key, \"kindBranch\", kindBranch);\n if (e.apps === undefined) fail(e.key, \"apps\", e.apps);\n for (const b of [\"selectable\", \"shareableDefault\", \"platformFloor\"] as const) {\n if (typeof e[b] !== \"boolean\") fail(e.key, b, e[b]);\n }\n if (e.levelFloor !== 1 && e.levelFloor !== 3) fail(e.key, \"levelFloor\", e.levelFloor);\n if (e.specialDataType === undefined) fail(e.key, \"specialDataType\", e.specialDataType);\n const row: ScopeRow = {\n scopeCode: code(e.key),\n parentScopeCode: e.parentKey ? code(e.parentKey) : null,\n rowType: e.rowType as ScopeRowType,\n kindBranch: kindBranch as ScopeKindBranch,\n apps: { pave: e.apps.pave, thread: e.apps.thread, leads: e.apps.leads },\n selectable: e.selectable as boolean,\n shareableDefault: e.shareableDefault as boolean,\n platformFloor: e.platformFloor as boolean,\n levelFloor: e.levelFloor,\n specialDataType: e.specialDataType as ScopeSpecialDataType,\n status: e.status as ScopeRowStatus,\n replacesV3: [...(e.replacesV3 ?? [])],\n };\n if (e.kindRow !== undefined) row.kindRow = code(e.kindRow);\n rows.push(row);\n }\n return rows;\n}\n\n/** The v3 → v4 from-to table of a CVC-236 SOT (`migrations.table`), in selection codes. */\nexport function scopeMigrationsFromSot(sot: CoreInformationScopeSot): ScopeMigration[] {\n const code = keyReader(sot);\n const byKey = new Map(sot.entries.map((e) => [e.key, e]));\n return (sot.migrations?.table ?? []).map((l) => {\n const m: ScopeMigration = {\n from: code(l.from),\n to: l.to.map(code),\n rule: l.rule as ScopeMigrationRule,\n ...(l.note === undefined ? {} : { note: l.note }),\n ...(l.widens === undefined ? {} : { widens: l.widens }),\n ...(l.informational === undefined ? {} : { informational: l.informational }),\n ...(l.policyReading === undefined\n ? {}\n : { policyReading: l.policyReading as ScopeMigration[\"policyReading\"] }),\n };\n if (l.releaseReading === undefined) return m;\n if (l.releaseReading !== \"retain\") {\n return {\n ...m,\n releaseReading: l.releaseReading as ScopeMigration[\"releaseReading\"],\n ...(l.releaseReadingNote === undefined ? {} : { releaseReadingNote: l.releaseReadingNote }),\n };\n }\n const e = byKey.get(l.from);\n if (e?.v3Fields === undefined || e.v3Domains === undefined) {\n fail(l.from, \"v3Fields / v3Domains (its line is releaseReading retain)\", e?.v3Fields);\n }\n return {\n ...m,\n releaseReading: l.releaseReading as ScopeMigration[\"releaseReading\"],\n v3Fields: [...e.v3Fields],\n v3Domains: [...e.v3Domains],\n ...(e.v3FieldsNote === undefined ? {} : { v3FieldsNote: e.v3FieldsNote }),\n };\n });\n}\n","/**\n * @htilabs/platform-common-models — CVC-236 Information Scope page: UI copy + row order\n *\n * AUTO-GENERATED FILE — DO NOT EDIT BY HAND.\n * Regenerate with:\n * `python3 scripts/gen-information-scope-ui-copy.py <prototype root> <platform-prototype root>`.\n *\n * Canon (read from git objects at origin/main):\n * - ORDER: htilabstech/prototype data/cvcs/core_information_scope.yaml (the CVC-236 tree;\n * a category's `units:`, or its `groupings:`' units in grouping order).\n * - WORDS: htilabstech/platform-prototype src/data.js `sharing.scopeCatalog`\n * `sub` (per category) and `hint` (per row) — presentation text authored there and\n * preserved by id by the records repo's tools/build_information_scope_registry.py.\n * The two copies agree on every category, row and order (the generator refuses otherwise).\n * Keys are package keys (canon `.` spelled `__`), as in `coreInformationScopeSot`.\n * `src/services/__tests__/informationScopeUiCopy.test.ts` holds every key to a live SOT row.\n */\n\n/** Where this data was taken from (provenance, not compared by `--check`). */\nexport const INFORMATION_SCOPE_UI_COPY_SOURCE = {\n \"order\": {\n \"repo\": \"htilabstech/prototype\",\n \"file\": \"data/cvcs/core_information_scope.yaml\",\n \"sha\": \"395bb7aa\"\n },\n \"words\": {\n \"repo\": \"htilabstech/platform-prototype\",\n \"file\": \"src/data.js\",\n \"sha\": \"c324f715\",\n \"line\": 33875\n }\n} as const;\n\n// <data>\n/** Every category, in canon's order (package keys). */\nexport const INFORMATION_SCOPE_CATEGORY_ORDER: readonly string[] = [\n \"system\",\n \"notes\",\n \"identifying\",\n \"contact\",\n \"health_accommodation\",\n \"immigration_legal_status\",\n \"risk\",\n \"services\",\n \"instruments\",\n \"relationships_household\",\n \"offenders__identifying\",\n \"offenders__contact\",\n \"offenders__health_accommodation\",\n \"offenders__immigration_legal_status\",\n \"offenders__risk\",\n \"offenders__services\",\n \"offenders__instruments\",\n \"offenders__relationships_household\",\n \"family__identifying\",\n \"family__contact\",\n \"family__health_accommodation\",\n \"family__immigration_legal_status\",\n \"family__risk\",\n \"family__services\",\n \"family__instruments\",\n \"family__relationships_household\",\n \"others__identifying\",\n \"others__contact\",\n \"others__health_accommodation\",\n \"others__immigration_legal_status\",\n \"others__risk\",\n \"others__services\",\n \"others__instruments\",\n \"others__relationships_household\",\n \"network_associations\",\n \"commercial_activity\",\n \"investigative_work_product\",\n \"object_identifiers\",\n];\n\n/** Per category: the one-line description drawn under its title. */\nexport const INFORMATION_SCOPE_CATEGORY_SUB: Readonly<Record<string, string>> = {\n \"system\": \"Session timestamps, source info — always shared\",\n \"notes\": \"The session summary, and notes written in a session or on the case\",\n \"identifying\": \"Names, DOB, addresses, identifiers, demographics\",\n \"contact\": \"How to reach the person safely: contact info + safety preferences, the Priorities & Safety triage\",\n \"health_accommodation\": \"Health status, accommodation needs\",\n \"immigration_legal_status\": \"Immigration status, immigration applications\",\n \"risk\": \"Indicators, screening outcomes, per-instrument assessment responses, determinations, system involvement — the people who caused harm are their own branch\",\n \"services\": \"Contact history with this agency, service records, service plans + goals — three tiers of sensitivity\",\n \"instruments\": \"Initial Screen, intake screens, assessments, Findings — a Summary & outcome row and a Full questions, narratives & notes row per instrument\",\n \"relationships_household\": \"The client's account of the people around them — each relationship record, the household roster, pets; each entry names the other person as name + kind and carries nothing else about them\",\n \"offenders__identifying\": \"People who caused harm — the person's own record, grouped by kind (identifying information)\",\n \"offenders__contact\": \"People who caused harm — the person's own record, grouped by kind (contact & safety)\",\n \"offenders__health_accommodation\": \"People who caused harm — the person's own record, grouped by kind (health & accommodation)\",\n \"offenders__immigration_legal_status\": \"People who caused harm — the person's own record, grouped by kind (immigration & legal status)\",\n \"offenders__risk\": \"People who caused harm — the person's own record, grouped by kind (risk-related)\",\n \"offenders__services\": \"People who caused harm — the person's own record, grouped by kind (services & case history)\",\n \"offenders__instruments\": \"People who caused harm — the person's own record, grouped by kind (screens & assessments)\",\n \"offenders__relationships_household\": \"People who caused harm — the person's own record, grouped by kind (relationships & household)\",\n \"family__identifying\": \"Eligible family members — the person's own record, grouped by kind (identifying information)\",\n \"family__contact\": \"Eligible family members — the person's own record, grouped by kind (contact & safety)\",\n \"family__health_accommodation\": \"Eligible family members — the person's own record, grouped by kind (health & accommodation)\",\n \"family__immigration_legal_status\": \"Eligible family members — the person's own record, grouped by kind (immigration & legal status)\",\n \"family__risk\": \"Eligible family members — the person's own record, grouped by kind (risk-related)\",\n \"family__services\": \"Eligible family members — the person's own record, grouped by kind (services & case history)\",\n \"family__instruments\": \"Eligible family members — the person's own record, grouped by kind (screens & assessments)\",\n \"family__relationships_household\": \"Eligible family members — the person's own record, grouped by kind (relationships & household)\",\n \"others__identifying\": \"Other people on the case — the person's own record, grouped by kind (identifying information)\",\n \"others__contact\": \"Other people on the case — the person's own record, grouped by kind (contact & safety)\",\n \"others__health_accommodation\": \"Other people on the case — the person's own record, grouped by kind (health & accommodation)\",\n \"others__immigration_legal_status\": \"Other people on the case — the person's own record, grouped by kind (immigration & legal status)\",\n \"others__risk\": \"Other people on the case — the person's own record, grouped by kind (risk-related)\",\n \"others__services\": \"Other people on the case — the person's own record, grouped by kind (services & case history)\",\n \"others__instruments\": \"Other people on the case — the person's own record, grouped by kind (screens & assessments)\",\n \"others__relationships_household\": \"Other people on the case — the person's own record, grouped by kind (relationships & household)\",\n \"network_associations\": \"Personas, network membership, relationships, criminal-org links\",\n \"commercial_activity\": \"Ads, listings, posting activity, pricing, business fronts\",\n \"investigative_work_product\": \"Analyst determinations, dispositions, case briefs\",\n \"object_identifiers\": \"Phone numbers, vehicle identifiers, image hashes, account handles\",\n};\n\n/** Per category: its live rows in canon's order (package keys; empty when it has none). */\nexport const INFORMATION_SCOPE_ROW_ORDER: Readonly<Record<string, readonly string[]>> = {\n \"system\": [\n \"system_info\",\n ],\n \"notes\": [\n \"session_summary\",\n \"case_notes\",\n ],\n \"identifying\": [\n \"names\",\n \"dob\",\n \"addresses\",\n \"additional_ids\",\n \"demographics\",\n \"identifying__other\",\n ],\n \"contact\": [\n \"contact_info\",\n \"safe_locations\",\n \"priorities_safety\",\n \"encounter_location\",\n ],\n \"health_accommodation\": [\n \"health_status\",\n \"accommodation_needs\",\n ],\n \"immigration_legal_status\": [\n \"immigration_status\",\n \"immigration_applications\",\n ],\n \"risk\": [\n \"screen_indicators\",\n \"victimization\",\n \"system_involvement\",\n \"derived_risk_signals\",\n ],\n \"services\": [\n \"contact_history\",\n \"service_history\",\n \"plans_goals\",\n ],\n \"instruments\": [\n \"summary_initial_screen\",\n \"summary_mental_health_screen\",\n \"summary_behavioral_health_intake\",\n \"summary_trauma_and_coping_screen\",\n \"summary_ae_intake\",\n \"summary_ida\",\n \"summary_lap\",\n \"summary_danger_assessment\",\n \"summary_stalking_assessment\",\n \"summary_injury_and_strangulation\",\n \"summary_hope_scale\",\n \"summary_needs_assessment\",\n \"summary_tra\",\n \"summary_findings\",\n \"full_initial_screen\",\n \"full_mental_health_screen\",\n \"full_behavioral_health_intake\",\n \"full_trauma_and_coping_screen\",\n \"full_ae_intake\",\n \"full_ida\",\n \"full_lap\",\n \"full_danger_assessment\",\n \"full_stalking_assessment\",\n \"full_injury_and_strangulation\",\n \"full_hope_scale\",\n \"full_needs_assessment\",\n \"full_tra\",\n \"full_findings\",\n ],\n \"relationships_household\": [],\n \"offenders__identifying\": [],\n \"offenders__contact\": [\n \"offenders__safe_locations\",\n ],\n \"offenders__health_accommodation\": [],\n \"offenders__immigration_legal_status\": [],\n \"offenders__risk\": [],\n \"offenders__services\": [],\n \"offenders__instruments\": [\n \"offenders__instrument_summary\",\n \"offenders__instrument_full\",\n ],\n \"offenders__relationships_household\": [],\n \"family__identifying\": [],\n \"family__contact\": [\n \"family__safe_locations\",\n ],\n \"family__health_accommodation\": [],\n \"family__immigration_legal_status\": [],\n \"family__risk\": [],\n \"family__services\": [],\n \"family__instruments\": [\n \"family__instrument_summary\",\n \"family__instrument_full\",\n ],\n \"family__relationships_household\": [],\n \"others__identifying\": [],\n \"others__contact\": [\n \"others__safe_locations\",\n ],\n \"others__health_accommodation\": [],\n \"others__immigration_legal_status\": [],\n \"others__risk\": [],\n \"others__services\": [],\n \"others__instruments\": [\n \"others__instrument_summary\",\n \"others__instrument_full\",\n ],\n \"others__relationships_household\": [],\n \"network_associations\": [\n \"network_membership\",\n \"persona_links\",\n ],\n \"commercial_activity\": [\n \"ad_content\",\n \"commercial_patterns\",\n ],\n \"investigative_work_product\": [\n \"case_determinations\",\n \"case_lifecycle\",\n \"case_attachments\",\n ],\n \"object_identifiers\": [\n \"phone_identifiers\",\n \"object_identity_attributes\",\n ],\n};\n\n/** Per row (only rows that have one): the hint line drawn under it. */\nexport const INFORMATION_SCOPE_ROW_HINT: Readonly<Record<string, string>> = {\n \"system_info\": \"Always included\",\n \"names\": \"All logged name entries\",\n \"additional_ids\": \"Other IDs entered separately\",\n \"identifying__other\": \"Living situation · work & income · education · languages · citizenship · physical description · vehicle\",\n \"safe_locations\": \"Shelter placements + confidential program addresses\",\n \"encounter_location\": \"The session's meetup / incident location — not the survivor's own addresses (CVC-191 reasons Meet / contact + Incident)\",\n \"immigration_status\": \"Visa type + birth country + relevant flags\",\n \"commercial_patterns\": \"Pricing, schedule, venues\",\n \"case_attachments\": \"Content-dependent — attachment handling flags govern\",\n \"object_identity_attributes\": \"Names, trade names, ages\",\n};\n// </data>\n","/**\n * @htilabs/platform-common-models — CVC-236 Information Scope page: UI copy + row order\n *\n * The words and order the prototype's Information scope page draws that the\n * CVC-236 SOT (`coreInformationScopeSot`) does not carry:\n *\n * - a category's one-line description under its title (`scopeCategorySub`),\n * - the hint line under some rows (`scopeRowHint`),\n * - the rows of a category in canon's order (`scopeRowDisplayOrder`,\n * `sortScopeRows`) — the SOT lists a category's children in code order,\n * which differs from canon's tree order in Narrative notes and Health &\n * accommodation.\n *\n * The data is GENERATED (`src/generated/informationScopeUiCopy.ts`, by\n * `scripts/gen-information-scope-ui-copy.py`): order from the records\n * repo's CVC-236 tree, words from the Platform prototype's\n * `sharing.scopeCatalog` (`sub` / `hint`). Text is carried as written there.\n *\n * Every function takes either spelling of a row: the package key\n * (`offenders__contact`) or the selection code (`offenders.contact`).\n * Additive: nothing that reads the SOT changes.\n */\n\nimport {\n INFORMATION_SCOPE_CATEGORY_ORDER,\n INFORMATION_SCOPE_CATEGORY_SUB,\n INFORMATION_SCOPE_ROW_HINT,\n INFORMATION_SCOPE_ROW_ORDER,\n INFORMATION_SCOPE_UI_COPY_SOURCE,\n} from \"../generated/informationScopeUiCopy.js\";\n\nexport {\n INFORMATION_SCOPE_CATEGORY_ORDER,\n INFORMATION_SCOPE_CATEGORY_SUB,\n INFORMATION_SCOPE_ROW_HINT,\n INFORMATION_SCOPE_ROW_ORDER,\n INFORMATION_SCOPE_UI_COPY_SOURCE,\n};\n\nconst own = (o: object, k: string): boolean => Object.prototype.hasOwnProperty.call(o, k);\n\n/** A selection code or package key → its package key (`.` spelled `__`). */\nfunction toKey(codeOrKey: string): string {\n return codeOrKey.replace(/\\./g, \"__\");\n}\n\n/** A package key → its selection code (`__` read as `.`). */\nfunction toCode(key: string): string {\n return key.replace(/__/g, \".\");\n}\n\n/** The one-line description under a category's title, or `undefined`. */\nexport function scopeCategorySub(category: string): string | undefined {\n const k = toKey(category);\n return own(INFORMATION_SCOPE_CATEGORY_SUB, k) ? INFORMATION_SCOPE_CATEGORY_SUB[k] : undefined;\n}\n\n/** The hint line under a row, or `undefined` when the row has none. */\nexport function scopeRowHint(row: string): string | undefined {\n const k = toKey(row);\n return own(INFORMATION_SCOPE_ROW_HINT, k) ? INFORMATION_SCOPE_ROW_HINT[k] : undefined;\n}\n\n/**\n * A category's live rows in canon's order, as selection codes\n * (`identifying.other`, `offenders.safe_locations`). Empty for an unknown\n * category or one with no rows. For Screens & assessments: the Summary &\n * outcome rows, then the Full rows, each in instrument order.\n */\nexport function scopeRowDisplayOrder(category: string): readonly string[] {\n const k = toKey(category);\n return own(INFORMATION_SCOPE_ROW_ORDER, k) ? INFORMATION_SCOPE_ROW_ORDER[k].map(toCode) : [];\n}\n\n/**\n * `rows` (either spelling, returned as given) sorted into canon's order for\n * `category`. Rows the order does not name keep their relative order and\n * come last. Does not modify `rows`.\n */\nexport function sortScopeRows<T extends string>(category: string, rows: readonly T[]): T[] {\n const k = toKey(category);\n const order = own(INFORMATION_SCOPE_ROW_ORDER, k) ? INFORMATION_SCOPE_ROW_ORDER[k] : [];\n const rank = new Map(order.map((r, i) => [r, i]));\n return rows\n .map((r, i) => ({ r, i, at: rank.get(toKey(r)) ?? order.length }))\n .sort((a, b) => a.at - b.at || a.i - b.i)\n .map((x) => x.r);\n}\n\n/** `categories` (either spelling, returned as given) in canon's order; unknown last. */\nexport function sortScopeCategories<T extends string>(categories: readonly T[]): T[] {\n const rank = new Map(INFORMATION_SCOPE_CATEGORY_ORDER.map((c, i) => [c, i]));\n const n = INFORMATION_SCOPE_CATEGORY_ORDER.length;\n return categories\n .map((c, i) => ({ c, i, at: rank.get(toKey(c)) ?? n }))\n .sort((a, b) => a.at - b.at || a.i - b.i)\n .map((x) => x.c);\n}\n","/**\n * @htilabs/platform-common-models — the release (ROI) wizard's quick-fill scope presets\n *\n * ONE home for the three presets the ROI wizard offers staff when they record what a\n * survivor authorizes — \"Full case collaboration\" / \"Name + risk information\" /\n * \"Identifying info only\" — and that the Admin Hub's Information scope tab lists under\n * \"Default scope presets\". Every app reads this export; no app keeps its own list\n * (Crysta, 2026-11-16: one vocabulary, one source, never hand-copied).\n *\n * Source of truth: the prototype monolith's `HTI_ROI_SCOPE_PRESETS` (ids, item lists and\n * their order, stamped `HTI_ROI_SCOPE_PRESETS_VERSION`) and the wizard's pill words\n * (`presetChip(...)`), at the commit in `ROI_SCOPE_PRESETS_SOURCE`. The monolith carries no\n * description and no on/off for a preset; `description` and `enabled` are the Admin Hub\n * prototype's (`data.sharing.scopePresets`). `src/__sot__/roiScopePresets.pin.json` is the\n * independently derived snapshot (`npm run sot:pins -- --only=roiScopePresets`);\n * `roi-scope-presets-canon.test.ts` holds this module equal to it and resolves every item\n * against the published CVC-236 v4 tree.\n *\n * Item ids are CVC-236 `core-information_scope` row codes on tree version 4 (canon's dotted\n * spelling — every preset row today is a plain key). A code covers every row beneath it,\n * so `family` is the whole Eligible-family-member kind. Instrument Summary rows are\n * `selectable: false` in the tree — no picker offers one alone — but canon lists the\n * presets per row on purpose, and the presets keep them.\n *\n * `enabled` is display-only in the prototype (the Admin Hub's \"Enabled\" chip; no control in\n * either prototype changes it), so it is the default here and nothing stores it per account.\n *\n * Pure: no mongoose, no I/O. Browser-safe through `./information-scope`.\n */\n\n/** The three fixed preset ids, in the wizard's pill order. */\nexport const ROI_SCOPE_PRESET_IDS = [\"full_collab\", \"risk_only\", \"identifying\"] as const;\nexport type RoiScopePresetId = (typeof ROI_SCOPE_PRESET_IDS)[number];\n\n/** The CVC-236 tree version every preset list is authored on (canon `HTI_ROI_SCOPE_PRESETS_VERSION`). */\nexport const ROI_SCOPE_PRESETS_SCOPE_VERSION = 4 as const;\n\n/** Where the presets were copied from (the pin restates it). */\nexport const ROI_SCOPE_PRESETS_SOURCE = {\n repo: \"htilabstech/prototype\",\n file: \"HTI-LEADS-PAVE-Thread-prototype.html\",\n commit: \"ba5ded6de6affdb11054a18a8a8a561be987a403\",\n mirror: { repo: \"htilabstech/platform-prototype\", file: \"src/data.js\", commit: \"398fb24\" },\n} as const;\n\nexport interface RoiScopePresetDefinition {\n readonly id: RoiScopePresetId;\n /** The wizard's pill word. */\n readonly label: string;\n /** The Admin Hub's one-line description. */\n readonly description: string;\n /** Whether the preset is offered by default (display-only in the prototype). */\n readonly enabled: boolean;\n /** CVC-236 v4 row codes, in canon's order; `system_info` included. */\n readonly itemIds: readonly string[];\n}\n\nconst freeze = (p: RoiScopePresetDefinition): RoiScopePresetDefinition =>\n Object.freeze({ ...p, itemIds: Object.freeze([...p.itemIds]) });\n\n/** The three ROI scope presets, canon's lists verbatim, in pill order. */\nexport const ROI_SCOPE_PRESETS: readonly RoiScopePresetDefinition[] = Object.freeze([\n freeze({\n id: \"full_collab\",\n label: \"Full case collaboration\",\n description: \"Broad packet for coordinated providers working the case together.\",\n enabled: true,\n itemIds: [\n \"names\",\n \"dob\",\n \"addresses\",\n \"demographics\",\n \"screen_indicators\",\n \"victimization\",\n \"summary_initial_screen\",\n \"summary_ae_intake\",\n \"summary_ida\",\n \"summary_lap\",\n \"summary_danger_assessment\",\n \"summary_stalking_assessment\",\n \"summary_injury_and_strangulation\",\n \"summary_tra\",\n \"summary_hope_scale\",\n \"summary_needs_assessment\",\n \"full_ida\",\n \"contact_info\",\n \"priorities_safety\",\n \"encounter_location\",\n \"contact_history\",\n \"service_history\",\n \"plans_goals\",\n \"session_summary\",\n \"case_notes\",\n \"relationships_household\",\n \"family\",\n \"system_info\",\n ],\n }),\n freeze({\n id: \"risk_only\",\n label: \"Name + risk information\",\n description: \"Minimal identifying info — risk + screening for a coordinated handoff.\",\n enabled: true,\n itemIds: [\n \"names\",\n \"screen_indicators\",\n \"victimization\",\n \"summary_initial_screen\",\n \"summary_ae_intake\",\n \"summary_ida\",\n \"summary_lap\",\n \"summary_danger_assessment\",\n \"summary_stalking_assessment\",\n \"summary_injury_and_strangulation\",\n \"system_info\",\n ],\n }),\n freeze({\n id: \"identifying\",\n label: \"Identifying info only\",\n description: \"Used for verification with law enforcement / medical partners.\",\n enabled: true,\n itemIds: [\"names\", \"dob\", \"addresses\", \"additional_ids\", \"demographics\", \"system_info\"],\n }),\n]);\n\n/** Each preset's pill word, by id. */\nexport const ROI_SCOPE_PRESET_LABELS: Readonly<Record<RoiScopePresetId, string>> = Object.freeze(\n Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.label])) as Record<\n RoiScopePresetId,\n string\n >,\n);\n\n/** Each preset's item list, by id. */\nexport const ROI_SCOPE_PRESET_ITEM_IDS: Readonly<Record<RoiScopePresetId, readonly string[]>> =\n Object.freeze(\n Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.itemIds])) as Record<\n RoiScopePresetId,\n readonly string[]\n >,\n );\n\n/** Whether `id` names one of the three presets. */\nexport function isRoiScopePresetId(id: unknown): id is RoiScopePresetId {\n return typeof id === \"string\" && (ROI_SCOPE_PRESET_IDS as readonly string[]).includes(id);\n}\n\n/** The preset with this id, or `undefined`. */\nexport function roiScopePresetById(id: string): RoiScopePresetDefinition | undefined {\n return ROI_SCOPE_PRESETS.find((p) => p.id === id);\n}\n\n/** The CVC-236 row fields this module reads. */\nexport interface RoiScopePresetRowLike {\n readonly scopeCode: string;\n readonly status: string;\n}\n\n/** The slice of the CVC-236 resolver this module reads (`createInformationScopeResolver`). */\nexport interface RoiScopePresetRowSource<R extends RoiScopePresetRowLike> {\n row(code: string): R | undefined;\n}\n\n/**\n * A preset's rows, resolved against the CVC-236 tree, in the preset's order. Throws when\n * the id is not a preset, or when an item does not resolve to a live row — a preset never\n * silently selects less than canon says.\n *\n * ```ts\n * const scope = createInformationScopeResolver({ rows: scopeRowsFromSot(sot), migrations: scopeMigrationsFromSot(sot) });\n * roiScopePresetRows(\"risk_only\", scope); // ScopeRow[]\n * ```\n */\nexport function roiScopePresetRows<R extends RoiScopePresetRowLike>(\n id: string,\n scope: RoiScopePresetRowSource<R>,\n): R[] {\n const preset = roiScopePresetById(id);\n if (!preset) throw new Error(`roiScopePresetRows: \"${id}\" is not an ROI scope preset`);\n return preset.itemIds.map((code) => {\n const row = scope.row(code);\n if (!row || row.status === \"retired\") {\n throw new Error(\n `roiScopePresetRows: preset \"${id}\" names \"${code}\", which is not a live CVC-236 row`,\n );\n }\n return row;\n });\n}\n"],"mappings":";AAkEO,IAAM,4BAA4B;AAalC,IAAM,sCAAyD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AAGnF,IAAM,gCAAgC;AAsStC,IAAM,uBAAuB,CAAC,QACnC,QAAQ,UAAa,IAAI,cAAc,IAAI,WAAW;AAQjD,IAAM,iBAAiB,CAAC,QAC7B,QAAQ,UAAa,I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AI,CAAC,OAAO,IAAI,WAAW,WAAW;AACpC,YAAM,IAAI;AAAA,QACR,+BAA+B,EAAE,YAAY,IAAI;AAAA,MACnD;AAAA,IACF;AACA,WAAO;AAAA,EACT,CAAC;AACH;","names":[]}
|
package/dist/models/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-
|
|
1
|
+
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-DAuhe0cd.cjs';
|
|
2
2
|
import 'mongoose';
|
|
3
|
-
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-
|
|
3
|
+
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-1pWiqEBC.cjs';
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-
|
|
1
|
+
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-DAuhe0cd.js';
|
|
2
2
|
import 'mongoose';
|
|
3
|
-
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-
|
|
3
|
+
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-uz57Fic9.js';
|
package/dist/schemas/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
2
|
import { InferRawDocType, Schema } from 'mongoose';
|
|
3
|
-
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-
|
|
3
|
+
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DAuhe0cd.cjs';
|
|
4
4
|
import { a as AddAgencyOrgTypeFieldsOptions } from '../agency-BXvE4yWu.cjs';
|
|
5
5
|
export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, b as AgencyOrgTypeFields, O as ORG_TYPE_FIELD_NAMES, c as OrgTypeFieldName, d as OrgTypeFields, e as OrgTypeFieldsHolder, V as VSP_TWO_STEP_ISSUE, f as addAgencyOrgTypeFields, g as addOrgTypeFields, h as agencyOrgTypeSchemaDefinition, i as applyRunValidatorsIfUnset, j as installVspTwoStepHooks, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, k as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, l as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, n as vspTwoStepHoldsOnUpdate } from '../agency-BXvE4yWu.cjs';
|
|
6
6
|
export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, b as ProgramReviewStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus } from '../vocabulary-Cxhi9EGt.cjs';
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
2
|
import { InferRawDocType, Schema } from 'mongoose';
|
|
3
|
-
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-
|
|
3
|
+
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DAuhe0cd.js';
|
|
4
4
|
import { a as AddAgencyOrgTypeFieldsOptions } from '../agency-NEW6NOGD.js';
|
|
5
5
|
export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, b as AgencyOrgTypeFields, O as ORG_TYPE_FIELD_NAMES, c as OrgTypeFieldName, d as OrgTypeFields, e as OrgTypeFieldsHolder, V as VSP_TWO_STEP_ISSUE, f as addAgencyOrgTypeFields, g as addOrgTypeFields, h as agencyOrgTypeSchemaDefinition, i as applyRunValidatorsIfUnset, j as installVspTwoStepHooks, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, k as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, l as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, n as vspTwoStepHoldsOnUpdate } from '../agency-NEW6NOGD.js';
|
|
6
6
|
export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, b as ProgramReviewStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus } from '../vocabulary-Cxhi9EGt.js';
|