@decaf-ts/as-graph 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/README.md +158 -2
  2. package/dist/as-graph.cjs +1 -1
  3. package/dist/as-graph.cjs.map +1 -1
  4. package/dist/as-graph.js +1 -1
  5. package/dist/as-graph.js.map +1 -1
  6. package/lib/cjs/dagster/DagsterGraphEventBridge.cjs +344 -0
  7. package/lib/cjs/dagster/DagsterGraphEventBridge.cjs.map +1 -0
  8. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +789 -0
  9. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -0
  10. package/lib/cjs/dagster/DagsterResultMapper.cjs +56 -0
  11. package/lib/cjs/dagster/DagsterResultMapper.cjs.map +1 -0
  12. package/lib/cjs/dagster/DagsterTypes.cjs +4 -0
  13. package/lib/cjs/dagster/DagsterTypes.cjs.map +1 -0
  14. package/lib/cjs/dagster/capabilities.cjs +102 -0
  15. package/lib/cjs/dagster/capabilities.cjs.map +1 -0
  16. package/lib/cjs/dagster/constants.cjs +92 -0
  17. package/lib/cjs/dagster/constants.cjs.map +1 -0
  18. package/lib/cjs/dagster/index.cjs +32 -0
  19. package/lib/cjs/dagster/index.cjs.map +1 -0
  20. package/lib/cjs/engine/constants.cjs +6 -1
  21. package/lib/cjs/engine/constants.cjs.map +1 -1
  22. package/lib/cjs/engine/execution/GraphCodeMode.cjs +137 -0
  23. package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -0
  24. package/lib/cjs/engine/execution/GraphExecutionBackend.cjs +89 -0
  25. package/lib/cjs/engine/execution/GraphExecutionBackend.cjs.map +1 -0
  26. package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs +107 -0
  27. package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs.map +1 -0
  28. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +250 -733
  29. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  30. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +804 -0
  31. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -0
  32. package/lib/cjs/engine/execution/index.cjs +4 -0
  33. package/lib/cjs/engine/execution/index.cjs.map +1 -1
  34. package/lib/cjs/engine/index.cjs +4 -0
  35. package/lib/cjs/engine/index.cjs.map +1 -1
  36. package/lib/cjs/engine/runs/GraphRunService.cjs +61 -0
  37. package/lib/cjs/engine/runs/GraphRunService.cjs.map +1 -1
  38. package/lib/cjs/engine/services/GraphWorkflowService.cjs +33 -14
  39. package/lib/cjs/engine/services/GraphWorkflowService.cjs.map +1 -1
  40. package/lib/cjs/mastra/MastraCapabilities.cjs +171 -0
  41. package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -0
  42. package/lib/cjs/mastra/MastraConditionBridge.cjs +39 -0
  43. package/lib/cjs/mastra/MastraConditionBridge.cjs.map +1 -0
  44. package/lib/cjs/mastra/MastraEventBridge.cjs +486 -0
  45. package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -0
  46. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +351 -0
  47. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -0
  48. package/lib/cjs/mastra/MastraResumeGuard.cjs +127 -0
  49. package/lib/cjs/mastra/MastraResumeGuard.cjs.map +1 -0
  50. package/lib/cjs/mastra/MastraSchemaConverter.cjs +124 -0
  51. package/lib/cjs/mastra/MastraSchemaConverter.cjs.map +1 -0
  52. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +461 -0
  53. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -0
  54. package/lib/cjs/mastra/MastraWorkflowManager.cjs +401 -0
  55. package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -0
  56. package/lib/cjs/mastra/index.cjs +35 -0
  57. package/lib/cjs/mastra/index.cjs.map +1 -0
  58. package/lib/cjs/mastra/types.cjs +34 -0
  59. package/lib/cjs/mastra/types.cjs.map +1 -0
  60. package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs +136 -0
  61. package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs.map +1 -0
  62. package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs +140 -0
  63. package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs.map +1 -0
  64. package/lib/cjs/nest/graph/GraphEngineController.cjs +227 -0
  65. package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -0
  66. package/lib/cjs/nest/graph/GraphExecutionModule.cjs +30 -2
  67. package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
  68. package/lib/cjs/nest/graph/index.cjs +3 -0
  69. package/lib/cjs/nest/graph/index.cjs.map +1 -1
  70. package/lib/cjs/nest/graph/main.cjs +54 -0
  71. package/lib/cjs/nest/graph/main.cjs.map +1 -0
  72. package/lib/cjs/nest/graph/servingErrors.cjs +3 -0
  73. package/lib/cjs/nest/graph/servingErrors.cjs.map +1 -1
  74. package/lib/cjs/node/utility/code/node.cjs +11 -3
  75. package/lib/cjs/node/utility/code/node.cjs.map +1 -1
  76. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +2 -3
  77. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
  78. package/lib/cjs/shared/graph/constants.cjs +8 -0
  79. package/lib/cjs/shared/graph/constants.cjs.map +1 -1
  80. package/lib/cjs/shared/graph/index.cjs +2 -1
  81. package/lib/cjs/shared/graph/index.cjs.map +1 -1
  82. package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs +146 -0
  83. package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs.map +1 -0
  84. package/lib/cjs/shared/graph/layout/index.cjs +23 -0
  85. package/lib/cjs/shared/graph/layout/index.cjs.map +1 -0
  86. package/lib/cjs/shared/graph/layout/layout-options.cjs +93 -0
  87. package/lib/cjs/shared/graph/layout/layout-options.cjs.map +1 -0
  88. package/lib/cjs/shared/ui/index.cjs +8 -10
  89. package/lib/cjs/shared/ui/index.cjs.map +1 -1
  90. package/lib/esm/dagster/DagsterGraphEventBridge.js +339 -0
  91. package/lib/esm/dagster/DagsterGraphEventBridge.js.map +1 -0
  92. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +781 -0
  93. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -0
  94. package/lib/esm/dagster/DagsterResultMapper.js +51 -0
  95. package/lib/esm/dagster/DagsterResultMapper.js.map +1 -0
  96. package/lib/esm/dagster/DagsterTypes.js +2 -0
  97. package/lib/esm/dagster/DagsterTypes.js.map +1 -0
  98. package/lib/esm/dagster/capabilities.js +97 -0
  99. package/lib/esm/dagster/capabilities.js.map +1 -0
  100. package/lib/esm/dagster/constants.js +88 -0
  101. package/lib/esm/dagster/constants.js.map +1 -0
  102. package/lib/esm/dagster/index.js +15 -0
  103. package/lib/esm/dagster/index.js.map +1 -0
  104. package/lib/esm/engine/constants.js +5 -0
  105. package/lib/esm/engine/constants.js.map +1 -1
  106. package/lib/esm/engine/execution/GraphCodeMode.js +132 -0
  107. package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -0
  108. package/lib/esm/engine/execution/GraphExecutionBackend.js +83 -0
  109. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -0
  110. package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js +102 -0
  111. package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js.map +1 -0
  112. package/lib/esm/engine/execution/GraphExecutionEngine.js +232 -716
  113. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  114. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +799 -0
  115. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -0
  116. package/lib/esm/engine/execution/index.js +4 -0
  117. package/lib/esm/engine/execution/index.js.map +1 -1
  118. package/lib/esm/engine/index.js +4 -0
  119. package/lib/esm/engine/index.js.map +1 -1
  120. package/lib/esm/engine/runs/GraphRunService.js +62 -1
  121. package/lib/esm/engine/runs/GraphRunService.js.map +1 -1
  122. package/lib/esm/engine/services/GraphWorkflowService.js +33 -14
  123. package/lib/esm/engine/services/GraphWorkflowService.js.map +1 -1
  124. package/lib/esm/mastra/MastraCapabilities.js +164 -0
  125. package/lib/esm/mastra/MastraCapabilities.js.map +1 -0
  126. package/lib/esm/mastra/MastraConditionBridge.js +34 -0
  127. package/lib/esm/mastra/MastraConditionBridge.js.map +1 -0
  128. package/lib/esm/mastra/MastraEventBridge.js +481 -0
  129. package/lib/esm/mastra/MastraEventBridge.js.map +1 -0
  130. package/lib/esm/mastra/MastraGraphExecutionBackend.js +346 -0
  131. package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -0
  132. package/lib/esm/mastra/MastraResumeGuard.js +123 -0
  133. package/lib/esm/mastra/MastraResumeGuard.js.map +1 -0
  134. package/lib/esm/mastra/MastraSchemaConverter.js +119 -0
  135. package/lib/esm/mastra/MastraSchemaConverter.js.map +1 -0
  136. package/lib/esm/mastra/MastraWorkflowCompiler.js +456 -0
  137. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -0
  138. package/lib/esm/mastra/MastraWorkflowManager.js +396 -0
  139. package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -0
  140. package/lib/esm/mastra/index.js +18 -0
  141. package/lib/esm/mastra/index.js.map +1 -0
  142. package/lib/esm/mastra/types.js +30 -0
  143. package/lib/esm/mastra/types.js.map +1 -0
  144. package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js +129 -0
  145. package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js.map +1 -0
  146. package/lib/esm/nest/graph/GraphEngineCapabilityService.js +131 -0
  147. package/lib/esm/nest/graph/GraphEngineCapabilityService.js.map +1 -0
  148. package/lib/esm/nest/graph/GraphEngineController.js +218 -0
  149. package/lib/esm/nest/graph/GraphEngineController.js.map +1 -0
  150. package/lib/esm/nest/graph/GraphExecutionModule.js +30 -2
  151. package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
  152. package/lib/esm/nest/graph/index.js +3 -0
  153. package/lib/esm/nest/graph/index.js.map +1 -1
  154. package/lib/esm/nest/graph/main.js +51 -0
  155. package/lib/esm/nest/graph/main.js.map +1 -0
  156. package/lib/esm/nest/graph/servingErrors.js +3 -0
  157. package/lib/esm/nest/graph/servingErrors.js.map +1 -1
  158. package/lib/esm/node/utility/code/node.js +11 -3
  159. package/lib/esm/node/utility/code/node.js.map +1 -1
  160. package/lib/esm/shared/graph/GraphExecutionStateMapper.js.map +1 -1
  161. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +2 -3
  162. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
  163. package/lib/esm/shared/graph/constants.js +8 -0
  164. package/lib/esm/shared/graph/constants.js.map +1 -1
  165. package/lib/esm/shared/graph/index.js +2 -1
  166. package/lib/esm/shared/graph/index.js.map +1 -1
  167. package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js +107 -0
  168. package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js.map +1 -0
  169. package/lib/esm/shared/graph/layout/index.js +6 -0
  170. package/lib/esm/shared/graph/layout/index.js.map +1 -0
  171. package/lib/esm/shared/graph/layout/layout-options.js +96 -0
  172. package/lib/esm/shared/graph/layout/layout-options.js.map +1 -0
  173. package/lib/esm/shared/ui/index.js +8 -10
  174. package/lib/esm/shared/ui/index.js.map +1 -1
  175. package/lib/types/dagster/DagsterGraphEventBridge.d.cts +142 -0
  176. package/lib/types/dagster/DagsterGraphEventBridge.d.mts +142 -0
  177. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +323 -0
  178. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +323 -0
  179. package/lib/types/dagster/DagsterResultMapper.d.cts +50 -0
  180. package/lib/types/dagster/DagsterResultMapper.d.mts +50 -0
  181. package/lib/types/dagster/DagsterTypes.d.cts +355 -0
  182. package/lib/types/dagster/DagsterTypes.d.mts +355 -0
  183. package/lib/types/dagster/capabilities.d.cts +34 -0
  184. package/lib/types/dagster/capabilities.d.mts +34 -0
  185. package/lib/types/dagster/constants.d.cts +87 -0
  186. package/lib/types/dagster/constants.d.mts +87 -0
  187. package/lib/types/dagster/index.d.cts +14 -0
  188. package/lib/types/dagster/index.d.mts +14 -0
  189. package/lib/types/engine/constants.d.cts +5 -0
  190. package/lib/types/engine/constants.d.mts +5 -0
  191. package/lib/types/engine/execution/GraphCodeMode.d.cts +52 -0
  192. package/lib/types/engine/execution/GraphCodeMode.d.mts +52 -0
  193. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +306 -0
  194. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +306 -0
  195. package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.cts +59 -0
  196. package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.mts +59 -0
  197. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +116 -135
  198. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +116 -135
  199. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +232 -0
  200. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +232 -0
  201. package/lib/types/engine/execution/index.d.cts +4 -0
  202. package/lib/types/engine/execution/index.d.mts +4 -0
  203. package/lib/types/engine/index.d.cts +4 -0
  204. package/lib/types/engine/index.d.mts +4 -0
  205. package/lib/types/engine/runs/GraphRunService.d.cts +19 -0
  206. package/lib/types/engine/runs/GraphRunService.d.mts +19 -0
  207. package/lib/types/engine/services/GraphWorkflowService.d.cts +22 -0
  208. package/lib/types/engine/services/GraphWorkflowService.d.mts +22 -0
  209. package/lib/types/mastra/MastraCapabilities.d.cts +91 -0
  210. package/lib/types/mastra/MastraCapabilities.d.mts +91 -0
  211. package/lib/types/mastra/MastraConditionBridge.d.cts +38 -0
  212. package/lib/types/mastra/MastraConditionBridge.d.mts +38 -0
  213. package/lib/types/mastra/MastraEventBridge.d.cts +189 -0
  214. package/lib/types/mastra/MastraEventBridge.d.mts +189 -0
  215. package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +119 -0
  216. package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +119 -0
  217. package/lib/types/mastra/MastraResumeGuard.d.cts +58 -0
  218. package/lib/types/mastra/MastraResumeGuard.d.mts +58 -0
  219. package/lib/types/mastra/MastraSchemaConverter.d.cts +39 -0
  220. package/lib/types/mastra/MastraSchemaConverter.d.mts +39 -0
  221. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +218 -0
  222. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +218 -0
  223. package/lib/types/mastra/MastraWorkflowManager.d.cts +220 -0
  224. package/lib/types/mastra/MastraWorkflowManager.d.mts +220 -0
  225. package/lib/types/mastra/index.d.cts +17 -0
  226. package/lib/types/mastra/index.d.mts +17 -0
  227. package/lib/types/mastra/types.d.cts +222 -0
  228. package/lib/types/mastra/types.d.mts +222 -0
  229. package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.cts +87 -0
  230. package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.mts +87 -0
  231. package/lib/types/nest/graph/GraphEngineCapabilityService.d.cts +98 -0
  232. package/lib/types/nest/graph/GraphEngineCapabilityService.d.mts +98 -0
  233. package/lib/types/nest/graph/GraphEngineController.d.cts +74 -0
  234. package/lib/types/nest/graph/GraphEngineController.d.mts +74 -0
  235. package/lib/types/nest/graph/GraphExecutionModule.d.cts +8 -0
  236. package/lib/types/nest/graph/GraphExecutionModule.d.mts +8 -0
  237. package/lib/types/nest/graph/index.d.cts +3 -0
  238. package/lib/types/nest/graph/index.d.mts +3 -0
  239. package/lib/types/nest/graph/main.d.cts +1 -0
  240. package/lib/types/nest/graph/main.d.mts +1 -0
  241. package/lib/types/nest/graph/servingErrors.d.cts +3 -1
  242. package/lib/types/nest/graph/servingErrors.d.mts +3 -1
  243. package/lib/types/node/utility/code/node.d.cts +1 -1
  244. package/lib/types/node/utility/code/node.d.mts +1 -1
  245. package/lib/types/shared/graph/GraphExecutionStateMapper.d.cts +5 -5
  246. package/lib/types/shared/graph/GraphExecutionStateMapper.d.mts +5 -5
  247. package/lib/types/shared/graph/constants.d.cts +8 -0
  248. package/lib/types/shared/graph/constants.d.mts +8 -0
  249. package/lib/types/shared/graph/index.d.cts +2 -1
  250. package/lib/types/shared/graph/index.d.mts +2 -1
  251. package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.cts +49 -0
  252. package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.mts +49 -0
  253. package/lib/types/shared/graph/layout/index.d.cts +5 -0
  254. package/lib/types/shared/graph/layout/index.d.mts +5 -0
  255. package/lib/types/shared/graph/layout/layout-options.d.cts +46 -0
  256. package/lib/types/shared/graph/layout/layout-options.d.mts +46 -0
  257. package/lib/types/shared/graph/types.d.cts +4 -3
  258. package/lib/types/shared/graph/types.d.mts +4 -3
  259. package/lib/types/shared/ui/index.d.cts +8 -10
  260. package/lib/types/shared/ui/index.d.mts +8 -10
  261. package/package.json +49 -6
  262. package/lib/cjs/shared/ui/GraphNodeView.cjs +0 -114
  263. package/lib/cjs/shared/ui/GraphNodeView.cjs.map +0 -1
  264. package/lib/cjs/shared/ui/GraphRunView.cjs +0 -96
  265. package/lib/cjs/shared/ui/GraphRunView.cjs.map +0 -1
  266. package/lib/cjs/shared/ui/GraphWorkflowView.cjs +0 -78
  267. package/lib/cjs/shared/ui/GraphWorkflowView.cjs.map +0 -1
  268. package/lib/cjs/shared/ui/types.cjs +0 -4
  269. package/lib/cjs/shared/ui/types.cjs.map +0 -1
  270. package/lib/esm/shared/ui/GraphNodeView.js +0 -107
  271. package/lib/esm/shared/ui/GraphNodeView.js.map +0 -1
  272. package/lib/esm/shared/ui/GraphRunView.js +0 -90
  273. package/lib/esm/shared/ui/GraphRunView.js.map +0 -1
  274. package/lib/esm/shared/ui/GraphWorkflowView.js +0 -72
  275. package/lib/esm/shared/ui/GraphWorkflowView.js.map +0 -1
  276. package/lib/esm/shared/ui/types.js +0 -2
  277. package/lib/esm/shared/ui/types.js.map +0 -1
  278. package/lib/types/shared/ui/GraphNodeView.d.cts +0 -48
  279. package/lib/types/shared/ui/GraphNodeView.d.mts +0 -48
  280. package/lib/types/shared/ui/GraphRunView.d.cts +0 -88
  281. package/lib/types/shared/ui/GraphRunView.d.mts +0 -88
  282. package/lib/types/shared/ui/GraphWorkflowView.d.cts +0 -18
  283. package/lib/types/shared/ui/GraphWorkflowView.d.mts +0 -18
  284. package/lib/types/shared/ui/types.d.cts +0 -200
  285. package/lib/types/shared/ui/types.d.mts +0 -200
