@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
@@ -0,0 +1,4 @@
1
+ import type { SchemaDiagnostic } from '../diagnostic.js';
2
+ import type { DomainSchemaIR } from '../model/schema.js';
3
+ /** The Domain icon draws at least one size, each SVG text admissible for its size (DV_DOMAIN_ICON). */
4
+ export declare function validateDomainIcon(schema: DomainSchemaIR): readonly SchemaDiagnostic[];
@@ -0,0 +1,29 @@
1
+ import { DOMAIN_ICON_SIZES, domainIconSvgIssue } from '../../language/definition/metadata.js';
2
+ import { diagnostic } from '../diagnostic.js';
3
+ /** The Domain icon draws at least one size, each SVG text admissible for its size (DV_DOMAIN_ICON). */
4
+ export function validateDomainIcon(schema) {
5
+ const { icon } = schema;
6
+ if (icon === undefined)
7
+ return Object.freeze([]);
8
+ const diagnostics = [];
9
+ let drawn = 0;
10
+ for (const size of DOMAIN_ICON_SIZES) {
11
+ const art = icon[size];
12
+ if (art === undefined)
13
+ continue;
14
+ drawn += 1;
15
+ for (const variant of ['svg', 'dark']) {
16
+ const text = art[variant];
17
+ if (text === undefined)
18
+ continue;
19
+ const issue = domainIconSvgIssue(text, size);
20
+ if (issue !== undefined) {
21
+ diagnostics.push(diagnostic('DV_DOMAIN_ICON', `/icon/${size}/${variant}`, `Domain icon ${size} ${variant === 'svg' ? 'drawing' : 'dark drawing'} ${issue}.`));
22
+ }
23
+ }
24
+ }
25
+ if (drawn === 0) {
26
+ diagnostics.push(diagnostic('DV_DOMAIN_ICON', '/icon', 'Domain icon draws no size.'));
27
+ }
28
+ return Object.freeze(diagnostics);
29
+ }
@@ -0,0 +1,40 @@
1
+ import type { core as zodCore } from 'zod';
2
+ import type { DiagnosticCode as ValueDiagnosticCode } from '../../language/validation/diagnostic.js';
3
+ import type { SchemaDiagnosticCode } from '../diagnostic.js';
4
+ /** A JSON Schema of the published document, or a part of one. */
5
+ export type JsonSchema = zodCore.JSONSchema.JSONSchema;
6
+ /**
7
+ * A check JSON Schema cannot state, which the published document names: the code the Kernel
8
+ * reports, with its value code for a check on value schemas, and the rule in one plain sentence.
9
+ */
10
+ export interface NamedRuleEntry {
11
+ readonly code: SchemaDiagnosticCode;
12
+ readonly valueCode?: ValueDiagnosticCode;
13
+ readonly statement: string;
14
+ }
15
+ /**
16
+ * `schema` with the `x-astrale-rule` marker naming the checks of `Rule` it leaves to the Kernel.
17
+ * `Rule` is given at each call, so that a name outside it does not compile.
18
+ */
19
+ export declare function named<Rule extends string = never>(schema: JsonSchema, ...rules: [NoInfer<Rule>, ...NoInfer<Rule>[]]): JsonSchema;
20
+ /**
21
+ * The check that a document is portable JSON, which `schema.decode` and `schema.accept` make first.
22
+ * JSON Schema reads a parsed value and compares numbers by their value: it states that no string or
23
+ * member name holds U+0000, and cannot state negative zero, a lone surrogate, a UTF-8 size, a
24
+ * nesting depth without one definition per level, a count of members, or what the text was.
25
+ */
26
+ export declare const jsonValueRules: {
27
+ readonly 'portable-json': {
28
+ readonly code: 'DV_JSON_VALUE';
29
+ readonly statement: string;
30
+ };
31
+ };
32
+ export type JsonValueRule = keyof typeof jsonValueRules;
33
+ /**
34
+ * Portable JSON in JSON Schema: `root` constrains the whole document, and `definitions` holds every
35
+ * value it reaches and every string. The named check leaves `x-astrale-rule` on `portable-json`.
36
+ */
37
+ export declare function jsonValueJsonSchema(): {
38
+ readonly root: JsonSchema;
39
+ readonly definitions: Readonly<Record<string, JsonSchema>>;
40
+ };
@@ -0,0 +1,46 @@
1
+ import { RULES } from '../rule.js';
2
+ /**
3
+ * `schema` with the `x-astrale-rule` marker naming the checks of `Rule` it leaves to the Kernel.
4
+ * `Rule` is given at each call, so that a name outside it does not compile.
5
+ */
6
+ export function named(schema, ...rules) {
7
+ return { ...schema, 'x-astrale-rule': rules };
8
+ }
9
+ /**
10
+ * The check that a document is portable JSON, which `schema.decode` and `schema.accept` make first.
11
+ * JSON Schema reads a parsed value and compares numbers by their value: it states that no string or
12
+ * member name holds U+0000, and cannot state negative zero, a lone surrogate, a UTF-8 size, a
13
+ * nesting depth without one definition per level, a count of members, or what the text was.
14
+ */
15
+ export const jsonValueRules = {
16
+ 'portable-json': { code: 'DV_JSON_VALUE', statement: RULES.DV_JSON_VALUE.statement },
17
+ };
18
+ const VALUE = '#/$defs/portable-json';
19
+ const TEXT = '#/$defs/portable-string';
20
+ /**
21
+ * Portable JSON in JSON Schema: `root` constrains the whole document, and `definitions` holds every
22
+ * value it reaches and every string. The named check leaves `x-astrale-rule` on `portable-json`.
23
+ */
24
+ export function jsonValueJsonSchema() {
25
+ return {
26
+ root: { $ref: VALUE },
27
+ definitions: {
28
+ 'portable-json': named({
29
+ anyOf: [
30
+ { type: 'null' },
31
+ { type: 'boolean' },
32
+ { type: 'number' },
33
+ { $ref: TEXT },
34
+ { type: 'array', items: { $ref: VALUE } },
35
+ {
36
+ type: 'object',
37
+ propertyNames: { $ref: TEXT },
38
+ additionalProperties: { $ref: VALUE },
39
+ },
40
+ ],
41
+ }, 'portable-json'),
42
+ // The pattern is the character itself, which every regular-expression dialect reads.
43
+ 'portable-string': { type: 'string', not: { pattern: '\u0000' } },
44
+ },
45
+ };
46
+ }
@@ -1,4 +1,39 @@
1
+ import type { PolicyExpression } from '../../../language/policy/model/policy.js';
2
+ import type { DomainSchemaIR } from '../../model/schema.js';
1
3
  import type { PolicyValidationContext } from './context.js';
