@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,3 +1,5 @@
1
1
  import type { DomainSchemaLookup } from '../dependency/lookup.js';
2
- import type { DomainSchema } from '../model/schema.js';
2
+ import type { DomainSchema, DomainSchemaIR } from '../model/schema.js';
3
3
  export declare function acceptDomainSchema(input: unknown, lookup?: DomainSchemaLookup): DomainSchema;
4
+ /** Hold a document `structureDomainSchema` already read to the semantics of its language. */
5
+ export declare function acceptStructuredDomainSchema(structured: DomainSchemaIR, lookup: DomainSchemaLookup): DomainSchema;
@@ -1,22 +1,14 @@
1
- import { accept as acceptJsonValue, BoundaryError as JsonBoundaryError, } from '@astrale-os/kernel-dsl/value';
2
1
  import { canonicalDomainSchemaAfterValidation } from '../canonical/revision.js';
3
2
  import { emptyDomainSchemaLookup } from '../dependency/lookup.js';
4
- import { SchemaError, diagnostic } from '../diagnostic.js';
3
+ import { SchemaError } from '../diagnostic.js';
5
4
  import { rememberDomainClosure } from '../resolution/closure.js';
6
5
  import { validateDomainSchemaSemantics } from '../validation/domain.js';
7
- import { routeDomainSchema } from '../validation/domain.route.js';
6
+ import { structureDomainSchema } from '../validation/domain.route.js';
8
7
  export function acceptDomainSchema(input, lookup = emptyDomainSchemaLookup()) {
9
- let admitted;
10
- try {
11
- admitted = acceptJsonValue(input);
12
- }
13
- catch (error) {
14
- if (error instanceof JsonBoundaryError) {
15
- throw new SchemaError([diagnostic('DV_JSON_VALUE', error.pointer, error.message)]);
16
- }
17
- throw error;
18
- }
19
- const structured = routeDomainSchema(admitted);
8
+ return acceptStructuredDomainSchema(structureDomainSchema(input), lookup);
9
+ }
10
+ /** Hold a document `structureDomainSchema` already read to the semantics of its language. */
11
+ export function acceptStructuredDomainSchema(structured, lookup) {
20
12
  const validation = validateDomainSchemaSemantics(structured, lookup);
21
13
  if (validation.diagnostics.length > 0)
22
14
  throw new SchemaError(validation.diagnostics);
@@ -0,0 +1,21 @@
1
+ import type { ClassRef } from '../../addressing/index.js';
2
+ import type { CallableValidation } from '../../domain/model/input.js';
3
+ import type { CallableDefinition } from '../../language/callable/model/callable.js';
4
+ import type { DomainSchema } from '../model/schema.js';
5
+ /** One admitted callable contract and the validators of its exact owner environment. */
6
+ export interface AcceptedCallable extends CallableValidation {
7
+ readonly definition: CallableDefinition;
8
+ }
9
+ /**
10
+ * Accept one callable contract in the exact environment of its owner Domain, by the one validation
11
+ * every contract passes wherever it is declared (`validateContract`, `validateContractPolicy`,
12
+ * `validateCheckBudget`): the structure of a Function declaration without `ref`, its value schemas
13
+ * against the owner registry, its execution modifier and admission age, and its Policy with the
14
+ * budget of its checks. `receiver` is the owner Node Class whose Node receives the call and which
15
+ * the Policy names `self`: the Class of a Function instance, whose Node carries the contract, or
16
+ * the owner of an instance Method. Without it, as at a Function declaration, the Policy names none.
17
+ * Returns the canonical definition and its validators.
18
+ */
19
+ export declare function acceptCallable(input: unknown, owner: DomainSchema, options?: {
20
+ readonly receiver?: ClassRef;
21
+ }): AcceptedCallable;
@@ -0,0 +1,96 @@
1
+ import { accept as acceptJsonValue, BoundaryError as JsonBoundaryError, } from '@astrale-os/kernel-dsl/value';
2
+ import { definitionRefIndex } from '../../addressing/ordering.js';
3
+ import { isBinaryInput } from '../../language/callable/model/callable.js';
4
+ import { deepFreeze } from '../../language/freeze.js';
5
+ import { measureChecks } from '../../language/policy/analysis/budgets.js';
6
+ import { PolicyTyping } from '../../language/policy/analysis/typing.js';
7
+ import { normalizePolicyChecks } from '../../language/policy/normalization/normalize.js';
8
+ import {} from '../../language/value/evaluate/preparation.js';
9
+ import { analyzeDefinitions } from '../analysis/class.js';
10
+ import { SchemaError, diagnostic } from '../diagnostic.js';
11
+ import { canonicalizeCallable } from '../normalization/domain.js';
12
+ import { lookupForDomainClosure } from '../resolution/closure.js';
13
+ import { buildDomainResolutionContext } from '../resolution/context.js';
14
+ import { callableValidation } from '../resolution/domain.js';
15
+ import { createDomainValueSchemaRegistry } from '../resolution/value.registry.js';
16
+ import { validateContract } from '../validation/callable.js';
17
+ import { parseCallableContract } from '../validation/domain.structure.js';
18
+ import { validateCheckBudget } from '../validation/policy/budgets.js';
19
+ import { PolicyValidationContext } from '../validation/policy/context.js';
20
+ import { validatePolicyReferences } from '../validation/policy/references.js';
21
+ import { validateContractPolicy } from '../validation/policy/uses.js';
22
+ // An accepted DomainSchema is immutable and retains its closure, so its environment is reusable.
23
+ const environments = new WeakMap();
24
+ /**
25
+ * Accept one callable contract in the exact environment of its owner Domain, by the one validation
26
+ * every contract passes wherever it is declared (`validateContract`, `validateContractPolicy`,
27
+ * `validateCheckBudget`): the structure of a Function declaration without `ref`, its value schemas
28
+ * against the owner registry, its execution modifier and admission age, and its Policy with the
29
+ * budget of its checks. `receiver` is the owner Node Class whose Node receives the call and which
30
+ * the Policy names `self`: the Class of a Function instance, whose Node carries the contract, or
31
+ * the owner of an instance Method. Without it, as at a Function declaration, the Policy names none.
32
+ * Returns the canonical definition and its validators.
33
+ */
34
+ export function acceptCallable(input, owner, options = {}) {
35
+ let value;
36
+ try {
37
+ value = acceptJsonValue(input);
38
+ }
39
+ catch (error) {
40
+ if (error instanceof JsonBoundaryError) {
41
+ throw new SchemaError([diagnostic('DV_JSON_VALUE', error.pointer, error.message)]);
42
+ }
43
+ throw error;
44
+ }
45
+ const callable = parseCallableContract(value);
46
+ const environment = ownerEnvironment(owner);
47
+ const { receiver } = options;
48
+ if (receiver !== undefined) {
49
+ const resolved = environment.resolution.resolve(receiver);
50
+ if (resolved === undefined ||
51
+ resolved.ref.kind !== 'class' ||
52
+ resolved.kind !== 'node' ||
53
+ definitionRefIndex(resolved.ref) !== definitionRefIndex(receiver) ||
54
+ receiver.origin !== owner.origin) {
55
+ throw new SchemaError([
56
+ diagnostic('DV_REF_RESOLVES', '', 'A receiver must be a Node Class of the owner Domain.'),
57
+ ]);
58
+ }
59
+ }
60
+ const issues = [];
61
+ validateContract(callable, '', environment.registry, issues);
62
+ if (typeof callable.policy === 'object') {
63
+ const policies = new PolicyValidationContext(environment.resolution, environment.analysis);
64
+ // Normalizes the owner's named Policies, which the Policy's checks are typed against.
65
+ validatePolicyReferences(policies);
66
+ validateContractPolicy(policies, new PolicyTyping(policies), callable, '', receiver);
67
+ // A document measures its own check trees (`validatePolicyBudgets`); this one is in none.
68
+ validateCheckBudget(policies, '/policy', measureChecks(normalizePolicyChecks(callable.policy)));
69
+ issues.push(...policies.diagnostics);
70
+ }
71
+ if (issues.length > 0)
72
+ throw new SchemaError(issues);
73
+ const definition = deepFreeze(canonicalizeCallable(callable));
74
+ const validation = callableValidation(isBinaryInput(definition.input) ? definition.input.metadata : definition.input, definition.output.mode === 'binary'
75
+ ? undefined
76
+ : definition.output.mode === 'value'
77
+ ? definition.output.schema
78
+ : definition.output.item, environment.registry,
79
+ // Patterns live with these validators: carried contracts never grow a process-wide pool.
80
+ new Map());
81
+ return Object.freeze({ ...validation, definition });
82
+ }
83
+ function ownerEnvironment(owner) {
84
+ const cached = environments.get(owner);
85
+ if (cached !== undefined)
86
+ return cached;
87
+ const lookup = lookupForDomainClosure(owner);
88
+ const resolution = buildDomainResolutionContext(owner, lookup);
89
+ const environment = Object.freeze({
90
+ resolution,
91
+ analysis: analyzeDefinitions(resolution),
92
+ registry: createDomainValueSchemaRegistry(owner, lookup),
93
+ });
94
+ environments.set(owner, environment);
95
+ return environment;
96
+ }
@@ -40,6 +40,10 @@ export interface DefinitionAnalysisResult {
40
40
  readonly definitions: ReadonlyMap<string, DefinitionAnalysis>;
41
41
  readonly diagnostics: readonly SchemaDiagnostic[];
42
42
  }
43
+ /**
44
+ * Compose every Class from its parents, unless a chain of parents is past its limit: then nothing
45
+ * is composed, since composing holds each Class's ancestors and walks them on the call stack.
46
+ */
43
47
  export declare function analyzeDefinitions(environment: DomainResolutionContext): DefinitionAnalysisResult;
44
48
  /** The exact signature required by abstract Method composition. */
45
49
  export declare function sameMethodSignature(left: MethodDefinition, right: MethodDefinition): boolean;
@@ -1,41 +1,72 @@
1
- import { json } from '@astrale-os/kernel-dsl/value';
1
+ import { equal } from '@astrale-os/kernel-dsl/value';
2
2
  import { Key, PropertyKey } from '../../addressing/index.js';
3
3
  import { definitionRefIndex } from '../../addressing/ordering.js';
4
4
  import { composeMethods } from '../../language/callable/composition.js';
5
+ import { chainDepths } from '../../language/chain.js';
6
+ import { limits } from '../../language/limits.js';
5
7
  import { canonicalizeValueSchema } from '../../language/value/profile/canonicalize.js';
8
+ import { escapePointerToken } from '../../language/value/syntax/pointer.js';
6
9
  import { diagnostic } from '../diagnostic.js';
7
10
  const formatDefinitionRef = Key.of;
11
+ /**
12
+ * A refusal at each Class past the limit. A dependency was accepted under the same limit and each
13
+ * of its Classes reads only its own closure, so such a Class is always one of the candidate. A
14
+ * direct parent is at depth 1. Every other walk of inheritance runs on the call stack, under this.
15
+ */
16
+ function validateInheritanceDepth(environment) {
17
+ const depths = chainDepths(environment.definitions.values(), ({ declaration }) => declaration.extends.flatMap((parent) => environment.resolveAny(parent) ?? []));
18
+ return [...depths].flatMap(([{ ref }, depth]) => depth > limits.inheritance.depth
19
+ ? [
20
+ diagnostic('DV_INHERITANCE_LIMITS', `/classes/${escapePointerToken(ref.name)}/extends`, `Class ${formatDefinitionRef(ref)} has ${depth} parents on its longest chain, over the maximum ${limits.inheritance.depth}.`),
21
+ ]
22
+ : []);
23
+ }
24
+ /**
25
+ * Compose every Class from its parents, unless a chain of parents is past its limit: then nothing
26
+ * is composed, since composing holds each Class's ancestors and walks them on the call stack.
27
+ */
8
28
  export function analyzeDefinitions(environment) {
29
+ const pastLimit = validateInheritanceDepth(environment);
30
+ if (pastLimit.length > 0)
31
+ return Object.freeze({ definitions: new Map(), diagnostics: Object.freeze(pastLimit) });
9
32
  const diagnostics = [];
10
33
  const result = new Map();
11
34
  const visiting = new Set();
35
+ // A dependency was accepted against this same exact closure: a rule breaks here only at a Class
36
+ // of the candidate, or on an incomplete closure, which the dependency diagnostics report. An
37
+ // unresolved parent is reported where the candidate names it, by Class validation.
38
+ const reporter = (owner) => (code, at, message, ref) => {
39
+ if (owner.origin !== environment.candidate.origin)
40
+ return;
41
+ const pointer = `/classes/${escapePointerToken(owner.name)}${at}`;
42
+ diagnostics.push(diagnostic(code, pointer, message, ref));
43
+ };
12
44
  const analyze = (ref) => {
13
45
  const key = definitionRefIndex(ref);
14
46
  const cached = result.get(key);
15
47
  if (cached !== undefined)
16
48
  return cached;
17
- if (visiting.has(key)) {
18
- diagnostics.push(diagnostic('DV_CLASS_ACYCLIC', '', `Inheritance cycle reaches ${formatDefinitionRef(ref)}.`, formatDefinitionRef(ref)));
19
- return undefined;
20
- }
21
49
  const resolved = environment.resolveAny(ref);
22
50
  if (resolved === undefined)
23
51
  return undefined;
24
52
  visiting.add(key);
53
+ const report = reporter(ref);
25
54
  const declaration = resolved.declaration;
26
55
  const parents = declaration.extends;
27
- const parentAnalyses = parents.flatMap((parent) => {
56
+ const parentAnalyses = parents.flatMap((parent, index) => {
28
57
  const target = environment.resolveAny(parent);
29
- if (target === undefined) {
30
- diagnostics.push(diagnostic('DV_REF_RESOLVES', '', `Inheritance ref ${formatDefinitionRef(parent)} does not resolve.`, formatDefinitionRef(parent)));
58
+ if (target?.ref.kind !== 'class')
59
+ return [];
60
+ if (visiting.has(definitionRefIndex(target.ref))) {
61
+ report('DV_CLASS_ACYCLIC', `/extends/${index}`, `Inheritance cycle reaches ${formatDefinitionRef(parent)}.`, formatDefinitionRef(parent));
31
62
  return [];
32
63
  }
33
- const analysis = target.ref.kind === 'class' ? analyze(target.ref) : undefined;
64
+ const analysis = analyze(target.ref);
34
65
  return analysis === undefined ? [] : [analysis];
35
66
  });
36
67
  const properties = mergeFields(parentAnalyses.map((parent) => parent.properties), ownFields(ref, declaration));
37
- const data = mergeData(ref, declaration, parentAnalyses, diagnostics);
38
- const methods = mergeMethods(ref, declaration, parentAnalyses, diagnostics);
68
+ const data = mergeData(ref, declaration, parentAnalyses, report);
69
+ const methods = mergeMethods(ref, declaration, parentAnalyses, report);
39
70
  const analysis = {
40
71
  ref,
41
72
  declaration,
@@ -82,7 +113,7 @@ function mergeFields(inherited, own) {
82
113
  }
83
114
  return result;
84
115
  }
85
- function mergeData(owner, declaration, parents, diagnostics) {
116
+ function mergeData(owner, declaration, parents, report) {
86
117
  let effective;
87
118
  for (const parent of parents) {
88
119
  if (parent.data === undefined)
@@ -92,14 +123,15 @@ function mergeData(owner, declaration, parents, diagnostics) {
92
123
  continue;
93
124
  }
94
125
  if (effective.identity !== parent.data.identity) {
95
- diagnostics.push(diagnostic('DV_DATA_COMPOSITION', '', `Data has distinct declaring owners ${formatDefinitionRef(effective.owner)} and ${formatDefinitionRef(parent.data.owner)}.`));
126
+ const index = declaration.extends.findIndex((ref) => definitionRefIndex(ref) === definitionRefIndex(parent.ref));
127
+ report('DV_DATA_COMPOSITION', `/extends/${index}`, `Data has distinct declaring owners ${formatDefinitionRef(effective.owner)} and ${formatDefinitionRef(parent.data.owner)}.`);
96
128
  }
97
129
  }
98
130
  const own = 'data' in declaration ? declaration.data : undefined;
99
131
  if (own === undefined)
100
132
  return effective;
101
133
  if (effective !== undefined) {
102
- diagnostics.push(diagnostic('DV_DATA_COMPOSITION', '', `Data redeclares the inherited contract from ${formatDefinitionRef(effective.owner)}.`));
134
+ report('DV_DATA_COMPOSITION', '/data', `Data redeclares the inherited contract from ${formatDefinitionRef(effective.owner)}.`);
103
135
  }
104
136
  return {
105
137
  identity: `${definitionRefIndex(owner)}\u0000data`,
@@ -107,16 +139,24 @@ function mergeData(owner, declaration, parents, diagnostics) {
107
139
  declaration: own,
108
140
  };
109
141
  }
110
- function mergeMethods(owner, declaration, parents, diagnostics) {
142
+ function mergeMethods(owner, declaration, parents, report) {
111
143
  const own = new Map(Object.entries('methods' in declaration ? declaration.methods : {}).map(([name, method]) => [
112
144
  name,
113
145
  { key: `${Key.of(owner)}.method.${name}`, owner, name, declaration: method },
114
146
  ]));
115
- return composeMethods(parents, own, declaration.abstract, (left, right) => sameMethodSignature(left.declaration, right.declaration), (message) => diagnostics.push(diagnostic('DV_METHOD_COMPOSITION', '', message, Key.of(owner))));
147
+ return composeMethods(parents, own, declaration.abstract, (left, right) => sameMethodSignature(left.declaration, right.declaration),
148
+ // A changed signature is the local Method's; an ambiguous or missing one needs a local Method.
149
+ (message, issue) => {
150
+ const local = issue.kind === 'signature'
151
+ ? [...own.values()].find(({ key }) => key === issue.local)
152
+ : undefined;
153
+ const at = local === undefined ? '/methods' : `/methods/${escapePointerToken(local.name)}`;
154
+ report('DV_METHOD_COMPOSITION', at, message, Key.of(owner));
155
+ });
116
156
  }
117
157
  /** The exact signature required by abstract Method composition. */
118
158
  export function sameMethodSignature(left, right) {
119
- return json.serialize(methodSignature(left)) === json.serialize(methodSignature(right));
159
+ return equal(methodSignature(left), methodSignature(right));
120
160
  }
121
161
  /**
122
162
  * Shared canonical signature used by admission and compatibility explanations. The execution
@@ -6,7 +6,10 @@ interface CanonicalDomainSchema {
6
6
  readonly revision: Revision;
7
7
  }
8
8
  export declare function canonicalDomainSchema(value: DomainSchema): CanonicalDomainSchema;
9
- /** Internal acceptance seam. The caller must establish whole-Domain validity first. */
9
+ /**
10
+ * Internal acceptance seam. The caller must establish the structure first; canonicalization judges
11
+ * nothing further, so the result is an accepted Schema only once whole-Domain validity holds too.
12
+ */
10
13
  export declare function canonicalDomainSchemaAfterValidation(value: DomainSchemaIR): CanonicalDomainSchema;
11
14
  export declare function revisionOfDomainSchema(schema: DomainSchema): Revision;
12
15
  export {};
@@ -1,17 +1,20 @@
1
1
  import { json } from '@astrale-os/kernel-dsl/value';
2
+ import { digestRevisionBytes } from '../../addressing/revision.js';
2
3
  import { asDomainSchema } from '../model/schema.js';
3
- import { digestDomainSchemaBytes } from './domain.digest.js';
4
- import { canonicalizeDomainSchema } from './domain.js';
4
+ import { normalizeDomainSchema } from '../normalization/domain.js';
5
5
  // Only canonical schemas created here own a retained revision, never caller-owned input.
6
6
  const revisions = new WeakMap();
7
7
  export function canonicalDomainSchema(value) {
8
8
  return canonicalDomainSchemaAfterValidation(value);
9
9
  }
10
- /** Internal acceptance seam. The caller must establish whole-Domain validity first. */
10
+ /**
11
+ * Internal acceptance seam. The caller must establish the structure first; canonicalization judges
12
+ * nothing further, so the result is an accepted Schema only once whole-Domain validity holds too.
13
+ */
11
14
  export function canonicalDomainSchemaAfterValidation(value) {
12
- const schema = asDomainSchema(canonicalizeDomainSchema(value));
15
+ const schema = asDomainSchema(normalizeDomainSchema(value));
13
16
  const bytes = json.encode(schema);
14
- const revision = digestDomainSchemaBytes(bytes);
17
+ const revision = digestRevisionBytes(bytes);
15
18
  revisions.set(schema, revision);
16
19
  return Object.freeze({ schema, bytes, revision });
17
20
  }
@@ -1,3 +1,6 @@
1
1
  export { compare, compareMeaning, compareStructure } from './compare.js';
2
+ export { closedParents } from './extension.js';
3
+ export { COMPARISON_RULES as RULES } from './rule.js';
4
+ export type { ComparisonRule as Rule } from './rule.js';
2
5
  export { requiredBump } from './versioning/index.js';
3
- export type { Analysis, Assessment, Bump, Comparison, ComparisonEntry, ComparisonEvidence, ComparisonRequest, ComparisonScope, Facet, Fingerprint, MeaningComparison, Observation, RequiredBump, SchemaIdentity, StructureComparison, Subject, Usage, VersionChange, } from './model.js';
6
+ export type { Analysis, Assessment, Bump, Comparison, ComparisonEntry, ComparisonEvidence, ComparisonRequest, ComparisonScope, DiagnosticCode, Facet, Fingerprint, MeaningComparison, Observation, RequiredBump, SchemaIdentity, StructureComparison, Subject, Usage, VersionChange, } from './model.js';
@@ -1,2 +1,4 @@
1
1
  export { compare, compareMeaning, compareStructure } from './compare.js';
2
+ export { closedParents } from './extension.js';
3
+ export { COMPARISON_RULES as RULES } from './rule.js';
2
4
  export { requiredBump } from './versioning/index.js';
@@ -1,7 +1,7 @@
1
1
  import { isMethodExecutable } from '../../../language/callable/executable.js';
2
2
  import { isBinaryInput } from '../../../language/callable/model/callable.js';
3
+ import { deepFreeze } from '../../../language/freeze.js';
3
4
  import { methodSignature as inheritedSignature } from '../../analysis/class.js';
4
- import { deepFreeze } from '../../canonical/freeze.js';
5
5
  import { keyForDefinitionRef } from '../coordinate.js';
6
6
  import { CALLABLE_FIELDS, fieldsOf } from '../fields.js';
7
7
  import { fingerprintMeaning, semanticValueSchema } from './values.js';
@@ -1,5 +1,6 @@
1
1
  import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
2
  import type { Key as SemanticKey } from '../../../addressing/index.js';
3
+ import type { Inheritance } from '../../../language/class/model/class.js';
3
4
  import type { EffectiveField } from '../../analysis/class.js';
4
5
  import type { Context } from '../context.js';
5
6
  import type { ClassCoordinate } from '../coordinate.js';
@@ -10,10 +11,12 @@ interface ClassRequirement {
10
11
  readonly ancestors: readonly SemanticKey[];
11
12
  }
12
13
  /**
13
- * A reference needs the Class to exist with its kind, abstractness and orientation; inheritance
14
- * additionally takes on the source ancestors, class policies, data contract and, for an Edge, the
15
- * endpoint and constraint contracts. A target projected onto a source requirement keeps only the
16
- * ancestors the source named, so a superset satisfies it while a removal changes it.
14
+ * A reference needs the Class to exist with its kind, abstractness and orientation, and, for an
15
+ * Edge, the uniqueness tuples that cover it, its ancestors' included: a dependent may name one of
16
+ * its Edges by any of them. Inheritance additionally takes on the source ancestors, class
17
+ * policies, data contract and, for an Edge, the endpoint and constraint contracts. A target
18
+ * projected onto a source requirement keeps only the ancestors the source named, so a superset
19
+ * satisfies it while a removal changes it.
17
20
  */
18
21
  export declare function classMeaning(context: Context, coordinate: ClassCoordinate, level: DependencyMeaningLevel, onto?: ClassRequirement): {
19
22
  readonly meaning: JsonValue;
@@ -38,6 +41,8 @@ export declare function compareLostProperties({ pair, report, }: {
38
41
  readonly pair: SubjectPair;
39
42
  readonly report: Report;
40
43
  }): void;
44
+ /** Which Classes may extend a Class, as an extension facet compares it. */
45
+ export declare function inheritanceMeaning(inheritance: Inheritance): JsonValue;
41
46
  /** Newly required data is an obligation even though it was absent from the source footprint. */
42
47
  export declare function compareAddedProperties({ context, pair, report, }: {
43
48
  readonly context: ComparisonContext;
@@ -1,6 +1,7 @@
1
1
  import { compareUnicode } from '../../../addressing/ordering.js';
2
+ import { compareEdgeUniqueTuples, coveringEdgeUniqueTuples, } from '../../../language/class/unique.js';
3
+ import { deepFreeze } from '../../../language/freeze.js';
2
4
  import { isClassRuleChecks } from '../../../language/policy/model/policy.js';
3
- import { deepFreeze } from '../../canonical/freeze.js';
4
5
  import { effectiveDefinition } from '../context.js';
5
6
  import { propertyCoordinate } from '../coordinate.js';
6
7
  import { keyForDefinitionRef } from '../coordinate.js';
@@ -8,10 +9,12 @@ import { CLASS_FIELDS, PROPERTY_FIELDS, fieldsOf } from '../fields.js';
8
9
  import { usageOf } from '../references.js';
9
10
  import { semanticValueSchema } from './values.js';
10
11
  /**
11
- * A reference needs the Class to exist with its kind, abstractness and orientation; inheritance
12
- * additionally takes on the source ancestors, class policies, data contract and, for an Edge, the
13
- * endpoint and constraint contracts. A target projected onto a source requirement keeps only the
14
- * ancestors the source named, so a superset satisfies it while a removal changes it.
12
+ * A reference needs the Class to exist with its kind, abstractness and orientation, and, for an
13
+ * Edge, the uniqueness tuples that cover it, its ancestors' included: a dependent may name one of
14
+ * its Edges by any of them. Inheritance additionally takes on the source ancestors, class
15
+ * policies, data contract and, for an Edge, the endpoint and constraint contracts. A target
16
+ * projected onto a source requirement keeps only the ancestors the source named, so a superset
17
+ * satisfies it while a removal changes it.
15
18
  */
16
19
  export function classMeaning(context, coordinate, level, onto) {
17
20
  const owner = context.schemas.get(coordinate.ref.origin);
@@ -23,40 +26,42 @@ export function classMeaning(context, coordinate, level, onto) {
23
26
  const requirement = Object.freeze({
24
27
  ancestors,
25
28
  });
26
- const meaning = {
27
- coordinate: 'class',
28
- level: level,
29
- ...fieldsOf({ declaration, roles: CLASS_FIELDS, level }),
30
- ...(level === 'inherit'
29
+ const covering = coveringTuples(context, declaration);
30
+ // The fields whose meaning is not their declared value; `CLASS_FIELDS` decides which count.
31
+ const normalized = {
32
+ ...declaration,
33
+ extends: onto === undefined
34
+ ? ancestors
35
+ : onto.ancestors.filter((ancestor) => ancestors.includes(ancestor)),
36
+ policies: Object.fromEntries(Object.entries(declaration.policies)
37
+ .filter(([, policy]) => policy !== undefined)
38
+ .map(([role, policy]) => [role, classPolicyMeaning(policy)])),
39
+ ...(declaration.kind === 'node'
31
40
  ? {
32
- extends: onto === undefined
33
- ? ancestors
34
- : onto.ancestors.filter((ancestor) => ancestors.includes(ancestor)),
35
- policies: Object.fromEntries(Object.entries(declaration.policies)
36
- .filter(([, policy]) => policy !== undefined)
37
- .map(([role, policy]) => [role, classPolicyMeaning(policy)])),
38
- ...(declaration.kind === 'node'
39
- ? {
40
- data: analysis.data === undefined
41
- ? null
42
- : {
43
- owner: keyForDefinitionRef(analysis.data.owner),
44
- declaration: analysis.data.declaration,
45
- },
46
- }
47
- : { endpoints: declaration.endpoints, constraints: declaration.constraints }),
41
+ data: analysis.data === undefined
42
+ ? null
43
+ : {
44
+ owner: keyForDefinitionRef(analysis.data.owner),
45
+ declaration: analysis.data.declaration,
46
+ },
48
47
  }
49
48
  : {}),
49
+ ...(covering.length === 0 ? {} : { unique: covering }),
50
+ };
51
+ const meaning = {
52
+ coordinate: 'class',
53
+ level: level,
54
+ ...fieldsOf({ declaration: normalized, roles: CLASS_FIELDS, level }),
50
55
  };
51
56
  return { meaning: deepFreeze(meaning), requirement };
52
57
  }
53
58
  /**
54
- * A named Policy compares by its key; `false` or Policy checks by their value, as a callable's
59
+ * A named Policy compares by its key; a constant or Policy checks by their value, as a callable's
55
60
  * Policy does.
56
61
  */
57
62
  function classPolicyMeaning(policy) {
58
- if (policy === false)
59
- return false;
63
+ if (typeof policy === 'boolean')
64
+ return policy;
60
65
  return isClassRuleChecks(policy) ? policy : keyForDefinitionRef(policy);
61
66
  }
62
67
  /**
@@ -109,6 +114,18 @@ function ancestorKeys(context, ref) {
109
114
  visit(ref);
110
115
  return [...seen].sort(compareUnicode);
111
116
  }
117
+ /**
118
+ * The uniqueness tuples covering an Edge Class (`coveringEdgeUniqueTuples`): those it and each of
119
+ * its ancestors declare, each with the Class declaring it, whose extent it bounds, in Class then
120
+ * tuple order. A Node Class's own tuples stay its declared field.
121
+ */
122
+ function coveringTuples(context, declaration) {
123
+ if (declaration.kind !== 'edge')
124
+ return [];
125
+ return [
126
+ ...coveringEdgeUniqueTuples(declaration, (ref) => context.schemas.get(ref.origin)?.classes[ref.name]),
127
+ ].sort((left, right) => compareUnicode(left.class, right.class) || compareEdgeUniqueTuples(left.fields, right.fields));
128
+ }
112
129
  /**
113
130
  * A Class a dependent references or inherits keeps every effective Property it had, whichever
114
131
  * ancestor declares it. Each Property is compared on its owner, which still declares it when the
@@ -139,6 +156,10 @@ function propertyIdentities(identities) {
139
156
  properties: Object.fromEntries(identities.map((identity) => [identity, true])),
140
157
  });
141
158
  }
159
+ /** Which Classes may extend a Class, as an extension facet compares it. */
160
+ export function inheritanceMeaning(inheritance) {
161
+ return deepFreeze({ coordinate: 'class', inheritance });
162
+ }
142
163
  /** Newly required data is an obligation even though it was absent from the source footprint. */
143
164
  export function compareAddedProperties({ context, pair, report, }) {
144
165
  if (pair.source?.kind !== 'class' || pair.target?.kind !== 'class')
@@ -5,7 +5,7 @@ import type { ComparisonContext, SubjectPair } from '../scope.js';
5
5
  export declare function compareFacet({ context, pair, facet, }: {
6
6
  readonly context: ComparisonContext;
7
7
  readonly pair: SubjectPair;
8
- readonly facet: Exclude<Facet, 'class.composition' | 'class.properties' | 'property.required'>;
8
+ readonly facet: Exclude<Facet, 'class.composition' | 'class.properties' | 'class.inheritance' | 'property.required'>;
9
9
  }): {
10
10
  readonly before?: Value;
11
11
  readonly after?: Value;
@@ -1,4 +1,4 @@
1
- import { deepFreeze } from '../../canonical/freeze.js';
1
+ import { deepFreeze } from '../../../language/freeze.js';
2
2
  import { CORE_FIELDS, POLICY_FIELDS, VIEW_FIELDS, fieldsOf } from '../fields.js';
3
3
  import { functionSignature } from './callables.js';
4
4
  export function memberMeaning(owner, ref) {
@@ -1,7 +1,7 @@
1
1
  import { json } from '@astrale-os/kernel-dsl/value';
2
+ import { digestRevisionBytes } from '../../../addressing/revision.js';
2
3
  import { isValueObject as isJsonObject } from '../../../language/value/model/object.js';
3
4
  import { SCHEMA_ARRAY_KEYWORDS, SCHEMA_MAP_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, } from '../../../language/value/syntax/keywords.js';
4
- import { digestDomainSchemaBytes } from '../../canonical/domain.digest.js';
5
5
  import { ANNOTATION_KEYWORDS } from '../fields.js';
6
6
  /** Drop annotation keywords wherever a schema keyword nests a schema; never inside data. */
7
7
  export function semanticValueSchema(value) {
@@ -30,7 +30,7 @@ export function semanticValueSchema(value) {
30
30
  return semantic;
31
31
  }
32
32
  export function fingerprintMeaning(value) {
33
- return digestDomainSchemaBytes(json.encode(value));
33
+ return digestRevisionBytes(json.encode(value));
34
34
  }
35
35
  function isJsonSchema(value) {
36
36
  return typeof value === 'boolean' || isJsonObject(value);
@@ -1,7 +1,6 @@
1
1
  import type { ClassRef, DefinitionRef, Key as SemanticKey } from '../../addressing/index.js';
2
2
  import type { DefinitionAnalysis, EffectiveMethod } from '../analysis/class.js';
3
3
  import type { DomainSchema } from '../model/schema.js';
4
- import { SchemaError } from '../diagnostic.js';
5
4
  /** One accepted root with its exact closure and a memoized Definition analysis per owner. */
6
5
  export interface Context {
7
6
  readonly schemas: ReadonlyMap<string, DomainSchema>;
@@ -16,4 +15,8 @@ export declare function effectiveDefinition(context: Context, owner: DomainSchem
16
15
  /** Effective Methods are keyed by name; a coordinate names one by its exact Method Key. */
17
16
  export declare function effectiveMethod(analysis: DefinitionAnalysis, key: SemanticKey): EffectiveMethod | undefined;
18
17
  export declare function requireOwner(context: Context, ref: DefinitionRef, key: SemanticKey): DomainSchema;
19
- export declare function contextInvalid(message: string, key: SemanticKey): SchemaError;
18
+ /**
19
+ * Acceptance proved every reference of a Domain against the closure it retains, so what a comparison
20
+ * reaches from one has a meaning there. Its absence is a defect here and no answer about a document.
21
+ */
22
+ export declare function retainedContextDefect(key: SemanticKey): TypeError;
@@ -1,7 +1,6 @@
1
1
  import { MethodKey } from '../../addressing/index.js';
2
2
  import { definitionRefIndex } from '../../addressing/ordering.js';
3
3
  import { analyzeDefinitions } from '../analysis/class.js';
4
- import { SchemaError, diagnostic } from '../diagnostic.js';
5
4
  import { knownDomainClosure, lookupForDomainClosure } from '../resolution/closure.js';
6
5
  import { buildDomainResolutionContext } from '../resolution/context.js';
7
6
  /**
@@ -39,11 +38,14 @@ export function effectiveMethod(analysis, key) {
39
38
  }
40
39
  export function requireOwner(context, ref, key) {
41
40
  const owner = context.schemas.get(ref.origin);
42
- if (owner === undefined) {
43
- throw contextInvalid(`Retained acceptance context cannot resolve ${key}.`, key);
44
- }
41
+ if (owner === undefined)
42
+ throw retainedContextDefect(key);
45
43
  return owner;
46
44
  }
47
- export function contextInvalid(message, key) {
48
- return new SchemaError([diagnostic('DM_DEPENDENCY_CONTEXT_INVALID', '', message, key)]);
45
+ /**
46
+ * Acceptance proved every reference of a Domain against the closure it retains, so what a comparison
47
+ * reaches from one has a meaning there. Its absence is a defect here and no answer about a document.
48
+ */
49
+ export function retainedContextDefect(key) {
50
+ return new TypeError(`Retained acceptance context has no meaning for ${key}.`);
49
51
  }
@@ -20,10 +20,10 @@ export function keyForDefinitionRef(ref) {
20
20
  /** Interpret one canonical V1 Key as a Definition or a Class member location. */
21
21
  export function keyReference(key) {
22
22
  const semantic = key.slice(key.indexOf(':') + 1);
23
+ // A Core slug may hold `.`: the name of a Core key is the whole rest of its coordinate.
24
+ if (semantic.startsWith('core.'))
25
+ return { kind: 'core', name: semantic.slice('core.'.length) };
23
26
  const parts = semantic.split('.');
24
- if (parts[0] === 'core' && parts.length === 2) {
25
- return { kind: 'core', name: parts[1] };
26
- }
27
27
  if (parts.length === 2) {
28
28
  return { kind: parts[0], name: parts[1] };
29
29
  }