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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. package/dist/v1/addressing/class-key.js +3 -3
  2. package/dist/v1/addressing/definition-ref.js +21 -37
  3. package/dist/v1/addressing/domain-dependency.d.ts +0 -6
  4. package/dist/v1/addressing/domain-dependency.js +1 -6
  5. package/dist/v1/addressing/key.d.ts +4 -1
  6. package/dist/v1/addressing/key.js +23 -3
  7. package/dist/v1/addressing/ordering.d.ts +2 -0
  8. package/dist/v1/addressing/ordering.js +2 -0
  9. package/dist/v1/addressing/patterns.d.ts +1 -1
  10. package/dist/v1/addressing/patterns.js +2 -6
  11. package/dist/v1/builder/callable/authoring.d.ts +11 -5
  12. package/dist/v1/builder/callable/authoring.js +2 -0
  13. package/dist/v1/builder/class/authoring.d.ts +94 -224
  14. package/dist/v1/builder/class/authoring.js +30 -35
  15. package/dist/v1/builder/class/handle.d.ts +27 -0
  16. package/dist/v1/builder/class/handle.js +1 -0
  17. package/dist/v1/builder/class/input.d.ts +159 -0
  18. package/dist/v1/builder/class/projection.d.ts +129 -0
  19. package/dist/v1/builder/class/projection.js +1 -0
  20. package/dist/v1/builder/class/property.d.ts +3 -9
  21. package/dist/v1/builder/class/property.js +1 -0
  22. package/dist/v1/builder/core/authoring.d.ts +1 -1
  23. package/dist/v1/builder/index.d.ts +10 -2
  24. package/dist/v1/builder/index.js +2 -0
  25. package/dist/v1/builder/lowering/callable.js +1 -0
  26. package/dist/v1/builder/lowering/class.d.ts +9 -1
  27. package/dist/v1/builder/lowering/class.js +62 -17
  28. package/dist/v1/builder/lowering/policy.js +6 -24
  29. package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
  30. package/dist/v1/builder/lowering/property-keys.js +108 -0
  31. package/dist/v1/builder/lowering/schema/compile.js +13 -6
  32. package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
  33. package/dist/v1/builder/lowering/schema/context.js +36 -7
  34. package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
  35. package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
  36. package/dist/v1/builder/lowering/value/compile.js +29 -22
  37. package/dist/v1/builder/lowering/value/file.d.ts +7 -0
  38. package/dist/v1/builder/lowering/value/file.js +14 -0
  39. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  40. package/dist/v1/builder/lowering/value/path.js +2 -4
  41. package/dist/v1/builder/lowering/value/zod.js +41 -7
  42. package/dist/v1/builder/policy/authoring.d.ts +80 -9
  43. package/dist/v1/builder/policy/authoring.js +99 -68
  44. package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
  45. package/dist/v1/builder/policy/legacy/edge.js +16 -0
  46. package/dist/v1/builder/schema/define.d.ts +0 -1
  47. package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
  48. package/dist/v1/builder/schema/diagnostic.js +5 -10
  49. package/dist/v1/builder/schema/input.d.ts +4 -1
  50. package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
  51. package/dist/v1/builder/schema/projection/class.d.ts +78 -16
  52. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  53. package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
  54. package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
  55. package/dist/v1/builder/schema/projection/model.d.ts +4 -2
  56. package/dist/v1/builder/schema/projection/property.d.ts +38 -4
  57. package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
  58. package/dist/v1/builder/schema/projection.d.ts +1 -1
  59. package/dist/v1/builder/schema/rule.d.ts +316 -0
  60. package/dist/v1/builder/schema/rule.js +192 -0
  61. package/dist/v1/builder/value/file.d.ts +34 -0
  62. package/dist/v1/builder/value/file.js +77 -0
  63. package/dist/v1/builder/value/full-match.d.ts +0 -1
  64. package/dist/v1/builder/value/full-match.js +0 -1
  65. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  66. package/dist/v1/builder/value/path.d.ts +1 -1
  67. package/dist/v1/bundle/codec.js +55 -74
  68. package/dist/v1/bundle/diagnostic.d.ts +3 -1
  69. package/dist/v1/bundle/diagnostic.js +9 -7
  70. package/dist/v1/bundle/index.d.ts +2 -0
  71. package/dist/v1/bundle/index.js +1 -0
  72. package/dist/v1/bundle/model.js +1 -1
  73. package/dist/v1/bundle/rule.d.ts +14 -0
  74. package/dist/v1/bundle/rule.js +41 -0
  75. package/dist/v1/bundle/structure.js +6 -8
  76. package/dist/v1/compiled/admission/accept.js +9 -15
  77. package/dist/v1/compiled/admission/closure.js +17 -34
  78. package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
  79. package/dist/v1/compiled/admission/diagnostic.js +40 -3
  80. package/dist/v1/compiled/admission/revision.d.ts +9 -1
  81. package/dist/v1/compiled/admission/revision.js +7 -3
  82. package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
  83. package/dist/v1/compiled/admission/semantics/class.js +48 -19
  84. package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
  85. package/dist/v1/compiled/admission/semantics/core.js +56 -24
  86. package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
  87. package/dist/v1/compiled/admission/semantics/edge.js +6 -65
  88. package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
  89. package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
  90. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
  91. package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
  92. package/dist/v1/compiled/admission/semantics/policy/parity.js +44 -53
  93. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
  94. package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
  95. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
  96. package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
  97. package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
  98. package/dist/v1/compiled/admission/wire/callable.js +24 -20
  99. package/dist/v1/compiled/admission/wire/class.js +79 -30
  100. package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
  101. package/dist/v1/compiled/admission/wire/entry.js +36 -13
  102. package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
  103. package/dist/v1/compiled/admission/wire/policy.js +27 -20
  104. package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
  105. package/dist/v1/compiled/admission/wire/program.js +39 -44
  106. package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
  107. package/dist/v1/compiled/admission/wire/property.js +8 -5
  108. package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
  109. package/dist/v1/compiled/admission/wire/value.js +0 -7
  110. package/dist/v1/compiled/codec/json.js +4 -3
  111. package/dist/v1/compiled/compiler/compile.js +15 -33
  112. package/dist/v1/compiled/diagnostic.d.ts +1 -1
  113. package/dist/v1/compiled/diagnostic.js +2 -3
  114. package/dist/v1/compiled/index.d.ts +2 -0
  115. package/dist/v1/compiled/index.js +1 -0
  116. package/dist/v1/compiled/loader/load.d.ts +3 -2
  117. package/dist/v1/compiled/loader/load.js +13 -52
  118. package/dist/v1/compiled/model/schema.d.ts +3 -0
  119. package/dist/v1/compiled/rule.d.ts +49 -0
  120. package/dist/v1/compiled/rule.js +169 -0
  121. package/dist/v1/domain/create.js +9 -10
  122. package/dist/v1/domain/model/domain.d.ts +2 -7
  123. package/dist/v1/domain/model/input.d.ts +19 -10
  124. package/dist/v1/domain/namespace/member-collection.js +8 -7
  125. package/dist/v1/domain/projection/classes.js +11 -8
  126. package/dist/v1/domain/validation/create.d.ts +7 -16
  127. package/dist/v1/domain/validation/create.js +35 -81
  128. package/dist/v1/index.d.ts +5 -3
  129. package/dist/v1/index.js +1 -1
  130. package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
  131. package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
  132. package/dist/v1/language/callable/admission.d.ts +15 -0
  133. package/dist/v1/language/callable/admission.js +44 -0
  134. package/dist/v1/language/callable/model/callable.d.ts +10 -0
  135. package/dist/v1/language/callable/resolved.d.ts +26 -5
  136. package/dist/v1/language/chain.d.ts +7 -0
  137. package/dist/v1/language/chain.js +24 -0
  138. package/dist/v1/language/class/inheritance.d.ts +36 -5
  139. package/dist/v1/language/class/inheritance.js +85 -1
  140. package/dist/v1/language/class/lifetime.d.ts +50 -11
  141. package/dist/v1/language/class/lifetime.js +89 -20
  142. package/dist/v1/language/class/model/class.d.ts +45 -9
  143. package/dist/v1/language/class/model/edge.d.ts +31 -2
  144. package/dist/v1/language/class/model/property.d.ts +16 -7
  145. package/dist/v1/language/class/property-values.js +2 -4
  146. package/dist/v1/language/class/resolved.d.ts +9 -4
  147. package/dist/v1/language/class/unique.d.ts +143 -0
  148. package/dist/v1/language/class/unique.js +264 -0
  149. package/dist/v1/language/core/facts.d.ts +85 -0
  150. package/dist/v1/language/core/facts.js +116 -0
  151. package/dist/v1/language/cycle.d.ts +10 -0
  152. package/dist/v1/language/cycle.js +30 -0
  153. package/dist/v1/language/definition/metadata.d.ts +38 -0
  154. package/dist/v1/language/definition/metadata.js +51 -0
  155. package/dist/v1/language/freeze.d.ts +5 -0
  156. package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
  157. package/dist/v1/language/index.d.ts +7 -2
  158. package/dist/v1/language/index.js +5 -1
  159. package/dist/v1/language/limits.d.ts +83 -0
  160. package/dist/v1/language/limits.js +77 -0
  161. package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
  162. package/dist/v1/language/policy/analysis/branches.js +8 -8
  163. package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
  164. package/dist/v1/language/policy/analysis/budgets.js +140 -20
  165. package/dist/v1/language/policy/analysis/checks.js +8 -6
  166. package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
  167. package/dist/v1/language/policy/analysis/composition.js +11 -0
  168. package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
  169. package/dist/v1/language/policy/analysis/typing.js +456 -0
  170. package/dist/v1/language/policy/model/policy.d.ts +71 -9
  171. package/dist/v1/language/policy/model/policy.js +42 -4
  172. package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
  173. package/dist/v1/language/policy/normalization/normalize.js +46 -68
  174. package/dist/v1/language/suspended.d.ts +7 -0
  175. package/dist/v1/language/suspended.js +23 -0
  176. package/dist/v1/language/validation/diagnostic.d.ts +15 -1
  177. package/dist/v1/language/validation/diagnostic.js +21 -0
  178. package/dist/v1/language/validation/rule.d.ts +45 -0
  179. package/dist/v1/language/validation/rule.js +109 -0
  180. package/dist/v1/language/value/compile/fields.js +16 -16
  181. package/dist/v1/language/value/compile/load.d.ts +5 -0
  182. package/dist/v1/language/value/compile/load.js +13 -0
  183. package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
  184. package/dist/v1/language/value/evaluate/assertions.js +19 -8
  185. package/dist/v1/language/value/evaluate/evaluator.js +117 -120
  186. package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
  187. package/dist/v1/language/value/evaluate/preparation.js +100 -47
  188. package/dist/v1/language/value/evaluate/program.d.ts +2 -1
  189. package/dist/v1/language/value/evaluate/program.js +6 -6
  190. package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
  191. package/dist/v1/language/value/evaluate/validate.js +15 -11
  192. package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
  193. package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
  194. package/dist/v1/language/value/files.d.ts +44 -0
  195. package/dist/v1/language/value/files.js +151 -0
  196. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  197. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  198. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  199. package/dist/v1/language/value/inclusion/assertions.js +28 -0
  200. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  201. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  202. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  203. package/dist/v1/language/value/inclusion/equivalence.js +76 -0
  204. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  205. package/dist/v1/language/value/inclusion/evidence.js +140 -0
  206. package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
  207. package/dist/v1/language/value/inclusion/includes.js +58 -723
  208. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  209. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  210. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  211. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  212. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  213. package/dist/v1/language/value/inclusion/location.js +66 -0
  214. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  215. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  216. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  217. package/dist/v1/language/value/inclusion/objects.js +190 -0
  218. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  219. package/dist/v1/language/value/inclusion/strings.js +29 -0
  220. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  221. package/dist/v1/language/value/inclusion/types.js +34 -0
  222. package/dist/v1/language/value/model/blob.d.ts +6 -0
  223. package/dist/v1/language/value/model/blob.js +8 -0
  224. package/dist/v1/language/value/model/file.d.ts +41 -0
  225. package/dist/v1/language/value/model/file.js +122 -0
  226. package/dist/v1/language/value/ordering.d.ts +14 -0
  227. package/dist/v1/language/value/ordering.js +144 -77
  228. package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
  229. package/dist/v1/language/value/profile/canonicalize.js +67 -87
  230. package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
  231. package/dist/v1/language/value/profile/json.validate.js +18 -5
  232. package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
  233. package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
  234. package/dist/v1/language/value/profile/rules.js +27 -44
  235. package/dist/v1/language/value/profile/validate.js +1 -10
  236. package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
  237. package/dist/v1/language/value/profile/vocabulary.js +58 -5
  238. package/dist/v1/language/value/reference/closure.js +6 -6
  239. package/dist/v1/language/value/reference/recursion.js +9 -48
  240. package/dist/v1/language/value/reference/references.d.ts +3 -1
  241. package/dist/v1/language/value/reference/references.js +7 -7
  242. package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
  243. package/dist/v1/language/value/reference/registry.index.js +33 -16
  244. package/dist/v1/language/value/regexp/ast.js +6 -7
  245. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  246. package/dist/v1/language/value/regexp/compile.js +14 -12
  247. package/dist/v1/language/value/regexp/syntax.js +3 -2
  248. package/dist/v1/language/value/regexp/unicode.d.ts +1 -1
  249. package/dist/v1/language/value/regexp/unicode.js +1 -1
  250. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  251. package/dist/v1/language/value/syntax/keywords.js +4 -20
  252. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  253. package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
  254. package/dist/v1/language/value/syntax/pointer.js +5 -2
  255. package/dist/v1/language/value/syntax/walk.d.ts +9 -0
  256. package/dist/v1/language/value/syntax/walk.js +37 -20
  257. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
  258. package/dist/v1/schema/admission/accept.d.ts +3 -1
  259. package/dist/v1/schema/admission/accept.js +6 -14
  260. package/dist/v1/schema/admission/callable.d.ts +21 -0
  261. package/dist/v1/schema/admission/callable.js +96 -0
  262. package/dist/v1/schema/analysis/class.d.ts +4 -0
  263. package/dist/v1/schema/analysis/class.js +57 -17
  264. package/dist/v1/schema/canonical/revision.d.ts +4 -1
  265. package/dist/v1/schema/canonical/revision.js +8 -5
  266. package/dist/v1/schema/compatibility/api.d.ts +4 -1
  267. package/dist/v1/schema/compatibility/api.js +2 -0
  268. package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
  269. package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
  270. package/dist/v1/schema/compatibility/comparators/classes.js +50 -29
  271. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  272. package/dist/v1/schema/compatibility/comparators/members.js +1 -1
  273. package/dist/v1/schema/compatibility/comparators/values.js +2 -2
  274. package/dist/v1/schema/compatibility/context.d.ts +5 -2
  275. package/dist/v1/schema/compatibility/context.js +8 -6
  276. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  277. package/dist/v1/schema/compatibility/diff.js +2 -4
  278. package/dist/v1/schema/compatibility/extension.d.ts +11 -0
  279. package/dist/v1/schema/compatibility/extension.js +22 -0
  280. package/dist/v1/schema/compatibility/fields.d.ts +20 -4
  281. package/dist/v1/schema/compatibility/fields.js +13 -3
  282. package/dist/v1/schema/compatibility/meaning/footprint.js +16 -51
  283. package/dist/v1/schema/compatibility/model.d.ts +17 -5
  284. package/dist/v1/schema/compatibility/references.d.ts +0 -3
  285. package/dist/v1/schema/compatibility/references.js +1 -9
  286. package/dist/v1/schema/compatibility/report.js +1 -1
  287. package/dist/v1/schema/compatibility/rule.d.ts +13 -0
  288. package/dist/v1/schema/compatibility/rule.js +23 -0
  289. package/dist/v1/schema/compatibility/scope.d.ts +2 -0
  290. package/dist/v1/schema/compatibility/scope.js +4 -1
  291. package/dist/v1/schema/compatibility/structure/index.js +6 -4
  292. package/dist/v1/schema/compatibility/structure/requirements.js +58 -61
  293. package/dist/v1/schema/compatibility/versioning/index.js +1 -1
  294. package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
  295. package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
  296. package/dist/v1/schema/compatibility/walk.d.ts +17 -0
  297. package/dist/v1/schema/compatibility/walk.js +41 -0
  298. package/dist/v1/schema/diagnostic.d.ts +17 -3
  299. package/dist/v1/schema/diagnostic.js +14 -11
  300. package/dist/v1/schema/enforcement/changes.d.ts +590 -0
  301. package/dist/v1/schema/enforcement/changes.js +566 -0
  302. package/dist/v1/schema/enforcement/derived.d.ts +236 -0
  303. package/dist/v1/schema/enforcement/derived.js +243 -0
  304. package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
  305. package/dist/v1/schema/enforcement/dispose.js +275 -0
  306. package/dist/v1/schema/enforcement/facts.d.ts +89 -0
  307. package/dist/v1/schema/enforcement/facts.js +70 -0
  308. package/dist/v1/schema/enforcement/fields.d.ts +65 -0
  309. package/dist/v1/schema/enforcement/fields.js +36 -0
  310. package/dist/v1/schema/enforcement/index.d.ts +39 -0
  311. package/dist/v1/schema/enforcement/index.js +10 -0
  312. package/dist/v1/schema/enforcement/install.d.ts +1634 -0
  313. package/dist/v1/schema/enforcement/install.js +1223 -0
  314. package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
  315. package/dist/v1/schema/enforcement/lifecycle.js +91 -0
  316. package/dist/v1/schema/enforcement/model.d.ts +253 -0
  317. package/dist/v1/schema/enforcement/model.js +1 -0
  318. package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
  319. package/dist/v1/schema/enforcement/obligations.js +240 -0
  320. package/dist/v1/schema/enforcement/write.d.ts +1314 -0
  321. package/dist/v1/schema/enforcement/write.js +1017 -0
  322. package/dist/v1/schema/index.d.ts +11 -1
  323. package/dist/v1/schema/index.js +5 -0
  324. package/dist/v1/schema/model/schema.d.ts +23 -1
  325. package/dist/v1/schema/model/schema.js +1 -1
  326. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  327. package/dist/v1/schema/normalization/domain.js +50 -13
  328. package/dist/v1/schema/resolution/closure.js +2 -1
  329. package/dist/v1/schema/resolution/context.js +17 -18
  330. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  331. package/dist/v1/schema/resolution/domain.js +6 -12
  332. package/dist/v1/schema/resolution/origins.js +6 -8
  333. package/dist/v1/schema/rule.d.ts +25 -0
  334. package/dist/v1/schema/rule.js +459 -0
  335. package/dist/v1/schema/validation/callable.d.ts +35 -2
  336. package/dist/v1/schema/validation/callable.js +65 -9
  337. package/dist/v1/schema/validation/class.d.ts +6 -2
  338. package/dist/v1/schema/validation/class.js +128 -105
  339. package/dist/v1/schema/validation/core.js +103 -173
  340. package/dist/v1/schema/validation/domain.js +25 -15
  341. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  342. package/dist/v1/schema/validation/domain.json-schema.js +222 -0
  343. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  344. package/dist/v1/schema/validation/domain.route.js +18 -0
  345. package/dist/v1/schema/validation/domain.structure.d.ts +7797 -0
  346. package/dist/v1/schema/validation/domain.structure.js +516 -160
  347. package/dist/v1/schema/validation/icon.d.ts +4 -0
  348. package/dist/v1/schema/validation/icon.js +29 -0
  349. package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
  350. package/dist/v1/schema/validation/json.json-schema.js +46 -0
  351. package/dist/v1/schema/validation/policy/budgets.d.ts +37 -2
  352. package/dist/v1/schema/validation/policy/budgets.js +94 -121
  353. package/dist/v1/schema/validation/policy/context.d.ts +6 -5
  354. package/dist/v1/schema/validation/policy/context.js +7 -10
  355. package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
  356. package/dist/v1/schema/validation/policy/objects.js +6 -14
  357. package/dist/v1/schema/validation/policy/references.js +20 -62
  358. package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
  359. package/dist/v1/schema/validation/policy/typing.js +22 -356
  360. package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
  361. package/dist/v1/schema/validation/policy/uses.js +63 -91
  362. package/dist/v1/schema/validation/policy/validate.js +5 -5
  363. package/dist/v1/schema/validation/value-api.d.ts +27 -1
  364. package/dist/v1/schema/validation/value-api.js +37 -2
  365. package/dist/v1/schema/validation/value.d.ts +3 -0
  366. package/dist/v1/schema/validation/value.js +9 -17
  367. package/dist/v1/schema/validation/value.json-schema.d.ts +54 -0
  368. package/dist/v1/schema/validation/value.json-schema.js +163 -0
  369. package/dist/v1/schema/validation/view.js +4 -8
  370. package/dist/value/accept.d.ts +9 -3
  371. package/dist/value/accept.js +25 -1
  372. package/dist/value/canonical.d.ts +22 -1
  373. package/dist/value/canonical.js +114 -21
  374. package/dist/value/decode.d.ts +7 -0
  375. package/dist/value/decode.js +159 -9
  376. package/dist/value/equal.d.ts +9 -1
  377. package/dist/value/equal.js +37 -3
  378. package/dist/value/immutable.optimization.d.ts +2 -0
  379. package/dist/value/immutable.optimization.js +4 -0
  380. package/dist/value/index.d.ts +5 -3
  381. package/dist/value/index.js +2 -1
  382. package/dist/value/json.d.ts +2 -2
  383. package/dist/value/json.js +2 -2
  384. package/dist/value/limits.d.ts +11 -0
  385. package/dist/value/rule.d.ts +12 -0
  386. package/dist/value/rule.js +50 -0
  387. package/dist/value/types.d.ts +6 -0
  388. package/dist/value/unicode.d.ts +2 -1
  389. package/dist/value/unicode.js +2 -0
  390. package/package.json +15 -4
  391. package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
  392. package/dist/v1/builder/lowering/core-properties.js +0 -76
  393. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
  394. package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
  395. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
  396. package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
  397. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
  398. package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
  399. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
  400. package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
  401. package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
  402. package/dist/v1/compiled/admission/wire/pattern.js +0 -111
  403. package/dist/v1/language/class/index.d.ts +0 -8
  404. package/dist/v1/language/class/index.js +0 -1
  405. package/dist/v1/language/core/index.d.ts +0 -2
  406. package/dist/v1/language/value/index.d.ts +0 -11
  407. package/dist/v1/language/value/index.js +0 -8
  408. package/dist/v1/schema/canonical/domain.d.ts +0 -3
  409. package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
  410. package/dist/v1/schema/canonical/domain.digest.js +0 -5
  411. package/dist/v1/schema/canonical/domain.js +0 -5
  412. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  413. /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
