@astrale-os/kernel-dsl 0.2.0-beta.47 → 0.2.0-beta.49

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.
Files changed (142) hide show
  1. package/dist/v1/addressing/patterns.d.ts +0 -5
  2. package/dist/v1/addressing/patterns.js +5 -5
  3. package/dist/v1/builder/callable/authoring.d.ts +1 -1
  4. package/dist/v1/builder/class/authoring.d.ts +0 -12
  5. package/dist/v1/builder/class/property.d.ts +1 -1
  6. package/dist/v1/builder/index.d.ts +1 -1
  7. package/dist/v1/builder/lowering/callable.d.ts +2 -1
  8. package/dist/v1/builder/lowering/core.d.ts +3 -2
  9. package/dist/v1/builder/lowering/schema/compile.js +14 -1
  10. package/dist/v1/builder/lowering/value/zod.d.ts +3 -2
  11. package/dist/v1/builder/lowering/view.d.ts +2 -1
  12. package/dist/v1/builder/schema/define.d.ts +4 -2
  13. package/dist/v1/builder/schema/handle.d.ts +2 -1
  14. package/dist/v1/builder/schema/input.d.ts +8 -0
  15. package/dist/v1/builder/schema/projection/callable.d.ts +51 -0
  16. package/dist/v1/builder/schema/projection/callable.js +1 -0
  17. package/dist/v1/builder/schema/projection/class.d.ts +89 -0
  18. package/dist/v1/builder/schema/projection/class.js +1 -0
  19. package/dist/v1/builder/schema/projection/core-input.d.ts +32 -0
  20. package/dist/v1/builder/schema/projection/core-input.js +1 -0
  21. package/dist/v1/builder/schema/projection/domain.d.ts +59 -0
  22. package/dist/v1/builder/schema/projection/domain.js +1 -0
  23. package/dist/v1/builder/schema/projection/identity.d.ts +39 -0
  24. package/dist/v1/builder/schema/projection/identity.js +1 -0
  25. package/dist/v1/builder/schema/projection/model.d.ts +59 -0
  26. package/dist/v1/builder/schema/projection/model.js +1 -0
  27. package/dist/v1/builder/schema/projection/property.d.ts +32 -0
  28. package/dist/v1/builder/schema/projection/property.js +1 -0
  29. package/dist/v1/builder/schema/projection/resolved-class.d.ts +76 -0
  30. package/dist/v1/builder/schema/projection/resolved-class.js +1 -0
  31. package/dist/v1/builder/schema/projection.d.ts +4 -375
  32. package/dist/v1/bundle/structure.d.ts +2 -1
  33. package/dist/v1/compiled/admission/accept.d.ts +1 -1
  34. package/dist/v1/compiled/admission/accept.js +7 -1005
  35. package/dist/v1/compiled/admission/closure.d.ts +3 -0
  36. package/dist/v1/compiled/admission/closure.js +173 -0
  37. package/dist/v1/compiled/admission/diagnostic.d.ts +7 -0
  38. package/dist/v1/compiled/admission/diagnostic.js +13 -0
  39. package/dist/v1/compiled/admission/revision.js +2 -0
  40. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +5 -0
  41. package/dist/v1/compiled/admission/semantics/cardinality.js +113 -0
  42. package/dist/v1/compiled/admission/semantics/class.d.ts +5 -0
  43. package/dist/v1/compiled/admission/semantics/class.js +125 -0
  44. package/dist/v1/compiled/admission/semantics/context.d.ts +60 -0
  45. package/dist/v1/compiled/admission/semantics/context.js +81 -0
  46. package/dist/v1/compiled/admission/semantics/core.d.ts +35 -0
  47. package/dist/v1/compiled/admission/semantics/core.js +123 -0
  48. package/dist/v1/compiled/admission/semantics/edge.d.ts +8 -0
  49. package/dist/v1/compiled/admission/semantics/edge.js +89 -0
  50. package/dist/v1/compiled/admission/semantics/policy/admit.d.ts +4 -0
  51. package/dist/v1/compiled/admission/semantics/policy/admit.js +57 -0
  52. package/dist/v1/compiled/admission/semantics/policy/callable.d.ts +5 -0
  53. package/dist/v1/compiled/admission/semantics/policy/callable.js +72 -0
  54. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +24 -0
  55. package/dist/v1/compiled/admission/semantics/policy/contracts.js +45 -0
  56. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +8 -0
  57. package/dist/v1/compiled/admission/semantics/policy/equality.js +27 -0
  58. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +9 -0
  59. package/dist/v1/compiled/admission/semantics/policy/measure.js +81 -0
  60. package/dist/v1/compiled/admission/semantics/policy/parity.d.ts +4 -0
  61. package/dist/v1/compiled/admission/semantics/policy/parity.js +126 -0
  62. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +8 -0
  63. package/dist/v1/compiled/admission/semantics/policy/pattern.js +78 -0
  64. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +28 -0
  65. package/dist/v1/compiled/admission/semantics/policy/typing.js +206 -0
  66. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +10 -0
  67. package/dist/v1/compiled/admission/semantics/policy/variants.js +65 -0
  68. package/dist/v1/compiled/admission/semantics.d.ts +1 -1
  69. package/dist/v1/compiled/admission/semantics.js +8 -1222
  70. package/dist/v1/compiled/admission/wire/callable.d.ts +6 -0
  71. package/dist/v1/compiled/admission/wire/callable.js +90 -0
  72. package/dist/v1/compiled/admission/wire/class.d.ts +4 -0
  73. package/dist/v1/compiled/admission/wire/class.js +117 -0
  74. package/dist/v1/compiled/admission/wire/core.d.ts +5 -0
  75. package/dist/v1/compiled/admission/wire/core.js +32 -0
  76. package/dist/v1/compiled/admission/wire/dependency.d.ts +14 -0
  77. package/dist/v1/compiled/admission/wire/dependency.js +43 -0
  78. package/dist/v1/compiled/admission/wire/entry.d.ts +5 -0
  79. package/dist/v1/compiled/admission/wire/entry.js +100 -0
  80. package/dist/v1/compiled/admission/wire/pattern.d.ts +12 -0
  81. package/dist/v1/compiled/admission/wire/pattern.js +111 -0
  82. package/dist/v1/compiled/admission/wire/policy.d.ts +5 -0
  83. package/dist/v1/compiled/admission/wire/policy.js +168 -0
  84. package/dist/v1/compiled/admission/wire/program.d.ts +4 -0
  85. package/dist/v1/compiled/admission/wire/program.js +52 -0
  86. package/dist/v1/compiled/admission/wire/property.d.ts +4 -0
  87. package/dist/v1/compiled/admission/wire/property.js +74 -0
  88. package/dist/v1/compiled/admission/wire/reference.d.ts +8 -0
  89. package/dist/v1/compiled/admission/wire/reference.js +33 -0
  90. package/dist/v1/compiled/admission/wire/value.d.ts +29 -0
  91. package/dist/v1/compiled/admission/wire/value.js +98 -0
  92. package/dist/v1/compiled/admission/wire/view.d.ts +3 -0
  93. package/dist/v1/compiled/admission/wire/view.js +17 -0
  94. package/dist/v1/compiled/compiler/compile.js +2 -0
  95. package/dist/v1/compiled/model/schema.d.ts +5 -1
  96. package/dist/v1/domain/projection/classes.js +2 -9
  97. package/dist/v1/index.d.ts +1 -1
  98. package/dist/v1/language/class/inheritance.d.ts +12 -0
  99. package/dist/v1/language/class/inheritance.js +25 -0
  100. package/dist/v1/language/class/resolved.d.ts +5 -1
  101. package/dist/v1/language/definition/metadata.d.ts +8 -0
  102. package/dist/v1/language/definition/metadata.js +12 -0
  103. package/dist/v1/language/value/model/blob.d.ts +0 -2
  104. package/dist/v1/language/value/model/blob.js +2 -2
  105. package/dist/v1/language/value/model/instant.d.ts +0 -2
  106. package/dist/v1/language/value/model/instant.js +1 -1
  107. package/dist/v1/language/value/model/schema.d.ts +2 -1
  108. package/dist/v1/language/value/model/schema.js +1 -5
  109. package/dist/v1/language/value/reference/registry.d.ts +2 -1
  110. package/dist/v1/language/value/regexp/syntax.d.ts +2 -1
  111. package/dist/v1/language/view/model/view.d.ts +2 -10
  112. package/dist/v1/schema/analysis/class.d.ts +2 -1
  113. package/dist/v1/schema/canonical/revision.d.ts +2 -1
  114. package/dist/v1/schema/compatibility/comparators/classes.d.ts +2 -1
  115. package/dist/v1/schema/compatibility/coordinate.d.ts +2 -1
  116. package/dist/v1/schema/compatibility/references.js +1 -10
  117. package/dist/v1/schema/compatibility/report.d.ts +2 -1
  118. package/dist/v1/schema/compatibility/scope.d.ts +0 -4
  119. package/dist/v1/schema/compatibility/scope.js +1 -1
  120. package/dist/v1/schema/diagnostic.d.ts +1 -1
  121. package/dist/v1/schema/model/schema.d.ts +5 -1
  122. package/dist/v1/schema/normalization/domain.js +11 -6
  123. package/dist/v1/schema/resolution/definition.index.d.ts +1 -2
  124. package/dist/v1/schema/resolution/definition.index.js +0 -3
  125. package/dist/v1/schema/resolution/origins.d.ts +1 -1
  126. package/dist/v1/schema/resolution/origins.js +0 -5
  127. package/dist/v1/schema/validation/class.js +10 -50
  128. package/dist/v1/schema/validation/core.js +1 -27
  129. package/dist/v1/schema/validation/domain.d.ts +2 -1
  130. package/dist/v1/schema/validation/domain.structure.d.ts +0 -2
  131. package/dist/v1/schema/validation/domain.structure.js +8 -8
  132. package/dist/v1/schema/validation/policy/context.js +5 -16
  133. package/dist/v1/schema/validation/view.js +14 -9
  134. package/dist/value/accept.d.ts +1 -1
  135. package/dist/value/accept.js +32 -6
  136. package/dist/value/canonical.js +10 -2
  137. package/dist/value/immutable.optimization.d.ts +4 -1
  138. package/dist/value/immutable.optimization.js +8 -2
  139. package/dist/value/limits.d.ts +1 -1
  140. package/dist/value/unicode.d.ts +3 -0
  141. package/dist/value/unicode.js +27 -0
  142. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { Key } from '../../../addressing/index.js';
