@htilabs/platform-common-models 0.59.0 → 0.61.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 (35) hide show
  1. package/README.md +90 -1
  2. package/dist/index.cjs +91 -13
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +91 -13
  5. package/dist/index.js.map +1 -1
  6. package/dist/org-directory/index.cjs +5 -4
  7. package/dist/org-directory/index.cjs.map +1 -1
  8. package/dist/org-directory/index.d.cts +15 -7
  9. package/dist/org-directory/index.d.ts +15 -7
  10. package/dist/org-directory/index.js +5 -4
  11. package/dist/org-directory/index.js.map +1 -1
  12. package/dist/points-of-contact/index.cjs +4 -3
  13. package/dist/points-of-contact/index.cjs.map +1 -1
  14. package/dist/points-of-contact/index.js +4 -3
  15. package/dist/points-of-contact/index.js.map +1 -1
  16. package/dist/schemas/index.cjs +10 -6
  17. package/dist/schemas/index.cjs.map +1 -1
  18. package/dist/schemas/index.d.cts +8 -4
  19. package/dist/schemas/index.d.ts +8 -4
  20. package/dist/schemas/index.js +10 -6
  21. package/dist/schemas/index.js.map +1 -1
  22. package/dist/sharing-ceiling/index.cjs +81 -7
  23. package/dist/sharing-ceiling/index.cjs.map +1 -1
  24. package/dist/sharing-ceiling/index.d.cts +64 -4
  25. package/dist/sharing-ceiling/index.d.ts +64 -4
  26. package/dist/sharing-ceiling/index.js +81 -7
  27. package/dist/sharing-ceiling/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/orgDirectory/__tests__/orgRecord.test.ts +6 -3
  30. package/src/orgDirectory/orgRecord.ts +14 -6
  31. package/src/orgDirectory/rules.ts +3 -2
  32. package/src/schemas/organization.ts +7 -4
  33. package/src/sharingCeiling/__tests__/resolveShare.purposeRule.test.ts +836 -0
  34. package/src/sharingCeiling/index.ts +4 -0
  35. package/src/sharingCeiling/resolve.ts +219 -15
