@astrale-os/kernel-dsl 1.0.0-beta.2 → 1.0.0-beta.20

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 (307) hide show
  1. package/dist/v1/addressing/class-key.js +3 -3
  2. package/dist/v1/addressing/definition-ref.js +21 -37
  3. package/dist/v1/addressing/domain-dependency.d.ts +0 -6
  4. package/dist/v1/addressing/domain-dependency.js +1 -6
  5. package/dist/v1/addressing/key.d.ts +4 -1
  6. package/dist/v1/addressing/key.js +23 -3
  7. package/dist/v1/addressing/ordering.d.ts +2 -0
  8. package/dist/v1/addressing/ordering.js +4 -0
  9. package/dist/v1/addressing/patterns.d.ts +1 -1
  10. package/dist/v1/addressing/patterns.js +2 -6
  11. package/dist/v1/builder/callable/authoring.d.ts +11 -5
  12. package/dist/v1/builder/callable/authoring.js +2 -0
  13. package/dist/v1/builder/class/authoring.d.ts +94 -224
  14. package/dist/v1/builder/class/authoring.js +31 -33
  15. package/dist/v1/builder/class/handle.d.ts +27 -0
  16. package/dist/v1/builder/class/handle.js +1 -0
  17. package/dist/v1/builder/class/input.d.ts +159 -0
  18. package/dist/v1/builder/class/projection.d.ts +129 -0
  19. package/dist/v1/builder/class/projection.js +1 -0
  20. package/dist/v1/builder/class/property.d.ts +3 -9
  21. package/dist/v1/builder/class/property.js +1 -0
  22. package/dist/v1/builder/core/authoring.d.ts +1 -1
  23. package/dist/v1/builder/index.d.ts +5 -2
  24. package/dist/v1/builder/lowering/callable.js +1 -0
  25. package/dist/v1/builder/lowering/class.d.ts +9 -1
  26. package/dist/v1/builder/lowering/class.js +62 -17
  27. package/dist/v1/builder/lowering/policy.js +2 -0
  28. package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
  29. package/dist/v1/builder/lowering/property-keys.js +108 -0
  30. package/dist/v1/builder/lowering/schema/compile.js +11 -6
  31. package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
  32. package/dist/v1/builder/lowering/schema/context.js +36 -4
  33. package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
  34. package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
  35. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  36. package/dist/v1/builder/lowering/value/path.js +2 -4
  37. package/dist/v1/builder/lowering/value/zod.js +1 -3
  38. package/dist/v1/builder/policy/authoring.d.ts +85 -5
  39. package/dist/v1/builder/policy/authoring.js +107 -68
  40. package/dist/v1/builder/schema/define.d.ts +0 -1
  41. package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
  42. package/dist/v1/builder/schema/diagnostic.js +5 -10
  43. package/dist/v1/builder/schema/input.d.ts +1 -1
  44. package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
  45. package/dist/v1/builder/schema/projection/class.d.ts +118 -15
  46. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  47. package/dist/v1/builder/schema/projection/identity.d.ts +2 -1
  48. package/dist/v1/builder/schema/projection/model.d.ts +4 -2
  49. package/dist/v1/builder/schema/projection/property.d.ts +1 -1
  50. package/dist/v1/builder/schema/projection/resolved-class.d.ts +2 -1
  51. package/dist/v1/builder/schema/projection.d.ts +1 -1
  52. package/dist/v1/builder/value/full-match.d.ts +0 -1
  53. package/dist/v1/builder/value/full-match.js +0 -1
  54. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  55. package/dist/v1/builder/value/path.d.ts +1 -1
  56. package/dist/v1/bundle/codec.js +11 -13
  57. package/dist/v1/bundle/diagnostic.d.ts +2 -0
  58. package/dist/v1/bundle/diagnostic.js +9 -7
  59. package/dist/v1/bundle/model.js +1 -1
  60. package/dist/v1/bundle/structure.js +4 -6
  61. package/dist/v1/compiled/admission/accept.js +4 -10
  62. package/dist/v1/compiled/admission/closure.js +2 -2
  63. package/dist/v1/compiled/admission/diagnostic.d.ts +1 -1
  64. package/dist/v1/compiled/admission/diagnostic.js +1 -3
  65. package/dist/v1/compiled/admission/revision.d.ts +9 -1
  66. package/dist/v1/compiled/admission/revision.js +6 -3
  67. package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
  68. package/dist/v1/compiled/admission/semantics/class.js +37 -12
  69. package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
  70. package/dist/v1/compiled/admission/semantics/core.js +56 -24
  71. package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
  72. package/dist/v1/compiled/admission/semantics/edge.js +6 -65
  73. package/dist/v1/compiled/admission/semantics/policy/callable.js +0 -2
  74. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
  75. package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
  76. package/dist/v1/compiled/admission/semantics/policy/parity.js +40 -43
  77. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
  78. package/dist/v1/compiled/admission/semantics/policy/pattern.js +4 -16
  79. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
  80. package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
  81. package/dist/v1/compiled/admission/wire/callable.js +11 -1
  82. package/dist/v1/compiled/admission/wire/class.js +73 -21
  83. package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
  84. package/dist/v1/compiled/admission/wire/policy.js +8 -7
  85. package/dist/v1/compiled/compiler/compile.js +8 -8
  86. package/dist/v1/compiled/diagnostic.js +2 -3
  87. package/dist/v1/compiled/loader/load.d.ts +3 -2
  88. package/dist/v1/compiled/loader/load.js +11 -45
  89. package/dist/v1/domain/create.js +5 -6
  90. package/dist/v1/domain/model/domain.d.ts +2 -7
  91. package/dist/v1/domain/model/input.d.ts +2 -1
  92. package/dist/v1/domain/namespace/member-collection.js +4 -6
  93. package/dist/v1/domain/projection/classes.js +4 -1
  94. package/dist/v1/domain/validation/create.d.ts +6 -3
  95. package/dist/v1/domain/validation/create.js +21 -69
  96. package/dist/v1/index.d.ts +2 -1
  97. package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
  98. package/dist/v1/language/.spec/schemas/value-schema.schema.json +22 -0
  99. package/dist/v1/language/callable/admission.d.ts +15 -0
  100. package/dist/v1/language/callable/admission.js +43 -0
  101. package/dist/v1/language/callable/model/callable.d.ts +10 -0
  102. package/dist/v1/language/callable/resolved.d.ts +16 -3
  103. package/dist/v1/language/class/inheritance.d.ts +36 -5
  104. package/dist/v1/language/class/inheritance.js +87 -1
  105. package/dist/v1/language/class/lifetime.d.ts +50 -11
  106. package/dist/v1/language/class/lifetime.js +89 -20
  107. package/dist/v1/language/class/model/class.d.ts +45 -9
  108. package/dist/v1/language/class/model/edge.d.ts +31 -2
  109. package/dist/v1/language/class/model/property.d.ts +16 -7
  110. package/dist/v1/language/class/property-values.js +2 -4
  111. package/dist/v1/language/class/unique.d.ts +143 -0
  112. package/dist/v1/language/class/unique.js +264 -0
  113. package/dist/v1/language/core/facts.d.ts +85 -0
  114. package/dist/v1/language/core/facts.js +116 -0
  115. package/dist/v1/language/definition/metadata.d.ts +5 -0
  116. package/dist/v1/language/definition/metadata.js +7 -0
  117. package/dist/v1/language/freeze.d.ts +5 -0
  118. package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
  119. package/dist/v1/language/index.d.ts +7 -2
  120. package/dist/v1/language/index.js +5 -1
  121. package/dist/v1/language/limits.d.ts +64 -0
  122. package/dist/v1/language/limits.js +60 -0
  123. package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
  124. package/dist/v1/language/policy/analysis/branches.js +2 -1
  125. package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
  126. package/dist/v1/language/policy/analysis/budgets.js +133 -19
  127. package/dist/v1/language/policy/analysis/checks.js +3 -2
  128. package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
  129. package/dist/v1/language/policy/analysis/typing.js +455 -0
  130. package/dist/v1/language/policy/model/policy.d.ts +49 -9
  131. package/dist/v1/language/policy/model/policy.js +14 -0
  132. package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
  133. package/dist/v1/language/policy/normalization/normalize.js +22 -21
  134. package/dist/v1/language/validation/diagnostic.d.ts +15 -1
  135. package/dist/v1/language/validation/diagnostic.js +21 -0
  136. package/dist/v1/language/validation/rule.d.ts +45 -0
  137. package/dist/v1/language/validation/rule.js +109 -0
  138. package/dist/v1/language/value/compile/fields.js +4 -8
  139. package/dist/v1/language/value/evaluate/program.d.ts +2 -1
  140. package/dist/v1/language/value/evaluate/program.js +2 -2
  141. package/dist/v1/language/value/evaluate/validate.d.ts +2 -2
  142. package/dist/v1/language/value/evaluate/validate.js +6 -2
  143. package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
  144. package/dist/v1/language/value/evaluate/validity.optimization.js +342 -0
  145. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  146. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  147. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  148. package/dist/v1/language/value/inclusion/assertions.js +29 -0
  149. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  150. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  151. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  152. package/dist/v1/language/value/inclusion/equivalence.js +74 -0
  153. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  154. package/dist/v1/language/value/inclusion/evidence.js +138 -0
  155. package/dist/v1/language/value/inclusion/includes.d.ts +17 -0
  156. package/dist/v1/language/value/inclusion/includes.js +25 -719
  157. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  158. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  159. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  160. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  161. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  162. package/dist/v1/language/value/inclusion/location.js +63 -0
  163. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  164. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  165. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  166. package/dist/v1/language/value/inclusion/objects.js +190 -0
  167. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  168. package/dist/v1/language/value/inclusion/strings.js +29 -0
  169. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  170. package/dist/v1/language/value/inclusion/types.js +11 -0
  171. package/dist/v1/language/value/ordering.d.ts +14 -0
  172. package/dist/v1/language/value/ordering.js +86 -9
  173. package/dist/v1/language/value/profile/canonicalize.js +6 -5
  174. package/dist/v1/language/value/profile/json.validate.d.ts +3 -1
  175. package/dist/v1/language/value/profile/json.validate.js +3 -2
  176. package/dist/v1/language/value/profile/meta-schema.compiled.js +4 -1
  177. package/dist/v1/language/value/profile/rules.js +17 -43
  178. package/dist/v1/language/value/profile/validate.js +1 -10
  179. package/dist/v1/language/value/profile/vocabulary.d.ts +35 -2
  180. package/dist/v1/language/value/profile/vocabulary.js +52 -5
  181. package/dist/v1/language/value/reference/closure.js +3 -4
  182. package/dist/v1/language/value/reference/recursion.js +2 -22
  183. package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
  184. package/dist/v1/language/value/reference/registry.index.js +33 -16
  185. package/dist/v1/language/value/regexp/ast.js +6 -7
  186. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  187. package/dist/v1/language/value/regexp/compile.js +14 -12
  188. package/dist/v1/language/value/regexp/syntax.js +3 -2
  189. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  190. package/dist/v1/language/value/syntax/keywords.js +4 -20
  191. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  192. package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
  193. package/dist/v1/language/value/syntax/pointer.js +5 -2
  194. package/dist/v1/language/value/syntax/walk.d.ts +2 -0
  195. package/dist/v1/language/value/syntax/walk.js +19 -20
  196. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2519 -0
  197. package/dist/v1/schema/admission/accept.js +3 -14
  198. package/dist/v1/schema/admission/callable.d.ts +21 -0
  199. package/dist/v1/schema/admission/callable.js +96 -0
  200. package/dist/v1/schema/analysis/class.js +33 -15
  201. package/dist/v1/schema/canonical/revision.js +4 -4
  202. package/dist/v1/schema/compatibility/api.d.ts +2 -1
  203. package/dist/v1/schema/compatibility/api.js +1 -0
  204. package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
  205. package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
  206. package/dist/v1/schema/compatibility/comparators/classes.js +29 -8
  207. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  208. package/dist/v1/schema/compatibility/comparators/members.js +1 -1
  209. package/dist/v1/schema/compatibility/comparators/values.js +2 -2
  210. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  211. package/dist/v1/schema/compatibility/diff.js +2 -4
  212. package/dist/v1/schema/compatibility/extension.d.ts +11 -0
  213. package/dist/v1/schema/compatibility/extension.js +22 -0
  214. package/dist/v1/schema/compatibility/fields.d.ts +20 -4
  215. package/dist/v1/schema/compatibility/fields.js +13 -3
  216. package/dist/v1/schema/compatibility/meaning/footprint.js +16 -50
  217. package/dist/v1/schema/compatibility/model.d.ts +17 -5
  218. package/dist/v1/schema/compatibility/report.js +1 -1
  219. package/dist/v1/schema/compatibility/scope.d.ts +2 -0
  220. package/dist/v1/schema/compatibility/scope.js +4 -1
  221. package/dist/v1/schema/compatibility/structure/index.js +6 -4
  222. package/dist/v1/schema/compatibility/structure/requirements.js +57 -58
  223. package/dist/v1/schema/compatibility/versioning/index.js +1 -1
  224. package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
  225. package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
  226. package/dist/v1/schema/compatibility/walk.d.ts +17 -0
  227. package/dist/v1/schema/compatibility/walk.js +41 -0
  228. package/dist/v1/schema/diagnostic.d.ts +17 -3
  229. package/dist/v1/schema/diagnostic.js +14 -11
  230. package/dist/v1/schema/index.d.ts +10 -1
  231. package/dist/v1/schema/index.js +4 -0
  232. package/dist/v1/schema/model/schema.d.ts +20 -1
  233. package/dist/v1/schema/model/schema.js +1 -1
  234. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  235. package/dist/v1/schema/normalization/domain.js +29 -9
  236. package/dist/v1/schema/resolution/closure.js +2 -1
  237. package/dist/v1/schema/resolution/context.js +13 -13
  238. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  239. package/dist/v1/schema/resolution/domain.js +2 -2
  240. package/dist/v1/schema/resolution/origins.js +3 -2
  241. package/dist/v1/schema/rule.d.ts +26 -0
  242. package/dist/v1/schema/rule.js +440 -0
  243. package/dist/v1/schema/validation/callable.d.ts +35 -2
  244. package/dist/v1/schema/validation/callable.js +65 -9
  245. package/dist/v1/schema/validation/class.d.ts +6 -2
  246. package/dist/v1/schema/validation/class.js +127 -104
  247. package/dist/v1/schema/validation/core.js +90 -168
  248. package/dist/v1/schema/validation/domain.js +4 -13
  249. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  250. package/dist/v1/schema/validation/domain.json-schema.js +197 -0
  251. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  252. package/dist/v1/schema/validation/domain.route.js +18 -0
  253. package/dist/v1/schema/validation/domain.structure.d.ts +7780 -0
  254. package/dist/v1/schema/validation/domain.structure.js +398 -147
  255. package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
  256. package/dist/v1/schema/validation/json.json-schema.js +46 -0
  257. package/dist/v1/schema/validation/policy/budgets.d.ts +33 -2
  258. package/dist/v1/schema/validation/policy/budgets.js +87 -121
  259. package/dist/v1/schema/validation/policy/context.d.ts +6 -5
  260. package/dist/v1/schema/validation/policy/context.js +7 -10
  261. package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
  262. package/dist/v1/schema/validation/policy/objects.js +6 -14
  263. package/dist/v1/schema/validation/policy/references.js +11 -27
  264. package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
  265. package/dist/v1/schema/validation/policy/typing.js +22 -356
  266. package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
  267. package/dist/v1/schema/validation/policy/uses.js +66 -89
  268. package/dist/v1/schema/validation/policy/validate.js +5 -5
  269. package/dist/v1/schema/validation/value-api.d.ts +22 -0
  270. package/dist/v1/schema/validation/value-api.js +34 -1
  271. package/dist/v1/schema/validation/value.d.ts +3 -0
  272. package/dist/v1/schema/validation/value.js +9 -17
  273. package/dist/v1/schema/validation/value.json-schema.d.ts +49 -0
  274. package/dist/v1/schema/validation/value.json-schema.js +137 -0
  275. package/dist/v1/schema/validation/view.js +4 -8
  276. package/dist/value/canonical.d.ts +6 -0
  277. package/dist/value/canonical.js +36 -0
  278. package/dist/value/decode.d.ts +7 -0
  279. package/dist/value/decode.js +159 -9
  280. package/dist/value/index.d.ts +1 -1
  281. package/dist/value/json.d.ts +2 -2
  282. package/dist/value/json.js +2 -2
  283. package/dist/value/types.d.ts +6 -0
  284. package/dist/value/unicode.d.ts +2 -1
  285. package/dist/value/unicode.js +2 -0
  286. package/package.json +8 -1
  287. package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
  288. package/dist/v1/builder/lowering/core-properties.js +0 -76
  289. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
  290. package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
  291. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
  292. package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
  293. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
  294. package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
  295. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
  296. package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
  297. package/dist/v1/language/class/index.d.ts +0 -8
  298. package/dist/v1/language/class/index.js +0 -1
  299. package/dist/v1/language/core/index.d.ts +0 -2
  300. package/dist/v1/language/value/index.d.ts +0 -11
  301. package/dist/v1/language/value/index.js +0 -8
  302. package/dist/v1/schema/canonical/domain.d.ts +0 -3
  303. package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
  304. package/dist/v1/schema/canonical/domain.digest.js +0 -5
  305. package/dist/v1/schema/canonical/domain.js +0 -5
  306. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  307. /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
