@makaio/framework 1.0.0-dev-1789000242829 → 1.0.0-dev-1789034250920

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 (280) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/adapters/claude/index.d.mts +24 -24
  3. package/dist/adapters/config/index.d.mts +1 -1
  4. package/dist/adapters/index.d.mts +2 -2
  5. package/dist/adapters/node.d.mts +1 -1
  6. package/dist/artifact--nbPrvm5.mjs +1 -0
  7. package/dist/attempt-control-evidence-BKw1U3wL.mjs +1 -0
  8. package/dist/bus/index.mjs +1 -1
  9. package/dist/clients/index.d.mts +1 -1
  10. package/dist/clients/managed-install.d.mts +1 -1
  11. package/dist/code-execution/worker-entry.d.mts +1 -1
  12. package/dist/contracts/adapter/index.d.mts +2 -2
  13. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  14. package/dist/contracts/artifact/index.d.mts +3 -3
  15. package/dist/contracts/artifact/index.mjs +1 -1
  16. package/dist/contracts/auth/index.d.mts +2 -2
  17. package/dist/contracts/automation-trigger/index.d.mts +3 -3
  18. package/dist/contracts/canonical-model/index.d.mts +1 -1
  19. package/dist/contracts/capabilities/index.d.mts +1 -1
  20. package/dist/contracts/client/index.d.mts +2 -2
  21. package/dist/contracts/code-execution/index.d.mts +1 -1
  22. package/dist/contracts/common/index.d.mts +1 -1
  23. package/dist/contracts/config/index.d.mts +1 -1
  24. package/dist/contracts/extension/index.d.mts +5 -5
  25. package/dist/contracts/facet/index.d.mts +1 -1
  26. package/dist/contracts/harness/index.d.mts +1 -1
  27. package/dist/contracts/host/index.d.mts +1 -1
  28. package/dist/contracts/index.d.mts +301 -75
  29. package/dist/contracts/index.mjs +1 -1
  30. package/dist/contracts/materialization/index.d.mts +2 -2
  31. package/dist/contracts/model-registry/index.d.mts +1 -1
  32. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  33. package/dist/contracts/platform/index.d.mts +1 -1
  34. package/dist/contracts/provider/index.d.mts +2 -2
  35. package/dist/contracts/reaction/index.d.mts +1 -1
  36. package/dist/contracts/session/index.d.mts +2 -2
  37. package/dist/contracts/shared/index.d.mts +2 -2
  38. package/dist/contracts/skill/index.d.mts +1 -1
  39. package/dist/contracts/telemetry/index.d.mts +1 -1
  40. package/dist/contracts/timeout/index.d.mts +1 -1
  41. package/dist/contracts/variant/index.d.mts +1 -1
  42. package/dist/contracts/worker/index.d.mts +2 -2
  43. package/dist/contracts/worker/index.mjs +1 -1
  44. package/dist/contracts/workflow/index.d.mts +2 -2
  45. package/dist/contracts/workflow/index.mjs +1 -1
  46. package/dist/{contribution-BfEEQ8YZ.d.mts → contribution-CejwVIb3.d.mts} +2 -2
  47. package/dist/{definition-6d5JBi55.d.mts → definition-DSOXLpQj.d.mts} +1 -1
  48. package/dist/{detached-extension-handle-BJnk3WEh.mjs → detached-extension-handle-BNvRSUVO.mjs} +1 -1
  49. package/dist/{execution-attempt-repository-DSpz2kyW.d.mts → execution-attempt-repository-BoNwNybg.d.mts} +85 -3
  50. package/dist/{extension-context-Cpf_n5FH.d.mts → extension-context-SrQpa_kp.d.mts} +3 -3
  51. package/dist/{hook-responses-CpEfxEmG.d.mts → hook-responses-E1gipXIp.d.mts} +1 -1
  52. package/dist/{index-BxJRljy-.d.mts → index-0_Ao0hwU.d.mts} +236 -101
  53. package/dist/{index-C75h1xHF2.d.mts → index-6BDbhx3A2.d.mts} +1 -1
  54. package/dist/{index-hm8NV4CJ2.d.mts → index-B7VWSBm72.d.mts} +4 -4
  55. package/dist/{index-BTluq4-E.d.mts → index-B94tZHiU.d.mts} +6295 -3178
  56. package/dist/{index-Dzozmb5u.d.mts → index-BFchykav.d.mts} +3 -3
  57. package/dist/{index-Dckvm0Ml2.d.mts → index-BN0qpem12.d.mts} +16 -16
  58. package/dist/{index-CVh7ZP2I.d.mts → index-BN2_TMtX.d.mts} +6 -6
  59. package/dist/{index-CilWtThn.d.mts → index-BPrpnLRQ.d.mts} +4 -4
  60. package/dist/{index-BfwHYuRf.d.mts → index-BTwMms1p.d.mts} +1 -1
  61. package/dist/{index-Bj2JCo9V.d.mts → index-BXair-QK.d.mts} +1 -1
  62. package/dist/{index-DR308wUB2.d.mts → index-BeLI73yw2.d.mts} +3 -3
  63. package/dist/{index-CRM23ToM2.d.mts → index-BncQwKi-2.d.mts} +39 -39
  64. package/dist/{index-BlHq_Ksb.d.mts → index-CLmjrH8K.d.mts} +2 -2
  65. package/dist/{index-BM-FPWjs2.d.mts → index-CTNGL-cq2.d.mts} +1 -1
  66. package/dist/{index-D7IZQNhD.d.mts → index-CgYGg-Ne2.d.mts} +2 -2
  67. package/dist/{index-DY_0TRvM.d.mts → index-Cp9olTr7.d.mts} +8 -8
  68. package/dist/{index-CCNCo440.d.mts → index-D1rYHYPO.d.mts} +16 -16
  69. package/dist/{index-DvoitgXV.d.mts → index-DKq33gti.d.mts} +22 -22
  70. package/dist/{index-Bn6sN1op.d.mts → index-DUH2eTyC.d.mts} +1 -1
  71. package/dist/{index-C742b1FV.d.mts → index-DUdGqxHD.d.mts} +1 -1
  72. package/dist/{index-BfzuauBt2.d.mts → index-DWlmiprx2.d.mts} +1 -1
  73. package/dist/{index-6kg8YFYt.d.mts → index-DnZksNTM.d.mts} +1 -1
  74. package/dist/{index-B3G-Hzwn.d.mts → index-Dp3UZQv_.d.mts} +1 -1
  75. package/dist/{index-CjMMvZch.d.mts → index-DxUstDMY.d.mts} +1 -1
  76. package/dist/{index-GTCM4lXx.d.mts → index-MKNhvbfG.d.mts} +4 -4
  77. package/dist/{index-CDhbUjUH.d.mts → index-OLGGmjgd.d.mts} +1 -1
  78. package/dist/{index-Bzxs2nVR.d.mts → index-yapYXeah.d.mts} +8 -8
  79. package/dist/kernel/cli/index.d.mts +2 -2
  80. package/dist/kernel/cli/register.d.mts +1 -1
  81. package/dist/kernel/extension/index.d.mts +1 -1
  82. package/dist/kernel/index.d.mts +5 -5
  83. package/dist/kernel/namespace/index.d.mts +1 -1
  84. package/dist/kernel/observability/index.d.mts +1 -1
  85. package/dist/kernel/providers/index.d.mts +1 -1
  86. package/dist/kernel/window/index.d.mts +1 -1
  87. package/dist/{lib-BmXBuE-w.mjs → lib-B1Mvm4hQ.mjs} +1 -1
  88. package/dist/{lib-R-c_q77C.mjs → lib-D1-cvcTz.mjs} +1 -1
  89. package/dist/{load-extensions-Bu10B5B1.d.mts → load-extensions-D6SVKBPw.d.mts} +1 -1
  90. package/dist/{load-extensions-s4YmICgn.mjs → load-extensions-bwisKaW0.mjs} +1 -1
  91. package/dist/{namespace-CY-9Evdf.d.mts → namespace-BYBMtQUy.d.mts} +4 -4
  92. package/dist/{namespace-btfJrUf6.d.mts → namespace-CYYFqmtJ.d.mts} +6 -6
  93. package/dist/{namespace-fEBskugJ.d.mts → namespace-CZJQrexB.d.mts} +18 -18
  94. package/dist/{namespace-CfA0C0JR.d.mts → namespace-CfNNUjVv.d.mts} +2 -2
  95. package/dist/{namespace-B0_Sg-1m.d.mts → namespace-CjFT0wBT.d.mts} +2 -2
  96. package/dist/{namespace-Dmbm2JzV.d.mts → namespace-l1Rcc4mp.d.mts} +2 -2
  97. package/dist/node/bus-server/index.d.mts +1 -1
  98. package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
  99. package/dist/{package-BaTrCWZl.d.mts → package-CnR_tOsW.d.mts} +21 -3
  100. package/dist/package-tvzH3A0x.mjs +7 -0
  101. package/dist/package.json +1 -1
  102. package/dist/rules/index.d.mts +1 -1
  103. package/dist/rules/schemas.d.mts +1 -1
  104. package/dist/runtime-bun/index.mjs +1 -1
  105. package/dist/runtime-node/code-execution/index.d.mts +2 -2
  106. package/dist/runtime-node/extension-discovery.d.mts +1 -1
  107. package/dist/runtime-node/extension-validation.d.mts +1 -1
  108. package/dist/runtime-node/extension-validation.mjs +1 -1
  109. package/dist/runtime-node/index.d.mts +5 -5
  110. package/dist/runtime-node/index.mjs +2 -2
  111. package/dist/runtime-node/makaio-config.d.mts +1 -1
  112. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  113. package/dist/{schemas-yXs929kr.d.mts → schemas-Ct0tTtkV.d.mts} +11 -11
  114. package/dist/{schemas-CQe4xCRn.d.mts → schemas-D6JvwH-h.d.mts} +2 -2
  115. package/dist/{schemas-Cz7H2f7S.d.mts → schemas-DChhgfU0.d.mts} +7 -7
  116. package/dist/{schemas-CSeLgroC.d.mts → schemas-DNUfTOJ0.d.mts} +1 -1
  117. package/dist/{schemas-bcDK-fK3.d.mts → schemas-mTWvDwx9.d.mts} +8 -8
  118. package/dist/services/adapter-runtime/index.d.mts +3 -3
  119. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  120. package/dist/services/adapter-runtime/schemas.d.mts +1 -1
  121. package/dist/services/adapter-subsystem/index.d.mts +3 -3
  122. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  123. package/dist/services/agent-runtime/index.d.mts +2 -2
  124. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  125. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  126. package/dist/services/capability/index.d.mts +2 -2
  127. package/dist/services/code-execution/index.d.mts +1 -1
  128. package/dist/services/codebase/index.d.mts +2 -2
  129. package/dist/services/codebase/namespace.d.mts +1 -1
  130. package/dist/services/codebase/schemas.d.mts +1 -1
  131. package/dist/services/compression/index.d.mts +2 -2
  132. package/dist/services/compression/namespace.d.mts +1 -1
  133. package/dist/services/compression/schemas.d.mts +1 -1
  134. package/dist/services/context-rules/index.d.mts +4 -4
  135. package/dist/services/execution-target/index.d.mts +3 -3
  136. package/dist/services/execution-target/namespace.d.mts +1 -1
  137. package/dist/services/execution-target/schemas.d.mts +1 -1
  138. package/dist/services/filesystem/index.d.mts +1 -1
  139. package/dist/services/filesystem/namespace.d.mts +6 -6
  140. package/dist/services/filesystem/schemas.d.mts +3 -3
  141. package/dist/services/harness/index.d.mts +3 -3
  142. package/dist/services/index.d.mts +57 -57
  143. package/dist/services/log-import/browser.d.mts +2 -2
  144. package/dist/services/log-import/index.d.mts +2 -2
  145. package/dist/services/log-import/log-import.d.mts +1 -1
  146. package/dist/services/log-import/namespace.d.mts +2 -2
  147. package/dist/services/log-import/schemas.d.mts +1 -1
  148. package/dist/services/materialization/index.d.mts +1 -1
  149. package/dist/services/model-registry/index.d.mts +1 -1
  150. package/dist/services/preferences/index.d.mts +2 -2
  151. package/dist/services/preferences/schemas.d.mts +1 -1
  152. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  153. package/dist/services/provider-context/index.d.mts +1 -1
  154. package/dist/services/session/handlers/index.d.mts +1 -1
  155. package/dist/services/session/index.d.mts +9 -9
  156. package/dist/services/session/messages/namespace.d.mts +1 -1
  157. package/dist/services/session/orchestrator-testing/index.d.mts +1 -1
  158. package/dist/services/session/session-events/namespace.d.mts +1 -1
  159. package/dist/services/session/storage/namespace.d.mts +1 -1
  160. package/dist/services/session/storage/schema.d.mts +1 -1
  161. package/dist/services/session/testing/orchestrator-shared.d.mts +1 -1
  162. package/dist/services/session/turns/namespace.d.mts +1 -1
  163. package/dist/services/session-editor/index.d.mts +1 -1
  164. package/dist/services/settings/index.d.mts +3 -3
  165. package/dist/services/settings/namespace.d.mts +8 -8
  166. package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
  167. package/dist/services/settings/storage/index.d.mts +3 -3
  168. package/dist/services/settings/storage/providers-namespace.d.mts +1 -1
  169. package/dist/services/subagent/index.d.mts +1 -1
  170. package/dist/services/subagent-template/index.d.mts +2 -2
  171. package/dist/services/subagent-template/namespace.d.mts +1 -1
  172. package/dist/services/subagent-template/schemas.d.mts +1 -1
  173. package/dist/services/tool-approval/index.d.mts +1 -1
  174. package/dist/services/tools/index.d.mts +1 -1
  175. package/dist/services/tray-menu/index.d.mts +3 -3
  176. package/dist/services/tray-menu/namespace.d.mts +1 -1
  177. package/dist/services/tray-menu/schemas.d.mts +1 -1
  178. package/dist/services/turn/index.d.mts +1 -1
  179. package/dist/services/turn/namespace.d.mts +1 -1
  180. package/dist/services/workflow-transitions/index.d.mts +1 -1
  181. package/dist/{session-lineage-CEyJWg_J.d.mts → session-lineage-9_qwkjUq.d.mts} +1 -1
  182. package/dist/{src-CmLn6zYj.mjs → src-BZdlyUxT.mjs} +1 -1
  183. package/dist/storage/drizzle/client.d.mts +1 -1
  184. package/dist/storage/drizzle/index.d.mts +1 -1
  185. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  186. package/dist/storage/handlers/index.d.mts +1 -1
  187. package/dist/{transition-bYkXnLY2.d.mts → transition-DNi6L7i2.d.mts} +2 -2
  188. package/dist/{types-Bnc-pdB12.d.mts → types-BeAxyCuU2.d.mts} +1 -1
  189. package/dist/{types-BNKqcHfP.d.mts → types-DXobLxrf.d.mts} +18 -18
  190. package/dist/ui-kernel/index.d.mts +1 -1
  191. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  192. package/dist/{view-builder-CA5qUx85.d.mts → view-builder-B5gP9RnN.d.mts} +1 -1
  193. package/dist/worker-Cmme3rMM.mjs +1 -0
  194. package/dist/{workflow-5yHn_Knq.mjs → workflow-DNks09Ip.mjs} +1 -1
  195. package/dist/workflow-engine/execution-attempt-repository.d.mts +1 -1
  196. package/dist/workflow-engine/index.d.mts +89 -51
  197. package/dist/workflow-engine/index.mjs +1 -1
  198. package/dist/workflow-engine/package.d.mts +1 -1
  199. package/dist/workflow-engine/package.mjs +1 -1
  200. package/dist/workflow-engine/provider-operation.d.mts +1 -1
  201. package/dist/workflow-engine/testing/conformance.d.mts +1 -1
  202. package/dist/workflow-engine/testing/conformance.mjs +2 -2
  203. package/dist/workflow-engine/testing/index.d.mts +3 -1
  204. package/dist/workflow-engine/testing/index.mjs +1 -1
  205. package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
  206. package/dist/workflow-engine/testing/sqlite.mjs +50 -33
  207. package/package.json +1 -1
  208. package/dist/artifact-Cxm5ZX7L.mjs +0 -1
  209. package/dist/package-BT94BLu4.mjs +0 -7
  210. package/dist/worker-Cx1JDOB9.mjs +0 -1
  211. package/dist/{adapter-binding-DhANVB-O.d.mts → adapter-binding-CTssGlH_.d.mts} +0 -0
  212. package/dist/{attempt-fixtures-CMx-2OlG.mjs → attempt-fixtures-B8FSy_vs.mjs} +0 -0
  213. package/dist/{attempt-record-codec-D2Gb_epJ.mjs → attempt-record-codec-BrungudT.mjs} +0 -0
  214. package/dist/{base-orchestrator-tAgnJAKu.d.mts → base-orchestrator-C5Z9Aowq.d.mts} +0 -0
  215. package/dist/{capability-service-Cpkonrc0.d.mts → capability-service-DX3wLjdt.d.mts} +0 -0
  216. package/dist/{client-At2zn3yg.d.mts → client-BsXMxeCN.d.mts} +0 -0
  217. package/dist/{client-binary-version-verifier-EOj8xXqm.d.mts → client-binary-version-verifier-uMFQoKZj.d.mts} +0 -0
  218. package/dist/{clients-namespace-CVRwXq8f.d.mts → clients-namespace-1hXA6qNd.d.mts} +0 -0
  219. package/dist/{config-namespace-D7GbrasR.d.mts → config-namespace-Bpq9WOY4.d.mts} +0 -0
  220. package/dist/{create-static-mount-BIH26VH8.mjs → create-static-mount-Cr24q94C.mjs} +0 -0
  221. package/dist/{definition-VK1rERAp.d.mts → definition-Ckt_WmJw.d.mts} +0 -0
  222. package/dist/{extension-discovery-B0ZL076T.d.mts → extension-discovery-Dx118u_N.d.mts} +0 -0
  223. package/dist/{filesystem-service-BWoNtujU.d.mts → filesystem-service-DtApanQk.d.mts} +0 -0
  224. package/dist/{index-Bk0Xjk-B.d.mts → index-1AKlC3kZ.d.mts} +0 -0
  225. package/dist/{index-CDA33y5A.d.mts → index-5KVPGsig.d.mts} +0 -0
  226. package/dist/{index-8a41yDOl.d.mts → index-B4lidHiL.d.mts} +0 -0
  227. package/dist/{index-DzHc6hsJ.d.mts → index-Bw7benCh.d.mts} +0 -0
  228. package/dist/{index-DXSVC0bM.d.mts → index-C0zo4Id_.d.mts} +0 -0
  229. package/dist/{index-BL1F1xYB.d.mts → index-C3n8beRR.d.mts} +0 -0
  230. package/dist/{index-BBkJsViX2.d.mts → index-C4DMSFLE2.d.mts} +6 -6
  231. /package/dist/{index-C8oBOTl_.d.mts → index-C86rKLPD.d.mts} +0 -0
  232. /package/dist/{index-BIlFSGnW.d.mts → index-CIl66QhT.d.mts} +0 -0
  233. /package/dist/{index-D4XNkbM4.d.mts → index-CUcEfh31.d.mts} +0 -0
  234. /package/dist/{index-DwY1Mt9a.d.mts → index-CrDp6vHG.d.mts} +0 -0
  235. /package/dist/{index-DCfYa3cF.d.mts → index-CzKJC3Bt.d.mts} +0 -0
  236. /package/dist/{index-Ccaqmi0J.d.mts → index-DK8lSIvY.d.mts} +0 -0
  237. /package/dist/{index-Du-eXjEN.d.mts → index-DLsopffG.d.mts} +0 -0
  238. /package/dist/{index-BcPO9w0j.d.mts → index-DNN9jOVO.d.mts} +0 -0
  239. /package/dist/{index-krTCFThl2.d.mts → index-DSRxn5Zr2.d.mts} +0 -0
  240. /package/dist/{index-CSJOBx3H.d.mts → index-Dfv9hyZE.d.mts} +0 -0
  241. /package/dist/{index-BpsurXEW.d.mts → index-DqS8eCAT.d.mts} +0 -0
  242. /package/dist/{index-CjazerMN.d.mts → index-Dv5aNxoa.d.mts} +0 -0
  243. /package/dist/{index-CWeWBh-_.d.mts → index-DxxORQny.d.mts} +0 -0
  244. /package/dist/{index-BTHdi23O.d.mts → index-DyBuGOvY.d.mts} +0 -0
  245. /package/dist/{index-DwKPj8jD.d.mts → index-lLuIAmRB.d.mts} +0 -0
  246. /package/dist/{index-Bn1JTbn_2.d.mts → index-qLkIGcgv2.d.mts} +0 -0
  247. /package/dist/{index-DCHdW5g-.d.mts → index-tCFckLG6.d.mts} +0 -0
  248. /package/dist/{json-value-BKUDMT7k.d.mts → json-value-Bjl8jzom.d.mts} +0 -0
  249. /package/dist/{jsonl-transport-3yp3clGp.mjs → jsonl-transport-D4ch0vsf.mjs} +0 -0
  250. /package/dist/{lib-DF6sgNx_.mjs → lib-BLdnqIFF.mjs} +0 -0
  251. /package/dist/{namespace-BHb_9sh4.d.mts → namespace-BHkEHrUG.d.mts} +0 -0
  252. /package/dist/{namespace-KTRWfIPy.d.mts → namespace-Bivbsfms.d.mts} +0 -0
  253. /package/dist/{namespace-BiEV44Mk.d.mts → namespace-C-4xI2rm.d.mts} +0 -0
  254. /package/dist/{namespace-BNNFD-ul.d.mts → namespace-CvCk6Y9i.d.mts} +0 -0
  255. /package/dist/{namespace-BgaVgd00.d.mts → namespace-DXrdGpbs.d.mts} +0 -0
  256. /package/dist/{namespace-B3MnuAqp.d.mts → namespace-Dwf7aOLt.d.mts} +0 -0
  257. /package/dist/{namespace-Czr38fiF.d.mts → namespace-E4ajXk0W.d.mts} +0 -0
  258. /package/dist/{namespace-CjmNxtr1.d.mts → namespace-XUB3XnBK.d.mts} +0 -0
  259. /package/dist/{orchestrator-shared-Cwc6JKkV.d.mts → orchestrator-shared-D2I9gyOl.d.mts} +0 -0
  260. /package/dist/{packages-DTz_1dCa.d.mts → packages-Dj9Nul23.d.mts} +0 -0
  261. /package/dist/{providers-namespace-Bming6U8.d.mts → providers-namespace-BA0JT--_.d.mts} +0 -0
  262. /package/dist/{runtime-inputs-DeOea-ab.d.mts → runtime-inputs-CIYLDuBM.d.mts} +0 -0
  263. /package/dist/{schema-DFCBjTB7.d.mts → schema-B098Jz9p.d.mts} +0 -0
  264. /package/dist/{schemas-DqWwz4eR.d.mts → schemas-ADuQFkhH.d.mts} +0 -0
  265. /package/dist/{schemas-BLy33xay.d.mts → schemas-BZyi7v9g.d.mts} +0 -0
  266. /package/dist/{schemas-DYIVJDlx.d.mts → schemas-COQUToGQ.d.mts} +0 -0
  267. /package/dist/{schemas-DwqibWUL.d.mts → schemas-DKy_XYjq.d.mts} +0 -0
  268. /package/dist/{schemas-DTBWnWjN.d.mts → schemas-DMxM4U1A.d.mts} +0 -0
  269. /package/dist/{schemas-GyKYcV-Z2.d.mts → schemas-DNvDh0eE2.d.mts} +0 -0
  270. /package/dist/{schemas-BkCqhK3X.d.mts → schemas-DYtUc2WA.d.mts} +0 -0
  271. /package/dist/{server-lifecycle-_m_x1_TC.d.mts → server-lifecycle-B8UabaW3.d.mts} +0 -0
  272. /package/dist/{src-DdaPoQOD.mjs → src-D9PYcdDS.mjs} +0 -0
  273. /package/dist/{storage-namespace-zRXWqAfO.d.mts → storage-namespace-DITavhRL.d.mts} +0 -0
  274. /package/dist/{storage-namespace-definition-CsaZPU3n.d.mts → storage-namespace-definition-1uCuoHvM.d.mts} +0 -0
  275. /package/dist/{types-CccTiXH2.d.mts → types-BlaguWul.d.mts} +0 -0
  276. /package/dist/{types-nor1SQLZ.d.mts → types-CbXf822E.d.mts} +0 -0
  277. /package/dist/{types-DjxvRcX6.d.mts → types-KF8zuMhi.d.mts} +0 -0
  278. /package/dist/{types-Dswhi1L9.d.mts → types-RWRXplnM.d.mts} +0 -0
  279. /package/dist/{types-DXGVwrQn.d.mts → types-nY8yr3th.d.mts} +0 -0
  280. /package/dist/{window-registry-DQ7udUzI.d.mts → window-registry-Dq5uOWpH.d.mts} +0 -0
