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

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 +12 -51
  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 +15 -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 +16 -3
  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 +14 -10
  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 +5 -13
  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
@@ -7,6 +7,29 @@ export function policyVariableClass(variable) {
7
7
  const selector = policyVariableSelector(variable);
8
8
  return selector.kind === 'any' ? undefined : selector.class;
9
9
  }
10
+ /**
11
+ * A composition of a Pattern, a named Policy or Policy checks, read through its operator: `allOf`
12
+ * holds where every operand holds, `anyOf` where one does. It is stored under the one key its
13
+ * operator names; every reader takes the operator and the operands from here.
14
+ */
15
+ export var PolicyComposition;
16
+ (function (PolicyComposition) {
17
+ function is(value) {
18
+ return 'allOf' in value || 'anyOf' in value;
19
+ }
20
+ PolicyComposition.is = is;
21
+ function of(composition) {
22
+ return 'allOf' in composition
23
+ ? { operator: 'allOf', operands: composition.allOf }
24
+ : { operator: 'anyOf', operands: composition.anyOf };
25
+ }
26
+ PolicyComposition.of = of;
27
+ /** Store `operands` under the key `operator` names. */
28
+ function from(operator, operands) {
29
+ return operator === 'allOf' ? { allOf: operands } : { anyOf: operands };
30
+ }
31
+ PolicyComposition.from = from;
32
+ })(PolicyComposition || (PolicyComposition = {}));
10
33
  /** Exact projected identity, including Class-owned Method declarations. */
