@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,1395 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ActionPersistence_exports = {};
30
+ __export(ActionPersistence_exports, {
31
+ AttemptAdmissionRejected: () => AttemptAdmissionRejected,
32
+ AttemptEvidenceQuarantined: () => AttemptEvidenceQuarantined,
33
+ AttemptSuspended: () => AttemptSuspended,
34
+ CacheConflictDetected: () => CacheConflictDetected,
35
+ CacheCorruptionDetected: () => CacheCorruptionDetected,
36
+ earliestBoundarySnapshot: () => earliestBoundarySnapshot,
37
+ evidenceQuarantined: () => evidenceQuarantined,
38
+ make: () => make,
39
+ maxInertJsonCharacters: () => maxInertJsonCharacters,
40
+ maxInertJsonDepth: () => maxInertJsonDepth,
41
+ maxInertJsonNodes: () => maxInertJsonNodes
42
+ });
43
+ module.exports = __toCommonJS(ActionPersistence_exports);
44
+ var import_crypto = require("@smthrs/crypto");
45
+ var import_engine = require("@smthrs/engine");
46
+ var import_flow = require("@smthrs/flow");
47
+ var CacheEnvironment = __toESM(require("@smthrs/flow/CacheEnvironment"), 1);
48
+ var import_journal = require("@smthrs/journal");
49
+ var import_kernel = require("@smthrs/kernel");
50
+ var import_keys = require("@smthrs/keys");
51
+ var import_run_store = require("@smthrs/run-store");
52
+ var import_step_cache = require("@smthrs/step-cache");
53
+ var Cause = __toESM(require("effect/Cause"), 1);
54
+ var Clock = __toESM(require("effect/Clock"), 1);
55
+ var Context = __toESM(require("effect/Context"), 1);
56
+ var Effect = __toESM(require("effect/Effect"), 1);
57
+ var Exit = __toESM(require("effect/Exit"), 1);
58
+ var Metric = __toESM(require("effect/Metric"), 1);
59
+ var Option = __toESM(require("effect/Option"), 1);
60
+ var Schema = __toESM(require("effect/Schema"), 1);
61
+ var EngineStoreMetrics = __toESM(require("../EngineStoreMetrics.js"), 1);
62
+ var Inconsistency = __toESM(require("../Inconsistency.js"), 1);
63
+ var ReplayOnly = __toESM(require("../ReplayOnly.js"), 1);
64
+ var StepBoundary = __toESM(require("../StepBoundary.js"), 1);
65
+ var StepSandbox = __toESM(require("../StepSandbox.js"), 1);
66
+ var WorkspaceSandbox = __toESM(require("../WorkspaceSandbox.js"), 1);
67
+ var AttemptAdmission = __toESM(require("./AttemptAdmission.js"), 1);
68
+ var CacheAdmission = __toESM(require("./CacheAdmission.js"), 1);
69
+ var CacheAgeHistory = __toESM(require("./CacheAgeHistory.js"), 1);
70
+ var CacheAgeVerdicts = __toESM(require("./CacheAgeVerdicts.js"), 1);
71
+ var CacheOutputPolicy = __toESM(require("./CacheOutputPolicy.js"), 1);
72
+ var CachePublication = __toESM(require("./CachePublication.js"), 1);
73
+ var CallFacts = __toESM(require("./CallFacts.js"), 1);
74
+ var CopiedRecord = __toESM(require("./CopiedRecord.js"), 1);
75
+ var EffectRecords = __toESM(require("./EffectRecords.js"), 1);
76
+ var HostReflection = __toESM(require("./HostReflection.js"), 1);
77
+ var JournalRecords = __toESM(require("./JournalRecords.js"), 1);
78
+ var ProvenanceSlot = __toESM(require("./ProvenanceSlot.js"), 1);
79
+ var SandboxedExecution = __toESM(require("./SandboxedExecution.js"), 1);
80
+ var StepFacts = __toESM(require("./StepFacts.js"), 1);
81
+ class AttemptSuspended extends Schema.TaggedError()(
82
+ "@smthrs/engine-store/AttemptSuspended",
83
+ {
84
+ code: Schema.Literal("attempt_suspended"),
85
+ runId: Schema.String,
86
+ keyDigest: Schema.String,
87
+ attempt: Schema.Int
88
+ }
89
+ ) {
90
+ }
91
+ class AttemptAdmissionRejected extends Schema.TaggedError()(
92
+ "@smthrs/engine-store/AttemptAdmissionRejected",
93
+ {
94
+ code: Schema.Literal("attempt_admission_rejected"),
95
+ keyDigest: Schema.String,
96
+ outcome: Schema.String
97
+ }
98
+ ) {
99
+ }
100
+ class CacheConflictDetected extends Schema.TaggedError()(
101
+ "@smthrs/engine-store/CacheConflictDetected",
102
+ {
103
+ code: Schema.Literal("cache_conflict_detected"),
104
+ keyDigest: Schema.String,
105
+ recordedRunId: Schema.String
106
+ }
107
+ ) {
108
+ }
109
+ class CacheCorruptionDetected extends Schema.TaggedError()(
110
+ "@smthrs/engine-store/CacheCorruptionDetected",
111
+ {
112
+ code: Schema.Literal("cache_corruption_detected"),
113
+ keyDigest: Schema.String,
114
+ path: Schema.String,
115
+ recordedDigest: Schema.String,
116
+ measuredDigest: Schema.String
117
+ }
118
+ ) {
119
+ }
120
+ class AttemptEvidenceQuarantined extends Schema.TaggedError()(
121
+ "@smthrs/engine-store/AttemptEvidenceQuarantined",
122
+ {
123
+ code: Schema.Literal("attempt_evidence_quarantined"),
124
+ keyDigest: Schema.String,
125
+ attempt: Schema.Int,
126
+ path: Schema.String,
127
+ recordedDigest: Schema.String,
128
+ measuredDigest: Schema.String
129
+ }
130
+ ) {
131
+ }
132
+ const evidenceQuarantined = (cause) => {
133
+ for (const reason of cause.reasons) {
134
+ const carried = Cause.isFailReason(reason) ? reason.error : Cause.isDieReason(reason) ? reason.defect : void 0;
135
+ if (carried instanceof AttemptEvidenceQuarantined) {
136
+ return carried;
137
+ }
138
+ }
139
+ return void 0;
140
+ };
141
+ const replayCorruption = (cause) => {
142
+ for (const reason of cause.reasons) {
143
+ if (Cause.isFailReason(reason) && reason.error instanceof StepBoundary.BoundaryCorruption) {
144
+ return reason.error;
145
+ }
146
+ }
147
+ return void 0;
148
+ };
149
+ const actionKind = (action) => typeof action === "object" && action !== null && typeof action.name === "string" ? action.name : "flows/engine-store/action";
150
+ const declarationViolated = (cause) => cause.reasons.some(
151
+ (reason) => Cause.isFailReason(reason) && (reason.error instanceof StepBoundary.UndeclaredWrite || reason.error instanceof StepSandbox.UndeclaredRead)
152
+ );
153
+ const settlementViolated = (cause) => cause.reasons.some(
154
+ (reason) => Cause.isFailReason(reason) && (reason.error instanceof StepBoundary.UndeclaredWrite || reason.error instanceof StepBoundary.MissingDeclaredOutput || reason.error instanceof StepBoundary.SurvivingDeclaredRemoval)
155
+ );
156
+ const AttemptMeta = Schema.Struct({
157
+ tier: Schema.Literals(["sealed", "compensable", "irreversible"]),
158
+ // Only a genuine action idempotency key permits automatic released retry.
159
+ // Old rows without this evidence remain fail-closed (issues #2982/#3409).
160
+ keyed: Schema.optional(Schema.Literal(true)),
161
+ /**
162
+ * The sealed declaration admits multiple legitimate recorded results under
163
+ * this key. Absence remains the durable determinism claim.
164
+ */
165
+ nondeterministic: Schema.optional(Schema.Literal(true)),
166
+ boundary: Schema.optional(StepBoundary.BoundaryEvidence),
167
+ /**
168
+ * The prepare-time measurement matched the caller-declared read set the
169
+ * step key was derived from (issue #106). Only such completions may enter
170
+ * the shared cache: a stale declaration executes against the *real*
171
+ * content, so recording its result under the declaration's key would hand
172
+ * a later, genuinely accurate run the wrong value as a verified hit.
173
+ */
174
+ readSetVerified: Schema.optional(Schema.Literal(true)),
175
+ /**
176
+ * The row's boundary evidence failed integrity verification and was removed
177
+ * after its detailed corruption record reached the journal (issue #171).
178
+ * The succeeded outcome remains authoritative, but this row may never be
179
+ * converged into the shared cache again.
180
+ */
181
+ boundaryQuarantined: Schema.optional(Schema.Literal(true)),
182
+ /**
183
+ * The failed row records a boundary violation (a prepare or settle
184
+ * failure), so the failed replay branch can re-emit the `hardViolation`
185
+ * journal record idempotently after a crash in the finish→emit window
186
+ * (issue #109) — the violation kind is not recoverable from the persisted
187
+ * cause alone.
188
+ */
189
+ hardViolation: Schema.optional(Schema.Literal(true)),
190
+ snapshotId: Schema.optional(Schema.String),
191
+ /**
192
+ * The jj operation that recorded `snapshotId`, when the host reports one.
193
+ * A whole-repository rewind restores it to undo bookmark moves, rebases,
194
+ * `describe`, and `abandon` that a tree restore leaves in place.
195
+ */
196
+ snapshotOperationId: Schema.optional(Schema.String),
197
+ /**
198
+ * The engine `SnapshotBoundary` handle taken before this attempt executed.
199
+ * Wrapped so an opaque `null` or `undefined` handle stays distinguishable
200
+ * from no handle; `handle` is absent when the handle was `undefined`.
201
+ */
202
+ boundarySnapshot: Schema.optional(Schema.Struct({ handle: Schema.optionalKey(Schema.Unknown) })),
203
+ // The incarnation that admitted the running row. Since issues #102/#103
204
+ // the adoption decision rests on the admission permit rather than this
205
+ // nonce — a live same-key fiber of this process would be holding the
206
+ // permit, which distinguishes a dead fiber from a live dispatch in a way
207
+ // the recorded incarnation cannot — but the field is kept as durable
208
+ // forensic evidence of which incarnation last drove the attempt.
209
+ admittedBy: Schema.optional(import_run_store.Ownership.OwnerId),
210
+ /**
211
+ * How far this attempt's effect boundary got, in EXECUTABLE state.
212
+ *
213
+ * The journal's boundary records already say this, and adoption cannot use
214
+ * them: `@smthrs/journal` puts every payload it writes through redaction,
215
+ * deliberately, so a recorded `output` may never be re-entered as a flow's
216
+ * result (issue #72), and the journal offers no read addressed by producer
217
+ * identity — only a full scan of the run. So the same fact is written here,
218
+ * where the attempt's `outcome` column is already replayed verbatim, in the
219
+ * SAME transaction as the record that describes it.
220
+ *
221
+ * - `intended`: the body was dispatched and its outcome is not durably
222
+ * known. Whether the effect reached the outside world is genuinely
223
+ * unanswerable from durable state.
224
+ * - `parked`: the body reached a durable wait and suspended, so it never
225
+ * finished and nothing crossed. Recorded explicitly because a park leaves
226
+ * the same `running` row a crash does.
227
+ * - `succeeded`: the body completed and the row carries its result.
228
+ */
229
+ effectCrossing: Schema.optional(Schema.Literals(["intended", "parked", "succeeded"]))
230
+ });
231
+ const decodeMeta = (value) => {
232
+ const decoded = Schema.decodeUnknownResult(AttemptMeta)(value);
233
+ return decoded._tag === "Success" ? decoded.success : void 0;
234
+ };
235
+ const earliestBoundarySnapshot = (attempts, runId, stepKeyDigest, range) => Effect.gen(function* () {
236
+ for (let attempt = range.earliest; attempt <= range.latest; attempt++) {
237
+ const row = yield* attempts.get({ runId, stepKeyDigest, attempt }).pipe(Effect.orDie);
238
+ const persisted = Option.isSome(row) ? decodeMeta(row.value.meta)?.boundarySnapshot : void 0;
239
+ if (persisted !== void 0) return Option.some(persisted.handle);
240
+ }
241
+ return Option.none();
242
+ });
243
+ const CauseJson = Schema.Struct({
244
+ reasons: Schema.Array(Schema.Union([
245
+ Schema.Struct({ _tag: Schema.Literal("Fail"), error: Schema.Unknown }),
246
+ Schema.Struct({ _tag: Schema.Literal("Die"), defect: Schema.Unknown }),
247
+ Schema.Struct({
248
+ _tag: Schema.Literal("Interrupt"),
249
+ fiberId: Schema.optional(Schema.NullOr(Schema.Number))
250
+ })
251
+ ]))
252
+ });
253
+ const maxInertJsonDepth = import_run_store.AttemptStore.maximumJsonDepth - 4;
254
+ const maxInertJsonNodes = import_run_store.AttemptStore.maximumJsonNodes - 8;
255
+ const maxInertJsonCharacters = 256 * 1024;
256
+ const inertJsonRejected = /* @__PURE__ */ Symbol("inertJsonRejected");
257
+ const inertJsonOmitted = /* @__PURE__ */ Symbol("inertJsonOmitted");
258
+ const arrayBufferViewMarker = "[ArrayBufferView]";
259
+ const spendNodes = (budget, nodes) => {
260
+ if (budget.nodes + nodes > maxInertJsonNodes) return false;
261
+ budget.nodes += nodes;
262
+ return true;
263
+ };
264
+ const isWellFormedInertString = (value) => {
265
+ for (let index = 0; index < value.length; index++) {
266
+ const unit = value.charCodeAt(index);
267
+ if (unit >= 55296 && unit <= 56319) {
268
+ const low = value.charCodeAt(++index);
269
+ if (!(low >= 56320 && low <= 57343)) return false;
270
+ } else if (unit >= 56320 && unit <= 57343) return false;
271
+ }
272
+ return true;
273
+ };
274
+ const spend = (budget, value) => {
275
+ budget.characters += value.length;
276
+ return budget.characters <= maxInertJsonCharacters && isWellFormedInertString(value);
277
+ };
278
+ const spendEnumeratedKey = (budget, key) => {
279
+ budget.enumeratedKeys += 1;
280
+ if (budget.enumeratedKeys > maxInertJsonNodes) return false;
281
+ return typeof key !== "string" || spend(budget, key);
282
+ };
283
+ const inertJson = (value, budget) => {
284
+ const active = /* @__PURE__ */ new WeakSet();
285
+ const reduce = (current, depth) => {
286
+ if (depth > maxInertJsonDepth) return inertJsonRejected;
287
+ if (depth > 0 && !spendNodes(budget, 1)) return inertJsonRejected;
288
+ if (current === null) return null;
289
+ switch (typeof current) {
290
+ case "boolean":
291
+ return current;
292
+ case "number":
293
+ return Number.isFinite(current) ? current : null;
294
+ case "string":
295
+ return spend(budget, current) ? current : inertJsonRejected;
296
+ case "undefined":
297
+ case "symbol":
298
+ case "function":
299
+ case "bigint":
300
+ return inertJsonOmitted;
301
+ case "object": {
302
+ if (HostReflection.host.isProxy(current) || active.has(current)) return inertJsonRejected;
303
+ if (ArrayBuffer.isView(current)) return arrayBufferViewMarker;
304
+ active.add(current);
305
+ try {
306
+ if (Array.isArray(current)) {
307
+ const lengthDescriptor = Object.getOwnPropertyDescriptor(current, "length");
308
+ if (lengthDescriptor === void 0 || !("value" in lengthDescriptor) || typeof lengthDescriptor.value !== "number") return inertJsonRejected;
309
+ const output2 = [];
310
+ for (let index = 0; index < lengthDescriptor.value; index++) {
311
+ const descriptor = Object.getOwnPropertyDescriptor(current, String(index));
312
+ const reduced = reduce(
313
+ descriptor !== void 0 && "value" in descriptor ? descriptor.value : void 0,
314
+ depth + 1
315
+ );
316
+ if (reduced === inertJsonRejected) return inertJsonRejected;
317
+ output2.push(reduced === inertJsonOmitted ? null : reduced);
318
+ }
319
+ return output2;
320
+ }
321
+ const output = {};
322
+ const tag = Object.getOwnPropertyDescriptor(current, "_tag");
323
+ const conflictMessage = tag !== void 0 && "value" in tag && tag.value === WorkspaceSandbox.MaterializationConflict.identifier;
324
+ for (const key of Reflect.ownKeys(current)) {
325
+ if (!spendEnumeratedKey(budget, key)) return inertJsonRejected;
326
+ if (typeof key !== "string") continue;
327
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
328
+ if (descriptor === void 0) continue;
329
+ if (!descriptor.enumerable && !(key === "message" && conflictMessage) || !("value" in descriptor)) {
330
+ continue;
331
+ }
332
+ const member = (key === "message" || key === "stack") && typeof descriptor.value === "string" ? import_journal.Redaction.redact(descriptor.value) : descriptor.value;
333
+ const reduced = reduce(member, depth + 1);
334
+ if (reduced === inertJsonRejected) return inertJsonRejected;
335
+ if (reduced === inertJsonOmitted) continue;
336
+ Object.defineProperty(output, key, {
337
+ value: reduced,
338
+ enumerable: true,
339
+ configurable: true,
340
+ writable: true
341
+ });
342
+ }
343
+ return output;
344
+ } finally {
345
+ active.delete(current);
346
+ }
347
+ }
348
+ }
349
+ return inertJsonRejected;
350
+ };
351
+ try {
352
+ const reduced = reduce(value, 0);
353
+ return reduced === inertJsonRejected || reduced === inertJsonOmitted ? null : reduced;
354
+ } catch {
355
+ return null;
356
+ }
357
+ };
358
+ const persistCause = (cause) => {
359
+ const budget = { nodes: 2, characters: 0, enumeratedKeys: 0 };
360
+ const reasons = [];
361
+ for (const reason of cause.reasons) {
362
+ if (!spendNodes(budget, 3)) {
363
+ return { reasons: [{ _tag: "Die", defect: null }] };
364
+ }
365
+ if (Cause.isFailReason(reason)) {
366
+ reasons.push({ _tag: "Fail", error: inertJson(reason.error, budget) });
367
+ } else if (Cause.isDieReason(reason)) {
368
+ reasons.push({ _tag: "Die", defect: inertJson(reason.defect, budget) });
369
+ } else {
370
+ reasons.push({ _tag: "Interrupt", fiberId: reason.fiberId ?? null });
371
+ }
372
+ }
373
+ return { reasons };
374
+ };
375
+ const attemptPayload = (value) => value;
376
+ const rehydrateCause = (error) => {
377
+ const decoded = Schema.decodeUnknownResult(CauseJson)(error);
378
+ if (decoded._tag === "Success" && decoded.success.reasons.length > 0) {
379
+ return Cause.fromReasons(decoded.success.reasons.map((reason) => {
380
+ switch (reason._tag) {
381
+ case "Fail":
382
+ return Cause.makeFailReason(reason.error);
383
+ case "Die":
384
+ return Cause.makeDieReason(reason.defect);
385
+ case "Interrupt":
386
+ return Cause.makeInterruptReason(reason.fiberId ?? void 0);
387
+ }
388
+ }));
389
+ }
390
+ return Cause.die(error);
391
+ };
392
+ const declaredCachePolicy = (action) => {
393
+ const annotations = action?.annotations;
394
+ return Context.isContext(annotations) ? CacheEnvironment.cachePolicyOf(annotations) : void 0;
395
+ };
396
+ const make = (deps) => {
397
+ const execute = (input, stepKeyDigest) => Effect.andThen(
398
+ import_flow.Action.reportDispatch({ outcome: "executed", stepKeyDigest, attempt: input.attempt }),
399
+ deps.execute(input)
400
+ );
401
+ const admission = deps.admission ?? AttemptAdmission.makeUnsafe();
402
+ const recordedAgeVerdict = deps.cacheAgeVerdict ?? CacheAgeVerdicts.make(deps.runId);
403
+ const lineageId = import_engine.FlowEngine.Lineage.root(deps.runId);
404
+ return Effect.fn("ActionPersistence.execute")((input) => {
405
+ const replay = { gated: false };
406
+ return Effect.gen(function* () {
407
+ yield* Effect.annotateCurrentSpan({
408
+ runId: deps.runId,
409
+ attempt: input.attempt,
410
+ tier: input.tier
411
+ });
412
+ const attempts = yield* import_run_store.AttemptStore.AttemptStore;
413
+ const cache = yield* import_step_cache.CacheStore.CacheStore;
414
+ const journal = yield* import_journal.Journal.Journal;
415
+ const runs = yield* import_run_store.RunStore.RunStore;
416
+ const policy = declaredCachePolicy(input.action);
417
+ const scopeTag = policy?.scope === "run" ? `run:${deps.runId}` : policy?.scope === "flow" ? `flow:${Option.getOrUndefined(
418
+ Option.map(yield* Effect.serviceOption(import_flow.FlowRuntime.FlowInstance), (instance) => instance.flow._tag)
419
+ ) ?? `run:${deps.runId}`}` : void 0;
420
+ const stepKeyDigest = yield* Schema.decodeUnknownEffect(import_crypto.Sha256)(input.key).pipe(Effect.orDie);
421
+ replay.stepKeyDigest = stepKeyDigest;
422
+ const keyDigest = scopeTag === void 0 ? stepKeyDigest : yield* Schema.decodeUnknownEffect(import_crypto.Sha256)(`${input.key}\0scope:${scopeTag}`).pipe(Effect.orDie);
423
+ yield* Effect.annotateCurrentSpan({ stepKeyDigest, keyDigest });
424
+ const attemptId = { runId: deps.runId, stepKeyDigest, attempt: input.attempt };
425
+ const emitLifecycle = (record) => journal.emitDurable(record, deps.owner).pipe(
426
+ Effect.catch((error) => error.code === "fence_lost" ? Effect.interrupt : Effect.fail(error))
427
+ );
428
+ const callFacts = CallFacts.make(input.action, deps.runId);
429
+ const stepFacts = StepFacts.make(input.action, deps.runId);
430
+ const emitStepSettled = (outcome) => Effect.flatMap(
431
+ stepFacts.settled(outcome),
432
+ (record) => record === void 0 ? Effect.void : Effect.asVoid(emitLifecycle(record))
433
+ );
434
+ const emitCallInvoked = Effect.flatMap(
435
+ callFacts.invoked,
436
+ (record) => record === void 0 ? Effect.void : Effect.asVoid(emitLifecycle(record))
437
+ );
438
+ const emitCallSettled = (outcome) => Effect.flatMap(
439
+ callFacts.settled(outcome),
440
+ (record) => record === void 0 ? Effect.void : Effect.asVoid(emitLifecycle(record))
441
+ );
442
+ const atomically = (effect) => journal.transact(effect);
443
+ const settleAttempt = (row, records) => atomically(Effect.gen(function* () {
444
+ const finished = yield* attempts.finish(row, deps.owner);
445
+ if (finished._tag !== "Finished") {
446
+ return false;
447
+ }
448
+ if (row.state === "succeeded" && stepFacts.annotated) {
449
+ const committed = yield* attempts.get(attemptId);
450
+ if (Option.isNone(committed)) {
451
+ return yield* Effect.fail(
452
+ new import_run_store.AttemptStore.AttemptStoreError({
453
+ code: "persistence_failed",
454
+ method: "get",
455
+ message: "Finished checkpoint outcome disappeared",
456
+ cause: attemptId
457
+ })
458
+ );
459
+ }
460
+ yield* emitStepSettled(committed.value.outcome);
461
+ }
462
+ yield* Effect.forEach(records, (record) => emitLifecycle(record), { discard: true });
463
+ if (row.state === "succeeded" && callFacts.settles) {
464
+ const committed = yield* attempts.get(attemptId);
465
+ if (Option.isNone(committed)) {
466
+ return yield* Effect.die(new Error("Finished call outcome disappeared"));
467
+ }
468
+ yield* emitCallSettled(committed.value.outcome);
469
+ }
470
+ return true;
471
+ }));
472
+ const fencedAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
473
+ const heartbeat = yield* runs.heartbeat(deps.runId, deps.owner, fencedAtMs);
474
+ if (heartbeat._tag !== "Updated") {
475
+ return yield* Effect.interrupt;
476
+ }
477
+ if (input.tier === "irreversible" && input.attempt > 1 && deps.idempotencyKey === void 0) {
478
+ return yield* Effect.fail(
479
+ new import_flow.Action.IrreversibleRetryRequiresIdempotencyKey({
480
+ actionName: actionKind(input.action),
481
+ attempt: input.attempt
482
+ })
483
+ );
484
+ }
485
+ const cacheDeclaration = CacheAdmission.declaration(input);
486
+ const declarationMeta = {
487
+ tier: input.tier,
488
+ ...deps.idempotencyKey === void 0 ? {} : { keyed: true },
489
+ ...input.nondeterministic === void 0 ? {} : { nondeterministic: input.nondeterministic }
490
+ };
491
+ const cacheSource = (action, recorded) => ({
492
+ runId: deps.runId,
493
+ lineageId,
494
+ sourceId: `cache:${keyDigest}:${action}${recorded === void 0 ? "" : `:${recorded.runId}:${recorded.eventSeq}`}`,
495
+ sourceSeq: 0
496
+ });
497
+ const noteUnshareable = (unshareable) => Effect.gen(function* () {
498
+ const reason = yield* Schema.decodeUnknownEffect(import_crypto.Sha256)(`${unshareable.stage}:${unshareable.message}`).pipe(
499
+ Effect.orDie
500
+ );
501
+ yield* emitLifecycle(JournalRecords.cacheProvenance(cacheSource(`unpublished:${reason}`), {
502
+ keyDigest,
503
+ action: "unpublished",
504
+ stage: unshareable.stage,
505
+ message: unshareable.message
506
+ }));
507
+ });
508
+ const recordCache = (options) => Effect.gen(function* () {
509
+ const meta = options.admission.meta;
510
+ let unshareable = yield* CachePublication.publishArtifacts(meta.boundary);
511
+ const generation = yield* Schema.decodeUnknownEffect(import_keys.DerivedKey)({
512
+ kind: "cache-generation",
513
+ meta,
514
+ result: options.result
515
+ }).pipe(Effect.orDie);
516
+ const recording = yield* atomically(
517
+ Effect.gen(function* () {
518
+ const receipt = yield* emitLifecycle(
519
+ JournalRecords.cacheProvenance({
520
+ runId: deps.runId,
521
+ lineageId,
522
+ cacheKey: keyDigest,
523
+ sourceId: `${deps.sourceId}:cache:${keyDigest}:recorded:${generation}`,
524
+ sourceSeq: 0
525
+ }, { keyDigest, action: "recorded" })
526
+ );
527
+ const entry = {
528
+ keyDigest,
529
+ result: options.result,
530
+ meta,
531
+ createdAtMs: options.createdAtMs,
532
+ recordedRunId: deps.runId,
533
+ recordedEventSeq: receipt.seq
534
+ };
535
+ const outcome = yield* cache.put(entry);
536
+ if (outcome._tag === "Inserted") {
537
+ const recorded = { runId: deps.runId, eventSeq: receipt.seq };
538
+ yield* emitLifecycle(JournalRecords.cacheProvenance(cacheSource("admitted", recorded), {
539
+ keyDigest,
540
+ action: "admitted",
541
+ recordedRunId: recorded.runId,
542
+ recordedEventSeq: recorded.eventSeq
543
+ }));
544
+ }
545
+ return { entry, outcome };
546
+ })
547
+ ).pipe(Effect.catchTag("@smthrs/step-cache/CacheStoreError", (error) => (
548
+ // Only availability of the local transaction is optional. A known
549
+ // deterministic Conflict below still belongs to Inconsistency.
550
+ noteUnshareable({ stage: "entry", message: `local cache publication failed: ${error.message}` }).pipe(
551
+ Effect.as(void 0)
552
+ )
553
+ )));
554
+ if (recording === void 0) {
555
+ return;
556
+ }
557
+ if (unshareable === void 0 && recording.outcome._tag !== "Conflict") {
558
+ unshareable = yield* CachePublication.publishEntry(recording.entry);
559
+ }
560
+ if (unshareable !== void 0) {
561
+ yield* noteUnshareable(unshareable);
562
+ }
563
+ if (recording.outcome._tag === "Conflict") {
564
+ const conflicting = yield* cache.get(keyDigest);
565
+ if (meta.nondeterministic === true) {
566
+ const recorded = Option.map(conflicting, (entry) => ({
567
+ runId: entry.recordedRunId,
568
+ eventSeq: entry.recordedEventSeq
569
+ }));
570
+ yield* emitLifecycle(
571
+ JournalRecords.cacheProvenance(
572
+ cacheSource("conflict_first_writer", Option.getOrUndefined(recorded)),
573
+ {
574
+ keyDigest,
575
+ action: "conflict_first_writer",
576
+ recordedRunId: Option.getOrNull(Option.map(recorded, (value) => value.runId)),
577
+ recordedEventSeq: Option.getOrNull(Option.map(recorded, (value) => value.eventSeq))
578
+ }
579
+ )
580
+ );
581
+ return;
582
+ }
583
+ const receiverOption = yield* Effect.serviceOption(Inconsistency.Inconsistency);
584
+ const receiver = Option.isSome(receiverOption) ? receiverOption.value : Inconsistency.make({ journal, verdict: "fail", owner: deps.owner });
585
+ const verdict = yield* receiver.note({
586
+ key: keyDigest,
587
+ existing: Option.getOrUndefined(conflicting),
588
+ attempted: recording.entry
589
+ });
590
+ if (verdict === "fail") {
591
+ return yield* Effect.fail(
592
+ new CacheConflictDetected({
593
+ code: "cache_conflict_detected",
594
+ keyDigest,
595
+ recordedRunId: Option.isSome(conflicting) ? conflicting.value.recordedRunId : "unknown"
596
+ })
597
+ );
598
+ }
599
+ }
600
+ });
601
+ return yield* admission.withPermit(`${deps.runId}|${stepKeyDigest}`)(
602
+ Effect.gen(function* () {
603
+ const attemptSource = (record) => ({
604
+ runId: deps.runId,
605
+ lineageId,
606
+ // A sealed dispatch's result lives in the step cache, so the record
607
+ // carries the digest that addresses it: replay hands the projection
608
+ // the sealed value instead of re-deriving it, and a cache miss is
609
+ // simply an absent value rather than a broken fold.
610
+ ...input.tier === "sealed" ? { cacheKey: keyDigest } : {},
611
+ sourceId: `${deps.sourceId}:attempt:${stepKeyDigest}:${input.attempt}:${record}`,
612
+ sourceSeq: 0
613
+ });
614
+ const emitConverging = (record) => emitLifecycle(record).pipe(
615
+ Effect.catch(
616
+ (error) => error.code !== "idempotency_conflict" ? Effect.fail(error) : record.eventType === "flows.engine.cache-provenance" ? ProvenanceSlot.accept({ journal, runId: deps.runId, record, conflict: error }) : CopiedRecord.accept({ journal, runs, runId: deps.runId, record, conflict: error })
617
+ )
618
+ );
619
+ const expireRow = (ttlMs, stale) => Effect.gen(function* () {
620
+ const recorded = {
621
+ runId: stale.recordedRunId,
622
+ eventSeq: stale.recordedEventSeq
623
+ };
624
+ const nowMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
625
+ yield* emitConverging(
626
+ JournalRecords.cacheProvenance(cacheSource("expired", recorded), {
627
+ keyDigest,
628
+ action: "expired",
629
+ ttlMs,
630
+ ageMs: nowMs - stale.createdAtMs,
631
+ recordedRunId: recorded.runId,
632
+ recordedEventSeq: recorded.eventSeq
633
+ })
634
+ );
635
+ yield* cache.evict(keyDigest, { ifRecordedBy: recorded });
636
+ });
637
+ const admitByAge = (ttlMs, row) => Effect.gen(function* () {
638
+ const recorded = { runId: row.recordedRunId, eventSeq: row.recordedEventSeq };
639
+ const nowMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
640
+ const measured = nowMs - row.createdAtMs <= ttlMs ? "admitted" : "expired";
641
+ const decision = (verdict) => JournalRecords.cacheProvenance(cacheSource("ttl", recorded), {
642
+ keyDigest,
643
+ action: "ttl",
644
+ ttlMs,
645
+ verdict,
646
+ recordedRunId: recorded.runId,
647
+ recordedEventSeq: recorded.eventSeq
648
+ });
649
+ const expectedSource = cacheSource("ttl", recorded).sourceId;
650
+ const prior = yield* CacheAgeHistory.find(journal, deps.runId, (entry) => {
651
+ const payload = entry.payload;
652
+ return entry.sourceId === expectedSource || payload?.action === "ttl" && payload.keyDigest === keyDigest && payload.recordedRunId === recorded.runId && payload.recordedEventSeq === recorded.eventSeq;
653
+ });
654
+ if (prior !== void 0 && (prior.sourceId !== expectedSource || prior.sourceSeq !== 0)) {
655
+ yield* emitConverging(JournalRecords.cacheProvenance(cacheSource("replay_failed", recorded), {
656
+ keyDigest,
657
+ action: "replay_failed",
658
+ reason: "incompatible-age-history",
659
+ recordedRunId: recorded.runId,
660
+ recordedEventSeq: recorded.eventSeq
661
+ }));
662
+ return yield* Effect.fail(
663
+ new import_journal.Journal.JournalError({
664
+ code: "idempotency_conflict",
665
+ message: "incompatible recorded cache-age decision: producer identity changed",
666
+ cause: prior
667
+ })
668
+ );
669
+ }
670
+ return yield* emitLifecycle(decision(measured)).pipe(
671
+ Effect.as(measured),
672
+ Effect.catch((error) => {
673
+ if (error.code !== "idempotency_conflict") {
674
+ return Effect.fail(error);
675
+ }
676
+ const conflict = new import_journal.Journal.JournalError({
677
+ code: "idempotency_conflict",
678
+ message: "incompatible recorded cache-age decision: restore the original TTL and history identity or use a new action identity; the cache row was not served or expired",
679
+ cause: error
680
+ });
681
+ const opposite = measured === "admitted" ? "expired" : "admitted";
682
+ return emitLifecycle(decision(opposite)).pipe(
683
+ Effect.catch(
684
+ (oppositeError) => oppositeError.code === "idempotency_conflict" ? CacheAgeHistory.copiedVerdict({
685
+ journal,
686
+ runs,
687
+ runId: deps.runId,
688
+ decision: decision(measured),
689
+ conflict
690
+ }).pipe(
691
+ Effect.tapError(
692
+ (failure) => failure.code === "idempotency_conflict" ? emitConverging(JournalRecords.cacheProvenance(cacheSource("replay_failed", recorded), {
693
+ keyDigest,
694
+ action: "replay_failed",
695
+ reason: "incompatible-age-history",
696
+ recordedRunId: recorded.runId,
697
+ recordedEventSeq: recorded.eventSeq
698
+ })).pipe(Effect.asVoid) : Effect.void
699
+ ),
700
+ Effect.map((verdict) => ({ _tag: "Historical", verdict }))
701
+ ) : Effect.fail(oppositeError)
702
+ ),
703
+ Effect.flatMap(
704
+ (receipt) => receipt._tag === "Historical" ? Effect.succeed(receipt.verdict) : receipt._tag === "Duplicate" ? Effect.succeed(opposite) : Effect.fail(conflict)
705
+ )
706
+ );
707
+ })
708
+ );
709
+ });
710
+ const admissible = (ttlMs, row) => Effect.gen(function* () {
711
+ if (ttlMs === void 0) {
712
+ const recorded = yield* recordedAgeVerdict(journal, keyDigest);
713
+ if (recorded !== void 0) {
714
+ return yield* Effect.fail(
715
+ new import_journal.Journal.JournalError({
716
+ code: "idempotency_conflict",
717
+ message: "incompatible recorded cache-age decision: ttlMs cannot be removed after a recorded verdict",
718
+ cause: recorded
719
+ })
720
+ );
721
+ }
722
+ return row;
723
+ }
724
+ if (Option.isNone(row)) {
725
+ return row;
726
+ }
727
+ if ((yield* admitByAge(ttlMs, row.value)) === "admitted") {
728
+ return row;
729
+ }
730
+ yield* expireRow(ttlMs, row.value);
731
+ return Option.none();
732
+ });
733
+ const existing = yield* attempts.get(attemptId);
734
+ if (cacheDeclaration._tag === "Eligible") {
735
+ const observed = yield* cache.get(keyDigest).pipe(
736
+ Effect.catch(
737
+ (error) => noteUnshareable({ stage: "entry", message: `cache lookup failed: ${error.message}` }).pipe(
738
+ Effect.as(Option.none())
739
+ )
740
+ )
741
+ );
742
+ const evidenceDecision = CacheAdmission.candidate(
743
+ Option.isSome(observed) ? decodeMeta(observed.value.meta) : void 0
744
+ );
745
+ const outputDecision = evidenceDecision._tag === "CandidateEvidence" ? CacheOutputPolicy.replay(input.metadata, evidenceDecision.evidence) : void 0;
746
+ const candidate = outputDecision?._tag === "Refused" ? outputDecision : evidenceDecision;
747
+ const cached = Option.isNone(observed) || candidate._tag === "CandidateEvidence" || policy?.ttlMs === void 0 ? yield* admissible(policy?.ttlMs, observed) : observed;
748
+ if (Option.isSome(cached)) {
749
+ if (candidate._tag === "Refused") {
750
+ yield* emitConverging(JournalRecords.cacheProvenance(
751
+ cacheSource("replay_failed", {
752
+ runId: cached.value.recordedRunId,
753
+ eventSeq: cached.value.recordedEventSeq
754
+ }),
755
+ {
756
+ keyDigest,
757
+ action: "replay_failed",
758
+ reason: candidate.reason,
759
+ recordedRunId: cached.value.recordedRunId,
760
+ recordedEventSeq: cached.value.recordedEventSeq
761
+ }
762
+ ));
763
+ }
764
+ if (candidate._tag === "CandidateEvidence" && Option.isNone(existing)) {
765
+ const boundary2 = yield* StepBoundary.StepBoundary;
766
+ const measured = yield* boundary2.prepare(cacheDeclaration.metadata).pipe(Effect.option);
767
+ const verified = Option.isSome(measured) && StepBoundary.readSetMatches(measured.value);
768
+ if (verified) {
769
+ const evidence2 = candidate.evidence;
770
+ yield* emitCallInvoked;
771
+ let materialized = yield* boundary2.replayOutputs(evidence2).pipe(Effect.exit);
772
+ if (Exit.isFailure(materialized) && CachePublication.replayMissingArtifact(materialized.cause) !== void 0) {
773
+ if (yield* CachePublication.hydrateArtifacts(evidence2)) {
774
+ materialized = yield* boundary2.replayOutputs(evidence2).pipe(Effect.exit);
775
+ }
776
+ }
777
+ if (Exit.isSuccess(materialized)) {
778
+ const recorded = {
779
+ runId: cached.value.recordedRunId,
780
+ eventSeq: cached.value.recordedEventSeq
781
+ };
782
+ yield* emitConverging(JournalRecords.cacheProvenance(cacheSource("hit", recorded), {
783
+ keyDigest,
784
+ recordedRunId: cached.value.recordedRunId,
785
+ recordedEventSeq: cached.value.recordedEventSeq
786
+ }));
787
+ yield* Metric.update(EngineStoreMetrics.stepCacheDecision.VerifiedHit, 1);
788
+ yield* import_flow.Action.reportDispatch({
789
+ outcome: "replayed",
790
+ stepKeyDigest,
791
+ attempt: input.attempt
792
+ });
793
+ return cached.value.result;
794
+ }
795
+ const corruption = replayCorruption(materialized.cause);
796
+ yield* emitConverging(
797
+ JournalRecords.cacheProvenance(
798
+ cacheSource("replay_failed", {
799
+ runId: cached.value.recordedRunId,
800
+ eventSeq: cached.value.recordedEventSeq
801
+ }),
802
+ {
803
+ keyDigest,
804
+ action: "replay_failed",
805
+ reason: corruption === void 0 ? "host" : "corruption",
806
+ recordedRunId: cached.value.recordedRunId,
807
+ recordedEventSeq: cached.value.recordedEventSeq
808
+ }
809
+ )
810
+ );
811
+ if (corruption !== void 0) {
812
+ const receiverOption = yield* Effect.serviceOption(Inconsistency.Inconsistency);
813
+ const receiver = Option.isSome(receiverOption) ? receiverOption.value : Inconsistency.make({ journal, verdict: "fail", owner: deps.owner });
814
+ const verdict = yield* receiver.noteCorruption({
815
+ runId: deps.runId,
816
+ keyDigest,
817
+ path: corruption.path,
818
+ recordedDigest: corruption.recordedDigest,
819
+ measuredDigest: corruption.measuredDigest,
820
+ recordedRunId: cached.value.recordedRunId,
821
+ recordedEventSeq: cached.value.recordedEventSeq
822
+ });
823
+ yield* cache.evict(keyDigest, {
824
+ ifRecordedBy: {
825
+ runId: cached.value.recordedRunId,
826
+ eventSeq: cached.value.recordedEventSeq
827
+ }
828
+ });
829
+ if (verdict === "fail") {
830
+ return yield* Effect.fail(
831
+ new CacheCorruptionDetected({
832
+ code: "cache_corruption_detected",
833
+ keyDigest,
834
+ path: corruption.path,
835
+ recordedDigest: corruption.recordedDigest,
836
+ measuredDigest: corruption.measuredDigest
837
+ })
838
+ );
839
+ }
840
+ }
841
+ yield* Metric.update(EngineStoreMetrics.stepCacheDecision.ReplayFailed, 1);
842
+ } else if (Option.isSome(measured)) {
843
+ yield* emitConverging(
844
+ JournalRecords.cacheProvenance(
845
+ cacheSource("stale_read_set", {
846
+ runId: cached.value.recordedRunId,
847
+ eventSeq: cached.value.recordedEventSeq
848
+ }),
849
+ {
850
+ keyDigest,
851
+ action: "stale_read_set",
852
+ recordedRunId: cached.value.recordedRunId,
853
+ recordedEventSeq: cached.value.recordedEventSeq
854
+ }
855
+ )
856
+ );
857
+ yield* cache.evict(keyDigest, {
858
+ ifRecordedBy: {
859
+ runId: cached.value.recordedRunId,
860
+ eventSeq: cached.value.recordedEventSeq
861
+ }
862
+ });
863
+ yield* Metric.update(EngineStoreMetrics.stepCacheDecision.StaleReadSet, 1);
864
+ } else {
865
+ yield* Metric.update(EngineStoreMetrics.stepCacheDecision.Unmeasurable, 1);
866
+ }
867
+ } else if (candidate._tag === "Refused") {
868
+ yield* Metric.update(EngineStoreMetrics.stepCacheDecision.UnverifiableEvidence, 1);
869
+ }
870
+ } else {
871
+ yield* Metric.update(EngineStoreMetrics.stepCacheDecision.Miss, 1);
872
+ }
873
+ }
874
+ if (Option.isSome(existing)) {
875
+ const row = existing.value;
876
+ if (row.state === "succeeded") {
877
+ yield* emitCallInvoked;
878
+ const meta2 = decodeMeta(row.meta);
879
+ let corruptEvidence = false;
880
+ const outputDecision = meta2?.boundary === void 0 ? void 0 : CacheOutputPolicy.replay(input.metadata, meta2.boundary);
881
+ const storedDecision = CacheAdmission.candidate(meta2);
882
+ const refused = storedDecision._tag === "Refused" && (storedDecision.reason === "contradictory-evidence" || storedDecision.reason === "quarantined-evidence") ? storedDecision : outputDecision;
883
+ if (refused?._tag === "Refused") {
884
+ yield* emitConverging(JournalRecords.cacheProvenance(cacheSource("replay_failed"), {
885
+ keyDigest,
886
+ action: "replay_failed",
887
+ reason: refused.reason
888
+ }));
889
+ }
890
+ if (meta2?.boundary !== void 0 && refused?._tag !== "Refused") {
891
+ const boundary2 = yield* StepBoundary.StepBoundary;
892
+ const materialized = yield* boundary2.replayOutputs(meta2.boundary).pipe(Effect.exit);
893
+ if (Exit.isFailure(materialized)) {
894
+ const corruption = replayCorruption(materialized.cause);
895
+ corruptEvidence = corruption !== void 0;
896
+ yield* emitConverging(
897
+ JournalRecords.cacheProvenance(cacheSource("replay_failed"), {
898
+ keyDigest,
899
+ action: "replay_failed",
900
+ reason: corruption === void 0 ? "host" : "corruption"
901
+ })
902
+ );
903
+ if (corruption !== void 0) {
904
+ const receiverOption = yield* Effect.serviceOption(Inconsistency.Inconsistency);
905
+ const receiver = Option.isSome(receiverOption) ? receiverOption.value : Inconsistency.make({ journal, verdict: "fail", owner: deps.owner });
906
+ const verdict = yield* receiver.noteCorruption({
907
+ runId: deps.runId,
908
+ // The attempt row, not a cache row: this evidence is
909
+ // addressed by (runId, stepKeyDigest, attempt).
910
+ keyDigest: stepKeyDigest,
911
+ path: corruption.path,
912
+ recordedDigest: corruption.recordedDigest,
913
+ measuredDigest: corruption.measuredDigest
914
+ });
915
+ const { boundary: _quarantined, readSetVerified: _unverified, ...retainedMeta } = meta2;
916
+ const quarantinedMeta = {
917
+ ...retainedMeta,
918
+ boundaryQuarantined: true
919
+ };
920
+ const quarantined = yield* atomically(Effect.gen(function* () {
921
+ const quarantineAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
922
+ const fence = yield* runs.heartbeat(deps.runId, deps.owner, quarantineAtMs);
923
+ if (fence._tag !== "Updated") {
924
+ return false;
925
+ }
926
+ const patched = yield* attempts.patch(
927
+ attemptId,
928
+ { meta: attemptPayload(quarantinedMeta) },
929
+ deps.owner
930
+ );
931
+ return patched._tag === "Patched";
932
+ }));
933
+ if (!quarantined) {
934
+ return yield* Effect.interrupt;
935
+ }
936
+ if (verdict === "fail") {
937
+ return yield* Effect.die(
938
+ new AttemptEvidenceQuarantined({
939
+ code: "attempt_evidence_quarantined",
940
+ keyDigest: stepKeyDigest,
941
+ attempt: input.attempt,
942
+ path: corruption.path,
943
+ recordedDigest: corruption.recordedDigest,
944
+ measuredDigest: corruption.measuredDigest
945
+ })
946
+ );
947
+ }
948
+ }
949
+ }
950
+ }
951
+ const admission3 = CacheAdmission.completion(
952
+ cacheDeclaration,
953
+ meta2,
954
+ corruptEvidence || refused?._tag === "Refused"
955
+ );
956
+ if (admission3._tag === "PublishCompletion") {
957
+ yield* recordCache({
958
+ result: row.outcome,
959
+ admission: admission3,
960
+ createdAtMs: row.finishedAtMs ?? (yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor)))
961
+ });
962
+ }
963
+ if (meta2?.boundary?.deviation !== void 0) {
964
+ yield* emitConverging(
965
+ JournalRecords.expectedSetDeviation(attemptSource("deviation"), {
966
+ ...attemptId,
967
+ ...meta2.boundary.deviation
968
+ })
969
+ );
970
+ }
971
+ yield* emitStepSettled(row.outcome);
972
+ yield* emitConverging(
973
+ JournalRecords.attemptFinished(attemptSource("finished"), { ...attemptId, state: "succeeded" })
974
+ );
975
+ yield* emitCallSettled(row.outcome);
976
+ yield* import_flow.Action.reportDispatch({ outcome: "replayed", stepKeyDigest, attempt: input.attempt });
977
+ return row.outcome;
978
+ }
979
+ if (row.state === "failed") {
980
+ yield* emitCallInvoked;
981
+ if (decodeMeta(row.meta)?.hardViolation === true) {
982
+ yield* emitConverging(
983
+ JournalRecords.hardViolation(attemptSource("hard-violation"), {
984
+ ...attemptId,
985
+ error: rehydrateCause(row.error)
986
+ })
987
+ );
988
+ }
989
+ yield* emitConverging(
990
+ JournalRecords.attemptFinished(attemptSource("finished"), { ...attemptId, state: "failed" })
991
+ );
992
+ return yield* Effect.failCause(rehydrateCause(row.error));
993
+ }
994
+ if (row.state === "suspended") {
995
+ return yield* Effect.fail(
996
+ new AttemptSuspended({
997
+ code: "attempt_suspended",
998
+ runId: deps.runId,
999
+ keyDigest: stepKeyDigest,
1000
+ attempt: input.attempt
1001
+ })
1002
+ );
1003
+ }
1004
+ }
1005
+ const runningRow = Option.isSome(existing) && existing.value.state === "running" ? existing.value : void 0;
1006
+ const runningMeta = runningRow === void 0 ? void 0 : decodeMeta(runningRow.meta);
1007
+ if (runningRow !== void 0 && runningMeta?.effectCrossing === "succeeded") {
1008
+ yield* emitCallInvoked;
1009
+ const finishedAtMs2 = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
1010
+ const finished2 = yield* settleAttempt(
1011
+ { ...attemptId, state: "succeeded", finishedAtMs: finishedAtMs2 },
1012
+ [JournalRecords.attemptFinished(attemptSource("finished"), { ...attemptId, state: "succeeded" })]
1013
+ );
1014
+ if (!finished2) {
1015
+ return yield* Effect.interrupt;
1016
+ }
1017
+ return runningRow.outcome;
1018
+ }
1019
+ if (input.tier === "irreversible" && runningMeta?.effectCrossing === "intended" && deps.idempotencyKey === void 0) {
1020
+ return yield* Effect.fail(
1021
+ new import_flow.Action.IrreversibleRetryRequiresIdempotencyKey({
1022
+ actionName: actionKind(input.action),
1023
+ attempt: input.attempt
1024
+ })
1025
+ );
1026
+ }
1027
+ if (deps.replayOnly !== void 0) {
1028
+ replay.gated = true;
1029
+ const refused = {
1030
+ runId: deps.runId,
1031
+ stepKeyDigest,
1032
+ attempt: input.attempt,
1033
+ action: actionKind(input.action)
1034
+ };
1035
+ yield* deps.replayOnly.observe({
1036
+ ...refused,
1037
+ tier: input.tier,
1038
+ outcome: runningRow === void 0 ? "would-execute" : "resumes"
1039
+ });
1040
+ return yield* Effect.die(new ReplayOnly.WouldExecute(refused));
1041
+ }
1042
+ const adopted = runningRow !== void 0;
1043
+ yield* atomically(Effect.gen(function* () {
1044
+ if (!adopted) {
1045
+ const now = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
1046
+ const initialMeta = { ...declarationMeta, admittedBy: deps.owner };
1047
+ const put = yield* attempts.put(
1048
+ { ...attemptId, state: "running", startedAtMs: now, meta: attemptPayload(initialMeta) },
1049
+ deps.owner
1050
+ );
1051
+ if (put._tag === "FenceLost" || put._tag === "RunNotFound") {
1052
+ return yield* Effect.interrupt;
1053
+ }
1054
+ if (put._tag !== "Inserted") {
1055
+ return yield* Effect.fail(
1056
+ new AttemptAdmissionRejected({
1057
+ code: "attempt_admission_rejected",
1058
+ keyDigest: stepKeyDigest,
1059
+ outcome: put._tag
1060
+ })
1061
+ );
1062
+ }
1063
+ } else {
1064
+ const claimAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
1065
+ const claimFence = yield* runs.heartbeat(deps.runId, deps.owner, claimAtMs);
1066
+ if (claimFence._tag !== "Updated") {
1067
+ return yield* Effect.interrupt;
1068
+ }
1069
+ const rehomed = yield* attempts.patch(attemptId, {
1070
+ meta: attemptPayload(
1071
+ { ...runningMeta, ...declarationMeta, admittedBy: deps.owner }
1072
+ )
1073
+ }, deps.owner);
1074
+ if (rehomed._tag !== "Patched") {
1075
+ return yield* Effect.interrupt;
1076
+ }
1077
+ }
1078
+ yield* emitLifecycle(
1079
+ JournalRecords.attemptStarted(attemptSource("started"), { ...attemptId, tier: input.tier })
1080
+ );
1081
+ yield* emitCallInvoked;
1082
+ }));
1083
+ const snapshotFields = (id, operationId) => operationId === void 0 ? { meta: { snapshotId: id }, announced: { snapshotId: id } } : {
1084
+ meta: { snapshotId: id, snapshotOperationId: operationId },
1085
+ announced: { snapshotId: id, operationId }
1086
+ };
1087
+ const announceSnapshot = (fields) => emitLifecycle(
1088
+ JournalRecords.snapshotIdentified(attemptSource("snapshot"), { ...attemptId, ...fields.announced })
1089
+ );
1090
+ let snapshotId;
1091
+ let snapshotMeta = {};
1092
+ if (input.tier !== "compensable") {
1093
+ yield* emitLifecycle(
1094
+ JournalRecords.snapshotIdentified(attemptSource("snapshot"), { ...attemptId, carried: true })
1095
+ );
1096
+ }
1097
+ if (input.tier === "compensable") {
1098
+ const jj = deps.engineJj === void 0 ? yield* import_kernel.Jj.Jj : deps.engineJj;
1099
+ const boundaryHandle = input.snapshot === void 0 ? void 0 : yield* input.snapshot;
1100
+ const boundarySnapshot = runningMeta?.boundarySnapshot ?? (input.snapshot === void 0 ? void 0 : boundaryHandle === void 0 ? {} : { handle: boundaryHandle });
1101
+ const boundaryMeta = boundarySnapshot === void 0 ? {} : { boundarySnapshot };
1102
+ if (adopted && runningMeta?.snapshotId !== void 0) {
1103
+ yield* jj.restore(runningMeta.snapshotId);
1104
+ snapshotId = runningMeta.snapshotId;
1105
+ const fields = snapshotFields(snapshotId, runningMeta.snapshotOperationId);
1106
+ snapshotMeta = { ...fields.meta, ...boundaryMeta };
1107
+ yield* announceSnapshot(fields);
1108
+ } else {
1109
+ if (input.attempt > 1) {
1110
+ const previous = yield* attempts.get({ ...attemptId, attempt: input.attempt - 1 });
1111
+ if (Option.isSome(previous) && decodeMeta(previous.value.meta)?.snapshotId !== void 0) {
1112
+ yield* jj.restore(decodeMeta(previous.value.meta).snapshotId);
1113
+ }
1114
+ }
1115
+ const snapshot = yield* jj.snapshot(`smithers action ${stepKeyDigest} attempt ${input.attempt}`);
1116
+ snapshotId = snapshot.commitId;
1117
+ const fields = snapshotFields(snapshotId, snapshot.operationId);
1118
+ snapshotMeta = { ...fields.meta, ...boundaryMeta };
1119
+ yield* atomically(
1120
+ attempts.patch(attemptId, {
1121
+ meta: attemptPayload(
1122
+ { ...declarationMeta, admittedBy: deps.owner, ...snapshotMeta }
1123
+ )
1124
+ }, deps.owner).pipe(Effect.andThen(announceSnapshot(fields)))
1125
+ );
1126
+ }
1127
+ }
1128
+ const failBoundaryAttempt = (cause) => Effect.gen(function* () {
1129
+ const finishedAtMs2 = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
1130
+ const finished2 = yield* settleAttempt({
1131
+ ...attemptId,
1132
+ state: "failed",
1133
+ finishedAtMs: finishedAtMs2,
1134
+ error: attemptPayload(persistCause(cause)),
1135
+ meta: { ...declarationMeta, hardViolation: true }
1136
+ }, [
1137
+ JournalRecords.hardViolation(attemptSource("hard-violation"), { ...attemptId, error: cause }),
1138
+ JournalRecords.attemptFinished(attemptSource("finished"), { ...attemptId, state: "failed" })
1139
+ ]);
1140
+ if (!finished2) {
1141
+ return yield* Effect.interrupt;
1142
+ }
1143
+ return yield* Effect.failCause(cause);
1144
+ });
1145
+ const boundary = input.tier === "sealed" && input.metadata !== void 0 ? yield* StepBoundary.StepBoundary : void 0;
1146
+ const preparedResult = boundary === void 0 || input.metadata === void 0 ? void 0 : yield* boundary.prepare(input.metadata).pipe(Effect.exit);
1147
+ if (preparedResult !== void 0 && Exit.isFailure(preparedResult)) {
1148
+ return yield* failBoundaryAttempt(preparedResult.cause);
1149
+ }
1150
+ const prepared = preparedResult === void 0 ? void 0 : preparedResult.value;
1151
+ const stepSandbox = boundary === void 0 || input.metadata === void 0 ? Option.none() : yield* Effect.serviceOption(StepSandbox.StepSandbox);
1152
+ const opened = Option.isSome(stepSandbox) ? yield* stepSandbox.value.open.pipe(Effect.exit) : void 0;
1153
+ if (opened !== void 0 && Exit.isFailure(opened)) {
1154
+ return yield* failBoundaryAttempt(opened.cause);
1155
+ }
1156
+ const sandbox = boundary === void 0 || input.metadata === void 0 ? void 0 : opened !== void 0 ? opened.value : Option.getOrUndefined(yield* Effect.serviceOption(WorkspaceSandbox.WorkspaceSandbox));
1157
+ const isolated = sandbox === void 0 || input.metadata === void 0 ? void 0 : yield* SandboxedExecution.execute({
1158
+ sandbox,
1159
+ descriptor: input.metadata,
1160
+ workflow: execute(input, stepKeyDigest)
1161
+ }).pipe(Effect.exit);
1162
+ const settlement = isolated !== void 0 && Exit.isSuccess(isolated) ? isolated.value : void 0;
1163
+ const effect = input.tier === "irreversible" || input.tier === "compensable" ? {
1164
+ id: `${deps.runId}:${stepKeyDigest}:${input.attempt}`,
1165
+ kind: actionKind(input.action),
1166
+ tier: input.tier,
1167
+ runId: deps.runId,
1168
+ lineageId,
1169
+ sourceId: deps.sourceId,
1170
+ attempt: input.attempt,
1171
+ ...deps.idempotencyKey === void 0 ? {} : { idempotencyKey: deps.idempotencyKey },
1172
+ ...snapshotId === void 0 ? {} : { changeId: snapshotId }
1173
+ } : void 0;
1174
+ const parked = (cause) => Effect.map(
1175
+ Effect.serviceOption(import_flow.FlowRuntime.FlowInstance),
1176
+ (instance) => evidenceQuarantined(cause) !== void 0 || Option.getOrUndefined(instance)?.suspended === true && Cause.hasInterruptsOnly(cause)
1177
+ );
1178
+ const dispatchMeta = {
1179
+ ...runningMeta,
1180
+ ...declarationMeta,
1181
+ admittedBy: deps.owner,
1182
+ ...snapshotMeta
1183
+ };
1184
+ const recordCrossing = (crossing, patch, record) => Effect.flatMap(
1185
+ atomically(Effect.gen(function* () {
1186
+ if (record !== void 0) {
1187
+ yield* emitLifecycle(record);
1188
+ }
1189
+ const patched = yield* attempts.patch(
1190
+ attemptId,
1191
+ {
1192
+ ...patch,
1193
+ meta: attemptPayload({ ...dispatchMeta, effectCrossing: crossing })
1194
+ },
1195
+ deps.owner
1196
+ );
1197
+ return patched._tag === "Patched";
1198
+ })),
1199
+ (recorded) => recorded ? Effect.void : Effect.interrupt
1200
+ );
1201
+ const dispatch = effect === void 0 ? execute(input, stepKeyDigest) : Effect.uninterruptibleMask(
1202
+ (restore) => Effect.gen(function* () {
1203
+ yield* recordCrossing("intended", {}, EffectRecords.boundary(effect, "intended"));
1204
+ const exit = yield* Effect.exit(restore(execute(input, stepKeyDigest)));
1205
+ yield* Exit.isSuccess(exit) ? recordCrossing(
1206
+ "succeeded",
1207
+ { outcome: attemptPayload(exit.value) },
1208
+ EffectRecords.boundary(effect, "succeeded", exit.value)
1209
+ ) : Effect.flatMap(
1210
+ parked(exit.cause),
1211
+ (isPark) => isPark ? recordCrossing("parked", {}) : emitLifecycle(EffectRecords.boundary(effect, "unknown")).pipe(
1212
+ Effect.catchCause(
1213
+ (cause) => Effect.logWarning("engine-store: failed to persist unknown effect boundary", cause).pipe(
1214
+ Effect.annotateLogs({ runId: deps.runId, step: input.key })
1215
+ )
1216
+ )
1217
+ )
1218
+ );
1219
+ return yield* exit;
1220
+ })
1221
+ );
1222
+ const outcome = isolated === void 0 ? yield* dispatch.pipe(Effect.exit) : Exit.map(isolated, (settled2) => settled2.result);
1223
+ if (Exit.isFailure(outcome)) {
1224
+ if (yield* parked(outcome.cause)) {
1225
+ return yield* Effect.failCause(outcome.cause);
1226
+ }
1227
+ const finishedAtMs2 = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
1228
+ const violation = declarationViolated(outcome.cause);
1229
+ const finished2 = yield* settleAttempt({
1230
+ ...attemptId,
1231
+ state: "failed",
1232
+ finishedAtMs: finishedAtMs2,
1233
+ error: attemptPayload(persistCause(outcome.cause)),
1234
+ meta: attemptPayload(
1235
+ {
1236
+ ...declarationMeta,
1237
+ ...violation ? { hardViolation: true } : {},
1238
+ ...snapshotMeta
1239
+ }
1240
+ )
1241
+ }, [
1242
+ ...violation ? [
1243
+ JournalRecords.hardViolation(attemptSource("hard-violation"), {
1244
+ ...attemptId,
1245
+ error: outcome.cause
1246
+ })
1247
+ ] : [],
1248
+ JournalRecords.attemptFinished(attemptSource("finished"), { ...attemptId, state: "failed" })
1249
+ ]);
1250
+ if (!finished2) {
1251
+ return yield* Effect.interrupt;
1252
+ }
1253
+ return yield* Effect.failCause(outcome.cause);
1254
+ }
1255
+ if (settlement !== void 0) {
1256
+ yield* emitConverging(
1257
+ JournalRecords.diffBundleCaptured(attemptSource("diff-bundle"), {
1258
+ ...attemptId,
1259
+ bundleIdentity: settlement.bundleIdentity,
1260
+ changedPaths: settlement.files.map((change) => change.path),
1261
+ deviations: settlement.deviations
1262
+ })
1263
+ );
1264
+ const dispatcher = Option.getOrUndefined(
1265
+ yield* Effect.serviceOption(WorkspaceSandbox.EffectDispatcher)
1266
+ );
1267
+ const deduped = /* @__PURE__ */ new Set();
1268
+ for (const queued of settlement.effects) {
1269
+ if (deduped.has(queued.idempotencyKey)) continue;
1270
+ deduped.add(queued.idempotencyKey);
1271
+ if (dispatcher !== void 0) yield* dispatcher.dispatch(queued);
1272
+ }
1273
+ yield* emitConverging(
1274
+ JournalRecords.copyBackSettled(attemptSource("copy-back"), {
1275
+ ...attemptId,
1276
+ bundleIdentity: settlement.bundleIdentity,
1277
+ rebases: settlement.rebases,
1278
+ queued: [...deduped],
1279
+ dispatched: dispatcher === void 0 ? [] : [...deduped]
1280
+ })
1281
+ );
1282
+ }
1283
+ const settled = prepared === void 0 || boundary === void 0 ? void 0 : yield* boundary.settle(prepared).pipe(Effect.exit);
1284
+ yield* settled === void 0 ? Effect.void : Metric.update(
1285
+ EngineStoreMetrics.boundarySettlement[Exit.isSuccess(settled) ? settled.value.deviation === void 0 ? "Clean" : "Deviation" : settlementViolated(settled.cause) ? "Violation" : "Refused"],
1286
+ 1
1287
+ );
1288
+ if (settled !== void 0 && Exit.isFailure(settled)) {
1289
+ return yield* failBoundaryAttempt(settled.cause);
1290
+ }
1291
+ const settledEvidence = settled === void 0 ? void 0 : settled.value;
1292
+ const evidence = settledEvidence === void 0 || settlement === void 0 ? settledEvidence : {
1293
+ ...settledEvidence,
1294
+ ...settlement.deviations.length === 0 ? {
1295
+ wholeTreeWritesVerified: true,
1296
+ // `StepSandbox` is the injectable façade; the
1297
+ // `WorkspaceSandbox` service is the same isolated
1298
+ // transaction backend and proves the same read property.
1299
+ hermeticReadsVerified: true
1300
+ } : {
1301
+ deviation: {
1302
+ _tag: "ExpectedSetDeviation",
1303
+ paths: settlement.deviations,
1304
+ diffIdentity: settlement.bundleIdentity
1305
+ }
1306
+ }
1307
+ };
1308
+ const finishedAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor));
1309
+ const readSetVerified = prepared !== void 0 && StepBoundary.readSetMatches(prepared);
1310
+ const meta = {
1311
+ ...declarationMeta,
1312
+ ...snapshotMeta,
1313
+ ...evidence === void 0 ? {} : { boundary: evidence },
1314
+ ...readSetVerified ? { readSetVerified: true } : {}
1315
+ };
1316
+ const finished = yield* settleAttempt(
1317
+ {
1318
+ ...attemptId,
1319
+ state: "succeeded",
1320
+ finishedAtMs,
1321
+ outcome: attemptPayload(outcome.value),
1322
+ meta: attemptPayload(meta)
1323
+ },
1324
+ [
1325
+ ...evidence?.deviation === void 0 ? [] : [
1326
+ JournalRecords.expectedSetDeviation(attemptSource("deviation"), {
1327
+ ...attemptId,
1328
+ ...evidence.deviation
1329
+ })
1330
+ ],
1331
+ JournalRecords.attemptFinished(attemptSource("finished"), { ...attemptId, state: "succeeded" })
1332
+ ]
1333
+ );
1334
+ if (!finished) return yield* Effect.interrupt;
1335
+ const admission2 = CacheAdmission.completion(cacheDeclaration, meta, false);
1336
+ if (admission2._tag === "PublishCompletion") {
1337
+ yield* recordCache({ result: outcome.value, admission: admission2, createdAtMs: finishedAtMs });
1338
+ } else if (admission2.reason === "unverified-recorded-reads") {
1339
+ yield* emitConverging(
1340
+ JournalRecords.cacheProvenance(cacheSource("unverified_read_set"), {
1341
+ keyDigest,
1342
+ action: "unverified_read_set"
1343
+ })
1344
+ );
1345
+ }
1346
+ return outcome.value;
1347
+ })
1348
+ );
1349
+ }).pipe(
1350
+ // The operation's own span is annotated above once the digest exists;
1351
+ // this ambient context gives every child store, boundary, and sandbox
1352
+ // span the dispatch identity as it opens.
1353
+ //
1354
+ // `stepKey`, never `key`: `@smthrs/journal`'s `Redaction.isSensitiveKey`
1355
+ // treats a standalone trailing `key` word as a credential name and
1356
+ // replaces the value, and `RedactedLogger` applies that rule to every
1357
+ // log annotation under a real host. The span uses the same name so a
1358
+ // trace and a log line name the dispatch identically.
1359
+ Effect.annotateSpans({
1360
+ runId: deps.runId,
1361
+ stepKey: input.key,
1362
+ attempt: input.attempt,
1363
+ tier: input.tier
1364
+ }),
1365
+ Effect.annotateLogs({
1366
+ runId: deps.runId,
1367
+ stepKey: input.key,
1368
+ attempt: input.attempt,
1369
+ tier: input.tier
1370
+ }),
1371
+ EngineStoreMetrics.observe({
1372
+ timer: EngineStoreMetrics.dispatchDuration,
1373
+ counter: EngineStoreMetrics.dispatch
1374
+ }),
1375
+ // A dispatch that settled without reaching the gate was served from a
1376
+ // durable record: a recorded success, or a recorded failure it rethrew.
1377
+ // An interruption or a defect settled nothing and reports nothing.
1378
+ Effect.onExit((exit) => {
1379
+ const replayOnly = deps.replayOnly;
1380
+ const stepKeyDigest = replay.stepKeyDigest;
1381
+ if (replayOnly === void 0 || replay.gated || stepKeyDigest === void 0) return Effect.void;
1382
+ if (Exit.isFailure(exit) && (Cause.hasInterrupts(exit.cause) || Cause.hasDies(exit.cause))) return Effect.void;
1383
+ return replayOnly.observe({
1384
+ runId: deps.runId,
1385
+ stepKeyDigest,
1386
+ attempt: input.attempt,
1387
+ action: actionKind(input.action),
1388
+ tier: input.tier,
1389
+ outcome: "replayed"
1390
+ });
1391
+ })
1392
+ );
1393
+ });
1394
+ };
1395
+ //# sourceMappingURL=ActionPersistence.js.map