@smthrs/engine-store 0.0.0-stage → 1.0.0-rc.3

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 (787) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/LICENSE +21 -0
  3. package/README.md +146 -2
  4. package/dist/cjs/ArtifactGc.d.ts +235 -0
  5. package/dist/cjs/ArtifactGc.d.ts.map +1 -0
  6. package/dist/cjs/ArtifactGc.js +183 -0
  7. package/dist/cjs/ArtifactGc.js.map +7 -0
  8. package/dist/cjs/ArtifactSync.d.ts +164 -0
  9. package/dist/cjs/ArtifactSync.d.ts.map +1 -0
  10. package/dist/cjs/ArtifactSync.js +144 -0
  11. package/dist/cjs/ArtifactSync.js.map +7 -0
  12. package/dist/cjs/CacheSync.d.ts +112 -0
  13. package/dist/cjs/CacheSync.d.ts.map +1 -0
  14. package/dist/cjs/CacheSync.js +64 -0
  15. package/dist/cjs/CacheSync.js.map +7 -0
  16. package/dist/cjs/DeferredClockFold.d.ts +354 -0
  17. package/dist/cjs/DeferredClockFold.d.ts.map +1 -0
  18. package/dist/cjs/DeferredClockFold.js +335 -0
  19. package/dist/cjs/DeferredClockFold.js.map +7 -0
  20. package/dist/cjs/DisasterRecovery.d.ts +431 -0
  21. package/dist/cjs/DisasterRecovery.d.ts.map +1 -0
  22. package/dist/cjs/DisasterRecovery.js +453 -0
  23. package/dist/cjs/DisasterRecovery.js.map +7 -0
  24. package/dist/cjs/DurableEngineState.d.ts +776 -0
  25. package/dist/cjs/DurableEngineState.d.ts.map +1 -0
  26. package/dist/cjs/DurableEngineState.js +1536 -0
  27. package/dist/cjs/DurableEngineState.js.map +7 -0
  28. package/dist/cjs/EngineStore.d.ts +158 -0
  29. package/dist/cjs/EngineStore.d.ts.map +1 -0
  30. package/dist/cjs/EngineStore.js +398 -0
  31. package/dist/cjs/EngineStore.js.map +7 -0
  32. package/dist/cjs/EngineStoreMetrics.d.ts +276 -0
  33. package/dist/cjs/EngineStoreMetrics.d.ts.map +1 -0
  34. package/dist/cjs/EngineStoreMetrics.js +135 -0
  35. package/dist/cjs/EngineStoreMetrics.js.map +7 -0
  36. package/dist/cjs/Errors.d.ts +22 -0
  37. package/dist/cjs/Errors.d.ts.map +1 -0
  38. package/dist/cjs/Errors.js +39 -0
  39. package/dist/cjs/Errors.js.map +7 -0
  40. package/dist/cjs/EventTypes.d.ts +27 -0
  41. package/dist/cjs/EventTypes.d.ts.map +1 -0
  42. package/dist/cjs/EventTypes.js +37 -0
  43. package/dist/cjs/EventTypes.js.map +7 -0
  44. package/dist/cjs/ExecutionFacts.d.ts +59 -0
  45. package/dist/cjs/ExecutionFacts.d.ts.map +1 -0
  46. package/dist/cjs/ExecutionFacts.js +123 -0
  47. package/dist/cjs/ExecutionFacts.js.map +7 -0
  48. package/dist/cjs/ExecutionSnapshot.d.ts +117 -0
  49. package/dist/cjs/ExecutionSnapshot.d.ts.map +1 -0
  50. package/dist/cjs/ExecutionSnapshot.js +111 -0
  51. package/dist/cjs/ExecutionSnapshot.js.map +7 -0
  52. package/dist/cjs/Inconsistency.d.ts +154 -0
  53. package/dist/cjs/Inconsistency.d.ts.map +1 -0
  54. package/dist/cjs/Inconsistency.js +135 -0
  55. package/dist/cjs/Inconsistency.js.map +7 -0
  56. package/dist/cjs/Migrations.d.ts +56 -0
  57. package/dist/cjs/Migrations.d.ts.map +1 -0
  58. package/dist/cjs/Migrations.js +78 -0
  59. package/dist/cjs/Migrations.js.map +7 -0
  60. package/dist/cjs/OwnerIdentity.d.ts +91 -0
  61. package/dist/cjs/OwnerIdentity.d.ts.map +1 -0
  62. package/dist/cjs/OwnerIdentity.js +65 -0
  63. package/dist/cjs/OwnerIdentity.js.map +7 -0
  64. package/dist/cjs/PlanInputStore.d.ts +110 -0
  65. package/dist/cjs/PlanInputStore.d.ts.map +1 -0
  66. package/dist/cjs/PlanInputStore.js +224 -0
  67. package/dist/cjs/PlanInputStore.js.map +7 -0
  68. package/dist/cjs/PlanMergeStore.d.ts +113 -0
  69. package/dist/cjs/PlanMergeStore.d.ts.map +1 -0
  70. package/dist/cjs/PlanMergeStore.js +255 -0
  71. package/dist/cjs/PlanMergeStore.js.map +7 -0
  72. package/dist/cjs/PlanScheduler.d.ts +363 -0
  73. package/dist/cjs/PlanScheduler.d.ts.map +1 -0
  74. package/dist/cjs/PlanScheduler.js +1090 -0
  75. package/dist/cjs/PlanScheduler.js.map +7 -0
  76. package/dist/cjs/Reconciliation.d.ts +175 -0
  77. package/dist/cjs/Reconciliation.d.ts.map +1 -0
  78. package/dist/cjs/Reconciliation.js +119 -0
  79. package/dist/cjs/Reconciliation.js.map +7 -0
  80. package/dist/cjs/ReplayOnly.d.ts +91 -0
  81. package/dist/cjs/ReplayOnly.d.ts.map +1 -0
  82. package/dist/cjs/ReplayOnly.js +52 -0
  83. package/dist/cjs/ReplayOnly.js.map +7 -0
  84. package/dist/cjs/Retention.d.ts +113 -0
  85. package/dist/cjs/Retention.d.ts.map +1 -0
  86. package/dist/cjs/Retention.js +99 -0
  87. package/dist/cjs/Retention.js.map +7 -0
  88. package/dist/cjs/RunCatalogRead.d.ts +17 -0
  89. package/dist/cjs/RunCatalogRead.d.ts.map +1 -0
  90. package/dist/cjs/RunCatalogRead.js +33 -0
  91. package/dist/cjs/RunCatalogRead.js.map +7 -0
  92. package/dist/cjs/RunChangeFeed.d.ts +75 -0
  93. package/dist/cjs/RunChangeFeed.d.ts.map +1 -0
  94. package/dist/cjs/RunChangeFeed.js +96 -0
  95. package/dist/cjs/RunChangeFeed.js.map +7 -0
  96. package/dist/cjs/RunState.d.ts +116 -0
  97. package/dist/cjs/RunState.d.ts.map +1 -0
  98. package/dist/cjs/RunState.js +76 -0
  99. package/dist/cjs/RunState.js.map +7 -0
  100. package/dist/cjs/Selection.d.ts +495 -0
  101. package/dist/cjs/Selection.d.ts.map +1 -0
  102. package/dist/cjs/Selection.js +288 -0
  103. package/dist/cjs/Selection.js.map +7 -0
  104. package/dist/cjs/SelectionStore.d.ts +141 -0
  105. package/dist/cjs/SelectionStore.d.ts.map +1 -0
  106. package/dist/cjs/SelectionStore.js +229 -0
  107. package/dist/cjs/SelectionStore.js.map +7 -0
  108. package/dist/cjs/StepBoundary.d.ts +501 -0
  109. package/dist/cjs/StepBoundary.d.ts.map +1 -0
  110. package/dist/cjs/StepBoundary.js +619 -0
  111. package/dist/cjs/StepBoundary.js.map +7 -0
  112. package/dist/cjs/StepCacheFold.d.ts +148 -0
  113. package/dist/cjs/StepCacheFold.d.ts.map +1 -0
  114. package/dist/cjs/StepCacheFold.js +131 -0
  115. package/dist/cjs/StepCacheFold.js.map +7 -0
  116. package/dist/cjs/StepSandbox.d.ts +78 -0
  117. package/dist/cjs/StepSandbox.d.ts.map +1 -0
  118. package/dist/cjs/StepSandbox.js +75 -0
  119. package/dist/cjs/StepSandbox.js.map +7 -0
  120. package/dist/cjs/WakeBus.d.ts +116 -0
  121. package/dist/cjs/WakeBus.d.ts.map +1 -0
  122. package/dist/cjs/WakeBus.js +89 -0
  123. package/dist/cjs/WakeBus.js.map +7 -0
  124. package/dist/cjs/WorkspaceSandbox.d.ts +619 -0
  125. package/dist/cjs/WorkspaceSandbox.d.ts.map +1 -0
  126. package/dist/cjs/WorkspaceSandbox.js +711 -0
  127. package/dist/cjs/WorkspaceSandbox.js.map +7 -0
  128. package/dist/cjs/index.d.ts +157 -0
  129. package/dist/cjs/index.d.ts.map +1 -0
  130. package/dist/cjs/index.js +95 -0
  131. package/dist/cjs/index.js.map +7 -0
  132. package/dist/cjs/internal/ActionPersistence.d.ts +276 -0
  133. package/dist/cjs/internal/ActionPersistence.d.ts.map +1 -0
  134. package/dist/cjs/internal/ActionPersistence.js +1395 -0
  135. package/dist/cjs/internal/ActionPersistence.js.map +7 -0
  136. package/dist/cjs/internal/ArtifactRoots.d.ts +38 -0
  137. package/dist/cjs/internal/ArtifactRoots.d.ts.map +1 -0
  138. package/dist/cjs/internal/ArtifactRoots.js +89 -0
  139. package/dist/cjs/internal/ArtifactRoots.js.map +7 -0
  140. package/dist/cjs/internal/AttemptAdmission.d.ts +53 -0
  141. package/dist/cjs/internal/AttemptAdmission.d.ts.map +1 -0
  142. package/dist/cjs/internal/AttemptAdmission.js +52 -0
  143. package/dist/cjs/internal/AttemptAdmission.js.map +7 -0
  144. package/dist/cjs/internal/AttemptLifecycle.d.ts +245 -0
  145. package/dist/cjs/internal/AttemptLifecycle.d.ts.map +1 -0
  146. package/dist/cjs/internal/AttemptLifecycle.js +112 -0
  147. package/dist/cjs/internal/AttemptLifecycle.js.map +7 -0
  148. package/dist/cjs/internal/AttemptProbe.d.ts +53 -0
  149. package/dist/cjs/internal/AttemptProbe.d.ts.map +1 -0
  150. package/dist/cjs/internal/AttemptProbe.js +66 -0
  151. package/dist/cjs/internal/AttemptProbe.js.map +7 -0
  152. package/dist/cjs/internal/CacheAdmission.d.ts +79 -0
  153. package/dist/cjs/internal/CacheAdmission.d.ts.map +1 -0
  154. package/dist/cjs/internal/CacheAdmission.js +71 -0
  155. package/dist/cjs/internal/CacheAdmission.js.map +7 -0
  156. package/dist/cjs/internal/CacheAgeHistory.d.ts +27 -0
  157. package/dist/cjs/internal/CacheAgeHistory.d.ts.map +1 -0
  158. package/dist/cjs/internal/CacheAgeHistory.js +61 -0
  159. package/dist/cjs/internal/CacheAgeHistory.js.map +7 -0
  160. package/dist/cjs/internal/CacheAgeVerdicts.d.ts +15 -0
  161. package/dist/cjs/internal/CacheAgeVerdicts.d.ts.map +1 -0
  162. package/dist/cjs/internal/CacheAgeVerdicts.js +73 -0
  163. package/dist/cjs/internal/CacheAgeVerdicts.js.map +7 -0
  164. package/dist/cjs/internal/CacheOutputPolicy.d.ts +24 -0
  165. package/dist/cjs/internal/CacheOutputPolicy.d.ts.map +1 -0
  166. package/dist/cjs/internal/CacheOutputPolicy.js +75 -0
  167. package/dist/cjs/internal/CacheOutputPolicy.js.map +7 -0
  168. package/dist/cjs/internal/CachePublication.d.ts +97 -0
  169. package/dist/cjs/internal/CachePublication.d.ts.map +1 -0
  170. package/dist/cjs/internal/CachePublication.js +80 -0
  171. package/dist/cjs/internal/CachePublication.js.map +7 -0
  172. package/dist/cjs/internal/CallFacts.d.ts +15 -0
  173. package/dist/cjs/internal/CallFacts.d.ts.map +1 -0
  174. package/dist/cjs/internal/CallFacts.js +97 -0
  175. package/dist/cjs/internal/CallFacts.js.map +7 -0
  176. package/dist/cjs/internal/CopiedRecord.d.ts +61 -0
  177. package/dist/cjs/internal/CopiedRecord.d.ts.map +1 -0
  178. package/dist/cjs/internal/CopiedRecord.js +134 -0
  179. package/dist/cjs/internal/CopiedRecord.js.map +7 -0
  180. package/dist/cjs/internal/DeferredPersistence.d.ts +108 -0
  181. package/dist/cjs/internal/DeferredPersistence.d.ts.map +1 -0
  182. package/dist/cjs/internal/DeferredPersistence.js +270 -0
  183. package/dist/cjs/internal/DeferredPersistence.js.map +7 -0
  184. package/dist/cjs/internal/EffectRecords.d.ts +92 -0
  185. package/dist/cjs/internal/EffectRecords.d.ts.map +1 -0
  186. package/dist/cjs/internal/EffectRecords.js +63 -0
  187. package/dist/cjs/internal/EffectRecords.js.map +7 -0
  188. package/dist/cjs/internal/EngineJj.d.ts +30 -0
  189. package/dist/cjs/internal/EngineJj.d.ts.map +1 -0
  190. package/dist/cjs/internal/EngineJj.js +42 -0
  191. package/dist/cjs/internal/EngineJj.js.map +7 -0
  192. package/dist/cjs/internal/EngineStateSchema.d.ts +68 -0
  193. package/dist/cjs/internal/EngineStateSchema.d.ts.map +1 -0
  194. package/dist/cjs/internal/EngineStateSchema.js +58 -0
  195. package/dist/cjs/internal/EngineStateSchema.js.map +7 -0
  196. package/dist/cjs/internal/ExecutionSnapshotRead.d.ts +162 -0
  197. package/dist/cjs/internal/ExecutionSnapshotRead.d.ts.map +1 -0
  198. package/dist/cjs/internal/ExecutionSnapshotRead.js +199 -0
  199. package/dist/cjs/internal/ExecutionSnapshotRead.js.map +7 -0
  200. package/dist/cjs/internal/ExecutionSnapshotRelations.d.ts +39 -0
  201. package/dist/cjs/internal/ExecutionSnapshotRelations.d.ts.map +1 -0
  202. package/dist/cjs/internal/ExecutionSnapshotRelations.js +105 -0
  203. package/dist/cjs/internal/ExecutionSnapshotRelations.js.map +7 -0
  204. package/dist/cjs/internal/ExitEncoding.d.ts +180 -0
  205. package/dist/cjs/internal/ExitEncoding.d.ts.map +1 -0
  206. package/dist/cjs/internal/ExitEncoding.js +236 -0
  207. package/dist/cjs/internal/ExitEncoding.js.map +7 -0
  208. package/dist/cjs/internal/FileBoundarySnapshot.d.ts +14 -0
  209. package/dist/cjs/internal/FileBoundarySnapshot.d.ts.map +1 -0
  210. package/dist/cjs/internal/FileBoundarySnapshot.js +51 -0
  211. package/dist/cjs/internal/FileBoundarySnapshot.js.map +7 -0
  212. package/dist/cjs/internal/FileEnumeration.d.ts +127 -0
  213. package/dist/cjs/internal/FileEnumeration.d.ts.map +1 -0
  214. package/dist/cjs/internal/FileEnumeration.js +194 -0
  215. package/dist/cjs/internal/FileEnumeration.js.map +7 -0
  216. package/dist/cjs/internal/HostReflection.d.ts +80 -0
  217. package/dist/cjs/internal/HostReflection.d.ts.map +1 -0
  218. package/dist/cjs/internal/HostReflection.js +43 -0
  219. package/dist/cjs/internal/HostReflection.js.map +7 -0
  220. package/dist/cjs/internal/JournalRecords.d.ts +325 -0
  221. package/dist/cjs/internal/JournalRecords.d.ts.map +1 -0
  222. package/dist/cjs/internal/JournalRecords.js +122 -0
  223. package/dist/cjs/internal/JournalRecords.js.map +7 -0
  224. package/dist/cjs/internal/NodeJournal.d.ts +157 -0
  225. package/dist/cjs/internal/NodeJournal.d.ts.map +1 -0
  226. package/dist/cjs/internal/NodeJournal.js +192 -0
  227. package/dist/cjs/internal/NodeJournal.js.map +7 -0
  228. package/dist/cjs/internal/Ordering.d.ts +14 -0
  229. package/dist/cjs/internal/Ordering.d.ts.map +1 -0
  230. package/dist/cjs/internal/Ordering.js +25 -0
  231. package/dist/cjs/internal/Ordering.js.map +7 -0
  232. package/dist/cjs/internal/PlanInputs.d.ts +14 -0
  233. package/dist/cjs/internal/PlanInputs.d.ts.map +1 -0
  234. package/dist/cjs/internal/PlanInputs.js +78 -0
  235. package/dist/cjs/internal/PlanInputs.js.map +7 -0
  236. package/dist/cjs/internal/PlanMerges.d.ts +178 -0
  237. package/dist/cjs/internal/PlanMerges.d.ts.map +1 -0
  238. package/dist/cjs/internal/PlanMerges.js +125 -0
  239. package/dist/cjs/internal/PlanMerges.js.map +7 -0
  240. package/dist/cjs/internal/ProvenanceSlot.d.ts +30 -0
  241. package/dist/cjs/internal/ProvenanceSlot.d.ts.map +1 -0
  242. package/dist/cjs/internal/ProvenanceSlot.js +53 -0
  243. package/dist/cjs/internal/ProvenanceSlot.js.map +7 -0
  244. package/dist/cjs/internal/ResultEnvelope.d.ts +88 -0
  245. package/dist/cjs/internal/ResultEnvelope.d.ts.map +1 -0
  246. package/dist/cjs/internal/ResultEnvelope.js +90 -0
  247. package/dist/cjs/internal/ResultEnvelope.js.map +7 -0
  248. package/dist/cjs/internal/RetentionOps.d.ts +414 -0
  249. package/dist/cjs/internal/RetentionOps.d.ts.map +1 -0
  250. package/dist/cjs/internal/RetentionOps.js +354 -0
  251. package/dist/cjs/internal/RetentionOps.js.map +7 -0
  252. package/dist/cjs/internal/RunCatalogOps.d.ts +118 -0
  253. package/dist/cjs/internal/RunCatalogOps.d.ts.map +1 -0
  254. package/dist/cjs/internal/RunCatalogOps.js +85 -0
  255. package/dist/cjs/internal/RunCatalogOps.js.map +7 -0
  256. package/dist/cjs/internal/RunCoordinator.d.ts +78 -0
  257. package/dist/cjs/internal/RunCoordinator.d.ts.map +1 -0
  258. package/dist/cjs/internal/RunCoordinator.js +123 -0
  259. package/dist/cjs/internal/RunCoordinator.js.map +7 -0
  260. package/dist/cjs/internal/RunDriver.d.ts +192 -0
  261. package/dist/cjs/internal/RunDriver.d.ts.map +1 -0
  262. package/dist/cjs/internal/RunDriver.js +1584 -0
  263. package/dist/cjs/internal/RunDriver.js.map +7 -0
  264. package/dist/cjs/internal/RunLifecycle.d.ts +22 -0
  265. package/dist/cjs/internal/RunLifecycle.d.ts.map +1 -0
  266. package/dist/cjs/internal/RunLifecycle.js +63 -0
  267. package/dist/cjs/internal/RunLifecycle.js.map +7 -0
  268. package/dist/cjs/internal/RunListing.d.ts +78 -0
  269. package/dist/cjs/internal/RunListing.d.ts.map +1 -0
  270. package/dist/cjs/internal/RunListing.js +171 -0
  271. package/dist/cjs/internal/RunListing.js.map +7 -0
  272. package/dist/cjs/internal/RunListingError.d.ts +35 -0
  273. package/dist/cjs/internal/RunListingError.d.ts.map +1 -0
  274. package/dist/cjs/internal/RunListingError.js +47 -0
  275. package/dist/cjs/internal/RunListingError.js.map +7 -0
  276. package/dist/cjs/internal/RuntimeGraph.d.ts +73 -0
  277. package/dist/cjs/internal/RuntimeGraph.d.ts.map +1 -0
  278. package/dist/cjs/internal/RuntimeGraph.js +180 -0
  279. package/dist/cjs/internal/RuntimeGraph.js.map +7 -0
  280. package/dist/cjs/internal/SandboxedExecution.d.ts +80 -0
  281. package/dist/cjs/internal/SandboxedExecution.d.ts.map +1 -0
  282. package/dist/cjs/internal/SandboxedExecution.js +104 -0
  283. package/dist/cjs/internal/SandboxedExecution.js.map +7 -0
  284. package/dist/cjs/internal/StateTransaction.d.ts +44 -0
  285. package/dist/cjs/internal/StateTransaction.d.ts.map +1 -0
  286. package/dist/cjs/internal/StateTransaction.js +52 -0
  287. package/dist/cjs/internal/StateTransaction.js.map +7 -0
  288. package/dist/cjs/internal/StepFacts.d.ts +14 -0
  289. package/dist/cjs/internal/StepFacts.d.ts.map +1 -0
  290. package/dist/cjs/internal/StepFacts.js +58 -0
  291. package/dist/cjs/internal/StepFacts.js.map +7 -0
  292. package/dist/cjs/internal/TypedEvents.d.ts +14 -0
  293. package/dist/cjs/internal/TypedEvents.d.ts.map +1 -0
  294. package/dist/cjs/internal/TypedEvents.js +37 -0
  295. package/dist/cjs/internal/TypedEvents.js.map +7 -0
  296. package/dist/cjs/migrations/0001_initial.d.ts +17 -0
  297. package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
  298. package/dist/cjs/migrations/0001_initial.js +61 -0
  299. package/dist/cjs/migrations/0001_initial.js.map +7 -0
  300. package/dist/cjs/migrations/0002_selection_store.d.ts +15 -0
  301. package/dist/cjs/migrations/0002_selection_store.d.ts.map +1 -0
  302. package/dist/cjs/migrations/0002_selection_store.js +56 -0
  303. package/dist/cjs/migrations/0002_selection_store.js.map +7 -0
  304. package/dist/cjs/migrations/0003_plan_inputs.d.ts +13 -0
  305. package/dist/cjs/migrations/0003_plan_inputs.d.ts.map +1 -0
  306. package/dist/cjs/migrations/0003_plan_inputs.js +90 -0
  307. package/dist/cjs/migrations/0003_plan_inputs.js.map +7 -0
  308. package/dist/cjs/migrations/0004_plan_environment.d.ts +14 -0
  309. package/dist/cjs/migrations/0004_plan_environment.d.ts.map +1 -0
  310. package/dist/cjs/migrations/0004_plan_environment.js +56 -0
  311. package/dist/cjs/migrations/0004_plan_environment.js.map +7 -0
  312. package/dist/cjs/migrations/0005_plan_merges.d.ts +14 -0
  313. package/dist/cjs/migrations/0005_plan_merges.d.ts.map +1 -0
  314. package/dist/cjs/migrations/0005_plan_merges.js +82 -0
  315. package/dist/cjs/migrations/0005_plan_merges.js.map +7 -0
  316. package/dist/cjs/migrations/0006_execution_listing.d.ts +15 -0
  317. package/dist/cjs/migrations/0006_execution_listing.d.ts.map +1 -0
  318. package/dist/cjs/migrations/0006_execution_listing.js +101 -0
  319. package/dist/cjs/migrations/0006_execution_listing.js.map +7 -0
  320. package/dist/cjs/migrations/0007_run_parent_sequence.d.ts +15 -0
  321. package/dist/cjs/migrations/0007_run_parent_sequence.d.ts.map +1 -0
  322. package/dist/cjs/migrations/0007_run_parent_sequence.js +40 -0
  323. package/dist/cjs/migrations/0007_run_parent_sequence.js.map +7 -0
  324. package/dist/cjs/migrations/0008_deferred_consumption.d.ts +16 -0
  325. package/dist/cjs/migrations/0008_deferred_consumption.d.ts.map +1 -0
  326. package/dist/cjs/migrations/0008_deferred_consumption.js +45 -0
  327. package/dist/cjs/migrations/0008_deferred_consumption.js.map +7 -0
  328. package/dist/cjs/migrations/0009_deferred_clock_facts.d.ts +24 -0
  329. package/dist/cjs/migrations/0009_deferred_clock_facts.d.ts.map +1 -0
  330. package/dist/cjs/migrations/0009_deferred_clock_facts.js +141 -0
  331. package/dist/cjs/migrations/0009_deferred_clock_facts.js.map +7 -0
  332. package/dist/cjs/migrations/0010_pending_cancellation.d.ts +15 -0
  333. package/dist/cjs/migrations/0010_pending_cancellation.d.ts.map +1 -0
  334. package/dist/cjs/migrations/0010_pending_cancellation.js +41 -0
  335. package/dist/cjs/migrations/0010_pending_cancellation.js.map +7 -0
  336. package/dist/cjs/package.json +1 -0
  337. package/dist/cjs/test/TestStores.d.ts +89 -0
  338. package/dist/cjs/test/TestStores.d.ts.map +1 -0
  339. package/dist/cjs/test/TestStores.js +98 -0
  340. package/dist/cjs/test/TestStores.js.map +7 -0
  341. package/dist/esm/ArtifactGc.d.ts +235 -0
  342. package/dist/esm/ArtifactGc.d.ts.map +1 -0
  343. package/dist/esm/ArtifactGc.js +268 -0
  344. package/dist/esm/ArtifactGc.js.map +1 -0
  345. package/dist/esm/ArtifactSync.d.ts +164 -0
  346. package/dist/esm/ArtifactSync.d.ts.map +1 -0
  347. package/dist/esm/ArtifactSync.js +176 -0
  348. package/dist/esm/ArtifactSync.js.map +1 -0
  349. package/dist/esm/CacheSync.d.ts +112 -0
  350. package/dist/esm/CacheSync.d.ts.map +1 -0
  351. package/dist/esm/CacheSync.js +94 -0
  352. package/dist/esm/CacheSync.js.map +1 -0
  353. package/dist/esm/DeferredClockFold.d.ts +354 -0
  354. package/dist/esm/DeferredClockFold.d.ts.map +1 -0
  355. package/dist/esm/DeferredClockFold.js +472 -0
  356. package/dist/esm/DeferredClockFold.js.map +1 -0
  357. package/dist/esm/DisasterRecovery.d.ts +431 -0
  358. package/dist/esm/DisasterRecovery.d.ts.map +1 -0
  359. package/dist/esm/DisasterRecovery.js +523 -0
  360. package/dist/esm/DisasterRecovery.js.map +1 -0
  361. package/dist/esm/DurableEngineState.d.ts +776 -0
  362. package/dist/esm/DurableEngineState.d.ts.map +1 -0
  363. package/dist/esm/DurableEngineState.js +1648 -0
  364. package/dist/esm/DurableEngineState.js.map +1 -0
  365. package/dist/esm/EngineStore.d.ts +158 -0
  366. package/dist/esm/EngineStore.d.ts.map +1 -0
  367. package/dist/esm/EngineStore.js +403 -0
  368. package/dist/esm/EngineStore.js.map +1 -0
  369. package/dist/esm/EngineStoreMetrics.d.ts +276 -0
  370. package/dist/esm/EngineStoreMetrics.d.ts.map +1 -0
  371. package/dist/esm/EngineStoreMetrics.js +260 -0
  372. package/dist/esm/EngineStoreMetrics.js.map +1 -0
  373. package/dist/esm/Errors.d.ts +22 -0
  374. package/dist/esm/Errors.d.ts.map +1 -0
  375. package/dist/esm/Errors.js +22 -0
  376. package/dist/esm/Errors.js.map +1 -0
  377. package/dist/esm/EventTypes.d.ts +27 -0
  378. package/dist/esm/EventTypes.d.ts.map +1 -0
  379. package/dist/esm/EventTypes.js +27 -0
  380. package/dist/esm/EventTypes.js.map +1 -0
  381. package/dist/esm/ExecutionFacts.d.ts +59 -0
  382. package/dist/esm/ExecutionFacts.d.ts.map +1 -0
  383. package/dist/esm/ExecutionFacts.js +96 -0
  384. package/dist/esm/ExecutionFacts.js.map +1 -0
  385. package/dist/esm/ExecutionSnapshot.d.ts +117 -0
  386. package/dist/esm/ExecutionSnapshot.d.ts.map +1 -0
  387. package/dist/esm/ExecutionSnapshot.js +95 -0
  388. package/dist/esm/ExecutionSnapshot.js.map +1 -0
  389. package/dist/esm/Inconsistency.d.ts +154 -0
  390. package/dist/esm/Inconsistency.d.ts.map +1 -0
  391. package/dist/esm/Inconsistency.js +133 -0
  392. package/dist/esm/Inconsistency.js.map +1 -0
  393. package/dist/esm/Migrations.d.ts +56 -0
  394. package/dist/esm/Migrations.d.ts.map +1 -0
  395. package/dist/esm/Migrations.js +91 -0
  396. package/dist/esm/Migrations.js.map +1 -0
  397. package/dist/esm/OwnerIdentity.d.ts +91 -0
  398. package/dist/esm/OwnerIdentity.d.ts.map +1 -0
  399. package/dist/esm/OwnerIdentity.js +99 -0
  400. package/dist/esm/OwnerIdentity.js.map +1 -0
  401. package/dist/esm/PlanInputStore.d.ts +110 -0
  402. package/dist/esm/PlanInputStore.d.ts.map +1 -0
  403. package/dist/esm/PlanInputStore.js +207 -0
  404. package/dist/esm/PlanInputStore.js.map +1 -0
  405. package/dist/esm/PlanMergeStore.d.ts +113 -0
  406. package/dist/esm/PlanMergeStore.d.ts.map +1 -0
  407. package/dist/esm/PlanMergeStore.js +244 -0
  408. package/dist/esm/PlanMergeStore.js.map +1 -0
  409. package/dist/esm/PlanScheduler.d.ts +363 -0
  410. package/dist/esm/PlanScheduler.d.ts.map +1 -0
  411. package/dist/esm/PlanScheduler.js +1321 -0
  412. package/dist/esm/PlanScheduler.js.map +1 -0
  413. package/dist/esm/Reconciliation.d.ts +175 -0
  414. package/dist/esm/Reconciliation.d.ts.map +1 -0
  415. package/dist/esm/Reconciliation.js +175 -0
  416. package/dist/esm/Reconciliation.js.map +1 -0
  417. package/dist/esm/ReplayOnly.d.ts +91 -0
  418. package/dist/esm/ReplayOnly.d.ts.map +1 -0
  419. package/dist/esm/ReplayOnly.js +59 -0
  420. package/dist/esm/ReplayOnly.js.map +1 -0
  421. package/dist/esm/Retention.d.ts +113 -0
  422. package/dist/esm/Retention.d.ts.map +1 -0
  423. package/dist/esm/Retention.js +139 -0
  424. package/dist/esm/Retention.js.map +1 -0
  425. package/dist/esm/RunCatalogRead.d.ts +17 -0
  426. package/dist/esm/RunCatalogRead.d.ts.map +1 -0
  427. package/dist/esm/RunCatalogRead.js +17 -0
  428. package/dist/esm/RunCatalogRead.js.map +1 -0
  429. package/dist/esm/RunChangeFeed.d.ts +75 -0
  430. package/dist/esm/RunChangeFeed.d.ts.map +1 -0
  431. package/dist/esm/RunChangeFeed.js +81 -0
  432. package/dist/esm/RunChangeFeed.js.map +1 -0
  433. package/dist/esm/RunState.d.ts +116 -0
  434. package/dist/esm/RunState.d.ts.map +1 -0
  435. package/dist/esm/RunState.js +109 -0
  436. package/dist/esm/RunState.js.map +1 -0
  437. package/dist/esm/Selection.d.ts +495 -0
  438. package/dist/esm/Selection.d.ts.map +1 -0
  439. package/dist/esm/Selection.js +482 -0
  440. package/dist/esm/Selection.js.map +1 -0
  441. package/dist/esm/SelectionStore.d.ts +141 -0
  442. package/dist/esm/SelectionStore.d.ts.map +1 -0
  443. package/dist/esm/SelectionStore.js +215 -0
  444. package/dist/esm/SelectionStore.js.map +1 -0
  445. package/dist/esm/StepBoundary.d.ts +501 -0
  446. package/dist/esm/StepBoundary.d.ts.map +1 -0
  447. package/dist/esm/StepBoundary.js +919 -0
  448. package/dist/esm/StepBoundary.js.map +1 -0
  449. package/dist/esm/StepCacheFold.d.ts +148 -0
  450. package/dist/esm/StepCacheFold.d.ts.map +1 -0
  451. package/dist/esm/StepCacheFold.js +201 -0
  452. package/dist/esm/StepCacheFold.js.map +1 -0
  453. package/dist/esm/StepSandbox.d.ts +78 -0
  454. package/dist/esm/StepSandbox.d.ts.map +1 -0
  455. package/dist/esm/StepSandbox.js +70 -0
  456. package/dist/esm/StepSandbox.js.map +1 -0
  457. package/dist/esm/WakeBus.d.ts +116 -0
  458. package/dist/esm/WakeBus.d.ts.map +1 -0
  459. package/dist/esm/WakeBus.js +121 -0
  460. package/dist/esm/WakeBus.js.map +1 -0
  461. package/dist/esm/WorkspaceSandbox.d.ts +619 -0
  462. package/dist/esm/WorkspaceSandbox.d.ts.map +1 -0
  463. package/dist/esm/WorkspaceSandbox.js +985 -0
  464. package/dist/esm/WorkspaceSandbox.js.map +1 -0
  465. package/dist/esm/index.d.ts +157 -0
  466. package/dist/esm/index.d.ts.map +1 -0
  467. package/dist/esm/index.js +157 -0
  468. package/dist/esm/index.js.map +1 -0
  469. package/dist/esm/internal/ActionPersistence.d.ts +276 -0
  470. package/dist/esm/internal/ActionPersistence.d.ts.map +1 -0
  471. package/dist/esm/internal/ActionPersistence.js +2306 -0
  472. package/dist/esm/internal/ActionPersistence.js.map +1 -0
  473. package/dist/esm/internal/ArtifactRoots.d.ts +38 -0
  474. package/dist/esm/internal/ArtifactRoots.d.ts.map +1 -0
  475. package/dist/esm/internal/ArtifactRoots.js +76 -0
  476. package/dist/esm/internal/ArtifactRoots.js.map +1 -0
  477. package/dist/esm/internal/AttemptAdmission.d.ts +53 -0
  478. package/dist/esm/internal/AttemptAdmission.d.ts.map +1 -0
  479. package/dist/esm/internal/AttemptAdmission.js +52 -0
  480. package/dist/esm/internal/AttemptAdmission.js.map +1 -0
  481. package/dist/esm/internal/AttemptLifecycle.d.ts +245 -0
  482. package/dist/esm/internal/AttemptLifecycle.d.ts.map +1 -0
  483. package/dist/esm/internal/AttemptLifecycle.js +104 -0
  484. package/dist/esm/internal/AttemptLifecycle.js.map +1 -0
  485. package/dist/esm/internal/AttemptProbe.d.ts +53 -0
  486. package/dist/esm/internal/AttemptProbe.d.ts.map +1 -0
  487. package/dist/esm/internal/AttemptProbe.js +83 -0
  488. package/dist/esm/internal/AttemptProbe.js.map +1 -0
  489. package/dist/esm/internal/CacheAdmission.d.ts +79 -0
  490. package/dist/esm/internal/CacheAdmission.d.ts.map +1 -0
  491. package/dist/esm/internal/CacheAdmission.js +72 -0
  492. package/dist/esm/internal/CacheAdmission.js.map +1 -0
  493. package/dist/esm/internal/CacheAgeHistory.d.ts +27 -0
  494. package/dist/esm/internal/CacheAgeHistory.d.ts.map +1 -0
  495. package/dist/esm/internal/CacheAgeHistory.js +49 -0
  496. package/dist/esm/internal/CacheAgeHistory.js.map +1 -0
  497. package/dist/esm/internal/CacheAgeVerdicts.d.ts +15 -0
  498. package/dist/esm/internal/CacheAgeVerdicts.d.ts.map +1 -0
  499. package/dist/esm/internal/CacheAgeVerdicts.js +54 -0
  500. package/dist/esm/internal/CacheAgeVerdicts.js.map +1 -0
  501. package/dist/esm/internal/CacheOutputPolicy.d.ts +24 -0
  502. package/dist/esm/internal/CacheOutputPolicy.d.ts.map +1 -0
  503. package/dist/esm/internal/CacheOutputPolicy.js +73 -0
  504. package/dist/esm/internal/CacheOutputPolicy.js.map +1 -0
  505. package/dist/esm/internal/CachePublication.d.ts +97 -0
  506. package/dist/esm/internal/CachePublication.d.ts.map +1 -0
  507. package/dist/esm/internal/CachePublication.js +116 -0
  508. package/dist/esm/internal/CachePublication.js.map +1 -0
  509. package/dist/esm/internal/CallFacts.d.ts +15 -0
  510. package/dist/esm/internal/CallFacts.d.ts.map +1 -0
  511. package/dist/esm/internal/CallFacts.js +83 -0
  512. package/dist/esm/internal/CallFacts.js.map +1 -0
  513. package/dist/esm/internal/CopiedRecord.d.ts +61 -0
  514. package/dist/esm/internal/CopiedRecord.d.ts.map +1 -0
  515. package/dist/esm/internal/CopiedRecord.js +165 -0
  516. package/dist/esm/internal/CopiedRecord.js.map +1 -0
  517. package/dist/esm/internal/DeferredPersistence.d.ts +108 -0
  518. package/dist/esm/internal/DeferredPersistence.d.ts.map +1 -0
  519. package/dist/esm/internal/DeferredPersistence.js +240 -0
  520. package/dist/esm/internal/DeferredPersistence.js.map +1 -0
  521. package/dist/esm/internal/EffectRecords.d.ts +92 -0
  522. package/dist/esm/internal/EffectRecords.d.ts.map +1 -0
  523. package/dist/esm/internal/EffectRecords.js +94 -0
  524. package/dist/esm/internal/EffectRecords.js.map +1 -0
  525. package/dist/esm/internal/EngineJj.d.ts +30 -0
  526. package/dist/esm/internal/EngineJj.d.ts.map +1 -0
  527. package/dist/esm/internal/EngineJj.js +29 -0
  528. package/dist/esm/internal/EngineJj.js.map +1 -0
  529. package/dist/esm/internal/EngineStateSchema.d.ts +68 -0
  530. package/dist/esm/internal/EngineStateSchema.d.ts.map +1 -0
  531. package/dist/esm/internal/EngineStateSchema.js +53 -0
  532. package/dist/esm/internal/EngineStateSchema.js.map +1 -0
  533. package/dist/esm/internal/ExecutionSnapshotRead.d.ts +162 -0
  534. package/dist/esm/internal/ExecutionSnapshotRead.d.ts.map +1 -0
  535. package/dist/esm/internal/ExecutionSnapshotRead.js +218 -0
  536. package/dist/esm/internal/ExecutionSnapshotRead.js.map +1 -0
  537. package/dist/esm/internal/ExecutionSnapshotRelations.d.ts +39 -0
  538. package/dist/esm/internal/ExecutionSnapshotRelations.d.ts.map +1 -0
  539. package/dist/esm/internal/ExecutionSnapshotRelations.js +81 -0
  540. package/dist/esm/internal/ExecutionSnapshotRelations.js.map +1 -0
  541. package/dist/esm/internal/ExitEncoding.d.ts +180 -0
  542. package/dist/esm/internal/ExitEncoding.d.ts.map +1 -0
  543. package/dist/esm/internal/ExitEncoding.js +361 -0
  544. package/dist/esm/internal/ExitEncoding.js.map +1 -0
  545. package/dist/esm/internal/FileBoundarySnapshot.d.ts +14 -0
  546. package/dist/esm/internal/FileBoundarySnapshot.d.ts.map +1 -0
  547. package/dist/esm/internal/FileBoundarySnapshot.js +29 -0
  548. package/dist/esm/internal/FileBoundarySnapshot.js.map +1 -0
  549. package/dist/esm/internal/FileEnumeration.d.ts +127 -0
  550. package/dist/esm/internal/FileEnumeration.d.ts.map +1 -0
  551. package/dist/esm/internal/FileEnumeration.js +236 -0
  552. package/dist/esm/internal/FileEnumeration.js.map +1 -0
  553. package/dist/esm/internal/HostReflection.d.ts +80 -0
  554. package/dist/esm/internal/HostReflection.d.ts.map +1 -0
  555. package/dist/esm/internal/HostReflection.js +98 -0
  556. package/dist/esm/internal/HostReflection.js.map +1 -0
  557. package/dist/esm/internal/JournalRecords.d.ts +325 -0
  558. package/dist/esm/internal/JournalRecords.d.ts.map +1 -0
  559. package/dist/esm/internal/JournalRecords.js +306 -0
  560. package/dist/esm/internal/JournalRecords.js.map +1 -0
  561. package/dist/esm/internal/NodeJournal.d.ts +157 -0
  562. package/dist/esm/internal/NodeJournal.d.ts.map +1 -0
  563. package/dist/esm/internal/NodeJournal.js +298 -0
  564. package/dist/esm/internal/NodeJournal.js.map +1 -0
  565. package/dist/esm/internal/Ordering.d.ts +14 -0
  566. package/dist/esm/internal/Ordering.d.ts.map +1 -0
  567. package/dist/esm/internal/Ordering.js +14 -0
  568. package/dist/esm/internal/Ordering.js.map +1 -0
  569. package/dist/esm/internal/PlanInputs.d.ts +14 -0
  570. package/dist/esm/internal/PlanInputs.d.ts.map +1 -0
  571. package/dist/esm/internal/PlanInputs.js +57 -0
  572. package/dist/esm/internal/PlanInputs.js.map +1 -0
  573. package/dist/esm/internal/PlanMerges.d.ts +178 -0
  574. package/dist/esm/internal/PlanMerges.d.ts.map +1 -0
  575. package/dist/esm/internal/PlanMerges.js +113 -0
  576. package/dist/esm/internal/PlanMerges.js.map +1 -0
  577. package/dist/esm/internal/ProvenanceSlot.d.ts +30 -0
  578. package/dist/esm/internal/ProvenanceSlot.d.ts.map +1 -0
  579. package/dist/esm/internal/ProvenanceSlot.js +39 -0
  580. package/dist/esm/internal/ProvenanceSlot.js.map +1 -0
  581. package/dist/esm/internal/ResultEnvelope.d.ts +88 -0
  582. package/dist/esm/internal/ResultEnvelope.d.ts.map +1 -0
  583. package/dist/esm/internal/ResultEnvelope.js +83 -0
  584. package/dist/esm/internal/ResultEnvelope.js.map +1 -0
  585. package/dist/esm/internal/RetentionOps.d.ts +414 -0
  586. package/dist/esm/internal/RetentionOps.d.ts.map +1 -0
  587. package/dist/esm/internal/RetentionOps.js +576 -0
  588. package/dist/esm/internal/RetentionOps.js.map +1 -0
  589. package/dist/esm/internal/RunCatalogOps.d.ts +118 -0
  590. package/dist/esm/internal/RunCatalogOps.d.ts.map +1 -0
  591. package/dist/esm/internal/RunCatalogOps.js +120 -0
  592. package/dist/esm/internal/RunCatalogOps.js.map +1 -0
  593. package/dist/esm/internal/RunCoordinator.d.ts +78 -0
  594. package/dist/esm/internal/RunCoordinator.d.ts.map +1 -0
  595. package/dist/esm/internal/RunCoordinator.js +115 -0
  596. package/dist/esm/internal/RunCoordinator.js.map +1 -0
  597. package/dist/esm/internal/RunDriver.d.ts +192 -0
  598. package/dist/esm/internal/RunDriver.d.ts.map +1 -0
  599. package/dist/esm/internal/RunDriver.js +2334 -0
  600. package/dist/esm/internal/RunDriver.js.map +1 -0
  601. package/dist/esm/internal/RunLifecycle.d.ts +22 -0
  602. package/dist/esm/internal/RunLifecycle.d.ts.map +1 -0
  603. package/dist/esm/internal/RunLifecycle.js +49 -0
  604. package/dist/esm/internal/RunLifecycle.js.map +1 -0
  605. package/dist/esm/internal/RunListing.d.ts +78 -0
  606. package/dist/esm/internal/RunListing.d.ts.map +1 -0
  607. package/dist/esm/internal/RunListing.js +146 -0
  608. package/dist/esm/internal/RunListing.js.map +1 -0
  609. package/dist/esm/internal/RunListingError.d.ts +35 -0
  610. package/dist/esm/internal/RunListingError.d.ts.map +1 -0
  611. package/dist/esm/internal/RunListingError.js +27 -0
  612. package/dist/esm/internal/RunListingError.js.map +1 -0
  613. package/dist/esm/internal/RuntimeGraph.d.ts +73 -0
  614. package/dist/esm/internal/RuntimeGraph.d.ts.map +1 -0
  615. package/dist/esm/internal/RuntimeGraph.js +182 -0
  616. package/dist/esm/internal/RuntimeGraph.js.map +1 -0
  617. package/dist/esm/internal/SandboxedExecution.d.ts +80 -0
  618. package/dist/esm/internal/SandboxedExecution.d.ts.map +1 -0
  619. package/dist/esm/internal/SandboxedExecution.js +107 -0
  620. package/dist/esm/internal/SandboxedExecution.js.map +1 -0
  621. package/dist/esm/internal/StateTransaction.d.ts +44 -0
  622. package/dist/esm/internal/StateTransaction.d.ts.map +1 -0
  623. package/dist/esm/internal/StateTransaction.js +54 -0
  624. package/dist/esm/internal/StateTransaction.js.map +1 -0
  625. package/dist/esm/internal/StepFacts.d.ts +14 -0
  626. package/dist/esm/internal/StepFacts.d.ts.map +1 -0
  627. package/dist/esm/internal/StepFacts.js +35 -0
  628. package/dist/esm/internal/StepFacts.js.map +1 -0
  629. package/dist/esm/internal/TypedEvents.d.ts +14 -0
  630. package/dist/esm/internal/TypedEvents.d.ts.map +1 -0
  631. package/dist/esm/internal/TypedEvents.js +14 -0
  632. package/dist/esm/internal/TypedEvents.js.map +1 -0
  633. package/dist/esm/migrations/0001_initial.d.ts +17 -0
  634. package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
  635. package/dist/esm/migrations/0001_initial.js +41 -0
  636. package/dist/esm/migrations/0001_initial.js.map +1 -0
  637. package/dist/esm/migrations/0002_selection_store.d.ts +15 -0
  638. package/dist/esm/migrations/0002_selection_store.d.ts.map +1 -0
  639. package/dist/esm/migrations/0002_selection_store.js +34 -0
  640. package/dist/esm/migrations/0002_selection_store.js.map +1 -0
  641. package/dist/esm/migrations/0003_plan_inputs.d.ts +13 -0
  642. package/dist/esm/migrations/0003_plan_inputs.d.ts.map +1 -0
  643. package/dist/esm/migrations/0003_plan_inputs.js +70 -0
  644. package/dist/esm/migrations/0003_plan_inputs.js.map +1 -0
  645. package/dist/esm/migrations/0004_plan_environment.d.ts +14 -0
  646. package/dist/esm/migrations/0004_plan_environment.d.ts.map +1 -0
  647. package/dist/esm/migrations/0004_plan_environment.js +33 -0
  648. package/dist/esm/migrations/0004_plan_environment.js.map +1 -0
  649. package/dist/esm/migrations/0005_plan_merges.d.ts +14 -0
  650. package/dist/esm/migrations/0005_plan_merges.d.ts.map +1 -0
  651. package/dist/esm/migrations/0005_plan_merges.js +59 -0
  652. package/dist/esm/migrations/0005_plan_merges.js.map +1 -0
  653. package/dist/esm/migrations/0006_execution_listing.d.ts +15 -0
  654. package/dist/esm/migrations/0006_execution_listing.d.ts.map +1 -0
  655. package/dist/esm/migrations/0006_execution_listing.js +81 -0
  656. package/dist/esm/migrations/0006_execution_listing.js.map +1 -0
  657. package/dist/esm/migrations/0007_run_parent_sequence.d.ts +15 -0
  658. package/dist/esm/migrations/0007_run_parent_sequence.d.ts.map +1 -0
  659. package/dist/esm/migrations/0007_run_parent_sequence.js +18 -0
  660. package/dist/esm/migrations/0007_run_parent_sequence.js.map +1 -0
  661. package/dist/esm/migrations/0008_deferred_consumption.d.ts +16 -0
  662. package/dist/esm/migrations/0008_deferred_consumption.d.ts.map +1 -0
  663. package/dist/esm/migrations/0008_deferred_consumption.js +24 -0
  664. package/dist/esm/migrations/0008_deferred_consumption.js.map +1 -0
  665. package/dist/esm/migrations/0009_deferred_clock_facts.d.ts +24 -0
  666. package/dist/esm/migrations/0009_deferred_clock_facts.d.ts.map +1 -0
  667. package/dist/esm/migrations/0009_deferred_clock_facts.js +127 -0
  668. package/dist/esm/migrations/0009_deferred_clock_facts.js.map +1 -0
  669. package/dist/esm/migrations/0010_pending_cancellation.d.ts +15 -0
  670. package/dist/esm/migrations/0010_pending_cancellation.d.ts.map +1 -0
  671. package/dist/esm/migrations/0010_pending_cancellation.js +19 -0
  672. package/dist/esm/migrations/0010_pending_cancellation.js.map +1 -0
  673. package/dist/esm/test/TestStores.d.ts +89 -0
  674. package/dist/esm/test/TestStores.d.ts.map +1 -0
  675. package/dist/esm/test/TestStores.js +103 -0
  676. package/dist/esm/test/TestStores.js.map +1 -0
  677. package/docs/README.md +113 -0
  678. package/docs/api.md +1494 -0
  679. package/docs/concepts/attempts-and-replay.md +149 -0
  680. package/docs/concepts/cache-admission.md +265 -0
  681. package/docs/concepts/call-facts.md +86 -0
  682. package/docs/concepts/durable-waits.md +175 -0
  683. package/docs/concepts/execution-facts.md +90 -0
  684. package/docs/concepts/ownership-and-fencing.md +128 -0
  685. package/docs/concepts/step-boundaries.md +148 -0
  686. package/docs/concepts/workspace-transactions.md +199 -0
  687. package/docs/event-types.md +14 -0
  688. package/docs/guides/back-up-and-restore.md +164 -0
  689. package/docs/guides/collect-unreferenced-artifacts.md +128 -0
  690. package/docs/guides/compose-a-durable-engine.md +146 -0
  691. package/docs/guides/coordinate-two-processes.md +120 -0
  692. package/docs/guides/defer-work-with-selection.md +171 -0
  693. package/docs/guides/delete-old-run-history.md +154 -0
  694. package/docs/guides/drive-a-plan.md +314 -0
  695. package/docs/guides/observe-engine-metrics.md +98 -0
  696. package/docs/guides/observe-executions.md +187 -0
  697. package/docs/guides/reclaim-runs-from-a-dead-host.md +133 -0
  698. package/docs/guides/share-a-cache-across-machines.md +134 -0
  699. package/docs/guides/testing.md +123 -0
  700. package/docs/installation.md +102 -0
  701. package/docs/quickstart.md +215 -0
  702. package/docs/troubleshooting.md +347 -0
  703. package/package.json +438 -3
  704. package/src/ArtifactGc.ts +408 -0
  705. package/src/ArtifactSync.ts +278 -0
  706. package/src/CacheSync.ts +131 -0
  707. package/src/DeferredClockFold.ts +586 -0
  708. package/src/DisasterRecovery.ts +888 -0
  709. package/src/DurableEngineState.ts +2656 -0
  710. package/src/EngineStore.ts +656 -0
  711. package/src/EngineStoreMetrics.ts +331 -0
  712. package/src/Errors.ts +28 -0
  713. package/src/EventTypes.ts +27 -0
  714. package/src/ExecutionFacts.ts +125 -0
  715. package/src/ExecutionSnapshot.ts +186 -0
  716. package/src/Inconsistency.ts +253 -0
  717. package/src/Migrations.ts +95 -0
  718. package/src/OwnerIdentity.ts +125 -0
  719. package/src/PlanInputStore.ts +292 -0
  720. package/src/PlanMergeStore.ts +330 -0
  721. package/src/PlanScheduler.ts +1806 -0
  722. package/src/Reconciliation.ts +224 -0
  723. package/src/ReplayOnly.ts +95 -0
  724. package/src/Retention.ts +214 -0
  725. package/src/RunCatalogRead.ts +27 -0
  726. package/src/RunChangeFeed.ts +125 -0
  727. package/src/RunState.ts +137 -0
  728. package/src/Selection.ts +683 -0
  729. package/src/SelectionStore.ts +353 -0
  730. package/src/StepBoundary.ts +1165 -0
  731. package/src/StepCacheFold.ts +244 -0
  732. package/src/StepSandbox.ts +110 -0
  733. package/src/WakeBus.ts +167 -0
  734. package/src/WorkspaceSandbox.ts +1604 -0
  735. package/src/index.ts +185 -0
  736. package/src/internal/ActionPersistence.ts +2687 -0
  737. package/src/internal/ArtifactRoots.ts +92 -0
  738. package/src/internal/AttemptAdmission.ts +76 -0
  739. package/src/internal/AttemptLifecycle.ts +163 -0
  740. package/src/internal/AttemptProbe.ts +90 -0
  741. package/src/internal/CacheAdmission.ts +133 -0
  742. package/src/internal/CacheAgeHistory.ts +58 -0
  743. package/src/internal/CacheAgeVerdicts.ts +61 -0
  744. package/src/internal/CacheOutputPolicy.ts +82 -0
  745. package/src/internal/CachePublication.ts +153 -0
  746. package/src/internal/CallFacts.ts +87 -0
  747. package/src/internal/CopiedRecord.ts +201 -0
  748. package/src/internal/DeferredPersistence.ts +459 -0
  749. package/src/internal/EffectRecords.ts +136 -0
  750. package/src/internal/EngineJj.ts +30 -0
  751. package/src/internal/EngineStateSchema.ts +92 -0
  752. package/src/internal/ExecutionSnapshotRead.ts +298 -0
  753. package/src/internal/ExecutionSnapshotRelations.ts +121 -0
  754. package/src/internal/ExitEncoding.ts +453 -0
  755. package/src/internal/FileBoundarySnapshot.ts +39 -0
  756. package/src/internal/FileEnumeration.ts +334 -0
  757. package/src/internal/HostReflection.ts +128 -0
  758. package/src/internal/JournalRecords.ts +396 -0
  759. package/src/internal/NodeJournal.ts +340 -0
  760. package/src/internal/Ordering.ts +14 -0
  761. package/src/internal/PlanInputs.ts +62 -0
  762. package/src/internal/PlanMerges.ts +123 -0
  763. package/src/internal/ProvenanceSlot.ts +52 -0
  764. package/src/internal/ResultEnvelope.ts +118 -0
  765. package/src/internal/RetentionOps.ts +865 -0
  766. package/src/internal/RunCatalogOps.ts +174 -0
  767. package/src/internal/RunCoordinator.ts +215 -0
  768. package/src/internal/RunDriver.ts +3152 -0
  769. package/src/internal/RunLifecycle.ts +53 -0
  770. package/src/internal/RunListing.ts +210 -0
  771. package/src/internal/RunListingError.ts +37 -0
  772. package/src/internal/RuntimeGraph.ts +253 -0
  773. package/src/internal/SandboxedExecution.ts +165 -0
  774. package/src/internal/StateTransaction.ts +71 -0
  775. package/src/internal/StepFacts.ts +36 -0
  776. package/src/internal/TypedEvents.ts +29 -0
  777. package/src/migrations/0001_initial.ts +51 -0
  778. package/src/migrations/0002_selection_store.ts +38 -0
  779. package/src/migrations/0003_plan_inputs.ts +75 -0
  780. package/src/migrations/0004_plan_environment.ts +34 -0
  781. package/src/migrations/0005_plan_merges.ts +60 -0
  782. package/src/migrations/0006_execution_listing.ts +86 -0
  783. package/src/migrations/0007_run_parent_sequence.ts +19 -0
  784. package/src/migrations/0008_deferred_consumption.ts +27 -0
  785. package/src/migrations/0009_deferred_clock_facts.ts +163 -0
  786. package/src/migrations/0010_pending_cancellation.ts +20 -0
  787. package/src/test/TestStores.ts +145 -0