@@ -1,4 +1,4 @@
1
- import { I as RecordAllocationInput, Mt as AttemptOutcomeControlObservation$1, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent$1, dt as ProviderOperationOwnershipRecord, it as ProviderOperationClaim, j as OutcomeCodec, r as AllocationRecordingDecision, rt as ProcessBoundProvisionerLossProof, s as AttemptControlState, u as BeginProvisioningInput, w as ExecutionOwnerId, x as ExecutionAttemptRepository, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision } from "../../execution-attempt-repository-DSpz2kyW.mjs";
1
+ import { Ht as AttemptControlEvidence, I as RecordAllocationInput, Mt as AttemptOutcomeControlObservation$1, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent$1, dt as ProviderOperationOwnershipRecord, it as ProviderOperationClaim, j as OutcomeCodec, r as AllocationRecordingDecision, rt as ProcessBoundProvisionerLossProof, s as AttemptControlState, u as BeginProvisioningInput, w as ExecutionOwnerId, x as ExecutionAttemptRepository, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision } from "../../execution-attempt-repository-BoNwNybg.mjs";
2
2
  import { BoundedRecoveryEvidence, ExecutionAttemptInstruction, ExecutionAttemptPreparationResult, ProviderAllocationRef, WorkerAllocationLifetime, WorkflowRunResult } from "@makaio/framework/contracts";
3
3
 
4
4
  //#region subsystems/workflow-engine/src/testing/attempt-record-codec.d.ts
@@ -62,6 +62,8 @@ interface InMemoryAttemptRepositoryState {
62
62
  readonly requestBindings: Map<string, Map<string, string>>;
63
63
  /** First owner cancellation request for each attempt, surviving controller replacement. */
64
64
  readonly cancellations: Map<string, ExecutionAttemptCancellationIntent$1>;
65
+ /** Immutable facts keyed by Attempt, then numeric revision and generation. */
66
+ readonly controlEvidence: Map<string, Map<string, AttemptControlEvidence>>;
65
67
  }
