@astrale-os/kernel-dsl 1.0.0-beta.3 → 1.0.0-beta.31

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 (413) 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 +2 -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 +30 -35
  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 +10 -2
  24. package/dist/v1/builder/index.js +2 -0
  25. package/dist/v1/builder/lowering/callable.js +1 -0
  26. package/dist/v1/builder/lowering/class.d.ts +9 -1
  27. package/dist/v1/builder/lowering/class.js +62 -17
  28. package/dist/v1/builder/lowering/policy.js +6 -24
  29. package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
  30. package/dist/v1/builder/lowering/property-keys.js +108 -0
  31. package/dist/v1/builder/lowering/schema/compile.js +13 -6
  32. package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
  33. package/dist/v1/builder/lowering/schema/context.js +36 -7
  34. package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
  35. package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
  36. package/dist/v1/builder/lowering/value/compile.js +29 -22
  37. package/dist/v1/builder/lowering/value/file.d.ts +7 -0
  38. package/dist/v1/builder/lowering/value/file.js +14 -0
  39. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  40. package/dist/v1/builder/lowering/value/path.js +2 -4
  41. package/dist/v1/builder/lowering/value/zod.js +41 -7
  42. package/dist/v1/builder/policy/authoring.d.ts +80 -9
  43. package/dist/v1/builder/policy/authoring.js +99 -68
  44. package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
  45. package/dist/v1/builder/policy/legacy/edge.js +16 -0
  46. package/dist/v1/builder/schema/define.d.ts +0 -1
  47. package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
  48. package/dist/v1/builder/schema/diagnostic.js +5 -10
  49. package/dist/v1/builder/schema/input.d.ts +4 -1
  50. package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
  51. package/dist/v1/builder/schema/projection/class.d.ts +78 -16
  52. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  53. package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
  54. package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
  55. package/dist/v1/builder/schema/projection/model.d.ts +4 -2
  56. package/dist/v1/builder/schema/projection/property.d.ts +38 -4
  57. package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
  58. package/dist/v1/builder/schema/projection.d.ts +1 -1
  59. package/dist/v1/builder/schema/rule.d.ts +316 -0
  60. package/dist/v1/builder/schema/rule.js +192 -0
  61. package/dist/v1/builder/value/file.d.ts +34 -0
  62. package/dist/v1/builder/value/file.js +77 -0
  63. package/dist/v1/builder/value/full-match.d.ts +0 -1
  64. package/dist/v1/builder/value/full-match.js +0 -1
  65. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  66. package/dist/v1/builder/value/path.d.ts +1 -1
  67. package/dist/v1/bundle/codec.js +55 -74
  68. package/dist/v1/bundle/diagnostic.d.ts +3 -1
  69. package/dist/v1/bundle/diagnostic.js +9 -7
  70. package/dist/v1/bundle/index.d.ts +2 -0
  71. package/dist/v1/bundle/index.js +1 -0
  72. package/dist/v1/bundle/model.js +1 -1
  73. package/dist/v1/bundle/rule.d.ts +14 -0
  74. package/dist/v1/bundle/rule.js +41 -0
  75. package/dist/v1/bundle/structure.js +6 -8
  76. package/dist/v1/compiled/admission/accept.js +9 -15
  77. package/dist/v1/compiled/admission/closure.js +17 -34
  78. package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
  79. package/dist/v1/compiled/admission/diagnostic.js +40 -3
  80. package/dist/v1/compiled/admission/revision.d.ts +9 -1
  81. package/dist/v1/compiled/admission/revision.js +7 -3
  82. package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
  83. package/dist/v1/compiled/admission/semantics/class.js +48 -19
  84. package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
  85. package/dist/v1/compiled/admission/semantics/core.js +56 -24
  86. package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
  87. package/dist/v1/compiled/admission/semantics/edge.js +6 -65
  88. package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
  89. package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
  90. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
  91. package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
  92. package/dist/v1/compiled/admission/semantics/policy/parity.js +44 -53
  93. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
  94. package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
  95. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
  96. package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
  97. package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
  98. package/dist/v1/compiled/admission/wire/callable.js +24 -20
  99. package/dist/v1/compiled/admission/wire/class.js +79 -30
  100. package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
  101. package/dist/v1/compiled/admission/wire/entry.js +36 -13
  102. package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
  103. package/dist/v1/compiled/admission/wire/policy.js +27 -20
  104. package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
  105. package/dist/v1/compiled/admission/wire/program.js +39 -44
  106. package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
  107. package/dist/v1/compiled/admission/wire/property.js +8 -5
  108. package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
  109. package/dist/v1/compiled/admission/wire/value.js +0 -7
  110. package/dist/v1/compiled/codec/json.js +4 -3
  111. package/dist/v1/compiled/compiler/compile.js +15 -33
  112. package/dist/v1/compiled/diagnostic.d.ts +1 -1
  113. package/dist/v1/compiled/diagnostic.js +2 -3
  114. package/dist/v1/compiled/index.d.ts +2 -0
  115. package/dist/v1/compiled/index.js +1 -0
  116. package/dist/v1/compiled/loader/load.d.ts +3 -2
  117. package/dist/v1/compiled/loader/load.js +13 -52
  118. package/dist/v1/compiled/model/schema.d.ts +3 -0
  119. package/dist/v1/compiled/rule.d.ts +49 -0
  120. package/dist/v1/compiled/rule.js +169 -0
  121. package/dist/v1/domain/create.js +9 -10
  122. package/dist/v1/domain/model/domain.d.ts +2 -7
  123. package/dist/v1/domain/model/input.d.ts +19 -10
  124. package/dist/v1/domain/namespace/member-collection.js +8 -7
  125. package/dist/v1/domain/projection/classes.js +11 -8
  126. package/dist/v1/domain/validation/create.d.ts +7 -16
  127. package/dist/v1/domain/validation/create.js +35 -81
  128. package/dist/v1/index.d.ts +5 -3
  129. package/dist/v1/index.js +1 -1
  130. package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
  131. package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
  132. package/dist/v1/language/callable/admission.d.ts +15 -0
  133. package/dist/v1/language/callable/admission.js +44 -0
  134. package/dist/v1/language/callable/model/callable.d.ts +10 -0
  135. package/dist/v1/language/callable/resolved.d.ts +26 -5
  136. package/dist/v1/language/chain.d.ts +7 -0
  137. package/dist/v1/language/chain.js +24 -0
  138. package/dist/v1/language/class/inheritance.d.ts +36 -5
  139. package/dist/v1/language/class/inheritance.js +85 -1
  140. package/dist/v1/language/class/lifetime.d.ts +50 -11
  141. package/dist/v1/language/class/lifetime.js +89 -20
  142. package/dist/v1/language/class/model/class.d.ts +45 -9
  143. package/dist/v1/language/class/model/edge.d.ts +31 -2
  144. package/dist/v1/language/class/model/property.d.ts +16 -7
  145. package/dist/v1/language/class/property-values.js +2 -4
  146. package/dist/v1/language/class/resolved.d.ts +9 -4
  147. package/dist/v1/language/class/unique.d.ts +143 -0
  148. package/dist/v1/language/class/unique.js +264 -0
  149. package/dist/v1/language/core/facts.d.ts +85 -0
  150. package/dist/v1/language/core/facts.js +116 -0
  151. package/dist/v1/language/cycle.d.ts +10 -0
  152. package/dist/v1/language/cycle.js +30 -0
  153. package/dist/v1/language/definition/metadata.d.ts +38 -0
  154. package/dist/v1/language/definition/metadata.js +51 -0
  155. package/dist/v1/language/freeze.d.ts +5 -0
  156. package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
  157. package/dist/v1/language/index.d.ts +7 -2
  158. package/dist/v1/language/index.js +5 -1
  159. package/dist/v1/language/limits.d.ts +83 -0
  160. package/dist/v1/language/limits.js +77 -0
  161. package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
  162. package/dist/v1/language/policy/analysis/branches.js +8 -8
  163. package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
  164. package/dist/v1/language/policy/analysis/budgets.js +140 -20
  165. package/dist/v1/language/policy/analysis/checks.js +8 -6
  166. package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
  167. package/dist/v1/language/policy/analysis/composition.js +11 -0
  168. package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
  169. package/dist/v1/language/policy/analysis/typing.js +456 -0
  170. package/dist/v1/language/policy/model/policy.d.ts +71 -9
  171. package/dist/v1/language/policy/model/policy.js +42 -4
  172. package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
  173. package/dist/v1/language/policy/normalization/normalize.js +46 -68
  174. package/dist/v1/language/suspended.d.ts +7 -0
  175. package/dist/v1/language/suspended.js +23 -0
  176. package/dist/v1/language/validation/diagnostic.d.ts +15 -1
  177. package/dist/v1/language/validation/diagnostic.js +21 -0
  178. package/dist/v1/language/validation/rule.d.ts +45 -0
  179. package/dist/v1/language/validation/rule.js +109 -0
  180. package/dist/v1/language/value/compile/fields.js +16 -16
  181. package/dist/v1/language/value/compile/load.d.ts +5 -0
  182. package/dist/v1/language/value/compile/load.js +13 -0
  183. package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
  184. package/dist/v1/language/value/evaluate/assertions.js +19 -8
  185. package/dist/v1/language/value/evaluate/evaluator.js +117 -120
  186. package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
  187. package/dist/v1/language/value/evaluate/preparation.js +100 -47
  188. package/dist/v1/language/value/evaluate/program.d.ts +2 -1
  189. package/dist/v1/language/value/evaluate/program.js +6 -6
  190. package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
  191. package/dist/v1/language/value/evaluate/validate.js +15 -11
  192. package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
  193. package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
  194. package/dist/v1/language/value/files.d.ts +44 -0
  195. package/dist/v1/language/value/files.js +151 -0
  196. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  197. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  198. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  199. package/dist/v1/language/value/inclusion/assertions.js +28 -0
  200. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  201. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  202. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  203. package/dist/v1/language/value/inclusion/equivalence.js +76 -0
  204. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  205. package/dist/v1/language/value/inclusion/evidence.js +140 -0
  206. package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
  207. package/dist/v1/language/value/inclusion/includes.js +58 -723
  208. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  209. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  210. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  211. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  212. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  213. package/dist/v1/language/value/inclusion/location.js +66 -0
  214. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  215. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  216. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  217. package/dist/v1/language/value/inclusion/objects.js +190 -0
  218. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  219. package/dist/v1/language/value/inclusion/strings.js +29 -0
  220. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  221. package/dist/v1/language/value/inclusion/types.js +34 -0
  222. package/dist/v1/language/value/model/blob.d.ts +6 -0
  223. package/dist/v1/language/value/model/blob.js +8 -0
  224. package/dist/v1/language/value/model/file.d.ts +41 -0
  225. package/dist/v1/language/value/model/file.js +122 -0
  226. package/dist/v1/language/value/ordering.d.ts +14 -0
  227. package/dist/v1/language/value/ordering.js +144 -77
  228. package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
  229. package/dist/v1/language/value/profile/canonicalize.js +67 -87
  230. package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
  231. package/dist/v1/language/value/profile/json.validate.js +18 -5
  232. package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
  233. package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
  234. package/dist/v1/language/value/profile/rules.js +27 -44
  235. package/dist/v1/language/value/profile/validate.js +1 -10
  236. package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
  237. package/dist/v1/language/value/profile/vocabulary.js +58 -5
  238. package/dist/v1/language/value/reference/closure.js +6 -6
  239. package/dist/v1/language/value/reference/recursion.js +9 -48
  240. package/dist/v1/language/value/reference/references.d.ts +3 -1
  241. package/dist/v1/language/value/reference/references.js +7 -7
  242. package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
  243. package/dist/v1/language/value/reference/registry.index.js +33 -16
  244. package/dist/v1/language/value/regexp/ast.js +6 -7
  245. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  246. package/dist/v1/language/value/regexp/compile.js +14 -12
  247. package/dist/v1/language/value/regexp/syntax.js +3 -2
  248. package/dist/v1/language/value/regexp/unicode.d.ts +1 -1
  249. package/dist/v1/language/value/regexp/unicode.js +1 -1
  250. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  251. package/dist/v1/language/value/syntax/keywords.js +4 -20
  252. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  253. package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
  254. package/dist/v1/language/value/syntax/pointer.js +5 -2
  255. package/dist/v1/language/value/syntax/walk.d.ts +9 -0
  256. package/dist/v1/language/value/syntax/walk.js +37 -20
  257. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
  258. package/dist/v1/schema/admission/accept.d.ts +3 -1
  259. package/dist/v1/schema/admission/accept.js +6 -14
  260. package/dist/v1/schema/admission/callable.d.ts +21 -0
  261. package/dist/v1/schema/admission/callable.js +96 -0
  262. package/dist/v1/schema/analysis/class.d.ts +4 -0
  263. package/dist/v1/schema/analysis/class.js +57 -17
  264. package/dist/v1/schema/canonical/revision.d.ts +4 -1
  265. package/dist/v1/schema/canonical/revision.js +8 -5
  266. package/dist/v1/schema/compatibility/api.d.ts +4 -1
  267. package/dist/v1/schema/compatibility/api.js +2 -0
  268. package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
  269. package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
  270. package/dist/v1/schema/compatibility/comparators/classes.js +50 -29
  271. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  272. package/dist/v1/schema/compatibility/comparators/members.js +1 -1
  273. package/dist/v1/schema/compatibility/comparators/values.js +2 -2
  274. package/dist/v1/schema/compatibility/context.d.ts +5 -2
  275. package/dist/v1/schema/compatibility/context.js +8 -6
  276. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  277. package/dist/v1/schema/compatibility/diff.js +2 -4
  278. package/dist/v1/schema/compatibility/extension.d.ts +11 -0
  279. package/dist/v1/schema/compatibility/extension.js +22 -0
  280. package/dist/v1/schema/compatibility/fields.d.ts +20 -4
  281. package/dist/v1/schema/compatibility/fields.js +13 -3
  282. package/dist/v1/schema/compatibility/meaning/footprint.js +16 -51
  283. package/dist/v1/schema/compatibility/model.d.ts +17 -5
  284. package/dist/v1/schema/compatibility/references.d.ts +0 -3
  285. package/dist/v1/schema/compatibility/references.js +1 -9
  286. package/dist/v1/schema/compatibility/report.js +1 -1
  287. package/dist/v1/schema/compatibility/rule.d.ts +13 -0
  288. package/dist/v1/schema/compatibility/rule.js +23 -0
  289. package/dist/v1/schema/compatibility/scope.d.ts +2 -0
  290. package/dist/v1/schema/compatibility/scope.js +4 -1
  291. package/dist/v1/schema/compatibility/structure/index.js +6 -4
  292. package/dist/v1/schema/compatibility/structure/requirements.js +58 -61
  293. package/dist/v1/schema/compatibility/versioning/index.js +1 -1
  294. package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
  295. package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
  296. package/dist/v1/schema/compatibility/walk.d.ts +17 -0
  297. package/dist/v1/schema/compatibility/walk.js +41 -0
  298. package/dist/v1/schema/diagnostic.d.ts +17 -3
  299. package/dist/v1/schema/diagnostic.js +14 -11
  300. package/dist/v1/schema/enforcement/changes.d.ts +590 -0
  301. package/dist/v1/schema/enforcement/changes.js +566 -0
  302. package/dist/v1/schema/enforcement/derived.d.ts +236 -0
  303. package/dist/v1/schema/enforcement/derived.js +243 -0
  304. package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
  305. package/dist/v1/schema/enforcement/dispose.js +275 -0
  306. package/dist/v1/schema/enforcement/facts.d.ts +89 -0
  307. package/dist/v1/schema/enforcement/facts.js +70 -0
  308. package/dist/v1/schema/enforcement/fields.d.ts +65 -0
  309. package/dist/v1/schema/enforcement/fields.js +36 -0
  310. package/dist/v1/schema/enforcement/index.d.ts +39 -0
  311. package/dist/v1/schema/enforcement/index.js +10 -0
  312. package/dist/v1/schema/enforcement/install.d.ts +1634 -0
  313. package/dist/v1/schema/enforcement/install.js +1223 -0
  314. package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
  315. package/dist/v1/schema/enforcement/lifecycle.js +91 -0
  316. package/dist/v1/schema/enforcement/model.d.ts +253 -0
  317. package/dist/v1/schema/enforcement/model.js +1 -0
  318. package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
  319. package/dist/v1/schema/enforcement/obligations.js +240 -0
  320. package/dist/v1/schema/enforcement/write.d.ts +1314 -0
  321. package/dist/v1/schema/enforcement/write.js +1017 -0
  322. package/dist/v1/schema/index.d.ts +11 -1
  323. package/dist/v1/schema/index.js +5 -0
  324. package/dist/v1/schema/model/schema.d.ts +23 -1
  325. package/dist/v1/schema/model/schema.js +1 -1
  326. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  327. package/dist/v1/schema/normalization/domain.js +50 -13
  328. package/dist/v1/schema/resolution/closure.js +2 -1
  329. package/dist/v1/schema/resolution/context.js +17 -18
  330. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  331. package/dist/v1/schema/resolution/domain.js +6 -12
  332. package/dist/v1/schema/resolution/origins.js +6 -8
  333. package/dist/v1/schema/rule.d.ts +25 -0
  334. package/dist/v1/schema/rule.js +459 -0
  335. package/dist/v1/schema/validation/callable.d.ts +35 -2
  336. package/dist/v1/schema/validation/callable.js +65 -9
  337. package/dist/v1/schema/validation/class.d.ts +6 -2
  338. package/dist/v1/schema/validation/class.js +128 -105
  339. package/dist/v1/schema/validation/core.js +103 -173
  340. package/dist/v1/schema/validation/domain.js +25 -15
  341. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  342. package/dist/v1/schema/validation/domain.json-schema.js +222 -0
  343. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  344. package/dist/v1/schema/validation/domain.route.js +18 -0
  345. package/dist/v1/schema/validation/domain.structure.d.ts +7797 -0
  346. package/dist/v1/schema/validation/domain.structure.js +516 -160
  347. package/dist/v1/schema/validation/icon.d.ts +4 -0
  348. package/dist/v1/schema/validation/icon.js +29 -0
  349. package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
  350. package/dist/v1/schema/validation/json.json-schema.js +46 -0
  351. package/dist/v1/schema/validation/policy/budgets.d.ts +37 -2
  352. package/dist/v1/schema/validation/policy/budgets.js +94 -121
  353. package/dist/v1/schema/validation/policy/context.d.ts +6 -5
  354. package/dist/v1/schema/validation/policy/context.js +7 -10
  355. package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
  356. package/dist/v1/schema/validation/policy/objects.js +6 -14
  357. package/dist/v1/schema/validation/policy/references.js +20 -62
  358. package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
  359. package/dist/v1/schema/validation/policy/typing.js +22 -356
  360. package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
  361. package/dist/v1/schema/validation/policy/uses.js +63 -91
  362. package/dist/v1/schema/validation/policy/validate.js +5 -5
  363. package/dist/v1/schema/validation/value-api.d.ts +27 -1
  364. package/dist/v1/schema/validation/value-api.js +37 -2
  365. package/dist/v1/schema/validation/value.d.ts +3 -0
  366. package/dist/v1/schema/validation/value.js +9 -17
  367. package/dist/v1/schema/validation/value.json-schema.d.ts +54 -0
  368. package/dist/v1/schema/validation/value.json-schema.js +163 -0
  369. package/dist/v1/schema/validation/view.js +4 -8
  370. package/dist/value/accept.d.ts +9 -3
  371. package/dist/value/accept.js +25 -1
  372. package/dist/value/canonical.d.ts +22 -1
  373. package/dist/value/canonical.js +114 -21
  374. package/dist/value/decode.d.ts +7 -0
  375. package/dist/value/decode.js +159 -9
  376. package/dist/value/equal.d.ts +9 -1
  377. package/dist/value/equal.js +37 -3
  378. package/dist/value/immutable.optimization.d.ts +2 -0
  379. package/dist/value/immutable.optimization.js +4 -0
  380. package/dist/value/index.d.ts +5 -3
  381. package/dist/value/index.js +2 -1
  382. package/dist/value/json.d.ts +2 -2
  383. package/dist/value/json.js +2 -2
  384. package/dist/value/limits.d.ts +11 -0
  385. package/dist/value/rule.d.ts +12 -0
  386. package/dist/value/rule.js +50 -0
  387. package/dist/value/types.d.ts +6 -0
  388. package/dist/value/unicode.d.ts +2 -1
  389. package/dist/value/unicode.js +2 -0
  390. package/package.json +15 -4
  391. package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
  392. package/dist/v1/builder/lowering/core-properties.js +0 -76
  393. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
  394. package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
  395. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
  396. package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
  397. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
  398. package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
  399. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
  400. package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
  401. package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
  402. package/dist/v1/compiled/admission/wire/pattern.js +0 -111
  403. package/dist/v1/language/class/index.d.ts +0 -8
  404. package/dist/v1/language/class/index.js +0 -1
  405. package/dist/v1/language/core/index.d.ts +0 -2
  406. package/dist/v1/language/value/index.d.ts +0 -11
  407. package/dist/v1/language/value/index.js +0 -8
  408. package/dist/v1/schema/canonical/domain.d.ts +0 -3
  409. package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
  410. package/dist/v1/schema/canonical/domain.digest.js +0 -5
  411. package/dist/v1/schema/canonical/domain.js +0 -5
  412. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  413. /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
