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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. package/dist/v1/addressing/class-key.js +3 -3
  2. package/dist/v1/addressing/definition-ref.js +21 -37
  3. package/dist/v1/addressing/domain-dependency.d.ts +0 -6
  4. package/dist/v1/addressing/domain-dependency.js +1 -6
  5. package/dist/v1/addressing/key.d.ts +4 -1
  6. package/dist/v1/addressing/key.js +23 -3
  7. package/dist/v1/addressing/ordering.d.ts +2 -0
  8. package/dist/v1/addressing/ordering.js +2 -0
  9. package/dist/v1/addressing/patterns.d.ts +1 -1
  10. package/dist/v1/addressing/patterns.js +2 -6
  11. package/dist/v1/builder/callable/authoring.d.ts +11 -5
  12. package/dist/v1/builder/callable/authoring.js +2 -0
  13. package/dist/v1/builder/class/authoring.d.ts +94 -224
  14. package/dist/v1/builder/class/authoring.js +30 -35
  15. package/dist/v1/builder/class/handle.d.ts +27 -0
  16. package/dist/v1/builder/class/handle.js +1 -0
  17. package/dist/v1/builder/class/input.d.ts +159 -0
  18. package/dist/v1/builder/class/projection.d.ts +129 -0
  19. package/dist/v1/builder/class/projection.js +1 -0
  20. package/dist/v1/builder/class/property.d.ts +3 -9
  21. package/dist/v1/builder/class/property.js +1 -0
  22. package/dist/v1/builder/core/authoring.d.ts +1 -1
  23. package/dist/v1/builder/index.d.ts +10 -2
  24. package/dist/v1/builder/index.js +2 -0
  25. package/dist/v1/builder/lowering/callable.js +1 -0
  26. package/dist/v1/builder/lowering/class.d.ts +9 -1
  27. package/dist/v1/builder/lowering/class.js +62 -17
  28. package/dist/v1/builder/lowering/policy.js +6 -24
  29. package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
  30. package/dist/v1/builder/lowering/property-keys.js +108 -0
  31. package/dist/v1/builder/lowering/schema/compile.js +13 -6
  32. package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
  33. package/dist/v1/builder/lowering/schema/context.js +36 -7
  34. package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
  35. package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
  36. package/dist/v1/builder/lowering/value/compile.js +29 -22
  37. package/dist/v1/builder/lowering/value/file.d.ts +7 -0
  38. package/dist/v1/builder/lowering/value/file.js +14 -0
  39. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  40. package/dist/v1/builder/lowering/value/path.js +2 -4
  41. package/dist/v1/builder/lowering/value/zod.js +41 -7
  42. package/dist/v1/builder/policy/authoring.d.ts +80 -9
  43. package/dist/v1/builder/policy/authoring.js +99 -68
  44. package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
  45. package/dist/v1/builder/policy/legacy/edge.js +16 -0
  46. package/dist/v1/builder/schema/define.d.ts +0 -1
  47. package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
  48. package/dist/v1/builder/schema/diagnostic.js +5 -10
  49. package/dist/v1/builder/schema/input.d.ts +4 -1
  50. package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
  51. package/dist/v1/builder/schema/projection/class.d.ts +78 -16
  52. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  53. package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
  54. package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
  55. package/dist/v1/builder/schema/projection/model.d.ts +4 -2
  56. package/dist/v1/builder/schema/projection/property.d.ts +38 -4
  57. package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
  58. package/dist/v1/builder/schema/projection.d.ts +1 -1
  59. package/dist/v1/builder/schema/rule.d.ts +316 -0
  60. package/dist/v1/builder/schema/rule.js +192 -0
  61. package/dist/v1/builder/value/file.d.ts +34 -0
  62. package/dist/v1/builder/value/file.js +77 -0
  63. package/dist/v1/builder/value/full-match.d.ts +0 -1
  64. package/dist/v1/builder/value/full-match.js +0 -1
  65. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  66. package/dist/v1/builder/value/path.d.ts +1 -1
  67. package/dist/v1/bundle/codec.js +55 -74
  68. package/dist/v1/bundle/diagnostic.d.ts +3 -1
  69. package/dist/v1/bundle/diagnostic.js +9 -7
  70. package/dist/v1/bundle/index.d.ts +2 -0
  71. package/dist/v1/bundle/index.js +1 -0
  72. package/dist/v1/bundle/model.js +1 -1
  73. package/dist/v1/bundle/rule.d.ts +14 -0
  74. package/dist/v1/bundle/rule.js +41 -0
  75. package/dist/v1/bundle/structure.js +6 -8
  76. package/dist/v1/compiled/admission/accept.js +9 -15
  77. package/dist/v1/compiled/admission/closure.js +17 -34
  78. package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
  79. package/dist/v1/compiled/admission/diagnostic.js +40 -3
  80. package/dist/v1/compiled/admission/revision.d.ts +9 -1
  81. package/dist/v1/compiled/admission/revision.js +7 -3
  82. package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
  83. package/dist/v1/compiled/admission/semantics/class.js +48 -19
  84. package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
  85. package/dist/v1/compiled/admission/semantics/core.js +56 -24
  86. package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
  87. package/dist/v1/compiled/admission/semantics/edge.js +6 -65
  88. package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
  89. package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
  90. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
  91. package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
  92. package/dist/v1/compiled/admission/semantics/policy/parity.js +44 -53
  93. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
  94. package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
  95. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
  96. package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
  97. package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
  98. package/dist/v1/compiled/admission/wire/callable.js +24 -20
  99. package/dist/v1/compiled/admission/wire/class.js +79 -30
  100. package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
  101. package/dist/v1/compiled/admission/wire/entry.js +36 -13
  102. package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
  103. package/dist/v1/compiled/admission/wire/policy.js +27 -20
  104. package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
  105. package/dist/v1/compiled/admission/wire/program.js +39 -44
  106. package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
  107. package/dist/v1/compiled/admission/wire/property.js +8 -5
  108. package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
  109. package/dist/v1/compiled/admission/wire/value.js +0 -7
  110. package/dist/v1/compiled/codec/json.js +4 -3
  111. package/dist/v1/compiled/compiler/compile.js +15 -33
  112. package/dist/v1/compiled/diagnostic.d.ts +1 -1
  113. package/dist/v1/compiled/diagnostic.js +2 -3
  114. package/dist/v1/compiled/index.d.ts +2 -0
  115. package/dist/v1/compiled/index.js +1 -0
  116. package/dist/v1/compiled/loader/load.d.ts +3 -2
  117. package/dist/v1/compiled/loader/load.js +13 -52
  118. package/dist/v1/compiled/model/schema.d.ts +3 -0
  119. package/dist/v1/compiled/rule.d.ts +49 -0
  120. package/dist/v1/compiled/rule.js +169 -0
  121. package/dist/v1/domain/create.js +9 -10
  122. package/dist/v1/domain/model/domain.d.ts +2 -7
  123. package/dist/v1/domain/model/input.d.ts +19 -10
  124. package/dist/v1/domain/namespace/member-collection.js +8 -7
  125. package/dist/v1/domain/projection/classes.js +11 -8
  126. package/dist/v1/domain/validation/create.d.ts +7 -16
  127. package/dist/v1/domain/validation/create.js +35 -81
  128. package/dist/v1/index.d.ts +5 -3
  129. package/dist/v1/index.js +1 -1
  130. package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
  131. package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
  132. package/dist/v1/language/callable/admission.d.ts +15 -0
  133. package/dist/v1/language/callable/admission.js +44 -0
  134. package/dist/v1/language/callable/model/callable.d.ts +10 -0
  135. package/dist/v1/language/callable/resolved.d.ts +26 -5
  136. package/dist/v1/language/chain.d.ts +7 -0
  137. package/dist/v1/language/chain.js +24 -0
  138. package/dist/v1/language/class/inheritance.d.ts +36 -5
  139. package/dist/v1/language/class/inheritance.js +85 -1
  140. package/dist/v1/language/class/lifetime.d.ts +50 -11
  141. package/dist/v1/language/class/lifetime.js +89 -20
  142. package/dist/v1/language/class/model/class.d.ts +45 -9
  143. package/dist/v1/language/class/model/edge.d.ts +31 -2
  144. package/dist/v1/language/class/model/property.d.ts +16 -7
  145. package/dist/v1/language/class/property-values.js +2 -4
  146. package/dist/v1/language/class/resolved.d.ts +9 -4
  147. package/dist/v1/language/class/unique.d.ts +143 -0
  148. package/dist/v1/language/class/unique.js +264 -0
  149. package/dist/v1/language/core/facts.d.ts +85 -0
  150. package/dist/v1/language/core/facts.js +116 -0
  151. package/dist/v1/language/cycle.d.ts +10 -0
  152. package/dist/v1/language/cycle.js +30 -0
  153. package/dist/v1/language/definition/metadata.d.ts +38 -0
  154. package/dist/v1/language/definition/metadata.js +51 -0
  155. package/dist/v1/language/freeze.d.ts +5 -0
  156. package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
  157. package/dist/v1/language/index.d.ts +7 -2
  158. package/dist/v1/language/index.js +5 -1
  159. package/dist/v1/language/limits.d.ts +83 -0
  160. package/dist/v1/language/limits.js +77 -0
  161. package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
  162. package/dist/v1/language/policy/analysis/branches.js +8 -8
  163. package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
  164. package/dist/v1/language/policy/analysis/budgets.js +140 -20
  165. package/dist/v1/language/policy/analysis/checks.js +8 -6
  166. package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
  167. package/dist/v1/language/policy/analysis/composition.js +11 -0
  168. package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
  169. package/dist/v1/language/policy/analysis/typing.js +456 -0
  170. package/dist/v1/language/policy/model/policy.d.ts +71 -9
  171. package/dist/v1/language/policy/model/policy.js +42 -4
  172. package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
  173. package/dist/v1/language/policy/normalization/normalize.js +46 -68
  174. package/dist/v1/language/suspended.d.ts +7 -0
  175. package/dist/v1/language/suspended.js +23 -0
  176. package/dist/v1/language/validation/diagnostic.d.ts +15 -1
  177. package/dist/v1/language/validation/diagnostic.js +21 -0
  178. package/dist/v1/language/validation/rule.d.ts +45 -0
  179. package/dist/v1/language/validation/rule.js +109 -0
  180. package/dist/v1/language/value/compile/fields.js +16 -16
  181. package/dist/v1/language/value/compile/load.d.ts +5 -0
  182. package/dist/v1/language/value/compile/load.js +13 -0
  183. package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
  184. package/dist/v1/language/value/evaluate/assertions.js +19 -8
  185. package/dist/v1/language/value/evaluate/evaluator.js +117 -120
  186. package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
  187. package/dist/v1/language/value/evaluate/preparation.js +100 -47
  188. package/dist/v1/language/value/evaluate/program.d.ts +2 -1
  189. package/dist/v1/language/value/evaluate/program.js +6 -6
  190. package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
  191. package/dist/v1/language/value/evaluate/validate.js +15 -11
  192. package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
  193. package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
  194. package/dist/v1/language/value/files.d.ts +44 -0
  195. package/dist/v1/language/value/files.js +151 -0
  196. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  197. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  198. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  199. package/dist/v1/language/value/inclusion/assertions.js +28 -0
  200. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  201. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  202. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  203. package/dist/v1/language/value/inclusion/equivalence.js +76 -0
  204. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  205. package/dist/v1/language/value/inclusion/evidence.js +140 -0
  206. package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
  207. package/dist/v1/language/value/inclusion/includes.js +58 -723
  208. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  209. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  210. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  211. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  212. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  213. package/dist/v1/language/value/inclusion/location.js +66 -0
  214. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  215. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  216. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  217. package/dist/v1/language/value/inclusion/objects.js +190 -0
  218. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  219. package/dist/v1/language/value/inclusion/strings.js +29 -0
  220. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  221. package/dist/v1/language/value/inclusion/types.js +34 -0
  222. package/dist/v1/language/value/model/blob.d.ts +6 -0
  223. package/dist/v1/language/value/model/blob.js +8 -0
  224. package/dist/v1/language/value/model/file.d.ts +41 -0
  225. package/dist/v1/language/value/model/file.js +122 -0
  226. package/dist/v1/language/value/ordering.d.ts +14 -0
  227. package/dist/v1/language/value/ordering.js +144 -77
  228. package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
  229. package/dist/v1/language/value/profile/canonicalize.js +67 -87
  230. package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
  231. package/dist/v1/language/value/profile/json.validate.js +18 -5
  232. package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
  233. package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
  234. package/dist/v1/language/value/profile/rules.js +27 -44
  235. package/dist/v1/language/value/profile/validate.js +1 -10
  236. package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
  237. package/dist/v1/language/value/profile/vocabulary.js +58 -5
  238. package/dist/v1/language/value/reference/closure.js +6 -6
  239. package/dist/v1/language/value/reference/recursion.js +9 -48
  240. package/dist/v1/language/value/reference/references.d.ts +3 -1
  241. package/dist/v1/language/value/reference/references.js +7 -7
  242. package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
  243. package/dist/v1/language/value/reference/registry.index.js +33 -16
  244. package/dist/v1/language/value/regexp/ast.js +6 -7
  245. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  246. package/dist/v1/language/value/regexp/compile.js +14 -12
  247. package/dist/v1/language/value/regexp/syntax.js +3 -2
  248. package/dist/v1/language/value/regexp/unicode.d.ts +1 -1
  249. package/dist/v1/language/value/regexp/unicode.js +1 -1
  250. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  251. package/dist/v1/language/value/syntax/keywords.js +4 -20
  252. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  253. package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
  254. package/dist/v1/language/value/syntax/pointer.js +5 -2
  255. package/dist/v1/language/value/syntax/walk.d.ts +9 -0
  256. package/dist/v1/language/value/syntax/walk.js +37 -20
  257. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
  258. package/dist/v1/schema/admission/accept.d.ts +3 -1
  259. package/dist/v1/schema/admission/accept.js +6 -14
  260. package/dist/v1/schema/admission/callable.d.ts +21 -0
  261. package/dist/v1/schema/admission/callable.js +96 -0
  262. package/dist/v1/schema/analysis/class.d.ts +4 -0
  263. package/dist/v1/schema/analysis/class.js +57 -17
  264. package/dist/v1/schema/canonical/revision.d.ts +4 -1
  265. package/dist/v1/schema/canonical/revision.js +8 -5
  266. package/dist/v1/schema/compatibility/api.d.ts +4 -1
  267. package/dist/v1/schema/compatibility/api.js +2 -0
  268. package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
  269. package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
  270. package/dist/v1/schema/compatibility/comparators/classes.js +50 -29
  271. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  272. package/dist/v1/schema/compatibility/comparators/members.js +1 -1
  273. package/dist/v1/schema/compatibility/comparators/values.js +2 -2
  274. package/dist/v1/schema/compatibility/context.d.ts +5 -2
  275. package/dist/v1/schema/compatibility/context.js +8 -6
  276. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  277. package/dist/v1/schema/compatibility/diff.js +2 -4
  278. package/dist/v1/schema/compatibility/extension.d.ts +11 -0
  279. package/dist/v1/schema/compatibility/extension.js +22 -0
  280. package/dist/v1/schema/compatibility/fields.d.ts +20 -4
  281. package/dist/v1/schema/compatibility/fields.js +13 -3
  282. package/dist/v1/schema/compatibility/meaning/footprint.js +16 -51
  283. package/dist/v1/schema/compatibility/model.d.ts +17 -5
  284. package/dist/v1/schema/compatibility/references.d.ts +0 -3
  285. package/dist/v1/schema/compatibility/references.js +1 -9
  286. package/dist/v1/schema/compatibility/report.js +1 -1
  287. package/dist/v1/schema/compatibility/rule.d.ts +13 -0
  288. package/dist/v1/schema/compatibility/rule.js +23 -0
  289. package/dist/v1/schema/compatibility/scope.d.ts +2 -0
  290. package/dist/v1/schema/compatibility/scope.js +4 -1
  291. package/dist/v1/schema/compatibility/structure/index.js +6 -4
  292. package/dist/v1/schema/compatibility/structure/requirements.js +58 -61
  293. package/dist/v1/schema/compatibility/versioning/index.js +1 -1
  294. package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
  295. package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
  296. package/dist/v1/schema/compatibility/walk.d.ts +17 -0
  297. package/dist/v1/schema/compatibility/walk.js +41 -0
  298. package/dist/v1/schema/diagnostic.d.ts +17 -3
  299. package/dist/v1/schema/diagnostic.js +14 -11
  300. package/dist/v1/schema/enforcement/changes.d.ts +590 -0
  301. package/dist/v1/schema/enforcement/changes.js +566 -0
  302. package/dist/v1/schema/enforcement/derived.d.ts +236 -0
  303. package/dist/v1/schema/enforcement/derived.js +243 -0
  304. package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
  305. package/dist/v1/schema/enforcement/dispose.js +275 -0
  306. package/dist/v1/schema/enforcement/facts.d.ts +89 -0
  307. package/dist/v1/schema/enforcement/facts.js +70 -0
  308. package/dist/v1/schema/enforcement/fields.d.ts +65 -0
  309. package/dist/v1/schema/enforcement/fields.js +36 -0
  310. package/dist/v1/schema/enforcement/index.d.ts +39 -0
  311. package/dist/v1/schema/enforcement/index.js +10 -0
  312. package/dist/v1/schema/enforcement/install.d.ts +1634 -0
  313. package/dist/v1/schema/enforcement/install.js +1223 -0
  314. package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
  315. package/dist/v1/schema/enforcement/lifecycle.js +91 -0
  316. package/dist/v1/schema/enforcement/model.d.ts +253 -0
  317. package/dist/v1/schema/enforcement/model.js +1 -0
  318. package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
  319. package/dist/v1/schema/enforcement/obligations.js +240 -0
  320. package/dist/v1/schema/enforcement/write.d.ts +1314 -0
  321. package/dist/v1/schema/enforcement/write.js +1017 -0
  322. package/dist/v1/schema/index.d.ts +11 -1
  323. package/dist/v1/schema/index.js +5 -0
  324. package/dist/v1/schema/model/schema.d.ts +23 -1
  325. package/dist/v1/schema/model/schema.js +1 -1
  326. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  327. package/dist/v1/schema/normalization/domain.js +50 -13
  328. package/dist/v1/schema/resolution/closure.js +2 -1
  329. package/dist/v1/schema/resolution/context.js +17 -18
  330. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  331. package/dist/v1/schema/resolution/domain.js +6 -12
  332. package/dist/v1/schema/resolution/origins.js +6 -8
  333. package/dist/v1/schema/rule.d.ts +25 -0
  334. package/dist/v1/schema/rule.js +459 -0
  335. package/dist/v1/schema/validation/callable.d.ts +35 -2
  336. package/dist/v1/schema/validation/callable.js +65 -9
  337. package/dist/v1/schema/validation/class.d.ts +6 -2
  338. package/dist/v1/schema/validation/class.js +128 -105
  339. package/dist/v1/schema/validation/core.js +103 -173
  340. package/dist/v1/schema/validation/domain.js +25 -15
  341. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  342. package/dist/v1/schema/validation/domain.json-schema.js +222 -0
  343. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  344. package/dist/v1/schema/validation/domain.route.js +18 -0
  345. package/dist/v1/schema/validation/domain.structure.d.ts +7797 -0
  346. package/dist/v1/schema/validation/domain.structure.js +516 -160
  347. package/dist/v1/schema/validation/icon.d.ts +4 -0
  348. package/dist/v1/schema/validation/icon.js +29 -0
  349. package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
  350. package/dist/v1/schema/validation/json.json-schema.js +46 -0
  351. package/dist/v1/schema/validation/policy/budgets.d.ts +37 -2
  352. package/dist/v1/schema/validation/policy/budgets.js +94 -121
  353. package/dist/v1/schema/validation/policy/context.d.ts +6 -5
  354. package/dist/v1/schema/validation/policy/context.js +7 -10
  355. package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
  356. package/dist/v1/schema/validation/policy/objects.js +6 -14
  357. package/dist/v1/schema/validation/policy/references.js +20 -62
  358. package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
  359. package/dist/v1/schema/validation/policy/typing.js +22 -356
  360. package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
  361. package/dist/v1/schema/validation/policy/uses.js +63 -91
  362. package/dist/v1/schema/validation/policy/validate.js +5 -5
  363. package/dist/v1/schema/validation/value-api.d.ts +27 -1
  364. package/dist/v1/schema/validation/value-api.js +37 -2
  365. package/dist/v1/schema/validation/value.d.ts +3 -0
  366. package/dist/v1/schema/validation/value.js +9 -17
  367. package/dist/v1/schema/validation/value.json-schema.d.ts +54 -0
  368. package/dist/v1/schema/validation/value.json-schema.js +163 -0
  369. package/dist/v1/schema/validation/view.js +4 -8
  370. package/dist/value/accept.d.ts +9 -3
  371. package/dist/value/accept.js +25 -1
  372. package/dist/value/canonical.d.ts +22 -1
  373. package/dist/value/canonical.js +114 -21
  374. package/dist/value/decode.d.ts +7 -0
  375. package/dist/value/decode.js +159 -9
  376. package/dist/value/equal.d.ts +9 -1
  377. package/dist/value/equal.js +37 -3
  378. package/dist/value/immutable.optimization.d.ts +2 -0
  379. package/dist/value/immutable.optimization.js +4 -0
  380. package/dist/value/index.d.ts +5 -3
  381. package/dist/value/index.js +2 -1
  382. package/dist/value/json.d.ts +2 -2
  383. package/dist/value/json.js +2 -2
  384. package/dist/value/limits.d.ts +11 -0
  385. package/dist/value/rule.d.ts +12 -0
  386. package/dist/value/rule.js +50 -0
  387. package/dist/value/types.d.ts +6 -0
  388. package/dist/value/unicode.d.ts +2 -1
  389. package/dist/value/unicode.js +2 -0
  390. package/package.json +15 -4
  391. package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
  392. package/dist/v1/builder/lowering/core-properties.js +0 -76
  393. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
  394. package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
  395. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
  396. package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
  397. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
  398. package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
  399. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
  400. package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
  401. package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
  402. package/dist/v1/compiled/admission/wire/pattern.js +0 -111
  403. package/dist/v1/language/class/index.d.ts +0 -8
  404. package/dist/v1/language/class/index.js +0 -1
  405. package/dist/v1/language/core/index.d.ts +0 -2
  406. package/dist/v1/language/value/index.d.ts +0 -11
  407. package/dist/v1/language/value/index.js +0 -8
  408. package/dist/v1/schema/canonical/domain.d.ts +0 -3
  409. package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
  410. package/dist/v1/schema/canonical/domain.digest.js +0 -5
  411. package/dist/v1/schema/canonical/domain.js +0 -5
  412. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  413. /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
