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

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 (76) hide show
  1. package/dist/v1/addressing/class-key.js +5 -4
  2. package/dist/v1/addressing/method-key.js +3 -2
  3. package/dist/v1/builder/class/property.d.ts +3 -1
  4. package/dist/v1/builder/class/property.js +9 -1
  5. package/dist/v1/builder/lowering/schema/compile.js +1 -1
  6. package/dist/v1/builder/lowering/value/compile.js +3 -0
  7. package/dist/v1/builder/lowering/value/zod.js +11 -2
  8. package/dist/v1/builder/lowering/view.d.ts +2 -2
  9. package/dist/v1/builder/lowering/view.js +2 -14
  10. package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
  11. package/dist/v1/builder/value/full-match.js +6 -3
  12. package/dist/v1/builder/view/authoring.d.ts +3 -7
  13. package/dist/v1/builder/view/authoring.js +5 -2
  14. package/dist/v1/compiled/admission/accept.js +31 -6
  15. package/dist/v1/compiled/admission/semantics.js +49 -16
  16. package/dist/v1/compiled/compiler/compile.js +1 -0
  17. package/dist/v1/compiled/loader/load.js +1 -0
  18. package/dist/v1/domain/create.js +0 -19
  19. package/dist/v1/domain/model/domain.d.ts +0 -1
  20. package/dist/v1/domain/model/input.d.ts +3 -0
  21. package/dist/v1/domain/projection/classes.js +1 -0
  22. package/dist/v1/domain/validation/create.d.ts +2 -0
  23. package/dist/v1/domain/validation/create.js +12 -0
  24. package/dist/v1/language/class/model/property.d.ts +3 -0
  25. package/dist/v1/language/class/resolved.d.ts +3 -0
  26. package/dist/v1/language/index.d.ts +2 -0
  27. package/dist/v1/language/index.js +1 -0
  28. package/dist/v1/language/policy/normalization/normalize.d.ts +4 -0
  29. package/dist/v1/language/policy/normalization/normalize.js +51 -13
  30. package/dist/v1/language/value/inclusion/includes.d.ts +9 -0
  31. package/dist/v1/language/value/inclusion/includes.js +777 -0
  32. package/dist/v1/language/value/profile/rules.js +11 -32
  33. package/dist/v1/language/value/regexp/ast.js +3 -64
  34. package/dist/v1/language/value/regexp/compile.d.ts +25 -2
  35. package/dist/v1/language/value/regexp/compile.js +48 -12
  36. package/dist/v1/language/value/regexp/syntax.d.ts +11 -1
  37. package/dist/v1/language/value/regexp/syntax.js +14 -2
  38. package/dist/v1/language/value/regexp/unicode.d.ts +32 -0
  39. package/dist/v1/language/value/regexp/unicode.js +139 -0
  40. package/dist/v1/language/value/syntax/full-match.js +6 -3
  41. package/dist/v1/language/view/model/view.d.ts +6 -0
  42. package/dist/v1/language/view/resolved.d.ts +2 -2
  43. package/dist/v1/schema/analysis/class.d.ts +2 -1
  44. package/dist/v1/schema/analysis/class.js +1 -0
  45. package/dist/v1/schema/compatibility/comparators/callables.d.ts +7 -0
  46. package/dist/v1/schema/compatibility/comparators/callables.js +13 -0
  47. package/dist/v1/schema/compatibility/comparators/classes.d.ts +18 -0
  48. package/dist/v1/schema/compatibility/comparators/classes.js +54 -0
  49. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  50. package/dist/v1/schema/compatibility/comparators/index.js +14 -2
  51. package/dist/v1/schema/compatibility/context.d.ts +6 -2
  52. package/dist/v1/schema/compatibility/context.js +12 -6
  53. package/dist/v1/schema/compatibility/evidence.d.ts +8 -1
  54. package/dist/v1/schema/compatibility/evidence.js +10 -1
  55. package/dist/v1/schema/compatibility/fields.d.ts +2 -0
  56. package/dist/v1/schema/compatibility/fields.js +1 -0
  57. package/dist/v1/schema/compatibility/meaning/footprint.js +3 -1
  58. package/dist/v1/schema/compatibility/meaning/index.js +4 -2
  59. package/dist/v1/schema/compatibility/model.d.ts +11 -6
  60. package/dist/v1/schema/compatibility/references.d.ts +8 -1
  61. package/dist/v1/schema/compatibility/references.js +39 -6
  62. package/dist/v1/schema/compatibility/scope.d.ts +5 -0
  63. package/dist/v1/schema/compatibility/scope.js +5 -2
  64. package/dist/v1/schema/compatibility/structure/index.js +21 -2
  65. package/dist/v1/schema/compatibility/structure/requirements.js +26 -1
  66. package/dist/v1/schema/compatibility/subjects.js +20 -2
  67. package/dist/v1/schema/diagnostic.d.ts +1 -1
  68. package/dist/v1/schema/normalization/domain.js +1 -0
  69. package/dist/v1/schema/resolution/domain.d.ts +4 -1
  70. package/dist/v1/schema/resolution/domain.js +7 -7
  71. package/dist/v1/schema/resolution/origins.d.ts +11 -4
  72. package/dist/v1/schema/resolution/origins.js +7 -8
  73. package/dist/v1/schema/validation/class.d.ts +10 -0
  74. package/dist/v1/schema/validation/class.js +13 -2
  75. package/dist/v1/schema/validation/domain.structure.js +1 -0
  76. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import type { DefinitionRef } from '../../addressing/index.js';