@@ -0,0 +1,232 @@
1
+ /**
2
+ * @module as-graph/execution/LocalGraphExecutionBackend
3
+ * @summary Built-in reference graph execution backend (DECAF-50 §4.9).
4
+ * @description The `RamAdapter` analogue of the engine abstraction seam: the
5
+ * reference interpreter extracted verbatim from {@link GraphExecutionEngine}.
6
+ * Given a resolved, topologically layered plan (and the canonical document for
7
+ * translation parity), it executes nodes layer-by-layer, honours disabled-node
8
+ * semantics, builds node inputs from routed edges/literal/expression bindings/
9
+ * manifest defaults, validates executor outputs against the effective manifest,
10
+ * routes values along activated data edges, and reports every transition through
11
+ * the facade-owned {@link GraphExecutionEventSink}. All per-run state lives in
12
+ * the facade-created {@link GraphExecutionFrame} carried by the sink; the backend
13
+ * holds only the facade-provided collaborators (value adapter, optional code
14
+ * sandbox evaluator, and owning engine reference).
15
+ */
16
+ import type { Adapter, Context, MaybeContextualArg } from "@decaf-ts/core";
17
+ import type { GraphExecutionEngine } from "./GraphExecutionEngine.d.cts";
18
+ import type { GraphWorkflowDocument } from "../../shared/graph/index.d.cts";
19
+ import type { GraphExecutionResult } from "../types.d.cts";
20
+ import type { CodeSandboxEvaluator } from "./CodeSandboxEvaluator.d.cts";
21
+ import type { GraphBackendCapabilities, GraphBackendExecutionRequest, GraphBackendWorkflowStore, GraphBackendWorkflowSummary, GraphExecutionBackend } from "./GraphExecutionBackend.d.cts";
22
+ /**
23
+ * Configuration for the {@link LocalGraphExecutionBackend}.
24
+ */
25
+ export interface LocalGraphExecutionBackendConfig extends Record<string, unknown> {
26
+ /** Decaf adapter backing cached/pinned value persistence. */
27
+ valueAdapter: Adapter<any, any, any, any>;
28
+ /** Optional pluggable code sandbox evaluator. */
29
+ codeSandboxEvaluator?: CodeSandboxEvaluator;
30
+ /**
31
+ * Optional workflow catalogue port backing the listing/lookup capability.
32
+ * Hosts pass their `GraphWorkflowService` here; when absent the backend
33
+ * reports the capability as `not_supported` instead of returning an empty list.
34
+ */
35
+ workflowStore?: GraphBackendWorkflowStore;
36
+ /** The facade engine, exposed to node contexts. */
37
+ engine: GraphExecutionEngine;
38
+ }
39
+ /**
40
+ * Built-in reference graph execution backend. Registers itself under
41
+ * {@link GRAPH_LOCAL_EXECUTION_BACKEND} on construction.
42
+ */
43
+ export declare class LocalGraphExecutionBackend implements GraphExecutionBackend<LocalGraphExecutionBackendConfig> {
44
+ /** This backend executes locally, in-process. */
45
+ readonly local = true;
46
+ /**
47
+ * This backend executes code-mode surfaces host-side through the
48
+ * facade-owned `CodeSandboxEvaluator` (SAA-193 C1).
49
+ */
50
+ readonly codeMode: "hostSide";
51
+ private valueAdapter;
52
+ private codeSandboxEvaluator?;
53
+ private workflowStore?;
54
+ private engine;
55
+ constructor();
56
+ /**
57
+ * Resolves the backend's runtime collaborators. Called by the facade during
58
+ * `GraphExecutionEngine.initialize`.
59
+ *
60
+ * @param config - The facade-provided collaborators.
61
+ */
62
+ initialize(config: LocalGraphExecutionBackendConfig): Promise<void>;
63
+ /**
64
+ * Effective capability metadata: code-mode is host-side and workflow
65
+ * listing/lookup is supported exactly when a catalogue port is wired in.
66
+ */
67
+ get capabilities(): GraphBackendCapabilities;
68
+ /**
69
+ * Lists the workflows visible to the requesting principal through the wired
70
+ * `GraphWorkflowStore` port.
71
+ *
72
+ * @param args - Optional decaf contextual arguments forwarded to the store.
73
+ * @returns Workflow summaries, newest first when the store orders them.
74
+ * @throws {GraphExecutionError} when no workflow store is wired in.
75
+ */
76
+ listWorkflows(...args: MaybeContextualArg<Context>): Promise<GraphBackendWorkflowSummary[]>;
77
+ /**
78
+ * Reads a single canonical workflow document through the wired
79
+ * `GraphWorkflowStore` port.
80
+ *
81
+ * @param workflowId - The workflow id to read.
82
+ * @param args - Optional decaf contextual arguments forwarded to the store.
83
+ * @returns The canonical workflow document.
84
+ * @throws {GraphExecutionError} when no workflow store is wired in.
85
+ */
86
+ getWorkflow(workflowId: string, ...args: MaybeContextualArg<Context>): Promise<GraphWorkflowDocument>;
87
+ /**
88
+ * Executes a validated/resolved workflow's plan against the facade-owned
89
+ * frame carried by the request's event sink.
90
+ *
91
+ * @param request - The execution request.
92
+ * @returns The complete execution result.
93
+ * @throws {GraphExecutionError} when the request's sink is not the
94
+ * facade-created frame-aware sink.
95
+ */
96
+ execute(request: GraphBackendExecutionRequest): Promise<GraphExecutionResult>;
97
+ /**
98
+ * Executes a layer of nodes with the configured concurrency.
99
+ */
100
+ private executeLayer;
101
+ /**
102
+ * Executes a single node, honouring disabled-node semantics (§4.9).
103
+ */
104
+ private executeNode;
105
+ /**
106
+ * Resolves whether a plan node is activated for execution under the
107
+ * DECAF-50 §4.9 branch semantics. A node with no incoming data edges is
108
+ * a root/source node and always runs. A node fed by one or more data
109
+ * edges runs only when at least one of those edges was activated by a
110
+ * routed upstream output port — a branch the upstream switch (or any
111
+ * partial-output node) did not select leaves its downstream edges
112
+ * unactivated, so the branch is never executed. Workflow-boundary edges
113
+ * are active from the start because workflow inputs are seeded before
114
+ * execution begins.
115
+ */
116
+ private isNodeActivated;
117
+ /**
118
+ * Skips a node whose incoming data edges were all left unactivated by an
119
+ * upstream branch selection. The node is not executed and its outputs are
120
+ * never routed or collected into workflow outputs (DECAF-50 §4.9).
121
+ */
122
+ private skipInactiveNode;
123
+ /**
124
+ * Applies the explicit disabled-node semantics (§4.9):
125
+ * `skip`, `passThroughFirstInput`, or `emitDefaults`, resolved from the
126
+ * instance metadata, document settings, and the default.
127
+ */
128
+ private executeDisabledNode;
129
+ /**
130
+ * Invokes the node's catalogue-resolved executor (§4.9 request contract,
131
+ * post-cutover: every executor receives the full request with
132
+ * configuration and input data separated).
133
+ */
134
+ private invokeExecutor;
135
+ /**
136
+ * Validates executor outputs against the effective output manifest
137
+ * (§4.9): unknown outputs are rejected by default; missing required
138
+ * outputs fail the node. Lenient transition manifests (legacy
139
+ * executor-only registrations) are exempt until cutover.
140
+ */
141
+ private validateNodeOutputs;
142
+ /**
143
+ * Collects the resolved credential references for a node: credential-type
144
+ * parameter values plus the `credentials` record in instance metadata.
145
+ * Documents carry references only — secret material never enters requests.
146
+ */
147
+ private collectCredentials;
148
+ /**
149
+ * Resolves a node's input values from routed data edges, literal bindings,
150
+ * allowed expression bindings, and manifest port defaults (§4.9).
151
+ *
152
+ * When multiple edges target the same port, their values are spread into the
153
+ * top-level inputs keyed by each edge's `sourcePort`. This allows multiple
154
+ * workflow input badges to connect to a single port (e.g. the Code node's
155
+ * `data` port) and have all values accessible directly as
156
+ * `$input.{sourcePort}` (e.g. `$input.count`, `$input.text`).
157
+ */
158
+ private resolveNodeInputs;
159
+ /**
160
+ * Resolves a node's persisted parameters at execution time, evaluating any
161
+ * `GraphValueTemplate` user property through the code-evaluator VM and
162
+ * leaving straight literal values unchanged.
163
+ */
164
+ private resolveNodeParameters;
165
+ /**
166
+ * Evaluates a persisted `GraphValueTemplate` with the pluggable
167
+ * {@link CodeSandboxEvaluator} (DECAF-32 §22.4) — no new evaluator.
168
+ * `expression` mode evaluates the body directly; `template` mode compiles its
169
+ * `{{ ... }}` placeholders into a JavaScript template literal evaluated in
170
+ * the same sandbox, so both modes share the code-evaluator VM.
171
+ */
172
+ private evaluateValueTemplate;
173
+ /**
174
+ * Evaluates an expression binding with the EXISTING allowed-expression
175
+ * machinery only (the pluggable {@link CodeSandboxEvaluator}, DECAF-32
176
+ * §22.4) — no new evaluator. The expression sees the already-routed input
177
+ * values as `$input` and the run metadata as context.
178
+ */
179
+ private evaluateExpressionBinding;
180
+ /**
181
+ * Attempts to read a pinned value for the node. Returns the cached outputs
182
+ * when a valid pinned value exists, or `undefined` to proceed with normal
183
+ * execution.
184
+ */
185
+ private tryPinnedValue;
186
+ /**
187
+ * Recursively computes fingerprints for all upstream dependencies of a node
188
+ * using the results already accumulated in the frame.
189
+ */
190
+ private computeDependencyFingerprints;
191
+ /**
192
+ * Routes a node's outputs to downstream inputs and workflow outputs along
193
+ * data edges (connection edges are structural and never route values).
194
+ *
195
+ * An edge is traversed only when the source node actually emitted the
196
+ * edge's `sourcePort` (DECAF-50 §4.9 branch semantics). A node that
197
+ * emitted a subset of its declared outputs — e.g. a switch that selected
198
+ * one case — therefore activates only the downstream branch edges of the
199
+ * emitted ports; unselected branch edges are left unactivated, so their
200
+ * downstream nodes are skipped and never contribute to workflow outputs.
201
+ * Emitting an output port explicitly with `undefined` still counts as
202
+ * activated (the port was produced by the executor).
203
+ */
204
+ private routeOutgoingEdges;
205
+ /**
206
+ * Emits a `NODE_STATE_CHANGED` event (DECAF-48 §4.4) carrying the given
207
+ * visual state for the node. Rides the existing Observable pipeline; no
208
+ * second out-of-band channel.
209
+ */
210
+ private emitNodeStateChanged;
211
+ /**
212
+ * Emits an `EDGE_STATE_CHANGED` event (DECAF-48 §4.4) carrying the given
213
+ * visual state for a routed edge.
214
+ */
215
+ private emitEdgeStateChanged;
216
+ /**
217
+ * Creates a {@link GraphPinningService} backed by the run's value store
218
+ * adapter.
219
+ */
220
+ private createPinningService;
221
+ /**
222
+ * Resolves the effective loop-iteration ceilings for a run. A node-level
223
+ * `maxIterations` can never exceed these; loop executors read them from the
224
+ * node context.
225
+ */
226
+ private executionLimits;
227
+ private assertNotAborted;
228
+ /**
229
+ * Converts an error into a serialized payload.
230
+ */
231
+ private toErrorPayload;
232
+ }
@@ -0,0 +1,232 @@
1
+ /**
2
+ * @module as-graph/execution/LocalGraphExecutionBackend
3
+ * @summary Built-in reference graph execution backend (DECAF-50 §4.9).
4
+ * @description The `RamAdapter` analogue of the engine abstraction seam: the
5
+ * reference interpreter extracted verbatim from {@link GraphExecutionEngine}.
6
+ * Given a resolved, topologically layered plan (and the canonical document for
7
+ * translation parity), it executes nodes layer-by-layer, honours disabled-node
8
+ * semantics, builds node inputs from routed edges/literal/expression bindings/
9
+ * manifest defaults, validates executor outputs against the effective manifest,
10
+ * routes values along activated data edges, and reports every transition through
11
+ * the facade-owned {@link GraphExecutionEventSink}. All per-run state lives in
12
+ * the facade-created {@link GraphExecutionFrame} carried by the sink; the backend
13
+ * holds only the facade-provided collaborators (value adapter, optional code
14
+ * sandbox evaluator, and owning engine reference).
15
+ */
16
+ import type { Adapter, Context, MaybeContextualArg } from "@decaf-ts/core";
17
+ import type { GraphExecutionEngine } from "./GraphExecutionEngine.d.mts";
18
+ import type { GraphWorkflowDocument } from "../../shared/graph/index.d.mts";
19
+ import type { GraphExecutionResult } from "../types.d.mts";
20
+ import type { CodeSandboxEvaluator } from "./CodeSandboxEvaluator.d.mts";
21
+ import type { GraphBackendCapabilities, GraphBackendExecutionRequest, GraphBackendWorkflowStore, GraphBackendWorkflowSummary, GraphExecutionBackend } from "./GraphExecutionBackend.d.mts";
22
+ /**
23
+ * Configuration for the {@link LocalGraphExecutionBackend}.
24
+ */
25
+ export interface LocalGraphExecutionBackendConfig extends Record<string, unknown> {
26
+ /** Decaf adapter backing cached/pinned value persistence. */
27
+ valueAdapter: Adapter<any, any, any, any>;
28
+ /** Optional pluggable code sandbox evaluator. */
29
+ codeSandboxEvaluator?: CodeSandboxEvaluator;
30
+ /**
31
+ * Optional workflow catalogue port backing the listing/lookup capability.
32
+ * Hosts pass their `GraphWorkflowService` here; when absent the backend
33
+ * reports the capability as `not_supported` instead of returning an empty list.
34
+ */
35
+ workflowStore?: GraphBackendWorkflowStore;
36
+ /** The facade engine, exposed to node contexts. */
37
+ engine: GraphExecutionEngine;
38
+ }
39
+ /**
40
+ * Built-in reference graph execution backend. Registers itself under
41
+ * {@link GRAPH_LOCAL_EXECUTION_BACKEND} on construction.
42
+ */
43
+ export declare class LocalGraphExecutionBackend implements GraphExecutionBackend<LocalGraphExecutionBackendConfig> {
44
+ /** This backend executes locally, in-process. */
45
+ readonly local = true;
46
+ /**
47
+ * This backend executes code-mode surfaces host-side through the
48
+ * facade-owned `CodeSandboxEvaluator` (SAA-193 C1).
49
+ */
50
+ readonly codeMode: "hostSide";
51
+ private valueAdapter;
52
+ private codeSandboxEvaluator?;
53
+ private workflowStore?;
54
+ private engine;
55
+ constructor();
56
+ /**
57
+ * Resolves the backend's runtime collaborators. Called by the facade during
58
+ * `GraphExecutionEngine.initialize`.
59
+ *
60
+ * @param config - The facade-provided collaborators.
61
+ */
62
+ initialize(config: LocalGraphExecutionBackendConfig): Promise<void>;
63
+ /**
64
+ * Effective capability metadata: code-mode is host-side and workflow
65
+ * listing/lookup is supported exactly when a catalogue port is wired in.
66
+ */
67
+ get capabilities(): GraphBackendCapabilities;
68
+ /**
69
+ * Lists the workflows visible to the requesting principal through the wired
70
+ * `GraphWorkflowStore` port.
71
+ *
72
+ * @param args - Optional decaf contextual arguments forwarded to the store.
73
+ * @returns Workflow summaries, newest first when the store orders them.
74
+ * @throws {GraphExecutionError} when no workflow store is wired in.
75
+ */
76
+ listWorkflows(...args: MaybeContextualArg<Context>): Promise<GraphBackendWorkflowSummary[]>;
77
+ /**
78
+ * Reads a single canonical workflow document through the wired
79
+ * `GraphWorkflowStore` port.
80
+ *
81
+ * @param workflowId - The workflow id to read.
82
+ * @param args - Optional decaf contextual arguments forwarded to the store.
83
+ * @returns The canonical workflow document.
84
+ * @throws {GraphExecutionError} when no workflow store is wired in.
85
+ */
86
+ getWorkflow(workflowId: string, ...args: MaybeContextualArg<Context>): Promise<GraphWorkflowDocument>;
87
+ /**
88
+ * Executes a validated/resolved workflow's plan against the facade-owned
89
+ * frame carried by the request's event sink.
90
+ *
91
+ * @param request - The execution request.
92
+ * @returns The complete execution result.
93
+ * @throws {GraphExecutionError} when the request's sink is not the
94
+ * facade-created frame-aware sink.
95
+ */
96
+ execute(request: GraphBackendExecutionRequest): Promise<GraphExecutionResult>;
97
+ /**
98
+ * Executes a layer of nodes with the configured concurrency.
99
+ */
100
+ private executeLayer;
101
+ /**
102
+ * Executes a single node, honouring disabled-node semantics (§4.9).
103
+ */
104
+ private executeNode;
105
+ /**
106
+ * Resolves whether a plan node is activated for execution under the
107
+ * DECAF-50 §4.9 branch semantics. A node with no incoming data edges is
108
+ * a root/source node and always runs. A node fed by one or more data
109
+ * edges runs only when at least one of those edges was activated by a
110
+ * routed upstream output port — a branch the upstream switch (or any
111
+ * partial-output node) did not select leaves its downstream edges
112
+ * unactivated, so the branch is never executed. Workflow-boundary edges
113
+ * are active from the start because workflow inputs are seeded before
114
+ * execution begins.
115
+ */
116
+ private isNodeActivated;
117
+ /**
118
+ * Skips a node whose incoming data edges were all left unactivated by an
119
+ * upstream branch selection. The node is not executed and its outputs are
120
+ * never routed or collected into workflow outputs (DECAF-50 §4.9).
121
+ */
122
+ private skipInactiveNode;
123
+ /**
124
+ * Applies the explicit disabled-node semantics (§4.9):
125
+ * `skip`, `passThroughFirstInput`, or `emitDefaults`, resolved from the
126
+ * instance metadata, document settings, and the default.
127
+ */
128
+ private executeDisabledNode;
129
+ /**
130
+ * Invokes the node's catalogue-resolved executor (§4.9 request contract,
131
+ * post-cutover: every executor receives the full request with
132
+ * configuration and input data separated).
133
+ */
134
+ private invokeExecutor;
135
+ /**
136
+ * Validates executor outputs against the effective output manifest
137
+ * (§4.9): unknown outputs are rejected by default; missing required
138
+ * outputs fail the node. Lenient transition manifests (legacy
139
+ * executor-only registrations) are exempt until cutover.
140
+ */
141
+ private validateNodeOutputs;
142
+ /**
143
+ * Collects the resolved credential references for a node: credential-type
144
+ * parameter values plus the `credentials` record in instance metadata.
145
+ * Documents carry references only — secret material never enters requests.
146
+ */
147
+ private collectCredentials;
148
+ /**
149
+ * Resolves a node's input values from routed data edges, literal bindings,
150
+ * allowed expression bindings, and manifest port defaults (§4.9).
151
+ *
152
+ * When multiple edges target the same port, their values are spread into the
153
+ * top-level inputs keyed by each edge's `sourcePort`. This allows multiple
154
+ * workflow input badges to connect to a single port (e.g. the Code node's
155
+ * `data` port) and have all values accessible directly as
156
+ * `$input.{sourcePort}` (e.g. `$input.count`, `$input.text`).
157
+ */
158
+ private resolveNodeInputs;
159
+ /**
160
+ * Resolves a node's persisted parameters at execution time, evaluating any
161
+ * `GraphValueTemplate` user property through the code-evaluator VM and
162
+ * leaving straight literal values unchanged.
163
+ */
164
+ private resolveNodeParameters;
165
+ /**
166
+ * Evaluates a persisted `GraphValueTemplate` with the pluggable
167
+ * {@link CodeSandboxEvaluator} (DECAF-32 §22.4) — no new evaluator.
168
+ * `expression` mode evaluates the body directly; `template` mode compiles its
169
+ * `{{ ... }}` placeholders into a JavaScript template literal evaluated in
170
+ * the same sandbox, so both modes share the code-evaluator VM.
171
+ */
172
+ private evaluateValueTemplate;
173
+ /**
174
+ * Evaluates an expression binding with the EXISTING allowed-expression
175
+ * machinery only (the pluggable {@link CodeSandboxEvaluator}, DECAF-32
176
+ * §22.4) — no new evaluator. The expression sees the already-routed input
177
+ * values as `$input` and the run metadata as context.
178
+ */
179
+ private evaluateExpressionBinding;
180
+ /**
181
+ * Attempts to read a pinned value for the node. Returns the cached outputs
182
+ * when a valid pinned value exists, or `undefined` to proceed with normal
183
+ * execution.
184
+ */
185
+ private tryPinnedValue;
186
+ /**
187
+ * Recursively computes fingerprints for all upstream dependencies of a node
188
+ * using the results already accumulated in the frame.
189
+ */
190
+ private computeDependencyFingerprints;
191
+ /**
192
+ * Routes a node's outputs to downstream inputs and workflow outputs along
193
+ * data edges (connection edges are structural and never route values).
194
+ *
195
+ * An edge is traversed only when the source node actually emitted the
196
+ * edge's `sourcePort` (DECAF-50 §4.9 branch semantics). A node that
197
+ * emitted a subset of its declared outputs — e.g. a switch that selected
198
+ * one case — therefore activates only the downstream branch edges of the
199
+ * emitted ports; unselected branch edges are left unactivated, so their
200
+ * downstream nodes are skipped and never contribute to workflow outputs.
201
+ * Emitting an output port explicitly with `undefined` still counts as
202
+ * activated (the port was produced by the executor).
203
+ */
204
+ private routeOutgoingEdges;
205
+ /**
206
+ * Emits a `NODE_STATE_CHANGED` event (DECAF-48 §4.4) carrying the given
207
+ * visual state for the node. Rides the existing Observable pipeline; no
208
+ * second out-of-band channel.
209
+ */
210
+ private emitNodeStateChanged;
211
+ /**
212
+ * Emits an `EDGE_STATE_CHANGED` event (DECAF-48 §4.4) carrying the given
213
+ * visual state for a routed edge.
214
+ */
215
+ private emitEdgeStateChanged;
216
+ /**
217
+ * Creates a {@link GraphPinningService} backed by the run's value store
218
+ * adapter.
219
+ */
220
+ private createPinningService;
221
+ /**
222
+ * Resolves the effective loop-iteration ceilings for a run. A node-level
223
+ * `maxIterations` can never exceed these; loop executors read them from the
224
+ * node context.
225
+ */
226
+ private executionLimits;
227
+ private assertNotAborted;
228
+ /**
229
+ * Converts an error into a serialized payload.
230
+ */
231
+ private toErrorPayload;
232
+ }
@@ -7,6 +7,10 @@ export * from "./GraphExecutionContext.d.cts";
7
7
  export * from "./GraphNodeExecutor.d.cts";
