@akterjs/effect 0.0.0-stage → 0.1.0

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 (798) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +43 -2
  3. package/dist/contract/actor/actor-already-exists.errors.d.mts +8 -0
  4. package/dist/contract/actor/actor-already-exists.errors.mjs +4 -0
  5. package/dist/contract/actor/actor-definition.pure.d.mts +21 -0
  6. package/dist/contract/actor/actor-definition.pure.mjs +106 -0
  7. package/dist/contract/actor/actor-erased.errors.d.mts +8 -0
  8. package/dist/contract/actor/actor-erased.errors.mjs +4 -0
  9. package/dist/contract/actor/actor-names.pure.d.mts +11 -0
  10. package/dist/contract/actor/actor-names.pure.mjs +51 -0
  11. package/dist/contract/actor/actor-not-created.errors.d.mts +8 -0
  12. package/dist/contract/actor/actor-not-created.errors.mjs +4 -0
  13. package/dist/contract/actor/actor-not-registered.errors.d.mts +8 -0
  14. package/dist/contract/actor/actor-not-registered.errors.mjs +4 -0
  15. package/dist/contract/actor/actor-registry.service.d.mts +16 -0
  16. package/dist/contract/actor/actor-registry.service.mjs +21 -0
  17. package/dist/contract/actor/actor.contract.d.mts +238 -0
  18. package/dist/contract/actor/actor.contract.mjs +1 -0
  19. package/dist/contract/actor/host-interface.pure.d.mts +23 -0
  20. package/dist/contract/actor/host-interface.pure.mjs +39 -0
  21. package/dist/contract/actor/reserved-member.errors.d.mts +9 -0
  22. package/dist/contract/actor/reserved-member.errors.mjs +7 -0
  23. package/dist/contract/akter.service.d.mts +75 -0
  24. package/dist/contract/akter.service.mjs +134 -0
  25. package/dist/contract/caller/authentication.api.d.mts +6 -0
  26. package/dist/contract/caller/authentication.api.mjs +5 -0
  27. package/dist/contract/caller/caller-admission.pure.d.mts +27 -0
  28. package/dist/contract/caller/caller-admission.pure.mjs +59 -0
  29. package/dist/contract/caller/caller-not-allowed.errors.d.mts +16 -0
  30. package/dist/contract/caller/caller-not-allowed.errors.mjs +18 -0
  31. package/dist/contract/caller/caller.schema.d.mts +7 -0
  32. package/dist/contract/caller/caller.schema.mjs +8 -0
  33. package/dist/contract/caller/current-caller.service.d.mts +7 -0
  34. package/dist/contract/caller/current-caller.service.mjs +4 -0
  35. package/dist/contract/caller/principal.schema.d.mts +13 -0
  36. package/dist/contract/caller/principal.schema.mjs +10 -0
  37. package/dist/contract/caller/unauthenticated.errors.d.mts +8 -0
  38. package/dist/contract/caller/unauthenticated.errors.mjs +4 -0
  39. package/dist/contract/client/actor-client.adapter.d.mts +42 -0
  40. package/dist/contract/client/actor-client.adapter.mjs +90 -0
  41. package/dist/contract/client/actor-client.contract.d.mts +30 -0
  42. package/dist/contract/client/actor-client.contract.mjs +1 -0
  43. package/dist/contract/client/actor-rpc.contract.d.mts +33 -0
  44. package/dist/contract/client/actor-rpc.contract.mjs +16 -0
  45. package/dist/contract/client/actor-unavailable.errors.d.mts +9 -0
  46. package/dist/contract/client/actor-unavailable.errors.mjs +7 -0
  47. package/dist/contract/client/client-failure.contract.d.mts +28 -0
  48. package/dist/contract/client/client-failure.contract.mjs +28 -0
  49. package/dist/contract/client/invalid-request.errors.d.mts +9 -0
  50. package/dist/contract/client/invalid-request.errors.mjs +7 -0
  51. package/dist/contract/client/storage-limit.errors.d.mts +16 -0
  52. package/dist/contract/client/storage-limit.errors.mjs +14 -0
  53. package/dist/contract/command/command-id-expired.errors.d.mts +11 -0
  54. package/dist/contract/command/command-id-expired.errors.mjs +9 -0
  55. package/dist/contract/command/command-id.schema.d.mts +3 -0
  56. package/dist/contract/command/command-id.schema.mjs +4 -0
  57. package/dist/contract/command/command.contract.d.mts +117 -0
  58. package/dist/contract/command/command.contract.mjs +111 -0
  59. package/dist/contract/command/outbox-id.pure.d.mts +9 -0
  60. package/dist/contract/command/outbox-id.pure.mjs +14 -0
  61. package/dist/contract/command/outbox.schema.d.mts +9 -0
  62. package/dist/contract/command/outbox.schema.mjs +10 -0
  63. package/dist/contract/command/timer.schema.d.mts +20 -0
  64. package/dist/contract/command/timer.schema.mjs +14 -0
  65. package/dist/contract/computer/checkpoint-expired.errors.d.mts +12 -0
  66. package/dist/contract/computer/checkpoint-expired.errors.mjs +8 -0
  67. package/dist/contract/computer/computer-client-failure.contract.d.mts +16 -0
  68. package/dist/contract/computer/computer-client-failure.contract.mjs +1 -0
  69. package/dist/contract/computer/computer-client.adapter.d.mts +21 -0
  70. package/dist/contract/computer/computer-client.adapter.mjs +70 -0
  71. package/dist/contract/computer/computer-client.contract.d.mts +56 -0
  72. package/dist/contract/computer/computer-client.contract.mjs +1 -0
  73. package/dist/contract/computer/computer-held.errors.d.mts +13 -0
  74. package/dist/contract/computer/computer-held.errors.mjs +11 -0
  75. package/dist/contract/computer/computer-limit.errors.d.mts +15 -0
  76. package/dist/contract/computer/computer-limit.errors.mjs +13 -0
  77. package/dist/contract/computer/computer-lost.errors.d.mts +12 -0
  78. package/dist/contract/computer/computer-lost.errors.mjs +8 -0
  79. package/dist/contract/computer/computer-not-found.errors.d.mts +9 -0
  80. package/dist/contract/computer/computer-not-found.errors.mjs +5 -0
  81. package/dist/contract/computer/computer.schema.d.mts +122 -0
  82. package/dist/contract/computer/computer.schema.mjs +117 -0
  83. package/dist/contract/computer/computers-unavailable.errors.d.mts +9 -0
  84. package/dist/contract/computer/computers-unavailable.errors.mjs +5 -0
  85. package/dist/contract/computer/files/computer-files.schema.d.mts +28 -0
  86. package/dist/contract/computer/files/computer-files.schema.mjs +24 -0
  87. package/dist/contract/computer/rpc/computer-rpc.contract.d.mts +108 -0
  88. package/dist/contract/computer/rpc/computer-rpc.contract.mjs +117 -0
  89. package/dist/contract/computer/step/computer-step.contract.d.mts +21 -0
  90. package/dist/contract/computer/step/computer-step.contract.mjs +89 -0
  91. package/dist/contract/computer/step/computer-step.schema.d.mts +69 -0
  92. package/dist/contract/computer/step/computer-step.schema.mjs +71 -0
  93. package/dist/contract/computer/step/step-failure.schema.d.mts +13 -0
  94. package/dist/contract/computer/step/step-failure.schema.mjs +24 -0
  95. package/dist/contract/computer/step/step-not-found.errors.d.mts +9 -0
  96. package/dist/contract/computer/step/step-not-found.errors.mjs +5 -0
  97. package/dist/contract/description/published-contract.pure.d.mts +51 -0
  98. package/dist/contract/description/published-contract.pure.mjs +75 -0
  99. package/dist/contract/file/access/file-access-denied.errors.d.mts +11 -0
  100. package/dist/contract/file/access/file-access-denied.errors.mjs +9 -0
  101. package/dist/contract/file/access/file-access.contract.d.mts +35 -0
  102. package/dist/contract/file/access/file-access.contract.mjs +32 -0
  103. package/dist/contract/file/actor-files.contract.d.mts +50 -0
  104. package/dist/contract/file/actor-files.contract.mjs +1 -0
  105. package/dist/contract/file/blob-transfer.errors.d.mts +9 -0
  106. package/dist/contract/file/blob-transfer.errors.mjs +7 -0
  107. package/dist/contract/file/file-client-failure.contract.d.mts +24 -0
  108. package/dist/contract/file/file-client-failure.contract.mjs +1 -0
  109. package/dist/contract/file/file-client.adapter.d.mts +17 -0
  110. package/dist/contract/file/file-client.adapter.mjs +21 -0
  111. package/dist/contract/file/file-client.contract.d.mts +14 -0
  112. package/dist/contract/file/file-client.contract.mjs +1 -0
  113. package/dist/contract/file/file-listing.pure.d.mts +6 -0
  114. package/dist/contract/file/file-listing.pure.mjs +18 -0
  115. package/dist/contract/file/file-not-found.errors.d.mts +8 -0
  116. package/dist/contract/file/file-not-found.errors.mjs +4 -0
  117. package/dist/contract/file/file-path.pure.d.mts +4 -0
  118. package/dist/contract/file/file-path.pure.mjs +38 -0
  119. package/dist/contract/file/files-unavailable.errors.d.mts +8 -0
  120. package/dist/contract/file/files-unavailable.errors.mjs +4 -0
  121. package/dist/contract/file/invalid-file-request.errors.d.mts +9 -0
  122. package/dist/contract/file/invalid-file-request.errors.mjs +7 -0
  123. package/dist/contract/file/rpc/file-rpc.contract.d.mts +88 -0
  124. package/dist/contract/file/rpc/file-rpc.contract.mjs +117 -0
  125. package/dist/contract/file/rpc/file-too-large.errors.d.mts +13 -0
  126. package/dist/contract/file/rpc/file-too-large.errors.mjs +11 -0
  127. package/dist/contract/file/rpc/rpc-file-clients.layer.d.mts +10 -0
  128. package/dist/contract/file/rpc/rpc-file-clients.layer.mjs +95 -0
  129. package/dist/contract/fork/fork-rpc.contract.d.mts +40 -0
  130. package/dist/contract/fork/fork-rpc.contract.mjs +26 -0
  131. package/dist/contract/history/actor-journal.service.d.mts +58 -0
  132. package/dist/contract/history/actor-journal.service.mjs +67 -0
  133. package/dist/contract/history/history-entry.pure.d.mts +79 -0
  134. package/dist/contract/history/history-entry.pure.mjs +95 -0
  135. package/dist/contract/hosted/handler-failed.errors.d.mts +16 -0
  136. package/dist/contract/hosted/handler-failed.errors.mjs +14 -0
  137. package/dist/contract/hosted/handler-failure.pure.d.mts +21 -0
  138. package/dist/contract/hosted/handler-failure.pure.mjs +86 -0
  139. package/dist/contract/hosted/hosted-actor.service.d.mts +23 -0
  140. package/dist/contract/hosted/hosted-actor.service.mjs +64 -0
  141. package/dist/contract/hosted/hosted-command.service.d.mts +20 -0
  142. package/dist/contract/hosted/hosted-command.service.mjs +88 -0
  143. package/dist/contract/hosted/hosted-create.service.d.mts +17 -0
  144. package/dist/contract/hosted/hosted-create.service.mjs +67 -0
  145. package/dist/contract/hosted/hosted-error.contract.d.mts +11 -0
  146. package/dist/contract/hosted/hosted-error.contract.mjs +1 -0
  147. package/dist/contract/hosted/hosted-failure.schema.d.mts +18 -0
  148. package/dist/contract/hosted/hosted-failure.schema.mjs +31 -0
  149. package/dist/contract/hosted/hosted-outcome.contract.d.mts +18 -0
  150. package/dist/contract/hosted/hosted-outcome.contract.mjs +1 -0
  151. package/dist/contract/hosted/hosted-query.service.d.mts +16 -0
  152. package/dist/contract/hosted/hosted-query.service.mjs +42 -0
  153. package/dist/contract/hosted/hosted-request.pure.d.mts +61 -0
  154. package/dist/contract/hosted/hosted-request.pure.mjs +91 -0
  155. package/dist/contract/job/job-id.pure.d.mts +11 -0
  156. package/dist/contract/job/job-id.pure.mjs +20 -0
  157. package/dist/contract/job/job-patches.contract.d.mts +32 -0
  158. package/dist/contract/job/job-patches.contract.mjs +45 -0
  159. package/dist/contract/job/job-signal.schema.d.mts +13 -0
  160. package/dist/contract/job/job-signal.schema.mjs +16 -0
  161. package/dist/contract/job/reserved-payload-field.errors.d.mts +10 -0
  162. package/dist/contract/job/reserved-payload-field.errors.mjs +8 -0
  163. package/dist/contract/job/started-job.schema.d.mts +7 -0
  164. package/dist/contract/job/started-job.schema.mjs +8 -0
  165. package/dist/contract/json-codec.pure.d.mts +7 -0
  166. package/dist/contract/json-codec.pure.mjs +14 -0
  167. package/dist/contract/room.contract.d.mts +75 -0
  168. package/dist/contract/room.contract.mjs +36 -0
  169. package/dist/contract/secret/actor-secrets.adapter.d.mts +33 -0
  170. package/dist/contract/secret/actor-secrets.adapter.mjs +38 -0
  171. package/dist/contract/secret/invalid-secret-name.errors.d.mts +10 -0
  172. package/dist/contract/secret/invalid-secret-name.errors.mjs +8 -0
  173. package/dist/contract/secret/secret-unavailable.errors.d.mts +11 -0
  174. package/dist/contract/secret/secret-unavailable.errors.mjs +10 -0
  175. package/dist/contract/secret/secret.schema.d.mts +25 -0
  176. package/dist/contract/secret/secret.schema.mjs +34 -0
  177. package/dist/contract/spend/billing-unavailable.errors.d.mts +12 -0
  178. package/dist/contract/spend/billing-unavailable.errors.mjs +8 -0
  179. package/dist/contract/spend/spend-cap-reached.errors.d.mts +17 -0
  180. package/dist/contract/spend/spend-cap-reached.errors.mjs +15 -0
  181. package/dist/contract/state/actor-state.pure.d.mts +38 -0
  182. package/dist/contract/state/actor-state.pure.mjs +153 -0
  183. package/dist/contract/state/actor-state.service.d.mts +45 -0
  184. package/dist/contract/state/actor-state.service.mjs +18 -0
  185. package/dist/contract/state/state-migration.pure.d.mts +11 -0
  186. package/dist/contract/state/state-migration.pure.mjs +23 -0
  187. package/dist/contract/state/state-read.pure.d.mts +12 -0
  188. package/dist/contract/state/state-read.pure.mjs +22 -0
  189. package/dist/contract/state/state-unreadable.errors.d.mts +9 -0
  190. package/dist/contract/state/state-unreadable.errors.mjs +7 -0
  191. package/dist/host/actor/actor-database.service.d.mts +46 -0
  192. package/dist/host/actor/actor-database.service.mjs +112 -0
  193. package/dist/host/actor/actor-exclusive.pure.d.mts +7 -0
  194. package/dist/host/actor/actor-exclusive.pure.mjs +16 -0
  195. package/dist/host/actor/actor-records.sql.d.mts +29 -0
  196. package/dist/host/actor/actor-records.sql.mjs +26 -0
  197. package/dist/host/actor/reserved-name.errors.d.mts +10 -0
  198. package/dist/host/actor/reserved-name.errors.mjs +8 -0
  199. package/dist/host/actor/reserved-names.pure.d.mts +15 -0
  200. package/dist/host/actor/reserved-names.pure.mjs +20 -0
  201. package/dist/host/actor/room.actor.d.mts +4 -0
  202. package/dist/host/actor/room.actor.mjs +36 -0
  203. package/dist/host/blob/blob-frames.pure.d.mts +7 -0
  204. package/dist/host/blob/blob-frames.pure.mjs +28 -0
  205. package/dist/host/blob/blob-grant.schema.d.mts +14 -0
  206. package/dist/host/blob/blob-grant.schema.mjs +15 -0
  207. package/dist/host/blob/blob-grants.service.d.mts +28 -0
  208. package/dist/host/blob/blob-grants.service.mjs +129 -0
  209. package/dist/host/blob/blob-keyring.service.d.mts +18 -0
  210. package/dist/host/blob/blob-keyring.service.mjs +4 -0
  211. package/dist/host/blob/blob-range.pure.d.mts +13 -0
  212. package/dist/host/blob/blob-range.pure.mjs +23 -0
  213. package/dist/host/blob/blob-sealing.contract.d.mts +37 -0
  214. package/dist/host/blob/blob-sealing.contract.mjs +1 -0
  215. package/dist/host/blob/blob-sealing.service.d.mts +11 -0
  216. package/dist/host/blob/blob-sealing.service.mjs +16 -0
  217. package/dist/host/blob/export/blob-archive.sql.d.mts +21 -0
  218. package/dist/host/blob/export/blob-archive.sql.mjs +75 -0
  219. package/dist/host/blob/export/blob-export-holds.sql.d.mts +49 -0
  220. package/dist/host/blob/export/blob-export-holds.sql.mjs +25 -0
  221. package/dist/host/blob/plain-blob-sealing.pure.d.mts +5 -0
  222. package/dist/host/blob/plain-blob-sealing.pure.mjs +55 -0
  223. package/dist/host/blob/reference/blob-catalog.sql.d.mts +40 -0
  224. package/dist/host/blob/reference/blob-catalog.sql.mjs +145 -0
  225. package/dist/host/blob/reference/blob-coordinator.pure.d.mts +10 -0
  226. package/dist/host/blob/reference/blob-coordinator.pure.mjs +153 -0
  227. package/dist/host/blob/reference/blob-file-page.sql.d.mts +13 -0
  228. package/dist/host/blob/reference/blob-file-page.sql.mjs +21 -0
  229. package/dist/host/blob/reference/blob-forks.sql.d.mts +21 -0
  230. package/dist/host/blob/reference/blob-forks.sql.mjs +40 -0
  231. package/dist/host/blob/reference/blob-lineage.sql.d.mts +14 -0
  232. package/dist/host/blob/reference/blob-lineage.sql.mjs +24 -0
  233. package/dist/host/blob/reference/blob-reads.pure.d.mts +15 -0
  234. package/dist/host/blob/reference/blob-reads.pure.mjs +97 -0
  235. package/dist/host/blob/reference/blob-receipts.sql.d.mts +71 -0
  236. package/dist/host/blob/reference/blob-receipts.sql.mjs +176 -0
  237. package/dist/host/blob/reference/blob-transfer-adopt.pure.d.mts +21 -0
  238. package/dist/host/blob/reference/blob-transfer-adopt.pure.mjs +68 -0
  239. package/dist/host/blob/reference/blob-transfer-fork.pure.d.mts +15 -0
  240. package/dist/host/blob/reference/blob-transfer-fork.pure.mjs +125 -0
  241. package/dist/host/blob/reference/blob-transfer-upkeep.pure.d.mts +18 -0
  242. package/dist/host/blob/reference/blob-transfer-upkeep.pure.mjs +54 -0
  243. package/dist/host/blob/reference/blob-transfer.pure.d.mts +85 -0
  244. package/dist/host/blob/reference/blob-transfer.pure.mjs +1 -0
  245. package/dist/host/blob/sealed-blob-sealing.pure.d.mts +10 -0
  246. package/dist/host/blob/sealed-blob-sealing.pure.mjs +130 -0
  247. package/dist/host/blob/stream/blob-directory.pure.d.mts +18 -0
  248. package/dist/host/blob/stream/blob-directory.pure.mjs +84 -0
  249. package/dist/host/blob/stream/blob-length.pure.d.mts +9 -0
  250. package/dist/host/blob/stream/blob-length.pure.mjs +19 -0
  251. package/dist/host/blob/stream/blob-writing.pure.d.mts +8 -0
  252. package/dist/host/blob/stream/blob-writing.pure.mjs +15 -0
  253. package/dist/host/command/batch/command-batch.sql.d.mts +61 -0
  254. package/dist/host/command/batch/command-batch.sql.mjs +100 -0
  255. package/dist/host/command/command-context.adapter.d.mts +47 -0
  256. package/dist/host/command/command-context.adapter.mjs +90 -0
  257. package/dist/host/command/command-id-age.pure.d.mts +13 -0
  258. package/dist/host/command/command-id-age.pure.mjs +31 -0
  259. package/dist/host/command/command-id-reuse.pure.d.mts +28 -0
  260. package/dist/host/command/command-id-reuse.pure.mjs +38 -0
  261. package/dist/host/command/command-id-reused.errors.d.mts +13 -0
  262. package/dist/host/command/command-id-reused.errors.mjs +11 -0
  263. package/dist/host/command/command-journal.sql.d.mts +84 -0
  264. package/dist/host/command/command-journal.sql.mjs +74 -0
  265. package/dist/host/command/command-rejected.errors.d.mts +8 -0
  266. package/dist/host/command/command-rejected.errors.mjs +4 -0
  267. package/dist/host/command/command-replay.service.d.mts +62 -0
  268. package/dist/host/command/command-replay.service.mjs +140 -0
  269. package/dist/host/command/command-reply.pure.d.mts +8 -0
  270. package/dist/host/command/command-reply.pure.mjs +12 -0
  271. package/dist/host/command/command-runner.service.d.mts +68 -0
  272. package/dist/host/command/command-runner.service.mjs +215 -0
  273. package/dist/host/command/files/command-file-inputs.sql.d.mts +51 -0
  274. package/dist/host/command/files/command-file-inputs.sql.mjs +59 -0
  275. package/dist/host/command/history-pruned.errors.d.mts +10 -0
  276. package/dist/host/command/history-pruned.errors.mjs +8 -0
  277. package/dist/host/command/replay/replay-cursor-stalled.errors.d.mts +9 -0
  278. package/dist/host/command/replay/replay-cursor-stalled.errors.mjs +7 -0
  279. package/dist/host/command/replay/replay-cursor.pure.d.mts +7 -0
  280. package/dist/host/command/replay/replay-cursor.pure.mjs +12 -0
  281. package/dist/host/computer/computer-steps.sql.d.mts +14 -0
  282. package/dist/host/computer/computer-steps.sql.mjs +76 -0
  283. package/dist/host/computer/job-computers.service.d.mts +20 -0
  284. package/dist/host/computer/job-computers.service.mjs +59 -0
  285. package/dist/host/computer/local-computer-files.layer.d.mts +11 -0
  286. package/dist/host/computer/local-computer-files.layer.mjs +69 -0
  287. package/dist/host/computer/local-computer-log.layer.d.mts +23 -0
  288. package/dist/host/computer/local-computer-log.layer.mjs +64 -0
  289. package/dist/host/computer/local-computer-records.layer.d.mts +190 -0
  290. package/dist/host/computer/local-computer-records.layer.mjs +99 -0
  291. package/dist/host/computer/local-computer.schema.d.mts +69 -0
  292. package/dist/host/computer/local-computer.schema.mjs +29 -0
  293. package/dist/host/computer/local-computers.adapter.d.mts +18 -0
  294. package/dist/host/computer/local-computers.adapter.mjs +248 -0
  295. package/dist/host/computer/local-step.layer.d.mts +30 -0
  296. package/dist/host/computer/local-step.layer.mjs +119 -0
  297. package/dist/host/file/actor-file-storage.sql.d.mts +15 -0
  298. package/dist/host/file/actor-file-storage.sql.mjs +82 -0
  299. package/dist/host/file/actor-files.sql.d.mts +9 -0
  300. package/dist/host/file/actor-files.sql.mjs +3 -0
  301. package/dist/host/file/blob-home-lock.pure.d.mts +8 -0
  302. package/dist/host/file/blob-home-lock.pure.mjs +10 -0
  303. package/dist/host/file/blob-home.sql.d.mts +19 -0
  304. package/dist/host/file/blob-home.sql.mjs +30 -0
  305. package/dist/host/file/local-blob-home.service.d.mts +16 -0
  306. package/dist/host/file/local-blob-home.service.mjs +43 -0
  307. package/dist/host/file/local-blob-owner.sql.d.mts +30 -0
  308. package/dist/host/file/local-blob-owner.sql.mjs +68 -0
  309. package/dist/host/file/local-file-upkeep.pure.d.mts +12 -0
  310. package/dist/host/file/local-file-upkeep.pure.mjs +41 -0
  311. package/dist/host/file/replay-file-storage.sql.d.mts +7 -0
  312. package/dist/host/file/replay-file-storage.sql.mjs +26 -0
  313. package/dist/host/fork/actor-fork.sql.d.mts +52 -0
  314. package/dist/host/fork/actor-fork.sql.mjs +42 -0
  315. package/dist/host/fork/fork-computers.adapter.d.mts +43 -0
  316. package/dist/host/fork/fork-computers.adapter.mjs +193 -0
  317. package/dist/host/hash/blob-hashing.service.d.mts +10 -0
  318. package/dist/host/hash/blob-hashing.service.mjs +4 -0
  319. package/dist/host/job/job-durables.sql.d.mts +44 -0
  320. package/dist/host/job/job-durables.sql.mjs +136 -0
  321. package/dist/host/job/job-engine.adapter.d.mts +33 -0
  322. package/dist/host/job/job-engine.adapter.mjs +258 -0
  323. package/dist/host/job/job-journal.sql.d.mts +85 -0
  324. package/dist/host/job/job-journal.sql.mjs +109 -0
  325. package/dist/host/job/job-results.service.d.mts +37 -0
  326. package/dist/host/job/job-results.service.mjs +63 -0
  327. package/dist/host/job/job-runs.pure.d.mts +103 -0
  328. package/dist/host/job/job-runs.pure.mjs +193 -0
  329. package/dist/host/job/undelivered-result.pure.d.mts +49 -0
  330. package/dist/host/job/undelivered-result.pure.mjs +147 -0
  331. package/dist/host/layout/actor-layout.sql.d.mts +8 -0
  332. package/dist/host/layout/actor-layout.sql.mjs +33 -0
  333. package/dist/host/layout/layout-version.errors.d.mts +10 -0
  334. package/dist/host/layout/layout-version.errors.mjs +8 -0
  335. package/dist/host/layout/layout-version.pure.d.mts +10 -0
  336. package/dist/host/layout/layout-version.pure.mjs +14 -0
  337. package/dist/host/migration/actor-migrations.service.d.mts +46 -0
  338. package/dist/host/migration/actor-migrations.service.mjs +143 -0
  339. package/dist/host/migration/migration-edited.errors.d.mts +9 -0
  340. package/dist/host/migration/migration-edited.errors.mjs +7 -0
  341. package/dist/host/migration/migration-failed.errors.d.mts +12 -0
  342. package/dist/host/migration/migration-failed.errors.mjs +10 -0
  343. package/dist/host/migration/migration-failure.pure.d.mts +9 -0
  344. package/dist/host/migration/migration-failure.pure.mjs +19 -0
  345. package/dist/host/migration/migration-hasher.adapter.d.mts +15 -0
  346. package/dist/host/migration/migration-hasher.adapter.mjs +40 -0
  347. package/dist/host/migration/migration-missing.errors.d.mts +9 -0
  348. package/dist/host/migration/migration-missing.errors.mjs +7 -0
  349. package/dist/host/migration/migration-plan.pure.d.mts +20 -0
  350. package/dist/host/migration/migration-plan.pure.mjs +32 -0
  351. package/dist/host/outbox/actor-outbox.sql.d.mts +33 -0
  352. package/dist/host/outbox/actor-outbox.sql.mjs +28 -0
  353. package/dist/host/outbox/outbox-acknowledgements.sql.d.mts +12 -0
  354. package/dist/host/outbox/outbox-acknowledgements.sql.mjs +47 -0
  355. package/dist/host/outbox/outbox-runner.service.d.mts +37 -0
  356. package/dist/host/outbox/outbox-runner.service.mjs +155 -0
  357. package/dist/host/query/query-policy.pure.d.mts +15 -0
  358. package/dist/host/query/query-policy.pure.mjs +12 -0
  359. package/dist/host/query/query-runner.service.d.mts +42 -0
  360. package/dist/host/query/query-runner.service.mjs +72 -0
  361. package/dist/host/sqlite/actor-connections.pure.d.mts +26 -0
  362. package/dist/host/sqlite/actor-connections.pure.mjs +4 -0
  363. package/dist/host/sqlite/sqlite-connection.adapter.d.mts +22 -0
  364. package/dist/host/sqlite/sqlite-connection.adapter.mjs +151 -0
  365. package/dist/host/sqlite/sqlite-driver.service.d.mts +33 -0
  366. package/dist/host/sqlite/sqlite-driver.service.mjs +88 -0
  367. package/dist/host/sqlite/sqlite-parameters.pure.d.mts +5 -0
  368. package/dist/host/sqlite/sqlite-parameters.pure.mjs +21 -0
  369. package/dist/host/sqlite/sqlite-reason.pure.d.mts +8 -0
  370. package/dist/host/sqlite/sqlite-reason.pure.mjs +13 -0
  371. package/dist/host/timer/actor-timers.sql.d.mts +32 -0
  372. package/dist/host/timer/actor-timers.sql.mjs +8 -0
  373. package/dist/host/timer/timer-runner.service.d.mts +26 -0
  374. package/dist/host/timer/timer-runner.service.mjs +68 -0
  375. package/dist/host/upkeep/actor-due.sql.d.mts +26 -0
  376. package/dist/host/upkeep/actor-due.sql.mjs +43 -0
  377. package/dist/host/upkeep/actor-upkeep.service.d.mts +55 -0
  378. package/dist/host/upkeep/actor-upkeep.service.mjs +218 -0
  379. package/dist/host/upkeep/execution-authority.pure.d.mts +19 -0
  380. package/dist/host/upkeep/execution-authority.pure.mjs +10 -0
  381. package/dist/runtime/akter-local.layer.d.mts +28 -0
  382. package/dist/runtime/akter-local.layer.mjs +24 -0
  383. package/dist/runtime/akter.layer.d.mts +91 -0
  384. package/dist/runtime/akter.layer.mjs +99 -0
  385. package/dist/runtime/blob-hashing.layer.d.mts +4 -0
  386. package/dist/runtime/blob-hashing.layer.mjs +15 -0
  387. package/dist/runtime/hosted-environment.layer.d.mts +34 -0
  388. package/dist/runtime/hosted-environment.layer.mjs +40 -0
  389. package/dist/runtime/http-server.layer.d.mts +9 -0
  390. package/dist/runtime/http-server.layer.mjs +15 -0
  391. package/dist/runtime/local-actor-engine.layer.d.mts +10 -0
  392. package/dist/runtime/local-actor-engine.layer.mjs +14 -0
  393. package/dist/runtime/local-engine.layer.d.mts +15 -0
  394. package/dist/runtime/local-engine.layer.mjs +14 -0
  395. package/dist/runtime/local-environments.layer.d.mts +24 -0
  396. package/dist/runtime/local-environments.layer.mjs +159 -0
  397. package/dist/runtime/local-file-clients.layer.d.mts +13 -0
  398. package/dist/runtime/local-file-clients.layer.mjs +78 -0
  399. package/dist/runtime/local-job-runtime.layer.d.mts +19 -0
  400. package/dist/runtime/local-job-runtime.layer.mjs +21 -0
  401. package/dist/serve/archive/archived-actors.layer.d.mts +17 -0
  402. package/dist/serve/archive/archived-actors.layer.mjs +84 -0
  403. package/dist/serve/archive/archived-store.layer.d.mts +12 -0
  404. package/dist/serve/archive/archived-store.layer.mjs +40 -0
  405. package/dist/serve/engine/actor-engine.layer.d.mts +8 -0
  406. package/dist/serve/engine/actor-engine.layer.mjs +30 -0
  407. package/dist/serve/engine/actor-fork.service.d.mts +63 -0
  408. package/dist/serve/engine/actor-fork.service.mjs +277 -0
  409. package/dist/serve/engine/actor-holding.pure.d.mts +7 -0
  410. package/dist/serve/engine/actor-holding.pure.mjs +9 -0
  411. package/dist/serve/engine/actor-host.service.d.mts +66 -0
  412. package/dist/serve/engine/actor-host.service.mjs +209 -0
  413. package/dist/serve/engine/actor-location.service.d.mts +38 -0
  414. package/dist/serve/engine/actor-location.service.mjs +109 -0
  415. package/dist/serve/engine/actor-residents.pure.d.mts +92 -0
  416. package/dist/serve/engine/actor-residents.pure.mjs +201 -0
  417. package/dist/serve/engine/actor-shard.pure.d.mts +4 -0
  418. package/dist/serve/engine/actor-shard.pure.mjs +8 -0
  419. package/dist/serve/engine/actor-state.pure.d.mts +17 -0
  420. package/dist/serve/engine/actor-state.pure.mjs +20 -0
  421. package/dist/serve/engine/actors-not-hosted.errors.d.mts +9 -0
  422. package/dist/serve/engine/actors-not-hosted.errors.mjs +7 -0
  423. package/dist/serve/engine/job-runtime.layer.d.mts +6 -0
  424. package/dist/serve/engine/job-runtime.layer.mjs +5 -0
  425. package/dist/serve/environment/environment-already-exists.errors.d.mts +10 -0
  426. package/dist/serve/environment/environment-already-exists.errors.mjs +9 -0
  427. package/dist/serve/environment/environment-in-use.errors.d.mts +10 -0
  428. package/dist/serve/environment/environment-in-use.errors.mjs +14 -0
  429. package/dist/serve/environment/environment-not-found.errors.d.mts +10 -0
  430. package/dist/serve/environment/environment-not-found.errors.mjs +9 -0
  431. package/dist/serve/environment/environment-records.sql.d.mts +92 -0
  432. package/dist/serve/environment/environment-records.sql.mjs +59 -0
  433. package/dist/serve/environment/environment-store.sql.d.mts +38 -0
  434. package/dist/serve/environment/environment-store.sql.mjs +78 -0
  435. package/dist/serve/environment/local-environment.schema.d.mts +38 -0
  436. package/dist/serve/environment/local-environment.schema.mjs +43 -0
  437. package/dist/serve/environment/local-environments.service.d.mts +44 -0
  438. package/dist/serve/environment/local-environments.service.mjs +196 -0
  439. package/dist/serve/environment/promotion-notice.pure.d.mts +22 -0
  440. package/dist/serve/environment/promotion-notice.pure.mjs +30 -0
  441. package/dist/serve/environment/snapshot-operations.sql.d.mts +32 -0
  442. package/dist/serve/environment/snapshot-operations.sql.mjs +131 -0
  443. package/dist/serve/environment/store-snapshot.sql.d.mts +32 -0
  444. package/dist/serve/environment/store-snapshot.sql.mjs +74 -0
  445. package/dist/serve/erasure/local-actor-erasure.service.d.mts +26 -0
  446. package/dist/serve/erasure/local-actor-erasure.service.mjs +102 -0
  447. package/dist/serve/history/actor-host-runners.service.d.mts +23 -0
  448. package/dist/serve/history/actor-host-runners.service.mjs +35 -0
  449. package/dist/serve/hosted/hosted-app-build.errors.d.mts +13 -0
  450. package/dist/serve/hosted/hosted-app-build.errors.mjs +9 -0
  451. package/dist/serve/hosted/hosted-app-checks.layer.d.mts +15 -0
  452. package/dist/serve/hosted/hosted-app-checks.layer.mjs +32 -0
  453. package/dist/serve/hosted/hosted-file-forward.layer.d.mts +22 -0
  454. package/dist/serve/hosted/hosted-file-forward.layer.mjs +42 -0
  455. package/dist/serve/hosted/hosted-file-rpcs.layer.d.mts +25 -0
  456. package/dist/serve/hosted/hosted-file-rpcs.layer.mjs +82 -0
  457. package/dist/serve/hosted/hosted-file-server.layer.d.mts +18 -0
  458. package/dist/serve/hosted/hosted-file-server.layer.mjs +33 -0
  459. package/dist/serve/hosted/hosted-files.layer.d.mts +32 -0
  460. package/dist/serve/hosted/hosted-files.layer.mjs +55 -0
  461. package/dist/serve/hosted/hosted-runtime.layer.d.mts +42 -0
  462. package/dist/serve/hosted/hosted-runtime.layer.mjs +48 -0
  463. package/dist/serve/hosted/hosted-runtime.service.d.mts +77 -0
  464. package/dist/serve/hosted/hosted-runtime.service.mjs +74 -0
  465. package/dist/serve/hosted/hosted-secrets.layer.d.mts +10 -0
  466. package/dist/serve/hosted/hosted-secrets.layer.mjs +28 -0
  467. package/dist/serve/http/loopback-host.pure.d.mts +11 -0
  468. package/dist/serve/http/loopback-host.pure.mjs +29 -0
  469. package/dist/serve/inspect/actor-inspection.schema.d.mts +119 -0
  470. package/dist/serve/inspect/actor-inspection.schema.mjs +75 -0
  471. package/dist/serve/inspect/actor-inspection.sql.d.mts +12 -0
  472. package/dist/serve/inspect/actor-inspection.sql.mjs +43 -0
  473. package/dist/serve/inspect/inspect.service.d.mts +24 -0
  474. package/dist/serve/inspect/inspect.service.mjs +92 -0
  475. package/dist/serve/inspect/inspector-page.pure.d.mts +2 -0
  476. package/dist/serve/inspect/inspector-page.pure.mjs +155 -0
  477. package/dist/serve/inspect/inspector-wal.pure.d.mts +3 -0
  478. package/dist/serve/inspect/inspector-wal.pure.mjs +19 -0
  479. package/dist/serve/inspect/inspector.handlers.d.mts +5 -0
  480. package/dist/serve/inspect/inspector.handlers.mjs +50 -0
  481. package/dist/serve/inspect/inspector.layer.d.mts +9 -0
  482. package/dist/serve/inspect/inspector.layer.mjs +14 -0
  483. package/dist/serve/live/live-reads.service.d.mts +44 -0
  484. package/dist/serve/live/live-reads.service.mjs +152 -0
  485. package/dist/serve/live/live-tables.sql.d.mts +35 -0
  486. package/dist/serve/live/live-tables.sql.mjs +66 -0
  487. package/dist/serve/live/state-reads.pure.d.mts +11 -0
  488. package/dist/serve/live/state-reads.pure.mjs +7 -0
  489. package/dist/serve/rpc/actor-rpc.handlers.d.mts +24 -0
  490. package/dist/serve/rpc/actor-rpc.handlers.mjs +142 -0
  491. package/dist/serve/rpc/akter-server.layer.d.mts +18 -0
  492. package/dist/serve/rpc/akter-server.layer.mjs +61 -0
  493. package/dist/serve/rpc/computer/computer-copy.layer.d.mts +22 -0
  494. package/dist/serve/rpc/computer/computer-copy.layer.mjs +70 -0
  495. package/dist/serve/rpc/computer/computer-rpc-access.pure.d.mts +29 -0
  496. package/dist/serve/rpc/computer/computer-rpc-access.pure.mjs +46 -0
  497. package/dist/serve/rpc/computer/computer-rpc.layer.d.mts +39 -0
  498. package/dist/serve/rpc/computer/computer-rpc.layer.mjs +84 -0
  499. package/dist/serve/rpc/computer/step-rpc.handlers.d.mts +23 -0
  500. package/dist/serve/rpc/computer/step-rpc.handlers.mjs +43 -0
  501. package/dist/serve/rpc/development-authentication.handlers.d.mts +7 -0
  502. package/dist/serve/rpc/development-authentication.handlers.mjs +19 -0
  503. package/dist/serve/rpc/development-guard.pure.d.mts +10 -0
  504. package/dist/serve/rpc/development-guard.pure.mjs +16 -0
  505. package/dist/serve/rpc/file/file-rpc-access.pure.d.mts +55 -0
  506. package/dist/serve/rpc/file/file-rpc-access.pure.mjs +67 -0
  507. package/dist/serve/rpc/file/file-rpc.layer.d.mts +53 -0
  508. package/dist/serve/rpc/file/file-rpc.layer.mjs +143 -0
  509. package/dist/serve/rpc/file/upload-sessions.pure.d.mts +45 -0
  510. package/dist/serve/rpc/file/upload-sessions.pure.mjs +187 -0
  511. package/dist/serve/rpc/in-process-client.layer.d.mts +13 -0
  512. package/dist/serve/rpc/in-process-client.layer.mjs +34 -0
  513. package/dist/serve/rpc/listener-not-loopback.errors.d.mts +9 -0
  514. package/dist/serve/rpc/listener-not-loopback.errors.mjs +7 -0
  515. package/dist/serve/rpc/ndjson-only.pure.d.mts +5 -0
  516. package/dist/serve/rpc/ndjson-only.pure.mjs +14 -0
  517. package/dist/serve/rpc/served-rpc.layer.d.mts +6 -0
  518. package/dist/serve/rpc/served-rpc.layer.mjs +19 -0
  519. package/dist/serve/store/actor-not-migrated.errors.d.mts +10 -0
  520. package/dist/serve/store/actor-not-migrated.errors.mjs +8 -0
  521. package/dist/serve/store/store-migrations.layer.d.mts +5 -0
  522. package/dist/serve/store/store-migrations.layer.mjs +18 -0
  523. package/dist/serve/store/store-migrations.service.d.mts +26 -0
  524. package/dist/serve/store/store-migrations.service.mjs +47 -0
  525. package/dist/serve/store/store-unreadable.errors.d.mts +9 -0
  526. package/dist/serve/store/store-unreadable.errors.mjs +7 -0
  527. package/dist/serve/verify/verify.layer.d.mts +16 -0
  528. package/dist/serve/verify/verify.layer.mjs +36 -0
  529. package/dist/testing/story-driver.service.d.mts +29 -0
  530. package/dist/testing/story-driver.service.mjs +126 -0
  531. package/dist/testing/story.layer.d.mts +21 -0
  532. package/dist/testing/story.layer.mjs +42 -0
  533. package/package.json +106 -3
  534. package/src/contract/actor/actor-already-exists.errors.ts +8 -0
  535. package/src/contract/actor/actor-definition.pure.ts +157 -0
  536. package/src/contract/actor/actor-erased.errors.ts +8 -0
  537. package/src/contract/actor/actor-names.pure.ts +64 -0
  538. package/src/contract/actor/actor-not-created.errors.ts +8 -0
  539. package/src/contract/actor/actor-not-registered.errors.ts +8 -0
  540. package/src/contract/actor/actor-registry.service.ts +35 -0
  541. package/src/contract/actor/actor.contract.ts +409 -0
  542. package/src/contract/actor/host-interface.pure.ts +60 -0
  543. package/src/contract/actor/reserved-member.errors.ts +9 -0
  544. package/src/contract/akter.service.ts +233 -0
  545. package/src/contract/caller/authentication.api.ts +9 -0
  546. package/src/contract/caller/caller-admission.pure.ts +90 -0
  547. package/src/contract/caller/caller-not-allowed.errors.ts +26 -0
  548. package/src/contract/caller/caller.schema.ts +7 -0
  549. package/src/contract/caller/current-caller.service.ts +7 -0
  550. package/src/contract/caller/principal.schema.ts +13 -0
  551. package/src/contract/caller/unauthenticated.errors.ts +8 -0
  552. package/src/contract/client/actor-client.adapter.ts +217 -0
  553. package/src/contract/client/actor-client.contract.ts +53 -0
  554. package/src/contract/client/actor-rpc.contract.ts +91 -0
  555. package/src/contract/client/actor-unavailable.errors.ts +9 -0
  556. package/src/contract/client/client-failure.contract.ts +53 -0
  557. package/src/contract/client/invalid-request.errors.ts +9 -0
  558. package/src/contract/client/storage-limit.errors.ts +16 -0
  559. package/src/contract/command/command-id-expired.errors.ts +11 -0
  560. package/src/contract/command/command-id.schema.ts +5 -0
  561. package/src/contract/command/command.contract.ts +334 -0
  562. package/src/contract/command/outbox-id.pure.ts +25 -0
  563. package/src/contract/command/outbox.schema.ts +11 -0
  564. package/src/contract/command/timer.schema.ts +21 -0
  565. package/src/contract/computer/checkpoint-expired.errors.ts +12 -0
  566. package/src/contract/computer/computer-client-failure.contract.ts +27 -0
  567. package/src/contract/computer/computer-client.adapter.ts +110 -0
  568. package/src/contract/computer/computer-client.contract.ts +75 -0
  569. package/src/contract/computer/computer-held.errors.ts +10 -0
  570. package/src/contract/computer/computer-limit.errors.ts +11 -0
  571. package/src/contract/computer/computer-lost.errors.ts +10 -0
  572. package/src/contract/computer/computer-not-found.errors.ts +9 -0
  573. package/src/contract/computer/computer.schema.ts +159 -0
  574. package/src/contract/computer/computers-unavailable.errors.ts +9 -0
  575. package/src/contract/computer/files/computer-files.schema.ts +31 -0
  576. package/src/contract/computer/rpc/computer-rpc.contract.ts +140 -0
  577. package/src/contract/computer/step/computer-step.contract.ts +126 -0
  578. package/src/contract/computer/step/computer-step.schema.ts +80 -0
  579. package/src/contract/computer/step/step-failure.schema.ts +26 -0
  580. package/src/contract/computer/step/step-not-found.errors.ts +7 -0
  581. package/src/contract/description/published-contract.pure.ts +187 -0
  582. package/src/contract/file/access/file-access-denied.errors.ts +11 -0
  583. package/src/contract/file/access/file-access.contract.ts +56 -0
  584. package/src/contract/file/actor-files.contract.ts +78 -0
  585. package/src/contract/file/blob-transfer.errors.ts +6 -0
  586. package/src/contract/file/file-client-failure.contract.ts +43 -0
  587. package/src/contract/file/file-client.adapter.ts +45 -0
  588. package/src/contract/file/file-client.contract.ts +24 -0
  589. package/src/contract/file/file-listing.pure.ts +30 -0
  590. package/src/contract/file/file-not-found.errors.ts +6 -0
  591. package/src/contract/file/file-path.pure.ts +37 -0
  592. package/src/contract/file/files-unavailable.errors.ts +8 -0
  593. package/src/contract/file/invalid-file-request.errors.ts +9 -0
  594. package/src/contract/file/rpc/file-rpc.contract.ts +148 -0
  595. package/src/contract/file/rpc/file-too-large.errors.ts +10 -0
  596. package/src/contract/file/rpc/rpc-file-clients.layer.ts +184 -0
  597. package/src/contract/fork/fork-rpc.contract.ts +44 -0
  598. package/src/contract/history/actor-journal.service.ts +195 -0
  599. package/src/contract/history/history-entry.pure.ts +282 -0
  600. package/src/contract/hosted/handler-failed.errors.ts +16 -0
  601. package/src/contract/hosted/handler-failure.pure.ts +161 -0
  602. package/src/contract/hosted/hosted-actor.service.ts +97 -0
  603. package/src/contract/hosted/hosted-command.service.ts +114 -0
  604. package/src/contract/hosted/hosted-create.service.ts +95 -0
  605. package/src/contract/hosted/hosted-error.contract.ts +22 -0
  606. package/src/contract/hosted/hosted-failure.schema.ts +32 -0
  607. package/src/contract/hosted/hosted-outcome.contract.ts +21 -0
  608. package/src/contract/hosted/hosted-query.service.ts +50 -0
  609. package/src/contract/hosted/hosted-request.pure.ts +185 -0
  610. package/src/contract/job/job-id.pure.ts +37 -0
  611. package/src/contract/job/job-patches.contract.ts +86 -0
  612. package/src/contract/job/job-signal.schema.ts +23 -0
  613. package/src/contract/job/reserved-payload-field.errors.ts +10 -0
  614. package/src/contract/job/started-job.schema.ts +9 -0
  615. package/src/contract/json-codec.pure.ts +27 -0
  616. package/src/contract/room.contract.ts +31 -0
  617. package/src/contract/secret/actor-secrets.adapter.ts +87 -0
  618. package/src/contract/secret/invalid-secret-name.errors.ts +10 -0
  619. package/src/contract/secret/secret-unavailable.errors.ts +13 -0
  620. package/src/contract/secret/secret.schema.ts +43 -0
  621. package/src/contract/spend/billing-unavailable.errors.ts +12 -0
  622. package/src/contract/spend/spend-cap-reached.errors.ts +17 -0
  623. package/src/contract/state/actor-state.pure.ts +192 -0
  624. package/src/contract/state/actor-state.service.ts +69 -0
  625. package/src/contract/state/state-migration.pure.ts +57 -0
  626. package/src/contract/state/state-read.pure.ts +40 -0
  627. package/src/contract/state/state-unreadable.errors.ts +9 -0
  628. package/src/host/actor/actor-database.service.ts +145 -0
  629. package/src/host/actor/actor-exclusive.pure.ts +32 -0
  630. package/src/host/actor/actor-records.sql.ts +78 -0
  631. package/src/host/actor/reserved-name.errors.ts +10 -0
  632. package/src/host/actor/reserved-names.pure.ts +40 -0
  633. package/src/host/actor/room.actor.ts +57 -0
  634. package/src/host/blob/blob-frames.pure.ts +52 -0
  635. package/src/host/blob/blob-grant.schema.ts +22 -0
  636. package/src/host/blob/blob-grants.service.ts +197 -0
  637. package/src/host/blob/blob-keyring.service.ts +25 -0
  638. package/src/host/blob/blob-range.pure.ts +33 -0
  639. package/src/host/blob/blob-sealing.contract.ts +46 -0
  640. package/src/host/blob/blob-sealing.service.ts +25 -0
  641. package/src/host/blob/export/blob-archive.sql.ts +153 -0
  642. package/src/host/blob/export/blob-export-holds.sql.ts +91 -0
  643. package/src/host/blob/plain-blob-sealing.pure.ts +70 -0
  644. package/src/host/blob/reference/blob-catalog.sql.ts +339 -0
  645. package/src/host/blob/reference/blob-coordinator.pure.ts +217 -0
  646. package/src/host/blob/reference/blob-file-page.sql.ts +48 -0
  647. package/src/host/blob/reference/blob-forks.sql.ts +125 -0
  648. package/src/host/blob/reference/blob-lineage.sql.ts +63 -0
  649. package/src/host/blob/reference/blob-reads.pure.ts +172 -0
  650. package/src/host/blob/reference/blob-receipts.sql.ts +375 -0
  651. package/src/host/blob/reference/blob-transfer-adopt.pure.ts +127 -0
  652. package/src/host/blob/reference/blob-transfer-fork.pure.ts +174 -0
  653. package/src/host/blob/reference/blob-transfer-upkeep.pure.ts +132 -0
  654. package/src/host/blob/reference/blob-transfer.pure.ts +127 -0
  655. package/src/host/blob/sealed-blob-sealing.pure.ts +163 -0
  656. package/src/host/blob/stream/blob-directory.pure.ts +177 -0
  657. package/src/host/blob/stream/blob-length.pure.ts +40 -0
  658. package/src/host/blob/stream/blob-writing.pure.ts +49 -0
  659. package/src/host/command/batch/command-batch.sql.ts +207 -0
  660. package/src/host/command/command-context.adapter.ts +134 -0
  661. package/src/host/command/command-id-age.pure.ts +54 -0
  662. package/src/host/command/command-id-reuse.pure.ts +90 -0
  663. package/src/host/command/command-id-reused.errors.ts +13 -0
  664. package/src/host/command/command-journal.sql.ts +232 -0
  665. package/src/host/command/command-rejected.errors.ts +8 -0
  666. package/src/host/command/command-replay.service.ts +223 -0
  667. package/src/host/command/command-reply.pure.ts +21 -0
  668. package/src/host/command/command-runner.service.ts +320 -0
  669. package/src/host/command/files/command-file-inputs.sql.ts +114 -0
  670. package/src/host/command/history-pruned.errors.ts +10 -0
  671. package/src/host/command/replay/replay-cursor-stalled.errors.ts +9 -0
  672. package/src/host/command/replay/replay-cursor.pure.ts +19 -0
  673. package/src/host/computer/computer-steps.sql.ts +120 -0
  674. package/src/host/computer/job-computers.service.ts +84 -0
  675. package/src/host/computer/local-computer-files.layer.ts +103 -0
  676. package/src/host/computer/local-computer-log.layer.ts +115 -0
  677. package/src/host/computer/local-computer-records.layer.ts +205 -0
  678. package/src/host/computer/local-computer.schema.ts +36 -0
  679. package/src/host/computer/local-computers.adapter.ts +379 -0
  680. package/src/host/computer/local-step.layer.ts +174 -0
  681. package/src/host/file/actor-file-storage.sql.ts +79 -0
  682. package/src/host/file/actor-files.sql.ts +15 -0
  683. package/src/host/file/blob-home-lock.pure.ts +23 -0
  684. package/src/host/file/blob-home.sql.ts +55 -0
  685. package/src/host/file/local-blob-home.service.ts +71 -0
  686. package/src/host/file/local-blob-owner.sql.ts +89 -0
  687. package/src/host/file/local-file-upkeep.pure.ts +77 -0
  688. package/src/host/file/replay-file-storage.sql.ts +43 -0
  689. package/src/host/fork/actor-fork.sql.ts +110 -0
  690. package/src/host/fork/fork-computers.adapter.ts +366 -0
  691. package/src/host/hash/blob-hashing.service.ts +14 -0
  692. package/src/host/job/job-durables.sql.ts +214 -0
  693. package/src/host/job/job-engine.adapter.ts +420 -0
  694. package/src/host/job/job-journal.sql.ts +257 -0
  695. package/src/host/job/job-results.service.ts +111 -0
  696. package/src/host/job/job-runs.pure.ts +445 -0
  697. package/src/host/job/undelivered-result.pure.ts +265 -0
  698. package/src/host/layout/actor-layout.sql.ts +45 -0
  699. package/src/host/layout/layout-version.errors.ts +10 -0
  700. package/src/host/layout/layout-version.pure.ts +22 -0
  701. package/src/host/migration/actor-migrations.service.ts +159 -0
  702. package/src/host/migration/migration-edited.errors.ts +9 -0
  703. package/src/host/migration/migration-failed.errors.ts +12 -0
  704. package/src/host/migration/migration-failure.pure.ts +28 -0
  705. package/src/host/migration/migration-hasher.adapter.ts +70 -0
  706. package/src/host/migration/migration-missing.errors.ts +9 -0
  707. package/src/host/migration/migration-plan.pure.ts +66 -0
  708. package/src/host/outbox/actor-outbox.sql.ts +98 -0
  709. package/src/host/outbox/outbox-acknowledgements.sql.ts +93 -0
  710. package/src/host/outbox/outbox-runner.service.ts +253 -0
  711. package/src/host/query/query-policy.pure.ts +31 -0
  712. package/src/host/query/query-runner.service.ts +132 -0
  713. package/src/host/sqlite/actor-connections.pure.ts +44 -0
  714. package/src/host/sqlite/sqlite-connection.adapter.ts +260 -0
  715. package/src/host/sqlite/sqlite-driver.service.ts +151 -0
  716. package/src/host/sqlite/sqlite-parameters.pure.ts +28 -0
  717. package/src/host/sqlite/sqlite-reason.pure.ts +19 -0
  718. package/src/host/timer/actor-timers.sql.ts +67 -0
  719. package/src/host/timer/timer-runner.service.ts +117 -0
  720. package/src/host/upkeep/actor-due.sql.ts +71 -0
  721. package/src/host/upkeep/actor-upkeep.service.ts +404 -0
  722. package/src/host/upkeep/execution-authority.pure.ts +37 -0
  723. package/src/runtime/akter-local.layer.ts +49 -0
  724. package/src/runtime/akter.layer.ts +208 -0
  725. package/src/runtime/blob-hashing.layer.ts +21 -0
  726. package/src/runtime/hosted-environment.layer.ts +85 -0
  727. package/src/runtime/http-server.layer.ts +29 -0
  728. package/src/runtime/local-actor-engine.layer.ts +33 -0
  729. package/src/runtime/local-engine.layer.ts +37 -0
  730. package/src/runtime/local-environments.layer.ts +214 -0
  731. package/src/runtime/local-file-clients.layer.ts +112 -0
  732. package/src/runtime/local-job-runtime.layer.ts +38 -0
  733. package/src/serve/archive/archived-actors.layer.ts +97 -0
  734. package/src/serve/archive/archived-store.layer.ts +46 -0
  735. package/src/serve/engine/actor-engine.layer.ts +46 -0
  736. package/src/serve/engine/actor-fork.service.ts +403 -0
  737. package/src/serve/engine/actor-holding.pure.ts +28 -0
  738. package/src/serve/engine/actor-host.service.ts +454 -0
  739. package/src/serve/engine/actor-location.service.ts +219 -0
  740. package/src/serve/engine/actor-residents.pure.ts +500 -0
  741. package/src/serve/engine/actor-shard.pure.ts +13 -0
  742. package/src/serve/engine/actor-state.pure.ts +45 -0
  743. package/src/serve/engine/actors-not-hosted.errors.ts +9 -0
  744. package/src/serve/engine/job-runtime.layer.ts +13 -0
  745. package/src/serve/environment/environment-already-exists.errors.ts +9 -0
  746. package/src/serve/environment/environment-in-use.errors.ts +17 -0
  747. package/src/serve/environment/environment-not-found.errors.ts +9 -0
  748. package/src/serve/environment/environment-records.sql.ts +208 -0
  749. package/src/serve/environment/environment-store.sql.ts +116 -0
  750. package/src/serve/environment/local-environment.schema.ts +79 -0
  751. package/src/serve/environment/local-environments.service.ts +268 -0
  752. package/src/serve/environment/promotion-notice.pure.ts +63 -0
  753. package/src/serve/environment/snapshot-operations.sql.ts +210 -0
  754. package/src/serve/environment/store-snapshot.sql.ts +128 -0
  755. package/src/serve/erasure/local-actor-erasure.service.ts +170 -0
  756. package/src/serve/history/actor-host-runners.service.ts +85 -0
  757. package/src/serve/hosted/hosted-app-build.errors.ts +11 -0
  758. package/src/serve/hosted/hosted-app-checks.layer.ts +74 -0
  759. package/src/serve/hosted/hosted-file-forward.layer.ts +63 -0
  760. package/src/serve/hosted/hosted-file-rpcs.layer.ts +149 -0
  761. package/src/serve/hosted/hosted-file-server.layer.ts +75 -0
  762. package/src/serve/hosted/hosted-files.layer.ts +76 -0
  763. package/src/serve/hosted/hosted-runtime.layer.ts +145 -0
  764. package/src/serve/hosted/hosted-runtime.service.ts +128 -0
  765. package/src/serve/hosted/hosted-secrets.layer.ts +38 -0
  766. package/src/serve/http/loopback-host.pure.ts +67 -0
  767. package/src/serve/inspect/actor-inspection.schema.ts +94 -0
  768. package/src/serve/inspect/actor-inspection.sql.ts +112 -0
  769. package/src/serve/inspect/inspect.service.ts +173 -0
  770. package/src/serve/inspect/inspector-page.pure.ts +159 -0
  771. package/src/serve/inspect/inspector-wal.pure.ts +40 -0
  772. package/src/serve/inspect/inspector.handlers.ts +103 -0
  773. package/src/serve/inspect/inspector.layer.ts +26 -0
  774. package/src/serve/live/live-reads.service.ts +285 -0
  775. package/src/serve/live/live-tables.sql.ts +148 -0
  776. package/src/serve/live/state-reads.pure.ts +22 -0
  777. package/src/serve/rpc/actor-rpc.handlers.ts +242 -0
  778. package/src/serve/rpc/akter-server.layer.ts +119 -0
  779. package/src/serve/rpc/computer/computer-copy.layer.ts +95 -0
  780. package/src/serve/rpc/computer/computer-rpc-access.pure.ts +75 -0
  781. package/src/serve/rpc/computer/computer-rpc.layer.ts +143 -0
  782. package/src/serve/rpc/computer/step-rpc.handlers.ts +84 -0
  783. package/src/serve/rpc/development-authentication.handlers.ts +28 -0
  784. package/src/serve/rpc/development-guard.pure.ts +39 -0
  785. package/src/serve/rpc/file/file-rpc-access.pure.ts +119 -0
  786. package/src/serve/rpc/file/file-rpc.layer.ts +209 -0
  787. package/src/serve/rpc/file/upload-sessions.pure.ts +363 -0
  788. package/src/serve/rpc/in-process-client.layer.ts +62 -0
  789. package/src/serve/rpc/listener-not-loopback.errors.ts +9 -0
  790. package/src/serve/rpc/ndjson-only.pure.ts +33 -0
  791. package/src/serve/rpc/served-rpc.layer.ts +34 -0
  792. package/src/serve/store/actor-not-migrated.errors.ts +10 -0
  793. package/src/serve/store/store-migrations.layer.ts +35 -0
  794. package/src/serve/store/store-migrations.service.ts +76 -0
  795. package/src/serve/store/store-unreadable.errors.ts +9 -0
  796. package/src/serve/verify/verify.layer.ts +77 -0
  797. package/src/testing/story-driver.service.ts +266 -0
  798. package/src/testing/story.layer.ts +99 -0
