@astrale-os/kernel-dsl 1.0.0-beta.15 → 1.0.0-beta.16

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.
@@ -2,7 +2,7 @@ import { Key } from '../../../../addressing/index.js';
2
2
  import { PolicyTyping } from '../../../../language/policy/analysis/typing.js';
3
3
  import {} from '../../../../language/policy/model/policy.js';
4
4
  import {} from '../../../model/schema.js';
5
- import { classSatisfiesAny, isCompiledEdge } from '../context.js';
5
+ import { isCompiledEdge } from '../context.js';
6
6
  import { referenceContract } from './contracts.js';
7
7
  /** Types one entry's Policies against the Node Classes of its own closure, as source admission. */
8
8
  export function compiledPolicyTyping(context, entry, normalized, origins) {
@@ -14,7 +14,7 @@ export function compiledPolicyTyping(context, entry, normalized, origins) {
14
14
  allNodeClasses: nodeClasses.map((value) => value.ref),
15
15
  concreteNodeClasses: nodeClasses.filter((value) => !value.abstract).map((value) => value.ref),
16
16
  isLocalPolicy: (ref) => ref.origin === entry.origin && ref.kind === 'policy',
17
- classExtends: (candidate, required) => classSatisfiesAny(context, candidate, [required]),
17
+ resolveClass: (ref) => context.classes.get(Key.of(ref))?.value,
18
18
  edgeDeclaration: (ref) => {
19
19
  const value = context.classes.get(Key.of(ref))?.value;
20
20
  return value !== undefined && isCompiledEdge(value) ? value : undefined;
@@ -0,0 +1,462 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.astrale.ai/dsl/v1/draft-2020-12",
4
+ "title": "JSON Schema Draft 2020-12",
5
+ "$comment": "The Draft 2020-12 meta-schemas the V1 value-schema dialect composes, each under its own $id, exactly as the validator of the dialect embeds them. With value-schema.schema.json, they resolve the dialect without a network fetch.",
6
+ "$defs": {
7
+ "schema": {
8
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
9
+ "$id": "https://json-schema.org/draft/2020-12/schema",
10
+ "$vocabulary": {
11
+ "https://json-schema.org/draft/2020-12/vocab/core": true,
12
+ "https://json-schema.org/draft/2020-12/vocab/applicator": true,
13
+ "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
14
+ "https://json-schema.org/draft/2020-12/vocab/validation": true,
15
+ "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
16
+ "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
17
+ "https://json-schema.org/draft/2020-12/vocab/content": true
18
+ },
19
+ "$dynamicAnchor": "meta",
20
+ "title": "Core and Validation specifications meta-schema",
21
+ "allOf": [
22
+ {
23
+ "$ref": "meta/core"
24
+ },
25
+ {
26
+ "$ref": "meta/applicator"
27
+ },
28
+ {
29
+ "$ref": "meta/unevaluated"
30
+ },
31
+ {
32
+ "$ref": "meta/validation"
33
+ },
34
+ {
35
+ "$ref": "meta/meta-data"
36
+ },
37
+ {
38
+ "$ref": "meta/format-annotation"
39
+ },
40
+ {
41
+ "$ref": "meta/content"
42
+ }
43
+ ],
44
+ "type": [
45
+ "object",
46
+ "boolean"
47
+ ],
48
+ "$comment": "This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",
49
+ "properties": {
50
+ "definitions": {
51
+ "$comment": "\"definitions\" has been replaced by \"$defs\".",
52
+ "type": "object",
53
+ "additionalProperties": {
54
+ "$dynamicRef": "#meta"
55
+ },
56
+ "deprecated": true,
57
+ "default": {}
58
+ },
59
+ "dependencies": {
60
+ "$comment": "\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.",
61
+ "type": "object",
62
+ "additionalProperties": {
63
+ "anyOf": [
64
+ {
65
+ "$dynamicRef": "#meta"
66
+ },
67
+ {
68
+ "$ref": "meta/validation#/$defs/stringArray"
69
+ }
70
+ ]
71
+ },
72
+ "deprecated": true,
73
+ "default": {}
74
+ },
75
+ "$recursiveAnchor": {
76
+ "$comment": "\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".",
77
+ "$ref": "meta/core#/$defs/anchorString",
78
+ "deprecated": true
79
+ },
80
+ "$recursiveRef": {
81
+ "$comment": "\"$recursiveRef\" has been replaced by \"$dynamicRef\".",
82
+ "$ref": "meta/core#/$defs/uriReferenceString",
83
+ "deprecated": true
84
+ }
85
+ }
86
+ },
87
+ "core": {
88
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
89
+ "$id": "https://json-schema.org/draft/2020-12/meta/core",
90
+ "$vocabulary": {
91
+ "https://json-schema.org/draft/2020-12/vocab/core": true
92
+ },
93
+ "$dynamicAnchor": "meta",
94
+ "title": "Core vocabulary meta-schema",
95
+ "type": [
96
+ "object",
97
+ "boolean"
98
+ ],
99
+ "properties": {
100
+ "$id": {
101
+ "$ref": "#/$defs/uriReferenceString",
102
+ "$comment": "Non-empty fragments not allowed.",
103
+ "pattern": "^[^#]*#?$"
104
+ },
105
+ "$schema": {
106
+ "$ref": "#/$defs/uriString"
107
+ },
108
+ "$ref": {
109
+ "$ref": "#/$defs/uriReferenceString"
110
+ },
111
+ "$anchor": {
112
+ "$ref": "#/$defs/anchorString"
113
+ },
114
+ "$dynamicRef": {
115
+ "$ref": "#/$defs/uriReferenceString"
116
+ },
117
+ "$dynamicAnchor": {
118
+ "$ref": "#/$defs/anchorString"
119
+ },
120
+ "$vocabulary": {
121
+ "type": "object",
122
+ "propertyNames": {
123
+ "$ref": "#/$defs/uriString"
124
+ },
125
+ "additionalProperties": {
126
+ "type": "boolean"
127
+ }
128
+ },
129
+ "$comment": {
130
+ "type": "string"
131
+ },
132
+ "$defs": {
133
+ "type": "object",
134
+ "additionalProperties": {
135
+ "$dynamicRef": "#meta"
136
+ }
137
+ }
138
+ },
139
+ "$defs": {
140
+ "anchorString": {
141
+ "type": "string",
142
+ "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$"
143
+ },
144
+ "uriString": {
145
+ "type": "string",
146
+ "format": "uri"
147
+ },
148
+ "uriReferenceString": {
149
+ "type": "string",
150
+ "format": "uri-reference"
151
+ }
152
+ }
153
+ },
154
+ "applicator": {
155
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
156
+ "$id": "https://json-schema.org/draft/2020-12/meta/applicator",
157
+ "$vocabulary": {
158
+ "https://json-schema.org/draft/2020-12/vocab/applicator": true
159
+ },
160
+ "$dynamicAnchor": "meta",
161
+ "title": "Applicator vocabulary meta-schema",
162
+ "type": [
163
+ "object",
164
+ "boolean"
165
+ ],
166
+ "properties": {
167
+ "prefixItems": {
168
+ "$ref": "#/$defs/schemaArray"
169
+ },
170
+ "items": {
171
+ "$dynamicRef": "#meta"
172
+ },
173
+ "contains": {
174
+ "$dynamicRef": "#meta"
175
+ },
176
+ "additionalProperties": {
177
+ "$dynamicRef": "#meta"
178
+ },
179
+ "properties": {
180
+ "type": "object",
181
+ "additionalProperties": {
182
+ "$dynamicRef": "#meta"
183
+ },
184
+ "default": {}
185
+ },
186
+ "patternProperties": {
187
+ "type": "object",
188
+ "additionalProperties": {
189
+ "$dynamicRef": "#meta"
190
+ },
191
+ "propertyNames": {
192
+ "format": "regex"
193
+ },
194
+ "default": {}
195
+ },
196
+ "dependentSchemas": {
197
+ "type": "object",
198
+ "additionalProperties": {
199
+ "$dynamicRef": "#meta"
200
+ },
201
+ "default": {}
202
+ },
203
+ "propertyNames": {
204
+ "$dynamicRef": "#meta"
205
+ },
206
+ "if": {
207
+ "$dynamicRef": "#meta"
208
+ },
209
+ "then": {
210
+ "$dynamicRef": "#meta"
211
+ },
212
+ "else": {
213
+ "$dynamicRef": "#meta"
214
+ },
215
+ "allOf": {
216
+ "$ref": "#/$defs/schemaArray"
217
+ },
218
+ "anyOf": {
219
+ "$ref": "#/$defs/schemaArray"
220
+ },
221
+ "oneOf": {
222
+ "$ref": "#/$defs/schemaArray"
223
+ },
224
+ "not": {
225
+ "$dynamicRef": "#meta"
226
+ }
227
+ },
228
+ "$defs": {
229
+ "schemaArray": {
230
+ "type": "array",
231
+ "minItems": 1,
232
+ "items": {
233
+ "$dynamicRef": "#meta"
234
+ }
235
+ }
236
+ }
237
+ },
238
+ "unevaluated": {
239
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
240
+ "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated",
241
+ "$vocabulary": {
242
+ "https://json-schema.org/draft/2020-12/vocab/unevaluated": true
243
+ },
244
+ "$dynamicAnchor": "meta",
245
+ "title": "Unevaluated applicator vocabulary meta-schema",
246
+ "type": [
247
+ "object",
248
+ "boolean"
249
+ ],
250
+ "properties": {
251
+ "unevaluatedItems": {
252
+ "$dynamicRef": "#meta"
253
+ },
254
+ "unevaluatedProperties": {
255
+ "$dynamicRef": "#meta"
256
+ }
257
+ }
258
+ },
259
+ "validation": {
260
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
261
+ "$id": "https://json-schema.org/draft/2020-12/meta/validation",
262
+ "$vocabulary": {
263
+ "https://json-schema.org/draft/2020-12/vocab/validation": true
264
+ },
265
+ "$dynamicAnchor": "meta",
266
+ "title": "Validation vocabulary meta-schema",
267
+ "type": [
268
+ "object",
269
+ "boolean"
270
+ ],
271
+ "properties": {
272
+ "type": {
273
+ "anyOf": [
274
+ {
275
+ "$ref": "#/$defs/simpleTypes"
276
+ },
277
+ {
278
+ "type": "array",
279
+ "items": {
280
+ "$ref": "#/$defs/simpleTypes"
281
+ },
282
+ "minItems": 1,
283
+ "uniqueItems": true
284
+ }
285
+ ]
286
+ },
287
+ "const": true,
288
+ "enum": {
289
+ "type": "array",
290
+ "items": true
291
+ },
292
+ "multipleOf": {
293
+ "type": "number",
294
+ "exclusiveMinimum": 0
295
+ },
296
+ "maximum": {
297
+ "type": "number"
298
+ },
299
+ "exclusiveMaximum": {
300
+ "type": "number"
301
+ },
302
+ "minimum": {
303
+ "type": "number"
304
+ },
305
+ "exclusiveMinimum": {
306
+ "type": "number"
307
+ },
308
+ "maxLength": {
309
+ "$ref": "#/$defs/nonNegativeInteger"
310
+ },
311
+ "minLength": {
312
+ "$ref": "#/$defs/nonNegativeIntegerDefault0"
313
+ },
314
+ "pattern": {
315
+ "type": "string",
316
+ "format": "regex"
317
+ },
318
+ "maxItems": {
319
+ "$ref": "#/$defs/nonNegativeInteger"
320
+ },
321
+ "minItems": {
322
+ "$ref": "#/$defs/nonNegativeIntegerDefault0"
323
+ },
324
+ "uniqueItems": {
325
+ "type": "boolean",
326
+ "default": false
327
+ },
328
+ "maxContains": {
329
+ "$ref": "#/$defs/nonNegativeInteger"
330
+ },
331
+ "minContains": {
332
+ "$ref": "#/$defs/nonNegativeInteger",
333
+ "default": 1
334
+ },
335
+ "maxProperties": {
336
+ "$ref": "#/$defs/nonNegativeInteger"
337
+ },
338
+ "minProperties": {
339
+ "$ref": "#/$defs/nonNegativeIntegerDefault0"
340
+ },
341
+ "required": {
342
+ "$ref": "#/$defs/stringArray"
343
+ },
344
+ "dependentRequired": {
345
+ "type": "object",
346
+ "additionalProperties": {
347
+ "$ref": "#/$defs/stringArray"
348
+ }
349
+ }
350
+ },
351
+ "$defs": {
352
+ "nonNegativeInteger": {
353
+ "type": "integer",
354
+ "minimum": 0
355
+ },
356
+ "nonNegativeIntegerDefault0": {
357
+ "$ref": "#/$defs/nonNegativeInteger",
358
+ "default": 0
359
+ },
360
+ "simpleTypes": {
361
+ "enum": [
362
+ "array",
363
+ "boolean",
364
+ "integer",
365
+ "null",
366
+ "number",
367
+ "object",
368
+ "string"
369
+ ]
370
+ },
371
+ "stringArray": {
372
+ "type": "array",
373
+ "items": {
374
+ "type": "string"
375
+ },
376
+ "uniqueItems": true,
377
+ "default": []
378
+ }
379
+ }
380
+ },
381
+ "meta-data": {
382
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
383
+ "$id": "https://json-schema.org/draft/2020-12/meta/meta-data",
384
+ "$vocabulary": {
385
+ "https://json-schema.org/draft/2020-12/vocab/meta-data": true
386
+ },
387
+ "$dynamicAnchor": "meta",
388
+ "title": "Meta-data vocabulary meta-schema",
389
+ "type": [
390
+ "object",
391
+ "boolean"
392
+ ],
393
+ "properties": {
394
+ "title": {
395
+ "type": "string"
396
+ },
397
+ "description": {
398
+ "type": "string"
399
+ },
400
+ "default": true,
401
+ "deprecated": {
402
+ "type": "boolean",
403
+ "default": false
404
+ },
405
+ "readOnly": {
406
+ "type": "boolean",
407
+ "default": false
408
+ },
409
+ "writeOnly": {
410
+ "type": "boolean",
411
+ "default": false
412
+ },
413
+ "examples": {
414
+ "type": "array",
415
+ "items": true
416
+ }
417
+ }
418
+ },
419
+ "format-annotation": {
420
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
421
+ "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation",
422
+ "$vocabulary": {
423
+ "https://json-schema.org/draft/2020-12/vocab/format-annotation": true
424
+ },
425
+ "$dynamicAnchor": "meta",
426
+ "title": "Format vocabulary meta-schema for annotation results",
427
+ "type": [
428
+ "object",
429
+ "boolean"
430
+ ],
431
+ "properties": {
432
+ "format": {
433
+ "type": "string"
434
+ }
435
+ }
436
+ },
437
+ "content": {
438
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
439
+ "$id": "https://json-schema.org/draft/2020-12/meta/content",
440
+ "$vocabulary": {
441
+ "https://json-schema.org/draft/2020-12/vocab/content": true
442
+ },
443
+ "$dynamicAnchor": "meta",
444
+ "title": "Content vocabulary meta-schema",
445
+ "type": [
446
+ "object",
447
+ "boolean"
448
+ ],
449
+ "properties": {
450
+ "contentEncoding": {
451
+ "type": "string"
452
+ },
453
+ "contentMediaType": {
454
+ "type": "string"
455
+ },
456
+ "contentSchema": {
457
+ "$dynamicRef": "#meta"
458
+ }
459
+ }
460
+ }
461
+ }
462
+ }
@@ -2,6 +2,7 @@ import type { ClassRef, PolicyRef } from '../../../addressing/index.js';
2
2
  import type { EdgeContract } from '../../class/model/edge.js';
3
3
  import type { PolicyExpression, PolicyObjectRef } from '../model/policy.js';
4
4
  import type { CheckLeafClasses } from './checks.js';
5
+ import { type ClassAncestry } from '../../class/inheritance.js';
5
6
  import { type PatternBranch } from './branches.js';
6
7
  export type ObjectContract = {
7
8
  readonly kind: 'default';
@@ -21,10 +22,11 @@ export type PolicyUseContract = {
21
22
  export interface PolicyTypingScope {
22
23
  readonly normalized: ReadonlyMap<string, PolicyExpression>;
23
24
  readonly allNodeClasses: readonly ClassRef[];
25
+ /** The concrete Classes of `allNodeClasses`, in its order. */
24
26
  readonly concreteNodeClasses: readonly ClassRef[];
25
27
  isLocalPolicy(ref: PolicyRef): boolean;
26
- /** Whether `candidate` is the `required` Class or a same-kind descendant. */
27
- classExtends(candidate: ClassRef, required: ClassRef): boolean;
28
+ /** The Class a ref names in the closure, as satisfaction reads it. */
29
+ resolveClass(ref: ClassRef): ClassAncestry | undefined;
28
30
  edgeDeclaration(ref: ClassRef): EdgeContract | undefined;
29
31
  /** The contract of a Node a Policy pattern references, `undefined` when it has none. */
30
32
  referenceContract(ref: PolicyObjectRef): ObjectContract | undefined;