11
34
  export function policyObjectKey(ref) {
12
35
  return ref.kind === 'method'
@@ -33,9 +56,23 @@ export function projectedMemberClass(ref) {
33
56
  function kernelClassRef(name) {
34
57
  return Object.freeze({ origin: 'kernel.astrale.ai', kind: 'class', name });
35
58
  }
59
+ /**
60
+ * Every Class slot: the observations, which admit every caller when absent, then the writes, which
61
+ * admit only the Domain that declares the Class when absent.
62
+ */
63
+ export const CLASS_OPERATIONS = Object.freeze([
64
+ 'read',
65
+ 'traverse',
66
+ 'create',
67
+ 'update',
68
+ 'delete',
69
+ ]);
70
+ export function isClassObservation(operation) {
71
+ return operation === 'read' || operation === 'traverse';
72
+ }
36
73
  export function isClassRuleChecks(value) {
37
74
  return (typeof value === 'object' &&
38
- ('check' in value || 'sameNode' in value || 'allOf' in value || 'anyOf' in value));
75
+ ('check' in value || 'sameNode' in value || PolicyComposition.is(value)));
39
76
  }
40
77
  /**
41
78
  * Whether every way Policy checks can hold passes through a check, so that the caller decides each
@@ -46,7 +83,8 @@ export function checksNameTheCaller(value) {
46
83
  return true;
47
84
  if ('sameNode' in value)
48
85
  return false;
49
- if ('allOf' in value)
50
- return value.allOf.some(checksNameTheCaller);
51
- return value.anyOf.every(checksNameTheCaller);
86
+ const { operator, operands } = PolicyComposition.of(value);
87
+ return operator === 'allOf'
88
+ ? operands.some(checksNameTheCaller)
89
+ : operands.every(checksNameTheCaller);
52
90
  }
@@ -1,4 +1,4 @@
1
- import type { NodeClassPolicy, PolicyCheckExpression, PolicyExpression, PolicyPatternExpression } from '../model/policy.js';
1
+ import type { ClassSlotPolicy, PolicyCheckExpression, PolicyExpression, PolicyPatternExpression } from '../model/policy.js';
2
2
  export declare function normalizePolicyExpression(value: PolicyExpression): PolicyExpression;
3
3
  /**
4
4
  * The fixed point of the single pass: a Pattern the single pass reproduces is returned unchanged,
@@ -6,10 +6,10 @@ export declare function normalizePolicyExpression(value: PolicyExpression): Poli
6
6
  */
7
7
  export declare function normalizePolicyPattern(value: PolicyPatternExpression): PolicyPatternExpression;
8
8
  /**
9
- * The one spelling of a Node Class observation rule: normalized Policy checks without a composition
10
- * of one operand, or the Policy that a lone check of `self` names, which is how a Class has always
11
- * declared one. Callable checks keep their compositions of one operand: their revisions predate
12
- * this rule.
9
+ * The one spelling of a Class rule: normalized Policy checks without a composition of one operand,
10
+ * or the Policy that a lone check of `self` names, which is how a Class has always declared one.
11
+ * Callable checks keep their compositions of one operand: their revisions predate this rule. A
12
+ * create rule checks no `self`, so it keeps its checks.
13
13
  */
14
- export declare function normalizeClassRule(value: NodeClassPolicy): NodeClassPolicy;
14
+ export declare function normalizeClassRule<Slot extends ClassSlotPolicy>(value: Slot): Slot;
15
15
  export declare function normalizePolicyChecks(value: PolicyCheckExpression): PolicyCheckExpression;
@@ -1,14 +1,12 @@
1
1
  import { json } from '@astrale-os/kernel-dsl/value';
2
2
  import { definitionRefIndex, compareDefinitionRefs } from '../../../addressing/ordering.js';
3
- import { isClassRuleChecks, policyObjectKey, policyVariableSelector } from '../model/policy.js';
3
+ import { isClassRuleChecks, PolicyComposition, policyObjectKey, policyVariableSelector, } from '../model/policy.js';
4
4
  export function normalizePolicyExpression(value) {
5
5
  if ('match' in value) {
6
6
  return { match: normalizePolicyPattern(value.match) };
7
7
  }
8
- if ('allOf' in value) {
9
- return { allOf: uniqueRefs(value.allOf) };
10
- }
11
- return { anyOf: uniqueRefs(value.anyOf) };
8
+ const { operator, operands: refs } = PolicyComposition.of(value);
9
+ return PolicyComposition.from(operator, operands(uniqueRefs(refs)));
12
10
  }
13
11
  /**
14
12
  * Passes after the first, while one still changes the Pattern. A pass numbers variables by the
@@ -40,58 +38,53 @@ function normalizePatternOnce(value) {
40
38
  return normalizePatternNode(rewritten);
41
39
  }
42
40
  /**
43
- * The one spelling of a Node Class observation rule: normalized Policy checks without a composition
44
- * of one operand, or the Policy that a lone check of `self` names, which is how a Class has always
45
- * declared one. Callable checks keep their compositions of one operand: their revisions predate
46
- * this rule.
41
+ * The one spelling of a Class rule: normalized Policy checks without a composition of one operand,
42
+ * or the Policy that a lone check of `self` names, which is how a Class has always declared one.
43
+ * Callable checks keep their compositions of one operand: their revisions predate this rule. A
44
+ * create rule checks no `self`, so it keeps its checks.
47
45
  */
48
46
  export function normalizeClassRule(value) {
49
47
  if (!isClassRuleChecks(value))
50
48
  return value;
51
49
  const checks = unwrapSingleOperands(normalizePolicyChecks(value));
52
- return 'check' in checks && checks.object.kind === 'self' ? checks.check : checks;
50
+ return ('check' in checks && checks.object.kind === 'self' ? checks.check : checks);
53
51
  }
54
52
  /** Replace each composition of one operand by that operand, merging what it then nests. */
55
53
  function unwrapSingleOperands(value) {
56
54
  if ('check' in value || 'sameNode' in value)
57
55
  return value;
58
- const all = 'allOf' in value;
59
- const children = uniqueJson((all ? value.allOf : value.anyOf).flatMap((child) => {
60
- const unwrapped = unwrapSingleOperands(child);
61
- if (all && 'allOf' in unwrapped)
62
- return unwrapped.allOf;
63
- if (!all && 'anyOf' in unwrapped)
64
- return unwrapped.anyOf;
65
- return [unwrapped];
66
- }));
56
+ const { operator, operands: values } = PolicyComposition.of(value);
57
+ const children = uniqueJson(values.flatMap((child) => operandsUnder(operator, unwrapSingleOperands(child))));
67
58
  if (children.length === 1)
68
59
  return children[0];
69
- const operands = policyCheckComposition(children);
70
- return all ? { allOf: operands } : { anyOf: operands };
60
+ return PolicyComposition.from(operator, operands(children));
71
61
  }
72
62
  export function normalizePolicyChecks(value) {
73
63
  if ('check' in value)
74
64
  return value;
75
65
  if ('sameNode' in value)
76
66
  return { sameNode: normalizeEquality(value.sameNode) };
77
- if ('allOf' in value) {
78
- const children = value.allOf.flatMap((child) => {
79
- const normalized = normalizePolicyChecks(child);
80
- return 'allOf' in normalized ? normalized.allOf : [normalized];
81
- });
82
- return { allOf: policyCheckComposition(uniqueJson(children)) };
83
- }
84
- const children = value.anyOf.flatMap((child) => {
85
- const normalized = normalizePolicyChecks(child);
86
- return 'anyOf' in normalized ? normalized.anyOf : [normalized];
87
- });
88
- return { anyOf: policyCheckComposition(uniqueJson(children)) };
67
+ const { operator, operands: values } = PolicyComposition.of(value);
68
+ const children = values.flatMap((child) => operandsUnder(operator, normalizePolicyChecks(child)));
69
+ return PolicyComposition.from(operator, operands(uniqueJson(children)));
89
70
  }
90
- function policyCheckComposition(values) {
91
- // Structural routing may carry an invalid empty array into semantic validation;
92
- // validateChecks reports it before the DomainSchema can be accepted.
71
+ /**
72
+ * The operands of a non-empty list, mapped, flattened, deduplicated or sorted one by one: still at
73
+ * least one. The structure and compiled admission refuse an empty list.
74
+ */
75
+ function operands(values) {
93
76
  return values;
94
77
  }
78
+ /**
79
+ * What `value` contributes to a composition under `operator`: its operands if it composes so. The
80
+ * grammar is recursive, so a composition's operands are of its own expression type.
81
+ */
82
+ function operandsUnder(operator, value) {
83
+ if (!PolicyComposition.is(value))
84
+ return [value];
85
+ const composed = PolicyComposition.of(value);
86
+ return composed.operator === operator ? composed.operands : [value];
87
+ }
95
88
  function normalizePatternNode(value) {
96
89
  if ('sameNode' in value)
97
90
  return { sameNode: normalizeEquality(value.sameNode) };
@@ -106,23 +99,14 @@ function normalizePatternNode(value) {
106
99
  if ('exists' in value) {
107
100
  return {
108
101
  exists: {
109
- nodes: [...value.exists.nodes].sort((left, right) => left.variable.id - right.variable.id),
102
+ nodes: operands([...value.exists.nodes].sort((left, right) => left.variable.id - right.variable.id)),
110
103
  where: normalizePatternNode(value.exists.where),
111
104
  },
112
105
  };
113
106
  }
114
- if ('allOf' in value) {
115
- const children = value.allOf.flatMap((child) => {
116
- const normalized = normalizePatternNode(child);
117
- return 'allOf' in normalized ? normalized.allOf : [normalized];
118
- });
119
- return { allOf: uniqueJson(children) };
120
- }
121
- const children = value.anyOf.flatMap((child) => {
122
- const normalized = normalizePatternNode(child);
123
- return 'anyOf' in normalized ? normalized.anyOf : [normalized];
124
- });
125
- return { anyOf: uniqueJson(children) };
107
+ const { operator, operands: values } = PolicyComposition.of(value);
108
+ const children = values.flatMap((child) => operandsUnder(operator, normalizePatternNode(child)));
109
+ return PolicyComposition.from(operator, operands(uniqueJson(children)));
126
110
  }
127
111
  function canonicalVariableIds(value) {
128
112
  const declarations = new Map();
@@ -180,12 +164,10 @@ function collectDeclarations(value, result, depths, depth = 0) {
180
164
  collectDeclarations(value.exists.where, result, depths, depth + 1);
181
165
  return;
182
166
  }
183
- if ('allOf' in value)
184
- for (const child of value.allOf)
185
- collectDeclarations(child, result, depths, depth);
186
- if ('anyOf' in value)
187
- for (const child of value.anyOf)
188
- collectDeclarations(child, result, depths, depth);
167
+ if (!PolicyComposition.is(value))
168
+ return;
169
+ for (const child of PolicyComposition.of(value).operands)
170
+ collectDeclarations(child, result, depths, depth);
189
171
  }
190
172
  function collectUses(value, result) {
191
173
  if ('sameNode' in value) {
@@ -206,8 +188,7 @@ function collectUses(value, result) {
206
188
  }
207
189
  if ('exists' in value)
208
190
  return collectUses(value.exists.where, result);
209
- const children = 'allOf' in value ? value.allOf : value.anyOf;
210
- for (const child of children)
191
+ for (const child of PolicyComposition.of(value).operands)
211
192
  collectUses(child, result);
212
193
  }
213
194
  function rank(names) {
@@ -253,12 +234,11 @@ function collectFirstUseKeys(value, colors, scoped, result, prefix = '$') {
253
234
  collectFirstUseKeys(value.exists.where, colors, scoped, result, `${prefix}:exists`);
254
235
  return;
255
236
  }
256
- const key = 'allOf' in value ? 'allOf' : 'anyOf';
257
- const operands = 'allOf' in value ? value.allOf : value.anyOf;
237
+ const { operator, operands } = PolicyComposition.of(value);
258
238
  const children = operands
259
239
  .map((child) => [patternSignature(child, colors), patternSignature(child, scoped), child])
260
240
  .sort(([left, leftScoped], [right, rightScoped]) => compareUtf8Bytes(left, right) || compareUtf8Bytes(leftScoped, rightScoped));
261
- children.forEach(([, , child], index) => collectFirstUseKeys(child, colors, scoped, result, `${prefix}:${key}:${index}`));
241
+ children.forEach(([, , child], index) => collectFirstUseKeys(child, colors, scoped, result, `${prefix}:${operator}:${index}`));
262
242
  }
263
243
  function patternSignature(value, colors) {
264
244
  if ('sameNode' in value)
@@ -272,9 +252,8 @@ function patternSignature(value, colors) {
272
252
  .sort(compareUtf8Bytes)
273
253
  .join(',')}:${patternSignature(value.exists.where, colors)}`;
274
254
  }
275
- const key = 'allOf' in value ? 'allOf' : 'anyOf';
276
- const operands = 'allOf' in value ? value.allOf : value.anyOf;
277
- return `${key}:${operands
255
+ const { operator, operands } = PolicyComposition.of(value);
256
+ return `${operator}:${operands
278
257
  .map((child) => patternSignature(child, colors))
279
258
  .sort(compareUtf8Bytes)
280
259
  .join('|')}`;
@@ -297,7 +276,7 @@ function rewriteVariables(value, ids) {
297
276
  if ('exists' in value) {
298
277
  return {
299
278
  exists: {
300
- nodes: value.exists.nodes.map((node) => {
279
+ nodes: operands(value.exists.nodes.map((node) => {
301
280
  const variable = {
302
281
  kind: 'variable',
303
282
  id: ids.get(node.variable.id) ?? node.variable.id,
@@ -305,14 +284,13 @@ function rewriteVariables(value, ids) {
305
284
  return 'class' in node
306
285
  ? { variable, class: node.class }
307
286
  : { variable, selector: node.selector };
308
- }),
287
+ })),
309
288
  where: rewriteVariables(value.exists.where, ids),
310
289
  },
311
290
  };
312
291
  }
313
- if ('allOf' in value)
314
- return { allOf: value.allOf.map((child) => rewriteVariables(child, ids)) };
315
- return { anyOf: value.anyOf.map((child) => rewriteVariables(child, ids)) };
292
+ const { operator, operands: values } = PolicyComposition.of(value);
293
+ return PolicyComposition.from(operator, operands(values.map((child) => rewriteVariables(child, ids))));
316
294
  }
317
295
  function selectorSignature(node) {
318
296
  const selector = policyVariableSelector(node);
@@ -0,0 +1,7 @@
1
+ /** A computation that suspends on each computation whose answer it waits for. */
2
+ export type Suspended<Answer, Result = Answer> = Generator<Suspended<Answer>, Result, Answer>;
3
+ /**
4
+ * The answer of a suspended computation. Those waiting on one another sit on a stack of their own,
5
+ * so how many can wait at once does not depend on the call stack.
6
+ */
7
+ export declare function runSuspended<Answer>(start: Suspended<Answer>): Answer;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The answer of a suspended computation. Those waiting on one another sit on a stack of their own,
3
+ * so how many can wait at once does not depend on the call stack.
4
+ */
5
+ export function runSuspended(start) {
6
+ const waiting = [];
7
+ let current = start;
8
+ let step = current.next();
9
+ for (;;) {
10
+ if (step.done === true) {
11
+ const caller = waiting.pop();
12
+ if (caller === undefined)
13
+ return step.value;
14
+ current = caller;
15
+ step = current.next(step.value);
16
+ }
17
+ else {
18
+ waiting.push(current);
19
+ current = step.value;
20
+ step = current.next();
21
+ }
22
+ }
23
+ }
@@ -1,4 +1,4 @@
1
- export type DiagnosticCode = 'CALLABLE_INPUT_FIELD_UNKNOWN' | 'DOMAIN_CLASS_ABSTRACT' | 'DOMAIN_PROPERTY_INPUT_INVALID' | 'DOMAIN_PROPERTY_REQUIRED' | 'DOMAIN_PROPERTY_UNKNOWN' | 'DOMAIN_VALIDATION_TARGET_UNKNOWN' | 'VALUE_SCHEMA_INSTANCE_INVALID' | 'VS_DIALECT' | 'VS_DYNAMIC_FORBIDDEN' | 'VS_KEYWORD_CLOSED' | 'VS_META_SCHEMA' | 'VS_NUMBER_DOMAIN' | 'VS_PATH_EXTENSION' | 'VS_RECURSION_PRODUCTIVE' | 'VS_REFERENCE_FORM' | 'VS_REFERENCE_RESOLUTION' | 'VS_REGEX_PORTABLE' | 'VS_RESOURCE_ID' | 'VS_VALUE_KIND';
1
+ export type DiagnosticCode = 'CALLABLE_INPUT_FIELD_UNKNOWN' | 'DOMAIN_CLASS_ABSTRACT' | 'DOMAIN_PROPERTY_INPUT_INVALID' | 'DOMAIN_PROPERTY_REQUIRED' | 'DOMAIN_PROPERTY_UNKNOWN' | 'VALUE_SCHEMA_INSTANCE_INVALID' | 'VS_DIALECT' | 'VS_DYNAMIC_FORBIDDEN' | 'VS_KEYWORD_CLOSED' | 'VS_META_SCHEMA' | 'VS_NUMBER_DOMAIN' | 'VS_PATH_EXTENSION' | 'VS_RECURSION_PRODUCTIVE' | 'VS_REFERENCE_FORM' | 'VS_REFERENCE_RESOLUTION' | 'VS_REGEX_PORTABLE' | 'VS_RESOURCE_ID' | 'VS_VALUE_KIND' | 'VS_VALUE_KIND_JSON';
2
2
  export interface Diagnostic<out Code extends DiagnosticCode = DiagnosticCode> {
3
3
  readonly code: Code;
4
4
  readonly pointer: string;
@@ -6,3 +6,17 @@ export interface Diagnostic<out Code extends DiagnosticCode = DiagnosticCode> {
6
6
  readonly ref?: string;
7
7
  }
8
8
  export declare function diagnostic<const Code extends DiagnosticCode>(code: Code, pointer: string, message: string, ref?: string): Diagnostic<Code>;
9
+ /** The fields every diagnostic family shares. */
10
+ interface DiagnosticFields {
11
+ readonly code: string;
12
+ readonly pointer: string;
13
+ readonly message: string;
14
+ readonly ref?: string;
15
+ }
16
+ /** Order diagnostics by pointer, then code, then message. */
17
+ export declare function orderDiagnostics<Value extends DiagnosticFields>(diagnostics: readonly Value[]): Value[];
18
+ /** Keep one of each pointer, code, ref and message, then order them. */
19
+ export declare function orderAndDeduplicate<Value extends DiagnosticFields>(diagnostics: readonly Value[]): Value[];
20
+ /** One line per diagnostic: its pointer (`/` for the root), its code and its message. */
21
+ export declare function formatDiagnostics(diagnostics: readonly DiagnosticFields[]): string;
22
+ export {};
@@ -1,3 +1,24 @@
1
+ import { compareUnicode } from '../../addressing/ordering.js';
1
2
  export function diagnostic(code, pointer, message, ref) {
2
3
  return Object.freeze({ code, pointer, message, ...(ref === undefined ? {} : { ref }) });
3
4
  }
5
+ /** Order diagnostics by pointer, then code, then message. */
6
+ export function orderDiagnostics(diagnostics) {
7
+ return [...diagnostics].sort((left, right) => compareUnicode(left.pointer, right.pointer) ||
8
+ compareUnicode(left.code, right.code) ||
9
+ compareUnicode(left.message, right.message));
10
+ }
11
+ /** Keep one of each pointer, code, ref and message, then order them. */
12
+ export function orderAndDeduplicate(diagnostics) {
13
+ const unique = new Map();
14
+ for (const value of diagnostics) {
15
+ unique.set(`${value.pointer}\u0000${value.code}\u0000${value.ref ?? ''}\u0000${value.message}`, value);
16
+ }
17
+ return orderDiagnostics([...unique.values()]);
18
+ }
19
+ /** One line per diagnostic: its pointer (`/` for the root), its code and its message. */
20
+ export function formatDiagnostics(diagnostics) {
21
+ return diagnostics
22
+ .map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
23
+ .join('\n');
24
+ }
@@ -0,0 +1,45 @@
1
+ import type { LimitKey } from '../limits.js';
2
+ import type { DiagnosticCode } from './diagnostic.js';
3
+ /**
4
+ * What a rule reads to decide. `schema`: a value schema alone, with its place in the declaration
5
+ * that holds it (a Property, a callable input or output). `context`: a value schema and what its
6
+ * Domain can reach, the Node Classes of the Domain and of its direct dependencies and the exact
7
+ * dependency closure. `value`: a value, under an accepted schema or a contract of the Domain.
8
+ * `warning`: a value schema, which the rule reports without refusing it.
9
+ */
10
+ export type ValueRuleStage = 'schema' | 'context' | 'value' | 'warning';
11
+ /**
12
+ * The rule one diagnostic code reports, whatever it checks: what `schema.RULES` and `VALUE_RULES`
13
+ * say of every code, each with the stages of its own checks.
14
+ */
15
+ export interface DiagnosticRule {
16
+ /**
17
+ * The positions the rule constrains, which its diagnostics point at: JSON Pointer templates in
18
+ * which a `{name}` token stands for one token of the kind it names and `{/path*}` for any number
19
+ * of tokens.
20
+ */
21
+ readonly positions: readonly [string, ...string[]];
22
+ /** The rule, in one plain sentence. */
23
+ readonly statement: string;
24
+ /** The limits of `schema.limits` the rule enforces, by key, where it enforces some. */
25
+ readonly limits?: readonly [LimitKey, ...LimitKey[]];
26
+ /**
27
+ * The conditions of the published JSON Schema of the document that state the rule, where some
28
+ * do: the URI fragment of each `if` or `not` subschema whose failure refuses the document with
29
+ * this rule's code.
30
+ */
31
+ readonly conditions?: readonly [string, ...string[]];
32
+ }
33
+ /**
34
+ * The rule one value diagnostic code reports. Its positions are relative to the value schema, the
35
+ * value or the Domain input it checks. A condition refuses a value schema of the document with
36
+ * `DV_VALUE_SCHEMA` and this rule's code as its `valueCode`.
37
+ */
38
+ export interface ValueRule extends DiagnosticRule {
39
+ readonly stage: ValueRuleStage;
40
+ }
41
+ /**
42
+ * Every value diagnostic code with the rule it reports. A code added to the language does not
43
+ * compile until it is described here.
44
+ */
45
+ export declare const VALUE_RULES: Readonly<Record<DiagnosticCode, ValueRule>>;
@@ -0,0 +1,109 @@
1
+ import { deepFreeze } from '../freeze.js';
2
+ /**
3
+ * Every value diagnostic code with the rule it reports. A code added to the language does not
4
+ * compile until it is described here.
5
+ */
6
+ export const VALUE_RULES = deepFreeze({
7
+ CALLABLE_INPUT_FIELD_UNKNOWN: {
8
+ stage: 'value',
9
+ positions: [''],
10
+ statement: 'An input field validated on its own is a field of the Callable input, which has fields only when it is a closed object.',
11
+ },
12
+ DOMAIN_CLASS_ABSTRACT: {
13
+ stage: 'value',
14
+ positions: ['/class'],
15
+ statement: 'Properties are validated for a concrete Class only.',
16
+ },
17
+ DOMAIN_PROPERTY_INPUT_INVALID: {
18
+ stage: 'value',
19
+ positions: ['/properties'],
20
+ statement: 'The Properties of a Class are a canonical map of Property keys to portable values.',
21
+ },
22
+ DOMAIN_PROPERTY_REQUIRED: {
23
+ stage: 'value',
24
+ positions: ['/properties/{key}'],
25
+ statement: 'Every required Property of the Class has a value.',
26
+ },
27
+ DOMAIN_PROPERTY_UNKNOWN: {
28
+ stage: 'value',
29
+ positions: ['/properties/{key}'],
30
+ statement: 'Every Property given a value is a Property of the Class, its own or inherited.',
31
+ },
32
+ VALUE_SCHEMA_INSTANCE_INVALID: {
33
+ stage: 'value',
34
+ positions: ['{/path*}'],
35
+ statement: 'A value satisfies its complete value schema.',
36
+ },
37
+ VS_DIALECT: {
38
+ stage: 'schema',
39
+ positions: ['{/path*}/$schema'],
40
+ statement: 'A value schema names $schema at its root only, and there names the dialect https://schemas.astrale.ai/dsl/v1/value-schema.',
41
+ },
42
+ VS_DYNAMIC_FORBIDDEN: {
43
+ stage: 'schema',
44
+ positions: [
45
+ '{/path*}/$anchor',
46
+ '{/path*}/$dynamicAnchor',
47
+ '{/path*}/$dynamicRef',
48
+ '{/path*}/$vocabulary',
49
+ ],
50
+ statement: 'A value schema names none of $anchor, $dynamicAnchor, $dynamicRef and $vocabulary.',
51
+ },
52
+ VS_KEYWORD_CLOSED: {
53
+ stage: 'schema',
54
+ positions: ['{/path*}/{keyword}'],
55
+ statement: 'Every keyword of a value schema is one of the closed V1 vocabulary.',
56
+ },
57
+ VS_META_SCHEMA: {
58
+ stage: 'schema',
59
+ positions: ['{/path*}'],
60
+ statement: 'A value schema is JSON valid under the meta-schema of the dialect, with fullMatch a string and no two equal values in an enum, at every location.',
61
+ },
62
+ VS_NUMBER_DOMAIN: {
63
+ stage: 'value',
64
+ positions: ['{/path*}'],
65
+ statement: 'A value, like a value schema, is portable JSON: its numbers are finite and not negative zero, its strings well formed, and its size within the value limits.',
66
+ },
67
+ VS_PATH_EXTENSION: {
68
+ stage: 'schema',
69
+ positions: ['{/path*}/x-astrale-path{/path*}', '{/path*}'],
70
+ statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema, and reads target node, cardinality one and a non-empty set of Node Class refs it accepts.',
71
+ },
72
+ VS_RECURSION_PRODUCTIVE: {
73
+ stage: 'schema',
74
+ positions: ['{/path*}'],
75
+ statement: 'Every reference cycle of a value schema crosses a keyword that steps into the value: to a member, a member name or an item.',
76
+ },
77
+ VS_REFERENCE_FORM: {
78
+ stage: 'schema',
79
+ positions: ['{/path*}/$ref'],
80
+ statement: 'A $ref is a JSON Pointer fragment into its own value schema, or the id of the graph NodePath schema beside x-astrale-path.',
81
+ },
82
+ VS_REFERENCE_RESOLUTION: {
83
+ stage: 'context',
84
+ positions: ['{/path*}/$ref', '{/path*}/x-astrale-path/accepts/{index}', ''],
85
+ statement: 'A $ref resolves to a location of its own value schema, x-astrale-path accepts Node Classes of the Domain or of a direct dependency, and the schema is checked with the exact dependency closure of its Domain.',
86
+ },
87
+ VS_REGEX_PORTABLE: {
88
+ stage: 'schema',
89
+ positions: ['{/path*}/pattern', '{/path*}/fullMatch', '{/path*}/patternProperties/{pattern}'],
90
+ statement: 'Every pattern, fullMatch and patternProperties name is an RFC 9485 I-Regexp within the regular-expression limits.',
91
+ limits: ['regexp.maxCodePoints', 'regexp.maxNesting', 'regexp.maxRepeat', 'regexp.maxStates'],
92
+ },
93
+ VS_RESOURCE_ID: {
94
+ stage: 'schema',
95
+ positions: ['{/path*}/$id'],
96
+ statement: 'A value schema declares no $id: it is embedded, not a resource of its own.',
97
+ },
98
+ VS_VALUE_KIND: {
99
+ stage: 'schema',
100
+ positions: ['{/path*}/x-astrale-value-kind', '{/path*}/x-astrale-file'],
101
+ statement: 'x-astrale-value-kind declares instant beside type string at any location, blob as the whole schema of a Property, exactly as values.blob writes it, or file at any location of a callable input, exactly as values.file writes it, the only place x-astrale-file stands.',
102
+ conditions: ['#/$defs/value-location/anyOf/1/if'],
103
+ },
104
+ VS_VALUE_KIND_JSON: {
105
+ stage: 'warning',
106
+ positions: ['/classes/{class}/properties/{property}'],
107
+ statement: 'A Property of value kind json is filtered by equality only, so its author is warned.',
108
+ },
109
+ });
@@ -1,60 +1,60 @@
1
+ import { compareCodeUnits } from '../../../addressing/ordering.js';
2
+ import { escapePointerToken } from '../syntax/pointer.js';
1
3
  /** Exact field constraints available for independent scalar route validation. */
2
4
  export function inputFieldNodes(program) {
3
5
  const fields = new Map();
4
6
  const visited = new Set();
5
7
  let closed = false;
6
8
  let unsupported = false;
7
- const visit = (index) => {
9
+ // A worklist, not recursion: admission runs this on the graph of a received schema, whose chain of
10
+ // references may be longer than the call stack. The result is sorted, so the visiting order does
11
+ // not show.
12
+ const pending = [program.root];
13
+ while (pending.length > 0) {
14
+ const index = pending.pop();
8
15
  if (visited.has(index))
9
- return;
16
+ continue;
10
17
  visited.add(index);
11
18
  const node = program.nodes[index];
12
19
  if (node === undefined ||
13
20
  node.schema === null ||
14
21
  typeof node.schema !== 'object' ||
15
22
  Array.isArray(node.schema))
16
- return;
23
+ continue;
17
24
  const schema = node.schema;
18
25
  if (schema.additionalProperties === false || schema.unevaluatedProperties === false)
19
26
  closed = true;
20
27
  if (schema.anyOf !== undefined || schema.oneOf !== undefined || schema.if !== undefined)
21
28
  unsupported = true;
22
29
  if (node.reference !== undefined)
23
- visit(node.reference);
30
+ pending.push(node.reference);
24
31
  if (Array.isArray(schema.allOf)) {
25
32
  schema.allOf.forEach((_, position) => {
26
33
  const child = node.children[`allOf/${position}`];
27
34
  if (child === undefined)
28
35
  throw new TypeError('Compiled input allOf branch is absent.');
29
- visit(child);
36
+ pending.push(child);
30
37
  });
31
38
  }
32
39
  if (schema.properties === null ||
33
40
  typeof schema.properties !== 'object' ||
34
41
  Array.isArray(schema.properties))
35
- return;
42
+ continue;
36
43
  for (const name of Object.keys(schema.properties)) {
37
- const child = node.children[`properties/${escapePointer(name)}`];
44
+ const child = node.children[`properties/${escapePointerToken(name)}`];
38
45
  if (child === undefined)
39
46
  throw new TypeError(`Compiled input field ${name} is absent.`);
40
47
  const constraints = fields.get(name) ?? new Set();
41
48
  constraints.add(child);
42
49
  fields.set(name, constraints);
43
50
  }
44
- };
45
- visit(program.root);
51
+ }
46
52
  if (!closed || unsupported)
47
53
  return undefined;
48
54
  return Object.freeze(Object.fromEntries([...fields]
49
- .sort(([left], [right]) => compare(left, right))
55
+ .sort(([left], [right]) => compareCodeUnits(left, right))
50
56
  .map(([name, nodes]) => [
51
57
  name,
52
58
  Object.freeze([...nodes].sort((left, right) => left - right)),
53
59
  ])));
54
60
  }
55
- function escapePointer(value) {
56
- return value.replaceAll('~', '~0').replaceAll('/', '~1');
57
- }
58
- function compare(left, right) {
59
- return left < right ? -1 : left > right ? 1 : 0;
60
- }
@@ -1,5 +1,10 @@
1
1
  import type { CompiledInstanceSchema } from '../evaluate/types.js';
2
2
  import type { IndexedValueProgram, ValueProgram } from './model.js';
3
+ /** Index the programs of one entry against the table of the machines they use, each listed once. */
4
+ export declare function indexValuePrograms(programs: readonly ValueProgram[]): {
5
+ readonly values: readonly IndexedValueProgram[];
6
+ readonly patterns: ValueProgram['patterns'];
7
+ };
3
8
  /** Bind already-admitted entry-local indices without copying any pattern machine. */
4
9
  export declare function bindValueProgram(program: IndexedValueProgram, patterns: ValueProgram['patterns']): ValueProgram;
5
10
  /** Bind admitted portable indices to the canonical instance evaluator. */
@@ -1,6 +1,19 @@
1
1
  import { loadPattern } from '../regexp/matcher.js';
2
2
  import { appendPointer } from '../syntax/pointer.js';
3
3
  const loadedPrograms = new WeakMap();
4
+ /** Index the programs of one entry against the table of the machines they use, each listed once. */
5
+ export function indexValuePrograms(programs) {
6
+ const indices = new Map();
7
+ const indexOf = (pattern) => {
8
+ const known = indices.get(pattern);
9
+ if (known !== undefined)
10
+ return known;
11
+ indices.set(pattern, indices.size);
12
+ return indices.size - 1;
13
+ };
14
+ const values = programs.map((program) => Object.freeze({ ...program, patterns: Object.freeze(program.patterns.map(indexOf)) }));
15
+ return { values: Object.freeze(values), patterns: Object.freeze([...indices.keys()]) };
16
+ }
4
17
  /** Bind already-admitted entry-local indices without copying any pattern machine. */
5
18
  export function bindValueProgram(program, patterns) {
6
19
  return Object.freeze({