@@ -1,6 +1,7 @@
1
+ import { escapePointerToken } from '../language/value/syntax/pointer.js';
1
2
  import { SchemaError } from '../schema/diagnostic.js';
2
- import { routeDomainSchema } from '../schema/validation/domain.route.js';
3
- import { BundleError, diagnostic } from './diagnostic.js';
3
+ import { structureDomainSchema } from '../schema/validation/domain.route.js';
4
+ import { BundleError, diagnostic, schemaDiagnosticAt } from './diagnostic.js';
4
5
  import { DOMAIN_BUNDLE_FORMAT, DOMAIN_BUNDLE_VERSION } from './model.js';
5
6
  export function parseDomainSchemaBundleStructure(input) {
6
7
  if (!isObject(input)) {
@@ -12,7 +13,7 @@ export function parseDomainSchemaBundleStructure(input) {
12
13
  const expected = new Set(['format', 'version', 'root', 'closure']);
13
14
  for (const key of Object.keys(input)) {
14
15
  if (!expected.has(key)) {
15
- diagnostics.push(diagnostic('BUNDLE_STRUCTURE', `/${escapeToken(key)}`, `Unknown bundle field ${key}.`));
16
+ diagnostics.push(diagnostic('BUNDLE_STRUCTURE', `/${escapePointerToken(key)}`, `Unknown bundle field ${key}.`));
16
17
  }
17
18
  }
18
19
  for (const key of expected) {
@@ -51,12 +52,12 @@ function routeAt(value, pointer, diagnostics) {
51
52
  if (value === undefined)
52
53
  return undefined;
53
54
  try {
54
- return routeDomainSchema(value);
55
+ return structureDomainSchema(value);
55
56
  }
56
57
  catch (error) {
57
58
  if (!(error instanceof SchemaError))
58
59
  throw error;
59
- diagnostics.push(...error.diagnostics.map((entry) => diagnostic(entry.code, `${pointer}${entry.pointer}`, entry.message, entry.ref)));
60
+ diagnostics.push(...error.diagnostics.map((entry) => schemaDiagnosticAt(pointer, entry)));
60
61
  return undefined;
61
62
  }
62
63
  }
@@ -66,6 +67,3 @@ function isObject(value) {
66
67
  function describe(value) {
67
68
  return value === undefined ? '(missing)' : JSON.stringify(value);
68
69
  }
69
- function escapeToken(value) {
70
- return value.replaceAll('~', '~0').replaceAll('/', '~1');
71
- }
@@ -1,17 +1,18 @@
1
- import { accept as acceptPortable } from '@astrale-os/kernel-dsl/value';
2
- import { dependencyLimits } from '../../addressing/domain-dependency.js';
1
+ import { acceptImmutable } from '@astrale-os/kernel-dsl/value';
2
+ import { deepFreeze } from '../../language/freeze.js';
3
+ import { closureDocument, limits } from '../../language/limits.js';
3
4
  import {} from '../model/schema.js';
4
5
  import { validateClosure } from './closure.js';
5
- import { invalid, pointer } from './diagnostic.js';
6
+ import { compiledDocument, invalid, pointer } from './diagnostic.js';
6
7
  import { validateCompiledSemantics } from './semantics.js';
7
8
  import { dependency } from './wire/dependency.js';
8
9
  import { entry } from './wire/entry.js';
9
- import {} from './wire/pattern.js';
10
+ import {} from './wire/program.js';
10
11
  import { object, exact, array } from './wire/value.js';
11
- const MAXIMUM_COMPILED_SCHEMA_MEMBERS = 1_000_000;
12
12
  /** Admit one detached compiled closure before indices and declarations become executable. */
13
13
  export function acceptCompiledSchema(input) {
14
- const root = object(acceptPortable(input, { limits: { maxMembers: MAXIMUM_COMPILED_SCHEMA_MEMBERS } }), 'CompiledSchema', '');
14
+ const document = compiledDocument(() => acceptImmutable(input, closureDocument));
15
+ const root = object(document, 'CompiledSchema', '');
15
16
  exact(root, ['format', 'version', 'root', 'closure'], 'CompiledSchema', '');
16
17
  if (root.format !== 'astrale.dsl.compiled-schema')
17
18
  invalid('format', undefined, '/format');
@@ -20,7 +21,7 @@ export function acceptCompiledSchema(input) {
20
21
  const rootPin = dependency(root.root, 'root', '/root');
21
22
  const machines = new Map();
22
23
  const closure = array(root.closure, 'closure', '/closure').map((value, index) => entry(value, index, `/closure/${index}`, machines));
23
- if (closure.length > dependencyLimits.closure) {
24
+ if (closure.length > limits.dependency.closure) {
24
25
  invalid('dependency closure limit', 'COMPILED_DEPENDENCY_LIMITS', '/closure');
25
26
  }
26
27
  const closureOrigins = new Set();
@@ -34,7 +35,7 @@ export function acceptCompiledSchema(input) {
34
35
  if (rootEntry?.revision !== rootPin.revision)
35
36
  invalid('root pin', undefined, '/root');
36
37
  for (const [entryIndex, owner] of closure.entries()) {
37
- if (Object.keys(owner.dependencies).length > dependencyLimits.direct) {
38
+ if (Object.keys(owner.dependencies).length > limits.dependency.direct) {
38
39
  invalid('direct dependency limit', 'COMPILED_DEPENDENCY_LIMITS', `/closure/${entryIndex}/dependencies`);
39
40
  }
40
41
  for (const [alias, pin] of Object.entries(owner.dependencies)) {
@@ -69,10 +70,3 @@ export function acceptCompiledSchema(input) {
69
70
  validateCompiledSemantics(candidate);
70
71
  return deepFreeze(candidate);
71
72
  }
72
- function deepFreeze(input) {
73
- if (input === null || typeof input !== 'object' || Object.isFrozen(input))
74
- return input;
75
- for (const value of Object.values(input))
76
- deepFreeze(value);
77
- return Object.freeze(input);
78
- }
@@ -1,12 +1,13 @@
1
1
  import {} from '@astrale-os/kernel-dsl/value';
2
- import { dependencyLimits } from '../../addressing/domain-dependency.js';
3
2
  import { Key, isDefinitionRef } from '../../addressing/index.js';
3
+ import { chainDepths } from '../../language/chain.js';
4
4
  import {} from '../../language/class/model/edge.js';
5
+ import { limits } from '../../language/limits.js';
5
6
  import {} from '../model/schema.js';
6
7
  import { invalid, pointer } from './diagnostic.js';
7
8
  /** Require closed direct references, acyclic inheritance and concrete Core Classes. */
8
9
  export function validateClosure(candidate) {
9
- validateDependencyCycles(candidate);
10
+ validateDependencyDepth(candidate);
10
11
  const definitions = new Map();
11
12
  for (const [entryIndex, entry] of candidate.closure.entries()) {
12
13
  const collections = [
@@ -64,6 +65,10 @@ export function validateClosure(candidate) {
64
65
  value: definition,
65
66
  path: `/closure/${entryIndex}/definitions/classes/${classIndex}`,
66
67
  });
68
+ const depths = chainDepths(classes.values(), ({ value }) => value.extends.flatMap((ref) => classes.get(Key.of(ref)) ?? []));
69
+ for (const [{ path }, depth] of depths)
70
+ if (depth > limits.inheritance.depth)
71
+ invalid('Class inheritance depth limit', 'COMPILED_SOURCE_INVALID', `${path}/extends`);
67
72
  const visiting = new Set();
68
73
  const visited = new Set();
69
74
  const visitClass = (key) => {
@@ -122,38 +127,16 @@ export function validateClosure(candidate) {
122
127
  }
123
128
  }
124
129
  }
125
- function validateDependencyCycles(candidate) {
126
- const byOrigin = new Map(candidate.closure.map((entry, index) => [entry.origin, { entry, index }]));
127
- const active = new Set();
128
- const visited = new Set();
129
- const frames = [];
130
- const push = (origin, depth) => {
131
- if (depth > dependencyLimits.depth) {
132
- invalid('dependency depth limit', 'COMPILED_DEPENDENCY_LIMITS', `/closure/${byOrigin.get(origin)?.index ?? 0}/dependencies`);
133
- }
134
- active.add(origin);
135
- frames.push({
136
- origin,
137
- depth,
138
- dependencies: Object.values(byOrigin.get(origin)?.entry.dependencies ?? {}),
139
- index: 0,
140
- });
141
- };
142
- push(candidate.root.origin, 0);
143
- while (frames.length > 0) {
144
- const frame = frames.at(-1);
145
- const dependency = frame.dependencies[frame.index++];
146
- if (dependency === undefined) {
147
- frames.pop();
148
- active.delete(frame.origin);
149
- visited.add(frame.origin);
150
- continue;
151
- }
152
- if (active.has(dependency.origin)) {
153
- invalid('dependency cycle', 'COMPILED_DEPENDENCY_CYCLE', `/closure/${byOrigin.get(dependency.origin)?.index ?? 0}/dependencies`);
154
- }
155
- if (!visited.has(dependency.origin))
156
- push(dependency.origin, frame.depth + 1);
130
+ /**
131
+ * Refuse the first Domain whose longest chain of dependencies passes the limit. Admission proved
132
+ * every pin before this, and an entry's revision covers its pins, so the chains cannot close a cycle.
133
+ */
134
+ function validateDependencyDepth(candidate) {
135
+ const byOrigin = new Map(candidate.closure.map((entry) => [entry.origin, entry]));
136
+ const depths = chainDepths(candidate.closure, (entry) => Object.values(entry.dependencies).map(({ origin }) => byOrigin.get(origin)));
137
+ const index = candidate.closure.findIndex((entry) => depths.get(entry) > limits.dependency.depth);
138
+ if (index >= 0) {
139
+ invalid('dependency depth limit', 'COMPILED_DEPENDENCY_LIMITS', `/closure/${index}/dependencies`);
157
140
  }
158
141
  }
159
142
  function walk(input, path, visit) {
@@ -1,7 +1,29 @@
1
1
  import { type CompiledDiagnosticCode } from '../diagnostic.js';
2
2
  /** Append one escaped JSON Pointer segment. */
3
- export declare function pointer(parent: string, member: string | number): string;
3
+ export { appendPointer as pointer } from '../../language/value/syntax/pointer.js';
4
4
  /** Report a structural compiled-input violation with its stable diagnostic code. */
5
5
  export declare function invalid(label: string, code?: CompiledDiagnosticCode, path?: string): never;
6
+ /** How a refusal names the Policy checks of each use site and, once typed, their object contract. */
7
+ export declare const POLICY_CHECK_SITE: {
8
+ readonly callable: {
9
+ readonly name: 'Callable Policy';
10
+ readonly objects: 'the callable object contract';
11
+ };
12
+ readonly class: {
13
+ readonly name: 'Class rule';
14
+ readonly objects: 'the Class rule object contract';
15
+ };
16
+ readonly create: {
17
+ readonly name: 'Create rule';
18
+ };
19
+ };
6
20
  /** Report a contextual compiled-language violation at its original source pointer. */
7
21
  export declare function fail(pointer: string, message: string): never;
22
+ /** Cross the portable value boundary with a compiled document, whose refusal is answered as one. */
23
+ export declare function compiledDocument<Result>(cross: () => Result): Result;
24
+ /**
25
+ * Encode a document's revision canonically, refusing at `path` a part over the encoder's limits. A
26
+ * document may hold more members than the encoder takes, and has no revision then. What the encoder
27
+ * reports is located in what it encoded, so its pointer stays in the message.
28
+ */
29
+ export declare function withinEncodingLimits<Result>(path: string, encode: () => Result): Result;
@@ -1,13 +1,50 @@
1
+ import { BoundaryError, json } from '@astrale-os/kernel-dsl/value';
1
2
  import { invalidCompiled } from '../diagnostic.js';
2
3
  /** Append one escaped JSON Pointer segment. */
3
- export function pointer(parent, member) {
4
- return `${parent}/${String(member).replaceAll('~', '~0').replaceAll('/', '~1')}`;
5
- }
4
+ export { appendPointer as pointer } from '../../language/value/syntax/pointer.js';
6
5
  /** Report a structural compiled-input violation with its stable diagnostic code. */
7
6
  export function invalid(label, code = 'COMPILED_STRUCTURE_INVALID', path = '') {
8
7
  return invalidCompiled(code, `Invalid compiled Schema ${label}.`, path);
9
8
  }
9
+ /** How a refusal names the Policy checks of each use site and, once typed, their object contract. */
10
+ export const POLICY_CHECK_SITE = {
11
+ callable: { name: 'Callable Policy', objects: 'the callable object contract' },
12
+ class: { name: 'Class rule', objects: 'the Class rule object contract' },
13
+ create: { name: 'Create rule' },
14
+ };
10
15
  /** Report a contextual compiled-language violation at its original source pointer. */
11
16
  export function fail(pointer, message) {
12
17
  return invalidCompiled('COMPILED_SOURCE_INVALID', message, pointer);
13
18
  }
19
+ /** Cross the portable value boundary with a compiled document, whose refusal is answered as one. */
20
+ export function compiledDocument(cross) {
21
+ try {
22
+ return cross();
23
+ }
24
+ catch (error) {
25
+ if (error instanceof BoundaryError) {
26
+ return invalidCompiled('COMPILED_STRUCTURE_INVALID', error.message, error.pointer, {
27
+ cause: error,
28
+ });
29
+ }
30
+ if (error instanceof json.DecodeError) {
31
+ return invalidCompiled('COMPILED_STRUCTURE_INVALID', error.message, '', { cause: error });
32
+ }
33
+ throw error;
34
+ }
35
+ }
36
+ /**
37
+ * Encode a document's revision canonically, refusing at `path` a part over the encoder's limits. A
38
+ * document may hold more members than the encoder takes, and has no revision then. What the encoder
39
+ * reports is located in what it encoded, so its pointer stays in the message.
40
+ */
41
+ export function withinEncodingLimits(path, encode) {
42
+ try {
43
+ return encode();
44
+ }
45
+ catch (error) {
46
+ if (!(error instanceof BoundaryError) || error.code !== 'VALUE_LIMIT')
47
+ throw error;
48
+ return invalidCompiled('COMPILED_STRUCTURE_INVALID', error.message, path, { cause: error });
49
+ }
50
+ }
@@ -1,4 +1,12 @@
1
1
  import type { Revision } from '../../addressing/index.js';
2
- import type { CompiledSchemaEntry } from '../model/schema.js';
2
+ import type { FunctionDefinition, MethodDefinition } from '../../language/callable/model/callable.js';
3
+ import type { JsonSchema } from '../../language/value/model/schema.js';
4
+ import type { CompiledFunction, CompiledMethod, CompiledSchemaEntry } from '../model/schema.js';
3
5
  /** Derive the exact canonical source-revision preimage without constructing an authored Schema. */
4
6
  export declare function revisionOfCompiledEntry(entry: CompiledSchemaEntry): Revision;
7
+ /** The source definition of a compiled Method: its value programs back to their schemas. */
8
+ export declare function sourceMethod(entry: CompiledSchemaEntry, method: CompiledMethod): MethodDefinition;
9
+ /** The source definition of a compiled Function: its value programs back to their schemas. */
10
+ export declare function sourceFunction(entry: CompiledSchemaEntry, definition: CompiledFunction): FunctionDefinition;
11
+ /** The schema of the root node of the entry's value program `index`. */
12
+ export declare function schemaOf(entry: CompiledSchemaEntry, index: number): JsonSchema;
@@ -10,6 +10,7 @@ function revisionPreimage(entry) {
10
10
  version: 'v1',
11
11
  origin: entry.origin,
12
12
  name: entry.name,
13
+ ...(entry.icon === undefined ? {} : { icon: entry.icon }),
13
14
  ...(entry.entrypoint === undefined ? {} : { entrypoint: entry.entrypoint }),
14
15
  dependencies: entry.dependencies,
15
16
  classes: Object.fromEntries(entry.definitions.classes.map((definition) => [
@@ -44,7 +45,8 @@ function sourceClass(entry, definition) {
44
45
  methods: Object.fromEntries(methods.map((method) => [method.name, sourceMethod(entry, method)])),
45
46
  };
46
47
  }
47
- function sourceMethod(entry, method) {
48
+ /** The source definition of a compiled Method: its value programs back to their schemas. */
49
+ export function sourceMethod(entry, method) {
48
50
  const { name: _, input, fields: __, output, ...rest } = method;
49
51
  return {
50
52
  ...rest,
@@ -52,7 +54,8 @@ function sourceMethod(entry, method) {
52
54
  output: sourceOutput(entry, output),
53
55
  };
54
56
  }
55
- function sourceFunction(entry, definition) {
57
+ /** The source definition of a compiled Function: its value programs back to their schemas. */
58
+ export function sourceFunction(entry, definition) {
56
59
  const { input, fields: _, output, ...rest } = definition;
57
60
  return {
58
61
  ...rest,
@@ -72,7 +75,8 @@ function sourceOutput(entry, output) {
72
75
  const schema = schemaOf(entry, output.value);
73
76
  return output.mode === 'value' ? { mode: 'value', schema } : { mode: 'stream', item: schema };
74
77
  }
75
- function schemaOf(entry, index) {
78
+ /** The schema of the root node of the entry's value program `index`. */
79
+ export function schemaOf(entry, index) {
76
80
  const program = entry.values[index];
77
81
  const root = program?.nodes[program.root];
78
82
  if (root === undefined)
@@ -1,5 +1,8 @@
1
1
  import { type Located, type CompiledClass, type ClassAnalysis, type SemanticIndex } from './context.js';
2
- /** Compose inherited Properties, Methods and Data ownership once per Class. */
2
+ /**
3
+ * Compose inherited Properties, Methods and Data ownership once per Class. The closure check has
4
+ * already proved every parent present and the inheritance graph acyclic.
5
+ */
3
6
  export declare function analyzeClasses(classes: ReadonlyMap<string, Located<CompiledClass>>): ReadonlyMap<string, ClassAnalysis>;
4
7
  /** Check automatic Properties, immutability and abstract Class obligations. */
5
8
  export declare function validateClassFacets(context: SemanticIndex): void;
@@ -1,27 +1,27 @@
1
- import { json } from '@astrale-os/kernel-dsl/value';
1
+ import { equal } from '@astrale-os/kernel-dsl/value';
2
2
  import { Key, PropertyKey as PropertyKeyValue, } from '../../../addressing/index.js';
3
3
  import { composeMethods } from '../../../language/callable/composition.js';
4
4
  import { isMethodExecutable } from '../../../language/callable/executable.js';
5
+ import { keyableProperty } from '../../../language/class/unique.js';
5
6
  import { bindValueProgram } from '../../../language/value/compile/load.js';
6
7
  import {} from '../../model/schema.js';
7
8
  import { fail } from '../diagnostic.js';
8
9
  import {} from './context.js';
9
- /** Compose inherited Properties, Methods and Data ownership once per Class. */
10
+ /**
11
+ * Compose inherited Properties, Methods and Data ownership once per Class. The closure check has
12
+ * already proved every parent present and the inheritance graph acyclic.
13
+ */
10
14
  export function analyzeClasses(classes) {
11
15
  const analyses = new Map();
12
- const visiting = new Set();
13
16
  const analyze = (located) => {
14
17
  const classKey = Key.of(located.value.ref);
15
18
  const cached = analyses.get(classKey);
16
19
  if (cached !== undefined)
17
20
  return cached;
18
- if (visiting.has(classKey))
19
- fail(`${located.pointer}/extends`, 'Class inheritance is cyclic.');
20
- visiting.add(classKey);
21
21
  const parents = located.value.extends.map((ref, index) => {
22
22
  const parent = classes.get(Key.of(ref));
23
- if (parent === undefined)
24
- fail(`${located.pointer}/extends/${index}`, 'Parent Class is absent.');
23
+ if (parent.value.inheritance === 'final')
24
+ fail(`${located.pointer}/extends/${index}`, 'A final Class has no subclass.');
25
25
  return analyze(parent);
26
26
  });
27
27
  const properties = new Map();
@@ -68,7 +68,6 @@ export function analyzeClasses(classes) {
68
68
  ...(dataOwner === undefined ? {} : { dataOwner }),
69
69
  };
70
70
  analyses.set(classKey, analysis);
71
- visiting.delete(classKey);
72
71
  return analysis;
73
72
  };
74
73
  for (const value of classes.values())
@@ -76,24 +75,27 @@ export function analyzeClasses(classes) {
76
75
  return analyses;
77
76
  }
78
77
  function sameMethodSignature(leftEntry, left, rightEntry, right) {
79
- return (programKey(leftEntry, left.input) === programKey(rightEntry, right.input) &&
80
- outputKey(leftEntry, left.output) === outputKey(rightEntry, right.output) &&
78
+ return (sameProgram(leftEntry, left.input, rightEntry, right.input) &&
79
+ sameOutput(leftEntry, left.output, rightEntry, right.output) &&
81
80
  left.auth === right.auth &&
82
81
  left.static === right.static &&
83
82
  left.execution?.durable === right.execution?.durable);
84
83
  }
85
- function outputKey(entry, output) {
86
- return output.mode === 'binary' ? 'binary' : `${output.mode}:${programKey(entry, output.value)}`;
84
+ function sameOutput(leftEntry, left, rightEntry, right) {
85
+ if (left.mode !== right.mode)
86
+ return false;
87
+ if (left.mode === 'binary' || right.mode === 'binary')
88
+ return true;
89
+ return sameProgram(leftEntry, left.value, rightEntry, right.value);
87
90
  }
88
- function programKey(entry, value) {
89
- return json.serialize(bindValueProgram(entry.values[value], entry.patterns));
91
+ function sameProgram(leftEntry, left, rightEntry, right) {
92
+ return equal(bindValueProgram(leftEntry.values[left], leftEntry.patterns), bindValueProgram(rightEntry.values[right], rightEntry.patterns));
90
93
  }
91
94
  /** Check automatic Properties, immutability and abstract Class obligations. */
92
95
  export function validateClassFacets(context) {
93
96
  for (const located of context.classes.values()) {
94
- if (located.value.abstract &&
95
- (located.value.policies.read !== undefined || located.value.policies.traverse !== undefined)) {
96
- fail(`${located.pointer}/policies`, 'Abstract Classes cannot declare observation Policies.');
97
+ if (located.value.abstract && Object.keys(located.value.policies).length > 0) {
98
+ fail(`${located.pointer}/policies`, 'Abstract Classes cannot declare Class Policies.');
97
99
  }
98
100
  for (const [index, property] of located.value.properties.entries()) {
99
101
  const path = `${located.pointer}/properties/${index}`;
@@ -114,11 +116,38 @@ export function validateClassFacets(context) {
114
116
  }
115
117
  }
116
118
  }
119
+ if (located.value.unique !== undefined) {
120
+ const properties = context.analyses.get(Key.of(located.value.ref))?.properties;
121
+ const keyable = (key, at) => {
122
+ const property = properties?.get(key)?.declaration;
123
+ if (property === undefined || !keyableProperty(property.ordering, property.auto)) {
124
+ fail(at, 'A key Property is a keyable Property of the Class.');
125
+ }
126
+ };
127
+ // A Node tuple names Properties only; an Edge tuple names them as `{ property }`.
128
+ const value = located.value;
129
+ if (value.kind === 'node') {
130
+ for (const [t, tuple] of (value.unique ?? []).entries())
131
+ for (const [f, key] of tuple.entries())
132
+ keyable(key, `${located.pointer}/unique/${t}/${f}`);
133
+ }
134
+ else {
135
+ for (const [t, tuple] of (value.unique ?? []).entries())
136
+ for (const [f, field] of tuple.entries())
137
+ if (typeof field !== 'string')
138
+ keyable(field.property, `${located.pointer}/unique/${t}/${f}/property`);
139
+ }
140
+ }
117
141
  if (located.value.kind === 'node') {
118
142
  for (const [index, method] of located.value.methods.entries()) {
119
- if (!isMethodExecutable(located.value, method) && method.policy !== undefined) {
143
+ if (isMethodExecutable(located.value, method))
144
+ continue;
145
+ if (method.policy !== undefined) {
120
146
  fail(`${located.pointer}/methods/${index}/policy`, 'An abstract Method cannot have a Policy.');
121
147
  }
148
+ if (method.admission !== undefined) {
149
+ fail(`${located.pointer}/methods/${index}/admission`, 'An abstract Method cannot have an admission age.');
150
+ }
122
151
  }
123
152
  }
124
153
  }
@@ -1,7 +1,5 @@
1
- import { type ClassRef } from '../../../addressing/index.js';
2
- import { type CoreEdge } from '../../../language/core/model/core.js';
3
1
  import { type CompiledSchemaEntry, type CompiledSchema } from '../../model/schema.js';
4
- import { type Located, type CompiledClass, type ClassAnalysis, type CompiledEdge, type SemanticIndex } from './context.js';
2
+ import { type Located, type CompiledClass, type ClassAnalysis, type SemanticIndex } from './context.js';
5
3
  /** A local Core Node paired with its admitted Class analysis. */
6
4
  export interface CoreNode {
7
5
  readonly key: string;
@@ -10,26 +8,5 @@ export interface CoreNode {
10
8
  readonly analysis: ClassAnalysis;
11
9
  readonly pointer: string;
12
10
  }
13
- /**
14
- * A local Definition other than a Core Node, or a Class-owned Method. The Domain projects it as a
15
- * Kernel declaration Node, so `class` names that Kernel Class rather than an authored one.
16
- */
17
- interface CoreMemberEndpoint {
18
- readonly key: string;
19
- readonly class: ClassRef;
20
- readonly pointer: string;
21
- }
22
- type CoreEndpoint = CoreNode | CoreMemberEndpoint | {
23
- readonly key: 'domain';
24
- };
25
- /** A Core Edge paired with resolved endpoints and its exact Class. */
26
- export interface CoreEdgeValue {
27
- readonly source: CoreEndpoint;
28
- readonly target: CoreEndpoint;
29
- readonly value: CoreEdge;
30
- readonly class: Located<CompiledEdge>;
31
- readonly pointer: string;
32
- }
33
11
  /** Admit local Core Nodes, Properties and Edge endpoint contracts. */
34
12
  export declare function validateCore(candidate: CompiledSchema, context: SemanticIndex): void;
35
- export {};
@@ -1,15 +1,19 @@
1
1
  import { Key } from '../../../addressing/index.js';
2
2
  import { isMethodExecutable } from '../../../language/callable/executable.js';
3
+ import { coveringEdgeUniqueTuples, coveringNodeUniqueTuples, edgeUniqueKeys, nodeUniqueKeys, } from '../../../language/class/unique.js';
4
+ import { checkCoreEdgeSet, checkHeldKeys, coreEndpointsSatisfy, DOMAIN_ENDPOINT_CLASS, } from '../../../language/core/facts.js';
3
5
  import {} from '../../../language/core/model/core.js';
4
6
  import { policyObjectOrigin, policyObjectKey, projectedMemberClass, } from '../../../language/index.js';
5
7
  import { bindValueProgram } from '../../../language/value/compile/load.js';
6
8
  import { validateValueProgram } from '../../../language/value/evaluate/program.js';
9
+ import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
7
10
  import {} from '../../model/schema.js';
8
11
  import { fail } from '../diagnostic.js';
9
- import { validateCoreEdgeSet } from './cardinality.js';
10
12
  import { isCompiledEdge, classSatisfiesAny, } from './context.js';
13
+ import { sameIncidentEndpoint } from './edge.js';
11
14
  /** Admit local Core Nodes, Properties and Edge endpoint contracts. */
12
15
  export function validateCore(candidate, context) {
16
+ const resolve = (ref) => context.classes.get(Key.of(ref))?.value;
13
17
  for (const [entryIndex, entry] of candidate.closure.entries()) {
14
18
  const nodes = new Map();
15
19
  for (const [index, value] of entry.definitions.core.entries()) {
@@ -31,6 +35,9 @@ export function validateCore(candidate, context) {
31
35
  pointer: path,
32
36
  });
33
37
  }
38
+ checkHeldKeys(nodes.values(), (node) => nodeUniqueKeys(coveringNodeUniqueTuples(node.class.value, resolve), {
39
+ props: node.value.properties,
40
+ }), (node) => fail(node.pointer, 'Core Node holds a key another Core Node holds.'));
34
41
  const edges = [];
35
42
  for (const [index, value] of entry.facts.core.entries()) {
36
43
  const path = `/closure/${entryIndex}/facts/core/${index}`;
@@ -46,14 +53,7 @@ export function validateCore(candidate, context) {
46
53
  validateCoreProperties(value.properties, analysis, `${path}/properties`);
47
54
  const source = resolveCoreEndpoint(context, entry, value.source, nodes, `${path}/source`);
48
55
  const target = resolveCoreEndpoint(context, entry, value.target, nodes, `${path}/target`);
49
- const declaration = classValue.value;
50
- const satisfies = declaration.orientation === 'directed'
51
- ? endpointSatisfies(context, source, declaration.endpoints.source.accepts) &&
52
- endpointSatisfies(context, target, declaration.endpoints.target.accepts)
53
- : (endpointSatisfies(context, source, declaration.endpoints[0].accepts) &&
54
- endpointSatisfies(context, target, declaration.endpoints[1].accepts)) ||
55
- (endpointSatisfies(context, source, declaration.endpoints[1].accepts) &&
56
- endpointSatisfies(context, target, declaration.endpoints[0].accepts));
56
+ const satisfies = coreEndpointsSatisfy(classValue.value, source, target, (endpoint, accepts) => endpointSatisfies(context, endpoint, accepts));
57
57
  if (!satisfies)
58
58
  fail(path, 'Core Edge endpoints do not satisfy its exact Class.');
59
59
  edges.push({
@@ -64,28 +64,66 @@ export function validateCore(candidate, context) {
64
64
  pointer: path,
65
65
  });
66
66
  }
67
- validateCoreEdgeSet(context, entry, entryIndex, nodes, edges);
67
+ checkCoreEdgeSet({
68
+ edges: edges.map((edge) => ({
69
+ edge,
70
+ class: Key.of(edge.value.class),
71
+ contract: edge.class.value,
72
+ source: edge.source,
73
+ target: edge.target,
74
+ })),
75
+ classes: entry.definitions.classes
76
+ .filter(isCompiledEdge)
77
+ .map((value) => ({ key: Key.of(value.ref), contract: value })),
78
+ nodes: [...nodes.values()].map(({ key, value, pointer }) => ({
79
+ key,
80
+ class: value.class,
81
+ pointer,
82
+ })),
83
+ satisfies: (ref, accepts) => classSatisfiesAny(context, ref, accepts),
84
+ keys: ({ edge }) => edgeUniqueKeys(coveringEdgeUniqueTuples(edge.class.value, resolve), {
85
+ source: edge.source.key,
86
+ target: edge.target.key,
87
+ props: edge.value.properties,
88
+ }),
89
+ sameIncident: sameIncidentEndpoint,
90
+ report: (issue) => coreEdgeFailure(issue, entryIndex),
91
+ });
92
+ }
93
+ }
94
+ function coreEdgeFailure(issue, entryIndex) {
95
+ switch (issue.kind) {
96
+ case 'identity':
97
+ return fail(issue.edge.pointer, 'Core Edge duplicates an exact normalized Edge identity.');
98
+ case 'no-self':
99
+ return fail(issue.edge.pointer, 'Core Edge violates noSelf.');
100
+ case 'key':
101
+ return fail(issue.edge.pointer, 'Core Edge holds a key another Core Edge holds.');
102
+ case 'acyclic':
103
+ return fail(`/closure/${entryIndex}/facts/core`, 'Core Edge set violates exact-Class acyclicity.');
104
+ case 'degree':
105
+ return fail(issue.pointer, `Core degree ${issue.degree} violates Edge count ${issue.count}.`);
68
106
  }
69
107
  }
70
108
  function validateCoreProperties(values, analysis, path) {
71
109
  for (const key of Object.keys(values))
72
110
  if (!analysis.properties.has(key))
73
- fail(`${path}/${escapePointer(key)}`, 'Core properties contain an unknown Property key.');
111
+ fail(`${path}/${escapePointerToken(key)}`, 'Core properties contain an unknown Property key.');
74
112
  for (const property of analysis.properties.values()) {
75
113
  if (!Object.hasOwn(values, property.key)) {
76
114
  if (property.declaration.required && property.declaration.auto === undefined)
77
- fail(`${path}/${escapePointer(property.key)}`, 'Core properties omit a required Property.');
115
+ fail(`${path}/${escapePointerToken(property.key)}`, 'Core properties omit a required Property.');
78
116
  continue;
79
117
  }
80
118
  if (property.declaration.auto !== undefined)
81
- fail(`${path}/${escapePointer(property.key)}`, 'Core properties cannot author an automatic Property.');
119
+ fail(`${path}/${escapePointerToken(property.key)}`, 'Core properties cannot author an automatic Property.');
82
120
  if (validateValueProgram(bindValueProgram(property.entry.values[property.declaration.value], property.entry.patterns), values[property.key]).length > 0)
83
- fail(`${path}/${escapePointer(property.key)}`, 'Core Property value does not satisfy its exact contract.');
121
+ fail(`${path}/${escapePointerToken(property.key)}`, 'Core Property value does not satisfy its exact contract.');
84
122
  }
85
123
  }
86
124
  function resolveCoreEndpoint(context, entry, ref, nodes, path) {
87
125
  if (ref.kind === 'domain')
88
- return { key: 'domain' };
126
+ return { key: 'domain', member: { class: DOMAIN_ENDPOINT_CLASS, pointer: path } };
89
127
  const undeclared = () => fail(path, 'Core endpoint does not name a declared local Definition.');
90
128
  if (policyObjectOrigin(ref) !== entry.origin)
91
129
  return undeclared();
@@ -93,7 +131,8 @@ function resolveCoreEndpoint(context, entry, ref, nodes, path) {
93
131
  return nodes.get(Key.of(ref)) ?? undeclared();
94
132
  if (!declaresProjectedMember(context, entry, ref))
95
133
  return undeclared();
96
- return { key: policyObjectKey(ref), class: projectedMemberClass(ref), pointer: path };
134
+ // A projected member's degree is reported at the endpoint that names it.
135
+ return { key: policyObjectKey(ref), member: { class: projectedMemberClass(ref), pointer: path } };
97
136
  }
98
137
  /** Only a projected declaration can carry a Core fact; an abstract Method is never projected. */
99
138
  function declaresProjectedMember(context, entry, ref) {
@@ -112,12 +151,5 @@ function declaresProjectedMember(context, entry, ref) {
112
151
  return declarations.some((declaration) => declaration.ref.name === ref.name);
113
152
  }
114
153
  function endpointSatisfies(context, endpoint, accepts) {
115
- if ('value' in endpoint)
116
- return classSatisfiesAny(context, endpoint.value.class, accepts);
117
- if ('class' in endpoint)
118
- return classSatisfiesAny(context, endpoint.class, accepts);
119
- return true;
120
- }
121
- function escapePointer(value) {
122
- return value.replaceAll('~', '~0').replaceAll('/', '~1');
154
+ return classSatisfiesAny(context, 'value' in endpoint ? endpoint.value.class : endpoint.member.class, accepts);
123
155
  }
@@ -1,8 +1,6 @@
1
- import { type EdgeCount, type IncidentEndpoint } from '../../../language/class/model/edge.js';
1
+ import { type IncidentEndpoint } from '../../../language/class/model/edge.js';
2
2
  import { type SemanticIndex } from './context.js';
3
- /** Check Edge endpoint contracts and safe inheritance refinement. */
3
+ /** Check safe Edge inheritance refinement; the wire and closure checks own the endpoints. */
4
4
  export declare function validateEdges(context: SemanticIndex): void;
5
5
  /** Compare undirected endpoint acceptance and cardinality contracts. */
6
6
  export declare function sameIncidentEndpoint(left: IncidentEndpoint, right: IncidentEndpoint): boolean;
7
- /** Interpret an Edge count as inclusive degree bounds. */
8
- export declare function countBounds(value: EdgeCount): readonly [number, number];