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

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 (738) hide show
  1. package/CHANGELOG.md +240 -0
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -1
  4. package/dist/upgrade/contract.d.ts +0 -1
  5. package/dist/upgrade/contract.js +0 -1
  6. package/dist/upgrade/index.d.ts +0 -1
  7. package/dist/upgrade/index.js +0 -1
  8. package/dist/v1/addressing/class-key.d.ts +12 -0
  9. package/dist/v1/addressing/class-key.js +39 -0
  10. package/dist/v1/addressing/definition-ref.d.ts +28 -0
  11. package/dist/v1/addressing/definition-ref.js +63 -0
  12. package/dist/v1/addressing/domain-dependency.d.ts +18 -0
  13. package/dist/v1/addressing/domain-dependency.js +6 -0
  14. package/dist/v1/addressing/index.d.ts +10 -4
  15. package/dist/v1/addressing/index.js +5 -3
  16. package/dist/v1/addressing/key.d.ts +14 -16
  17. package/dist/v1/addressing/key.js +24 -34
  18. package/dist/v1/addressing/method-address.d.ts +9 -0
  19. package/dist/v1/addressing/method-address.js +1 -0
  20. package/dist/v1/addressing/method-key.d.ts +15 -0
  21. package/dist/v1/addressing/method-key.js +60 -0
  22. package/dist/v1/addressing/ordering.d.ts +6 -0
  23. package/dist/v1/addressing/ordering.js +20 -0
  24. package/dist/v1/addressing/patterns.d.ts +12 -3
  25. package/dist/v1/addressing/patterns.js +11 -2
  26. package/dist/v1/addressing/property-key.d.ts +10 -15
  27. package/dist/v1/addressing/property-key.js +24 -15
  28. package/dist/v1/addressing/revision.d.ts +8 -0
  29. package/dist/v1/addressing/revision.js +8 -0
  30. package/dist/v1/builder/callable/authoring.d.ts +117 -0
  31. package/dist/v1/builder/{callable.js → callable/authoring.js} +28 -7
  32. package/dist/v1/builder/class/authoring.d.ts +378 -0
  33. package/dist/v1/builder/class/authoring.js +134 -0
  34. package/dist/v1/builder/class/property.d.ts +58 -0
  35. package/dist/v1/builder/class/property.js +57 -0
  36. package/dist/v1/builder/core/authoring.d.ts +42 -0
  37. package/dist/v1/builder/core/authoring.js +39 -0
  38. package/dist/v1/builder/index.d.ts +26 -22
  39. package/dist/v1/builder/index.js +11 -11
  40. package/dist/v1/builder/lowering/callable.d.ts +24 -0
  41. package/dist/v1/builder/{compiler → lowering}/callable.js +11 -14
  42. package/dist/v1/builder/lowering/class.d.ts +22 -0
  43. package/dist/v1/builder/lowering/class.js +134 -0
  44. package/dist/v1/builder/lowering/core-properties.d.ts +10 -0
  45. package/dist/v1/builder/{compiler/core.properties.js → lowering/core-properties.js} +14 -8
  46. package/dist/v1/builder/lowering/core.d.ts +22 -0
  47. package/dist/v1/builder/{compiler → lowering}/core.js +17 -11
  48. package/dist/v1/builder/lowering/policy.d.ts +16 -0
  49. package/dist/v1/builder/{compiler → lowering}/policy.js +19 -14
  50. package/dist/v1/builder/{compiler/schema.capture.d.ts → lowering/schema/capture.d.ts} +2 -3
  51. package/dist/v1/builder/lowering/schema/capture.js +70 -0
  52. package/dist/v1/builder/{compiler/schema.d.ts → lowering/schema/compile.d.ts} +4 -4
  53. package/dist/v1/builder/{compiler/schema.js → lowering/schema/compile.js} +34 -44
  54. package/dist/v1/builder/lowering/schema/context.d.ts +44 -0
  55. package/dist/v1/builder/{compiler/schema.context.js → lowering/schema/context.js} +66 -74
  56. package/dist/v1/builder/{compiler/schema.ownership.d.ts → lowering/schema/ownership.d.ts} +1 -2
  57. package/dist/v1/builder/{compiler/schema.ownership.js → lowering/schema/ownership.js} +1 -2
  58. package/dist/v1/builder/lowering/value/compile.d.ts +15 -0
  59. package/dist/v1/builder/{compiler/value.js → lowering/value/compile.js} +44 -61
  60. package/dist/v1/builder/lowering/value/path.d.ts +3 -0
  61. package/dist/v1/builder/{compiler/value.path.js → lowering/value/path.js} +1 -2
  62. package/dist/v1/builder/{compiler/value.zod.d.ts → lowering/value/zod.d.ts} +8 -9
  63. package/dist/v1/builder/{compiler/value.zod.js → lowering/value/zod.js} +10 -11
  64. package/dist/v1/builder/lowering/view.d.ts +11 -0
  65. package/dist/v1/builder/{compiler → lowering}/view.js +7 -7
  66. package/dist/v1/builder/{policy.d.ts → policy/authoring.d.ts} +19 -17
  67. package/dist/v1/builder/{policy.js → policy/authoring.js} +23 -12
  68. package/dist/v1/builder/schema/define.d.ts +11 -0
  69. package/dist/v1/builder/{schema.js → schema/define.js} +1 -2
  70. package/dist/v1/builder/schema/diagnostic.d.ts +16 -0
  71. package/dist/v1/builder/schema/diagnostic.js +31 -0
  72. package/dist/v1/builder/{internal/authoring.d.ts → schema/handle.d.ts} +1 -2
  73. package/dist/v1/builder/{internal/authoring.js → schema/handle.js} +0 -1
  74. package/dist/v1/builder/schema/input.d.ts +15 -0
  75. package/dist/v1/builder/schema/input.js +1 -0
  76. package/dist/v1/builder/{internal/authoring.lazy.d.ts → schema/lazy.d.ts} +0 -1
  77. package/dist/v1/builder/{internal/authoring.lazy.js → schema/lazy.js} +0 -1
  78. package/dist/v1/builder/schema/projection.d.ts +370 -0
  79. package/dist/v1/builder/schema/projection.js +1 -0
  80. package/dist/v1/builder/value/full-match.d.ts +4 -0
  81. package/dist/v1/builder/value/full-match.js +11 -0
  82. package/dist/v1/builder/value/path-metadata.d.ts +4 -0
  83. package/dist/v1/builder/{internal/path.metadata.js → value/path-metadata.js} +0 -1
  84. package/dist/v1/builder/value/path.d.ts +8 -0
  85. package/dist/v1/builder/{path.js → value/path.js} +4 -5
  86. package/dist/v1/builder/{value-schema.d.ts → value/schema.d.ts} +2 -3
  87. package/dist/v1/builder/{value-schema.js → value/schema.js} +0 -1
  88. package/dist/v1/builder/view/authoring.d.ts +17 -0
  89. package/dist/v1/builder/view/authoring.js +16 -0
  90. package/dist/v1/bundle/codec.d.ts +0 -1
  91. package/dist/v1/bundle/codec.js +36 -19
  92. package/dist/v1/bundle/create.d.ts +3 -0
  93. package/dist/v1/bundle/create.js +5 -0
  94. package/dist/v1/bundle/diagnostic.d.ts +10 -0
  95. package/dist/v1/bundle/diagnostic.js +17 -0
  96. package/dist/v1/bundle/index.d.ts +3 -2
  97. package/dist/v1/bundle/index.js +2 -2
  98. package/dist/v1/bundle/model.d.ts +1 -4
  99. package/dist/v1/bundle/model.js +0 -6
  100. package/dist/v1/bundle/structure.d.ts +1 -2
  101. package/dist/v1/bundle/structure.js +6 -6
  102. package/dist/v1/bundle/transport.d.ts +8 -0
  103. package/dist/v1/bundle/transport.js +7 -0
  104. package/dist/v1/compiled/admission/accept.d.ts +3 -0
  105. package/dist/v1/compiled/admission/accept.js +910 -0
  106. package/dist/v1/compiled/admission/revision.d.ts +4 -0
  107. package/dist/v1/compiled/admission/revision.js +73 -0
  108. package/dist/v1/compiled/admission/semantics.d.ts +7 -0
  109. package/dist/v1/compiled/admission/semantics.js +1114 -0
  110. package/dist/v1/compiled/codec/json.d.ts +3 -0
  111. package/dist/v1/compiled/codec/json.js +9 -0
  112. package/dist/v1/compiled/compiler/compile.d.ts +4 -0
  113. package/dist/v1/compiled/compiler/compile.js +113 -0
  114. package/dist/v1/compiled/diagnostic.d.ts +11 -0
  115. package/dist/v1/compiled/diagnostic.js +13 -0
  116. package/dist/v1/compiled/generated.d.ts +10 -0
  117. package/dist/v1/compiled/generated.js +15 -0
  118. package/dist/v1/compiled/index.d.ts +7 -0
  119. package/dist/v1/compiled/index.js +5 -0
  120. package/dist/v1/compiled/loader/index.d.ts +1 -0
  121. package/dist/v1/compiled/loader/index.js +1 -0
  122. package/dist/v1/compiled/loader/load.d.ts +9 -0
  123. package/dist/v1/compiled/loader/load.js +147 -0
  124. package/dist/v1/compiled/model/schema.d.ts +73 -0
  125. package/dist/v1/compiled/model/schema.js +1 -0
  126. package/dist/v1/domain/create.d.ts +8 -0
  127. package/dist/v1/domain/create.js +264 -0
  128. package/dist/v1/domain/index.d.ts +2 -0
  129. package/dist/v1/domain/index.js +1 -0
  130. package/dist/v1/domain/model/domain.d.ts +59 -0
  131. package/dist/v1/domain/model/domain.js +1 -0
  132. package/dist/v1/domain/model/input.d.ts +31 -0
  133. package/dist/v1/domain/model/input.js +1 -0
  134. package/dist/v1/domain/namespace/member-collection.d.ts +5 -0
  135. package/dist/v1/domain/namespace/member-collection.js +81 -0
  136. package/dist/v1/domain/projection/classes.d.ts +4 -0
  137. package/dist/v1/domain/projection/classes.js +198 -0
  138. package/dist/v1/domain/validation/create.d.ts +18 -0
  139. package/dist/v1/domain/validation/create.js +75 -0
  140. package/dist/v1/index.d.ts +14 -5
  141. package/dist/v1/index.js +6 -3
  142. package/dist/v1/language/callable/index.d.ts +2 -0
  143. package/dist/v1/language/callable/index.js +1 -0
  144. package/dist/v1/language/callable/model/callable.d.ts +33 -0
  145. package/dist/v1/language/callable/model/callable.js +1 -0
  146. package/dist/v1/language/callable/resolved.d.ts +68 -0
  147. package/dist/v1/language/callable/resolved.js +1 -0
  148. package/dist/v1/language/class/facets.d.ts +58 -0
  149. package/dist/v1/language/class/facets.js +1 -0
  150. package/dist/v1/language/class/index.d.ts +8 -0
  151. package/dist/v1/language/class/index.js +1 -0
  152. package/dist/v1/language/class/model/class.d.ts +37 -0
  153. package/dist/v1/language/class/model/class.js +1 -0
  154. package/dist/v1/{schema/definition → language/class/model}/data.d.ts +2 -3
  155. package/dist/v1/{schema/definition → language/class/model}/data.js +0 -1
  156. package/dist/v1/{schema/definition → language/class/model}/edge.d.ts +9 -6
  157. package/dist/v1/language/class/model/edge.js +1 -0
  158. package/dist/v1/language/class/model/property.d.ts +17 -0
  159. package/dist/v1/language/class/model/property.js +1 -0
  160. package/dist/v1/language/class/property-values.d.ts +15 -0
  161. package/dist/v1/language/class/property-values.js +30 -0
  162. package/dist/v1/language/class/resolved.d.ts +126 -0
  163. package/dist/v1/language/class/resolved.js +1 -0
  164. package/dist/v1/language/core/index.d.ts +2 -0
  165. package/dist/v1/language/core/index.js +1 -0
  166. package/dist/v1/language/core/model/core.d.ts +20 -0
  167. package/dist/v1/language/core/model/core.js +1 -0
  168. package/dist/v1/language/core/resolved.d.ts +21 -0
  169. package/dist/v1/language/core/resolved.js +1 -0
  170. package/dist/v1/{schema → language/definition}/metadata.d.ts +0 -1
  171. package/dist/v1/{schema → language/definition}/metadata.js +0 -1
  172. package/dist/v1/language/definition.d.ts +7 -0
  173. package/dist/v1/language/definition.js +1 -0
  174. package/dist/v1/language/index.d.ts +25 -0
  175. package/dist/v1/language/index.js +2 -0
  176. package/dist/v1/{schema/policy/validation → language/policy/analysis}/branches.d.ts +2 -4
  177. package/dist/v1/{schema/policy/validation → language/policy/analysis}/branches.js +14 -30
  178. package/dist/v1/{schema/policy/validation → language/policy/analysis}/budgets.d.ts +1 -4
  179. package/dist/v1/language/policy/analysis/budgets.js +25 -0
  180. package/dist/v1/language/policy/index.d.ts +3 -0
  181. package/dist/v1/language/policy/index.js +1 -0
  182. package/dist/v1/{schema/policy/ast.d.ts → language/policy/model/policy.d.ts} +7 -7
  183. package/dist/v1/language/policy/model/policy.js +1 -0
  184. package/dist/v1/language/policy/normalization/normalize.d.ts +4 -0
  185. package/dist/v1/{schema/policy → language/policy/normalization}/normalize.js +12 -16
  186. package/dist/v1/language/policy/resolved.d.ts +9 -0
  187. package/dist/v1/language/policy/resolved.js +1 -0
  188. package/dist/v1/language/resolved.d.ts +10 -0
  189. package/dist/v1/language/resolved.js +1 -0
  190. package/dist/v1/language/state/index.d.ts +3 -0
  191. package/dist/v1/language/state/index.js +1 -0
  192. package/dist/v1/language/state/machine.d.ts +28 -0
  193. package/dist/v1/language/state/machine.js +40 -0
  194. package/dist/v1/language/state/topology.d.ts +14 -0
  195. package/dist/v1/language/state/topology.js +69 -0
  196. package/dist/v1/language/validation/diagnostic.d.ts +8 -0
  197. package/dist/v1/language/validation/diagnostic.js +3 -0
  198. package/dist/v1/language/value/compile/fields.d.ts +3 -0
  199. package/dist/v1/language/value/compile/fields.js +60 -0
  200. package/dist/v1/language/value/compile/load.d.ts +4 -0
  201. package/dist/v1/language/value/compile/load.js +41 -0
  202. package/dist/v1/language/value/compile/model.d.ts +27 -0
  203. package/dist/v1/language/value/compile/model.js +1 -0
  204. package/dist/v1/{schema/value/instance → language/value/evaluate}/assertions.d.ts +0 -1
  205. package/dist/v1/{schema/value/instance → language/value/evaluate}/assertions.js +1 -2
  206. package/dist/v1/{schema/value/instance → language/value/evaluate}/evaluator.d.ts +0 -1
  207. package/dist/v1/{schema/value/instance → language/value/evaluate}/evaluator.js +6 -18
  208. package/dist/v1/{schema/value/instance/compiler.d.ts → language/value/evaluate/preparation.d.ts} +4 -4
  209. package/dist/v1/language/value/evaluate/preparation.js +135 -0
  210. package/dist/v1/language/value/evaluate/program.d.ts +3 -0
  211. package/dist/v1/language/value/evaluate/program.js +16 -0
  212. package/dist/v1/{schema/value/instance → language/value/evaluate}/types.d.ts +8 -5
  213. package/dist/v1/{schema/value/instance → language/value/evaluate}/types.js +0 -1
  214. package/dist/v1/{schema/value/instance.validate.d.ts → language/value/evaluate/validate.d.ts} +4 -5
  215. package/dist/v1/{schema/value/instance.validate.js → language/value/evaluate/validate.js} +5 -6
  216. package/dist/v1/language/value/index.d.ts +11 -0
  217. package/dist/v1/language/value/index.js +8 -0
  218. package/dist/v1/{schema/value → language/value/model}/instant.d.ts +1 -1
  219. package/dist/v1/{schema/value → language/value/model}/instant.js +1 -1
  220. package/dist/v1/{schema/value → language/value/model}/object.d.ts +1 -1
  221. package/dist/v1/{schema/value → language/value/model}/object.js +0 -1
  222. package/dist/v1/{schema/value → language/value/model}/schema.d.ts +3 -4
  223. package/dist/v1/{schema/value → language/value/model}/schema.js +0 -2
  224. package/dist/v1/{schema → language}/value/ordering.d.ts +5 -3
  225. package/dist/v1/{schema → language}/value/ordering.js +16 -14
  226. package/dist/v1/{schema → language}/value/profile/canonicalize.d.ts +2 -3
  227. package/dist/v1/{schema → language}/value/profile/canonicalize.js +4 -7
  228. package/dist/v1/language/value/profile/json.validate.d.ts +2 -0
  229. package/dist/v1/{schema → language}/value/profile/json.validate.js +1 -2
  230. package/dist/v1/{schema → language}/value/profile/meta-schema.compiled.d.ts +0 -1
  231. package/dist/v1/{schema → language}/value/profile/meta-schema.compiled.js +1 -2
  232. package/dist/v1/language/value/profile/meta-schema.d.ts +4 -0
  233. package/dist/v1/{schema/value/profile/meta-schema.validate.js → language/value/profile/meta-schema.js} +2 -2
  234. package/dist/v1/language/value/profile/rules.d.ts +3 -0
  235. package/dist/v1/{schema → language}/value/profile/rules.js +7 -50
  236. package/dist/v1/language/value/profile/validate.d.ts +4 -0
  237. package/dist/v1/{schema → language}/value/profile/validate.js +14 -22
  238. package/dist/v1/{schema → language}/value/profile/vocabulary.d.ts +0 -1
  239. package/dist/v1/{schema → language}/value/profile/vocabulary.js +0 -1
  240. package/dist/v1/language/value/reference/closure.d.ts +11 -0
  241. package/dist/v1/{schema/value/resources → language/value/reference}/closure.js +13 -21
  242. package/dist/v1/{schema/value/resources → language/value/reference}/recursion.d.ts +3 -4
  243. package/dist/v1/{schema/value/resources → language/value/reference}/recursion.js +5 -6
  244. package/dist/v1/language/value/reference/references.d.ts +17 -0
  245. package/dist/v1/language/value/reference/references.js +45 -0
  246. package/dist/v1/{schema/value → language/value/reference}/registry.d.ts +9 -7
  247. package/dist/v1/language/value/reference/registry.index.d.ts +14 -0
  248. package/dist/v1/{schema/value/resources → language/value/reference}/registry.index.js +7 -45
  249. package/dist/v1/language/value/reference/registry.js +1 -0
  250. package/dist/v1/language/value/regexp/ast.d.ts +21 -0
  251. package/dist/v1/language/value/regexp/ast.js +326 -0
  252. package/dist/v1/language/value/regexp/compile.d.ts +3 -0
  253. package/dist/v1/language/value/regexp/compile.js +96 -0
  254. package/dist/v1/{schema → language}/value/regexp/lower.d.ts +1 -2
  255. package/dist/v1/{schema → language}/value/regexp/lower.js +2 -3
  256. package/dist/v1/language/value/regexp/matcher.d.ts +7 -0
  257. package/dist/v1/language/value/regexp/matcher.js +50 -0
  258. package/dist/v1/{schema → language}/value/regexp/pattern.d.ts +0 -1
  259. package/dist/v1/{schema → language}/value/regexp/pattern.js +0 -1
  260. package/dist/v1/language/value/regexp/syntax.d.ts +2 -0
  261. package/dist/v1/language/value/regexp/syntax.js +5 -0
  262. package/dist/v1/language/value/syntax/full-match.d.ts +6 -0
  263. package/dist/v1/language/value/syntax/full-match.js +20 -0
  264. package/dist/v1/{schema/value/location → language/value/syntax}/keywords.d.ts +0 -1
  265. package/dist/v1/{schema/value/location → language/value/syntax}/keywords.js +0 -1
  266. package/dist/v1/{schema/value/extensions → language/value/syntax}/node-path/schema.d.ts +1 -2
  267. package/dist/v1/{schema/value/extensions → language/value/syntax}/node-path/schema.js +2 -3
  268. package/dist/v1/language/value/syntax/node-path/validate.d.ts +4 -0
  269. package/dist/v1/{schema/value/extensions → language/value/syntax}/node-path/validate.js +16 -18
  270. package/dist/v1/{schema/value/location → language/value/syntax}/pointer.d.ts +0 -1
  271. package/dist/v1/{schema/value/location → language/value/syntax}/pointer.js +1 -2
  272. package/dist/v1/{schema/value/location → language/value/syntax}/walk.d.ts +1 -2
  273. package/dist/v1/{schema/value/location → language/value/syntax}/walk.js +1 -2
  274. package/dist/v1/language/view/index.d.ts +2 -0
  275. package/dist/v1/language/view/index.js +1 -0
  276. package/dist/v1/language/view/model/view.d.ts +11 -0
  277. package/dist/v1/language/view/model/view.js +1 -0
  278. package/dist/v1/language/view/resolved.d.ts +9 -0
  279. package/dist/v1/language/view/resolved.js +1 -0
  280. package/dist/v1/schema/admission/accept.d.ts +3 -0
  281. package/dist/v1/schema/{domain.accept.js → admission/accept.js} +8 -9
  282. package/dist/v1/schema/{definition/analysis.d.ts → analysis/class.d.ts} +17 -18
  283. package/dist/v1/schema/{definition/analysis.js → analysis/class.js} +21 -30
  284. package/dist/v1/schema/canonical/domain.d.ts +2 -2
  285. package/dist/v1/schema/canonical/domain.digest.d.ts +1 -2
  286. package/dist/v1/schema/canonical/domain.digest.js +2 -6
  287. package/dist/v1/schema/canonical/domain.js +3 -224
  288. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  289. package/dist/v1/schema/canonical/freeze.js +0 -1
  290. package/dist/v1/schema/{domain.revision.d.ts → canonical/revision.d.ts} +2 -3
  291. package/dist/v1/schema/{domain.revision.js → canonical/revision.js} +3 -4
  292. package/dist/v1/schema/codec/header.d.ts +17 -0
  293. package/dist/v1/schema/codec/header.js +26 -0
  294. package/dist/v1/schema/{domain.codec.d.ts → codec/schema.d.ts} +2 -3
  295. package/dist/v1/schema/{domain.codec.js → codec/schema.js} +4 -5
  296. package/dist/v1/schema/{dependency.meaning.d.ts → compatibility/meaning.d.ts} +4 -5
  297. package/dist/v1/schema/{dependency.meaning.js → compatibility/meaning.js} +121 -124
  298. package/dist/v1/schema/{domain.lookup.d.ts → dependency/lookup.d.ts} +3 -4
  299. package/dist/v1/schema/{domain.lookup.js → dependency/lookup.js} +1 -2
  300. package/dist/v1/schema/diagnostic.d.ts +7 -7
  301. package/dist/v1/schema/diagnostic.js +9 -9
  302. package/dist/v1/schema/index.d.ts +24 -34
  303. package/dist/v1/schema/index.js +11 -14
  304. package/dist/v1/schema/model/format.d.ts +2 -0
  305. package/dist/v1/schema/model/format.js +2 -0
  306. package/dist/v1/schema/model/schema.d.ts +30 -0
  307. package/dist/v1/schema/model/schema.js +4 -0
  308. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  309. package/dist/v1/schema/normalization/domain.js +210 -0
  310. package/dist/v1/schema/resolution/closure.d.ts +3 -4
  311. package/dist/v1/schema/resolution/closure.js +6 -7
  312. package/dist/v1/schema/resolution/context.d.ts +11 -12
  313. package/dist/v1/schema/resolution/context.js +82 -50
  314. package/dist/v1/schema/resolution/definition.index.d.ts +13 -35
  315. package/dist/v1/schema/resolution/definition.index.js +8 -18
  316. package/dist/v1/schema/resolution/domain.d.ts +4 -0
  317. package/dist/v1/schema/resolution/domain.js +112 -0
  318. package/dist/v1/schema/resolution/origins.d.ts +11 -14
  319. package/dist/v1/schema/resolution/origins.js +31 -44
  320. package/dist/v1/schema/resolution/value.registry.d.ts +3 -4
  321. package/dist/v1/schema/resolution/value.registry.js +7 -14
  322. package/dist/v1/schema/revision.d.ts +1 -0
  323. package/dist/v1/schema/revision.js +1 -0
  324. package/dist/v1/schema/validation/class.d.ts +5 -0
  325. package/dist/v1/schema/validation/class.js +257 -0
  326. package/dist/v1/schema/validation/core.d.ts +5 -0
  327. package/dist/v1/schema/{core/validate.js → validation/core.js} +39 -30
  328. package/dist/v1/schema/validation/domain.d.ts +11 -0
  329. package/dist/v1/schema/{domain.validate.js → validation/domain.js} +12 -12
  330. package/dist/v1/schema/validation/domain.route.d.ts +1 -2
  331. package/dist/v1/schema/validation/domain.route.js +3 -4
  332. package/dist/v1/schema/validation/domain.structure.d.ts +3 -4
  333. package/dist/v1/schema/validation/domain.structure.js +203 -207
  334. package/dist/v1/schema/validation/policy/budgets.d.ts +4 -0
  335. package/dist/v1/schema/{policy/validation → validation/policy}/budgets.js +2 -32
  336. package/dist/v1/schema/validation/policy/context.d.ts +28 -0
  337. package/dist/v1/schema/{policy/validation → validation/policy}/context.js +23 -33
  338. package/dist/v1/schema/{policy/validation → validation/policy}/references.d.ts +0 -1
  339. package/dist/v1/schema/{policy/validation → validation/policy}/references.js +18 -11
  340. package/dist/v1/schema/{policy/validation → validation/policy}/typing.d.ts +4 -8
  341. package/dist/v1/schema/{policy/validation → validation/policy}/typing.js +25 -67
  342. package/dist/v1/schema/{policy/validation → validation/policy}/uses.d.ts +0 -1
  343. package/dist/v1/schema/{policy/validation → validation/policy}/uses.js +27 -63
  344. package/dist/v1/schema/{policy/validation → validation/policy}/validate.d.ts +3 -4
  345. package/dist/v1/schema/{policy/validation → validation/policy}/validate.js +0 -1
  346. package/dist/v1/schema/{value/index.d.ts → validation/value-api.d.ts} +9 -10
  347. package/dist/v1/schema/{value/index.js → validation/value-api.js} +4 -5
  348. package/dist/v1/schema/validation/value.d.ts +4 -5
  349. package/dist/v1/schema/validation/value.js +4 -9
  350. package/dist/v1/schema/validation/view.d.ts +3 -0
  351. package/dist/v1/schema/{view/validate.js → validation/view.js} +11 -4
  352. package/dist/v1/value/full-match.d.ts +2 -0
  353. package/dist/v1/value/full-match.js +2 -0
  354. package/dist/v1.d.ts +1 -2
  355. package/dist/v1.js +1 -2
  356. package/dist/value/accept.d.ts +0 -1
  357. package/dist/value/accept.js +0 -1
  358. package/dist/value/canonical.d.ts +0 -1
  359. package/dist/value/canonical.js +0 -1
  360. package/dist/value/decode.d.ts +0 -1
  361. package/dist/value/decode.js +0 -1
  362. package/dist/value/equal.d.ts +0 -1
  363. package/dist/value/equal.js +0 -1
  364. package/dist/value/error.d.ts +0 -1
  365. package/dist/value/error.js +0 -1
  366. package/dist/value/index.d.ts +0 -1
  367. package/dist/value/index.js +0 -1
  368. package/dist/value/json.d.ts +0 -1
  369. package/dist/value/json.js +0 -1
  370. package/dist/value/limits.d.ts +0 -1
  371. package/dist/value/limits.js +0 -1
  372. package/dist/value/types.d.ts +0 -1
  373. package/dist/value/types.js +0 -1
  374. package/dist/value/unicode.d.ts +0 -1
  375. package/dist/value/unicode.js +0 -1
  376. package/dist/version/dispatch.d.ts +0 -1
  377. package/dist/version/dispatch.js +0 -1
  378. package/dist/version/index.d.ts +0 -1
  379. package/dist/version/index.js +0 -1
  380. package/package.json +69 -13
  381. package/dist/index.d.ts.map +0 -1
  382. package/dist/index.js.map +0 -1
  383. package/dist/upgrade/contract.d.ts.map +0 -1
  384. package/dist/upgrade/contract.js.map +0 -1
  385. package/dist/upgrade/index.d.ts.map +0 -1
  386. package/dist/upgrade/index.js.map +0 -1
  387. package/dist/v1/addressing/index.d.ts.map +0 -1
  388. package/dist/v1/addressing/index.js.map +0 -1
  389. package/dist/v1/addressing/key.d.ts.map +0 -1
  390. package/dist/v1/addressing/key.js.map +0 -1
  391. package/dist/v1/addressing/patterns.d.ts.map +0 -1
  392. package/dist/v1/addressing/patterns.js.map +0 -1
  393. package/dist/v1/addressing/property-key.d.ts.map +0 -1
  394. package/dist/v1/addressing/property-key.js.map +0 -1
  395. package/dist/v1/addressing/ref.d.ts +0 -35
  396. package/dist/v1/addressing/ref.d.ts.map +0 -1
  397. package/dist/v1/addressing/ref.js +0 -94
  398. package/dist/v1/addressing/ref.js.map +0 -1
  399. package/dist/v1/addressing/schema-ref.d.ts +0 -8
  400. package/dist/v1/addressing/schema-ref.d.ts.map +0 -1
  401. package/dist/v1/addressing/schema-ref.js +0 -2
  402. package/dist/v1/addressing/schema-ref.js.map +0 -1
  403. package/dist/v1/builder/callable.d.ts +0 -92
  404. package/dist/v1/builder/callable.d.ts.map +0 -1
  405. package/dist/v1/builder/callable.js.map +0 -1
  406. package/dist/v1/builder/compiler/callable.d.ts +0 -20
  407. package/dist/v1/builder/compiler/callable.d.ts.map +0 -1
  408. package/dist/v1/builder/compiler/callable.js.map +0 -1
  409. package/dist/v1/builder/compiler/core.d.ts +0 -6
  410. package/dist/v1/builder/compiler/core.d.ts.map +0 -1
  411. package/dist/v1/builder/compiler/core.js.map +0 -1
  412. package/dist/v1/builder/compiler/core.properties.d.ts +0 -6
  413. package/dist/v1/builder/compiler/core.properties.d.ts.map +0 -1
  414. package/dist/v1/builder/compiler/core.properties.js.map +0 -1
  415. package/dist/v1/builder/compiler/definition.d.ts +0 -32
  416. package/dist/v1/builder/compiler/definition.d.ts.map +0 -1
  417. package/dist/v1/builder/compiler/definition.js +0 -197
  418. package/dist/v1/builder/compiler/definition.js.map +0 -1
  419. package/dist/v1/builder/compiler/policy.d.ts +0 -17
  420. package/dist/v1/builder/compiler/policy.d.ts.map +0 -1
  421. package/dist/v1/builder/compiler/policy.js.map +0 -1
  422. package/dist/v1/builder/compiler/schema.capture.d.ts.map +0 -1
  423. package/dist/v1/builder/compiler/schema.capture.js +0 -85
  424. package/dist/v1/builder/compiler/schema.capture.js.map +0 -1
  425. package/dist/v1/builder/compiler/schema.context.d.ts +0 -45
  426. package/dist/v1/builder/compiler/schema.context.d.ts.map +0 -1
  427. package/dist/v1/builder/compiler/schema.context.js.map +0 -1
  428. package/dist/v1/builder/compiler/schema.d.ts.map +0 -1
  429. package/dist/v1/builder/compiler/schema.js.map +0 -1
  430. package/dist/v1/builder/compiler/schema.ownership.d.ts.map +0 -1
  431. package/dist/v1/builder/compiler/schema.ownership.js.map +0 -1
  432. package/dist/v1/builder/compiler/value.d.ts +0 -26
  433. package/dist/v1/builder/compiler/value.d.ts.map +0 -1
  434. package/dist/v1/builder/compiler/value.js.map +0 -1
  435. package/dist/v1/builder/compiler/value.path.d.ts +0 -4
  436. package/dist/v1/builder/compiler/value.path.d.ts.map +0 -1
  437. package/dist/v1/builder/compiler/value.path.js.map +0 -1
  438. package/dist/v1/builder/compiler/value.zod.d.ts.map +0 -1
  439. package/dist/v1/builder/compiler/value.zod.js.map +0 -1
  440. package/dist/v1/builder/compiler/view.d.ts +0 -12
  441. package/dist/v1/builder/compiler/view.d.ts.map +0 -1
  442. package/dist/v1/builder/compiler/view.js.map +0 -1
  443. package/dist/v1/builder/core.d.ts +0 -27
  444. package/dist/v1/builder/core.d.ts.map +0 -1
  445. package/dist/v1/builder/core.js +0 -21
  446. package/dist/v1/builder/core.js.map +0 -1
  447. package/dist/v1/builder/definition.d.ts +0 -155
  448. package/dist/v1/builder/definition.d.ts.map +0 -1
  449. package/dist/v1/builder/definition.js +0 -141
  450. package/dist/v1/builder/definition.js.map +0 -1
  451. package/dist/v1/builder/full-match.d.ts +0 -12
  452. package/dist/v1/builder/full-match.d.ts.map +0 -1
  453. package/dist/v1/builder/full-match.js +0 -21
  454. package/dist/v1/builder/full-match.js.map +0 -1
  455. package/dist/v1/builder/index.d.ts.map +0 -1
  456. package/dist/v1/builder/index.js.map +0 -1
  457. package/dist/v1/builder/internal/authoring.d.ts.map +0 -1
  458. package/dist/v1/builder/internal/authoring.js.map +0 -1
  459. package/dist/v1/builder/internal/authoring.lazy.d.ts.map +0 -1
  460. package/dist/v1/builder/internal/authoring.lazy.js.map +0 -1
  461. package/dist/v1/builder/internal/diagnostic.d.ts +0 -4
  462. package/dist/v1/builder/internal/diagnostic.d.ts.map +0 -1
  463. package/dist/v1/builder/internal/diagnostic.js +0 -16
  464. package/dist/v1/builder/internal/diagnostic.js.map +0 -1
  465. package/dist/v1/builder/internal/path.metadata.d.ts +0 -5
  466. package/dist/v1/builder/internal/path.metadata.d.ts.map +0 -1
  467. package/dist/v1/builder/internal/path.metadata.js.map +0 -1
  468. package/dist/v1/builder/path.d.ts +0 -9
  469. package/dist/v1/builder/path.d.ts.map +0 -1
  470. package/dist/v1/builder/path.js.map +0 -1
  471. package/dist/v1/builder/policy.d.ts.map +0 -1
  472. package/dist/v1/builder/policy.js.map +0 -1
  473. package/dist/v1/builder/property.d.ts +0 -37
  474. package/dist/v1/builder/property.d.ts.map +0 -1
  475. package/dist/v1/builder/property.js +0 -36
  476. package/dist/v1/builder/property.js.map +0 -1
  477. package/dist/v1/builder/schema.d.ts +0 -6
  478. package/dist/v1/builder/schema.d.ts.map +0 -1
  479. package/dist/v1/builder/schema.input.d.ts +0 -19
  480. package/dist/v1/builder/schema.input.d.ts.map +0 -1
  481. package/dist/v1/builder/schema.input.js +0 -2
  482. package/dist/v1/builder/schema.input.js.map +0 -1
  483. package/dist/v1/builder/schema.js.map +0 -1
  484. package/dist/v1/builder/value-schema.d.ts.map +0 -1
  485. package/dist/v1/builder/value-schema.js.map +0 -1
  486. package/dist/v1/builder/view.d.ts +0 -19
  487. package/dist/v1/builder/view.d.ts.map +0 -1
  488. package/dist/v1/builder/view.js +0 -7
  489. package/dist/v1/builder/view.js.map +0 -1
  490. package/dist/v1/builder.d.ts +0 -3
  491. package/dist/v1/builder.d.ts.map +0 -1
  492. package/dist/v1/builder.js +0 -2
  493. package/dist/v1/builder.js.map +0 -1
  494. package/dist/v1/bundle/codec.d.ts.map +0 -1
  495. package/dist/v1/bundle/codec.js.map +0 -1
  496. package/dist/v1/bundle/index.d.ts.map +0 -1
  497. package/dist/v1/bundle/index.js.map +0 -1
  498. package/dist/v1/bundle/model.d.ts.map +0 -1
  499. package/dist/v1/bundle/model.js.map +0 -1
  500. package/dist/v1/bundle/structure.d.ts.map +0 -1
  501. package/dist/v1/bundle/structure.js.map +0 -1
  502. package/dist/v1/bundle.d.ts +0 -3
  503. package/dist/v1/bundle.d.ts.map +0 -1
  504. package/dist/v1/bundle.js +0 -3
  505. package/dist/v1/bundle.js.map +0 -1
  506. package/dist/v1/index.d.ts.map +0 -1
  507. package/dist/v1/index.js.map +0 -1
  508. package/dist/v1/schema/callable.d.ts +0 -29
  509. package/dist/v1/schema/callable.d.ts.map +0 -1
  510. package/dist/v1/schema/callable.js +0 -2
  511. package/dist/v1/schema/callable.js.map +0 -1
  512. package/dist/v1/schema/canonical/domain.d.ts.map +0 -1
  513. package/dist/v1/schema/canonical/domain.digest.d.ts.map +0 -1
  514. package/dist/v1/schema/canonical/domain.digest.js.map +0 -1
  515. package/dist/v1/schema/canonical/domain.js.map +0 -1
  516. package/dist/v1/schema/canonical/freeze.d.ts.map +0 -1
  517. package/dist/v1/schema/canonical/freeze.js.map +0 -1
  518. package/dist/v1/schema/core/declaration.d.ts +0 -17
  519. package/dist/v1/schema/core/declaration.d.ts.map +0 -1
  520. package/dist/v1/schema/core/declaration.js +0 -2
  521. package/dist/v1/schema/core/declaration.js.map +0 -1
  522. package/dist/v1/schema/core/validate.d.ts +0 -6
  523. package/dist/v1/schema/core/validate.d.ts.map +0 -1
  524. package/dist/v1/schema/core/validate.js.map +0 -1
  525. package/dist/v1/schema/definition/analysis.d.ts.map +0 -1
  526. package/dist/v1/schema/definition/analysis.js.map +0 -1
  527. package/dist/v1/schema/definition/class.d.ts +0 -28
  528. package/dist/v1/schema/definition/class.d.ts.map +0 -1
  529. package/dist/v1/schema/definition/class.js +0 -2
  530. package/dist/v1/schema/definition/class.js.map +0 -1
  531. package/dist/v1/schema/definition/data.d.ts.map +0 -1
  532. package/dist/v1/schema/definition/data.js.map +0 -1
  533. package/dist/v1/schema/definition/edge.d.ts.map +0 -1
  534. package/dist/v1/schema/definition/edge.js +0 -2
  535. package/dist/v1/schema/definition/edge.js.map +0 -1
  536. package/dist/v1/schema/definition/interface.d.ts +0 -22
  537. package/dist/v1/schema/definition/interface.d.ts.map +0 -1
  538. package/dist/v1/schema/definition/interface.js +0 -2
  539. package/dist/v1/schema/definition/interface.js.map +0 -1
  540. package/dist/v1/schema/definition/property.d.ts +0 -18
  541. package/dist/v1/schema/definition/property.d.ts.map +0 -1
  542. package/dist/v1/schema/definition/property.js +0 -2
  543. package/dist/v1/schema/definition/property.js.map +0 -1
  544. package/dist/v1/schema/definition/validate.d.ts +0 -5
  545. package/dist/v1/schema/definition/validate.d.ts.map +0 -1
  546. package/dist/v1/schema/definition/validate.js +0 -221
  547. package/dist/v1/schema/definition/validate.js.map +0 -1
  548. package/dist/v1/schema/dependency.meaning.d.ts.map +0 -1
  549. package/dist/v1/schema/dependency.meaning.js.map +0 -1
  550. package/dist/v1/schema/diagnostic.d.ts.map +0 -1
  551. package/dist/v1/schema/diagnostic.js.map +0 -1
  552. package/dist/v1/schema/domain.accept.d.ts +0 -4
  553. package/dist/v1/schema/domain.accept.d.ts.map +0 -1
  554. package/dist/v1/schema/domain.accept.js.map +0 -1
  555. package/dist/v1/schema/domain.codec.d.ts.map +0 -1
  556. package/dist/v1/schema/domain.codec.js.map +0 -1
  557. package/dist/v1/schema/domain.header.d.ts +0 -15
  558. package/dist/v1/schema/domain.header.d.ts.map +0 -1
  559. package/dist/v1/schema/domain.header.js +0 -21
  560. package/dist/v1/schema/domain.header.js.map +0 -1
  561. package/dist/v1/schema/domain.ir.d.ts +0 -40
  562. package/dist/v1/schema/domain.ir.d.ts.map +0 -1
  563. package/dist/v1/schema/domain.ir.js +0 -5
  564. package/dist/v1/schema/domain.ir.js.map +0 -1
  565. package/dist/v1/schema/domain.lookup.d.ts.map +0 -1
  566. package/dist/v1/schema/domain.lookup.js.map +0 -1
  567. package/dist/v1/schema/domain.resolve.d.ts +0 -26
  568. package/dist/v1/schema/domain.resolve.d.ts.map +0 -1
  569. package/dist/v1/schema/domain.resolve.js +0 -43
  570. package/dist/v1/schema/domain.resolve.js.map +0 -1
  571. package/dist/v1/schema/domain.revision.d.ts.map +0 -1
  572. package/dist/v1/schema/domain.revision.js.map +0 -1
  573. package/dist/v1/schema/domain.validate.d.ts +0 -12
  574. package/dist/v1/schema/domain.validate.d.ts.map +0 -1
  575. package/dist/v1/schema/domain.validate.js.map +0 -1
  576. package/dist/v1/schema/index.d.ts.map +0 -1
  577. package/dist/v1/schema/index.js.map +0 -1
  578. package/dist/v1/schema/metadata.d.ts.map +0 -1
  579. package/dist/v1/schema/metadata.js.map +0 -1
  580. package/dist/v1/schema/policy/ast.d.ts.map +0 -1
  581. package/dist/v1/schema/policy/ast.js +0 -2
  582. package/dist/v1/schema/policy/ast.js.map +0 -1
  583. package/dist/v1/schema/policy/normalize.d.ts +0 -5
  584. package/dist/v1/schema/policy/normalize.d.ts.map +0 -1
  585. package/dist/v1/schema/policy/normalize.js.map +0 -1
  586. package/dist/v1/schema/policy/validation/branches.d.ts.map +0 -1
  587. package/dist/v1/schema/policy/validation/branches.js.map +0 -1
  588. package/dist/v1/schema/policy/validation/budgets.d.ts.map +0 -1
  589. package/dist/v1/schema/policy/validation/budgets.js.map +0 -1
  590. package/dist/v1/schema/policy/validation/context.d.ts +0 -28
  591. package/dist/v1/schema/policy/validation/context.d.ts.map +0 -1
  592. package/dist/v1/schema/policy/validation/context.js.map +0 -1
  593. package/dist/v1/schema/policy/validation/references.d.ts.map +0 -1
  594. package/dist/v1/schema/policy/validation/references.js.map +0 -1
  595. package/dist/v1/schema/policy/validation/typing.d.ts.map +0 -1
  596. package/dist/v1/schema/policy/validation/typing.js.map +0 -1
  597. package/dist/v1/schema/policy/validation/uses.d.ts.map +0 -1
  598. package/dist/v1/schema/policy/validation/uses.js.map +0 -1
  599. package/dist/v1/schema/policy/validation/validate.d.ts.map +0 -1
  600. package/dist/v1/schema/policy/validation/validate.js.map +0 -1
  601. package/dist/v1/schema/reference.d.ts +0 -43
  602. package/dist/v1/schema/reference.d.ts.map +0 -1
  603. package/dist/v1/schema/reference.js +0 -31
  604. package/dist/v1/schema/reference.js.map +0 -1
  605. package/dist/v1/schema/resolution/closure.d.ts.map +0 -1
  606. package/dist/v1/schema/resolution/closure.js.map +0 -1
  607. package/dist/v1/schema/resolution/context.d.ts.map +0 -1
  608. package/dist/v1/schema/resolution/context.js.map +0 -1
  609. package/dist/v1/schema/resolution/definition.index.d.ts.map +0 -1
  610. package/dist/v1/schema/resolution/definition.index.js.map +0 -1
  611. package/dist/v1/schema/resolution/origins.d.ts.map +0 -1
  612. package/dist/v1/schema/resolution/origins.js.map +0 -1
  613. package/dist/v1/schema/resolution/value.registry.d.ts.map +0 -1
  614. package/dist/v1/schema/resolution/value.registry.js.map +0 -1
  615. package/dist/v1/schema/validation/domain.route.d.ts.map +0 -1
  616. package/dist/v1/schema/validation/domain.route.js.map +0 -1
  617. package/dist/v1/schema/validation/domain.structure.d.ts.map +0 -1
  618. package/dist/v1/schema/validation/domain.structure.js.map +0 -1
  619. package/dist/v1/schema/validation/value.d.ts.map +0 -1
  620. package/dist/v1/schema/validation/value.js.map +0 -1
  621. package/dist/v1/schema/value/extensions/node-path/schema.d.ts.map +0 -1
  622. package/dist/v1/schema/value/extensions/node-path/schema.js.map +0 -1
  623. package/dist/v1/schema/value/extensions/node-path/validate.d.ts +0 -5
  624. package/dist/v1/schema/value/extensions/node-path/validate.d.ts.map +0 -1
  625. package/dist/v1/schema/value/extensions/node-path/validate.js.map +0 -1
  626. package/dist/v1/schema/value/index.d.ts.map +0 -1
  627. package/dist/v1/schema/value/index.js.map +0 -1
  628. package/dist/v1/schema/value/instance/assertions.d.ts.map +0 -1
  629. package/dist/v1/schema/value/instance/assertions.js.map +0 -1
  630. package/dist/v1/schema/value/instance/compiler.d.ts.map +0 -1
  631. package/dist/v1/schema/value/instance/compiler.js +0 -69
  632. package/dist/v1/schema/value/instance/compiler.js.map +0 -1
  633. package/dist/v1/schema/value/instance/evaluator.d.ts.map +0 -1
  634. package/dist/v1/schema/value/instance/evaluator.js.map +0 -1
  635. package/dist/v1/schema/value/instance/types.d.ts.map +0 -1
  636. package/dist/v1/schema/value/instance/types.js.map +0 -1
  637. package/dist/v1/schema/value/instance.validate.d.ts.map +0 -1
  638. package/dist/v1/schema/value/instance.validate.js.map +0 -1
  639. package/dist/v1/schema/value/instant.d.ts.map +0 -1
  640. package/dist/v1/schema/value/instant.js.map +0 -1
  641. package/dist/v1/schema/value/location/keywords.d.ts.map +0 -1
  642. package/dist/v1/schema/value/location/keywords.js.map +0 -1
  643. package/dist/v1/schema/value/location/pointer.d.ts.map +0 -1
  644. package/dist/v1/schema/value/location/pointer.js.map +0 -1
  645. package/dist/v1/schema/value/location/walk.d.ts.map +0 -1
  646. package/dist/v1/schema/value/location/walk.js.map +0 -1
  647. package/dist/v1/schema/value/object.d.ts.map +0 -1
  648. package/dist/v1/schema/value/object.js.map +0 -1
  649. package/dist/v1/schema/value/ordering.d.ts.map +0 -1
  650. package/dist/v1/schema/value/ordering.js.map +0 -1
  651. package/dist/v1/schema/value/profile/canonicalize.d.ts.map +0 -1
  652. package/dist/v1/schema/value/profile/canonicalize.js.map +0 -1
  653. package/dist/v1/schema/value/profile/dialect.d.ts +0 -5
  654. package/dist/v1/schema/value/profile/dialect.d.ts.map +0 -1
  655. package/dist/v1/schema/value/profile/dialect.js +0 -36
  656. package/dist/v1/schema/value/profile/dialect.js.map +0 -1
  657. package/dist/v1/schema/value/profile/json.validate.d.ts +0 -3
  658. package/dist/v1/schema/value/profile/json.validate.d.ts.map +0 -1
  659. package/dist/v1/schema/value/profile/json.validate.js.map +0 -1
  660. package/dist/v1/schema/value/profile/meta-schema.compiled.d.ts.map +0 -1
  661. package/dist/v1/schema/value/profile/meta-schema.compiled.js.map +0 -1
  662. package/dist/v1/schema/value/profile/meta-schema.validate.d.ts +0 -4
  663. package/dist/v1/schema/value/profile/meta-schema.validate.d.ts.map +0 -1
  664. package/dist/v1/schema/value/profile/meta-schema.validate.js.map +0 -1
  665. package/dist/v1/schema/value/profile/rules.d.ts +0 -5
  666. package/dist/v1/schema/value/profile/rules.d.ts.map +0 -1
  667. package/dist/v1/schema/value/profile/rules.js.map +0 -1
  668. package/dist/v1/schema/value/profile/validate.d.ts +0 -5
  669. package/dist/v1/schema/value/profile/validate.d.ts.map +0 -1
  670. package/dist/v1/schema/value/profile/validate.js.map +0 -1
  671. package/dist/v1/schema/value/profile/vocabulary.d.ts.map +0 -1
  672. package/dist/v1/schema/value/profile/vocabulary.js.map +0 -1
  673. package/dist/v1/schema/value/regexp/linear.d.ts +0 -20
  674. package/dist/v1/schema/value/regexp/linear.d.ts.map +0 -1
  675. package/dist/v1/schema/value/regexp/linear.js +0 -24
  676. package/dist/v1/schema/value/regexp/linear.js.map +0 -1
  677. package/dist/v1/schema/value/regexp/lower.d.ts.map +0 -1
  678. package/dist/v1/schema/value/regexp/lower.js.map +0 -1
  679. package/dist/v1/schema/value/regexp/pattern.d.ts.map +0 -1
  680. package/dist/v1/schema/value/regexp/pattern.js.map +0 -1
  681. package/dist/v1/schema/value/regexp/syntax.d.ts +0 -3
  682. package/dist/v1/schema/value/regexp/syntax.d.ts.map +0 -1
  683. package/dist/v1/schema/value/regexp/syntax.js +0 -217
  684. package/dist/v1/schema/value/regexp/syntax.js.map +0 -1
  685. package/dist/v1/schema/value/registry.d.ts.map +0 -1
  686. package/dist/v1/schema/value/registry.js +0 -2
  687. package/dist/v1/schema/value/registry.js.map +0 -1
  688. package/dist/v1/schema/value/resources/closure.d.ts +0 -12
  689. package/dist/v1/schema/value/resources/closure.d.ts.map +0 -1
  690. package/dist/v1/schema/value/resources/closure.js.map +0 -1
  691. package/dist/v1/schema/value/resources/recursion.d.ts.map +0 -1
  692. package/dist/v1/schema/value/resources/recursion.js.map +0 -1
  693. package/dist/v1/schema/value/resources/references.d.ts +0 -25
  694. package/dist/v1/schema/value/resources/references.d.ts.map +0 -1
  695. package/dist/v1/schema/value/resources/references.js +0 -93
  696. package/dist/v1/schema/value/resources/references.js.map +0 -1
  697. package/dist/v1/schema/value/resources/registry.index.d.ts +0 -22
  698. package/dist/v1/schema/value/resources/registry.index.d.ts.map +0 -1
  699. package/dist/v1/schema/value/resources/registry.index.js.map +0 -1
  700. package/dist/v1/schema/value/schema.d.ts.map +0 -1
  701. package/dist/v1/schema/value/schema.js.map +0 -1
  702. package/dist/v1/schema/view/declaration.d.ts +0 -14
  703. package/dist/v1/schema/view/declaration.d.ts.map +0 -1
  704. package/dist/v1/schema/view/declaration.js +0 -2
  705. package/dist/v1/schema/view/declaration.js.map +0 -1
  706. package/dist/v1/schema/view/validate.d.ts +0 -4
  707. package/dist/v1/schema/view/validate.d.ts.map +0 -1
  708. package/dist/v1/schema/view/validate.js.map +0 -1
  709. package/dist/v1/schema.d.ts +0 -3
  710. package/dist/v1/schema.d.ts.map +0 -1
  711. package/dist/v1/schema.js +0 -3
  712. package/dist/v1/schema.js.map +0 -1
  713. package/dist/v1.d.ts.map +0 -1
  714. package/dist/v1.js.map +0 -1
  715. package/dist/value/accept.d.ts.map +0 -1
  716. package/dist/value/accept.js.map +0 -1
  717. package/dist/value/canonical.d.ts.map +0 -1
  718. package/dist/value/canonical.js.map +0 -1
  719. package/dist/value/decode.d.ts.map +0 -1
  720. package/dist/value/decode.js.map +0 -1
  721. package/dist/value/equal.d.ts.map +0 -1
  722. package/dist/value/equal.js.map +0 -1
  723. package/dist/value/error.d.ts.map +0 -1
  724. package/dist/value/error.js.map +0 -1
  725. package/dist/value/index.d.ts.map +0 -1
  726. package/dist/value/index.js.map +0 -1
  727. package/dist/value/json.d.ts.map +0 -1
  728. package/dist/value/json.js.map +0 -1
  729. package/dist/value/limits.d.ts.map +0 -1
  730. package/dist/value/limits.js.map +0 -1
  731. package/dist/value/types.d.ts.map +0 -1
  732. package/dist/value/types.js.map +0 -1
  733. package/dist/value/unicode.d.ts.map +0 -1
  734. package/dist/value/unicode.js.map +0 -1
  735. package/dist/version/dispatch.d.ts.map +0 -1
  736. package/dist/version/dispatch.js.map +0 -1
  737. package/dist/version/index.d.ts.map +0 -1
  738. package/dist/version/index.js.map +0 -1