8
8
  export * from "./GraphExecutionResult.d.cts";
9
9
  export * from "./GraphExecutionFrame.d.cts";
10
+ export * from "./GraphExecutionBackend.d.cts";
11
+ export * from "./GraphExecutionBackendRegistry.d.cts";
12
+ export * from "./GraphCodeMode.d.cts";
13
+ export * from "./LocalGraphExecutionBackend.d.cts";
10
14
  export * from "./GraphExecutionEngine.d.cts";
11
15
  export * from "./CodeSandboxEvaluator.d.cts";
12
16
  export * from "./IsolatedVmCodeSandboxEvaluator.d.cts";
@@ -7,6 +7,10 @@ export * from "./GraphExecutionContext.d.mts";
7
7
  export * from "./GraphNodeExecutor.d.mts";
8
8
  export * from "./GraphExecutionResult.d.mts";
9
9
  export * from "./GraphExecutionFrame.d.mts";
10
+ export * from "./GraphExecutionBackend.d.mts";
11
+ export * from "./GraphExecutionBackendRegistry.d.mts";
12
+ export * from "./GraphCodeMode.d.mts";
13
+ export * from "./LocalGraphExecutionBackend.d.mts";
10
14
  export * from "./GraphExecutionEngine.d.mts";
11
15
  export * from "./CodeSandboxEvaluator.d.mts";