package/README.md CHANGED
@@ -16,6 +16,95 @@ 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
+ ## 0.61.0 — the share resolver names an authored purpose-specific partner rule: `partnerPurposeRule` → the virtual `byPurpose` fork (additive; Crysta 2026-11-10, "match the prototype")
20
+
21
+ **What changed.** `resolveShare` gains one optional input and reads one more
22
+ rung of the prototype's ladder (`src/data.js` @ aa2c63a `governingPolicyFor`
23
+ L55006-L55028). When no policy is attached to the relationship for the
24
+ purpose, but the account has AUTHORED a purpose-specific rule for the partner
25
+ (`policies.partnerOverrides[partner].byPurpose[purpose]` with a
26
+ `sharingPosture` — the Share Partners "purpose-specific rule"), the answer
27
+ names that rule as the governing policy:
28
+
29
+ - input `partnerPurposeRule?: { posture: "open" | "approval" | "blocked";
30
+ partnerName?: string | null } | null`;
31
+ - `governing` = `{ id: "pol-bp-<partner>-<purpose>", familyId: (the same),
32
+ name: "<purposeLabel> — <partnerName> variant", version: 1, level:
33
+ "relationship", posture: <the rule's>, infoScope: null, infoScopeItems:
34
+ null, edited: true, origin: "fork", virtual: true, rulePath:
35
+ "policies.partnerOverrides[<partner>].byPurpose[<purpose>] (purpose-specific
36
+ rule, reported as its fork)" }` — `ShareNamedPolicy` gains `virtual?: true`;
37
+ - the rung sits after the relationship policy and before the account
38
+ default; a team-to-team row and an attached relationship policy still win;
39
+ the sending team's own policy still rides as a ceiling over it (data.js
40
+ `done()`), now also when that team policy is the account default the fork
41
+ sits over.
42
+
43
+ **What binds — the prototype's `effectiveCeiling`, with two deliberate corrections.**
44
+
45
+ - **Posture starts from the rule** whenever a rule is present, whatever the
46
+ ladder named (data.js L55342: `bp.sharingPosture || over.sharingPosture ||
47
+ …` — the rule first): **`relationshipPosture` is ignored when a
48
+ `partnerPurposeRule` is present**, so the answer never depends on a caller
49
+ keeping the two in sync. Policies and the team ceiling can only raise it.
50
+ Under the fork the account default's posture is not consulted (L55391 skips
51
+ a virtual policy) — so a rule saying open over an account default saying
52
+ blocked now ALLOWS the share (0.60.0, which had no fork, answered blocked).
53
+ - **Scope under the fork** = clamp 5's ceiling (L55504): `legacyCeiling` (a
54
+ rule's own category list, if the caller still carries one, goes there),
55
+ else an EDITED account default's category list — data.js projects it into
56
+ `sharingScopeEdits[__default__]` (`projectScopeEdits` L55163-L55164), read
57
+ as "Outside the payload for this purpose" — else the Platform default's
58
+ starting scope. The default's list does not bind as 5b (L55539). The team
59
+ ceiling (5d), the account's Information Scope, the Platform default's
60
+ Required / Blocked and the floor bind as everywhere.
61
+ - **Correction 1 — field groups (narrower than the prototype, pending the
62
+ owner's word).** The edited account default's field groups
63
+ (`infoScopeItems`) still bind under the fork. data.js drops them (its 5c,
64
+ L55658, reads only the governing policy) while keeping the same default's
65
+ category list; a posture-only partner rule must not silently release field
66
+ groups the admin withheld. For the same reason the edited default's
67
+ category list binds even when `legacyCeiling` is passed (data.js would read
68
+ the legacy partner rule instead of it, L55504; 0.60.0 bound both).
69
+ - **Wording.** When the rule itself blocked: a discretionary share is excluded
70
+ as "Partner is blocked for this purpose by your account's sharing policy"
71
+ (`policies.partnerOverrides[<p>].byPurpose[<purpose>].sharingPosture=blocked
72
+ (Share Partners — purpose-specific rule)`, L55447-L55448); a report is
73
+ carved out as "Partner is blocked for ordinary sharing — reachable for
74
+ reports" (`reports-never-blocked-at-partner-layer (…)`, L55436-L55446).
75
+ - **Correction 2 — the saved cause is the real cause.** data.js uses the
76
+ purpose-rule sentence whenever a rule exists, even when the rule is open
77
+ and an attached policy blocked (its path then claims the rule was
78
+ blocked). Here the policy that blocked is named; the decision is the same.
79
+ - A rule for an `__external__` recipient is ignored (L55333: `__external__`
80
+ stays scope-only); not applied inside the account; a posture that is not
81
+ one of the three is no rule.
82
+
83
+ **Consumers.** Nothing changes until an app passes `partnerPurposeRule`;
84
+ without it every answer is byte-identical to 0.60.0 (proved over 1,440
85
+ vectors). PAVE and Thread pass it
86
+ when the relationship row carries a purpose-specific posture for the purpose,
87
+ with `purposeLabel` and the partner's display name, and read
88
+ `governing.virtual` to know the governing policy is the rule (no document to
89
+ open).
90
+
91
+ ## 0.60.0 — the Org record names who added an organization `addedBy` (BREAKING vs 0.59.0, which no app adopted)
92
+
93
+ An organization's arrival now uses the same three names a Program, a Service
94
+ Listing and a Point of contact use: `addedBy` · `addedInApp` · `reviewStatus`
95
+ (UDD ratification request R17, "how an organization arrived").
96
+
97
+ - `ORG_RECORD_FIELD_NAMES`: `addedBy` replaces `addedByUserId`;
98
+ `addedInSession` leaves the definition.
99
+ - `ORG_AS_BUILT_FIELD_NAMES` gains `addedByUserId` and `addedInSession` (PAVE
100
+ 2.0 rows carry them; the mount still declares them).
101
+ - `orgArrivalStamp` returns `{ reviewStatus, addedInApp, addedBy,
102
+ addedInSession? }`.
103
+ - `DirectoryOrganizationView.addedBy` replaces `addedByUserId` and reads a
104
+ stored `addedByUserId` when `addedBy` is absent.
105
+
106
+ 0.59.0 was published an hour before this and has no consumer; adopt 0.60.0.
107
+
19
108
  ## 0.59.0 — the Org record: one definition of an `organizations` row for every app (additive; Crysta 2026-11-10)
20
109
 
21
110
  **Why.** The platform-wide organization registry is one collection
@@ -33,7 +122,7 @@ twin):
33
122
  - `orgDirectory/orgRecord.ts` — the field list (`ORG_RECORD_FIELD_NAMES`:
34
123
  `legalName` · `commonName` · `shortName` · `website` · `parentOrgId` ·
35
124
  `vsp` · `vspPrivateNonprofit` · `reviewStatus` · `addedInApp` ·
36
- `addedByUserId` · `addedInSession`), the as-built extras every model must
125
+ `addedByUserId` · `addedInSession`; see 0.60.0 for the arrival names), the as-built extras every model must
37
126
  also declare (`ORG_AS_BUILT_FIELD_NAMES`), and the whole row
