@astrale-os/kernel-core 0.9.0-beta.9 → 1.0.0-beta.2

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 (378) hide show
  1. package/dist/auth/authority/accept.js +4 -0
  2. package/dist/auth/authority/admission/admission.d.ts +4 -1
  3. package/dist/auth/authority/admission/admission.js +46 -147
  4. package/dist/auth/authority/admission/index.d.ts +1 -1
  5. package/dist/auth/authority/admission/index.js +1 -1
  6. package/dist/auth/authority/admission/references.d.ts +13 -0
  7. package/dist/auth/authority/admission/references.js +38 -0
  8. package/dist/auth/authority/admission/term.d.ts +6 -0
  9. package/dist/auth/authority/admission/term.js +60 -0
  10. package/dist/auth/authority/admission/wire.d.ts +8 -0
  11. package/dist/auth/authority/admission/wire.js +33 -0
  12. package/dist/auth/authority/canonical.d.ts +2 -0
  13. package/dist/auth/authority/canonical.js +15 -0
  14. package/dist/auth/authority/index.d.ts +9 -2
  15. package/dist/auth/authority/index.js +6 -1
  16. package/dist/auth/authority/language/index.d.ts +3 -1
  17. package/dist/auth/authority/language/index.js +1 -0
  18. package/dist/auth/authority/language/predicate.d.ts +31 -16
  19. package/dist/auth/authority/language/predicate.js +1 -1
  20. package/dist/auth/authority/language/program.d.ts +21 -0
  21. package/dist/auth/authority/language/program.js +2 -0
  22. package/dist/auth/authority/normalization/index.d.ts +1 -1
  23. package/dist/auth/authority/normalization/index.js +1 -1
  24. package/dist/auth/authority/normalization/normalize.d.ts +2 -0
  25. package/dist/auth/authority/normalization/normalize.js +38 -16
  26. package/dist/auth/authority/ownership.optimization.d.ts +8 -0
  27. package/dist/auth/authority/ownership.optimization.js +83 -0
  28. package/dist/auth/authority/prepare-binder-body.d.ts +4 -0
  29. package/dist/auth/authority/prepare-binder-body.js +31 -0
  30. package/dist/auth/authority/program.d.ts +28 -0
  31. package/dist/auth/authority/program.js +191 -0
  32. package/dist/auth/authority/semantics/class-authority.d.ts +8 -0
  33. package/dist/auth/authority/semantics/class-authority.js +26 -0
  34. package/dist/auth/authority/semantics/composition.d.ts +39 -0
  35. package/dist/auth/authority/semantics/composition.js +112 -0
  36. package/dist/auth/authority/semantics/failure.d.ts +21 -0
  37. package/dist/auth/authority/semantics/failure.js +10 -0
  38. package/dist/auth/authority/semantics/index.d.ts +11 -0
  39. package/dist/auth/authority/semantics/index.js +5 -0
  40. package/dist/auth/authority/semantics/interpret.d.ts +41 -0
  41. package/dist/auth/authority/semantics/interpret.js +388 -0
  42. package/dist/auth/authority/semantics/snapshot.d.ts +40 -0
  43. package/dist/auth/authority/semantics/terms.d.ts +20 -0
  44. package/dist/auth/authority/semantics/terms.js +96 -0
  45. package/dist/auth/authority/semantics/vocabulary.d.ts +19 -0
  46. package/dist/auth/context/context.d.ts +4 -3
  47. package/dist/auth/expression/authoring/builder.d.ts +2 -11
  48. package/dist/auth/expression/authoring/builder.js +1 -45
  49. package/dist/auth/expression/authoring/index.d.ts +1 -1
  50. package/dist/auth/expression/authoring/index.js +1 -1
  51. package/dist/auth/expression/index.d.ts +1 -2
  52. package/dist/auth/expression/index.js +1 -2
  53. package/dist/auth/expression/language/identity-expression.d.ts +2 -22
  54. package/dist/auth/grant/index.d.ts +1 -1
  55. package/dist/auth/grant/index.js +1 -1
  56. package/dist/auth/grant/resolved/admission.d.ts +4 -3
  57. package/dist/auth/grant/resolved/admission.js +23 -13
  58. package/dist/auth/grant/resolved/grant.d.ts +1 -1
  59. package/dist/auth/grant/resolved/index.d.ts +1 -1
  60. package/dist/auth/grant/resolved/index.js +1 -1
  61. package/dist/auth/grant/unresolved/admission.d.ts +4 -1
  62. package/dist/auth/grant/unresolved/admission.js +27 -67
  63. package/dist/auth/grant/unresolved/limits.d.ts +2 -4
  64. package/dist/auth/grant/unresolved/limits.js +1 -5
  65. package/dist/auth/identity/admission.js +11 -3
  66. package/dist/auth/identity/identity.d.ts +15 -3
  67. package/dist/auth/identity/index.d.ts +1 -1
  68. package/dist/auth/index.d.ts +4 -4
  69. package/dist/auth/index.js +1 -1
  70. package/dist/auth/jwk/index.d.ts +1 -1
  71. package/dist/auth/jwk/index.js +1 -1
  72. package/dist/auth/jwk/thumbprint.d.ts +2 -0
  73. package/dist/auth/jwk/thumbprint.js +12 -6
  74. package/dist/auth/register/fingerprint/fingerprint.d.ts +25 -0
  75. package/dist/auth/register/fingerprint/fingerprint.js +31 -0
  76. package/dist/auth/register/fingerprint/index.d.ts +2 -0
  77. package/dist/auth/register/index.d.ts +5 -0
  78. package/dist/auth/register/request/admission.d.ts +3 -0
  79. package/dist/auth/register/request/admission.js +103 -0
  80. package/dist/auth/register/request/index.d.ts +3 -0
  81. package/dist/auth/register/request/limits.d.ts +6 -0
  82. package/dist/auth/register/request/limits.js +6 -0
  83. package/dist/auth/register/request/request.d.ts +19 -0
  84. package/dist/auth/{provision → register}/request/self-issuer.d.ts +1 -1
  85. package/dist/auth/{provision → register}/request/self-issuer.js +1 -1
  86. package/dist/auth/register/result/index.d.ts +1 -0
  87. package/dist/auth/register/result/result.d.ts +10 -0
  88. package/dist/auth/register/result/result.js +1 -0
  89. package/dist/callable/contract/body.d.ts +10 -0
  90. package/dist/callable/contract/body.js +7 -0
  91. package/dist/callable/contract/index.d.ts +2 -1
  92. package/dist/callable/contract/index.js +1 -1
  93. package/dist/callable/contract/output.d.ts +18 -2
  94. package/dist/callable/index.d.ts +3 -2
  95. package/dist/callable/index.js +2 -1
  96. package/dist/callable/invocation/call.d.ts +16 -2
  97. package/dist/callable/invocation/call.js +41 -1
  98. package/dist/callable/invocation/index.d.ts +1 -1
  99. package/dist/callable/invocation/index.js +1 -1
  100. package/dist/callable/invocation/result.d.ts +2 -2
  101. package/dist/dns-label.d.ts +1 -2
  102. package/dist/dns-label.js +2 -3
  103. package/dist/graph/graph/graph.d.ts +1 -5
  104. package/dist/graph/graph/graph.js +3 -27
  105. package/dist/graph/graph/index.d.ts +2 -4
  106. package/dist/graph/graph/index.js +2 -3
  107. package/dist/graph/graph/model/codec.js +4 -4
  108. package/dist/graph/graph/model/index.d.ts +1 -1
  109. package/dist/graph/graph/model/index.js +1 -1
  110. package/dist/graph/graph/model/model.d.ts +7 -7
  111. package/dist/graph/graph/model/model.js +6 -6
  112. package/dist/graph/graph/model/wire.d.ts +58 -78
  113. package/dist/graph/graph/model/wire.js +18 -19
  114. package/dist/graph/mutate/authoring/builder.d.ts +2 -2
  115. package/dist/graph/mutate/authoring/builder.js +2 -2
  116. package/dist/graph/mutate/authoring/create.js +13 -5
  117. package/dist/graph/mutate/index.d.ts +1 -1
  118. package/dist/graph/mutate/language/codec.js +3 -3
  119. package/dist/graph/mutate/language/model.d.ts +4 -4
  120. package/dist/graph/mutate/language/wire.d.ts +226 -215
  121. package/dist/graph/mutate/language/wire.js +42 -47
  122. package/dist/graph/mutate/result/index.d.ts +4 -3
  123. package/dist/graph/mutate/result/index.js +8 -6
  124. package/dist/graph/mutate/result/wire.d.ts +4 -4
  125. package/dist/graph/mutate/result/wire.js +7 -4
  126. package/dist/graph/node/identity/id.d.ts +0 -4
  127. package/dist/graph/node/identity/id.js +0 -5
  128. package/dist/graph/node/identity/order.js +20 -0
  129. package/dist/graph/path/authoring/path.d.ts +8 -5
  130. package/dist/graph/path/authoring/path.js +21 -3
  131. package/dist/graph/path/language/model.d.ts +8 -3
  132. package/dist/graph/path/language/syntax.js +23 -8
  133. package/dist/graph/query/authoring/builder.js +37 -5
  134. package/dist/graph/query/authoring/model.d.ts +20 -1
  135. package/dist/graph/query/index.d.ts +4 -2
  136. package/dist/graph/query/index.js +1 -0
  137. package/dist/graph/query/language/codec.js +18 -3
  138. package/dist/graph/query/language/fingerprint.js +8 -0
  139. package/dist/graph/query/language/model.d.ts +22 -4
  140. package/dist/graph/query/language/wire.d.ts +124 -114
  141. package/dist/graph/query/language/wire.js +54 -47
  142. package/dist/graph/query/order/index.d.ts +53 -0
  143. package/dist/graph/query/order/index.js +79 -0
  144. package/dist/graph/query/reference/evaluate.d.ts +1 -0
  145. package/dist/graph/query/reference/evaluate.js +39 -52
  146. package/dist/graph/query/result/index.js +1 -1
  147. package/dist/graph/query/result/wire.d.ts +93 -94
  148. package/dist/graph/query/result/wire.js +20 -20
  149. package/dist/graph/reconcile/condition/model.d.ts +2 -2
  150. package/dist/graph/reconcile/condition/references.d.ts +0 -1
  151. package/dist/graph/reconcile/condition/references.js +4 -4
  152. package/dist/graph/reconcile/correspondence.d.ts +9 -8
  153. package/dist/graph/reconcile/evidence.d.ts +2 -2
  154. package/dist/graph/reconcile/mutation/assess.d.ts +2 -1
  155. package/dist/graph/reconcile/observation.d.ts +4 -3
  156. package/dist/graph/reconcile/planning/canonical.d.ts +6 -0
  157. package/dist/graph/reconcile/planning/canonical.js +28 -0
  158. package/dist/graph/reconcile/planning/context.d.ts +3 -3
  159. package/dist/graph/reconcile/planning/model.d.ts +8 -4
  160. package/dist/graph/reconcile/planning/plan.js +2 -1
  161. package/dist/schema/authority/authority-relation.js +3 -0
  162. package/dist/schema/authority/claims.d.ts +24 -25
  163. package/dist/schema/authority/claims.js +8 -8
  164. package/dist/schema/authority/governed-by.d.ts +16 -91
  165. package/dist/schema/authority/governed-by.js +1 -1
  166. package/dist/schema/authority/operation-node.d.ts +27 -13
  167. package/dist/schema/authority/operations.d.ts +8 -168
  168. package/dist/schema/authority/policy.d.ts +27 -15
  169. package/dist/schema/authority/vocabulary.d.ts +3 -0
  170. package/dist/schema/authority/vocabulary.js +25 -0
  171. package/dist/schema/callables/entrypoint.d.ts +32 -0
  172. package/dist/schema/callables/entrypoint.js +12 -0
  173. package/dist/schema/callables/execution.d.ts +269 -0
  174. package/dist/schema/callables/execution.js +32 -0
  175. package/dist/schema/callables/function.d.ts +3400 -55
  176. package/dist/schema/callables/function.js +4 -3
  177. package/dist/schema/callables/index.d.ts +2 -1
  178. package/dist/schema/callables/index.js +2 -1
  179. package/dist/schema/callables/method-of.d.ts +18 -143
  180. package/dist/schema/callables/method-of.js +2 -2
  181. package/dist/schema/callables/view.d.ts +83 -51
  182. package/dist/schema/definitions/class.d.ts +45 -33
  183. package/dist/schema/definitions/extends.d.ts +16 -110
  184. package/dist/schema/definitions/instance-of.d.ts +17 -69
  185. package/dist/schema/domain/domain.d.ts +3343 -148
  186. package/dist/schema/domain/domain.js +6 -3
  187. package/dist/schema/domain/of-domain.d.ts +18 -192
  188. package/dist/schema/domain/of-domain.js +1 -1
  189. package/dist/schema/identity/composition.d.ts +5 -0
  190. package/dist/schema/identity/composition.js +5 -0
  191. package/dist/schema/identity/identity.d.ts +225 -122
  192. package/dist/schema/identity/identity.js +3 -4
  193. package/dist/schema/index.d.ts +1 -0
  194. package/dist/schema/index.js +1 -0
  195. package/dist/schema/installation/operation-id.d.ts +1 -2
  196. package/dist/schema/installation/operation-id.js +2 -4
  197. package/dist/schema/introspection/index.d.ts +1 -1
  198. package/dist/schema/introspection/language.d.ts +12 -28
  199. package/dist/schema/kernel/projection/callables.js +2 -3
  200. package/dist/schema/kernel/projection/core.d.ts +7 -0
  201. package/dist/schema/kernel/projection/core.js +51 -0
  202. package/dist/schema/kernel/projection/definitions.d.ts +13 -0
  203. package/dist/schema/kernel/projection/definitions.js +71 -0
  204. package/dist/schema/kernel/projection/index.d.ts +3 -3
  205. package/dist/schema/kernel/projection/index.js +2 -2
  206. package/dist/schema/kernel/projection/methods.d.ts +5 -0
  207. package/dist/schema/kernel/projection/methods.js +41 -0
  208. package/dist/schema/kernel/projection/part.d.ts +34 -0
  209. package/dist/schema/kernel/projection/part.js +42 -0
  210. package/dist/schema/kernel/projection/paths.d.ts +6 -0
  211. package/dist/schema/kernel/projection/{keys.js → paths.js} +12 -14
  212. package/dist/schema/kernel/projection/project.d.ts +4 -2
  213. package/dist/schema/kernel/projection/project.js +33 -258
  214. package/dist/schema/kernel/projection/properties.d.ts +11 -0
  215. package/dist/schema/kernel/projection/properties.js +36 -0
  216. package/dist/schema/kernel/projection/relations.d.ts +7 -0
  217. package/dist/schema/kernel/projection/relations.js +61 -0
  218. package/dist/schema/kernel/projection/types.d.ts +28 -2
  219. package/dist/schema/kernel/schema.d.ts +8737 -5086
  220. package/dist/schema/kernel/schema.js +12 -8
  221. package/dist/schema/kernel/syscalls/contracts/admit.d.ts +15 -12
  222. package/dist/schema/kernel/syscalls/contracts/admit.js +16 -9
  223. package/dist/schema/kernel/syscalls/contracts/blob.d.ts +31 -0
  224. package/dist/schema/kernel/syscalls/contracts/blob.js +24 -0
  225. package/dist/schema/kernel/syscalls/contracts/can.d.ts +19 -8
  226. package/dist/schema/kernel/syscalls/contracts/can.js +12 -4
  227. package/dist/schema/kernel/syscalls/contracts/delegate.d.ts +6 -7
  228. package/dist/schema/kernel/syscalls/contracts/delegate.js +5 -5
  229. package/dist/schema/kernel/syscalls/contracts/execution.d.ts +60 -0
  230. package/dist/schema/kernel/syscalls/contracts/execution.js +46 -0
  231. package/dist/schema/kernel/syscalls/contracts/expected.d.ts +5 -0
  232. package/dist/schema/kernel/syscalls/contracts/expected.js +9 -0
  233. package/dist/schema/kernel/syscalls/contracts/identity.d.ts +18 -19
  234. package/dist/schema/kernel/syscalls/contracts/identity.js +6 -7
  235. package/dist/schema/kernel/syscalls/contracts/impersonate.d.ts +6 -0
  236. package/dist/schema/kernel/syscalls/contracts/impersonate.js +4 -0
  237. package/dist/schema/kernel/syscalls/contracts/index.d.ts +6 -3
  238. package/dist/schema/kernel/syscalls/contracts/index.js +6 -3
  239. package/dist/schema/kernel/syscalls/contracts/install.d.ts +149 -217
  240. package/dist/schema/kernel/syscalls/contracts/install.js +22 -26
  241. package/dist/schema/kernel/syscalls/contracts/installation.d.ts +65 -351
  242. package/dist/schema/kernel/syscalls/contracts/installation.js +29 -67
  243. package/dist/schema/kernel/syscalls/contracts/introspect.d.ts +11 -15
  244. package/dist/schema/kernel/syscalls/contracts/introspect.js +8 -15
  245. package/dist/schema/kernel/syscalls/contracts/journal.d.ts +26 -27
  246. package/dist/schema/kernel/syscalls/contracts/journal.js +15 -15
  247. package/dist/schema/kernel/syscalls/contracts/mint.d.ts +5 -7
  248. package/dist/schema/kernel/syscalls/contracts/mint.js +4 -5
  249. package/dist/schema/kernel/syscalls/contracts/mutate.d.ts +243 -224
  250. package/dist/schema/kernel/syscalls/contracts/mutate.js +7 -1
  251. package/dist/schema/kernel/syscalls/contracts/query.d.ts +232 -222
  252. package/dist/schema/kernel/syscalls/contracts/query.js +10 -15
  253. package/dist/schema/kernel/syscalls/contracts/register.d.ts +20 -0
  254. package/dist/schema/kernel/syscalls/contracts/register.js +24 -0
  255. package/dist/schema/kernel/syscalls/contracts/uninstall.d.ts +54 -148
  256. package/dist/schema/kernel/syscalls/contracts/uninstall.js +6 -5
  257. package/dist/schema/kernel/syscalls/contracts/view-host-requirements.d.ts +17 -0
  258. package/dist/schema/kernel/syscalls/contracts/view-host-requirements.js +40 -0
  259. package/dist/schema/kernel/syscalls/contracts/view-resolve.d.ts +27 -28
  260. package/dist/schema/kernel/syscalls/contracts/view-resolve.js +16 -24
  261. package/dist/schema/kernel/syscalls/contracts/whoami.d.ts +19 -20
  262. package/dist/schema/kernel/syscalls/contracts/whoami.js +2 -2
  263. package/dist/schema/kernel/syscalls/contracts/whois.d.ts +22 -23
  264. package/dist/schema/kernel/syscalls/contracts/whois.js +3 -3
  265. package/dist/schema/kernel/syscalls/declarations/admit.d.ts +18 -18
  266. package/dist/schema/kernel/syscalls/declarations/admit.js +3 -3
  267. package/dist/schema/kernel/syscalls/declarations/can.d.ts +19 -14
  268. package/dist/schema/kernel/syscalls/declarations/can.js +4 -4
  269. package/dist/schema/kernel/syscalls/declarations/delegate.d.ts +9 -12
  270. package/dist/schema/kernel/syscalls/declarations/delegate.js +4 -4
  271. package/dist/schema/kernel/syscalls/declarations/download.d.ts +12 -0
  272. package/dist/schema/kernel/syscalls/declarations/download.js +10 -0
  273. package/dist/schema/kernel/syscalls/declarations/execution.d.ts +105 -0
  274. package/dist/schema/kernel/syscalls/declarations/execution.js +52 -0
  275. package/dist/schema/kernel/syscalls/declarations/impersonate.d.ts +9 -0
  276. package/dist/schema/kernel/syscalls/declarations/impersonate.js +12 -0
  277. package/dist/schema/kernel/syscalls/declarations/index.d.ts +870 -1323
  278. package/dist/schema/kernel/syscalls/declarations/index.js +18 -2
  279. package/dist/schema/kernel/syscalls/declarations/install.d.ts +29 -172
  280. package/dist/schema/kernel/syscalls/declarations/install.js +7 -5
  281. package/dist/schema/kernel/syscalls/declarations/introspect.d.ts +8 -19
  282. package/dist/schema/kernel/syscalls/declarations/introspect.js +3 -4
  283. package/dist/schema/kernel/syscalls/declarations/journal.d.ts +29 -31
  284. package/dist/schema/kernel/syscalls/declarations/journal.js +4 -2
  285. package/dist/schema/kernel/syscalls/declarations/mint.d.ts +8 -13
  286. package/dist/schema/kernel/syscalls/declarations/mint.js +5 -5
  287. package/dist/schema/kernel/syscalls/declarations/mutate.d.ts +239 -256
  288. package/dist/schema/kernel/syscalls/declarations/mutate.js +4 -2
  289. package/dist/schema/kernel/syscalls/declarations/query.d.ts +235 -260
  290. package/dist/schema/kernel/syscalls/declarations/query.js +4 -2
  291. package/dist/schema/kernel/syscalls/declarations/register.d.ts +23 -0
  292. package/dist/schema/kernel/syscalls/declarations/register.js +10 -0
  293. package/dist/schema/kernel/syscalls/declarations/uninstall.d.ts +49 -153
  294. package/dist/schema/kernel/syscalls/declarations/uninstall.js +4 -2
  295. package/dist/schema/kernel/syscalls/declarations/upload.d.ts +15 -0
  296. package/dist/schema/kernel/syscalls/declarations/upload.js +10 -0
  297. package/dist/schema/kernel/syscalls/declarations/use-policy.d.ts +4 -0
  298. package/dist/schema/kernel/syscalls/declarations/use-policy.js +9 -0
  299. package/dist/schema/kernel/syscalls/declarations/view-resolve.d.ts +30 -37
  300. package/dist/schema/kernel/syscalls/declarations/view-resolve.js +5 -3
  301. package/dist/schema/kernel/syscalls/declarations/whoami.d.ts +22 -26
  302. package/dist/schema/kernel/syscalls/declarations/whoami.js +3 -3
  303. package/dist/schema/kernel/syscalls/declarations/whois.d.ts +25 -29
  304. package/dist/schema/kernel/syscalls/declarations/whois.js +5 -3
  305. package/dist/schema/kernel/syscalls/descriptors/execution.d.ts +153 -0
  306. package/dist/schema/kernel/syscalls/descriptors/execution.js +11 -0
  307. package/dist/schema/kernel/syscalls/descriptors/function.d.ts +8 -2
  308. package/dist/schema/kernel/syscalls/descriptors/functions.d.ts +3 -1
  309. package/dist/schema/kernel/syscalls/descriptors/functions.js +3 -1
  310. package/dist/schema/kernel/syscalls/descriptors/identity.d.ts +47 -13
  311. package/dist/schema/kernel/syscalls/descriptors/identity.js +2 -1
  312. package/dist/schema/kernel/syscalls/descriptors/index.d.ts +2 -1
  313. package/dist/schema/kernel/syscalls/descriptors/index.js +2 -1
  314. package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.d.ts +5 -2
  315. package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.js +8 -38
  316. package/dist/schema/kernel/syscalls/descriptors/view.d.ts +11 -9
  317. package/dist/schema/kernel/syscalls/index.d.ts +2 -2
  318. package/dist/schema/kernel/syscalls/index.js +2 -2
  319. package/dist/schema/kernel/syscalls/references/execution.d.ts +55 -0
  320. package/dist/schema/kernel/syscalls/references/execution.js +13 -0
  321. package/dist/schema/kernel/syscalls/references/functions.d.ts +12 -2
  322. package/dist/schema/kernel/syscalls/references/functions.js +3 -1
  323. package/dist/schema/kernel/syscalls/references/identity.d.ts +9 -0
  324. package/dist/schema/kernel/syscalls/references/identity.js +1 -0
  325. package/dist/schema/kernel/syscalls/references/index.d.ts +2 -1
  326. package/dist/schema/kernel/syscalls/references/index.js +2 -1
  327. package/dist/schema/meta/created-by.d.ts +32 -0
  328. package/dist/schema/meta/created-by.js +17 -0
  329. package/dist/schema/meta/descriptable.d.ts +13 -11
  330. package/dist/schema/meta/edge.d.ts +5 -9
  331. package/dist/schema/meta/iconable.d.ts +13 -11
  332. package/dist/schema/meta/index.d.ts +1 -0
  333. package/dist/schema/meta/index.js +1 -0
  334. package/dist/schema/meta/named.d.ts +13 -9
  335. package/dist/schema/meta/node.d.ts +9 -1
  336. package/dist/schema/meta/remotable.d.ts +15 -22
  337. package/dist/schema/meta/statused.d.ts +13 -7
  338. package/dist/schema/meta/timestamped.d.ts +14 -12
  339. package/package.json +9 -7
  340. package/dist/auth/expression/normalization/canonicalize.d.ts +0 -7
  341. package/dist/auth/expression/normalization/canonicalize.js +0 -102
  342. package/dist/auth/expression/normalization/index.d.ts +0 -2
  343. package/dist/auth/expression/normalization/index.js +0 -2
  344. package/dist/auth/expression/normalization/raise-denials.d.ts +0 -3
  345. package/dist/auth/expression/normalization/raise-denials.js +0 -59
  346. package/dist/auth/provision/fingerprint/fingerprint.d.ts +0 -9
  347. package/dist/auth/provision/fingerprint/fingerprint.js +0 -33
  348. package/dist/auth/provision/fingerprint/index.d.ts +0 -2
  349. package/dist/auth/provision/index.d.ts +0 -5
  350. package/dist/auth/provision/request/admission.d.ts +0 -3
  351. package/dist/auth/provision/request/admission.js +0 -125
  352. package/dist/auth/provision/request/index.d.ts +0 -3
  353. package/dist/auth/provision/request/request.d.ts +0 -29
  354. package/dist/auth/provision/result/index.d.ts +0 -1
  355. package/dist/auth/provision/result/result.d.ts +0 -12
  356. package/dist/graph/graph/navigation/error.d.ts +0 -12
  357. package/dist/graph/graph/navigation/error.js +0 -20
  358. package/dist/graph/graph/navigation/index.d.ts +0 -2
  359. package/dist/graph/graph/navigation/index.js +0 -1
  360. package/dist/graph/graph/navigation/model.d.ts +0 -15
  361. package/dist/schema/callables/view-for.d.ts +0 -296
  362. package/dist/schema/callables/view-for.js +0 -12
  363. package/dist/schema/kernel/projection/keys.d.ts +0 -3
  364. package/dist/schema/kernel/projection/path.d.ts +0 -2
  365. package/dist/schema/kernel/projection/path.js +0 -140
  366. package/dist/schema/kernel/syscalls/contracts/provision.d.ts +0 -292
  367. package/dist/schema/kernel/syscalls/contracts/provision.js +0 -19
  368. package/dist/schema/kernel/syscalls/declarations/define.d.ts +0 -5
  369. package/dist/schema/kernel/syscalls/declarations/define.js +0 -7
  370. package/dist/schema/kernel/syscalls/declarations/provision.d.ts +0 -296
  371. package/dist/schema/kernel/syscalls/declarations/provision.js +0 -8
  372. /package/dist/auth/{provision/request/request.js → authority/semantics/snapshot.js} +0 -0
  373. /package/dist/auth/{provision/result/index.js → authority/semantics/vocabulary.js} +0 -0
  374. /package/dist/auth/{provision → register}/fingerprint/index.js +0 -0
  375. /package/dist/auth/{provision → register}/index.js +0 -0
  376. /package/dist/auth/{provision → register}/request/index.js +0 -0
  377. /package/dist/auth/{provision/result/result.js → register/request/request.js} +0 -0
  378. /package/dist/{graph/graph/navigation/model.js → auth/register/result/index.js} +0 -0