12
16
  export * from "./IsolatedVmCodeSandboxEvaluator.d.mts";
@@ -29,6 +29,10 @@ export * from "./execution/GraphExecutionContext.d.cts";
29
29
  export * from "./execution/GraphNodeExecutor.d.cts";
30
30
  export * from "./execution/GraphExecutionFrame.d.cts";
31
31
  export * from "./execution/GraphExecutionResult.d.cts";
32
+ export * from "./execution/GraphExecutionBackend.d.cts";
33
+ export * from "./execution/GraphExecutionBackendRegistry.d.cts";
34
+ export * from "./execution/GraphCodeMode.d.cts";
35
+ export * from "./execution/LocalGraphExecutionBackend.d.cts";
32
36
  export * from "./execution/GraphExecutionEngine.d.cts";
33
37
  export * from "./execution/CodeSandboxEvaluator.d.cts";
34
38
  export * from "./execution/IsolatedVmCodeSandboxEvaluator.d.cts";
@@ -29,6 +29,10 @@ export * from "./execution/GraphExecutionContext.d.mts";
29
29
  export * from "./execution/GraphNodeExecutor.d.mts";
30
30
  export * from "./execution/GraphExecutionFrame.d.mts";
31
31
  export * from "./execution/GraphExecutionResult.d.mts";
