@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,9 +1,15 @@
1
- import { json } from '@astrale-os/kernel-dsl/value';
1
+ import { equal } from '@astrale-os/kernel-dsl/value';
2
2
  import { Key } from '../../../addressing/index.js';
3
+ import { limits } from '../../../language/limits.js';
3
4
  import { normalizeClassRule } from '../../../language/policy/normalization/normalize.js';
4
- import { invalid, pointer } from '../diagnostic.js';
5
+ import { invalid, pointer, POLICY_CHECK_SITE } from '../diagnostic.js';
5
6
  import { definitionRef, policyObjectRef } from './reference.js';
6
7
  import { object, exact, description, array, unique, boundedInteger, integer, memberName, } from './value.js';
8
+ /**
9
+ * The nesting a decoder follows before refusing: a structural guard for the recursion, far above
10
+ * the depths `limits.policy` admits, which the semantic checks enforce.
11
+ */
12
+ const WIRE_DEPTH = 64;
7
13
  /** Decode a named Policy and its expression grammar. */
8
14
  export function compiledPolicy(input, path) {
9
15
  const value = object(input, 'Policy', path);
@@ -14,7 +20,7 @@ export function compiledPolicy(input, path) {
14
20
  return value;
15
21
  }
16
22
  function policyExpression(input, depth, path) {
17
- if (depth > 64)
23
+ if (depth > WIRE_DEPTH)
18
24
  invalid('Policy expression depth', undefined, path);
19
25
  const value = object(input, 'Policy expression', path);
20
26
  if (Object.hasOwn(value, 'match')) {
@@ -31,7 +37,7 @@ function policyExpression(input, depth, path) {
31
37
  unique(refs.map(Key.of), `Policy ${member}`, memberPath);
32
38
  }
33
39
  function policyPattern(input, depth, path) {
34
- if (depth > 64)
40
+ if (depth > WIRE_DEPTH)
35
41
  invalid('Policy pattern depth', undefined, path);
36
42
  const value = object(input, 'Policy pattern', path);
37
43
  if (Object.hasOwn(value, 'sameNode')) {
@@ -49,7 +55,7 @@ function policyPattern(input, depth, path) {
49
55
  exact(exists, ['nodes', 'where'], 'Policy exists', existsPath);
50
56
  const nodesPath = `${existsPath}/nodes`;
51
57
  const nodes = array(exists.nodes, 'Policy variables', nodesPath);
52
- if (nodes.length < 1 || nodes.length > 4)
58
+ if (nodes.length < 1 || nodes.length > limits.policy.variablesPerExists)
53
59
  invalid('Policy variables', undefined, nodesPath);
54
60
  for (const [index, node] of nodes.entries()) {
55
61
  const variablePath = `${nodesPath}/${index}`;
@@ -97,8 +103,9 @@ function policyPattern(input, depth, path) {
97
103
  const repeatPath = `${path}/repeat`;
98
104
  const repeat = object(value.repeat, 'Policy repeat', repeatPath);
99
105
  exact(repeat, ['min', 'max'], 'Policy repeat', repeatPath);
100
- const minimum = boundedInteger(repeat.min, 0, 3, 'Policy repeat minimum', `${repeatPath}/min`);
101
- const maximum = boundedInteger(repeat.max, 0, 3, 'Policy repeat maximum', `${repeatPath}/max`);
106
+ const { repetition } = limits.policy;
107
+ const minimum = boundedInteger(repeat.min, 0, repetition, 'Policy repeat minimum', `${repeatPath}/min`);
108
+ const maximum = boundedInteger(repeat.max, 0, repetition, 'Policy repeat maximum', `${repeatPath}/max`);
102
109
  if (minimum > maximum)
103
110
  invalid('Policy repeat order', undefined, repeatPath);
104
111
  }
@@ -130,25 +137,25 @@ export function callablePolicy(input, path) {
130
137
  policyCheck(input, 0, path);
131
138
  }
132
139
  /**
133
- * Check one Node Class rule: Policy checks over `self` and `ref` objects only, in their one
134
- * spelling. A lone check of `self` is spelled as the Policy reference itself.
140
+ * Check one Class rule: Policy checks over `self` and `ref` objects only, or, in a Node create
141
+ * rule, `ref` objects only, in their one spelling. A lone check of `self` is spelled as the Policy
142
+ * reference itself.
135
143
  */
136
- export function classRuleChecks(input, path) {
137
- policyCheck(input, 0, path, 'class');
138
- const rule = input;
139
- if (json.serialize(normalizeClassRule(rule)) !== json.serialize(rule))
144
+ export function classRuleChecks(input, path, site) {
145
+ policyCheck(input, 0, path, site);
146
+ const normalized = normalizeClassRule(input);
147
+ if (!equal(normalized, input)) {
140
148
  invalid('Class rule spelling', undefined, path);
149
+ }
141
150
  }
142
- /** What a site calls its checks in a refusal. */
143
- const SITE = { callable: 'Callable Policy', class: 'Class rule' };
144
151
  /** Check the recursive Policy check wire grammar of one use site. */
145
152
  function policyCheck(input, depth, path, site = 'callable') {
146
- const name = SITE[site];
147
- if (depth > 64)
153
+ const { name } = POLICY_CHECK_SITE[site];
154
+ if (depth > WIRE_DEPTH)
148
155
  invalid(`${name} depth`, undefined, path);
149
156
  const value = object(input, name, path);
150
157
  if (Object.hasOwn(value, 'sameNode')) {
151
- const equality = site === 'class' ? 'Class rule equality' : 'Callable equality';
158
+ const equality = site === 'callable' ? 'Callable equality' : `${name} equality`;
152
159
  exact(value, ['sameNode'], equality, path);
153
160
  const pair = object(value.sameNode, equality, `${path}/sameNode`);
154
161
  exact(pair, ['left', 'right'], `${equality} operands`, `${path}/sameNode`);
@@ -172,9 +179,9 @@ function policyCheck(input, depth, path, site = 'callable') {
172
179
  policyCheck(expression, depth + 1, `${memberPath}/${index}`, site);
173
180
  }
174
181
  function policyCheckObject(input, objectPath, site) {
175
- const name = SITE[site];
182
+ const { name } = POLICY_CHECK_SITE[site];
176
183
  const target = object(input, `${name} object`, objectPath);
177
- if (target.kind === 'self')
184
+ if (target.kind === 'self' && site !== 'create')
178
185
  exact(target, ['kind'], `${name} self`, objectPath);
179
186
  else if (target.kind === 'input' && site === 'callable') {
180
187
  exact(target, ['kind', 'field'], `${name} input`, objectPath);
@@ -1,4 +1,14 @@
1
1
  import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
- import { type Pattern, type RunPattern, type IndexedValueProgram } from '../../model/schema.js';
3
- /** Decode a value program and validate its local node and pattern indices. */
4
- export declare function program(input: JsonValue, programIndex: number, path: string, table: readonly (Pattern | RunPattern)[]): IndexedValueProgram;
2
+ import { type Pattern, type RunPattern, type ValueProgram } from '../../model/schema.js';
3
+ /** The machine compiled from each admitted I-Regexp source, shared by its occurrences. */
4
+ export type Machines = Map<string, Pattern | RunPattern>;
5
+ /**
6
+ * Read a value program as its root schema, the one node the revision covers. JSON gives its members
7
+ * no order, so they are put back in the order the compiler walks. Its graph and its machines are what
8
+ * that schema derives, with the derivation the compiler emits them from. The rest of a received
9
+ * program, and the pattern table of its entry, may come from another compiler, from a host with other
10
+ * Unicode data, or from a forger, and the artifact carries no compiler version that could tell those
11
+ * apart, so they are ignored rather than compared. Generated material executes them without this
12
+ * admission.
13
+ */
14
+ export declare function program(input: JsonValue, programIndex: number, path: string, machines: Machines): ValueProgram;
@@ -1,52 +1,47 @@
1
1
  import {} from '@astrale-os/kernel-dsl/value';
2
- import { isValueObject } from '../../../language/value/model/object.js';
2
+ import { deriveValueGraph } from '../../../language/value/evaluate/preparation.js';
3
+ import { canonicalizeSchemaMembers } from '../../../language/value/profile/canonicalize.js';
4
+ import { compilePattern } from '../../../language/value/regexp/compile.js';
5
+ import { isIRegexp } from '../../../language/value/regexp/syntax.js';
6
+ import { isJsonSchema } from '../../../language/value/syntax/walk.js';
3
7
  import {} from '../../model/schema.js';
4
- import { invalid, pointer } from '../diagnostic.js';
5
- import { object, exact, array, index, unique, integer } from './value.js';
6
- /** Decode a value program and validate its local node and pattern indices. */
7
- export function program(input, programIndex, path, table) {
8
+ import { fail, invalid } from '../diagnostic.js';
9
+ import { object, array, index } from './value.js';
10
+ /**
11
+ * Read a value program as its root schema, the one node the revision covers. JSON gives its members
12
+ * no order, so they are put back in the order the compiler walks. Its graph and its machines are what
13
+ * that schema derives, with the derivation the compiler emits them from. The rest of a received
14
+ * program, and the pattern table of its entry, may come from another compiler, from a host with other
15
+ * Unicode data, or from a forger, and the artifact carries no compiler version that could tell those
16
+ * apart, so they are ignored rather than compared. Generated material executes them without this
17
+ * admission.
18
+ */
19
+ export function program(input, programIndex, path, machines) {
8
20
  const value = object(input, `values[${programIndex}]`, path);
9
- exact(value, ['root', 'nodes', 'patterns'], 'ValueProgram', path);
10
21
  const nodesPath = `${path}/nodes`;
11
- const nodes = array(value.nodes, 'ValueProgram nodes', nodesPath).map((node, index) => valueNode(node, index, `${nodesPath}/${index}`));
22
+ const nodes = array(value.nodes, 'ValueProgram nodes', nodesPath);
12
23
  const root = index(value.root, nodes.length, 'ValueProgram root', `${path}/root`);
13
- const patternsPath = `${path}/patterns`;
14
- const patterns = array(value.patterns, 'ValueProgram patterns', patternsPath).map((item, position) => index(item, table.length, 'ValueProgram pattern', `${patternsPath}/${position}`));
15
- const sources = patterns.map((index) => table[index].source);
16
- unique(sources, 'patterns', patternsPath);
17
- const available = new Set(sources);
18
- for (const [nodeIndex, node] of nodes.entries()) {
19
- if (isValueObject(node.schema)) {
20
- const required = [node.schema.pattern, node.schema.fullMatch];
21
- if (isValueObject(node.schema.patternProperties)) {
22
- required.push(...Object.keys(node.schema.patternProperties));
23
- }
24
- for (const source of required) {
25
- if (typeof source === 'string' && !available.has(source)) {
26
- invalid('ValueProgram pattern binding', undefined, patternsPath);
27
- }
28
- }
29
- }
30
- for (const [name, child] of Object.entries(node.children))
31
- index(child, nodes.length, 'ValueNode child', pointer(`${nodesPath}/${nodeIndex}/children`, name));
32
- if (node.reference !== undefined)
33
- index(node.reference, nodes.length, 'ValueNode reference', `${nodesPath}/${nodeIndex}/reference`);
34
- }
35
- return { root, nodes, patterns };
36
- }
37
- function valueNode(input, nodeIndex, path) {
38
- const value = object(input, `nodes[${nodeIndex}]`, path);
39
- exact(value, ['schema', 'children'], 'ValueNode', path, ['reference']);
40
- const children = {};
41
- const childrenPath = `${path}/children`;
42
- for (const [name, child] of Object.entries(object(value.children, 'ValueNode children', childrenPath))) {
43
- children[name] = integer(child, 'ValueNode child', pointer(childrenPath, name));
44
- }
24
+ const rootPath = `${nodesPath}/${root}`;
25
+ const { schema } = object(nodes[root], `nodes[${root}]`, rootPath);
26
+ const schemaPath = `${rootPath}/schema`;
27
+ if (!isJsonSchema(schema))
28
+ invalid('ValueNode schema', undefined, schemaPath);
29
+ const derivation = deriveValueGraph(canonicalizeSchemaMembers(schema), schemaPath);
30
+ if ('refusal' in derivation)
31
+ fail(derivation.refusal.pointer, derivation.refusal.message);
45
32
  return {
46
- schema: value.schema,
47
- children,
48
- ...(value.reference === undefined
49
- ? {}
50
- : { reference: integer(value.reference, 'reference', `${path}/reference`) }),
33
+ ...derivation.graph,
34
+ patterns: derivation.sources.map((source) => machine(source, schemaPath, machines)),
51
35
  };
52
36
  }
37
+ /** The machine of one source, by the same bounded rules as source resolution. */
38
+ function machine(source, path, machines) {
39
+ let compiled = machines.get(source);
40
+ if (compiled === undefined) {
41
+ if (!isIRegexp(source))
42
+ invalid('Pattern source', 'COMPILED_SOURCE_INVALID', path);
43
+ compiled = compilePattern(source);
44
+ machines.set(source, compiled);
45
+ }
46
+ return compiled;
47
+ }
@@ -1,4 +1,7 @@
1
1
  import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
2
  import { type ValueProgram, type CompiledClass } from '../../model/schema.js';
3
- /** Decode a Property and re-admit its State and ordering contracts. */
3
+ /**
4
+ * Decode a Property, re-admit its State contract and return it with the ordering its value derives.
5
+ * The revision leaves ordering out, so the received one is not read.
6
+ */
4
7
  export declare function compiledProperty(input: JsonValue, values: readonly ValueProgram[], node: boolean, path: string): CompiledClass['properties'][number];
@@ -5,7 +5,10 @@ import { classifyValueProgramOrdering } from '../../../language/value/ordering.j
5
5
  import {} from '../../model/schema.js';
6
6
  import { invalid } from '../diagnostic.js';
7
7
  import { object, exact, memberName, boolean, description, index, array, unique } from './value.js';
8
- /** Decode a Property and re-admit its State and ordering contracts. */
8
+ /**
9
+ * Decode a Property, re-admit its State contract and return it with the ordering its value derives.
10
+ * The revision leaves ordering out, so the received one is not read.
11
+ */
9
12
  export function compiledProperty(input, values, node, path) {
10
13
  const value = object(input, 'Compiled Property', path);
11
14
  exact(value, ['name', 'required', 'value'], 'Compiled Property', path, [
@@ -52,12 +55,12 @@ export function compiledProperty(input, values, node, path) {
52
55
  }
53
56
  state = topology;
54
57
  }
55
- if (value.ordering !== classifyValueProgramOrdering(values[valueIndex])) {
56
- invalid('Property ordering', 'COMPILED_CANONICAL_MISMATCH', `${path}/ordering`);
57
- }
58
+ const { ordering: _, ...declared } = value;
59
+ const ordering = classifyValueProgramOrdering(values[valueIndex]);
58
60
  return {
59
- ...value,
61
+ ...declared,
60
62
  ...(state === undefined ? {} : { state }),
63
+ ...(ordering === undefined ? {} : { ordering }),
61
64
  };
62
65
  }
63
66
  function propertyAuto(input, path) {
@@ -23,7 +23,5 @@ export declare function description(input: JsonValue | undefined, label: string,
23
23
  export declare function unique(values: readonly string[], label: string, path: string): void;
24
24
  /** Require an index within the referenced table. */
25
25
  export declare function index(input: JsonValue | undefined, length: number, label: string, path: string): number;
26
- /** Require a Unicode scalar-range bound. */
27
- export declare function scalar(input: JsonValue | undefined, label: string, path: string): number;
28
26
  /** Order wire names independently of the host locale. */
29
27
  export declare function compare(left: string, right: string): number;
@@ -85,13 +85,6 @@ export function index(input, length, label, path) {
85
85
  invalid(label, undefined, path);
86
86
  return value;
87
87
  }
88
- /** Require a Unicode scalar-range bound. */
89
- export function scalar(input, label, path) {
90
- const value = integer(input, label, path);
91
- if (value > 0x10ffff)
92
- invalid(label, undefined, path);
93
- return value;
94
- }
95
88
  /** Order wire names independently of the host locale. */
96
89
  export function compare(left, right) {
97
90
  return left < right ? -1 : left > right ? 1 : 0;
@@ -1,9 +1,10 @@
1
1
  import { json } from '@astrale-os/kernel-dsl/value';
2
+ import { closureDocument } from '../../language/limits.js';
2
3
  import { acceptCompiledSchema } from '../admission/accept.js';
4
+ import { compiledDocument } from '../admission/diagnostic.js';
3
5
  export function encode(schema) {
4
- return new TextEncoder().encode(json.serialize(schema));
6
+ return compiledDocument(() => json.encode(schema, closureDocument));
5
7
  }
6
8
  export function decode(input) {
7
- const text = typeof input === 'string' ? input : new TextDecoder().decode(input);
8
- return acceptCompiledSchema(json.decode(text));
9
+ return acceptCompiledSchema(compiledDocument(() => json.decode(input, closureDocument)));
9
10
  }
@@ -1,5 +1,7 @@
1
+ import { compareCodeUnits } from '../../addressing/ordering.js';
1
2
  import { isBinaryInput } from '../../language/callable/model/callable.js';
2
3
  import { inputFieldNodes } from '../../language/value/compile/fields.js';
4
+ import { indexValuePrograms } from '../../language/value/compile/load.js';
3
5
  import { prepareValueSchema } from '../../language/value/evaluate/preparation.js';
4
6
  import { classifyPreparedOrdering } from '../../language/value/ordering.js';
5
7
  import { revisionOfDomainSchema } from '../../schema/canonical/revision.js';
@@ -13,7 +15,7 @@ export function compile(schema) {
13
15
  ...requireDomainClosure(schema).map(({ schema: dependency }) => dependency),
14
16
  ]
15
17
  .filter((value, index, all) => all.findIndex(({ origin }) => origin === value.origin) === index)
16
- .sort((left, right) => compare(left.origin, right.origin));
18
+ .sort((left, right) => compareCodeUnits(left.origin, right.origin));
17
19
  const closure = Object.freeze(sources.map((source) => compileEntry(source, lookup)));
18
20
  return Object.freeze({
19
21
  format: 'astrale.dsl.compiled-schema',
@@ -24,30 +26,17 @@ export function compile(schema) {
24
26
  }
25
27
  function compileEntry(schema, lookup) {
26
28
  const registry = createDomainValueSchemaRegistry(schema, lookup);
27
- const values = [];
29
+ const programs = [];
28
30
  const pool = new Map();
29
- const patternIndices = new Map();
30
31
  const prepare = (contract, pointer) => {
31
32
  const result = prepareValueSchema(contract, registry, pointer, pool);
32
33
  if (!result.compiled)
33
34
  throw new TypeError(`Cannot compile ValueSchema: ${result.message}`);
34
35
  return result.value;
35
36
  };
36
- const addProgram = (program) => {
37
- const patterns = program.patterns.map((pattern) => {
38
- let index = patternIndices.get(pattern);
39
- if (index === undefined) {
40
- index = patternIndices.size;
41
- patternIndices.set(pattern, index);
42
- }
43
- return index;
44
- });
45
- return values.push(Object.freeze({ ...program, patterns: Object.freeze(patterns) })) - 1;
46
- };
37
+ const addProgram = (program) => programs.push(program) - 1;
47
38
  const add = (contract, pointer) => addProgram(prepare(contract, pointer).program());
48
- const properties = (definition, pointer) => Object.entries(definition.properties)
49
- .sort(([left], [right]) => compare(left, right))
50
- .map(([name, property]) => {
39
+ const properties = (definition, pointer) => Object.entries(definition.properties).map(([name, property]) => {
51
40
  const prepared = prepare(property.schema, `${pointer}/properties/${name}/schema`);
52
41
  const ordering = classifyPreparedOrdering(prepared);
53
42
  return {
@@ -67,20 +56,16 @@ function compileEntry(schema, lookup) {
67
56
  mode: value.mode,
68
57
  value: add(value.mode === 'value' ? value.schema : value.item, pointer),
69
58
  };
70
- const classes = Object.values(schema.classes)
71
- .sort((left, right) => compare(left.ref.name, right.ref.name))
72
- .map((definition) => {
59
+ const classes = Object.values(schema.classes).map((definition) => {
73
60
  const pointer = `/classes/${definition.ref.name}`;
74
61
  if (definition.kind === 'edge') {
75
62
  const { properties: _, ...rest } = definition;
76
63
  return { ...rest, properties: properties(definition, pointer) };
77
64
  }
78
65
  const { properties: _, methods: __, ...rest } = definition;
79
- const methods = Object.entries(definition.methods)
80
- .sort(([left], [right]) => compare(left, right))
81
- .map(([name, method]) => {
66
+ const methods = Object.entries(definition.methods).map(([name, method]) => {
82
67
  const input = add(method.input, `${pointer}/methods/${name}/input`);
83
- const fields = inputFieldNodes(values[input]);
68
+ const fields = inputFieldNodes(programs[input]);
84
69
  return {
85
70
  name,
86
71
  auth: method.auth,
@@ -89,6 +74,7 @@ function compileEntry(schema, lookup) {
89
74
  static: method.static,
90
75
  abstract: method.abstract,
91
76
  ...(method.execution === undefined ? {} : { execution: method.execution }),
77
+ ...(method.admission === undefined ? {} : { admission: method.admission }),
92
78
  input,
93
79
  ...(fields === undefined ? {} : { fields }),
94
80
  output: output(method.output, `${pointer}/methods/${name}/output`),
@@ -96,9 +82,7 @@ function compileEntry(schema, lookup) {
96
82
  });
97
83
  return { ...rest, properties: properties(definition, pointer), methods };
98
84
  });
99
- const functions = Object.values(schema.functions)
100
- .sort((left, right) => compare(left.ref.name, right.ref.name))
101
- .map((definition) => {
85
+ const functions = Object.values(schema.functions).map((definition) => {
102
86
  const binary = isBinaryInput(definition.input);
103
87
  const inputIndex = add(binary ? definition.input.metadata : definition.input, binary
104
88
  ? `/functions/${definition.ref.name}/input/metadata`
@@ -110,13 +94,14 @@ function compileEntry(schema, lookup) {
110
94
  maximumBytes: definition.input.maximumBytes,
111
95
  }
112
96
  : inputIndex;
113
- const fields = inputFieldNodes(values[inputIndex]);
97
+ const fields = inputFieldNodes(programs[inputIndex]);
114
98
  return {
115
99
  ref: definition.ref,
116
100
  auth: definition.auth,
117
101
  ...(definition.policy === undefined ? {} : { policy: definition.policy }),
118
102
  ...(definition.description === undefined ? {} : { description: definition.description }),
119
103
  ...(definition.execution === undefined ? {} : { execution: definition.execution }),
104
+ ...(definition.admission === undefined ? {} : { admission: definition.admission }),
120
105
  input,
121
106
  ...(fields === undefined ? {} : { fields }),
122
107
  output: output(definition.output, `/functions/${definition.ref.name}/output`),
@@ -126,6 +111,7 @@ function compileEntry(schema, lookup) {
126
111
  origin: schema.origin,
127
112
  revision: revisionOfDomainSchema(schema),
128
113
  name: schema.name,
114
+ ...(schema.icon === undefined ? {} : { icon: schema.icon }),
129
115
  ...(schema.entrypoint === undefined ? {} : { entrypoint: schema.entrypoint }),
130
116
  dependencies: schema.dependencies,
131
117
  definitions: Object.freeze({
@@ -136,10 +122,6 @@ function compileEntry(schema, lookup) {
136
122
  core: Object.freeze(Object.values(schema.core.nodes)),
137
123
  }),
138
124
  facts: Object.freeze({ core: schema.core.edges }),
139
- values: Object.freeze(values),
140
- patterns: Object.freeze([...patternIndices.keys()]),
125
+ ...indexValuePrograms(programs),
141
126
  });
142
127
  }
143
- function compare(left, right) {
144
- return left < right ? -1 : left > right ? 1 : 0;
145
- }
@@ -1,4 +1,4 @@
1
- export type CompiledDiagnosticCode = 'COMPILED_CANONICAL_MISMATCH' | 'COMPILED_DEPENDENCY_CYCLE' | 'COMPILED_DEPENDENCY_LIMITS' | 'COMPILED_SOURCE_INVALID' | 'COMPILED_STRUCTURE_INVALID';
1
+ export type CompiledDiagnosticCode = 'COMPILED_CANONICAL_MISMATCH' | 'COMPILED_DEPENDENCY_LIMITS' | 'COMPILED_SOURCE_INVALID' | 'COMPILED_STRUCTURE_INVALID';
2
2
  export interface CompiledDiagnostic<out Code extends CompiledDiagnosticCode = CompiledDiagnosticCode> {
3
3
  readonly code: Code;
4
4
  readonly pointer: string;
@@ -1,9 +1,8 @@
1
+ import { formatDiagnostics } from '../language/validation/diagnostic.js';
1
2
  export class CompiledSchemaError extends Error {
2
3
  diagnostics;
3
4
  constructor(diagnostics, options) {
4
- super(diagnostics
5
- .map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
6
- .join('\n'), options);
5
+ super(formatDiagnostics(diagnostics), options);
7
6
  this.name = 'CompiledSchemaError';
8
7
  this.diagnostics = Object.freeze([...diagnostics]);
9
8
  }
@@ -2,6 +2,8 @@ export { acceptCompiledSchema as accept } from './admission/accept.js';
2
2
  export { compile } from './compiler/compile.js';
3
3
  export { decode, encode } from './codec/json.js';
4
4
  export { load } from './loader/load.js';
5
+ export { COMPILED_RULES as RULES, READMITTED_RULES, READMITTED_VALUE_RULES } from './rule.js';
6
+ export type { CompiledRule as Rule, ReadmittedRule } from './rule.js';
5
7
  export { CompiledSchemaError as Error } from './diagnostic.js';
6
8
  export type { CompiledDiagnostic as Diagnostic, CompiledDiagnosticCode as DiagnosticCode, } from './diagnostic.js';
7
9
  export type * from './model/schema.js';
@@ -2,4 +2,5 @@ export { acceptCompiledSchema as accept } from './admission/accept.js';
2
2
  export { compile } from './compiler/compile.js';
3
3
  export { decode, encode } from './codec/json.js';
4
4
  export { load } from './loader/load.js';
5
+ export { COMPILED_RULES as RULES, READMITTED_RULES, READMITTED_VALUE_RULES } from './rule.js';
5
6
  export { CompiledSchemaError as Error } from './diagnostic.js';
@@ -1,9 +1,10 @@
1
+ import type { Domain } from '../../domain/model/domain.js';
1
2
  import type { CompiledSchema, DomainOfCompiled } from '../model/schema.js';
2
3
  /** Load admitted compiled data through the one resolved Domain constructor. */
3
4
  export declare function load<const Input extends CompiledSchema>(input: Input): DomainOfCompiled<Input>;
4
- export declare function load(input: unknown): import('../../domain/model/domain.js').Domain;
5
+ export declare function load(input: unknown): Domain;
5
6
  /**
6
7
  * Realize compiled material whose exact embedded bytes were already proven by generated build code.
7
8
  * External bytes and caller-provided values must continue through {@link load}.
8
9
  */
9
- export declare function realize(compiled: CompiledSchema): import('../../domain/model/domain.js').Domain;
10
+ export declare function realize(compiled: CompiledSchema): Domain;
@@ -1,10 +1,11 @@
1
1
  import { Key, MethodKey, PropertyKey as PropertyKeyValue } from '../../addressing/index.js';
2
2
  import { compareUnicode } from '../../addressing/ordering.js';
3
3
  import { createDomain } from '../../domain/create.js';
4
- import { combineDomainValidation, createDomainValidation, unknownInputField, } from '../../domain/validation/create.js';
4
+ import { createDomainValidation, validateInputField } from '../../domain/validation/create.js';
5
5
  import { bindValueProgram } from '../../language/value/compile/load.js';
6
6
  import { validateValueProgram } from '../../language/value/evaluate/program.js';
7
7
  import { acceptCompiledSchema } from '../admission/accept.js';
8
+ import { schemaOf, sourceFunction, sourceMethod } from '../admission/revision.js';
8
9
  export function load(input) {
9
10
  return realize(acceptCompiledSchema(input));
10
11
  }
@@ -14,13 +15,14 @@ export function load(input) {
14
15
  */
15
16
  export function realize(compiled) {
16
17
  const entries = new Map(compiled.closure.map((entry) => [entry.origin, loadEntry(entry)]));
18
+ const loaded = [...entries.values()];
17
19
  const root = entries.get(compiled.root.origin);
18
20
  if (root === undefined || root.entry.revision !== compiled.root.revision) {
19
21
  throw new TypeError('Compiled root is absent or has the wrong revision.');
20
22
  }
21
23
  return createDomain({
22
24
  root: compiled.root,
23
- entries: Object.freeze([...entries.values()]
25
+ entries: Object.freeze(loaded
24
26
  .map(({ entry, definitions }) => Object.freeze({
25
27
  origin: entry.origin,
26
28
  revision: entry.revision,
@@ -29,7 +31,8 @@ export function realize(compiled) {
29
31
  coreEdges: entry.facts.core,
30
32
  }))
31
33
  .sort((left, right) => compareUnicode(left.origin, right.origin))),
32
- validation: combineDomainValidation([...entries.values()].map(({ validation }) => validation)),
34
+ // Closure admission refuses a duplicate Definition, so no two entries share a key.
35
+ validation: createDomainValidation(new Map(loaded.flatMap(({ properties }) => [...properties])), new Map(loaded.flatMap(({ callables }) => [...callables]))),
33
36
  });
34
37
  }
35
38
  function loadEntry(entry) {
@@ -52,13 +55,13 @@ function loadEntry(entry) {
52
55
  const methods = Object.fromEntries(compiled.methods.map((method) => {
53
56
  const key = MethodKey.of(compiled.ref, method.name);
54
57
  callablePrograms.set(key, callableProgram(method));
55
- return [method.name, loadMethod(entry, method)];
58
+ return [method.name, Object.freeze(sourceMethod(entry, method))];
56
59
  }));
57
60
  return Object.freeze({ ...definition, properties, methods });
58
61
  });
59
62
  const functions = entry.definitions.functions.map((compiled) => {
60
63
  callablePrograms.set(Key.of(compiled.ref), callableProgram(compiled));
61
- return loadFunction(entry, compiled);
64
+ return Object.freeze(sourceFunction(entry, compiled));
62
65
  });
63
66
  return {
64
67
  entry,
@@ -69,46 +72,9 @@ function loadEntry(entry) {
69
72
  ...entry.definitions.views,
70
73
  ...entry.definitions.core,
71
74
  ]),
72
- validation: programValidation(entry.values.map((value) => bindValueProgram(value, entry.patterns)), propertyPrograms, propertyOrdering, callablePrograms),
75
+ ...programValidation(entry.values.map((value) => bindValueProgram(value, entry.patterns)), propertyPrograms, propertyOrdering, callablePrograms),
73
76
  };
74
77
  }
75
- function loadMethod(entry, value) {
76
- const { name: _, input, fields: __, output, ...definition } = value;
77
- return Object.freeze({
78
- ...definition,
79
- input: schemaOf(entry, input),
80
- output: loadOutput(entry, output),
81
- });
82
- }
83
- function loadFunction(entry, value) {
84
- const { input, fields: _, output, ...definition } = value;
85
- return Object.freeze({
86
- ...definition,
87
- input: typeof input === 'number'
88
- ? schemaOf(entry, input)
89
- : {
90
- mode: 'binary',
91
- metadata: schemaOf(entry, input.metadata),
92
- maximumBytes: input.maximumBytes,
93
- },
94
- output: loadOutput(entry, output),
95
- });
96
- }
97
- function loadOutput(entry, output) {
98
- if (output.mode === 'binary')
99
- return output;
100
- const schema = schemaOf(entry, output.value);
101
- return output.mode === 'value'
102
- ? { mode: 'value', schema }
103
- : { mode: 'stream', item: schema };
104
- }
105
- function schemaOf(entry, index) {
106
- const program = entry.values[index];
107
- const root = program?.nodes[program.root];
108
- if (root === undefined)
109
- throw new TypeError(`Compiled Value program ${index} is absent.`);
110
- return root.schema;
111
- }
112
78
  function callableProgram(value) {
113
79
  return {
114
80
  input: typeof value.input === 'number' ? value.input : value.input.metadata,
@@ -141,15 +107,10 @@ function programValidation(programs, properties, propertyOrdering, callables) {
141
107
  ...(callable.fields === undefined
142
108
  ? {}
143
109
  : { fields: Object.freeze(Object.keys(callable.fields)) }),
144
- validateInput: (value) => validateValueProgram(input, value),
145
- validateInputField(field, value) {
146
- const nodes = callable.fields?.[field];
147
- return nodes === undefined
148
- ? unknownInputField(field)
149
- : validateValueProgram(input, value, nodes);
150
- },
151
- validateOutput: (value) => output === undefined ? [] : validateValueProgram(output, value),
110
+ validateInput: (value, options) => validateValueProgram(input, value, [input.root], options),
111
+ validateInputField: (field, value) => validateInputField(input, callable.fields, field, value),
112
+ validateOutput: (value, options) => output === undefined ? [] : validateValueProgram(output, value, [output.root], options),
152
113
  }));
153
114
  }
154
- return createDomainValidation(propertyValidation, callableValidation);
115
+ return { properties: propertyValidation, callables: callableValidation };
155
116
  }
@@ -5,6 +5,7 @@ import type { MethodDefinition } from '../../language/callable/model/callable.js
5
5
  import type { ClassDefinition } from '../../language/class/model/class.js';
6
6
  import type { PropertyDefinition } from '../../language/class/model/property.js';
7
7
  import type { CoreDefinition, CoreEdge } from '../../language/core/model/core.js';
8
+ import type { DomainIcon } from '../../language/definition/metadata.js';
8
9
  import type { PolicyDefinition } from '../../language/policy/model/policy.js';
9
10
  import type { IndexedValueProgram, Pattern, RunPattern } from '../../language/value/compile/model.js';
10
11
  import type { OrderingKind } from '../../language/value/ordering.js';
@@ -55,6 +56,8 @@ export interface CompiledSchemaEntry {
55
56
  readonly revision: Revision;
56
57
  /** The source Domain display name. */
57
58
  readonly name: string;
59
+ /** The source Domain presentation icon. */
60
+ readonly icon?: DomainIcon;
58
61
  /** The source Domain entrypoint View. */
59
62
  readonly entrypoint?: ViewRef;
60
63
  readonly dependencies: DomainDependencyMap;