@@ -0,0 +1,865 @@
1
+ /**
2
+ * Retention: the one operation that deletes finished run state.
3
+ *
4
+ * Nothing in the composition removed a `flows_runs` row or anything that hangs
5
+ * off one. Every run a workspace ever finished stayed in `.flows/engine.db`
6
+ * with its attempts, its persisted deferred completions and clock deadlines,
7
+ * its journal entries, and its checkpoints, and journal compaction is off by
8
+ * default (`SqlJournal` `Options.compaction`), so the file only grew. This
9
+ * module is the deletion side, and the whole of it: one operation, run
10
+ * explicitly.
11
+ *
12
+ * Three properties make it safe to run against a live workspace.
13
+ *
14
+ * - **One transaction.** Every delete runs inside a single `journal.transact`,
15
+ * so a crash leaves either a run with all of its rows or none of them —
16
+ * never a run row whose history is gone, or history whose run row is gone.
17
+ * - **Terminal and aged only.** A run is a candidate only when its status is
18
+ * `completed`, `failed`, or `cancelled` AND it finished before the cutoff.
19
+ * A running, pending, or suspended run is never a candidate at any age.
20
+ * - **Nothing a live run still needs.** A candidate is retained when a live
21
+ * run stands on either side of it in the lineage, over BOTH relations that
22
+ * make one run the parent of another: the `flows_run_parents` edge a spawned
23
+ * child is recorded under, and the reserved `parent_run_id` column the
24
+ * rounds of one trampoline lineage are chained through. Upward: an aged
25
+ * terminal run with a live ancestor stays, because a parent reads a settled
26
+ * child's result out of its run row (`agent/await`) and a parent parked on
27
+ * an approval, a deferred, or a timer can be parked for longer than the
28
+ * threshold before it ever asks. Downward: an aged terminal run whose
29
+ * descendant is still live stays, because deleting it would leave that
30
+ * descendant's `parent_run_id` pointing at nothing and would drop the live
31
+ * descendant's lineage edges with the `flows_run_parents_gc` trigger.
32
+ * - **Explicit.** Nothing schedules this. Automatic retention stays opt-in,
33
+ * for the reason `ArtifactGc` states: deletion is the irreversible
34
+ * direction, and a human approving a plan must be approving the deletions.
35
+ *
36
+ * Journal history is deleted outright rather than compacted to a checkpoint.
37
+ * `Journal.checkpoint` and `Journal.compact` are owner-fenced — `SqlJournal`'s
38
+ * `fenceGuard` requires a consensus lease held by the exact owner passed in —
39
+ * so neither can be called for a finished, ownerless run at all. Deleting the run's entries and checkpoints is strictly stronger than
40
+ * compacting them to a checkpoint, and it happens in the same transaction as
41
+ * the run row, which is the property a compaction could not have given.
42
+ *
43
+ * The operation is idempotent. With a positive integer limit and a fixed,
44
+ * finite, acyclic run lineage, each successful non-dry pass deletes at least
45
+ * one collectable run until none remain. Continuation children are selected
46
+ * before parents; parents pinned by excluded children do not consume the
47
+ * bound. Runs protected by age or live lineage remain until eligible.
48
+ *
49
+ * @since 0.1.0
50
+ */
51
+
52
+ import * as Dialect from "@smthrs/database/Dialect"
53
+ import * as Journal from "@smthrs/journal/Journal"
54
+ import * as JournalEvent from "@smthrs/journal/JournalEvent"
55
+ import * as RunStore from "@smthrs/run-store/RunStore"
56
+ import * as Clock from "effect/Clock"
57
+ import * as Context from "effect/Context"
58
+ import * as Effect from "effect/Effect"
59
+ import * as Layer from "effect/Layer"
60
+ import * as Schema from "effect/Schema"
61
+ import * as SqlClient from "effect/unstable/sql/SqlClient"
62
+ import type { SqlError } from "effect/unstable/sql/SqlError"
63
+
64
+ /**
65
+ * Stable error codes returned by retention.
66
+ *
67
+ * @category models
68
+ * @since 0.1.0
69
+ */
70
+ export const RetentionErrorCode = Schema.Literals(["scan_failed", "delete_failed"])
71
+
72
+ /**
73
+ * Stable error codes returned by retention.
74
+ *
75
+ * @category models
76
+ * @since 0.1.0
77
+ */
78
+ export type RetentionErrorCode = typeof RetentionErrorCode.Type
79
+
80
+ /**
81
+ * A retention pass that could not complete.
82
+ *
83
+ * `scan_failed` means the candidate set could not be computed and nothing was
84
+ * deleted. `delete_failed` means the candidate set held but a delete refused;
85
+ * the transaction rolled back, so nothing was deleted then either, and
86
+ * re-running converges once the cause is fixed.
87
+ *
88
+ * @category errors
89
+ * @since 0.1.0
90
+ */
91
+ export class RetentionError extends Schema.TaggedError<RetentionError>()(
92
+ "@smthrs/engine-store/RetentionError",
93
+ {
94
+ code: RetentionErrorCode,
95
+ message: Schema.String,
96
+ cause: Schema.optional(Schema.Unknown)
97
+ }
98
+ ) {}
99
+
100
+ /**
101
+ * Options for one retention pass.
102
+ *
103
+ * @category models
104
+ * @since 0.1.0
105
+ */
106
+ export interface RetainOptions {
107
+ /**
108
+ * How long a run must have been finished to be collected, in milliseconds.
109
+ * A run's age is measured from `finished_at_ms`, or from `created_at_ms`
110
+ * for a terminal row that never recorded one. Zero collects every terminal
111
+ * run; a negative value is read as zero.
112
+ */
113
+ readonly olderThanMs: number
114
+ /**
115
+ * Largest number of runs one pass deletes. Defaults to
116
+ * {@link defaultLimit}. Retention is idempotent, so a workspace with more
117
+ * aged runs than the bound converges over repeated passes instead of
118
+ * holding one long write transaction open. A negative value is read as
119
+ * zero, so a pass under a mistyped bound deletes nothing.
120
+ */
121
+ readonly limit?: number | undefined
122
+ /** Compute and report the pass without deleting anything. */
123
+ readonly dryRun?: boolean | undefined
124
+ }
125
+
126
+ /**
127
+ * What one retention pass did, or — under `dryRun` — would do.
128
+ *
129
+ * @category models
130
+ * @since 0.1.0
131
+ */
132
+ export interface RetainReport {
133
+ /** Runs finished at or before this instant were candidates. */
134
+ readonly cutoffMs: number
135
+ /** The runs deleted, oldest first. */
136
+ readonly runIds: ReadonlyArray<string>
137
+ /**
138
+ * Aged terminal runs left in place because a descendant of theirs is not
139
+ * terminal, or is terminal and is not being deleted by this pass. They
140
+ * become collectable once that descendant is. At most `limit` of them are
141
+ * reported, the oldest first, so the report costs no more than the pass.
142
+ */
143
+ readonly retainedForLiveDescendants: ReadonlyArray<string>
144
+ /**
145
+ * Aged terminal runs left in place because an ancestor of theirs is not
146
+ * terminal. That ancestor can still read the run's settled result through
147
+ * `agent/await`, which answers out of the run row. They become collectable
148
+ * once every ancestor is terminal — a terminal ancestor holds nothing back,
149
+ * whatever its own age. A run retained for both reasons is reported under
150
+ * {@link retainedForLiveDescendants}, and at most `limit` runs are reported.
151
+ */
152
+ readonly retainedForLiveAncestors: ReadonlyArray<string>
153
+ readonly runs: number
154
+ readonly attempts: number
155
+ readonly clockDeadlines: number
156
+ readonly deferredCompletions: number
157
+ readonly journalEntries: number
158
+ readonly journalCheckpoints: number
159
+ /** Producer identities journal compaction kept after deleting event payloads. */
160
+ readonly journalIdentities: number
161
+ /** Time-travel archive rows; always zero where that table is not installed. */
162
+ readonly archiveEntries: number
163
+ /** Time-travel receipt rows reached through their audits. */
164
+ readonly timeTravelReceipts: number
165
+ readonly dryRun: boolean
166
+ }
167
+
168
+ /**
169
+ * Explicit run retention.
170
+ *
171
+ * @category models
172
+ * @since 0.1.0
173
+ */
174
+ export interface Service {
175
+ /**
176
+ * Deletes up to `limit` aged terminal runs and their dependents atomically.
177
+ * With a positive integer limit and a fixed, finite, acyclic lineage, each
178
+ * successful non-dry pass makes progress until all collectable runs are gone,
179
+ * including continuation chains longer than the bound. Age and live-lineage
180
+ * protection still apply. Explicit only; nothing schedules this operation.
181
+ */
182
+ readonly retain: (
183
+ options: RetainOptions
184
+ ) => Effect.Effect<RetainReport, RetentionError | Journal.JournalError>
185
+ }
186
+
187
+ /**
188
+ * Service tag for run retention.
189
+ *
190
+ * @category services
191
+ * @since 0.1.0
192
+ */
193
+ export class Retention extends Context.Service<Retention, Service>()("@smthrs/engine-store/Retention") {}
194
+
195
+ /**
196
+ * Runs deleted by one pass when the caller names no bound. Large enough that
197
+ * an ordinary workspace finishes in one pass, small enough that the write
198
+ * transaction stays short on a workspace that has never been collected.
199
+ *
200
+ * @category constants
201
+ * @since 0.1.0
202
+ */
203
+ export const defaultLimit = 1000
204
+
205
+ /**
206
+ * Run ids per `IN (...)` list. SQLite's default host-parameter ceiling is 999.
207
+ *
208
+ * @category constants
209
+ * @since 0.1.0
210
+ */
211
+ const chunkSize = 500
212
+
213
+ /**
214
+ * One table a deleted run leaves rows in.
215
+ *
216
+ * @category models
217
+ * @since 1.0.0
218
+ */
219
+ export interface RunScopedTable {
220
+ readonly table: string
221
+ /** The column naming the run. */
222
+ readonly column: string
223
+ /**
224
+ * Whether the migration ladder this package composes installs the table.
225
+ *
226
+ * A ladder table missing from an engine database is a broken schema, so
227
+ * {@link installedTables} can be asked to keep it and let the delete refuse.
228
+ * A table beyond the ladder belongs to a store the host may simply not have
229
+ * composed, and is skipped when the catalog does not list it.
230
+ */
231
+ readonly ladder: boolean
232
+ /**
233
+ * Whether the table also holds the runs' journal companion streams
234
+ * (`JournalEvent.companionRunId`), which name a run through a derived id
235
+ * rather than the run id itself. {@link companionStreams} lists them.
236
+ */
237
+ readonly companions?: boolean | undefined
238
+ }
239
+
240
+ /**
241
+ * The journal companion streams a run owns beside its own stream. A deleted
242
+ * run's companion streams go with it.
243
+ *
244
+ * @category constants
245
+ * @since 1.0.0
246
+ */
247
+ export const companionStreams: ReadonlyArray<string> = [RunStore.companionStream]
248
+
249
+ /**
250
+ * Every table a deleted run leaves rows in, and the column naming the run.
251
+ *
252
+ * ONE inventory, because two passes read it: {@link Service.retain} over the
253
+ * engine ladder, and `Retention.collect` over whatever a host's file holds. A
254
+ * table listed by only one of them is a table the other leaks forever. Tables
255
+ * are listed rather than discovered from foreign keys because the set spans
256
+ * six packages that migrate into one database, and a silently missing entry is
257
+ * exactly that leak.
258
+ *
259
+ * The run rows themselves are not here: they go last and in generation order,
260
+ * which {@link deleteRuns} does after this list.
261
+ * `flows_time_travel_receipts` is reached through its audit rather than listed
262
+ * here because the upstream table has no run column: its `audit_id` points to
263
+ * `flows_time_travel_audits.id`, whose row carries `run_id`.
264
+ *
265
+ * @category constants
266
+ * @since 0.1.0
267
+ */
268
+ export const runScopedTables: ReadonlyArray<RunScopedTable> = [
269
+ { table: "flows_deferred_completions", column: "execution_id", ladder: true },
270
+ { table: "flows_clock_deadlines", column: "execution_id", ladder: true },
271
+ { table: "flows_attempts", column: "run_id", ladder: true },
272
+ { table: "flows_journal_events", column: "run_id", ladder: true, companions: true },
273
+ { table: "flows_journal_checkpoints", column: "run_id", ladder: true, companions: true },
274
+ { table: "flows_journal_dedup", column: "run_id", ladder: true, companions: true },
275
+ { table: "flows_consensus_leases", column: "run_id", ladder: true },
276
+ { table: "flows_step_cache_recorded", column: "recorded_run_id", ladder: true },
277
+ { table: "flows_time_travel_archive", column: "run_id", ladder: false },
278
+ { table: "flows_time_travel_snapshots", column: "run_id", ladder: false },
279
+ { table: "flows_time_travel_audits", column: "run_id", ladder: false },
280
+ { table: "flows_time_travel_edges", column: "child_run_id", ladder: false },
281
+ { table: "control_run_messages", column: "run_id", ladder: false },
282
+ { table: "control_runs", column: "run_id", ladder: false }
283
+ ]
284
+
285
+ /**
286
+ * The statuses a run can never leave.
287
+ *
288
+ * @category constants
289
+ * @since 1.0.0
290
+ */
291
+ export const terminalStatuses: ReadonlyArray<string> = ["completed", "failed", "cancelled"]
292
+
293
+ /** `terminalStatuses` as a SQL list, for the lineage prelude below. */
294
+ const terminalList = terminalStatuses.map((status) => `'${status}'`).join(", ")
295
+
296
+ /**
297
+ * The prelude every scan opens with: which runs a live run stands above, and
298
+ * which it stands below.
299
+ *
300
+ * Two relations make one run the parent of another, and a walk over either one
301
+ * alone misses half the lineage. A SPAWNED child records its parent as a
302
+ * `flows_run_parents` edge, one row per parent so a diamond records both, and
303
+ * leaves `parent_run_id` NULL: the engine reserves that column for the rounds
304
+ * of one trampoline lineage (`RunDriver.continueLineage`). The edge is the
305
+ * relation every `agent/await` depends on. `link` is both relations as one
306
+ * edge list.
307
+ *
308
+ * `under_live` is every run reachable downward from a run that is not
309
+ * terminal. Those runs have a live ancestor, which can still read a settled
310
+ * result out of their run row. `over_live` is every run reachable upward from
311
+ * one. Those runs have a live descendant, whose own lineage the
312
+ * `flows_run_parents_gc` trigger would drop with them. An edge whose parent
313
+ * row is gone is not reachable from `live` at all, so it holds nothing back,
314
+ * and since only terminal runs are ever deleted it never can.
315
+ *
316
+ * The walks carry run ids and nothing else, so `UNION` makes them terminate on
317
+ * their own: a corrupt edge that closed a cycle adds a row the set already
318
+ * holds, and the walk stops. That matters because these reads run inside the
319
+ * pass's write transaction. They are SQLite-specific, like the `sqlite_master`
320
+ * probe below, and rc.0 is SQLite-only.
321
+ *
322
+ * `parentEdges: false` drops the `flows_run_parents` half of `link`. A
323
+ * database that carries the run rows but not the engine's edge table — the
324
+ * control plane's, which migrates the run store and the journal and nothing
325
+ * else — has no edges to walk, and reading the missing table would fail the
326
+ * whole scan. The `parent_run_id` half still runs, so the continuation
327
+ * lineage is guarded there too. The retention pass itself always walks both.
328
+ *
329
+ * @category constructors
330
+ * @since 0.1.0
331
+ */
332
+ export const lineagePrelude = (
333
+ options: { readonly parentEdges: boolean }
334
+ ): string => `
335
+ WITH RECURSIVE
336
+ link(child_id, parent_id) AS (
337
+ ${
338
+ options.parentEdges
339
+ ? `SELECT child_id, parent_id FROM flows_run_parents
340
+ UNION
341
+ `
342
+ : ``
343
+ }SELECT run_id, parent_run_id FROM flows_runs WHERE parent_run_id IS NOT NULL
344
+ ),
345
+ live(run_id) AS (
346
+ SELECT run_id FROM flows_runs WHERE status NOT IN (${terminalList})
347
+ ),
348
+ under_live(run_id) AS (
349
+ SELECT link.child_id FROM link JOIN live ON live.run_id = link.parent_id
350
+ UNION
351
+ SELECT link.child_id FROM link JOIN under_live ON under_live.run_id = link.parent_id
352
+ ),
353
+ over_live(run_id) AS (
354
+ SELECT link.parent_id FROM link JOIN live ON live.run_id = link.child_id
355
+ UNION
356
+ SELECT link.parent_id FROM link JOIN over_live ON over_live.run_id = link.child_id
357
+ )
358
+ `
359
+
360
+ /**
361
+ * The bound one pass may delete, as both passes read it.
362
+ *
363
+ * Clamped, not interpolated: SQLite reads a negative `LIMIT` as no limit at
364
+ * all, which would make a mistyped bound a full sweep, and rejects `NaN` or a
365
+ * fraction as a datatype mismatch. Anything that is not a non-negative safe
366
+ * integer is read as zero, so the pass deletes nothing.
367
+ *
368
+ * @category constructors
369
+ * @since 1.0.0
370
+ */
371
+ export const normalizeLimit = (limit: number | undefined): number => {
372
+ const bound = limit ?? defaultLimit
373
+ return Number.isSafeInteger(bound) && bound >= 0 ? bound : 0
374
+ }
375
+
376
+ /**
377
+ * Which runs a pass may delete, and which it must keep, as CTEs.
378
+ *
379
+ * `eligible` is every terminal run older than the cutoff that no live run
380
+ * stands above or below. `blocked` is every other run plus every ancestor of
381
+ * one over `parent_run_id`: a continuation parent must outlive every child
382
+ * excluded by age or live lineage, and this propagates that exclusion before
383
+ * any bound is applied. `inclusive` says whether a run finished exactly at
384
+ * the cutoff is old enough.
385
+ */
386
+ const scanPrelude = (
387
+ sql: SqlClient.SqlClient,
388
+ options: {
389
+ readonly cutoffMs: number
390
+ readonly inclusive: boolean
391
+ readonly parentEdges: boolean
392
+ readonly pins?: ReadonlyArray<string> | undefined
393
+ }
394
+ ) =>
395
+ sql`
396
+ ${sql.unsafe(lineagePrelude({ parentEdges: options.parentEdges }))},
397
+ eligible(run_id) AS (
398
+ SELECT run_id FROM flows_runs
399
+ WHERE ${sql.in("status", terminalStatuses)}
400
+ AND ${
401
+ options.inclusive
402
+ ? sql`COALESCE(finished_at_ms, created_at_ms) <= ${options.cutoffMs}`
403
+ : sql`COALESCE(finished_at_ms, created_at_ms) < ${options.cutoffMs}`
404
+ }
405
+ AND run_id NOT IN (SELECT run_id FROM under_live)
406
+ AND run_id NOT IN (SELECT run_id FROM over_live)
407
+ AND ${
408
+ options.pins === undefined || options.pins.length === 0 ?
409
+ sql.literal("1 = 1")
410
+ : sql`run_id NOT IN ${sql.in(options.pins)}`
411
+ }
412
+ ),
413
+ blocked(run_id) AS (
414
+ SELECT run_id FROM flows_runs WHERE run_id NOT IN (SELECT run_id FROM eligible)
415
+ UNION
416
+ SELECT runs.parent_run_id FROM flows_runs AS runs
417
+ JOIN blocked ON blocked.run_id = runs.run_id
418
+ WHERE runs.parent_run_id IS NOT NULL
419
+ )
420
+ `
421
+
422
+ /**
423
+ * The runs one pass deletes: at most `limit` of them, children before parents.
424
+ *
425
+ * The one candidate query, shared by {@link Service.retain} and
426
+ * `Retention.collect`. A trampoline parent always finishes before its
427
+ * successor, so an oldest-first window over a lineage longer than the bound
428
+ * held only ancestors, each pinned by the round just outside the window, and
429
+ * every later pass selected the same window and deleted nothing. Depth walks
430
+ * from roots, visiting each continuation row once; corrupt cycles have no
431
+ * root and cannot enter the deletion set. Excluded runs and their ancestors
432
+ * are dropped before the bound, so pinned parents cannot consume it. The
433
+ * result is presented oldest first.
434
+ *
435
+ * @category getters
436
+ * @since 1.0.0
437
+ */
438
+ export const candidatesOf = (
439
+ sql: SqlClient.SqlClient,
440
+ options: {
441
+ readonly cutoffMs: number
442
+ readonly inclusive: boolean
443
+ readonly parentEdges: boolean
444
+ readonly pins?: ReadonlyArray<string> | undefined
445
+ readonly limit: number
446
+ }
447
+ ): Effect.Effect<ReadonlyArray<Candidate>, SqlError> =>
448
+ sql<{ readonly run_id: string; readonly parent_run_id: string | null }>`
449
+ ${scanPrelude(sql, options)},
450
+ depths(run_id, depth) AS (
451
+ SELECT run_id, 0 FROM flows_runs WHERE parent_run_id IS NULL
452
+ UNION ALL
453
+ SELECT runs.run_id, depths.depth + 1 FROM flows_runs AS runs
454
+ JOIN depths ON runs.parent_run_id = depths.run_id
455
+ ),
456
+ selected AS (
457
+ SELECT runs.run_id, runs.parent_run_id,
458
+ COALESCE(runs.finished_at_ms, runs.created_at_ms) AS finished_at_ms
459
+ FROM flows_runs AS runs JOIN depths ON depths.run_id = runs.run_id
460
+ WHERE runs.run_id NOT IN (SELECT run_id FROM blocked)
461
+ ORDER BY depths.depth DESC, COALESCE(runs.finished_at_ms, runs.created_at_ms), runs.run_id
462
+ LIMIT ${normalizeLimit(options.limit)}
463
+ )
464
+ SELECT run_id, parent_run_id FROM selected ORDER BY finished_at_ms, run_id
465
+ `.pipe(
466
+ Effect.map((rows): ReadonlyArray<Candidate> =>
467
+ rows.map((row) => ({ runId: row.run_id, parentRunId: row.parent_run_id }))
468
+ )
469
+ )
470
+
471
+ /** Classifies a read of the scan phase, where nothing has been deleted yet. */
472
+ const scanning = (what: string) => (cause: unknown): RetentionError =>
473
+ new RetentionError({ code: "scan_failed", message: `${what} could not be read`, cause })
474
+
475
+ /** Classifies a statement of the delete phase, which rolls the pass back. */
476
+ const deleting = (what: string) => (cause: unknown): RetentionError =>
477
+ new RetentionError({ code: "delete_failed", message: `${what} could not be collected`, cause })
478
+
479
+ const chunksOf = (ids: ReadonlyArray<string>): ReadonlyArray<ReadonlyArray<string>> => {
480
+ const chunks: Array<ReadonlyArray<string>> = []
481
+ for (let offset = 0; offset < ids.length; offset += chunkSize) {
482
+ chunks.push(ids.slice(offset, offset + chunkSize))
483
+ }
484
+ return chunks
485
+ }
486
+
487
+ /**
488
+ * A run a pass proposes to delete, and the run it names as its parent.
489
+ *
490
+ * @category models
491
+ * @since 0.1.0
492
+ */
493
+ export interface Candidate {
494
+ readonly runId: string
495
+ readonly parentRunId: string | null
496
+ }
497
+
498
+ /** A run and the candidate it names as its parent. */
499
+ interface ChildEdge {
500
+ readonly runId: string
501
+ readonly parentRunId: string
502
+ }
503
+
504
+ /**
505
+ * What one deletion pass removed, or would remove under `dryRun`.
506
+ *
507
+ * @category models
508
+ * @since 0.1.0
509
+ */
510
+ export interface DeletionReport {
511
+ /** The candidates deleted, in the order they were given. */
512
+ readonly runIds: ReadonlyArray<string>
513
+ /** Candidates kept because a run outside the pass still names them. */
514
+ readonly pinned: ReadonlyArray<string>
515
+ /**
516
+ * Rows counted per table, `flows_runs` included, zeroes omitted. Counted
517
+ * whether or not the pass deletes, so a dry run reports the same numbers.
518
+ */
519
+ readonly deleted: Readonly<Record<string, number>>
520
+ }
521
+
522
+ /** Reads the installed SQLite table names once for inventory decisions. */
523
+ const installedTableNames = (sql: SqlClient.SqlClient): Effect.Effect<ReadonlySet<string>, RetentionError> =>
524
+ Dialect.tables(sql).pipe(
525
+ Effect.map((rows) => new Set(rows.map((row) => row.name))),
526
+ Effect.mapError(scanning("the schema catalog"))
527
+ )
528
+
529
+ /**
530
+ * The {@link runScopedTables} entries this database actually has.
531
+ *
532
+ * `assumeLadder` keeps every entry the ladder installs whether the catalog
533
+ * lists it or not. {@link Service.retain} passes `true`: this package composes
534
+ * the run-store, journal, step-cache and engine migrations, so a ladder table
535
+ * missing from the file it is pointed at is a broken schema, and a delete that
536
+ * refuses says so. `Retention.collect` passes `false`, because it also runs
537
+ * against the control plane's database, which migrates the run store and the
538
+ * journal and nothing else; there a missing ladder table is a host that
539
+ * composed fewer stores, and the pass still owes it a complete sweep of what
540
+ * it has.
541
+ *
542
+ * The catalog read is SQLite-specific, like the lineage prelude above and the
543
+ * `flows_run_parents_gc` trigger this package ships. rc.0 is SQLite-only.
544
+ *
545
+ * @category getters
546
+ * @since 0.1.0
547
+ */
548
+ export const installedTables = (
549
+ sql: SqlClient.SqlClient,
550
+ options: { readonly assumeLadder: boolean }
551
+ ): Effect.Effect<ReadonlyArray<RunScopedTable>, RetentionError> =>
552
+ installedTableNames(sql).pipe(
553
+ Effect.map((present) =>
554
+ runScopedTables.filter((entry) => (options.assumeLadder && entry.ladder) || present.has(entry.table))
555
+ )
556
+ )
557
+
558
+ const countIn = (sql: SqlClient.SqlClient, table: string, column: string, ids: ReadonlyArray<string>) =>
559
+ Effect.reduce(chunksOf(ids), () => 0, (total, chunk) =>
560
+ sql<{ readonly total: number }>`
561
+ SELECT COUNT(*) AS total FROM ${sql.unsafe(table)} WHERE ${sql.in(column, chunk)}
562
+ `.pipe(
563
+ Effect.map((rows) => rows.reduce((sum, row) => sum + Number(row.total), total)),
564
+ Effect.mapError(deleting(table))
565
+ ))
566
+
567
+ const deleteIn = (sql: SqlClient.SqlClient, table: string, column: string, ids: ReadonlyArray<string>) =>
568
+ Effect.forEach(
569
+ chunksOf(ids),
570
+ (chunk) =>
571
+ sql`DELETE FROM ${sql.unsafe(table)} WHERE ${sql.in(column, chunk)}`.pipe(
572
+ Effect.mapError(deleting(table))
573
+ ),
574
+ { discard: true }
575
+ )
576
+
577
+ const countTimeTravelReceipts = (sql: SqlClient.SqlClient, ids: ReadonlyArray<string>) =>
578
+ Effect.reduce(chunksOf(ids), () => 0, (total, chunk) =>
579
+ sql<{ readonly total: number }>`
580
+ SELECT COUNT(*) AS total
581
+ FROM flows_time_travel_receipts
582
+ WHERE audit_id IN (
583
+ SELECT id FROM flows_time_travel_audits WHERE ${sql.in("run_id", chunk)}
584
+ )
585
+ `.pipe(
586
+ Effect.map((rows) => rows.reduce((sum, row) => sum + Number(row.total), total)),
587
+ Effect.mapError(deleting("flows_time_travel_receipts"))
588
+ ))
589
+
590
+ const deleteTimeTravelReceipts = (sql: SqlClient.SqlClient, ids: ReadonlyArray<string>) =>
591
+ Effect.forEach(
592
+ chunksOf(ids),
593
+ (chunk) =>
594
+ sql`
595
+ DELETE FROM flows_time_travel_receipts
596
+ WHERE audit_id IN (
597
+ SELECT id FROM flows_time_travel_audits WHERE ${sql.in("run_id", chunk)}
598
+ )
599
+ `.pipe(Effect.mapError(deleting("flows_time_travel_receipts"))),
600
+ { discard: true }
601
+ )
602
+
603
+ /** Every run whose parent is a candidate, candidates included. */
604
+ const childrenOf = (sql: SqlClient.SqlClient, candidateIds: ReadonlyArray<string>) =>
605
+ Effect.reduce(
606
+ chunksOf(candidateIds),
607
+ (): Array<ChildEdge> => [],
608
+ (accumulated, chunk) =>
609
+ // `parent_run_id` is the match predicate, so every row this returns
610
+ // has one.
611
+ sql<{ readonly run_id: string; readonly parent_run_id: string }>`
612
+ SELECT run_id, parent_run_id FROM flows_runs WHERE ${sql.in("parent_run_id", chunk)}
613
+ `.pipe(
614
+ Effect.map((rows) => {
615
+ for (const row of rows) {
616
+ accumulated.push({ runId: row.run_id, parentRunId: row.parent_run_id })
617
+ }
618
+ return accumulated
619
+ }),
620
+ Effect.mapError(scanning("the run lineage"))
621
+ )
622
+ )
623
+
624
+ /**
625
+ * Drops from `doomed` every candidate that must outlive this pass, and
626
+ * every ancestor of one.
627
+ *
628
+ * A candidate whose child is not being deleted has to stay: `flows_runs`
629
+ * carries a self-referential foreign key on `parent_run_id`, so deleting
630
+ * it would orphan a row that still exists. Retention is upward-closed for
631
+ * the same reason — once a candidate is retained, the candidate it points
632
+ * at is still referenced and is retained too.
633
+ */
634
+ const pinAncestors = (
635
+ doomed: Set<string>,
636
+ retained: Set<string>,
637
+ parentOf: ReadonlyMap<string, string | null>,
638
+ from: string
639
+ ): void => {
640
+ let current: string | undefined = from
641
+ while (current !== undefined && doomed.has(current)) {
642
+ doomed.delete(current)
643
+ retained.add(current)
644
+ current = parentOf.get(current) ?? undefined
645
+ }
646
+ }
647
+
648
+ /**
649
+ * Groups the doomed runs so that no group holds a run and one of its
650
+ * doomed descendants. Deleting a parent while its child row still exists
651
+ * violates the foreign key, and SQLite evaluates it per row rather than at
652
+ * commit, so the delete runs deepest generation first.
653
+ */
654
+ const generations = (
655
+ doomed: ReadonlySet<string>,
656
+ parentOf: ReadonlyMap<string, string | null>
657
+ ): ReadonlyArray<ReadonlyArray<string>> => {
658
+ const depths = new Map<string, number>()
659
+ const depthOf = (runId: string): number => {
660
+ const known = depths.get(runId)
661
+ if (known !== undefined) return known
662
+ const parent = parentOf.get(runId) ?? undefined
663
+ const depth = parent !== undefined && doomed.has(parent) ? depthOf(parent) + 1 : 0
664
+ depths.set(runId, depth)
665
+ return depth
666
+ }
667
+ const byDepth = new Map<number, Array<string>>()
668
+ for (const runId of doomed) {
669
+ const depth = depthOf(runId)
670
+ const bucket = byDepth.get(depth)
671
+ if (bucket === undefined) byDepth.set(depth, [runId])
672
+ else bucket.push(runId)
673
+ }
674
+ return Array.from(byDepth.keys())
675
+ .sort((left, right) => right - left)
676
+ .map((depth) => byDepth.get(depth)!)
677
+ }
678
+
679
+ /**
680
+ * Deletes `candidates` and every row the inventory says names them.
681
+ *
682
+ * The one deletion in this package. Both passes call it, so neither can be
683
+ * holding a shorter table list than the other, and neither can be deleting
684
+ * run rows in an order the self-referential foreign key refuses: a handoff
685
+ * parent always sorts before its successor, so a pass that deleted in age
686
+ * order broke as soon as one lineage straddled a chunk boundary.
687
+ *
688
+ * The caller owns the transaction. Nothing here is atomic on its own, and a
689
+ * pass that removed the dependents of every candidate and then refused on the
690
+ * run rows would have destroyed history it could not put back.
691
+ *
692
+ * @category constructors
693
+ * @since 0.1.0
694
+ */
695
+ export const deleteRuns = (
696
+ sql: SqlClient.SqlClient,
697
+ candidates: ReadonlyArray<Candidate>,
698
+ options: { readonly dryRun: boolean; readonly assumeLadder: boolean }
699
+ ): Effect.Effect<DeletionReport, RetentionError> =>
700
+ Effect.gen(function*() {
701
+ const installed = yield* installedTableNames(sql)
702
+ const tables = runScopedTables.filter((entry) =>
703
+ (options.assumeLadder && entry.ladder) || installed.has(entry.table)
704
+ )
705
+ const hasTimeTravelReceipts = installed.has("flows_time_travel_receipts") &&
706
+ installed.has("flows_time_travel_audits")
707
+ const candidateIds = candidates.map((candidate) => candidate.runId)
708
+ const parentOf = new Map(candidates.map((candidate) => [candidate.runId, candidate.parentRunId]))
709
+ const doomed = new Set(candidateIds)
710
+ const pinned = new Set<string>()
711
+ const candidateSet = new Set(candidateIds)
712
+ // The foreign key, which no lineage filter covers: a child row that is
713
+ // terminal and simply outside this pass — younger than the cutoff, or past
714
+ // the bound — still points at its parent.
715
+ for (const child of yield* childrenOf(sql, candidateIds)) {
716
+ if (candidateSet.has(child.runId)) continue
717
+ pinAncestors(doomed, pinned, parentOf, child.parentRunId)
718
+ }
719
+ // `candidates` arrives oldest first, so this reads in the order the pass
720
+ // collected.
721
+ const runIds = candidateIds.filter((runId) => doomed.has(runId))
722
+
723
+ const companionIds = runIds.flatMap((runId) =>
724
+ companionStreams.map((stream) => JournalEvent.companionRunId(stream, runId))
725
+ )
726
+ const idsFor = (entry: RunScopedTable): ReadonlyArray<string> =>
727
+ entry.companions === true ? [...runIds, ...companionIds] : runIds
728
+
729
+ const deleted: Record<string, number> = {}
730
+ if (hasTimeTravelReceipts) {
731
+ const total = yield* countTimeTravelReceipts(sql, runIds)
732
+ if (total > 0) deleted["flows_time_travel_receipts"] = total
733
+ }
734
+ for (const entry of tables) {
735
+ const total = yield* countIn(sql, entry.table, entry.column, idsFor(entry))
736
+ if (total > 0) deleted[entry.table] = total
737
+ }
738
+ if (runIds.length > 0) deleted["flows_runs"] = runIds.length
739
+
740
+ if (!options.dryRun) {
741
+ // Receipts have no run column, so remove them through their audits
742
+ // before the ordinary inventory reaches and deletes those audit rows.
743
+ if (hasTimeTravelReceipts) yield* deleteTimeTravelReceipts(sql, runIds)
744
+ for (const entry of tables) yield* deleteIn(sql, entry.table, entry.column, idsFor(entry))
745
+ // Last, and deepest generation first. The `flows_run_parents_gc`
746
+ // trigger drops each run's DAG edges as its row goes.
747
+ for (const generation of generations(doomed, parentOf)) {
748
+ yield* deleteIn(sql, "flows_runs", "run_id", generation)
749
+ }
750
+ }
751
+
752
+ return { runIds, pinned: Array.from(pinned), deleted }
753
+ })
754
+
755
+ /**
756
+ * Builds the retention operation over the composition's own durable tables.
757
+ *
758
+ * The scan reads `flows_runs` directly, the way `DurableEngineState` and
759
+ * `ArtifactGc` do: this package composes the run-store, journal, and engine
760
+ * migrations, so the schema is its own.
761
+ *
762
+ * @category constructors
763
+ * @since 0.1.0
764
+ */
765
+ export const make = (): Effect.Effect<Service, never, SqlClient.SqlClient | Journal.Journal> =>
766
+ Effect.gen(function*() {
767
+ const sql = yield* Effect.service(SqlClient.SqlClient)
768
+ const journal = yield* Journal.Journal
769
+
770
+ /**
771
+ * Aged terminal runs held by live lineage or an excluded continuation
772
+ * descendant. An upward exclusion takes precedence over a live ancestor.
773
+ *
774
+ * These runs are never candidates — `candidatesOf` excludes them — so this
775
+ * read exists to say WHY a workspace with aged runs collected fewer than
776
+ * it holds. It carries the pass's own bound so the report costs no more
777
+ * than the pass does.
778
+ */
779
+ const retainedByLineage = (cutoffMs: number, limit: number) =>
780
+ sql<{ readonly run_id: string; readonly live_descendant: number }>`
781
+ ${scanPrelude(sql, { cutoffMs, inclusive: true, parentEdges: true })}
782
+ SELECT
783
+ run_id,
784
+ (run_id IN (SELECT run_id FROM over_live) OR EXISTS (
785
+ SELECT 1 FROM flows_runs AS child
786
+ WHERE child.parent_run_id = flows_runs.run_id
787
+ AND child.run_id IN (SELECT run_id FROM blocked)
788
+ )) AS live_descendant
789
+ FROM flows_runs
790
+ WHERE ${sql.in("status", terminalStatuses)}
791
+ AND COALESCE(finished_at_ms, created_at_ms) <= ${cutoffMs}
792
+ AND run_id IN (SELECT run_id FROM blocked)
793
+ ORDER BY COALESCE(finished_at_ms, created_at_ms), run_id
794
+ LIMIT ${limit}
795
+ `.pipe(Effect.mapError(scanning("the run lineage")))
796
+
797
+ const pass = (options: RetainOptions, cutoffMs: number) =>
798
+ Effect.gen(function*() {
799
+ const limit = normalizeLimit(options.limit)
800
+ const candidates = yield* candidatesOf(sql, { cutoffMs, inclusive: true, parentEdges: true, limit }).pipe(
801
+ Effect.mapError(scanning("the run table"))
802
+ )
803
+ const retained = new Set<string>()
804
+ const retainedAbove = new Set<string>()
805
+ // Why the workspace kept aged runs this pass. These never entered the
806
+ // candidate set, so this only classifies them. It runs before the
807
+ // deletes so the report describes the file the pass was handed.
808
+ for (const held of yield* retainedByLineage(cutoffMs, limit)) {
809
+ if (Number(held.live_descendant) > 0) retained.add(held.run_id)
810
+ else retainedAbove.add(held.run_id)
811
+ }
812
+ // The whole deletion, shared with `Retention.collect` so the two
813
+ // passes cannot hold different table lists or different orders. This
814
+ // database is the engine's own ladder, so a table of it that the
815
+ // catalog does not list is a broken schema and the delete says so.
816
+ const removed = yield* deleteRuns(sql, candidates, {
817
+ dryRun: options.dryRun === true,
818
+ assumeLadder: true
819
+ })
820
+
821
+ return {
822
+ cutoffMs,
823
+ runIds: removed.runIds,
824
+ retainedForLiveDescendants: Array.from(retained).sort(),
825
+ retainedForLiveAncestors: Array.from(retainedAbove).sort(),
826
+ runs: removed.runIds.length,
827
+ attempts: removed.deleted["flows_attempts"] ?? 0,
828
+ clockDeadlines: removed.deleted["flows_clock_deadlines"] ?? 0,
829
+ deferredCompletions: removed.deleted["flows_deferred_completions"] ?? 0,
830
+ journalEntries: removed.deleted["flows_journal_events"] ?? 0,
831
+ journalCheckpoints: removed.deleted["flows_journal_checkpoints"] ?? 0,
832
+ journalIdentities: removed.deleted["flows_journal_dedup"] ?? 0,
833
+ archiveEntries: removed.deleted["flows_time_travel_archive"] ?? 0,
834
+ timeTravelReceipts: removed.deleted["flows_time_travel_receipts"] ?? 0,
835
+ dryRun: options.dryRun === true
836
+ } satisfies RetainReport
837
+ })
838
+
839
+ const retain: Service["retain"] = Effect.fn("Retention.retain")((options: RetainOptions) =>
840
+ Effect.gen(function*() {
841
+ const nowMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor))
842
+ const cutoffMs = nowMs - Math.max(0, options.olderThanMs)
843
+ // One commit: `transact` joins the run-row deletes, the dependent
844
+ // deletes, and the journal truncation into a single write transaction,
845
+ // so a crash can never leave a run without its history or history
846
+ // without its run. A transaction that cannot commit fails as the
847
+ // `JournalError` it is rather than being laundered into a retention
848
+ // code that would claim to know why.
849
+ return yield* journal.transact(pass(options, cutoffMs))
850
+ })
851
+ )
852
+
853
+ return { retain }
854
+ })
855
+
856
+ /**
857
+ * Provides run retention. Nothing schedules `retain()`; invoking it stays an
858
+ * explicit caller decision.
859
+ *
860
+ * @category layers
861
+ * @since 0.1.0
862
+ */
863
+ export const layer: Layer.Layer<Retention, never, SqlClient.SqlClient | Journal.Journal> = Layer.effect(Retention)(
864
+ make()
865
+ )