66
68
  /**
67
69
  * The in-memory realization together with the state backing it.
@@ -1 +1 @@
1
- import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,l as c,m as l,n as u,o as d,s as f,u as p,v as m,x as h,y as g}from"../../execution-attempt-repository-CWbgCTwA.mjs";import{a as _,i as v,n as y,o as b,t as x}from"../../execution-attempt-owner-recovery-D4APLAvt.mjs";import{isProviderOperationResolved as S}from"../provider-operation.mjs";import{a as C,c as w,d as T,f as E,i as D,l as ee,n as O,o as k,p as A,r as j,s as M,t as N,u as P}from"../../attempt-record-codec-D2Gb_epJ.mjs";import{a as F,c as I,d as L,f as R,i as z,l as B,m as V,n as H,o as U,p as W,r as G,s as K,t as q,u as J}from"../../attempt-fixtures-CMx-2OlG.mjs";import{randomUUID as Y}from"node:crypto";import{BoundedRecoveryEvidenceSchema as X}from"@makaio/framework/contracts";function Z(e){if(e.kind===`accepted`||e.kind===`duplicate`)return e;throw Error(`Expected a committed test outcome, received ${e.kind}`)}function Q(e,t){return{...e,status:`settled`,settlementKind:t,claimable:!1,operationStartGate:`closed`}}function $(F,I={}){let L=I.attempts??new Map,R=I.operations??new Map,z=e=>R.get(e)?.obligation===`terminal-convergence`,B=I.committedOutcomes??new Map,V=I.outcomeControlObservations??new Map,H=I.activeAttempts??new Map,U=I.requestBindings??new Map,W=I.cancellations??new Map,G=e=>{let t=e.settlementKind!=null,n=!t&&H.get(e.executionId)===e.executionAttemptId;return s({matchesExecution:!0,settled:t,active:n,allocated:n&&e.allocationRef!==null&&!z(e.executionAttemptId)})},K=e=>{let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:S(t,n)?{kind:`resolved`,attempt:t}:n.token===null||n.token!==e.token||n.generation!==e.generation||n.ownerId!==e.ownerId?{kind:`stale`,attempt:t}:{kind:`authorized`,attempt:t,operation:n}},q=(e,t)=>{e.completionEvidence===null&&R.set(e.executionAttemptId,{...e,completionEvidence:t})},J=(e,t)=>{let n=M(e.allocationRef),r=K(e.claim);if(r.kind!==`not-found`&&T(r.attempt,n),r.kind===`resolved`)return{kind:`resolved`,allocationRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i,operation:a}=r;if(i.allocationRef!==null)return f(i.allocationRef,n)?{kind:`duplicate`,allocationRef:i.allocationRef}:{kind:`conflict`,allocationRef:i.allocationRef};let o=H.get(i.executionId)===i.executionAttemptId;return L.set(i.executionAttemptId,{...i,status:i.settlementKind===null?`allocated`:i.status,allocationRef:n,claimable:i.settlementKind===null&&t&&o}),R.set(a.executionAttemptId,{...a,obligation:`allocation-control`}),{kind:`recorded`}},Z={async getAttemptWithAllocation(e){return L.get(e)??null},async recordDiscoveredAllocation(e){return J(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=w(e),r=K(e.claim);if(r.kind===`stale`)return{kind:`stale`,storedRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.executionId===e.executionId?i.allocationRef===null?{kind:`not-allocated`}:f(i.allocationRef,t)?(L.set(i.executionAttemptId,{...i,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:i.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=D(new Date().toISOString()),n=[];for(let r of L.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&D(r.claimExpiresAt)<t||n.push(A(r)));return n.sort(O)},async listOpenProviderOperations(e){if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw RangeError(`limit must be a positive safe integer`);let t=D(e.observedAt),n=[];for(let e of R.values()){let r=L.get(e.executionAttemptId);!r||S(r,e)||e.ownerId!==null&&e.leaseExpiresAt!==null&&D(e.leaseExpiresAt)>t||n.push({attempt:r,operation:e})}return n.sort((e,t)=>O(e.attempt,t.attempt)).slice(0,e.limit)}},$=e=>{let t=j(e.bootstrapTimeoutMs);if(L.has(e.executionAttemptId))throw new u(e.executionAttemptId);let n={executionAttemptId:e.executionAttemptId,executionId:e.executionId,instruction:e.instruction,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,...t,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null,...N},r=H.get(e.executionId),i=r===void 0?void 0:L.get(r);return i!==void 0&&L.set(i.executionAttemptId,{...i,claimable:i.status===`allocated`?!1:i.claimable,operationStartGate:`closed`}),L.set(e.executionAttemptId,n),H.set(e.executionId,e.executionAttemptId),n};return{async createAttempt(e){return $({...e,instruction:b(e.instruction)})},async ensureAttempt(e){let t=v(e),n=U.get(t.executionId),r=n?.get(t.requestKey);if(r!==void 0)return y(t,L.get(r)??null);let i=$(t),a=n??new Map;return a.set(t.requestKey,i.executionAttemptId),U.set(t.executionId,a),{kind:`created`,attempt:structuredClone(i)}},async readAttemptSettlement(e){let t=_(e);return x(t,{attempt:L.get(t.executionAttemptId)??null,activeAttemptId:H.get(t.executionId)??null,outcomeText:B.get(t.executionAttemptId)??null,controlObservation:V.get(t.executionAttemptId)??null},F)},async readBootstrapStartState(e){let t=L.get(e.executionAttemptId);return!t||t.executionId!==e.executionId?null:{settled:t.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:t.allocationRef!==null,allocationTerminated:z(e.executionAttemptId),operationStartGate:t.operationStartGate,bootstrapDeadlineAt:t.bootstrapDeadlineAt??null}},async beginProvisioning(e){let t=k(e.allocationLifetime),n=L.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};if(n.settlementKind!=null)return{kind:`resolved`,allocationRef:n.allocationRef};if(n.allocationRef!==null)return{kind:`allocated`,allocationRef:n.allocationRef};if(n.operationStartGate===`closed`)return{kind:`fenced`};if(n.status!==`pending`)return{kind:`already-provisioning`};L.set(e.executionAttemptId,{...n,status:`provisioning`,providerId:e.providerId,allocationLifetime:t,provisionerIncarnationId:e.provisionerIncarnationId});let r={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:C(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{executionAttemptId:e.executionAttemptId,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt,obligation:`provisioning-resolution`,failureCount:0,lastFailure:null,completionEvidence:null}),{kind:`started`,claim:r}},async getProviderOperation(e){return R.get(e)??null},async renewProviderOperationClaim(e){let t=K(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=C(e.leaseExpiresAt);return R.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(S(t,n))return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&D(n.leaseExpiresAt)>D(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:C(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{...n,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt}),{kind:`claimed`,claim:r}},async handoffProviderOperation(e){let t=e.evidence===void 0?void 0:X.parse(e.evidence),n=K(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t??n.operation.lastFailure}),{kind:`recorded`}):{kind:n.kind}},async recordProviderOperationUncertainty(e){let t=X.parse(e.evidence),n=K(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async completeProviderOperation(e){let t=X.parse(e.evidence),n=L.get(e.claim.executionAttemptId),r=R.get(e.claim.executionAttemptId);return!n||!r?{kind:`not-found`}:r.token!==e.claim.token||r.generation!==e.claim.generation||r.ownerId!==e.claim.ownerId?{kind:`stale`}:S(n,r)?{kind:`already-completed`}:r.completionEvidence===null?(q(r,t),n.settlementKind===null?{kind:`evidence-recorded`}:{kind:`completed`}):{kind:`evidence-recorded`}},async recordAllocation(e){return J(e,!0)},async recordProvisioningAbsent(e){let t=X.parse(e.evidence),n=K(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?r.settlementKind===null?(L.set(r.executionAttemptId,Q(r,`abandoned`)),q(i,t),{kind:`recorded`}):(q(i,t),{kind:`completed`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=X.parse(e.proof.evidence),n=K(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n,a=g(r,e);return a===null?r.settlementKind===null?(L.set(r.executionAttemptId,Q(r,`abandoned`)),q(i,t),{kind:`recorded`}):(q(i,t),{kind:`completed`}):a},async recordAllocationTerminated(e){let t=X.parse(e.evidence),n=K(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(R.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=K(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.settlementKind===null?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(L.set(n.executionAttemptId,Q(n,`infrastructure-failure`)),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`resolved`}:{kind:`not-found`}},async registerRuntime(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=G(t)??h(t,e);if(n!==null)return n;let r=t.runtimeGeneration+1;return L.set(t.executionAttemptId,{...t,runtimeGeneration:r,runtimeIncarnationId:e.runtimeIncarnationId,runtimeReadyAt:null,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null}),{kind:`registered`,runtimeGeneration:r}},async admitOperation(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=G(t);if(n!==null)return n;let r=o(t,e,t.activeOperationId!==null&&t.activeOperationKey===e.admissionKey&&t.activeOperationAdmittedAt===null?C(new Date().toISOString()):``,t);if(r!==null)return r;let i=crypto.randomUUID(),a=C(new Date().toISOString());return L.set(t.executionAttemptId,{...t,activeOperationId:i,activeOperationKind:e.operationKind,activeOperationKey:e.admissionKey,activeOperationGeneration:t.runtimeGeneration,activeOperationAdmittedAt:a}),{kind:`admitted`,operationId:i,runtimeGeneration:t.runtimeGeneration,admittedAt:a}},async getInstruction(e){let t=L.get(e.executionAttemptId);return t?.executionId===e.executionId?t.instruction:null},async reportOperation(e){let t=P(e.result),n=L.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=m({matchesExecution:!0,settled:n.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:n.allocationRef!==null&&!z(e.executionAttemptId)},n,n,{...e,result:t});if(r!==null)return r;let i=ee([...n.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return L.set(e.executionAttemptId,{...n,preparationReceipts:i,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:e.operationId}),{kind:`accepted`,binding:t.binding}},async completeOperation(t){let n=L.get(t.executionAttemptId);if(n===void 0)return{kind:`not-found`};if(n.settlementKind!=null)return{kind:`resolved`};let r=e(n,t);return r===null?(L.set(n.executionAttemptId,{...n,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:t.operationId}),{kind:`completed`}):r},async markRuntimeReady(e){let t=C(e.readyAt),r=L.get(e.executionAttemptId);if(r===void 0||r.executionId!==e.executionId)return{kind:`not-found`};let i=G(r)??n(r,e);return i===null?(L.set(r.executionAttemptId,{...r,runtimeReadyAt:t}),{kind:`ready`,acceptedAt:t}):i},async getAttemptControlState(e){let t=L.get(e);return t===void 0?null:E(t)},async requestAttemptCancellation(e){let t=i(e),n=L.get(t.executionAttemptId);if(n===void 0||n.executionId!==t.executionId)return{kind:`not-found`};let r=c(W.get(t.executionAttemptId)??null,t,new Date().toISOString());return r.kind===`conflict`?r:(W.set(t.executionAttemptId,{...r.intent}),L.set(t.executionAttemptId,{...n,operationStartGate:`closed`}),r)},async requestCancellation(e){let t=a(e),n={...t,requestKey:Y()},r=new Date().toISOString(),i=[...L].filter(([,e])=>e.executionId===t.executionId).map(([e,t])=>{let i=c(W.get(e)??null,n,r);if(i.kind===`conflict`)throw Error(`Conflicting generated cancellation request key`);return{id:e,attempt:t,intent:i.intent}});for(let{id:e,attempt:t,intent:n}of i)W.set(e,{...n}),L.set(e,{...t,operationStartGate:`closed`})},async readCancellation(e){let t=W.get(e);return t===void 0?null:{...t}},async getActiveAttempt(e,t){return H.get(e)===t?L.get(t)??null:null},canonicalizeOutcome(e){return d(F,e)},decodeOutcome(e){return t(F,e)},async commitOutcome(e){let n=e.result;if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let i=L.get(e.executionAttemptId);if(i===void 0)return{kind:`fenced`};let a=B.get(e.executionAttemptId);if(a!==void 0){let i=t(F,a);return r(a,n.text)?{kind:`duplicate`,outcome:i,text:a,controlObservation:structuredClone(V.get(e.executionAttemptId)??null)}:{kind:`conflict`}}if(i.settlementKind!=null)return{kind:`conflict`};l(i,e.runtimeFence);let o=p(W.get(e.executionAttemptId)??null);return B.set(e.executionAttemptId,n.text),V.set(e.executionAttemptId,o),L.set(e.executionAttemptId,Q(i,`outcome`)),{kind:`accepted`,outcome:t(F,n.text),text:n.text,controlObservation:structuredClone(o)}},async abandonPendingAttempt(e,t){if(H.get(t)!==e)return{kind:`fenced`};let n=L.get(e);return n?n.status===`allocated`?{kind:`allocated`}:n.status===`provisioning`?{kind:`provisioning`}:n.status===`settled`?{kind:n.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:(L.set(e,Q(n,`abandoned`)),{kind:`abandoned`}):{kind:`fenced`}},recovery:Z,attempts:L,operations:R,committedOutcomes:B,outcomeControlObservations:V,activeAttempts:H,requestBindings:U,cancellations:W}}export{N as INITIAL_ATTEMPT_CONTROL_STATE,q as TEST_OWNER_ID,H as TEST_PROVIDER_ID,G as TEST_PROVISIONER_INCARNATION_ID,z as allocateTestAttempt,F as beginTestProvisioning,$ as createInMemoryAttemptRepository,U as driveTestAttemptToAllocated,K as leaseAt,I as makeBeginProvisioningInput,B as makeEvidence,J as makeProcessLossProof,L as makeTestAllocationRef,R as makeTestInstruction,W as makeTestWorkflowResult,Z as requireCommittedOutcome,V as workflowRunResultOutcomeCodec};
1
+ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,l as c,m as l,n as u,o as ee,s as d,u as f,v as p,x as m,y as h}from"../../execution-attempt-repository-CWbgCTwA.mjs";import{a as g,i as _,n as v,o as y,t as te}from"../../execution-attempt-owner-recovery-D4APLAvt.mjs";import{i as b,n as x,r as ne,t as S}from"../../attempt-control-evidence-BKw1U3wL.mjs";import{isProviderOperationResolved as C}from"../provider-operation.mjs";import{a as w,c as T,d as E,f as D,i as O,l as k,n as A,o as j,p as re,r as ie,s as M,t as N,u as P}from"../../attempt-record-codec-BrungudT.mjs";import{a as F,c as I,d as L,f as R,i as z,l as B,m as V,n as H,o as U,p as W,r as G,s as K,t as q,u as J}from"../../attempt-fixtures-B8FSy_vs.mjs";import{randomUUID as ae}from"node:crypto";import{BoundedRecoveryEvidenceSchema as Y}from"@makaio/framework/contracts";function X(e){if(e.kind===`accepted`||e.kind===`duplicate`)return e;throw Error(`Expected a committed test outcome, received ${e.kind}`)}function Z(e,t){return{...e,status:`settled`,settlementKind:t,claimable:!1,operationStartGate:`closed`}}function Q(F,I={}){let L=I.attempts??new Map,R=I.operations??new Map,z=e=>R.get(e)?.obligation===`terminal-convergence`,B=I.committedOutcomes??new Map,V=I.outcomeControlObservations??new Map,H=I.activeAttempts??new Map,U=I.requestBindings??new Map,W=I.cancellations??new Map,G=I.controlEvidence??new Map,K=e=>{let t=e.settlementKind!=null,n=!t&&H.get(e.executionId)===e.executionAttemptId;return s({matchesExecution:!0,settled:t,active:n,allocated:n&&e.allocationRef!==null&&!z(e.executionAttemptId)})},q=e=>{let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:C(t,n)?{kind:`resolved`,attempt:t}:n.token===null||n.token!==e.token||n.generation!==e.generation||n.ownerId!==e.ownerId?{kind:`stale`,attempt:t}:{kind:`authorized`,attempt:t,operation:n}},J=(e,t)=>{e.completionEvidence===null&&R.set(e.executionAttemptId,{...e,completionEvidence:t})},X=(e,t)=>{let n=M(e.allocationRef),r=q(e.claim);if(r.kind!==`not-found`&&E(r.attempt,n),r.kind===`resolved`)return{kind:`resolved`,allocationRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i,operation:a}=r;if(i.allocationRef!==null)return d(i.allocationRef,n)?{kind:`duplicate`,allocationRef:i.allocationRef}:{kind:`conflict`,allocationRef:i.allocationRef};let o=H.get(i.executionId)===i.executionAttemptId;return L.set(i.executionAttemptId,{...i,status:i.settlementKind===null?`allocated`:i.status,allocationRef:n,claimable:i.settlementKind===null&&t&&o}),R.set(a.executionAttemptId,{...a,obligation:`allocation-control`}),{kind:`recorded`}},Q={async getAttemptWithAllocation(e){return L.get(e)??null},async recordDiscoveredAllocation(e){return X(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=T(e),r=q(e.claim);if(r.kind===`stale`)return{kind:`stale`,storedRef:r.attempt.allocationRef};if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.executionId===e.executionId?i.allocationRef===null?{kind:`not-allocated`}:d(i.allocationRef,t)?(L.set(i.executionAttemptId,{...i,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:i.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=O(new Date().toISOString()),n=[];for(let r of L.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&O(r.claimExpiresAt)<t||n.push(re(r)));return n.sort(A)},async listOpenProviderOperations(e){if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw RangeError(`limit must be a positive safe integer`);let t=O(e.observedAt),n=[];for(let e of R.values()){let r=L.get(e.executionAttemptId);!r||C(r,e)||e.ownerId!==null&&e.leaseExpiresAt!==null&&O(e.leaseExpiresAt)>t||n.push({attempt:r,operation:e})}return n.sort((e,t)=>A(e.attempt,t.attempt)).slice(0,e.limit)}},$=e=>{let t=ie(e.bootstrapTimeoutMs);if(L.has(e.executionAttemptId))throw new u(e.executionAttemptId);let n={executionAttemptId:e.executionAttemptId,executionId:e.executionId,instruction:e.instruction,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,...t,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null,...N},r=H.get(e.executionId),i=r===void 0?void 0:L.get(r);return i!==void 0&&L.set(i.executionAttemptId,{...i,claimable:i.status===`allocated`?!1:i.claimable,operationStartGate:`closed`}),L.set(e.executionAttemptId,n),H.set(e.executionId,e.executionAttemptId),n};return{async createAttempt(e){return $({...e,instruction:y(e.instruction)})},async ensureAttempt(e){let t=_(e),n=U.get(t.executionId),r=n?.get(t.requestKey);if(r!==void 0)return v(t,L.get(r)??null);let i=$(t),a=n??new Map;return a.set(t.requestKey,i.executionAttemptId),U.set(t.executionId,a),{kind:`created`,attempt:structuredClone(i)}},async readAttemptSettlement(e){let t=g(e);return te(t,{attempt:L.get(t.executionAttemptId)??null,activeAttemptId:H.get(t.executionId)??null,outcomeText:B.get(t.executionAttemptId)??null,controlObservation:V.get(t.executionAttemptId)??null},F)},async readBootstrapStartState(e){let t=L.get(e.executionAttemptId);return!t||t.executionId!==e.executionId?null:{settled:t.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:t.allocationRef!==null,allocationTerminated:z(e.executionAttemptId),operationStartGate:t.operationStartGate,bootstrapDeadlineAt:t.bootstrapDeadlineAt??null}},async beginProvisioning(e){let t=j(e.allocationLifetime),n=L.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};if(n.settlementKind!=null)return{kind:`resolved`,allocationRef:n.allocationRef};if(n.allocationRef!==null)return{kind:`allocated`,allocationRef:n.allocationRef};if(n.operationStartGate===`closed`)return{kind:`fenced`};if(n.status!==`pending`)return{kind:`already-provisioning`};L.set(e.executionAttemptId,{...n,status:`provisioning`,providerId:e.providerId,allocationLifetime:t,provisionerIncarnationId:e.provisionerIncarnationId});let r={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:w(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{executionAttemptId:e.executionAttemptId,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt,obligation:`provisioning-resolution`,failureCount:0,lastFailure:null,completionEvidence:null}),{kind:`started`,claim:r}},async getProviderOperation(e){return R.get(e)??null},async renewProviderOperationClaim(e){let t=q(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=w(e.leaseExpiresAt);return R.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=L.get(e.executionAttemptId),n=R.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(C(t,n))return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&O(n.leaseExpiresAt)>O(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:w(e.leaseExpiresAt)};return R.set(e.executionAttemptId,{...n,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt}),{kind:`claimed`,claim:r}},async handoffProviderOperation(e){let t=e.evidence===void 0?void 0:Y.parse(e.evidence),n=q(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t??n.operation.lastFailure}),{kind:`recorded`}):{kind:n.kind}},async recordProviderOperationUncertainty(e){let t=Y.parse(e.evidence),n=q(e.claim);return n.kind===`authorized`?(R.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async completeProviderOperation(e){let t=Y.parse(e.evidence),n=L.get(e.claim.executionAttemptId),r=R.get(e.claim.executionAttemptId);return!n||!r?{kind:`not-found`}:r.token!==e.claim.token||r.generation!==e.claim.generation||r.ownerId!==e.claim.ownerId?{kind:`stale`}:C(n,r)?{kind:`already-completed`}:r.completionEvidence===null?(J(r,t),n.settlementKind===null?{kind:`evidence-recorded`}:{kind:`completed`}):{kind:`evidence-recorded`}},async recordAllocation(e){return X(e,!0)},async recordProvisioningAbsent(e){let t=Y.parse(e.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?r.settlementKind===null?(L.set(r.executionAttemptId,Z(r,`abandoned`)),J(i,t),{kind:`recorded`}):(J(i,t),{kind:`completed`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=Y.parse(e.proof.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n,a=h(r,e);return a===null?r.settlementKind===null?(L.set(r.executionAttemptId,Z(r,`abandoned`)),J(i,t),{kind:`recorded`}):(J(i,t),{kind:`completed`}):a},async recordAllocationTerminated(e){let t=Y.parse(e.evidence),n=q(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(R.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=q(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.settlementKind===null?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(L.set(n.executionAttemptId,Z(n,`infrastructure-failure`)),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`resolved`}:{kind:`not-found`}},async registerRuntime(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=K(t)??m(t,e);if(n!==null)return n;let r=t.runtimeGeneration+1;return L.set(t.executionAttemptId,{...t,runtimeGeneration:r,runtimeIncarnationId:e.runtimeIncarnationId,runtimeReadyAt:null,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null}),{kind:`registered`,runtimeGeneration:r}},async admitOperation(e){let t=L.get(e.executionAttemptId);if(t===void 0||t.executionId!==e.executionId)return{kind:`not-found`};let n=K(t);if(n!==null)return n;let r=o(t,e,t.activeOperationId!==null&&t.activeOperationKey===e.admissionKey&&t.activeOperationAdmittedAt===null?w(new Date().toISOString()):``,t);if(r!==null)return r;let i=crypto.randomUUID(),a=w(new Date().toISOString());return L.set(t.executionAttemptId,{...t,activeOperationId:i,activeOperationKind:e.operationKind,activeOperationKey:e.admissionKey,activeOperationGeneration:t.runtimeGeneration,activeOperationAdmittedAt:a}),{kind:`admitted`,operationId:i,runtimeGeneration:t.runtimeGeneration,admittedAt:a}},async getInstruction(e){let t=L.get(e.executionAttemptId);return t?.executionId===e.executionId?t.instruction:null},async reportOperation(e){let t=P(e.result),n=L.get(e.executionAttemptId);if(n===void 0||n.executionId!==e.executionId)return{kind:`not-found`};let r=p({matchesExecution:!0,settled:n.settlementKind!=null,active:H.get(e.executionId)===e.executionAttemptId,allocated:n.allocationRef!==null&&!z(e.executionAttemptId)},n,n,{...e,result:t});if(r!==null)return r;let i=k([...n.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return L.set(e.executionAttemptId,{...n,preparationReceipts:i,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:e.operationId}),{kind:`accepted`,binding:t.binding}},async completeOperation(t){let n=L.get(t.executionAttemptId);if(n===void 0)return{kind:`not-found`};if(n.settlementKind!=null)return{kind:`resolved`};let r=e(n,t);return r===null?(L.set(n.executionAttemptId,{...n,activeOperationId:null,activeOperationKind:null,activeOperationKey:null,activeOperationGeneration:null,activeOperationAdmittedAt:null,lastCompletedOperationId:t.operationId}),{kind:`completed`}):r},async markRuntimeReady(e){let t=w(e.readyAt),r=L.get(e.executionAttemptId);if(r===void 0||r.executionId!==e.executionId)return{kind:`not-found`};let i=K(r)??n(r,e);return i===null?(L.set(r.executionAttemptId,{...r,runtimeReadyAt:t}),{kind:`ready`,acceptedAt:t}):i},async getAttemptControlState(e){let t=L.get(e);return t===void 0?null:D(t)},async requestAttemptCancellation(e){let t=i(e),n=L.get(t.executionAttemptId);if(n===void 0||n.executionId!==t.executionId)return{kind:`not-found`};let r=c(W.get(t.executionAttemptId)??null,t,new Date().toISOString());return r.kind===`conflict`?r:(W.set(t.executionAttemptId,{...r.intent}),L.set(t.executionAttemptId,{...n,operationStartGate:`closed`}),r)},async requestCancellation(e){let t=a(e),n={...t,requestKey:ae()},r=new Date().toISOString(),i=[...L].filter(([,e])=>e.executionId===t.executionId).map(([e,t])=>{let i=c(W.get(e)??null,n,r);if(i.kind===`conflict`)throw Error(`Conflicting generated cancellation request key`);return{id:e,attempt:t,intent:i.intent}});for(let{id:e,attempt:t,intent:n}of i)W.set(e,{...n}),L.set(e,{...t,operationStartGate:`closed`})},async readCancellation(e){let t=W.get(e);return t===void 0?null:{...t}},async readAttemptCancellationControl(e){let{executionId:t,executionAttemptId:n}=e,r=L.get(n);return r===void 0||r.executionId!==t?null:structuredClone({control:D(r),cancellation:W.get(n)??null,evidence:[...G.get(n)?.values()??[]].sort((e,t)=>e.controlRevision-t.controlRevision||e.runtimeGeneration-t.runtimeGeneration)})},async recordAttemptControlReceipt(e){let t=ne(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t,s=`${a}:${o}`,c=G.get(i)??new Map,l=c.get(s),u=S(L.get(i)??null,W.get(i)??null,l?.receipt??null,t);return u.kind===`accepted`&&(c.set(s,{controlRevision:a,runtimeGeneration:o,receipt:r,report:l?.report??null}),G.set(i,c)),u},async reportAttemptControl(e){let t=b(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t,s=`${a}:${o}`,c=G.get(i)??new Map,l=c.get(s),u=x(L.get(i)??null,W.get(i)??null,l?.report??null,t);return u.kind===`accepted`&&(c.set(s,{controlRevision:a,runtimeGeneration:o,receipt:l?.receipt??null,report:r}),G.set(i,c)),u},async getActiveAttempt(e,t){return H.get(e)===t?L.get(t)??null:null},canonicalizeOutcome(e){return ee(F,e)},decodeOutcome(e){return t(F,e)},async commitOutcome(e){let n=e.result;if(H.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let i=L.get(e.executionAttemptId);if(i===void 0)return{kind:`fenced`};let a=B.get(e.executionAttemptId);if(a!==void 0){let i=t(F,a);return r(a,n.text)?{kind:`duplicate`,outcome:i,text:a,controlObservation:structuredClone(V.get(e.executionAttemptId)??null)}:{kind:`conflict`}}if(i.settlementKind!=null)return{kind:`conflict`};l(i,e.runtimeFence);let o=f(W.get(e.executionAttemptId)??null);return B.set(e.executionAttemptId,n.text),V.set(e.executionAttemptId,o),L.set(e.executionAttemptId,Z(i,`outcome`)),{kind:`accepted`,outcome:t(F,n.text),text:n.text,controlObservation:structuredClone(o)}},async abandonPendingAttempt(e,t){if(H.get(t)!==e)return{kind:`fenced`};let n=L.get(e);return n?n.status===`allocated`?{kind:`allocated`}:n.status===`provisioning`?{kind:`provisioning`}:n.status===`settled`?{kind:n.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:(L.set(e,Z(n,`abandoned`)),{kind:`abandoned`}):{kind:`fenced`}},recovery:Q,attempts:L,operations:R,committedOutcomes:B,outcomeControlObservations:V,activeAttempts:H,requestBindings:U,cancellations:W,controlEvidence:G}}export{N as INITIAL_ATTEMPT_CONTROL_STATE,q as TEST_OWNER_ID,H as TEST_PROVIDER_ID,G as TEST_PROVISIONER_INCARNATION_ID,z as allocateTestAttempt,F as beginTestProvisioning,Q as createInMemoryAttemptRepository,U as driveTestAttemptToAllocated,K as leaseAt,I as makeBeginProvisioningInput,B as makeEvidence,J as makeProcessLossProof,L as makeTestAllocationRef,R as makeTestInstruction,W as makeTestWorkflowResult,X as requireCommittedOutcome,V as workflowRunResultOutcomeCodec};
@@ -1,4 +1,4 @@
1
- import { j as OutcomeCodec, x as ExecutionAttemptRepository } from "../../execution-attempt-repository-DSpz2kyW.mjs";
1
+ import { j as OutcomeCodec, x as ExecutionAttemptRepository } from "../../execution-attempt-repository-BoNwNybg.mjs";
2
2
  import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
3
3
 
4
4
  //#region subsystems/workflow-engine/src/testing/sqlite-attempt-repository.d.ts
@@ -1,4 +1,11 @@
1
- import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,n as te,o as ne,r as u,s as d,t as f,u as re,v as ie,x as ae,y as oe}from"../../execution-attempt-repository-CWbgCTwA.mjs";import{a as se,i as ce,n as le,o as p,t as ue}from"../../execution-attempt-owner-recovery-D4APLAvt.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as m,isProviderOperationResolved as h}from"../provider-operation.mjs";import{a as g,c as de,d as fe,i as _,l as v,o as pe,p as me,r as y,s as he,t as ge,u as _e}from"../../attempt-record-codec-D2Gb_epJ.mjs";import{z as b}from"zod";import{BoundedRecoveryEvidenceSchema as x,ExecutionAttemptOperationKindSchema as S,ProviderAllocationRefSchema as C,WorkerAllocationLifetimeSchema as w}from"@makaio/framework/contracts";import{getRawSqlExecutor as ve,isSqliteUniqueViolationError as ye,serializeByKey as T,serializeDatabaseOperation as be}from"@makaio/framework/storage/drizzle";import{sql as E}from"drizzle-orm";const xe=[`CREATE TABLE IF NOT EXISTS test_execution_attempt_cancellation (
1
+ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,n as te,o as ne,r as u,s as d,t as f,u as re,v as ie,x as ae,y as oe}from"../../execution-attempt-repository-CWbgCTwA.mjs";import{a as se,i as ce,n as le,o as p,t as ue}from"../../execution-attempt-owner-recovery-D4APLAvt.mjs";import{i as de,n as fe,r as pe,t as me}from"../../attempt-control-evidence-BKw1U3wL.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as m,isProviderOperationResolved as h}from"../provider-operation.mjs";import{a as g,c as he,d as ge,i as _,l as v,o as _e,p as ve,r as y,s as ye,t as be,u as xe}from"../../attempt-record-codec-BrungudT.mjs";import{z as b}from"zod";import{BoundedRecoveryEvidenceSchema as x,ExecutionAttemptControlReceiptSchema as Se,ExecutionAttemptControlReportSchema as Ce,ExecutionAttemptOperationKindSchema as S,ProviderAllocationRefSchema as C,WorkerAllocationLifetimeSchema as w}from"@makaio/framework/contracts";import{getRawSqlExecutor as we,isSqliteUniqueViolationError as Te,serializeByKey as T,serializeDatabaseOperation as Ee}from"@makaio/framework/storage/drizzle";import{sql as E}from"drizzle-orm";const De=[`CREATE TABLE IF NOT EXISTS test_execution_attempt_control_evidence (
2
+ execution_attempt_id TEXT NOT NULL,
3
+ control_revision INTEGER NOT NULL,
4
+ runtime_generation INTEGER NOT NULL,
5
+ receipt_json TEXT,
6
+ report_json TEXT,
7
+ PRIMARY KEY (execution_attempt_id, control_revision, runtime_generation)
8
+ )`,`CREATE TABLE IF NOT EXISTS test_execution_attempt_cancellation (
2
9
  execution_attempt_id TEXT PRIMARY KEY,
3
10
  request_key TEXT NOT NULL,
4
11
  control_revision INTEGER NOT NULL,
@@ -52,7 +59,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
52
59
  failure_count INTEGER NOT NULL DEFAULT 0,
53
60
  last_failure TEXT,
54
61
  completion_evidence TEXT
55
- )`];function D(e,t,n){let r=e.find(e=>e===t);if(r===void 0)throw Error(`Stored '${n}' value '${t}' is not part of the port's vocabulary`);return r}function O(e,t){return e===null?null:t(JSON.parse(e))}const k=b.object({requestKey:b.string().min(1),controlRevision:b.number().int().positive(),requestedAt:b.string().datetime(),reason:b.string().optional()}),A=b.object({controlRevision:b.number().int().nonnegative(),cancellation:k.nullable()});function j(e){if(e===null)return null;let t=A.parse(JSON.parse(e));if(t.controlRevision!==(t.cancellation?.controlRevision??0))throw Error(`Stored outcome control revision does not match its cancellation receipt`);return t}function M(e){return{runtimeGeneration:e.runtime_generation,runtimeIncarnationId:e.runtime_incarnation_id,runtimeReadyAt:e.runtime_ready_at,operationStartGate:D(f,e.operation_start_gate,`operation_start_gate`),activeOperationId:e.active_operation_id,activeOperationKind:e.active_operation_kind===null?null:S.parse(e.active_operation_kind),activeOperationKey:e.active_operation_key,activeOperationGeneration:e.active_operation_generation,activeOperationAdmittedAt:e.active_operation_admitted_at,lastCompletedOperationId:e.last_completed_operation_id}}function N(e){return{...M(e),executionAttemptId:e.execution_attempt_id,executionId:e.execution_id,instruction:p(JSON.parse(e.instruction)),preparationReceipts:v(JSON.parse(e.preparation_receipts)),status:D(c,e.status,`status`),allocationRef:O(e.allocation_ref,e=>C.parse(e)),createdAt:e.created_at,bootstrapDeadlineAt:e.bootstrap_deadline_at,providerId:e.provider_id,allocationLifetime:e.allocation_lifetime===null?null:w.parse(e.allocation_lifetime),provisionerIncarnationId:e.provisioner_incarnation_id,settlementKind:e.settlement_kind===null?null:D(u,e.settlement_kind,`settlement_kind`),claimable:e.claimable!==0,claimExpiresAt:e.claim_expires_at}}function P(e){return{executionAttemptId:e.execution_attempt_id,generation:e.generation,ownerId:e.owner_id,token:e.token,leaseExpiresAt:e.lease_expires_at,obligation:D(m,e.obligation,`obligation`),failureCount:e.failure_count,lastFailure:O(e.last_failure,e=>x.parse(e)),completionEvidence:O(e.completion_evidence,e=>x.parse(e))}}const F=new Map,I=new Map;function L(e){if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;return n.includes(`SQLITE_BUSY`)||n.startsWith(`Failed query: BEGIN IMMEDIATE`)||n.startsWith(`Failed query: COMMIT`)||L(t.cause)}function R(e){if(typeof e!=`object`||!e)return!1;let t=e;return(typeof t.message==`string`?t.message:``).includes(`no transaction is active`)||R(t.cause)}async function z(){await new Promise(e=>setImmediate(e))}async function Se(e){for(let t=0;;t+=1)try{await e.run(E.raw(`COMMIT`));return}catch(e){if(!L(e)||t===100)throw e;await z()}}async function Ce(e,t){return T(F,e,t)}async function we(e,t){return T(I,e,t)}const B=new WeakMap;async function Te(e,t){let n=(await t.all(E.raw(`PRAGMA database_list`))).find(e=>e.name===`main`)?.file??null;if(n!==null&&n!==``)return`file:${n}`;let r=B.get(e);if(r!==void 0)return r;let i=`connection:${crypto.randomUUID()}`;return B.set(e,i),i}async function V(e,t){let n=await e();if(typeof n!=`function`)return n;if((await n()).rowsAffected>0)return typeof t==`function`?t():t;let r=await e();if(typeof r!=`function`)return r;throw Error(`A guarded transition affected no rows while durable state still permitted it`)}function H(e){return E`EXISTS (SELECT 1 FROM test_provider_operation
62
+ )`];function D(e,t,n){let r=e.find(e=>e===t);if(r===void 0)throw Error(`Stored '${n}' value '${t}' is not part of the port's vocabulary`);return r}function O(e,t){return e===null?null:t(JSON.parse(e))}const k=b.object({requestKey:b.string().min(1),controlRevision:b.number().int().positive(),requestedAt:b.string().datetime(),reason:b.string().optional()}),A=b.object({controlRevision:b.number().int().nonnegative(),cancellation:k.nullable()});function j(e){if(e===null)return null;let t=A.parse(JSON.parse(e));if(t.controlRevision!==(t.cancellation?.controlRevision??0))throw Error(`Stored outcome control revision does not match its cancellation receipt`);return t}function M(e){return{runtimeGeneration:e.runtime_generation,runtimeIncarnationId:e.runtime_incarnation_id,runtimeReadyAt:e.runtime_ready_at,operationStartGate:D(f,e.operation_start_gate,`operation_start_gate`),activeOperationId:e.active_operation_id,activeOperationKind:e.active_operation_kind===null?null:S.parse(e.active_operation_kind),activeOperationKey:e.active_operation_key,activeOperationGeneration:e.active_operation_generation,activeOperationAdmittedAt:e.active_operation_admitted_at,lastCompletedOperationId:e.last_completed_operation_id}}function N(e){return{...M(e),executionAttemptId:e.execution_attempt_id,executionId:e.execution_id,instruction:p(JSON.parse(e.instruction)),preparationReceipts:v(JSON.parse(e.preparation_receipts)),status:D(c,e.status,`status`),allocationRef:O(e.allocation_ref,e=>C.parse(e)),createdAt:e.created_at,bootstrapDeadlineAt:e.bootstrap_deadline_at,providerId:e.provider_id,allocationLifetime:e.allocation_lifetime===null?null:w.parse(e.allocation_lifetime),provisionerIncarnationId:e.provisioner_incarnation_id,settlementKind:e.settlement_kind===null?null:D(u,e.settlement_kind,`settlement_kind`),claimable:e.claimable!==0,claimExpiresAt:e.claim_expires_at}}function P(e){return{executionAttemptId:e.execution_attempt_id,generation:e.generation,ownerId:e.owner_id,token:e.token,leaseExpiresAt:e.lease_expires_at,obligation:D(m,e.obligation,`obligation`),failureCount:e.failure_count,lastFailure:O(e.last_failure,e=>x.parse(e)),completionEvidence:O(e.completion_evidence,e=>x.parse(e))}}const F=new Map,I=new Map;function L(e){if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;return n.includes(`SQLITE_BUSY`)||n.startsWith(`Failed query: BEGIN IMMEDIATE`)||n.startsWith(`Failed query: COMMIT`)||L(t.cause)}function R(e){if(typeof e!=`object`||!e)return!1;let t=e;return(typeof t.message==`string`?t.message:``).includes(`no transaction is active`)||R(t.cause)}async function z(){await new Promise(e=>setImmediate(e))}async function Oe(e){for(let t=0;;t+=1)try{await e.run(E.raw(`COMMIT`));return}catch(e){if(!L(e)||t===100)throw e;await z()}}async function ke(e,t){return T(F,e,t)}async function Ae(e,t){return T(I,e,t)}const B=new WeakMap;async function je(e,t){let n=(await t.all(E.raw(`PRAGMA database_list`))).find(e=>e.name===`main`)?.file??null;if(n!==null&&n!==``)return`file:${n}`;let r=B.get(e);if(r!==void 0)return r;let i=`connection:${crypto.randomUUID()}`;return B.set(e,i),i}async function V(e,t){let n=await e();if(typeof n!=`function`)return n;if((await n()).rowsAffected>0)return typeof t==`function`?t():t;let r=await e();if(typeof r!=`function`)return r;throw Error(`A guarded transition affected no rows while durable state still permitted it`)}function H(e){return E`EXISTS (SELECT 1 FROM test_provider_operation
56
63
  WHERE execution_attempt_id = ${e.executionAttemptId}
57
64
  AND generation = ${e.generation}
58
65
  AND owner_id = ${e.ownerId}
@@ -68,33 +75,35 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
68
75
  WHERE execution_attempt_id = ${e}
69
76
  AND obligation = ${`terminal-convergence`})`}function K(){return E`EXISTS (SELECT 1 FROM test_active_execution_attempt
70
77
  WHERE execution_id = test_execution_attempt.execution_id
71
- AND execution_attempt_id = test_execution_attempt.execution_attempt_id)`}async function q(c,u){let b=ve(c);await b.run(E.raw(`PRAGMA busy_timeout = 0`));let S=await Te(c,b);await Ce(S,async()=>{for(let e of xe)await b.run(E.raw(e));let e=await b.all(E.raw(`PRAGMA table_info(test_execution_attempt)`));e.some(e=>e.name===`bootstrap_deadline_at`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt ADD COLUMN bootstrap_deadline_at TEXT`)),e.some(e=>e.name===`outcome_control_observation`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt ADD COLUMN outcome_control_observation TEXT`));let t=await b.all(E.raw(`PRAGMA table_info(test_execution_attempt_cancellation)`));t.some(e=>e.name===`request_key`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt_cancellation ADD COLUMN request_key TEXT`)),t.some(e=>e.name===`control_revision`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt_cancellation ADD COLUMN control_revision INTEGER NOT NULL DEFAULT 1`));let n=await b.all(E`SELECT execution_attempt_id FROM test_execution_attempt_cancellation WHERE request_key IS NULL`);for(let e of n)await b.run(E`UPDATE test_execution_attempt_cancellation SET request_key = ${crypto.randomUUID()}
72
- WHERE execution_attempt_id = ${e.execution_attempt_id} AND request_key IS NULL`);(await b.all(E.raw(`PRAGMA table_info(test_provider_operation)`))).some(e=>e.name===`completion_evidence`)||await b.run(E.raw(`ALTER TABLE test_provider_operation ADD COLUMN completion_evidence TEXT`))});let C,w=async e=>be(c,()=>we(S,async()=>{if(C!==void 0)throw Error(`This repository was retired by a failed transaction rollback`,{cause:C});for(let t=0;;t+=1)try{return await b.withSession(async t=>{let n=!1;try{await t.run(E.raw(`BEGIN IMMEDIATE`)),n=!0;let r=await e(t);return await Se(t),r}catch(e){try{await t.run(E.raw(`ROLLBACK`))}catch(t){throw!n&&R(t)?e:(C=AggregateError([e,t],`Transaction rollback failed`),C)}throw e}})}catch(e){if(!L(e)||t===100)throw e;await z()}})),T=async(e,t)=>{let[n]=await e.all(E`SELECT request_key, control_revision, requested_at, reason
73
- FROM test_execution_attempt_cancellation WHERE execution_attempt_id = ${t}`);return n===void 0?null:k.parse({requestKey:n.request_key,controlRevision:n.control_revision,requestedAt:n.requested_at,...n.reason===null?{}:{reason:n.reason}})},O=async(e,t,n)=>{await e.run(E`INSERT INTO test_execution_attempt_cancellation
78
+ AND execution_attempt_id = test_execution_attempt.execution_attempt_id)`}async function q(c,u){let b=we(c);await b.run(E.raw(`PRAGMA busy_timeout = 0`));let S=await je(c,b);await ke(S,async()=>{for(let e of De)await b.run(E.raw(e));let e=await b.all(E.raw(`PRAGMA table_info(test_execution_attempt)`));e.some(e=>e.name===`bootstrap_deadline_at`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt ADD COLUMN bootstrap_deadline_at TEXT`)),e.some(e=>e.name===`outcome_control_observation`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt ADD COLUMN outcome_control_observation TEXT`));let t=await b.all(E.raw(`PRAGMA table_info(test_execution_attempt_cancellation)`));t.some(e=>e.name===`request_key`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt_cancellation ADD COLUMN request_key TEXT`)),t.some(e=>e.name===`control_revision`)||await b.run(E.raw(`ALTER TABLE test_execution_attempt_cancellation ADD COLUMN control_revision INTEGER NOT NULL DEFAULT 1`));let n=await b.all(E`SELECT execution_attempt_id FROM test_execution_attempt_cancellation WHERE request_key IS NULL`);for(let e of n)await b.run(E`UPDATE test_execution_attempt_cancellation SET request_key = ${crypto.randomUUID()}
79
+ WHERE execution_attempt_id = ${e.execution_attempt_id} AND request_key IS NULL`);(await b.all(E.raw(`PRAGMA table_info(test_provider_operation)`))).some(e=>e.name===`completion_evidence`)||await b.run(E.raw(`ALTER TABLE test_provider_operation ADD COLUMN completion_evidence TEXT`))});let C,w=async e=>Ee(c,()=>Ae(S,async()=>{if(C!==void 0)throw Error(`This repository was retired by a failed transaction rollback`,{cause:C});for(let t=0;;t+=1)try{return await b.withSession(async t=>{let n=!1;try{await t.run(E.raw(`BEGIN IMMEDIATE`)),n=!0;let r=await e(t);return await Oe(t),r}catch(e){try{await t.run(E.raw(`ROLLBACK`))}catch(t){throw!n&&R(t)?e:(C=AggregateError([e,t],`Transaction rollback failed`),C)}throw e}})}catch(e){if(!L(e)||t===100)throw e;await z()}})),T=async(e,t)=>{let[n]=await e.all(E`SELECT request_key, control_revision, requested_at, reason
80
+ FROM test_execution_attempt_cancellation WHERE execution_attempt_id = ${t}`);return n===void 0?null:k.parse({requestKey:n.request_key,controlRevision:n.control_revision,requestedAt:n.requested_at,...n.reason===null?{}:{reason:n.reason}})},O=async(e,t)=>(await e.all(E`SELECT control_revision, runtime_generation, receipt_json, report_json
81
+ FROM test_execution_attempt_control_evidence WHERE execution_attempt_id = ${t}
82
+ ORDER BY control_revision, runtime_generation`)).map(e=>({controlRevision:e.control_revision,runtimeGeneration:e.runtime_generation,receipt:e.receipt_json===null?null:Se.parse(JSON.parse(e.receipt_json)),report:e.report_json===null?null:Ce.parse(JSON.parse(e.report_json))})),A=async(e,t,n)=>{await e.run(E`INSERT INTO test_execution_attempt_cancellation
74
83
  (execution_attempt_id, request_key, control_revision, requested_at, reason)
75
84
  VALUES (${t}, ${n.requestKey}, ${n.controlRevision},
76
85
  ${n.requestedAt}, ${n.reason??null})`),await e.run(E`UPDATE test_execution_attempt SET operation_start_gate = 'closed'
77
- WHERE execution_attempt_id = ${t}`)},A=async(e,t)=>(await e.all(E`SELECT * FROM test_execution_attempt WHERE execution_attempt_id = ${t}`))[0],F=async(e,t)=>(await e.all(E`SELECT * FROM test_provider_operation WHERE execution_attempt_id = ${t}`))[0],I=async(e,t)=>(await F(e,t))?.obligation===`terminal-convergence`,B=async(e,t)=>(await e.all(E`SELECT execution_attempt_id FROM test_active_execution_attempt WHERE execution_id = ${t}`))[0]?.execution_attempt_id??null,q=async(e,t)=>{let n=t.settlement_kind!==null,r=!n&&await B(e,t.execution_id)===t.execution_attempt_id;return s({matchesExecution:!0,settled:n,active:r,allocated:r&&t.allocation_ref!==null&&!await I(e,t.execution_attempt_id)})},J=async(e,t)=>{let n=await A(e,t.executionAttemptId),r=await F(e,t.executionAttemptId);if(n===void 0||r===void 0)return{kind:`not-found`};let i=N(n);return h(i,P(r))?{kind:`resolved`,attempt:i}:r.token===null||r.token!==t.token||r.generation!==t.generation||r.owner_id!==t.ownerId?{kind:`stale`,attempt:i}:{kind:`authorized`,attempt:i,attemptRow:n,operation:r}},Y=async(e,t)=>{let n=await J(e,t);return n.kind===`authorized`?void 0:{kind:n.kind}},X=async(e,t,n,r)=>{let i=await e.run(E`UPDATE test_execution_attempt
86
+ WHERE execution_attempt_id = ${t}`)},F=async(e,t)=>(await e.all(E`SELECT * FROM test_execution_attempt WHERE execution_attempt_id = ${t}`))[0],I=async(e,t)=>(await e.all(E`SELECT * FROM test_provider_operation WHERE execution_attempt_id = ${t}`))[0],B=async(e,t)=>(await I(e,t))?.obligation===`terminal-convergence`,q=async(e,t)=>(await e.all(E`SELECT execution_attempt_id FROM test_active_execution_attempt WHERE execution_id = ${t}`))[0]?.execution_attempt_id??null,J=async(e,t)=>{let n=t.settlement_kind!==null,r=!n&&await q(e,t.execution_id)===t.execution_attempt_id;return s({matchesExecution:!0,settled:n,active:r,allocated:r&&t.allocation_ref!==null&&!await B(e,t.execution_attempt_id)})},Y=async(e,t)=>{let n=await F(e,t.executionAttemptId),r=await I(e,t.executionAttemptId);if(n===void 0||r===void 0)return{kind:`not-found`};let i=N(n);return h(i,P(r))?{kind:`resolved`,attempt:i}:r.token===null||r.token!==t.token||r.generation!==t.generation||r.owner_id!==t.ownerId?{kind:`stale`,attempt:i}:{kind:`authorized`,attempt:i,attemptRow:n,operation:r}},X=async(e,t)=>{let n=await Y(e,t);return n.kind===`authorized`?void 0:{kind:n.kind}},Z=async(e,t,n,r)=>{let i=await e.run(E`UPDATE test_execution_attempt
78
87
  SET status = ${`settled`}, settlement_kind = ${n}, claimable = ${0},
79
88
  operation_start_gate = ${`closed`}
80
89
  WHERE execution_attempt_id = ${t}
81
90
  AND settlement_kind IS NULL
82
- AND ${r}`);return i.rowsAffected,i},Z=async(e,t,n,r,i,a)=>{if(!a){let a=await X(e,t,`abandoned`,r);if(a.rowsAffected===0)return a;if((await e.run(E`UPDATE test_provider_operation
91
+ AND ${r}`);return i.rowsAffected,i},Q=async(e,t,n,r,i,a)=>{if(!a){let a=await Z(e,t,`abandoned`,r);if(a.rowsAffected===0)return a;if((await e.run(E`UPDATE test_provider_operation
83
92
  SET completion_evidence = ${JSON.stringify(i)}
84
93
  WHERE execution_attempt_id = ${t}
85
94
  AND ${H(n)}
86
- AND completion_evidence IS NULL`)).rowsAffected===0&&(await F(e,t))?.completion_evidence===null)throw Error(`Pre-allocation settlement succeeded without provider completion evidence`);return a}return e.run(E`UPDATE test_provider_operation
95
+ AND completion_evidence IS NULL`)).rowsAffected===0&&(await I(e,t))?.completion_evidence===null)throw Error(`Pre-allocation settlement succeeded without provider completion evidence`);return a}return e.run(E`UPDATE test_provider_operation
87
96
  SET completion_evidence = ${JSON.stringify(i)}
88
97
  WHERE execution_attempt_id = ${t}
89
98
  AND ${H(n)}
90
- AND completion_evidence IS NULL`)},Q=(e,t)=>{let n=he(e.allocationRef),r=t?E`CASE WHEN settlement_kind IS NULL AND ${K()} THEN 1 ELSE 0 END`:E`${0}`;return w(t=>V(async()=>{let i=await J(t,e.claim);if(i.kind!==`not-found`&&fe(i.attempt,n),i.kind===`resolved`)return{kind:`resolved`,allocationRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.allocationRef===null?async()=>{let i=await t.run(E`UPDATE test_execution_attempt
99
+ AND completion_evidence IS NULL`)},Me=(e,t)=>{let n=ye(e.allocationRef),r=t?E`CASE WHEN settlement_kind IS NULL AND ${K()} THEN 1 ELSE 0 END`:E`${0}`;return w(t=>V(async()=>{let i=await Y(t,e.claim);if(i.kind!==`not-found`&&ge(i.attempt,n),i.kind===`resolved`)return{kind:`resolved`,allocationRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.allocationRef===null?async()=>{let i=await t.run(E`UPDATE test_execution_attempt
91
100
  SET status = CASE WHEN settlement_kind IS NULL THEN ${`allocated`} ELSE status END,
92
101
  allocation_ref = ${JSON.stringify(n)},
93
102
  claimable = ${r}
94
103
  WHERE execution_attempt_id = ${a.executionAttemptId}
95
104
  AND allocation_ref IS NULL
96
105
  AND ${W(e.claim)}`);return i.rowsAffected===0||await t.run(E`UPDATE test_provider_operation SET obligation = ${`allocation-control`}
97
- WHERE execution_attempt_id = ${a.executionAttemptId}`),i}:d(a.allocationRef,n)?{kind:`duplicate`,allocationRef:a.allocationRef}:{kind:`conflict`,allocationRef:a.allocationRef}},{kind:`recorded`}))},Ee={async getAttemptWithAllocation(e){return w(async t=>{let n=await A(t,e);return n===void 0?null:N(n)})},async recordDiscoveredAllocation(e){return Q(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=de(e);return w(r=>V(async()=>{let i=await J(r,e.claim);if(i.kind===`stale`)return{kind:`stale`,storedRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a,attemptRow:o}=i;return a.executionId===e.executionId?a.allocationRef===null?{kind:`not-allocated`}:d(a.allocationRef,t)?()=>r.run(E`UPDATE test_execution_attempt SET allocation_ref = ${JSON.stringify(n)}
106
+ WHERE execution_attempt_id = ${a.executionAttemptId}`),i}:d(a.allocationRef,n)?{kind:`duplicate`,allocationRef:a.allocationRef}:{kind:`conflict`,allocationRef:a.allocationRef}},{kind:`recorded`}))},Ne={async getAttemptWithAllocation(e){return w(async t=>{let n=await F(t,e);return n===void 0?null:N(n)})},async recordDiscoveredAllocation(e){return Me(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=he(e);return w(r=>V(async()=>{let i=await Y(r,e.claim);if(i.kind===`stale`)return{kind:`stale`,storedRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a,attemptRow:o}=i;return a.executionId===e.executionId?a.allocationRef===null?{kind:`not-allocated`}:d(a.allocationRef,t)?()=>r.run(E`UPDATE test_execution_attempt SET allocation_ref = ${JSON.stringify(n)}
98
107
  WHERE execution_attempt_id = ${a.executionAttemptId}
99
108
  AND execution_id = ${e.executionId}
100
109
  AND allocation_ref = ${o.allocation_ref}
@@ -105,7 +114,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
105
114
  AND allocation_ref IS NOT NULL
106
115
  AND claimable = ${1}
107
116
  AND (claim_expires_at IS NULL OR claim_expires_at >= ${n})
108
- ORDER BY created_at ASC, execution_attempt_id ASC`)).map(e=>me(N(e)))})},async listOpenProviderOperations(e){let t=g(e.observedAt);if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw RangeError(`Provider-operation recovery limit must be a positive safe integer`);return w(async n=>(await n.all(E`SELECT attempt.*, operation.generation, operation.owner_id, operation.token, operation.lease_expires_at,
117
+ ORDER BY created_at ASC, execution_attempt_id ASC`)).map(e=>ve(N(e)))})},async listOpenProviderOperations(e){let t=g(e.observedAt);if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw RangeError(`Provider-operation recovery limit must be a positive safe integer`);return w(async n=>(await n.all(E`SELECT attempt.*, operation.generation, operation.owner_id, operation.token, operation.lease_expires_at,
109
118
  operation.obligation, operation.failure_count, operation.last_failure, operation.completion_evidence
110
119
  FROM test_execution_attempt AS attempt
111
120
  INNER JOIN test_provider_operation AS operation
@@ -119,7 +128,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
119
128
  ORDER BY attempt.created_at ASC, attempt.execution_attempt_id ASC
120
129
  LIMIT ${e.limit}`)).map(e=>({attempt:N(e),operation:P(e)})))}},$=async(e,t,n)=>{let{instruction:r}=t,{createdAt:i,bootstrapDeadlineAt:a}=n;try{await e.run(E`INSERT INTO test_execution_attempt
121
130
  (execution_attempt_id, execution_id, instruction, status, claimable, created_at, bootstrap_deadline_at)
122
- VALUES (${t.executionAttemptId}, ${t.executionId}, ${JSON.stringify(r)}, ${`pending`}, ${0}, ${i}, ${a})`)}catch(e){throw ye(e)?new te(t.executionAttemptId,{cause:e}):e}return await e.run(E`UPDATE test_execution_attempt
131
+ VALUES (${t.executionAttemptId}, ${t.executionId}, ${JSON.stringify(r)}, ${`pending`}, ${0}, ${i}, ${a})`)}catch(e){throw Te(e)?new te(t.executionAttemptId,{cause:e}):e}return await e.run(E`UPDATE test_execution_attempt
123
132
  SET claimable = ${0}
124
133
  WHERE execution_attempt_id = (
125
134
  SELECT execution_attempt_id
@@ -135,9 +144,9 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
135
144
  )`),await e.run(E`INSERT INTO test_active_execution_attempt (execution_id, execution_attempt_id)
136
145
  VALUES (${t.executionId}, ${t.executionAttemptId})
137
146
  ON CONFLICT(execution_id)
138
- DO UPDATE SET execution_attempt_id = excluded.execution_attempt_id`),{...ge,executionAttemptId:t.executionAttemptId,executionId:t.executionId,instruction:r,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,createdAt:i,bootstrapDeadlineAt:a,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null}};return{async createAttempt(e){let t={...e,instruction:p(e.instruction)},n=y(e.bootstrapTimeoutMs);return w(e=>$(e,t,n))},async ensureAttempt(e){let t=ce(e);return w(async e=>{let n=(await e.all(E`SELECT execution_attempt_id FROM test_execution_attempt_request
139
- WHERE execution_id = ${t.executionId} AND request_key = ${t.requestKey}`))[0];if(n!==void 0){let r=await A(e,n.execution_attempt_id);return le(t,r===void 0?null:N(r))}let r=await $(e,t,y(t.bootstrapTimeoutMs));return await e.run(E`INSERT INTO test_execution_attempt_request (execution_id, request_key, execution_attempt_id)
140
- VALUES (${t.executionId}, ${t.requestKey}, ${r.executionAttemptId})`),{kind:`created`,attempt:structuredClone(r)}})},async readAttemptSettlement(e){let t=se(e);return w(async e=>{let n=await A(e,t.executionAttemptId);return n===void 0||n.execution_id!==t.executionId?{kind:`not-found`}:ue(t,{attempt:N(n),activeAttemptId:await B(e,t.executionId),outcomeText:n.workflow_result,controlObservation:j(n.outcome_control_observation)},u)})},async readBootstrapStartState(e){return w(async t=>{let n=await A(t,e.executionAttemptId);return n===void 0||n.execution_id!==e.executionId?null:{settled:n.settlement_kind!==null,active:await B(t,e.executionId)===e.executionAttemptId,allocated:n.allocation_ref!==null,allocationTerminated:await I(t,e.executionAttemptId),operationStartGate:D(f,n.operation_start_gate,`operation_start_gate`),bootstrapDeadlineAt:n.bootstrap_deadline_at}})},async beginProvisioning(e){let t=pe(e.allocationLifetime),n={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:g(e.leaseExpiresAt)};return w(r=>V(async()=>{let i=await A(r,e.executionAttemptId);if(i===void 0||i.execution_id!==e.executionId)return{kind:`not-found`};let a=N(i);return await B(r,e.executionId)===e.executionAttemptId?a.settlementKind==null?a.allocationRef===null?a.operationStartGate===`closed`?{kind:`fenced`}:a.status===`pending`?async()=>{let i=await r.run(E`UPDATE test_execution_attempt
147
+ DO UPDATE SET execution_attempt_id = excluded.execution_attempt_id`),{...be,executionAttemptId:t.executionAttemptId,executionId:t.executionId,instruction:r,preparationReceipts:Object.freeze([]),status:`pending`,allocationRef:null,createdAt:i,bootstrapDeadlineAt:a,providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null}};return{async createAttempt(e){let t={...e,instruction:p(e.instruction)},n=y(e.bootstrapTimeoutMs);return w(e=>$(e,t,n))},async ensureAttempt(e){let t=ce(e);return w(async e=>{let n=(await e.all(E`SELECT execution_attempt_id FROM test_execution_attempt_request
148
+ WHERE execution_id = ${t.executionId} AND request_key = ${t.requestKey}`))[0];if(n!==void 0){let r=await F(e,n.execution_attempt_id);return le(t,r===void 0?null:N(r))}let r=await $(e,t,y(t.bootstrapTimeoutMs));return await e.run(E`INSERT INTO test_execution_attempt_request (execution_id, request_key, execution_attempt_id)
149
+ VALUES (${t.executionId}, ${t.requestKey}, ${r.executionAttemptId})`),{kind:`created`,attempt:structuredClone(r)}})},async readAttemptSettlement(e){let t=se(e);return w(async e=>{let n=await F(e,t.executionAttemptId);return n===void 0||n.execution_id!==t.executionId?{kind:`not-found`}:ue(t,{attempt:N(n),activeAttemptId:await q(e,t.executionId),outcomeText:n.workflow_result,controlObservation:j(n.outcome_control_observation)},u)})},async readBootstrapStartState(e){return w(async t=>{let n=await F(t,e.executionAttemptId);return n===void 0||n.execution_id!==e.executionId?null:{settled:n.settlement_kind!==null,active:await q(t,e.executionId)===e.executionAttemptId,allocated:n.allocation_ref!==null,allocationTerminated:await B(t,e.executionAttemptId),operationStartGate:D(f,n.operation_start_gate,`operation_start_gate`),bootstrapDeadlineAt:n.bootstrap_deadline_at}})},async beginProvisioning(e){let t=_e(e.allocationLifetime),n={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:g(e.leaseExpiresAt)};return w(r=>V(async()=>{let i=await F(r,e.executionAttemptId);if(i===void 0||i.execution_id!==e.executionId)return{kind:`not-found`};let a=N(i);return await q(r,e.executionId)===e.executionAttemptId?a.settlementKind==null?a.allocationRef===null?a.operationStartGate===`closed`?{kind:`fenced`}:a.status===`pending`?async()=>{let i=await r.run(E`UPDATE test_execution_attempt
141
150
  SET status = ${`provisioning`},
142
151
  provider_id = ${e.providerId},
143
152
  allocation_lifetime = ${t},
@@ -151,43 +160,43 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
151
160
  AND ${K()}`);return i.rowsAffected===0||await r.run(E`INSERT INTO test_provider_operation
152
161
  (execution_attempt_id, generation, owner_id, token, lease_expires_at, obligation, failure_count)
153
162
  VALUES (${e.executionAttemptId}, ${n.generation}, ${n.ownerId}, ${n.token},
154
- ${n.leaseExpiresAt}, ${`provisioning-resolution`}, ${0})`),i}:{kind:`already-provisioning`}:{kind:`allocated`,allocationRef:a.allocationRef}:{kind:`resolved`,allocationRef:a.allocationRef}:{kind:`fenced`}},{kind:`started`,claim:n}))},async getProviderOperation(e){return w(async t=>{let n=await F(t,e);return n===void 0?null:P(n)})},async renewProviderOperationClaim(e){let t=g(e.leaseExpiresAt);return w(n=>V(async()=>await Y(n,e.claim)??(()=>n.run(E`UPDATE test_provider_operation SET lease_expires_at = ${t}
163
+ ${n.leaseExpiresAt}, ${`provisioning-resolution`}, ${0})`),i}:{kind:`already-provisioning`}:{kind:`allocated`,allocationRef:a.allocationRef}:{kind:`resolved`,allocationRef:a.allocationRef}:{kind:`fenced`}},{kind:`started`,claim:n}))},async getProviderOperation(e){return w(async t=>{let n=await I(t,e);return n===void 0?null:P(n)})},async renewProviderOperationClaim(e){let t=g(e.leaseExpiresAt);return w(n=>V(async()=>await X(n,e.claim)??(()=>n.run(E`UPDATE test_provider_operation SET lease_expires_at = ${t}
155
164
  WHERE execution_attempt_id = ${e.claim.executionAttemptId}
156
- AND ${W(e.claim)}`)),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:t}}))},async takeOverProviderOperation(e){return w(async t=>{let n=await A(t,e.executionAttemptId),r=await F(t,e.executionAttemptId);if(n===void 0||r===void 0)return{kind:`not-found`};if(h(N(n),P(r)))return{kind:`resolved`};let i=g(e.observedAt);if(r.owner_id!==null&&r.lease_expires_at!==null&&_(r.lease_expires_at)>_(i))return{kind:`stale`};let a={executionAttemptId:e.executionAttemptId,generation:r.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:g(e.leaseExpiresAt)},{rowsAffected:o}=await t.run(E`UPDATE test_provider_operation
165
+ AND ${W(e.claim)}`)),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:t}}))},async takeOverProviderOperation(e){return w(async t=>{let n=await F(t,e.executionAttemptId),r=await I(t,e.executionAttemptId);if(n===void 0||r===void 0)return{kind:`not-found`};if(h(N(n),P(r)))return{kind:`resolved`};let i=g(e.observedAt);if(r.owner_id!==null&&r.lease_expires_at!==null&&_(r.lease_expires_at)>_(i))return{kind:`stale`};let a={executionAttemptId:e.executionAttemptId,generation:r.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:g(e.leaseExpiresAt)},{rowsAffected:o}=await t.run(E`UPDATE test_provider_operation
157
166
  SET generation = ${a.generation}, owner_id = ${a.ownerId}, token = ${a.token},
158
167
  lease_expires_at = ${a.leaseExpiresAt}
159
168
  WHERE execution_attempt_id = ${e.executionAttemptId}
160
169
  AND generation = ${r.generation}
161
- AND ${U(e.executionAttemptId)}`);if(o===0){let n=await A(t,e.executionAttemptId),r=await F(t,e.executionAttemptId);return n!==void 0&&r!==void 0&&h(N(n),P(r))?{kind:`resolved`}:{kind:`stale`}}return{kind:`claimed`,claim:a}})},async handoffProviderOperation(e){let t=e.evidence===void 0?null:x.parse(e.evidence);return w(n=>V(async()=>await Y(n,e.claim)??(()=>n.run(t===null?E`UPDATE test_provider_operation
170
+ AND ${U(e.executionAttemptId)}`);if(o===0){let n=await F(t,e.executionAttemptId),r=await I(t,e.executionAttemptId);return n!==void 0&&r!==void 0&&h(N(n),P(r))?{kind:`resolved`}:{kind:`stale`}}return{kind:`claimed`,claim:a}})},async handoffProviderOperation(e){let t=e.evidence===void 0?null:x.parse(e.evidence);return w(n=>V(async()=>await X(n,e.claim)??(()=>n.run(t===null?E`UPDATE test_provider_operation
162
171
  SET owner_id = NULL, token = NULL, lease_expires_at = NULL
163
172
  WHERE execution_attempt_id = ${e.claim.executionAttemptId}
164
173
  AND ${W(e.claim)}`:E`UPDATE test_provider_operation
165
174
  SET owner_id = NULL, token = NULL, lease_expires_at = NULL,
166
175
  last_failure = ${JSON.stringify(t)}
167
176
  WHERE execution_attempt_id = ${e.claim.executionAttemptId}
168
- AND ${W(e.claim)}`)),{kind:`recorded`}))},async recordProviderOperationUncertainty(e){let t=x.parse(e.evidence);return w(n=>V(async()=>await Y(n,e.claim)??(()=>n.run(E`UPDATE test_provider_operation
177
+ AND ${W(e.claim)}`)),{kind:`recorded`}))},async recordProviderOperationUncertainty(e){let t=x.parse(e.evidence);return w(n=>V(async()=>await X(n,e.claim)??(()=>n.run(E`UPDATE test_provider_operation
169
178
  SET failure_count = failure_count + 1, last_failure = ${JSON.stringify(t)}
170
179
  WHERE execution_attempt_id = ${e.claim.executionAttemptId}
171
- AND ${W(e.claim)}`)),{kind:`recorded`}))},async completeProviderOperation(e){let t=x.parse(e.evidence);return w(async n=>{let r=await A(n,e.claim.executionAttemptId),i=await F(n,e.claim.executionAttemptId);if(r===void 0||i===void 0)return{kind:`not-found`};if(!(i.generation===e.claim.generation&&i.owner_id===e.claim.ownerId&&i.token===e.claim.token))return{kind:`stale`};if(h(N(r),P(i)))return{kind:`already-completed`};if(i.completion_evidence!==null)return{kind:`evidence-recorded`};if((await n.run(E`UPDATE test_provider_operation
180
+ AND ${W(e.claim)}`)),{kind:`recorded`}))},async completeProviderOperation(e){let t=x.parse(e.evidence);return w(async n=>{let r=await F(n,e.claim.executionAttemptId),i=await I(n,e.claim.executionAttemptId);if(r===void 0||i===void 0)return{kind:`not-found`};if(!(i.generation===e.claim.generation&&i.owner_id===e.claim.ownerId&&i.token===e.claim.token))return{kind:`stale`};if(h(N(r),P(i)))return{kind:`already-completed`};if(i.completion_evidence!==null)return{kind:`evidence-recorded`};if((await n.run(E`UPDATE test_provider_operation
172
181
  SET completion_evidence = ${JSON.stringify(t)}
173
182
  WHERE execution_attempt_id = ${e.claim.executionAttemptId}
174
183
  AND ${H(e.claim)}
175
- AND completion_evidence IS NULL`)).rowsAffected>0){let t=await A(n,e.claim.executionAttemptId);return t===void 0?{kind:`not-found`}:t.settlement_kind===null?{kind:`evidence-recorded`}:{kind:`completed`}}let a=await A(n,e.claim.executionAttemptId),o=await F(n,e.claim.executionAttemptId);return a===void 0||o===void 0?{kind:`not-found`}:o.generation===e.claim.generation&&o.owner_id===e.claim.ownerId&&o.token===e.claim.token?h(N(a),P(o))?{kind:`already-completed`}:o.completion_evidence===null?{kind:`stale`}:{kind:`evidence-recorded`}:{kind:`stale`}})},async recordAllocation(e){return Q(e,!0)},async recordProvisioningAbsent(e){let t=x.parse(e.evidence),n=!1;return w(r=>V(async()=>{let i=await J(r,e.claim);if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.executionId===e.executionId?a.allocationRef===null?(n=a.settlementKind!==null,()=>Z(r,a.executionAttemptId,e.claim,E`execution_id = ${e.executionId}
184
+ AND completion_evidence IS NULL`)).rowsAffected>0){let t=await F(n,e.claim.executionAttemptId);return t===void 0?{kind:`not-found`}:t.settlement_kind===null?{kind:`evidence-recorded`}:{kind:`completed`}}let a=await F(n,e.claim.executionAttemptId),o=await I(n,e.claim.executionAttemptId);return a===void 0||o===void 0?{kind:`not-found`}:o.generation===e.claim.generation&&o.owner_id===e.claim.ownerId&&o.token===e.claim.token?h(N(a),P(o))?{kind:`already-completed`}:o.completion_evidence===null?{kind:`stale`}:{kind:`evidence-recorded`}:{kind:`stale`}})},async recordAllocation(e){return Me(e,!0)},async recordProvisioningAbsent(e){let t=x.parse(e.evidence),n=!1;return w(r=>V(async()=>{let i=await Y(r,e.claim);if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.executionId===e.executionId?a.allocationRef===null?(n=a.settlementKind!==null,()=>Q(r,a.executionAttemptId,e.claim,E`execution_id = ${e.executionId}
176
185
  AND allocation_ref IS NULL
177
- AND ${H(e.claim)}`,t,n)):{kind:`allocated`,allocationRef:a.allocationRef}:{kind:`not-found`}},()=>n?{kind:`completed`}:{kind:`recorded`}))},async recordProvisionerIncarnationLost(e){let t=x.parse(e.proof.evidence),n=!1;return w(r=>V(async()=>{let i=await J(r,e.claim);if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i,o=oe(a,e);return o===null?(n=a.settlementKind!==null,()=>Z(r,a.executionAttemptId,e.claim,E`execution_id = ${e.executionId}
186
+ AND ${H(e.claim)}`,t,n)):{kind:`allocated`,allocationRef:a.allocationRef}:{kind:`not-found`}},()=>n?{kind:`completed`}:{kind:`recorded`}))},async recordProvisionerIncarnationLost(e){let t=x.parse(e.proof.evidence),n=!1;return w(r=>V(async()=>{let i=await Y(r,e.claim);if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i,o=oe(a,e);return o===null?(n=a.settlementKind!==null,()=>Q(r,a.executionAttemptId,e.claim,E`execution_id = ${e.executionId}
178
187
  AND allocation_ref IS NULL
179
188
  AND allocation_lifetime = ${`provisioner-process-bound`}
180
189
  AND provisioner_incarnation_id = ${e.proof.provisionerIncarnationId}
181
- AND ${H(e.claim)}`,t,n)):o},()=>n?{kind:`completed`}:{kind:`recorded`}))},async recordAllocationTerminated(e){let t=x.parse(e.evidence);return w(n=>V(async()=>{let r=await J(n,e.claim);if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.allocationRef===null?{kind:`not-allocated`}:()=>n.run(E`UPDATE test_provider_operation
190
+ AND ${H(e.claim)}`,t,n)):o},()=>n?{kind:`completed`}:{kind:`recorded`}))},async recordAllocationTerminated(e){let t=x.parse(e.evidence);return w(n=>V(async()=>{let r=await Y(n,e.claim);if(r.kind!==`authorized`)return{kind:r.kind};let{attempt:i}=r;return i.allocationRef===null?{kind:`not-allocated`}:()=>n.run(E`UPDATE test_provider_operation
182
191
  SET obligation = ${`terminal-convergence`}, last_failure = ${JSON.stringify(t)}
183
192
  WHERE execution_attempt_id = ${i.executionAttemptId}
184
193
  AND ${W(e.claim)}
185
194
  AND EXISTS (SELECT 1 FROM test_execution_attempt
186
195
  WHERE execution_attempt_id = ${i.executionAttemptId}
187
- AND allocation_ref IS NOT NULL)`)},{kind:`recorded`}))},async recordInfrastructureFailure(e){return w(t=>V(async()=>{let n=await J(t,e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.settlementKind===null?r.allocationRef===null?{kind:`not-allocated`}:D(m,i.obligation,`obligation`)===`terminal-convergence`?()=>X(t,r.executionAttemptId,`infrastructure-failure`,E`execution_id = ${e.executionId}
196
+ AND allocation_ref IS NOT NULL)`)},{kind:`recorded`}))},async recordInfrastructureFailure(e){return w(t=>V(async()=>{let n=await Y(t,e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.settlementKind===null?r.allocationRef===null?{kind:`not-allocated`}:D(m,i.obligation,`obligation`)===`terminal-convergence`?()=>Z(t,r.executionAttemptId,`infrastructure-failure`,E`execution_id = ${e.executionId}
188
197
  AND allocation_ref IS NOT NULL
189
198
  AND ${G(r.executionAttemptId)}
190
- AND ${H(e.claim)}`):{kind:`not-terminated`}:{kind:`resolved`}:{kind:`not-found`}},{kind:`recorded`}))},async registerRuntime(e){return w(async t=>{let n=0,r=await V(async()=>{let r=await A(t,e.executionAttemptId);if(r===void 0||r.execution_id!==e.executionId)return{kind:`not-found`};let i=await q(t,r);if(i!==null)return i;let a=M(r),o=ae(a,e);return o===null?(n=a.runtimeGeneration+1,()=>t.run(E`UPDATE test_execution_attempt
199
+ AND ${H(e.claim)}`):{kind:`not-terminated`}:{kind:`resolved`}:{kind:`not-found`}},{kind:`recorded`}))},async registerRuntime(e){return w(async t=>{let n=0,r=await V(async()=>{let r=await F(t,e.executionAttemptId);if(r===void 0||r.execution_id!==e.executionId)return{kind:`not-found`};let i=await J(t,r);if(i!==null)return i;let a=M(r),o=ae(a,e);return o===null?(n=a.runtimeGeneration+1,()=>t.run(E`UPDATE test_execution_attempt
191
200
  SET runtime_generation = ${n},
192
201
  runtime_incarnation_id = ${e.runtimeIncarnationId},
193
202
  runtime_ready_at = NULL,
@@ -203,7 +212,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
203
212
  AND (active_operation_id IS NULL OR active_operation_kind = ${`runtime-probe`})
204
213
  AND allocation_ref IS NOT NULL
205
214
  AND NOT ${G(e.executionAttemptId)}
206
- AND ${K()}`)):o},{kind:`applied`});return r.kind===`applied`?{kind:`registered`,runtimeGeneration:n}:r})},async admitOperation(e){let t=crypto.randomUUID(),n=g(new Date().toISOString()),r=e.operationKind===`runtime-probe`?E`1 = 1`:E`runtime_ready_at IS NOT NULL`;return w(i=>V(async()=>{let a=await A(i,e.executionAttemptId);if(a===void 0||a.execution_id!==e.executionId)return{kind:`not-found`};let s=await q(i,a);if(s!==null)return s;let c=o(M(a),e,n,N(a));return c===null?()=>i.run(E`UPDATE test_execution_attempt
215
+ AND ${K()}`)):o},{kind:`applied`});return r.kind===`applied`?{kind:`registered`,runtimeGeneration:n}:r})},async admitOperation(e){let t=crypto.randomUUID(),n=g(new Date().toISOString()),r=e.operationKind===`runtime-probe`?E`1 = 1`:E`runtime_ready_at IS NOT NULL`;return w(i=>V(async()=>{let a=await F(i,e.executionAttemptId);if(a===void 0||a.execution_id!==e.executionId)return{kind:`not-found`};let s=await J(i,a);if(s!==null)return s;let c=o(M(a),e,n,N(a));return c===null?()=>i.run(E`UPDATE test_execution_attempt
207
216
  SET active_operation_id = ${t},
208
217
  active_operation_kind = ${e.operationKind},
209
218
  active_operation_key = ${e.admissionKey},
@@ -220,7 +229,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
220
229
  AND allocation_ref IS NOT NULL
221
230
  AND NOT ${G(e.executionAttemptId)}
222
231
  AND ${r}
223
- AND ${K()}`):c},{kind:`admitted`,operationId:t,runtimeGeneration:e.runtimeGeneration,admittedAt:n}))},async getInstruction(e){return w(async t=>{let n=await A(t,e.executionAttemptId);return n?.execution_id===e.executionId?p(JSON.parse(n.instruction)):null})},async reportOperation(e){let t=_e(e.result);return w(n=>V(async()=>{let r=await A(n,e.executionAttemptId);if(r===void 0||r.execution_id!==e.executionId)return{kind:`not-found`};let i=N(r),a=ie({matchesExecution:!0,settled:r.settlement_kind!==null,active:await B(n,e.executionId)===e.executionAttemptId,allocated:r.allocation_ref!==null&&!await I(n,e.executionAttemptId)},i,i,{...e,result:t});if(a!==null)return a;let o=v([...i.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return()=>n.run(E`UPDATE test_execution_attempt
232
+ AND ${K()}`):c},{kind:`admitted`,operationId:t,runtimeGeneration:e.runtimeGeneration,admittedAt:n}))},async getInstruction(e){return w(async t=>{let n=await F(t,e.executionAttemptId);return n?.execution_id===e.executionId?p(JSON.parse(n.instruction)):null})},async reportOperation(e){let t=xe(e.result);return w(n=>V(async()=>{let r=await F(n,e.executionAttemptId);if(r===void 0||r.execution_id!==e.executionId)return{kind:`not-found`};let i=N(r),a=ie({matchesExecution:!0,settled:r.settlement_kind!==null,active:await q(n,e.executionId)===e.executionAttemptId,allocated:r.allocation_ref!==null&&!await B(n,e.executionAttemptId)},i,i,{...e,result:t});if(a!==null)return a;let o=v([...i.preparationReceipts,{operationId:e.operationId,runtimeGeneration:e.runtimeGeneration,result:t}]);return()=>n.run(E`UPDATE test_execution_attempt
224
233
  SET preparation_receipts = ${JSON.stringify(o)},
225
234
  active_operation_id = NULL,
226
235
  active_operation_kind = NULL,
@@ -239,7 +248,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
239
248
  AND preparation_receipts = ${r.preparation_receipts}
240
249
  AND allocation_ref IS NOT NULL
241
250
  AND NOT ${G(e.executionAttemptId)}
242
- AND ${K()}`)},{kind:`accepted`,binding:t.binding}))},async completeOperation(t){return w(n=>V(async()=>{let r=await A(n,t.executionAttemptId);if(r===void 0)return{kind:`not-found`};if(r.settlement_kind!==null)return{kind:`resolved`};let i=e(M(r),t);return i===null?()=>n.run(E`UPDATE test_execution_attempt
251
+ AND ${K()}`)},{kind:`accepted`,binding:t.binding}))},async completeOperation(t){return w(n=>V(async()=>{let r=await F(n,t.executionAttemptId);if(r===void 0)return{kind:`not-found`};if(r.settlement_kind!==null)return{kind:`resolved`};let i=e(M(r),t);return i===null?()=>n.run(E`UPDATE test_execution_attempt
243
252
  SET active_operation_id = NULL,
244
253
  active_operation_kind = NULL,
245
254
  active_operation_key = NULL,
@@ -250,7 +259,7 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
250
259
  AND settlement_kind IS NULL
251
260
  AND active_operation_id = ${t.operationId}
252
261
  AND active_operation_kind IN (${`runtime-probe`}, ${`workflow-run`})
253
- AND active_operation_generation = ${t.runtimeGeneration}`):i},{kind:`completed`}))},async markRuntimeReady(e){let t=g(e.readyAt);return w(r=>V(async()=>{let i=await A(r,e.executionAttemptId);if(i===void 0||i.execution_id!==e.executionId)return{kind:`not-found`};let a=await q(r,i);if(a!==null)return a;let o=n(M(i),e);return o===null?()=>r.run(E`UPDATE test_execution_attempt SET runtime_ready_at = ${t}
262
+ AND active_operation_generation = ${t.runtimeGeneration}`):i},{kind:`completed`}))},async markRuntimeReady(e){let t=g(e.readyAt);return w(r=>V(async()=>{let i=await F(r,e.executionAttemptId);if(i===void 0||i.execution_id!==e.executionId)return{kind:`not-found`};let a=await J(r,i);if(a!==null)return a;let o=n(M(i),e);return o===null?()=>r.run(E`UPDATE test_execution_attempt SET runtime_ready_at = ${t}
254
263
  WHERE execution_attempt_id = ${e.executionAttemptId}
255
264
  AND execution_id = ${e.executionId}
256
265
  AND settlement_kind IS NULL
@@ -259,20 +268,28 @@ import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as ee,
259
268
  AND active_operation_id IS NULL
260
269
  AND allocation_ref IS NOT NULL
261
270
  AND NOT ${G(e.executionAttemptId)}
262
- AND ${K()}`):o},{kind:`ready`,acceptedAt:t}))},async getAttemptControlState(e){return w(async t=>{let n=await A(t,e);return n===void 0?null:M(n)})},async requestAttemptCancellation(e){let t=i(e);return w(async e=>{let n=await A(e,t.executionAttemptId);if(n===void 0||n.execution_id!==t.executionId)return{kind:`not-found`};let r=l(await T(e,t.executionAttemptId),t,new Date().toISOString());return r.kind===`accepted`&&await O(e,t.executionAttemptId,r.intent),r})},async requestCancellation(e){let t=a(e),n={requestKey:crypto.randomUUID(),reason:t.reason};await w(async e=>{let r=await e.all(E`SELECT execution_attempt_id FROM test_execution_attempt WHERE execution_id = ${t.executionId}`),i=new Date().toISOString(),a=[];for(let t of r){let r=l(await T(e,t.execution_attempt_id),n,i);if(r.kind===`conflict`)throw Error(`Generated cancellation request key conflicts with its receipt`);a.push({executionAttemptId:t.execution_attempt_id,decision:r})}for(let{executionAttemptId:t,decision:n}of a)n.kind===`accepted`&&await O(e,t,n.intent)})},async readCancellation(e){return w(t=>T(t,e))},async getActiveAttempt(e,t){return w(async n=>{if(await B(n,e)!==t)return null;let r=await A(n,t);return r===void 0?null:N(r)})},canonicalizeOutcome(e){return ne(u,e)},decodeOutcome(e){return t(u,e)},async commitOutcome(e){let n=e.result,i=e.runtimeFence,a=i===void 0?E`1 = 1`:E`
271
+ AND ${K()}`):o},{kind:`ready`,acceptedAt:t}))},async getAttemptControlState(e){return w(async t=>{let n=await F(t,e);return n===void 0?null:M(n)})},async requestAttemptCancellation(e){let t=i(e);return w(async e=>{let n=await F(e,t.executionAttemptId);if(n===void 0||n.execution_id!==t.executionId)return{kind:`not-found`};let r=l(await T(e,t.executionAttemptId),t,new Date().toISOString());return r.kind===`accepted`&&await A(e,t.executionAttemptId,r.intent),r})},async requestCancellation(e){let t=a(e),n={requestKey:crypto.randomUUID(),reason:t.reason};await w(async e=>{let r=await e.all(E`SELECT execution_attempt_id FROM test_execution_attempt WHERE execution_id = ${t.executionId}`),i=new Date().toISOString(),a=[];for(let t of r){let r=l(await T(e,t.execution_attempt_id),n,i);if(r.kind===`conflict`)throw Error(`Generated cancellation request key conflicts with its receipt`);a.push({executionAttemptId:t.execution_attempt_id,decision:r})}for(let{executionAttemptId:t,decision:n}of a)n.kind===`accepted`&&await A(e,t,n.intent)})},async readCancellation(e){return w(t=>T(t,e))},async readAttemptCancellationControl(e){let{executionId:t,executionAttemptId:n}=e;return w(async e=>{let r=await F(e,n);return r===void 0||r.execution_id!==t?null:{control:M(r),cancellation:await T(e,n),evidence:await O(e,n)}})},async recordAttemptControlReceipt(e){let t=pe(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t;return w(async e=>{let n=await F(e,i),s=(await O(e,i)).find(e=>e.controlRevision===a&&e.runtimeGeneration===o),c=me(n===void 0?null:N(n),await T(e,i),s?.receipt??null,t);return c.kind===`accepted`&&await e.run(E`INSERT INTO test_execution_attempt_control_evidence
272
+ (execution_attempt_id, control_revision, runtime_generation, receipt_json)
273
+ VALUES (${i}, ${a}, ${o}, ${JSON.stringify(r)})
274
+ ON CONFLICT (execution_attempt_id, control_revision, runtime_generation)
275
+ DO UPDATE SET receipt_json = excluded.receipt_json`),c})},async reportAttemptControl(e){let t=de(e),{executionId:n,...r}=t,{executionAttemptId:i,controlRevision:a,runtimeGeneration:o}=t;return w(async e=>{let n=await F(e,i),s=(await O(e,i)).find(e=>e.controlRevision===a&&e.runtimeGeneration===o),c=fe(n===void 0?null:N(n),await T(e,i),s?.report??null,t);return c.kind===`accepted`&&await e.run(E`INSERT INTO test_execution_attempt_control_evidence
276
+ (execution_attempt_id, control_revision, runtime_generation, report_json)
277
+ VALUES (${i}, ${a}, ${o}, ${JSON.stringify(r)})
278
+ ON CONFLICT (execution_attempt_id, control_revision, runtime_generation)
279
+ DO UPDATE SET report_json = excluded.report_json`),c})},async getActiveAttempt(e,t){return w(async n=>{if(await q(n,e)!==t)return null;let r=await F(n,t);return r===void 0?null:N(r)})},canonicalizeOutcome(e){return ne(u,e)},decodeOutcome(e){return t(u,e)},async commitOutcome(e){let n=e.result,i=e.runtimeFence,a=i===void 0?E`1 = 1`:E`
263
280
  runtime_generation = ${i.runtimeGeneration}
264
281
  AND ${i.operationId===null?E`active_operation_id IS NULL`:E`active_operation_id = ${i.operationId}
265
- AND active_operation_generation = ${i.runtimeGeneration}`}`;return w(o=>{let s=null;return V(async()=>{if(await B(o,e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let c=await A(o,e.executionAttemptId);if(c===void 0)return{kind:`fenced`};let l=c.workflow_result;if(l!==null){let e=t(u,l);return r(l,n.text)?{kind:`duplicate`,outcome:e,text:l,controlObservation:j(c.outcome_control_observation)}:{kind:`conflict`}}return c.settlement_kind===null?(i!==void 0&&ee(M(c),i),s=re(await T(o,e.executionAttemptId)),async()=>{let t=await o.run(E`UPDATE test_execution_attempt SET workflow_result = ${n.text},
282
+ AND active_operation_generation = ${i.runtimeGeneration}`}`;return w(o=>{let s=null;return V(async()=>{if(await q(o,e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let c=await F(o,e.executionAttemptId);if(c===void 0)return{kind:`fenced`};let l=c.workflow_result;if(l!==null){let e=t(u,l);return r(l,n.text)?{kind:`duplicate`,outcome:e,text:l,controlObservation:j(c.outcome_control_observation)}:{kind:`conflict`}}return c.settlement_kind===null?(i!==void 0&&ee(M(c),i),s=re(await T(o,e.executionAttemptId)),async()=>{let t=await o.run(E`UPDATE test_execution_attempt SET workflow_result = ${n.text},
266
283
  outcome_control_observation = ${JSON.stringify(s)}
267
284
  WHERE execution_attempt_id = ${e.executionAttemptId}
268
285
  AND workflow_result IS NULL
269
286
  AND settlement_kind IS NULL
270
287
  AND ${a}
271
- AND ${K()}`);return t.rowsAffected===0?t:X(o,e.executionAttemptId,`outcome`,E`workflow_result IS NOT NULL`)}):{kind:`conflict`}},()=>({kind:`accepted`,outcome:t(u,n.text),text:n.text,controlObservation:s}))})},async abandonPendingAttempt(e,t){return w(n=>V(async()=>{if(await B(n,t)!==e)return{kind:`fenced`};let r=await A(n,e);if(r===void 0)return{kind:`fenced`};let i=N(r);return i.status===`allocated`?{kind:`allocated`}:i.status===`provisioning`?{kind:`provisioning`}:i.status===`settled`?{kind:i.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:()=>n.run(E`UPDATE test_execution_attempt
288
+ AND ${K()}`);return t.rowsAffected===0?t:Z(o,e.executionAttemptId,`outcome`,E`workflow_result IS NOT NULL`)}):{kind:`conflict`}},()=>({kind:`accepted`,outcome:t(u,n.text),text:n.text,controlObservation:s}))})},async abandonPendingAttempt(e,t){return w(n=>V(async()=>{if(await q(n,t)!==e)return{kind:`fenced`};let r=await F(n,e);if(r===void 0)return{kind:`fenced`};let i=N(r);return i.status===`allocated`?{kind:`allocated`}:i.status===`provisioning`?{kind:`provisioning`}:i.status===`settled`?{kind:i.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:()=>n.run(E`UPDATE test_execution_attempt
272
289
  SET status = ${`settled`}, settlement_kind = ${`abandoned`}, claimable = ${0},
273
290
  operation_start_gate = ${`closed`}
274
291
  WHERE execution_attempt_id = ${e}
275
292
  AND execution_id = ${t}
276
293
  AND status = ${`pending`}
277
294
  AND settlement_kind IS NULL
278
- AND ${K()}`)},{kind:`abandoned`}))},recovery:Ee}}export{q as createSqliteAttemptRepository};
295
+ AND ${K()}`)},{kind:`abandoned`}))},recovery:Ne}}export{q as createSqliteAttemptRepository};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1789000242829",
3
+ "version": "1.0.0-dev-1789034250920",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/makaio-ai/makaio-framework.git",
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{C as t,S as n,a as r,b as i,c as a,d as o,i as s,l as c,n as l,r as u,y as d}from"./schemas-NKlV5jqJ.mjs";import{a as f,f as ee,l as p,m}from"./kind-registration-BanX_UAF.mjs";import{t as h}from"./zod-json-schema-DGWHUOK0.mjs";import{t as g}from"./ajv-Dz-0DD7m.mjs";import{t as _}from"./2020-DvDj4r_K.mjs";import{t as te}from"./dist-DMIaE8sg.mjs";import{z as v}from"zod";import{createBusNamespace as ne}from"@makaio/framework/core";const y=v.strictObject({evidence:n}),b=v.strictObject({kind:v.literal(`text`),text:v.string()}),[x,S,C]=n.options,w=v.union([x.pick({source:!0,location:!0}).extend({content:b}),S.pick({source:!0,location:!0}).extend({content:b}),C.pick({source:!0,location:!0}).extend({content:b})]);function T(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function E(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function D(e,t){if(t===`#`)return{node:e,pointer:``};if(!t.startsWith(`#/`))return;let n;try{n=decodeURIComponent(t.slice(1))}catch{return}let r=e;for(let e of n.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(t)||Number(t)>=r.length)return;r=r[Number(t)]}else{let e=T(r);if(!e||!Object.hasOwn(e,t))return;r=e[t]}}let i=typeof r==`boolean`?r:T(r);return i===void 0?void 0:{node:i,pointer:n}}function O(e,t){if(t===``)return!1;let n=e;for(let e of t.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(n=Array.isArray(n)?n[Number(t)]:T(n)?.[t],typeof T(n)?.$id==`string`)return!0}return!1}function re(e,t,r){if(e[`x-makaio-value-type`]!==`evidence/v1`)return;let i=n.safeParse(t);if(!i.success)throw Error(`Invalid schema-declared evidence at ${r}`);return{evidence:i.data,dataPath:r}}function ie(e,t,n,r){if(typeof t.$ref!=`string`)return!1;if(r)return!0;let i=D(e,t.$ref);return i===void 0?!0:typeof i.node!=`boolean`&&k(e,i.node,n,O(e,i.pointer))}function k(e,t,n=new WeakSet,r=!1){let i=T(t);if(!i||n.has(i))return!1;n.add(i);let a=r||i!==e&&typeof i.$id==`string`;if(i[`x-makaio-value-type`]===`evidence/v1`||typeof i.$dynamicRef==`string`||ie(e,i,n,a)||[`additionalItems`,`additionalProperties`,`contains`,`else`,`if`,`items`,`then`,`unevaluatedItems`,`unevaluatedProperties`].some(t=>k(e,i[t],n,a))||[`allOf`,`anyOf`,`oneOf`,`prefixItems`].some(t=>Array.isArray(i[t])&&i[t].some(t=>k(e,t,n,a)))||Array.isArray(i.items)&&i.items.some(t=>k(e,t,n,a)))return!0;for(let t of[`dependentSchemas`,`dependencies`,`patternProperties`,`properties`]){let r=T(i[t]);if(r&&Object.values(r).some(t=>k(e,t,n,a)))return!0}return!1}var A=class{dataSchema;matchesSchema;occurrences=new Map;visited=new WeakMap;constructor(e,t){this.dataSchema=e,this.matchesSchema=t}extract(e){return this.visit(this.dataSchema,e,`/data`),[...this.occurrences.values()]}visit(e,t,n,r=``){let i=this.visited.get(e)??new Set;if(i.has(n))return;if(i.add(n),this.visited.set(e,i),typeof e.$dynamicRef==`string`)throw Error(`Evidence discovery does not support active $dynamicRef at ${n}`);if(typeof e.$ref==`string`){if(O(this.dataSchema,r))throw Error(`Evidence discovery does not support local $ref inside nested $id resource at ${n}`);let i=D(this.dataSchema,e.$ref);if(i===void 0)throw Error(`Cannot resolve local schema reference ${e.$ref} at ${n}`);if(typeof i.node!=`boolean`&&this.visit(i.node,t,n,i.pointer),this.dataSchema.$schema!==`https://json-schema.org/draft/2020-12/schema`)return}let a=re(e,t,n);if(a){this.occurrences.set(n,a);return}this.visitCombiners(e,t,n,r),this.visitConditional(e,t,n,r),this.visitDependencies(e,t,n,r),this.assertSupportedApplicators(e,n,r),Array.isArray(t)?this.visitArray(e,t,n,r):typeof t==`object`&&t&&this.visitObject(e,t,n,r)}visitCombiners(e,t,n,r){for(let i of[`allOf`,`anyOf`,`oneOf`]){let a=e[i];if(Array.isArray(a))for(let[e,o]of a.entries()){let a=T(o),s=`${r}/${i}/${e}`;a&&(i===`allOf`||this.matchesSchema(this.dataSchema,s,t))&&this.visit(a,t,n,s)}}}visitConditional(e,t,n,r){let i=typeof e.if==`boolean`?e.if:T(e.if);if(i===void 0)return;let a=`${r}/if`,o=this.matchesSchema(this.dataSchema,a,t);o&&typeof i!=`boolean`&&this.visit(i,t,n,a);let s=o?`then`:`else`,c=T(e[s]);c&&this.visit(c,t,n,`${r}/${s}`)}visitDependencies(e,t,n,r){if(!(typeof t!=`object`||!t||Array.isArray(t)))for(let i of[`dependentSchemas`,`dependencies`]){let a=T(e[i]);if(a)for(let[e,o]of Object.entries(a)){let a=T(o);Object.hasOwn(t,e)&&a&&this.visit(a,t,n,`${r}/${i}/${E(e)}`)}}}assertSupportedApplicators(e,t,n){for(let r of[`unevaluatedProperties`,`unevaluatedItems`])if(k(this.dataSchema,e[r],void 0,O(this.dataSchema,n)))throw Error(`Evidence under unsupported ${r} applicator at ${t}`)}visitArray(e,t,n,r){let i=Array.isArray(e.prefixItems),a=i?e.prefixItems:Array.isArray(e.items)?e.items:[];a.forEach((e,a)=>{let o=T(e),s=i?`prefixItems`:`items`;o&&a<t.length&&this.visit(o,t[a],`${n}/${a}`,`${r}/${s}/${a}`)});let o=Array.isArray(e.items)?T(e.additionalItems):T(e.items);if(o){let i=Array.isArray(e.items)?`additionalItems`:`items`;t.slice(a.length).forEach((e,t)=>this.visit(o,e,`${n}/${a.length+t}`,`${r}/${i}`))}this.visitContains(e,t,n,r)}visitContains(e,t,n,r){let i=T(e.contains);if(!i)return;let a=`${r}/contains`;t.forEach((e,t)=>{this.matchesSchema(this.dataSchema,a,e)&&this.visit(i,e,`${n}/${t}`,a)})}visitObject(e,t,n,r){let i=T(e.properties),a=T(e.patternProperties);for(let[o,s]of Object.entries(t)){let t=E(o),c=i!==void 0&&Object.hasOwn(i,o),l=T(i?.[o]);l&&this.visit(l,s,`${n}/${t}`,`${r}/properties/${t}`);let u=this.visitPatterns(a,o,s,`${n}/${t}`,r),d=T(e.additionalProperties);!c&&!u&&d&&this.visit(d,s,`${n}/${t}`,`${r}/additionalProperties`)}}visitPatterns(e,t,n,r,i){let a=!1;for(let[o,s]of Object.entries(e??{})){if(!new RegExp(o,`u`).test(t))continue;a=!0;let e=T(s);e&&this.visit(e,n,r,`${i}/patternProperties/${E(o)}`)}return a}};function j(e,t,n){return new A(e,n.matchesSchema).extract(t)}function M(e){let{dataSchema:t,hooks:n,...r}=e,i={$schema:`https://json-schema.org/draft/2020-12/schema`,...h(t)};ee(i);let a=f.parse({...r,dataSchema:i});if(a.kind!==e.kind)throw Error(`Artifact kind identifiers must not contain surrounding whitespace`);let o=v.fromJSONSchema(a.dataSchema),s=v.unknown().superRefine((e,t)=>{let n=o.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:`custom`,path:e.path,message:e.message})}).pipe(t).superRefine((e,t)=>{try{m(e,a.titlePath)}catch(e){t.addIssue({code:`custom`,path:a.titlePath.split(`.`),message:e instanceof Error?e.message:`Artifact title must be a nonblank string`})}});return{...structuredClone(a),kind:e.kind,schemaVersion:e.schemaVersion,dataSchema:s,...n?{hooks:n}:{},toRegistration:()=>structuredClone(a)}}var N=e(g(),1),P=e(_(),1),F=e(te(),1);function I(e){let t={allErrors:!0,strict:!1,strictSchema:!0},n=e.dataSchema.$schema===`https://json-schema.org/draft/2020-12/schema`?new P.default(t):new N.default(t);return(0,F.default)(n),n.addKeyword({keyword:i,schemaType:`string`,valid:!0}),n.compile(e.dataSchema)}function L(e){return{hooks:[...e.hooks]}}const R=[`inline`,`summary`,`link`,`omit`],z=v.string().min(1),B=v.object({kinds:v.array(v.string().min(1)).optional(),hint:z.optional(),depth:v.number().int().min(1).max(20).optional(),nested:v.lazy(()=>V).optional()}),V=v.record(v.string().min(1),B);function H(e){return JSON.stringify([e.kind,e.id,e.revision])}const U=v.enum([`not-selected`,`not-found`,`depth-exceeded`,`unsupported-ref-class`,`cycle-detected`]),W=v.object({target:c,sourceRef:t,relationType:v.string().min(1),hint:z,status:v.enum([`resolved`,`unresolved`]),reason:U.optional()}).superRefine((e,t)=>{e.status===`unresolved`&&e.reason===void 0&&t.addIssue({code:v.ZodIssueCode.custom,path:[`reason`],message:`reason is required for unresolved artifact context refs`}),e.status===`resolved`&&e.reason!==void 0&&t.addIssue({code:v.ZodIssueCode.custom,path:[`reason`],message:`reason must be omitted for resolved artifact context refs`}),e.status===`resolved`&&e.target.refClass!==`artifact`&&t.addIssue({code:v.ZodIssueCode.custom,path:[`target`],message:`resolved artifact context refs must target an artifact revision`})}),G=v.object({rootRef:t,refs:v.array(W),resolved:v.array(o)}).superRefine((e,t)=>{let n=new Set(e.resolved.map(H));n.has(H(e.rootRef))||t.addIssue({code:v.ZodIssueCode.custom,path:[`resolved`],message:`resolved artifact context wire payloads must include the root artifact revision`}),e.refs.forEach((e,r)=>{n.has(H(e.sourceRef))||t.addIssue({code:v.ZodIssueCode.custom,path:[`refs`,r,`sourceRef`],message:`artifact context ref sources must have a matching revision in resolved`}),!(e.status!==`resolved`||e.target.refClass!==`artifact`)&&(n.has(H(e.target))||t.addIssue({code:v.ZodIssueCode.custom,path:[`refs`,r,`target`],message:`resolved artifact context refs must have a matching revision in resolved`}))})});function K(e){let t=G.parse(e),n=new Map(t.resolved.map(e=>[Z(e),e])),r=new Map;for(let e of t.refs){let t=Z(e.sourceRef),n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}let i=n.get(Z(t.rootRef));if(!i)throw Error(`Resolved artifact context is missing root artifact '${Z(t.rootRef)}'`);let a=q(t.rootRef,i,`inline`,r,n);return{root:a,flatten(){let e=[];return X(a,e),e}}}function q(e,t,n,r,i){return{status:`resolved`,ref:e,artifact:t,hint:n,children:Y(e,r,i,new Set([Z(e)]))}}function J(e,t,n,r,i,a,o){let s=Z(e),c=new Set(o);return c.add(s),{status:`resolved`,ref:e,artifact:t,relation:n,hint:r,children:Y(e,i,a,c)}}function Y(e,t,n,r){return(t.get(Z(e))??[]).map(e=>{if(e.status===`unresolved`)return{status:`unresolved`,target:e.target,relation:e.relationType,hint:e.hint,reason:e.reason};if(e.target.refClass!==`artifact`)throw Error(`Resolved artifact context refs must target an artifact revision`);let i=Z(e.target),a=n.get(i);if(!a)throw Error(`Resolved artifact context is missing target artifact '${i}'`);return r.has(i)?{status:`unresolved`,target:e.target,relation:e.relationType,hint:e.hint,reason:`cycle-detected`}:J(e.target,a,e.relationType,e.hint,t,n,r)})}function X(e,t){if(e.status!==`unresolved`){t.push(e.artifact);for(let n of e.children)X(n,t)}}function Z(e){return JSON.stringify([e.kind,e.id,e.revision])}const Q={"kind.register":{request:f,response:v.object({registered:v.boolean()})},"kind.list":{request:v.object({kind:v.string().min(1).optional()}),response:v.object({kinds:v.array(f)})},"relation-type.register":{request:d,response:v.object({registered:v.boolean()})},"relation-type.list":{request:v.object({type:v.string().min(1).optional()}),response:v.object({relationTypes:v.array(d)})},create:{request:o.omit({id:!0,revision:!0,timestamp:!0}).extend({id:t.shape.id.optional()}),response:v.object({artifact:o})},revise:{request:v.object({previous:t,statusPath:v.string().regex(/^(?:\/(?:[^~/]|~[01])*)+$/,`Expected a data-relative JSON Pointer`).optional(),revision:o.omit({id:!0,revision:!0,timestamp:!0})}),response:v.object({artifact:o})},resolve:{request:v.object({ref:t}),response:v.object({artifact:o.nullable()})},query:{request:r,response:v.object({artifacts:v.array(o)})},compare:{request:l,response:u},"evidence.resolve":{request:y,response:w},resolveContext:{request:v.object({ref:t,selectors:V.optional(),maxDepth:v.number().int().min(1).max(20).default(5)}),response:v.object({context:G})},created:v.object({artifact:o}),revised:v.object({previous:t,artifact:o}),"relation.added":v.object({artifact:t,relation:a}),"observation.added":v.object({artifact:t,observation:s}),"status.changed":v.object({artifact:t,path:v.string().min(1),previous:v.unknown().optional(),current:v.unknown().optional()}),"kind.changed":v.object({kind:v.string().min(1),schemaVersion:p})},$=ne(`artifact`,Q),ae=$.subjects;export{w as _,W as a,R as c,V as d,L as f,y as g,j as h,K as i,B as l,M as m,Q as n,U as o,I as p,ae as r,G as s,$ as t,z as u};