2
- import { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks } from '../../../language/policy/analysis/budgets.js';
3
- export { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks, };
4
+ import { type CheckMeasure, type PolicyMeasure } from '../../../language/policy/analysis/budgets.js';
5
+ /** What `PL_BUDGET` compares with `limits.policy` in one document, frozen. */
6
+ export interface PolicyMeasures {
7
+ /** Each named Policy the DSL can measure, by name. */
8
+ readonly policies: Readonly<Record<string, PolicyMeasure>>;
9
+ /**
10
+ * The named Policies the DSL cannot measure, in document order: a composition that reaches
11
+ * itself, or that names a Policy the document does not declare or one it cannot measure.
12
+ */
13
+ readonly unmeasured: readonly string[];
14
+ /**
15
+ * Each check tree by the JSON Pointer of its position: the Policy of a Function or a Method, or
16
+ * the rule of a Class slot.
17
+ */
18
+ readonly checks: Readonly<Record<string, CheckMeasure>>;
19
+ }
20
+ /**
21
+ * Measure the Policies of a document as `PL_BUDGET` does: it reads the document's structure alone,
22
+ * so a document the structure admits is measured whatever its other rules decide. Throws
23
+ * `SchemaError` with the diagnostics of a document that is not portable JSON or that its
24
+ * structure refuses.
25
+ */
26
+ export declare function measurePolicies(input: unknown): PolicyMeasures;
27
+ /** The measures of one structured document, from its Policies once normalized. */
28
+ export declare function measureDomainPolicies(schema: DomainSchemaIR, normalized?: ReadonlyMap<string, PolicyExpression>): PolicyMeasures;
29
+ /**
30
+ * `PL_BUDGET`: every measure of the document within `limits.policy`. Typing expands what stays in
31
+ * `normalized`, and a Policy without a measure within them has no bound on its expansion, so it
32
+ * leaves: it is refused here or by `PL_REF` or `PL_COMPOSITION`, and whatever composes it with it.
33
+ */
4
34
  export declare function validatePolicyBudgets(context: PolicyValidationContext): void;
