@htilabs/platform-common-models 0.34.0 → 0.36.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.
Files changed (52) hide show
  1. package/README.md +135 -0
  2. package/dist/constants/index.cjs +2 -0
  3. package/dist/constants/index.cjs.map +1 -1
  4. package/dist/constants/index.js +2 -0
  5. package/dist/constants/index.js.map +1 -1
  6. package/dist/{cvcEntry-DAuhe0cd.d.cts → cvcEntry-BqAGctqK.d.cts} +36 -36
  7. package/dist/{cvcEntry-DAuhe0cd.d.ts → cvcEntry-BqAGctqK.d.ts} +36 -36
  8. package/dist/{index-1pWiqEBC.d.cts → index-BTqHP4DM.d.cts} +1 -1
  9. package/dist/{index-uz57Fic9.d.ts → index-Dr6GBCoY.d.ts} +1 -1
  10. package/dist/index.cjs +2 -0
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +2 -2
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +2 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/models/index.d.cts +2 -2
  17. package/dist/models/index.d.ts +2 -2
  18. package/dist/org-directory/index.cjs +4 -3
  19. package/dist/org-directory/index.cjs.map +1 -1
  20. package/dist/org-directory/index.d.cts +22 -6
  21. package/dist/org-directory/index.d.ts +22 -6
  22. package/dist/org-directory/index.js +4 -3
  23. package/dist/org-directory/index.js.map +1 -1
  24. package/dist/points-of-contact/index.cjs +6 -3
  25. package/dist/points-of-contact/index.cjs.map +1 -1
  26. package/dist/points-of-contact/index.js +6 -3
  27. package/dist/points-of-contact/index.js.map +1 -1
  28. package/dist/schemas/index.d.cts +11 -11
  29. package/dist/schemas/index.d.ts +11 -11
  30. package/dist/share-review/index.cjs +301 -0
  31. package/dist/share-review/index.cjs.map +1 -0
  32. package/dist/share-review/index.d.cts +431 -0
  33. package/dist/share-review/index.d.ts +431 -0
  34. package/dist/share-review/index.js +263 -0
  35. package/dist/share-review/index.js.map +1 -0
  36. package/package.json +11 -1
  37. package/src/__sot__/README.md +2 -0
  38. package/src/__sot__/captureConflictSemantics.pin.json +156 -0
  39. package/src/generated/captureConflictSemantics.ts +200 -0
  40. package/src/orgDirectory/__tests__/orgDirectory.test.ts +60 -0
  41. package/src/orgDirectory/rules.ts +26 -9
  42. package/src/pointsOfContact/__tests__/writer.test.ts +15 -0
  43. package/src/shareReview/__tests__/captureConflictSemantics.test.ts +148 -0
  44. package/src/shareReview/__tests__/captureConflictSemanticsPin.test.ts +78 -0
  45. package/src/shareReview/__tests__/recommendedDecision.test.ts +35 -0
  46. package/src/shareReview/__tests__/reviewDecision.test.ts +102 -0
  47. package/src/shareReview/__tests__/shareFieldReviewPlan.test.ts +523 -0
  48. package/src/shareReview/captureConflictSemantics.ts +170 -0
  49. package/src/shareReview/index.ts +23 -0
  50. package/src/shareReview/recommendedDecision.ts +21 -0
  51. package/src/shareReview/reviewDecision.ts +71 -0
  52. package/src/shareReview/shareFieldReviewPlan.ts +288 -0
package/README.md CHANGED
@@ -16,6 +16,82 @@ Package exports are organized into a public root API and a small number of
16
16
  dedicated subpaths (`/validation`, `/cvcs`) — consult `package.json` for the
17
17
  authoritative `exports` map.
18
18
 