@@ -18,3 +18,41 @@ export declare const name: Readonly<{
18
18
  }>;
19
19
  /** The common source and compiled grammar for a name displayed exactly as authored. */
20
20
  export declare function isDomainNameText(value: string): boolean;
21
+ /**
22
+ * The same grammar as a portable pattern: no control character, and neither first nor last a
23
+ * character `trim` removes, spelled out since `\s` differs between regular expression engines.
24
+ */
25
+ export declare const DOMAIN_NAME_TEXT_PATTERN: RegExp;
26
+ /** One drawing of a Domain icon size: inline SVG text, with an optional dark-theme variant. */
27
+ export interface DomainIconArt {
28
+ /** The light-theme drawing, always present. */
29
+ readonly svg: string;
30
+ /** The dark-theme drawing, when the Domain draws one. */
31
+ readonly dark?: string;
32
+ }
33
+ /** A Domain presentation icon: up to three hand-drawn sizes, at least one present. */
34
+ export interface DomainIcon {
35
+ /** Drawn for 16 to 24 px, on a 24 x 24 artboard. */
36
+ readonly small?: DomainIconArt;
37
+ /** Drawn for 28 to 96 px, on a 64 x 64 artboard. */
38
+ readonly medium?: DomainIconArt;
39
+ /** Drawn for 128 px and more, on a 512 x 512 artboard. */
40
+ readonly large?: DomainIconArt;
41
+ }
42
+ /** The sizes of a Domain icon, smallest first: the canonical order of its members. */
43
+ export declare const DOMAIN_ICON_SIZES: readonly ["small", "medium", "large"];
44
+ /** A Domain icon size. */
45
+ export type DomainIconSize = (typeof DOMAIN_ICON_SIZES)[number];
46
+ /** Exact V1 bound, in bytes of UTF-8, of each SVG text of one Domain icon size. */
47
+ export declare const domainIcon: Readonly<{
48
+ readonly small: 8192;
49
+ readonly medium: 32768;
50
+ readonly large: 262144;
51
+ }>;
52
+ /**
53
+ * Why one SVG text is no admissible Domain icon drawing of `size`, or undefined when it is one:
54
+ * within the size's UTF-8 bound, one complete `<svg>` root with a visible vector element, no
55
+ * executable, external or styling content, and no `url(` but a local `url(#id)`. A lexical check,
56
+ * not a parser: a Shell renders the drawing only as an image, never inline.
57
+ */
58
+ export declare function domainIconSvgIssue(svg: string, size: DomainIconSize): string | undefined;
@@ -22,3 +22,54 @@ const DOMAIN_NAME_CONTROL = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/u;
22
22
  export function isDomainNameText(value) {
23
23
  return value.trim() === value && !DOMAIN_NAME_CONTROL.test(value);
24
24
  }