35
+ /**
36
+ * `PL_BUDGET` for one check tree at `pointer`, from its measure: the document's trees, and the
37
+ * checks of a contract a Node carries, which no document holds.
38
+ */
39
+ export declare function validateCheckBudget(context: PolicyValidationContext, pointer: string, measure: CheckMeasure): void;
@@ -1,132 +1,105 @@
1
- import { policyObjectOrigin, policyVariableClass } from '../../../language/index.js';
2
- import { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks, } from '../../../language/policy/analysis/budgets.js';
3
- import { escapePointer } from './context.js';
4
- export { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks, };
5
- export function validatePolicyBudgets(context) {
6
- // Measure every distinct composition node once. A node's expanded measure is independent of the
7
- // path that reaches it (the only path-sensitive outcome, the back-edge `undefined`, already holds
8
- // for every node on or reaching a composition cycle, regardless of entry), so caching the
9
- // completed result by node identity turns path enumeration over the composition DAG into work
10
- // linear in the number of nodes while preserving the exact measure and PL_BUDGET decision.
11
- const measures = new Map();
12
- for (const name of Object.keys(context.environment.candidate.policies)) {
13
- const measure = measurePolicy(context, name, new Set(), measures);
1
+ import { deepFreeze } from '../../../language/freeze.js';
2
+ import { limits } from '../../../language/limits.js';
3
+ import { exceededLimits, measureChecks, policyMeasurer, } from '../../../language/policy/analysis/budgets.js';
4
+ import { CLASS_OPERATIONS, isClassRuleChecks } from '../../../language/policy/model/policy.js';
5
+ import { normalizePolicyChecks, normalizePolicyExpression, } from '../../../language/policy/normalization/normalize.js';
6
+ import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
7
+ import { structureDomainSchema } from '../domain.route.js';
8
+ import { SITE } from './uses.js';
9
+ /**
10
+ * Measure the Policies of a document as `PL_BUDGET` does: it reads the document's structure alone,
11
+ * so a document the structure admits is measured whatever its other rules decide. Throws
12
+ * `SchemaError` with the diagnostics of a document that is not portable JSON or that its
13
+ * structure refuses.
14
+ */
15
+ export function measurePolicies(input) {
16
+ return measureDomainPolicies(structureDomainSchema(input));
17
+ }
18
+ /** The measures of one structured document, from its Policies once normalized. */
19
+ export function measureDomainPolicies(schema, normalized = normalizedPolicies(schema)) {
20
+ const measurePolicy = policyMeasurer(schema.origin, normalized, (ref) => ref.origin === schema.origin &&
21
+ ref.kind === 'policy' &&
22
+ Object.hasOwn(schema.policies, ref.name));
23
+ const policies = {};
24
+ const unmeasured = [];
25
+ for (const name of Object.keys(schema.policies)) {
26
+ const measure = measurePolicy(name);
14
27
  if (measure === undefined)
15
- continue;
16
- const pointer = `/policies/${escapePointer(name)}`;
17
- if (measure.depth > MAX_PATTERN_DEPTH) {
18
- context.add('PL_BUDGET', pointer, `Expanded Pattern depth ${measure.depth} exceeds ${MAX_PATTERN_DEPTH}.`);
19
- }
20
- if (measure.edgeCounts.length > MAX_BRANCHES) {
21
- context.add('PL_BUDGET', pointer, `Expanded Pattern has more than ${MAX_BRANCHES} normalized branches.`);
22
- }
23
- const edgeMaximum = Math.max(0, ...measure.edgeCounts);
24
- if (edgeMaximum > MAX_EDGES) {
25
- context.add('PL_BUDGET', pointer, `A normalized branch contains ${edgeMaximum} graph predicates; the maximum is ${MAX_EDGES}.`);
26
- }
27
- if (measure.domains.size > MAX_DOMAINS) {
28
- context.add('PL_BUDGET', pointer, `Expanded Pattern references ${measure.domains.size} Domains; the maximum is ${MAX_DOMAINS}.`);
29
- }
28
+ unmeasured.push(name);
29
+ else
30
+ policies[name] = measure;
30
31
  }
31
- }
32
- function measurePolicy(context, name, visiting, measures) {
33
- if (visiting.has(name))
34
- return undefined;
35
- if (measures.has(name))
36
- return measures.get(name);
37
- const declaration = context.normalized.get(name);
38
- if (declaration === undefined)
39
- return undefined;
40
- const nested = new Set(visiting);
41
- nested.add(name);
42
- const measure = measureDeclaration(context, declaration, nested, measures);
43
- measures.set(name, measure);
44
- return measure;
45
- }
46
- function measureDeclaration(context, declaration, nested, measures) {
47
- if ('match' in declaration) {
48
- return measurePattern(declaration.match, context.environment.candidate.origin);
32
+ const checks = {};
33
+ for (const [pointer, expression] of checkTrees(schema)) {
34
+ checks[pointer] = measureChecks(normalizePolicyChecks(expression));
49
35
  }
50
- const refs = 'allOf' in declaration ? declaration.allOf : declaration.anyOf;
51
- const children = refs.flatMap((ref) => {
52
- if (!context.isLocalPolicy(ref))
53
- return [];
54
- const value = measurePolicy(context, ref.name, nested, measures);
55
- return value === undefined ? [] : [value];
56
- });
57
- if (children.length !== refs.length || children.length === 0)
58
- return undefined;
59
- return combineMeasures('allOf' in declaration ? 'allOf' : 'anyOf', children);
36
+ return deepFreeze({ policies, unmeasured, checks });
60
37
  }
61
- function measurePattern(pattern, ownOrigin) {
62
- if ('sameNode' in pattern)
63
- return {
64
- depth: 1,
65
- edgeCounts: [1],
66
- domains: new Set([
67
- ownOrigin,
68
- ...[pattern.sameNode.left, pattern.sameNode.right].flatMap((term) => term.kind === 'ref' ? [policyObjectOrigin(term.ref)] : []),
69
- ]),
70
- };
71
- if (isEdge(pattern)) {
72
- return {
73
- depth: 1,
74
- edgeCounts: [1],
75
- domains: new Set([
76
- ownOrigin,
77
- pattern.class.origin,
78
- ...[pattern.source, pattern.target].flatMap((term) => term.kind === 'ref' ? [policyObjectOrigin(term.ref)] : []),
79
- ]),
80
- };
38
+ /**
39
+ * `PL_BUDGET`: every measure of the document within `limits.policy`. Typing expands what stays in
40
+ * `normalized`, and a Policy without a measure within them has no bound on its expansion, so it
41
+ * leaves: it is refused here or by `PL_REF` or `PL_COMPOSITION`, and whatever composes it with it.
42
+ */
43
+ export function validatePolicyBudgets(context) {
44
+ const measures = measureDomainPolicies(context.environment.candidate, context.normalized);
45
+ for (const name of measures.unmeasured)
46
+ context.normalized.delete(name);
47
+ for (const [name, measure] of Object.entries(measures.policies)) {
48
+ for (const limit of exceededLimits(measure)) {
49
+ context.normalized.delete(name);
50
+ context.add('PL_BUDGET', `/policies/${escapePointerToken(name)}`, REFUSAL[limit](measure));
51
+ }
81
52
  }
82
- if ('exists' in pattern) {
83
- const child = measurePattern(pattern.exists.where, ownOrigin);
84
- return {
85
- depth: child.depth + 1,
86
- edgeCounts: child.edgeCounts,
87
- domains: new Set([
88
- ...child.domains,
89
- ...pattern.exists.nodes.flatMap((node) => {
90
- const ref = policyVariableClass(node);
91
- return ref === undefined ? [] : [ref.origin];
92
- }),
93
- ]),
94
- };
53
+ for (const [pointer, measure] of Object.entries(measures.checks)) {
54
+ validateCheckBudget(context, pointer, measure);
95
55
  }
96
- const { key, values } = patternOperands(pattern);
97
- return combineMeasures(key, values.map((child) => measurePattern(child, ownOrigin)));
98
56
  }
99
- function combineMeasures(key, children) {
100
- const depth = 1 + Math.max(0, ...children.map((child) => child.depth));
101
- const domains = new Set(children.flatMap((child) => [...child.domains]));
102
- if (key === 'anyOf') {
103
- return {
104
- depth,
105
- edgeCounts: children.flatMap((child) => child.edgeCounts).slice(0, BRANCH_OVERFLOW),
106
- domains,
107
- };
108
- }
109
- let edgeCounts = [0];
110
- for (const child of children) {
111
- const next = [];
112
- for (const left of edgeCounts) {
113
- for (const right of child.edgeCounts) {
114
- next.push(left + right);
115
- if (next.length >= BRANCH_OVERFLOW)
116
- break;
57
+ /**
58
+ * `PL_BUDGET` for one check tree at `pointer`, from its measure: the document's trees, and the
59
+ * checks of a contract a Node carries, which no document holds.
60
+ */
61
+ export function validateCheckBudget(context, pointer, measure) {
62
+ if (exceededLimits(measure).length === 0)
63
+ return;
64
+ const { checkDepth, checkBranches, checkLeaves } = limits.policy;
65
+ // A callable holds its checks at `policy`; a Class rule at `policies/{operation}`.
66
+ const site = SITE[pointer.endsWith('/policy') ? 'callable' : 'class'];
67
+ context.add('PL_BUDGET', pointer, `${site.checks} require depth <= ${checkDepth}, branches <= ${checkBranches}, and leaves <= ${checkLeaves}; got ${measure.checkDepth}, ${measure.checkBranches}, ${measure.checkLeaves}.`);
68
+ }
69
+ /** How `PL_BUDGET` explains each limit a named Policy exceeds. */
70
+ const REFUSAL = {
71
+ patternDepth: (measure) => `Expanded Pattern depth ${measure.patternDepth} exceeds ${limits.policy.patternDepth}.`,
72
+ normalizedBranches: () => `Expanded Pattern has more than ${limits.policy.normalizedBranches} normalized branches.`,
73
+ edgePredicates: (measure) => `A normalized branch contains ${measure.edgePredicates} graph predicates; the maximum is ${limits.policy.edgePredicates}.`,
74
+ referencedDomains: (measure) => `Expanded Pattern references ${measure.referencedDomains} Domains; the maximum is ${limits.policy.referencedDomains}.`,
75
+ };
76
+ function normalizedPolicies(schema) {
77
+ return new Map(Object.entries(schema.policies).map(([name, declaration]) => [
78
+ name,
79
+ normalizePolicyExpression(declaration.expression),
80
+ ]));
81
+ }
82
+ /** Every check tree of a document with the pointer of its position, in document order. */
83
+ function* checkTrees(schema) {
84
+ for (const [name, declaration] of Object.entries(schema.classes)) {
85
+ const owner = `/classes/${escapePointerToken(name)}`;
86
+ for (const operation of CLASS_OPERATIONS) {
87
+ const rule = declaration.policies[operation];
88
+ if (typeof rule === 'object' && isClassRuleChecks(rule)) {
89
+ yield [`${owner}/policies/${operation}`, rule];
90
+ }
91
+ }
92
+ if (declaration.kind !== 'node')
93
+ continue;
94
+ for (const [method, value] of Object.entries(declaration.methods)) {
95
+ if (typeof value.policy === 'object') {
96
+ yield [`${owner}/methods/${escapePointerToken(method)}/policy`, value.policy];
117
97
  }
118
- if (next.length >= BRANCH_OVERFLOW)
119
- break;
120
98
  }
121
- edgeCounts = next;
122
99
  }
123
- return { depth, edgeCounts, domains };
124
- }
125
- function patternOperands(value) {
126
- return 'allOf' in value
127
- ? { key: 'allOf', values: value.allOf }
128
- : { key: 'anyOf', values: value.anyOf };
129
- }
130
- function isEdge(value) {
131
- return 'source' in value;
100
+ for (const [name, declaration] of Object.entries(schema.functions)) {
101
+ if (typeof declaration.policy === 'object') {
102
+ yield [`/functions/${escapePointerToken(name)}/policy`, declaration.policy];
103
+ }
104
+ }
132
105
  }
@@ -1,11 +1,12 @@
1
1
  import type { ClassDefinition } from '../../../language/class/model/class.js';
2
- import type { PolicyExpression } from '../../../language/policy/model/policy.js';
2
+ import type { ObjectContract, PolicyTypingScope } from '../../../language/policy/analysis/typing.js';
3
+ import type { PolicyExpression, PolicyObjectRef } from '../../../language/policy/model/policy.js';
3
4
  import type { DefinitionAnalysisResult } from '../../analysis/class.js';
4
5
  import type { SchemaDiagnostic, SchemaDiagnosticCode } from '../../diagnostic.js';
5
6
  import type { DomainResolutionContext } from '../../resolution/context.js';
6
7
  import type { IndexedClassDefinition } from '../../resolution/definition.index.js';
7
8
  import { type ClassRef, type PolicyRef } from '../../../addressing/index.js';
8
- export declare class PolicyValidationContext {
9
+ export declare class PolicyValidationContext implements PolicyTypingScope {
9
10
  #private;
10
11
  readonly environment: DomainResolutionContext;
11
12
  readonly analysis: DefinitionAnalysisResult;
@@ -21,8 +22,8 @@ export declare class PolicyValidationContext {
21
22
  edgeDeclaration(ref: ClassRef): Extract<ClassDefinition, {
22
23
  readonly kind: 'edge';
23
24
  }> | undefined;
24
- /** Return true when candidate is the required Class or a same-kind descendant. */
25
- classExtends(candidate: ClassRef, required: ClassRef): boolean;
25
+ resolveClass(ref: ClassRef): ClassDefinition | undefined;
26
+ /** The contract a Policy pattern reference types, reporting an invalid one under `/policies`. */
27
+ referenceContract(ref: PolicyObjectRef): ObjectContract | undefined;
26
28
  add(code: SchemaDiagnosticCode, pointer: string, message: string, ref?: string): void;
27
29
  }
28
- export declare function escapePointer(value: string): string;
@@ -1,7 +1,7 @@
1
1
  import { Key } from '../../../addressing/index.js';
2
2
  import { definitionRefIndex } from '../../../addressing/ordering.js';
3
- import { classSatisfies } from '../../../language/class/inheritance.js';
4
3
  import { diagnostic } from '../../diagnostic.js';
4
+ import { referenceContracts } from './objects.js';
5
5
  const formatDefinitionRef = Key.of;
6
6
  export class PolicyValidationContext {
7
7
  environment;
@@ -62,17 +62,14 @@ export class PolicyValidationContext {
62
62
  }
63
63
  return resolved.declaration;
64
64
  }
65
- /** Return true when candidate is the required Class or a same-kind descendant. */
66
- classExtends(candidate, required) {
67
- const resolve = (ref) => this.environment.resolveAny(ref)?.declaration;
68
- const actual = resolve(candidate);
69
- const target = resolve(required);
70
- return actual !== undefined && target !== undefined && classSatisfies(actual, target, resolve);
65
+ resolveClass(ref) {
66
+ return this.environment.resolveAny(ref)?.declaration;
67
+ }
68
+ /** The contract a Policy pattern reference types, reporting an invalid one under `/policies`. */
69
+ referenceContract(ref) {
70
+ return referenceContracts(this, ref, '/policies')?.[0];
71
71
  }
72
72
  add(code, pointer, message, ref) {
73
73
  this.diagnostics.push(diagnostic(code, pointer, message, ref));
74
74
  }
75
75
  }
76
- export function escapePointer(value) {
77
- return value.replaceAll('~', '~0').replaceAll('/', '~1');
78
- }
@@ -1,4 +1,4 @@
1
1
  import type { PolicyObjectRef } from '../../../language/index.js';
2
+ import type { ObjectContract } from '../../../language/policy/analysis/typing.js';
2
3
  import type { PolicyValidationContext } from './context.js';
3
- import type { ObjectContract } from './typing.js';
4
4
  export declare function referenceContracts(validation: PolicyValidationContext, ref: PolicyObjectRef, pointer: string): readonly ObjectContract[] | undefined;
@@ -1,11 +1,6 @@
1
1
  import { definitionRefIndex } from '../../../addressing/ordering.js';
2
2
  import { isMethodExecutable } from '../../../language/callable/executable.js';
3
- import { policyObjectKey, policyObjectOrigin } from '../../../language/index.js';
4
- const KERNEL_ORIGIN = 'kernel.astrale.ai';
5
- const PROJECTION_CLASS = nodeClassRef('Class');
6
- const PROJECTION_FUNCTION = nodeClassRef('Function');
7
- const PROJECTION_POLICY = nodeClassRef('Policy');
8
- const PROJECTION_VIEW = nodeClassRef('View');
3
+ import { policyObjectKey, policyObjectOrigin, projectedMemberClass, } from '../../../language/index.js';
9
4
  export function referenceContracts(validation, ref, pointer) {
10
5
  const candidate = validation.environment.candidate;
11
6
  const local = policyObjectOrigin(ref) === candidate.origin;
@@ -21,7 +16,7 @@ export function referenceContracts(validation, ref, pointer) {
21
16
  case 'class': {
22
17
  const resolved = validation.environment.resolve(ref);
23
18
  return resolved?.ref.kind === ref.kind
24
- ? [{ kind: 'exact', ref: PROJECTION_CLASS }]
19
+ ? [{ kind: 'exact', ref: projectedMemberClass(ref) }]
25
20
  : invalidPolicyObjectRef(validation, ref, pointer);
26
21
  }
27
22
  case 'method': {
@@ -29,20 +24,20 @@ export function referenceContracts(validation, ref, pointer) {
29
24
  const method = declaringClass?.kind === 'node' ? declaringClass.methods[ref.name] : undefined;
30
25
  return method === undefined || !isMethodExecutable(declaringClass, method)
31
26
  ? invalidPolicyObjectRef(validation, ref, pointer)
32
- : [{ kind: 'exact', ref: PROJECTION_FUNCTION }];
27
+ : [{ kind: 'exact', ref: projectedMemberClass(ref) }];
33
28
  }
34
29
  case 'function':
35
30
  return owner.functions[ref.name] === undefined
36
31
  ? invalidPolicyObjectRef(validation, ref, pointer)
37
- : [{ kind: 'exact', ref: PROJECTION_FUNCTION }];
32
+ : [{ kind: 'exact', ref: projectedMemberClass(ref) }];
38
33
  case 'policy':
39
34
  return owner.policies[ref.name] === undefined
40
35
  ? invalidPolicyObjectRef(validation, ref, pointer)
41
- : [{ kind: 'exact', ref: PROJECTION_POLICY }];
36
+ : [{ kind: 'exact', ref: projectedMemberClass(ref) }];
42
37
  case 'view':
43
38
  return owner.views[ref.name] === undefined
44
39
  ? invalidPolicyObjectRef(validation, ref, pointer)
45
- : [{ kind: 'exact', ref: PROJECTION_VIEW }];
40
+ : [{ kind: 'exact', ref: projectedMemberClass(ref) }];
46
41
  case 'core': {
47
42
  const node = owner.core.nodes[ref.name];
48
43
  if (node === undefined)
@@ -66,6 +61,3 @@ function invalidPolicyObjectRef(validation, ref, pointer) {
66
61
  validation.add('PL_REF', `${pointer}/ref`, `${policyObjectKey(ref)} is not an exact local or direct-dependency projected Policy object.`, policyObjectKey(ref));
67
62
  return undefined;
68
63
  }
69
- function nodeClassRef(name) {
70
- return { origin: KERNEL_ORIGIN, kind: 'class', name };
71
- }