@astrale-os/sdk 0.6.0-beta.5 → 0.6.0-beta.50

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 (651) hide show
  1. package/README.md +213 -60
  2. package/dist/application/action/action.d.ts +6 -0
  3. package/dist/application/action/authoring.d.ts +1 -1
  4. package/dist/application/action/context.d.ts +81 -33
  5. package/dist/application/action/define.d.ts +3 -3
  6. package/dist/application/action/index.d.ts +1 -1
  7. package/dist/application/define.d.ts +8 -6
  8. package/dist/application/define.js +28 -14
  9. package/dist/application/dependency/index.d.ts +1 -1
  10. package/dist/application/dependency/invoker.d.ts +21 -10
  11. package/dist/application/domain.d.ts +30 -0
  12. package/dist/application/error/error.d.ts +16 -1
  13. package/dist/application/error/error.js +39 -5
  14. package/dist/application/error/index.d.ts +1 -1
  15. package/dist/application/error/index.js +1 -1
  16. package/dist/application/index.d.ts +4 -4
  17. package/dist/application/index.js +1 -1
  18. package/dist/application/integration/define.d.ts +8 -1
  19. package/dist/application/integration/index.d.ts +2 -2
  20. package/dist/application/integration/integration.d.ts +13 -1
  21. package/dist/application/integration/operation.d.ts +16 -3
  22. package/dist/application/mutation/authoring/builder.d.ts +81 -33
  23. package/dist/application/mutation/authoring/builder.js +100 -30
  24. package/dist/application/mutation/authoring/guard.d.ts +37 -0
  25. package/dist/application/mutation/authoring/guard.js +150 -0
  26. package/dist/application/mutation/authoring/index.d.ts +5 -2
  27. package/dist/application/mutation/authoring/index.js +2 -1
  28. package/dist/application/mutation/authoring/names.d.ts +19 -0
  29. package/dist/application/mutation/authoring/names.js +83 -0
  30. package/dist/application/mutation/authoring/properties.d.ts +5 -3
  31. package/dist/application/mutation/authoring/properties.js +35 -2
  32. package/dist/application/mutation/authoring/transition.d.ts +3 -2
  33. package/dist/application/mutation/authoring/transition.js +4 -1
  34. package/dist/application/mutation/define.d.ts +24 -10
  35. package/dist/application/mutation/define.js +49 -53
  36. package/dist/application/mutation/execution/execute.d.ts +2 -2
  37. package/dist/application/mutation/execution/execute.js +78 -7
  38. package/dist/application/mutation/execution/executor.d.ts +4 -1
  39. package/dist/application/mutation/execution/executor.js +6 -1
  40. package/dist/application/mutation/failure.d.ts +17 -1
  41. package/dist/application/mutation/failure.js +40 -19
  42. package/dist/application/mutation/index.d.ts +9 -5
  43. package/dist/application/mutation/index.js +5 -2
  44. package/dist/application/mutation/legacy/v6/builder.d.ts +84 -0
  45. package/dist/application/mutation/legacy/v6/define.d.ts +18 -0
  46. package/dist/application/mutation/legacy/v6/define.js +56 -0
  47. package/dist/application/mutation/legacy/v6/mutation.d.ts +28 -0
  48. package/dist/application/mutation/{authoring → legacy/v6}/precondition.d.ts +4 -0
  49. package/dist/application/mutation/mutation.d.ts +47 -19
  50. package/dist/application/query/answer/answer.d.ts +117 -0
  51. package/dist/application/query/answer/conformance.d.ts +4 -0
  52. package/dist/application/query/answer/conformance.js +27 -0
  53. package/dist/application/query/answer/facts.d.ts +17 -0
  54. package/dist/application/query/answer/facts.js +57 -0
  55. package/dist/application/query/composite/builder.d.ts +1 -1
  56. package/dist/application/query/composite/builder.js +2 -2
  57. package/dist/application/query/composite/plan.d.ts +1 -5
  58. package/dist/application/query/composite/plan.js +1 -3
  59. package/dist/application/query/composite/query.d.ts +1 -2
  60. package/dist/application/query/define.d.ts +3 -34
  61. package/dist/application/query/define.js +5 -131
  62. package/dist/application/query/defined/define.d.ts +45 -0
  63. package/dist/application/query/defined/define.js +96 -0
  64. package/dist/application/query/defined/query.d.ts +139 -0
  65. package/dist/application/query/definition.d.ts +12 -0
  66. package/dist/application/query/definition.js +47 -0
  67. package/dist/application/query/execution/bounds.d.ts +22 -0
  68. package/dist/application/query/execution/bounds.js +88 -0
  69. package/dist/application/query/execution/client.d.ts +21 -0
  70. package/dist/application/query/execution/crossings.d.ts +25 -0
  71. package/dist/application/query/execution/crossings.js +192 -0
  72. package/dist/application/query/execution/error.d.ts +71 -0
  73. package/dist/application/query/execution/error.js +50 -0
  74. package/dist/application/query/execution/execute.d.ts +4 -10
  75. package/dist/application/query/execution/execute.js +3 -45
  76. package/dist/application/query/execution/executor.d.ts +2 -2
  77. package/dist/application/query/execution/refusal.d.ts +37 -0
  78. package/dist/application/query/execution/refusal.js +80 -0
  79. package/dist/application/query/execution/rows.d.ts +42 -0
  80. package/dist/application/query/execution/rows.js +320 -0
  81. package/dist/application/query/execution/run.d.ts +75 -0
  82. package/dist/application/query/execution/run.js +328 -0
  83. package/dist/application/query/execution/split.d.ts +24 -0
  84. package/dist/application/query/execution/split.js +190 -0
  85. package/dist/application/query/failure.d.ts +8 -0
  86. package/dist/application/query/failure.js +8 -0
  87. package/dist/application/query/handles/build.d.ts +10 -0
  88. package/dist/application/query/handles/build.js +53 -0
  89. package/dist/application/query/handles/conditions.d.ts +94 -0
  90. package/dist/application/query/handles/domain.d.ts +157 -0
  91. package/dist/application/query/handles/handles.d.ts +271 -0
  92. package/dist/application/query/handles/handles.js +1 -0
  93. package/dist/application/query/handles/model.d.ts +106 -0
  94. package/dist/application/query/handles/model.js +261 -0
  95. package/dist/application/query/handles/plan.d.ts +100 -0
  96. package/dist/application/query/handles/plan.js +37 -0
  97. package/dist/application/query/handles/reads.d.ts +106 -0
  98. package/dist/application/query/handles/reads.js +971 -0
  99. package/dist/application/query/handles/relations.d.ts +106 -0
  100. package/dist/application/query/handles/relations.js +1 -0
  101. package/dist/application/query/handles/rows.d.ts +94 -0
  102. package/dist/application/query/handles/rows.js +4 -0
  103. package/dist/application/query/handles/terms.d.ts +103 -0
  104. package/dist/application/query/handles/terms.js +282 -0
  105. package/dist/application/query/index.d.ts +14 -8
  106. package/dist/application/query/index.js +10 -5
  107. package/dist/application/query/language/index.d.ts +2 -0
  108. package/dist/application/query/language/index.js +2 -0
  109. package/dist/application/query/language/query.d.ts +323 -0
  110. package/dist/application/query/language/query.js +2 -0
  111. package/dist/application/query/{collection → legacy/v6/collection}/identity.d.ts +2 -2
  112. package/dist/application/query/{collection → legacy/v6/collection}/metadata.d.ts +1 -1
  113. package/dist/application/query/{collection → legacy/v6/collection}/union.d.ts +4 -4
  114. package/dist/application/query/{collection → legacy/v6/collection}/union.js +15 -8
  115. package/dist/application/query/legacy/v6/conformance.d.ts +15 -0
  116. package/dist/application/query/legacy/v6/conformance.js +46 -0
  117. package/dist/application/query/legacy/v6/define.d.ts +37 -0
  118. package/dist/application/query/legacy/v6/define.js +90 -0
  119. package/dist/application/query/legacy/v6/execution/execute.d.ts +18 -0
  120. package/dist/application/query/legacy/v6/execution/execute.js +50 -0
  121. package/dist/application/query/legacy/v6/index.d.ts +7 -0
  122. package/dist/application/query/legacy/v6/index.js +3 -0
  123. package/dist/application/query/legacy/v6/kernel.d.ts +6 -0
  124. package/dist/application/query/legacy/v6/kernel.js +5 -0
  125. package/dist/application/query/{single → legacy/v6/single}/pagination.js +1 -1
  126. package/dist/application/query/{single → legacy/v6/single}/query.d.ts +2 -14
  127. package/dist/application/query/legacy/v6/single/query.js +1 -0
  128. package/dist/application/query/query.d.ts +19 -4
  129. package/dist/application/routes/admission.d.ts +3 -3
  130. package/dist/application/routes/admission.js +3 -3
  131. package/dist/application/routes/index.d.ts +3 -2
  132. package/dist/application/routes/route.d.ts +3 -3
  133. package/dist/application/runtime/actions.js +3 -0
  134. package/dist/application/runtime/declarations.d.ts +6 -6
  135. package/dist/application/runtime/define.d.ts +5 -5
  136. package/dist/application/runtime/workflows.d.ts +3 -1
  137. package/dist/application/runtime/workflows.js +3 -4
  138. package/dist/application/view/define.js +4 -6
  139. package/dist/application/view/frontend.d.ts +2 -2
  140. package/dist/application/view/index.d.ts +1 -1
  141. package/dist/application/view/route.d.ts +0 -14
  142. package/dist/application/view/route.js +1 -64
  143. package/dist/application/workflow/authoring.d.ts +3 -2
  144. package/dist/application/workflow/context.d.ts +8 -2
  145. package/dist/application/workflow/define.d.ts +4 -4
  146. package/dist/application/workflow/define.js +14 -9
  147. package/dist/application/workflow/durable.d.ts +211 -0
  148. package/dist/application/workflow/durable.js +1 -0
  149. package/dist/application/workflow/index.d.ts +3 -2
  150. package/dist/application/workflow/runner/inline.js +3 -4
  151. package/dist/application/workflow/runner/runner.d.ts +2 -2
  152. package/dist/application/workflow/step/output.d.ts +2 -0
  153. package/dist/application/workflow/step/output.js +73 -0
  154. package/dist/application/workflow/workflow.d.ts +5 -3
  155. package/dist/deployment/adapter/adapter.d.ts +55 -13
  156. package/dist/deployment/adapter/bundle/bundle.d.ts +36 -0
  157. package/dist/deployment/adapter/bundle/bundle.js +1 -0
  158. package/dist/deployment/adapter/bundle/file.d.ts +10 -0
  159. package/dist/deployment/adapter/bundle/file.js +1 -0
  160. package/dist/deployment/adapter/bundle/index.d.ts +2 -0
  161. package/dist/deployment/adapter/bundle/index.js +1 -0
  162. package/dist/deployment/adapter/define.d.ts +4 -3
  163. package/dist/deployment/adapter/define.js +107 -23
  164. package/dist/deployment/adapter/index.d.ts +4 -3
  165. package/dist/deployment/adapter/index.js +1 -0
  166. package/dist/deployment/adapter/release/command.d.ts +33 -0
  167. package/dist/deployment/adapter/release/command.js +1 -0
  168. package/dist/deployment/adapter/release/context.d.ts +94 -0
  169. package/dist/deployment/adapter/release/context.js +1 -0
  170. package/dist/deployment/adapter/release/index.d.ts +4 -0
  171. package/dist/deployment/adapter/release/index.js +1 -0
  172. package/dist/deployment/adapter/release/list.d.ts +53 -0
  173. package/dist/deployment/adapter/release/list.js +1 -0
  174. package/dist/deployment/adapter/release/refusal.d.ts +10 -0
  175. package/dist/deployment/adapter/release/refusal.js +14 -0
  176. package/dist/deployment/adapter/release/result.d.ts +56 -0
  177. package/dist/deployment/adapter/release/result.js +1 -0
  178. package/dist/deployment/address/configuration.d.ts +96 -0
  179. package/dist/deployment/address/configuration.js +274 -0
  180. package/dist/deployment/address/fingerprint.d.ts +5 -0
  181. package/dist/deployment/address/fingerprint.js +27 -0
  182. package/dist/deployment/address/index.d.ts +5 -0
  183. package/dist/deployment/address/index.js +4 -0
  184. package/dist/deployment/address/label.d.ts +42 -0
  185. package/dist/deployment/address/label.js +80 -0
  186. package/dist/deployment/address/line.d.ts +29 -0
  187. package/dist/deployment/address/line.js +53 -0
  188. package/dist/deployment/address/record.d.ts +73 -0
  189. package/dist/deployment/address/record.js +138 -0
  190. package/dist/deployment/address/summary.d.ts +30 -0
  191. package/dist/deployment/address/summary.js +1 -0
  192. package/dist/deployment/address/vectors.d.ts +60 -0
  193. package/dist/deployment/address/vectors.js +517 -0
  194. package/dist/deployment/authoring.d.ts +0 -2
  195. package/dist/deployment/authoring.js +0 -1
  196. package/dist/deployment/build/build.d.ts +15 -2
  197. package/dist/deployment/build/compile.d.ts +4 -4
  198. package/dist/deployment/build/compile.js +19 -17
  199. package/dist/deployment/build/frontend/compilation.d.ts +2 -4
  200. package/dist/deployment/build/frontend/compilation.js +0 -5
  201. package/dist/deployment/build/frontend/digest.js +1 -5
  202. package/dist/deployment/build/index.d.ts +1 -0
  203. package/dist/deployment/build/index.js +1 -0
  204. package/dist/deployment/build/manifest.d.ts +59 -0
  205. package/dist/deployment/build/manifest.js +118 -0
  206. package/dist/deployment/build/material.d.ts +2 -2
  207. package/dist/deployment/build/material.js +31 -13
  208. package/dist/deployment/build/schema.d.ts +2 -2
  209. package/dist/deployment/deployment.d.ts +3 -2
  210. package/dist/deployment/environment.d.ts +6 -0
  211. package/dist/deployment/environment.js +6 -0
  212. package/dist/deployment/index.d.ts +4 -6
  213. package/dist/deployment/index.js +1 -2
  214. package/dist/deployment/release/addressing.d.ts +6 -5
  215. package/dist/deployment/release/addressing.js +2 -3
  216. package/dist/deployment/release/assemble.d.ts +6 -3
  217. package/dist/deployment/release/assemble.js +12 -10
  218. package/dist/deployment/release/release.d.ts +16 -5
  219. package/dist/deployment/release/seal.d.ts +14 -0
  220. package/dist/deployment/release/seal.js +22 -0
  221. package/dist/deployment/release/{publication → served}/callables.d.ts +2 -2
  222. package/dist/deployment/release/{publication → served}/callables.js +2 -2
  223. package/dist/deployment/release/served/index.d.ts +11 -0
  224. package/dist/deployment/release/served/index.js +26 -0
  225. package/dist/deployment/release/{publication → served}/views.d.ts +2 -2
  226. package/dist/deployment/release/{publication → served}/views.js +0 -1
  227. package/dist/deployment/runtime/admission.d.ts +2 -2
  228. package/dist/deployment/runtime/admission.js +5 -5
  229. package/dist/deployment/verify/index.d.ts +3 -4
  230. package/dist/deployment/verify/index.js +2 -3
  231. package/dist/deployment/verify/preflight/bundle.d.ts +18 -0
  232. package/dist/deployment/verify/preflight/bundle.js +71 -0
  233. package/dist/deployment/verify/preflight/index.d.ts +1 -12
  234. package/dist/deployment/verify/preflight/index.js +1 -12
  235. package/dist/deployment/verify/readiness/fetch.d.ts +13 -0
  236. package/dist/deployment/verify/readiness/fetch.js +26 -0
  237. package/dist/deployment/verify/readiness/identity.d.ts +3 -6
  238. package/dist/deployment/verify/readiness/identity.js +3 -3
  239. package/dist/deployment/verify/readiness/index.d.ts +15 -8
  240. package/dist/deployment/verify/readiness/index.js +25 -6
  241. package/dist/deployment/verify/readiness/release.d.ts +8 -0
  242. package/dist/deployment/verify/readiness/release.js +22 -0
  243. package/dist/deployment/worker/address.d.ts +26 -0
  244. package/dist/deployment/worker/address.js +43 -0
  245. package/dist/deployment/worker/build.d.ts +60 -0
  246. package/dist/deployment/worker/build.js +172 -0
  247. package/dist/deployment/worker/configuration.d.ts +73 -0
  248. package/dist/deployment/worker/configuration.js +165 -0
  249. package/dist/deployment/worker/content.d.ts +38 -0
  250. package/dist/deployment/worker/content.js +169 -0
  251. package/dist/deployment/worker/index.d.ts +29 -0
  252. package/dist/deployment/worker/index.js +29 -0
  253. package/dist/deployment/worker/limits.d.ts +30 -0
  254. package/dist/deployment/worker/limits.js +30 -0
  255. package/dist/deployment/worker/record.d.ts +29 -0
  256. package/dist/deployment/worker/record.js +69 -0
  257. package/dist/deployment/worker/request.d.ts +118 -0
  258. package/dist/deployment/worker/request.js +280 -0
  259. package/dist/deployment/worker/response.d.ts +101 -0
  260. package/dist/deployment/worker/response.js +207 -0
  261. package/dist/execution/cache/cache.d.ts +17 -0
  262. package/dist/execution/cache/cache.js +11 -0
  263. package/dist/execution/cache/index.d.ts +2 -0
  264. package/dist/execution/cache/index.js +2 -0
  265. package/dist/execution/cache/memory.d.ts +13 -0
  266. package/dist/execution/cache/memory.js +48 -0
  267. package/dist/execution/identity/authentication.d.ts +33 -3
  268. package/dist/execution/identity/authentication.js +90 -36
  269. package/dist/execution/identity/callback.d.ts +20 -20
  270. package/dist/execution/identity/callback.js +34 -26
  271. package/dist/execution/identity/delivery.d.ts +6 -4
  272. package/dist/execution/identity/delivery.js +25 -20
  273. package/dist/execution/identity/identity.d.ts +17 -3
  274. package/dist/execution/identity/identity.js +12 -4
  275. package/dist/execution/identity/jwks.d.ts +5 -0
  276. package/dist/execution/identity/jwks.js +92 -102
  277. package/dist/execution/index.d.ts +6 -4
  278. package/dist/execution/index.js +4 -2
  279. package/dist/execution/invocation/admission/age.d.ts +57 -0
  280. package/dist/execution/invocation/admission/age.js +208 -0
  281. package/dist/execution/invocation/admission/authentication.d.ts +13 -13
  282. package/dist/execution/invocation/admission/authentication.js +52 -44
  283. package/dist/execution/invocation/admission/authority.d.ts +28 -6
  284. package/dist/execution/invocation/admission/authority.js +9 -2
  285. package/dist/execution/invocation/admission/index.d.ts +4 -3
  286. package/dist/execution/invocation/admission/index.js +3 -2
  287. package/dist/execution/invocation/admission/input.d.ts +2 -2
  288. package/dist/execution/invocation/admission/input.js +16 -2
  289. package/dist/execution/invocation/admission/target.d.ts +11 -0
  290. package/dist/execution/invocation/admission/target.js +22 -3
  291. package/dist/execution/invocation/capabilities/bind.d.ts +13 -0
  292. package/dist/execution/invocation/capabilities/bind.js +61 -0
  293. package/dist/execution/invocation/capabilities/index.d.ts +1 -0
  294. package/dist/execution/invocation/capabilities/index.js +1 -0
  295. package/dist/execution/invocation/dependency/bind.d.ts +3 -1
  296. package/dist/execution/invocation/dependency/bind.js +36 -16
  297. package/dist/execution/invocation/dispatch/action.js +4 -2
  298. package/dist/execution/invocation/dispatch/context.d.ts +7 -6
  299. package/dist/execution/invocation/dispatch/context.js +11 -44
  300. package/dist/execution/invocation/dispatch/workflow.js +4 -6
  301. package/dist/execution/invocation/handler.js +8 -2
  302. package/dist/execution/invocation/index.d.ts +2 -2
  303. package/dist/execution/invocation/index.js +1 -1
  304. package/dist/execution/invocation/integration/authentication.d.ts +3 -3
  305. package/dist/execution/invocation/integration/authentication.js +7 -7
  306. package/dist/execution/invocation/integration/call.d.ts +2 -1
  307. package/dist/execution/invocation/integration/call.js +3 -3
  308. package/dist/execution/invocation/integration/clients.d.ts +1 -1
  309. package/dist/execution/invocation/integration/index.d.ts +1 -0
  310. package/dist/execution/invocation/integration/index.js +1 -0
  311. package/dist/execution/invocation/invocation.d.ts +6 -0
  312. package/dist/execution/invocation/invocation.js +129 -21
  313. package/dist/execution/invocation/lifecycle/active.d.ts +8 -2
  314. package/dist/execution/invocation/lifecycle/active.js +3 -3
  315. package/dist/execution/invocation/lifecycle/index.d.ts +1 -1
  316. package/dist/execution/invocation/result/errors.d.ts +0 -10
  317. package/dist/execution/invocation/result/errors.js +4 -16
  318. package/dist/execution/invocation/result/index.d.ts +3 -2
  319. package/dist/execution/invocation/result/index.js +2 -1
  320. package/dist/execution/invocation/result/project.js +41 -1
  321. package/dist/execution/invocation/result/undeclared.d.ts +7 -0
  322. package/dist/execution/invocation/result/undeclared.js +18 -0
  323. package/dist/execution/node/serve.d.ts +2 -2
  324. package/dist/execution/node/serve.js +1 -1
  325. package/dist/execution/runtime/index.d.ts +1 -0
  326. package/dist/execution/runtime/index.js +1 -0
  327. package/dist/execution/runtime/load.d.ts +3 -3
  328. package/dist/execution/runtime/load.js +3 -2
  329. package/dist/execution/runtime/release.d.ts +17 -0
  330. package/dist/execution/runtime/release.js +7 -0
  331. package/dist/execution/serve.d.ts +18 -4
  332. package/dist/execution/serve.js +10 -0
  333. package/dist/execution/service/create.js +44 -7
  334. package/dist/execution/service/initialization.d.ts +4 -4
  335. package/dist/execution/service/initialization.js +23 -14
  336. package/dist/execution/service/release.d.ts +2 -2
  337. package/dist/execution/service/release.js +3 -2
  338. package/dist/execution/service/service.d.ts +20 -5
  339. package/dist/execution/service/serving/delivery.d.ts +5 -0
  340. package/dist/execution/service/{publication → serving}/delivery.js +4 -1
  341. package/dist/execution/service/{publication → serving}/index.d.ts +1 -1
  342. package/dist/execution/service/serving/installation.d.ts +4 -0
  343. package/dist/execution/service/serving/installation.js +9 -0
  344. package/dist/execution/service/serving/source.d.ts +11 -0
  345. package/dist/execution/service/serving/source.js +15 -0
  346. package/dist/execution/workflows/attempts.d.ts +87 -0
  347. package/dist/execution/workflows/attempts.js +205 -0
  348. package/dist/execution/workflows/discovery.d.ts +14 -0
  349. package/dist/execution/workflows/discovery.js +151 -0
  350. package/dist/execution/workflows/engine.d.ts +83 -0
  351. package/dist/execution/workflows/engine.js +1 -0
  352. package/dist/execution/workflows/envelope.d.ts +12 -0
  353. package/dist/execution/workflows/envelope.js +46 -0
  354. package/dist/execution/workflows/failure.d.ts +56 -0
  355. package/dist/execution/workflows/failure.js +204 -0
  356. package/dist/execution/workflows/index.d.ts +4 -0
  357. package/dist/execution/workflows/index.js +3 -0
  358. package/dist/execution/workflows/integrations.d.ts +13 -0
  359. package/dist/execution/workflows/integrations.js +25 -0
  360. package/dist/execution/workflows/options.d.ts +81 -0
  361. package/dist/execution/workflows/options.js +158 -0
  362. package/dist/execution/workflows/receiver.d.ts +27 -0
  363. package/dist/execution/workflows/receiver.js +100 -0
  364. package/dist/execution/workflows/route.d.ts +12 -0
  365. package/dist/execution/workflows/route.js +35 -0
  366. package/dist/execution/workflows/run.d.ts +23 -0
  367. package/dist/execution/workflows/run.js +369 -0
  368. package/dist/execution/workflows/steps.d.ts +51 -0
  369. package/dist/execution/workflows/steps.js +93 -0
  370. package/dist/index.d.ts +4 -4
  371. package/dist/index.js +2 -2
  372. package/dist/platform/graph/alias.d.ts +1 -5
  373. package/dist/platform/graph/alias.js +1 -5
  374. package/dist/platform/graph/document/index.d.ts +1 -1
  375. package/dist/platform/graph/document/index.js +1 -1
  376. package/dist/platform/graph/index.d.ts +1 -1
  377. package/dist/platform/graph/index.js +1 -1
  378. package/dist/platform/release/index.d.ts +2 -0
  379. package/dist/platform/release/index.js +2 -0
  380. package/dist/platform/schema/callable-authoring.d.ts +21 -0
  381. package/dist/platform/schema/callable-authoring.js +27 -0
  382. package/dist/platform/schema/class-authoring.d.ts +56 -12
  383. package/dist/platform/schema/class-authoring.js +37 -4
  384. package/dist/platform/schema/class-icon-svg.d.ts +9 -0
  385. package/dist/platform/schema/class-icon-svg.js +29 -0
  386. package/dist/platform/schema/class-icon.d.ts +3 -8
  387. package/dist/platform/schema/class-icon.js +2 -29
  388. package/dist/platform/schema/index.d.ts +6 -4
  389. package/dist/platform/schema/index.js +2 -1
  390. package/dist/platform/schema/kernel-compiled.d.ts +2 -0
  391. package/dist/platform/schema/kernel-compiled.js +2 -0
  392. package/dist/platform/schema/kernel.d.ts +4 -2
  393. package/dist/platform/schema/property.d.ts +5 -0
  394. package/dist/platform/schema/schema-authoring.d.ts +14 -7
  395. package/dist/platform/schema/schema-authoring.js +5 -1
  396. package/dist/platform/versioning/dependents.d.ts +18 -0
  397. package/dist/platform/versioning/dependents.js +15 -0
  398. package/dist/platform/versioning/index.d.ts +5 -0
  399. package/dist/platform/versioning/index.js +5 -0
  400. package/dist/platform/versioning/name.d.ts +38 -0
  401. package/dist/platform/versioning/name.js +58 -0
  402. package/dist/platform/versioning/reference.d.ts +48 -0
  403. package/dist/platform/versioning/reference.js +95 -0
  404. package/dist/platform/versioning/version.d.ts +72 -0
  405. package/dist/platform/versioning/version.js +98 -0
  406. package/dist/project/admit.js +1 -5
  407. package/dist/project/define.d.ts +4 -4
  408. package/dist/project/define.js +55 -35
  409. package/dist/project/index.d.ts +1 -1
  410. package/dist/project/install-command.d.ts +6 -0
  411. package/dist/project/install-command.js +9 -0
  412. package/dist/project/project.d.ts +10 -8
  413. package/dist/testing/dataset/define.d.ts +1 -1
  414. package/dist/testing/durable/engine.d.ts +128 -0
  415. package/dist/testing/durable/engine.js +619 -0
  416. package/dist/testing/durable/index.d.ts +3 -0
  417. package/dist/testing/durable/index.js +1 -0
  418. package/dist/testing/durable/steps.d.ts +30 -0
  419. package/dist/testing/durable/steps.js +45 -0
  420. package/dist/testing/index.d.ts +8 -1
  421. package/dist/testing/index.js +6 -1
  422. package/dist/testing/load.js +1 -1
  423. package/dist/testing/query.d.ts +17 -0
  424. package/dist/testing/query.js +34 -0
  425. package/dist/tooling/cli/adapter-command.d.ts +35 -0
  426. package/dist/tooling/cli/adapter-command.js +66 -0
  427. package/dist/tooling/cli/arguments.d.ts +17 -6
  428. package/dist/tooling/cli/arguments.js +175 -52
  429. package/dist/tooling/cli/build.d.ts +55 -0
  430. package/dist/tooling/cli/build.js +77 -0
  431. package/dist/tooling/cli/bun.d.ts +0 -1
  432. package/dist/tooling/cli/bun.js +0 -7
  433. package/dist/tooling/cli/commit.d.ts +35 -0
  434. package/dist/tooling/cli/commit.js +235 -0
  435. package/dist/tooling/cli/deploy-mode.d.ts +26 -0
  436. package/dist/tooling/cli/deploy-mode.js +59 -0
  437. package/dist/tooling/cli/deploy-result.d.ts +80 -0
  438. package/dist/tooling/cli/deploy-result.js +64 -0
  439. package/dist/tooling/cli/diff/declared.d.ts +7 -0
  440. package/dist/tooling/cli/diff/declared.js +27 -0
  441. package/dist/tooling/cli/diff/index.d.ts +30 -0
  442. package/dist/tooling/cli/diff/index.js +58 -0
  443. package/dist/tooling/cli/diff/render.d.ts +15 -0
  444. package/dist/tooling/cli/diff/render.js +131 -0
  445. package/dist/tooling/cli/diff/report.d.ts +88 -0
  446. package/dist/tooling/cli/diff/report.js +154 -0
  447. package/dist/tooling/cli/dotenv.d.ts +5 -5
  448. package/dist/tooling/cli/dotenv.js +6 -36
  449. package/dist/tooling/cli/help.js +173 -60
  450. package/dist/tooling/cli/immutable-deployment.d.ts +83 -0
  451. package/dist/tooling/cli/immutable-deployment.js +135 -0
  452. package/dist/tooling/cli/index.d.ts +12 -4
  453. package/dist/tooling/cli/index.js +6 -3
  454. package/dist/tooling/cli/installed-on.d.ts +83 -0
  455. package/dist/tooling/cli/installed-on.js +156 -0
  456. package/dist/tooling/cli/list.d.ts +152 -0
  457. package/dist/tooling/cli/list.js +331 -0
  458. package/dist/tooling/cli/log.d.ts +5 -2
  459. package/dist/tooling/cli/log.js +9 -2
  460. package/dist/tooling/cli/orchestrate.d.ts +0 -6
  461. package/dist/tooling/cli/orchestrate.js +252 -91
  462. package/dist/tooling/cli/project.d.ts +3 -3
  463. package/dist/tooling/cli/publish/index.d.ts +81 -0
  464. package/dist/tooling/cli/publish/index.js +383 -0
  465. package/dist/tooling/cli/publish/report.d.ts +49 -0
  466. package/dist/tooling/cli/publish/report.js +15 -0
  467. package/dist/tooling/cli/registry/client.d.ts +121 -0
  468. package/dist/tooling/cli/registry/client.js +354 -0
  469. package/dist/tooling/cli/registry/error.d.ts +11 -0
  470. package/dist/tooling/cli/registry/error.js +17 -0
  471. package/dist/tooling/cli/registry/executable.d.ts +35 -0
  472. package/dist/tooling/cli/registry/executable.js +96 -0
  473. package/dist/tooling/cli/registry/index.d.ts +9 -0
  474. package/dist/tooling/cli/registry/index.js +8 -0
  475. package/dist/tooling/cli/registry/installations.d.ts +67 -0
  476. package/dist/tooling/cli/registry/installations.js +108 -0
  477. package/dist/tooling/cli/registry/process.d.ts +36 -0
  478. package/dist/tooling/cli/registry/process.js +119 -0
  479. package/dist/tooling/cli/secrets.d.ts +9 -0
  480. package/dist/tooling/cli/secrets.js +19 -0
  481. package/dist/tooling/cli/yank.d.ts +34 -0
  482. package/dist/tooling/cli/yank.js +32 -0
  483. package/dist/tooling/linter/adapters/typescript/definition-calls.d.ts +34 -0
  484. package/dist/tooling/linter/adapters/typescript/definition-calls.js +88 -0
  485. package/dist/tooling/linter/adapters/typescript/imports.d.ts +0 -1
  486. package/dist/tooling/linter/adapters/typescript/imports.js +1 -5
  487. package/dist/tooling/linter/adapters/typescript/index.d.ts +3 -2
  488. package/dist/tooling/linter/adapters/typescript/index.js +3 -2
  489. package/dist/tooling/linter/adapters/typescript/query-observation.js +37 -12
  490. package/dist/tooling/linter/adapters/typescript/syntax.d.ts +3 -3
  491. package/dist/tooling/linter/adapters/typescript/syntax.js +13 -25
  492. package/dist/tooling/linter/adapters/typescript/type-analysis.d.ts +2 -0
  493. package/dist/tooling/linter/adapters/typescript/type-analysis.js +10 -0
  494. package/dist/tooling/linter/implementations/source/callable-requirements.d.ts +1 -2
  495. package/dist/tooling/linter/implementations/source/callable-requirements.js +11 -16
  496. package/dist/tooling/linter/implementations/source/definitions.d.ts +2 -0
  497. package/dist/tooling/linter/implementations/source/definitions.js +425 -0
  498. package/dist/tooling/linter/implementations/source/dependencies.js +13 -72
  499. package/dist/tooling/linter/implementations/source/global.js +18 -11
  500. package/dist/tooling/linter/implementations/source/mutations.js +146 -48
  501. package/dist/tooling/linter/implementations/source/policy-edges.d.ts +2 -0
  502. package/dist/tooling/linter/implementations/source/policy-edges.js +113 -0
  503. package/dist/tooling/linter/implementations/source/providers.js +5 -5
  504. package/dist/tooling/linter/implementations/source/queries.js +1 -17
  505. package/dist/tooling/linter/implementations/source/shared.d.ts +19 -5
  506. package/dist/tooling/linter/implementations/source/shared.js +131 -55
  507. package/dist/tooling/linter/implementations/source/verifiers.js +4 -2
  508. package/dist/tooling/linter/implementations/source/views.js +2 -2
  509. package/dist/tooling/linter/implementations/source/workflows.js +499 -17
  510. package/dist/tooling/linter/policy/generated.js +15 -64
  511. package/dist/tooling/linter/requirements/registry.js +11 -9
  512. package/dist/tooling/packaging/declarations/ownership.js +1 -1
  513. package/dist/tooling/packaging/finalize.d.ts +1 -1
  514. package/dist/tooling/packaging/finalize.js +1 -1
  515. package/docs/admission-age.md +88 -0
  516. package/docs/auth-api-migration.md +55 -0
  517. package/docs/business-errors.md +42 -0
  518. package/docs/domain-definition-migration.md +44 -0
  519. package/docs/domain-schema-migration.md +36 -0
  520. package/docs/durable-workflows.md +473 -0
  521. package/docs/handler-dependencies.md +285 -0
  522. package/docs/legacy/query-v6.md +62 -0
  523. package/docs/queries.md +475 -0
  524. package/docs/release.md +155 -0
  525. package/docs/schema-cost.md +124 -0
  526. package/package.json +49 -17
  527. package/dist/application/application.d.ts +0 -28
  528. package/dist/application/query/execution/projection.d.ts +0 -3
  529. package/dist/application/query/execution/projection.js +0 -3
  530. package/dist/deployment/adapter/deploy/context.d.ts +0 -15
  531. package/dist/deployment/adapter/deploy/index.d.ts +0 -2
  532. package/dist/deployment/adapter/deploy/result.d.ts +0 -50
  533. package/dist/deployment/adapter/prepare/artifact.d.ts +0 -33
  534. package/dist/deployment/adapter/prepare/context.d.ts +0 -23
  535. package/dist/deployment/adapter/prepare/index.d.ts +0 -2
  536. package/dist/deployment/deploy.d.ts +0 -20
  537. package/dist/deployment/deploy.js +0 -31
  538. package/dist/deployment/release/publication/index.d.ts +0 -6
  539. package/dist/deployment/release/publication/index.js +0 -6
  540. package/dist/deployment/release/publication/manifest.d.ts +0 -3
  541. package/dist/deployment/release/publication/manifest.js +0 -5
  542. package/dist/deployment/release/publication/requirements.d.ts +0 -3
  543. package/dist/deployment/release/publication/requirements.js +0 -3
  544. package/dist/deployment/release/publication/seal.d.ts +0 -10
  545. package/dist/deployment/release/publication/seal.js +0 -39
  546. package/dist/deployment/verify/preflight/artifact.d.ts +0 -6
  547. package/dist/deployment/verify/preflight/artifact.js +0 -122
  548. package/dist/deployment/verify/preflight/publication.d.ts +0 -4
  549. package/dist/deployment/verify/preflight/publication.js +0 -14
  550. package/dist/deployment/verify/readiness/deployment.d.ts +0 -3
  551. package/dist/deployment/verify/readiness/deployment.js +0 -151
  552. package/dist/deployment/verify/readiness/publication.d.ts +0 -11
  553. package/dist/deployment/verify/readiness/publication.js +0 -41
  554. package/dist/execution/service/errors.d.ts +0 -3
  555. package/dist/execution/service/errors.js +0 -3
  556. package/dist/execution/service/publication/delivery.d.ts +0 -2
  557. package/dist/execution/service/publication/installation.d.ts +0 -3
  558. package/dist/execution/service/publication/installation.js +0 -8
  559. package/dist/execution/service/publication/source.d.ts +0 -3
  560. package/dist/execution/service/publication/source.js +0 -11
  561. package/dist/platform/publication/index.d.ts +0 -2
  562. package/dist/platform/publication/index.js +0 -2
  563. package/dist/tooling/cli/astrale/authority.d.ts +0 -5
  564. package/dist/tooling/cli/astrale/authority.js +0 -11
  565. package/dist/tooling/cli/astrale/executable.d.ts +0 -2
  566. package/dist/tooling/cli/astrale/executable.js +0 -47
  567. package/dist/tooling/cli/astrale/failure.d.ts +0 -6
  568. package/dist/tooling/cli/astrale/failure.js +0 -48
  569. package/dist/tooling/cli/astrale/instance.d.ts +0 -11
  570. package/dist/tooling/cli/astrale/instance.js +0 -52
  571. package/dist/tooling/cli/astrale/process.d.ts +0 -13
  572. package/dist/tooling/cli/astrale/process.js +0 -94
  573. package/dist/tooling/cli/astrale/version.d.ts +0 -18
  574. package/dist/tooling/cli/astrale/version.js +0 -55
  575. package/dist/tooling/cli/credential.d.ts +0 -2
  576. package/dist/tooling/cli/credential.js +0 -57
  577. package/dist/tooling/cli/deprecations.d.ts +0 -9
  578. package/dist/tooling/cli/deprecations.js +0 -15
  579. package/dist/tooling/cli/development/candidate.d.ts +0 -25
  580. package/dist/tooling/cli/development/candidate.js +0 -176
  581. package/dist/tooling/cli/development/deployment.d.ts +0 -16
  582. package/dist/tooling/cli/development/deployment.js +0 -39
  583. package/dist/tooling/cli/development/develop.d.ts +0 -11
  584. package/dist/tooling/cli/development/develop.js +0 -243
  585. package/dist/tooling/cli/development/lease.d.ts +0 -18
  586. package/dist/tooling/cli/development/lease.js +0 -163
  587. package/dist/tooling/cli/development/lifecycle.d.ts +0 -9
  588. package/dist/tooling/cli/development/lifecycle.js +0 -43
  589. package/dist/tooling/cli/development/project-imports.d.ts +0 -22
  590. package/dist/tooling/cli/development/project-imports.js +0 -39
  591. package/dist/tooling/cli/development/project-lock.d.ts +0 -16
  592. package/dist/tooling/cli/development/project-lock.js +0 -41
  593. package/dist/tooling/cli/development/rebuild.d.ts +0 -13
  594. package/dist/tooling/cli/development/rebuild.js +0 -58
  595. package/dist/tooling/cli/development/release-evidence.d.ts +0 -4
  596. package/dist/tooling/cli/development/release-evidence.js +0 -10
  597. package/dist/tooling/cli/development/report.d.ts +0 -6
  598. package/dist/tooling/cli/development/report.js +0 -14
  599. package/dist/tooling/cli/development/session-file.d.ts +0 -53
  600. package/dist/tooling/cli/development/session-file.js +0 -337
  601. package/dist/tooling/cli/development/source-watch.d.ts +0 -14
  602. package/dist/tooling/cli/development/source-watch.js +0 -140
  603. package/dist/tooling/cli/development/sources.d.ts +0 -7
  604. package/dist/tooling/cli/development/sources.js +0 -48
  605. package/dist/tooling/cli/development/target-lock.d.ts +0 -16
  606. package/dist/tooling/cli/development/target-lock.js +0 -68
  607. package/dist/tooling/cli/development/view.d.ts +0 -28
  608. package/dist/tooling/cli/development/view.js +0 -151
  609. package/dist/tooling/cli/environment-release.d.ts +0 -21
  610. package/dist/tooling/cli/environment-release.js +0 -46
  611. package/dist/tooling/cli/evidence.d.ts +0 -11
  612. package/dist/tooling/cli/evidence.js +0 -53
  613. package/dist/tooling/cli/installation/index.d.ts +0 -2
  614. package/dist/tooling/cli/installation/index.js +0 -1
  615. package/dist/tooling/cli/installation/observation.d.ts +0 -10
  616. package/dist/tooling/cli/installation/observation.js +0 -44
  617. package/dist/tooling/cli/installation/reconcile.d.ts +0 -32
  618. package/dist/tooling/cli/installation/reconcile.js +0 -122
  619. package/dist/tooling/linter/implementations/source/migrations.d.ts +0 -2
  620. package/dist/tooling/linter/implementations/source/migrations.js +0 -113
  621. package/dist/tooling/linter/qualification/index.d.ts +0 -10
  622. package/dist/tooling/linter/qualification/index.js +0 -2
  623. package/dist/tooling/linter/qualification/query-fixtures.d.ts +0 -2
  624. package/dist/tooling/linter/qualification/query-fixtures.js +0 -68
  625. package/dist/tooling/linter/qualification/runner.d.ts +0 -3
  626. package/dist/tooling/linter/qualification/runner.js +0 -6
  627. /package/dist/application/{application.js → domain.js} +0 -0
  628. /package/dist/application/{query/single/query.js → mutation/legacy/v6/builder.js} +0 -0
  629. /package/dist/{deployment/adapter/deploy/context.js → application/mutation/legacy/v6/mutation.js} +0 -0
  630. /package/dist/application/mutation/{authoring → legacy/v6}/precondition.js +0 -0
  631. /package/dist/{deployment/adapter/deploy/index.js → application/query/answer/answer.js} +0 -0
  632. /package/dist/{deployment/adapter/deploy/result.js → application/query/defined/query.js} +0 -0
  633. /package/dist/{deployment/adapter/prepare/artifact.js → application/query/execution/client.js} +0 -0
  634. /package/dist/{deployment/adapter/prepare/context.js → application/query/handles/conditions.js} +0 -0
  635. /package/dist/{deployment/adapter/prepare/index.js → application/query/handles/domain.js} +0 -0
  636. /package/dist/application/query/{collection → legacy/v6/collection}/identity.js +0 -0
  637. /package/dist/application/query/{collection → legacy/v6/collection}/limits.d.ts +0 -0
  638. /package/dist/application/query/{collection → legacy/v6/collection}/limits.js +0 -0
  639. /package/dist/application/query/{collection → legacy/v6/collection}/metadata.js +0 -0
  640. /package/dist/application/query/{execution → legacy/v6/execution}/pages.d.ts +0 -0
  641. /package/dist/application/query/{execution → legacy/v6/execution}/pages.js +0 -0
  642. /package/dist/application/query/{single → legacy/v6/single}/index.d.ts +0 -0
  643. /package/dist/application/query/{single → legacy/v6/single}/index.js +0 -0
  644. /package/dist/application/query/{single → legacy/v6/single}/node.d.ts +0 -0
  645. /package/dist/application/query/{single → legacy/v6/single}/node.js +0 -0
  646. /package/dist/application/query/{single → legacy/v6/single}/pagination.d.ts +0 -0
  647. /package/dist/application/query/{single → legacy/v6/single}/selection.d.ts +0 -0
  648. /package/dist/application/query/{single → legacy/v6/single}/selection.js +0 -0
  649. /package/dist/deployment/release/{publication → served}/routes.d.ts +0 -0
  650. /package/dist/deployment/release/{publication → served}/routes.js +0 -0
  651. /package/dist/execution/service/{publication → serving}/index.js +0 -0