@@ -1,21 +1,30 @@
1
1
  import * as portable from '@astrale-os/kernel-dsl/value';
2
2
  import { NodeId } from '../../../graph/node/index.js';
3
3
  import { AuthValueError } from '../../error.js';
4
- import { canonicalize as canonicalizeGrant } from '../../grant/index.js';
5
4
  import { admitAuthorityExpr, limits } from '../admission/index.js';
6
5
  import { AUTHORITY_PREDICATE_VERSION } from '../language/index.js';
6
+ import { ownCanonical, ownedExpression, ownsExpression } from '../ownership.optimization.js';
7
7
  /** Validate and canonicalize one authority expression into its versioned crossing envelope. */
8
8
  export function canonicalize(expr) {
9
- const admitted = admitAuthorityExpr(portable.accept(expr));
9
+ const owned = ownedExpression(expr);
10
+ if (owned !== undefined)
11
+ return owned;
12
+ const admitted = admitAuthorityExpr(portable.acceptForRead(expr));
10
13
  return canonicalizeAdmitted(admitted);
11
14
  }
12
15
  export function canonicalizeAdmitted(expr) {
13
- return Object.freeze({
16
+ return ownCanonical(Object.freeze({
14
17
  version: AUTHORITY_PREDICATE_VERSION,
15
18
  predicate: normalize(expr, '/predicate', new Set(), false),
16
- });
19
+ }));
20
+ }
21
+ /** Internal scoped normalization; this body is not a closed owned authority expression. */
22
+ export function normalizeBinderBodyAdmitted(expr) {
23
+ return normalize(expr, '/predicate/where', new Set(), true);
17
24
  }