@@ -1,71 +1,25 @@
1
1
  import { Key } from '../../../addressing/index.js';
2
2
  import { compareUnicode } from '../../../addressing/ordering.js';
3
- import { isGraphRoot } from '../../../language/class/inheritance.js';
3
+ import { edgeContractRefines } from '../../../language/class/inheritance.js';
4
4
  import {} from '../../../language/class/model/edge.js';
5
5
  import { fail } from '../diagnostic.js';
6
- import { isCompiledEdge, classSatisfiesAny, } from './context.js';
7
- /** Check Edge endpoint contracts and safe inheritance refinement. */
6
+ import { isCompiledEdge, classSatisfiesAny } from './context.js';
7
+ /** Check safe Edge inheritance refinement; the wire and closure checks own the endpoints. */
8
8
  export function validateEdges(context) {
9
9
  for (const located of context.classes.values()) {
10
10
  if (!isCompiledEdge(located.value))
11
11
  continue;
12
12
  const edge = located.value;
13
- const endpoints = edge.orientation === 'directed'
14
- ? [edge.endpoints.source, edge.endpoints.target]
15
- : edge.endpoints;
16
- if (endpoints[0].role === endpoints[1].role)
17
- fail(`${located.pointer}/endpoints`, 'Edge endpoint roles must differ.');
18
- for (const [endpointIndex, endpoint] of endpoints.entries()) {
19
- const seen = new Set();
20
- for (const [acceptIndex, ref] of endpoint.accepts.entries()) {
21
- const key = Key.of(ref);
22
- if (seen.has(key))
23
- fail(`${located.pointer}/endpoints/${endpointIndex}/accepts/${acceptIndex}`, 'Edge endpoint repeats an accepted Class.');
24
- seen.add(key);
25
- if (context.classes.get(key)?.value.kind !== 'node')
26
- fail(`${located.pointer}/endpoints/${endpointIndex}/accepts/${acceptIndex}`, 'Edge endpoint must accept a Node Class.');
27
- }
28
- }
29
13
  for (const [parentIndex, parentRef] of edge.extends.entries()) {
30
14
  const parent = context.classes.get(Key.of(parentRef))?.value;
31
- if (parent !== undefined && isCompiledEdge(parent) && !edgeRefines(context, edge, parent)) {
15
+ if (parent !== undefined &&
16
+ isCompiledEdge(parent) &&
17
+ !edgeContractRefines(edge, parent, (candidate, accepts) => classSatisfiesAny(context, candidate, accepts))) {
32
18
  fail(`${located.pointer}/extends/${parentIndex}`, 'Edge Class does not safely refine its parent.');
33
19
  }
34
20
  }
35
21
  }
36
22
  }
37
- function edgeRefines(context, child, parent) {
38
- if (isGraphRoot(parent))
39
- return true;
40
- if (child.orientation !== parent.orientation)
41
- return false;
42
- if (parent.constraints.noSelf === true && child.constraints.noSelf !== true)
43
- return false;
44
- if (parent.constraints.acyclic === true && child.constraints.acyclic !== true)
45
- return false;
46
- if (child.orientation === 'directed' && parent.orientation === 'directed') {
47
- return (endpointRefines(context, child.endpoints.source, parent.endpoints.source) &&
48
- countRefines(child.endpoints.source.outgoing, parent.endpoints.source.outgoing) &&
49
- endpointRefines(context, child.endpoints.target, parent.endpoints.target) &&
50
- countRefines(child.endpoints.target.incoming, parent.endpoints.target.incoming));
51
- }
52
- if (child.orientation !== 'undirected' || parent.orientation !== 'undirected')
53
- return false;
54
- const refine = (a, b) => endpointRefines(context, child.endpoints[a], parent.endpoints[b]) &&
55
- countRefines(child.endpoints[a].incident, parent.endpoints[b].incident);
56
- const direct = refine(0, 0) && refine(1, 1);
57
- if (direct)
58
- return true;
59
- return refine(0, 1) && refine(1, 0);
60
- }
61
- function endpointRefines(context, child, parent) {
62
- return child.accepts.every((accepted) => classSatisfiesAny(context, accepted, parent.accepts));
63
- }
64
- function countRefines(child, parent) {
65
- const [childMin, childMax] = countBounds(child);
66
- const [parentMin, parentMax] = countBounds(parent);
67
- return childMin >= parentMin && childMax <= parentMax;
68
- }
69
23
  /** Compare undirected endpoint acceptance and cardinality contracts. */
70
24
  export function sameIncidentEndpoint(left, right) {
71
25
  const a = left.accepts.map(Key.of).sort(compareUnicode);
@@ -74,16 +28,3 @@ export function sameIncidentEndpoint(left, right) {
74
28
  a.length === b.length &&
75
29
  a.every((value, index) => value === b[index]));
76
30
  }
77
- /** Interpret an Edge count as inclusive degree bounds. */
78
- export function countBounds(value) {
79
- switch (value) {
80
- case '0..*':
81
- return [0, Number.POSITIVE_INFINITY];
82
- case '1..*':
83
- return [1, Number.POSITIVE_INFINITY];
84
- case '0..1':
85
- return [0, 1];
86
- case '1':
87
- return [1, 1];
88
- }
89
- }
@@ -28,8 +28,6 @@ export function validateCallablePolicy(context, entry, expression, inputIndex, f
28
28
  return;
29
29
  }
30
30
  const children = 'allOf' in expression ? expression.allOf : expression.anyOf;
31
- if (children.length === 0)
32
- fail(path, 'Callable Policy composition must be non-empty.');
33
31
  children.forEach((child, index) => validateCallablePolicy(context, entry, child, inputIndex, fields, instanceMethod, `${path}/${index}`));
34
32
  }
