@xemahq/kernel-contracts 0.57.0 → 0.58.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/capability/lib/capability-reach.d.ts +4 -1
- package/dist/capability/lib/capability-reach.d.ts.map +1 -1
- package/dist/capability/lib/capability-reach.js +18 -5
- package/dist/capability/lib/capability-reach.js.map +1 -1
- package/package.json +1 -1
- package/src/capability/lib/capability-reach.ts +63 -17
|
@@ -9,5 +9,8 @@ export declare const DEFAULT_CAPABILITY_REACH = CapabilityReach.Owner;
|
|
|
9
9
|
export declare const REACH_RANK: Readonly<Record<CapabilityReach, number>>;
|
|
10
10
|
export declare function reachWithin(candidate: CapabilityReach, ceiling: CapabilityReach): boolean;
|
|
11
11
|
export declare function joinReach(derived: CapabilityReach, declared?: CapabilityReach | undefined): CapabilityReach;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function deriveCapabilityReach(input: {
|
|
13
|
+
readonly ref?: string;
|
|
14
|
+
readonly invocationKind?: string;
|
|
15
|
+
}): CapabilityReach;
|
|
13
16
|
//# sourceMappingURL=capability-reach.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-reach.d.ts","sourceRoot":"","sources":["../../../src/capability/lib/capability-reach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"capability-reach.d.ts","sourceRoot":"","sources":["../../../src/capability/lib/capability-reach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqCxB,oBAAY,eAAe;IAKzB,KAAK,UAAU;IAMf,WAAW,gBAAgB;IAM3B,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,qBAAqB,mCAAgC,CAAC;AAQnE,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAQ9D,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAI/D,CAAC;AAGH,wBAAgB,WAAW,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAEzF;AAeD,wBAAgB,SAAS,CACvB,OAAO,EAAE,eAAe,EACxB,QAAQ,CAAC,EAAE,eAAe,GAAG,SAAS,GACrC,eAAe,CAGjB;AA6BD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAE3C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,eAAe,CAWlB"}
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.REACH_RANK = exports.DEFAULT_CAPABILITY_REACH = exports.CapabilityReachSchema = exports.CapabilityReach = void 0;
|
|
4
4
|
exports.reachWithin = reachWithin;
|
|
5
5
|
exports.joinReach = joinReach;
|
|
6
|
-
exports.
|
|
6
|
+
exports.deriveCapabilityReach = deriveCapabilityReach;
|
|
7
7
|
const zod_1 = require("zod");
|
|
8
|
+
const connector_capability_ref_1 = require("./connector-capability-ref");
|
|
8
9
|
var CapabilityReach;
|
|
9
10
|
(function (CapabilityReach) {
|
|
10
11
|
CapabilityReach["Owner"] = "owner";
|
|
@@ -26,9 +27,21 @@ function joinReach(derived, declared) {
|
|
|
26
27
|
return derived;
|
|
27
28
|
return exports.REACH_RANK[declared] > exports.REACH_RANK[derived] ? declared : derived;
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
function deriveCapabilityReach(input) {
|
|
31
|
+
if (input.invocationKind === 'connector') {
|
|
32
|
+
return CapabilityReach.Integration;
|
|
33
|
+
}
|
|
34
|
+
if (input.ref !== undefined &&
|
|
35
|
+
refDomain(input.ref) === connector_capability_ref_1.CONNECTOR_CAPABILITY_DOMAIN) {
|
|
36
|
+
return CapabilityReach.Integration;
|
|
37
|
+
}
|
|
38
|
+
return exports.DEFAULT_CAPABILITY_REACH;
|
|
39
|
+
}
|
|
40
|
+
function refDomain(ref) {
|
|
41
|
+
const separator = ref.indexOf(':');
|
|
42
|
+
if (separator <= 0) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return ref.slice(0, separator);
|
|
33
46
|
}
|
|
34
47
|
//# sourceMappingURL=capability-reach.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-reach.js","sourceRoot":"","sources":["../../../src/capability/lib/capability-reach.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"capability-reach.js","sourceRoot":"","sources":["../../../src/capability/lib/capability-reach.ts"],"names":[],"mappings":";;;AAgFA,kCAEC;AAeD,8BAMC;AA6BD,sDAgBC;AApJD,6BAAwB;AAExB,yEAAyE;AAmCzE,IAAY,eAkBX;AAlBD,WAAY,eAAe;IAKzB,kCAAe,CAAA;IAMf,8CAA2B,CAAA;IAM3B,wCAAqB,CAAA;AACvB,CAAC,EAlBW,eAAe,+BAAf,eAAe,QAkB1B;AAEY,QAAA,qBAAqB,GAAG,OAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAQtD,QAAA,wBAAwB,GAAG,eAAe,CAAC,KAAK,CAAC;AAQjD,QAAA,UAAU,GAA8C,MAAM,CAAC,MAAM,CAAC;IACjF,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IAC1B,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;IAChC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;CAC9B,CAAC,CAAC;AAGH,SAAgB,WAAW,CAAC,SAA0B,EAAE,OAAwB;IAC9E,OAAO,kBAAU,CAAC,SAAS,CAAC,IAAI,kBAAU,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAeD,SAAgB,SAAS,CACvB,OAAwB,EACxB,QAAsC;IAEtC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC3C,OAAO,kBAAU,CAAC,QAAQ,CAAC,GAAG,kBAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AA6BD,SAAgB,qBAAqB,CAAC,KAKrC;IACC,IAAI,KAAK,CAAC,cAAc,KAAK,WAAW,EAAE,CAAC;QACzC,OAAO,eAAe,CAAC,WAAW,CAAC;IACrC,CAAC;IACD,IACE,KAAK,CAAC,GAAG,KAAK,SAAS;QACvB,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,sDAA2B,EACpD,CAAC;QACD,OAAO,eAAe,CAAC,WAAW,CAAC;IACrC,CAAC;IACD,OAAO,gCAAwB,CAAC;AAClC,CAAC;AAUD,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/kernel-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
import { CONNECTOR_CAPABILITY_DOMAIN } from './connector-capability-ref';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* `CapabilityReach` — DECLARED answer to "how far outside the owner does
|
|
5
7
|
* invoking this capability reach?".
|
|
@@ -19,13 +21,13 @@ import { z } from 'zod';
|
|
|
19
21
|
* declarations. Adding an integration capability is a one-line declaration at
|
|
20
22
|
* the producer; no edit to `authorization-api`, and no way to forget one.
|
|
21
23
|
*
|
|
22
|
-
* PRECEDENCE — declared
|
|
23
|
-
*
|
|
24
|
-
* Absent ⇒ derived. A
|
|
25
|
-
*
|
|
26
|
-
* with no declaration at all. Everything
|
|
27
|
-
* {@link CapabilityReach.Owner}, which is the SAFE default: it
|
|
28
|
-
* beyond what the owner already holds.
|
|
24
|
+
* PRECEDENCE — declared RAISES, derivation is the floor
|
|
25
|
+
* -----------------------------------------------------
|
|
26
|
+
* Absent ⇒ derived. A capability that is a connector — by its invocation
|
|
27
|
+
* binding OR by its ref domain, see {@link deriveCapabilityReach} — derives
|
|
28
|
+
* {@link CapabilityReach.Integration} with no declaration at all. Everything
|
|
29
|
+
* else derives {@link CapabilityReach.Owner}, which is the SAFE default: it
|
|
30
|
+
* grants nothing beyond what the owner already holds.
|
|
29
31
|
*
|
|
30
32
|
* A declaration may therefore only ever be needed to RAISE reach above the
|
|
31
33
|
* derived floor (an http-bound capability that nonetheless touches org-wide
|
|
@@ -104,16 +106,60 @@ export function joinReach(
|
|
|
104
106
|
/**
|
|
105
107
|
* The reach a capability has by construction, before any declaration.
|
|
106
108
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
109
|
+
* TWO independent structural signals, either of which is sufficient. Both are
|
|
110
|
+
* facts about the capability that the platform already holds — neither is a
|
|
111
|
+
* guess, and neither needs an author to remember anything:
|
|
112
|
+
*
|
|
113
|
+
* 1. **The invocation binding kind.** A `connector`-kind binding reaches a
|
|
114
|
+
* connected external system — that is what a connector IS.
|
|
115
|
+
* 2. **The ref domain.** A ref in the `connector` domain
|
|
116
|
+
* ({@link CONNECTOR_CAPABILITY_DOMAIN}) is a connector capability by the
|
|
117
|
+
* ref grammar itself, which is a typed contract, not a naming convention.
|
|
118
|
+
*
|
|
119
|
+
* Signal 2 is not redundant, and leaving it out was a real bug: connector
|
|
120
|
+
* capabilities are today published with `http` invocation bindings (they are
|
|
121
|
+
* invoked through the connector gateway over HTTP), so binding-kind alone
|
|
122
|
+
* derives `owner` and every `connector:*` ref silently drops out of the
|
|
123
|
+
* `connected` reach tier. That is the exact failure mode — a capability quietly
|
|
124
|
+
* outside the tier that names it — this whole mechanism replaced a
|
|
125
|
+
* hand-maintained roster to prevent.
|
|
126
|
+
*
|
|
127
|
+
* Everything else derives the safe floor; raising it is the author's explicit
|
|
128
|
+
* act via a declared `reach`.
|
|
129
|
+
*
|
|
130
|
+
* Kept here, beside the enum, so the projector, the registry and the tier
|
|
131
|
+
* resolver cannot drift on what "derived" means.
|
|
132
|
+
*/
|
|
133
|
+
export function deriveCapabilityReach(input: {
|
|
134
|
+
/** Canonical capability ref. Unparseable refs contribute no signal. */
|
|
135
|
+
readonly ref?: string;
|
|
136
|
+
/** `CapabilityInvocationBinding.kind`, when the capability declares one. */
|
|
137
|
+
readonly invocationKind?: string;
|
|
138
|
+
}): CapabilityReach {
|
|
139
|
+
if (input.invocationKind === 'connector') {
|
|
140
|
+
return CapabilityReach.Integration;
|
|
141
|
+
}
|
|
142
|
+
if (
|
|
143
|
+
input.ref !== undefined &&
|
|
144
|
+
refDomain(input.ref) === CONNECTOR_CAPABILITY_DOMAIN
|
|
145
|
+
) {
|
|
146
|
+
return CapabilityReach.Integration;
|
|
147
|
+
}
|
|
148
|
+
return DEFAULT_CAPABILITY_REACH;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Domain segment of a capability ref, or `undefined` when the ref does not
|
|
153
|
+
* parse.
|
|
111
154
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
155
|
+
* Deliberately does NOT throw: this is a derivation input, and a malformed ref
|
|
156
|
+
* must contribute no reach signal rather than abort the read path that is
|
|
157
|
+
* validating it. The ref's own validation happens where it is written.
|
|
114
158
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
159
|
+
function refDomain(ref: string): string | undefined {
|
|
160
|
+
const separator = ref.indexOf(':');
|
|
161
|
+
if (separator <= 0) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
return ref.slice(0, separator);
|
|
119
165
|
}
|