19
+ ## share-review / 0.36.0 (additive)
20
+
21
+ New subpath `@htilabs/platform-common-models/share-review` (th-hbo9t.2; Thread
22
+ `ADR-THREAD-CASESHARE-INBOUND-REVIEW` D-b / D-e): the pure inbound-CaseShare
23
+ review kernel, lifted from pave-2.0 `packages/domain` @ 312943078 and **re-keyed
24
+ by hti-features registry field id** (`capture.living_situation`, …) instead of
25
+ PAVE's `assertion_domain`. No mongoose, no I/O, no React; not re-exported from
26
+ the package root.
27
+
28
+ - `REVIEW_DECISIONS` / `isReviewDecision` — the seven decisions (`add`,
29
+ `theirs_current`, `mine_current`, `replace`, `keep_mine`, `keep_both_flagged`,
30
+ `exclude`), code lifted unchanged; an allowlist guard.
31
+ - `resolvedSemantics(fieldId)` — a FIELD query, total. An unauthored field falls
32
+ back to `single_value_keep_replace` with `authored: false` (rule path
33
+ `unauthored_default_keep_replace`); `keep_both_flagged` ends every conflict's
34
+ `choices`.
35
+ - `planFieldReview(offers)` — `{ adds, conflicts, blockingRemaining }`. Input is
36
+ `{ offerId, fieldId, targetPopulated, decision? }`: plan only offered fields,
37
+ and pass `targetPopulated: false` when the held value is identical. Rule paths
38
+ `no_held_value` · `additive_never_conflicts` · `derived_never_conflicts` ·
39
+ `conflict_requires_decision`. `displayQuestion` is true only for
40
+ `capture.name` over a held name, and such a row has `canExclude: false`
41
+ (`DisplayChoice` = `"keep" | "incoming"`). PAVE's `unverified` bucket and
42
+ `survivorDeclined` input are **not** carried.
43
+ - `isOfferedForRow(row, decision)` — **the write gate**, bucket-aware: an add row
44
+ admits `add` (+ `exclude` when `canExclude`); a conflict row admits its
45
+ semantics' pair, `keep_both_flagged` and `exclude`. The planner counts a
46
+ conflict resolved by the same rule, so `replace` never clears an end-date
47
+ conflict and `mine_current` never clears a keep/replace one.
48
+ - `canApproveReview(plan)` — the field half of the approve gate (the case-link
49
+ half is the caller's).
50
+ - `recommendedDecision(semantics)` — `log_end_date_current` → `theirs_current`,
51
+ else `replace` (canon's Apply / Accept all).
52
+
53
+ **The semantics table is generated, never hand-edited.** The pin
54
+ `src/__sot__/captureConflictSemantics.pin.json` is derived by `sot:pins` from the
55
+ hti-features registry (`capture_conflict_semantics` on `captured` rows; only an
56
+ omitted key is unauthored), and `src/generated/captureConflictSemantics.ts` is
57
+ emitted from the pin. At hti-features `ed3a1f9` it authors 141 of 533 captured
58
+ rows, equal key for key to the prototype's generated
59
+ `HTI_CAPTURE_CONFLICT_SEMANTICS` block (c2b0b8b0). The weekly
60
+ `cvc-sot-drift.yml` detector re-derives it with the other pins.
61
+
62
+ ```bash
63
+ HTI_FEATURES_DIR=../hti-features npm run sot:pins -- --only=captureConflictSemantics
64
+ npm run gen:capture-conflict-semantics # re-emit the module from the pin
65
+ npm run gen:capture-conflict-semantics:check # hermetic (CI): module == pin
66
+ ```
67
+
68
+ Not lifted (D-b): PAVE's `fieldConflictOutcome`, `reviewControls`,
69
+ `justificationRequired`, `isOfferedDecision` (replaced by the row gate),
70
+ lifecycle backend and React composites.
71
+
72
+ ## org-directory row shape / 0.35.0 (behaviour fix)
73
+
74
+ `organizationRowShape` no longer decides `pave` from the FORM of `type`.
75
+ `organizations.type` is moving from the IC-58 Int to the CVC-48 key on every
76
+ shared row (auth's provisioning already writes the key; `migrate:org-type-keys`
77
+ rewrites the rest), and the old rule classed every such row `pave` — so
78
+ `mintPartnerContact` and the Platform's `writableRowShape` would have refused
79
+ (409 `foreign_row_shape`) every migrated Thread / auth organization.
80
+
81
+ - `pave` = a string `id`, or an `acronym` / `location` key (PAVE 2.0's legacy
82
+ own shape). On platform-prod (27 rows) and platform-dev (131 rows),
83
+ 2026-10-16, all 31 PAVE rows carry all three and no other row carries any.
84
+ - `thread` = a numeric `type` or a non-empty string `type` (no SOT lookup; the
85
+ subpath stays SOT-free).
86
+ - `unknown` = no type, `type: null`, an empty string (the Platform's account rows).
87
+ - A row whose only PAVE trait was a string `type` (none exist in prod or dev)
88
+ moves from `pave` to `thread`, and is no longer refused as a write target.
89
+ - `DirectoryOrganizationView.typeKey` is the stored string `type` on any shape
90
+ (a migrated Thread / auth row included); `type` stays the numeric form.
91
+
92
+ Consumers that call `organizationRowShape` (platform `lib/org-directory`, the
93
+ points-of-contact writer) must take 0.35.0 before the org-type migration runs.
94
+
19
95
  ## why-nots / 0.34.0 (additive)
20
96
 
21
97
  0.34.0 republishes CVC-219 `core-why_nots` as `whyNots.v1.1.0.json`, mirrored
@@ -809,6 +885,65 @@ The target database name is parsed from the Mongo URI (`mongodb://` and
809
885
  - **`--dry-run`** never prompts or aborts for any database (it writes nothing),
810
886
  but its output states whether a real run *would* proceed, prompt, or abort.
811
887
 
888
+ ## `organizations.type` → CVC-48 keys (migration)
889
+
890
+ `npm run migrate:org-type-keys` moves `organizations.type` on the shared
891
+ platform DB from IC-58 legacy numbers to storable CVC-48 keys
892
+ (`AGENCY_TYPE_KEYS`). Run it in **Phase 3** of the release order only — after
893
+ auth, PAVE, platform and Thread have deployed readers that accept both forms —
894
+ platform-dev first, then platform-prod, each from a sheet proposed against and
895
+ reviewed for **that** database. `MONGO_URI` must name the database; it is never
896
+ logged (only host and database are).
897
+
898
+ Output files hold production data. By default they go to
899
+ `$ORG_TYPE_MIGRATION_DIR` (else `~/org-type-migration`), outside the checkout,
900
+ and the repo's `.gitignore` ignores their names.
901
+
902
+ 1. **Propose (read-only, never prompts).** One CSV row per organization whose
903
+ `type` is not already a storable key: `source_db, _id, name, current_type,
904
+ table_key, type_key, agency_id, agency_type, proposed_key, reason,
905
+ approved_key`. `proposed_key` is, in order:
906
+ - blank for a canonical singleton (`canonicalKey`): listed as `excluded:`,
907
+ never proposed, and refused if approved (Thread's seed owns its type);
908
+ - the linked agency's storable `agencies.type`, when the agency ↔
909
+ organization pair holds from both sides (`unknown` does not win);
910
+ - PAVE's exact `typeKey` (pl-958 rows), when storable and it still maps to
911
+ the stored number (PAVE's `referralEntityKeyOfRow` rule);
912
+ - the legacy table's key, when it is a leaf;
913
+ - else blank with `needs pick: maps to heading <label>`.
914
+
915
+ ```bash
916
+ MONGO_URI="<cluster>/platform-dev" npm run migrate:org-type-keys -- --propose
917
+ ```
918
+
919
+ 2. **Review.** Fill `approved_key` with a storable key for each row to
920
+ migrate; leave it blank to leave the row alone. A heading, a number or any
921
+ other non-storable value refuses the whole sheet, as does a sheet whose
922
+ `source_db` is not the target database (dev and prod share `_id`s).
923
+
924
+ 3. **Apply.** `--dry-run` first. A real run against a non-`-test` database
925
+ asks you to type its name (the seed guard above). **All or nothing:** if any
926
+ approved row no longer holds the value the proposal saw (gone, changed, a
927
+ canonical singleton), nothing is written — re-propose. Otherwise the exact
928
+ before-image (`type` and `updatedTime`) of every row about to change is
929
+ saved first (`--before-images`, never overwritten), and each row is written
930
+ with a compare-and-swap on that `type` and `updatedTime`, setting the key and
931
+ `updatedTime: now` (the Platform repository's concurrency token).
932
+
933
+ ```bash
934
+ MONGO_URI=… npm run migrate:org-type-keys -- --apply reviewed.csv --dry-run
935
+ MONGO_URI=… npm run migrate:org-type-keys -- --apply reviewed.csv
936
+ ```
937
+
938
+ 4. **Rollback** (if needed) restores `type` and `updatedTime` exactly (Int32
939
+ stays Int32) on each row still as the apply left it. **It writes the legacy
940
+ NUMBER back**, so it must not be used once Phase 4 makes
941
+ `organizations.type` validation key-only.
942
+
943
+ ```bash
944
+ MONGO_URI=… npm run migrate:org-type-keys -- --rollback ~/org-type-migration/org-type-before-images.<db>.<time>.json
945
+ ```
946
+
812
947
  ## Service Catalog: Deprecation Notice
813
948
 
814
949
  The hardcoded `IC_48_*` constants and helpers in
@@ -7889,6 +7889,7 @@ var UnrecognizedServiceMechanismError = class extends Error {
7889
7889
  this.values = values;
7890
7890
  this.name = "UnrecognizedServiceMechanismError";
7891
7891
  }
7892
+ values;
7892
7893
  };
7893
7894
  function requireServiceMechanismKey(value) {
7894
7895
  const key = serviceMechanismKeyForCanonicalCode(value);
@@ -7972,6 +7973,7 @@ var UnrecognizedServiceStampError = class extends Error {
7972
7973
  this.stamps = stamps;
7973
7974
  this.name = "UnrecognizedServiceStampError";
7974
7975
  }
7976
+ stamps;
7975
7977
  };
7976
7978
  function normalizeServiceStamps(stamps) {
7977
7979
  const out = {};