@@ -3,11 +3,12 @@ import { isRuntime } from '../../application/runtime/index.js';
3
3
  import { invocationPath } from '../../deployment/release/invocation.js';
4
4
  import { identity as captureIdentity } from '../identity/index.js';
5
5
  import { createHandler } from '../invocation/index.js';
6
- import { initialize, load } from '../runtime/index.js';
6
+ import { initialize, load, serving as servedRelease } from '../runtime/index.js';
7
+ import { createDurableReceiver, durableServing, isCanonicalDurableRequest, isDurableRequest, } from '../workflows/index.js';
7
8
  import { initialization } from './initialization.js';
8
9
  import { lifecycle } from './lifecycle.js';
9
- import { delivery, installation, source } from './publication/index.js';
10
10
  import { loadRelease } from './release.js';
11
+ import { delivery, installation, source } from './serving/index.js';
11
12
  /** Create one lazy running Service around the exact current Release. */
12
13
  export function createService(input) {
13
14
  if (input === null || typeof input !== 'object' || Array.isArray(input))
@@ -16,24 +17,28 @@ export function createService(input) {
16
17
  throw new TypeError('Service Runtime is not admitted.');
17
18
  const selectedIdentity = captureIdentity(input.identity);
18
19
  const providedDelivery = delivery(input.delivery);
20
+ const durable = input.durable;
21
+ // Preserve eager admission for an already loaded engine; providers stay outside ordinary startup.
22
+ const serving = durable === undefined || typeof durable === 'function' ? undefined : durableServing(durable);
19
23
  let running;
20
24
  const state = lifecycle(() => running?.server.drain());
21
25
  const realized = initialization(async () => {
22
26
  const release = await loadRelease(input.load, input.environment, input.runtime);
23
- if (release.addressing.issuer !== selectedIdentity.issuer) {
27
+ const served = servedRelease(release);
28
+ if (served.issuer !== selectedIdentity.issuer) {
24
29
  throw new TypeError('Service Identity differs from Release Addressing.');
25
30
  }
26
31
  if (selectedIdentity.subject !== release.build.schema.compiled.root.origin) {
27
32
  throw new TypeError('Service Identity subject differs from the Release Domain origin.');
28
33
  }
29
- const selectedDelivery = providedDelivery ?? selectedIdentity.delivery(release.publication);
30
- installation(release, selectedDelivery);
34
+ const selectedDelivery = providedDelivery ?? selectedIdentity.delivery(served.document);
35
+ installation(served.document, selectedDelivery);
31
36
  const loaded = load(release);
32
37
  const runtime = await initialize(loaded, input.environment);
33
38
  const prepared = prepareServer({
34
39
  ...serverOptions(input.server),
35
40
  path: invocationPath(),
36
- publicOrigin: release.addressing.publicUrl,
41
+ publicOrigin: served.publicUrl,
37
42
  invocation: {
38
43
  source: selectedIdentity.issuer,
39
44
  next: () => crypto.randomUUID(),
@@ -42,19 +47,35 @@ export function createService(input) {
42
47
  ...(selectedIdentity.tokenExchange === undefined
43
48
  ? {}
44
49
  : { tokenExchange: selectedIdentity.tokenExchange }),
45
- publication: source(loaded),
50
+ ...source(loaded),
46
51
  ...(selectedDelivery === undefined ? {} : { delivery: selectedDelivery }),
47
52
  });
48
53
  const server = prepared.create(createHandler({
49
54
  runtime,
50
55
  authority: selectedIdentity,
51
56
  ...(input.workflows === undefined ? {} : { workflows: input.workflows }),
57
+ ...(input.cache === undefined ? {} : { cache: input.cache }),
52
58
  }));
53
59
  running = Object.freeze({ release, runtime, server });
54
60
  if (!state.accepting)
55
61
  server.drain();
56
62
  return running;
57
63
  });
64
+ const receiver = initialization(async (request) => {
65
+ const selected = typeof durable === 'function' ? await durable(request) : undefined;
66
+ const configuration = serving ?? (selected === undefined ? undefined : durableServing(selected));
67
+ if (configuration === undefined)
68
+ return undefined;
69
+ const { runtime } = await realized.get();
70
+ return createDurableReceiver({
71
+ workflows: runtime.loaded.registry.workflows,
72
+ domain: runtime.loaded.domain,
73
+ declared: runtime.loaded.release.build.requirements.capabilities.classes ?? [],
74
+ identity: selectedIdentity,
75
+ serving: configuration,
76
+ integrations: runtime.clients,
77
+ });
78
+ });
58
79
  let closing;
59
80
  const service = Object.freeze({
60
81
  async fetch(request, host) {
@@ -63,6 +84,15 @@ export function createService(input) {
63
84
  const ready = await realized.get();
64
85
  if (!state.accepting)
65
86
  return unavailable();
87
+ // Without engine configuration only durable calls fail: the engine's discovery is refused.
88
+ if (isDurableRequest(request)) {
89
+ if (!isCanonicalDurableRequest(request))
90
+ return notServed();
91
+ const selected = await receiver.get(request);
92
+ if (!state.accepting)
93
+ return unavailable();
94
+ return selected?.fetch(request) ?? notServed();
95
+ }
66
96
  return ready.server.app.fetch(request, host);
67
97
  },
68
98
  async release() {
@@ -95,6 +125,7 @@ function serverOptions(input) {
95
125
  'issuer',
96
126
  'publicOrigin',
97
127
  'tokenExchange',
128
+ 'release',
98
129
  'publication',
99
130
  'delivery',
100
131
  'handler',
@@ -104,6 +135,12 @@ function serverOptions(input) {
104
135
  }
105
136
  return input;
106
137
  }
138
+ function notServed() {
139
+ return new Response('{"error":"This deployment serves no durable Workflows."}', {
140
+ status: 404,
141
+ headers: { 'content-type': 'application/json', 'cache-control': 'no-store' },
142
+ });
143
+ }
107
144
  function unavailable() {
108
145
  return new Response('{"error":"Service is draining."}', {
109
146
  status: 503,
@@ -1,6 +1,6 @@
1
- export interface Initialization<Value> {
2
- get(): Promise<Value>;
1
+ export interface Initialization<Value, Arguments extends readonly unknown[] = []> {
2
+ get(...args: Arguments): Promise<Value>;
3
3
  current(): Promise<Value> | undefined;
4
4
  }
5
- /** Share one successful initialization and allow a later retry after failure. */
6
- export declare function initialization<Value>(create: () => Promise<Value>): Initialization<Value>;
5
+ /** Share an initialized value; absence and failure leave initialization retryable. */
6
+ export declare function initialization<Value, Arguments extends readonly unknown[] = []>(create: (...args: Arguments) => Promise<Value>): Initialization<Value, Arguments>;
@@ -1,18 +1,27 @@
1
- /** Share one successful initialization and allow a later retry after failure. */
1
+ /** Share an initialized value; absence and failure leave initialization retryable. */
2
2
  export function initialization(create) {
3
- let current;
3
+ let state;
4
+ const get = (...args) => {
5
+ if (state?.phase === 'ready')
6
+ return state.promise;
7
+ if (state !== undefined) {
8
+ // Absence can depend on the initializing request. A waiter gets its own eligibility check.
9
+ return state.promise.then((value) => (value === undefined ? get(...args) : value));
10
+ }
11
+ const pending = create(...args).then((value) => {
12
+ if (state?.promise === pending)
13
+ state = value === undefined ? undefined : { phase: 'ready', promise: pending };
14
+ return value;
15
+ }, (cause) => {
16
+ if (state?.promise === pending)
17
+ state = undefined;
18
+ throw cause;
19
+ });
20
+ state = { phase: 'pending', promise: pending };
21
+ return pending;
22
+ };
4
23
  return Object.freeze({
5
- get() {
6
- if (current !== undefined)
7
- return current;
8
- const pending = create().catch((cause) => {
9
- if (current === pending)
10
- current = undefined;
11
- throw cause;
12
- });
13
- current = pending;
14
- return pending;
15
- },
16
- current: () => current,
24
+ get,
25
+ current: () => state?.promise,
17
26
  });
18
27
  }
@@ -1,7 +1,7 @@
1
1
  import type { Runtime } from '../../application/runtime/index.js';
2
2
  import type { Build } from '../../deployment/build/build.js';
3
- import type { Release } from '../../deployment/release/release.js';
4
3
  import type { schema } from '../../platform/schema/index.js';
5
- export type ReleaseForRuntime<RuntimeValue extends Runtime> = Release<Build<schema.DomainSchema, RuntimeValue>>;
4
+ import type { ServedRelease } from '../runtime/index.js';
5
+ export type ReleaseForRuntime<RuntimeValue extends Runtime> = ServedRelease<Build<schema.DomainSchema, RuntimeValue>>;
6
6
  export type ReleaseLoader<Environment, RuntimeValue extends Runtime = Runtime> = (environment: Environment) => ReleaseForRuntime<RuntimeValue> | Promise<ReleaseForRuntime<RuntimeValue>>;
7
7
  export declare function loadRelease<Environment, RuntimeValue extends Runtime>(load: ReleaseLoader<Environment, RuntimeValue>, environment: Environment, runtime: RuntimeValue): Promise<ReleaseForRuntime<RuntimeValue>>;
@@ -1,10 +1,11 @@
1
- import { isRelease } from '../../deployment/release/admission.js';
1
+ import { isServedRelease } from '../runtime/index.js';
2
2
  export async function loadRelease(load, environment, runtime) {
3
3
  if (typeof load !== 'function')
4
4
  throw new TypeError('Service Release loader is invalid.');
5
5
  const release = await load(environment);
6
- if (!isRelease(release))
6
+ if (!isServedRelease(release)) {
7
7
  throw new TypeError('Service loader returned an unadmitted Release.');
8
+ }
8
9
  if (release.build.runtime !== runtime) {
9
10
  throw new TypeError('Service Release Runtime differs from the generated entrypoint Runtime.');
10
11
  }
@@ -1,23 +1,38 @@
1
1
  import type { ApplicationHost, ServerCloseOptions, ServerOptions } from '@astrale-os/kernel-server';
2
- import type { publication } from '@astrale-os/kernel-server';
2
+ import type { release } from '@astrale-os/kernel-server';
3
3
  import type { Runtime } from '../../application/runtime/index.js';
4
4
  import type { WorkflowRunner } from '../../application/workflow/runner/index.js';
5
- import type { Release } from '../../deployment/release/index.js';
5
+ import type { DeploymentCache } from '../cache/index.js';
6
6
  import type { Identity } from '../identity/index.js';
7
+ import type { ServedRelease } from '../runtime/index.js';
8
+ import type { DurableServing, DurableServingProvider } from '../workflows/index.js';
7
9
  import type { ReleaseLoader } from './release.js';
8
- export type ServiceServerOptions = Omit<ServerOptions, 'path' | 'invocation' | 'issuer' | 'publicOrigin' | 'tokenExchange' | 'publication' | 'delivery'>;
10
+ export type ServiceServerOptions = Omit<ServerOptions, 'path' | 'invocation' | 'issuer' | 'publicOrigin' | 'tokenExchange' | 'release' | 'delivery'>;
9
11
  export interface ServiceInput<Environment, RuntimeValue extends Runtime = Runtime> {
10
12
  readonly runtime: RuntimeValue;
11
13
  readonly environment: Environment;
12
14
  readonly load: ReleaseLoader<Environment, RuntimeValue>;
13
15
  readonly identity: Identity;
14
16
  readonly server: ServiceServerOptions;
15
- readonly delivery?: publication.delivery.Provider;
17
+ /**
18
+ * Answers Delivery v2 over an immutable deployment's Release. Defaults to the Identity's own.
19
+ */
20
+ readonly delivery?: release.delivery.Provider;
16
21
  readonly workflows?: WorkflowRunner;
22
+ /**
23
+ * Where admissions of callables that declare an admission age are kept for the next calls.
24
+ * Absent: every call is admitted by its source Kernel.
25
+ */
26
+ readonly cache?: DeploymentCache;
27
+ /**
28
+ * Serve the Release's durable Workflows. A provider is resolved on the first engine request,
29
+ * shared by concurrent requests, and retried after initialization fails.
30
+ */
31
+ readonly durable?: DurableServing | DurableServingProvider;
17
32
  }
18
33
  export interface Service {
19
34
  fetch(request: Request, host?: ApplicationHost): Promise<Response>;
20
- release(): Promise<Release>;
35
+ release(): Promise<ServedRelease>;
21
36
  drain(): void;
22
37
  close(options: ServerCloseOptions): Promise<void>;
23
38
  }
@@ -0,0 +1,5 @@
1
+ import type { release } from '@astrale-os/kernel-server';
2
+ /**
3
+ * Capture an explicit Delivery v2 Provider over an immutable deployment's Release.
4
+ */
5
+ export declare function delivery(input: release.delivery.Provider | undefined): release.delivery.Provider | undefined;
@@ -1,8 +1,11 @@
1
+ /**
2
+ * Capture an explicit Delivery v2 Provider over an immutable deployment's Release.
3
+ */
1
4
  export function delivery(input) {
2
5
  if (input === undefined)
3
6
  return undefined;
4
7
  if (input === null || typeof input !== 'object' || typeof input.create !== 'function') {
5
- throw new TypeError('Publication delivery Provider is invalid.');
8
+ throw new TypeError('Delivery Provider is invalid.');
6
9
  }
7
10
  const create = input.create.bind(input);
8
11
  return Object.freeze({ create });
@@ -1,3 +1,3 @@
1
1
  export { delivery } from './delivery.js';
2
2
  export { installation } from './installation.js';
3
- export { source } from './source.js';
3
+ export { source, type ServingSource } from './source.js';
@@ -0,0 +1,4 @@
1
+ import type { release } from '@astrale-os/kernel-server';
2
+ import type { Serving } from '../../runtime/index.js';
3
+ /** A served document advertises Delivery exactly when the Service has a Provider for it. */
4
+ export declare function installation(served: Serving['document'], provider: release.delivery.Provider | undefined): void;
@@ -0,0 +1,9 @@
1
+ /** A served document advertises Delivery exactly when the Service has a Provider for it. */
2
+ export function installation(served, provider) {
3
+ const advertised = served.delivery !== undefined;
4
+ if (advertised !== (provider !== undefined)) {
5
+ throw new TypeError(advertised
6
+ ? 'Release advertises delivery without a Provider.'
7
+ : 'Delivery Provider has no Release endpoint.');
8
+ }
9
+ }
@@ -0,0 +1,11 @@
1
+ import type { ReleaseSource } from '@astrale-os/kernel-server';
2
+ import type { LoadedRuntime } from '../../runtime/index.js';
3
+ /** The one source a Kernel Server serves, as `ServerOptions` takes it. */
4
+ export type ServingSource = {
5
+ readonly release: ReleaseSource;
6
+ };
7
+ /**
8
+ * Prepare, once, the exact snapshot the loaded Release serves: an immutable deployment serves its
9
+ * DomainRelease through prepareReleaseSnapshot, which admits routing naming that exact release.
10
+ */
11
+ export declare function source(runtime: LoadedRuntime): ServingSource;
@@ -0,0 +1,15 @@
1
+ import { prepareReleaseSnapshot } from '@astrale-os/kernel-server';
2
+ /**
3
+ * Prepare, once, the exact snapshot the loaded Release serves: an immutable deployment serves its
4
+ * DomainRelease through prepareReleaseSnapshot, which admits routing naming that exact release.
5
+ */
6
+ export function source(runtime) {
7
+ const served = runtime.release;
8
+ const snapshot = prepareReleaseSnapshot({
9
+ release: served.document,
10
+ bundle: served.build.schema.bundle.bytes(),
11
+ table: served.routes,
12
+ domain: runtime.domain,
13
+ });
14
+ return Object.freeze({ release: Object.freeze({ current: () => snapshot }) });
15
+ }
@@ -0,0 +1,87 @@
1
+ import type { DurableEngine } from './engine.js';
2
+ import type { KernelRefusal } from './failure.js';
3
+ import type { StepRetryBudget } from './options.js';
4
+ /**
5
+ * What the failure of one Step attempt means for its Step, read from protocol facts alone:
6
+ *
7
+ * - `permanent`: the Kernel refused a request that cannot succeed sent again unchanged. The Step
8
+ * fails at once.
9
+ * - `platform`: the Kernel or the way to it was unavailable, and sending the request again repeats
10
+ * no effect. The Step waits and tries again without spending an attempt, bounded only by its
11
+ * `maxDurationMs` and by cancellation. An attempt after an unkeyed `invoke` that may have run,
12
+ * which the next attempt sends again, is never one: it spends an attempt.
13
+ * - `own`: anything else, the Step's code, a Provider, or a refusal whose retry meaning the Kernel
14
+ * leaves open. The attempt spends one of the Step's attempts.
15
+ */
16
+ export type AttemptFailureKind = 'permanent' | 'platform' | 'own';
17
+ /** One failed Step attempt, as its journal entry records it. */
18
+ export interface FailedAttempt {
19
+ readonly kind: AttemptFailureKind;
20
+ /** The delay the failure prescribes: a Kernel `retryAfterMs`, or the Step's own `retryAfter`. */
21
+ readonly delayMs?: number;
22
+ readonly refusal?: KernelRefusal;
23
+ /** When the attempt started and ended, on the run's clock. */
24
+ readonly startedAt: number;
25
+ readonly endedAt: number;
26
+ }
27
+ /** What the failed attempts of one Step spent so far. */
28
+ export interface StepSpending {
29
+ /** The start of the Step's first attempt, from which `maxDurationMs` runs. */
30
+ readonly startedAt: number;
31
+ /** Attempts that failed for the Step's own reason. */
32
+ readonly attempts: number;
33
+ /** Platform failures since the Step's last own failure, which space the next platform wait. */
34
+ readonly unavailable: number;
35
+ }
36
+ /** How a Step goes on after a failed attempt. */
37
+ export type NextAttempt = {
38
+ readonly kind: 'retry';
39
+ readonly delayMs: number;
40
+ /** A wait for the platform, or the backoff of an own failure. */
41
+ readonly wait: typeof UNAVAILABLE | typeof BACKOFF;
42
+ readonly spending: StepSpending;
43
+ } | {
44
+ readonly kind: 'exhausted';
45
+ readonly refusal?: KernelRefusal;
46
+ };
47
+ /** Name prefix of the durable wait before the attempt that follows an own failure. */
48
+ export declare const BACKOFF = "retry";
49
+ /** Name prefix of the durable wait before the attempt that follows a platform failure. */
50
+ export declare const UNAVAILABLE = "unavailable";
51
+ /**
52
+ * The outcome of a Kernel call that repeats no effect when sent again, a read or a call carrying
53
+ * its idempotency key: its failure lets the Step tell an unreachable Kernel from its own failure.
54
+ */
55
+ export declare function resendableCall<Output>(call: () => Output): Output;
56
+ /**
57
+ * The outcome of a Kernel call that runs its effect again when sent again, an `invoke` without a
58
+ * key: `ran` hears that the call may have run, unless its failure proves it did not.
59
+ */
60
+ export declare function unkeyedCall<Output>(call: () => Promise<Output>, ran: () => void): Promise<Output>;
61
+ /**
62
+ * Classify the failure of one Step attempt, a declared error excepted, by the first Kernel answer or
63
+ * transport failure among its causes, and name the Kernel refusal behind it, if any.
64
+ */
65
+ export declare function classifyFailure(cause: unknown): Pick<FailedAttempt, 'kind' | 'delayMs' | 'refusal'>;
66
+ /**
67
+ * The terminal failure a Step attempt hands the engine for `cause`: the engine journals it as the
68
+ * attempt's outcome, so the Step decides whether to go on from the journal alone, live and on
69
+ * replay. Its message starts with the Kernel refusal's codes, if any, and is bounded.
70
+ * `repeatsEffects` says whether the attempt ran a request the next attempt runs again with its
71
+ * effect, so an outage never repeats that effect beyond the Step's budget.
72
+ */
73
+ export declare function failedAttemptError(engine: DurableEngine, cause: unknown, startedAt: number, endedAt: number, repeatsEffects: boolean): Error;
74
+ /** The failed attempt a journaled `run` outcome records, if it records one. */
75
+ export declare function failedAttemptOf(engine: DurableEngine, outcome: unknown): FailedAttempt | undefined;
76
+ /**
77
+ * How a Step goes on after `failed`, given what its earlier attempts spent:
78
+ *
79
+ * - A permanent failure exhausts the Step at once.
80
+ * - An own failure spends an attempt; the next one waits the delay the failure prescribes, or the
81
+ * Step's backoff over its own failures.
82
+ * - A platform failure spends no attempt; the next one waits the longer of the delay the Kernel
83
+ * prescribes and the Step's backoff over its platform failures since its last own one, so a long
84
+ * outage costs one attempt per `maxIntervalMs`.
85
+ * - Either way, a failure at or past `maxDurationMs` from the Step's first attempt exhausts it.
86
+ */
87
+ export declare function nextAttempt(spent: StepSpending | undefined, failed: FailedAttempt, budget: StepRetryBudget): NextAttempt;
@@ -0,0 +1,205 @@
1
+ import { ClientError, ResponseError, TransportError, isExpectationMismatch, isMaintenanceSessionStale, isSnapshotStale, retryAfterOf, } from '../../platform/client/index.js';
2
+ import { attemptMessage, kernelRefusalOf, StepRetryAfter } from './failure.js';
3
+ /** Name prefix of the durable wait before the attempt that follows an own failure. */
4
+ export const BACKOFF = 'retry';
5
+ /** Name prefix of the durable wait before the attempt that follows a platform failure. */
6
+ export const UNAVAILABLE = 'unavailable';
7
+ /** Metadata key under which a failed attempt's journal entry records its `FailedAttempt`. */
8
+ const ATTEMPT = 'astrale.attempt';
9
+ /** The longest message a failed attempt's journal entry keeps, so an outage journals little. */
10
+ const MAXIMUM_MESSAGE = 1_024;
11
+ /** How deep a failure's causes are searched for the call that failed. */
12
+ const MAXIMUM_CAUSE_DEPTH = 8;
13
+ /**
14
+ * Kernel refusals that name a request that cannot succeed sent again unchanged: a malformed or
15
+ * unsupported request, or a Domain meaning this Instance does not serve.
16
+ */
17
+ const PERMANENT_CODES = new Set([
18
+ 1001, // PARSE_ERROR
19
+ 1002, // INVALID_REQUEST
20
+ 3003, // METHOD_NOT_ALLOWED
21
+ 4002, // UNSUPPORTED
22
+ ]);
23
+ const OUTCOME_UNKNOWN = 5002;
24
+ /** HTTP answers without an invocation response that say the server took no work. */
25
+ const UNAVAILABLE_STATUS = /^(?:429|502|503)$/u;
26
+ const STATUS_OF_ANSWER = /^server returned HTTP (\d{3}) without an invocation response\.$/u;
27
+ const STATUS_OF_DISCOVERY = /^Release discovery returned HTTP (\d{3})\.$/u;
28
+ /** Failures of Kernel calls that send again without repeating an effect: reads and keyed calls. */
29
+ const resendable = new WeakSet();
30
+ /**
31
+ * The outcome of a Kernel call that repeats no effect when sent again, a read or a call carrying
32
+ * its idempotency key: its failure lets the Step tell an unreachable Kernel from its own failure.
33
+ */
34
+ export function resendableCall(call) {
35
+ let output;
36
+ try {
37
+ output = call();
38
+ }
39
+ catch (cause) {
40
+ markResendable(cause);
41
+ throw cause;
42
+ }
43
+ if (!(output instanceof Promise))
44
+ return output;
45
+ return output.catch((cause) => {
46
+ markResendable(cause);
47
+ throw cause;
48
+ });
49
+ }
50
+ function markResendable(cause) {
51
+ if (cause !== null && typeof cause === 'object')
52
+ resendable.add(cause);
53
+ }
54
+ /**
55
+ * The outcome of a Kernel call that runs its effect again when sent again, an `invoke` without a
56
+ * key: `ran` hears that the call may have run, unless its failure proves it did not.
57
+ */
58
+ export function unkeyedCall(call, ran) {
59
+ const failed = (cause) => {
60
+ // For a call sent without a key, only a failure that proves nothing ran is the platform's.
61
+ if (classifyFailure(cause).kind !== 'platform')
62
+ ran();
63
+ throw cause;
64
+ };
65
+ let output;
66
+ try {
67
+ output = call();
68
+ }
69
+ catch (cause) {
70
+ return failed(cause);
71
+ }
72
+ return Promise.resolve(output).then((value) => {
73
+ ran();
74
+ return value;
75
+ }, failed);
76
+ }
77
+ /**
78
+ * Classify the failure of one Step attempt, a declared error excepted, by the first Kernel answer or
79
+ * transport failure among its causes, and name the Kernel refusal behind it, if any.
80
+ */
81
+ export function classifyFailure(cause) {
82
+ const refusal = kernelRefusalOf(cause);
83
+ const named = refusal === undefined ? {} : { refusal };
84
+ if (cause instanceof StepRetryAfter)
85
+ return { kind: 'own', delayMs: cause.delayMs, ...named };
86
+ let resent = false;
87
+ let current = cause;
88
+ for (let depth = 0; depth < MAXIMUM_CAUSE_DEPTH; depth += 1) {
89
+ if (current === null || typeof current !== 'object')
90
+ break;
91
+ resent ||= resendable.has(current);
92
+ if (current instanceof ResponseError)
93
+ return { ...refusalKind(current, resent), ...named };
94
+ if (current instanceof TransportError)
95
+ return { kind: transportKind(current, resent), ...named };
96
+ if (current instanceof ClientError && unavailableStatus(STATUS_OF_DISCOVERY, current.message)) {
97
+ // Release discovery is a read the Kernel's own server failed to answer.
98
+ return { kind: 'platform', ...named };
99
+ }
100
+ current = current.cause;
101
+ }
102
+ return { kind: 'own', ...named };
103
+ }
104
+ function refusalKind(error, resent) {
105
+ // Read before the refusal guards, which narrow a `ResponseError` they reject to nothing.
106
+ const { code } = error;
107
+ // Capacity, draining and maintenance: refused before any work was admitted.
108
+ const delayMs = retryAfterOf(error);
109
+ if (delayMs !== undefined)
110
+ return { kind: 'platform', delayMs };
111
+ // A sealed conflict whose snapshot advanced ran nothing, and may be sent again at once.
112
+ if (isSnapshotStale(error))
113
+ return { kind: 'platform' };
114
+ if (PERMANENT_CODES.has(code) ||
115
+ isExpectationMismatch(error) ||
116
+ isMaintenanceSessionStale(error)) {
117
+ return { kind: 'permanent' };
118
+ }
119
+ // The Kernel asks not to send again an unknown outcome automatically, unless its key replays it.
120
+ if (code === OUTCOME_UNKNOWN && resent)
121
+ return { kind: 'platform' };
122
+ return { kind: 'own' };
123
+ }
124
+ /**
125
+ * A transport failure is the platform's when it is no local bound or deadline, and its request
126
+ * provably did not reach the Kernel or repeats no effect when sent again.
127
+ */
128
+ function transportKind(error, resent) {
129
+ // A deadline may be the request's own cost: it spends an attempt, as any slow attempt does.
130
+ if (error.phase === 'timeout')
131
+ return 'own';
132
+ // A failure with neither a network cause nor an unavailable answer is a local bound.
133
+ const network = error.cause !== undefined || unavailableStatus(STATUS_OF_ANSWER, error.message);
134
+ if (!network)
135
+ return 'own';
136
+ if (error.context.kind === 'acquisition')
137
+ return 'platform';
138
+ return error.context.delivery === 'not-sent' || resent ? 'platform' : 'own';
139
+ }
140
+ function unavailableStatus(pattern, message) {
141
+ const status = pattern.exec(message)?.[1];
142
+ return status !== undefined && UNAVAILABLE_STATUS.test(status);
143
+ }
144
+ /**
145
+ * The terminal failure a Step attempt hands the engine for `cause`: the engine journals it as the
146
+ * attempt's outcome, so the Step decides whether to go on from the journal alone, live and on
147
+ * replay. Its message starts with the Kernel refusal's codes, if any, and is bounded.
148
+ * `repeatsEffects` says whether the attempt ran a request the next attempt runs again with its
149
+ * effect, so an outage never repeats that effect beyond the Step's budget.
150
+ */
151
+ export function failedAttemptError(engine, cause, startedAt, endedAt, repeatsEffects) {
152
+ const classified = classifyFailure(cause);
153
+ const kind = repeatsEffects && classified.kind === 'platform' ? 'own' : classified.kind;
154
+ const failed = { ...classified, kind, startedAt, endedAt };
155
+ const message = attemptMessage(cause);
156
+ const error = new engine.TerminalError(message.length > MAXIMUM_MESSAGE ? `${message.slice(0, MAXIMUM_MESSAGE - 1)}…` : message, { metadata: { [ATTEMPT]: JSON.stringify(failed) } });
157
+ // Kept on the live error only: what the attempt threw, for a test engine to show.
158
+ Object.defineProperty(error, 'cause', { value: cause, configurable: true, writable: true });
159
+ return error;
160
+ }
161
+ /** The failed attempt a journaled `run` outcome records, if it records one. */
162
+ export function failedAttemptOf(engine, outcome) {
163
+ if (!(outcome instanceof engine.TerminalError) || outcome instanceof engine.CancelledError) {
164
+ return undefined;
165
+ }
166
+ const encoded = outcome.metadata?.[ATTEMPT];
167
+ return encoded === undefined ? undefined : JSON.parse(encoded);
168
+ }
169
+ /**
170
+ * How a Step goes on after `failed`, given what its earlier attempts spent:
171
+ *
172
+ * - A permanent failure exhausts the Step at once.
173
+ * - An own failure spends an attempt; the next one waits the delay the failure prescribes, or the
174
+ * Step's backoff over its own failures.
175
+ * - A platform failure spends no attempt; the next one waits the longer of the delay the Kernel
176
+ * prescribes and the Step's backoff over its platform failures since its last own one, so a long
177
+ * outage costs one attempt per `maxIntervalMs`.
178
+ * - Either way, a failure at or past `maxDurationMs` from the Step's first attempt exhausts it.
179
+ */
180
+ export function nextAttempt(spent, failed, budget) {
181
+ const refusal = failed.refusal === undefined ? {} : { refusal: failed.refusal };
182
+ if (failed.kind === 'permanent')
183
+ return { kind: 'exhausted', ...refusal };
184
+ const startedAt = spent?.startedAt ?? failed.startedAt;
185
+ const own = failed.kind === 'own';
186
+ const attempts = (spent?.attempts ?? 0) + (own ? 1 : 0);
187
+ const unavailable = own ? 0 : (spent?.unavailable ?? 0) + 1;
188
+ if ((budget.maxAttempts !== undefined && attempts >= budget.maxAttempts) ||
189
+ (budget.maxDurationMs !== undefined && failed.endedAt - startedAt >= budget.maxDurationMs)) {
190
+ return { kind: 'exhausted', ...refusal };
191
+ }
192
+ const delayMs = own
193
+ ? (failed.delayMs ?? backoff(budget, attempts))
194
+ : Math.max(failed.delayMs ?? 0, backoff(budget, unavailable));
195
+ return {
196
+ kind: 'retry',
197
+ delayMs,
198
+ wait: own ? BACKOFF : UNAVAILABLE,
199
+ spending: { startedAt, attempts, unavailable },
200
+ };
201
+ }
202
+ /** The `failures`-th wait of a capped exponential backoff, the first one `initialIntervalMs`. */
203
+ function backoff(budget, failures) {
204
+ return Math.min(budget.maxIntervalMs, budget.initialIntervalMs * budget.intervalFactor ** (failures - 1));
205
+ }
@@ -0,0 +1,14 @@
1
+ import type { Fetch } from '@astrale-os/kernel-client';
2
+ import type { WorkflowEngine } from '@astrale-os/kernel-protocol/issuer/workflow-engine';
3
+ /** Discovery failure never admits static keys for an issuer-prefixed request. */
4
+ export declare class WorkflowEngineUnavailable extends Error {
5
+ readonly name = "WorkflowEngineUnavailable";
6
+ }
7
+ /** One receiver retains bounded, recently admitted engine authority and deduplicates refreshes. */
8
+ export declare function workflowEngineDiscovery(fetch: Fetch, now?: () => number): Readonly<{
9
+ resolve(issuer: string): Promise<WorkflowEngine>;
10
+ /** A crypto provider rejected this authority; the next request must discover it again. */
11
+ forget(issuer: string, observedKeys: readonly string[]): void;
12
+ /** Authentication refusal expires the basis for the next request, without replaying its body. */
13
+ invalidate(issuer: string, observedKeys: readonly string[]): void;
14
+ }>;