@smthrs/flow 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 (654) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/LICENSE +21 -0
  3. package/README.md +210 -2
  4. package/THIRD_PARTY_NOTICES.md +52 -0
  5. package/dist/cjs/Action/Action.d.ts +250 -0
  6. package/dist/cjs/Action/Action.d.ts.map +1 -0
  7. package/dist/cjs/Action/Action.js +42 -0
  8. package/dist/cjs/Action/Action.js.map +7 -0
  9. package/dist/cjs/Action/AttemptTimedOut.d.ts +33 -0
  10. package/dist/cjs/Action/AttemptTimedOut.d.ts.map +1 -0
  11. package/dist/cjs/Action/AttemptTimedOut.js +51 -0
  12. package/dist/cjs/Action/AttemptTimedOut.js.map +7 -0
  13. package/dist/cjs/Action/BoundaryMode.d.ts +29 -0
  14. package/dist/cjs/Action/BoundaryMode.d.ts.map +1 -0
  15. package/dist/cjs/Action/BoundaryMode.js +36 -0
  16. package/dist/cjs/Action/BoundaryMode.js.map +7 -0
  17. package/dist/cjs/Action/CacheEnvironment.d.ts +158 -0
  18. package/dist/cjs/Action/CacheEnvironment.d.ts.map +1 -0
  19. package/dist/cjs/Action/CacheEnvironment.js +57 -0
  20. package/dist/cjs/Action/CacheEnvironment.js.map +7 -0
  21. package/dist/cjs/Action/ConcurrentKeylessDispatch.d.ts +34 -0
  22. package/dist/cjs/Action/ConcurrentKeylessDispatch.d.ts.map +1 -0
  23. package/dist/cjs/Action/ConcurrentKeylessDispatch.js +46 -0
  24. package/dist/cjs/Action/ConcurrentKeylessDispatch.js.map +7 -0
  25. package/dist/cjs/Action/Context.d.ts +131 -0
  26. package/dist/cjs/Action/Context.d.ts.map +1 -0
  27. package/dist/cjs/Action/Context.js +68 -0
  28. package/dist/cjs/Action/Context.js.map +7 -0
  29. package/dist/cjs/Action/DuplicateImplementation.d.ts +20 -0
  30. package/dist/cjs/Action/DuplicateImplementation.d.ts.map +1 -0
  31. package/dist/cjs/Action/DuplicateImplementation.js +46 -0
  32. package/dist/cjs/Action/DuplicateImplementation.js.map +7 -0
  33. package/dist/cjs/Action/FileBoundary.d.ts +59 -0
  34. package/dist/cjs/Action/FileBoundary.d.ts.map +1 -0
  35. package/dist/cjs/Action/FileBoundary.js +81 -0
  36. package/dist/cjs/Action/FileBoundary.js.map +7 -0
  37. package/dist/cjs/Action/FileInput.d.ts +28 -0
  38. package/dist/cjs/Action/FileInput.d.ts.map +1 -0
  39. package/dist/cjs/Action/FileInput.js +42 -0
  40. package/dist/cjs/Action/FileInput.js.map +7 -0
  41. package/dist/cjs/Action/Filegroup.d.ts +16 -0
  42. package/dist/cjs/Action/Filegroup.d.ts.map +1 -0
  43. package/dist/cjs/Action/Filegroup.js +27 -0
  44. package/dist/cjs/Action/Filegroup.js.map +7 -0
  45. package/dist/cjs/Action/Glob.d.ts +8 -0
  46. package/dist/cjs/Action/Glob.d.ts.map +1 -0
  47. package/dist/cjs/Action/Glob.js +28 -0
  48. package/dist/cjs/Action/Glob.js.map +7 -0
  49. package/dist/cjs/Action/ImplementationVersionMismatch.d.ts +26 -0
  50. package/dist/cjs/Action/ImplementationVersionMismatch.d.ts.map +1 -0
  51. package/dist/cjs/Action/ImplementationVersionMismatch.js +45 -0
  52. package/dist/cjs/Action/ImplementationVersionMismatch.js.map +7 -0
  53. package/dist/cjs/Action/Implementations.d.ts +114 -0
  54. package/dist/cjs/Action/Implementations.d.ts.map +1 -0
  55. package/dist/cjs/Action/Implementations.js +65 -0
  56. package/dist/cjs/Action/Implementations.js.map +7 -0
  57. package/dist/cjs/Action/InfraInterrupt.d.ts +26 -0
  58. package/dist/cjs/Action/InfraInterrupt.d.ts.map +1 -0
  59. package/dist/cjs/Action/InfraInterrupt.js +46 -0
  60. package/dist/cjs/Action/InfraInterrupt.js.map +7 -0
  61. package/dist/cjs/Action/InfraInterruptRetriesExhausted.d.ts +33 -0
  62. package/dist/cjs/Action/InfraInterruptRetriesExhausted.d.ts.map +1 -0
  63. package/dist/cjs/Action/InfraInterruptRetriesExhausted.js +54 -0
  64. package/dist/cjs/Action/InfraInterruptRetriesExhausted.js.map +7 -0
  65. package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts +26 -0
  66. package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts.map +1 -0
  67. package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.js +47 -0
  68. package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.js.map +7 -0
  69. package/dist/cjs/Action/StepIdentity.d.ts +153 -0
  70. package/dist/cjs/Action/StepIdentity.d.ts.map +1 -0
  71. package/dist/cjs/Action/StepIdentity.js +75 -0
  72. package/dist/cjs/Action/StepIdentity.js.map +7 -0
  73. package/dist/cjs/Action/TreeArtifact.d.ts +8 -0
  74. package/dist/cjs/Action/TreeArtifact.d.ts.map +1 -0
  75. package/dist/cjs/Action/TreeArtifact.js +25 -0
  76. package/dist/cjs/Action/TreeArtifact.js.map +7 -0
  77. package/dist/cjs/Action/TypeId.d.ts +8 -0
  78. package/dist/cjs/Action/TypeId.d.ts.map +1 -0
  79. package/dist/cjs/Action/TypeId.js +25 -0
  80. package/dist/cjs/Action/TypeId.js.map +7 -0
  81. package/dist/cjs/Action/UncanonicalIdempotencyKey.d.ts +32 -0
  82. package/dist/cjs/Action/UncanonicalIdempotencyKey.d.ts.map +1 -0
  83. package/dist/cjs/Action/UncanonicalIdempotencyKey.js +51 -0
  84. package/dist/cjs/Action/UncanonicalIdempotencyKey.js.map +7 -0
  85. package/dist/cjs/Action/idempotencyKey.d.ts +21 -0
  86. package/dist/cjs/Action/idempotencyKey.d.ts.map +1 -0
  87. package/dist/cjs/Action/idempotencyKey.js +59 -0
  88. package/dist/cjs/Action/idempotencyKey.js.map +7 -0
  89. package/dist/cjs/Action/index.d.ts +29 -0
  90. package/dist/cjs/Action/index.d.ts.map +1 -0
  91. package/dist/cjs/Action/index.js +60 -0
  92. package/dist/cjs/Action/index.js.map +7 -0
  93. package/dist/cjs/Action/make.d.ts +128 -0
  94. package/dist/cjs/Action/make.d.ts.map +1 -0
  95. package/dist/cjs/Action/make.js +373 -0
  96. package/dist/cjs/Action/make.js.map +7 -0
  97. package/dist/cjs/Action/raceAll.d.ts +21 -0
  98. package/dist/cjs/Action/raceAll.d.ts.map +1 -0
  99. package/dist/cjs/Action/raceAll.js +46 -0
  100. package/dist/cjs/Action/raceAll.js.map +7 -0
  101. package/dist/cjs/Action/retry.d.ts +19 -0
  102. package/dist/cjs/Action/retry.d.ts.map +1 -0
  103. package/dist/cjs/Action/retry.js +75 -0
  104. package/dist/cjs/Action/retry.js.map +7 -0
  105. package/dist/cjs/Deadline.d.ts +105 -0
  106. package/dist/cjs/Deadline.d.ts.map +1 -0
  107. package/dist/cjs/Deadline.js +104 -0
  108. package/dist/cjs/Deadline.js.map +7 -0
  109. package/dist/cjs/DurableClock.d.ts +61 -0
  110. package/dist/cjs/DurableClock.d.ts.map +1 -0
  111. package/dist/cjs/DurableClock.js +90 -0
  112. package/dist/cjs/DurableClock.js.map +7 -0
  113. package/dist/cjs/DurableDeferred.d.ts +311 -0
  114. package/dist/cjs/DurableDeferred.d.ts.map +1 -0
  115. package/dist/cjs/DurableDeferred.js +322 -0
  116. package/dist/cjs/DurableDeferred.js.map +7 -0
  117. package/dist/cjs/DurableQueue.d.ts +160 -0
  118. package/dist/cjs/DurableQueue.d.ts.map +1 -0
  119. package/dist/cjs/DurableQueue.js +229 -0
  120. package/dist/cjs/DurableQueue.js.map +7 -0
  121. package/dist/cjs/ExternalJob.d.ts +179 -0
  122. package/dist/cjs/ExternalJob.d.ts.map +1 -0
  123. package/dist/cjs/ExternalJob.js +338 -0
  124. package/dist/cjs/ExternalJob.js.map +7 -0
  125. package/dist/cjs/Fault.d.ts +131 -0
  126. package/dist/cjs/Fault.d.ts.map +1 -0
  127. package/dist/cjs/Fault.js +157 -0
  128. package/dist/cjs/Fault.js.map +7 -0
  129. package/dist/cjs/Flow/Annotations.d.ts +245 -0
  130. package/dist/cjs/Flow/Annotations.d.ts.map +1 -0
  131. package/dist/cjs/Flow/Annotations.js +72 -0
  132. package/dist/cjs/Flow/Annotations.js.map +7 -0
  133. package/dist/cjs/Flow/CapabilityCeiling.d.ts +21 -0
  134. package/dist/cjs/Flow/CapabilityCeiling.d.ts.map +1 -0
  135. package/dist/cjs/Flow/CapabilityCeiling.js +49 -0
  136. package/dist/cjs/Flow/CapabilityCeiling.js.map +7 -0
  137. package/dist/cjs/Flow/DeadlineExceeded.d.ts +33 -0
  138. package/dist/cjs/Flow/DeadlineExceeded.d.ts.map +1 -0
  139. package/dist/cjs/Flow/DeadlineExceeded.js +52 -0
  140. package/dist/cjs/Flow/DeadlineExceeded.js.map +7 -0
  141. package/dist/cjs/Flow/ExecutionIdRequired.d.ts +25 -0
  142. package/dist/cjs/Flow/ExecutionIdRequired.d.ts.map +1 -0
  143. package/dist/cjs/Flow/ExecutionIdRequired.js +46 -0
  144. package/dist/cjs/Flow/ExecutionIdRequired.js.map +7 -0
  145. package/dist/cjs/Flow/ExecutionIds.d.ts +80 -0
  146. package/dist/cjs/Flow/ExecutionIds.d.ts.map +1 -0
  147. package/dist/cjs/Flow/ExecutionIds.js +66 -0
  148. package/dist/cjs/Flow/ExecutionIds.js.map +7 -0
  149. package/dist/cjs/Flow/Flow.d.ts +422 -0
  150. package/dist/cjs/Flow/Flow.d.ts.map +1 -0
  151. package/dist/cjs/Flow/Flow.js +17 -0
  152. package/dist/cjs/Flow/Flow.js.map +7 -0
  153. package/dist/cjs/Flow/MaxRoundsExceeded.d.ts +35 -0
  154. package/dist/cjs/Flow/MaxRoundsExceeded.d.ts.map +1 -0
  155. package/dist/cjs/Flow/MaxRoundsExceeded.js +50 -0
  156. package/dist/cjs/Flow/MaxRoundsExceeded.js.map +7 -0
  157. package/dist/cjs/Flow/Outcome.d.ts +162 -0
  158. package/dist/cjs/Flow/Outcome.d.ts.map +1 -0
  159. package/dist/cjs/Flow/Outcome.js +80 -0
  160. package/dist/cjs/Flow/Outcome.js.map +7 -0
  161. package/dist/cjs/Flow/Result.d.ts +186 -0
  162. package/dist/cjs/Flow/Result.d.ts.map +1 -0
  163. package/dist/cjs/Flow/Result.js +159 -0
  164. package/dist/cjs/Flow/Result.js.map +7 -0
  165. package/dist/cjs/Flow/Runtime.d.ts +98 -0
  166. package/dist/cjs/Flow/Runtime.d.ts.map +1 -0
  167. package/dist/cjs/Flow/Runtime.js +160 -0
  168. package/dist/cjs/Flow/Runtime.js.map +7 -0
  169. package/dist/cjs/Flow/TypeId.d.ts +8 -0
  170. package/dist/cjs/Flow/TypeId.d.ts.map +1 -0
  171. package/dist/cjs/Flow/TypeId.js +25 -0
  172. package/dist/cjs/Flow/TypeId.js.map +7 -0
  173. package/dist/cjs/Flow/index.d.ts +17 -0
  174. package/dist/cjs/Flow/index.d.ts.map +1 -0
  175. package/dist/cjs/Flow/index.js +29 -0
  176. package/dist/cjs/Flow/index.js.map +7 -0
  177. package/dist/cjs/Flow/internal.d.ts +34 -0
  178. package/dist/cjs/Flow/internal.d.ts.map +1 -0
  179. package/dist/cjs/Flow/internal.js +187 -0
  180. package/dist/cjs/Flow/internal.js.map +7 -0
  181. package/dist/cjs/Flow/make.d.ts +134 -0
  182. package/dist/cjs/Flow/make.d.ts.map +1 -0
  183. package/dist/cjs/Flow/make.js +104 -0
  184. package/dist/cjs/Flow/make.js.map +7 -0
  185. package/dist/cjs/FlowRuntime/CancelRequestFailed.d.ts +55 -0
  186. package/dist/cjs/FlowRuntime/CancelRequestFailed.d.ts.map +1 -0
  187. package/dist/cjs/FlowRuntime/CancelRequestFailed.js +51 -0
  188. package/dist/cjs/FlowRuntime/CancelRequestFailed.js.map +7 -0
  189. package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.d.ts +23 -0
  190. package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.d.ts.map +1 -0
  191. package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.js +55 -0
  192. package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.js.map +7 -0
  193. package/dist/cjs/FlowRuntime/FlowCycleDetected.d.ts +28 -0
  194. package/dist/cjs/FlowRuntime/FlowCycleDetected.d.ts.map +1 -0
  195. package/dist/cjs/FlowRuntime/FlowCycleDetected.js +49 -0
  196. package/dist/cjs/FlowRuntime/FlowCycleDetected.js.map +7 -0
  197. package/dist/cjs/FlowRuntime/FlowExecutionNotFound.d.ts +38 -0
  198. package/dist/cjs/FlowRuntime/FlowExecutionNotFound.d.ts.map +1 -0
  199. package/dist/cjs/FlowRuntime/FlowExecutionNotFound.js +53 -0
  200. package/dist/cjs/FlowRuntime/FlowExecutionNotFound.js.map +7 -0
  201. package/dist/cjs/FlowRuntime/FlowInstance.d.ts +115 -0
  202. package/dist/cjs/FlowRuntime/FlowInstance.d.ts.map +1 -0
  203. package/dist/cjs/FlowRuntime/FlowInstance.js +37 -0
  204. package/dist/cjs/FlowRuntime/FlowInstance.js.map +7 -0
  205. package/dist/cjs/FlowRuntime/FlowRuntime.d.ts +198 -0
  206. package/dist/cjs/FlowRuntime/FlowRuntime.d.ts.map +1 -0
  207. package/dist/cjs/FlowRuntime/FlowRuntime.js +37 -0
  208. package/dist/cjs/FlowRuntime/FlowRuntime.js.map +7 -0
  209. package/dist/cjs/FlowRuntime/NodeRecord.d.ts +175 -0
  210. package/dist/cjs/FlowRuntime/NodeRecord.d.ts.map +1 -0
  211. package/dist/cjs/FlowRuntime/NodeRecord.js +17 -0
  212. package/dist/cjs/FlowRuntime/NodeRecord.js.map +7 -0
  213. package/dist/cjs/FlowRuntime/WaitingAnnotation.d.ts +69 -0
  214. package/dist/cjs/FlowRuntime/WaitingAnnotation.d.ts.map +1 -0
  215. package/dist/cjs/FlowRuntime/WaitingAnnotation.js +53 -0
  216. package/dist/cjs/FlowRuntime/WaitingAnnotation.js.map +7 -0
  217. package/dist/cjs/FlowRuntime/index.d.ts +14 -0
  218. package/dist/cjs/FlowRuntime/index.d.ts.map +1 -0
  219. package/dist/cjs/FlowRuntime/index.js +26 -0
  220. package/dist/cjs/FlowRuntime/index.js.map +7 -0
  221. package/dist/cjs/Graph.d.ts +325 -0
  222. package/dist/cjs/Graph.d.ts.map +1 -0
  223. package/dist/cjs/Graph.js +1022 -0
  224. package/dist/cjs/Graph.js.map +7 -0
  225. package/dist/cjs/HumanTask.d.ts +440 -0
  226. package/dist/cjs/HumanTask.d.ts.map +1 -0
  227. package/dist/cjs/HumanTask.js +413 -0
  228. package/dist/cjs/HumanTask.js.map +7 -0
  229. package/dist/cjs/Interpreter.d.ts +222 -0
  230. package/dist/cjs/Interpreter.d.ts.map +1 -0
  231. package/dist/cjs/Interpreter.js +888 -0
  232. package/dist/cjs/Interpreter.js.map +7 -0
  233. package/dist/cjs/Poll.d.ts +238 -0
  234. package/dist/cjs/Poll.d.ts.map +1 -0
  235. package/dist/cjs/Poll.js +150 -0
  236. package/dist/cjs/Poll.js.map +7 -0
  237. package/dist/cjs/RetryPolicy.d.ts +273 -0
  238. package/dist/cjs/RetryPolicy.d.ts.map +1 -0
  239. package/dist/cjs/RetryPolicy.js +251 -0
  240. package/dist/cjs/RetryPolicy.js.map +7 -0
  241. package/dist/cjs/Sleep.d.ts +98 -0
  242. package/dist/cjs/Sleep.d.ts.map +1 -0
  243. package/dist/cjs/Sleep.js +133 -0
  244. package/dist/cjs/Sleep.js.map +7 -0
  245. package/dist/cjs/Stall.d.ts +173 -0
  246. package/dist/cjs/Stall.d.ts.map +1 -0
  247. package/dist/cjs/Stall.js +92 -0
  248. package/dist/cjs/Stall.js.map +7 -0
  249. package/dist/cjs/WaitFor.d.ts +109 -0
  250. package/dist/cjs/WaitFor.d.ts.map +1 -0
  251. package/dist/cjs/WaitFor.js +117 -0
  252. package/dist/cjs/WaitFor.js.map +7 -0
  253. package/dist/cjs/index.d.ts +107 -0
  254. package/dist/cjs/index.d.ts.map +1 -0
  255. package/dist/cjs/index.js +69 -0
  256. package/dist/cjs/index.js.map +7 -0
  257. package/dist/cjs/internal/BoundedJson.d.ts +48 -0
  258. package/dist/cjs/internal/BoundedJson.d.ts.map +1 -0
  259. package/dist/cjs/internal/BoundedJson.js +96 -0
  260. package/dist/cjs/internal/BoundedJson.js.map +7 -0
  261. package/dist/cjs/internal/DeclarationSite.d.ts +135 -0
  262. package/dist/cjs/internal/DeclarationSite.d.ts.map +1 -0
  263. package/dist/cjs/internal/DeclarationSite.js +89 -0
  264. package/dist/cjs/internal/DeclarationSite.js.map +7 -0
  265. package/dist/cjs/internal/Declarations.d.ts +35 -0
  266. package/dist/cjs/internal/Declarations.d.ts.map +1 -0
  267. package/dist/cjs/internal/Declarations.js +50 -0
  268. package/dist/cjs/internal/Declarations.js.map +7 -0
  269. package/dist/cjs/internal/ExecutionMiddleware.d.ts +21 -0
  270. package/dist/cjs/internal/ExecutionMiddleware.d.ts.map +1 -0
  271. package/dist/cjs/internal/ExecutionMiddleware.js +39 -0
  272. package/dist/cjs/internal/ExecutionMiddleware.js.map +7 -0
  273. package/dist/cjs/internal/JsonSchemaSubset.d.ts +133 -0
  274. package/dist/cjs/internal/JsonSchemaSubset.d.ts.map +1 -0
  275. package/dist/cjs/internal/JsonSchemaSubset.js +229 -0
  276. package/dist/cjs/internal/JsonSchemaSubset.js.map +7 -0
  277. package/dist/cjs/internal/OutcomeMarker.d.ts +18 -0
  278. package/dist/cjs/internal/OutcomeMarker.d.ts.map +1 -0
  279. package/dist/cjs/internal/OutcomeMarker.js +27 -0
  280. package/dist/cjs/internal/OutcomeMarker.js.map +7 -0
  281. package/dist/cjs/package.json +1 -0
  282. package/dist/esm/Action/Action.d.ts +250 -0
  283. package/dist/esm/Action/Action.d.ts.map +1 -0
  284. package/dist/esm/Action/Action.js +30 -0
  285. package/dist/esm/Action/Action.js.map +1 -0
  286. package/dist/esm/Action/AttemptTimedOut.d.ts +33 -0
  287. package/dist/esm/Action/AttemptTimedOut.d.ts.map +1 -0
  288. package/dist/esm/Action/AttemptTimedOut.js +32 -0
  289. package/dist/esm/Action/AttemptTimedOut.js.map +1 -0
  290. package/dist/esm/Action/BoundaryMode.d.ts +29 -0
  291. package/dist/esm/Action/BoundaryMode.d.ts.map +1 -0
  292. package/dist/esm/Action/BoundaryMode.js +23 -0
  293. package/dist/esm/Action/BoundaryMode.js.map +1 -0
  294. package/dist/esm/Action/CacheEnvironment.d.ts +158 -0
  295. package/dist/esm/Action/CacheEnvironment.d.ts.map +1 -0
  296. package/dist/esm/Action/CacheEnvironment.js +130 -0
  297. package/dist/esm/Action/CacheEnvironment.js.map +1 -0
  298. package/dist/esm/Action/ConcurrentKeylessDispatch.d.ts +34 -0
  299. package/dist/esm/Action/ConcurrentKeylessDispatch.d.ts.map +1 -0
  300. package/dist/esm/Action/ConcurrentKeylessDispatch.js +33 -0
  301. package/dist/esm/Action/ConcurrentKeylessDispatch.js.map +1 -0
  302. package/dist/esm/Action/Context.d.ts +131 -0
  303. package/dist/esm/Action/Context.d.ts.map +1 -0
  304. package/dist/esm/Action/Context.js +99 -0
  305. package/dist/esm/Action/Context.js.map +1 -0
  306. package/dist/esm/Action/DuplicateImplementation.d.ts +20 -0
  307. package/dist/esm/Action/DuplicateImplementation.d.ts.map +1 -0
  308. package/dist/esm/Action/DuplicateImplementation.js +20 -0
  309. package/dist/esm/Action/DuplicateImplementation.js.map +1 -0
  310. package/dist/esm/Action/FileBoundary.d.ts +59 -0
  311. package/dist/esm/Action/FileBoundary.d.ts.map +1 -0
  312. package/dist/esm/Action/FileBoundary.js +60 -0
  313. package/dist/esm/Action/FileBoundary.js.map +1 -0
  314. package/dist/esm/Action/FileInput.d.ts +28 -0
  315. package/dist/esm/Action/FileInput.d.ts.map +1 -0
  316. package/dist/esm/Action/FileInput.js +32 -0
  317. package/dist/esm/Action/FileInput.js.map +1 -0
  318. package/dist/esm/Action/Filegroup.d.ts +16 -0
  319. package/dist/esm/Action/Filegroup.d.ts.map +1 -0
  320. package/dist/esm/Action/Filegroup.js +15 -0
  321. package/dist/esm/Action/Filegroup.js.map +1 -0
  322. package/dist/esm/Action/Glob.d.ts +8 -0
  323. package/dist/esm/Action/Glob.d.ts.map +1 -0
  324. package/dist/esm/Action/Glob.js +7 -0
  325. package/dist/esm/Action/Glob.js.map +1 -0
  326. package/dist/esm/Action/ImplementationVersionMismatch.d.ts +26 -0
  327. package/dist/esm/Action/ImplementationVersionMismatch.d.ts.map +1 -0
  328. package/dist/esm/Action/ImplementationVersionMismatch.js +24 -0
  329. package/dist/esm/Action/ImplementationVersionMismatch.js.map +1 -0
  330. package/dist/esm/Action/Implementations.d.ts +114 -0
  331. package/dist/esm/Action/Implementations.d.ts.map +1 -0
  332. package/dist/esm/Action/Implementations.js +94 -0
  333. package/dist/esm/Action/Implementations.js.map +1 -0
  334. package/dist/esm/Action/InfraInterrupt.d.ts +26 -0
  335. package/dist/esm/Action/InfraInterrupt.d.ts.map +1 -0
  336. package/dist/esm/Action/InfraInterrupt.js +25 -0
  337. package/dist/esm/Action/InfraInterrupt.js.map +1 -0
  338. package/dist/esm/Action/InfraInterruptRetriesExhausted.d.ts +33 -0
  339. package/dist/esm/Action/InfraInterruptRetriesExhausted.d.ts.map +1 -0
  340. package/dist/esm/Action/InfraInterruptRetriesExhausted.js +32 -0
  341. package/dist/esm/Action/InfraInterruptRetriesExhausted.js.map +1 -0
  342. package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts +26 -0
  343. package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts.map +1 -0
  344. package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.js +25 -0
  345. package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.js.map +1 -0
  346. package/dist/esm/Action/StepIdentity.d.ts +153 -0
  347. package/dist/esm/Action/StepIdentity.d.ts.map +1 -0
  348. package/dist/esm/Action/StepIdentity.js +139 -0
  349. package/dist/esm/Action/StepIdentity.js.map +1 -0
  350. package/dist/esm/Action/TreeArtifact.d.ts +8 -0
  351. package/dist/esm/Action/TreeArtifact.d.ts.map +1 -0
  352. package/dist/esm/Action/TreeArtifact.js +7 -0
  353. package/dist/esm/Action/TreeArtifact.js.map +1 -0
  354. package/dist/esm/Action/TypeId.d.ts +8 -0
  355. package/dist/esm/Action/TypeId.d.ts.map +1 -0
  356. package/dist/esm/Action/TypeId.js +9 -0
  357. package/dist/esm/Action/TypeId.js.map +1 -0
  358. package/dist/esm/Action/UncanonicalIdempotencyKey.d.ts +32 -0
  359. package/dist/esm/Action/UncanonicalIdempotencyKey.d.ts.map +1 -0
  360. package/dist/esm/Action/UncanonicalIdempotencyKey.js +31 -0
  361. package/dist/esm/Action/UncanonicalIdempotencyKey.js.map +1 -0
  362. package/dist/esm/Action/idempotencyKey.d.ts +21 -0
  363. package/dist/esm/Action/idempotencyKey.d.ts.map +1 -0
  364. package/dist/esm/Action/idempotencyKey.js +50 -0
  365. package/dist/esm/Action/idempotencyKey.js.map +1 -0
  366. package/dist/esm/Action/index.d.ts +29 -0
  367. package/dist/esm/Action/index.d.ts.map +1 -0
  368. package/dist/esm/Action/index.js +30 -0
  369. package/dist/esm/Action/index.js.map +1 -0
  370. package/dist/esm/Action/make.d.ts +128 -0
  371. package/dist/esm/Action/make.d.ts.map +1 -0
  372. package/dist/esm/Action/make.js +405 -0
  373. package/dist/esm/Action/make.js.map +1 -0
  374. package/dist/esm/Action/raceAll.d.ts +21 -0
  375. package/dist/esm/Action/raceAll.d.ts.map +1 -0
  376. package/dist/esm/Action/raceAll.js +20 -0
  377. package/dist/esm/Action/raceAll.js.map +1 -0
  378. package/dist/esm/Action/retry.d.ts +19 -0
  379. package/dist/esm/Action/retry.d.ts.map +1 -0
  380. package/dist/esm/Action/retry.js +72 -0
  381. package/dist/esm/Action/retry.js.map +1 -0
  382. package/dist/esm/Deadline.d.ts +105 -0
  383. package/dist/esm/Deadline.d.ts.map +1 -0
  384. package/dist/esm/Deadline.js +152 -0
  385. package/dist/esm/Deadline.js.map +1 -0
  386. package/dist/esm/DurableClock.d.ts +61 -0
  387. package/dist/esm/DurableClock.d.ts.map +1 -0
  388. package/dist/esm/DurableClock.js +75 -0
  389. package/dist/esm/DurableClock.js.map +1 -0
  390. package/dist/esm/DurableDeferred.d.ts +311 -0
  391. package/dist/esm/DurableDeferred.d.ts.map +1 -0
  392. package/dist/esm/DurableDeferred.js +357 -0
  393. package/dist/esm/DurableDeferred.js.map +1 -0
  394. package/dist/esm/DurableQueue.d.ts +160 -0
  395. package/dist/esm/DurableQueue.d.ts.map +1 -0
  396. package/dist/esm/DurableQueue.js +303 -0
  397. package/dist/esm/DurableQueue.js.map +1 -0
  398. package/dist/esm/ExternalJob.d.ts +179 -0
  399. package/dist/esm/ExternalJob.d.ts.map +1 -0
  400. package/dist/esm/ExternalJob.js +296 -0
  401. package/dist/esm/ExternalJob.js.map +1 -0
  402. package/dist/esm/Fault.d.ts +131 -0
  403. package/dist/esm/Fault.d.ts.map +1 -0
  404. package/dist/esm/Fault.js +198 -0
  405. package/dist/esm/Fault.js.map +1 -0
  406. package/dist/esm/Flow/Annotations.d.ts +245 -0
  407. package/dist/esm/Flow/Annotations.d.ts.map +1 -0
  408. package/dist/esm/Flow/Annotations.js +110 -0
  409. package/dist/esm/Flow/Annotations.js.map +1 -0
  410. package/dist/esm/Flow/CapabilityCeiling.d.ts +21 -0
  411. package/dist/esm/Flow/CapabilityCeiling.d.ts.map +1 -0
  412. package/dist/esm/Flow/CapabilityCeiling.js +27 -0
  413. package/dist/esm/Flow/CapabilityCeiling.js.map +1 -0
  414. package/dist/esm/Flow/DeadlineExceeded.d.ts +33 -0
  415. package/dist/esm/Flow/DeadlineExceeded.d.ts.map +1 -0
  416. package/dist/esm/Flow/DeadlineExceeded.js +34 -0
  417. package/dist/esm/Flow/DeadlineExceeded.js.map +1 -0
  418. package/dist/esm/Flow/ExecutionIdRequired.d.ts +25 -0
  419. package/dist/esm/Flow/ExecutionIdRequired.d.ts.map +1 -0
  420. package/dist/esm/Flow/ExecutionIdRequired.js +30 -0
  421. package/dist/esm/Flow/ExecutionIdRequired.js.map +1 -0
  422. package/dist/esm/Flow/ExecutionIds.d.ts +80 -0
  423. package/dist/esm/Flow/ExecutionIds.d.ts.map +1 -0
  424. package/dist/esm/Flow/ExecutionIds.js +91 -0
  425. package/dist/esm/Flow/ExecutionIds.js.map +1 -0
  426. package/dist/esm/Flow/Flow.d.ts +422 -0
  427. package/dist/esm/Flow/Flow.d.ts.map +1 -0
  428. package/dist/esm/Flow/Flow.js +3 -0
  429. package/dist/esm/Flow/Flow.js.map +1 -0
  430. package/dist/esm/Flow/MaxRoundsExceeded.d.ts +35 -0
  431. package/dist/esm/Flow/MaxRoundsExceeded.d.ts.map +1 -0
  432. package/dist/esm/Flow/MaxRoundsExceeded.js +34 -0
  433. package/dist/esm/Flow/MaxRoundsExceeded.js.map +1 -0
  434. package/dist/esm/Flow/Outcome.d.ts +162 -0
  435. package/dist/esm/Flow/Outcome.d.ts.map +1 -0
  436. package/dist/esm/Flow/Outcome.js +115 -0
  437. package/dist/esm/Flow/Outcome.js.map +1 -0
  438. package/dist/esm/Flow/Result.d.ts +186 -0
  439. package/dist/esm/Flow/Result.d.ts.map +1 -0
  440. package/dist/esm/Flow/Result.js +171 -0
  441. package/dist/esm/Flow/Result.js.map +1 -0
  442. package/dist/esm/Flow/Runtime.d.ts +98 -0
  443. package/dist/esm/Flow/Runtime.d.ts.map +1 -0
  444. package/dist/esm/Flow/Runtime.js +231 -0
  445. package/dist/esm/Flow/Runtime.js.map +1 -0
  446. package/dist/esm/Flow/TypeId.d.ts +8 -0
  447. package/dist/esm/Flow/TypeId.d.ts.map +1 -0
  448. package/dist/esm/Flow/TypeId.js +9 -0
  449. package/dist/esm/Flow/TypeId.js.map +1 -0
  450. package/dist/esm/Flow/index.d.ts +17 -0
  451. package/dist/esm/Flow/index.d.ts.map +1 -0
  452. package/dist/esm/Flow/index.js +18 -0
  453. package/dist/esm/Flow/index.js.map +1 -0
  454. package/dist/esm/Flow/internal.d.ts +34 -0
  455. package/dist/esm/Flow/internal.d.ts.map +1 -0
  456. package/dist/esm/Flow/internal.js +149 -0
  457. package/dist/esm/Flow/internal.js.map +1 -0
  458. package/dist/esm/Flow/make.d.ts +134 -0
  459. package/dist/esm/Flow/make.d.ts.map +1 -0
  460. package/dist/esm/Flow/make.js +106 -0
  461. package/dist/esm/Flow/make.js.map +1 -0
  462. package/dist/esm/FlowRuntime/CancelRequestFailed.d.ts +55 -0
  463. package/dist/esm/FlowRuntime/CancelRequestFailed.d.ts.map +1 -0
  464. package/dist/esm/FlowRuntime/CancelRequestFailed.js +53 -0
  465. package/dist/esm/FlowRuntime/CancelRequestFailed.js.map +1 -0
  466. package/dist/esm/FlowRuntime/ExecutionIdentityConflict.d.ts +23 -0
  467. package/dist/esm/FlowRuntime/ExecutionIdentityConflict.d.ts.map +1 -0
  468. package/dist/esm/FlowRuntime/ExecutionIdentityConflict.js +24 -0
  469. package/dist/esm/FlowRuntime/ExecutionIdentityConflict.js.map +1 -0
  470. package/dist/esm/FlowRuntime/FlowCycleDetected.d.ts +28 -0
  471. package/dist/esm/FlowRuntime/FlowCycleDetected.d.ts.map +1 -0
  472. package/dist/esm/FlowRuntime/FlowCycleDetected.js +35 -0
  473. package/dist/esm/FlowRuntime/FlowCycleDetected.js.map +1 -0
  474. package/dist/esm/FlowRuntime/FlowExecutionNotFound.d.ts +38 -0
  475. package/dist/esm/FlowRuntime/FlowExecutionNotFound.d.ts.map +1 -0
  476. package/dist/esm/FlowRuntime/FlowExecutionNotFound.js +40 -0
  477. package/dist/esm/FlowRuntime/FlowExecutionNotFound.js.map +1 -0
  478. package/dist/esm/FlowRuntime/FlowInstance.d.ts +115 -0
  479. package/dist/esm/FlowRuntime/FlowInstance.d.ts.map +1 -0
  480. package/dist/esm/FlowRuntime/FlowInstance.js +24 -0
  481. package/dist/esm/FlowRuntime/FlowInstance.js.map +1 -0
  482. package/dist/esm/FlowRuntime/FlowRuntime.d.ts +198 -0
  483. package/dist/esm/FlowRuntime/FlowRuntime.d.ts.map +1 -0
  484. package/dist/esm/FlowRuntime/FlowRuntime.js +34 -0
  485. package/dist/esm/FlowRuntime/FlowRuntime.js.map +1 -0
  486. package/dist/esm/FlowRuntime/NodeRecord.d.ts +175 -0
  487. package/dist/esm/FlowRuntime/NodeRecord.d.ts.map +1 -0
  488. package/dist/esm/FlowRuntime/NodeRecord.js +21 -0
  489. package/dist/esm/FlowRuntime/NodeRecord.js.map +1 -0
  490. package/dist/esm/FlowRuntime/WaitingAnnotation.d.ts +69 -0
  491. package/dist/esm/FlowRuntime/WaitingAnnotation.d.ts.map +1 -0
  492. package/dist/esm/FlowRuntime/WaitingAnnotation.js +53 -0
  493. package/dist/esm/FlowRuntime/WaitingAnnotation.js.map +1 -0
  494. package/dist/esm/FlowRuntime/index.d.ts +14 -0
  495. package/dist/esm/FlowRuntime/index.d.ts.map +1 -0
  496. package/dist/esm/FlowRuntime/index.js +15 -0
  497. package/dist/esm/FlowRuntime/index.js.map +1 -0
  498. package/dist/esm/Graph.d.ts +325 -0
  499. package/dist/esm/Graph.d.ts.map +1 -0
  500. package/dist/esm/Graph.js +1482 -0
  501. package/dist/esm/Graph.js.map +1 -0
  502. package/dist/esm/HumanTask.d.ts +440 -0
  503. package/dist/esm/HumanTask.d.ts.map +1 -0
  504. package/dist/esm/HumanTask.js +794 -0
  505. package/dist/esm/HumanTask.js.map +1 -0
  506. package/dist/esm/Interpreter.d.ts +222 -0
  507. package/dist/esm/Interpreter.d.ts.map +1 -0
  508. package/dist/esm/Interpreter.js +1269 -0
  509. package/dist/esm/Interpreter.js.map +1 -0
  510. package/dist/esm/Poll.d.ts +238 -0
  511. package/dist/esm/Poll.d.ts.map +1 -0
  512. package/dist/esm/Poll.js +282 -0
  513. package/dist/esm/Poll.js.map +1 -0
  514. package/dist/esm/RetryPolicy.d.ts +273 -0
  515. package/dist/esm/RetryPolicy.d.ts.map +1 -0
  516. package/dist/esm/RetryPolicy.js +429 -0
  517. package/dist/esm/RetryPolicy.js.map +1 -0
  518. package/dist/esm/Sleep.d.ts +98 -0
  519. package/dist/esm/Sleep.d.ts.map +1 -0
  520. package/dist/esm/Sleep.js +230 -0
  521. package/dist/esm/Sleep.js.map +1 -0
  522. package/dist/esm/Stall.d.ts +173 -0
  523. package/dist/esm/Stall.d.ts.map +1 -0
  524. package/dist/esm/Stall.js +138 -0
  525. package/dist/esm/Stall.js.map +1 -0
  526. package/dist/esm/WaitFor.d.ts +109 -0
  527. package/dist/esm/WaitFor.d.ts.map +1 -0
  528. package/dist/esm/WaitFor.js +184 -0
  529. package/dist/esm/WaitFor.js.map +1 -0
  530. package/dist/esm/index.d.ts +107 -0
  531. package/dist/esm/index.d.ts.map +1 -0
  532. package/dist/esm/index.js +108 -0
  533. package/dist/esm/index.js.map +1 -0
  534. package/dist/esm/internal/BoundedJson.d.ts +48 -0
  535. package/dist/esm/internal/BoundedJson.d.ts.map +1 -0
  536. package/dist/esm/internal/BoundedJson.js +107 -0
  537. package/dist/esm/internal/BoundedJson.js.map +1 -0
  538. package/dist/esm/internal/DeclarationSite.d.ts +135 -0
  539. package/dist/esm/internal/DeclarationSite.d.ts.map +1 -0
  540. package/dist/esm/internal/DeclarationSite.js +196 -0
  541. package/dist/esm/internal/DeclarationSite.js.map +1 -0
  542. package/dist/esm/internal/Declarations.d.ts +35 -0
  543. package/dist/esm/internal/Declarations.d.ts.map +1 -0
  544. package/dist/esm/internal/Declarations.js +43 -0
  545. package/dist/esm/internal/Declarations.js.map +1 -0
  546. package/dist/esm/internal/ExecutionMiddleware.d.ts +21 -0
  547. package/dist/esm/internal/ExecutionMiddleware.d.ts.map +1 -0
  548. package/dist/esm/internal/ExecutionMiddleware.js +13 -0
  549. package/dist/esm/internal/ExecutionMiddleware.js.map +1 -0
  550. package/dist/esm/internal/JsonSchemaSubset.d.ts +133 -0
  551. package/dist/esm/internal/JsonSchemaSubset.d.ts.map +1 -0
  552. package/dist/esm/internal/JsonSchemaSubset.js +363 -0
  553. package/dist/esm/internal/JsonSchemaSubset.js.map +1 -0
  554. package/dist/esm/internal/OutcomeMarker.d.ts +18 -0
  555. package/dist/esm/internal/OutcomeMarker.d.ts.map +1 -0
  556. package/dist/esm/internal/OutcomeMarker.js +18 -0
  557. package/dist/esm/internal/OutcomeMarker.js.map +1 -0
  558. package/docs/README.md +150 -0
  559. package/docs/api.md +436 -0
  560. package/docs/concepts/bodies-and-plans.md +157 -0
  561. package/docs/concepts/execution-identity.md +142 -0
  562. package/docs/concepts/flows-and-actions.md +129 -0
  563. package/docs/concepts/suspension-and-replay.md +130 -0
  564. package/docs/concepts/the-runtime-port.md +110 -0
  565. package/docs/concepts/trampoline-rounds.md +151 -0
  566. package/docs/guides/ask-a-person.md +184 -0
  567. package/docs/guides/build-a-body.md +161 -0
  568. package/docs/guides/cancel-and-roll-back.md +112 -0
  569. package/docs/guides/implement-an-action.md +147 -0
  570. package/docs/guides/inspect-the-plan.md +154 -0
  571. package/docs/guides/poll-until-ready.md +167 -0
  572. package/docs/guides/queue-work-to-a-worker.md +122 -0
  573. package/docs/guides/retry-a-failing-action.md +243 -0
  574. package/docs/guides/reuse-a-recorded-result.md +122 -0
  575. package/docs/guides/run-a-child-flow.md +108 -0
  576. package/docs/guides/run-an-external-job.md +86 -0
  577. package/docs/guides/use-a-prompt.md +38 -0
  578. package/docs/guides/wait-for-a-deadline.md +141 -0
  579. package/docs/guides/wait-for-an-external-signal.md +151 -0
  580. package/docs/installation.md +82 -0
  581. package/docs/quickstart.md +155 -0
  582. package/docs/reference/flow.md +1831 -0
  583. package/docs/testing.md +157 -0
  584. package/docs/troubleshooting.md +286 -0
  585. package/package.json +327 -3
  586. package/src/Action/Action.ts +333 -0
  587. package/src/Action/AttemptTimedOut.ts +37 -0
  588. package/src/Action/BoundaryMode.ts +33 -0
  589. package/src/Action/CacheEnvironment.ts +170 -0
  590. package/src/Action/ConcurrentKeylessDispatch.ts +38 -0
  591. package/src/Action/Context.ts +156 -0
  592. package/src/Action/DuplicateImplementation.ts +24 -0
  593. package/src/Action/FileBoundary.ts +77 -0
  594. package/src/Action/FileInput.ts +42 -0
  595. package/src/Action/Filegroup.ts +16 -0
  596. package/src/Action/Glob.ts +8 -0
  597. package/src/Action/ImplementationVersionMismatch.ts +27 -0
  598. package/src/Action/Implementations.ts +149 -0
  599. package/src/Action/InfraInterrupt.ts +30 -0
  600. package/src/Action/InfraInterruptRetriesExhausted.ts +37 -0
  601. package/src/Action/IrreversibleRetryRequiresIdempotencyKey.ts +32 -0
  602. package/src/Action/StepIdentity.ts +219 -0
  603. package/src/Action/TreeArtifact.ts +8 -0
  604. package/src/Action/TypeId.ts +9 -0
  605. package/src/Action/UncanonicalIdempotencyKey.ts +36 -0
  606. package/src/Action/idempotencyKey.ts +67 -0
  607. package/src/Action/index.ts +31 -0
  608. package/src/Action/make.ts +657 -0
  609. package/src/Action/raceAll.ts +48 -0
  610. package/src/Action/retry.ts +92 -0
  611. package/src/Deadline.ts +185 -0
  612. package/src/DurableClock.ts +133 -0
  613. package/src/DurableDeferred.ts +753 -0
  614. package/src/DurableQueue.ts +519 -0
  615. package/src/ExternalJob.ts +432 -0
  616. package/src/Fault.ts +279 -0
  617. package/src/Flow/Annotations.ts +151 -0
  618. package/src/Flow/CapabilityCeiling.ts +37 -0
  619. package/src/Flow/DeadlineExceeded.ts +40 -0
  620. package/src/Flow/ExecutionIdRequired.ts +36 -0
  621. package/src/Flow/ExecutionIds.ts +133 -0
  622. package/src/Flow/Flow.ts +576 -0
  623. package/src/Flow/MaxRoundsExceeded.ts +39 -0
  624. package/src/Flow/Outcome.ts +179 -0
  625. package/src/Flow/Result.ts +284 -0
  626. package/src/Flow/Runtime.ts +309 -0
  627. package/src/Flow/TypeId.ts +9 -0
  628. package/src/Flow/index.ts +19 -0
  629. package/src/Flow/internal.ts +237 -0
  630. package/src/Flow/make.ts +279 -0
  631. package/src/FlowRuntime/CancelRequestFailed.ts +56 -0
  632. package/src/FlowRuntime/ExecutionIdentityConflict.ts +32 -0
  633. package/src/FlowRuntime/FlowCycleDetected.ts +41 -0
  634. package/src/FlowRuntime/FlowExecutionNotFound.ts +46 -0
  635. package/src/FlowRuntime/FlowInstance.ts +128 -0
  636. package/src/FlowRuntime/FlowRuntime.ts +333 -0
  637. package/src/FlowRuntime/NodeRecord.ts +183 -0
  638. package/src/FlowRuntime/WaitingAnnotation.ts +85 -0
  639. package/src/FlowRuntime/index.ts +17 -0
  640. package/src/Graph.ts +1860 -0
  641. package/src/HumanTask.ts +1003 -0
  642. package/src/Interpreter.ts +1593 -0
  643. package/src/Poll.ts +414 -0
  644. package/src/RetryPolicy.ts +550 -0
  645. package/src/Sleep.ts +267 -0
  646. package/src/Stall.ts +217 -0
  647. package/src/WaitFor.ts +228 -0
  648. package/src/index.ts +125 -0
  649. package/src/internal/BoundedJson.ts +109 -0
  650. package/src/internal/DeclarationSite.ts +214 -0
  651. package/src/internal/Declarations.ts +49 -0
  652. package/src/internal/ExecutionMiddleware.ts +29 -0
  653. package/src/internal/JsonSchemaSubset.ts +392 -0
  654. package/src/internal/OutcomeMarker.ts +19 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Interpreter.ts"],