@@ -0,0 +1,320 @@
1
+ import { Clock, Context, Duration, Effect, HashMap, Layer, Option } from "effect";
2
+ import type { SqlClient, SqlError } from "effect/sql";
3
+
4
+ import type { CommandEnvironment, HostedError, HostedOutcome, HostedRequest } from "#src/contract/actor/actor.contract";
5
+
6
+ import type { OpenedActor } from "#src/host/actor/actor-database.service";
7
+ import { HandlerSql } from "#src/host/query/query-policy.pure";
8
+ import { CommandContext } from "./command-context.adapter.js";
9
+ import { checkCommandId } from "./command-id-age.pure.js";
10
+ import {
11
+ isResultCommandId,
12
+ isTimerCommandId,
13
+ jobIdOfResult,
14
+ jobOfResult,
15
+ refuseReserved,
16
+ refuseReuse,
17
+ resultMember,
18
+ reuseDefect,
19
+ sameCommand,
20
+ } from "./command-id-reuse.pure.js";
21
+ import type { Reuse } from "./command-id-reuse.pure.js";
22
+ import {
23
+ CommandBatchJournal,
24
+ currentState,
25
+ pruneJournal,
26
+ recordCommand,
27
+ recordedCommand,
28
+ settle,
29
+ } from "./command-journal.sql.js";
30
+ import type { JournalRow, RecordedCommand } from "./command-journal.sql.js";
31
+
32
+ import { journalFailure, replyOf } from "./command-reply.pure.js";
33
+
34
+ interface CommandRequest {
35
+ readonly commandId: string;
36
+ readonly key: string;
37
+ readonly member: string;
38
+ readonly payload: string;
39
+ readonly principal: string;
40
+ }
41
+
42
+ interface CreationRequest {
43
+ readonly commandId: string;
44
+ readonly key: string;
45
+ readonly mode: "create" | "ensure";
46
+ readonly payload: string;
47
+ readonly principal: string;
48
+ }
49
+
50
+ interface ResultRequest {
51
+ readonly commandId: string;
52
+ readonly job: string;
53
+ readonly key: string;
54
+ readonly payload: string;
55
+ readonly principal: string;
56
+ }
57
+
58
+ interface Resulting {
59
+ readonly opened: OpenedActor;
60
+ readonly request: ResultRequest;
61
+ }
62
+
63
+ interface Running {
64
+ readonly opened: OpenedActor;
65
+ readonly request: CommandRequest;
66
+ }
67
+
68
+ interface Creating {
69
+ readonly opened: OpenedActor;
70
+ readonly request: CreationRequest;
71
+ }
72
+
73
+ interface Pruning {
74
+ readonly before: number;
75
+ readonly opened: OpenedActor;
76
+ }
77
+
78
+ type Invoke = (request: HostedRequest, environment: CommandEnvironment) => Effect.Effect<HostedOutcome, HostedError>;
79
+
80
+ interface Executing extends Running {
81
+ readonly context: CommandContext["Service"];
82
+ readonly invoke: Invoke;
83
+ }
84
+
85
+ type Outcome = Effect.Effect<string, HostedError | SqlError.SqlError>;
86
+
87
+ type Admit = (running: Running) => Effect.Effect<void, HostedError>;
88
+
89
+ interface Gate {
90
+ readonly admit: Admit;
91
+ readonly reused: (reuse: Reuse) => Effect.Effect<never, HostedError>;
92
+ readonly screen: Admit;
93
+ }
94
+
95
+ const creationModes = HashMap.make(["akter.create", "create" as const], ["akter.ensure", "ensure" as const]);
96
+
97
+ const internal: Gate = { admit: () => Effect.void, reused: reuseDefect, screen: () => Effect.void };
98
+
99
+ const HistoryRetention = Context.Reference<Duration.Duration>(
100
+ "@akterjs/effect/host/command/command-runner.service/HistoryRetention",
101
+ { defaultValue: () => Duration.infinity },
102
+ );
103
+
104
+ const admitting =
105
+ (retention: Duration.Duration): Admit =>
106
+ ({ opened, request }) => {
107
+ if (!Duration.isFinite(retention)) {
108
+ return Effect.void;
109
+ }
110
+
111
+ return Effect.flatMap(Clock.currentTimeMillis, (now) =>
112
+ checkCommandId({
113
+ actor: opened.actor.name,
114
+ commandId: request.commandId,
115
+ keptSince: now - Duration.toMillis(retention),
116
+ now,
117
+ }),
118
+ );
119
+ };
120
+
121
+ const fromClient = (retention: Duration.Duration): Gate => ({
122
+ admit: admitting(retention),
123
+ reused: refuseReuse,
124
+ screen: ({ opened, request }) =>
125
+ refuseReserved({ actor: opened.actor.name, commandId: request.commandId, principal: request.principal }),
126
+ });
127
+
128
+ interface Settling {
129
+ readonly at: number;
130
+ readonly handled: Effect.Effect<HostedOutcome, HostedError>;
131
+ readonly principal: string;
132
+ readonly sql: SqlClient.SqlClient;
133
+ }
134
+
135
+ /** Runs the handler and saves its outcome in one savepoint; the outcome's writes go through the batch's writer. */
136
+ const settled = Effect.fnUntraced(function* settled({ at, handled, principal, sql }: Settling) {
137
+ const writer = yield* CommandBatchJournal.writer(sql);
138
+
139
+ const saving = Effect.flatMap(handled, (outcome) =>
140
+ Effect.tap(settle({ at, outcome, principal, sql: writer }), () =>
141
+ Option.match(outcome.state, { onNone: () => Effect.void, onSome: CommandBatchJournal.saved }),
142
+ ),
143
+ );
144
+
145
+ return yield* sql.withTransaction(saving).pipe(
146
+ Effect.catchTags({
147
+ ActorAlreadyExistsError: journalFailure,
148
+ CommandRejectedError: (rejected) => Effect.succeed(rejected.exit),
149
+ HandlerFailedError: journalFailure,
150
+ }),
151
+ );
152
+ });
153
+
154
+ /** Writes the command's journal row; inside an engine batch, at the seq the batch journal gives it. */
155
+ const journal = Effect.fnUntraced(function* journal(row: JournalRow, sql: SqlClient.SqlClient) {
156
+ const { command, commandId, exit, principal } = row;
157
+ const seq = yield* CommandBatchJournal.record(commandId, { command, exit, principal });
158
+
159
+ yield* recordCommand({ row, seq, sql: yield* CommandBatchJournal.writer(sql) });
160
+ });
161
+
162
+ const execute = Effect.fnUntraced(function* execute({ context, invoke, opened, request }: Executing) {
163
+ const { sql } = opened;
164
+ const at = yield* Clock.currentTimeMillis;
165
+ const state = yield* CommandBatchJournal.state(sql, currentState(sql));
166
+ const tracked = yield* context.track({ files: opened.files(sql), key: request.key, sql });
167
+ const handled = Effect.provideService(invoke({ ...request, state }, tracked.environment), HandlerSql, true);
168
+ const journaled = yield* settled({ at, handled, principal: request.principal, sql });
169
+
170
+ const recorded = yield* tracked.recorded;
171
+ const { commandId, member: command, payload, principal } = request;
172
+
173
+ yield* journal({ ...recorded, at, command, commandId, exit: journaled, payload, principal }, sql);
174
+
175
+ return journaled;
176
+ });
177
+
178
+ const replayed = (
179
+ gate: Gate,
180
+ { opened, request }: Running,
181
+ recorded: RecordedCommand,
182
+ ): Effect.Effect<string, HostedError> => {
183
+ const reuse: Reuse = {
184
+ actor: opened.actor.name,
185
+ commandId: request.commandId,
186
+ member: request.member,
187
+ principal: request.principal,
188
+ recordedMember: recorded.command,
189
+ recordedPrincipal: recorded.principal,
190
+ };
191
+
192
+ if (!sameCommand(reuse)) {
193
+ return gate.reused(reuse);
194
+ }
195
+
196
+ return Effect.succeed(recorded.exit);
197
+ };
198
+
199
+ type Once = (running: Running, invoke: Invoke, gate: Gate) => Outcome;
200
+
201
+ const onceWith = (context: CommandContext["Service"]): Once =>
202
+ Effect.fnUntraced(function* once(running: Running, invoke: Invoke, gate: Gate) {
203
+ const { opened, request } = running;
204
+
205
+ yield* gate.screen(running);
206
+
207
+ const journaled = yield* opened.sql.withTransaction(
208
+ Effect.gen(function* runOnce() {
209
+ const recorded = yield* CommandBatchJournal.recorded(
210
+ opened.sql,
211
+ request.commandId,
212
+ recordedCommand({ commandId: request.commandId, sql: opened.sql }),
213
+ );
214
+
215
+ if (Option.isSome(recorded)) {
216
+ return yield* replayed(gate, running, recorded.value);
217
+ }
218
+
219
+ yield* gate.admit(running);
220
+
221
+ // A failed statement's full message is logged under the command's id when the caller gets a generic one.
222
+ return yield* execute({ context, invoke, opened, request }).pipe(
223
+ Effect.annotateLogs({ actor: opened.actor.name, commandId: request.commandId }),
224
+ );
225
+ }),
226
+ );
227
+
228
+ return yield* replyOf(journaled);
229
+ });
230
+
231
+ interface Paths {
232
+ readonly create: (creating: Creating) => Outcome;
233
+ readonly result: (resulting: Resulting) => Outcome;
234
+ readonly run: (running: Running) => Outcome;
235
+ readonly runOwn: (running: Running) => Outcome;
236
+ }
237
+
238
+ const replayWith =
239
+ ({ create, result, run, runOwn }: Paths) =>
240
+ (running: Running): Outcome => {
241
+ const { opened, request } = running;
242
+
243
+ if (isTimerCommandId(request.commandId)) {
244
+ return runOwn(running);
245
+ }
246
+
247
+ if (isResultCommandId(request.commandId)) {
248
+ return result({ opened, request: { ...request, job: jobOfResult(request.member) } });
249
+ }
250
+
251
+ return Option.match(HashMap.get(creationModes, request.member), {
252
+ onNone: () => run(running),
253
+ onSome: (mode) => create({ opened, request: { ...request, mode } }),
254
+ });
255
+ };
256
+
257
+ const prune = ({ before, opened }: Pruning): Effect.Effect<void, SqlError.SqlError> =>
258
+ Effect.andThen(pruneJournal({ before, sql: opened.sql }), CommandBatchJournal.forget);
259
+
260
+ export class CommandRunner extends Context.Service<
261
+ CommandRunner,
262
+ {
263
+ readonly create: (creating: Creating) => Outcome;
264
+ readonly prune: (pruning: Pruning) => Effect.Effect<void, SqlError.SqlError>;
265
+ readonly replay: (running: Running) => Outcome;
266
+ readonly result: (resulting: Resulting) => Outcome;
267
+ readonly run: (running: Running) => Outcome;
268
+ readonly runOwn: (running: Running) => Outcome;
269
+ }
270
+ >()("@akterjs/effect/host/command/command-runner.service/CommandRunner", {
271
+ make: Effect.gen(function* makeCommandRunner() {
272
+ const context = yield* CommandContext;
273
+ const retention = yield* HistoryRetention;
274
+ const once = onceWith(context);
275
+ const client = fromClient(retention);
276
+
277
+ const run = Effect.fn("CommandRunner.run")(function* run(running: Running) {
278
+ return yield* once(running, running.opened.actor.runCommand, client);
279
+ });
280
+
281
+ const create = Effect.fn("CommandRunner.create")(function* create({ opened, request }: Creating) {
282
+ const member = `akter.${request.mode}`;
283
+
284
+ return yield* once(
285
+ { opened, request: { ...request, member } },
286
+ (hosted, environment) => opened.actor.runCreate({ ...hosted, member: request.mode }, environment),
287
+ client,
288
+ );
289
+ });
290
+
291
+ const result = Effect.fn("CommandRunner.result")(function* result({
292
+ opened,
293
+ request: { job, ...rest },
294
+ }: Resulting) {
295
+ const member = resultMember(job);
296
+
297
+ return yield* once(
298
+ { opened, request: { ...rest, member } },
299
+ (hosted, environment) =>
300
+ opened.actor.runResult({ ...hosted, jobId: jobIdOfResult(rest.commandId), member: job }, environment),
301
+ internal,
302
+ );
303
+ });
304
+
305
+ const runOwn = Effect.fn("CommandRunner.runOwn")(function* runOwn(running: Running) {
306
+ return yield* once(running, running.opened.actor.runCommand, internal);
307
+ });
308
+
309
+ return { create, prune, replay: replayWith({ create, result, run, runOwn }), result, run, runOwn } as const;
310
+ }),
311
+ }) {
312
+ public static readonly historyRetention = HistoryRetention;
313
+
314
+ /** Whether a failed statement's message reaches the caller or only the host's log. */
315
+ public static readonly statementDetail = CommandContext.statementDetail;
316
+
317
+ public static readonly layer = Layer.effect(this, this.make).pipe(Layer.provide(CommandContext.layer));
318
+ }
319
+
320
+ export type { CommandRequest, CreationRequest, Running };
@@ -0,0 +1,114 @@
1
+ import { Array as Arr, Effect, Option, Ref, Schema } from "effect";
2
+ import type { SqlClient, SqlError } from "effect/sql";
3
+
4
+ import type { FileStorage } from "#src/contract/file/actor-files.contract";
5
+ import { BlobTransferError } from "#src/contract/file/blob-transfer.errors";
6
+
7
+ const ReceiptInput = Schema.Struct({
8
+ actor: Schema.String,
9
+ blob: Schema.String,
10
+ bytes: Schema.Int,
11
+ claim: Schema.String,
12
+ expiresAt: Schema.Int,
13
+ grant: Schema.String,
14
+ receipt: Schema.String,
15
+ sha256: Schema.String,
16
+ state: Schema.Literals(["uploading", "prepared", "consumed", "canceled"]),
17
+ });
18
+
19
+ const FileInput = Schema.Struct({ receipt: Schema.String, row: Schema.Option(ReceiptInput) });
20
+
21
+ const FileInputs = Schema.fromJsonString(Schema.toCodecJson(Schema.Array(FileInput)));
22
+
23
+ type FileInputValue = typeof FileInput.Type;
24
+
25
+ const consumedInput = 1;
26
+
27
+ interface Capturing {
28
+ readonly files: FileStorage;
29
+ readonly sql: SqlClient.SqlClient;
30
+ readonly used: Ref.Ref<readonly FileInputValue[]>;
31
+ }
32
+
33
+ interface Replaying {
34
+ readonly files: FileStorage;
35
+ readonly inputs: readonly FileInputValue[];
36
+ readonly sql: SqlClient.SqlClient;
37
+ }
38
+
39
+ interface Retaining {
40
+ readonly commandId: string;
41
+ readonly recorded: string;
42
+ readonly sql: SqlClient.SqlClient;
43
+ }
44
+
45
+ const fileInput = (sql: SqlClient.SqlClient, receipt: string): Effect.Effect<FileInputValue, SqlError.SqlError> =>
46
+ Effect.map(
47
+ sql<
48
+ typeof ReceiptInput.Type
49
+ >`SELECT actor, blob, bytes, claim, expires_at AS expiresAt, grant, receipt, sha256, state FROM akter_blob_receipts WHERE receipt = ${receipt}`,
50
+ (rows) => ({ receipt, row: Arr.head(rows) }),
51
+ );
52
+
53
+ const captureFileInputs = ({ files, sql, used }: Capturing): FileStorage => ({
54
+ ...files,
55
+ attach: (attaching) =>
56
+ Effect.gen(function* captureAttachment() {
57
+ yield* files.available;
58
+ const input = yield* fileInput(sql, attaching.receipt);
59
+
60
+ yield* Ref.update(used, (inputs) => Arr.append(inputs, input));
61
+
62
+ return yield* files.attach(attaching);
63
+ }),
64
+ });
65
+
66
+ const restoreInput = (sql: SqlClient.SqlClient, input: FileInputValue): Effect.Effect<void, SqlError.SqlError> =>
67
+ Option.match(input.row, {
68
+ onNone: () => Effect.asVoid(sql`DELETE FROM akter_blob_receipts WHERE receipt = ${input.receipt}`),
69
+ onSome: (row) =>
70
+ Effect.asVoid(
71
+ sql`INSERT INTO akter_blob_receipts (receipt, actor, blob, claim, expires_at, bytes, sha256, grant, state) VALUES (${row.receipt}, ${row.actor}, ${row.blob}, ${row.claim}, ${row.expiresAt}, ${row.bytes}, ${row.sha256}, ${row.grant}, ${row.state}) ON CONFLICT (receipt) DO UPDATE SET actor = excluded.actor, blob = excluded.blob, claim = excluded.claim, expires_at = excluded.expires_at, bytes = excluded.bytes, sha256 = excluded.sha256, grant = excluded.grant, state = excluded.state`,
72
+ ),
73
+ });
74
+
75
+ const replayFileInputs = ({ files, sql, inputs }: Replaying): Effect.Effect<FileStorage> =>
76
+ Effect.map(Ref.make(inputs), (left) => ({
77
+ ...files,
78
+ attach: (attaching) =>
79
+ Effect.gen(function* replayAttachment() {
80
+ const input = yield* Ref.modify(
81
+ left,
82
+ (remaining) => [Arr.head(remaining), Arr.drop(remaining, consumedInput)] as const,
83
+ );
84
+
85
+ if (Option.isNone(input) || input.value.receipt !== attaching.receipt) {
86
+ return yield* BlobTransferError.make({ blob: "", message: "the replay did not record this upload receipt" });
87
+ }
88
+
89
+ yield* restoreInput(sql, input.value);
90
+
91
+ return yield* files.attach(attaching);
92
+ }),
93
+ }));
94
+
95
+ const retainFileInputs = ({ sql, commandId, recorded }: Retaining): Effect.Effect<void, SqlError.SqlError> =>
96
+ Effect.flatMap(Effect.orDie(Schema.decodeEffect(FileInputs)(recorded)), (inputs) =>
97
+ Effect.forEach(
98
+ inputs,
99
+ (input) =>
100
+ Option.match(input.row, {
101
+ onNone: () => Effect.void,
102
+ onSome: (row) =>
103
+ Effect.andThen(
104
+ sql`INSERT INTO akter_blob_history (command_id, claim, actor, blob) VALUES (${commandId}, ${row.claim}, ${row.actor}, ${row.blob}) ON CONFLICT DO NOTHING`,
105
+ Effect.asVoid(sql`DELETE FROM akter_blob_releases WHERE claim = ${row.claim}`),
106
+ ),
107
+ }),
108
+ { discard: true },
109
+ ),
110
+ );
111
+
112
+ export { captureFileInputs, FileInputs, replayFileInputs, retainFileInputs };
113
+
114
+ export type { FileInputValue };
@@ -0,0 +1,10 @@
1
+ import { Schema } from "effect";
2
+
3
+ export class HistoryPrunedError extends Schema.TaggedError<HistoryPrunedError, { readonly brand: unique symbol }>()(
4
+ "HistoryPrunedError",
5
+ {
6
+ actor: Schema.String,
7
+ coveredSince: Schema.Int,
8
+ key: Schema.String,
9
+ },
10
+ ) {}
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+
3
+ export class ReplayCursorStalledError extends Schema.TaggedError<
4
+ ReplayCursorStalledError,
5
+ { readonly brand: unique symbol }
6
+ >()("ReplayCursorStalledError", {
7
+ after: Schema.Int,
8
+ cursor: Schema.Int,
9
+ }) {}
@@ -0,0 +1,19 @@
1
+ import { Option } from "effect";
2
+ import { dual } from "effect/Function";
3
+
4
+ import { ReplayCursorStalledError } from "./replay-cursor-stalled.errors.js";
5
+
6
+ const dataFirstArity = 2;
7
+
8
+ const stalledCursor: {
9
+ (after: number): (cursor: number) => Option.Option<ReplayCursorStalledError>;
10
+ (cursor: number, after: number): Option.Option<ReplayCursorStalledError>;
11
+ } = dual(dataFirstArity, (cursor: number, after: number): Option.Option<ReplayCursorStalledError> => {
12
+ if (cursor > after) {
13
+ return Option.none();
14
+ }
15
+
16
+ return Option.some(ReplayCursorStalledError.make({ after, cursor }));
17
+ });
18
+
19
+ export { stalledCursor };
@@ -0,0 +1,120 @@
1
+ import { Array as Arr, Cause, Effect, Exit, Option, Record as Rec, Schema, Struct } from "effect";
2
+ import type { SqlClient, SqlError } from "effect/sql";
3
+
4
+ import { ExecRan } from "#src/contract/computer/computer.schema";
5
+ import { StepEnd, StepStart, largestPage, stepPage } from "#src/contract/computer/step/computer-step.schema";
6
+ import type { ComputerStep, StepPage, StepState } from "#src/contract/computer/step/computer-step.schema";
7
+ import { StoredExit } from "#src/contract/job/job-signal.schema";
8
+
9
+ /** One journaled step: its start, its end when it settled, and whether its job has finished. */
10
+ interface StepRow {
11
+ readonly end: string | null;
12
+ readonly finished: number;
13
+ readonly job: string;
14
+ readonly name: string;
15
+ readonly start: string;
16
+ }
17
+
18
+ type Sql<Value> = Effect.Effect<Value, SqlError.SqlError>;
19
+
20
+ /**
21
+ * A durable step journals two activities in its job (`computer-step.contract.ts`): `step-start/<name>`, then
22
+ * `step/<name>`. Each is stored as `activity/<activity>/<attempt>`, and a step's name holds no slash.
23
+ */
24
+ const startPrefix = "activity/step-start/";
25
+
26
+ /** SQLite counts a string's characters from 1. */
27
+ const firstCharacter = 1;
28
+
29
+ const nameAt = startPrefix.length + firstCharacter;
30
+
31
+ /** Every journaled step start with its name, its latest end, and whether its job has a result, filtered by `where`. */
32
+ const stepRows = (where: string): string =>
33
+ `WITH starts AS (SELECT rowid AS seq, execution_id AS job, substr(entry, ${String(nameAt)}, instr(substr(entry, ${String(nameAt)}), '/') - 1) AS name, value AS start FROM akter_workflow WHERE substr(entry, 1, ${String(startPrefix.length)}) = '${startPrefix}') SELECT job, name, start, (SELECT e.value FROM akter_workflow e WHERE e.execution_id = starts.job AND substr(e.entry, 1, length('activity/step/' || starts.name || '/')) = 'activity/step/' || starts.name || '/' ORDER BY e.rowid DESC LIMIT 1) AS "end", EXISTS (SELECT 1 FROM akter_workflow r WHERE r.execution_id = starts.job AND r.entry = 'result') AS finished FROM starts WHERE ${where} ORDER BY seq DESC LIMIT ?`;
34
+
35
+ const decodeExit = Schema.decodeUnknownOption(StoredExit);
36
+
37
+ const decodeStart = Schema.decodeUnknownOption(Schema.toCodecJson(StepStart));
38
+
39
+ const decodeEnd = Schema.decodeUnknownOption(Schema.toCodecJson(StepEnd));
40
+
41
+ const isRan = Schema.is(ExecRan);
42
+
43
+ const encodeFailure = Schema.encodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
44
+
45
+ const successOf = (stored: string): Option.Option<unknown> => Option.flatMap(decodeExit(stored), Exit.getSuccess);
46
+
47
+ /** A failure as the error the step journaled, as JSON, such as `{"_tag":"ComputerLostError",…}`; `defect` when it died. */
48
+ const failureOf = (cause: Cause.Cause<unknown>): string =>
49
+ Option.getOrElse(Option.flatMap(Cause.findErrorOption(cause), encodeFailure), () => "defect");
50
+
51
+ /** A step with no journaled end: `running` while its job runs, `unknown` once the job finished without settling it. */
52
+ const unsettled: readonly StepState[] = ["running", "unknown"];
53
+
54
+ type Settled = Pick<ComputerStep, "endedAt" | "exitCode" | "failure" | "stderr" | "stdout" | "truncated"> & {
55
+ readonly state: StepState;
56
+ };
57
+
58
+ const endedWith = (end: StepEnd): Settled => {
59
+ if (!isRan(end.outcome)) {
60
+ return { endedAt: end.endedAt, state: "unknown" };
61
+ }
62
+
63
+ const { exitCode, stderr, stdout, truncated } = end.outcome;
64
+ const exit = Rec.getSomes({ exitCode: Option.fromUndefinedOr(exitCode) });
65
+
66
+ return { ...exit, endedAt: end.endedAt, state: "ran", stderr, stdout, truncated };
67
+ };
68
+
69
+ /** Where a step is: its journaled end, or `running` until its job finishes without one, which leaves it `unknown`. */
70
+ const settledOf = (row: StepRow): Settled => {
71
+ const stored = Option.flatMap(Option.fromNullishOr(row.end), decodeExit);
72
+
73
+ return Option.match(stored, {
74
+ onNone: () => ({ state: Option.getOrElse(Arr.get(unsettled, row.finished), (): StepState => "unknown") }),
75
+ onSome: (exit) =>
76
+ Exit.match(exit, {
77
+ onFailure: (cause) => ({ failure: failureOf(cause), state: "failed" }),
78
+ onSuccess: (value) =>
79
+ Option.match(decodeEnd(value), { onNone: () => ({ state: "unknown" }), onSome: endedWith }),
80
+ }),
81
+ });
82
+ };
83
+
84
+ /** A row as a step; none when its start is not a step's, such as an activity of the app's own by that name. */
85
+ const stepOf = (row: StepRow): Option.Option<ComputerStep> =>
86
+ Option.map(Option.flatMap(successOf(row.start), decodeStart), (start) => ({
87
+ command: start.command,
88
+ computer: start.computer,
89
+ job: row.job,
90
+ name: row.name,
91
+ startedAt: start.startedAt,
92
+ step: start.key,
93
+ timeoutSeconds: start.timeoutSeconds,
94
+ ...settledOf(row),
95
+ }));
96
+
97
+ const withoutOutput = (step: ComputerStep): ComputerStep => Struct.omit(step, ["stderr", "stdout", "truncated"]);
98
+
99
+ /** The actor's steps, newest first, without their output. */
100
+ const stepsPage = ({
101
+ limit = stepPage,
102
+ sql,
103
+ }: StepPage & { readonly sql: SqlClient.SqlClient }): Sql<readonly ComputerStep[]> =>
104
+ Effect.map(sql.unsafe<StepRow>(stepRows("1"), [limit]), (rows) =>
105
+ Arr.map(Arr.getSomes(Arr.map(rows, stepOf)), withoutOutput),
106
+ );
107
+
108
+ /** One step by its key, with its output when it ran. */
109
+ const stepByKey = ({
110
+ sql,
111
+ step,
112
+ }: {
113
+ readonly sql: SqlClient.SqlClient;
114
+ readonly step: string;
115
+ }): Sql<Option.Option<ComputerStep>> =>
116
+ Effect.map(sql.unsafe<StepRow>(stepRows("instr(start, ?) > 0"), [step, largestPage]), (rows) =>
117
+ Arr.findFirst(Arr.getSomes(Arr.map(rows, stepOf)), (found) => found.step === step),
118
+ );
119
+
120
+ export { stepByKey, stepsPage };
@@ -0,0 +1,84 @@
1
+ import { Config, Context, Effect, Layer, Option, Ref } from "effect";
2
+
3
+ import { ActorComputerClients } from "#src/contract/computer/computer-client.adapter";
4
+ import type { ComputerAddress, ComputerClient } from "#src/contract/computer/computer-client.contract";
5
+ import { ComputersUnavailableError } from "#src/contract/computer/computers-unavailable.errors";
6
+
7
+ type Clients = ActorComputerClients["Service"];
8
+
9
+ const unbound = ComputersUnavailableError.make({ message: "computers aren't available on this host" });
10
+
11
+ /** Each operation reaches the clients bound when it runs, so a host bound after the app was built still answers. */
12
+ const clientThrough = (current: Effect.Effect<Clients, ComputersUnavailableError>) => {
13
+ const connected = (address: ComputerAddress): Effect.Effect<ComputerClient, ComputersUnavailableError> =>
14
+ Effect.map(current, (clients) => clients.connect(address));
15
+
16
+ return (address: ComputerAddress): ComputerClient => {
17
+ const client = connected(address);
18
+
19
+ return {
20
+ ensure: (spec) => Effect.flatMap(client, (bound) => bound.ensure(spec)),
21
+ exec: (computer, request) => Effect.flatMap(client, (bound) => bound.exec(computer, request)),
22
+ files: (computer, request) => Effect.flatMap(client, (bound) => bound.files(computer, request)),
23
+ fork: (computer, fork) => Effect.flatMap(client, (bound) => bound.fork(computer, fork)),
24
+ get: (computer) => Effect.flatMap(client, (bound) => bound.get(computer)),
25
+ list: Effect.flatMap(client, (bound) => bound.list),
26
+ pause: (computer, hold) => Effect.flatMap(client, (bound) => bound.pause(computer, hold)),
27
+ remove: (computer) => Effect.flatMap(client, (bound) => bound.remove(computer)),
28
+ resume: (computer, hold) => Effect.flatMap(client, (bound) => bound.resume(computer, hold)),
29
+ stop: (computer) => Effect.flatMap(client, (bound) => bound.stop(computer)),
30
+ };
31
+ };
32
+ };
33
+
34
+ /**
35
+ * Whether the local engine runs computers: off unless `AKTER_LOCAL_COMPUTERS` is `true`, because a local computer runs
36
+ * its steps on this machine. Off, the app's jobs see no computers, as before the local engine had them.
37
+ */
38
+ const localComputersOn = Config.Boolean("AKTER_LOCAL_COMPUTERS").pipe(Config.withDefault(false));
39
+
40
+ const make = Effect.gen(function* makeJobComputers() {
41
+ const bound = yield* Ref.make(Option.none<Clients>());
42
+ const current = Effect.flatMap(Ref.get(bound), (found) => Effect.mapError(Effect.fromOption(found), () => unbound));
43
+
44
+ const clients = ActorComputerClients.of({
45
+ connect: clientThrough(current),
46
+ logs: (address, computer, page) => Effect.flatMap(current, (found) => found.logs(address, computer, page)),
47
+ });
48
+
49
+ return {
50
+ bind: (host: Clients): Effect.Effect<void> => Ref.set(bound, Option.some(host)),
51
+ clients,
52
+ };
53
+ });
54
+
55
+ /**
56
+ * The computers a job runtime's activities reach through `Actor.computer(key)`: whichever the engine hosting the app
57
+ * bound last. Job handlers keep the context the app layer was built in, and the app is built before the engine that
58
+ * hosts it, so the engine binds its computers here once it knows where they live, as the local engine does for each
59
+ * environment it serves. Until one binds, every call fails with `ComputersUnavailableError`. `Akter.jobs` and
60
+ * `Akter.local` share one through the layer memo, as they share the job engine. Its layer gives the app these
61
+ * computers only while `AKTER_LOCAL_COMPUTERS` is on; off, it gives none, so computers another layer provides stay
62
+ * visible and `Actor.computer(key)` answers as on a host without computers.
63
+ */
64
+ export class JobComputers extends Context.Service<
65
+ JobComputers,
66
+ {
67
+ readonly bind: (clients: Clients) => Effect.Effect<void>;
68
+ readonly clients: Clients;
69
+ }
70
+ >()("@akterjs/effect/host/computer/job-computers.service/JobComputers") {
71
+ public static readonly layer: Layer.Layer<JobComputers> = Layer.effectContext(
72
+ Effect.gen(function* buildJobComputers() {
73
+ const computers = yield* make;
74
+ const on = yield* Effect.orDie(localComputersOn);
75
+ const context = Context.make(JobComputers, computers);
76
+
77
+ if (!on) {
78
+ return context;
79
+ }
80
+
81
+ return Context.add(context, ActorComputerClients, computers.clients);
82
+ }),
83
+ );
84
+ }