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

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 (321) hide show
  1. package/dist/v1/addressing/class-key.js +5 -4
  2. package/dist/v1/addressing/method-key.js +3 -2
  3. package/dist/v1/addressing/patterns.d.ts +0 -5
  4. package/dist/v1/addressing/patterns.js +5 -5
  5. package/dist/v1/builder/callable/authoring.d.ts +87 -41
  6. package/dist/v1/builder/callable/authoring.js +29 -14
  7. package/dist/v1/builder/class/authoring.d.ts +311 -36
  8. package/dist/v1/builder/class/authoring.js +3 -4
  9. package/dist/v1/builder/class/property.d.ts +16 -8
  10. package/dist/v1/builder/class/property.js +21 -5
  11. package/dist/v1/builder/core/authoring.d.ts +28 -13
  12. package/dist/v1/builder/core/authoring.js +22 -2
  13. package/dist/v1/builder/index.d.ts +9 -8
  14. package/dist/v1/builder/index.js +2 -2
  15. package/dist/v1/builder/lowering/callable.d.ts +3 -1
  16. package/dist/v1/builder/lowering/callable.js +43 -51
  17. package/dist/v1/builder/lowering/class.d.ts +7 -0
  18. package/dist/v1/builder/lowering/class.js +79 -29
  19. package/dist/v1/builder/lowering/core.d.ts +3 -2
  20. package/dist/v1/builder/lowering/core.js +9 -6
  21. package/dist/v1/builder/lowering/policy.d.ts +8 -1
  22. package/dist/v1/builder/lowering/policy.js +35 -0
  23. package/dist/v1/builder/lowering/schema/capture.js +9 -4
  24. package/dist/v1/builder/lowering/schema/compile.d.ts +2 -2
  25. package/dist/v1/builder/lowering/schema/compile.js +15 -2
  26. package/dist/v1/builder/lowering/schema/context.d.ts +11 -8
  27. package/dist/v1/builder/lowering/schema/context.js +59 -29
  28. package/dist/v1/builder/lowering/schema/ownership.d.ts +3 -3
  29. package/dist/v1/builder/lowering/schema/ownership.js +2 -1
  30. package/dist/v1/builder/lowering/value/compile.js +14 -4
  31. package/dist/v1/builder/lowering/value/zod.d.ts +7 -6
  32. package/dist/v1/builder/lowering/value/zod.js +16 -7
  33. package/dist/v1/builder/lowering/view.d.ts +4 -3
  34. package/dist/v1/builder/lowering/view.js +2 -14
  35. package/dist/v1/builder/policy/authoring.d.ts +23 -6
  36. package/dist/v1/builder/policy/authoring.js +35 -8
  37. package/dist/v1/builder/schema/define.d.ts +8 -5
  38. package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
  39. package/dist/v1/builder/schema/handle.d.ts +2 -1
  40. package/dist/v1/builder/schema/input.d.ts +9 -1
  41. package/dist/v1/builder/schema/projection/callable.d.ts +51 -0
  42. package/dist/v1/builder/schema/projection/callable.js +1 -0
  43. package/dist/v1/builder/schema/projection/class.d.ts +89 -0
  44. package/dist/v1/builder/schema/projection/class.js +1 -0
  45. package/dist/v1/builder/schema/projection/core-input.d.ts +32 -0
  46. package/dist/v1/builder/schema/projection/core-input.js +1 -0
  47. package/dist/v1/builder/schema/projection/domain.d.ts +59 -0
  48. package/dist/v1/builder/schema/projection/domain.js +1 -0
  49. package/dist/v1/builder/schema/projection/identity.d.ts +39 -0
  50. package/dist/v1/builder/schema/projection/identity.js +1 -0
  51. package/dist/v1/builder/schema/projection/model.d.ts +59 -0
  52. package/dist/v1/builder/schema/projection/model.js +1 -0
  53. package/dist/v1/builder/schema/projection/property.d.ts +32 -0
  54. package/dist/v1/builder/schema/projection/property.js +1 -0
  55. package/dist/v1/builder/schema/projection/resolved-class.d.ts +76 -0
  56. package/dist/v1/builder/schema/projection/resolved-class.js +1 -0
  57. package/dist/v1/builder/schema/projection.d.ts +4 -258
  58. package/dist/v1/builder/value/full-match.js +6 -3
  59. package/dist/v1/builder/value/path.d.ts +2 -2
  60. package/dist/v1/builder/value/path.js +2 -2
  61. package/dist/v1/builder/view/authoring.d.ts +6 -14
  62. package/dist/v1/builder/view/authoring.js +13 -5
  63. package/dist/v1/bundle/structure.d.ts +2 -1
  64. package/dist/v1/compiled/admission/accept.d.ts +1 -1
  65. package/dist/v1/compiled/admission/accept.js +11 -814
  66. package/dist/v1/compiled/admission/closure.d.ts +3 -0
  67. package/dist/v1/compiled/admission/closure.js +173 -0
  68. package/dist/v1/compiled/admission/diagnostic.d.ts +7 -0
  69. package/dist/v1/compiled/admission/diagnostic.js +13 -0
  70. package/dist/v1/compiled/admission/revision.js +9 -1
  71. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +5 -0
  72. package/dist/v1/compiled/admission/semantics/cardinality.js +113 -0
  73. package/dist/v1/compiled/admission/semantics/class.d.ts +5 -0
  74. package/dist/v1/compiled/admission/semantics/class.js +125 -0
  75. package/dist/v1/compiled/admission/semantics/context.d.ts +60 -0
  76. package/dist/v1/compiled/admission/semantics/context.js +81 -0
  77. package/dist/v1/compiled/admission/semantics/core.d.ts +35 -0
  78. package/dist/v1/compiled/admission/semantics/core.js +123 -0
  79. package/dist/v1/compiled/admission/semantics/edge.d.ts +8 -0
  80. package/dist/v1/compiled/admission/semantics/edge.js +89 -0
  81. package/dist/v1/compiled/admission/semantics/policy/admit.d.ts +4 -0
  82. package/dist/v1/compiled/admission/semantics/policy/admit.js +63 -0
  83. package/dist/v1/compiled/admission/semantics/policy/callable.d.ts +5 -0
  84. package/dist/v1/compiled/admission/semantics/policy/callable.js +72 -0
  85. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +24 -0
  86. package/dist/v1/compiled/admission/semantics/policy/contracts.js +45 -0
  87. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +8 -0
  88. package/dist/v1/compiled/admission/semantics/policy/equality.js +27 -0
  89. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +9 -0
  90. package/dist/v1/compiled/admission/semantics/policy/measure.js +81 -0
  91. package/dist/v1/compiled/admission/semantics/policy/parity.d.ts +4 -0
  92. package/dist/v1/compiled/admission/semantics/policy/parity.js +138 -0
  93. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +8 -0
  94. package/dist/v1/compiled/admission/semantics/policy/pattern.js +78 -0
  95. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +28 -0
  96. package/dist/v1/compiled/admission/semantics/policy/typing.js +206 -0
  97. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +10 -0
  98. package/dist/v1/compiled/admission/semantics/policy/variants.js +65 -0
  99. package/dist/v1/compiled/admission/semantics.d.ts +1 -1
  100. package/dist/v1/compiled/admission/semantics.js +8 -1078
  101. package/dist/v1/compiled/admission/wire/callable.d.ts +6 -0
  102. package/dist/v1/compiled/admission/wire/callable.js +90 -0
  103. package/dist/v1/compiled/admission/wire/class.d.ts +4 -0
  104. package/dist/v1/compiled/admission/wire/class.js +133 -0
  105. package/dist/v1/compiled/admission/wire/core.d.ts +5 -0
  106. package/dist/v1/compiled/admission/wire/core.js +32 -0
  107. package/dist/v1/compiled/admission/wire/dependency.d.ts +14 -0
  108. package/dist/v1/compiled/admission/wire/dependency.js +43 -0
  109. package/dist/v1/compiled/admission/wire/entry.d.ts +5 -0
  110. package/dist/v1/compiled/admission/wire/entry.js +100 -0
  111. package/dist/v1/compiled/admission/wire/pattern.d.ts +12 -0
  112. package/dist/v1/compiled/admission/wire/pattern.js +111 -0
  113. package/dist/v1/compiled/admission/wire/policy.d.ts +10 -0
  114. package/dist/v1/compiled/admission/wire/policy.js +189 -0
  115. package/dist/v1/compiled/admission/wire/program.d.ts +4 -0
  116. package/dist/v1/compiled/admission/wire/program.js +52 -0
  117. package/dist/v1/compiled/admission/wire/property.d.ts +4 -0
  118. package/dist/v1/compiled/admission/wire/property.js +74 -0
  119. package/dist/v1/compiled/admission/wire/reference.d.ts +8 -0
  120. package/dist/v1/compiled/admission/wire/reference.js +33 -0
  121. package/dist/v1/compiled/admission/wire/value.d.ts +29 -0
  122. package/dist/v1/compiled/admission/wire/value.js +98 -0
  123. package/dist/v1/compiled/admission/wire/view.d.ts +3 -0
  124. package/dist/v1/compiled/admission/wire/view.js +17 -0
  125. package/dist/v1/compiled/compiler/compile.js +43 -11
  126. package/dist/v1/compiled/generated.d.ts +10 -0
  127. package/dist/v1/compiled/generated.js +15 -0
  128. package/dist/v1/compiled/loader/load.d.ts +5 -0
  129. package/dist/v1/compiled/loader/load.js +18 -4
  130. package/dist/v1/compiled/model/schema.d.ts +16 -7
  131. package/dist/v1/domain/create.js +18 -28
  132. package/dist/v1/domain/model/domain.d.ts +0 -1
  133. package/dist/v1/domain/model/input.d.ts +3 -0
  134. package/dist/v1/domain/projection/classes.js +13 -41
  135. package/dist/v1/domain/validation/create.d.ts +2 -0
  136. package/dist/v1/domain/validation/create.js +12 -0
  137. package/dist/v1/index.d.ts +5 -2
  138. package/dist/v1/index.js +3 -1
  139. package/dist/v1/language/callable/composition.d.ts +27 -0
  140. package/dist/v1/language/callable/composition.js +52 -0
  141. package/dist/v1/language/callable/executable.d.ts +6 -0
  142. package/dist/v1/language/callable/executable.js +4 -0
  143. package/dist/v1/language/callable/model/callable.d.ts +34 -9
  144. package/dist/v1/language/callable/model/callable.js +3 -1
  145. package/dist/v1/language/callable/resolved.d.ts +23 -8
  146. package/dist/v1/language/class/facets.d.ts +5 -2
  147. package/dist/v1/language/class/inheritance.d.ts +12 -0
  148. package/dist/v1/language/class/inheritance.js +25 -0
  149. package/dist/v1/language/class/lifetime.d.ts +17 -0
  150. package/dist/v1/language/class/lifetime.js +26 -0
  151. package/dist/v1/language/class/model/class.d.ts +8 -4
  152. package/dist/v1/language/class/model/property.d.ts +4 -2
  153. package/dist/v1/language/class/property-values.js +5 -2
  154. package/dist/v1/language/class/resolved.d.ts +25 -15
  155. package/dist/v1/language/core/model/core.d.ts +7 -1
  156. package/dist/v1/language/core/resolved.d.ts +6 -2
  157. package/dist/v1/language/definition/metadata.d.ts +8 -0
  158. package/dist/v1/language/definition/metadata.js +12 -0
  159. package/dist/v1/language/index.d.ts +9 -0
  160. package/dist/v1/language/index.js +6 -0
  161. package/dist/v1/language/policy/analysis/branches.d.ts +4 -3
  162. package/dist/v1/language/policy/analysis/branches.js +54 -12
  163. package/dist/v1/language/policy/analysis/budgets.js +1 -1
  164. package/dist/v1/language/policy/analysis/checks.d.ts +28 -0
  165. package/dist/v1/language/policy/analysis/checks.js +80 -0
  166. package/dist/v1/language/policy/index.d.ts +1 -0
  167. package/dist/v1/language/policy/index.js +1 -0
  168. package/dist/v1/language/policy/model/policy.d.ts +71 -5
  169. package/dist/v1/language/policy/model/policy.js +52 -1
  170. package/dist/v1/language/policy/normalization/normalize.d.ts +12 -1
  171. package/dist/v1/language/policy/normalization/normalize.js +178 -44
  172. package/dist/v1/language/state/index.d.ts +3 -0
  173. package/dist/v1/language/state/index.js +1 -0
  174. package/dist/v1/language/state/machine.d.ts +28 -0
  175. package/dist/v1/language/state/machine.js +40 -0
  176. package/dist/v1/language/state/topology.d.ts +14 -0
  177. package/dist/v1/language/state/topology.js +69 -0
  178. package/dist/v1/language/value/compile/fields.d.ts +1 -1
  179. package/dist/v1/language/value/compile/load.d.ts +4 -2
  180. package/dist/v1/language/value/compile/load.js +22 -1
  181. package/dist/v1/language/value/compile/model.d.ts +16 -1
  182. package/dist/v1/language/value/evaluate/assertions.d.ts +2 -0
  183. package/dist/v1/language/value/evaluate/assertions.js +13 -0
  184. package/dist/v1/language/value/evaluate/evaluator.js +111 -28
  185. package/dist/v1/language/value/evaluate/preparation.d.ts +10 -1
  186. package/dist/v1/language/value/evaluate/preparation.js +17 -26
  187. package/dist/v1/language/value/evaluate/program.js +1 -1
  188. package/dist/v1/language/value/evaluate/validate.d.ts +6 -2
  189. package/dist/v1/language/value/evaluate/validate.js +18 -11
  190. package/dist/v1/language/value/inclusion/includes.d.ts +9 -0
  191. package/dist/v1/language/value/inclusion/includes.js +777 -0
  192. package/dist/v1/language/value/model/blob.d.ts +31 -0
  193. package/dist/v1/language/value/model/blob.js +90 -0
  194. package/dist/v1/language/value/model/instant.d.ts +0 -2
  195. package/dist/v1/language/value/model/instant.js +1 -1
  196. package/dist/v1/language/value/model/schema.d.ts +2 -1
  197. package/dist/v1/language/value/model/schema.js +1 -5
  198. package/dist/v1/language/value/ordering.d.ts +2 -0
  199. package/dist/v1/language/value/ordering.js +4 -8
  200. package/dist/v1/language/value/profile/json.validate.js +1 -1
  201. package/dist/v1/language/value/profile/rules.js +48 -12
  202. package/dist/v1/language/value/reference/registry.d.ts +2 -1
  203. package/dist/v1/language/value/regexp/ast.js +3 -64
  204. package/dist/v1/language/value/regexp/compile.d.ts +32 -3
  205. package/dist/v1/language/value/regexp/compile.js +117 -21
  206. package/dist/v1/language/value/regexp/matcher.d.ts +6 -3
  207. package/dist/v1/language/value/regexp/matcher.js +185 -28
  208. package/dist/v1/language/value/regexp/syntax.d.ts +12 -1
  209. package/dist/v1/language/value/regexp/syntax.js +14 -2
  210. package/dist/v1/language/value/regexp/unicode.d.ts +32 -0
  211. package/dist/v1/language/value/regexp/unicode.js +139 -0
  212. package/dist/v1/language/value/syntax/full-match.js +8 -5
  213. package/dist/v1/language/value/syntax/node-path/validate.js +4 -6
  214. package/dist/v1/language/view/model/view.d.ts +2 -4
  215. package/dist/v1/language/view/resolved.d.ts +2 -2
  216. package/dist/v1/schema/analysis/class.d.ts +36 -6
  217. package/dist/v1/schema/analysis/class.js +31 -66
  218. package/dist/v1/schema/canonical/revision.d.ts +2 -1
  219. package/dist/v1/schema/canonical/revision.js +4 -1
  220. package/dist/v1/schema/compatibility/api.d.ts +3 -0
  221. package/dist/v1/schema/compatibility/api.js +2 -0
  222. package/dist/v1/schema/compatibility/comparators/callables.d.ts +39 -0
  223. package/dist/v1/schema/compatibility/comparators/callables.js +101 -0
  224. package/dist/v1/schema/compatibility/comparators/classes.d.ts +47 -0
  225. package/dist/v1/schema/compatibility/comparators/classes.js +160 -0
  226. package/dist/v1/schema/compatibility/comparators/index.d.ts +12 -0
  227. package/dist/v1/schema/compatibility/comparators/index.js +53 -0
  228. package/dist/v1/schema/compatibility/comparators/members.d.ts +4 -0
  229. package/dist/v1/schema/compatibility/comparators/members.js +49 -0
  230. package/dist/v1/schema/compatibility/comparators/values.d.ts +5 -0
  231. package/dist/v1/schema/compatibility/comparators/values.js +37 -0
  232. package/dist/v1/schema/compatibility/compare.d.ts +5 -0
  233. package/dist/v1/schema/compatibility/compare.js +23 -0
  234. package/dist/v1/schema/compatibility/context.d.ts +19 -0
  235. package/dist/v1/schema/compatibility/context.js +49 -0
  236. package/dist/v1/schema/compatibility/coordinate.d.ts +40 -0
  237. package/dist/v1/schema/compatibility/coordinate.js +38 -0
  238. package/dist/v1/schema/compatibility/diff.d.ts +12 -0
  239. package/dist/v1/schema/compatibility/diff.js +39 -0
  240. package/dist/v1/schema/compatibility/evidence.d.ts +16 -0
  241. package/dist/v1/schema/compatibility/evidence.js +62 -0
  242. package/dist/v1/schema/compatibility/fields.d.ts +194 -0
  243. package/dist/v1/schema/compatibility/fields.js +94 -0
  244. package/dist/v1/schema/compatibility/index.d.ts +6 -0
  245. package/dist/v1/schema/compatibility/index.js +3 -0
  246. package/dist/v1/schema/compatibility/meaning/footprint.d.ts +7 -0
  247. package/dist/v1/schema/compatibility/meaning/footprint.js +59 -0
  248. package/dist/v1/schema/compatibility/meaning/index.d.ts +3 -0
  249. package/dist/v1/schema/compatibility/meaning/index.js +16 -0
  250. package/dist/v1/schema/compatibility/model.d.ts +131 -0
  251. package/dist/v1/schema/compatibility/model.js +1 -0
  252. package/dist/v1/schema/compatibility/references.d.ts +38 -0
  253. package/dist/v1/schema/compatibility/references.js +149 -0
  254. package/dist/v1/schema/compatibility/report.d.ts +27 -0
  255. package/dist/v1/schema/compatibility/report.js +100 -0
  256. package/dist/v1/schema/compatibility/scope.d.ts +36 -0
  257. package/dist/v1/schema/compatibility/scope.js +110 -0
  258. package/dist/v1/schema/compatibility/structure/index.d.ts +3 -0
  259. package/dist/v1/schema/compatibility/structure/index.js +40 -0
  260. package/dist/v1/schema/compatibility/structure/inheritance.d.ts +7 -0
  261. package/dist/v1/schema/compatibility/structure/inheritance.js +68 -0
  262. package/dist/v1/schema/compatibility/structure/requirements.d.ts +7 -0
  263. package/dist/v1/schema/compatibility/structure/requirements.js +97 -0
  264. package/dist/v1/schema/compatibility/subjects.d.ts +39 -0
  265. package/dist/v1/schema/compatibility/subjects.js +143 -0
  266. package/dist/v1/schema/compatibility/versioning/index.d.ts +8 -0
  267. package/dist/v1/schema/compatibility/versioning/index.js +50 -0
  268. package/dist/v1/schema/compatibility/versioning/members.d.ts +12 -0
  269. package/dist/v1/schema/compatibility/versioning/members.js +47 -0
  270. package/dist/v1/schema/compatibility/versioning/surface.d.ts +11 -0
  271. package/dist/v1/schema/compatibility/versioning/surface.js +61 -0
  272. package/dist/v1/schema/diagnostic.d.ts +1 -1
  273. package/dist/v1/schema/fingerprint.d.ts +2 -0
  274. package/dist/v1/schema/fingerprint.js +1 -0
  275. package/dist/v1/schema/index.d.ts +4 -3
  276. package/dist/v1/schema/index.js +2 -1
  277. package/dist/v1/schema/model/schema.d.ts +8 -11
  278. package/dist/v1/schema/normalization/domain.js +57 -13
  279. package/dist/v1/schema/resolution/definition.index.d.ts +1 -2
  280. package/dist/v1/schema/resolution/definition.index.js +0 -3
  281. package/dist/v1/schema/resolution/domain.d.ts +4 -1
  282. package/dist/v1/schema/resolution/domain.js +26 -18
  283. package/dist/v1/schema/resolution/origins.d.ts +28 -5
  284. package/dist/v1/schema/resolution/origins.js +68 -31
  285. package/dist/v1/schema/validation/callable.d.ts +4 -0
  286. package/dist/v1/schema/validation/callable.js +39 -0
  287. package/dist/v1/schema/validation/class.d.ts +10 -0
  288. package/dist/v1/schema/validation/class.js +79 -60
  289. package/dist/v1/schema/validation/core.js +83 -55
  290. package/dist/v1/schema/validation/domain.d.ts +2 -1
  291. package/dist/v1/schema/validation/domain.js +2 -0
  292. package/dist/v1/schema/validation/domain.structure.d.ts +0 -2
  293. package/dist/v1/schema/validation/domain.structure.js +214 -171
  294. package/dist/v1/schema/validation/policy/budgets.js +36 -6
  295. package/dist/v1/schema/validation/policy/context.js +5 -16
  296. package/dist/v1/schema/validation/policy/objects.d.ts +4 -0
  297. package/dist/v1/schema/validation/policy/objects.js +71 -0
  298. package/dist/v1/schema/validation/policy/references.js +16 -4
  299. package/dist/v1/schema/validation/policy/typing.d.ts +2 -0
  300. package/dist/v1/schema/validation/policy/typing.js +55 -7
  301. package/dist/v1/schema/validation/policy/uses.js +73 -99
  302. package/dist/v1/schema/validation/value-api.d.ts +2 -0
  303. package/dist/v1/schema/validation/value-api.js +1 -0
  304. package/dist/v1/schema/validation/value.js +7 -1
  305. package/dist/v1/schema/validation/view.js +14 -9
  306. package/dist/value/accept.d.ts +9 -0
  307. package/dist/value/accept.js +106 -7
  308. package/dist/value/canonical.d.ts +3 -0
  309. package/dist/value/canonical.js +22 -6
  310. package/dist/value/immutable.optimization.d.ts +15 -0
  311. package/dist/value/immutable.optimization.js +34 -0
  312. package/dist/value/index.d.ts +1 -1
  313. package/dist/value/index.js +1 -1
  314. package/dist/value/json.d.ts +1 -1
  315. package/dist/value/json.js +1 -1
  316. package/dist/value/limits.d.ts +1 -1
  317. package/dist/value/unicode.d.ts +4 -1
  318. package/dist/value/unicode.js +28 -0
  319. package/package.json +19 -3
  320. package/dist/v1/schema/compatibility/meaning.d.ts +0 -29
  321. package/dist/v1/schema/compatibility/meaning.js +0 -605