4
+ "sourcesContent": ["/**\n * The body interpreter: what a flow does when it runs.\n *\n * A `Flow` has no handler to register \u2014 its `body` IS the behavior, per\n * `docs/concepts/flows-and-actions.md` \u2014 so something has to turn\n * the graph that body describes into execution. That is this\n * module. {@link layer} registers a flow with the runtime, and the\n * handler it installs builds the graph with {@link module:Graph.build} and\n * walks it: each node settles once, in dependency order, and the root's value\n * is the flow's result.\n *\n * What each variant does is the run-time half of what the AST recorded. An\n * `ActionCall` runs its declaration's implementation \u2014 looked up by tag in\n * {@link module:Implementations.Implementations} before the walk starts \u2014 as\n * the ordinary durable action `toLayer` built, so a node driven here takes\n * the same attempt journal, retry policy, and tier as the same action called\n * from a handler. Its invocation identity additionally folds this node's\n * structural address, keeping concurrent graph sites replay-stable. A `Map`\n * applies its deferred function to the real upstream value. A `Branch`\n * evaluates its digested predicate on the real\n * subject and settles ONLY the arm it took: the other arm is topology the plan\n * shows and the run skipped, and it is reported as such rather than silently\n * absent. An `All` joins its members by name, a `Succeed` yields its value, and\n * an inline `FlowCall` was already flattened by graph building, so it settles\n * with the body spliced beneath it. A `FlowCall` the author wrote as\n * `.child(payload)` is the one node that is NOT flattened: it opens a real child\n * execution under a deterministically derived id\n * ({@link childExecutionId}), which is what gives it its own journal lineage and\n * makes the parent's interruption and the child's suspension travel between\n * them.\n *\n * Planned references are resolved the way the plan names them: a payload\n * placeholder carries the `Ref` `{from, path}` its key material recorded, so\n * `result.files` reads `files` off the settled value of the node that produced\n * it.\n *\n * The walk is demand-driven from the root rather than a sweep over the node\n * list, because dependency order puts BOTH branch arms before the branch that\n * chooses between them, and executing an arm to discover it was not taken is\n * exactly what static topology exists to avoid.\n *\n * @since 0.1.0\n */\n\nimport { isRecord } from \"@smthrs/canonical/Record\"\nimport * as CapabilitySet from \"@smthrs/capability/CapabilitySet\"\nimport { DerivedKey, digest } from \"@smthrs/keys\"\nimport { isFatalDiagnostic } from \"@smthrs/plan/GraphBuildError\"\nimport * as KeyMaterial from \"@smthrs/plan/KeyMaterial\"\nimport * as Node from \"@smthrs/plan/Node\"\nimport * as Planned from \"@smthrs/plan/Planned\"\nimport * as StepKey from \"@smthrs/plan/StepKey\"\nimport * as Cause from \"effect/Cause\"\nimport * as Context from \"effect/Context\"\nimport type * as Crypto from \"effect/Crypto\"\nimport * as Deferred from \"effect/Deferred\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport type * as Fiber from \"effect/Fiber\"\nimport * as Layer from \"effect/Layer\"\nimport * as Option from \"effect/Option\"\nimport * as Predicate from \"effect/Predicate\"\nimport * as Schema from \"effect/Schema\"\nimport * as Scope from \"effect/Scope\"\nimport { type Implementation, Implementations, layerImplementations } from \"./Action/Implementations.ts\"\nimport { DispatchReport, DispatchSite } from \"./Action/StepIdentity.ts\"\nimport * as DurableDeferred from \"./DurableDeferred.ts\"\nimport { attenuateCapabilities } from \"./Flow/CapabilityCeiling.ts\"\nimport type { Any as AnyFlow, AnyStructSchema, AnyWithProps, Flow } from \"./Flow/Flow.ts\"\nimport * as Outcome from \"./Flow/Outcome.ts\"\nimport { Handoff } from \"./Flow/Result.ts\"\nimport { suspend } from \"./Flow/Runtime.ts\"\nimport { TypeId as FlowTypeId } from \"./Flow/TypeId.ts\"\nimport { FlowInstance } from \"./FlowRuntime/FlowInstance.ts\"\nimport { FlowRuntime } from \"./FlowRuntime/FlowRuntime.ts\"\nimport type * as NodeRecord from \"./FlowRuntime/NodeRecord.ts\"\nimport { annotateWaiting } from \"./FlowRuntime/WaitingAnnotation.ts\"\nimport * as Graph from \"./Graph.ts\"\nimport * as BoundedJson from \"./internal/BoundedJson.ts\"\nimport { ExecutionMiddleware } from \"./internal/ExecutionMiddleware.ts\"\nimport { OutcomeValueTypeId } from \"./internal/OutcomeMarker.ts\"\n\n/**\n * A graph the interpreter will not drive.\n *\n * Every code names something the run cannot recover from on its own: a graph\n * whose topology is incomplete, an action with no implementation wired up, a\n * call the interpreter does not execute, and a deferred function that did not\n * survive serialization beside its AST. `missing_implementation_version`\n * names a content-reusable action that lacks the canonical version contract;\n * `implementation_version_mismatch` names a declaration and registry that\n * disagree. Both are preflight failures, before action dispatch.\n * `join_mismatch` names a race, any, or quorum whose journaled decision this\n * plan's members can no longer reproduce.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class InterpreterError extends Schema.TaggedError<InterpreterError>()(\n \"@smthrs/flow/InterpreterError\",\n {\n code: Schema.Literals([\n \"incomplete_graph\",\n \"duplicate_node_id\",\n \"unresolved_action\",\n \"implementation_version_mismatch\",\n \"missing_implementation_version\",\n \"unresolved_reference\",\n \"unsupported_call\",\n \"missing_operation\",\n \"node_record_too_large\",\n \"join_mismatch\"\n ]),\n flow: Schema.String,\n node: Schema.String,\n message: Schema.String\n }\n) {}\n\n/**\n * What one interpretation produced: the root's value, every node that settled\n * with the value it settled with, and the nodes the run never reached because\n * a branch went the other way.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Interpretation {\n readonly value: unknown\n readonly settled: ReadonlyMap<string, unknown>\n /** Typed failures observed before a catch recovered them. */\n readonly failed: ReadonlyMap<string, unknown>\n readonly skipped: ReadonlyArray<string>\n}\n\n/**\n * The services a driven node needs: the runtime that executes an action, and\n * the execution it is part of.\n *\n * @private\n */\ntype Services = Crypto.Crypto | FlowRuntime | FlowInstance | Implementations\n\n/** Reads one own data property without invoking an accessor or letting a proxy trap escape. */\nconst ownDataProperty = (value: unknown, key: PropertyKey): unknown => {\n if (Object(value) !== value) return undefined\n try {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n return descriptor !== undefined && \"value\" in descriptor ? descriptor.value : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * The execution id a `.child()` boundary runs its child under.\n *\n * DECIDED: the id is DERIVED from the parent\n * execution and the child node's structural address, not minted. That is what\n * makes a boundary at-most-once under replay, exactly as\n * `docs/concepts/trampoline-rounds.md` requires of a round handoff: a\n * parent that is re-driven re-derives the same id, so the engine lands on the\n * child execution that already exists instead of starting a second copy of it.\n * The canonical tuple includes the callee and a canonical payload digest, so\n * delimiter splicing and a changed invocation cannot alias an earlier child.\n * SHA-256 uses the same injected derivation services as the repository's\n * other durable identities. The versioned key prefix is dropped because the\n * child-id wire format is the bare digest. `digest` owns the\n * prefix knowledge, so this package never guesses at a stored-key format.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const childExecutionId = (\n parentExecutionId: string,\n nodeId: string,\n calleeTag: string,\n payload: unknown\n): Effect.Effect<string, never, Crypto.Crypto> =>\n Effect.gen(function*() {\n const payloadDigest = yield* Schema.decodeUnknownEffect(DerivedKey)(payload).pipe(Effect.orDie)\n const tupleDigest = yield* Schema.decodeUnknownEffect(DerivedKey)([\n parentExecutionId,\n nodeId,\n calleeTag,\n payloadDigest\n ]).pipe(Effect.orDie)\n return digest(tupleDigest)\n })\n\n/**\n * The largest encoded page of a recorded plan.\n *\n * A journal entry has a byte bound and a projection clips an oversized one, so\n * a graph is PAGED rather than truncated: whatever does not fit in the plan\n * record follows as appended subgraph pages. The budget is deliberately well\n * under the 16 KiB gateway limit on graph events. The runtime measures the\n * encoded journal envelope; absent that hook, the complete node record is\n * measured in UTF-8. A node too large for one page is a typed preflight refusal.\n *\n * @since 1.0.0\n * @category constants\n */\nexport const maximumPageBytes = 12_000\n\n/**\n * How many distinct step key digests one node's settlement names.\n *\n * A journal entry has a byte bound and a digest is 64 characters, so the list\n * is capped rather than left to grow with whatever a node dispatched. The\n * cap is far above what any node reaches today \u2014 an action node drives one\n * dispatch and keeps one step key however many times it is retried \u2014 and a\n * node past it names the dispatches it started with rather than none.\n *\n * @since 1.0.0\n * @category constants\n */\nexport const maximumDispatchDigests = 16\n\n/** The declared tag a node dispatches, if it dispatches one. @private */\nconst actionTag = (ast: Node.Ast): string | undefined =>\n ast._tag === \"ActionCall\" ? ast.action : ast._tag === \"FlowCall\" ? ast.flow : undefined\n\n/** What one node of a driven graph tells a monitor about itself. @private */\nconst summarize = (node: Graph.GraphNode): NodeRecord.NodeSummary => {\n const action = actionTag(node.ast)\n return {\n id: node.id,\n kind: node.kind,\n dependsOn: KeyMaterial.dependencies(node.draft.material),\n tier: node.draft.material.kind,\n effects: node.draft.effects,\n ...(action === undefined ? {} : { action }),\n ...(node.declaredAt === undefined ? {} : { declaredAt: node.declaredAt })\n }\n}\n\n/**\n * The graph, as the pages a journal can hold.\n *\n * Nothing about one node has to fit one page. A node's summary is seated on a\n * page with no dependencies on it, and then its dependency list and the edges\n * that END on it are spread over as many following pages as they need: a\n * continuation page re-seats the same summary and carries the next disjoint\n * slice of `dependsOn`, so a reader that unions `dependsOn` per node id and\n * concatenates edges reassembles exactly the graph that was built. That is\n * what lets an input-driven fan-in \u2014 `Node.all` over a caller-sized list \u2014 be\n * recorded at any width instead of refused.\n *\n * A node's summary is seated no later than the first page naming one of its\n * dependencies or one of its incoming edges, so an assembled PREFIX of pages\n * never names an edge whose destination is unknown.\n *\n * The typed refusal is left for the one thing paging cannot divide: a node\n * whose summary with NO dependencies on it still exceeds the budget.\n *\n * @private\n */\nconst planPages = (\n flow: string,\n graph: Graph.Graph,\n measure: (record: NodeRecord.NodeRecord) => Effect.Effect<number, never, FlowInstance>\n): Effect.Effect<\n ReadonlyArray<NodeRecord.PlanRecorded | NodeRecord.SubgraphAppended>,\n InterpreterError,\n FlowInstance\n> =>\n Effect.gen(function*() {\n const incoming = new Map<string, Array<NodeRecord.EdgeSummary>>()\n let edgeCount = 0\n for (const edge of Graph.edges(graph)) {\n edgeCount += 1\n const summary = { from: edge.from, to: edge.to, reason: edge.reason }\n const existing = incoming.get(edge.to)\n if (existing === undefined) incoming.set(edge.to, [summary])\n else existing.push(summary)\n }\n type Page = { nodes: Array<NodeRecord.NodeSummary>; edges: Array<NodeRecord.EdgeSummary> }\n const graphNodes = Graph.nodes(graph)\n const pages: Array<Page> = []\n let current: Page = { nodes: [], edges: [] }\n const record = (\n page: Page,\n index: number,\n count: number\n ): NodeRecord.PlanRecorded | NodeRecord.SubgraphAppended => ({\n ...(index === 0\n ? { _tag: \"PlanRecorded\" as const, nodeCount: graphNodes.length }\n : { _tag: \"SubgraphAppended\" as const }),\n sourceId: `plan/0/${index}`,\n flow,\n generation: 0,\n page: index,\n pages: count,\n ...page\n })\n // Every page is started by a node seat or by an edge, and a node is seated\n // once plus at most once per dependency that starts a continuation page,\n // so the page count is at most nodes + dependencies + edges. Reserving\n // that many digits is what makes replacing the reservation with the final\n // count shrink an encoded envelope or leave it alone, never grow it.\n const reserved = graphNodes.reduce(\n (total, node) => total + KeyMaterial.dependencies(node.draft.material).length,\n graphNodes.length + edgeCount\n )\n const fits = (page: Page) =>\n Effect.map(measure(record(page, pages.length, reserved)), (bytes) => bytes <= maximumPageBytes)\n const flush = () => {\n pages.push(current)\n current = { nodes: [], edges: [] }\n }\n /**\n * How many of the remaining items the page still holds.\n *\n * A page only grows as items are added to it, so the boundary is found by\n * bisection: a thousand-way fan-in costs a logarithmic number of\n * measurements per page rather than one per item. Taking none is the page\n * as it stands, which was measured before anything was offered to it.\n */\n const admits = <T>(rest: ReadonlyArray<T>, grow: (take: number) => Page) =>\n Effect.gen(function*() {\n if (yield* fits(grow(rest.length))) return rest.length\n let low = 0\n let high = rest.length - 1\n while (low < high) {\n const mid = low + Math.ceil((high - low) / 2)\n if (yield* fits(grow(mid))) low = mid\n else high = mid - 1\n }\n return low\n })\n /**\n * Puts every item somewhere, starting a page whenever the current one is\n * full. `resume` prepares a freshly started page so what follows still\n * says which node it belongs to, and a page that was just started and\n * admits nothing is the end of what paging can do.\n */\n const spread = <T>(\n items: ReadonlyArray<T>,\n onto: (page: Page, taken: ReadonlyArray<T>) => Page,\n resume: (page: Page) => Page,\n refusal: () => InterpreterError\n ): Effect.Effect<void, InterpreterError, FlowInstance> =>\n Effect.gen(function*() {\n let rest = items\n let started = false\n while (rest.length > 0) {\n const take = yield* admits(rest, (count) => onto(current, rest.slice(0, count)))\n if (take > 0) {\n current = onto(current, rest.slice(0, take))\n rest = rest.slice(take)\n started = false\n continue\n }\n if (started) return yield* refusal()\n flush()\n current = resume(current)\n started = true\n }\n })\n for (const node of graphNodes) {\n const summary = summarize(node)\n const arriving = incoming.get(node.id) ?? []\n // The summary alone first. What a page must hold whole is the node\n // itself, and that is the only thing left to refuse.\n const bare: NodeRecord.NodeSummary = { ...summary, dependsOn: [] }\n const seat = (page: Page): Page => ({ nodes: [...page.nodes, bare], edges: page.edges })\n const tooLarge = () =>\n new InterpreterError({\n code: \"node_record_too_large\",\n flow,\n node: node.id,\n message:\n `Node \"${node.id}\" and its encoded envelope exceed ${maximumPageBytes} bytes with no dependencies on it`\n })\n if (!(yield* fits(seat(current)))) {\n if (current.nodes.length > 0 || current.edges.length > 0) flush()\n if (!(yield* fits(seat(current)))) return yield* tooLarge()\n }\n current = seat(current)\n // Then its dependencies, onto the summary the page just seated, and then\n // the edges that end on it. Either may run past this page onto the next.\n yield* spread(\n summary.dependsOn,\n (page, taken) => {\n const seated = page.nodes[page.nodes.length - 1]!\n return {\n nodes: [...page.nodes.slice(0, -1), { ...seated, dependsOn: [...seated.dependsOn, ...taken] }],\n edges: page.edges\n }\n },\n seat,\n tooLarge\n )\n yield* spread(\n arriving,\n (page, taken) => ({ nodes: page.nodes, edges: [...page.edges, ...taken] }),\n (page) => page,\n tooLarge\n )\n }\n pages.push(current)\n return pages.map((page, index) => record(page, index, pages.length))\n })\n\n/**\n * Interprets a flow body, or a bare node, against real values.\n *\n * The graph is built first and in full \u2014 planning is a pure function of the\n * declarations and the payload, so the whole shape of the round is known before\n * the first action runs \u2014 and then driven. The low-level default permits\n * process-local callbacks; pass `callbackIdentity: \"stable\"` for reproducible\n * callback identity. {@link layerWithImplementations} selects that policy by\n * default.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const interpret = (\n flowOrNode: Parameters<typeof Graph.build>[0],\n payload?: unknown,\n options: Graph.BuildOptions = {}\n): Effect.Effect<Interpretation, unknown, Services> => interpretWithPolicy(flowOrNode, payload, options, false)\n\n/** The canonical composition requires versions before permitting content-key reuse. @private */\nconst interpretWithPolicy = (\n flowOrNode: Parameters<typeof Graph.build>[0],\n payload: unknown,\n options: Graph.BuildOptions,\n requireReusableVersions: boolean,\n registerReachable?: (flow: AnyWithProps) => Effect.Effect<void>\n): Effect.Effect<Interpretation, unknown, Services> =>\n Effect.gen(function*() {\n const table = yield* Implementations\n const name = \"_tag\" in flowOrNode ? flowOrNode._tag : \"node\"\n const refuse = (\n code: InterpreterError[\"code\"],\n node: string,\n message: string\n ): Effect.Effect<never, InterpreterError> => Effect.fail(new InterpreterError({ code, flow: name, node, message }))\n\n const graph = yield* Effect.try({\n try: () => Graph.build(flowOrNode, payload, options),\n catch: (cause) => {\n // Graph.build normalizes its own refusals to GraphBuildError, but the\n // flow body runs inside this boundary and a body throws whatever it\n // throws. Reading `node` and `message` off the value without checking\n // built an InterpreterError its own schema rejects, and the\n // constructor's \"Schema validation failed\" then replaced the reason\n // the author needed. All three fields are read through own data\n // descriptors and narrowed here so a plain Error from a body arrives\n // as a typed failure that still says why. A body that threw produced no\n // topology, so it reports `incomplete_graph`.\n const refusalNode = ownDataProperty(cause, \"node\")\n const refusalCode = ownDataProperty(cause, \"code\")\n const refusalMessage = ownDataProperty(cause, \"message\")\n const node = typeof refusalNode === \"string\" ? refusalNode : \"\"\n const reported = typeof refusalMessage === \"string\" ? refusalMessage : \"\"\n return new InterpreterError({\n code: refusalCode === \"duplicate_node\" ? \"duplicate_node_id\" : \"incomplete_graph\",\n flow: name,\n node,\n message: reported === \"\"\n ? `building the graph of flow ${name} threw ${\n typeof cause === \"string\" ? cause : BoundedJson.render(cause, 512)\n }`\n : reported\n })\n }\n })\n\n const graphNodes = Graph.nodes(graph)\n const byId = new Map(graphNodes.map((node) => [node.id, node]))\n\n // Advisory diagnostics describe a graph that is exactly what will run, so\n // they are reported by `Graph.diagnostics` and do not stop a run. A fatal\n // one means the topology is not what the author wrote.\n const fatal = graph.diagnostics.find(isFatalDiagnostic)\n if (fatal !== undefined) {\n return yield* refuse(\n \"incomplete_graph\",\n fatal.node,\n `Graph of \"${name}\" is missing topology and cannot be driven: ${fatal.message}`\n )\n }\n\n /**\n * The node records this walk writes, if the runtime keeps any.\n *\n * A runtime without the seam costs a comparison per node and nothing else:\n * the record is built by the thunk only when something will hold it.\n */\n const runtime = yield* FlowRuntime\n const recordNode = runtime.recordNode\n const record = recordNode === undefined\n ? (_: () => NodeRecord.NodeRecord) => Effect.void as Effect.Effect<void, never, FlowInstance>\n : (make: () => NodeRecord.NodeRecord) => recordNode(make())\n // The whole graph, before the first node runs. Planning is pure, so this\n // is the complete declared ceiling of the round rather than a prefix of\n // what happened to run, and a monitor can draw the round it is watching\n // from the first record it receives.\n if (recordNode !== undefined) {\n const measure = runtime.nodeRecordBytes ??\n ((record: NodeRecord.NodeRecord) => Effect.succeed(new TextEncoder().encode(JSON.stringify(record)).byteLength))\n // Validate every page before writing the first or dispatching any action.\n const pages = yield* planPages(name, graph, measure)\n yield* Effect.forEach(pages, (page) => recordNode(page), { discard: true })\n }\n\n // Everything the walk needs that the built graph can be asked for before it\n // runs, is asked for here \u2014 so no such refusal can surface halfway through a\n // body with the actions ahead of it already committed.\n //\n // A reference out of the graph is the first: a round may be PLANNED against\n // a node an earlier generation settled \u2014 `Plan.append` exists for exactly\n // that \u2014 but one interpretation settles one graph, so there is nothing to\n // read it from. A missing implementation is the second, and it is a wiring\n // error rather than a run-time contingency: every action the graph names\n // is resolved up front, including the ones only an untaken branch arm would\n // have reached, because the plan is the declared ceiling of what may run.\n // Deferred operations must likewise survive beside every AST, even when\n // the walk would skip their branch or catch arm.\n const implementations = new Map<string, Implementation>()\n const handoffDeclarations = new Map<string, AnyFlow>()\n const childDeclarations = new Map<string, AnyWithProps>()\n for (const node of graphNodes) {\n const ast = node.ast\n if (ast._tag === \"Map\" && Node.mapper(ast) === undefined) {\n return yield* refuse(\"missing_operation\", node.id, `Map at \"${node.id}\" lost its mapper.`)\n }\n if (ast._tag === \"Branch\" && Node.predicate(ast) === undefined) {\n return yield* refuse(\"missing_operation\", node.id, `Branch at \"${node.id}\" lost its predicate.`)\n }\n if (ast._tag === \"Catch\" && ast.filter !== undefined && Node.catchFilter(ast) === undefined) {\n return yield* refuse(\"missing_operation\", node.id, `Catch at \"${node.id}\" lost its schema filter.`)\n }\n for (const dependency of KeyMaterial.dependencies(node.draft.material)) {\n if (byId.has(dependency)) continue\n return yield* refuse(\n \"unresolved_reference\",\n node.id,\n `Node \"${node.id}\" reads \"${dependency}\", which this graph does not hold.`\n )\n }\n if (node.ast._tag === \"FlowCall\" && node.ast.mode === \"handoff\") {\n const declaration = Node.declaration(node.ast)\n if (!Predicate.hasProperty(declaration, FlowTypeId)) {\n return yield* refuse(\n \"unsupported_call\",\n node.id,\n `Handoff to flow \"${node.ast.flow}\" at \"${node.id}\" lost its declaration. ` +\n \"Build and interpret the authored node in the same process so its payload can be encoded.\"\n )\n }\n handoffDeclarations.set(node.id, declaration as unknown as AnyFlow)\n if (registerReachable !== undefined) yield* registerReachable(declaration as unknown as AnyWithProps)\n continue\n }\n if (node.ast._tag === \"FlowCall\" && node.ast.mode === \"boundary\") {\n // A boundary is one node here and a real execution underneath, so what\n // it needs resolved up front is the callee itself: the declaration is\n // what `execute` is called on, and losing it is a wiring error rather\n // than a run-time contingency, exactly like an unimplemented action.\n const declaration = Node.declaration(node.ast)\n if (!Predicate.hasProperty(declaration, FlowTypeId)) {\n return yield* refuse(\n \"unsupported_call\",\n node.id,\n `Child boundary to flow \"${node.ast.flow}\" at \"${node.id}\" lost its declaration. ` +\n \"Build and interpret the authored node in the same process so the child can be executed.\"\n )\n }\n childDeclarations.set(node.id, declaration as unknown as AnyWithProps)\n if (registerReachable !== undefined) yield* registerReachable(declaration as unknown as AnyWithProps)\n continue\n }\n if (node.ast._tag !== \"ActionCall\") continue\n const implementation = yield* table.get(node.ast.action)\n if (Option.isNone(implementation)) {\n return yield* refuse(\n \"unresolved_action\",\n node.id,\n `Action \"${node.ast.action}\" has no implementation. ` +\n `Provide ONE Action.layerImplementations under both ${node.ast.action}.toLayer(execute) and ` +\n \"this interpreter layer: an implementation files itself with the table that is in scope \" +\n \"while IT is built, so a table merged beside it, or a second one built above it, is not the \" +\n \"table this driver reads.\"\n )\n }\n const declaration = Node.declaration(node.ast)\n const declaredVersion = ownDataProperty(declaration, \"implementationVersion\")\n if (requireReusableVersions) {\n const tier = ownDataProperty(declaration, \"tier\")\n if (tier === undefined) {\n return yield* refuse(\n \"incomplete_graph\",\n node.id,\n `Action \"${node.ast.action}\" lost its declaration, so its implementation identity cannot be checked. ` +\n \"Build the canonical composition from the authored action nodes.\"\n )\n }\n if (\n tier === \"sealed\" && ownDataProperty(declaration, \"idempotencyKey\") !== undefined &&\n declaredVersion === undefined\n ) {\n return yield* refuse(\n \"missing_implementation_version\",\n node.id,\n `Sealed action \"${node.ast.action}\" declares an idempotency key and can reuse recorded content. ` +\n \"Declare implementationVersion on Action.make and attest the same version in toLayer.\"\n )\n }\n }\n if (declaredVersion !== implementation.value.implementationVersion) {\n return yield* refuse(\n \"implementation_version_mismatch\",\n node.id,\n `Action \"${node.ast.action}\" does not match its registered implementationVersion. ` +\n \"Register the declared version and start a newly planned execution when its semantics change.\"\n )\n }\n implementations.set(node.ast.action, implementation.value)\n }\n\n // Graph.build also accepts authored references. Unlike Plan.compile, this\n // entry point has not yet checked them for cycles: a self-reference would\n // join its own in-flight deferred forever. Validate the entire dependency\n // graph before dispatch, including branch arms the execution might skip.\n const remaining = new Map<string, number>()\n const dependents = new Map<string, Array<string>>()\n const ready: Array<string> = []\n for (const node of graphNodes) {\n const dependencies = KeyMaterial.dependencies(node.draft.material)\n remaining.set(node.id, dependencies.length)\n if (dependencies.length === 0) ready.push(node.id)\n for (const dependency of dependencies) {\n const consumers = dependents.get(dependency)\n if (consumers === undefined) dependents.set(dependency, [node.id])\n else consumers.push(node.id)\n }\n }\n for (let index = 0; index < ready.length; index++) {\n for (const consumer of dependents.get(ready[index]!) ?? []) {\n const count = remaining.get(consumer)! - 1\n remaining.set(consumer, count)\n if (count === 0) ready.push(consumer)\n }\n }\n if (ready.length !== graphNodes.length) {\n const blocked = graphNodes.find((node) => remaining.get(node.id)! > 0)!\n return yield* refuse(\n \"incomplete_graph\",\n blocked.id,\n `Graph of \"${name}\" contains a dependency cycle blocking \"${blocked.id}\". ` +\n \"Use an acyclic reference, a child boundary, or a trampoline handoff.\"\n )\n }\n // The children a node settles with, in the order graph building recorded\n // them: `first` then the arms of a branch, `first` then the continuation of\n // a sequence, the members of a combination, the spliced body of an inline\n // call. Payload references are NOT here \u2014 they are named by the key\n // material, and settled from it.\n const sources = new Map<string, Array<string>>()\n for (const edge of Graph.edges(graph)) {\n if (edge.reason !== \"value\") continue\n sources.set(edge.to, [...sources.get(edge.to) ?? [], edge.from])\n }\n\n const settled = new Map<string, unknown>()\n const failed = new Map<string, unknown>()\n\n /**\n * Projects a settled value along the property path a `Ref` recorded \u2014\n * through `StepKey.project`, the one projection semantics for the value\n * channel. The scheduler digests exactly what this returns; resolving a\n * `Ref` any other way here would let two executions that key identically\n * consume different values.\n */\n const project = StepKey.project\n\n /**\n * Replaces every placeholder in a hydrated payload with what it stands for.\n *\n * The record is rebuilt with a null prototype and `defineProperty`, for the\n * reason {@link module:Graph.build}'s cloners are: `output[key] = \u2026` on an\n * object literal routes `__proto__` through `Object.prototype`'s accessor,\n * which drops an own `__proto__` field carrying a primitive and reparents\n * the clone when it carries an object. A graph hydrates that field as data,\n * so the value handed to an action has to keep it as data too.\n */\n const resolve = (value: unknown): unknown => {\n const reference = Planned.reference(value)\n if (reference !== undefined) {\n return project(\n settled.has(reference.node) ? settled.get(reference.node) : failed.get(reference.node),\n reference.path\n )\n }\n if (Array.isArray(value)) return value.map((item) => resolve(item))\n if (!isRecord(value)) return value\n const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n for (const key of Object.keys(value)) {\n Object.defineProperty(output, key, {\n configurable: true,\n enumerable: true,\n value: resolve(value[key]),\n writable: true\n })\n }\n const outcome = Object.getOwnPropertyDescriptor(value, OutcomeValueTypeId)\n if (outcome !== undefined && \"value\" in outcome) {\n Object.defineProperty(output, OutcomeValueTypeId, {\n configurable: false,\n enumerable: false,\n value: outcome.value,\n writable: false\n })\n }\n return output\n }\n\n /**\n * The settlement currently in flight for a node, for as long as it is.\n *\n * `settled.has(id)` alone is not a memo once the walk runs concurrently: it\n * answers \"has this node FINISHED\", and two demands that arrive while the\n * node is still running both see `false` and both execute it. A diamond\n * would then run its shared node twice, which for an action with effects is\n * a correctness bug rather than a wasted cycle.\n *\n * The check-and-register below is the whole reason this is a `suspend` and\n * not a generator: the callback runs synchronously, so no other fiber can\n * observe the gap between the lookup and the insert.\n *\n * Every computation runs on a fiber forked into `nodes`, the\n * interpretation's own scope, and every demand \u2014 the first included \u2014 is a\n * join on the node's deferred. Ownership by the interpretation rather than\n * by whichever demand arrived first is what makes a ref-diamond sound: a\n * failing `All` interrupts its member JOINS, never a shared node's\n * execution, so recovery arms above can still join the shared work; and\n * when the walk itself ends, closing the scope interrupts whatever is\n * still running, so an orphaned execution cannot outlive the\n * interpretation or write a phantom success into `settled` afterwards\n * (Skyframe's and `MemoMap`'s ownership model).\n */\n const inFlight = new Map<string, Deferred.Deferred<unknown, unknown>>()\n const nodes = yield* Scope.make()\n /**\n * The execution fiber of every node still running, so a join that settled\n * early can interrupt the work of the members it no longer waits for.\n */\n const executions = new Map<string, Fiber.Fiber<unknown, unknown>>()\n /**\n * The child execution id each `.child()` node opened. Interrupting the\n * node's fiber only stops its join: a losing child is cancelled through\n * the runtime, the same request a caller's cancellation makes.\n */\n const childExecutions = new Map<string, string>()\n\n /**\n * The nodes this walk has already settled a record for.\n *\n * Everything else is what the walk never reached, which is exactly the\n * `skipped` set reported below \u2014 an untaken branch arm, or a dependent of\n * something that failed.\n */\n const reported = new Set<string>()\n\n const settleNode = (id: string): Effect.Effect<unknown, unknown, Services> =>\n Effect.suspend(() => {\n if (settled.has(id)) return Effect.succeed(settled.get(id))\n const waiting = inFlight.get(id)\n // A later demand joins the execution rather than starting one.\n if (waiting !== undefined) return Deferred.await(waiting)\n const deferred = Deferred.makeUnsafe<unknown, unknown>()\n inFlight.set(id, deferred)\n const node = byId.get(id)!\n const action = actionTag(node.ast)\n // What this node's dispatches did, reported by the engine underneath\n // it: a node whose dispatches were ALL served from durable records\n // rebuilt nothing, and says so. The digests name those dispatches, so\n // the attempt rows the engine wrote under them belong to THIS node,\n // and the highest attempt reported is the node's real attempt count.\n // A `Set` keeps the digests unrepeated in report order: one dispatch\n // retried three times keeps one step key and reports it three times.\n const dispatches = { executed: 0, replayed: 0, attempts: 1, digests: new Set<string>() }\n const settleRecord =\n (outcome: NodeRecord.NodeOutcome, settlement: { readonly value: unknown }) => (): NodeRecord.NodeRecord => ({\n _tag: \"NodeSettled\",\n sourceId: `node/${id}/1/settled`,\n nodeId: id,\n outcome,\n attempts: dispatches.attempts,\n stepKeyDigests: [...dispatches.digests],\n value: settlement.value,\n ...(action === undefined ? {} : { action })\n })\n const execution = record(() => ({\n _tag: \"NodeScheduled\",\n sourceId: `node/${id}/1`,\n nodeId: id,\n kind: node.kind,\n attempt: 1,\n ...(action === undefined ? {} : { action })\n })).pipe(\n Effect.andThen(\n compute(node).pipe(\n Effect.provideService(\n DispatchReport,\n DispatchReport.of({\n dispatched: (dispatch) =>\n Effect.sync(() => {\n if (dispatch.outcome === \"executed\") dispatches.executed = dispatches.executed + 1\n else dispatches.replayed = dispatches.replayed + 1\n // Bounded where it is COLLECTED, not where it is\n // written: a cap applied at the end still holds every\n // digest in memory until then, and the point of the cap\n // is that one node cannot grow without bound.\n if (\n dispatch.stepKeyDigest !== undefined &&\n dispatches.digests.size < maximumDispatchDigests\n ) {\n dispatches.digests.add(dispatch.stepKeyDigest)\n }\n if (dispatch.attempt !== undefined && dispatch.attempt > dispatches.attempts) {\n dispatches.attempts = dispatch.attempt\n }\n })\n })\n )\n )\n ),\n Effect.tap((value) =>\n Effect.sync(() => {\n settled.set(id, value)\n reported.add(id)\n }).pipe(\n Effect.andThen(record(\n settleRecord(dispatches.executed === 0 && dispatches.replayed > 0 ? \"clean\" : \"built\", { value })\n ))\n )\n ),\n Effect.tapError((error) =>\n Effect.sync(() => {\n failed.set(id, error)\n reported.add(id)\n }).pipe(Effect.andThen(record(settleRecord(\"failed\", { value: error }))))\n ),\n Effect.onExit((exit) => {\n // An interrupted execution is evicted, not memoized: current\n // joiners observe the interruption, but a LATER demand \u2014 a\n // recovery arm, a re-driven walk \u2014 re-executes the node instead\n // of replaying an interrupt that says nothing about it.\n if (Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause)) inFlight.delete(id)\n executions.delete(id)\n return Deferred.done(deferred, exit)\n })\n )\n // `startImmediately` keeps the first demand's latency identical to the\n // old inline execution: the node runs synchronously until its first\n // real suspension, so a body that parks does so before the driver's\n // next tick \u2014 the same observable cadence a sequential walk had.\n return Effect.forkIn(\n Effect.withFiber((fiber) => {\n executions.set(id, fiber)\n return execution\n }),\n nodes,\n { startImmediately: true }\n ).pipe(Effect.andThen(Deferred.await(deferred)))\n })\n\n /**\n * The nodes that read each node's value through their key material: the\n * payload references and barriers a structural subtree does not show.\n */\n const readers = new Map<string, Array<string>>()\n for (const node of graphNodes) {\n for (const dependency of KeyMaterial.dependencies(node.draft.material)) {\n readers.set(dependency, [...readers.get(dependency) ?? [], node.id])\n }\n }\n\n /**\n * The work of the members a join no longer waits for: their running node\n * fibers and the child executions those nodes opened.\n *\n * A member's structural subtree is its own, so its running executions are\n * interrupted; nothing else demands them again. A node something outside that\n * subtree also reads is shared work the interpretation owns \u2014 the same\n * ownership an `All` failure respects \u2014 and keeps running, together with\n * everything inside the subtree it depends on.\n */\n // Graph building gives every node exactly one structural parent and reads\n // each child through that parent's key material, so the walk below never\n // reaches a node twice and every node in a subtree has a reader.\n const losingWork = (joinId: string, roots: ReadonlyArray<string>) => {\n const subtree = new Set<string>()\n const pending = [...roots]\n while (pending.length > 0) {\n const id = pending.pop()!\n subtree.add(id)\n pending.push(...sources.get(id) ?? [])\n }\n const kept = new Set<string>()\n const shared = [...subtree].filter((id) =>\n readers.get(id)!.some((reader) => reader !== joinId && !subtree.has(reader))\n )\n while (shared.length > 0) {\n const id = shared.pop()!\n if (kept.has(id) || !subtree.has(id)) continue\n kept.add(id)\n shared.push(...sources.get(id) ?? [], ...KeyMaterial.dependencies(byId.get(id)!.draft.material))\n }\n const fibers: Array<Fiber.Fiber<unknown, unknown>> = []\n const childRuns: Array<JoinChild> = []\n for (const id of subtree) {\n if (kept.has(id)) continue\n const fiber = executions.get(id)\n if (fiber === undefined) continue\n fibers.push(fiber)\n const executionId = childExecutions.get(id)\n if (executionId !== undefined) childRuns.push({ node: id, executionId })\n }\n return { fibers, childRuns }\n }\n\n /**\n * Cancels the child executions a join's losers opened, through the\n * runtime: interrupting a node's fiber only stops its join, so a losing\n * child is cancelled with the same request a caller's cancellation makes.\n */\n const cancelChildren = (childRuns: ReadonlyArray<JoinChild>): Effect.Effect<void, never, Services> =>\n Effect.forEach(\n childRuns,\n ({ executionId, node }) =>\n Effect.orDie(runtime.interrupt(childDeclarations.get(node)! as AnyFlow, executionId)),\n { discard: true }\n )\n\n /**\n * Settles a `Race` node: `race`, `any`, or `quorum`.\n *\n * The members that decided are journaled, in the order they decided,\n * under a durable deferred named for the node before any loser is\n * interrupted. A resumed walk that finds the record settles exactly those\n * members \u2014 whose own dispatches replay from their durable records \u2014 and\n * never demands the others, so it reaches the same verdict without\n * running a loser again. A defect or an interpreter refusal in a member is\n * not a decision: it propagates unjournaled, as it would from an `All`.\n *\n * The same record names the child executions the losers had opened, so a\n * process that dies between the journal write and their cancellation does\n * not orphan them: the resumed walk never demands a loser, and it cancels\n * those children from the record instead (#2892). Cancellation is a\n * first-writer-wins request, so repeating it on every replay is harmless.\n */\n const join = (\n node: Graph.GraphNode,\n ast: Extract<Node.Ast, { readonly _tag: \"Race\" }>,\n children: ReadonlyArray<string>\n ): Effect.Effect<unknown, unknown, Services> =>\n Effect.gen(function*() {\n const members = Object.keys(ast.nodes)\n const journal = DurableDeferred.make(`join/${node.id}`, { success: JoinDecision })\n const instance = yield* FlowInstance\n // A join is not a wait: reading its record must not consume the\n // waiting classification a parked sibling declared.\n const waiting = instance.waiting\n const recorded = yield* runtime.deferredResult(journal)\n instance.waiting = waiting\n if (Option.isSome(recorded) && Exit.isSuccess(recorded.value)) {\n const record = recorded.value.value\n const decided = \"members\" in record ? record.members : record\n const opened = \"members\" in record ? record.children : []\n const indices = decided.map((member) => members.indexOf(member))\n if (indices.some((index) => index < 0) || new Set(indices).size !== indices.length) {\n return yield* refuse(\n \"join_mismatch\",\n node.id,\n `Join at \"${node.id}\" journaled members ${JSON.stringify(decided)}, which it no longer holds.`\n )\n }\n const lost = opened.find((child) => !childDeclarations.has(child.node))\n if (lost !== undefined) {\n return yield* refuse(\n \"join_mismatch\",\n node.id,\n `Join at \"${node.id}\" journaled a losing child at \"${lost.node}\", which the plan no longer holds.`\n )\n }\n yield* cancelChildren(opened)\n // The losers are never demanded, so nothing of theirs starts again.\n const exits = yield* Effect.forEach(indices, (index) => Effect.exit(settleNode(children[index]!)), {\n concurrency: \"unbounded\"\n })\n // The verdict must close on the LAST journaled member, exactly as it\n // did live: one that closes earlier, or never, is a different join.\n const outcomes: Array<Decision> = []\n for (let position = 0; position < exits.length; position++) {\n const exit = exits[position]!\n if (classify(exit) !== \"decisive\") return yield* exit\n outcomes.push({ member: members[indices[position]!]!, exit })\n const verdict = decide(ast, members.length, outcomes)\n if (verdict !== undefined && position === exits.length - 1) return yield* verdict\n if (verdict !== undefined) break\n }\n return yield* refuse(\n \"join_mismatch\",\n node.id,\n `Join at \"${node.id}\" replayed members ${JSON.stringify(decided)} without reaching its verdict.`\n )\n }\n\n const outcomes: Array<Decision> = []\n let verdict: Exit.Exit<unknown, unknown> | undefined\n let journaled = false\n const over = Deferred.makeUnsafe<void>()\n const watch = (index: number) =>\n Effect.exit(settleNode(children[index]!)).pipe(\n Effect.flatMap((exit) =>\n Effect.sync(() => {\n if (verdict !== undefined) return\n const kind = classify(exit)\n // An interrupted member is still undecided: it parked, or a\n // join elsewhere cancelled shared work. The others may still\n // decide without it.\n if (kind === \"pending\") return\n if (kind === \"fatal\") {\n verdict = exit\n } else {\n outcomes.push({ member: members[index]!, exit })\n verdict = decide(ast, members.length, outcomes)\n journaled = verdict !== undefined\n }\n if (verdict !== undefined) Deferred.doneUnsafe(over, Exit.void)\n })\n )\n )\n yield* Effect.raceFirst(\n Effect.forEach(children, (_, index) => watch(index), { concurrency: \"unbounded\", discard: true }),\n Deferred.await(over)\n )\n // Every member ended interrupted: the join cannot decide in this\n // round, and the walk parks or ends with it.\n if (verdict === undefined) return yield* Effect.interrupt\n const decidedMembers = outcomes.map((outcome) => outcome.member)\n yield* Effect.uninterruptible(\n Effect.gen(function*() {\n const { childRuns, fibers } = losingWork(\n node.id,\n children.filter((_, index) => !decidedMembers.includes(members[index]!))\n )\n if (journaled) {\n yield* runtime.deferredDone(journal, {\n flowName: instance.flow._tag,\n executionId: instance.executionId,\n deferredName: journal.name,\n exit: Exit.succeed({ members: decidedMembers, children: childRuns })\n })\n }\n // The interruption is requested, not awaited: a loser's finalizers\n // may wait on work that only settles after the join returns, and\n // the node scope awaits every fiber when the walk ends anyway.\n yield* Effect.withFiber((current) =>\n Effect.sync(() => {\n for (const fiber of fibers) fiber.interruptUnsafe(current.id)\n })\n )\n yield* cancelChildren(childRuns)\n })\n )\n return yield* verdict\n })\n\n const compute: (node: Graph.GraphNode) => Effect.Effect<unknown, unknown, Services> = Effect.fnUntraced(\n function*(node: Graph.GraphNode) {\n const children = sources.get(node.id) ?? []\n const ast = node.ast\n if (ast._tag === \"AndThen\" && ast.next !== undefined) {\n // An explicit sequence is a success boundary for the WHOLE next\n // subtree. Joining first and then concurrently lets a nested All,\n // Map, or inline call start effects before its prerequisite settles.\n // bindPlanned is distinct: it declares data dependencies and can\n // expose independent work while the producer is still running.\n yield* settleNode(children[0]!)\n return yield* settleNode(children[1]!)\n }\n if (ast._tag === \"Branch\") {\n // The predicate decides on the REAL value, and only the arm it chose\n // is settled. Both arms are still in the plan; the untaken one is\n // reported as skipped.\n const decide = Node.predicate(ast)!\n const subject = yield* settleNode(children[0]!)\n return yield* settleNode(decide(subject) ? children[1]! : children[2]!)\n }\n if (ast._tag === \"Catch\") {\n // DECIDED: catch observes only typed\n // failures from ordinary protected execution. Interpreter refusals\n // propagate unchanged. Effect defects and\n // compensation failures remain outside this interpreter's error\n // channel, so recovery cannot conceal a broken invariant or weaken\n // withRollback's compensation guarantees.\n const protectedId = children[0]!\n return yield* Effect.matchEffect(settleNode(protectedId), {\n onFailure: (error) => {\n if (Schema.is(InterpreterError)(error)) return Effect.fail(error)\n const filter = Node.catchFilter(ast)\n if (filter !== undefined && !Schema.is(filter)(error)) {\n return Effect.fail(error)\n }\n // The failure arm's planned subject resolves through the\n // protected node id. Filing the typed failure as that settlement\n // also prevents its static failure edge from re-running the\n // protected graph while the recovery arm is driven.\n failed.set(protectedId, error)\n return settleNode(children[1]!)\n },\n onSuccess: Effect.succeed\n })\n }\n if (ast._tag === \"Race\") {\n // A join must not wait for every member, so its members are left\n // out of the dependency barrier below; its other dependencies \u2014 the\n // references and barriers it reads \u2014 still settle first.\n const members = new Set(children)\n yield* Effect.forEach(\n KeyMaterial.dependencies(node.draft.material).filter((dependency) =>\n !members.has(dependency) && !failed.has(dependency)\n ),\n settleNode,\n { concurrency: \"unbounded\", discard: true }\n )\n return yield* join(node, ast, children)\n }\n // Dependency order, from the key material: the same `Ref` and `Pending`\n // inputs the plan turns into edges, settled before the node that reads\n // them \u2014 and settled CONCURRENTLY, because independent dependencies are\n // exactly what the scheduler admits under separate permits. Two\n // execution surfaces disagreeing about concurrency is a correctness\n // hazard, not just a latency one.\n yield* Effect.forEach(\n KeyMaterial.dependencies(node.draft.material).filter((dependency) => !failed.has(dependency)),\n settleNode,\n { concurrency: \"unbounded\", discard: true }\n )\n switch (ast._tag) {\n case \"ActionCall\":\n // Resolved by the pre-pass above, which refuses the whole graph\n // when an action it names has no implementation. The structural\n // node address is durable dispatch identity, scoped to this one\n // implementation call; it never comes from fiber arrival order.\n return yield* implementations.get(ast.action)!.action(resolve(node.payload)).pipe(\n Effect.provideService(DispatchSite, node.id),\n attenuateCapabilities(node.capabilityCeilings)\n )\n case \"Succeed\":\n return resolve(node.payload)\n case \"Fail\":\n // The typed error channel, from a constant the plan already holds.\n // An enclosing catch observes it exactly as it observes an action's\n // failure, and an uncaught one is the body's typed failure.\n return yield* Effect.fail(resolve(node.payload))\n case \"Map\": {\n const transform = Node.mapper(ast)!\n return transform(yield* settleNode(children[0]!))\n }\n case \"All\": {\n // `All` is a combination, so its members settle concurrently \u2014 the\n // same semantics `PlanScheduler` gives the same graph. Fail-fast\n // matches `Effect.forEach`'s default and the scheduler's halt\n // rule \u2014 with the ownership caveat: what a failure interrupts is\n // each sibling's JOIN, not the node execution itself, which the\n // interpretation owns and interrupts when the walk ends. A node\n // whose execution was interrupted is evicted from the memo and\n // records nothing, so it reports as skipped rather than as a\n // phantom success.\n const members = Object.keys(ast.nodes)\n const values = yield* Effect.forEach(members, (_, index) => settleNode(children[index]!), {\n concurrency: \"unbounded\"\n })\n const joined: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n for (let index = 0; index < members.length; index++) {\n Object.defineProperty(joined, members[index]!, {\n configurable: true,\n enumerable: true,\n value: values[index],\n writable: true\n })\n }\n return joined\n }\n case \"AndThen\":\n return yield* settleNode(children[1]!)\n case \"FlowCall\": {\n if (ast.mode === \"handoff\") {\n const declaration = handoffDeclarations.get(node.id)!\n // DECIDED: a handoff target's schema\n // services come from the context registration captured. A\n // body's type cannot enumerate declarations hidden in its\n // topology, so erase only that dynamic service parameter after\n // resolving the concrete declaration here.\n const payload = yield* Effect.flatMap(\n Effect.orDie(declaration.payloadSchema.makeEffect(resolve(node.payload) as never)),\n (decoded) =>\n Effect.orDie(\n Schema.encodeEffect(Schema.toCodecJson(declaration.payloadSchema))(decoded)\n )\n ) as unknown as Effect.Effect<unknown, never, Services>\n const ceiling = (yield* attenuateCapabilities(node.capabilityCeilings)(CapabilitySet.current)).groups\n const outcome = {\n _tag: \"To\",\n flow: ast.flow,\n payload,\n ...(ceiling.length === 0 ? {} : { capabilityCeilings: ceiling })\n } satisfies Outcome.To<unknown>\n Object.defineProperty(outcome, OutcomeValueTypeId, {\n configurable: false,\n enumerable: false,\n value: \"To\",\n writable: false\n })\n return outcome\n }\n if (ast.mode === \"boundary\") {\n // The real boundary of `docs/guides/run-a-child-flow.md`: an\n // ordinary child execution, opened through the same `execute` a\n // handler would call. The parent's `FlowInstance` is in scope, so\n // the engine records the lineage edge, interrupts the child with\n // the parent, and turns a suspended child into a suspended\n // parent \u2014 genuine nesting, not a spliced imitation of it. It is\n // deliberately NOT `Effect.scoped`: the interrupt link the engine\n // installs is a finalizer of the PARENT's scope, and closing a\n // scope of our own here would run it the moment the child\n // settled. The same dynamic schema-service erasure the handoff\n // above records applies to the cast: a body's type cannot\n // enumerate the declarations hidden in its topology.\n const declaration = childDeclarations.get(node.id)!\n const instance = yield* FlowInstance\n const childPayload = resolve(node.payload)\n const executionId = yield* (childExecutionId(\n instance.executionId,\n node.id,\n declaration._tag,\n childPayload\n ) as unknown as Effect.Effect<string, never, Services>)\n childExecutions.set(node.id, executionId)\n return yield* (declaration.execute(childPayload, {\n executionId\n }) as Effect.Effect<unknown, unknown, Services>).pipe(attenuateCapabilities(node.capabilityCeilings))\n }\n const spliced = children[0]\n if (spliced === undefined) {\n return yield* refuse(\n \"unsupported_call\",\n node.id,\n `Flow \"${ast.flow}\" is called at \"${node.id}\" as a leaf, which this interpreter does not drive. ` +\n \"An inline .call() is spliced into the graph with the callee's body and driven with it, and \" +\n \"only a call that lost its declaration has no body to splice. Build and interpret the authored \" +\n `node in the same process, or call it as ${ast.flow}.child(payload) to run it as its own execution.`\n )\n }\n return yield* settleNode(spliced)\n }\n }\n }\n )\n\n // Closing the node scope on every exit \u2014 value, failure, or the\n // interpretation's own interruption \u2014 is the fail-fast half of the\n // ownership model: whatever is still running when the walk ends is\n // interrupted before the interpretation reports, so no execution\n // outlives it.\n /**\n * Everything the walk never reached, recorded once the walk is over.\n *\n * Only a walk that ENDED reports this. An interrupted one is a run that\n * parked or was cancelled, and its nodes are not skipped \u2014 the resumed\n * walk settles them, and recording them as skipped first would leave the\n * journal claiming a node never ran that later did. A typed failure is\n * terminal for the round, so its stranded nodes are skipped exactly as a\n * completed walk's untaken branch arm is.\n */\n const recordSkipped = (exit: Exit.Exit<unknown, unknown>) =>\n Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause) ? Effect.void : Effect.forEach(\n graphNodes.filter((node) => !reported.has(node.id)),\n (node) => {\n const action = actionTag(node.ast)\n return record(() => ({\n _tag: \"NodeSettled\",\n sourceId: `node/${node.id}/1/settled`,\n nodeId: node.id,\n outcome: \"skipped\",\n attempts: 0,\n // A node the walk never reached dispatched nothing, so it claims\n // no step key and there is no value it settled with.\n stepKeyDigests: [],\n ...(action === undefined ? {} : { action })\n }))\n },\n { discard: true }\n )\n\n const value = yield* settleNode(options.root ?? \"root\").pipe(\n Effect.onExit((exit) => Scope.close(nodes, exit)),\n Effect.onExit(recordSkipped)\n )\n return {\n value,\n settled,\n failed,\n skipped: Graph.nodes(graph).filter((node) => !settled.has(node.id) && !failed.has(node.id)).map((node) => node.id)\n }\n })\n\n/** A child execution a losing join member opened. @private */\nconst JoinChild = Schema.Struct({ node: Schema.String, executionId: Schema.String })\ntype JoinChild = typeof JoinChild.Type\n\n/**\n * The members a join decided on, in the order they decided, and the child\n * executions its losers had opened. A bare member list is the record written\n * before losing children were journaled; it names none, and still replays.\n *\n * @private\n */\nconst JoinDecision = Schema.Union([\n Schema.Struct({ members: Schema.Array(Schema.String), children: Schema.Array(JoinChild) }),\n Schema.Array(Schema.String)\n])\n\n/** One member's decisive settlement. @private */\ninterface Decision {\n readonly member: string\n readonly exit: Exit.Exit<unknown, unknown>\n}\n\n/**\n * How a member's settlement counts toward a join: a value or a typed failure\n * decides, an interruption is still undecided, and a defect or interpreter\n * refusal is fatal to the join.\n *\n * @private\n */\nconst classify = (exit: Exit.Exit<unknown, unknown>): \"decisive\" | \"pending\" | \"fatal\" => {\n if (Exit.isSuccess(exit)) return \"decisive\"\n if (Cause.hasInterruptsOnly(exit.cause)) return \"pending\"\n const reasons = exit.cause.reasons\n const typed = reasons.every((reason) => reason._tag !== \"Die\") &&\n reasons.some((reason) => reason._tag === \"Fail\") &&\n !reasons.some((reason) => reason._tag === \"Fail\" && Schema.is(InterpreterError)(reason.error))\n return typed ? \"decisive\" : \"fatal\"\n}\n\n/**\n * A join's verdict over the members that decided, in the order they decided,\n * or `undefined` while it is still open.\n *\n * `race` takes the first settlement. `any` and `quorum` succeed once `count`\n * members succeed, and fail with the failure that leaves too few members able\n * to: for `any`, that is the last one.\n *\n * @private\n */\nconst decide = (\n ast: Extract<Node.Ast, { readonly _tag: \"Race\" }>,\n width: number,\n outcomes: ReadonlyArray<Decision>\n): Exit.Exit<unknown, unknown> | undefined => {\n if (ast.mode === \"race\") return outcomes[0]?.exit\n const successes = outcomes.filter((outcome) => Exit.isSuccess(outcome.exit))\n if (successes.length >= ast.count) {\n if (ast.mode === \"any\") return successes[0]!.exit\n const joined: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n for (const success of successes) {\n Object.defineProperty(joined, success.member, {\n configurable: true,\n enumerable: true,\n value: (success.exit as Exit.Success<unknown>).value,\n writable: true\n })\n }\n return Exit.succeed(joined)\n }\n if (outcomes.length - successes.length > width - ast.count) return outcomes[outcomes.length - 1]!.exit\n return undefined\n}\n\n/**\n * Turns a body's root value into the settlement the engine acts on.\n *\n * Three of them exist, and only three\n * (`docs/concepts/trampoline-rounds.md`): `done(value)` is the answer, so the\n * value passes straight through; `Next.to(payload)` is the next round, recorded in the instance's\n * handoff slot so `Flow.intoResult` answers `Flow.Handoff`; and `park(reason)`\n * is a durable suspension, declared through the ordinary waiting vocabulary so\n * a durable driver parks the run under the flow's own reason and wake token\n * rather than the derived `timer`/`event` default. Anything else is an ordinary\n * value and is the answer as it stands, which is what keeps a body that never\n * heard of the trampoline working unchanged.\n *\n * @private\n */\nconst settleOutcome = (value: unknown): Effect.Effect<unknown, never, FlowInstance> => {\n if (!Outcome.isOutcome(value)) return Effect.succeed(value)\n switch (value._tag) {\n case \"Done\":\n return Effect.succeed(value.value)\n case \"To\":\n return Effect.gen(function*() {\n const instance = yield* FlowInstance\n const current = yield* CapabilitySet.current\n instance.handoff = new Handoff({\n flow: value.flow,\n payload: value.payload,\n capabilityCeilings: [...current.groups, ...(value.capabilityCeilings ?? [])]\n })\n })\n case \"Park\":\n return Effect.andThen(\n annotateWaiting(value.reason),\n Effect.flatMap(FlowInstance, suspend)\n )\n }\n}\n\n/**\n * Registers a flow with the runtime, driven by its body.\n *\n * This is the only way a flow's behavior reaches the runtime, and the reason a\n * flow has no `toLayer`: a flow has one behavior and it is the body, so there\n * is no second, opaque one to attach. An Action is what carries an\n * implementation, and it attaches that implementation with its own `toLayer`.\n * Compose this beside the action implementation layers the body calls, over the\n * {@link module:Implementations.layerImplementations} table they file\n * themselves in \u2014 the table goes UNDER them, because filing happens while an\n * implementation layer is built:\n *\n * ```ts\n * Layer.mergeAll(Read.toLayer(read), Write.toLayer(write), Interpreter.layer(Pipeline)).pipe(\n * Layer.provideMerge(Action.layerImplementations)\n * )\n * ```\n *\n * It accepts a flow whatever its requirement channel says, and requires only\n * the table. Registering a body is not running one: the handler installed here\n * resolves each call by tag when the run reaches it, which is the same thing a\n * driver does for a plan read back out of a journal. `Flow.execute` is where\n * the requirements are asked for.\n *\n * This low-level registration keeps the `process-local` callback policy for\n * compatibility. Select `callbackIdentity: \"stable\"`, or use\n * {@link layerWithImplementations}, to refuse unstable callbacks before\n * dispatch. Without that selection it makes no reproducible-plan guarantee.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layer = <\n Tag extends string,\n Payload extends AnyStructSchema,\n Success extends Schema.Top,\n Error extends Schema.Top\n>(\n flow: Flow<Tag, Payload, Success, Error, any>,\n options: Graph.BuildOptions = {}\n) => makeLayer(flow, options, false)\n\n/** Registers one interpreter policy without changing the low-level compatibility surface. @private */\nconst makeLayer = <\n Tag extends string,\n Payload extends AnyStructSchema,\n Success extends Schema.Top,\n Error extends Schema.Top\n>(\n flow: Flow<Tag, Payload, Success, Error, any>,\n options: Graph.BuildOptions,\n requireReusableVersions: boolean,\n reachable?: Set<AnyWithProps>,\n ifAbsent = false\n): Layer.Layer<\n never,\n never,\n | FlowRuntime\n | Implementations\n | Payload[\"DecodingServices\"]\n | Payload[\"EncodingServices\"]\n | Success[\"DecodingServices\"]\n | Success[\"EncodingServices\"]\n | Error[\"DecodingServices\"]\n | Error[\"EncodingServices\"]\n> =>\n Layer.effectDiscard(Effect.gen(function*() {\n const runtime = yield* FlowRuntime\n const registered = reachable ?? new Set<AnyWithProps>()\n if (registered.has(flow)) return\n // Lazy registration can be skipped by an independent live owner. Recheck\n // on later executions so releasing that owner permits fresh admission.\n if (!ifAbsent) registered.add(flow)\n const scope = yield* Effect.scope\n const context = yield* Effect.context<Services | Scope.Scope>()\n const implementations = Context.get(context, Implementations)\n // Keep discovered declarations in the host registration scope, rather\n // than the executing parent's scope: handoffs outlive that parent.\n // Dynamic declarations erase their codec services, just like execute;\n // those services still come from the registering host's context.\n const registerReachable = (declaration: AnyWithProps): Effect.Effect<void> =>\n Layer.buildWithScope(\n makeLayer(\n declaration as Flow<string, AnyStructSchema, Schema.Top, Schema.Top, any>,\n options,\n requireReusableVersions,\n registered,\n true\n ),\n scope\n ).pipe(\n Effect.provide(context),\n Effect.asVoid\n ) as Effect.Effect<void>\n const middleware = Context.get(flow.annotations, ExecutionMiddleware)\n yield* runtime.register(\n flow,\n ((payload: Payload[\"Type\"]) => {\n const body = Effect.flatMap(\n interpretWithPolicy(flow, payload, options, requireReusableVersions, registerReachable),\n (interpretation) => settleOutcome(interpretation.value)\n )\n // Registration owns action resolution. A caller may supply a different\n // table when entering this flow as a child; retain dynamic execution\n // services while restoring this flow's registered implementations.\n return (middleware === undefined ? body : middleware.wrap(payload, body)).pipe(\n Effect.provideService(Implementations, implementations)\n )\n }) as (payload: Payload[\"Type\"], executionId: string) => Effect.Effect<\n Success[\"Type\"],\n Error[\"Type\"],\n Crypto.Crypto | Implementations\n >,\n { ifAbsent }\n )\n }))\n\n/**\n * Composes one flow and its implementation layers around one isolated registry.\n *\n * The implementation layer must provide every action requirement carried by the\n * flow. Callback identity defaults to `stable`: raw callbacks are refused before\n * dispatch, with a diagnostic naming the callback and `Node.capture`. Captures\n * must cover semantic configuration and implementation versions, including\n * behavior reached through imports. Explicit `callbackIdentity: \"process-local\"`\n * is available for local experimentation, without a reproducible-plan claim.\n * Sealed actions with an idempotency key must declare `implementationVersion`\n * and register that exact version. This rule is independent of callback policy:\n * those declarations can reuse recorded content even if their code changes.\n * Keyless sealed actions use invocation identity; compensable and irreversible\n * actions do not use content-key caching. Their versions remain optional.\n * Versions must cover semantic handler and service changes; callback stability\n * cannot establish that declaration's completeness.\n *\n * The interpreter validates all named graph actions before dispatching any\n * of them. Conflicting registrations fail while the layer builds; use an explicit\n * `toLayer(handler, { override: true })` only for intentional scoped substitution.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerWithImplementations = <\n Tag extends string,\n Payload extends AnyStructSchema,\n Success extends Schema.Top,\n Error extends Schema.Top,\n Requires,\n Provided,\n E,\n R\n>(\n flow: Flow<Tag, Payload, Success, Error, Requires>,\n implementations:\n & Layer.Layer<Provided, E, R>\n & (\n [NoInfer<Requires>] extends [Provided] ? unknown\n : { readonly missingActionImplementations: Exclude<Requires, Provided> }\n ),\n options: Graph.BuildOptions = {}\n) =>\n Layer.merge(\n implementations,\n makeLayer(flow, { ...options, callbackIdentity: options.callbackIdentity ?? \"stable\" }, true)\n )\n .pipe(\n Layer.provide(Layer.fresh(layerImplementations))\n )\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CA,oBAAyB;AACzB,oBAA+B;AAC/B,kBAAmC;AACnC,6BAAkC;AAClC,kBAA6B;AAC7B,WAAsB;AACtB,cAAyB;AACzB,cAAyB;AACzB,YAAuB;AACvB,cAAyB;AAEzB,eAA0B;AAC1B,aAAwB;AACxB,WAAsB;AAEtB,YAAuB;AACvB,aAAwB;AACxB,gBAA2B;AAC3B,aAAwB;AACxB,YAAuB;AACvB,6BAA2E;AAC3E,0BAA6C;AAC7C,sBAAiC;AACjC,+BAAsC;AAEtC,cAAyB;AACzB,oBAAwB;AACxB,qBAAwB;AACxB,oBAAqC;AACrC,0BAA6B;AAC7B,yBAA4B;AAE5B,+BAAgC;AAChC,YAAuB;AACvB,kBAA6B;AAC7B,iCAAoC;AACpC,2BAAmC;AAkB5B,MAAM,yBAAyB,OAAO,YAA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oBAAoB,MAAM,SAAS,SAAS,yBAAyB,iBAAiB;AAAA,QACtF,CAAC,mBAAmB,cAAc,eAAe,KAAK;AAAA,MACxD;AAIA,cAAQ,eAAe,SAAY,OAAO,WAAW,KAAK,SAAS,IAAI,GAAG;AAAA,QACxE,OAAO,eAAe,wCAAiB,eAAe;AAAA,MACxD;AAAA,IACF;AAAA,IAKA,EAAE,SAAS;AAAA,EACb;AACF,CAAC,CAAC;AA0BG,MAAM,2BAA2B,CAUtC,MACA,iBAMA,UAA8B,CAAC,MAE/B,MAAM;AAAA,EACJ;AAAA,EACA,UAAU,MAAM,EAAE,GAAG,SAAS,kBAAkB,QAAQ,oBAAoB,SAAS,GAAG,IAAI;AAC9F,EACG;AAAA,EACC,MAAM,QAAQ,MAAM,MAAM,2CAAoB,CAAC;AACjD;",
6
+ "names": ["reported", "record", "declaration", "FlowTypeId", "value", "outcomes", "verdict", "decide", "payload"]
7
+ }
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Polling as a durable lineage: one attempt per round, a durable wait between
3
+ * attempts, and a bound the lineage settles on.
4
+ *
5
+ * Smithers 0.x had a `Poller` component — a check, an interval, a backoff, an
6
+ * attempt bound, and what to do at that bound. The pieces it was built from
7
+ * already exist here: {@link module:Sleep.action} is the durable wait, and
8
+ * `Flow.to` opens the next round. What was missing is the shape that puts them
9
+ * together, and that is this module.
10
+ *
11
+ * A poll is a flow whose body is ONE attempt. It runs the check, and branches:
12
+ * a satisfied check settles the lineage with the check's own output, an
13
+ * unsatisfied one sleeps for this attempt's delay and hands off to the next
14
+ * round with the attempt counter raised. The last attempt has no sleep and no
15
+ * handoff — it either answers with the output it just read (`return-last`) or
16
+ * fails {@link PollExhausted} (`fail`).
17
+ *
18
+ * Everything durable about it is durable for the ordinary reason. Each attempt
19
+ * is a round with its own keyed plan nodes, so a check that already ran replays
20
+ * from its recorded outcome instead of running again; the wait between attempts
21
+ * is a durable timer, so a process that dies during it resumes on the round it
22
+ * left rather than starting the poll over; and the attempt counter travels in
23
+ * the payload, so nothing about "which attempt is this" lives in memory.
24
+ *
25
+ * The bound is stated twice on purpose. The body ends the lineage on the last
26
+ * attempt, and `maxAttempts` is also the flow's `maxRounds` budget, so a
27
+ * lineage that somehow opened another round is refused by the engine rather
28
+ * than polling forever.
29
+ *
30
+ * @since 0.1.0
31
+ */
32
+ import * as Node from "@smthrs/plan/Node";
33
+ import type * as Repetition from "@smthrs/plan/Repetition";
34
+ import type * as Crypto from "effect/Crypto";
35
+ import type * as Layer from "effect/Layer";
36
+ import * as Schema from "effect/Schema";
37
+ import * as Action from "./Action/index.ts";
38
+ import * as Flow from "./Flow/index.ts";
39
+ import type { FlowRuntime } from "./FlowRuntime/FlowRuntime.ts";
40
+ import * as Sleep from "./Sleep.ts";
41
+ /**
42
+ * How the wait between attempts grows.
43
+ *
44
+ * `fixed` waits the interval every time, `linear` waits the interval times the
45
+ * attempt, and `exponential` doubles the interval on every attempt.
46
+ *
47
+ * @category models
48
+ * @since 0.1.0
49
+ */
50
+ export type Backoff = "fixed" | "linear" | "exponential";
51
+ /**
52
+ * What a check reports: whether the poll is over, and the value this attempt
53
+ * read.
54
+ *
55
+ * The output travels on every attempt, satisfied or not, because it is also
56
+ * the answer a `return-last` poll settles with when it runs out of attempts.
57
+ *
58
+ * @category models
59
+ * @since 0.1.0
60
+ */
61
+ export interface Check<out Result> {
62
+ readonly satisfied: boolean;
63
+ readonly output: Result;
64
+ }
65
+ /**
66
+ * The success schema a check action declares.
67
+ *
68
+ * @category schemas
69
+ * @since 0.1.0
70
+ */
71
+ export declare const CheckResult: <Result extends Schema.Top>(result: Result) => Schema.Struct<{
72
+ readonly satisfied: typeof Schema.Boolean;
73
+ readonly output: Result;
74
+ }>;
75
+ declare const PollExhausted_base: Schema.Class<PollExhausted, Schema.TaggedStruct<"@smthrs/flow/PollExhausted", {
76
+ readonly code: Schema.withConstructorDefault<Schema.Literal<"poll_exhausted">>;
77
+ readonly poll: Schema.String;
78
+ readonly attempts: Schema.Number;
79
+ readonly message: Schema.String;
80
+ }>, import("effect/Cause").YieldableError>;
81
+ /**
82
+ * A poll that used its last attempt without a satisfied check.
83
+ *
84
+ * It is a typed failure rather than a defect: running out of attempts is an
85
+ * expected outcome of polling something that may never become ready, so a
86
+ * caller recovers from it through `Node.catch` like any other declared failure.
87
+ *
88
+ * @category errors
89
+ * @since 0.1.0
90
+ */
91
+ export declare class PollExhausted extends PollExhausted_base {
92
+ }
93
+ /**
94
+ * The tag the exhaustion step is catalogued and resolved under.
95
+ *
96
+ * @category constructors
97
+ * @since 0.1.0
98
+ */
99
+ export declare const exhaustedTag = "system/poll-exhausted";
100
+ /**
101
+ * The declared step a poll takes when its last attempt was not satisfied.
102
+ *
103
+ * Running out of attempts is a step rather than a bare `Effect.fail` so the
104
+ * exhaustion is in the plan and in the journal: the round that gave up shows
105
+ * which poll gave up and after how many attempts, exactly like every other node
106
+ * a body drove.
107
+ *
108
+ * @category constructors
109
+ * @since 0.1.0
110
+ */
111
+ export declare const exhausted: Action.Declared<typeof exhaustedTag, Schema.Struct<{
112
+ readonly poll: typeof Schema.String;
113
+ readonly attempts: typeof Schema.Number;
114
+ }>, typeof Schema.Never, typeof PollExhausted, never>;
115
+ /**
116
+ * The wait before the attempt after this one, in milliseconds.
117
+ *
118
+ * @category combinators
119
+ * @since 0.1.0
120
+ */
121
+ export declare const delayMillis: (options: {
122
+ readonly intervalMs: number;
123
+ readonly backoff: Backoff;
124
+ readonly attempt: number;
125
+ }) => number;
126
+ /**
127
+ * What a poll round can fail with.
128
+ *
129
+ * {@link PollExhausted} is the poll's own failure. `SleepRequestInvalid` is the
130
+ * wait node's, declared because the wait between attempts is an ordinary
131
+ * {@link module:Sleep.action} node and its typed refusal is part of the
132
+ * topology a poll carries. Its codes cover a payload that names no deadline,
133
+ * names two deadlines, or names a value that is not a deadline. {@link make}
134
+ * refuses invalid author schedules at construction. A caller-visible round
135
+ * payload can still carry an invalid attempt that produces an invalid derived
136
+ * wait, so `Sleep` refuses that wait before the round parks.
137
+ *
138
+ * @category schemas
139
+ * @since 0.1.0
140
+ */
141
+ export declare const Failure: Schema.Union<readonly [typeof PollExhausted, typeof Sleep.SleepRequestInvalid]>;
142
+ /**
143
+ * The payload schema {@link make} derives from an author's input fields: the
144
+ * author's own fields, plus the attempt this round is.
145
+ *
146
+ * `attempt` is optional so a caller starts a poll with its own fields alone;
147
+ * the first round reads it as one.
148
+ *
149
+ * @category models
150
+ * @since 0.1.0
151
+ */
152
+ export type PayloadSchema<Input extends Schema.Struct.Fields> = Schema.Struct<Input & {
153
+ readonly attempt: Schema.optional<typeof Schema.Number>;
154
+ }>;
155
+ /**
156
+ * Declares a durable poller.
157
+ *
158
+ * **When to use**
159
+ *
160
+ * Use it wherever a run has to keep asking until something is ready — a build
161
+ * that finishes, a deployment that goes live, a review that lands — and the
162
+ * waiting has to survive a restart. `check` is the one thing an author writes:
163
+ * a body fragment that reads whatever it polls and reports a {@link Check}.
164
+ * Everything else is schedule. Under stable callback admission (the default of
165
+ * `Interpreter.layerWithImplementations`), wrap `check` in `Node.capture` with
166
+ * every semantic capture, including a version for imported behavior. An
167
+ * uncaptured check keeps the poll process-local. The helper captures its own
168
+ * callbacks using the schedule and the check's identity.
169
+ *
170
+ * ```ts
171
+ * const Deployment = Poll.make("deploy/wait", {
172
+ * input: { id: Schema.String },
173
+ * result: Schema.String,
174
+ * intervalMs: 5_000,
175
+ * backoff: "exponential",
176
+ * maxAttempts: 8,
177
+ * onTimeout: "fail",
178
+ * check: Node.capture(
179
+ * { action: Status.name, implementationVersion: "deploy/status-check/v1" },
180
+ * ({ attempt, id }) => Status.call({ attempt, id })
181
+ * )
182
+ * })
183
+ * ```
184
+ *
185
+ * The check may not fail. A check that can fail states what a failure means for
186
+ * the poll — give up, or treat it as "not ready yet" — with `Node.catch` inside
187
+ * the fragment, rather than leaving the poll to guess.
188
+ *
189
+ * A per-attempt time limit on the check itself is NOT a poll option. A plan
190
+ * node's duration is not something the body around it can bound; that bound
191
+ * belongs in the check's own implementation, where `DurableDeferred.raceAll`
192
+ * races the work against a durable clock and stays replayable.
193
+ *
194
+ * A schedule no clock can be armed with is refused here, with a `RangeError`
195
+ * naming the option that is wrong. `intervalMs` becomes the `millis` of a
196
+ * {@link module:Sleep.action} node, and a wait of `Infinity`, `NaN`, or a
197
+ * negative length arms a timer that never fires — a poll that hangs forever
198
+ * with a plan that looks correct. The check is on the schedule, not only on the
199
+ * interval: `{ intervalMs: 1000, maxAttempts: 2000, backoff: "exponential" }`
200
+ * states three finite options and asks for an infinite wait, so the LAST wait
201
+ * the poll can arm has to be a length too. `maxAttempts` is the lineage's round
202
+ * budget, and a budget below one attempt reaches `Flow.make` as a `maxRounds`
203
+ * complaint about an option the author never wrote.
204
+ *
205
+ * @throws A `RangeError` when `intervalMs` is not a duration a clock accepts,
206
+ * when `maxAttempts` is not a whole number of attempts of at least one, or when
207
+ * the interval under the declared backoff reaches a wait no clock can be armed
208
+ * with before the budget is spent.
209
+ * @category constructors
210
+ * @since 0.1.0
211
+ */
212
+ export declare const make: <const Tag extends string, Input extends Schema.Struct.Fields, Result extends Schema.Top, R = never>(tag: Tag, options: {
213
+ readonly input: Input;
214
+ readonly result: Result;
215
+ readonly check: (payload: Schema.Struct.Type<Input> & {
216
+ readonly attempt: number;
217
+ }) => Node.Node<Check<Result["Type"]>, never, R>;
218
+ readonly intervalMs: number;
219
+ readonly maxAttempts: number;
220
+ readonly backoff?: Backoff | undefined;
221
+ readonly onTimeout?: Repetition.AtCeiling | undefined;
222
+ }) => Flow.Flow<Tag, PayloadSchema<Input>, Result, typeof Failure, R>;
223
+ /**
224
+ * The exhaustion implementation, provided beside the other action layers a
225
+ * poll's rounds call.
226
+ *
227
+ * ```ts
228
+ * Layer.mergeAll(Poll.layer, Sleep.layer, Interpreter.layer(Deployment)).pipe(
229
+ * Layer.provideMerge(Action.layerImplementations)
230
+ * )
231
+ * ```
232
+ *
233
+ * @category layers
234
+ * @since 0.1.0
235
+ */
236
+ export declare const layer: Layer.Layer<never, never, Crypto.Crypto | FlowRuntime>;
237
+ export {};
238
+ //# sourceMappingURL=Poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Poll.d.ts","sourceRoot":"","sources":["../../src/Poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,KAAK,UAAU,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAE5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAA;AAExD;;;;;;;;;GASG;AACH,MAAM,WAAW,KAAK,CAAC,GAAG,CAAC,MAAM;IAC/B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,MAAM,CAAC,GAAG,EACnD,QAAQ,MAAM,KACb,MAAM,CAAC,MAAM,CAAC;IACf,QAAQ,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,CAAA;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB,CAAiE,CAAA;;;;;;;AAElE;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,kBAWlC;CAAG;AAEJ;;;;;GAKG;AACH,eAAO,M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AS;IACP,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,CACd,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAC9D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,SAAS,GAAG,SAAS,CAAA;CACtD,KACA,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,OAAO,EAAE,CAAC,CAoFhE,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,WAAW,CASxE,CAAA"}
@@ -0,0 +1,150 @@
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 Poll_exports = {};
30
+ __export(Poll_exports, {
31
+ CheckResult: () => CheckResult,
32
+ Failure: () => Failure,
33
+ PollExhausted: () => PollExhausted,
34
+ delayMillis: () => delayMillis,
35
+ exhausted: () => exhausted,
36
+ exhaustedTag: () => exhaustedTag,
37
+ layer: () => layer,
38
+ make: () => make
39
+ });
40
+ module.exports = __toCommonJS(Poll_exports);
41
+ var Node = __toESM(require("@smthrs/plan/Node"), 1);
42
+ var Effect = __toESM(require("effect/Effect"), 1);
43
+ var Schema = __toESM(require("effect/Schema"), 1);
44
+ var Action = __toESM(require("./Action/index.js"), 1);
45
+ var Flow = __toESM(require("./Flow/index.js"), 1);
46
+ var Sleep = __toESM(require("./Sleep.js"), 1);
47
+ const CheckResult = (result) => Schema.Struct({ satisfied: Schema.Boolean, output: result });
48
+ class PollExhausted extends Schema.TaggedError()(
49
+ "@smthrs/flow/PollExhausted",
50
+ {
51
+ // This wire shape freezes at 1.0.0-rc.0.
52
+ code: Schema.Literal("poll_exhausted").pipe(
53
+ Schema.withConstructorDefault(Effect.succeed("poll_exhausted"))
54
+ ),
55
+ poll: Schema.String,
56
+ attempts: Schema.Number,
57
+ message: Schema.String
58
+ }
59
+ ) {
60
+ }
61
+ const exhaustedTag = "system/poll-exhausted";
62
+ const exhausted = Action.makeSystem(exhaustedTag, {
63
+ payload: { poll: Schema.String, attempts: Schema.Number },
64
+ success: Schema.Never,
65
+ error: PollExhausted,
66
+ tier: "sealed"
67
+ });
68
+ const delayMillis = (options) => options.intervalMs * (options.backoff === "fixed" ? 1 : options.backoff === "linear" ? options.attempt : 2 ** (options.attempt - 1));
69
+ const Failure = Schema.Union([PollExhausted, Sleep.SleepRequestInvalid]);
70
+ const payloadSchema = (input, maxAttempts) => Schema.Struct({
71
+ ...input,
72
+ attempt: Schema.optional(
73
+ Schema.Int.check(
74
+ Schema.isGreaterThanOrEqualTo(1),
75
+ Schema.isLessThanOrEqualTo(maxAttempts)
76
+ )
77
+ )
78
+ });
79
+ const attemptOf = (payload) => {
80
+ const attempt = payload.attempt;
81
+ return typeof attempt === "number" ? attempt : 1;
82
+ };
83
+ const withAttempt = (payload, attempt) => ({ ...payload, attempt });
84
+ const make = (tag, options) => {
85
+ if (Object.prototype.hasOwnProperty.call(options.input, "attempt")) {
86
+ throw new TypeError(
87
+ `Poll.make: "${tag}" input cannot declare the reserved "attempt" field. Poll owns that counter across durable rounds.`
88
+ );
89
+ }
90
+ const input = Object.freeze({ ...options.input });
91
+ const result = options.result;
92
+ const check = options.check;
93
+ const intervalMs = options.intervalMs;
94
+ const maxAttempts = options.maxAttempts;
95
+ if (!Number.isFinite(intervalMs) || intervalMs < 0) {
96
+ throw new RangeError(
97
+ `Poll.make: "${tag}" intervalMs must be a finite number of milliseconds that is not negative, and was ${intervalMs}. The interval is the length of a durable wait, and a wait of that length never ends.`
98
+ );
99
+ }
100
+ if (!Number.isSafeInteger(maxAttempts) || maxAttempts < 1) {
101
+ throw new RangeError(
102
+ `Poll.make: "${tag}" maxAttempts must be a whole number of attempts of at least one, and was ${maxAttempts}. A poll checks at least once.`
103
+ );
104
+ }
105
+ const backoff = options.backoff ?? "fixed";
106
+ const longestWaitMs = maxAttempts > 1 ? delayMillis({ intervalMs, backoff, attempt: maxAttempts - 1 }) : 0;
107
+ if (!Number.isFinite(longestWaitMs)) {
108
+ throw new RangeError(
109
+ `Poll.make: "${tag}" asks for a wait of ${longestWaitMs} ms before its last attempt. An intervalMs of ${intervalMs} under the "${backoff}" backoff reaches a length no clock can be armed with by attempt ${maxAttempts - 1} of ${maxAttempts}. Lower maxAttempts, shorten the interval, or slow the backoff.`
110
+ );
111
+ }
112
+ const onTimeout = options.onTimeout ?? "fail";
113
+ const captures = { tag, intervalMs, backoff, maxAttempts, onTimeout, check: Node.functionIdentity(check) };
114
+ const body = (payload) => {
115
+ const attempt = attemptOf(payload);
116
+ const last = attempt >= maxAttempts;
117
+ return check(withAttempt(payload, attempt)).pipe(
118
+ Node.branch({
119
+ if: Node.capture(captures, (checked) => checked.satisfied),
120
+ then: (checked) => Flow.done(checked.output),
121
+ else: (checked) => last ? onTimeout === "return-last" ? Flow.done(checked.output) : exhausted.call({ poll: tag, attempts: attempt }) : Sleep.action.call({
122
+ millis: delayMillis({ intervalMs, backoff, attempt })
123
+ }).pipe(
124
+ Node.andThen(
125
+ self.to(withAttempt(payload, attempt + 1))
126
+ )
127
+ )
128
+ })
129
+ );
130
+ };
131
+ const self = Flow.make(tag, {
132
+ payload: payloadSchema(input, maxAttempts),
133
+ success: result,
134
+ error: Failure,
135
+ maxRounds: maxAttempts,
136
+ // A captured wrapper must not admit a process-local check as stable.
137
+ body: captures.check.algorithm === "sha256-source-ephemeral/v4" ? body : Node.capture(captures, body)
138
+ });
139
+ return self;
140
+ };
141
+ const layer = exhausted.toLayer(
142
+ ({ attempts, poll }) => Effect.fail(
143
+ new PollExhausted({
144
+ poll,
145
+ attempts,
146
+ message: `Poll "${poll}" used all ${attempts} attempts without a satisfied check.`
147
+ })
148
+ )
149
+ );
150
+ //# sourceMappingURL=Poll.js.map