35
33
  function isSingleNodePathField(context, entry, inputIndex, field) {
@@ -1,24 +1,9 @@
1
- import type { PolicyCheckObject } from '../../../../language/policy/model/policy.js';
1
+ import type { ObjectContract } from '../../../../language/policy/analysis/typing.js';
2
2
  import { type ClassRef } from '../../../../addressing/index.js';
3
+ import { type PolicyCheckObject, type PolicyObjectRef } from '../../../../language/policy/model/policy.js';
3
4
  import { type CompiledSchemaEntry } from '../../../model/schema.js';
4
5
  import { type SemanticIndex } from '../context.js';
5
- /** The default protected object contract or one exact Class. */
6
- export type CompiledObjectContract = {
7
- readonly kind: 'default';
8
- } | {
9
- readonly kind: 'exact';
10
- readonly ref: ClassRef;
11
- };
12
- /** The protected object or endpoint contracts of one Policy use. */
13
- export type CompiledPolicyUse = {
14
- readonly kind: 'object';
15
- readonly object: CompiledObjectContract;
16
- } | {
17
- readonly kind: 'edge';
18
- readonly source: CompiledObjectContract;
19
- readonly target: CompiledObjectContract;
20
- };
21
6
  /** Resolve callable Policy objects to their protected Class contracts. */
22
- export declare function callableObjectContracts(context: SemanticIndex, entry: CompiledSchemaEntry, input: number, receiver: ClassRef | undefined, object: PolicyCheckObject): readonly CompiledObjectContract[] | undefined;
23
- /** Select the protected contract for an object or Edge endpoint term. */
24
- export declare function compiledTargetContract(term: string, use: CompiledPolicyUse): CompiledObjectContract | undefined;
7
+ export declare function callableObjectContracts(context: SemanticIndex, entry: CompiledSchemaEntry, input: number, receiver: ClassRef | undefined, object: PolicyCheckObject): readonly ObjectContract[] | undefined;
8
+ /** Resolve a referenced Policy object to its protected Class contract. */
9
+ export declare function referenceContract(context: SemanticIndex, ref: PolicyObjectRef): ObjectContract | undefined;
@@ -1,4 +1,5 @@
1
1
  import { Key } from '../../../../addressing/index.js';
2
+ import { projectedMemberClass, } from '../../../../language/policy/model/policy.js';
2
3
  import {} from '../../../model/schema.js';
3
4
  import {} from '../context.js';
4
5
  /** Resolve callable Policy objects to their protected Class contracts. */
@@ -9,24 +10,16 @@ export function callableObjectContracts(context, entry, input, receiver, object)
9
10
  if (object.kind === 'input') {
10
11
  return nodePathAccepts(entry, input, object.field).map((ref) => ({ kind: 'exact', ref }));
11
12
  }
12
- const ref = object.ref;
13
+ const contract = referenceContract(context, object.ref);
14
+ return contract === undefined ? undefined : [contract];
15
+ }
16
+ /** Resolve a referenced Policy object to its protected Class contract. */
17
+ export function referenceContract(context, ref) {
13
18
  if (ref.kind === 'core') {
14
19
  const node = context.core.get(Key.of(ref))?.value;
15
- return node === undefined ? undefined : [{ kind: 'exact', ref: node.class }];
20
+ return node === undefined ? undefined : { kind: 'exact', ref: node.class };
16
21
  }
17
- const projection = ref.kind === 'class'
18
- ? 'Class'
19
- : ref.kind === 'function' || ref.kind === 'method'
20
- ? 'Function'
21
- : ref.kind === 'policy'
22
- ? 'Policy'
23
- : 'View';
24
- return [
25
- {
26
- kind: 'exact',
27
- ref: { origin: 'kernel.astrale.ai', kind: 'class', name: projection },
28
- },
29
- ];
22
+ return { kind: 'exact', ref: projectedMemberClass(ref) };
30
23
  }