@@ -1,119 +1,92 @@
1
1
  import { Key } from '../../../addressing/index.js';
2
2
  import { definitionRefIndex } from '../../../addressing/ordering.js';
3
3
  import { isBinaryInput } from '../../../language/callable/model/callable.js';
4
- import { admittedCheckClasses, neverAdmittedClasses, } from '../../../language/policy/analysis/checks.js';
5
- import { checksNameTheCaller, isClassRuleChecks } from '../../../language/policy/model/policy.js';
4
+ import { neverAdmittedClasses, } from '../../../language/policy/analysis/checks.js';
5
+ import { CLASS_OPERATIONS, checksNameTheCaller, isClassRuleChecks, PolicyComposition, } from '../../../language/policy/model/policy.js';
6
6
  import { normalizePolicyChecks } from '../../../language/policy/normalization/normalize.js';
7
7
  import { GRAPH_NODE_PATH_SCHEMA_ID } from '../../../language/value/syntax/node-path/schema.js';
8
- import { MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, measureChecks } from './budgets.js';
9
- import { escapePointer } from './context.js';
8
+ import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
9
+ import { declaredContracts } from '../callable.js';
10
10
  import { referenceContracts } from './objects.js';
11
11
  import { contractOfNodeDefinition } from './typing.js';
12
12
  const formatDefinitionRef = Key.of;