38
127
  (`ORGANIZATION_ROW_KEYS`).
39
128
  - Write shapes: `OrgIdentityWriteSchema`, `OrgVspWriteSchema` (the HMIS
package/dist/index.cjs CHANGED
@@ -18738,12 +18738,13 @@ var ORG_RECORD_FIELD_NAMES = Object.freeze([
18738
18738
  "vspPrivateNonprofit",
18739
18739
  "reviewStatus",
18740
18740
  "addedInApp",
18741
- "addedByUserId",
18742
- "addedInSession"
18741
+ "addedBy"
18743
18742
  ]);
18744
18743
  var ORG_AS_BUILT_FIELD_NAMES = Object.freeze([
18745
18744
  "requiresROI",
18746
18745
  "isCustom",
18746
+ "addedByUserId",
18747
+ "addedInSession",
18747
18748
  "division",
18748
18749
  "typeOverride",
18749
18750
  "typeKey"
@@ -18835,13 +18836,15 @@ var orgRecordSchemaDefinition = {
18835
18836
  /** The app it was added in (`thread`, `pave`, `leads`, `platform`). */
18836
18837
  addedInApp: { type: String },
18837
18838
  /** The adding user's platform `users._id`. */
18838
- addedByUserId: { type: String },
18839
- addedInSession: { type: String }
18839
+ addedBy: { type: String }
18840
18840
  };
18841
18841
  var orgAsBuiltSchemaDefinition = {
18842
18842
  /** Informational only: the release check reads the sender's `vsp` (GDR § 5.17 clause 2). */
18843
18843
  requiresROI: { type: Boolean },
18844
18844
  isCustom: { type: Boolean },
18845
+ /** The pre-0.60 spelling of `addedBy`; PAVE 2.0 rows carry it. */
18846
+ addedByUserId: { type: String },
18847
+ addedInSession: { type: String },
18845
18848
  division: { type: String },
18846
18849
  typeOverride: { type: String },
18847
18850
  /** The CVC-48 key PAVE writes beside a numeric `type`; retires with the type migration. */
@@ -18866,10 +18869,11 @@ var EXPECTED_INSTANCE = {
18866
18869
  vspPrivateNonprofit: "Boolean",
18867
18870
  reviewStatus: "String",
18868
18871
  addedInApp: "String",
18869
- addedByUserId: "String",
18870
- addedInSession: "String",
18872
+ addedBy: "String",
18871
18873
  requiresROI: "Boolean",
18872
18874
  isCustom: "Boolean",
18875
+ addedByUserId: "String",
18876
+ addedInSession: "String",
18873
18877
  division: "String",
18874
18878
  typeOverride: "String",
18875
18879
  typeKey: "String"
@@ -26374,8 +26378,31 @@ function resolveShare(input) {
26374
26378
  };
26375
26379
  }
26376
26380
  }
26381
+ let fork = null;
26377
26382
  if (gov === null && !inside && purposeKnown && recipientKey !== null) {
26378
26383
  gov = hit(cell(att.relationships, recipientKey), "relationship");
26384
+ const rule = input.partnerPurposeRule;
26385
+ const rulePosture2 = rule?.posture;
26386
+ if (gov === null && recipient.kind === "partner" && // `__external__` stays scope-only (data.js L55333)
26387
+ (rulePosture2 === "open" || rulePosture2 === "approval" || rulePosture2 === "blocked")) {
26388
+ const partnerName = typeof rule?.partnerName === "string" && rule.partnerName !== "" ? rule.partnerName : recipientKey;
26389
+ fork = {
26390
+ policy: {
26391
+ id: `pol-bp-${recipientKey}-${purpose}`,
26392
+ name: `${purposeLabel} \u2014 ${partnerName} variant`,
26393
+ purpose,
26394
+ posture: rulePosture2,
26395
+ infoScope: null,
26396
+ cadences: null,
26397
+ version: 1,
26398
+ origin: { kind: "fork" },
26399
+ edited: true
26400
+ },
26401
+ level: "relationship",
26402
+ version: 1,
26403
+ rulePath: `policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}] (purpose-specific rule, reported as its fork)`
26404
+ };
26405
+ }
26379
26406
  if (gov === null)
26380
26407
  gov = hit(own3(att.agencyDefaults, purpose), "agency_default");
26381
26408
  if (gov === null && pd !== null) {
@@ -26397,18 +26424,36 @@ function resolveShare(input) {
26397
26424
  };
26398
26425
  }
26399
26426
  }
26427
+ let defaultProjection = null;
26428
+ let defaultItems = null;
26429
+ if (fork !== null) {
26430
+ if (gov !== null && gov.level === "agency_default" && gov.policy.edited === true) {
26431
+ if (isStringList2(gov.policy.infoScope))
26432
+ defaultProjection = [...gov.policy.infoScope];
26433
+ const items = copyItems(gov.policy.infoScopeItems);
26434
+ if (items !== null)
26435
+ defaultItems = {
26436
+ rows: items,
26437
+ name: typeof gov.policy.name === "string" ? gov.policy.name : gov.policy.id
26438
+ };
26439
+ }
26440
+ gov = fork;
26441
+ }
26442
+ const rulePosture = input.partnerPurposeRule?.posture;
26443
+ const ruleAuthored = !inside && recipient.kind === "partner" && (rulePosture === "open" || rulePosture === "approval" || rulePosture === "blocked");
26400
26444
  let tc = null;
26401
26445
  if (teamId !== null && gov !== null) {
26402
26446
  const t = hit(cell(att.teams, teamId), "team");
26403
26447
  if (t !== null && t.policy.id !== gov.policy.id) tc = t;
26404
26448
  }
26405
- const govNamed = gov === null ? null : named(gov);
26449
+ const govNamed = gov === null ? null : fork !== null ? { ...named(gov), virtual: true } : named(gov);
26406
26450
  const tcNamed = tc === null ? null : named(tc);
26407
26451
  const rulePath = gov === null ? `no Platform default for purpose \u201C${purpose}\u201D \u2014 nothing governs (fails closed)` : tc === null ? gov.rulePath : `${gov.rulePath} \u2229 ${tc.rulePath} (the sending team's own policy is a ceiling \u2014 only what both allow)`;
26408
- let posture = input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
26452
+ let posture = ruleAuthored && rulePosture !== void 0 ? rulePosture : input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
26409
26453
  let postureSource = "relationship";
26410
26454
  let posturePol = null;
26411
- if (govNamed?.posture && SHARE_POSTURE_RANK[govNamed.posture] > SHARE_POSTURE_RANK[posture]) {
26455
+ if (fork === null && // data.js L55391: a virtual policy's posture is never applied
26456
+ govNamed?.posture && SHARE_POSTURE_RANK[govNamed.posture] > SHARE_POSTURE_RANK[posture]) {
26412
26457
  posture = govNamed.posture;
26413
26458
  postureSource = "policy";
26414
26459
  posturePol = govNamed;
@@ -26433,11 +26478,22 @@ function resolveShare(input) {
26433
26478
  } else if (posture === "blocked") {
26434
26479
  const pol = posturePol;
26435
26480
  const path = pol === null ? "relationship posture = blocked" : `sharingPurposePolicies[${pol.id}].posture=blocked (policy \u201C${pol.name}\u201D \u2014 ${pol.levelLabel})`;
26436
- if (report) {
26481
+ const byRule = ruleAuthored && postureSource === "relationship";
26482
+ if (report && byRule) {
26483
+ reportCarveOut = {
26484
+ note: "Partner is blocked for ordinary sharing \u2014 reachable for reports",
26485
+ rulePath: `reports-never-blocked-at-partner-layer (Crysta ruling 2026-08-23; policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}].sharingPosture=blocked does not bind a legal duty \u2014 who may send is a role/function question)`
26486
+ };
26487
+ } else if (report) {
26437
26488
  reportCarveOut = {
26438
26489
  note: pol === null ? "Blocked for ordinary sharing \u2014 reachable for reports (nothing at the partner layer extinguishes the duty)" : `The \u201C${pol.name}\u201D policy blocks ordinary sharing \u2014 reachable for reports`,
26439
26490
  rulePath: path
26440
26491
  };
26492
+ } else if (byRule) {
26493
+ excluded = {
26494
+ reason: "Partner is blocked for this purpose by your account's sharing policy",
26495
+ rulePath: `policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}].sharingPosture=blocked (Share Partners \u2014 purpose-specific rule)`
26496
+ };
26441
26497
  } else {
26442
26498
  excluded = {
26443
26499
  reason: pol === null ? "Blocked for this purpose by the relationship" : `Blocked for this purpose by your account's \u201C${pol.name}\u201D policy`,
@@ -26450,9 +26506,11 @@ function resolveShare(input) {
26450
26506
  const govList = govNamed?.infoScope ?? null;
26451
26507
  const polScopeBinds = gov !== null && Array.isArray(govList) && (level === "team_row" || level === "relationship" || level === "account_internal" || level === "inside_starter" || level === "agency_default" && gov.policy.edited === true);
26452
26508
  const legacy = legacyCeilingList(input.legacyCeiling);
26453
- const ceilingIsStarter = legacy === null;
26454
- let groupCeiling = legacy ?? pdRaw;
26455
- let ceilingPath = legacy !== null ? "sharingScopeEdits (the account's partner / default rule \u2014 the legacy cell chain)" : pd === null ? "no Platform default" : `pol-starter-${purpose} v${pd.version} (Platform default \u2014 the starting scope for this purpose)`;
26509
+ const projectionPath = `policies.sharingScopeEdits[__default__][${purpose}] (projected from your account default policy)`;
26510
+ const projOverLegacy = legacy !== null ? defaultProjection : null;
26511
+ const ceilingIsStarter = legacy === null && defaultProjection === null;
26512
+ let groupCeiling = legacy ?? defaultProjection ?? pdRaw;
26513
+ let ceilingPath = legacy !== null ? "sharingScopeEdits (the account's partner / default rule \u2014 the legacy cell chain)" : defaultProjection !== null ? projectionPath : pd === null ? "no Platform default" : `pol-starter-${purpose} v${pd.version} (Platform default \u2014 the starting scope for this purpose)`;
26456
26514
  if (ceilingIsStarter && polScopeBinds) {
26457
26515
  groupCeiling = null;
26458
26516
  ceilingPath = "";
@@ -26554,6 +26612,17 @@ function resolveShare(input) {
26554
26612
  `Outside what the \u201C${govName}\u201D policy allows for this purpose`
26555
26613
  );
26556
26614
  }
26615
+ if (allowed && !req && projOverLegacy !== null && !scopeListCovers(scope, projOverLegacy, g)) {
26616
+ allowed = false;
26617
+ reason = "Outside the payload for this purpose";
26618
+ path = projectionPath;
26619
+ }
26620
+ if (allowed && !req && projOverLegacy !== null && !scopeListStrictlyCovers(scope, projOverLegacy, g)) {
26621
+ addExcluded(
26622
+ outside((r) => scopeListCovers(scope, projOverLegacy, g, r)),
26623
+ "Outside the payload for this purpose"
26624
+ );
26625
+ }
26557
26626
  const govRows = polScopeBinds ? own3(govItems, g) : void 0;
26558
26627
  if (allowed && !req && isStringList2(govRows)) {
26559
26628
  const keep = new Set(govRows);
@@ -26563,6 +26632,15 @@ function resolveShare(input) {
26563
26632
  `Outside what the \u201C${govName}\u201D policy allows for this purpose`
26564
26633
  );
26565
26634
  }
26635
+ const defRows = defaultItems === null ? void 0 : own3(defaultItems.rows, g);
26636
+ if (allowed && !req && isStringList2(defRows)) {
26637
+ const keep = new Set(defRows);
26638
+ const kept = (r) => keep.has(r) || scope.ancestorsOf(r).some((a) => a !== g && keep.has(a));
26639
+ addExcluded(
26640
+ outside(kept),
26641
+ `Outside what the \u201C${defaultItems?.name ?? ""}\u201D policy allows for this purpose`
26642
+ );
26643
+ }
26566
26644
  if (allowed && !req && tcScope !== null && !scopeListCovers(scope, tcScope, g)) {
26567
26645
  allowed = false;
26568
26646
  reason = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;