31
24
  function nodePathAccepts(entry, input, field) {
32
25
  const root = entry.values[input]?.nodes[entry.values[input].root]?.schema;
@@ -37,9 +30,3 @@ function nodePathAccepts(entry, input, field) {
37
30
  ? annotation.accepts
38
31
  : [];
39
32
  }
40
- /** Select the protected contract for an object or Edge endpoint term. */
41
- export function compiledTargetContract(term, use) {
42
- if (use.kind === 'object')
43
- return term === 'object' ? use.object : undefined;
44
- return term === 'source' ? use.source : term === 'target' ? use.target : undefined;
45
- }
@@ -1,20 +1,20 @@
1
1
  import { Key } from '../../../../addressing/index.js';
2
- import {} from '../../../../language/class/model/edge.js';
3
2
  import { branchesOf, targetMode, isConnected, } from '../../../../language/policy/analysis/branches.js';
4
- import { MAX_PATTERN_DEPTH, MAX_BRANCHES, MAX_EDGES, MAX_DOMAINS, measureChecks, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, } from '../../../../language/policy/analysis/budgets.js';
5
- import { admittedCheckClasses, neverAdmittedClasses, } from '../../../../language/policy/analysis/checks.js';
6
- import { checksNameTheCaller, isClassRuleChecks, } from '../../../../language/policy/model/policy.js';
3
+ import { exceededLimits, measureChecks, policyMeasurer, } from '../../../../language/policy/analysis/budgets.js';
4
+ import { neverAdmittedClasses, } from '../../../../language/policy/analysis/checks.js';
5
+ import {} from '../../../../language/policy/analysis/typing.js';
6
+ import { CLASS_OPERATIONS, checksNameTheCaller, isClassRuleChecks, } from '../../../../language/policy/model/policy.js';
7
7
  import { normalizePolicyExpression } from '../../../../language/policy/normalization/normalize.js';
8
8
  import {} from '../../../model/schema.js';
9
9
  import { fail } from '../../diagnostic.js';
10
- import { isCompiledEdge } from '../context.js';
10
+ import { isCompiledEdge, } from '../context.js';
11
11
  import { callableObjectContracts } from './contracts.js';
12
- import { measureCompiledPolicy } from './measure.js';
13
- import { CompiledPolicyTyping } from './typing.js';
12
+ import { compiledPolicyTyping } from './typing.js';
14
13
  /** Check Policy typing and expansion budgets against the entry’s own closure. */
15
14
  export function validatePolicyParity(context, entry, entryIndex, policies, origins) {
16
15
  const normalized = new Map([...policies].map(([name, policy]) => [name, normalizePolicyExpression(policy.expression)]));
17
- const typing = new CompiledPolicyTyping(context, entry, normalized, origins);
16
+ const typing = compiledPolicyTyping(context, entry, normalized, origins);
17
+ const measurePolicy = policyMeasurer(entry.origin, normalized, (ref) => ref.origin === entry.origin);
18
18
  for (const [name, declaration] of policies) {
19
19
  const path = `/closure/${entryIndex}/definitions/policies/${declarationIndex(entry, 'policies', name)}`;
20
20
  if ('match' in declaration.expression) {
@@ -27,15 +27,11 @@ export function validatePolicyParity(context, entry, entryIndex, policies, origi
27
27
  }
28
28
  }
29
29
  }
30
- const measure = measureCompiledPolicy(entry.origin, name, normalized, new Set());
31
- if (measure !== undefined &&
32
- (measure.depth > MAX_PATTERN_DEPTH ||
33
- measure.edgeCounts.length > MAX_BRANCHES ||
34
- Math.max(0, ...measure.edgeCounts) > MAX_EDGES ||
35
- measure.domains.size > MAX_DOMAINS)) {
30
+ const measure = measurePolicy(name);
31
+ if (measure !== undefined && exceededLimits(measure).length > 0) {
36
32
  fail(path, 'Policy expansion exceeds the V1 depth, branch, Edge, or Domain budget.');
37
33
  }
38
- const branches = typing.expandedBranches(name, new Set(), `$${name}`);
34
+ const branches = typing.expandedBranches(name, `$${name}`);
39
35
  if (branches !== undefined) {
40
36
  for (const branch of branches) {
41
37
  const mode = targetMode(branch);
@@ -50,33 +46,25 @@ export function validatePolicyParity(context, entry, entryIndex, policies, origi
50
46
  }
51
47
  }
52
48
  for (const [classIndex, definition] of entry.definitions.classes.entries()) {
53
- for (const operation of ['read', 'traverse']) {
49
+ const edge = isCompiledEdge(definition) ? definition : undefined;
50
+ for (const operation of CLASS_OPERATIONS) {
54
51
  const policy = definition.policies[operation];
55
52
  if (typeof policy !== 'object')
56
53
  continue;
57
54
  const path = `/closure/${entryIndex}/definitions/classes/${classIndex}/policies/${operation}`;
58
55
  if (isClassRuleChecks(policy)) {
59
- // The wire admits rules only on a Node Class and only over `self` and `ref` objects.
60
- if (!checksNameTheCaller(policy))
61
- fail(path, 'Every branch of a Class rule must check a Policy: sameNode alone names no caller.');
62
- validatePolicyChecks(context, typing, entry, policy, -1, definition.ref, path, 'class');
56
+ // The wire admits rules only over `self` and `ref` objects, and `ref` alone to create a Node.
57
+ validatePolicyChecks(context, typing, entry, policy, -1, definition.ref, path, 'class', edge);
63
58
  continue;
64
59
  }
65
- const label = operation === 'read' ? 'Read' : 'Traverse';
60
+ const label = `${operation[0].toUpperCase()}${operation.slice(1)}`;
66
61
  if (definition.kind === 'node') {
67
62
  if (!typing.policyAccepts(policy.name, { kind: 'exact', ref: definition.ref })) {
68
63
  fail(path, `${label} Policy is incompatible with its protected Node Class.`);
69
64
  }
70
65
  }
71
- else if (isCompiledEdge(definition)) {
72
- const endpoints = definition.orientation === 'directed'
73
- ? [definition.endpoints.source, definition.endpoints.target]
74
- : definition.endpoints;
75
- const sources = typing.concreteEndpointClasses(endpoints[0].accepts);
76
- const targets = typing.concreteEndpointClasses(endpoints[1].accepts);
77
- if (sources.some((source) => targets.some((target) => !typing.policyAcceptsEdge(policy.name, { kind: 'exact', ref: source }, { kind: 'exact', ref: target })))) {
78
- fail(path, `${label} Policy is incompatible with an accepted Edge endpoint pair.`);
79
- }
66
+ else if (edge !== undefined && !typing.policyAcceptsEdgeClass(policy.name, edge)) {
67
+ fail(path, `${label} Policy is incompatible with an accepted Edge endpoint pair.`);
80
68
  }
81
69
  }
82
70
  if (definition.kind === 'node') {
@@ -101,34 +89,43 @@ const SITE = {
101
89
  callable: { checks: 'Callable Policy checks', objects: 'the callable object contract' },
102
90
  class: { checks: 'Class rule checks', objects: 'the Class rule object contract' },
103
91
  };
104
- function validatePolicyChecks(context, typing, entry, expression, input, receiver, path, site) {
105
- const measure = measureChecks(expression);
106
- if (measure.depth > MAX_CHECK_DEPTH ||
107
- measure.branches > MAX_BRANCHES ||
108
- measure.leaves > MAX_CHECK_LEAVES) {
92
+ function validatePolicyChecks(context, typing, entry, expression, input, receiver, path, site, edge) {
93
+ if (!checksNameTheCaller(expression)) {
94
+ fail(path, `${SITE[site].checks} must check a Policy on every branch: sameNode alone names no caller.`);
95
+ }
96
+ if (exceededLimits(measureChecks(expression)).length > 0) {
109
97
  fail(path, `${SITE[site].checks} exceed the V1 depth, branch, or leaf budget.`);
110
98
  }
111
99
  const leaves = new Map();
112
100
  const visit = (value, pointer) => {
113
- if ('sameNode' in value)
101
+ if ('sameNode' in value) {
102
+ // `self` is an Edge in an Edge Class rule, and sameNode compares Nodes.
103
+ if (edge !== undefined &&
104
+ (value.sameNode.left.kind === 'self' || value.sameNode.right.kind === 'self'))
105
+ fail(pointer, 'sameNode compares Nodes: self is an Edge here.');
114
106
  return;
107
+ }
115
108
  if (!('check' in value)) {
116
109
  const children = 'allOf' in value ? value.allOf : value.anyOf;
117
110
  children.forEach((child, index) => visit(child, `${pointer}/${index}`));
118
111
  return;
119
112
  }
113
+ if (edge !== undefined && value.object.kind === 'self') {
114
+ // An Edge is checked as an Edge Class Policy is: over every concrete endpoint pair.
115
+ if (!typing.policyAcceptsEdgeClass(value.check.name, edge))
116
+ fail(pointer, 'Named Policy is incompatible with an accepted Edge endpoint pair.');
117
+ const name = Key.of(edge.ref);
118
+ leaves.set(value, { accepted: [name], admitted: new Set([name]) });
119
+ return;
120
+ }
120
121
  const contracts = callableObjectContracts(context, entry, input, receiver, value.object);
121
122
  if (contracts === undefined)
122
123
  return;
123
- const typings = new Map(contracts.map((contract) => [
124
- contract.kind === 'exact' ? Key.of(contract.ref) : 'default',
125
- typing.policyBranchTyping(value.check.name, contract),
126
- ]));
127
- const admitted = admittedCheckClasses(typings);
128
- if (admitted === undefined) {
124
+ const classes = typing.checkLeafClasses(value.check.name, contracts);
125
+ if (classes === undefined) {
129
126
  fail(pointer, `Named Policy is incompatible with ${SITE[site].objects}.`);
130
127
  }
131
- leaves.set(value, { accepted: [...typings.keys()], admitted });
128
+ leaves.set(value, classes);
132
129
  };
133
130
  visit(expression, path);
134
131
  const [never] = neverAdmittedClasses(expression, leaves);
@@ -2,7 +2,10 @@ import { type MethodAddress } from '../../../../addressing/index.js';
2
2
  import { type PolicyExpression } from '../../../../language/policy/model/policy.js';
3
3
  import { type CompiledSchemaEntry } from '../../../model/schema.js';
4
4
  import { type SemanticIndex, type CompiledPolicy } from '../context.js';
5
- /** Check named Policy composition and scoped pattern references. */
5
+ /**
6
+ * Check named Policy composition and scoped pattern references. The wire grammar already bounds
7
+ * repeats and variables and refuses empty compositions.
8
+ */
6
9
  export declare function validatePolicyExpression(context: SemanticIndex, entry: CompiledSchemaEntry, expression: PolicyExpression, path: string, local: ReadonlyMap<string, CompiledPolicy>): void;
7
10
  /** Require an exact executable Method declaration for a Policy reference. */
8
11
  export declare function validatePolicyMethod(context: SemanticIndex, ref: MethodAddress, path: string): void;
@@ -1,20 +1,20 @@
1
1
  import { Key } from '../../../../addressing/index.js';
2
2
  import { isMethodExecutable } from '../../../../language/callable/executable.js';
3
3
  import { policyVariableClass } from '../../../../language/index.js';
4
- import { MAX_REPEAT, MAX_VARIABLES } from '../../../../language/policy/analysis/budgets.js';
5
4
  import {} from '../../../../language/policy/model/policy.js';
6
5
  import {} from '../../../model/schema.js';
7
6
  import { fail } from '../../diagnostic.js';
8
7
  import {} from '../context.js';
9
- /** Check named Policy composition and scoped pattern references. */
8
+ /**
9
+ * Check named Policy composition and scoped pattern references. The wire grammar already bounds
10
+ * repeats and variables and refuses empty compositions.
11
+ */
10
12
  export function validatePolicyExpression(context, entry, expression, path, local) {
11
13
  if ('match' in expression) {
12
14
  validatePattern(context, expression.match, `${path}/match`, new Set(), new Set());
13
15
  return;
14
16
  }
15
17
  const values = 'allOf' in expression ? expression.allOf : expression.anyOf;
16
- if (values.length === 0)
17
- fail(path, 'Named Policy composition must be non-empty.');
18
18
  for (const [index, ref] of values.entries()) {
19
19
  if (ref.origin !== entry.origin || ref.kind !== 'policy' || !local.has(ref.name))
20
20
  fail(`${path}/${index}`, 'Named Policy composition must reference a local Policy.');
@@ -31,19 +31,9 @@ function validatePattern(context, expression, path, scope, declared) {
31
31
  fail(`${path}/class`, 'Policy pattern Class must resolve to an Edge Class.');
32
32
  validatePolicyTerm(context, expression.source, `${path}/source`, scope);
33
33
  validatePolicyTerm(context, expression.target, `${path}/target`, scope);
34
- if (expression.repeat !== undefined &&
35
- (!Number.isInteger(expression.repeat.min) ||
36
- !Number.isInteger(expression.repeat.max) ||
37
- expression.repeat.min < 0 ||
38
- expression.repeat.max < expression.repeat.min ||
39
- expression.repeat.max > MAX_REPEAT))
40
- fail(`${path}/repeat`, 'Policy repeat is outside the V1 bounds.');
41
34
  return;
42
35
  }
43
36
  if ('exists' in expression) {
44
- if (expression.exists.nodes.length > MAX_VARIABLES) {
45
- fail(`${path}/exists/nodes`, 'Policy exists exceeds the V1 variable budget.');
46
- }
47
37
  const nested = new Set(scope);
48
38
  for (const [index, node] of expression.exists.nodes.entries()) {
49
39
  const id = node.variable.id;
@@ -59,8 +49,6 @@ function validatePattern(context, expression, path, scope, declared) {
59
49
  return;
60
50
  }
61
51
  const values = 'allOf' in expression ? expression.allOf : expression.anyOf;
62
- if (values.length === 0)
63
- fail(path, 'Policy pattern composition must be non-empty.');
64
52
  values.forEach((value, index) => validatePattern(context, value, `${path}/${index}`, scope, declared));
65
53
  }
66
54
  function validatePolicyTerm(context, term, path, scope) {
@@ -1,28 +1,6 @@
1
- import { type ClassRef } from '../../../../addressing/index.js';
2
- import { type PatternBranch } from '../../../../language/policy/analysis/branches.js';
1
+ import { PolicyTyping } from '../../../../language/policy/analysis/typing.js';
3
2
  import { type PolicyExpression } from '../../../../language/policy/model/policy.js';
4
3
  import { type CompiledSchemaEntry } from '../../../model/schema.js';
5
4
  import { type SemanticIndex } from '../context.js';
6
- import { type CompiledObjectContract, type CompiledPolicyUse } from './contracts.js';
7
5
  /** Types one entry's Policies against the Node Classes of its own closure, as source admission. */
8
- export declare class CompiledPolicyTyping {
9
- readonly context: SemanticIndex;
10
- readonly entry: CompiledSchemaEntry;
11
- readonly normalized: ReadonlyMap<string, PolicyExpression>;
12
- readonly allNodeClasses: readonly ClassRef[];
13
- readonly concreteNodeClasses: readonly ClassRef[];
14
- constructor(context: SemanticIndex, entry: CompiledSchemaEntry, normalized: ReadonlyMap<string, PolicyExpression>, origins: ReadonlySet<string>);
15
- expandedBranches(name: string, visiting: Set<string>, namespace: string): readonly PatternBranch[] | undefined;
16
- policyAccepts(name: string, object: CompiledObjectContract): boolean;
17
- policyBranchTyping(name: string, object: CompiledObjectContract): readonly boolean[] | undefined;
18
- policyAcceptsEdge(name: string, source: CompiledObjectContract, target: CompiledObjectContract): boolean;
19
- concreteEndpointClasses(accepts: readonly ClassRef[]): readonly ClassRef[];
20
- endpointsOverlap(left: readonly ClassRef[], right: readonly ClassRef[]): boolean;
21
- branchIsTyped(branch: PatternBranch, use: CompiledPolicyUse): boolean;
22
- private constraintsSatisfiable;
23
- private applyInitial;
24
- private applyExact;
25
- private applyAnyNodeClass;
26
- private applyRequirement;
27
- private applyEndpoint;
28
- }
6
+ export declare function compiledPolicyTyping(context: SemanticIndex, entry: CompiledSchemaEntry, normalized: ReadonlyMap<string, PolicyExpression>, origins: ReadonlySet<string>): PolicyTyping;