18
25
  function normalize(expr, path, locals, subjectBound) {
26
+ if (ownsExpression(expr))
27
+ return expr;
19
28
  switch (expr.op) {
20
29
  case 'true':
21
30
  case 'false':
@@ -33,17 +42,24 @@ function normalize(expr, path, locals, subjectBound) {
33
42
  case 'all':
34
43
  case 'any':
35
44
  return normalizeBoolean(expr.op, expr.predicates, path, locals, subjectBound);
36
- case 'grant':
45
+ case 'as':
37
46
  return Object.freeze({
38
- op: 'grant',
39
- grant: canonicalizeGrant(expr.grant),
47
+ op: 'as',
48
+ identity: NodeId(expr.identity),
40
49
  where: normalize(expr.where, `${path}/where`, locals, true),
41
50
  });
51
+ case 'same-node': {
52
+ const left = normalizeTerm(expr.left);
53
+ const right = normalizeTerm(expr.right);
54
+ return Object.freeze(compare(portable.json.serialize(left), portable.json.serialize(right)) <= 0
55
+ ? { op: 'same-node', left, right }
56
+ : { op: 'same-node', left: right, right: left });
57
+ }
42
58
  case 'related':
43
59
  return Object.freeze({
44
60
  op: 'related',
45
61
  source: normalizeTerm(expr.source),
46
- class: Object.freeze({ ...expr.class }),
62
+ via: normalizeClasses(expr.via),
47
63
  target: normalizeTerm(expr.target),
48
64
  ...(expr.repeat === undefined ? {} : { repeat: Object.freeze({ ...expr.repeat }) }),
49
65
  });
@@ -71,12 +87,6 @@ function normalize(expr, path, locals, subjectBound) {
71
87
  class: Object.freeze({ ...expr.class }),
72
88
  evidence: expr.evidence,
73
89
  });
74
- case 'domain-control':
75
- return Object.freeze({
76
- op: 'domain-control',
77
- identity: normalizeTerm(expr.identity),
78
- origin: expr.origin,
79
- });
80
90
  }
81
91
  }