@@ -0,0 +1,189 @@
1
+ import { json } from '@astrale-os/kernel-dsl/value';
2
+ import { Key } from '../../../addressing/index.js';
3
+ import { normalizeClassRule } from '../../../language/policy/normalization/normalize.js';
4
+ import { invalid, pointer } from '../diagnostic.js';
5
+ import { definitionRef, policyObjectRef } from './reference.js';
6
+ import { object, exact, description, array, unique, boundedInteger, integer, memberName, } from './value.js';
7
+ /** Decode a named Policy and its expression grammar. */
8
+ export function compiledPolicy(input, path) {
9
+ const value = object(input, 'Policy', path);
10
+ exact(value, ['ref', 'expression'], 'Policy', path, ['description']);
11
+ definitionRef(value.ref, 'policy', 'Policy ref', `${path}/ref`);
12
+ description(value.description, 'Policy description', `${path}/description`);
13
+ policyExpression(value.expression, 0, `${path}/expression`);
14
+ return value;
15
+ }
16
+ function policyExpression(input, depth, path) {
17
+ if (depth > 64)
18
+ invalid('Policy expression depth', undefined, path);
19
+ const value = object(input, 'Policy expression', path);
20
+ if (Object.hasOwn(value, 'match')) {
21
+ exact(value, ['match'], 'Policy expression', path);
22
+ policyPattern(value.match, depth + 1, `${path}/match`);
23
+ return;
24
+ }
25
+ const member = Object.hasOwn(value, 'allOf') ? 'allOf' : 'anyOf';
26
+ exact(value, [member], 'Policy expression', path);
27
+ const memberPath = pointer(path, member);
28
+ const refs = array(value[member], `Policy ${member}`, memberPath).map((item, index) => definitionRef(item, 'policy', `Policy ${member} ref`, `${memberPath}/${index}`));
29
+ if (refs.length === 0)
30
+ invalid(`Policy ${member}`, undefined, memberPath);
31
+ unique(refs.map(Key.of), `Policy ${member}`, memberPath);
32
+ }
33
+ function policyPattern(input, depth, path) {
34
+ if (depth > 64)
35
+ invalid('Policy pattern depth', undefined, path);
36
+ const value = object(input, 'Policy pattern', path);
37
+ if (Object.hasOwn(value, 'sameNode')) {
38
+ exact(value, ['sameNode'], 'Policy equality', path);
39
+ const pair = object(value.sameNode, 'Policy equality', `${path}/sameNode`);
40
+ exact(pair, ['left', 'right'], 'Policy equality operands', `${path}/sameNode`);
41
+ policyTerm(pair.left, false, `${path}/sameNode/left`);
42
+ policyTerm(pair.right, false, `${path}/sameNode/right`);
43
+ return;
44
+ }
45
+ if (Object.hasOwn(value, 'exists')) {
46
+ exact(value, ['exists'], 'Policy exists', path);
47
+ const existsPath = `${path}/exists`;
48
+ const exists = object(value.exists, 'Policy exists', existsPath);
49
+ exact(exists, ['nodes', 'where'], 'Policy exists', existsPath);
50
+ const nodesPath = `${existsPath}/nodes`;
51
+ const nodes = array(exists.nodes, 'Policy variables', nodesPath);
52
+ if (nodes.length < 1 || nodes.length > 4)
53
+ invalid('Policy variables', undefined, nodesPath);
54
+ for (const [index, node] of nodes.entries()) {
55
+ const variablePath = `${nodesPath}/${index}`;
56
+ const variable = object(node, 'Policy variable', variablePath);
57
+ policyTerm(variable.variable, true, `${variablePath}/variable`);
58
+ if (Object.hasOwn(variable, 'class')) {
59
+ exact(variable, ['variable', 'class'], 'Policy variable', variablePath);
60
+ definitionRef(variable.class, 'class', 'Policy variable Class', `${variablePath}/class`);
61
+ }
62
+ else {
63
+ exact(variable, ['variable', 'selector'], 'Policy variable', variablePath);
64
+ const selectorPath = `${variablePath}/selector`;
65
+ const selector = object(variable.selector, 'Policy variable selector', selectorPath);
66
+ if (selector.kind === 'any') {
67
+ exact(selector, ['kind'], 'Policy variable selector', selectorPath);
68
+ }
69
+ else if (selector.kind === 'satisfies') {
70
+ exact(selector, ['kind', 'class'], 'Policy variable selector', selectorPath);
71
+ definitionRef(selector.class, 'class', 'Policy variable selector Class', `${selectorPath}/class`);
72
+ }
73
+ else {
74
+ invalid('Policy variable selector kind', undefined, `${selectorPath}/kind`);
75
+ }
76
+ }
77
+ }
78
+ policyPattern(exists.where, depth + 1, `${existsPath}/where`);
79
+ return;
80
+ }
81
+ if (Object.hasOwn(value, 'allOf') || Object.hasOwn(value, 'anyOf')) {
82
+ const member = Object.hasOwn(value, 'allOf') ? 'allOf' : 'anyOf';
83
+ exact(value, [member], 'Policy pattern composition', path);
84
+ const memberPath = pointer(path, member);
85
+ const expressions = array(value[member], `Policy pattern ${member}`, memberPath);
86
+ if (expressions.length === 0)
87
+ invalid(`Policy pattern ${member}`, undefined, memberPath);
88
+ for (const [index, expression] of expressions.entries())
89
+ policyPattern(expression, depth + 1, `${memberPath}/${index}`);
90
+ return;
91
+ }
92
+ exact(value, ['source', 'class', 'target'], 'Policy Edge pattern', path, ['repeat']);
93
+ policyTerm(value.source, false, `${path}/source`);
94
+ definitionRef(value.class, 'class', 'Policy Edge Class', `${path}/class`);
95
+ policyTerm(value.target, false, `${path}/target`);
96
+ if (value.repeat !== undefined) {
97
+ const repeatPath = `${path}/repeat`;
98
+ const repeat = object(value.repeat, 'Policy repeat', repeatPath);
99
+ 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`);
102
+ if (minimum > maximum)
103
+ invalid('Policy repeat order', undefined, repeatPath);
104
+ }
105
+ }
106
+ function policyTerm(input, variableOnly, path) {
107
+ const value = object(input, 'Policy pattern term', path);
108
+ if (!variableOnly && value.kind === 'ref') {
109
+ exact(value, ['kind', 'ref'], 'Policy reference term', path);
110
+ policyObjectRef(value.ref, `${path}/ref`);
111
+ return;
112
+ }
113
+ if (value.kind === 'variable') {
114
+ exact(value, ['kind', 'id'], 'Policy variable term', path);
115
+ integer(value.id, 'Policy variable id', `${path}/id`);
116
+ return;
117
+ }
118
+ if (variableOnly ||
119
+ (value.kind !== 'subject' &&
120
+ value.kind !== 'object' &&
121
+ value.kind !== 'source' &&
122
+ value.kind !== 'target')) {
123
+ invalid('Policy pattern term', undefined, `${path}/kind`);
124
+ }
125
+ exact(value, ['kind'], 'Policy pattern term', path);
126
+ }
127
+ /** Check one callable's caller rule: `true`, the rule every caller satisfies, or Policy checks. */
128
+ export function callablePolicy(input, path) {
129
+ if (input !== true)
130
+ policyCheck(input, 0, path);
131
+ }
132
+ /**
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.
135
+ */
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))
140
+ invalid('Class rule spelling', undefined, path);
141
+ }
142
+ /** What a site calls its checks in a refusal. */
143
+ const SITE = { callable: 'Callable Policy', class: 'Class rule' };
144
+ /** Check the recursive Policy check wire grammar of one use site. */
145
+ function policyCheck(input, depth, path, site = 'callable') {
146
+ const name = SITE[site];
147
+ if (depth > 64)
148
+ invalid(`${name} depth`, undefined, path);
149
+ const value = object(input, name, path);
150
+ if (Object.hasOwn(value, 'sameNode')) {
151
+ const equality = site === 'class' ? 'Class rule equality' : 'Callable equality';
152
+ exact(value, ['sameNode'], equality, path);
153
+ const pair = object(value.sameNode, equality, `${path}/sameNode`);
154
+ exact(pair, ['left', 'right'], `${equality} operands`, `${path}/sameNode`);
155
+ policyCheckObject(pair.left, `${path}/sameNode/left`, site);
156
+ policyCheckObject(pair.right, `${path}/sameNode/right`, site);
157
+ return;
158
+ }
159
+ if (Object.hasOwn(value, 'check')) {
160
+ exact(value, ['check', 'object'], `${name} check`, path);
161
+ definitionRef(value.check, 'policy', `${name} ref`, `${path}/check`);
162
+ policyCheckObject(value.object, `${path}/object`, site);
163
+ return;
164
+ }
165
+ const member = Object.hasOwn(value, 'allOf') ? 'allOf' : 'anyOf';
166
+ exact(value, [member], `${name} composition`, path);
167
+ const memberPath = pointer(path, member);
168
+ const expressions = array(value[member], `${name} ${member}`, memberPath);
169
+ if (expressions.length === 0)
170
+ invalid(`${name} ${member}`, undefined, memberPath);
171
+ for (const [index, expression] of expressions.entries())
172
+ policyCheck(expression, depth + 1, `${memberPath}/${index}`, site);
173
+ }
174
+ function policyCheckObject(input, objectPath, site) {
175
+ const name = SITE[site];
176
+ const target = object(input, `${name} object`, objectPath);
177
+ if (target.kind === 'self')
178
+ exact(target, ['kind'], `${name} self`, objectPath);
179
+ else if (target.kind === 'input' && site === 'callable') {
180
+ exact(target, ['kind', 'field'], `${name} input`, objectPath);
181
+ memberName(target.field, `${name} input field`, `${objectPath}/field`);
182
+ }
183
+ else if (target.kind === 'ref') {
184
+ exact(target, ['kind', 'ref'], `${name} object ref`, objectPath);
185
+ policyObjectRef(target.ref, `${objectPath}/ref`);
186
+ }
187
+ else
188
+ invalid(`${name} object`, undefined, `${objectPath}/kind`);
189
+ }
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,52 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { isValueObject } from '../../../language/value/model/object.js';
3
+ 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
+ const value = object(input, `values[${programIndex}]`, path);
9
+ exact(value, ['root', 'nodes', 'patterns'], 'ValueProgram', path);
10
+ const nodesPath = `${path}/nodes`;
11
+ const nodes = array(value.nodes, 'ValueProgram nodes', nodesPath).map((node, index) => valueNode(node, index, `${nodesPath}/${index}`));
12
+ 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
+ }
45
+ return {
46
+ schema: value.schema,
47
+ children,
48
+ ...(value.reference === undefined
49
+ ? {}
50
+ : { reference: integer(value.reference, 'reference', `${path}/reference`) }),
51
+ };
52
+ }
@@ -0,0 +1,4 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ import { type ValueProgram, type CompiledClass } from '../../model/schema.js';
3
+ /** Decode a Property and re-admit its State and ordering contracts. */
4
+ export declare function compiledProperty(input: JsonValue, values: readonly ValueProgram[], node: boolean, path: string): CompiledClass['properties'][number];
@@ -0,0 +1,74 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import {} from '../../../language/state/index.js';
3
+ import { admitStateTopology } from '../../../language/state/topology.js';
4
+ import { classifyValueProgramOrdering } from '../../../language/value/ordering.js';
5
+ import {} from '../../model/schema.js';
6
+ import { invalid } from '../diagnostic.js';
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. */
9
+ export function compiledProperty(input, values, node, path) {
10
+ const value = object(input, 'Compiled Property', path);
11
+ exact(value, ['name', 'required', 'value'], 'Compiled Property', path, [
12
+ 'auto',
13
+ 'description',
14
+ 'immutable',
15
+ 'ordering',
16
+ 'state',
17
+ ]);
18
+ memberName(value.name, 'Property name', `${path}/name`);
19
+ boolean(value.required, 'Property required', `${path}/required`);
20
+ description(value.description, 'Property description', `${path}/description`);
21
+ if (value.auto !== undefined)
22
+ propertyAuto(value.auto, `${path}/auto`);
23
+ if (value.immutable !== undefined && value.immutable !== 'create' && value.immutable !== 'once') {
24
+ invalid('Property immutability', undefined, `${path}/immutable`);
25
+ }
26
+ const valueIndex = index(value.value, values.length, 'Property value', `${path}/value`);
27
+ let state;
28
+ if (value.state !== undefined) {
29
+ if (!node)
30
+ invalid('Property state placement', 'COMPILED_SOURCE_INVALID', `${path}/state`);
31
+ let topology;
32
+ try {
33
+ topology = admitStateTopology(value.state);
34
+ }
35
+ catch {
36
+ invalid('Property state topology', 'COMPILED_SOURCE_INVALID', `${path}/state`);
37
+ }
38
+ const program = values[valueIndex];
39
+ const schema = program.nodes[program.root].schema;
40
+ const states = Object.keys(topology.transitions);
41
+ const schemaObject = schema;
42
+ const schemaMatches = schema !== null &&
43
+ typeof schema === 'object' &&
44
+ !Array.isArray(schema) &&
45
+ Object.keys(schemaObject).length === 2 &&
46
+ schemaObject.type === 'string' &&
47
+ Array.isArray(schemaObject.enum) &&
48
+ schemaObject.enum.length === states.length &&
49
+ schemaObject.enum.every((state, index) => state === states[index]);
50
+ if (!value.required || value.auto !== undefined || !schemaMatches) {
51
+ invalid('Property state contract', 'COMPILED_SOURCE_INVALID', `${path}/state`);
52
+ }
53
+ state = topology;
54
+ }
55
+ if (value.ordering !== classifyValueProgramOrdering(values[valueIndex])) {
56
+ invalid('Property ordering', 'COMPILED_CANONICAL_MISMATCH', `${path}/ordering`);
57
+ }
58
+ return {
59
+ ...value,
60
+ ...(state === undefined ? {} : { state }),
61
+ };
62
+ }
63
+ function propertyAuto(input, path) {
64
+ const value = object(input, 'Property auto', path);
65
+ exact(value, ['on', 'set'], 'Property auto', path);
66
+ const eventsPath = `${path}/on`;
67
+ const events = array(value.on, 'Property auto events', eventsPath);
68
+ if (events.length === 0 || events.some((event) => event !== 'create' && event !== 'update')) {
69
+ invalid('Property auto events', undefined, eventsPath);
70
+ }
71
+ unique(events.map(String), 'Property auto events', eventsPath);
72
+ if (value.set !== 'instant')
73
+ invalid('Property auto setter', undefined, `${path}/set`);
74
+ }
@@ -0,0 +1,8 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ import { type DefinitionRef } from '../../../addressing/index.js';
3
+ /** Check a Domain or projected declaration endpoint. */
4
+ export declare function coreEndpoint(input: JsonValue | undefined, label: string, path: string): void;
5
+ /** Check a Policy reference to a projected declaration. */
6
+ export declare function policyObjectRef(input: JsonValue | undefined, path: string): void;
7
+ /** Require a canonical Definition coordinate of the expected kind. */
8
+ export declare function definitionRef<Kind extends DefinitionRef['kind'] | undefined>(input: JsonValue | undefined, kind: Kind, label: string, path: string): DefinitionRef;
@@ -0,0 +1,33 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { isDefinitionRef } from '../../../addressing/index.js';
3
+ import { MEMBER_NAME_PATTERN } from '../../../addressing/patterns.js';
4
+ import { invalid } from '../diagnostic.js';
5
+ import { object, exact } from './value.js';
6
+ /** Check a Domain or projected declaration endpoint. */
7
+ export function coreEndpoint(input, label, path) {
8
+ const value = object(input, label, path);
9
+ if (value.kind === 'domain')
10
+ exact(value, ['kind'], label, path);
11
+ else
12
+ projectedMemberRef(value, label, path);
13
+ }
14
+ /** Check a Policy reference to a projected declaration. */
15
+ export function policyObjectRef(input, path) {
16
+ projectedMemberRef(object(input, 'Policy object ref', path), 'Policy object ref', path);
17
+ }
18
+ function projectedMemberRef(ref, label, path) {
19
+ if (ref.kind !== 'method') {
20
+ definitionRef(ref, undefined, label, path);
21
+ return;
22
+ }
23
+ exact(ref, ['kind', 'owner', 'name'], `${label} Method`, path);
24
+ definitionRef(ref.owner, 'class', `${label} Method owner`, `${path}/owner`);
25
+ if (typeof ref.name !== 'string' || !MEMBER_NAME_PATTERN.test(ref.name))
26
+ invalid(`${label} Method name`, undefined, `${path}/name`);
27
+ }
28
+ /** Require a canonical Definition coordinate of the expected kind. */
29
+ export function definitionRef(input, kind, label, path) {
30
+ if (!isDefinitionRef(input) || (kind !== undefined && input.kind !== kind))
31
+ invalid(label, undefined, path);
32
+ return input;
33
+ }
@@ -0,0 +1,29 @@
1
+ import { type Value as JsonValue, type Object as JsonObject } from '@astrale-os/kernel-dsl/value';
2
+ /** Require a portable Object at the named wire boundary. */
3
+ export declare function object(input: JsonValue | undefined, label: string, path: string): JsonObject;
4
+ /** Require a portable Array at the named wire boundary. */
5
+ export declare function array(input: JsonValue | undefined, label: string, path: string): readonly JsonValue[];
6
+ /** Reject unknown and missing members in deterministic diagnostic order. */
7
+ export declare function exact(value: JsonObject, required: readonly string[], label: string, path: string, optional?: readonly string[]): void;
8
+ /** Require a non-negative safe integer. */
9
+ export declare function integer(input: JsonValue | undefined, label: string, path: string): number;
10
+ /** Require an integer within an inclusive interval. */
11
+ export declare function boundedInteger(input: JsonValue | undefined, minimum: number, maximum: number, label: string, path: string): number;
12
+ /** Require a Boolean wire value. */
13
+ export declare function boolean(input: JsonValue | undefined, label: string, path: string): boolean;
14
+ /** Require a String wire value. */
15
+ export declare function string(input: JsonValue | undefined, label: string, path: string): string;
16
+ /** Require a canonical declaration member name. */
17
+ export declare function memberName(input: JsonValue | undefined, label: string, path: string): string;
18
+ /** Check the length of an optional String member. */
19
+ export declare function boundedString(input: JsonValue | undefined, minimum: number, maximum: number, label: string, path: string): void;
20
+ /** Check the optional declaration description budget. */
21
+ export declare function description(input: JsonValue | undefined, label: string, path: string): void;
22
+ /** Reject the first repeated value at its exact index. */
23
+ export declare function unique(values: readonly string[], label: string, path: string): void;
24
+ /** Require an index within the referenced table. */
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
+ /** Order wire names independently of the host locale. */
29
+ export declare function compare(left: string, right: string): number;
@@ -0,0 +1,98 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { MEMBER_NAME_PATTERN } from '../../../addressing/patterns.js';
3
+ import { invalid, pointer } from '../diagnostic.js';
4
+ /** Require a portable Object at the named wire boundary. */
5
+ export function object(input, label, path) {
6
+ if (input === null || typeof input !== 'object' || Array.isArray(input))
7
+ invalid(label, undefined, path);
8
+ return input;
9
+ }
10
+ /** Require a portable Array at the named wire boundary. */
11
+ export function array(input, label, path) {
12
+ if (!Array.isArray(input))
13
+ invalid(label, undefined, path);
14
+ return input;
15
+ }
16
+ /** Reject unknown and missing members in deterministic diagnostic order. */
17
+ export function exact(value, required, label, path, optional = []) {
18
+ const allowed = new Set([...required, ...optional]);
19
+ const unknown = Object.keys(value)
20
+ .filter((key) => !allowed.has(key))
21
+ .sort(compare)[0];
22
+ if (unknown !== undefined)
23
+ invalid(label, undefined, pointer(path, unknown));
24
+ const missing = required.find((key) => !Object.hasOwn(value, key));
25
+ if (missing !== undefined)
26
+ invalid(label, undefined, pointer(path, missing));
27
+ }
28
+ /** Require a non-negative safe integer. */
29
+ export function integer(input, label, path) {
30
+ if (!Number.isSafeInteger(input) || input < 0)
31
+ invalid(label, undefined, path);
32
+ return input;
33
+ }
34
+ /** Require an integer within an inclusive interval. */
35
+ export function boundedInteger(input, minimum, maximum, label, path) {
36
+ const value = integer(input, label, path);
37
+ if (value < minimum || value > maximum)
38
+ invalid(label, undefined, path);
39
+ return value;
40
+ }
41
+ /** Require a Boolean wire value. */
42
+ export function boolean(input, label, path) {
43
+ if (typeof input !== 'boolean')
44
+ invalid(label, undefined, path);
45
+ return input;
46
+ }
47
+ /** Require a String wire value. */
48
+ export function string(input, label, path) {
49
+ if (typeof input !== 'string')
50
+ invalid(label, undefined, path);
51
+ return input;
52
+ }
53
+ /** Require a canonical declaration member name. */
54
+ export function memberName(input, label, path) {
55
+ const value = string(input, label, path);
56
+ if (!MEMBER_NAME_PATTERN.test(value))
57
+ invalid(label, undefined, path);
58
+ return value;
59
+ }
60
+ /** Check the length of an optional String member. */
61
+ export function boundedString(input, minimum, maximum, label, path) {
62
+ if (input === undefined)
63
+ return;
64
+ const value = string(input, label, path);
65
+ if (value.length < minimum || value.length > maximum)
66
+ invalid(label, undefined, path);
67
+ }
68
+ /** Check the optional declaration description budget. */
69
+ export function description(input, label, path) {
70
+ boundedString(input, 1, 1000, label, path);
71
+ }
72
+ /** Reject the first repeated value at its exact index. */
73
+ export function unique(values, label, path) {
74
+ const seen = new Set();
75
+ for (const [indexValue, value] of values.entries()) {
76
+ if (seen.has(value))
77
+ invalid(label, undefined, `${path}/${indexValue}`);
78
+ seen.add(value);
79
+ }
80
+ }
81
+ /** Require an index within the referenced table. */
82
+ export function index(input, length, label, path) {
83
+ const value = integer(input, label, path);
84
+ if (value >= length)
85
+ invalid(label, undefined, path);
86
+ return value;
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
+ /** Order wire names independently of the host locale. */
96
+ export function compare(left, right) {
97
+ return left < right ? -1 : left > right ? 1 : 0;
98
+ }
@@ -0,0 +1,3 @@
1
+ import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
2
+ /** Decode a View and its explicit target grammar. */
3
+ export declare function compiledView(input: JsonValue, path: string): never;
@@ -0,0 +1,17 @@
1
+ import {} from '@astrale-os/kernel-dsl/value';
2
+ import { invalid } from '../diagnostic.js';
3
+ import { definitionRef } from './reference.js';
4
+ import { object, exact, description } from './value.js';
5
+ /** Decode a View and its explicit target grammar. */
6
+ export function compiledView(input, path) {
7
+ const value = object(input, 'View', path);
8
+ exact(value, ['ref', 'target'], 'View', path, ['description']);
9
+ definitionRef(value.ref, 'view', 'View ref', `${path}/ref`);
10
+ description(value.description, 'View description', `${path}/description`);
11
+ const targetPath = `${path}/target`;
12
+ const target = object(value.target, 'View target', targetPath);
13
+ exact(target, ['kind'], 'Domain View target', targetPath);
14
+ if (target.kind !== 'domain')
15
+ invalid('View target', undefined, targetPath);
16
+ return value;
17
+ }
@@ -1,6 +1,7 @@
1
+ import { isBinaryInput } from '../../language/callable/model/callable.js';
1
2
  import { inputFieldNodes } from '../../language/value/compile/fields.js';
2
3
  import { prepareValueSchema } from '../../language/value/evaluate/preparation.js';
3
- import { classifyOrdering } from '../../language/value/ordering.js';
4
+ import { classifyPreparedOrdering } from '../../language/value/ordering.js';
4
5
  import { revisionOfDomainSchema } from '../../schema/canonical/revision.js';
5
6
  import { lookupForDomainClosure, requireDomainClosure } from '../../schema/resolution/closure.js';
6
7
  import { createDomainValueSchemaRegistry } from '../../schema/resolution/value.registry.js';
@@ -16,7 +17,7 @@ export function compile(schema) {
16
17
  const closure = Object.freeze(sources.map((source) => compileEntry(source, lookup)));
17
18
  return Object.freeze({
18
19
  format: 'astrale.dsl.compiled-schema',
19
- version: 1,
20
+ version: 2,
20
21
  root: Object.freeze({ origin: schema.origin, revision: revisionOfDomainSchema(schema) }),
21
22
  closure,
22
23
  });
@@ -24,24 +25,40 @@ export function compile(schema) {
24
25
  function compileEntry(schema, lookup) {
25
26
  const registry = createDomainValueSchemaRegistry(schema, lookup);
26
27
  const values = [];
27
- const add = (contract, pointer) => {
28
- const result = prepareValueSchema(contract, registry, pointer);
28
+ const pool = new Map();
29
+ const patternIndices = new Map();
30
+ const prepare = (contract, pointer) => {
31
+ const result = prepareValueSchema(contract, registry, pointer, pool);
29
32
  if (!result.compiled)
30
33
  throw new TypeError(`Cannot compile ValueSchema: ${result.message}`);
31
- return values.push(result.value.program()) - 1;
34
+ return result.value;
32
35
  };
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
+ };
47
+ const add = (contract, pointer) => addProgram(prepare(contract, pointer).program());
33
48
  const properties = (definition, pointer) => Object.entries(definition.properties)
34
49
  .sort(([left], [right]) => compare(left, right))
35
50
  .map(([name, property]) => {
36
- const ordering = classifyOrdering(property.schema, registry);
51
+ const prepared = prepare(property.schema, `${pointer}/properties/${name}/schema`);
52
+ const ordering = classifyPreparedOrdering(prepared);
37
53
  return {
38
54
  name,
39
55
  required: property.required,
40
- visibility: property.visibility,
41
56
  ...(property.auto === undefined ? {} : { auto: property.auto }),
57
+ ...(property.immutable === undefined ? {} : { immutable: property.immutable }),
42
58
  ...(property.description === undefined ? {} : { description: property.description }),
59
+ ...(property.state === undefined ? {} : { state: property.state }),
43
60
  ...(ordering === undefined ? {} : { ordering }),
44
- value: add(property.schema, `${pointer}/properties/${name}/schema`),
61
+ value: addProgram(prepared.program()),
45
62
  };
46
63
  });
47
64
  const output = (value, pointer) => value.mode === 'binary'
@@ -70,7 +87,8 @@ function compileEntry(schema, lookup) {
70
87
  ...(method.policy === undefined ? {} : { policy: method.policy }),
71
88
  ...(method.description === undefined ? {} : { description: method.description }),
72
89
  static: method.static,
73
- inheritance: method.inheritance,
90
+ abstract: method.abstract,
91
+ ...(method.execution === undefined ? {} : { execution: method.execution }),
74
92
  input,
75
93
  ...(fields === undefined ? {} : { fields }),
76
94
  output: output(method.output, `${pointer}/methods/${name}/output`),
@@ -81,13 +99,24 @@ function compileEntry(schema, lookup) {
81
99
  const functions = Object.values(schema.functions)
82
100
  .sort((left, right) => compare(left.ref.name, right.ref.name))
83
101
  .map((definition) => {
84
- const input = add(definition.input, `/functions/${definition.ref.name}/input`);
85
- const fields = inputFieldNodes(values[input]);
102
+ const binary = isBinaryInput(definition.input);
103
+ const inputIndex = add(binary ? definition.input.metadata : definition.input, binary
104
+ ? `/functions/${definition.ref.name}/input/metadata`
105
+ : `/functions/${definition.ref.name}/input`);
106
+ const input = binary
107
+ ? {
108
+ mode: 'binary',
109
+ metadata: inputIndex,
110
+ maximumBytes: definition.input.maximumBytes,
111
+ }
112
+ : inputIndex;
113
+ const fields = inputFieldNodes(values[inputIndex]);
86
114
  return {
87
115
  ref: definition.ref,
88
116
  auth: definition.auth,
89
117
  ...(definition.policy === undefined ? {} : { policy: definition.policy }),
90
118
  ...(definition.description === undefined ? {} : { description: definition.description }),
119
+ ...(definition.execution === undefined ? {} : { execution: definition.execution }),
91
120
  input,
92
121
  ...(fields === undefined ? {} : { fields }),
93
122
  output: output(definition.output, `/functions/${definition.ref.name}/output`),
@@ -96,6 +125,8 @@ function compileEntry(schema, lookup) {
96
125
  return Object.freeze({
97
126
  origin: schema.origin,
98
127
  revision: revisionOfDomainSchema(schema),
128
+ name: schema.name,
129
+ ...(schema.entrypoint === undefined ? {} : { entrypoint: schema.entrypoint }),
99
130
  dependencies: schema.dependencies,
100
131
  definitions: Object.freeze({
101
132
  classes: Object.freeze(classes),
@@ -106,6 +137,7 @@ function compileEntry(schema, lookup) {
106
137
  }),
107
138
  facts: Object.freeze({ core: schema.core.edges }),
108
139
  values: Object.freeze(values),
140
+ patterns: Object.freeze([...patternIndices.keys()]),
109
141
  });
110
142
  }
111
143
  function compare(left, right) {
@@ -0,0 +1,10 @@
1
+ import type { Domain } from '../domain/model/domain.js';
2
+ import type { CompiledSchema, DomainOfCompiled } from './model/schema.js';
3
+ declare const GENERATED_COMPILED_SCHEMA: unique symbol;
4
+ /** Exact compiled material embedded by an Astrale build generator. */
5
+ export interface GeneratedCompiledSchema<Resolved = Domain> extends CompiledSchema<Resolved> {
6
+ readonly [GENERATED_COMPILED_SCHEMA]: 'generated-compiled-schema';
7
+ }
8
+ /** Realize immutable, build-owned compiled material without repeating external admission. */
9
+ export declare function load<const Input extends GeneratedCompiledSchema>(input: Input): DomainOfCompiled<Input>;
10
+ export {};