32
+ export * from "./execution/GraphExecutionBackend.d.mts";
33
+ export * from "./execution/GraphExecutionBackendRegistry.d.mts";
34
+ export * from "./execution/GraphCodeMode.d.mts";
35
+ export * from "./execution/LocalGraphExecutionBackend.d.mts";
32
36
  export * from "./execution/GraphExecutionEngine.d.mts";
33
37
  export * from "./execution/CodeSandboxEvaluator.d.mts";
34
38
  export * from "./execution/IsolatedVmCodeSandboxEvaluator.d.mts";
@@ -1,5 +1,6 @@
1
1
  import type { Context, MaybeContextualArg } from "@decaf-ts/core";
2
2
  import { GraphExecutionEngine } from "../execution/GraphExecutionEngine.d.cts";
3
+ import type { GraphResumeAudit, GraphResumeRequest } from "../execution/GraphExecutionBackend.d.cts";
3
4
  import { type GraphRunEventEnvelope, type GraphRunLimits } from "../../shared/graph/index.d.cts";
4
5
  import { type GraphRun, type GraphRunCreateRequest, type GraphRunDocumentResolver, type GraphRunEventStore, type GraphRunStore } from "./types.d.cts";
5
6
  import type { GraphRunModel } from "../../shared/graph/index.d.cts";