1
+ import type { DefinitionRef, MethodAddress } from '../../addressing/index.js';
2
2
  import type { FunctionDefinition, MethodDefinition } from '../../language/callable/model/callable.js';
3
3
  import type { ClassDefinition } from '../../language/class/model/class.js';
4
4
  import type { CoreEndpointRef } from '../../language/core/model/core.js';
@@ -7,10 +7,17 @@ import type { JsonSchema } from '../../language/value/model/schema.js';
7
7
  import type { DomainSchemaIR } from '../model/schema.js';
8
8
  /**
9
9
  * Where one schema references a Definition. `extends` and `core` mean the schema inherits from or
10
- * instantiates the Definition; every other site only refers to it.
10
+ * instantiates the Definition; every other site only refers to it. `pattern` is the Edge Class a
11
+ * Policy pattern matches, whose orientation and accepted endpoint Classes Policy typing reads.
11
12
  */
12
- export type ReferenceSite = 'extends' | 'endpoint' | 'value' | 'policy' | 'view' | 'core';
13
- export type ReferenceCollector = (ref: DefinitionRef, site: ReferenceSite) => void;
13
+ export type ReferenceSite = 'extends' | 'endpoint' | 'value' | 'policy' | 'pattern' | 'view' | 'core';
14
+ /**
15
+ * What a site names: a Definition, or the Class-owned Method a Policy object term names. A Policy
16
+ * keeps the Method itself, since it resolves that Method's own executable declaration; a collector
17
+ * that needs Definitions only takes its owner Class.
18
+ */
19
+ export type ReferencedDefinition = DefinitionRef | MethodAddress;
20
+ export type ReferenceCollector = (ref: ReferencedDefinition, site: ReferenceSite) => void;
14
21
  /** Collect only semantic refs, never strings or objects embedded as JSON data. */
15
22
  export declare function collectUsedForeignOrigins(schema: DomainSchemaIR): ReadonlySet<string>;
16
23
  /** Complete structured references in one schema, in canonical order. */