82
92
  function normalizeBoolean(op, input, path, locals, subjectBound) {
@@ -95,7 +105,8 @@ function normalizeBoolean(op, input, path, locals, subjectBound) {
95
105
  for (const expr of flattened) {
96
106
  if (expr.op === identity)
97
107
  continue;
98
- unique.set(portable.json.serialize(expr), expr);
108
+ // Admission and normalization own these detached subtrees; sorting does not lose that proof.
109
+ unique.set(portable.json.serializeAdmitted(expr), expr);
99
110
  }
100
111
  const predicates = [...unique.entries()]
101
112
  .sort(([left], [right]) => compare(left, right))
@@ -119,6 +130,8 @@ function normalizeTerm(term) {
119
130
  return Object.freeze({ kind: 'class', ref: Object.freeze({ ...term.ref }) });
120
131
  case 'domain':
121
132
  return Object.freeze({ kind: 'domain', origin: term.origin });
133
+ case 'ref':
134
+ return Object.freeze({ kind: 'ref', ref: Object.freeze({ ...term.ref }) });
122
135
  case 'core':
123
136
  return Object.freeze({ kind: 'core', ref: Object.freeze({ ...term.ref }) });
124
137
  case 'local':
@@ -128,7 +141,16 @@ function normalizeTerm(term) {
128
141
  }
129
142
  }
130
143
  function normalizeLocal(local) {
131
- return Object.freeze({ id: local.id, class: Object.freeze({ ...local.class }) });
144
+ if (local.kind === 'any')
145
+ return Object.freeze({ id: local.id, kind: 'any' });
146
+ return Object.freeze({ id: local.id, kind: 'classes', classes: normalizeClasses(local.classes) });
147
+ }
148
+ function normalizeClasses(input) {
149
+ const classes = new Map(input.map((ref) => [classKey(ref), Object.freeze({ ...ref })]));
150
+ return Object.freeze([...classes.entries()].sort(([left], [right]) => compare(left, right)).map(([, ref]) => ref));
151
+ }
152
+ function classKey(ref) {
153
+ return `${ref.origin}:${ref.kind}.${ref.name}`;
132
154
  }
133
155
  function compare(left, right) {
134
156
  return left < right ? -1 : left > right ? 1 : 0;
@@ -0,0 +1,8 @@
1
+ import { type AuthorityExpr, type AuthorityPredicate } from './language/index.js';
2
+ /** Called only by the owner after detachment, admission and immutable normalization. */
3
+ export declare function ownCanonical(predicate: AuthorityPredicate): AuthorityPredicate;
4
+ /** Closed subprograms retain their lexical proof when composed outside another local binder. */
5
+ export declare function ownsExpression(expression: unknown, remainingDepth?: number): boolean;
6
+ /** Rewrap only owner-proven closed expressions, never a leaf borrowed from a lexical binder. */
7
+ export declare function ownedExpression(expression: AuthorityExpr): AuthorityPredicate | undefined;
8
+ export declare function ownsCanonical(input: unknown): boolean;
@@ -0,0 +1,83 @@
1
+ import * as portable from '@astrale-os/kernel-dsl/value';
2
+ import { AUTHORITY_PREDICATE_VERSION, } from './language/index.js';
3
+ // Static construction provenance only. No evaluated authority or graph facts live here.
4
+ const canonical = new WeakSet();
5
+ const expressions = new WeakMap();
6
+ const depths = new WeakMap();
7
+ /** Called only by the owner after detachment, admission and immutable normalization. */
8
+ export function ownCanonical(predicate) {
9
+ // Carry immutable structural provenance through containing Plans as well as Core calls.
10
+ // The normalized envelope can exceed a portable boundary's default budget even when the
11
+ // constructor's expression fits. In that case retain Core ownership only: a later crossing
12
+ // still applies its own limits, without adding a new constructor failure here.
13
+ try {
14
+ predicate = Object.freeze({
15
+ ...predicate,
16
+ predicate: portable.acceptImmutable(predicate.predicate),
17
+ });
18
+ predicate = portable.acceptImmutable(predicate);
19
+ }
20
+ catch (cause) {
21
+ if (!(cause instanceof portable.BoundaryError) || cause.code !== 'VALUE_LIMIT')
22
+ throw cause;
23
+ }
24
+ canonical.add(predicate);
25
+ retainClosedExpression(predicate.predicate);
26
+ expressions.set(predicate.predicate, predicate);
27
+ return predicate;
28
+ }
29
+ /** Closed subprograms retain their lexical proof when composed outside another local binder. */
30
+ export function ownsExpression(expression, remainingDepth = Infinity) {
31
+ if (expression === null ||
32
+ typeof expression !== 'object' ||
33
+ !expressions.has(expression))
34
+ return false;
35
+ if (remainingDepth === Infinity)
36
+ return true;
37
+ const value = expression;
38
+ return expressionDepth(value) <= remainingDepth;
39
+ }
40
+ function expressionDepth(expression) {
41
+ const known = depths.get(expression);
42
+ if (known !== undefined)
43
+ return known;
44
+ const children = expression.op === 'all' || expression.op === 'any'
45
+ ? expression.predicates
46
+ : expression.op === 'not'
47
+ ? [expression.predicate]
48
+ : expression.op === 'as' || expression.op === 'exists'
49
+ ? [expression.where]
50
+ : [];
51
+ const depth = children.length === 0 ? 0 : 1 + Math.max(...children.map(expressionDepth));
52
+ depths.set(expression, depth);
53
+ return depth;
54
+ }
55
+ /** Rewrap only owner-proven closed expressions, never a leaf borrowed from a lexical binder. */
56
+ export function ownedExpression(expression) {
57
+ const known = expressions.get(expression);
58
+ if (known === undefined)
59
+ return undefined;
60
+ if (known !== null)
61
+ return known;
62
+ const predicate = ownCanonical(Object.freeze({
63
+ version: AUTHORITY_PREDICATE_VERSION,
64
+ predicate: expression,
65
+ }));
66
+ expressions.set(expression, predicate);
67
+ return predicate;
68
+ }
69
+ function retainClosedExpression(expression) {
70
+ if (expressions.has(expression))
71
+ return;
72
+ expressions.set(expression, null);
73
+ if (expression.op === 'all' || expression.op === 'any') {
74
+ for (const child of expression.predicates)
75
+ retainClosedExpression(child);
76
+ }
77
+ else if (expression.op === 'not')
78
+ retainClosedExpression(expression.predicate);
79
+ // An identity binder or existential is closed, but its body may depend on its binder.
80
+ }
81
+ export function ownsCanonical(input) {
82
+ return input !== null && typeof input === 'object' && canonical.has(input);
83
+ }
@@ -0,0 +1,4 @@
1
+ import type { IdentityId } from '../identity/index.js';
2
+ import type { AuthorityExpr, AuthorityPredicate } from './language/index.js';
3
+ /** Prepare one body in a fresh subject scope, independently of the Identity it will bind. */
4
+ export declare function prepareBinderBody(where: AuthorityExpr): (identity: IdentityId) => AuthorityPredicate;
@@ -0,0 +1,31 @@
1
+ import * as portable from '@astrale-os/kernel-dsl/value';
2
+ import { isNodeId } from '../../graph/node/index.js';
3
+ import { AuthValueError } from '../error.js';
4
+ import { admitBinderBody } from './admission/index.js';
5
+ import { AUTHORITY_PREDICATE_VERSION } from './language/index.js';
6
+ import { normalizeBinderBodyAdmitted } from './normalization/index.js';
7
+ import { ownCanonical } from './ownership.optimization.js';
8
+ /** Prepare one body in a fresh subject scope, independently of the Identity it will bind. */
9
+ export function prepareBinderBody(where) {
10
+ const admitted = admitBinderBody(portable.acceptForRead(where));
11
+ const body = portable.acceptImmutable(normalizeBinderBodyAdmitted(admitted));
12
+ return identityBinder(body);
13
+ }
14
+ // A distinct closure scope retains only the normalized body, never an initial Identity or input.
15
+ function identityBinder(where) {
16
+ return (identity) => {
17
+ // Charge the entire expression on every binding, including the body and its outer container.
18
+ const value = portable.acceptForRead({ op: 'as', identity, where });
19
+ return ownCanonical(Object.freeze({
20
+ version: AUTHORITY_PREDICATE_VERSION,
21
+ predicate: Object.freeze({ op: 'as', identity: identityOf(value.identity), where }),
22
+ }));
23
+ };
24
+ }
25
+ // The same failure ordinary canonicalization reports for a malformed binder Identity.
26
+ function identityOf(input) {
27
+ if (!isNodeId(input)) {
28
+ throw new AuthValueError('AUTHORITY_PREDICATE_INVALID', 'Expected one canonical IdentityId', '/predicate/identity');
29
+ }
30
+ return input;
31
+ }
@@ -0,0 +1,28 @@
1
+ import type { ClassRef } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ import type { AuthorityPredicate } from './language/index.js';
3
+ import { type AuthorityProgram, type PredicateRef } from './language/index.js';
4
+ /** Collect one plan's predicates, then close them into one canonical program. */
5
+ export interface AuthorityProgramBuilder {
6
+ /**
7
+ * Reserve a provisional handle. A thunk is compiled only when `finish` selects its handle, so a
8
+ * planner may reserve programs for positions it later drops.
9
+ */
10
+ intern(predicate: AuthorityPredicate | (() => AuthorityPredicate)): PredicateRef;
11
+ /** Close over the used handles (every reserved handle by default); the builder then closes. */
12
+ finish(used?: Iterable<PredicateRef>): ClosedAuthorityProgram;
13
+ }
14
+ export interface ClosedAuthorityProgram {
15
+ readonly program: AuthorityProgram;
16
+ /** Final ordinal of one used provisional handle. Equal predicates share one ordinal. */
17
+ ref(handle: PredicateRef): PredicateRef;
18
+ }
19
+ /**
20
+ * Start one plan's program over the concrete Identity Classes Runtime closed from the pinned
21
+ * Registry. Equal predicate sets always close to equal programs: members are canonical, unique and
22
+ * sorted by their canonical JSON text, so equal meaning yields equal plans.
23
+ */
24
+ export declare function createAuthorityProgram(identities: readonly ClassRef[]): AuthorityProgramBuilder;
25
+ /** Re-admit one crossing or persisted program; an owned program is returned as is. */
26
+ export declare function acceptProgram(input: unknown): AuthorityProgram;
27
+ /** True exactly for an in-range ordinal of `program`. */
28
+ export declare function isPredicateRef(program: AuthorityProgram, value: unknown): value is PredicateRef;
@@ -0,0 +1,191 @@
1
+ import { patterns } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ import * as portable from '@astrale-os/kernel-dsl/value';
3
+ import { AuthValueError } from '../error.js';
4
+ import { accept } from './accept.js';
5
+ import { AUTHORITY_PREDICATE_VERSION, AUTHORITY_PROGRAM_VERSION, } from './language/index.js';
6
+ import { ownsCanonical } from './ownership.optimization.js';
7
+ /** Programs closed by this owner; admission of an owned program is an identity check. */
8
+ const owned = new WeakSet();
9
+ /**
10
+ * Start one plan's program over the concrete Identity Classes Runtime closed from the pinned
11
+ * Registry. Equal predicate sets always close to equal programs: members are canonical, unique and
12
+ * sorted by their canonical JSON text, so equal meaning yields equal plans.
13
+ */
14
+ export function createAuthorityProgram(identities) {
15
+ const classes = canonicalIdentities(identities);
16
+ const entries = [];
17
+ const handles = new Map();
18
+ let closed = false;
19
+ return Object.freeze({
20
+ intern(predicate) {
21
+ if (closed)
22
+ throw new TypeError('Authority program is already closed.');
23
+ let handle = handles.get(predicate);
24
+ if (handle === undefined) {
25
+ handle = entries.length;
26
+ entries.push(predicate);
27
+ handles.set(predicate, handle);
28
+ }
29
+ return handle;
30
+ },
31
+ finish(used) {
32
+ if (closed)
33
+ throw new TypeError('Authority program is already closed.');
34
+ closed = true;
35
+ const selected = new Set(used ?? entries.keys());
36
+ const keys = new Map();
37
+ const members = new Map();
38
+ for (const handle of [...selected].sort((left, right) => left - right)) {
39
+ const entry = entries[handle];
40
+ if (entry === undefined)
41
+ throw new TypeError('Unknown provisional Authority handle.');
42
+ const value = typeof entry === 'function' ? entry() : entry;
43
+ const predicate = ownsCanonical(value) ? value : accept(value);
44
+ const key = portable.json.serializeAdmitted(predicate.predicate);
45
+ keys.set(handle, key);
46
+ if (!members.has(key))
47
+ members.set(key, predicate.predicate);
48
+ }
49
+ const sorted = [...members.keys()].sort(compare);
50
+ const ordinals = new Map(sorted.map((key, ordinal) => [key, ordinal]));
51
+ const program = own({
52
+ version: AUTHORITY_PROGRAM_VERSION,
53
+ identities: classes,
54
+ predicates: Object.freeze(sorted.map((key) => members.get(key))),
55
+ });
56
+ return Object.freeze({
57
+ program,
58
+ ref(handle) {
59
+ const key = keys.get(handle);
60
+ if (key === undefined)
61
+ throw new TypeError('Authority handle was not closed.');
62
+ return ordinals.get(key);
63
+ },
64
+ });
65
+ },
66
+ });
67
+ }
68
+ /** Re-admit one crossing or persisted program; an owned program is returned as is. */
69
+ export function acceptProgram(input) {
70
+ if (input !== null && typeof input === 'object' && owned.has(input)) {
71
+ return input;
72
+ }
73
+ try {
74
+ const value = portable.accept(input);
75
+ if (value === null || Array.isArray(value) || typeof value !== 'object') {
76
+ invalid('', 'Expected an authority program object');
77
+ }
78
+ const record = value;
79
+ exact(record, ['identities', 'predicates', 'version'], '');
80
+ if (record.version !== AUTHORITY_PROGRAM_VERSION) {
81
+ invalid('/version', `Unsupported authority program version ${String(record.version)}`);
82
+ }
83
+ if (!Array.isArray(record.identities))
84
+ invalid('/identities', 'Expected an array');
85
+ const identities = record.identities.map((entry, index) => identityClass(entry, `/identities/${index}`));
86
+ const keys = identities.map(classKey);
87
+ for (let index = 1; index < keys.length; index++) {
88
+ if (compare(keys[index - 1], keys[index]) >= 0) {
89
+ invalid(`/identities/${index}`, 'Expected sorted unique Identity Classes');
90
+ }
91
+ }
92
+ if (!Array.isArray(record.predicates))
93
+ invalid('/predicates', 'Expected an array');
94
+ let previous;
95
+ const predicates = record.predicates.map((entry, index) => {
96
+ const path = `/predicates/${index}`;
97
+ let predicate;
98
+ try {
99
+ predicate = accept({ version: AUTHORITY_PREDICATE_VERSION, predicate: entry });
100
+ }
101
+ catch (cause) {
102
+ const pointer = cause instanceof AuthValueError ? cause.path.replace(/^\/predicate/u, '') : '';
103
+ throw new AuthValueError('AUTHORITY_PROGRAM_INVALID', 'Expected a canonical predicate', `${path}${pointer}`, {
104
+ cause,
105
+ });
106
+ }
107
+ const key = portable.json.serializeAdmitted(predicate.predicate);
108
+ if (key !== portable.json.serializeAdmitted(entry)) {
109
+ invalid(path, 'Expected a canonical predicate');
110
+ }
111
+ if (previous !== undefined && compare(previous, key) >= 0) {
112
+ invalid(path, 'Expected sorted unique predicates');
113
+ }
114
+ previous = key;
115
+ return predicate.predicate;
116
+ });
117
+ return own({
118
+ version: AUTHORITY_PROGRAM_VERSION,
119
+ identities: Object.freeze(identities),
120
+ predicates: Object.freeze(predicates),
121
+ });
122
+ }
123
+ catch (cause) {
124
+ if (cause instanceof AuthValueError && cause.code === 'AUTHORITY_PROGRAM_INVALID')
125
+ throw cause;
126
+ const path = cause instanceof portable.BoundaryError ? cause.pointer : '';
127
+ throw new AuthValueError('AUTHORITY_PROGRAM_INVALID', 'Expected a canonical authority program', path, {
128
+ cause,
129
+ });
130
+ }
131
+ }
132
+ /**
133
+ * Retain the portable owner's immutable proof when the program fits its default bounds, so a
134
+ * read-only containing Plan capture keeps this identity; otherwise retain Core ownership only.
135
+ */
136
+ function own(value) {
137
+ let program = Object.freeze(value);
138
+ try {
139
+ program = portable.acceptImmutable(program);
140
+ }
141
+ catch (cause) {
142
+ if (!(cause instanceof portable.BoundaryError) || cause.code !== 'VALUE_LIMIT')
143
+ throw cause;
144
+ }
145
+ owned.add(program);
146
+ return program;
147
+ }
148
+ /** True exactly for an in-range ordinal of `program`. */
149
+ export function isPredicateRef(program, value) {
150
+ return (Number.isSafeInteger(value) &&
151
+ value >= 0 &&
152
+ value < program.predicates.length);
153
+ }
154
+ function canonicalIdentities(input) {
155
+ const classes = new Map();
156
+ input.forEach((ref, index) => {
157
+ const value = identityClass(ref, `/identities/${index}`);
158
+ classes.set(classKey(value), value);
159
+ });
160
+ return Object.freeze([...classes.entries()].sort(([left], [right]) => compare(left, right)).map(([, ref]) => ref));
161
+ }
162
+ function identityClass(input, path) {
163
+ if (input === null || Array.isArray(input) || typeof input !== 'object') {
164
+ invalid(path, 'Expected a Class reference');
165
+ }
166
+ const value = input;
167
+ exact(value, ['kind', 'name', 'origin'], path);
168
+ if (value.kind !== 'class' ||
169
+ typeof value.origin !== 'string' ||
170
+ !patterns.origin.test(value.origin) ||
171
+ typeof value.name !== 'string' ||
172
+ !patterns.memberName.test(value.name)) {
173
+ invalid(path, 'Expected a canonical Class reference');
174
+ }
175
+ return Object.freeze({ origin: value.origin, kind: 'class', name: value.name });
176
+ }
177
+ function classKey(ref) {
178
+ return `${ref.origin}:${ref.kind}.${ref.name}`;
179
+ }
180
+ function exact(value, expected, path) {
181
+ const actual = Object.keys(value).sort(compare);
182
+ if (actual.length !== expected.length || actual.some((key, index) => key !== expected[index])) {
183
+ invalid(path, `Expected exactly ${expected.join(', ')}`);
184
+ }
185
+ }
186
+ function compare(left, right) {
187
+ return left < right ? -1 : left > right ? 1 : 0;
188
+ }
189
+ function invalid(path, message) {
190
+ throw new AuthValueError('AUTHORITY_PROGRAM_INVALID', message, path);
191
+ }
@@ -0,0 +1,8 @@
1
+ import type { AuthorityExpr, Requirement } from '../language/index.js';
2
+ import type { AuthorityVocabulary } from './vocabulary.js';
3
+ /**
4
+ * The meaning of `class-authority`. `owner` holds when the identity is the Domain that declares
5
+ * the Class. `allowed` holds for that owner, or when a capability Edge for the operation leads
6
+ * from the identity to the Class projection.
7
+ */
8
+ export declare function classAuthorityMeaning(requirement: Requirement, vocabulary: AuthorityVocabulary): AuthorityExpr;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The meaning of `class-authority`. `owner` holds when the identity is the Domain that declares
3
+ * the Class. `allowed` holds for that owner, or when a capability Edge for the operation leads
4
+ * from the identity to the Class projection.
5
+ */
6
+ export function classAuthorityMeaning(requirement, vocabulary) {
7
+ const owner = {
8
+ op: 'same-node',
9
+ left: requirement.identity,
10
+ right: { kind: 'domain', origin: requirement.class.origin },
11
+ };
12
+ if (requirement.evidence === 'owner')
13
+ return owner;
14
+ return {
15
+ op: 'any',
16
+ predicates: [
17
+ owner,
18
+ {
19
+ op: 'related',
20
+ source: requirement.identity,
21
+ via: [vocabulary.capabilities[requirement.operation]],
22
+ target: { kind: 'class', ref: requirement.class },
23
+ },
24
+ ],
25
+ };
26
+ }
@@ -0,0 +1,39 @@
1
+ import type { NodeId } from '../../../graph/node/index.js';
2
+ import type { ClassRef } from '../language/index.js';
3
+ import type { AuthoritySnapshot } from './snapshot.js';
4
+ import type { AuthorityVocabulary } from './vocabulary.js';
5
+ /** Ceilings a backend places on one binder's composition; overflow is a failure, never false. */
6
+ export interface CompositionLimits {
7
+ readonly compositionNodes: number;
8
+ readonly compositionEdges: number;
9
+ }
10
+ /**
11
+ * Composed status of one Identity. `full` is the complete truth, `positive` ignores exclusions,
12
+ * and `denied` records an exclusion that was reached in positive position.
13
+ */
14
+ export interface CompositionStatus {
15
+ readonly full: boolean;
16
+ readonly positive: boolean;
17
+ readonly denied: boolean;
18
+ }
19
+ /** One binder's live composition: every Identity reachable from its root. */
20
+ export interface CompositionClosure {
21
+ readonly root: NodeId;
22
+ /** Closure members, root first, in breadth-first order. */
23
+ readonly identities: readonly NodeId[];
24
+ /** False when the closure contains a cycle; the binder is then false. */
25
+ readonly acyclic: boolean;
26
+ /**
27
+ * Fold the closure children first from one leaf decision per member. Every member's leaf is
28
+ * decided. Undefined when the closure is cyclic.
29
+ */
30
+ status(leaf: (identity: NodeId) => boolean): CompositionStatus | undefined;
31
+ }
32
+ /** A binder admits its Identity when its composed status is positive and not denied. */
33
+ export declare function allowed(status: CompositionStatus): boolean;
34
+ /**
35
+ * Close the composition of one binder root: the outgoing `extends_with`, `constrained_by` and
36
+ * `excluded_from` Edges, followed transitively. The root must be live and every member must have a
37
+ * concrete Identity Class of `identities`; otherwise the composition is invalid, not false.
38
+ */
39
+ export declare function closeComposition(root: NodeId, snapshot: AuthoritySnapshot, vocabulary: AuthorityVocabulary, identities: readonly ClassRef[], limits?: CompositionLimits): CompositionClosure;
@@ -0,0 +1,112 @@
1
+ import { AuthorityFailure } from './failure.js';
2
+ /** A binder admits its Identity when its composed status is positive and not denied. */
3
+ export function allowed(status) {
4
+ return status.positive && !status.denied;
5
+ }
6
+ /**
7
+ * Close the composition of one binder root: the outgoing `extends_with`, `constrained_by` and
8
+ * `excluded_from` Edges, followed transitively. The root must be live and every member must have a
9
+ * concrete Identity Class of `identities`; otherwise the composition is invalid, not false.
10
+ */
11
+ export function closeComposition(root, snapshot, vocabulary, identities, limits) {
12
+ const allowedClasses = new Set(identities.map(classKey));
13
+ const { extension, constraint, exclusion } = vocabulary.composition;
14
+ const members = [];
15
+ const ordinals = new Map();
16
+ const children = [];
17
+ let edges = 0;
18
+ const admit = (id) => {
19
+ let ordinal = ordinals.get(id);
20
+ if (ordinal !== undefined)
21
+ return ordinal;
22
+ const node = snapshot.node(id);
23
+ if (node === undefined) {
24
+ throw new AuthorityFailure('AUTHORITY_COMPOSITION_INVALID', 'An Identity binder names no live Node.', { identity: id });
25
+ }
26
+ if (!allowedClasses.has(classKey(node.class))) {
27
+ throw new AuthorityFailure('AUTHORITY_COMPOSITION_INVALID', 'An Identity composition reaches a Node that is not an Identity.', { identity: id });
28
+ }
29
+ ordinal = members.length;
30
+ if (limits !== undefined && ordinal >= limits.compositionNodes) {
31
+ throw new AuthorityFailure('AUTHORITY_BUDGET_EXCEEDED', 'An Identity composition exceeds its Node ceiling.', { root, limit: limits.compositionNodes });
32
+ }
33
+ members.push(id);
34
+ ordinals.set(id, ordinal);
35
+ children.push({ extensions: [], constraints: [], exclusions: [] });
36
+ return ordinal;
37
+ };
38
+ admit(root);
39
+ for (let next = 0; next < members.length; next++) {
40
+ const id = members[next];
41
+ const row = children[next];
42
+ const follow = (edge, bucket) => {
43
+ for (const child of snapshot.edges(id, edge, 'out')) {
44
+ edges += 1;
45
+ if (limits !== undefined && edges > limits.compositionEdges) {
46
+ throw new AuthorityFailure('AUTHORITY_BUDGET_EXCEEDED', 'An Identity composition exceeds its Edge ceiling.', { root, limit: limits.compositionEdges });
47
+ }
48
+ bucket.push(admit(child));
49
+ }
50
+ };
51
+ follow(extension, row.extensions);
52
+ follow(constraint, row.constraints);
53
+ follow(exclusion, row.exclusions);
54
+ }
55
+ const order = childrenFirst(children);
56
+ const acyclic = order.length === members.length;
57
+ return Object.freeze({
58
+ root,
59
+ identities: Object.freeze(members),
60
+ acyclic,
61
+ status(leaf) {
62
+ if (!acyclic)
63
+ return undefined;
64
+ const values = [];
65
+ // Iterative in the dependency order, so a deep valid composition needs no call stack.
66
+ for (const ordinal of order) {
67
+ const row = children[ordinal];
68
+ const truth = leaf(members[ordinal]);
69
+ const full = (child) => values[child].full;
70
+ const positive = (child) => values[child].positive;
71
+ const denied = (child) => values[child].denied;
72
+ values[ordinal] = Object.freeze({
73
+ full: (truth || row.extensions.some(full)) &&
74
+ row.constraints.every(full) &&
75
+ !row.exclusions.some(full),
76
+ positive: (truth || row.extensions.some(positive)) && row.constraints.every(positive),
77
+ denied: row.exclusions.some(full) ||
78
+ row.extensions.some(denied) ||
79
+ row.constraints.some(denied),
80
+ });
81
+ }
82
+ return values[0];
83
+ },
84
+ });
85
+ }
86
+ /** Kahn order over the closure; shorter than the closure exactly when it contains a cycle. */
87
+ function childrenFirst(children) {
88
+ const parents = children.map(() => []);
89
+ const pending = new Uint32Array(children.length);
90
+ children.forEach((row, ordinal) => {
91
+ const dependencies = new Set([...row.extensions, ...row.constraints, ...row.exclusions]);
92
+ pending[ordinal] = dependencies.size;
93
+ for (const child of dependencies)
94
+ parents[child].push(ordinal);
95
+ });
96
+ const order = [];
97
+ pending.forEach((count, ordinal) => {
98
+ if (count === 0)
99
+ order.push(ordinal);
100
+ });
101
+ for (let next = 0; next < order.length; next++) {
102
+ for (const parent of parents[order[next]]) {
103
+ pending[parent] = pending[parent] - 1;
104
+ if (pending[parent] === 0)
105
+ order.push(parent);
106
+ }
107
+ }
108
+ return order;
109
+ }
110
+ function classKey(ref) {
111
+ return `${ref.origin}:${ref.kind}.${ref.name}`;
112
+ }