@@ -92,6 +93,24 @@ export declare class GraphRunService {
92
93
  * never grants a cancellation.
93
94
  */
94
95
  cancelRun(runId: string, ownerUser: string | null, ...args: MaybeContextualArg<Context>): Promise<GraphRun>;
96
+ /**
97
+ * Resumes a suspended run: resolves the run, asserts strict owner equality on
98
+ * the write path ({@link assertGraphResourceWriteOwnership}, SAA-105 R3), then
99
+ * delegates to the active backend's optional SAA-196 `resume?()` extension and
100
+ * audits the accepted resume through the event publisher (C18). A backend without
101
+ * the extension fails closed rather than silently no-op.
102
+ *
103
+ * C14: resume is exposed only through this service, behind the owner-equality
104
+ * write gate — never from an HTTP route. The standing SAA-200 hardening rule
105
+ * holds here too: a {@link GraphExecutionError} thrown by the backend is
106
+ * re-thrown without its `details` so no server-side state leaks to clients.
107
+ *
108
+ * @throws NotFoundError when no run exists for `runId`.
109
+ * @throws ForbiddenError when the caller is not the run's recorded owner.
110
+ * @throws GraphExecutionError when the active backend does not support resume
111
+ * or the backend rejects the resume.
112
+ */
113
+ resumeRun(runId: string, request: GraphResumeRequest, ownerUser: string | null, ...args: MaybeContextualArg<Context>): Promise<GraphResumeAudit>;
95
114
  /** Lists a run's event envelopes after the given sequence (ownership-checked). */
96
115
  listEvents(runId: string, afterSequence: number, ownerUser: string | null, ...args: MaybeContextualArg<Context>): Promise<GraphRunEventEnvelope[]>;
97
116
  /** Subscribes a live listener to a run's event stream (ownership-checked); returns an unsubscribe function. */
@@ -1,5 +1,6 @@
1
1
  import type { Context, MaybeContextualArg } from "@decaf-ts/core";
2
2
  import { GraphExecutionEngine } from "../execution/GraphExecutionEngine.d.mts";
3
+ import type { GraphResumeAudit, GraphResumeRequest } from "../execution/GraphExecutionBackend.d.mts";
3
4
  import { type GraphRunEventEnvelope, type GraphRunLimits } from "../../shared/graph/index.d.mts";
4
5
  import { type GraphRun, type GraphRunCreateRequest, type GraphRunDocumentResolver, type GraphRunEventStore, type GraphRunStore } from "./types.d.mts";
5
6
  import type { GraphRunModel } from "../../shared/graph/index.d.mts";
@@ -92,6 +93,24 @@ export declare class GraphRunService {
92
93
  * never grants a cancellation.
93
94
  */
94
95
  cancelRun(runId: string, ownerUser: string | null, ...args: MaybeContextualArg<Context>): Promise<GraphRun>;
96
+ /**
97
+ * Resumes a suspended run: resolves the run, asserts strict owner equality on
98
+ * the write path ({@link assertGraphResourceWriteOwnership}, SAA-105 R3), then
99
+ * delegates to the active backend's optional SAA-196 `resume?()` extension and
100
+ * audits the accepted resume through the event publisher (C18). A backend without
101
+ * the extension fails closed rather than silently no-op.
102
+ *
103
+ * C14: resume is exposed only through this service, behind the owner-equality
104
+ * write gate — never from an HTTP route. The standing SAA-200 hardening rule
105
+ * holds here too: a {@link GraphExecutionError} thrown by the backend is
106
+ * re-thrown without its `details` so no server-side state leaks to clients.
107
+ *
108
+ * @throws NotFoundError when no run exists for `runId`.
109
+ * @throws ForbiddenError when the caller is not the run's recorded owner.
110
+ * @throws GraphExecutionError when the active backend does not support resume
111
+ * or the backend rejects the resume.
112
+ */
113
+ resumeRun(runId: string, request: GraphResumeRequest, ownerUser: string | null, ...args: MaybeContextualArg<Context>): Promise<GraphResumeAudit>;
95
114
  /** Lists a run's event envelopes after the given sequence (ownership-checked). */
96
115
  listEvents(runId: string, afterSequence: number, ownerUser: string | null, ...args: MaybeContextualArg<Context>): Promise<GraphRunEventEnvelope[]>;
97
116
  /** Subscribes a live listener to a run's event stream (ownership-checked); returns an unsubscribe function. */
@@ -23,6 +23,13 @@ export declare function graphWorkflowOwnerOf(ctx: Context | undefined): string |
23
23
  * (`allowAnonymousAccess`) is set for reads (SAA-595 F3). Overwriting an
24
24
  * existing row is a write and is authorized by strict owner equality, so the
25
25
  * read tolerance never grants an overwrite (SAA-105 R3).
26
+ *
27
+ * @remarks The overwrite gate is a read-then-write check, so it depends on the
28
+ * persistence adapter's contract (SAA-105 R3-b): `read` must throw
29
+ * `NotFoundError` for an absent row, and `create` must be create-only — it must
30
+ * reject a duplicate primary key rather than upsert. An adapter whose `create`
31
+ * upserts (or whose `read` hides an existing row) would let a named caller
32
+ * silently overwrite an owner-less row and bypass the owner-equality gate.
26
33
  */
27
34
  export declare class GraphWorkflowService extends ModelService<GraphWorkflowModel> {
28
35
  protected catalogue: GraphNodeCatalogue | undefined;
@@ -50,6 +57,10 @@ export declare class GraphWorkflowService extends ModelService<GraphWorkflowMode
50
57
  * (SAA-105 R3): a named caller cannot overwrite an owner-less workflow and
51
58
  * the `allowAnonymousAccess` read tolerance never grants an overwrite.
52
59
  *
60
+ * @remarks Relies on the class-level adapter contract that `read` throws
61
+ * `NotFoundError` for an absent row and `create` rejects a duplicate primary
62
+ * key instead of upserting (SAA-105 R3-b).
63
+ *
53
64
  * @param {string} workflowId - Workflow id from the request path.
54
65
  * @param {GraphWorkflowDocument} document - Canonical document to persist (its `id` must equal `workflowId`).
55
66
  * @param args - An optional decaf `Context` carrying the owning principal.
@@ -119,6 +130,10 @@ export declare class GraphWorkflowService extends ModelService<GraphWorkflowMode
119
130
  * authorized by strict owner equality (SAA-105 R3) — see
120
131
  * {@link saveDocument}.
121
132
  *
133
+ * @remarks Relies on the class-level adapter contract that `read` throws
134
+ * `NotFoundError` for an absent row and `create` rejects a duplicate primary
135
+ * key instead of upserting (SAA-105 R3-b).
136
+ *
122
137
  * @param {string} workflowId - Workflow id from the request path.
123
138
  * @param {Record<string, unknown>} snapshot - JSON-safe canonical snapshot wrapper.
124
139
  * @param args - An optional decaf `Context` carrying the owning principal.
@@ -135,6 +150,13 @@ export declare class GraphWorkflowService extends ModelService<GraphWorkflowMode
135
150
  * @return {Promise<GraphWorkflowModel | null>} The workflow row, or `null` when it does not exist or ownership fails.
136
151
  */
137
152
  loadSnapshot(workflowId: string, ...args: MaybeContextualArg<Context>): Promise<GraphWorkflowModel | null>;
153
+ /**
154
+ * Existence probe for the owner-equality overwrite gate (SAA-105 R3-a): only a
155
+ * genuine absence (`NotFoundError`) resolves to `null`; every other read
156
+ * failure propagates so a transient store fault is never mistaken for absence
157
+ * and downgraded into an unconditional create.
158
+ */
159
+ private readExistingForWrite;
138
160
  /**
139
161
  * Read-visibility guard for a persisted workflow record via the centralized
140
162
  * {@link assertGraphResourceOwnership} check, honouring this service's