@htilabs/platform-common-models 0.60.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.
package/dist/index.js CHANGED
@@ -25419,8 +25419,31 @@ function resolveShare(input) {
25419
25419
  };
25420
25420
  }
25421
25421
  }
25422
+ let fork = null;
25422
25423
  if (gov === null && !inside && purposeKnown && recipientKey !== null) {
25423
25424
  gov = hit(cell(att.relationships, recipientKey), "relationship");
25425
+ const rule = input.partnerPurposeRule;
25426
+ const rulePosture2 = rule?.posture;
25427
+ if (gov === null && recipient.kind === "partner" && // `__external__` stays scope-only (data.js L55333)
25428
+ (rulePosture2 === "open" || rulePosture2 === "approval" || rulePosture2 === "blocked")) {
25429
+ const partnerName = typeof rule?.partnerName === "string" && rule.partnerName !== "" ? rule.partnerName : recipientKey;
25430
+ fork = {
25431
+ policy: {
25432
+ id: `pol-bp-${recipientKey}-${purpose}`,
25433
+ name: `${purposeLabel} \u2014 ${partnerName} variant`,
25434
+ purpose,
25435
+ posture: rulePosture2,
25436
+ infoScope: null,
25437
+ cadences: null,
25438
+ version: 1,
25439
+ origin: { kind: "fork" },
25440
+ edited: true
25441
+ },
25442
+ level: "relationship",
25443
+ version: 1,
25444
+ rulePath: `policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}] (purpose-specific rule, reported as its fork)`
25445
+ };
25446
+ }
25424
25447
  if (gov === null)
25425
25448
  gov = hit(own3(att.agencyDefaults, purpose), "agency_default");
25426
25449
  if (gov === null && pd !== null) {
@@ -25442,18 +25465,36 @@ function resolveShare(input) {
25442
25465
  };
25443
25466
  }
25444
25467
  }
25468
+ let defaultProjection = null;
25469
+ let defaultItems = null;
25470
+ if (fork !== null) {
25471
+ if (gov !== null && gov.level === "agency_default" && gov.policy.edited === true) {
25472
+ if (isStringList2(gov.policy.infoScope))
25473
+ defaultProjection = [...gov.policy.infoScope];
25474
+ const items = copyItems(gov.policy.infoScopeItems);
25475
+ if (items !== null)
25476
+ defaultItems = {
25477
+ rows: items,
25478
+ name: typeof gov.policy.name === "string" ? gov.policy.name : gov.policy.id
25479
+ };
25480
+ }
25481
+ gov = fork;
25482
+ }
25483
+ const rulePosture = input.partnerPurposeRule?.posture;
25484
+ const ruleAuthored = !inside && recipient.kind === "partner" && (rulePosture === "open" || rulePosture === "approval" || rulePosture === "blocked");
25445
25485
  let tc = null;
25446
25486
  if (teamId !== null && gov !== null) {
25447
25487
  const t = hit(cell(att.teams, teamId), "team");
25448
25488
  if (t !== null && t.policy.id !== gov.policy.id) tc = t;
25449
25489
  }
25450
- const govNamed = gov === null ? null : named(gov);
25490
+ const govNamed = gov === null ? null : fork !== null ? { ...named(gov), virtual: true } : named(gov);
25451
25491
  const tcNamed = tc === null ? null : named(tc);
