@astrale-os/kernel-dsl 1.0.0-beta.31 → 1.0.0-beta.32
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/v1/builder/callable/authoring.d.ts +2 -2
- package/dist/v1/builder/class/authoring.js +0 -1
- package/dist/v1/builder/class/input.d.ts +3 -5
- package/dist/v1/builder/index.d.ts +1 -1
- package/dist/v1/builder/lowering/class.js +0 -5
- package/dist/v1/builder/lowering/policy.js +24 -6
- package/dist/v1/builder/policy/authoring.d.ts +33 -7
- package/dist/v1/builder/policy/authoring.js +5 -2
- package/dist/v1/builder/policy/legacy/inputs.d.ts +8 -0
- package/dist/v1/builder/policy/legacy/inputs.js +1 -0
- package/dist/v1/compiled/admission/semantics/class.js +0 -15
- package/dist/v1/compiled/admission/semantics/context.d.ts +1 -2
- package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -2
- package/dist/v1/compiled/admission/semantics/policy/parity.js +26 -3
- package/dist/v1/compiled/admission/semantics/policy/typing.js +2 -0
- package/dist/v1/compiled/admission/wire/class.js +1 -10
- package/dist/v1/compiled/admission/wire/policy.js +21 -1
- package/dist/v1/compiled/rule.js +0 -1
- package/dist/v1/domain/projection/classes.js +0 -8
- package/dist/v1/index.d.ts +1 -1
- package/dist/v1/language/callable/admission.js +5 -3
- package/dist/v1/language/class/model/class.d.ts +1 -2
- package/dist/v1/language/class/resolved.d.ts +0 -7
- package/dist/v1/language/index.d.ts +1 -2
- package/dist/v1/language/index.js +1 -1
- package/dist/v1/language/limits.d.ts +2 -0
- package/dist/v1/language/limits.js +2 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +1 -1
- package/dist/v1/language/policy/analysis/branches.js +6 -0
- package/dist/v1/language/policy/analysis/budgets.d.ts +4 -2
- package/dist/v1/language/policy/analysis/budgets.js +18 -3
- package/dist/v1/language/policy/analysis/checks.d.ts +5 -2
- package/dist/v1/language/policy/analysis/checks.js +12 -11
- package/dist/v1/language/policy/analysis/typing.d.ts +15 -2
- package/dist/v1/language/policy/analysis/typing.js +106 -4
- package/dist/v1/language/policy/model/policy.d.ts +13 -0
- package/dist/v1/language/policy/model/policy.js +4 -0
- package/dist/v1/language/policy/normalization/normalize.js +9 -2
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +106 -16
- package/dist/v1/schema/analysis/class.d.ts +0 -8
- package/dist/v1/schema/analysis/class.js +0 -28
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +1 -1
- package/dist/v1/schema/compatibility/comparators/classes.js +1 -11
- package/dist/v1/schema/compatibility/evidence.js +12 -2
- package/dist/v1/schema/compatibility/fields.d.ts +2 -2
- package/dist/v1/schema/compatibility/fields.js +1 -1
- package/dist/v1/schema/diagnostic.d.ts +1 -1
- package/dist/v1/schema/enforcement/changes.d.ts +0 -6
- package/dist/v1/schema/enforcement/changes.js +0 -6
- package/dist/v1/schema/enforcement/derived.d.ts +0 -6
- package/dist/v1/schema/enforcement/derived.js +0 -6
- package/dist/v1/schema/enforcement/fields.d.ts +0 -1
- package/dist/v1/schema/enforcement/fields.js +0 -1
- package/dist/v1/schema/enforcement/write.d.ts +0 -7
- package/dist/v1/schema/enforcement/write.js +0 -7
- package/dist/v1/schema/normalization/domain.js +1 -1
- package/dist/v1/schema/resolution/origins.js +7 -2
- package/dist/v1/schema/rule.js +3 -7
- package/dist/v1/schema/validation/domain.structure.d.ts +5 -3
- package/dist/v1/schema/validation/domain.structure.js +3 -5
- package/dist/v1/schema/validation/policy/budgets.js +2 -1
- package/dist/v1/schema/validation/policy/context.d.ts +1 -0
- package/dist/v1/schema/validation/policy/context.js +3 -0
- package/dist/v1/schema/validation/policy/references.js +4 -1
- package/dist/v1/schema/validation/policy/typing.js +6 -0
- package/dist/v1/schema/validation/policy/uses.js +24 -2
- package/package.json +1 -1
- package/dist/v1/language/class/model/data.d.ts +0 -11
- package/dist/v1/language/class/model/data.js +0 -2
|
@@ -19,7 +19,7 @@ export function measurePolicies(input) {
|
|
|
19
19
|
export function measureDomainPolicies(schema, normalized = normalizedPolicies(schema)) {
|
|
20
20
|
const measurePolicy = policyMeasurer(schema.origin, normalized, (ref) => ref.origin === schema.origin &&
|
|
21
21
|
ref.kind === 'policy' &&
|
|
22
|
-
Object.hasOwn(schema.policies, ref.name));
|
|
22
|
+
Object.hasOwn(schema.policies, ref.name), (name) => schema.policies[name]?.input);
|
|
23
23
|
const policies = {};
|
|
24
24
|
const unmeasured = [];
|
|
25
25
|
for (const name of Object.keys(schema.policies)) {
|
|
@@ -68,6 +68,7 @@ export function validateCheckBudget(context, pointer, measure) {
|
|
|
68
68
|
}
|
|
69
69
|
/** How `PL_BUDGET` explains each limit a named Policy exceeds. */
|
|
70
70
|
const REFUSAL = {
|
|
71
|
+
inputs: (measure) => `Policy declares ${measure.inputs} Node inputs. The maximum is ${limits.policy.inputs}.`,
|
|
71
72
|
patternDepth: (measure) => `Expanded Pattern depth ${measure.patternDepth} exceeds ${limits.policy.patternDepth}.`,
|
|
72
73
|
normalizedBranches: () => `Expanded Pattern has more than ${limits.policy.normalizedBranches} normalized branches.`,
|
|
73
74
|
edgePredicates: (measure) => `A normalized branch contains ${measure.edgePredicates} graph predicates; the maximum is ${limits.policy.edgePredicates}.`,
|
|
@@ -15,6 +15,7 @@ export declare class PolicyValidationContext implements PolicyTypingScope {
|
|
|
15
15
|
readonly allNodeClasses: readonly ClassRef[];
|
|
16
16
|
readonly concreteNodeClasses: readonly ClassRef[];
|
|
17
17
|
constructor(environment: DomainResolutionContext, analysis: DefinitionAnalysisResult);
|
|
18
|
+
inputOf(name: string): Readonly<Record<string, ClassRef>> | undefined;
|
|
18
19
|
resolveNodeClass(ref: ClassRef, pointer: string): IndexedClassDefinition | undefined;
|
|
19
20
|
resolveEdge(ref: ClassRef, pointer: string): IndexedClassDefinition | undefined;
|
|
20
21
|
resolvePolicy(ref: PolicyRef, pointer: string): boolean;
|
|
@@ -20,6 +20,9 @@ export class PolicyValidationContext {
|
|
|
20
20
|
.filter((value) => !value.declaration.abstract)
|
|
21
21
|
.map((value) => value.ref);
|
|
22
22
|
}
|
|
23
|
+
inputOf(name) {
|
|
24
|
+
return this.environment.candidate.policies[name]?.input;
|
|
25
|
+
}
|
|
23
26
|
resolveNodeClass(ref, pointer) {
|
|
24
27
|
const resolved = this.environment.resolve(ref);
|
|
25
28
|
if (resolved === undefined || resolved.ref.kind !== 'class' || resolved.kind !== 'node') {
|
|
@@ -12,6 +12,8 @@ export function validatePolicyReferences(context) {
|
|
|
12
12
|
if (!equalDefinitionRefs(declaration.ref, expected)) {
|
|
13
13
|
context.add('DV_REF_RESOLVES', `${pointer}/ref`, `Policy ref must be exactly ${expected.origin}:policy.${expected.name}.`);
|
|
14
14
|
}
|
|
15
|
+
for (const [key, ref] of Object.entries(declaration.input ?? {}))
|
|
16
|
+
context.resolveNodeClass(ref, pointer + '/input/' + key);
|
|
15
17
|
const expression = declaration.expression;
|
|
16
18
|
context.normalized.set(name, normalizePolicyExpression(expression));
|
|
17
19
|
if ('match' in expression)
|
|
@@ -38,7 +40,8 @@ function validateMatch(context, name, pattern, pointer) {
|
|
|
38
40
|
context.add('PL_TARGET', `${pointer}/match`, `Normalized branch ${index} must use object or at least one of source and target, without mixing target modes.`);
|
|
39
41
|
continue;
|
|
40
42
|
}
|
|
41
|
-
if (!isConnected(branch)
|
|
43
|
+
if (!isConnected(branch) ||
|
|
44
|
+
Object.keys(context.environment.candidate.policies[name]?.input ?? {}).some((key) => !branch.terms.has('input:' + key))) {
|
|
42
45
|
context.add('PL_CONNECTIVITY', `${pointer}/match`, `Normalized ${mode} branch ${index} does not connect subject, every referenced protected term, and every scoped term.`);
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -6,8 +6,14 @@ export function validatePolicyTyping(context, typing) {
|
|
|
6
6
|
const branches = typing.expandedBranches(name, `$${name}`);
|
|
7
7
|
if (branches === undefined)
|
|
8
8
|
continue;
|
|
9
|
+
if (!typing.validDeclaration(name)) {
|
|
10
|
+
context.add('PL_USE', '/policies/' + escapePointerToken(name), 'Policy branches and operands must agree with the declared input names and Classes.');
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
9
13
|
for (const [index, branch] of branches.entries()) {
|
|
10
14
|
const mode = targetMode(branch);
|
|
15
|
+
if (mode === 'named')
|
|
16
|
+
continue;
|
|
11
17
|
if (mode === undefined) {
|
|
12
18
|
if (!('match' in context.environment.candidate.policies[name].expression)) {
|
|
13
19
|
context.add('PL_TARGET', `/policies/${escapePointerToken(name)}`, `Expanded normalized branch ${index} must use object or at least one of source and target, without mixing target modes.`);
|
|
@@ -113,6 +113,26 @@ function visitChecks(validation, typing, expression, context, pointer, leaves) {
|
|
|
113
113
|
if ('check' in expression) {
|
|
114
114
|
if (!validation.resolvePolicy(expression.check, `${pointer}/check`))
|
|
115
115
|
return;
|
|
116
|
+
if ('input' in expression) {
|
|
117
|
+
const actuals = Object.create(null);
|
|
118
|
+
for (const [key, operand] of Object.entries(expression.input)) {
|
|
119
|
+
const location = pointer + '/input/' + key;
|
|
120
|
+
const contracts = operand.kind === 'self'
|
|
121
|
+
? selfContracts(validation, context, location)
|
|
122
|
+
: operand.kind === 'input'
|
|
123
|
+
? inputContracts(validation, context, operand.field, location)
|
|
124
|
+
: referenceContracts(validation, operand.ref, location);
|
|
125
|
+
if (!contracts)
|
|
126
|
+
return;
|
|
127
|
+
actuals[key] = contracts;
|
|
128
|
+
}
|
|
129
|
+
const classes = typing.namedCheck(expression.check.name, expression.input, actuals);
|
|
130
|
+
if (!classes)
|
|
131
|
+
validation.add('PL_USE', pointer, 'Bindings must supply each declared input with a compatible Node.');
|
|
132
|
+
else
|
|
133
|
+
leaves.set(expression, classes);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
116
136
|
if (expression.object.kind === 'self' && context.edge !== undefined) {
|
|
117
137
|
// An Edge is checked as an Edge Class Policy is: over every concrete endpoint pair.
|
|
118
138
|
if (!typing.policyAcceptsEdgeClass(expression.check.name, context.edge.declaration)) {
|
|
@@ -120,7 +140,9 @@ function visitChecks(validation, typing, expression, context, pointer, leaves) {
|
|
|
120
140
|
return;
|
|
121
141
|
}
|
|
122
142
|
const edge = formatDefinitionRef(context.edge.ref);
|
|
123
|
-
leaves.set(expression,
|
|
143
|
+
leaves.set(expression, [
|
|
144
|
+
{ object: expression.object, accepted: [edge], admitted: new Set([edge]) },
|
|
145
|
+
]);
|
|
124
146
|
return;
|
|
125
147
|
}
|
|
126
148
|
const objectPointer = `${pointer}/object`;
|
|
@@ -136,7 +158,7 @@ function visitChecks(validation, typing, expression, context, pointer, leaves) {
|
|
|
136
158
|
validation.add('PL_USE', pointer, `${formatDefinitionRef(expression.check)} is incompatible with ${SITE[context.site].objects}.`, formatDefinitionRef(expression.check));
|
|
137
159
|
return;
|
|
138
160
|
}
|
|
139
|
-
leaves.set(expression, classes);
|
|
161
|
+
leaves.set(expression, [{ ...classes, object: expression.object }]);
|
|
140
162
|
return;
|
|
141
163
|
}
|
|
142
164
|
const { operator, operands } = PolicyComposition.of(expression);
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Object as JsonObject } from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
/** Canonical lowercase RFC 6838 media type without parameters. */
|
|
3
|
-
export declare const MEDIA_TYPE_PATTERN: RegExp;
|
|
4
|
-
export type MediaType = string;
|
|
5
|
-
/** Schema-level contract for one externally stored Node payload. */
|
|
6
|
-
export type DataDefinition = JsonObject & {
|
|
7
|
-
readonly mediaType: MediaType;
|
|
8
|
-
};
|
|
9
|
-
export interface DataFacet {
|
|
10
|
-
readonly data?: DataDefinition;
|
|
11
|
-
}
|