13
13
  /** How a refusal names the checks of each site and the contract of their objects. */
14
- const SITE = {
14
+ export const SITE = {
15
15
  callable: { checks: 'Callable checks', objects: 'the callable object contract' },
16
16
  class: { checks: 'Class rule checks', objects: 'the Class rule object contract' },
17
17
  };
18
- export function validateReadUses(context, typing) {
19
- validateClassPolicyUses(context, typing, 'read');
20
- }
21
- export function validateTraverseUses(context, typing) {
22
- validateClassPolicyUses(context, typing, 'traverse');
18
+ /** Type every Class slot: its Policy against the instance it decides, or its Policy checks. */
19
+ export function validateClassUses(context, typing) {
20
+ for (const operation of CLASS_OPERATIONS)
21
+ validateClassPolicyUses(context, typing, operation);
23
22
  }
24
23
  function validateClassPolicyUses(context, typing, operation) {
25
24
  for (const [name, declaration] of Object.entries(context.environment.candidate.classes)) {
26
25
  const ref = declaration.policies[operation];
27
26
  if (typeof ref !== 'object')
28
27
  continue;
29
- const pointer = `/classes/${escapePointer(name)}/policies/${operation}`;
28
+ const pointer = `/classes/${escapePointerToken(name)}/policies/${operation}`;
29
+ const self = { origin: context.environment.candidate.origin, kind: 'class', name };
30
30
  if (isClassRuleChecks(ref)) {
31
- // Structure admits Policy checks only on a Node Class: `self` is the observed exact Class.
31
+ // Structure admits `self` everywhere but in a Node create rule: there is no Node yet.
32
32
  validateChecks(context, typing, ref, {
33
33
  site: 'class',
34
34
  pointer,
35
35
  input: {},
36
- receiver: { origin: context.environment.candidate.origin, kind: 'class', name },
37
- instanceMethod: true,
36
+ ...(declaration.kind === 'node'
37
+ ? { receiver: self }
38
+ : { edge: { ref: self, declaration } }),
38
39
  });
39
40
  continue;
40
41
  }
41
42
  if (!context.resolvePolicy(ref, pointer))
42
43
  continue;
43
44
  if (declaration.kind === 'node') {
44
- const object = {
45
- kind: 'exact',
46
- ref: { origin: context.environment.candidate.origin, kind: 'class', name },
47
- };
45
+ const object = { kind: 'exact', ref: self };
48
46
  if (typing.policyAccepts(ref.name, object))
49
47
  continue;
50
48
  context.add('PL_USE', pointer, `${formatDefinitionRef(ref)} is not valid for every normalized branch of ${operation} Node Class ${name}.`, formatDefinitionRef(ref));
51
49
  continue;
52
50
  }
53
- const endpoints = declaration.orientation === 'directed'
54
- ? [declaration.endpoints.source, declaration.endpoints.target]
55
- : declaration.endpoints;
56
- const sources = typing.concreteEndpointClasses(endpoints[0].accepts);
57
- const targets = typing.concreteEndpointClasses(endpoints[1].accepts);
58
- const accepted = sources.every((source) => targets.every((target) => typing.policyAcceptsEdge(ref.name, { kind: 'exact', ref: source }, { kind: 'exact', ref: target })));
59
- if (!accepted) {
51
+ if (!typing.policyAcceptsEdgeClass(ref.name, declaration)) {
60
52
  context.add('PL_USE', pointer, `${formatDefinitionRef(ref)} is not valid for every concrete source/target pair of ${operation} Edge Class ${name}.`, formatDefinitionRef(ref));
61
53
  }
62
54
  }
63
55
  }
64
56
  export function validateCallableUses(context, typing) {
65
- for (const [name, declaration] of Object.entries(context.environment.candidate.functions)) {
66
- if (typeof declaration.policy !== 'object')
67
- continue;
68
- validateChecks(context, typing, declaration.policy, {
69
- site: 'callable',
70
- pointer: `/functions/${escapePointer(name)}/policy`,
71
- input: isBinaryInput(declaration.input) ? declaration.input.metadata : declaration.input,
72
- instanceMethod: false,
73
- });
74
- }
75
- for (const [name, declaration] of Object.entries(context.environment.candidate.classes)) {
76
- if (declaration.kind !== 'node')
77
- continue;
78
- validateDeclaredMethods(context, typing, 'classes', name, declaration.methods, {
79
- origin: context.environment.candidate.origin,
80
- kind: 'class',
81
- name,
82
- });
57
+ for (const { contract, pointer, receiver, method } of declaredContracts(context.environment.candidate)) {
58
+ // Definition analysis is the authority for the effective callable. A missing Method is already
59
+ // a definition diagnostic, so avoid inventing a second Policy interpretation for it.
60
+ if (method !== undefined) {
61
+ const owner = context.analysis.definitions.get(definitionRefIndex(method.owner));
62
+ if (owner !== undefined && !owner.methods.has(method.name))
63
+ continue;
64
+ }
65
+ validateContractPolicy(context, typing, contract, pointer, receiver);
83
66
  }
84
67
  }
85
- function validateDeclaredMethods(context, typing, namespace, name, methods, receiver) {
86
- const ownerAnalysis = context.analysis.definitions.get(definitionRefIndex(receiver));
87
- for (const [methodName, method] of Object.entries(methods)) {
88
- if (typeof method.policy !== 'object')
89
- continue;
90
- // Definition analysis is the authority for the effective callable. A
91
- // missing entry is already a definition diagnostic, so avoid inventing a
92
- // second Policy interpretation for it.
93
- if (ownerAnalysis !== undefined && !ownerAnalysis.methods.has(methodName))
94
- continue;
95
- validateChecks(context, typing, method.policy, {
96
- site: 'callable',
97
- pointer: `/${namespace}/${escapePointer(name)}/methods/${escapePointer(methodName)}/policy`,
98
- input: method.input,
99
- receiver,
100
- instanceMethod: !method.static,
101
- });
102
- }
68
+ /**
69
+ * Validate the Policy of one callable contract written at `pointer`, wherever it is declared:
70
+ * `self` names the Node of the `receiver` Class, and nothing where the call has no receiver.
71
+ */
72
+ export function validateContractPolicy(context, typing, contract, pointer, receiver) {
73
+ if (typeof contract.policy !== 'object')
74
+ return;
75
+ validateChecks(context, typing, contract.policy, {
76
+ site: 'callable',
77
+ pointer: `${pointer}/policy`,
78
+ input: isBinaryInput(contract.input) ? contract.input.metadata : contract.input,
79
+ ...(receiver === undefined ? {} : { receiver }),
80
+ });
103
81
  }
104
- function validateChecks(validation, typing, expression, context) {
82
+ export function validateChecks(validation, typing, expression, context) {
105
83
  // Checks decide the caller the way a named Policy does, so, as a Policy connects its subject,
106
84
  // each way they hold must pass through a check of the caller.
107
85
  if (!checksNameTheCaller(expression)) {
108
86
  validation.add('PL_CONNECTIVITY', context.pointer, `${SITE[context.site].checks} must check a Policy on every branch: sameNode alone names no caller.`);
109
87
  }
88
+ // Their budget is checked with the named Policies', from the same measure (`budgets.ts`).
110
89
  const normalized = normalizePolicyChecks(expression);
111
- const measure = measureChecks(normalized);
112
- if (measure.depth > MAX_CHECK_DEPTH ||
113
- measure.branches > MAX_BRANCHES ||
114
- measure.leaves > MAX_CHECK_LEAVES) {
115
- validation.add('PL_BUDGET', context.pointer, `${SITE[context.site].checks} require depth <= ${MAX_CHECK_DEPTH}, branches <= ${MAX_BRANCHES}, and leaves <= ${MAX_CHECK_LEAVES}; got ${measure.depth}, ${measure.branches}, ${measure.leaves}.`);
116
- }
117
90
  const leaves = new Map();
118
91
  visitChecks(validation, typing, normalized, context, context.pointer, leaves);
119
92
  for (const [object, className] of neverAdmittedClasses(normalized, leaves)) {
@@ -124,7 +97,11 @@ function visitChecks(validation, typing, expression, context, pointer, leaves) {
124
97
  if ('sameNode' in expression) {
125
98
  for (const [side, object] of Object.entries(expression.sameNode)) {
126
99
  const objectPointer = `${pointer}/sameNode/${side}`;
127
- if (object.kind === 'self')
100
+ if (object.kind === 'self' && context.edge !== undefined) {
101
+ // `self` is an Edge there, and sameNode compares Nodes.
102
+ validation.add('PL_USE', objectPointer, 'sameNode compares Nodes: self is an Edge here.');
103
+ }
104
+ else if (object.kind === 'self')
128
105
  selfContracts(validation, context, objectPointer);
129
106
  else if (object.kind === 'input')
130
107
  inputContracts(validation, context, object.field, objectPointer);
@@ -136,6 +113,16 @@ function visitChecks(validation, typing, expression, context, pointer, leaves) {
136
113
  if ('check' in expression) {
137
114
  if (!validation.resolvePolicy(expression.check, `${pointer}/check`))
138
115
  return;
116
+ if (expression.object.kind === 'self' && context.edge !== undefined) {
117
+ // An Edge is checked as an Edge Class Policy is: over every concrete endpoint pair.
118
+ if (!typing.policyAcceptsEdgeClass(expression.check.name, context.edge.declaration)) {
119
+ validation.add('PL_USE', pointer, `${formatDefinitionRef(expression.check)} is not valid for every concrete source/target pair of Edge Class ${context.edge.ref.name}.`, formatDefinitionRef(expression.check));
120
+ return;
121
+ }
122
+ const edge = formatDefinitionRef(context.edge.ref);
123
+ leaves.set(expression, { accepted: [edge], admitted: new Set([edge]) });
124
+ return;
125
+ }
139
126
  const objectPointer = `${pointer}/object`;
140
127
  const contracts = expression.object.kind === 'self'
141
128
  ? selfContracts(validation, context, objectPointer)
@@ -144,30 +131,20 @@ function visitChecks(validation, typing, expression, context, pointer, leaves) {
144
131
  : referenceContracts(validation, expression.object.ref, objectPointer);
145
132
  if (contracts === undefined)
146
133
  return;
147
- const typings = new Map(contracts.map((contract) => [
148
- contractName(contract),
149
- typing.policyBranchTyping(expression.check.name, contract),
150
- ]));
151
- const admitted = admittedCheckClasses(typings);
152
- if (admitted === undefined) {
134
+ const classes = typing.checkLeafClasses(expression.check.name, contracts);
135
+ if (classes === undefined) {
153
136
  validation.add('PL_USE', pointer, `${formatDefinitionRef(expression.check)} is incompatible with ${SITE[context.site].objects}.`, formatDefinitionRef(expression.check));
154
137
  return;
155
138
  }
156
- leaves.set(expression, { accepted: [...typings.keys()], admitted });
139
+ leaves.set(expression, classes);
157
140
  return;
158
141
  }
159
- const { key, values } = checkOperands(expression);
160
- if (values.length === 0) {
161
- validation.add('PL_COMPOSITION', `${pointer}/${key}`, `${key} must be non-empty.`);
162
- }
163
- values.forEach((child, index) => visitChecks(validation, typing, child, context, `${pointer}/${key}/${index}`, leaves));
164
- }
165
- function contractName(contract) {
166
- return contract.kind === 'exact' ? formatDefinitionRef(contract.ref) : 'default';
142
+ const { operator, operands } = PolicyComposition.of(expression);
143
+ operands.forEach((child, index) => visitChecks(validation, typing, child, context, `${pointer}/${operator}/${index}`, leaves));
167
144
  }
168
145
  function selfContracts(validation, context, pointer) {
169
- if (!context.instanceMethod || context.receiver === undefined) {
170
- validation.add('PL_USE', pointer, 'self is valid only for a Node instance Method.');
146
+ if (context.receiver === undefined) {
147
+ validation.add('PL_USE', pointer, 'self is valid only where a Node receives the call: a Node instance Method, or a Function instance, whose Node carries the contract.');
171
148
  return undefined;
172
149
  }
173
150
  return [contractOfNodeDefinition(context.receiver)];
@@ -225,8 +202,3 @@ function isDefinitionRef(value) {
225
202
  record.kind === 'class' &&
226
203
  typeof record.name === 'string');
227
204
  }
228
- function checkOperands(value) {
229
- return 'allOf' in value
230
- ? { key: 'allOf', values: value.allOf }
231
- : { key: 'anyOf', values: value.anyOf };
232
- }
@@ -1,8 +1,9 @@
1
+ import { PolicyTyping } from '../../../language/policy/analysis/typing.js';
1
2
  import { validatePolicyBudgets } from './budgets.js';
2
3
  import { PolicyValidationContext } from './context.js';
3
4
  import { validatePolicyReferences } from './references.js';
4
- import { PolicyTyping } from './typing.js';
5
- import { validateCallableUses, validateReadUses, validateTraverseUses } from './uses.js';
5
+ import { validatePolicyTyping } from './typing.js';
6
+ import { validateCallableUses, validateClassUses } from './uses.js';
6
7
  /**
7
8
  * Validates the closed V1 Policy language after structural parsing.
8
9
  *
@@ -15,9 +16,8 @@ export function validatePolicies(environment, analysis) {
15
16
  validatePolicyReferences(context);
16
17
  validatePolicyBudgets(context);
17
18
  const typing = new PolicyTyping(context);
18
- typing.validatePolicies();
19
- validateReadUses(context, typing);
20
- validateTraverseUses(context, typing);
19
+ validatePolicyTyping(context, typing);
20
+ validateClassUses(context, typing);
21
21
  validateCallableUses(context, typing);
22
22
  return Object.freeze(context.diagnostics);
23
23
  }
@@ -1,15 +1,41 @@
1
1
  /** The exact V1 value-schema grammar embedded in DomainSchema declarations. */
2
+ import type { ValueKind } from '@astrale-os/kernel-dsl/value';
2
3
  import type { Diagnostic } from '../../language/validation/diagnostic.js';
3
4
  import type { JsonSchema } from '../../language/value/model/schema.js';
4
5
  import type { OrderingKind } from '../../language/value/ordering.js';
5
6
  import type { DomainSchema } from '../model/schema.js';
6
7
  export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
7
- export { blob, isBlobValueSchema as isBlob } from '../../language/value/model/blob.js';
8
+ export { blob, isBlobReceipt, isBlobValueSchema as isBlob, } from '../../language/value/model/blob.js';
8
9
  export type { BlobOptions, BlobReceipt, BlobRef, BlobSchema, } from '../../language/value/model/blob.js';
10
+ export { file, isFileValueSchema as isFile } from '../../language/value/model/file.js';
11
+ export type { FileOptions, FileSchema } from '../../language/value/model/file.js';
12
+ export { filePositions, locateFiles } from '../../language/value/files.js';
13
+ export type { FilePosition, FileSegment, LocatedFile } from '../../language/value/files.js';
9
14
  export type { JsonSchema as Schema, JsonSchemaObject as SchemaObject, PathAnnotation, PropertyObjectSchema as PropertySchema, ValueSchemaContext as Context, } from '../../language/value/model/schema.js';
10
15
  export { instant } from '../../language/value/model/instant.js';
11
16
  export type { OrderingKind } from '../../language/value/ordering.js';
17
+ export { VALUE_KINDS } from '../../language/value/ordering.js';
18
+ export { GRAPH_NODE_PATH_SCHEMA_ID as NODE_PATH } from '../../language/value/syntax/node-path/schema.js';
19
+ export { DECLARED_VALUE_KINDS as DECLARED_KINDS, FORBIDDEN_KEYWORDS, SUBSCHEMA_KEYWORDS, VALUE_KEYWORDS as KEYWORDS, } from '../../language/value/profile/vocabulary.js';
20
+ export type { DeclaredValueKind as DeclaredKind, ValueKeyword as Keyword, } from '../../language/value/profile/vocabulary.js';
21
+ export { VALUE_RULES as RULES } from '../../language/validation/rule.js';
22
+ export type { ValueRule as Rule, ValueRuleStage as RuleStage, } from '../../language/validation/rule.js';
12
23
  /** Validate one complete JSON value under the exact accepted schema that owns the contract. */
13
24
  export declare function validate(owner: DomainSchema, contract: JsonSchema, input: unknown, pointer?: string): readonly Diagnostic[];
14
25
  /** Return the one portable scalar ordering domain admitted by a property schema, if any. */
15
26
  export declare function classifyOrdering(owner: DomainSchema, contract: JsonSchema): OrderingKind | undefined;
27
+ /**
28
+ * The value kind of a property schema: what a graph language may test on the property (Y4). It is
29
+ * the one kind of every non-null value the schema admits: `text` for strings, `number` for numbers
30
+ * and integers, `instant` for strings declared `x-astrale-value-kind: instant`, `enum` for a finite
31
+ * set of strings (`const` or `enum`), `boolean`, and `set` for arrays of `uniqueItems`. An
32
+ * ambiguous union, an object, an array with repetitions, a blob or a schema that admits no value is
33
+ * `json`. `$ref`, `allOf`, `anyOf` and `oneOf` are followed; `null` is a point of every kind.
34
+ */
35
+ export declare function classifyValueKind(owner: DomainSchema, contract: JsonSchema): ValueKind;
36
+ /**
37
+ * A warning for each class property whose value kind is `json` (an ambiguous union, an object, an
38
+ * array with repetitions): a Query filters it by equality only. Nothing refuses such a property;
39
+ * the CLI shows the warning to its author.
40
+ */
41
+ export declare function valueKindWarnings(owner: DomainSchema): readonly Diagnostic<'VS_VALUE_KIND_JSON'>[];
@@ -1,11 +1,19 @@
1
1
  /** The exact V1 value-schema grammar embedded in DomainSchema declarations. */
2
+ import { diagnostic } from '../../language/validation/diagnostic.js';
2
3
  import { validateJsonInstance } from '../../language/value/evaluate/validate.js';
3
- import { classifyOrdering as classifyOrderingWithRegistry } from '../../language/value/ordering.js';
4
+ import { classifyOrdering as classifyOrderingWithRegistry, classifyValueKind as classifyValueKindWithRegistry, } from '../../language/value/ordering.js';
5
+ import { escapePointerToken } from '../../language/value/syntax/pointer.js';
4
6
  import { createDomainValueSchemaRegistry } from '../resolution/value.registry.js';
5
7
  const registries = new WeakMap();
6
8
  export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
7
- export { blob, isBlobValueSchema as isBlob } from '../../language/value/model/blob.js';
9
+ export { blob, isBlobReceipt, isBlobValueSchema as isBlob, } from '../../language/value/model/blob.js';
10
+ export { file, isFileValueSchema as isFile } from '../../language/value/model/file.js';
11
+ export { filePositions, locateFiles } from '../../language/value/files.js';
8
12
  export { instant } from '../../language/value/model/instant.js';
13
+ export { VALUE_KINDS } from '../../language/value/ordering.js';
14
+ export { GRAPH_NODE_PATH_SCHEMA_ID as NODE_PATH } from '../../language/value/syntax/node-path/schema.js';
15
+ export { DECLARED_VALUE_KINDS as DECLARED_KINDS, FORBIDDEN_KEYWORDS, SUBSCHEMA_KEYWORDS, VALUE_KEYWORDS as KEYWORDS, } from '../../language/value/profile/vocabulary.js';
16
+ export { VALUE_RULES as RULES } from '../../language/validation/rule.js';
9
17
  /** Validate one complete JSON value under the exact accepted schema that owns the contract. */
10
18
  export function validate(owner, contract, input, pointer = '') {
11
19
  return validateJsonInstance(contract, input, registryFor(owner), pointer);
@@ -14,6 +22,33 @@ export function validate(owner, contract, input, pointer = '') {
14
22
  export function classifyOrdering(owner, contract) {
15
23
  return classifyOrderingWithRegistry(contract, registryFor(owner));
16
24
  }
25
+ /**
26
+ * The value kind of a property schema: what a graph language may test on the property (Y4). It is
27
+ * the one kind of every non-null value the schema admits: `text` for strings, `number` for numbers
28
+ * and integers, `instant` for strings declared `x-astrale-value-kind: instant`, `enum` for a finite
29
+ * set of strings (`const` or `enum`), `boolean`, and `set` for arrays of `uniqueItems`. An
30
+ * ambiguous union, an object, an array with repetitions, a blob or a schema that admits no value is
31
+ * `json`. `$ref`, `allOf`, `anyOf` and `oneOf` are followed; `null` is a point of every kind.
32
+ */
33
+ export function classifyValueKind(owner, contract) {
34
+ return classifyValueKindWithRegistry(contract, registryFor(owner));
35
+ }
36
+ /**
37
+ * A warning for each class property whose value kind is `json` (an ambiguous union, an object, an
38
+ * array with repetitions): a Query filters it by equality only. Nothing refuses such a property;
39
+ * the CLI shows the warning to its author.
40
+ */
41
+ export function valueKindWarnings(owner) {
42
+ const warnings = [];
43
+ for (const [className, definition] of Object.entries(owner.classes)) {
44
+ for (const [name, property] of Object.entries(definition.properties)) {
45
+ if (classifyValueKind(owner, property.schema) !== 'json')
46
+ continue;
47
+ warnings.push(diagnostic('VS_VALUE_KIND_JSON', `/classes/${escapePointerToken(className)}/properties/${escapePointerToken(name)}`, `The value kind of ${className}.${name} is json: a Query filters it by equality only.`));
48
+ }
49
+ }
50
+ return warnings;
51
+ }
17
52
  function registryFor(owner) {
18
53
  let registry = registries.get(owner);
19
54
  if (registry === undefined) {
@@ -1,4 +1,7 @@
1
+ import type { CallableDefinition } from '../../language/callable/model/callable.js';
1
2
  import type { ValueSchemaRegistry } from '../../language/value/reference/registry.js';
2
3
  import type { SchemaDiagnostic } from '../diagnostic.js';
3
4
  import type { DomainSchemaIR } from '../model/schema.js';
4
5
  export declare function validateEmbeddedValueSchemas(schema: DomainSchemaIR, registry: ValueSchemaRegistry): readonly SchemaDiagnostic[];
6
+ /** Validate the value schemas of one callable contract at `pointer`. */
7
+ export declare function validateCallable(declaration: CallableDefinition, pointer: string, registry: ValueSchemaRegistry, diagnostics: SchemaDiagnostic[]): void;
@@ -1,27 +1,22 @@
1
1
  import { isBinaryInput } from '../../language/callable/model/callable.js';
2
2
  import { validateValueSchema } from '../../language/value/profile/validate.js';
3
- import { diagnostic } from '../diagnostic.js';
3
+ import { escapePointerToken } from '../../language/value/syntax/pointer.js';
4
+ import { valueDiagnostic } from '../diagnostic.js';
4
5
  export function validateEmbeddedValueSchemas(schema, registry) {
5
6
  const diagnostics = [];
6
7
  for (const [name, declaration] of Object.entries(schema.classes)) {
7
- validateDefinition(declaration, `/classes/${escapePointer(name)}`, registry, diagnostics);
8
- }
9
- for (const [name, declaration] of Object.entries(schema.functions)) {
10
- validateCallable(declaration, `/functions/${escapePointer(name)}`, registry, diagnostics);
8
+ validateDefinition(declaration, `/classes/${escapePointerToken(name)}`, registry, diagnostics);
11
9
  }
10
+ // Callable contracts are validated at their site, as one contract (`validateContracts`).
12
11
  return Object.freeze(diagnostics);
13
12
  }
14
13
  function validateDefinition(declaration, pointer, registry, diagnostics) {
15
14
  for (const [name, property] of Object.entries(declaration.properties)) {
16
- validate(property.schema, 'property-facet', `${pointer}/properties/${escapePointer(name)}/schema`, registry, diagnostics);
17
- }
18
- if ('methods' in declaration) {
19
- for (const [name, method] of Object.entries(declaration.methods)) {
20
- validateCallable(method, `${pointer}/methods/${escapePointer(name)}`, registry, diagnostics);
21
- }
15
+ validate(property.schema, 'property-facet', `${pointer}/properties/${escapePointerToken(name)}/schema`, registry, diagnostics);
22
16
  }
23
17
  }
24
- function validateCallable(declaration, pointer, registry, diagnostics) {
18
+ /** Validate the value schemas of one callable contract at `pointer`. */
19
+ export function validateCallable(declaration, pointer, registry, diagnostics) {
25
20
  if (isBinaryInput(declaration.input)) {
26
21
  validate(declaration.input.metadata, 'callable-input', `${pointer}/input/metadata`, registry, diagnostics);
27
22
  }
@@ -36,10 +31,7 @@ function validateCallable(declaration, pointer, registry, diagnostics) {
36
31
  }
37
32
  }
38
33
  function validate(schema, context, pointer, registry, diagnostics) {
39
- for (const failure of validateValueSchema(schema, context, registry, pointer)) {
40
- diagnostics.push(diagnostic('DV_VALUE_SCHEMA', failure.pointer, `[${failure.code}] ${failure.message}`, failure.ref));
34
+ for (const refusal of validateValueSchema(schema, context, registry, pointer)) {
35
+ diagnostics.push(valueDiagnostic('DV_VALUE_SCHEMA', refusal));
41
36
  }
42
37
  }
43
- function escapePointer(value) {
44
- return value.replaceAll('~', '~0').replaceAll('/', '~1');
45
- }
@@ -0,0 +1,54 @@
1
+ import { type JsonSchema } from './json.json-schema.js';
2
+ /**
3
+ * The checks on value schemas JSON Schema cannot state, which the published document names with
4
+ * the positions it constrains. The Kernel reports each as `DV_VALUE_SCHEMA`, with its value code.
5
+ */
6
+ export declare const valueSchemaRules: {
7
+ readonly 'value-blob': {
8
+ readonly code: 'DV_VALUE_SCHEMA';
9
+ readonly valueCode: 'VS_VALUE_KIND';
10
+ readonly statement: 'A blob is declared only by the whole schema of a Property, exactly as values.blob writes it.';
11
+ };
12
+ readonly 'value-file': {
13
+ readonly code: 'DV_VALUE_SCHEMA';
14
+ readonly valueCode: 'VS_VALUE_KIND';
15
+ readonly statement: 'A file is declared only inside a callable input, exactly as values.file writes it, and x-astrale-file only beside it.';
16
+ };
17
+ readonly 'value-path': {
18
+ readonly code: 'DV_VALUE_SCHEMA';
19
+ readonly valueCode: 'VS_PATH_EXTENSION';
20
+ readonly statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema.';
21
+ };
22
+ readonly 'value-recursion': {
23
+ readonly code: 'DV_VALUE_SCHEMA';
24
+ readonly valueCode: 'VS_RECURSION_PRODUCTIVE';
25
+ readonly statement: string;
26
+ };
27
+ readonly 'value-reference-form': {
28
+ readonly code: 'DV_VALUE_SCHEMA';
29
+ readonly valueCode: 'VS_REFERENCE_FORM';
30
+ readonly statement: string;
31
+ };
32
+ readonly 'value-reference-resolution': {
33
+ readonly code: 'DV_VALUE_SCHEMA';
34
+ readonly valueCode: 'VS_REFERENCE_RESOLUTION';
35
+ readonly statement: 'A $ref resolves to a location of its own value schema, and x-astrale-path accepts Node Classes of the Domain or of a direct dependency.';
36
+ };
37
+ readonly 'value-regexp': {
38
+ readonly code: 'DV_VALUE_SCHEMA';
39
+ readonly valueCode: 'VS_REGEX_PORTABLE';
40
+ readonly statement: string;
41
+ };
42
+ };
43
+ export type ValueSchemaRule = keyof typeof valueSchemaRules;
44
+ /**
45
+ * The value language in JSON Schema, for the document that embeds value schemas: `root` constrains
46
+ * the `value-schema` definition with the published dialect and what the profile adds to it,
47
+ * `definitions` holds the locations it reaches and the members of the Path annotation, and
48
+ * `nodeProperty` constrains a Node Property definition. A named check leaves `x-astrale-rule` at the positions it constrains.
49
+ */
50
+ export declare function valueSchemaJsonSchema(): {
51
+ readonly root: readonly JsonSchema[];
52
+ readonly definitions: Readonly<Record<string, JsonSchema>>;
53
+ readonly nodeProperty: JsonSchema;
54
+ };
@@ -0,0 +1,163 @@
1
+ import { VALUE_RULES } from '../../language/validation/rule.js';
2
+ import { VALUE_SCHEMA_DIALECT } from '../../language/value/model/schema.js';
3
+ import { FORBIDDEN_KEYWORDS, SUBSCHEMA_KEYWORDS, VALUE_KEYWORDS, } from '../../language/value/profile/vocabulary.js';
4
+ import { named } from './json.json-schema.js';
5
+ /**
6
+ * The checks on value schemas JSON Schema cannot state, which the published document names with
7
+ * the positions it constrains. The Kernel reports each as `DV_VALUE_SCHEMA`, with its value code.
8
+ */
9
+ export const valueSchemaRules = {
10
+ 'value-blob': {
11
+ code: 'DV_VALUE_SCHEMA',
12
+ valueCode: 'VS_VALUE_KIND',
13
+ statement: 'A blob is declared only by the whole schema of a Property, exactly as values.blob writes it.',
14
+ },
15
+ 'value-file': {
16
+ code: 'DV_VALUE_SCHEMA',
17
+ valueCode: 'VS_VALUE_KIND',
18
+ statement: 'A file is declared only inside a callable input, exactly as values.file writes it, and x-astrale-file only beside it.',
19
+ },
20
+ // Its members are stated (`path-annotation`); where it stands is named.
21
+ 'value-path': {
22
+ code: 'DV_VALUE_SCHEMA',
23
+ valueCode: 'VS_PATH_EXTENSION',
24
+ statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema.',
25
+ },
26
+ 'value-recursion': {
27
+ code: 'DV_VALUE_SCHEMA',
28
+ valueCode: 'VS_RECURSION_PRODUCTIVE',
29
+ statement: VALUE_RULES.VS_RECURSION_PRODUCTIVE.statement,
30
+ },
31
+ 'value-reference-form': {
32
+ code: 'DV_VALUE_SCHEMA',
33
+ valueCode: 'VS_REFERENCE_FORM',
34
+ statement: VALUE_RULES.VS_REFERENCE_FORM.statement,
35
+ },
36
+ 'value-reference-resolution': {
37
+ code: 'DV_VALUE_SCHEMA',
38
+ valueCode: 'VS_REFERENCE_RESOLUTION',
39
+ statement: 'A $ref resolves to a location of its own value schema, and x-astrale-path accepts Node Classes of the Domain or of a direct dependency.',
40
+ },
41
+ 'value-regexp': {
42
+ code: 'DV_VALUE_SCHEMA',
43
+ valueCode: 'VS_REGEX_PORTABLE',
44
+ statement: VALUE_RULES.VS_REGEX_PORTABLE.statement,
45
+ },
46
+ };
47
+ const KIND = 'x-astrale-value-kind';
48
+ const LOCATION = '#/$defs/value-location';
49
+ const SUBSCHEMA = '#/$defs/value-subschema';
50
+ const PATH = '#/$defs/path-annotation';
51
+ const FILE = '#/$defs/file-annotation';
52
+ /**
53
+ * The value language in JSON Schema, for the document that embeds value schemas: `root` constrains
54
+ * the `value-schema` definition with the published dialect and what the profile adds to it,
55
+ * `definitions` holds the locations it reaches and the members of the Path annotation, and
56
+ * `nodeProperty` constrains a Node Property definition. A named check leaves `x-astrale-rule` at the positions it constrains.
57
+ */
58
+ export function valueSchemaJsonSchema() {
59
+ return {
60
+ root: [
61
+ { $ref: VALUE_SCHEMA_DIALECT },
62
+ { $ref: LOCATION },
63
+ objectOrBoolean({
64
+ properties: {
65
+ $schema: { const: VALUE_SCHEMA_DIALECT },
66
+ [KIND]: named({ enum: ['instant', 'blob', 'file'] }, 'value-blob', 'value-file'),
67
+ },
68
+ }),
69
+ ],
70
+ definitions: {
71
+ // Every location, the root included: the closed vocabulary and the subschemas it holds.
72
+ 'value-location': objectOrBoolean({
73
+ propertyNames: {
74
+ enum: VALUE_KEYWORDS.filter((keyword) => !FORBIDDEN_KEYWORDS.includes(keyword)),
75
+ },
76
+ properties: {
77
+ $id: false,
78
+ $ref: named({ type: 'string' }, 'value-recursion', 'value-reference-form', 'value-reference-resolution'),
79
+ enum: { type: 'array', uniqueItems: true },
80
+ fullMatch: named({ type: 'string' }, 'value-regexp'),
81
+ pattern: named({ type: 'string' }, 'value-regexp'),
82
+ 'x-astrale-file': named({ $ref: FILE }, 'value-file'),
83
+ 'x-astrale-path': named({ $ref: PATH }, 'value-path'),
84
+ ...Object.fromEntries(SUBSCHEMA_KEYWORDS.single.map((keyword) => [keyword, { $ref: SUBSCHEMA }])),
85
+ ...Object.fromEntries(SUBSCHEMA_KEYWORDS.array.map((keyword) => [
86
+ keyword,
87
+ { type: 'array', items: { $ref: SUBSCHEMA } },
88
+ ])),
89
+ ...Object.fromEntries(SUBSCHEMA_KEYWORDS.map.map((keyword) => {
90
+ const members = {
91
+ type: 'object',
92
+ additionalProperties: { $ref: SUBSCHEMA },
93
+ };
94
+ if (keyword !== 'patternProperties')
95
+ return [keyword, members];
96
+ return [keyword, named(members, 'value-regexp')];
97
+ })),
98
+ },
99
+ // An instant and a file are strings.
100
+ if: { required: [KIND], properties: { [KIND]: { enum: ['instant', 'file'] } } },
101
+ // oxlint-disable-next-line unicorn/no-thenable -- the JSON Schema keyword
102
+ then: { required: ['type'], properties: { type: { const: 'string' } } },
103
+ }),
104
+ // The Path annotation: the one Node a Path field resolves, of a Node Class it accepts.
105
+ 'path-annotation': {
106
+ type: 'object',
107
+ properties: {
108
+ target: { type: 'string', const: 'node' },
109
+ cardinality: { type: 'string', const: 'one' },
110
+ accepts: {
111
+ type: 'array',
112
+ minItems: 1,
113
+ uniqueItems: true,
114
+ items: named({ $ref: '#/$defs/class-ref' }, 'value-reference-resolution'),
115
+ },
116
+ },
117
+ required: ['target', 'cardinality', 'accepts'],
118
+ additionalProperties: false,
119
+ },
120
+ // The constraints of a file field, which a client checks before it uploads.
121
+ 'file-annotation': {
122
+ type: 'object',
123
+ properties: {
124
+ maxBytes: { type: 'integer', minimum: 1 },
125
+ mediaTypes: {
126
+ type: 'array',
127
+ minItems: 1,
128
+ uniqueItems: true,
129
+ items: { type: 'string' },
130
+ },
131
+ },
132
+ additionalProperties: false,
133
+ },
134
+ // A location below the root: no $schema, and no blob.
135
+ 'value-subschema': {
136
+ allOf: [
137
+ { $ref: LOCATION },
138
+ objectOrBoolean({
139
+ properties: {
140
+ $schema: false,
141
+ [KIND]: named({ enum: ['instant', 'file'] }, 'value-file'),
142
+ },
143
+ }),
144
+ ],
145
+ },
146
+ },
147
+ // An automatic or State Property holds no blob.
148
+ nodeProperty: {
149
+ if: { anyOf: [{ required: ['auto'] }, { required: ['state'] }] },
150
+ // oxlint-disable-next-line unicorn/no-thenable -- the JSON Schema keyword
151
+ then: {
152
+ properties: {
153
+ schema: {
154
+ not: { type: 'object', required: [KIND], properties: { [KIND]: { const: 'blob' } } },
155
+ },
156
+ },
157
+ },
158
+ },
159
+ };
160
+ }
161
+ function objectOrBoolean(object) {
162
+ return { anyOf: [{ type: 'boolean' }, { type: 'object', ...object }] };
163
+ }