3
+ import { invalid, pointer } from '../diagnostic.js';
4
+ import { definitionRef, policyObjectRef } from './reference.js';
5
+ import { object, exact, description, array, unique, boundedInteger, integer, memberName, } from './value.js';
6
+ /** Decode a named Policy and its expression grammar. */
7
+ export function compiledPolicy(input, path) {
8
+ const value = object(input, 'Policy', path);
9
+ exact(value, ['ref', 'expression'], 'Policy', path, ['description']);
10
+ definitionRef(value.ref, 'policy', 'Policy ref', `${path}/ref`);
11
+ description(value.description, 'Policy description', `${path}/description`);
12
+ policyExpression(value.expression, 0, `${path}/expression`);
13
+ return value;
14
+ }
15
+ function policyExpression(input, depth, path) {
16
+ if (depth > 64)
17
+ invalid('Policy expression depth', undefined, path);
18
+ const value = object(input, 'Policy expression', path);
19
+ if (Object.hasOwn(value, 'match')) {
20
+ exact(value, ['match'], 'Policy expression', path);
21
+ policyPattern(value.match, depth + 1, `${path}/match`);
22
+ return;
23
+ }
24
+ const member = Object.hasOwn(value, 'allOf') ? 'allOf' : 'anyOf';
25
+ exact(value, [member], 'Policy expression', path);
26
+ const memberPath = pointer(path, member);
27
+ const refs = array(value[member], `Policy ${member}`, memberPath).map((item, index) => definitionRef(item, 'policy', `Policy ${member} ref`, `${memberPath}/${index}`));
28
+ if (refs.length === 0)
29
+ invalid(`Policy ${member}`, undefined, memberPath);
30
+ unique(refs.map(Key.of), `Policy ${member}`, memberPath);
31
+ }
32
+ function policyPattern(input, depth, path) {
33
+ if (depth > 64)
34
+ invalid('Policy pattern depth', undefined, path);
35
+ const value = object(input, 'Policy pattern', path);
36
+ if (Object.hasOwn(value, 'sameNode')) {
37
+ exact(value, ['sameNode'], 'Policy equality', path);
38
+ const pair = object(value.sameNode, 'Policy equality', `${path}/sameNode`);
39
+ exact(pair, ['left', 'right'], 'Policy equality operands', `${path}/sameNode`);
40
+ policyTerm(pair.left, false, `${path}/sameNode/left`);
41
+ policyTerm(pair.right, false, `${path}/sameNode/right`);
42
+ return;
43
+ }
44
+ if (Object.hasOwn(value, 'exists')) {
45
+ exact(value, ['exists'], 'Policy exists', path);
46
+ const existsPath = `${path}/exists`;
47
+ const exists = object(value.exists, 'Policy exists', existsPath);
48
+ exact(exists, ['nodes', 'where'], 'Policy exists', existsPath);
49
+ const nodesPath = `${existsPath}/nodes`;
50
+ const nodes = array(exists.nodes, 'Policy variables', nodesPath);
51
+ if (nodes.length < 1 || nodes.length > 4)
52
+ invalid('Policy variables', undefined, nodesPath);
53
+ for (const [index, node] of nodes.entries()) {
54
+ const variablePath = `${nodesPath}/${index}`;
55
+ const variable = object(node, 'Policy variable', variablePath);
56
+ policyTerm(variable.variable, true, `${variablePath}/variable`);
57
+ if (Object.hasOwn(variable, 'class')) {
58
+ exact(variable, ['variable', 'class'], 'Policy variable', variablePath);
59
+ definitionRef(variable.class, 'class', 'Policy variable Class', `${variablePath}/class`);
60
+ }
61
+ else {
62
+ exact(variable, ['variable', 'selector'], 'Policy variable', variablePath);
63
+ const selectorPath = `${variablePath}/selector`;
64
+ const selector = object(variable.selector, 'Policy variable selector', selectorPath);
65
+ if (selector.kind === 'any') {
66
+ exact(selector, ['kind'], 'Policy variable selector', selectorPath);
67
+ }
68
+ else if (selector.kind === 'satisfies') {
69
+ exact(selector, ['kind', 'class'], 'Policy variable selector', selectorPath);
70
+ definitionRef(selector.class, 'class', 'Policy variable selector Class', `${selectorPath}/class`);
71
+ }
72
+ else {
73
+ invalid('Policy variable selector kind', undefined, `${selectorPath}/kind`);
74
+ }
75
+ }
76
+ }
77
+ policyPattern(exists.where, depth + 1, `${existsPath}/where`);
78
+ return;
79
+ }
80
+ if (Object.hasOwn(value, 'allOf') || Object.hasOwn(value, 'anyOf')) {
81
+ const member = Object.hasOwn(value, 'allOf') ? 'allOf' : 'anyOf';
82
+ exact(value, [member], 'Policy pattern composition', path);
83
+ const memberPath = pointer(path, member);
84
+ const expressions = array(value[member], `Policy pattern ${member}`, memberPath);
85
+ if (expressions.length === 0)
86
+ invalid(`Policy pattern ${member}`, undefined, memberPath);
87
+ for (const [index, expression] of expressions.entries())
88
+ policyPattern(expression, depth + 1, `${memberPath}/${index}`);
89
+ return;
90
+ }
91
+ exact(value, ['source', 'class', 'target'], 'Policy Edge pattern', path, ['repeat']);
92
+ policyTerm(value.source, false, `${path}/source`);
93
+ definitionRef(value.class, 'class', 'Policy Edge Class', `${path}/class`);
94
+ policyTerm(value.target, false, `${path}/target`);
95
+ if (value.repeat !== undefined) {
96
+ const repeatPath = `${path}/repeat`;
97
+ const repeat = object(value.repeat, 'Policy repeat', repeatPath);
98
+ exact(repeat, ['min', 'max'], 'Policy repeat', repeatPath);
99
+ const minimum = boundedInteger(repeat.min, 0, 3, 'Policy repeat minimum', `${repeatPath}/min`);
100
+ const maximum = boundedInteger(repeat.max, 0, 3, 'Policy repeat maximum', `${repeatPath}/max`);
101
+ if (minimum > maximum)
102
+ invalid('Policy repeat order', undefined, repeatPath);
103
+ }
104
+ }
105
+ function policyTerm(input, variableOnly, path) {
106
+ const value = object(input, 'Policy pattern term', path);
107
+ if (!variableOnly && value.kind === 'ref') {
108
+ exact(value, ['kind', 'ref'], 'Policy reference term', path);
109
+ policyObjectRef(value.ref, `${path}/ref`);
110
+ return;
111
+ }
112
+ if (value.kind === 'variable') {
113
+ exact(value, ['kind', 'id'], 'Policy variable term', path);
114
+ integer(value.id, 'Policy variable id', `${path}/id`);
115
+ return;
116
+ }
117
+ if (variableOnly ||
118
+ (value.kind !== 'subject' &&
119
+ value.kind !== 'object' &&
120
+ value.kind !== 'source' &&
121
+ value.kind !== 'target')) {
122
+ invalid('Policy pattern term', undefined, `${path}/kind`);
123
+ }
124
+ exact(value, ['kind'], 'Policy pattern term', path);
125
+ }
126
+ /** Check the recursive callable Policy wire grammar. */
127
+ export function policyCheck(input, depth, path) {
128
+ if (depth > 64)
129
+ invalid('Callable Policy depth', undefined, path);
130
+ const value = object(input, 'Callable Policy', path);
131
+ if (Object.hasOwn(value, 'sameNode')) {
132
+ exact(value, ['sameNode'], 'Callable equality', path);
133
+ const pair = object(value.sameNode, 'Callable equality', `${path}/sameNode`);
134
+ exact(pair, ['left', 'right'], 'Callable equality operands', `${path}/sameNode`);
135
+ policyCheckObject(pair.left, `${path}/sameNode/left`);
136
+ policyCheckObject(pair.right, `${path}/sameNode/right`);
137
+ return;
138
+ }
139
+ if (Object.hasOwn(value, 'check')) {
140
+ exact(value, ['check', 'object'], 'Callable Policy check', path);
141
+ definitionRef(value.check, 'policy', 'Callable Policy ref', `${path}/check`);
142
+ policyCheckObject(value.object, `${path}/object`);
143
+ return;
144
+ }
145
+ const member = Object.hasOwn(value, 'allOf') ? 'allOf' : 'anyOf';
146
+ exact(value, [member], 'Callable Policy composition', path);
147
+ const memberPath = pointer(path, member);
148
+ const expressions = array(value[member], `Callable Policy ${member}`, memberPath);
149
+ if (expressions.length === 0)
150
+ invalid(`Callable Policy ${member}`, undefined, memberPath);
151
+ for (const [index, expression] of expressions.entries())
152
+ policyCheck(expression, depth + 1, `${memberPath}/${index}`);
153
+ }
154
+ function policyCheckObject(input, objectPath) {
155
+ const target = object(input, 'Callable Policy object', objectPath);
156
+ if (target.kind === 'self')
157
+ exact(target, ['kind'], 'Callable Policy self', objectPath);
158
+ else if (target.kind === 'input') {
159
+ exact(target, ['kind', 'field'], 'Callable Policy input', objectPath);
160
+ memberName(target.field, 'Callable Policy input field', `${objectPath}/field`);
161
+ }
162
+ else if (target.kind === 'ref') {
163
+ exact(target, ['kind', 'ref'], 'Callable Policy object ref', objectPath);
164
+ policyObjectRef(target.ref, `${objectPath}/ref`);
165
+ }
166
+ else
167
+ invalid('Callable Policy object', undefined, `${objectPath}/kind`);
168
+ }
@@ -0,0 +1,4 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ import { type Pattern, type RunPattern, type IndexedValueProgram } from '../../model/schema.js';
3
+ /** Decode a value program and validate its local node and pattern indices. */
4
+ export declare function program(input: JsonValue, programIndex: number, path: string, table: readonly (Pattern | RunPattern)[]): IndexedValueProgram;
@@ -0,0 +1,52 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { isValueObject } from '../../../language/value/model/object.js';
3
+ import {} from '../../model/schema.js';
4
+ import { invalid, pointer } from '../diagnostic.js';
5
+ import { object, exact, array, index, unique, integer } from './value.js';
6
+ /** Decode a value program and validate its local node and pattern indices. */
7
+ export function program(input, programIndex, path, table) {
8
+ const value = object(input, `values[${programIndex}]`, path);
9
+ exact(value, ['root', 'nodes', 'patterns'], 'ValueProgram', path);
10
+ const nodesPath = `${path}/nodes`;
11
+ const nodes = array(value.nodes, 'ValueProgram nodes', nodesPath).map((node, index) => valueNode(node, index, `${nodesPath}/${index}`));
12
+ const root = index(value.root, nodes.length, 'ValueProgram root', `${path}/root`);
13
+ const patternsPath = `${path}/patterns`;
14
+ const patterns = array(value.patterns, 'ValueProgram patterns', patternsPath).map((item, position) => index(item, table.length, 'ValueProgram pattern', `${patternsPath}/${position}`));
15
+ const sources = patterns.map((index) => table[index].source);
16
+ unique(sources, 'patterns', patternsPath);
17
+ const available = new Set(sources);
18
+ for (const [nodeIndex, node] of nodes.entries()) {
19
+ if (isValueObject(node.schema)) {
20
+ const required = [node.schema.pattern, node.schema.fullMatch];
21
+ if (isValueObject(node.schema.patternProperties)) {
22
+ required.push(...Object.keys(node.schema.patternProperties));
23
+ }
24
+ for (const source of required) {
25
+ if (typeof source === 'string' && !available.has(source)) {
26
+ invalid('ValueProgram pattern binding', undefined, patternsPath);
27
+ }
28
+ }
29
+ }
30
+ for (const [name, child] of Object.entries(node.children))
31
+ index(child, nodes.length, 'ValueNode child', pointer(`${nodesPath}/${nodeIndex}/children`, name));
32
+ if (node.reference !== undefined)
33
+ index(node.reference, nodes.length, 'ValueNode reference', `${nodesPath}/${nodeIndex}/reference`);
34
+ }
35
+ return { root, nodes, patterns };
36
+ }
37
+ function valueNode(input, nodeIndex, path) {
38
+ const value = object(input, `nodes[${nodeIndex}]`, path);
39
+ exact(value, ['schema', 'children'], 'ValueNode', path, ['reference']);
40
+ const children = {};
41
+ const childrenPath = `${path}/children`;
42
+ for (const [name, child] of Object.entries(object(value.children, 'ValueNode children', childrenPath))) {
43
+ children[name] = integer(child, 'ValueNode child', pointer(childrenPath, name));
44
+ }
45
+ return {
46
+ schema: value.schema,
47
+ children,
48
+ ...(value.reference === undefined
49
+ ? {}
50
+ : { reference: integer(value.reference, 'reference', `${path}/reference`) }),
51
+ };
52
+ }
@@ -0,0 +1,4 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ import { type ValueProgram, type CompiledClass } from '../../model/schema.js';
3
+ /** Decode a Property and re-admit its State and ordering contracts. */
4
+ export declare function compiledProperty(input: JsonValue, values: readonly ValueProgram[], node: boolean, path: string): CompiledClass['properties'][number];
@@ -0,0 +1,74 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import {} from '../../../language/state/index.js';
3
+ import { admitStateTopology } from '../../../language/state/topology.js';
4
+ import { classifyValueProgramOrdering } from '../../../language/value/ordering.js';
5
+ import {} from '../../model/schema.js';
6
+ import { invalid } from '../diagnostic.js';
7
+ import { object, exact, memberName, boolean, description, index, array, unique } from './value.js';
8
+ /** Decode a Property and re-admit its State and ordering contracts. */
9
+ export function compiledProperty(input, values, node, path) {
10
+ const value = object(input, 'Compiled Property', path);
11
+ exact(value, ['name', 'required', 'value'], 'Compiled Property', path, [
12
+ 'auto',
13
+ 'description',
14
+ 'immutable',
15
+ 'ordering',
16
+ 'state',
17
+ ]);
18
+ memberName(value.name, 'Property name', `${path}/name`);
19
+ boolean(value.required, 'Property required', `${path}/required`);
20
+ description(value.description, 'Property description', `${path}/description`);
21
+ if (value.auto !== undefined)
22
+ propertyAuto(value.auto, `${path}/auto`);
23
+ if (value.immutable !== undefined && value.immutable !== 'create' && value.immutable !== 'once') {
24
+ invalid('Property immutability', undefined, `${path}/immutable`);
25
+ }
26
+ const valueIndex = index(value.value, values.length, 'Property value', `${path}/value`);
27
+ let state;
28
+ if (value.state !== undefined) {
29
+ if (!node)
30
+ invalid('Property state placement', 'COMPILED_SOURCE_INVALID', `${path}/state`);
31
+ let topology;
32
+ try {
33
+ topology = admitStateTopology(value.state);
34
+ }
35
+ catch {
36
+ invalid('Property state topology', 'COMPILED_SOURCE_INVALID', `${path}/state`);
37
+ }
38
+ const program = values[valueIndex];
39
+ const schema = program.nodes[program.root].schema;
40
+ const states = Object.keys(topology.transitions);
41
+ const schemaObject = schema;
42
+ const schemaMatches = schema !== null &&
43
+ typeof schema === 'object' &&
44
+ !Array.isArray(schema) &&
45
+ Object.keys(schemaObject).length === 2 &&
46
+ schemaObject.type === 'string' &&
47
+ Array.isArray(schemaObject.enum) &&
48
+ schemaObject.enum.length === states.length &&
49
+ schemaObject.enum.every((state, index) => state === states[index]);
50
+ if (!value.required || value.auto !== undefined || !schemaMatches) {
51
+ invalid('Property state contract', 'COMPILED_SOURCE_INVALID', `${path}/state`);
52
+ }
53
+ state = topology;
54
+ }
55
+ if (value.ordering !== classifyValueProgramOrdering(values[valueIndex])) {
56
+ invalid('Property ordering', 'COMPILED_CANONICAL_MISMATCH', `${path}/ordering`);
57
+ }
58
+ return {
59
+ ...value,
60
+ ...(state === undefined ? {} : { state }),
61
+ };
62
+ }
63
+ function propertyAuto(input, path) {
64
+ const value = object(input, 'Property auto', path);
65
+ exact(value, ['on', 'set'], 'Property auto', path);
66
+ const eventsPath = `${path}/on`;
67
+ const events = array(value.on, 'Property auto events', eventsPath);
68
+ if (events.length === 0 || events.some((event) => event !== 'create' && event !== 'update')) {
69
+ invalid('Property auto events', undefined, eventsPath);
70
+ }
71
+ unique(events.map(String), 'Property auto events', eventsPath);
72
+ if (value.set !== 'instant')
73
+ invalid('Property auto setter', undefined, `${path}/set`);
74
+ }
@@ -0,0 +1,8 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ import { type DefinitionRef } from '../../../addressing/index.js';
3
+ /** Check a Domain or projected declaration endpoint. */
4
+ export declare function coreEndpoint(input: JsonValue | undefined, label: string, path: string): void;
5
+ /** Check a Policy reference to a projected declaration. */
6
+ export declare function policyObjectRef(input: JsonValue | undefined, path: string): void;
7
+ /** Require a canonical Definition coordinate of the expected kind. */
8
+ export declare function definitionRef<Kind extends DefinitionRef['kind'] | undefined>(input: JsonValue | undefined, kind: Kind, label: string, path: string): DefinitionRef;
@@ -0,0 +1,33 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { isDefinitionRef } from '../../../addressing/index.js';
3
+ import { MEMBER_NAME_PATTERN } from '../../../addressing/patterns.js';
4
+ import { invalid } from '../diagnostic.js';
5
+ import { object, exact } from './value.js';
6
+ /** Check a Domain or projected declaration endpoint. */
7
+ export function coreEndpoint(input, label, path) {
8
+ const value = object(input, label, path);
9
+ if (value.kind === 'domain')
10
+ exact(value, ['kind'], label, path);
11
+ else
12
+ projectedMemberRef(value, label, path);
13
+ }
14
+ /** Check a Policy reference to a projected declaration. */
15
+ export function policyObjectRef(input, path) {
16
+ projectedMemberRef(object(input, 'Policy object ref', path), 'Policy object ref', path);
17
+ }
18
+ function projectedMemberRef(ref, label, path) {
19
+ if (ref.kind !== 'method') {
20
+ definitionRef(ref, undefined, label, path);
21
+ return;
22
+ }
23
+ exact(ref, ['kind', 'owner', 'name'], `${label} Method`, path);
24
+ definitionRef(ref.owner, 'class', `${label} Method owner`, `${path}/owner`);
25
+ if (typeof ref.name !== 'string' || !MEMBER_NAME_PATTERN.test(ref.name))
26
+ invalid(`${label} Method name`, undefined, `${path}/name`);
27
+ }
28
+ /** Require a canonical Definition coordinate of the expected kind. */
29
+ export function definitionRef(input, kind, label, path) {
30
+ if (!isDefinitionRef(input) || (kind !== undefined && input.kind !== kind))
31
+ invalid(label, undefined, path);
32
+ return input;
33
+ }
@@ -0,0 +1,29 @@
1
+ import { type Value as JsonValue, type Object as JsonObject } from '@astrale-os/kernel-dsl/value';
2
+ /** Require a portable Object at the named wire boundary. */
3
+ export declare function object(input: JsonValue | undefined, label: string, path: string): JsonObject;
4
+ /** Require a portable Array at the named wire boundary. */
5
+ export declare function array(input: JsonValue | undefined, label: string, path: string): readonly JsonValue[];
6
+ /** Reject unknown and missing members in deterministic diagnostic order. */
7
+ export declare function exact(value: JsonObject, required: readonly string[], label: string, path: string, optional?: readonly string[]): void;
8
+ /** Require a non-negative safe integer. */
9
+ export declare function integer(input: JsonValue | undefined, label: string, path: string): number;
10
+ /** Require an integer within an inclusive interval. */
11
+ export declare function boundedInteger(input: JsonValue | undefined, minimum: number, maximum: number, label: string, path: string): number;
12
+ /** Require a Boolean wire value. */
13
+ export declare function boolean(input: JsonValue | undefined, label: string, path: string): boolean;
14
+ /** Require a String wire value. */
15
+ export declare function string(input: JsonValue | undefined, label: string, path: string): string;
16
+ /** Require a canonical declaration member name. */
17
+ export declare function memberName(input: JsonValue | undefined, label: string, path: string): string;
18
+ /** Check the length of an optional String member. */
19
+ export declare function boundedString(input: JsonValue | undefined, minimum: number, maximum: number, label: string, path: string): void;
20
+ /** Check the optional declaration description budget. */
21
+ export declare function description(input: JsonValue | undefined, label: string, path: string): void;
22
+ /** Reject the first repeated value at its exact index. */
23
+ export declare function unique(values: readonly string[], label: string, path: string): void;
24
+ /** Require an index within the referenced table. */
25
+ export declare function index(input: JsonValue | undefined, length: number, label: string, path: string): number;
26
+ /** Require a Unicode scalar-range bound. */
27
+ export declare function scalar(input: JsonValue | undefined, label: string, path: string): number;
28
+ /** Order wire names independently of the host locale. */
29
+ export declare function compare(left: string, right: string): number;
@@ -0,0 +1,98 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { MEMBER_NAME_PATTERN } from '../../../addressing/patterns.js';
3
+ import { invalid, pointer } from '../diagnostic.js';
4
+ /** Require a portable Object at the named wire boundary. */
5
+ export function object(input, label, path) {
6
+ if (input === null || typeof input !== 'object' || Array.isArray(input))
7
+ invalid(label, undefined, path);
8
+ return input;
9
+ }
10
+ /** Require a portable Array at the named wire boundary. */
11
+ export function array(input, label, path) {
12
+ if (!Array.isArray(input))
13
+ invalid(label, undefined, path);
14
+ return input;
15
+ }
16
+ /** Reject unknown and missing members in deterministic diagnostic order. */
17
+ export function exact(value, required, label, path, optional = []) {
18
+ const allowed = new Set([...required, ...optional]);
19
+ const unknown = Object.keys(value)
20
+ .filter((key) => !allowed.has(key))
21
+ .sort(compare)[0];
22
+ if (unknown !== undefined)
23
+ invalid(label, undefined, pointer(path, unknown));
24
+ const missing = required.find((key) => !Object.hasOwn(value, key));
25
+ if (missing !== undefined)
26
+ invalid(label, undefined, pointer(path, missing));
27
+ }
28
+ /** Require a non-negative safe integer. */
29
+ export function integer(input, label, path) {
30
+ if (!Number.isSafeInteger(input) || input < 0)
31
+ invalid(label, undefined, path);
32
+ return input;
33
+ }
34
+ /** Require an integer within an inclusive interval. */
35
+ export function boundedInteger(input, minimum, maximum, label, path) {
36
+ const value = integer(input, label, path);
37
+ if (value < minimum || value > maximum)
38
+ invalid(label, undefined, path);
39
+ return value;
40
+ }
41
+ /** Require a Boolean wire value. */
42
+ export function boolean(input, label, path) {
43
+ if (typeof input !== 'boolean')
44
+ invalid(label, undefined, path);
45
+ return input;
46
+ }
47
+ /** Require a String wire value. */
48
+ export function string(input, label, path) {
49
+ if (typeof input !== 'string')
50
+ invalid(label, undefined, path);
51
+ return input;
52
+ }
53
+ /** Require a canonical declaration member name. */
54
+ export function memberName(input, label, path) {
55
+ const value = string(input, label, path);
56
+ if (!MEMBER_NAME_PATTERN.test(value))
57
+ invalid(label, undefined, path);
58
+ return value;
59
+ }
60
+ /** Check the length of an optional String member. */
61
+ export function boundedString(input, minimum, maximum, label, path) {
62
+ if (input === undefined)
63
+ return;
64
+ const value = string(input, label, path);
65
+ if (value.length < minimum || value.length > maximum)
66
+ invalid(label, undefined, path);
67
+ }
68
+ /** Check the optional declaration description budget. */
69
+ export function description(input, label, path) {
70
+ boundedString(input, 1, 1000, label, path);
71
+ }
72
+ /** Reject the first repeated value at its exact index. */
73
+ export function unique(values, label, path) {
74
+ const seen = new Set();
75
+ for (const [indexValue, value] of values.entries()) {
76
+ if (seen.has(value))
77
+ invalid(label, undefined, `${path}/${indexValue}`);
78
+ seen.add(value);
79
+ }
80
+ }
81
+ /** Require an index within the referenced table. */
82
+ export function index(input, length, label, path) {
83
+ const value = integer(input, label, path);
84
+ if (value >= length)
85
+ invalid(label, undefined, path);
86
+ return value;
87
+ }
88
+ /** Require a Unicode scalar-range bound. */
89
+ export function scalar(input, label, path) {
90
+ const value = integer(input, label, path);
91
+ if (value > 0x10ffff)
92
+ invalid(label, undefined, path);
93
+ return value;
94
+ }
95
+ /** Order wire names independently of the host locale. */
96
+ export function compare(left, right) {
97
+ return left < right ? -1 : left > right ? 1 : 0;
98
+ }
@@ -0,0 +1,3 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ /** Decode a View and its explicit target grammar. */
3
+ export declare function compiledView(input: JsonValue, path: string): never;
@@ -0,0 +1,17 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { invalid } from '../diagnostic.js';
3
+ import { definitionRef } from './reference.js';
4
+ import { object, exact, description } from './value.js';
5
+ /** Decode a View and its explicit target grammar. */
6
+ export function compiledView(input, path) {
7
+ const value = object(input, 'View', path);
8
+ exact(value, ['ref', 'target'], 'View', path, ['description']);
9
+ definitionRef(value.ref, 'view', 'View ref', `${path}/ref`);
10
+ description(value.description, 'View description', `${path}/description`);
11
+ const targetPath = `${path}/target`;
12
+ const target = object(value.target, 'View target', targetPath);
13
+ exact(target, ['kind'], 'Domain View target', targetPath);
14
+ if (target.kind !== 'domain')
15
+ invalid('View target', undefined, targetPath);
16
+ return value;
17
+ }
@@ -125,6 +125,8 @@ function compileEntry(schema, lookup) {
125
125
  return Object.freeze({
126
126
  origin: schema.origin,
127
127
  revision: revisionOfDomainSchema(schema),
128
+ name: schema.name,
129
+ ...(schema.entrypoint === undefined ? {} : { entrypoint: schema.entrypoint }),
128
130
  dependencies: schema.dependencies,
129
131
  definitions: Object.freeze({
130
132
  classes: Object.freeze(classes),
@@ -1,5 +1,5 @@
1
1
  import type { Key } from '../../addressing/index.js';
2
- import type { DomainDependency, DomainDependencyMap, Revision } from '../../addressing/index.js';
2
+ import type { DomainDependency, DomainDependencyMap, Revision, ViewRef } from '../../addressing/index.js';
3
3
  import type { Domain } from '../../domain/model/domain.js';
4
4
  import type { MethodDefinition } from '../../language/callable/model/callable.js';
5
5
  import type { ClassDefinition } from '../../language/class/model/class.js';
@@ -53,6 +53,10 @@ export type CompiledCoreEdge = CoreEdge;
53
53
  export interface CompiledSchemaEntry {
54
54
  readonly origin: Key.Origin;
55
55
  readonly revision: Revision;
56
+ /** The source Domain display name. */
57
+ readonly name: string;
58
+ /** The source Domain entrypoint View. */
59
+ readonly entrypoint?: ViewRef;
56
60
  readonly dependencies: DomainDependencyMap;
57
61
  readonly definitions: {
58
62
  readonly classes: readonly CompiledClass[];
@@ -1,5 +1,6 @@
1
1
  import { Key, MethodKey as MethodKeyValue, PropertyKey as PropertyKeyValue, } from '../../addressing/index.js';
2
2
  import { isMethodExecutable } from '../../language/callable/executable.js';
3
+ import { classSatisfies } from '../../language/class/inheritance.js';
3
4
  import { acceptPropertyValues } from '../../language/class/property-values.js';
4
5
  import { appendPointer } from '../../language/value/syntax/pointer.js';
5
6
  import { createMethodCollection, createPropertyCollection } from '../namespace/member-collection.js';
@@ -102,15 +103,7 @@ export function createClasses(definitions, validation) {
102
103
  static: Object.freeze({ methods: createMethodCollection(ownStaticMethods) }),
103
104
  }),
104
105
  satisfies(selected) {
105
- if (key === selected.key)
106
- return true;
107
- return parents.some((parent) => {
108
- if (parent.kind === 'node' && selected.kind === 'node')
109
- return parent.satisfies(selected);
110
- if (parent.kind === 'edge' && selected.kind === 'edge')
111
- return parent.satisfies(selected);
112
- return false;
113
- });
106
+ return classSatisfies(definition, selected.definition, (ref) => declarations.get(Key.of(ref)));
114
107
  },
115
108
  validateProperties(input) {
116
109
  return validateProperties(definition.abstract, effectiveProperties, input);
@@ -5,7 +5,7 @@ export { isBinaryInput } from './language/callable/model/callable.js';
5
5
  export type { EventOf, StateMachine, StateOf } from './language/state/index.js';
6
6
  export { PropertyValues } from './language/index.js';
7
7
  export * as metadata from './language/definition/metadata.js';
8
- export type { AnyResolvedClass, BoundMethodOf, BoundMethodShortcutsOf, CallableResultOf, CallableInputOf, CallableInputModeOf, CallableOutputOf, ClassSatisfactionKeysOf, ClassDefinition, CoreDefinition, CoreEdge, FunctionAuth, FunctionDefinition, BinaryInput, BinaryInputProjection, CallableInputContract, MethodDefinition, MethodOwnerKeyOf, PolicyCheckExpression, PolicyDefinition, PropertyInputOf, PropertyAccessOf, PropertyOutputOf, PropertyShortcutsOf, PropertyValuesOf, ResolvedClass, ResolvedCoreDefinition, ResolvedCoreEndpoint, ResolvedData, ResolvedFunction, ExecutableMethod, ResolvedMethod, ResolvedMethodCollection, ResolvedPolicy, ResolvedProperty, ResolvedView, MethodAccessOf, SelfMethodsOf, SelfPropertiesOf, SelfStaticMethodsOf, StaticMethodsOf, ViewDefinition, } from './language/index.js';
8
+ export type { AnyResolvedClass, BoundMethodOf, BoundMethodShortcutsOf, CallableResultOf, CallableInputOf, CallableInputModeOf, CallableOutputOf, ClassSatisfactionKeysOf, ClassDefinition, CoreDefinition, CoreEdge, FunctionAuth, FunctionDefinition, BinaryInput, BinaryInputProjection, CallableInputContract, MethodDefinition, MethodOwnerKeyOf, PolicyCheckExpression, PolicyDefinition, PropertyImmutability, PropertyInputOf, PropertyAccessOf, PropertyOutputOf, PropertyShortcutsOf, PropertyValuesOf, ResolvedClass, ResolvedCoreDefinition, ResolvedCoreEndpoint, ResolvedData, ResolvedFunction, ExecutableMethod, ResolvedMethod, ResolvedMethodCollection, ResolvedPolicy, ResolvedProperty, ResolvedView, MethodAccessOf, SelfMethodsOf, SelfPropertiesOf, SelfStaticMethodsOf, StaticMethodsOf, ViewDefinition, } from './language/index.js';
9
9
  export { acceptDefinitionRef, callableAddress, ClassKey, equalDefinitionRefs, isDefinitionRef, Key, MethodKey, PropertyKey, } from './addressing/index.js';
10
10
  export type { ClassRef, CoreRef, DefinitionBase, DefinitionKey, DefinitionRef, FunctionRef, MethodAddress, PolicyRef, Revision, ViewRef, } from './addressing/index.js';
11
11
  export type { Definition } from './language/index.js';
@@ -0,0 +1,12 @@
1
+ import type { ClassRef } from '../../addressing/index.js';
2
+ import type { ClassKind } from './model/class.js';
3
+ /** The representation shared by source, compiled and resolved Class admission. */
4
+ export interface ClassInheritance {
5
+ readonly ref: ClassRef;
6
+ readonly kind: ClassKind;
7
+ readonly extends: readonly ClassRef[];
8
+ }
9
+ /** Kernel graph roots are intrinsic supertypes, not authored structural Edge contracts. */
10
+ export declare function isGraphRoot(value: Pick<ClassInheritance, 'ref' | 'kind'>): boolean;
11
+ /** Same-kind satisfaction includes the intrinsic root and the declared parent closure. */
12
+ export declare function classSatisfies(candidate: ClassInheritance, required: ClassInheritance, resolve: (ref: ClassRef) => ClassInheritance | undefined): boolean;
@@ -0,0 +1,25 @@
1
+ /** Kernel graph roots are intrinsic supertypes, not authored structural Edge contracts. */
2
+ export function isGraphRoot(value) {
3
+ return (value.ref.origin === 'kernel.astrale.ai' &&
4
+ value.ref.name === (value.kind === 'node' ? 'Node' : 'Edge'));
5
+ }
6
+ /** Same-kind satisfaction includes the intrinsic root and the declared parent closure. */
7
+ export function classSatisfies(candidate, required, resolve) {
8
+ if (candidate.kind !== required.kind)
9
+ return false;
10
+ if (isGraphRoot(required))
11
+ return true;
12
+ const seen = new Set();
13
+ const visit = (value) => {
14
+ if (value.ref.origin === required.ref.origin && value.ref.name === required.ref.name)
15
+ return true;
16
+ if (seen.has(value))
17
+ return false;
18
+ seen.add(value);
19
+ return value.extends.some((ref) => {
20
+ const parent = resolve(ref);
21
+ return parent !== undefined && parent.kind === required.kind && visit(parent);
22
+ });
23
+ };
24
+ return visit(candidate);
25
+ }
@@ -45,6 +45,7 @@ export interface ResolvedClass<Kind extends ClassKind = ClassKind, Properties ex
45
45
  readonly kind: Kind;
46
46
  readonly abstract: boolean;
47
47
  readonly definition: Definition;
48
+ /** Explicitly authored parents; intrinsic graph roots do not alter schema bytes. */
48
49
  readonly extends: Parents & readonly ResolvedClass<Kind>[];
49
50
  /** Local observation Policies; Class inheritance never contributes an attachment. */
50
51
  readonly policies: Definition['policies'];
@@ -62,14 +63,17 @@ export interface ResolvedClass<Kind extends ClassKind = ClassKind, Properties ex
62
63
  readonly methods: Kind extends 'node' ? SelfStaticMethods : ResolvedMethodCollection<Record<never, never>>;
63
64
  };
64
65
  };
66
+ /** Same-kind nominal inheritance, including the universal Kernel Node or Edge root. */
65
67
  satisfies(selected: ResolvedClass<Kind>): boolean;
66
68
  validateProperties(input: unknown): readonly Diagnostic[];
67
69
  }
68
70
  /** One resolved Class with an exact graph kind, used at heterogeneous Domain boundaries. */
69
71
  export type AnyResolvedClass = ResolvedClass<'node'> | ResolvedClass<'edge'>;
70
- /** Exact Class keys satisfied by one resolved Class, including transitive parents. */
72
+ /** Class keys satisfied by one resolved Class, including its graph root and transitive parents. */
71
73
  export type ClassSatisfactionKeysOf<Class> = ClassSatisfactionKeys<Class, never>;
72
74
  type ClassSatisfactionKeys<Class, Seen> = Class extends Seen ? never : (Class extends {
75
+ readonly kind: infer Kind extends ClassKind;
76
+ } ? DefinitionKey<'kernel.astrale.ai', 'class', Kind extends 'node' ? 'Node' : 'Edge'> : never) | (Class extends {
73
77
  readonly key: infer ExactKey extends DefinitionKey<Key.Origin, 'class'>;
74
78
  } ? ExactKey : never) | (Class extends ResolvedClass<ClassKind, ResolvedPropertyCollection, ResolvedMethodCollection, ResolvedMethodCollection, ResolvedPropertyCollection, ResolvedMethodCollection, ResolvedMethodCollection, ClassDefinition, infer Parents> ? ClassSatisfactionKeys<Extract<Parents[number], ResolvedClass>, Seen | Class> : never);
75
79
  export type PropertyValueOf<Property> = Property extends ResolvedProperty<infer Value, boolean, StateTopology | undefined, unknown> ? Value : never;