@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/README.md +72 -0
- package/dist/index.cjs +81 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -7
- package/dist/index.js.map +1 -1
- package/dist/sharing-ceiling/index.cjs +81 -7
- package/dist/sharing-ceiling/index.cjs.map +1 -1
- package/dist/sharing-ceiling/index.d.cts +64 -4
- package/dist/sharing-ceiling/index.d.ts +64 -4
- package/dist/sharing-ceiling/index.js +81 -7
- package/dist/sharing-ceiling/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sharingCeiling/__tests__/resolveShare.purposeRule.test.ts +836 -0
- package/src/sharingCeiling/index.ts +4 -0
- package/src/sharingCeiling/resolve.ts +219 -15
|
@@ -882,8 +882,31 @@ function resolveShare(input) {
|
|
|
882
882
|
};
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
+
let fork = null;
|
|
885
886
|
if (gov === null && !inside && purposeKnown && recipientKey !== null) {
|
|
886
887
|
gov = hit(cell(att.relationships, recipientKey), "relationship");
|
|
888
|
+
const rule = input.partnerPurposeRule;
|
|
889
|
+
const rulePosture2 = rule?.posture;
|
|
890
|
+
if (gov === null && recipient.kind === "partner" && // `__external__` stays scope-only (data.js L55333)
|
|
891
|
+
(rulePosture2 === "open" || rulePosture2 === "approval" || rulePosture2 === "blocked")) {
|
|
892
|
+
const partnerName = typeof rule?.partnerName === "string" && rule.partnerName !== "" ? rule.partnerName : recipientKey;
|
|
893
|
+
fork = {
|
|
894
|
+
policy: {
|
|
895
|
+
id: `pol-bp-${recipientKey}-${purpose}`,
|
|
896
|
+
name: `${purposeLabel} \u2014 ${partnerName} variant`,
|
|
897
|
+
purpose,
|
|
898
|
+
posture: rulePosture2,
|
|
899
|
+
infoScope: null,
|
|
900
|
+
cadences: null,
|
|
901
|
+
version: 1,
|
|
902
|
+
origin: { kind: "fork" },
|
|
903
|
+
edited: true
|
|
904
|
+
},
|
|
905
|
+
level: "relationship",
|
|
906
|
+
version: 1,
|
|
907
|
+
rulePath: `policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}] (purpose-specific rule, reported as its fork)`
|
|
908
|
+
};
|
|
909
|
+
}
|
|
887
910
|
if (gov === null)
|
|
888
911
|
gov = hit(own2(att.agencyDefaults, purpose), "agency_default");
|
|
889
912
|
if (gov === null && pd !== null) {
|
|
@@ -905,18 +928,36 @@ function resolveShare(input) {
|
|
|
905
928
|
};
|
|
906
929
|
}
|
|
907
930
|
}
|
|
931
|
+
let defaultProjection = null;
|
|
932
|
+
let defaultItems = null;
|
|
933
|
+
if (fork !== null) {
|
|
934
|
+
if (gov !== null && gov.level === "agency_default" && gov.policy.edited === true) {
|
|
935
|
+
if (isStringList2(gov.policy.infoScope))
|
|
936
|
+
defaultProjection = [...gov.policy.infoScope];
|
|
937
|
+
const items = copyItems(gov.policy.infoScopeItems);
|
|
938
|
+
if (items !== null)
|
|
939
|
+
defaultItems = {
|
|
940
|
+
rows: items,
|
|
941
|
+
name: typeof gov.policy.name === "string" ? gov.policy.name : gov.policy.id
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
gov = fork;
|
|
945
|
+
}
|
|
946
|
+
const rulePosture = input.partnerPurposeRule?.posture;
|
|
947
|
+
const ruleAuthored = !inside && recipient.kind === "partner" && (rulePosture === "open" || rulePosture === "approval" || rulePosture === "blocked");
|
|
908
948
|
let tc = null;
|
|
909
949
|
if (teamId !== null && gov !== null) {
|
|
910
950
|
const t = hit(cell(att.teams, teamId), "team");
|
|
911
951
|
if (t !== null && t.policy.id !== gov.policy.id) tc = t;
|
|
912
952
|
}
|
|
913
|
-
const govNamed = gov === null ? null : named(gov);
|
|
953
|
+
const govNamed = gov === null ? null : fork !== null ? { ...named(gov), virtual: true } : named(gov);
|
|
914
954
|
const tcNamed = tc === null ? null : named(tc);
|
|
915
955
|
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)`;
|
|
916
|
-
let posture = input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
|
|
956
|
+
let posture = ruleAuthored && rulePosture !== void 0 ? rulePosture : input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
|
|
917
957
|
let postureSource = "relationship";
|
|
918
958
|
let posturePol = null;
|
|
919
|
-
if (
|
|
959
|
+
if (fork === null && // data.js L55391: a virtual policy's posture is never applied
|
|
960
|
+
govNamed?.posture && SHARE_POSTURE_RANK[govNamed.posture] > SHARE_POSTURE_RANK[posture]) {
|
|
920
961
|
posture = govNamed.posture;
|
|
921
962
|
postureSource = "policy";
|
|
922
963
|
posturePol = govNamed;
|
|
@@ -941,11 +982,22 @@ function resolveShare(input) {
|
|
|
941
982
|
} else if (posture === "blocked") {
|
|
942
983
|
const pol = posturePol;
|
|
943
984
|
const path = pol === null ? "relationship posture = blocked" : `sharingPurposePolicies[${pol.id}].posture=blocked (policy \u201C${pol.name}\u201D \u2014 ${pol.levelLabel})`;
|
|
944
|
-
|
|
985
|
+
const byRule = ruleAuthored && postureSource === "relationship";
|
|
986
|
+
if (report && byRule) {
|
|
987
|
+
reportCarveOut = {
|
|
988
|
+
note: "Partner is blocked for ordinary sharing \u2014 reachable for reports",
|
|
989
|
+
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)`
|
|
990
|
+
};
|
|
991
|
+
} else if (report) {
|
|
945
992
|
reportCarveOut = {
|
|
946
993
|
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`,
|
|
947
994
|
rulePath: path
|
|
948
995
|
};
|
|
996
|
+
} else if (byRule) {
|
|
997
|
+
excluded = {
|
|
998
|
+
reason: "Partner is blocked for this purpose by your account's sharing policy",
|
|
999
|
+
rulePath: `policies.partnerOverrides[${recipientKey}].byPurpose[${purpose}].sharingPosture=blocked (Share Partners \u2014 purpose-specific rule)`
|
|
1000
|
+
};
|
|
949
1001
|
} else {
|
|
950
1002
|
excluded = {
|
|
951
1003
|
reason: pol === null ? "Blocked for this purpose by the relationship" : `Blocked for this purpose by your account's \u201C${pol.name}\u201D policy`,
|
|
@@ -958,9 +1010,11 @@ function resolveShare(input) {
|
|
|
958
1010
|
const govList = govNamed?.infoScope ?? null;
|
|
959
1011
|
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);
|
|
960
1012
|
const legacy = legacyCeilingList(input.legacyCeiling);
|
|
961
|
-
const
|
|
962
|
-
|
|
963
|
-
|
|
1013
|
+
const projectionPath = `policies.sharingScopeEdits[__default__][${purpose}] (projected from your account default policy)`;
|
|
1014
|
+
const projOverLegacy = legacy !== null ? defaultProjection : null;
|
|
1015
|
+
const ceilingIsStarter = legacy === null && defaultProjection === null;
|
|
1016
|
+
let groupCeiling = legacy ?? defaultProjection ?? pdRaw;
|
|
1017
|
+
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)`;
|
|
964
1018
|
if (ceilingIsStarter && polScopeBinds) {
|
|
965
1019
|
groupCeiling = null;
|
|
966
1020
|
ceilingPath = "";
|
|
@@ -1062,6 +1116,17 @@ function resolveShare(input) {
|
|
|
1062
1116
|
`Outside what the \u201C${govName}\u201D policy allows for this purpose`
|
|
1063
1117
|
);
|
|
1064
1118
|
}
|
|
1119
|
+
if (allowed && !req && projOverLegacy !== null && !scopeListCovers(scope, projOverLegacy, g)) {
|
|
1120
|
+
allowed = false;
|
|
1121
|
+
reason = "Outside the payload for this purpose";
|
|
1122
|
+
path = projectionPath;
|
|
1123
|
+
}
|
|
1124
|
+
if (allowed && !req && projOverLegacy !== null && !scopeListStrictlyCovers(scope, projOverLegacy, g)) {
|
|
1125
|
+
addExcluded(
|
|
1126
|
+
outside((r) => scopeListCovers(scope, projOverLegacy, g, r)),
|
|
1127
|
+
"Outside the payload for this purpose"
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1065
1130
|
const govRows = polScopeBinds ? own2(govItems, g) : void 0;
|
|
1066
1131
|
if (allowed && !req && isStringList2(govRows)) {
|
|
1067
1132
|
const keep = new Set(govRows);
|
|
@@ -1071,6 +1136,15 @@ function resolveShare(input) {
|
|
|
1071
1136
|
`Outside what the \u201C${govName}\u201D policy allows for this purpose`
|
|
1072
1137
|
);
|
|
1073
1138
|
}
|
|
1139
|
+
const defRows = defaultItems === null ? void 0 : own2(defaultItems.rows, g);
|
|
1140
|
+
if (allowed && !req && isStringList2(defRows)) {
|
|
1141
|
+
const keep = new Set(defRows);
|
|
1142
|
+
const kept = (r) => keep.has(r) || scope.ancestorsOf(r).some((a) => a !== g && keep.has(a));
|
|
1143
|
+
addExcluded(
|
|
1144
|
+
outside(kept),
|
|
1145
|
+
`Outside what the \u201C${defaultItems?.name ?? ""}\u201D policy allows for this purpose`
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1074
1148
|
if (allowed && !req && tcScope !== null && !scopeListCovers(scope, tcScope, g)) {
|
|
1075
1149
|
allowed = false;
|
|
1076
1150
|
reason = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;
|