25452
25492
  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)`;
25453
- let posture = input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
25493
+ let posture = ruleAuthored && rulePosture !== void 0 ? rulePosture : input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
25454
25494
  let postureSource = "relationship";
25455
25495
  let posturePol = null;
25456
- if (govNamed?.posture && SHARE_POSTURE_RANK[govNamed.posture] > SHARE_POSTURE_RANK[posture]) {
25496
+ if (fork === null && // data.js L55391: a virtual policy's posture is never applied
25497
+ govNamed?.posture && SHARE_POSTURE_RANK[govNamed.posture] > SHARE_POSTURE_RANK[posture]) {
25457
25498
  posture = govNamed.posture;
25458
25499
  postureSource = "policy";
25459
25500
  posturePol = govNamed;
@@ -25478,11 +25519,22 @@ function resolveShare(input) {
25478
25519
  } else if (posture === "blocked") {
25479
25520
  const pol = posturePol;
25480
25521
  const path = pol === null ? "relationship posture = blocked" : `sharingPurposePolicies[${pol.id}].posture=blocked (policy \u201C${pol.name}\u201D \u2014 ${pol.levelLabel})`;
25481
- if (report) {
25522
+ const byRule = ruleAuthored && postureSource === "relationship";
25523
+ if (report && byRule) {
25524
+ reportCarveOut = {
25525
+ note: "Partner is blocked for ordinary sharing \u2014 reachable for reports",
25526
+ 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)`
25527
+ };
25528
+ } else if (report) {
25482
25529
  reportCarveOut = {
25483
25530
  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`,
25484
25531
  rulePath: path
25485
25532
  };
25533
+ } else if (byRule) {
25534
+ excluded = {
25535
+ reason: "Partner is blocked for this purpose by your account's sharing policy",
25536
+ rulePath: `policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}].sharingPosture=blocked (Share Partners \u2014 purpose-specific rule)`
25537
+ };
25486
25538
  } else {
25487
25539
  excluded = {
25488
25540
  reason: pol === null ? "Blocked for this purpose by the relationship" : `Blocked for this purpose by your account's \u201C${pol.name}\u201D policy`,
@@ -25495,9 +25547,11 @@ function resolveShare(input) {
25495
25547
  const govList = govNamed?.infoScope ?? null;
25496
25548
  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);
25497
25549
  const legacy = legacyCeilingList(input.legacyCeiling);
25498
- const ceilingIsStarter = legacy === null;
25499
- let groupCeiling = legacy ?? pdRaw;
25500
- 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)`;
25550
+ const projectionPath = `policies.sharingScopeEdits[__default__][${purpose}] (projected from your account default policy)`;
25551
+ const projOverLegacy = legacy !== null ? defaultProjection : null;
25552
+ const ceilingIsStarter = legacy === null && defaultProjection === null;
25553
+ let groupCeiling = legacy ?? defaultProjection ?? pdRaw;
25554
+ 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)`;
25501
25555
  if (ceilingIsStarter && polScopeBinds) {
25502
25556
  groupCeiling = null;
25503
25557
  ceilingPath = "";
@@ -25599,6 +25653,17 @@ function resolveShare(input) {
25599
25653
  `Outside what the \u201C${govName}\u201D policy allows for this purpose`
25600
25654
  );
25601
25655
  }
25656
+ if (allowed && !req && projOverLegacy !== null && !scopeListCovers(scope, projOverLegacy, g)) {
25657
+ allowed = false;
25658
+ reason = "Outside the payload for this purpose";
25659
+ path = projectionPath;
25660
+ }
25661
+ if (allowed && !req && projOverLegacy !== null && !scopeListStrictlyCovers(scope, projOverLegacy, g)) {
25662
+ addExcluded(
25663
+ outside((r) => scopeListCovers(scope, projOverLegacy, g, r)),
25664
+ "Outside the payload for this purpose"
25665
+ );
25666
+ }
25602
25667
  const govRows = polScopeBinds ? own3(govItems, g) : void 0;
25603
25668
  if (allowed && !req && isStringList2(govRows)) {
25604
25669
  const keep = new Set(govRows);
@@ -25608,6 +25673,15 @@ function resolveShare(input) {
25608
25673
  `Outside what the \u201C${govName}\u201D policy allows for this purpose`
25609
25674
  );
25610
25675
  }
25676
+ const defRows = defaultItems === null ? void 0 : own3(defaultItems.rows, g);
25677
+ if (allowed && !req && isStringList2(defRows)) {
25678
+ const keep = new Set(defRows);
25679
+ const kept = (r) => keep.has(r) || scope.ancestorsOf(r).some((a) => a !== g && keep.has(a));
25680
+ addExcluded(
25681
+ outside(kept),
25682
+ `Outside what the \u201C${defaultItems?.name ?? ""}\u201D policy allows for this purpose`
25683
+ );
25684
+ }
25611
25685
  if (allowed && !req && tcScope !== null && !scopeListCovers(scope, tcScope, g)) {
25612
25686
  allowed = false;
25613
25687
  reason = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;