@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.
@@ -15,7 +15,7 @@ export function validateDomainSchemaSemantics(schema, lookup) {
15
15
  const diagnostics = [
16
16
  ...context.diagnostics,
17
17
  ...validateEmbeddedValueSchemas(schema, registry),
18
- ...validateDefinitions(context, analysis),
18
+ ...validateDefinitions(context, analysis, registry),
19
19
  ...validateContracts(schema, registry),
20
20
  ...validatePolicies(context, analysis),
21
21
  ...validateViews(context),
@@ -22,8 +22,7 @@ export declare class PolicyValidationContext implements PolicyTypingScope {
22
22
  edgeDeclaration(ref: ClassRef): Extract<ClassDefinition, {
23
23
  readonly kind: 'edge';
24
24
  }> | undefined;
25
- /** Return true when candidate is the required Class or a same-kind descendant. */
26
- classExtends(candidate: ClassRef, required: ClassRef): boolean;
25
+ resolveClass(ref: ClassRef): ClassDefinition | undefined;
27
26
  /** The contract a Policy pattern reference types, reporting an invalid one under `/policies`. */
28
27
  referenceContract(ref: PolicyObjectRef): ObjectContract | undefined;
29
28
  add(code: SchemaDiagnosticCode, pointer: string, message: string, ref?: string): void;
@@ -1,6 +1,5 @@
1
1
  import { Key } from '../../../addressing/index.js';
2
2
  import { definitionRefIndex } from '../../../addressing/ordering.js';
3
- import { classSatisfies } from '../../../language/class/inheritance.js';
4
3
  import { diagnostic } from '../../diagnostic.js';
5
4
  import { referenceContracts } from './objects.js';
6
5
  const formatDefinitionRef = Key.of;
@@ -63,12 +62,8 @@ export class PolicyValidationContext {
63
62
  }
64
63
  return resolved.declaration;
65
64
  }
66
- /** Return true when candidate is the required Class or a same-kind descendant. */
67
- classExtends(candidate, required) {
68
- const resolve = (ref) => this.environment.resolveAny(ref)?.declaration;
69
- const actual = resolve(candidate);
70
- const target = resolve(required);
71
- return actual !== undefined && target !== undefined && classSatisfies(actual, target, resolve);
65
+ resolveClass(ref) {
66
+ return this.environment.resolveAny(ref)?.declaration;
72
67
  }
73
68
  /** The contract a Policy pattern reference types, reporting an invalid one under `/policies`. */
74
69
  referenceContract(ref) {
@@ -10,6 +10,8 @@ export type { BlobOptions, BlobReceipt, BlobRef, BlobSchema, } from '../../langu
10
10
  export type { JsonSchema as Schema, JsonSchemaObject as SchemaObject, PathAnnotation, PropertyObjectSchema as PropertySchema, ValueSchemaContext as Context, } from '../../language/value/model/schema.js';
11
11
  export { instant } from '../../language/value/model/instant.js';
12
12
  export type { OrderingKind } from '../../language/value/ordering.js';
13
+ export { VALUE_KINDS } from '../../language/value/ordering.js';
14
+ export { GRAPH_NODE_PATH_SCHEMA_ID as NODE_PATH } from '../../language/value/syntax/node-path/schema.js';
13
15
  export { DECLARED_VALUE_KINDS as DECLARED_KINDS, FORBIDDEN_KEYWORDS, SUBSCHEMA_KEYWORDS, VALUE_KEYWORDS as KEYWORDS, } from '../../language/value/profile/vocabulary.js';
14
16
  export type { DeclaredValueKind as DeclaredKind, ValueKeyword as Keyword, } from '../../language/value/profile/vocabulary.js';
15
17
  export { VALUE_RULES as RULES } from '../../language/validation/rule.js';
@@ -8,6 +8,8 @@ const registries = new WeakMap();
8
8
  export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
9
9
  export { blob, isBlobValueSchema as isBlob } from '../../language/value/model/blob.js';
10
10
  export { instant } from '../../language/value/model/instant.js';
11
+ export { VALUE_KINDS } from '../../language/value/ordering.js';
12
+ export { GRAPH_NODE_PATH_SCHEMA_ID as NODE_PATH } from '../../language/value/syntax/node-path/schema.js';
11
13
  export { DECLARED_VALUE_KINDS as DECLARED_KINDS, FORBIDDEN_KEYWORDS, SUBSCHEMA_KEYWORDS, VALUE_KEYWORDS as KEYWORDS, } from '../../language/value/profile/vocabulary.js';
12
14
  export { VALUE_RULES as RULES } from '../../language/validation/rule.js';
13
15
  /** Validate one complete JSON value under the exact accepted schema that owns the contract. */
@@ -13,7 +13,7 @@ export declare const valueSchemaRules: {
13
13
  readonly 'value-path': {
14
14
  readonly code: 'DV_VALUE_SCHEMA';
15
15
  readonly valueCode: 'VS_PATH_EXTENSION';
16
- readonly statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema, and reads target node, cardinality one and a non-empty set of Node Class refs it accepts.';
16
+ readonly statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema.';
17
17
  };
18
18
  readonly 'value-recursion': {
19
19
  readonly code: 'DV_VALUE_SCHEMA';
@@ -40,8 +40,8 @@ export type ValueSchemaRule = keyof typeof valueSchemaRules;
40
40
  /**
41
41
  * The value language in JSON Schema, for the document that embeds value schemas: `root` constrains
42
42
  * the `value-schema` definition with the published dialect and what the profile adds to it,
43
- * `definitions` holds the locations it reaches, and `nodeProperty` constrains a Node Property
44
- * definition. A named check leaves `x-astrale-rule` at the positions it constrains.
43
+ * `definitions` holds the locations it reaches and the members of the Path annotation, and
44
+ * `nodeProperty` constrains a Node Property definition. A named check leaves `x-astrale-rule` at the positions it constrains.
45
45
  */
46
46
  export declare function valueSchemaJsonSchema(): {
47
47
  readonly root: readonly JsonSchema[];
@@ -10,10 +10,11 @@ export const valueSchemaRules = {
10
10
  valueCode: 'VS_VALUE_KIND',
11
11
  statement: 'A blob is declared only by the whole schema of a Property, exactly as values.blob writes it.',
12
12
  },
13
+ // Its members are stated (`path-annotation`); where it stands is named.
13
14
  'value-path': {
14
15
  code: 'DV_VALUE_SCHEMA',
15
16
  valueCode: 'VS_PATH_EXTENSION',
16
- statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema, and reads target node, cardinality one and a non-empty set of Node Class refs it accepts.',
17
+ statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema.',
17
18
  },
18
19
  'value-recursion': {
19
20
  code: 'DV_VALUE_SCHEMA',
@@ -39,11 +40,12 @@ export const valueSchemaRules = {
39
40
  const KIND = 'x-astrale-value-kind';
40
41
  const LOCATION = '#/$defs/value-location';
41
42
  const SUBSCHEMA = '#/$defs/value-subschema';
43
+ const PATH = '#/$defs/path-annotation';
42
44
  /**
43
45
  * The value language in JSON Schema, for the document that embeds value schemas: `root` constrains
44
46
  * the `value-schema` definition with the published dialect and what the profile adds to it,
45
- * `definitions` holds the locations it reaches, and `nodeProperty` constrains a Node Property
46
- * definition. A named check leaves `x-astrale-rule` at the positions it constrains.
47
+ * `definitions` holds the locations it reaches and the members of the Path annotation, and
48
+ * `nodeProperty` constrains a Node Property definition. A named check leaves `x-astrale-rule` at the positions it constrains.
47
49
  */
48
50
  export function valueSchemaJsonSchema() {
49
51
  return {
@@ -79,7 +81,7 @@ export function valueSchemaJsonSchema() {
79
81
  enum: { type: 'array', uniqueItems: true },
80
82
  fullMatch: { type: 'string', 'x-astrale-rule': 'value-regexp' },
81
83
  pattern: { type: 'string', 'x-astrale-rule': 'value-regexp' },
82
- 'x-astrale-path': { type: 'object', 'x-astrale-rule': 'value-path' },
84
+ 'x-astrale-path': { $ref: PATH, 'x-astrale-rule': 'value-path' },
83
85
  ...Object.fromEntries(SUBSCHEMA_KEYWORDS.single.map((keyword) => [keyword, { $ref: SUBSCHEMA }])),
84
86
  ...Object.fromEntries(SUBSCHEMA_KEYWORDS.array.map((keyword) => [
85
87
  keyword,
@@ -99,6 +101,22 @@ export function valueSchemaJsonSchema() {
99
101
  // oxlint-disable-next-line unicorn/no-thenable -- the JSON Schema keyword
100
102
  then: { required: ['type'], properties: { type: { const: 'string' } } },
101
103
  }),
104
+ // The Path annotation: the one Node a Path field resolves, of a Node Class it accepts.
105
+ 'path-annotation': {
106
+ type: 'object',
107
+ properties: {
108
+ target: { type: 'string', const: 'node' },
109
+ cardinality: { type: 'string', const: 'one' },
110
+ accepts: {
111
+ type: 'array',
112
+ minItems: 1,
113
+ uniqueItems: true,
114
+ items: { $ref: '#/$defs/class-ref', 'x-astrale-rule': 'value-reference-resolution' },
115
+ },
116
+ },
117
+ required: ['target', 'cardinality', 'accepts'],
118
+ additionalProperties: false,
119
+ },
102
120
  // A location below the root: no $schema, and no blob.
103
121
  'value-subschema': {
104
122
  allOf: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "1.0.0-beta.15",
3
+ "version": "1.0.0-beta.16",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -81,6 +81,7 @@
81
81
  },
82
82
  "./v1/schema/domain-schema.schema.json": "./dist/v1/schema/.spec/schemas/domain-schema.schema.json",
83
83
  "./v1/schema/value-schema.schema.json": "./dist/v1/language/.spec/schemas/value-schema.schema.json",
84
+ "./v1/schema/draft-2020-12.schema.json": "./dist/v1/language/.spec/schemas/draft-2020-12.schema.json",
84
85
  "./v1/value/full-match": {
85
86
  "types": "./dist/v1/value/full-match.d.ts",
86
87
  "import": "./dist/v1/value/full-match.js"