25
+ /**
26
+ * The same grammar as a portable pattern: no control character, and neither first nor last a
27
+ * character `trim` removes, spelled out since `\s` differs between regular expression engines.
28
+ */
29
+ export const DOMAIN_NAME_TEXT_PATTERN =
30
+ // oxlint-disable-next-line no-control-regex
31
+ /^(?:[^\u0000-\u001f\u007f-\u009f\u0020\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff](?:[^\u0000-\u001f\u007f-\u009f\u2028\u2029]*[^\u0000-\u001f\u007f-\u009f\u0020\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])?)?$/u;
32
+ /** The sizes of a Domain icon, smallest first: the canonical order of its members. */
33
+ export const DOMAIN_ICON_SIZES = Object.freeze(['small', 'medium', 'large']);
34
+ /** Exact V1 bound, in bytes of UTF-8, of each SVG text of one Domain icon size. */
35
+ export const domainIcon = Object.freeze({ small: 8192, medium: 32768, large: 262144 });
36
+ const SVG_ROOT = /^<svg(?:\s[^>]*)?>[\s\S]*<\/svg>$/u;
37
+ const SVG_ROOT_OPEN = /<svg(?:\s|>)/gu;
38
+ const SVG_ROOT_CLOSE = /<\/svg\s*>/gu;
39
+ const SVG_GRAPHIC = /<(?:circle|ellipse|line|path|polygon|polyline|rect)\b/iu;
40
+ const SVG_UNSAFE = /<\s*(?:animate|discard|embed|foreignObject|iframe|image|object|script|set|style|use)\b|<!DOCTYPE\b|<!ENTITY\b|\son[a-z][\w:.-]*\s*=|\sstyle\s*=|(?:href|xlink:href)\s*=|javascript\s*:/iu;
41
+ // The one admitted `url(`: a reference to an element of the same drawing, by its id.
42
+ const SVG_LOCAL_URL = /url\(#[A-Za-z][A-Za-z0-9_-]*\)/gu;
43
+ const SVG_URL = /url\s*\(/iu;
44
+ /**
45
+ * Why one SVG text is no admissible Domain icon drawing of `size`, or undefined when it is one:
46
+ * within the size's UTF-8 bound, one complete `<svg>` root with a visible vector element, no
47
+ * executable, external or styling content, and no `url(` but a local `url(#id)`. A lexical check,
48
+ * not a parser: a Shell renders the drawing only as an image, never inline.
49
+ */
50
+ export function domainIconSvgIssue(svg, size) {
51
+ const bytes = utf8Length(svg);
52
+ if (bytes === 0)
53
+ return 'is empty';
54
+ if (bytes > domainIcon[size])
55
+ return `exceeds ${domainIcon[size]} bytes of UTF-8`;
56
+ if (!SVG_ROOT.test(svg) ||
57
+ (svg.match(SVG_ROOT_OPEN)?.length ?? 0) !== 1 ||
58
+ (svg.match(SVG_ROOT_CLOSE)?.length ?? 0) !== 1) {
59
+ return 'is not one complete <svg> element';
60
+ }
61
+ if (SVG_UNSAFE.test(svg) || SVG_URL.test(svg.replace(SVG_LOCAL_URL, ''))) {
62
+ return 'holds executable, external or styling content';
63
+ }
64
+ if (!SVG_GRAPHIC.test(svg))
65
+ return 'has no visible vector element';
66
+ return undefined;
67
+ }
68
+ function utf8Length(text) {
69
+ let bytes = 0;
70
+ for (const character of text) {
71
+ const point = character.codePointAt(0);
72
+ bytes += point < 0x80 ? 1 : point < 0x800 ? 2 : point < 0x10000 ? 3 : 4;
73
+ }
74
+ return bytes;
75
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Freeze `value` and every object it reaches, in place. An object already frozen is taken as frozen
3
+ * through, so a value built from frozen parts is frozen without walking them again.
4
+ */
5
+ export declare function deepFreeze<T>(value: T): Readonly<T>;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Freeze `value` and every object it reaches, in place. An object already frozen is taken as frozen
3
+ * through, so a value built from frozen parts is frozen without walking them again.
4
+ */
1
5
  export function deepFreeze(value) {
2
6
  if (value === null || typeof value !== 'object' || Object.isFrozen(value)) {
3
7
  return value;
@@ -1,3 +1,4 @@
1
+ export { admissionInputFields, isAdmissionMaxAge, MAXIMUM_ADMISSION_AGE_SECONDS, } from './callable/admission.js';
1
2
  export { isMethodExecutable } from './callable/executable.js';
2
3
  export { isBinaryInput } from './callable/model/callable.js';
3
4
  export type { ClassRef, CoreRef, DefinitionBase, DefinitionKey, DefinitionRef, FunctionRef, MethodKey, PolicyRef, PropertyKey, ViewRef, } from '../addressing/index.js';
@@ -6,6 +7,7 @@ export type { JsonSchema as ValueSchema, JsonSchemaObject as ValueSchemaObject,
6
7
  export type { OrderingKind } from './value/ordering.js';
7
8
  export type { ValueProgram } from './value/compile/model.js';
8
9
  export { valueProgramIncludes } from './value/inclusion/includes.js';
10
+ export { isInstantValue } from './value/model/instant.js';
9
11
  export { stateMachine } from './state/index.js';
10
12
  export type { EventOf, StateMachine, StateOf, StateTopology } from './state/index.js';
11
13
  export type * from './callable/model/callable.js';
@@ -13,8 +15,11 @@ export type * from './callable/resolved.js';
13
15
  export type * from './class/model/class.js';
14
16
  export type { DataDefinition, DataFacet, MediaType } from './class/model/data.js';
15
17
  export type * from './class/model/edge.js';
16
- export { edgeLifetimes } from './class/lifetime.js';
17
- export type { EdgeLifetime } from './class/lifetime.js';
18
+ export { admitsForeignSubclass, inheritanceOf } from './class/inheritance.js';
19
+ export { edgeLifetimes, lifetimeScope } from './class/lifetime.js';
20
+ export type { LifetimeScope } from './class/lifetime.js';
21
+ export { EDGE_UNIQUE_FORMS, NODE_UNIQUE_FORMS, NO_UNIQUE_FORMS, UNIQUE_FORMS, compareEdgeUniqueFields, compareEdgeUniqueTuples, compareNodeUniqueTuples, coveringEdgeUniqueTuples, coveringNodeUniqueTuples, edgeUniqueForm, edgeUniqueFormOf, edgeUniqueKeys, edgeUniqueTuple, edgeUniqueValue, edgeUniqueValues, enforcesEdgeUniqueTuple, enforcesNodeUniqueTuple, keyableProperty, namedEdgeUniqueTuple, nodeUniqueForm, nodeUniqueKeys, nodeUniqueTuple, nodeUniqueValue, nodeUniqueValues, } from './class/unique.js';
22
+ export type { DeclaredEdgeUniqueTuple, DeclaredNodeUniqueTuple, EdgeUniqueFacts, NodeUniqueFacts, UniqueForms, } from './class/unique.js';
18
23
  export type * from './class/model/property.js';
19
24
  export type * from './class/resolved.js';
20
25
  export type * from './class/facets.js';
@@ -1,7 +1,11 @@
1
+ export { admissionInputFields, isAdmissionMaxAge, MAXIMUM_ADMISSION_AGE_SECONDS, } from './callable/admission.js';
1
2
  export { isMethodExecutable } from './callable/executable.js';
2
3
  export { isBinaryInput } from './callable/model/callable.js';
3
4
  export { valueProgramIncludes } from './value/inclusion/includes.js';
5
+ export { isInstantValue } from './value/model/instant.js';
4
6
  export { stateMachine } from './state/index.js';
5
- export { edgeLifetimes } from './class/lifetime.js';
7
+ export { admitsForeignSubclass, inheritanceOf } from './class/inheritance.js';
8
+ export { edgeLifetimes, lifetimeScope } from './class/lifetime.js';
9
+ export { EDGE_UNIQUE_FORMS, NODE_UNIQUE_FORMS, NO_UNIQUE_FORMS, UNIQUE_FORMS, compareEdgeUniqueFields, compareEdgeUniqueTuples, compareNodeUniqueTuples, coveringEdgeUniqueTuples, coveringNodeUniqueTuples, edgeUniqueForm, edgeUniqueFormOf, edgeUniqueKeys, edgeUniqueTuple, edgeUniqueValue, edgeUniqueValues, enforcesEdgeUniqueTuple, enforcesNodeUniqueTuple, keyableProperty, namedEdgeUniqueTuple, nodeUniqueForm, nodeUniqueKeys, nodeUniqueTuple, nodeUniqueValue, nodeUniqueValues, } from './class/unique.js';
6
10
  export { PropertyValues } from './class/property-values.js';
7
11
  export { isClassRuleChecks, policyVariableClass, policyVariableSelector, policyObjectKey, policyObjectOrigin, projectedMemberClass, } from './policy/model/policy.js';
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The limits of the V1 language, each defined once: every check of a source Schema, a Bundle or a
3
+ * compiled closure reads its bound here. Every limit is inclusive: a count equal to it is
4
+ * accepted, one more is refused. `schema.limits` publishes this object, and each rule of
5
+ * `schema.RULES` and `schema.values.RULES` that enforces some of them names them in `limits`.
6
+ */
7
+ export declare const limits: Readonly<{
8
+ /** Bounds of the dependency graph of one Domain (`DV_DEPENDENCY_LIMITS`). */
9
+ dependency: Readonly<{
10
+ /** Direct dependencies one Domain declares. */
11
+ direct: 32;
12
+ /** Domains of a dependency closure, the Domain itself included. */
13
+ closure: 256;
14
+ /** Dependencies on the longest chain from a Domain: a direct dependency is at depth 1. */
15
+ depth: 32;
16
+ }>;
17
+ /** Bounds of one document holding a dependency closure whole: a Bundle or a compiled Schema. */
18
+ closure: Readonly<{
19
+ /** Members and items of the whole document, over every Domain it holds. */
20
+ members: 1000000;
21
+ }>;
22
+ /** Bounds of Class inheritance (`DV_INHERITANCE_LIMITS`). */
23
+ inheritance: Readonly<{
24
+ /** Parents on the longest chain from a Class, of any Domain: a direct parent is at depth 1. */
25
+ depth: 64;
26
+ }>;
27
+ /** Bounds of one I-Regexp in a value schema (`VS_REGEX_PORTABLE`), as RFC 9485 §8 allows. */
28
+ regexp: Readonly<{
29
+ /** Code points of one source. */
30
+ maxCodePoints: 4096;
31
+ /** Groups nested in one another in one source. */
32
+ maxNesting: 32;
33
+ /** The greatest bound of a counted repetition `{n}` or `{n,m}`. */
34
+ maxRepeat: 1000;
35
+ /** States of one compiled machine; the counted-run form never expands and is not bounded. */
36
+ maxStates: 10000;
37
+ }>;
38
+ /**
39
+ * Bounds of the Policy language. A named Policy is measured once normalized and once each
40
+ * composition is expanded into the Policies it names; a check tree, the checks of a callable or
41
+ * of a Node Class rule, once normalized (`PL_BUDGET`). The structure bounds the others
42
+ * (`STRUCTURE_MAXIMUM`).
43
+ */
44
+ policy: Readonly<{
45
+ /**
46
+ * Levels of a Policy pattern: an Edge or sameNode is one, and each allOf, anyOf, exists and
47
+ * composition adds one.
48
+ */
49
+ patternDepth: 4;
50
+ /**
51
+ * Branches of a Policy's normal form: an anyOf adds those of its operands, an allOf multiplies
52
+ * them.
53
+ */
54
+ normalizedBranches: 8;
55
+ /** Nodes one exists declares. */
56
+ variablesPerExists: 4;
57
+ /** Graph predicates, Edges and sameNode equalities, of one normalized branch. */
58
+ edgePredicates: 6;
59
+ /** The greatest bound of a repeated Edge. */
60
+ repetition: 3;
61
+ /** Domains a Policy names: its own, and the origin of every Class and object it references. */
62
+ referencedDomains: 4;
63
+ /** Levels of a check tree: a check or sameNode is one, and each allOf and anyOf adds one. */
64
+ checkDepth: 4;
65
+ /** Branches of a check tree: an anyOf adds those of its operands, an allOf multiplies them. */
66
+ checkBranches: 8;
67
+ /** Checks and sameNode equalities of a check tree. */
68
+ checkLeaves: 8;
69
+ }>;
70
+ }>;
71
+ /**
72
+ * What the portable value boundary allows a document holding a closure whole. It may hold more than
73
+ * any one Domain does, and each route it crosses reads this, so what one accepts another can read.
74
+ */
75
+ export declare const closureDocument: Readonly<{
76
+ limits: Readonly<{
77
+ maxMembers: 1000000;
78
+ }>;
79
+ }>;
80
+ /** A limit by its key in `limits`, `<group>.<name>`: `policy.patternDepth`. */
81
+ export type LimitKey = {
82
+ readonly [Group in keyof typeof limits & string]: `${Group}.${keyof (typeof limits)[Group] & string}`;
83
+ }[keyof typeof limits & string];
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The limits of the V1 language, each defined once: every check of a source Schema, a Bundle or a
3
+ * compiled closure reads its bound here. Every limit is inclusive: a count equal to it is
4
+ * accepted, one more is refused. `schema.limits` publishes this object, and each rule of
5
+ * `schema.RULES` and `schema.values.RULES` that enforces some of them names them in `limits`.
6
+ */
7
+ export const limits = Object.freeze({
8
+ /** Bounds of the dependency graph of one Domain (`DV_DEPENDENCY_LIMITS`). */
9
+ dependency: Object.freeze({
10
+ /** Direct dependencies one Domain declares. */
11
+ direct: 32,
12
+ /** Domains of a dependency closure, the Domain itself included. */
13
+ closure: 256,
14
+ /** Dependencies on the longest chain from a Domain: a direct dependency is at depth 1. */
15
+ depth: 32,
16
+ }),
17
+ /** Bounds of one document holding a dependency closure whole: a Bundle or a compiled Schema. */
18
+ closure: Object.freeze({
19
+ /** Members and items of the whole document, over every Domain it holds. */
20
+ members: 1_000_000,
21
+ }),
22
+ /** Bounds of Class inheritance (`DV_INHERITANCE_LIMITS`). */
23
+ inheritance: Object.freeze({
24
+ /** Parents on the longest chain from a Class, of any Domain: a direct parent is at depth 1. */
25
+ depth: 64,
26
+ }),
27
+ /** Bounds of one I-Regexp in a value schema (`VS_REGEX_PORTABLE`), as RFC 9485 §8 allows. */
28
+ regexp: Object.freeze({
29
+ /** Code points of one source. */
30
+ maxCodePoints: 4096,
31
+ /** Groups nested in one another in one source. */
32
+ maxNesting: 32,
33
+ /** The greatest bound of a counted repetition `{n}` or `{n,m}`. */
34
+ maxRepeat: 1000,
35
+ /** States of one compiled machine; the counted-run form never expands and is not bounded. */
36
+ maxStates: 10_000,
37
+ }),
38
+ /**
39
+ * Bounds of the Policy language. A named Policy is measured once normalized and once each
40
+ * composition is expanded into the Policies it names; a check tree, the checks of a callable or
41
+ * of a Node Class rule, once normalized (`PL_BUDGET`). The structure bounds the others
42
+ * (`STRUCTURE_MAXIMUM`).
43
+ */
44
+ policy: Object.freeze({
45
+ /**
46
+ * Levels of a Policy pattern: an Edge or sameNode is one, and each allOf, anyOf, exists and
47
+ * composition adds one.
48
+ */
49
+ patternDepth: 4,
50
+ /**
51
+ * Branches of a Policy's normal form: an anyOf adds those of its operands, an allOf multiplies
52
+ * them.
53
+ */
54
+ normalizedBranches: 8,
55
+ /** Nodes one exists declares. */
56
+ variablesPerExists: 4,
57
+ /** Graph predicates, Edges and sameNode equalities, of one normalized branch. */
58
+ edgePredicates: 6,
59
+ /** The greatest bound of a repeated Edge. */
60
+ repetition: 3,
61
+ /** Domains a Policy names: its own, and the origin of every Class and object it references. */
62
+ referencedDomains: 4,
63
+ /** Levels of a check tree: a check or sameNode is one, and each allOf and anyOf adds one. */
64
+ checkDepth: 4,
65
+ /** Branches of a check tree: an anyOf adds those of its operands, an allOf multiplies them. */
66
+ checkBranches: 8,
67
+ /** Checks and sameNode equalities of a check tree. */
68
+ checkLeaves: 8,
69
+ }),
70
+ });
71
+ /**
72
+ * What the portable value boundary allows a document holding a closure whole. It may hold more than
73
+ * any one Domain does, and each route it crosses reads this, so what one accepts another can read.
74
+ */
75
+ export const closureDocument = Object.freeze({
76
+ limits: Object.freeze({ maxMembers: limits.closure.members }),
77
+ });
@@ -18,3 +18,11 @@ export declare function capBranches(values: readonly PatternBranch[]): readonly
18
18
  export declare function isConnected(branch: PatternBranch): boolean;
19
19
  export declare function targetMode(branch: PatternBranch): PolicyTargetMode | undefined;
20
20
  export declare function termKey(term: PolicyPatternTerm, namespace: string): string;
21
+ /** Disjoint sets of term keys, merged by the equalities of one Policy branch. */
22
+ export declare class UnionFind {
23
+ #private;
24
+ constructor(values: Iterable<string>);
25
+ add(value: string): void;
26
+ find(value: string): string;
27
+ join(left: string, right: string): void;
28
+ }
@@ -1,5 +1,5 @@
1
1
  import { definitionRefIndex } from '../../../addressing/ordering.js';
2
- import { policyObjectKey, policyVariableSelector } from '../model/policy.js';
2
+ import { PolicyComposition, policyObjectKey, policyVariableSelector } from '../model/policy.js';
3
3
  import { BRANCH_OVERFLOW } from './budgets.js';
4
4
  export function branchesOf(pattern, namespace) {
5
5
  const variables = collectVariableClasses(pattern, namespace);
@@ -103,8 +103,9 @@ function branchesForNode(pattern, namespace, variables) {
103
103
  requiredVariables: new Set([...branch.requiredVariables, ...direct]),
104
104
  }));
105
105
  }
106
- const children = ('allOf' in pattern ? pattern.allOf : pattern.anyOf).map((child) => branchesForNode(child, namespace, variables));
107
- return 'allOf' in pattern ? branchProduct(children) : capBranches(children.flat());
106
+ const { operator, operands } = PolicyComposition.of(pattern);
107
+ const children = operands.map((child) => branchesForNode(child, namespace, variables));
108
+ return operator === 'allOf' ? branchProduct(children) : capBranches(children.flat());
108
109
  }
109
110
  function emptyBranch() {
110
111
  return {
@@ -135,10 +136,8 @@ function collectVariableClasses(pattern, namespace) {
135
136
  }
136
137
  visit(node.exists.where);
137
138
  }
138
- else if ('allOf' in node)
139
- node.allOf.forEach(visit);
140
- else if ('anyOf' in node)
141
- node.anyOf.forEach(visit);
139
+ else if (PolicyComposition.is(node))
140
+ PolicyComposition.of(node).operands.forEach(visit);
142
141
  };
143
142
  visit(pattern);
144
143
  return result;
@@ -146,7 +145,8 @@ function collectVariableClasses(pattern, namespace) {
146
145
  function variableKey(namespace, id) {
147
146
  return `variable:${namespace}:${id}`;
148
147
  }
149
- class UnionFind {
148
+ /** Disjoint sets of term keys, merged by the equalities of one Policy branch. */
149
+ export class UnionFind {
150
150
  #parents = new Map();
151
151
  constructor(values) {
152
152
  for (const value of values)
@@ -1,16 +1,49 @@
1
- import type { PolicyCheckExpression } from '../model/policy.js';
2
- export declare const MAX_PATTERN_DEPTH = 4;
3
- export declare const MAX_BRANCHES = 8;
4
- export declare const MAX_VARIABLES = 4;
5
- export declare const MAX_EDGES = 6;
6
- export declare const MAX_REPEAT = 3;
7
- export declare const MAX_DOMAINS = 4;
8
- export declare const MAX_CHECK_DEPTH = 4;
9
- export declare const MAX_CHECK_LEAVES = 8;
1
+ import type { PolicyRef } from '../../../addressing/index.js';
2
+ import type { PolicyCheckExpression, PolicyExpression } from '../model/policy.js';
3
+ import { limits } from '../../limits.js';
4
+ /** A key of `limits.policy`. */
5
+ export type PolicyLimit = keyof typeof limits.policy;
6
+ /**
7
+ * Where a count of Policy branches stops: one past its limit. Each branch count is exact up to its
8
+ * limit plus one and reads as that once it is over, so expansion stays bounded.
9
+ */
10
10
  export declare const BRANCH_OVERFLOW: number;
11
+ /**
12
+ * What `PL_BUDGET` compares with `limits.policy` for one named Policy once normalized and each of
13
+ * its compositions expanded, every count under the key of its limit. The branch count stops one
14
+ * past its limit: it is exact up to that, and once it is over, `edgePredicates` reads the branches
15
+ * it counted only. The other counts are exact.
16
+ */
17
+ export interface PolicyMeasure {
18
+ /** Levels of the expanded pattern. */
19
+ readonly patternDepth: number;
20
+ /** Branches of its normal form, at most `limits.policy.normalizedBranches + 1`. */
21
+ readonly normalizedBranches: number;
22
+ /** The most graph predicates, Edges and sameNode equalities, of one branch. */
23
+ readonly edgePredicates: number;
24
+ /** Domains the expanded pattern names, its own included. */
25
+ readonly referencedDomains: number;
26
+ }
27
+ /**
28
+ * What `PL_BUDGET` compares with `limits.policy` for one check tree once normalized, every count
29
+ * under the key of its limit. The branch count stops one past its limit; the other counts are
30
+ * exact.
31
+ */
11
32
  export interface CheckMeasure {
12
- readonly depth: number;
13
- readonly branches: number;
14
- readonly leaves: number;
33
+ /** Levels of the tree. */
34
+ readonly checkDepth: number;
35
+ /** Branches of its normal form, at most `limits.policy.checkBranches + 1`. */
36
+ readonly checkBranches: number;
37
+ /** Checks and sameNode equalities of the tree. */
38
+ readonly checkLeaves: number;
15
39
  }
40
+ /** The limits of `limits.policy` a measure exceeds, in the order the measure lists them. */
41
+ export declare function exceededLimits<Measure extends PolicyMeasure | CheckMeasure>(measure: Measure): readonly (keyof Measure & PolicyLimit)[];
42
+ /**
43
+ * Measure named Policies by their expanded branches, depth and referenced Domains. A Policy has no
44
+ * measure when it is not normalized, when its expansion reaches itself, or when a composition names
45
+ * a Policy `isLocal` refuses or one without a measure.
46
+ */
47
+ export declare function policyMeasurer(origin: string, normalized: ReadonlyMap<string, PolicyExpression>, isLocal: (ref: PolicyRef) => boolean): (name: string) => PolicyMeasure | undefined;
48
+ /** Measure one normalized check tree. */
16
49
  export declare function measureChecks(expression: PolicyCheckExpression): CheckMeasure;
@@ -1,25 +1,145 @@
1
- export const MAX_PATTERN_DEPTH = 4;
2
- export const MAX_BRANCHES = 8;
3
- export const MAX_VARIABLES = 4;
4
- export const MAX_EDGES = 6;
5
- export const MAX_REPEAT = 3;
6
- export const MAX_DOMAINS = 4;
7
- export const MAX_CHECK_DEPTH = 4;
8
- export const MAX_CHECK_LEAVES = 8;
9
- export const BRANCH_OVERFLOW = MAX_BRANCHES + 1;
1
+ import { limits } from '../../limits.js';
2
+ import { runSuspended } from '../../suspended.js';
3
+ import { PolicyComposition, policyObjectOrigin, policyVariableClass } from '../model/policy.js';
4
+ /**
5
+ * Where a count of Policy branches stops: one past its limit. Each branch count is exact up to its
6
+ * limit plus one and reads as that once it is over, so expansion stays bounded.
7
+ */
8
+ export const BRANCH_OVERFLOW = limits.policy.normalizedBranches + 1;
9
+ const CHECK_BRANCH_OVERFLOW = limits.policy.checkBranches + 1;
10
+ /** The limits of `limits.policy` a measure exceeds, in the order the measure lists them. */
11
+ export function exceededLimits(measure) {
12
+ return Object.keys(measure).filter((limit) => measure[limit] > limits.policy[limit]);
13
+ }
14
+ /**
15
+ * Measure named Policies by their expanded branches, depth and referenced Domains. A Policy has no
16
+ * measure when it is not normalized, when its expansion reaches itself, or when a composition names
17
+ * a Policy `isLocal` refuses or one without a measure.
18
+ */
19
+ export function policyMeasurer(origin, normalized, isLocal) {
20
+ // Measure every distinct composition node once. A node's expanded measure is independent of the
21
+ // path that reaches it (the only path-sensitive outcome, the back-edge `undefined`, already holds
22
+ // for every node on or reaching a composition cycle, regardless of entry), so caching the
23
+ // completed result by node identity turns path enumeration over the composition DAG into work
24
+ // linear in the number of nodes while preserving the exact measure.
25
+ const measures = new Map();
26
+ const visiting = new Set();
27
+ function* measurePolicy(name) {
28
+ if (visiting.has(name))
29
+ return undefined;
30
+ if (measures.has(name))
31
+ return measures.get(name);
32
+ const declaration = normalized.get(name);
33
+ if (declaration === undefined)
34
+ return undefined;
35
+ visiting.add(name);
36
+ const measure = yield* measureDeclaration(declaration);
37
+ visiting.delete(name);
38
+ measures.set(name, measure);
39
+ return measure;
40
+ }
41
+ function* measureDeclaration(declaration) {
42
+ if ('match' in declaration)
43
+ return measurePattern(declaration.match, origin);
44
+ const { operator, operands: refs } = PolicyComposition.of(declaration);
45
+ const children = [];
46
+ for (const ref of refs) {
47
+ if (!isLocal(ref))
48
+ continue;
49
+ const value = yield measurePolicy(ref.name);
50
+ if (value !== undefined)
51
+ children.push(value);
52
+ }
53
+ if (children.length !== refs.length || children.length === 0)
54
+ return undefined;
55
+ return combineMeasures(operator, children);
56
+ }
57
+ return (name) => {
58
+ const measure = runSuspended(measurePolicy(name));
59
+ return measure === undefined
60
+ ? undefined
61
+ : {
62
+ patternDepth: measure.depth,
63
+ normalizedBranches: measure.edgeCounts.length,
64
+ edgePredicates: Math.max(0, ...measure.edgeCounts),
65
+ referencedDomains: measure.domains.size,
66
+ };
67
+ };
68
+ }
69
+ function measurePattern(pattern, origin) {
70
+ if ('sameNode' in pattern)
71
+ return {
72
+ depth: 1,
73
+ edgeCounts: [1],
74
+ domains: new Set([
75
+ origin,
76
+ ...[pattern.sameNode.left, pattern.sameNode.right].flatMap((term) => term.kind === 'ref' ? [policyObjectOrigin(term.ref)] : []),
77
+ ]),
78
+ };
79
+ if ('source' in pattern)
80
+ return {
81
+ depth: 1,
82
+ edgeCounts: [1],
83
+ domains: new Set([
84
+ origin,
85
+ pattern.class.origin,
86
+ ...[pattern.source, pattern.target].flatMap((term) => term.kind === 'ref' ? [policyObjectOrigin(term.ref)] : []),
87
+ ]),
88
+ };
89
+ if ('exists' in pattern) {
90
+ const child = measurePattern(pattern.exists.where, origin);
91
+ return {
92
+ depth: child.depth + 1,
93
+ edgeCounts: child.edgeCounts,
94
+ domains: new Set([
95
+ ...child.domains,
96
+ ...pattern.exists.nodes.flatMap((node) => {
97
+ const ref = policyVariableClass(node);
98
+ return ref === undefined ? [] : [ref.origin];
99
+ }),
100
+ ]),
101
+ };
102
+ }
103
+ const { operator, operands } = PolicyComposition.of(pattern);
104
+ return combineMeasures(operator, operands.map((child) => measurePattern(child, origin)));
105
+ }
106
+ function combineMeasures(kind, children) {
107
+ const depth = 1 + Math.max(0, ...children.map((child) => child.depth));
108
+ const domains = new Set(children.flatMap((child) => [...child.domains]));
109
+ if (kind === 'anyOf')
110
+ return {
111
+ depth,
112
+ edgeCounts: children.flatMap((child) => child.edgeCounts).slice(0, BRANCH_OVERFLOW),
113
+ domains,
114
+ };
115
+ let edgeCounts = [0];
116
+ for (const child of children) {
117
+ const next = [];
118
+ for (const left of edgeCounts) {
119
+ for (const right of child.edgeCounts) {
120
+ next.push(left + right);
121
+ if (next.length >= BRANCH_OVERFLOW)
122
+ break;
123
+ }
124
+ if (next.length >= BRANCH_OVERFLOW)
125
+ break;
126
+ }
127
+ edgeCounts = next;
128
+ }
129
+ return { depth, edgeCounts, domains };
130
+ }
131
+ /** Measure one normalized check tree. */
10
132
  export function measureChecks(expression) {
11
133
  if ('check' in expression || 'sameNode' in expression)
12
- return { depth: 1, branches: 1, leaves: 1 };
13
- const children = ('allOf' in expression ? expression.allOf : expression.anyOf).map(measureChecks);
14
- const branches = 'allOf' in expression
15
- ? children.reduce((value, child) => saturatingProduct(value, child.branches), 1)
16
- : children.reduce((value, child) => Math.min(BRANCH_OVERFLOW, value + child.branches), 0);
134
+ return { checkDepth: 1, checkBranches: 1, checkLeaves: 1 };
135
+ const { operator, operands } = PolicyComposition.of(expression);
136
+ const children = operands.map(measureChecks);
137
+ const checkBranches = operator === 'allOf'
138
+ ? children.reduce((value, child) => Math.min(CHECK_BRANCH_OVERFLOW, value * child.checkBranches), 1)
139
+ : children.reduce((value, child) => Math.min(CHECK_BRANCH_OVERFLOW, value + child.checkBranches), 0);
17
140
  return {
18
- depth: 1 + Math.max(0, ...children.map((child) => child.depth)),
19
- branches,
20
- leaves: children.reduce((value, child) => value + child.leaves, 0),
141
+ checkDepth: 1 + Math.max(0, ...children.map((child) => child.checkDepth)),
142
+ checkBranches,
143
+ checkLeaves: children.reduce((value, child) => value + child.checkLeaves, 0),
21
144
  };
22
145
  }
23
- function saturatingProduct(left, right) {
24
- return Math.min(BRANCH_OVERFLOW, left * right);
25
- }
@@ -1,5 +1,6 @@
1
- import { policyObjectKey } from '../model/policy.js';
2
- import { MAX_BRANCHES, measureChecks } from './budgets.js';
1
+ import { limits } from '../../limits.js';
2
+ import { PolicyComposition, policyObjectKey } from '../model/policy.js';
3
+ import { measureChecks } from './budgets.js';
3
4
  /** Names a callable check object. Every leaf over one object sees the same Node at runtime. */
4
5
  function checkObjectName(object) {
5
6
  if (object.kind === 'self')
@@ -36,7 +37,7 @@ export function admittedCheckClasses(typing) {
36
37
  * check budget is already refused, so it is not expanded.
37
38
  */
38
39
  export function neverAdmittedClasses(expression, leaves) {
39
- if (measureChecks(expression).branches > MAX_BRANCHES)
40
+ if (measureChecks(expression).checkBranches > limits.policy.checkBranches)
40
41
  return [];
41
42
  const accepted = new Map();
42
43
  for (const [leaf, classes] of leaves)
@@ -72,9 +73,10 @@ export function neverAdmittedClasses(expression, leaves) {
72
73
  function disjunctiveForm(expression) {
73
74
  if ('check' in expression || 'sameNode' in expression)
74
75
  return [[expression]];
75
- if ('anyOf' in expression)
76
- return expression.anyOf.flatMap(disjunctiveForm);
77
- return expression.allOf
76
+ const { operator, operands } = PolicyComposition.of(expression);
77
+ if (operator === 'anyOf')
78
+ return operands.flatMap(disjunctiveForm);
79
+ return operands
78
80
  .map(disjunctiveForm)
79
81
  .reduce((left, right) => left.flatMap((prefix) => right.map((suffix) => [...prefix, ...suffix])), [[]]);
80
82
  }
@@ -0,0 +1,4 @@
1
+ import type { CycleEdge } from '../../cycle.js';
2
+ import type { PolicyExpression } from '../model/policy.js';
3
+ /** Each edge closing a cycle among the named Policies of `origin`, walking from `names` in order. */
4
+ export declare function compositionCycles(names: Iterable<string>, expressionOf: (name: string) => PolicyExpression | undefined, origin: string): Generator<CycleEdge<string>, void, undefined>;