@@ -0,0 +1,1114 @@
1
+ import { json } from '@astrale-os/kernel-dsl/value';
2
+ import { Key, PropertyKey as PropertyKeyValue } from '../../addressing/index.js';
3
+ import { compareUnicode } from '../../addressing/ordering.js';
4
+ import { branchesOf, branchProduct, capBranches, isConnected, targetMode, termKey, } from '../../language/policy/analysis/branches.js';
5
+ 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';
6
+ import { normalizePolicyChecks, normalizePolicyExpression, } from '../../language/policy/normalization/normalize.js';
7
+ import { validateValueProgram } from '../../language/value/evaluate/program.js';
8
+ import { GRAPH_NODE_PATH_SCHEMA_ID } from '../../language/value/syntax/node-path/schema.js';
9
+ import { invalidCompiled } from '../diagnostic.js';
10
+ /**
11
+ * Re-admit contextual Language laws after the portable compiled grammar and
12
+ * exact closure have been established. This module deliberately depends only
13
+ * on compiled and Language runtime machinery; it is safe in the load graph.
14
+ */
15
+ export function validateCompiledSemantics(candidate) {
16
+ const partial = index(candidate);
17
+ const analyses = analyzeClasses(partial.classes);
18
+ const context = { ...partial, analyses };
19
+ validateClassFacets(context);
20
+ validateEdges(context);
21
+ validateViews(candidate, context);
22
+ validatePolicies(candidate, context);
23
+ validateCore(candidate, context);
24
+ }
25
+ function index(candidate) {
26
+ const definitions = new Map();
27
+ const classes = new Map();
28
+ const policies = new Map();
29
+ const core = new Map();
30
+ for (const [entryIndex, entry] of candidate.closure.entries()) {
31
+ const collections = [
32
+ ['classes', entry.definitions.classes],
33
+ ['functions', entry.definitions.functions],
34
+ ['policies', entry.definitions.policies],
35
+ ['views', entry.definitions.views],
36
+ ['core', entry.definitions.core],
37
+ ];
38
+ for (const [collection, values] of collections) {
39
+ for (const [valueIndex, value] of values.entries()) {
40
+ const located = {
41
+ value,
42
+ entry,
43
+ entryIndex,
44
+ index: valueIndex,
45
+ pointer: `/closure/${entryIndex}/definitions/${collection}/${valueIndex}`,
46
+ };
47
+ definitions.set(Key.of(value.ref), {
48
+ ...located,
49
+ value: value.ref,
50
+ });
51
+ if (value.ref.kind === 'class')
52
+ classes.set(Key.of(value.ref), located);
53
+ if (value.ref.kind === 'policy')
54
+ policies.set(Key.of(value.ref), located);
55
+ if (value.ref.kind === 'core')
56
+ core.set(Key.of(value.ref), located);
57
+ }
58
+ }
59
+ }
60
+ return { definitions, classes, policies, core };
61
+ }
62
+ function analyzeClasses(classes) {
63
+ const analyses = new Map();
64
+ const visiting = new Set();
65
+ const analyze = (located) => {
66
+ const classKey = Key.of(located.value.ref);
67
+ const cached = analyses.get(classKey);
68
+ if (cached !== undefined)
69
+ return cached;
70
+ if (visiting.has(classKey))
71
+ fail(`${located.pointer}/extends`, 'Class inheritance is cyclic.');
72
+ visiting.add(classKey);
73
+ const parents = located.value.extends.map((ref, index) => {
74
+ const parent = classes.get(Key.of(ref));
75
+ if (parent === undefined)
76
+ fail(`${located.pointer}/extends/${index}`, 'Parent Class is absent.');
77
+ return analyze(parent);
78
+ });
79
+ const properties = new Map();
80
+ for (const parent of parents)
81
+ for (const [key, value] of parent.properties)
82
+ properties.set(key, value);
83
+ for (const property of located.value.properties) {
84
+ const key = PropertyKeyValue.of(located.value.ref, property.name);
85
+ properties.set(key, {
86
+ key,
87
+ owner: located.value.ref,
88
+ declaration: property,
89
+ entry: located.entry,
90
+ });
91
+ }
92
+ let dataOwner;
93
+ for (const parent of parents) {
94
+ if (parent.dataOwner === undefined)
95
+ continue;
96
+ if (dataOwner !== undefined && Key.of(dataOwner) !== Key.of(parent.dataOwner)) {
97
+ fail(located.pointer, 'Data has distinct inherited declaring owners.');
98
+ }
99
+ dataOwner = parent.dataOwner;
100
+ }
101
+ if (located.value.kind === 'node' && located.value.data !== undefined) {
102
+ if (dataOwner !== undefined)
103
+ fail(`${located.pointer}/data`, 'Data cannot redeclare an inherited contract.');
104
+ dataOwner = located.value.ref;
105
+ }
106
+ const inherited = new Map();
107
+ for (const parent of parents) {
108
+ for (const [name, method] of parent.methods) {
109
+ const values = inherited.get(name) ?? [];
110
+ if (!values.some(({ key }) => key === method.key))
111
+ values.push(method);
112
+ inherited.set(name, values);
113
+ }
114
+ }
115
+ const methods = new Map();
116
+ for (const [name, values] of inherited)
117
+ if (values.length === 1)
118
+ methods.set(name, values[0]);
119
+ if (located.value.kind === 'node') {
120
+ for (const own of located.value.methods) {
121
+ const inheritedMethods = inherited.get(own.name) ?? [];
122
+ for (const parent of inheritedMethods) {
123
+ if (parent.declaration.inheritance === 'sealed') {
124
+ fail(`${located.pointer}/methods`, `Method ${own.name} overrides a sealed Method.`);
125
+ }
126
+ if (!sameMethodSignature(located.entry, own, parent.entry, parent.declaration)) {
127
+ fail(`${located.pointer}/methods`, `Method ${own.name} changes its inherited signature.`);
128
+ }
129
+ if (parent.declaration.inheritance !== 'abstract' &&
130
+ policyKey(parent.declaration.policy) !== policyKey(own.policy)) {
131
+ fail(`${located.pointer}/methods`, `Method ${own.name} changes an executable inherited Policy.`);
132
+ }
133
+ }
134
+ methods.set(own.name, {
135
+ key: `${Key.of(located.value.ref)}.method.${own.name}`,
136
+ owner: located.value.ref,
137
+ declaration: own,
138
+ entry: located.entry,
139
+ });
140
+ inherited.delete(own.name);
141
+ }
142
+ for (const [name, values] of inherited) {
143
+ if (values.length > 1)
144
+ fail(`${located.pointer}/methods`, `Inherited Method ${name} is ambiguous.`);
145
+ }
146
+ if (!located.value.abstract) {
147
+ for (const [name, method] of methods) {
148
+ if (method.declaration.inheritance === 'abstract') {
149
+ fail(`${located.pointer}/methods`, `Concrete Class leaves Method ${name} abstract.`);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ const analysis = { properties, methods, ...(dataOwner === undefined ? {} : { dataOwner }) };
155
+ analyses.set(classKey, analysis);
156
+ visiting.delete(classKey);
157
+ return analysis;
158
+ };
159
+ for (const value of classes.values())
160
+ analyze(value);
161
+ return analyses;
162
+ }
163
+ function sameMethodSignature(leftEntry, left, rightEntry, right) {
164
+ return (programKey(leftEntry, left.input) === programKey(rightEntry, right.input) &&
165
+ outputKey(leftEntry, left.output) === outputKey(rightEntry, right.output) &&
166
+ left.auth === right.auth &&
167
+ left.static === right.static);
168
+ }
169
+ function outputKey(entry, output) {
170
+ return output.mode === 'binary' ? 'binary' : `${output.mode}:${programKey(entry, output.value)}`;
171
+ }
172
+ function programKey(entry, value) {
173
+ return json.serialize(entry.values[value]);
174
+ }
175
+ function policyKey(value) {
176
+ return json.serialize((value === undefined ? null : normalizePolicyChecks(value)));
177
+ }
178
+ function validateClassFacets(context) {
179
+ for (const located of context.classes.values()) {
180
+ for (const [index, property] of located.value.properties.entries()) {
181
+ const path = `${located.pointer}/properties/${index}`;
182
+ if (property.auto !== undefined) {
183
+ if (property.required && !property.auto.on.includes('create')) {
184
+ fail(`${path}/auto/on`, 'A required auto Property must run on create.');
185
+ }
186
+ if (property.auto.set === 'instant' && property.ordering !== 'instant') {
187
+ fail(`${path}/auto/set`, 'The instant setter requires an Instant value program.');
188
+ }
189
+ }
190
+ }
191
+ if (located.value.kind === 'node') {
192
+ for (const [index, method] of located.value.methods.entries()) {
193
+ if (method.inheritance === 'abstract' && method.policy !== undefined) {
194
+ fail(`${located.pointer}/methods/${index}/policy`, 'An abstract Method cannot have a Policy.');
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ function validateEdges(context) {
201
+ for (const located of context.classes.values()) {
202
+ if (!isCompiledEdge(located.value))
203
+ continue;
204
+ const edge = located.value;
205
+ const endpoints = edge.orientation === 'directed'
206
+ ? [edge.endpoints.source, edge.endpoints.target]
207
+ : edge.endpoints;
208
+ if (endpoints[0].role === endpoints[1].role)
209
+ fail(`${located.pointer}/endpoints`, 'Edge endpoint roles must differ.');
210
+ for (const [endpointIndex, endpoint] of endpoints.entries()) {
211
+ const seen = new Set();
212
+ for (const [acceptIndex, ref] of endpoint.accepts.entries()) {
213
+ const key = Key.of(ref);
214
+ if (seen.has(key))
215
+ fail(`${located.pointer}/endpoints/${endpointIndex}/accepts/${acceptIndex}`, 'Edge endpoint repeats an accepted Class.');
216
+ seen.add(key);
217
+ if (context.classes.get(key)?.value.kind !== 'node')
218
+ fail(`${located.pointer}/endpoints/${endpointIndex}/accepts/${acceptIndex}`, 'Edge endpoint must accept a Node Class.');
219
+ }
220
+ }
221
+ if (edge.orientation === 'undirected' &&
222
+ !sameIncidentEndpoint(edge.endpoints[0], edge.endpoints[1]) &&
223
+ undirectedOverlap(context, edge.endpoints)) {
224
+ fail(`${located.pointer}/endpoints`, 'Unequal undirected endpoint contracts overlap.');
225
+ }
226
+ for (const [parentIndex, parentRef] of edge.extends.entries()) {
227
+ const parent = context.classes.get(Key.of(parentRef))?.value;
228
+ if (parent !== undefined && isCompiledEdge(parent) && !edgeRefines(context, edge, parent)) {
229
+ fail(`${located.pointer}/extends/${parentIndex}`, 'Edge Class does not safely refine its parent.');
230
+ }
231
+ }
232
+ }
233
+ }
234
+ function edgeRefines(context, child, parent) {
235
+ if (child.orientation !== parent.orientation)
236
+ return false;
237
+ if (parent.constraints.noSelf === true && child.constraints.noSelf !== true)
238
+ return false;
239
+ if (parent.constraints.acyclic === true && child.constraints.acyclic !== true)
240
+ return false;
241
+ if (child.orientation === 'directed' && parent.orientation === 'directed') {
242
+ return (endpointRefines(context, child.endpoints.source, parent.endpoints.source) &&
243
+ countRefines(child.endpoints.source.outgoing, parent.endpoints.source.outgoing) &&
244
+ endpointRefines(context, child.endpoints.target, parent.endpoints.target) &&
245
+ countRefines(child.endpoints.target.incoming, parent.endpoints.target.incoming));
246
+ }
247
+ if (child.orientation !== 'undirected' || parent.orientation !== 'undirected')
248
+ return false;
249
+ const refine = (a, b) => endpointRefines(context, child.endpoints[a], parent.endpoints[b]) &&
250
+ countRefines(child.endpoints[a].incident, parent.endpoints[b].incident);
251
+ const direct = refine(0, 0) && refine(1, 1);
252
+ if (direct)
253
+ return true;
254
+ const reverse = refine(0, 1) && refine(1, 0);
255
+ return reverse && !hasEffectiveEdgePolicy(context, parent, new Set());
256
+ }
257
+ function hasEffectiveEdgePolicy(context, declaration, visited) {
258
+ if (declaration.policies.read !== undefined || declaration.policies.traverse !== undefined) {
259
+ return true;
260
+ }
261
+ for (const parentRef of declaration.extends) {
262
+ const key = Key.of(parentRef);
263
+ if (visited.has(key))
264
+ continue;
265
+ visited.add(key);
266
+ const parent = context.classes.get(key)?.value;
267
+ if (parent !== undefined &&
268
+ isCompiledEdge(parent) &&
269
+ hasEffectiveEdgePolicy(context, parent, visited)) {
270
+ return true;
271
+ }
272
+ }
273
+ return false;
274
+ }
275
+ function endpointRefines(context, child, parent) {
276
+ return child.accepts.every((accepted) => classSatisfiesAny(context, accepted, parent.accepts));
277
+ }
278
+ function countRefines(child, parent) {
279
+ const [childMin, childMax] = countBounds(child);
280
+ const [parentMin, parentMax] = countBounds(parent);
281
+ return childMin >= parentMin && childMax <= parentMax;
282
+ }
283
+ function sameIncidentEndpoint(left, right) {
284
+ const a = left.accepts.map(Key.of).sort(compareUnicode);
285
+ const b = right.accepts.map(Key.of).sort(compareUnicode);
286
+ return (left.incident === right.incident &&
287
+ a.length === b.length &&
288
+ a.every((value, index) => value === b[index]));
289
+ }
290
+ function undirectedOverlap(context, endpoints) {
291
+ return [...context.classes.values()].some(({ value }) => value.kind === 'node' &&
292
+ !value.abstract &&
293
+ classSatisfiesAny(context, value.ref, endpoints[0].accepts) &&
294
+ classSatisfiesAny(context, value.ref, endpoints[1].accepts));
295
+ }
296
+ function classSatisfiesAny(context, candidate, accepted) {
297
+ const targets = new Set(accepted.map(Key.of));
298
+ const visit = (ref, seen) => {
299
+ const key = Key.of(ref);
300
+ if (targets.has(key))
301
+ return true;
302
+ if (seen.has(key))
303
+ return false;
304
+ seen.add(key);
305
+ return context.classes.get(key)?.value.extends.some((parent) => visit(parent, seen)) ?? false;
306
+ };
307
+ return visit(candidate, new Set());
308
+ }
309
+ function validateViews(candidate, context) {
310
+ for (const [entryIndex, entry] of candidate.closure.entries()) {
311
+ for (const [viewIndex, view] of entry.definitions.views.entries()) {
312
+ if (view.target.kind !== 'definition')
313
+ continue;
314
+ for (const [targetIndex, ref] of view.target.definitions.entries()) {
315
+ if (context.classes.get(Key.of(ref))?.value.kind !== 'node') {
316
+ fail(`/closure/${entryIndex}/definitions/views/${viewIndex}/target/definitions/${targetIndex}`, 'A View Definition target must resolve to a Node Class.');
317
+ }
318
+ }
319
+ }
320
+ }
321
+ }
322
+ function validatePolicies(candidate, context) {
323
+ for (const [entryIndex, entry] of candidate.closure.entries()) {
324
+ const localPolicies = new Map(entry.definitions.policies.map((value) => [value.ref.name, value]));
325
+ for (const [policyIndex, policy] of entry.definitions.policies.entries()) {
326
+ validatePolicyExpression(context, entry, policy.expression, `/closure/${entryIndex}/definitions/policies/${policyIndex}/expression`, localPolicies);
327
+ }
328
+ validatePolicyCycles(entry, localPolicies, entryIndex);
329
+ validatePolicyParity(context, entry, entryIndex, localPolicies);
330
+ for (const [functionIndex, callable] of entry.definitions.functions.entries()) {
331
+ if (callable.policy !== undefined)
332
+ validateCallablePolicy(context, entry, callable.policy, callable.input, callable.fields, false, `/closure/${entryIndex}/definitions/functions/${functionIndex}/policy`);
333
+ }
334
+ for (const [classIndex, definition] of entry.definitions.classes.entries()) {
335
+ for (const [kind, ref] of Object.entries(definition.policies)) {
336
+ if (ref !== undefined &&
337
+ (ref.origin !== entry.origin || context.policies.get(Key.of(ref)) === undefined)) {
338
+ fail(`/closure/${entryIndex}/definitions/classes/${classIndex}/policies/${kind}`, 'Class Policies must name a local Policy Definition.');
339
+ }
340
+ }
341
+ if (definition.kind !== 'node')
342
+ continue;
343
+ for (const [methodIndex, callable] of definition.methods.entries()) {
344
+ if (callable.policy !== undefined)
345
+ validateCallablePolicy(context, entry, callable.policy, callable.input, callable.fields, !callable.static, `/closure/${entryIndex}/definitions/classes/${classIndex}/methods/${methodIndex}/policy`);
346
+ }
347
+ }
348
+ }
349
+ }
350
+ function validatePolicyExpression(context, entry, expression, path, local) {
351
+ if ('match' in expression) {
352
+ validatePattern(context, expression.match, `${path}/match`, new Set(), new Set());
353
+ return;
354
+ }
355
+ const values = 'allOf' in expression ? expression.allOf : expression.anyOf;
356
+ if (values.length === 0)
357
+ fail(path, 'Named Policy composition must be non-empty.');
358
+ for (const [index, ref] of values.entries()) {
359
+ if (ref.origin !== entry.origin || ref.kind !== 'policy' || !local.has(ref.name))
360
+ fail(`${path}/${index}`, 'Named Policy composition must reference a local Policy.');
361
+ }
362
+ }
363
+ function validatePattern(context, expression, path, scope, declared) {
364
+ if ('source' in expression) {
365
+ if (context.classes.get(Key.of(expression.class))?.value.kind !== 'edge')
366
+ fail(`${path}/class`, 'Policy pattern Class must resolve to an Edge Class.');
367
+ validatePolicyTerm(expression.source, `${path}/source`, scope);
368
+ validatePolicyTerm(expression.target, `${path}/target`, scope);
369
+ if (expression.repeat !== undefined &&
370
+ (!Number.isInteger(expression.repeat.min) ||
371
+ !Number.isInteger(expression.repeat.max) ||
372
+ expression.repeat.min < 0 ||
373
+ expression.repeat.max < expression.repeat.min ||
374
+ expression.repeat.max > MAX_REPEAT))
375
+ fail(`${path}/repeat`, 'Policy repeat is outside the V1 bounds.');
376
+ return;
377
+ }
378
+ if ('exists' in expression) {
379
+ if (expression.exists.nodes.length > MAX_VARIABLES) {
380
+ fail(`${path}/exists/nodes`, 'Policy exists exceeds the V1 variable budget.');
381
+ }
382
+ const nested = new Set(scope);
383
+ for (const [index, node] of expression.exists.nodes.entries()) {
384
+ const id = node.variable.id;
385
+ if (declared.has(id) || nested.has(id))
386
+ fail(`${path}/exists/nodes/${index}/variable/id`, 'Policy variable IDs must be globally unique and cannot shadow.');
387
+ declared.add(id);
388
+ nested.add(id);
389
+ if (context.classes.get(Key.of(node.class))?.value.kind !== 'node')
390
+ fail(`${path}/exists/nodes/${index}/class`, 'Policy variable Class must resolve to a Node Class.');
391
+ }
392
+ validatePattern(context, expression.exists.where, `${path}/exists/where`, nested, declared);
393
+ return;
394
+ }
395
+ const values = 'allOf' in expression ? expression.allOf : expression.anyOf;
396
+ if (values.length === 0)
397
+ fail(path, 'Policy pattern composition must be non-empty.');
398
+ values.forEach((value, index) => validatePattern(context, value, `${path}/${index}`, scope, declared));
399
+ }
400
+ function validatePolicyTerm(term, path, scope) {
401
+ if (term.kind === 'variable' && !scope.has(term.id))
402
+ fail(path, 'Policy variable is outside its declaring scope.');
403
+ }
404
+ function validatePolicyCycles(entry, local, entryIndex) {
405
+ const visiting = new Set();
406
+ const visited = new Set();
407
+ const visit = (name) => {
408
+ if (visiting.has(name))
409
+ fail(`/closure/${entryIndex}/definitions/policies`, `Named Policy composition cycle reaches ${name}.`);
410
+ if (visited.has(name))
411
+ return;
412
+ visiting.add(name);
413
+ const expression = local.get(name)?.expression;
414
+ if (expression !== undefined && !('match' in expression)) {
415
+ for (const ref of 'allOf' in expression ? expression.allOf : expression.anyOf)
416
+ if (ref.origin === entry.origin && ref.kind === 'policy')
417
+ visit(ref.name);
418
+ }
419
+ visiting.delete(name);
420
+ visited.add(name);
421
+ };
422
+ for (const name of local.keys())
423
+ visit(name);
424
+ }
425
+ function validateCallablePolicy(context, entry, expression, inputIndex, fields, instanceMethod, path) {
426
+ if ('check' in expression) {
427
+ if (expression.check.origin !== entry.origin ||
428
+ context.policies.get(Key.of(expression.check)) === undefined)
429
+ fail(`${path}/check`, 'Callable Policy must reference a local named Policy.');
430
+ const object = expression.object;
431
+ if (object.kind === 'self' && !instanceMethod)
432
+ fail(`${path}/object`, 'self is valid only for an instance Method.');
433
+ if (object.kind === 'input') {
434
+ if (fields === undefined ||
435
+ fields[object.field] === undefined ||
436
+ !isSingleNodePathField(context, entry, inputIndex, object.field))
437
+ fail(`${path}/object`, 'Callable Policy input target must be a direct required single-Node Path field.');
438
+ }
439
+ if (object.kind === 'ref') {
440
+ if (object.ref.origin !== entry.origin ||
441
+ context.definitions.get(Key.of(object.ref)) === undefined)
442
+ fail(`${path}/object/ref`, 'Callable Policy object refs must name an exact local Definition.');
443
+ }
444
+ return;
445
+ }
446
+ const children = 'allOf' in expression ? expression.allOf : expression.anyOf;
447
+ if (children.length === 0)
448
+ fail(path, 'Callable Policy composition must be non-empty.');
449
+ children.forEach((child, index) => validateCallablePolicy(context, entry, child, inputIndex, fields, instanceMethod, `${path}/${index}`));
450
+ }
451
+ function isSingleNodePathField(context, entry, inputIndex, field) {
452
+ const rootValue = entry.values[inputIndex]?.nodes[entry.values[inputIndex].root]?.schema;
453
+ if (rootValue === null || typeof rootValue !== 'object' || Array.isArray(rootValue))
454
+ return false;
455
+ const root = rootValue;
456
+ const properties = root.properties;
457
+ if (properties === null || typeof properties !== 'object' || Array.isArray(properties))
458
+ return false;
459
+ const schemaValue = properties[field];
460
+ if (schemaValue === null || typeof schemaValue !== 'object' || Array.isArray(schemaValue))
461
+ return false;
462
+ const schema = schemaValue;
463
+ const annotationValue = schema['x-astrale-path'];
464
+ if (annotationValue === null ||
465
+ typeof annotationValue !== 'object' ||
466
+ Array.isArray(annotationValue))
467
+ return false;
468
+ const annotation = annotationValue;
469
+ return (root.type === 'object' &&
470
+ root.additionalProperties === false &&
471
+ Array.isArray(root.required) &&
472
+ root.required.includes(field) &&
473
+ schema.$ref === GRAPH_NODE_PATH_SCHEMA_ID &&
474
+ annotation.target === 'node' &&
475
+ annotation.cardinality === 'one' &&
476
+ Array.isArray(annotation.accepts) &&
477
+ annotation.accepts.length > 0 &&
478
+ annotation.accepts.every((ref) => isNodeClassRef(context, ref)));
479
+ }
480
+ function isNodeClassRef(context, value) {
481
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
482
+ return false;
483
+ const ref = value;
484
+ if (typeof ref.origin !== 'string' || ref.kind !== 'class' || typeof ref.name !== 'string') {
485
+ return false;
486
+ }
487
+ return context.classes.get(Key.of(ref))?.value.kind === 'node';
488
+ }
489
+ function validatePolicyParity(context, entry, entryIndex, policies) {
490
+ const normalized = new Map([...policies].map(([name, policy]) => [name, normalizePolicyExpression(policy.expression)]));
491
+ const typing = new CompiledPolicyTyping(context, entry, normalized);
492
+ for (const [name, declaration] of policies) {
493
+ const path = `/closure/${entryIndex}/definitions/policies/${declarationIndex(entry, 'policies', name)}`;
494
+ if ('match' in declaration.expression) {
495
+ for (const branch of branchesOf(declaration.expression.match, name)) {
496
+ if (targetMode(branch) === undefined) {
497
+ fail(`${path}/expression/match`, 'A Policy branch must target object or at least one of source and target.');
498
+ }
499
+ if (!isConnected(branch)) {
500
+ fail(`${path}/expression/match`, 'A Policy branch must connect subject, every referenced protected term, and every scoped variable.');
501
+ }
502
+ }
503
+ }
504
+ const measure = measureCompiledPolicy(entry.origin, name, normalized, new Set());
505
+ if (measure !== undefined &&
506
+ (measure.depth > MAX_PATTERN_DEPTH ||
507
+ measure.edgeCounts.length > MAX_BRANCHES ||
508
+ Math.max(0, ...measure.edgeCounts) > MAX_EDGES ||
509
+ measure.domains.size > MAX_DOMAINS)) {
510
+ fail(path, 'Policy expansion exceeds the V1 depth, branch, Edge, or Domain budget.');
511
+ }
512
+ const branches = typing.expandedBranches(name, new Set(), `$${name}`);
513
+ if (branches !== undefined) {
514
+ for (const branch of branches) {
515
+ const mode = targetMode(branch);
516
+ if (mode === undefined)
517
+ fail(path, 'Expanded Policy branches must use one coherent target mode.');
518
+ const use = mode === 'object'
519
+ ? { kind: 'object', object: { kind: 'default' } }
520
+ : { kind: 'edge', source: { kind: 'default' }, target: { kind: 'default' } };
521
+ if (!typing.branchIsTyped(branch, use))
522
+ fail(path, 'A Policy branch has contradictory endpoint or repeat contracts.');
523
+ }
524
+ }
525
+ }
526
+ for (const [classIndex, definition] of entry.definitions.classes.entries()) {
527
+ for (const operation of ['read', 'traverse']) {
528
+ const policy = definition.policies[operation];
529
+ if (policy === undefined)
530
+ continue;
531
+ const path = `/closure/${entryIndex}/definitions/classes/${classIndex}/policies/${operation}`;
532
+ const label = operation === 'read' ? 'Read' : 'Traverse';
533
+ if (definition.kind === 'node') {
534
+ if (!typing.policyAccepts(policy.name, { kind: 'exact', ref: definition.ref })) {
535
+ fail(path, `${label} Policy is incompatible with its protected Node Class.`);
536
+ }
537
+ }
538
+ else if (isCompiledEdge(definition)) {
539
+ const endpoints = definition.orientation === 'directed'
540
+ ? [definition.endpoints.source, definition.endpoints.target]
541
+ : definition.endpoints;
542
+ const sources = typing.concreteEndpointClasses(endpoints[0].accepts);
543
+ const targets = typing.concreteEndpointClasses(endpoints[1].accepts);
544
+ if (sources.some((source) => targets.some((target) => !typing.policyAcceptsEdge(policy.name, { kind: 'exact', ref: source }, { kind: 'exact', ref: target })))) {
545
+ fail(path, `${label} Policy is incompatible with an accepted Edge endpoint pair.`);
546
+ }
547
+ }
548
+ }
549
+ if (definition.kind === 'node') {
550
+ for (const [methodIndex, method] of definition.methods.entries()) {
551
+ if (method.policy !== undefined) {
552
+ validateCallablePolicyTyping(context, typing, entry, method.policy, method.input, method.static ? undefined : definition.ref, `/closure/${entryIndex}/definitions/classes/${classIndex}/methods/${methodIndex}/policy`);
553
+ }
554
+ }
555
+ }
556
+ }
557
+ for (const [functionIndex, callable] of entry.definitions.functions.entries()) {
558
+ if (callable.policy !== undefined) {
559
+ validateCallablePolicyTyping(context, typing, entry, callable.policy, callable.input, undefined, `/closure/${entryIndex}/definitions/functions/${functionIndex}/policy`);
560
+ }
561
+ }
562
+ }
563
+ function declarationIndex(entry, kind, name) {
564
+ return entry.definitions[kind].findIndex(({ ref }) => ref.name === name);
565
+ }
566
+ function validateCallablePolicyTyping(context, typing, entry, expression, input, receiver, path) {
567
+ const measure = measureChecks(expression);
568
+ if (measure.depth > MAX_CHECK_DEPTH ||
569
+ measure.branches > MAX_BRANCHES ||
570
+ measure.leaves > MAX_CHECK_LEAVES) {
571
+ fail(path, 'Callable Policy checks exceed the V1 depth, branch, or leaf budget.');
572
+ }
573
+ const visit = (value, pointer) => {
574
+ if (!('check' in value)) {
575
+ const children = 'allOf' in value ? value.allOf : value.anyOf;
576
+ children.forEach((child, index) => visit(child, `${pointer}/${index}`));
577
+ return;
578
+ }
579
+ const contracts = callableObjectContracts(context, entry, input, receiver, value.object);
580
+ if (contracts !== undefined &&
581
+ contracts.some((contract) => !typing.policyAccepts(value.check.name, contract))) {
582
+ fail(pointer, 'Named Policy is incompatible with the callable object contract.');
583
+ }
584
+ };
585
+ visit(expression, path);
586
+ }
587
+ function callableObjectContracts(context, entry, input, receiver, object) {
588
+ if (object.kind === 'self') {
589
+ return receiver === undefined ? undefined : [{ kind: 'exact', ref: receiver }];
590
+ }
591
+ if (object.kind === 'input') {
592
+ return nodePathAccepts(entry, input, object.field).map((ref) => ({ kind: 'exact', ref }));
593
+ }
594
+ const ref = object.ref;
595
+ if (ref.kind === 'core') {
596
+ const node = context.core.get(Key.of(ref))?.value;
597
+ return node === undefined ? undefined : [{ kind: 'exact', ref: node.class }];
598
+ }
599
+ const projection = ref.kind === 'class'
600
+ ? 'Class'
601
+ : ref.kind === 'function'
602
+ ? 'Function'
603
+ : ref.kind === 'policy'
604
+ ? 'Policy'
605
+ : 'View';
606
+ return [
607
+ {
608
+ kind: 'exact',
609
+ ref: { origin: 'kernel.astrale.ai', kind: 'class', name: projection },
610
+ },
611
+ ];
612
+ }
613
+ function nodePathAccepts(entry, input, field) {
614
+ const root = entry.values[input]?.nodes[entry.values[input].root]?.schema;
615
+ const properties = root?.properties;
616
+ const fieldSchema = properties?.[field];
617
+ const annotation = fieldSchema?.['x-astrale-path'];
618
+ return Array.isArray(annotation?.accepts)
619
+ ? annotation.accepts
620
+ : [];
621
+ }
622
+ class CompiledPolicyTyping {
623
+ context;
624
+ entry;
625
+ normalized;
626
+ allNodeClasses;
627
+ concreteNodeClasses;
628
+ constructor(context, entry, normalized) {
629
+ this.context = context;
630
+ this.entry = entry;
631
+ this.normalized = normalized;
632
+ this.allNodeClasses = [...context.classes.values()]
633
+ .filter(({ value }) => value.kind === 'node')
634
+ .map(({ value }) => value.ref);
635
+ this.concreteNodeClasses = [...context.classes.values()]
636
+ .filter(({ value }) => value.kind === 'node' && !value.abstract)
637
+ .map(({ value }) => value.ref);
638
+ }
639
+ expandedBranches(name, visiting, namespace) {
640
+ if (visiting.has(name))
641
+ return undefined;
642
+ const declaration = this.normalized.get(name);
643
+ if (declaration === undefined)
644
+ return undefined;
645
+ if ('match' in declaration)
646
+ return branchesOf(declaration.match, namespace);
647
+ const nested = new Set(visiting);
648
+ nested.add(name);
649
+ const refs = 'allOf' in declaration ? declaration.allOf : declaration.anyOf;
650
+ const children = [];
651
+ for (const [index, ref] of refs.entries()) {
652
+ if (ref.origin !== this.entry.origin || ref.kind !== 'policy')
653
+ return undefined;
654
+ const expanded = this.expandedBranches(ref.name, nested, `${namespace}/${index}:${ref.name}`);
655
+ if (expanded === undefined)
656
+ return undefined;
657
+ children.push(expanded);
658
+ }
659
+ return 'allOf' in declaration ? branchProduct(children) : capBranches(children.flat());
660
+ }
661
+ policyAccepts(name, object) {
662
+ const branches = this.expandedBranches(name, new Set(), `$use:${name}`);
663
+ return (branches !== undefined &&
664
+ branches.every((branch) => this.branchIsTyped(branch, { kind: 'object', object })));
665
+ }
666
+ policyAcceptsEdge(name, source, target) {
667
+ const branches = this.expandedBranches(name, new Set(), `$edge-use:${name}`);
668
+ return (branches !== undefined &&
669
+ branches.every((branch) => this.branchIsTyped(branch, { kind: 'edge', source, target })));
670
+ }
671
+ concreteEndpointClasses(accepts) {
672
+ return this.concreteNodeClasses.filter((candidate) => classSatisfiesAny(this.context, candidate, accepts));
673
+ }
674
+ endpointsOverlap(left, right) {
675
+ const seed = [{ kind: 'open', requirements: [] }];
676
+ return this.applyEndpoint(this.applyEndpoint(seed, left), right).length > 0;
677
+ }
678
+ branchIsTyped(branch, use) {
679
+ if (targetMode(branch) !== use.kind)
680
+ return false;
681
+ return compiledEdgeAlternatives(branch.edges, this).some((variants) => this.constraintsSatisfiable(branch, variants, use));
682
+ }
683
+ constraintsSatisfiable(branch, variants, use) {
684
+ const terms = new Set(use.kind === 'object' ? ['subject', 'object'] : ['subject', 'source', 'target']);
685
+ for (const key of branch.variables.keys())
686
+ terms.add(key);
687
+ for (const edge of branch.edges) {
688
+ terms.add(termKey(edge.pattern.source, edge.namespace));
689
+ terms.add(termKey(edge.pattern.target, edge.namespace));
690
+ }
691
+ const union = new CompiledUnionFind(terms);
692
+ for (const variant of variants)
693
+ for (const [left, right] of variant.equalities)
694
+ union.join(left, right);
695
+ const constraints = new Map();
696
+ for (const variant of variants) {
697
+ for (const [term, accepts] of variant.constraints) {
698
+ const root = union.find(term);
699
+ const values = constraints.get(root) ?? [];
700
+ values.push(accepts);
701
+ constraints.set(root, values);
702
+ }
703
+ }
704
+ const groups = new Map();
705
+ for (const term of terms) {
706
+ const root = union.find(term);
707
+ const values = groups.get(root) ?? [];
708
+ values.push(term);
709
+ groups.set(root, values);
710
+ }
711
+ for (const [root, members] of groups) {
712
+ let candidates = [{ kind: 'open', requirements: [] }];
713
+ for (const member of members) {
714
+ candidates = this.applyInitial(candidates, member, branch, use);
715
+ if (candidates.length === 0)
716
+ return false;
717
+ }
718
+ for (const endpoint of constraints.get(root) ?? []) {
719
+ candidates = this.applyEndpoint(candidates, endpoint);
720
+ if (candidates.length === 0)
721
+ return false;
722
+ }
723
+ }
724
+ return true;
725
+ }
726
+ applyInitial(candidates, term, branch, use) {
727
+ if (term === 'subject')
728
+ return this.applyAnyNodeClass(candidates);
729
+ const contract = compiledTargetContract(term, use);
730
+ if (contract !== undefined) {
731
+ return contract.kind === 'exact'
732
+ ? this.applyExact(candidates, contract.ref)
733
+ : uniqueCompiledCandidates(this.allNodeClasses.flatMap((ref) => this.applyExact(candidates, ref)));
734
+ }
735
+ const exact = branch.variables.get(term);
736
+ return exact === undefined ? [] : this.applyExact(candidates, exact);
737
+ }
738
+ applyExact(candidates, exact) {
739
+ return uniqueCompiledCandidates(candidates.flatMap((candidate) => {
740
+ if (candidate.kind === 'exact')
741
+ return Key.of(candidate.ref) === Key.of(exact) ? [candidate] : [];
742
+ return candidate.requirements.every((required) => classSatisfiesAny(this.context, exact, [required]))
743
+ ? [{ kind: 'exact', ref: exact }]
744
+ : [];
745
+ }));
746
+ }
747
+ applyAnyNodeClass(candidates) {
748
+ return uniqueCompiledCandidates(candidates.flatMap((candidate) => candidate.kind === 'exact'
749
+ ? [candidate]
750
+ : this.allNodeClasses
751
+ .filter((ref) => candidate.requirements.every((required) => classSatisfiesAny(this.context, ref, [required])))
752
+ .map((ref) => ({ kind: 'exact', ref }))));
753
+ }
754
+ applyEndpoint(candidates, accepts) {
755
+ const result = [];
756
+ for (const candidate of candidates) {
757
+ if (candidate.kind === 'exact') {
758
+ if (classSatisfiesAny(this.context, candidate.ref, accepts))
759
+ result.push(candidate);
760
+ }
761
+ else {
762
+ for (const accept of accepts) {
763
+ result.push({
764
+ kind: 'open',
765
+ requirements: uniqueClassRefs([...candidate.requirements, accept]),
766
+ });
767
+ }
768
+ }
769
+ }
770
+ return uniqueCompiledCandidates(result);
771
+ }
772
+ }
773
+ function compiledTargetContract(term, use) {
774
+ if (use.kind === 'object')
775
+ return term === 'object' ? use.object : undefined;
776
+ return term === 'source' ? use.source : term === 'target' ? use.target : undefined;
777
+ }
778
+ function compiledEdgeAlternatives(edges, typing) {
779
+ let result = [[]];
780
+ for (const edge of edges) {
781
+ const variants = compiledVariantsForEdge(edge, typing);
782
+ if (variants.length === 0)
783
+ return [];
784
+ result = result.flatMap((prefix) => variants.map((variant) => [...prefix, variant]));
785
+ }
786
+ return result;
787
+ }
788
+ function compiledVariantsForEdge(use, typing) {
789
+ const declaration = typing.context.classes.get(Key.of(use.pattern.class))?.value;
790
+ if (declaration === undefined || !isCompiledEdge(declaration))
791
+ return [];
792
+ const endpoints = declaration.orientation === 'directed'
793
+ ? [declaration.endpoints.source, declaration.endpoints.target]
794
+ : declaration.endpoints;
795
+ const repeat = use.pattern.repeat ?? { min: 1, max: 1 };
796
+ const sourceKey = termKey(use.pattern.source, use.namespace);
797
+ const targetKey = termKey(use.pattern.target, use.namespace);
798
+ const variants = [];
799
+ for (let length = repeat.min; length <= repeat.max; length++) {
800
+ if (length === 0) {
801
+ variants.push({ constraints: [], equalities: [[sourceKey, targetKey]] });
802
+ continue;
803
+ }
804
+ const orientationCount = declaration.orientation === 'undirected' ? 2 ** length : 1;
805
+ for (let mask = 0; mask < orientationCount; mask++) {
806
+ const reversed = Array.from({ length }, (_, index) => declaration.orientation === 'undirected' && (mask & (1 << index)) !== 0);
807
+ let valid = true;
808
+ for (let index = 0; index + 1 < length; index++) {
809
+ const incoming = reversed[index] ? endpoints[0] : endpoints[1];
810
+ const outgoing = reversed[index + 1] ? endpoints[1] : endpoints[0];
811
+ if (!typing.endpointsOverlap(incoming.accepts, outgoing.accepts))
812
+ valid = false;
813
+ }
814
+ if (!valid)
815
+ continue;
816
+ const first = reversed[0] ? endpoints[1] : endpoints[0];
817
+ const last = reversed[length - 1] ? endpoints[0] : endpoints[1];
818
+ variants.push({
819
+ constraints: [
820
+ [sourceKey, first.accepts],
821
+ [targetKey, last.accepts],
822
+ ],
823
+ equalities: [],
824
+ });
825
+ }
826
+ }
827
+ return uniqueCompiledEdgeVariants(variants);
828
+ }
829
+ function uniqueCompiledEdgeVariants(values) {
830
+ const result = new Map();
831
+ for (const value of values) {
832
+ const key = `${value.constraints.map(([term, accepts]) => `${term}:${accepts.map(Key.of).sort(compareUnicode).join(',')}`).join('|')}=${value.equalities.map(([left, right]) => `${left}:${right}`).join('|')}`;
833
+ result.set(key, value);
834
+ }
835
+ return [...result.values()];
836
+ }
837
+ function uniqueCompiledCandidates(values) {
838
+ const result = new Map();
839
+ for (const value of values) {
840
+ const key = value.kind === 'exact'
841
+ ? `exact:${Key.of(value.ref)}`
842
+ : `open:${value.requirements.map(Key.of).sort(compareUnicode).join('|')}`;
843
+ result.set(key, value);
844
+ }
845
+ return [...result.values()];
846
+ }
847
+ function uniqueClassRefs(values) {
848
+ return [...new Map(values.map((value) => [Key.of(value), value])).values()];
849
+ }
850
+ function measureCompiledPolicy(origin, name, normalized, visiting) {
851
+ if (visiting.has(name))
852
+ return undefined;
853
+ const expression = normalized.get(name);
854
+ if (expression === undefined)
855
+ return undefined;
856
+ if ('match' in expression)
857
+ return measureCompiledPattern(expression.match, origin);
858
+ const nested = new Set(visiting);
859
+ nested.add(name);
860
+ const refs = 'allOf' in expression ? expression.allOf : expression.anyOf;
861
+ const children = refs.map((ref) => ref.origin === origin ? measureCompiledPolicy(origin, ref.name, normalized, nested) : undefined);
862
+ if (children.some((value) => value === undefined))
863
+ return undefined;
864
+ return combineCompiledMeasures('allOf' in expression ? 'allOf' : 'anyOf', children);
865
+ }
866
+ function measureCompiledPattern(pattern, origin) {
867
+ if ('source' in pattern)
868
+ return { depth: 1, edgeCounts: [1], domains: new Set([origin, pattern.class.origin]) };
869
+ if ('exists' in pattern) {
870
+ const child = measureCompiledPattern(pattern.exists.where, origin);
871
+ return {
872
+ depth: child.depth + 1,
873
+ edgeCounts: child.edgeCounts,
874
+ domains: new Set([
875
+ ...child.domains,
876
+ ...pattern.exists.nodes.map(({ class: ref }) => ref.origin),
877
+ ]),
878
+ };
879
+ }
880
+ return combineCompiledMeasures('allOf' in pattern ? 'allOf' : 'anyOf', ('allOf' in pattern ? pattern.allOf : pattern.anyOf).map((child) => measureCompiledPattern(child, origin)));
881
+ }
882
+ function combineCompiledMeasures(kind, children) {
883
+ const depth = 1 + Math.max(0, ...children.map((child) => child.depth));
884
+ const domains = new Set(children.flatMap((child) => [...child.domains]));
885
+ if (kind === 'anyOf')
886
+ return {
887
+ depth,
888
+ edgeCounts: children.flatMap((child) => child.edgeCounts).slice(0, BRANCH_OVERFLOW),
889
+ domains,
890
+ };
891
+ let edgeCounts = [0];
892
+ for (const child of children) {
893
+ const next = [];
894
+ for (const left of edgeCounts) {
895
+ for (const right of child.edgeCounts) {
896
+ next.push(left + right);
897
+ if (next.length >= BRANCH_OVERFLOW)
898
+ break;
899
+ }
900
+ if (next.length >= BRANCH_OVERFLOW)
901
+ break;
902
+ }
903
+ edgeCounts = next;
904
+ }
905
+ return { depth, edgeCounts, domains };
906
+ }
907
+ class CompiledUnionFind {
908
+ #parents = new Map();
909
+ constructor(values) {
910
+ for (const value of values)
911
+ this.add(value);
912
+ }
913
+ add(value) {
914
+ if (!this.#parents.has(value))
915
+ this.#parents.set(value, value);
916
+ }
917
+ find(value) {
918
+ this.add(value);
919
+ const parent = this.#parents.get(value);
920
+ if (parent === value)
921
+ return value;
922
+ const root = this.find(parent);
923
+ this.#parents.set(value, root);
924
+ return root;
925
+ }
926
+ join(left, right) {
927
+ const a = this.find(left);
928
+ const b = this.find(right);
929
+ if (a !== b)
930
+ this.#parents.set(b, a);
931
+ }
932
+ }
933
+ function validateCore(candidate, context) {
934
+ for (const [entryIndex, entry] of candidate.closure.entries()) {
935
+ const nodes = new Map();
936
+ for (const [index, value] of entry.definitions.core.entries()) {
937
+ const path = `/closure/${entryIndex}/definitions/core/${index}`;
938
+ const classValue = context.classes.get(Key.of(value.class));
939
+ if (value.class.origin !== entry.origin ||
940
+ classValue?.value.kind !== 'node' ||
941
+ classValue.value.abstract)
942
+ fail(`${path}/class`, 'A Core Node requires a local concrete Node Class.');
943
+ const analysis = context.analyses.get(Key.of(value.class));
944
+ if (analysis === undefined)
945
+ fail(`${path}/class`, 'Core Node Class analysis is absent.');
946
+ validateCoreProperties(value.properties, analysis, `${path}/properties`);
947
+ nodes.set(Key.of(value.ref), {
948
+ key: Key.of(value.ref),
949
+ value,
950
+ class: classValue,
951
+ analysis,
952
+ pointer: path,
953
+ });
954
+ }
955
+ const edges = [];
956
+ for (const [index, value] of entry.facts.core.entries()) {
957
+ const path = `/closure/${entryIndex}/facts/core/${index}`;
958
+ const classValue = context.classes.get(Key.of(value.class));
959
+ if (value.class.origin !== entry.origin ||
960
+ classValue === undefined ||
961
+ !isCompiledEdge(classValue.value) ||
962
+ classValue.value.abstract)
963
+ fail(`${path}/class`, 'A Core Edge requires a local concrete Edge Class.');
964
+ const analysis = context.analyses.get(Key.of(value.class));
965
+ if (analysis === undefined)
966
+ fail(`${path}/class`, 'Core Edge Class analysis is absent.');
967
+ validateCoreProperties(value.properties, analysis, `${path}/properties`);
968
+ const source = resolveCoreEndpoint(value.source, nodes, `${path}/source`);
969
+ const target = resolveCoreEndpoint(value.target, nodes, `${path}/target`);
970
+ const declaration = classValue.value;
971
+ const satisfies = declaration.orientation === 'directed'
972
+ ? endpointSatisfies(context, source, declaration.endpoints.source.accepts) &&
973
+ endpointSatisfies(context, target, declaration.endpoints.target.accepts)
974
+ : (endpointSatisfies(context, source, declaration.endpoints[0].accepts) &&
975
+ endpointSatisfies(context, target, declaration.endpoints[1].accepts)) ||
976
+ (endpointSatisfies(context, source, declaration.endpoints[1].accepts) &&
977
+ endpointSatisfies(context, target, declaration.endpoints[0].accepts));
978
+ if (!satisfies)
979
+ fail(path, 'Core Edge endpoints do not satisfy its exact Class.');
980
+ edges.push({
981
+ source,
982
+ target,
983
+ value,
984
+ class: classValue,
985
+ pointer: path,
986
+ });
987
+ }
988
+ validateCoreEdgeSet(context, entry, entryIndex, nodes, edges);
989
+ }
990
+ }
991
+ function validateCoreProperties(values, analysis, path) {
992
+ for (const key of Object.keys(values))
993
+ if (!analysis.properties.has(key))
994
+ fail(`${path}/${escapePointer(key)}`, 'Core properties contain an unknown Property key.');
995
+ for (const property of analysis.properties.values()) {
996
+ if (!Object.hasOwn(values, property.key)) {
997
+ if (property.declaration.required && property.declaration.auto === undefined)
998
+ fail(`${path}/${escapePointer(property.key)}`, 'Core properties omit a required Property.');
999
+ continue;
1000
+ }
1001
+ if (property.declaration.auto !== undefined)
1002
+ fail(`${path}/${escapePointer(property.key)}`, 'Core properties cannot author an automatic Property.');
1003
+ if (validateValueProgram(property.entry.values[property.declaration.value], values[property.key])
1004
+ .length > 0)
1005
+ fail(`${path}/${escapePointer(property.key)}`, 'Core Property value does not satisfy its exact contract.');
1006
+ }
1007
+ }
1008
+ function resolveCoreEndpoint(ref, nodes, path) {
1009
+ if (ref.kind === 'domain')
1010
+ return { key: 'domain' };
1011
+ const node = nodes.get(Key.of(ref));
1012
+ if (node === undefined)
1013
+ fail(path, 'Core endpoint does not name a declared local Core Node.');
1014
+ return node;
1015
+ }
1016
+ function endpointSatisfies(context, endpoint, accepts) {
1017
+ return !('value' in endpoint) || classSatisfiesAny(context, endpoint.value.class, accepts);
1018
+ }
1019
+ function validateCoreEdgeSet(context, entry, entryIndex, nodes, edges) {
1020
+ const seen = new Set();
1021
+ const slices = new Map();
1022
+ for (const edge of edges) {
1023
+ const classKey = Key.of(edge.value.class);
1024
+ const [source, target] = edge.class.value.orientation === 'undirected' &&
1025
+ compareUnicode(edge.source.key, edge.target.key) > 0
1026
+ ? [edge.target.key, edge.source.key]
1027
+ : [edge.source.key, edge.target.key];
1028
+ const key = `${classKey}\u0000${source}\u0000${target}`;
1029
+ if (seen.has(key))
1030
+ fail(edge.pointer, 'Core Edge duplicates an exact normalized Edge identity.');
1031
+ seen.add(key);
1032
+ const values = slices.get(classKey) ?? [];
1033
+ values.push(edge);
1034
+ slices.set(classKey, values);
1035
+ if (edge.class.value.constraints.noSelf === true && edge.source.key === edge.target.key)
1036
+ fail(edge.pointer, 'Core Edge violates noSelf.');
1037
+ }
1038
+ for (const edgeClass of entry.definitions.classes) {
1039
+ if (!isCompiledEdge(edgeClass))
1040
+ continue;
1041
+ const classEdges = slices.get(Key.of(edgeClass.ref)) ?? [];
1042
+ if (edgeClass.constraints.acyclic === true && hasCycle(classEdges))
1043
+ fail(`/closure/${entryIndex}/facts/core`, 'Core Edge set violates exact-Class acyclicity.');
1044
+ validateCardinality(context, edgeClass, classEdges, nodes);
1045
+ }
1046
+ }
1047
+ function validateCardinality(context, declaration, edges, nodes) {
1048
+ for (const node of nodes.values()) {
1049
+ if (declaration.orientation === 'directed') {
1050
+ if (classSatisfiesAny(context, node.value.class, declaration.endpoints.source.accepts))
1051
+ checkCount(declaration.endpoints.source.outgoing, edges.filter(({ source }) => source.key === node.key).length, node.pointer);
1052
+ if (classSatisfiesAny(context, node.value.class, declaration.endpoints.target.accepts))
1053
+ checkCount(declaration.endpoints.target.incoming, edges.filter(({ target }) => target.key === node.key).length, node.pointer);
1054
+ }
1055
+ else {
1056
+ const degree = edges.filter(({ source, target }) => source.key === node.key || target.key === node.key).length;
1057
+ const [first, second] = declaration.endpoints;
1058
+ if (classSatisfiesAny(context, node.value.class, first.accepts))
1059
+ checkCount(first.incident, degree, node.pointer);
1060
+ if (!sameIncidentEndpoint(first, second) &&
1061
+ classSatisfiesAny(context, node.value.class, second.accepts))
1062
+ checkCount(second.incident, degree, node.pointer);
1063
+ }
1064
+ }
1065
+ }
1066
+ function checkCount(count, degree, path) {
1067
+ const [minimum, maximum] = countBounds(count);
1068
+ if (degree < minimum || degree > maximum)
1069
+ fail(path, `Core degree ${degree} violates Edge count ${count}.`);
1070
+ }
1071
+ function countBounds(value) {
1072
+ switch (value) {
1073
+ case '0..*':
1074
+ return [0, Number.POSITIVE_INFINITY];
1075
+ case '1..*':
1076
+ return [1, Number.POSITIVE_INFINITY];
1077
+ case '0..1':
1078
+ return [0, 1];
1079
+ case '1':
1080
+ return [1, 1];
1081
+ }
1082
+ }
1083
+ function hasCycle(edges) {
1084
+ const outgoing = new Map();
1085
+ for (const edge of edges) {
1086
+ const values = outgoing.get(edge.source.key) ?? [];
1087
+ values.push(edge.target.key);
1088
+ outgoing.set(edge.source.key, values);
1089
+ }
1090
+ const visiting = new Set();
1091
+ const visited = new Set();
1092
+ const visit = (key) => {
1093
+ if (visiting.has(key))
1094
+ return true;
1095
+ if (visited.has(key))
1096
+ return false;
1097
+ visiting.add(key);
1098
+ if ((outgoing.get(key) ?? []).some(visit))
1099
+ return true;
1100
+ visiting.delete(key);
1101
+ visited.add(key);
1102
+ return false;
1103
+ };
1104
+ return [...outgoing.keys()].some(visit);
1105
+ }
1106
+ function escapePointer(value) {
1107
+ return value.replaceAll('~', '~0').replaceAll('/', '~1');
1108
+ }
1109
+ function isCompiledEdge(value) {
1110
+ return value.kind === 'edge';
1111
+ }
1112
+ function fail(pointer, message) {
1113
+ return invalidCompiled('COMPILED_SOURCE_INVALID', message, pointer);
1114
+ }