@plurnk/plurnk-contracts 8.0.0 → 9.0.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/SPEC.md +10 -24
- package/dist/schema/DaemonNotificationEnvelope.json +555 -0
- package/dist/schema/McpServerDefinition.json +1 -1
- package/dist/schema/PlurnkStatement.json +24 -0
- package/dist/schema/ProposalProjection.json +0 -4
- package/dist/src/Application.d.ts +22 -1
- package/dist/src/Application.d.ts.map +1 -1
- package/dist/src/Application.js +480 -15
- package/dist/src/Application.js.map +1 -1
- package/dist/src/ApplicationNotifications.d.ts +59 -19
- package/dist/src/ApplicationNotifications.d.ts.map +1 -1
- package/dist/src/ApplicationNotifications.js +40 -7
- package/dist/src/ApplicationNotifications.js.map +1 -1
- package/dist/src/ApplicationPort.d.ts +26 -7
- package/dist/src/ApplicationPort.d.ts.map +1 -1
- package/dist/src/ApplicationPort.js.map +1 -1
- package/dist/src/LogRow.d.ts +1 -1
- package/dist/src/LogRow.js +1 -1
- package/dist/src/LogRow.js.map +1 -1
- package/dist/src/Validator.d.ts +3 -3
- package/dist/src/Validator.d.ts.map +1 -1
- package/dist/src/Validator.js +8 -16
- package/dist/src/Validator.js.map +1 -1
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.generated.d.ts +820 -636
- package/dist/src/types.generated.d.ts.map +1 -1
- package/dist/src/types.generated.js.map +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -2
- package/dist/schema/ApplicationOperationEvent.json +0 -27
- package/dist/schema/CapabilityDescriptor.json +0 -28
- package/dist/schema/CapabilityPolicy.json +0 -22
- package/dist/schema/CapabilityProjection.json +0 -14
- package/dist/schema/CapabilitySelector.json +0 -29
- package/dist/src/CapabilityAdmission.d.ts +0 -11
- package/dist/src/CapabilityAdmission.d.ts.map +0 -1
- package/dist/src/CapabilityAdmission.js +0 -108
- package/dist/src/CapabilityAdmission.js.map +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// {§capability-policy-cascade} — selectors are exact conjunctions. Policy
|
|
2
|
-
// layers remain data; this class is the one deterministic evaluator shared by
|
|
3
|
-
// every consumer.
|
|
4
|
-
export default class CapabilityAdmission {
|
|
5
|
-
static matches(selector, descriptor) {
|
|
6
|
-
if (selector.operation !== undefined && selector.operation !== descriptor.operation)
|
|
7
|
-
return false;
|
|
8
|
-
if (selector.scheme !== undefined && selector.scheme !== descriptor.scheme)
|
|
9
|
-
return false;
|
|
10
|
-
if (selector.runtime !== undefined && selector.runtime !== descriptor.runtime)
|
|
11
|
-
return false;
|
|
12
|
-
if (selector.tool !== undefined && selector.tool !== descriptor.tool)
|
|
13
|
-
return false;
|
|
14
|
-
if (selector.access !== undefined && selector.access !== descriptor.access)
|
|
15
|
-
return false;
|
|
16
|
-
if (selector.traits !== undefined
|
|
17
|
-
&& !selector.traits.every((trait) => descriptor.traits.includes(trait)))
|
|
18
|
-
return false;
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
static allows(policy, descriptor) {
|
|
22
|
-
if (policy.deny?.some((selector) => CapabilityAdmission.matches(selector, descriptor)) === true)
|
|
23
|
-
return false;
|
|
24
|
-
return policy.only === undefined
|
|
25
|
-
|| policy.only.some((selector) => CapabilityAdmission.matches(selector, descriptor));
|
|
26
|
-
}
|
|
27
|
-
static allowsAcross(policies, descriptor) {
|
|
28
|
-
return policies.every((policy) => CapabilityAdmission.allows(policy, descriptor));
|
|
29
|
-
}
|
|
30
|
-
static preapproves(policy, descriptor) {
|
|
31
|
-
if (!CapabilityAdmission.allows(policy, descriptor))
|
|
32
|
-
return false;
|
|
33
|
-
return policy.allow?.some((selector) => CapabilityAdmission.matches(selector, descriptor)) === true;
|
|
34
|
-
}
|
|
35
|
-
static preapprovesAcross(policies, descriptor) {
|
|
36
|
-
if (!CapabilityAdmission.allowsAcross(policies, descriptor))
|
|
37
|
-
return false;
|
|
38
|
-
return policies.some((policy) => policy.allow?.some((selector) => CapabilityAdmission.matches(selector, descriptor)) === true);
|
|
39
|
-
}
|
|
40
|
-
// Lossless normalization of an intersection into one policy. `only` is an
|
|
41
|
-
// OR-list, so intersecting two lists is their compatible Cartesian product;
|
|
42
|
-
// deny lists and allow lists union.
|
|
43
|
-
static intersect(policies) {
|
|
44
|
-
const allow = CapabilityAdmission.#unique(policies.flatMap((policy) => policy.allow ?? []));
|
|
45
|
-
const deny = CapabilityAdmission.#unique(policies.flatMap((policy) => policy.deny ?? []));
|
|
46
|
-
let only;
|
|
47
|
-
for (const policy of policies) {
|
|
48
|
-
if (policy.only === undefined)
|
|
49
|
-
continue;
|
|
50
|
-
only = only === undefined
|
|
51
|
-
? [...policy.only]
|
|
52
|
-
: only.flatMap((left) => policy.only.flatMap((right) => {
|
|
53
|
-
const merged = CapabilityAdmission.#merge(left, right);
|
|
54
|
-
return merged === null ? [] : [merged];
|
|
55
|
-
}));
|
|
56
|
-
only = CapabilityAdmission.#unique(only);
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
...(allow.length === 0 ? {} : { allow }),
|
|
60
|
-
...(only === undefined ? {} : { only }),
|
|
61
|
-
...(deny.length === 0 ? {} : { deny }),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
static #merge(left, right) {
|
|
65
|
-
const merged = {};
|
|
66
|
-
for (const field of ["operation", "scheme", "runtime", "tool", "access"]) {
|
|
67
|
-
const l = left[field];
|
|
68
|
-
const r = right[field];
|
|
69
|
-
if (l !== undefined && r !== undefined && l !== r)
|
|
70
|
-
return null;
|
|
71
|
-
const value = l ?? r;
|
|
72
|
-
if (value !== undefined)
|
|
73
|
-
merged[field] = value;
|
|
74
|
-
}
|
|
75
|
-
const traits = [...new Set([...(left.traits ?? []), ...(right.traits ?? [])])].toSorted();
|
|
76
|
-
if (traits.length > 0)
|
|
77
|
-
merged.traits = traits;
|
|
78
|
-
return merged;
|
|
79
|
-
}
|
|
80
|
-
static #unique(selectors) {
|
|
81
|
-
const seen = new Set();
|
|
82
|
-
return selectors.filter((selector) => {
|
|
83
|
-
const key = JSON.stringify({
|
|
84
|
-
operation: selector.operation,
|
|
85
|
-
scheme: selector.scheme,
|
|
86
|
-
runtime: selector.runtime,
|
|
87
|
-
tool: selector.tool,
|
|
88
|
-
access: selector.access,
|
|
89
|
-
traits: selector.traits === undefined ? undefined : [...selector.traits].toSorted(),
|
|
90
|
-
});
|
|
91
|
-
if (seen.has(key))
|
|
92
|
-
return false;
|
|
93
|
-
seen.add(key);
|
|
94
|
-
return true;
|
|
95
|
-
}).toSorted((left, right) => CapabilityAdmission.#key(left).localeCompare(CapabilityAdmission.#key(right)));
|
|
96
|
-
}
|
|
97
|
-
static #key(selector) {
|
|
98
|
-
return JSON.stringify({
|
|
99
|
-
operation: selector.operation,
|
|
100
|
-
scheme: selector.scheme,
|
|
101
|
-
runtime: selector.runtime,
|
|
102
|
-
tool: selector.tool,
|
|
103
|
-
access: selector.access,
|
|
104
|
-
traits: selector.traits === undefined ? undefined : [...selector.traits].toSorted(),
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=CapabilityAdmission.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CapabilityAdmission.js","sourceRoot":"","sources":["../../src/CapabilityAdmission.ts"],"names":[],"mappings":"AAMA,0EAA0E;AAC1E,8EAA8E;AAC9E,kBAAkB;AAClB,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,MAAM,CAAC,OAAO,CAAC,QAA4B,EAAE,UAAgC;QACzE,IAAI,QAAQ,CAAC,SAAS,KAAK,SAAS,IAAI,QAAQ,CAAC,SAAS,KAAK,UAAU,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAClG,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,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,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,QAA4B;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC;YAClB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;SACtF,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type {\n CapabilityDescriptor,\n CapabilityPolicy,\n CapabilitySelector,\n} from \"./types.generated.ts\";\n\n// {§capability-policy-cascade} — selectors are exact conjunctions. Policy\n// layers remain data; this class is the one deterministic evaluator shared by\n// every consumer.\nexport default class CapabilityAdmission {\n static matches(selector: CapabilitySelector, descriptor: CapabilityDescriptor): boolean {\n if (selector.operation !== undefined && selector.operation !== descriptor.operation) return false;\n if (selector.scheme !== undefined && selector.scheme !== descriptor.scheme) return false;\n if (selector.runtime !== undefined && selector.runtime !== descriptor.runtime) return false;\n if (selector.tool !== undefined && selector.tool !== descriptor.tool) return false;\n if (selector.access !== undefined && selector.access !== descriptor.access) return false;\n if (selector.traits !== undefined\n && !selector.traits.every((trait) => descriptor.traits.includes(trait))) return false;\n return true;\n }\n\n static allows(policy: CapabilityPolicy, descriptor: CapabilityDescriptor): boolean {\n if (policy.deny?.some((selector) => CapabilityAdmission.matches(selector, descriptor)) === true) return false;\n return policy.only === undefined\n || policy.only.some((selector) => CapabilityAdmission.matches(selector, descriptor));\n }\n\n static allowsAcross(policies: readonly CapabilityPolicy[], descriptor: CapabilityDescriptor): boolean {\n return policies.every((policy) => CapabilityAdmission.allows(policy, descriptor));\n }\n\n static preapproves(policy: CapabilityPolicy, descriptor: CapabilityDescriptor): boolean {\n if (!CapabilityAdmission.allows(policy, descriptor)) return false;\n return policy.allow?.some((selector) => CapabilityAdmission.matches(selector, descriptor)) === true;\n }\n\n static preapprovesAcross(policies: readonly CapabilityPolicy[], descriptor: CapabilityDescriptor): boolean {\n if (!CapabilityAdmission.allowsAcross(policies, descriptor)) return false;\n return policies.some((policy) => policy.allow?.some((selector) => CapabilityAdmission.matches(selector, descriptor)) === true);\n }\n\n // Lossless normalization of an intersection into one policy. `only` is an\n // OR-list, so intersecting two lists is their compatible Cartesian product;\n // deny lists and allow lists union.\n static intersect(policies: readonly CapabilityPolicy[]): CapabilityPolicy {\n const allow = CapabilityAdmission.#unique(policies.flatMap((policy) => policy.allow ?? []));\n const deny = CapabilityAdmission.#unique(policies.flatMap((policy) => policy.deny ?? []));\n let only: CapabilitySelector[] | undefined;\n for (const policy of policies) {\n if (policy.only === undefined) continue;\n only = only === undefined\n ? [...policy.only]\n : only.flatMap((left) => policy.only!.flatMap((right) => {\n const merged = CapabilityAdmission.#merge(left, right);\n return merged === null ? [] : [merged];\n }));\n only = CapabilityAdmission.#unique(only);\n }\n return {\n ...(allow.length === 0 ? {} : { allow }),\n ...(only === undefined ? {} : { only }),\n ...(deny.length === 0 ? {} : { deny }),\n };\n }\n\n static #merge(left: CapabilitySelector, right: CapabilitySelector): CapabilitySelector | null {\n const merged: Record<string, unknown> = {};\n for (const field of [\"operation\", \"scheme\", \"runtime\", \"tool\", \"access\"] as const) {\n const l = left[field];\n const r = right[field];\n if (l !== undefined && r !== undefined && l !== r) return null;\n const value = l ?? r;\n if (value !== undefined) merged[field] = value;\n }\n const traits = [...new Set([...(left.traits ?? []), ...(right.traits ?? [])])].toSorted();\n if (traits.length > 0) merged.traits = traits;\n return merged;\n }\n\n static #unique(selectors: readonly CapabilitySelector[]): CapabilitySelector[] {\n const seen = new Set<string>();\n return selectors.filter((selector) => {\n const key = JSON.stringify({\n operation: selector.operation,\n scheme: selector.scheme,\n runtime: selector.runtime,\n tool: selector.tool,\n access: selector.access,\n traits: selector.traits === undefined ? undefined : [...selector.traits].toSorted(),\n });\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n }).toSorted((left, right) => CapabilityAdmission.#key(left).localeCompare(CapabilityAdmission.#key(right)));\n }\n\n static #key(selector: CapabilitySelector): string {\n return JSON.stringify({\n operation: selector.operation,\n scheme: selector.scheme,\n runtime: selector.runtime,\n tool: selector.tool,\n access: selector.access,\n traits: selector.traits === undefined ? undefined : [...selector.traits].toSorted(),\n });\n }\n}\n"]}
|