@@ -13,7 +13,8 @@ export function collectUsedForeignOrigins(schema) {
13
13
  export function collectDomainDefinitionRefs(schema) {
14
14
  const result = new Map();
15
15
  const add = (ref) => {
16
- result.set(definitionRefIndex(ref), ref);
16
+ const definition = ref.kind === 'method' ? ref.owner : ref;
17
+ result.set(definitionRefIndex(definition), definition);
17
18
  };
18
19
  for (const declaration of Object.values(schema.classes)) {
19
20
  collectClassRefs(declaration, add);
@@ -102,14 +103,14 @@ function collectPolicyPatternRefs(expression, add) {
102
103
  if ('sameNode' in expression) {
103
104
  for (const term of [expression.sameNode.left, expression.sameNode.right])
104
105
  if (term.kind === 'ref')
105
- add(term.ref.kind === 'method' ? term.ref.owner : term.ref, 'policy');
106
+ add(term.ref, 'policy');
106
107
  return;
107
108
  }
108
109
  if ('source' in expression) {
109
110
  for (const term of [expression.source, expression.target])
110
111
  if (term.kind === 'ref')
111
- add(term.ref.kind === 'method' ? term.ref.owner : term.ref, 'policy');
112
- add(expression.class, 'policy');
112
+ add(term.ref, 'policy');
113
+ add(expression.class, 'pattern');
113
114
  return;
114
115
  }
115
116
  if ('exists' in expression) {
@@ -128,15 +129,13 @@ function collectPolicyCheckRefs(expression, add) {
128
129
  if ('sameNode' in expression) {
129
130
  for (const term of [expression.sameNode.left, expression.sameNode.right])
130
131
  if (term.kind === 'ref')
131
- add(term.ref.kind === 'method' ? term.ref.owner : term.ref, 'policy');
132
+ add(term.ref, 'policy');
132
133
  return;
133
134
  }
134
135
  if ('check' in expression) {
135
136
  add(expression.check, 'policy');
136
137
  if (expression.object.kind === 'ref')
137
- add(expression.object.ref.kind === 'method'
138
- ? expression.object.ref.owner
139
- : expression.object.ref, 'policy');
138
+ add(expression.object.ref, 'policy');
140
139
  return;
141
140
  }
142
141
  const children = 'allOf' in expression ? expression.allOf : expression.anyOf;
@@ -1,5 +1,15 @@
1
+ import type { ClassRef } from '../../addressing/index.js';
2
+ import type { ClassDefinition } from '../../language/class/model/class.js';
1
3
  import type { DefinitionAnalysisResult } from '../analysis/class.js';
2
4
  import type { SchemaDiagnostic } from '../diagnostic.js';
3
5
  import type { DomainResolutionContext } from '../resolution/context.js';
4
6
  /** Validate the semantic contracts owned by Class declarations. */
5
7
  export declare function validateDefinitions(environment: DomainResolutionContext, analysis: DefinitionAnalysisResult): readonly SchemaDiagnostic[];
8
+ /** Whether `child` safely refines its parent Edge contract `parent`. */
9
+ export declare function edgeContractRefines(environment: DomainResolutionContext, child: Extract<ClassDefinition, {
10
+ readonly kind: 'edge';
11
+ }>, parent: Extract<ClassDefinition, {
12
+ readonly kind: 'edge';
13
+ }>): boolean;
14
+ /** Whether `candidate` is, or is a Node Class extending, one of `accepts`. */
15
+ export declare function classSatisfies(environment: DomainResolutionContext, candidate: ClassRef, accepts: readonly ClassRef[]): boolean;
@@ -62,6 +62,15 @@ function validateFacet(environment, declaration, pointer, diagnostics) {
62
62
  diagnostics.push(diagnostic('DV_PROPERTY_STATE', `${propertyPointer}/state`, error instanceof Error ? error.message : 'Invalid State topology.'));
63
63
  }
64
64
  }
65
+ if (property.immutable !== undefined) {
66
+ const immutablePointer = `${propertyPointer}/immutable`;
67
+ if (property.auto !== undefined || property.state !== undefined) {
68
+ diagnostics.push(diagnostic('DV_PROPERTY_IMMUTABLE', immutablePointer, 'An immutable Property is neither automatic nor a State Property.'));
69
+ }
70
+ if (property.immutable === 'once' && property.required) {
71
+ diagnostics.push(diagnostic('DV_PROPERTY_IMMUTABLE', immutablePointer, 'A required immutable Property is written at creation: declare it create, not once.'));
72
+ }
73
+ }
65
74
  if (property.auto === undefined)
66
75
  continue;
67
76
  const autoPointer = `${propertyPointer}/auto`;
@@ -149,7 +158,8 @@ function validateEdgeClassComposition(environment, diagnostics) {
149
158
  }
150
159
  }
151
160
  }
152
- function edgeContractRefines(environment, child, parent) {
161
+ /** Whether `child` safely refines its parent Edge contract `parent`. */
162
+ export function edgeContractRefines(environment, child, parent) {
153
163
  if (child.orientation !== parent.orientation)
154
164
  return false;
155
165
  if (parent.constraints.noSelf === true && child.constraints.noSelf !== true)
@@ -207,7 +217,8 @@ function undirectedEndpointsOverlap(environment, endpoints) {
207
217
  }
208
218
  return false;
209
219
  }
210
- function classSatisfies(environment, candidate, accepts) {
220
+ /** Whether `candidate` is, or is a Node Class extending, one of `accepts`. */
221
+ export function classSatisfies(environment, candidate, accepts) {
211
222
  if (accepts.some((ref) => definitionRefIndex(ref) === definitionRefIndex(candidate)))
212
223
  return true;
213
224
  const resolved = environment.resolveAny(candidate);
@@ -43,6 +43,7 @@ const propertyDefinitionSchema = strictObject({
43
43
  on: uniqueArray(enumeration(['create', 'update'])).min(1),
44
44
  set: literal('instant'),
45
45
  }).optional(),
46
+ immutable: enumeration(['create', 'once']).optional(),
46
47
  description: descriptionSchema.optional(),
47
48
  state: stateTopologySchema.optional(),
48
49
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "0.2.0-beta.45",
3
+ "version": "0.2.0-beta.47",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {