@graphrefly/ts 0.0.0 → 0.0.2

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 (405) hide show
  1. package/README.md +135 -0
  2. package/dist/actions-types-CSC3NMDl.d.ts +657 -0
  3. package/dist/actions-types-wl9Mgkmr.d.cts +657 -0
  4. package/dist/adapters/index.cjs +5219 -2974
  5. package/dist/adapters/index.cjs.map +1 -1
  6. package/dist/adapters/index.d.cts +204 -192
  7. package/dist/adapters/index.d.ts +204 -192
  8. package/dist/adapters/index.js +3685 -1833
  9. package/dist/adapters/index.js.map +1 -1
  10. package/dist/adapters/nestjs/microservices.cjs +841 -0
  11. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  12. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  13. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  14. package/dist/adapters/nestjs/microservices.js +206 -0
  15. package/dist/adapters/nestjs/microservices.js.map +1 -0
  16. package/dist/adapters/nestjs/native.cjs +1391 -0
  17. package/dist/adapters/nestjs/native.cjs.map +1 -0
  18. package/dist/adapters/nestjs/native.d.cts +111 -0
  19. package/dist/adapters/nestjs/native.d.ts +111 -0
  20. package/dist/adapters/nestjs/native.js +577 -0
  21. package/dist/adapters/nestjs/native.js.map +1 -0
  22. package/dist/adapters/nestjs/websockets.cjs +924 -0
  23. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  24. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  25. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  26. package/dist/adapters/nestjs/websockets.js +286 -0
  27. package/dist/adapters/nestjs/websockets.js.map +1 -0
  28. package/dist/adapters/nestjs.cjs +1085 -0
  29. package/dist/adapters/nestjs.cjs.map +1 -0
  30. package/dist/adapters/nestjs.d.cts +385 -0
  31. package/dist/adapters/nestjs.d.ts +385 -0
  32. package/dist/adapters/nestjs.js +112 -0
  33. package/dist/adapters/nestjs.js.map +1 -0
  34. package/dist/adapters/observe-storage.d.cts +4 -4
  35. package/dist/adapters/observe-storage.d.ts +4 -4
  36. package/dist/adapters/observe-storage.js +5 -4
  37. package/dist/adapters/observe-storage.js.map +1 -1
  38. package/dist/adapters/react.cjs +166 -0
  39. package/dist/adapters/react.cjs.map +1 -0
  40. package/dist/adapters/react.d.cts +31 -0
  41. package/dist/adapters/react.d.ts +31 -0
  42. package/dist/adapters/react.js +51 -0
  43. package/dist/adapters/react.js.map +1 -0
  44. package/dist/adapters/solid.cjs +157 -0
  45. package/dist/adapters/solid.cjs.map +1 -0
  46. package/dist/adapters/solid.d.cts +26 -0
  47. package/dist/adapters/solid.d.ts +26 -0
  48. package/dist/adapters/solid.js +48 -0
  49. package/dist/adapters/solid.js.map +1 -0
  50. package/dist/adapters/svelte.cjs +148 -0
  51. package/dist/adapters/svelte.cjs.map +1 -0
  52. package/dist/adapters/svelte.d.cts +31 -0
  53. package/dist/adapters/svelte.d.ts +31 -0
  54. package/dist/adapters/svelte.js +46 -0
  55. package/dist/adapters/svelte.js.map +1 -0
  56. package/dist/adapters/vue.cjs +155 -0
  57. package/dist/adapters/vue.cjs.map +1 -0
  58. package/dist/adapters/vue.d.cts +26 -0
  59. package/dist/adapters/vue.d.ts +26 -0
  60. package/dist/adapters/vue.js +46 -0
  61. package/dist/adapters/vue.js.map +1 -0
  62. package/dist/agent-runtime-types-core-CaXfKNtY.d.cts +406 -0
  63. package/dist/agent-runtime-types-core-hU299uIC.d.ts +406 -0
  64. package/dist/agent-runtime-types-tool-BEpSINol.d.ts +695 -0
  65. package/dist/agent-runtime-types-tool-DninPEzk.d.cts +695 -0
  66. package/dist/agentic-memory-retention-BmGX368S.d.ts +14 -0
  67. package/dist/agentic-memory-retention-Ih1qhX9Z.d.cts +14 -0
  68. package/dist/agentic-memory-types-CVSUS6XR.d.ts +473 -0
  69. package/dist/agentic-memory-types-FnnYlVUs.d.cts +473 -0
  70. package/dist/capability-admission-BW2CziT6.d.ts +102 -0
  71. package/dist/capability-admission-lwSecxXs.d.cts +102 -0
  72. package/dist/chunk-2KUAG2GZ.js +9693 -0
  73. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  74. package/dist/chunk-2NJP6GO4.js +1320 -0
  75. package/dist/chunk-2NJP6GO4.js.map +1 -0
  76. package/dist/{chunk-GDL26N2T.js → chunk-3KN7NJDR.js} +2 -2
  77. package/dist/{chunk-COHO25CZ.js → chunk-4NWSNI4K.js} +2232 -1672
  78. package/dist/chunk-4NWSNI4K.js.map +1 -0
  79. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  80. package/dist/chunk-6E76H4OU.js +132 -0
  81. package/dist/chunk-6E76H4OU.js.map +1 -0
  82. package/dist/chunk-7GOTIIQ7.js +819 -0
  83. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  84. package/dist/{chunk-D6BG7U6A.js → chunk-7HZRJMN6.js} +3 -3
  85. package/dist/{chunk-SCRFRCGR.js → chunk-BSQGE5PS.js} +1 -1
  86. package/dist/{chunk-PKVBHGBM.js → chunk-CJIFGJQG.js} +7 -7
  87. package/dist/{chunk-G4M3NHRJ.js → chunk-CX6B6PO2.js} +93 -10
  88. package/dist/chunk-CX6B6PO2.js.map +1 -0
  89. package/dist/chunk-DGUM43GV.js +11 -0
  90. package/dist/chunk-DGUM43GV.js.map +1 -0
  91. package/dist/{chunk-JIMUDQN3.js → chunk-E4QCH32M.js} +449 -447
  92. package/dist/chunk-E4QCH32M.js.map +1 -0
  93. package/dist/{chunk-RIIOUTGM.js → chunk-ECURQ3HD.js} +19 -129
  94. package/dist/chunk-ECURQ3HD.js.map +1 -0
  95. package/dist/{chunk-2ILL7HQI.js → chunk-EOKT4QFF.js} +134 -128
  96. package/dist/chunk-EOKT4QFF.js.map +1 -0
  97. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  98. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  99. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  100. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  101. package/dist/chunk-K7FB3JTD.js.map +1 -0
  102. package/dist/chunk-L6LDXRWE.js +219 -0
  103. package/dist/chunk-L6LDXRWE.js.map +1 -0
  104. package/dist/chunk-M7J6Z4IJ.js +1930 -0
  105. package/dist/chunk-M7J6Z4IJ.js.map +1 -0
  106. package/dist/chunk-MQEQMS7B.js +1009 -0
  107. package/dist/chunk-MQEQMS7B.js.map +1 -0
  108. package/dist/chunk-MTELVIYR.js +1421 -0
  109. package/dist/chunk-MTELVIYR.js.map +1 -0
  110. package/dist/chunk-PVC7WDKI.js +885 -0
  111. package/dist/chunk-PVC7WDKI.js.map +1 -0
  112. package/dist/chunk-RAHNUYA5.js +368 -0
  113. package/dist/chunk-RAHNUYA5.js.map +1 -0
  114. package/dist/{chunk-DK554R7P.js → chunk-S6HXABGL.js} +2 -1
  115. package/dist/chunk-S6HXABGL.js.map +1 -0
  116. package/dist/{chunk-I3IHOHCJ.js → chunk-SHZDP2MQ.js} +1181 -1001
  117. package/dist/chunk-SHZDP2MQ.js.map +1 -0
  118. package/dist/{chunk-Y3ZLRGHC.js → chunk-SIDJO2T4.js} +16 -16
  119. package/dist/chunk-STXRMPW4.js +4131 -0
  120. package/dist/chunk-STXRMPW4.js.map +1 -0
  121. package/dist/{chunk-JR4IKCR2.js → chunk-TPND5MJS.js} +5 -5
  122. package/dist/chunk-TQPCAIQI.js +612 -0
  123. package/dist/chunk-TQPCAIQI.js.map +1 -0
  124. package/dist/chunk-UT3MHJCW.js +49 -0
  125. package/dist/chunk-UT3MHJCW.js.map +1 -0
  126. package/dist/{chunk-TEW47IVR.js → chunk-VPEFSDME.js} +2 -2
  127. package/dist/{chunk-SWTLEQL6.js → chunk-WQIA3GFB.js} +2 -2
  128. package/dist/chunk-WQIA3GFB.js.map +1 -0
  129. package/dist/{chunk-DJC4CHLQ.js → chunk-YDWBXXQZ.js} +5 -5
  130. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  131. package/dist/composition/index.cjs +1256 -1059
  132. package/dist/composition/index.cjs.map +1 -1
  133. package/dist/composition/index.d.cts +4 -4
  134. package/dist/composition/index.d.ts +4 -4
  135. package/dist/composition/index.js +7 -6
  136. package/dist/core/index.cjs +1218 -1021
  137. package/dist/core/index.cjs.map +1 -1
  138. package/dist/core/index.d.cts +2 -2
  139. package/dist/core/index.d.ts +2 -2
  140. package/dist/core/index.js +5 -4
  141. package/dist/cqrs/index.cjs.map +1 -1
  142. package/dist/cqrs/index.d.cts +4 -4
  143. package/dist/cqrs/index.d.ts +4 -4
  144. package/dist/cqrs/index.js +3 -2
  145. package/dist/cqrs/index.js.map +1 -1
  146. package/dist/cqrs/messaging.cjs +312 -0
  147. package/dist/cqrs/messaging.cjs.map +1 -0
  148. package/dist/cqrs/messaging.d.cts +57 -0
  149. package/dist/cqrs/messaging.d.ts +57 -0
  150. package/dist/cqrs/messaging.js +274 -0
  151. package/dist/cqrs/messaging.js.map +1 -0
  152. package/dist/cqrs/work-queue.cjs +329 -0
  153. package/dist/cqrs/work-queue.cjs.map +1 -0
  154. package/dist/cqrs/work-queue.d.cts +90 -0
  155. package/dist/cqrs/work-queue.d.ts +90 -0
  156. package/dist/cqrs/work-queue.js +292 -0
  157. package/dist/cqrs/work-queue.js.map +1 -0
  158. package/dist/data/index.cjs +19 -0
  159. package/dist/data/index.cjs.map +1 -0
  160. package/dist/data/index.d.cts +36 -0
  161. package/dist/data/index.d.ts +36 -0
  162. package/dist/data/index.js +1 -0
  163. package/dist/data/index.js.map +1 -0
  164. package/dist/data-structures/index.cjs +1252 -1052
  165. package/dist/data-structures/index.cjs.map +1 -1
  166. package/dist/data-structures/index.d.cts +9 -8
  167. package/dist/data-structures/index.d.ts +9 -8
  168. package/dist/data-structures/index.js +9 -7
  169. package/dist/{describe-BZb7AS2y.d.ts → describe-B_A5fbXH.d.ts} +1 -1
  170. package/dist/{describe-Ciu8SUnN.d.cts → describe-CQRrkv-Q.d.cts} +1 -1
  171. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  172. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  173. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  174. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  175. package/dist/executors/tool-provider-adapters.js +1336 -0
  176. package/dist/executors/tool-provider-adapters.js.map +1 -0
  177. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  178. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  179. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  180. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  181. package/dist/executors/tool-provider-runtime.js +15 -0
  182. package/dist/executors/tool-provider-runtime.js.map +1 -0
  183. package/dist/executors/tool-provider.cjs +6392 -0
  184. package/dist/executors/tool-provider.cjs.map +1 -0
  185. package/dist/executors/tool-provider.d.cts +60 -0
  186. package/dist/executors/tool-provider.d.ts +60 -0
  187. package/dist/executors/tool-provider.js +89 -0
  188. package/dist/executors/tool-provider.js.map +1 -0
  189. package/dist/executors/work-queue.cjs +342 -0
  190. package/dist/executors/work-queue.cjs.map +1 -0
  191. package/dist/executors/work-queue.d.cts +90 -0
  192. package/dist/executors/work-queue.d.ts +90 -0
  193. package/dist/executors/work-queue.js +306 -0
  194. package/dist/executors/work-queue.js.map +1 -0
  195. package/dist/graph/index.cjs +1536 -1324
  196. package/dist/graph/index.cjs.map +1 -1
  197. package/dist/graph/index.d.cts +10 -9
  198. package/dist/graph/index.d.ts +10 -9
  199. package/dist/graph/index.js +22 -20
  200. package/dist/{graph-s23RbbFO.d.cts → graph-CWK3HLPB.d.cts} +134 -132
  201. package/dist/{graph-DfdF9zy4.d.ts → graph-ho5sotHP.d.ts} +134 -132
  202. package/dist/{index-SnzZu3x7.d.ts → index-CQWcE0Dw.d.ts} +18 -4
  203. package/dist/{index-CAEmLCYF.d.cts → index-DHA1i67c.d.cts} +18 -4
  204. package/dist/index.cjs +3331 -3020
  205. package/dist/index.cjs.map +1 -1
  206. package/dist/index.d.cts +14 -10
  207. package/dist/index.d.ts +14 -10
  208. package/dist/index.js +114 -108
  209. package/dist/inspection/boundary.cjs +98 -0
  210. package/dist/inspection/boundary.cjs.map +1 -0
  211. package/dist/inspection/boundary.d.cts +61 -0
  212. package/dist/inspection/boundary.d.ts +61 -0
  213. package/dist/inspection/boundary.js +75 -0
  214. package/dist/inspection/boundary.js.map +1 -0
  215. package/dist/measurements-C0mAvWU1.d.cts +164 -0
  216. package/dist/measurements-OMpCeBwh.d.ts +164 -0
  217. package/dist/{messages-BZqrGGm1.d.ts → messages-CAzUPPJM.d.cts} +10 -5
  218. package/dist/{messages-BZqrGGm1.d.cts → messages-CAzUPPJM.d.ts} +10 -5
  219. package/dist/messaging/index.cjs +756 -619
  220. package/dist/messaging/index.cjs.map +1 -1
  221. package/dist/messaging/index.d.cts +17 -226
  222. package/dist/messaging/index.d.ts +17 -226
  223. package/dist/messaging/index.js +19 -749
  224. package/dist/messaging/index.js.map +1 -1
  225. package/dist/operators/index.cjs +1256 -1059
  226. package/dist/operators/index.cjs.map +1 -1
  227. package/dist/operators/index.d.cts +6 -6
  228. package/dist/operators/index.d.ts +6 -6
  229. package/dist/operators/index.js +9 -8
  230. package/dist/orchestration/index.cjs +8664 -2617
  231. package/dist/orchestration/index.cjs.map +1 -1
  232. package/dist/orchestration/index.d.cts +171 -221
  233. package/dist/orchestration/index.d.ts +171 -221
  234. package/dist/orchestration/index.js +74 -982
  235. package/dist/orchestration/index.js.map +1 -1
  236. package/dist/orchestration/messaging.cjs +314 -0
  237. package/dist/orchestration/messaging.cjs.map +1 -0
  238. package/dist/orchestration/messaging.d.cts +56 -0
  239. package/dist/orchestration/messaging.d.ts +56 -0
  240. package/dist/orchestration/messaging.js +276 -0
  241. package/dist/orchestration/messaging.js.map +1 -0
  242. package/dist/orchestration/work-queue.cjs +1500 -0
  243. package/dist/orchestration/work-queue.cjs.map +1 -0
  244. package/dist/orchestration/work-queue.d.cts +196 -0
  245. package/dist/orchestration/work-queue.d.ts +196 -0
  246. package/dist/orchestration/work-queue.js +1289 -0
  247. package/dist/orchestration/work-queue.js.map +1 -0
  248. package/dist/patterns/event-flow.cjs +433 -0
  249. package/dist/patterns/event-flow.cjs.map +1 -0
  250. package/dist/patterns/event-flow.d.cts +115 -0
  251. package/dist/patterns/event-flow.d.ts +115 -0
  252. package/dist/patterns/event-flow.js +14 -0
  253. package/dist/patterns/event-flow.js.map +1 -0
  254. package/dist/patterns/index.cjs +748 -355
  255. package/dist/patterns/index.cjs.map +1 -1
  256. package/dist/patterns/index.d.cts +9 -5
  257. package/dist/patterns/index.d.ts +9 -5
  258. package/dist/patterns/index.js +13 -4
  259. package/dist/process-types-C9uMYz3i.d.ts +200 -0
  260. package/dist/process-types-h3uRlzDc.d.cts +200 -0
  261. package/dist/{reactive-collection-BxBqtIOE.d.cts → reactive-collection-B9R0Bl1P.d.cts} +11 -41
  262. package/dist/{reactive-collection-Cb1II1Fi.d.ts → reactive-collection-BXFrH0U2.d.ts} +11 -41
  263. package/dist/{reactive-collection-storage-D-KmjE0J.d.cts → reactive-collection-storage-BLGv8Xp8.d.cts} +5 -5
  264. package/dist/{reactive-collection-storage-BNiEc-Gd.d.ts → reactive-collection-storage-a4zD3665.d.ts} +5 -5
  265. package/dist/{reactive-map-BcB4KsQR.d.ts → reactive-map-C_8sOfdS.d.cts} +7 -6
  266. package/dist/{reactive-map-D-g3dv8I.d.cts → reactive-map-jle5dnok.d.ts} +7 -6
  267. package/dist/render/index.d.cts +3 -3
  268. package/dist/render/index.d.ts +3 -3
  269. package/dist/render/index.js +1 -0
  270. package/dist/scheduled-readiness-5rwQlyjV.d.ts +91 -0
  271. package/dist/scheduled-readiness-DpRY8jI0.d.cts +91 -0
  272. package/dist/semantic-memory-graph-C2ZUwIlq.d.ts +30 -0
  273. package/dist/semantic-memory-graph-DlZBD_Eu.d.cts +30 -0
  274. package/dist/{semantic-memory-graph-BYoIlP35.d.cts → semantic-memory-graph-types-BvzdqmkY.d.cts} +2 -28
  275. package/dist/{semantic-memory-graph-CxyXLms3.d.ts → semantic-memory-graph-types-Ci-OtahO.d.ts} +2 -28
  276. package/dist/solutions/index.cjs +6788 -2128
  277. package/dist/solutions/index.cjs.map +1 -1
  278. package/dist/solutions/index.d.cts +15 -519
  279. package/dist/solutions/index.d.ts +15 -519
  280. package/dist/solutions/index.js +91 -7
  281. package/dist/solutions/reactive-layout/browser/index.cjs +457 -0
  282. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -0
  283. package/dist/solutions/reactive-layout/browser/index.d.cts +44 -0
  284. package/dist/solutions/reactive-layout/browser/index.d.ts +44 -0
  285. package/dist/solutions/reactive-layout/browser/index.js +69 -0
  286. package/dist/solutions/reactive-layout/browser/index.js.map +1 -0
  287. package/dist/solutions/reactive-layout/index.cjs +4494 -0
  288. package/dist/solutions/reactive-layout/index.cjs.map +1 -0
  289. package/dist/solutions/reactive-layout/index.d.cts +37 -0
  290. package/dist/solutions/reactive-layout/index.d.ts +37 -0
  291. package/dist/solutions/reactive-layout/index.js +146 -0
  292. package/dist/solutions/reactive-layout/index.js.map +1 -0
  293. package/dist/solutions/reactive-layout/node-canvas/index.cjs +555 -0
  294. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -0
  295. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +54 -0
  296. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +54 -0
  297. package/dist/solutions/reactive-layout/node-canvas/index.js +131 -0
  298. package/dist/solutions/reactive-layout/node-canvas/index.js.map +1 -0
  299. package/dist/solutions/reactive-layout/react-native/index.cjs +504 -0
  300. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -0
  301. package/dist/solutions/reactive-layout/react-native/index.d.cts +51 -0
  302. package/dist/solutions/reactive-layout/react-native/index.d.ts +51 -0
  303. package/dist/solutions/reactive-layout/react-native/index.js +77 -0
  304. package/dist/solutions/reactive-layout/react-native/index.js.map +1 -0
  305. package/dist/solutions/reactive-layout/skia/index.cjs +557 -0
  306. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -0
  307. package/dist/solutions/reactive-layout/skia/index.d.cts +64 -0
  308. package/dist/solutions/reactive-layout/skia/index.d.ts +64 -0
  309. package/dist/solutions/reactive-layout/skia/index.js +70 -0
  310. package/dist/solutions/reactive-layout/skia/index.js.map +1 -0
  311. package/dist/solutions/work-item/actions.cjs +2345 -0
  312. package/dist/solutions/work-item/actions.cjs.map +1 -0
  313. package/dist/solutions/work-item/actions.d.cts +40 -0
  314. package/dist/solutions/work-item/actions.d.ts +40 -0
  315. package/dist/solutions/work-item/actions.js +2078 -0
  316. package/dist/solutions/work-item/actions.js.map +1 -0
  317. package/dist/solutions/work-item/scheduling.cjs +9797 -0
  318. package/dist/solutions/work-item/scheduling.cjs.map +1 -0
  319. package/dist/solutions/work-item/scheduling.d.cts +1868 -0
  320. package/dist/solutions/work-item/scheduling.d.ts +1868 -0
  321. package/dist/solutions/work-item/scheduling.js +146 -0
  322. package/dist/solutions/work-item/scheduling.js.map +1 -0
  323. package/dist/solutions/work-item/work-queue.cjs +306 -0
  324. package/dist/solutions/work-item/work-queue.cjs.map +1 -0
  325. package/dist/solutions/work-item/work-queue.d.cts +71 -0
  326. package/dist/solutions/work-item/work-queue.d.ts +71 -0
  327. package/dist/solutions/work-item/work-queue.js +270 -0
  328. package/dist/solutions/work-item/work-queue.js.map +1 -0
  329. package/dist/sources/browser.cjs +1399 -1052
  330. package/dist/sources/browser.cjs.map +1 -1
  331. package/dist/sources/browser.d.cts +33 -6
  332. package/dist/sources/browser.d.ts +33 -6
  333. package/dist/sources/browser.js +73 -6
  334. package/dist/sources/browser.js.map +1 -1
  335. package/dist/sources/index.cjs +1345 -1065
  336. package/dist/sources/index.cjs.map +1 -1
  337. package/dist/sources/index.d.cts +5 -5
  338. package/dist/sources/index.d.ts +5 -5
  339. package/dist/sources/index.js +7 -6
  340. package/dist/sources/node.cjs.map +1 -1
  341. package/dist/sources/node.d.cts +4 -4
  342. package/dist/sources/node.d.ts +4 -4
  343. package/dist/sources/node.js +2 -1
  344. package/dist/sources/node.js.map +1 -1
  345. package/dist/storage/browser.cjs +16 -0
  346. package/dist/storage/browser.cjs.map +1 -1
  347. package/dist/storage/browser.js +4 -3
  348. package/dist/storage/browser.js.map +1 -1
  349. package/dist/storage/index.cjs +16 -0
  350. package/dist/storage/index.cjs.map +1 -1
  351. package/dist/storage/index.d.cts +6 -5
  352. package/dist/storage/index.d.ts +6 -5
  353. package/dist/storage/index.js +10 -9
  354. package/dist/storage/node.cjs +16 -0
  355. package/dist/storage/node.cjs.map +1 -1
  356. package/dist/storage/node.js +4 -3
  357. package/dist/storage/node.js.map +1 -1
  358. package/dist/store-BmtEs9mG.d.ts +123 -0
  359. package/dist/store-PAAsYvML.d.cts +123 -0
  360. package/dist/testing/index.cjs +1 -0
  361. package/dist/testing/index.cjs.map +1 -1
  362. package/dist/testing/index.d.cts +1 -1
  363. package/dist/testing/index.d.ts +1 -1
  364. package/dist/testing/index.js +3 -2
  365. package/dist/types-BRNKoFHj.d.ts +357 -0
  366. package/dist/{types-h12mNYbq.d.ts → types-BS6CyR-x.d.cts} +49 -130
  367. package/dist/types-BWK2ay3e.d.cts +457 -0
  368. package/dist/types-BXKSAoE1.d.cts +357 -0
  369. package/dist/types-BaPpZItj.d.ts +457 -0
  370. package/dist/types-BhveCMg5.d.cts +274 -0
  371. package/dist/{types-bNMSWKqF.d.cts → types-C9NOgNJw.d.ts} +49 -130
  372. package/dist/types-CTsQ8Ww4.d.ts +274 -0
  373. package/dist/types-DL_05n2M.d.ts +34 -0
  374. package/dist/types-XDoqxYO9.d.cts +34 -0
  375. package/dist/work-item-runtime-types-BqtWnSCS.d.ts +138 -0
  376. package/dist/work-item-runtime-types-CHO03AKh.d.cts +138 -0
  377. package/dist/work-queue/index.cjs +1136 -0
  378. package/dist/work-queue/index.cjs.map +1 -0
  379. package/dist/work-queue/index.d.cts +21 -0
  380. package/dist/work-queue/index.d.ts +21 -0
  381. package/dist/work-queue/index.js +1082 -0
  382. package/dist/work-queue/index.js.map +1 -0
  383. package/package.json +603 -249
  384. package/dist/chunk-2ILL7HQI.js.map +0 -1
  385. package/dist/chunk-4VLAQHZI.js.map +0 -1
  386. package/dist/chunk-COHO25CZ.js.map +0 -1
  387. package/dist/chunk-DK554R7P.js.map +0 -1
  388. package/dist/chunk-G4M3NHRJ.js.map +0 -1
  389. package/dist/chunk-I3IHOHCJ.js.map +0 -1
  390. package/dist/chunk-JIMUDQN3.js.map +0 -1
  391. package/dist/chunk-RIIOUTGM.js.map +0 -1
  392. package/dist/chunk-SWTLEQL6.js.map +0 -1
  393. /package/dist/{chunk-GDL26N2T.js.map → chunk-3KN7NJDR.js.map} +0 -0
  394. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  395. /package/dist/{chunk-D6BG7U6A.js.map → chunk-7HZRJMN6.js.map} +0 -0
  396. /package/dist/{chunk-SCRFRCGR.js.map → chunk-BSQGE5PS.js.map} +0 -0
  397. /package/dist/{chunk-PKVBHGBM.js.map → chunk-CJIFGJQG.js.map} +0 -0
  398. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  399. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  400. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  401. /package/dist/{chunk-Y3ZLRGHC.js.map → chunk-SIDJO2T4.js.map} +0 -0
  402. /package/dist/{chunk-JR4IKCR2.js.map → chunk-TPND5MJS.js.map} +0 -0
  403. /package/dist/{chunk-TEW47IVR.js.map → chunk-VPEFSDME.js.map} +0 -0
  404. /package/dist/{chunk-DJC4CHLQ.js.map → chunk-YDWBXXQZ.js.map} +0 -0
  405. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/orchestration/index.ts"],"sourcesContent":["/**\n * Reusable application-infrastructure orchestration namespace.\n *\n * Retained root orchestration helpers land here only after B63 re-derives them\n * onto clean-slate graph surfaces.\n */\n\nimport { depBatch, type NodeFn } from \"../ctx/types.js\";\nimport type { Graph, TopologyGroup } from \"../graph/graph.js\";\nimport {\n\ttype BackoffPolicy,\n\tbackoffDelayMs,\n\tnextRetryDelayMs,\n\tnoBackoff,\n\ttype RetryPolicy,\n\ttype RetryStatus,\n\tretryPolicy,\n\tshouldRetry,\n} from \"../graph/resilience.js\";\nimport { timeout as timeoutOperator } from \"../graph/time.js\";\nimport type { Node } from \"../node/node.js\";\n\nexport {\n\ttype BackoffPolicy,\n\tbackoffDelayMs,\n\tnoBackoff,\n\tnextRetryDelayMs,\n\tretryPolicy,\n\ttype RetryPolicy,\n\ttype RetryStatus,\n\tshouldRetry,\n};\n\nexport type ResilienceEvent =\n\t| { readonly kind: \"attempt\"; readonly attempt: number }\n\t| {\n\t\t\treadonly kind: \"retry\";\n\t\t\treadonly attempt: number;\n\t\t\treadonly delayMs: number;\n\t\t\treadonly error: unknown;\n\t }\n\t| { readonly kind: \"success\"; readonly attempt?: number }\n\t| { readonly kind: \"failure\"; readonly attempt?: number; readonly error: unknown }\n\t| { readonly kind: \"exhausted\"; readonly attempt: number; readonly error: unknown };\n\nexport interface RetryStatusBundle {\n\treadonly status: Node<RetryStatus>;\n\treadonly errors: Node<unknown>;\n}\n\nexport interface BreakerOptions {\n\treadonly failureThreshold: number;\n\treadonly resetAfterMs?: number;\n\treadonly now?: () => number;\n\treadonly name?: string;\n}\n\nexport interface BreakerStatus {\n\treadonly state: \"closed\" | \"open\" | \"half-open\";\n\treadonly failures: number;\n\treadonly openedAtMs?: number;\n}\n\nexport interface BreakerBundle {\n\treadonly status: Node<BreakerStatus>;\n\treadonly allowed: Node<boolean>;\n}\n\nexport interface RateLimitOptions {\n\treadonly max: number;\n\treadonly windowMs: number;\n\treadonly now?: () => number;\n\treadonly name?: string;\n}\n\nexport interface RateLimitStatus {\n\treadonly allowed: number;\n\treadonly dropped: number;\n\treadonly remaining: number;\n\treadonly resetAtMs: number;\n}\n\nexport interface RateLimitBundle<T> {\n\treadonly allowed: Node<T>;\n\treadonly dropped: Node<T>;\n\treadonly status: Node<RateLimitStatus>;\n}\n\ntype RateLimitEvent<T> =\n\t| { readonly kind: \"allowed\"; readonly value: T; readonly status: RateLimitStatus }\n\t| { readonly kind: \"dropped\"; readonly value: T; readonly status: RateLimitStatus };\n\nexport interface TimeoutBundle<T> {\n\treadonly node: Node<T>;\n\treadonly status: Node<\"running\" | \"completed\" | \"errored\">;\n\treadonly errors: Node<unknown>;\n}\n\n/** D136 graph-visible process command fact. */\nexport interface ProcessCommand<T = unknown> {\n\treadonly id: string;\n\treadonly type: string;\n\treadonly payload: T;\n\treadonly processId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Event draft returned by a ProcessBundle reducer before runtime ordering. */\nexport interface ProcessEventDraft<T = unknown> {\n\treadonly id?: string;\n\treadonly type: string;\n\treadonly payload: T;\n\treadonly processId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Ordered process event fact. These are DATA facts, not protocol messages. */\nexport interface ProcessEvent<T = unknown> {\n\treadonly id: string;\n\treadonly type: string;\n\treadonly seq: number;\n\treadonly cursor: number;\n\treadonly commandId: string;\n\treadonly commandType: string;\n\treadonly payload: T;\n\treadonly timestampMs: number;\n\treadonly processId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Effect-request draft emitted by a ProcessBundle reducer for visible effect runners. */\nexport interface ProcessEffectRequestDraft<T = unknown> {\n\treadonly id?: string;\n\treadonly type: string;\n\treadonly payload: T;\n\treadonly processId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\n/** Ordered effect-request fact. Effect runners consume this node in later slices. */\nexport interface ProcessEffectRequest<T = unknown> {\n\treadonly id: string;\n\treadonly type: string;\n\treadonly seq: number;\n\treadonly cursor: number;\n\treadonly commandId: string;\n\treadonly commandType: string;\n\treadonly payload: T;\n\treadonly timestampMs: number;\n\treadonly processId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport type ProcessEffectCommandType =\n\t| \"effect.result\"\n\t| \"effect.failure\"\n\t| \"effect.cancel\"\n\t| \"effect.timeout\";\n\ninterface ProcessEffectOutcomeBase {\n\treadonly effectId: string;\n\treadonly effectType: string;\n\treadonly processId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly commandId?: string;\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport type ProcessEffectOutcome<TResult = unknown> =\n\t| (ProcessEffectOutcomeBase & { readonly kind: \"result\"; readonly value: TResult })\n\t| (ProcessEffectOutcomeBase & { readonly kind: \"failure\"; readonly error: unknown })\n\t| (ProcessEffectOutcomeBase & { readonly kind: \"cancel\"; readonly reason?: string })\n\t| (ProcessEffectOutcomeBase & { readonly kind: \"timeout\"; readonly error: unknown });\n\nexport type ProcessEffectCommandPayload<TResult = unknown> =\n\t| (Omit<ProcessEffectOutcomeBase, \"commandId\"> & {\n\t\t\treadonly kind: \"result\";\n\t\t\treadonly value: TResult;\n\t })\n\t| (Omit<ProcessEffectOutcomeBase, \"commandId\"> & {\n\t\t\treadonly kind: \"failure\";\n\t\t\treadonly error: unknown;\n\t })\n\t| (Omit<ProcessEffectOutcomeBase, \"commandId\"> & {\n\t\t\treadonly kind: \"cancel\";\n\t\t\treadonly reason?: string;\n\t })\n\t| (Omit<ProcessEffectOutcomeBase, \"commandId\"> & {\n\t\t\treadonly kind: \"timeout\";\n\t\t\treadonly error: unknown;\n\t });\n\nexport type ProcessErrorCode =\n\t| \"malformed-command\"\n\t| \"reducer-threw\"\n\t| \"clock-threw\"\n\t| \"malformed-state\"\n\t| \"malformed-event\"\n\t| \"malformed-effect\";\n\n/** Graph-visible ProcessBundle error fact. These are DATA facts, not protocol ERROR. */\nexport interface ProcessError {\n\treadonly code: ProcessErrorCode;\n\treadonly message: string;\n\treadonly command?: unknown;\n\treadonly commandId?: string;\n\treadonly commandType?: string;\n\treadonly cursor: ProcessCursor;\n}\n\n/** Accepted/rejected command outcome projected from the ProcessBundle runtime. */\nexport interface ProcessStatus {\n\treadonly state: \"accepted\" | \"rejected\";\n\treadonly commandId?: string;\n\treadonly commandType?: string;\n\treadonly eventCount: number;\n\treadonly effectCount: number;\n\treadonly errorCode?: ProcessErrorCode;\n\treadonly cursor: ProcessCursor;\n}\n\nexport interface ProcessEffectRunnerStatus {\n\treadonly state: \"requested\" | \"commanded\" | \"rejected\";\n\treadonly effectId?: string;\n\treadonly effectType?: string;\n\treadonly commandId?: string;\n\treadonly commandType?: ProcessEffectCommandType;\n\treadonly requested: number;\n\treadonly commanded: number;\n\treadonly rejected: number;\n}\n\nexport interface ProcessEffectRunnerError {\n\treadonly code: \"malformed-outcome\";\n\treadonly message: string;\n\treadonly outcome?: unknown;\n\treadonly effectId?: string;\n\treadonly effectType?: string;\n}\n\n/** Ordered audit fact for one attempted command reduction. */\nexport interface ProcessAuditRecord {\n\treadonly seq: number;\n\treadonly commandId?: string;\n\treadonly commandType?: string;\n\treadonly outcome: \"success\" | \"failure\";\n\treadonly eventIds: readonly string[];\n\treadonly eventTypes: readonly string[];\n\treadonly effectIds: readonly string[];\n\treadonly effectTypes: readonly string[];\n\treadonly errorCode?: ProcessErrorCode;\n\treadonly errorMessage?: string;\n\treadonly cursor: ProcessCursor;\n}\n\n/** Monotonic graph-visible ProcessBundle cursor counters. */\nexport interface ProcessCursor {\n\treadonly eventSeq: number;\n\treadonly effectSeq: number;\n\treadonly commandCount: number;\n\treadonly errorCount: number;\n\treadonly auditSeq: number;\n}\n\n/** Internal runtime stream fact exposed through ProcessBundle projection nodes. */\ntype ProcessRuntimeFact<TState = unknown, TEvent = unknown, TEffect = unknown> =\n\t| { readonly kind: \"state\"; readonly state: TState; readonly cursor: ProcessCursor }\n\t| { readonly kind: \"event\"; readonly event: ProcessEvent<TEvent> }\n\t| { readonly kind: \"effect-request\"; readonly effect: ProcessEffectRequest<TEffect> }\n\t| { readonly kind: \"status\"; readonly status: ProcessStatus }\n\t| { readonly kind: \"error\"; readonly error: ProcessError }\n\t| { readonly kind: \"audit\"; readonly audit: ProcessAuditRecord }\n\t| { readonly kind: \"cursor\"; readonly cursor: ProcessCursor };\n\ntype ProcessEffectRunnerFact<TResult = unknown> =\n\t| { readonly kind: \"outcome\"; readonly outcome: ProcessEffectOutcome<TResult> }\n\t| {\n\t\t\treadonly kind: \"command\";\n\t\t\treadonly command: ProcessCommand<ProcessEffectCommandPayload<TResult>>;\n\t }\n\t| { readonly kind: \"error\"; readonly error: ProcessEffectRunnerError };\n\n/** Reducer result: next process state plus optional event/effect-request drafts. */\nexport interface ProcessReduction<TState = unknown, TEvent = unknown, TEffect = unknown> {\n\treadonly state: TState;\n\treadonly events?: readonly ProcessEventDraft<TEvent>[];\n\treadonly effects?: readonly ProcessEffectRequestDraft<TEffect>[];\n}\n\n/** Sync ProcessBundle reducer. Async effects belong in graph-visible adapters, not here. */\nexport type ProcessReducer<\n\tTCommand = unknown,\n\tTState = unknown,\n\tTEvent = unknown,\n\tTEffect = unknown,\n> = (command: ProcessCommand<TCommand>, state: TState) => ProcessReduction<TState, TEvent, TEffect>;\n\n/** Options for a D136 facts-plus-reducer ProcessBundle. */\nexport interface ProcessBundleOptions<\n\tTCommand = unknown,\n\tTState = unknown,\n\tTEvent = unknown,\n\tTEffect = unknown,\n> {\n\treadonly name?: string;\n\treadonly initialState: TState;\n\treadonly reduce: ProcessReducer<TCommand, TState, TEvent, TEffect>;\n\treadonly now?: () => number;\n}\n\n/** D136 facts-plus-reducer process bundle. It is not a workflow engine or hidden runtime owner. */\nexport interface ProcessBundle<\n\tTCommand = unknown,\n\tTState = unknown,\n\tTEvent = unknown,\n\tTEffect = unknown,\n> {\n\treadonly command: Node<ProcessCommand<TCommand>>;\n\treadonly events: Node<ProcessEvent<TEvent>>;\n\treadonly state: Node<TState>;\n\treadonly audit: Node<ProcessAuditRecord>;\n\treadonly effectRequests: Node<ProcessEffectRequest<TEffect>>;\n\treadonly status: Node<ProcessStatus>;\n\treadonly errors: Node<ProcessError>;\n\treadonly cursor: Node<ProcessCursor>;\n\tdispatch(command: ProcessCommand<TCommand>): ProcessCommand<TCommand>;\n\t/** Release only graph-owned retain roots; process facts/topology/cache/state remain ordinary graph data. */\n\trelease(): void;\n}\n\nexport interface ProcessEffectRunnerOptions<TResult = unknown> {\n\treadonly name?: string;\n\treadonly outcomes: readonly Node<ProcessEffectOutcome<TResult>>[];\n}\n\nexport interface ProcessEffectRunnerBundle<TEffect = unknown, TResult = unknown> {\n\treadonly requests: Node<ProcessEffectRequest<TEffect>>;\n\treadonly outcomes: Node<ProcessEffectOutcome<TResult>>;\n\treadonly commands: Node<ProcessCommand<ProcessEffectCommandPayload<TResult>>>;\n\treadonly status: Node<ProcessEffectRunnerStatus>;\n\treadonly errors: Node<ProcessEffectRunnerError>;\n\trelease(): void;\n}\n\ninterface AttachedProcessCommandSources<TCommand> {\n\tsources: Node<ProcessCommand<TCommand>>[];\n}\n\nconst processCommandSources = new WeakMap<\n\tProcessBundle<unknown, unknown, unknown, unknown>,\n\tAttachedProcessCommandSources<unknown>\n>();\n\nexport function retryStatusBundle(\n\tgraph: Graph,\n\tevents: Node<ResilienceEvent>,\n\topts: { name?: string; policy?: RetryPolicy } = {},\n): RetryStatusBundle {\n\tconst policy = opts.policy ?? retryPolicy();\n\tconst name = opts.name ?? \"retry\";\n\tconst status = graph.node<RetryStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tlet next =\n\t\t\t\tctx.state.get<RetryStatus>() ??\n\t\t\t\t({ state: \"idle\", attempt: 0, maxAttempts: policy.maxAttempts } satisfies RetryStatus);\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as ResilienceEvent;\n\t\t\t\tif (event.kind === \"attempt\") {\n\t\t\t\t\tnext = { state: \"running\", attempt: event.attempt, maxAttempts: policy.maxAttempts };\n\t\t\t\t} else if (event.kind === \"retry\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\tstate: \"waiting\",\n\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\t\tdelayMs: event.delayMs,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"success\") {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\tstate: \"succeeded\",\n\t\t\t\t\t\tattempt: event.attempt ?? next.attempt,\n\t\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\t};\n\t\t\t\t} else if (event.kind === \"failure\") {\n\t\t\t\t\tconst attempt = event.attempt ?? next.attempt;\n\t\t\t\t\tnext = {\n\t\t\t\t\t\tstate: shouldRetry(policy, attempt) ? \"failed\" : \"exhausted\",\n\t\t\t\t\t\tattempt,\n\t\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\t\tdelayMs: shouldRetry(policy, attempt)\n\t\t\t\t\t\t\t? nextRetryDelayMs(policy, attempt + 1)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tnext = {\n\t\t\t\t\t\tstate: \"exhausted\",\n\t\t\t\t\t\tattempt: event.attempt,\n\t\t\t\t\t\tmaxAttempts: policy.maxAttempts,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(next);\n\t\t\tctx.down([[\"DATA\", next]]);\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"retryStatus\" },\n\t);\n\tconst errors = graph.node<unknown>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as ResilienceEvent;\n\t\t\t\tif (\"error\" in event) ctx.down([[\"DATA\", event.error]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/errors`, factory: \"retryErrors\" },\n\t);\n\treturn { status, errors };\n}\n\nexport function breakerBundle(\n\tgraph: Graph,\n\tevents: Node<ResilienceEvent>,\n\topts: BreakerOptions,\n): BreakerBundle {\n\tif (!Number.isInteger(opts.failureThreshold) || opts.failureThreshold <= 0) {\n\t\tthrow new RangeError(\"breakerBundle: failureThreshold must be a positive integer\");\n\t}\n\tconst name = opts.name ?? \"breaker\";\n\tconst now = opts.now ?? Date.now;\n\tconst status = graph.node<BreakerStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tlet next =\n\t\t\t\tctx.state.get<BreakerStatus>() ??\n\t\t\t\t({ state: \"closed\", failures: 0 } satisfies BreakerStatus);\n\t\t\tif (\n\t\t\t\tnext.state === \"open\" &&\n\t\t\t\topts.resetAfterMs !== undefined &&\n\t\t\t\tnext.openedAtMs !== undefined &&\n\t\t\t\tnow() - next.openedAtMs >= opts.resetAfterMs\n\t\t\t) {\n\t\t\t\tnext = { ...next, state: \"half-open\" };\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst event = raw as ResilienceEvent;\n\t\t\t\tif (event.kind === \"success\") {\n\t\t\t\t\tnext = { state: \"closed\", failures: 0 };\n\t\t\t\t} else if (event.kind === \"failure\" || event.kind === \"exhausted\") {\n\t\t\t\t\tconst failures = next.failures + 1;\n\t\t\t\t\tnext =\n\t\t\t\t\t\tfailures >= opts.failureThreshold\n\t\t\t\t\t\t\t? { state: \"open\", failures, openedAtMs: now() }\n\t\t\t\t\t\t\t: { ...next, failures };\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(next);\n\t\t\tctx.down([[\"DATA\", next]]);\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"breakerStatus\" },\n\t);\n\tconst allowed = graph.node<boolean>(\n\t\t[status],\n\t\t(ctx) => {\n\t\t\tconst statusBatch = depBatch(ctx, 0) ?? [];\n\t\t\tfor (const value of statusBatch) {\n\t\t\t\tctx.down([[\"DATA\", (value as BreakerStatus).state !== \"open\"]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/allowed`, factory: \"breakerAllowed\" },\n\t);\n\treturn { status, allowed };\n}\n\nexport function rateLimitBundle<T>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\topts: RateLimitOptions,\n): RateLimitBundle<T> {\n\tif (!Number.isInteger(opts.max) || opts.max <= 0) {\n\t\tthrow new RangeError(\"rateLimitBundle: max must be a positive integer\");\n\t}\n\tif (!Number.isFinite(opts.windowMs) || opts.windowMs <= 0) {\n\t\tthrow new RangeError(\"rateLimitBundle: windowMs must be positive\");\n\t}\n\tconst now = opts.now ?? Date.now;\n\tconst name = opts.name ?? \"rateLimit\";\n\tconst events = graph.node<RateLimitEvent<T>>(\n\t\t[source],\n\t\t(ctx) => {\n\t\t\ttype State = { count: number; resetAtMs: number; allowed: number; dropped: number };\n\t\t\tconst current = now();\n\t\t\tlet state =\n\t\t\t\tctx.state.get<State>() ??\n\t\t\t\t({ count: 0, resetAtMs: current + opts.windowMs, allowed: 0, dropped: 0 } satisfies State);\n\t\t\tif (current >= state.resetAtMs) {\n\t\t\t\tstate = { ...state, count: 0, resetAtMs: current + opts.windowMs };\n\t\t\t}\n\t\t\tfor (const value of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst allowed = state.count < opts.max;\n\t\t\t\tstate = allowed\n\t\t\t\t\t? { ...state, count: state.count + 1, allowed: state.allowed + 1 }\n\t\t\t\t\t: { ...state, dropped: state.dropped + 1 };\n\t\t\t\tconst status = {\n\t\t\t\t\tallowed: state.allowed,\n\t\t\t\t\tdropped: state.dropped,\n\t\t\t\t\tremaining: Math.max(0, opts.max - state.count),\n\t\t\t\t\tresetAtMs: state.resetAtMs,\n\t\t\t\t} satisfies RateLimitStatus;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\tallowed\n\t\t\t\t\t\t\t? ({ kind: \"allowed\", value: value as T, status } satisfies RateLimitEvent<T>)\n\t\t\t\t\t\t\t: ({ kind: \"dropped\", value: value as T, status } satisfies RateLimitEvent<T>),\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{ name: `${name}/events`, factory: \"rateLimitEvents\" },\n\t);\n\tconst allowed = graph.node<T>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RateLimitEvent<T>;\n\t\t\t\tif (typed.kind === \"allowed\") ctx.down([[\"DATA\", typed.value]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/allowed`, factory: \"rateLimitAllowed\" },\n\t);\n\tconst dropped = graph.node<T>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RateLimitEvent<T>;\n\t\t\t\tif (typed.kind === \"dropped\") ctx.down([[\"DATA\", typed.value]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/dropped`, factory: \"rateLimitDropped\" },\n\t);\n\tconst status = graph.node<RateLimitStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tctx.down([[\"DATA\", (event as RateLimitEvent<T>).status]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"rateLimitStatus\" },\n\t);\n\treturn { allowed, dropped, status };\n}\n\nexport function timeoutBundle<T>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\tms: number,\n\topts: { name?: string } = {},\n): TimeoutBundle<T> {\n\tconst name = opts.name ?? \"timeout\";\n\tconst node = timeoutOperator(source, ms);\n\tconst status = graph.node<\"running\" | \"completed\" | \"errored\">(\n\t\t[node],\n\t\t(ctx) => {\n\t\t\tconst terminal = ctx.terminal[0];\n\t\t\tif (terminal === true) ctx.down([[\"DATA\", \"completed\"]]);\n\t\t\telse if (terminal !== false && terminal !== undefined) ctx.down([[\"DATA\", \"errored\"]]);\n\t\t\telse if ((depBatch(ctx, 0) ?? []).length > 0) ctx.down([[\"DATA\", \"running\"]]);\n\t\t},\n\t\t{ name: `${name}/status`, factory: \"timeoutStatus\" },\n\t);\n\tconst errors = graph.node<unknown>(\n\t\t[node],\n\t\t(ctx) => {\n\t\t\tconst terminal = ctx.terminal[0];\n\t\t\tif (terminal !== true && terminal !== false && terminal !== undefined) {\n\t\t\t\tctx.down([[\"DATA\", terminal]]);\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/errors`, factory: \"timeoutErrors\" },\n\t);\n\treturn { node, status, errors };\n}\n\n/**\n * Build a D136 ProcessBundle from graph-visible command facts and a reducer.\n *\n * The bundle retains its runtime/projection nodes until `release()` is called.\n * Reducer and validation failures are emitted as DATA error/status/audit facts;\n * they do not mint protocol ERROR messages or own restore/hydration behavior.\n */\nexport function processBundle<\n\tTCommand = unknown,\n\tTState = unknown,\n\tTEvent = unknown,\n\tTEffect = unknown,\n>(\n\tgraph: Graph,\n\topts: ProcessBundleOptions<TCommand, TState, TEvent, TEffect>,\n): ProcessBundle<TCommand, TState, TEvent, TEffect> {\n\tif (typeof opts.reduce !== \"function\") {\n\t\tthrow new TypeError(\"processBundle: reduce must be a function\");\n\t}\n\tif (opts.initialState === undefined) {\n\t\tthrow new TypeError(\"processBundle: initialState must not be undefined\");\n\t}\n\tconst name = opts.name ?? \"process\";\n\tconst now = opts.now ?? Date.now;\n\tconst topology = graph.topologyGroup({ name: `${name}.process` });\n\tconst command = topology.node<ProcessCommand<TCommand>>([], null, {\n\t\tname: `${name}/command`,\n\t\tfactory: \"processCommand\",\n\t\tcompleteWhenDepsComplete: false,\n\t\terrorWhenDepsError: false,\n\t});\n\tconst runtime = topology.node<ProcessRuntimeFact<TState, TEvent, TEffect>>(\n\t\t[command],\n\t\t(ctx) => {\n\t\t\tlet state =\n\t\t\t\tctx.state.get<ProcessRuntimeState<TState>>() ??\n\t\t\t\t({\n\t\t\t\t\teventSeq: 0,\n\t\t\t\t\teffectSeq: 0,\n\t\t\t\t\tcommandCount: 0,\n\t\t\t\t\terrorCount: 0,\n\t\t\t\t\tauditSeq: 0,\n\t\t\t\t\tseenEventIds: [],\n\t\t\t\t\tseenEffectIds: [],\n\t\t\t\t\tstate: opts.initialState,\n\t\t\t\t} satisfies ProcessRuntimeState<TState>);\n\t\t\tctx.state.persist(true);\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tstate = reduceProcessCommandFact(\n\t\t\t\t\traw,\n\t\t\t\t\tstate,\n\t\t\t\t\topts.reduce as ProcessReducer<unknown, TState, unknown, unknown>,\n\t\t\t\t\tnow,\n\t\t\t\t\t(fact) => ctx.down([[\"DATA\", fact as ProcessRuntimeFact<TState, TEvent, TEffect>]]),\n\t\t\t\t);\n\t\t\t\tctx.state.set(state);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"processRuntime\",\n\t\t\tmeta: { process: \"facts-plus-reducer\", d: \"D136\" },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst events = processProjection<ProcessEvent<TEvent>, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/events`,\n\t\t\"processEvents\",\n\t\t(fact) => (fact.kind === \"event\" ? fact.event : undefined),\n\t);\n\tconst state = processProjection<TState, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/state`,\n\t\t\"processState\",\n\t\t(fact) => (fact.kind === \"state\" ? fact.state : undefined),\n\t);\n\tconst audit = processProjection<ProcessAuditRecord, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/audit`,\n\t\t\"processAudit\",\n\t\t(fact) => (fact.kind === \"audit\" ? fact.audit : undefined),\n\t);\n\tconst effectRequests = processProjection<ProcessEffectRequest<TEffect>, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/effectRequests`,\n\t\t\"processEffectRequests\",\n\t\t(fact) => (fact.kind === \"effect-request\" ? fact.effect : undefined),\n\t);\n\tconst status = processProjection<ProcessStatus, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/status`,\n\t\t\"processStatus\",\n\t\t(fact) => (fact.kind === \"status\" ? fact.status : undefined),\n\t);\n\tconst errors = processProjection<ProcessError, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/errors`,\n\t\t\"processErrors\",\n\t\t(fact) => (fact.kind === \"error\" ? fact.error : undefined),\n\t);\n\tconst cursor = processProjection<ProcessCursor, TState, TEvent, TEffect>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/cursor`,\n\t\t\"processCursor\",\n\t\t(fact) => (fact.kind === \"cursor\" ? fact.cursor : undefined),\n\t);\n\tconst retainProcessNodes = () => [\n\t\tgraph.retain(runtime, { reason: `${name}.process.runtime` }),\n\t\tgraph.retain(events, { reason: `${name}.process.events` }),\n\t\tgraph.retain(state, { reason: `${name}.process.state` }),\n\t\tgraph.retain(audit, { reason: `${name}.process.audit` }),\n\t\tgraph.retain(effectRequests, { reason: `${name}.process.effectRequests` }),\n\t\tgraph.retain(status, { reason: `${name}.process.status` }),\n\t\tgraph.retain(errors, { reason: `${name}.process.errors` }),\n\t\tgraph.retain(cursor, { reason: `${name}.process.cursor` }),\n\t];\n\tlet releaseRetains = retainProcessNodes();\n\tlet released = false;\n\tconst bundle: ProcessBundle<TCommand, TState, TEvent, TEffect> = {\n\t\tcommand,\n\t\tevents,\n\t\tstate,\n\t\taudit,\n\t\teffectRequests,\n\t\tstatus,\n\t\terrors,\n\t\tcursor,\n\t\tdispatch(next) {\n\t\t\tcommand.down([[\"DATA\", next]]);\n\t\t\treturn next;\n\t\t},\n\t\trelease() {\n\t\t\tif (released) return;\n\t\t\tconst activeRetains = releaseRetains;\n\t\t\treleaseRetains = [];\n\t\t\tfor (const releaseRetain of activeRetains) releaseRetain();\n\t\t\ttry {\n\t\t\t\ttopology.release({ reason: `${name}.process.release` });\n\t\t\t\treleased = true;\n\t\t\t\tprocessCommandSources.delete(\n\t\t\t\t\tbundle as unknown as ProcessBundle<unknown, unknown, unknown, unknown>,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\treleaseRetains = retainProcessNodes();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t};\n\tprocessCommandSources.set(\n\t\tbundle as unknown as ProcessBundle<unknown, unknown, unknown, unknown>,\n\t\t{ sources: [] },\n\t);\n\treturn bundle;\n}\n\n/**\n * Build a D156 graph-visible effect runner adapter over a ProcessBundle.\n *\n * The runner consumes visible effect-request and outcome facts, then publishes\n * ordinary ProcessCommand DATA facts back through process.command via a declared\n * graph edge. Async handlers, timers, and process state ownership stay outside\n * this helper.\n */\nexport function processEffectRunner<TEffect = unknown, TResult = unknown>(\n\tgraph: Graph,\n\tprocess: ProcessBundle<unknown, unknown, unknown, TEffect>,\n\topts: ProcessEffectRunnerOptions<TResult>,\n): ProcessEffectRunnerBundle<TEffect, TResult> {\n\tif (opts.outcomes.length === 0) {\n\t\tthrow new RangeError(\"processEffectRunner: outcomes must contain at least one node\");\n\t}\n\tconst name = opts.name ?? \"processEffectRunner\";\n\tconst topology = graph.topologyGroup({ name: `${name}.effectRunner` });\n\tconst requests = topology.node<ProcessEffectRequest<TEffect>>(\n\t\t[process.effectRequests],\n\t\t(ctx) => {\n\t\t\tfor (const request of depBatch(ctx, 0) ?? []) {\n\t\t\t\tctx.down([[\"DATA\", request as ProcessEffectRequest<TEffect>]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/requests`,\n\t\t\tfactory: \"processEffectRunnerRequests\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst runtime = topology.node<ProcessEffectRunnerFact<TResult>>(\n\t\t[...opts.outcomes],\n\t\t(ctx) => {\n\t\t\tfor (let i = 0; i < opts.outcomes.length; i += 1) {\n\t\t\t\tfor (const raw of depBatch(ctx, i) ?? []) {\n\t\t\t\t\tconst parsed = parseProcessEffectOutcome<TResult>(raw);\n\t\t\t\t\tif (typeof parsed === \"string\") {\n\t\t\t\t\t\tconst error = {\n\t\t\t\t\t\t\tcode: \"malformed-outcome\",\n\t\t\t\t\t\t\tmessage: parsed,\n\t\t\t\t\t\t\toutcome: raw,\n\t\t\t\t\t\t} satisfies ProcessEffectRunnerError;\n\t\t\t\t\t\tctx.down([[\"DATA\", { kind: \"error\", error }]]);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst outcome = parsed as ProcessEffectOutcome<TResult>;\n\t\t\t\t\tconst command = processEffectOutcomeCommand(outcome);\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"outcome\", outcome }]]);\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"command\", command }]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"processEffectRunner\",\n\t\t\tmeta: { process: \"effect-runner\", d: \"D156\" },\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst outcomes = processEffectRunnerProjection<ProcessEffectOutcome<TResult>, TResult>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/outcomes`,\n\t\t\"processEffectRunnerOutcomes\",\n\t\t(fact) => (fact.kind === \"outcome\" ? fact.outcome : undefined),\n\t);\n\tconst commands = processEffectRunnerProjection<\n\t\tProcessCommand<ProcessEffectCommandPayload<TResult>>,\n\t\tTResult\n\t>(topology, runtime, `${name}/commands`, \"processEffectRunnerCommands\", (fact) =>\n\t\tfact.kind === \"command\" ? fact.command : undefined,\n\t);\n\tconst errors = processEffectRunnerProjection<ProcessEffectRunnerError, TResult>(\n\t\ttopology,\n\t\truntime,\n\t\t`${name}/errors`,\n\t\t\"processEffectRunnerErrors\",\n\t\t(fact) => (fact.kind === \"error\" ? fact.error : undefined),\n\t);\n\tconst status = topology.node<ProcessEffectRunnerStatus>(\n\t\t[requests, runtime],\n\t\t(ctx) => {\n\t\t\tlet state =\n\t\t\t\tctx.state.get<ProcessEffectRunnerState>() ??\n\t\t\t\t({ requested: 0, commanded: 0, rejected: 0 } satisfies ProcessEffectRunnerState);\n\t\t\tfor (const request of depBatch(ctx, 0) ?? []) {\n\t\t\t\tstate = { ...state, requested: state.requested + 1 };\n\t\t\t\tconst typedRequest = request as ProcessEffectRequest<TEffect>;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstate: \"requested\",\n\t\t\t\t\t\t\teffectId: typedRequest.id,\n\t\t\t\t\t\t\teffectType: typedRequest.type,\n\t\t\t\t\t\t\trequested: state.requested,\n\t\t\t\t\t\t\tcommanded: state.commanded,\n\t\t\t\t\t\t\trejected: state.rejected,\n\t\t\t\t\t\t} satisfies ProcessEffectRunnerStatus,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t\tfor (const fact of depBatch(ctx, 1) ?? []) {\n\t\t\t\tconst typedFact = fact as ProcessEffectRunnerFact<TResult>;\n\t\t\t\tif (typedFact.kind === \"command\") {\n\t\t\t\t\tstate = { ...state, commanded: state.commanded + 1 };\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstate: \"commanded\",\n\t\t\t\t\t\t\t\teffectId: typedFact.command.payload.effectId,\n\t\t\t\t\t\t\t\teffectType: typedFact.command.payload.effectType,\n\t\t\t\t\t\t\t\tcommandId: typedFact.command.id,\n\t\t\t\t\t\t\t\tcommandType: typedFact.command.type as ProcessEffectCommandType,\n\t\t\t\t\t\t\t\trequested: state.requested,\n\t\t\t\t\t\t\t\tcommanded: state.commanded,\n\t\t\t\t\t\t\t\trejected: state.rejected,\n\t\t\t\t\t\t\t} satisfies ProcessEffectRunnerStatus,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t\tif (typedFact.kind === \"error\") {\n\t\t\t\t\tstate = { ...state, rejected: state.rejected + 1 };\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstate: \"rejected\",\n\t\t\t\t\t\t\t\teffectId: typedFact.error.effectId,\n\t\t\t\t\t\t\t\teffectType: typedFact.error.effectType,\n\t\t\t\t\t\t\t\trequested: state.requested,\n\t\t\t\t\t\t\t\tcommanded: state.commanded,\n\t\t\t\t\t\t\t\trejected: state.rejected,\n\t\t\t\t\t\t\t} satisfies ProcessEffectRunnerStatus,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/status`,\n\t\t\tfactory: \"processEffectRunnerStatus\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst retainRunnerNodes = () => [\n\t\tgraph.retain(requests, { reason: `${name}.effectRunner.requests` }),\n\t\tgraph.retain(outcomes, { reason: `${name}.effectRunner.outcomes` }),\n\t\tgraph.retain(commands, { reason: `${name}.effectRunner.commands` }),\n\t\tgraph.retain(status, { reason: `${name}.effectRunner.status` }),\n\t\tgraph.retain(errors, { reason: `${name}.effectRunner.errors` }),\n\t];\n\tlet releaseRetains = retainRunnerNodes();\n\ttry {\n\t\tattachProcessCommandSource(process, commands);\n\t} catch (error) {\n\t\tfor (const releaseRetain of releaseRetains) releaseRetain();\n\t\treleaseRetains = [];\n\t\ttopology.release({ reason: `${name}.effectRunner.failedAttach` });\n\t\tthrow error;\n\t}\n\tlet released = false;\n\treturn {\n\t\trequests,\n\t\toutcomes,\n\t\tcommands,\n\t\tstatus,\n\t\terrors,\n\t\trelease() {\n\t\t\tif (released) return;\n\t\t\tconst activeRetains = releaseRetains;\n\t\t\treleaseRetains = [];\n\t\t\tfor (const releaseRetain of activeRetains) releaseRetain();\n\t\t\tdetachProcessCommandSource(process, commands);\n\t\t\ttry {\n\t\t\t\ttopology.release({ reason: `${name}.effectRunner.release` });\n\t\t\t\treleased = true;\n\t\t\t} catch (error) {\n\t\t\t\tattachProcessCommandSource(process, commands);\n\t\t\t\treleaseRetains = retainRunnerNodes();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function constantBackoff(delayMs: number): BackoffPolicy {\n\treturn { kind: \"constant\", delayMs };\n}\n\ninterface ProcessEffectRunnerState {\n\trequested: number;\n\tcommanded: number;\n\trejected: number;\n}\n\ninterface ProcessRuntimeState<TState> {\n\teventSeq: number;\n\teffectSeq: number;\n\tcommandCount: number;\n\terrorCount: number;\n\tauditSeq: number;\n\tseenEventIds: string[];\n\tseenEffectIds: string[];\n\tstate: TState;\n}\n\nfunction processEffectRunnerProjection<T, TResult>(\n\ttopology: TopologyGroup,\n\truntime: Node<ProcessEffectRunnerFact<TResult>>,\n\tname: string,\n\tfactory: string,\n\tpick: (fact: ProcessEffectRunnerFact<TResult>) => T | undefined,\n): Node<T> {\n\treturn topology.node<T>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst value = pick(fact as ProcessEffectRunnerFact<TResult>);\n\t\t\t\tif (value !== undefined) ctx.down([[\"DATA\", value]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname,\n\t\t\tfactory,\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction parseProcessEffectOutcome<TResult>(raw: unknown): ProcessEffectOutcome<TResult> | string {\n\tif (!isObjectRecord(raw)) return \"processEffectRunner: outcome must be an object\";\n\tif (typeof raw.kind !== \"string\") {\n\t\treturn \"processEffectRunner: outcome kind must be a string\";\n\t}\n\tif (\n\t\traw.kind !== \"result\" &&\n\t\traw.kind !== \"failure\" &&\n\t\traw.kind !== \"cancel\" &&\n\t\traw.kind !== \"timeout\"\n\t) {\n\t\treturn \"processEffectRunner: outcome kind must be result, failure, cancel, or timeout\";\n\t}\n\tif (typeof raw.effectId !== \"string\" || raw.effectId.length === 0) {\n\t\treturn \"processEffectRunner: outcome effectId must be a non-empty string\";\n\t}\n\tif (typeof raw.effectType !== \"string\" || raw.effectType.length === 0) {\n\t\treturn \"processEffectRunner: outcome effectType must be a non-empty string\";\n\t}\n\tif (\"commandId\" in raw && raw.commandId !== undefined) {\n\t\tif (typeof raw.commandId !== \"string\" || raw.commandId.length === 0) {\n\t\t\treturn \"processEffectRunner: outcome commandId must be a non-empty string\";\n\t\t}\n\t}\n\tfor (const key of [\"processId\", \"correlationId\", \"causationId\"] as const) {\n\t\tif (key in raw && raw[key] !== undefined && typeof raw[key] !== \"string\") {\n\t\t\treturn `processEffectRunner: outcome ${key} must be a string`;\n\t\t}\n\t}\n\tif (\"metadata\" in raw && raw.metadata !== undefined && !isObjectRecord(raw.metadata)) {\n\t\treturn \"processEffectRunner: outcome metadata must be a plain object\";\n\t}\n\tif (raw.kind === \"result\" && !(\"value\" in raw)) {\n\t\treturn \"processEffectRunner: result outcome must carry value\";\n\t}\n\tif ((raw.kind === \"failure\" || raw.kind === \"timeout\") && !(\"error\" in raw)) {\n\t\treturn `processEffectRunner: ${raw.kind} outcome must carry error`;\n\t}\n\tif (\n\t\traw.kind === \"cancel\" &&\n\t\t\"reason\" in raw &&\n\t\traw.reason !== undefined &&\n\t\ttypeof raw.reason !== \"string\"\n\t) {\n\t\treturn \"processEffectRunner: cancel outcome reason must be a string\";\n\t}\n\treturn raw as unknown as ProcessEffectOutcome<TResult>;\n}\n\nfunction processEffectOutcomeCommand<TResult>(\n\toutcome: ProcessEffectOutcome<TResult>,\n): ProcessCommand<ProcessEffectCommandPayload<TResult>> {\n\tconst commandType = processEffectCommandType(outcome.kind);\n\treturn {\n\t\tid: outcome.commandId ?? `${outcome.effectId}:${commandType}`,\n\t\ttype: commandType,\n\t\tpayload: processEffectCommandPayload(outcome),\n\t\tprocessId: outcome.processId,\n\t\tcorrelationId: outcome.correlationId,\n\t\tcausationId: outcome.causationId,\n\t\tmetadata: outcome.metadata,\n\t};\n}\n\nfunction processEffectCommandType(kind: ProcessEffectOutcome[\"kind\"]): ProcessEffectCommandType {\n\tswitch (kind) {\n\t\tcase \"result\":\n\t\t\treturn \"effect.result\";\n\t\tcase \"failure\":\n\t\t\treturn \"effect.failure\";\n\t\tcase \"cancel\":\n\t\t\treturn \"effect.cancel\";\n\t\tcase \"timeout\":\n\t\t\treturn \"effect.timeout\";\n\t}\n}\n\nfunction processEffectCommandPayload<TResult>(\n\toutcome: ProcessEffectOutcome<TResult>,\n): ProcessEffectCommandPayload<TResult> {\n\tconst base = {\n\t\teffectId: outcome.effectId,\n\t\teffectType: outcome.effectType,\n\t\tprocessId: outcome.processId,\n\t\tcorrelationId: outcome.correlationId,\n\t\tcausationId: outcome.causationId,\n\t\tmetadata: outcome.metadata,\n\t};\n\tswitch (outcome.kind) {\n\t\tcase \"result\":\n\t\t\treturn { ...base, kind: \"result\", value: outcome.value };\n\t\tcase \"failure\":\n\t\t\treturn { ...base, kind: \"failure\", error: outcome.error };\n\t\tcase \"cancel\":\n\t\t\treturn { ...base, kind: \"cancel\", reason: outcome.reason };\n\t\tcase \"timeout\":\n\t\t\treturn { ...base, kind: \"timeout\", error: outcome.error };\n\t}\n}\n\nfunction attachProcessCommandSource(\n\tprocess: ProcessBundle<unknown, unknown, unknown, unknown>,\n\tsource: Node<ProcessCommand<unknown>>,\n): void {\n\tconst attached = processCommandSources.get(process);\n\tif (attached === undefined) {\n\t\tthrow new Error(\"processEffectRunner: process command source registry missing\");\n\t}\n\tconst sources = attached.sources as Node<ProcessCommand<unknown>>[];\n\tconst previousSources = [...sources];\n\tif (!sources.includes(source)) sources.push(source);\n\ttry {\n\t\tprocess.command.replaceDeps([...sources], processCommandSourceFn(sources.length));\n\t} catch (error) {\n\t\tsources.splice(0, sources.length, ...previousSources);\n\t\tprocess.command.replaceDeps(\n\t\t\t[...previousSources],\n\t\t\tprocessCommandSourceFn(previousSources.length),\n\t\t);\n\t\tthrow error;\n\t}\n}\n\nfunction detachProcessCommandSource(\n\tprocess: ProcessBundle<unknown, unknown, unknown, unknown>,\n\tsource: Node<ProcessCommand<unknown>>,\n): void {\n\tconst attached = processCommandSources.get(process);\n\tif (attached === undefined) {\n\t\tthrow new Error(\"processEffectRunner: process command source registry missing\");\n\t}\n\tconst sources = attached.sources as Node<ProcessCommand<unknown>>[];\n\tif (!sources.includes(source)) return;\n\tconst previousSources = [...sources];\n\tconst nextSources = sources.filter((candidate) => candidate !== source);\n\tsources.splice(0, sources.length, ...nextSources);\n\ttry {\n\t\tprocess.command.replaceDeps([...nextSources], processCommandSourceFn(nextSources.length));\n\t} catch (error) {\n\t\tsources.splice(0, sources.length, ...previousSources);\n\t\tprocess.command.replaceDeps(\n\t\t\t[...previousSources],\n\t\t\tprocessCommandSourceFn(previousSources.length),\n\t\t);\n\t\tthrow error;\n\t}\n}\n\nfunction processCommandSourceFn(sourceCount: number) {\n\treturn (ctx: Parameters<NodeFn>[0]) => {\n\t\tfor (let i = 0; i < sourceCount; i += 1) {\n\t\t\tfor (const command of depBatch(ctx, i) ?? []) {\n\t\t\t\tctx.down([[\"DATA\", command as ProcessCommand<unknown>]]);\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction processRuntimeDraft<TState>(\n\tstate: ProcessRuntimeState<TState>,\n): ProcessRuntimeState<TState> {\n\treturn {\n\t\teventSeq: state.eventSeq,\n\t\teffectSeq: state.effectSeq,\n\t\tcommandCount: state.commandCount,\n\t\terrorCount: state.errorCount,\n\t\tauditSeq: state.auditSeq,\n\t\tseenEventIds: [...state.seenEventIds],\n\t\tseenEffectIds: [...state.seenEffectIds],\n\t\tstate: state.state,\n\t};\n}\n\nfunction reduceProcessCommandFact<TState>(\n\traw: unknown,\n\tstate: ProcessRuntimeState<TState>,\n\treduce: ProcessReducer<unknown, TState, unknown, unknown>,\n\tnow: () => number,\n\temit: (fact: ProcessRuntimeFact<TState, unknown, unknown>) => void,\n): ProcessRuntimeState<TState> {\n\tconst draft = processRuntimeDraft(state);\n\tdraft.commandCount += 1;\n\tconst parsed = parseProcessCommand(raw);\n\tif (typeof parsed === \"string\") {\n\t\temitProcessFailure(draft, emit, raw, undefined, \"malformed-command\", parsed);\n\t\treturn draft;\n\t}\n\tconst command = parsed as ProcessCommand<unknown>;\n\tlet reduction: ProcessReduction<TState, unknown, unknown>;\n\tconst reducerState = cloneProcessState(state.state);\n\tif (!reducerState.ok) {\n\t\temitProcessFailure(draft, emit, command, command, \"malformed-state\", reducerState.message);\n\t\treturn draft;\n\t}\n\ttry {\n\t\treduction = reduce(command, reducerState.value);\n\t} catch (error) {\n\t\trethrowGraphRuntimeInvariant(error);\n\t\temitProcessFailure(draft, emit, command, command, \"reducer-threw\", errorMessage(error));\n\t\treturn draft;\n\t}\n\tif (!isObjectRecord(reduction) || !(\"state\" in reduction)) {\n\t\temitProcessFailure(\n\t\t\tdraft,\n\t\t\temit,\n\t\t\tcommand,\n\t\t\tcommand,\n\t\t\t\"malformed-state\",\n\t\t\t\"processBundle: reducer must return { state, events?, effects? }\",\n\t\t);\n\t\treturn draft;\n\t}\n\tif (reduction.state === undefined) {\n\t\temitProcessFailure(\n\t\t\tdraft,\n\t\t\temit,\n\t\t\tcommand,\n\t\t\tcommand,\n\t\t\t\"malformed-state\",\n\t\t\t\"processBundle: reducer state must not be undefined\",\n\t\t);\n\t\treturn draft;\n\t}\n\tconst privateState = cloneProcessState(reduction.state);\n\tif (!privateState.ok) {\n\t\temitProcessFailure(draft, emit, command, command, \"malformed-state\", privateState.message);\n\t\treturn draft;\n\t}\n\tconst visibleState = cloneProcessState(privateState.value);\n\tif (!visibleState.ok) {\n\t\temitProcessFailure(draft, emit, command, command, \"malformed-state\", visibleState.message);\n\t\treturn draft;\n\t}\n\tconst preparedEvents = prepareProcessEvents(command, draft, reduction.events ?? []);\n\tif (typeof preparedEvents === \"string\") {\n\t\temitProcessFailure(draft, emit, command, command, \"malformed-event\", preparedEvents);\n\t\treturn draft;\n\t}\n\tconst preparedEffects = prepareProcessEffects(command, draft, reduction.effects ?? []);\n\tif (typeof preparedEffects === \"string\") {\n\t\temitProcessFailure(draft, emit, command, command, \"malformed-effect\", preparedEffects);\n\t\treturn draft;\n\t}\n\tconst timestampMs = readTimestampMs(now);\n\tif (typeof timestampMs === \"string\") {\n\t\temitProcessFailure(draft, emit, command, command, \"clock-threw\", timestampMs);\n\t\treturn draft;\n\t}\n\tdraft.state = privateState.value;\n\temit({ kind: \"state\", state: visibleState.value, cursor: processCursorOf(draft) });\n\tconst events: ProcessEvent<unknown>[] = [];\n\tfor (const eventDraft of preparedEvents) {\n\t\tdraft.eventSeq += 1;\n\t\tdraft.seenEventIds.push(eventDraft.id);\n\t\tconst event: ProcessEvent<unknown> = {\n\t\t\tid: eventDraft.id,\n\t\t\ttype: eventDraft.type,\n\t\t\tseq: draft.eventSeq,\n\t\t\tcursor: draft.eventSeq,\n\t\t\tcommandId: command.id,\n\t\t\tcommandType: command.type,\n\t\t\tpayload: eventDraft.payload,\n\t\t\ttimestampMs,\n\t\t\t...(eventDraft.processId === undefined ? {} : { processId: eventDraft.processId }),\n\t\t\t...(eventDraft.correlationId === undefined\n\t\t\t\t? {}\n\t\t\t\t: { correlationId: eventDraft.correlationId }),\n\t\t\t...(eventDraft.causationId === undefined ? {} : { causationId: eventDraft.causationId }),\n\t\t\t...(eventDraft.metadata === undefined ? {} : { metadata: eventDraft.metadata }),\n\t\t};\n\t\tevents.push(event);\n\t\temit({ kind: \"event\", event });\n\t}\n\tconst effects: ProcessEffectRequest<unknown>[] = [];\n\tfor (const effectDraft of preparedEffects) {\n\t\tdraft.effectSeq += 1;\n\t\tdraft.seenEffectIds.push(effectDraft.id);\n\t\tconst effect: ProcessEffectRequest<unknown> = {\n\t\t\tid: effectDraft.id,\n\t\t\ttype: effectDraft.type,\n\t\t\tseq: draft.effectSeq,\n\t\t\tcursor: draft.effectSeq,\n\t\t\tcommandId: command.id,\n\t\t\tcommandType: command.type,\n\t\t\tpayload: effectDraft.payload,\n\t\t\ttimestampMs,\n\t\t\t...(effectDraft.processId === undefined ? {} : { processId: effectDraft.processId }),\n\t\t\t...(effectDraft.correlationId === undefined\n\t\t\t\t? {}\n\t\t\t\t: { correlationId: effectDraft.correlationId }),\n\t\t\t...(effectDraft.causationId === undefined ? {} : { causationId: effectDraft.causationId }),\n\t\t\t...(effectDraft.metadata === undefined ? {} : { metadata: effectDraft.metadata }),\n\t\t};\n\t\teffects.push(effect);\n\t\temit({ kind: \"effect-request\", effect });\n\t}\n\temitProcessStatus(draft, emit, command, \"accepted\", events.length, effects.length);\n\temitProcessAudit(draft, emit, command, \"success\", events, effects, undefined, undefined);\n\temit({ kind: \"cursor\", cursor: processCursorOf(draft) });\n\treturn draft;\n}\n\nfunction processProjection<TOut, TState, TEvent, TEffect>(\n\tgraph: Graph | TopologyGroup,\n\truntime: Node<ProcessRuntimeFact<TState, TEvent, TEffect>>,\n\tname: string,\n\tfactory: string,\n\tselect: (fact: ProcessRuntimeFact<TState, TEvent, TEffect>) => TOut | undefined,\n): Node<TOut> {\n\treturn graph.node<TOut>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst selected = select(raw as ProcessRuntimeFact<TState, TEvent, TEffect>);\n\t\t\t\tif (selected !== undefined) ctx.down([[\"DATA\", selected]]);\n\t\t\t}\n\t\t},\n\t\t{ name, factory, completeWhenDepsComplete: false, errorWhenDepsError: false },\n\t);\n}\n\nfunction parseProcessCommand(value: unknown): ProcessCommand<unknown> | string {\n\tif (!isObjectRecord(value)) return \"processBundle: command fact must be an object\";\n\tif (typeof value.id !== \"string\" || value.id.length === 0) {\n\t\treturn \"processBundle: command id must be a non-empty string\";\n\t}\n\tif (typeof value.type !== \"string\" || value.type.length === 0) {\n\t\treturn \"processBundle: command type must be a non-empty string\";\n\t}\n\treturn {\n\t\tid: value.id,\n\t\ttype: value.type,\n\t\tpayload: value.payload,\n\t\t...(typeof value.processId === \"string\" ? { processId: value.processId } : {}),\n\t\t...(typeof value.correlationId === \"string\" ? { correlationId: value.correlationId } : {}),\n\t\t...(typeof value.causationId === \"string\" ? { causationId: value.causationId } : {}),\n\t\t...(isObjectRecord(value.metadata) ? { metadata: value.metadata } : {}),\n\t};\n}\n\nfunction prepareProcessEvents(\n\tcommand: ProcessCommand<unknown>,\n\tstate: ProcessRuntimeState<unknown>,\n\tdrafts: readonly ProcessEventDraft<unknown>[],\n): Array<ProcessEventDraft<unknown> & { readonly id: string }> | string {\n\tif (!Array.isArray(drafts)) return \"processBundle: events must be an array\";\n\tconst seen = new Set<string>();\n\tconst out: Array<ProcessEventDraft<unknown> & { readonly id: string }> = [];\n\tfor (let i = 0; i < drafts.length; i += 1) {\n\t\tconst draft = drafts[i];\n\t\tif (!isObjectRecord(draft) || typeof draft.type !== \"string\" || draft.type.length === 0) {\n\t\t\treturn \"processBundle: event draft must have a non-empty type\";\n\t\t}\n\t\tconst id =\n\t\t\ttypeof draft.id === \"string\" && draft.id.length > 0\n\t\t\t\t? draft.id\n\t\t\t\t: `${command.id}:event:${state.eventSeq + i + 1}`;\n\t\tif (seen.has(id)) return `processBundle: duplicate event '${id}'`;\n\t\tif (state.seenEventIds.includes(id)) return `processBundle: duplicate event '${id}'`;\n\t\tseen.add(id);\n\t\tout.push({\n\t\t\tid,\n\t\t\ttype: draft.type,\n\t\t\tpayload: draft.payload,\n\t\t\t...(typeof draft.processId === \"string\" ? { processId: draft.processId } : {}),\n\t\t\t...(typeof draft.correlationId === \"string\" ? { correlationId: draft.correlationId } : {}),\n\t\t\t...(typeof draft.causationId === \"string\" ? { causationId: draft.causationId } : {}),\n\t\t\t...(isObjectRecord(draft.metadata) ? { metadata: draft.metadata } : {}),\n\t\t});\n\t}\n\treturn out;\n}\n\nfunction prepareProcessEffects(\n\tcommand: ProcessCommand<unknown>,\n\tstate: ProcessRuntimeState<unknown>,\n\tdrafts: readonly ProcessEffectRequestDraft<unknown>[],\n): Array<ProcessEffectRequestDraft<unknown> & { readonly id: string }> | string {\n\tif (!Array.isArray(drafts)) return \"processBundle: effects must be an array\";\n\tconst seen = new Set<string>();\n\tconst out: Array<ProcessEffectRequestDraft<unknown> & { readonly id: string }> = [];\n\tfor (let i = 0; i < drafts.length; i += 1) {\n\t\tconst draft = drafts[i];\n\t\tif (!isObjectRecord(draft) || typeof draft.type !== \"string\" || draft.type.length === 0) {\n\t\t\treturn \"processBundle: effect draft must have a non-empty type\";\n\t\t}\n\t\tconst id =\n\t\t\ttypeof draft.id === \"string\" && draft.id.length > 0\n\t\t\t\t? draft.id\n\t\t\t\t: `${command.id}:effect:${state.effectSeq + i + 1}`;\n\t\tif (seen.has(id)) return `processBundle: duplicate effect '${id}'`;\n\t\tif (state.seenEffectIds.includes(id)) return `processBundle: duplicate effect '${id}'`;\n\t\tseen.add(id);\n\t\tout.push({\n\t\t\tid,\n\t\t\ttype: draft.type,\n\t\t\tpayload: draft.payload,\n\t\t\t...(typeof draft.processId === \"string\" ? { processId: draft.processId } : {}),\n\t\t\t...(typeof draft.correlationId === \"string\" ? { correlationId: draft.correlationId } : {}),\n\t\t\t...(typeof draft.causationId === \"string\" ? { causationId: draft.causationId } : {}),\n\t\t\t...(isObjectRecord(draft.metadata) ? { metadata: draft.metadata } : {}),\n\t\t});\n\t}\n\treturn out;\n}\n\nfunction emitProcessFailure<TState>(\n\tstate: ProcessRuntimeState<TState>,\n\temit: (fact: ProcessRuntimeFact<TState, unknown, unknown>) => void,\n\traw: unknown,\n\tcommand: ProcessCommand<unknown> | undefined,\n\tcode: ProcessErrorCode,\n\tmessage: string,\n): void {\n\tstate.errorCount += 1;\n\tconst cursor = processCursorOf(state);\n\tconst error: ProcessError = {\n\t\tcode,\n\t\tmessage,\n\t\tcommand: raw,\n\t\t...(command === undefined ? {} : { commandId: command.id, commandType: command.type }),\n\t\tcursor,\n\t};\n\temit({ kind: \"error\", error });\n\temitProcessStatus(state, emit, command, \"rejected\", 0, 0, code);\n\temitProcessAudit(state, emit, command, \"failure\", [], [], code, message);\n\temit({ kind: \"cursor\", cursor: processCursorOf(state) });\n}\n\nfunction emitProcessStatus<TState>(\n\tstate: ProcessRuntimeState<TState>,\n\temit: (fact: ProcessRuntimeFact<TState, unknown, unknown>) => void,\n\tcommand: ProcessCommand<unknown> | undefined,\n\tstatusState: ProcessStatus[\"state\"],\n\teventCount: number,\n\teffectCount: number,\n\terrorCode?: ProcessErrorCode,\n): void {\n\temit({\n\t\tkind: \"status\",\n\t\tstatus: {\n\t\t\tstate: statusState,\n\t\t\t...(command === undefined ? {} : { commandId: command.id, commandType: command.type }),\n\t\t\teventCount,\n\t\t\teffectCount,\n\t\t\t...(errorCode === undefined ? {} : { errorCode }),\n\t\t\tcursor: processCursorOf(state),\n\t\t},\n\t});\n}\n\nfunction emitProcessAudit<TState>(\n\tstate: ProcessRuntimeState<TState>,\n\temit: (fact: ProcessRuntimeFact<TState, unknown, unknown>) => void,\n\tcommand: ProcessCommand<unknown> | undefined,\n\toutcome: ProcessAuditRecord[\"outcome\"],\n\tevents: readonly ProcessEvent<unknown>[],\n\teffects: readonly ProcessEffectRequest<unknown>[],\n\terrorCode: ProcessErrorCode | undefined,\n\terrorMessage: string | undefined,\n): void {\n\tstate.auditSeq += 1;\n\temit({\n\t\tkind: \"audit\",\n\t\taudit: {\n\t\t\tseq: state.auditSeq,\n\t\t\t...(command === undefined ? {} : { commandId: command.id, commandType: command.type }),\n\t\t\toutcome,\n\t\t\teventIds: events.map((event) => event.id),\n\t\t\teventTypes: events.map((event) => event.type),\n\t\t\teffectIds: effects.map((effect) => effect.id),\n\t\t\teffectTypes: effects.map((effect) => effect.type),\n\t\t\t...(errorCode === undefined ? {} : { errorCode }),\n\t\t\t...(errorMessage === undefined ? {} : { errorMessage }),\n\t\t\tcursor: processCursorOf(state),\n\t\t},\n\t});\n}\n\nfunction processCursorOf(state: ProcessRuntimeState<unknown>): ProcessCursor {\n\treturn {\n\t\teventSeq: state.eventSeq,\n\t\teffectSeq: state.effectSeq,\n\t\tcommandCount: state.commandCount,\n\t\terrorCount: state.errorCount,\n\t\tauditSeq: state.auditSeq,\n\t};\n}\n\ntype CloneProcessStateResult<TState> =\n\t| { readonly ok: true; readonly value: TState }\n\t| { readonly ok: false; readonly message: string };\n\nfunction cloneProcessState<TState>(state: TState): CloneProcessStateResult<TState> {\n\tif (typeof state !== \"object\" || state === null) return { ok: true, value: state };\n\ttry {\n\t\tif (typeof globalThis.structuredClone === \"function\") {\n\t\t\treturn { ok: true, value: globalThis.structuredClone(state) as TState };\n\t\t}\n\t\treturn { ok: true, value: JSON.parse(JSON.stringify(state)) as TState };\n\t} catch (error) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tmessage: `processBundle: state must be cloneable before reducer execution (${errorMessage(error)})`,\n\t\t};\n\t}\n}\n\nfunction readTimestampMs(now: () => number): number | string {\n\ttry {\n\t\tconst timestampMs = now();\n\t\tif (!Number.isFinite(timestampMs)) return \"processBundle: now() must return a finite number\";\n\t\treturn timestampMs;\n\t} catch (error) {\n\t\treturn errorMessage(error);\n\t}\n}\n\nfunction rethrowGraphRuntimeInvariant(error: unknown): void {\n\tconst message = errorMessage(error);\n\tif (\n\t\tmessage.includes(\"R-reentrancy\") ||\n\t\tmessage.includes(\"R-rewire\") ||\n\t\tmessage.includes(\"R-graph-domain\") ||\n\t\tmessage.includes(\"D37\") ||\n\t\tmessage.includes(\"D22\") ||\n\t\tmessage.includes(\"different graph\") ||\n\t\tmessage.includes(\"cross-graph\") ||\n\t\tmessage.includes(\"wire bridge\") ||\n\t\tmessage.includes(\"mid-fn topology mutation\") ||\n\t\tmessage.includes(\"reentrant dep mutation\") ||\n\t\tmessage.includes(\"feedback cycle\")\n\t) {\n\t\tthrow error;\n\t}\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuWA,IAAM,wBAAwB,oBAAI,QAGhC;AAEK,SAAS,kBACf,OACA,QACA,OAAgD,CAAC,GAC7B;AACpB,QAAM,SAAS,KAAK,UAAU,YAAY;AAC1C,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,SAAS,MAAM;AAAA,IACpB,CAAC,MAAM;AAAA,IACP,CAAC,QAAQ;AACR,UAAI,OACH,IAAI,MAAM,IAAiB,KAC1B,EAAE,OAAO,QAAQ,SAAS,GAAG,aAAa,OAAO,YAAY;AAC/D,iBAAW,OAAO,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG;AACzC,cAAM,QAAQ;AACd,YAAI,MAAM,SAAS,WAAW;AAC7B,iBAAO,EAAE,OAAO,WAAW,SAAS,MAAM,SAAS,aAAa,OAAO,YAAY;AAAA,QACpF,WAAW,MAAM,SAAS,SAAS;AAClC,iBAAO;AAAA,YACN,OAAO;AAAA,YACP,SAAS,MAAM;AAAA,YACf,aAAa,OAAO;AAAA,YACpB,SAAS,MAAM;AAAA,UAChB;AAAA,QACD,WAAW,MAAM,SAAS,WAAW;AACpC,iBAAO;AAAA,YACN,OAAO;AAAA,YACP,SAAS,M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KAAK;AAC3E;AAEA,SAAS,aAAa,OAAwB;AAC7C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC7D;","names":["allowed","status","state","errorMessage"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/orchestration/messaging.ts
21
+ var messaging_exports = {};
22
+ __export(messaging_exports, {
23
+ orchestrationMessageAckCommands: () => orchestrationMessageAckCommands,
24
+ orchestrationMessageCommand: () => orchestrationMessageCommand,
25
+ orchestrationMessagingRecipe: () => orchestrationMessagingRecipe,
26
+ processEventOutboxCommands: () => processEventOutboxCommands
27
+ });
28
+ module.exports = __toCommonJS(messaging_exports);
29
+
30
+ // src/protocol/messages.ts
31
+ var SENTINEL = void 0;
32
+
33
+ // src/ctx/types.ts
34
+ function depWaves(ctx, depIndex) {
35
+ return ctx.waveData[depIndex] ?? [];
36
+ }
37
+ function depBatch(ctx, depIndex) {
38
+ const waves = depWaves(ctx, depIndex);
39
+ if (waves.length === 0) return null;
40
+ const flattened = waves.flat().filter((v) => v !== SENTINEL);
41
+ return flattened.length === 0 ? [] : flattened;
42
+ }
43
+
44
+ // src/orchestration/messaging.ts
45
+ function orchestrationMessagingRecipe(graph, opts) {
46
+ const name = opts.name ?? "orchestrationMessaging";
47
+ const runtime = graph.node(
48
+ [opts.deliveries],
49
+ (ctx) => {
50
+ for (const raw of depBatch(ctx, 0) ?? []) {
51
+ const page = raw;
52
+ for (const message of page.messages) {
53
+ const delivery = messageDelivery(page, message);
54
+ const command = orchestrationMessageCommand(message, delivery, opts.policy);
55
+ if (command === void 0) {
56
+ ctx.down([["DATA", { kind: "issue", issue: messageIssue(message, delivery) }]]);
57
+ } else {
58
+ ctx.down([["DATA", { kind: "command", command }]]);
59
+ }
60
+ }
61
+ }
62
+ },
63
+ {
64
+ name: `${name}/runtime`,
65
+ factory: "orchestrationMessagingRuntime",
66
+ partial: true,
67
+ completeWhenDepsComplete: false,
68
+ errorWhenDepsError: false
69
+ }
70
+ );
71
+ const issues = project(
72
+ graph,
73
+ runtime,
74
+ `${name}/issues`,
75
+ "orchestrationMessagingIssues",
76
+ (fact) => fact.kind === "issue" ? fact.issue : void 0
77
+ );
78
+ const commands = project(
79
+ graph,
80
+ runtime,
81
+ `${name}/commands`,
82
+ "orchestrationMessagingCommands",
83
+ (fact) => fact.kind === "command" ? fact.command : void 0
84
+ );
85
+ return {
86
+ commands,
87
+ ackCommands: orchestrationMessageAckCommands(graph, {
88
+ name: `${name}/ackCommands`,
89
+ commands,
90
+ status: opts.status,
91
+ issues,
92
+ ackRejected: opts.policy?.ackRejected ?? true
93
+ }),
94
+ ...opts.events === void 0 || opts.policy?.outboxTopic === void 0 ? {} : {
95
+ outboxCommands: processEventOutboxCommands(graph, opts.events, opts.policy.outboxTopic, {
96
+ name: `${name}/outboxCommands`
97
+ })
98
+ },
99
+ issues
100
+ };
101
+ }
102
+ function orchestrationMessageCommand(message, delivery, policy) {
103
+ const mapped = policy?.command?.(message, delivery);
104
+ if (mapped !== void 0) return commandWithDelivery(mapped, delivery);
105
+ if (!isObjectRecord(message.payload)) return void 0;
106
+ const id = stringField(message.payload, "id") ?? delivery.commandId;
107
+ const type = stringField(message.payload, "type");
108
+ if (type === void 0) return void 0;
109
+ return commandWithDelivery(
110
+ {
111
+ id,
112
+ type,
113
+ payload: message.payload.payload,
114
+ processId: stringField(message.payload, "processId"),
115
+ correlationId: stringField(message.payload, "correlationId"),
116
+ causationId: stringField(message.payload, "causationId"),
117
+ metadata: {
118
+ ...objectField(message.payload, "metadata") ?? {}
119
+ }
120
+ },
121
+ delivery
122
+ );
123
+ }
124
+ function orchestrationMessageAckCommands(graph, opts) {
125
+ return graph.node(
126
+ opts.issues === void 0 ? [opts.commands, opts.status] : [opts.commands, opts.status, opts.issues],
127
+ (ctx) => {
128
+ const deliveries = ctx.state.get() ?? /* @__PURE__ */ new Map();
129
+ for (const raw of depBatch(ctx, 0) ?? []) {
130
+ const command = raw;
131
+ const delivery = commandDelivery(command);
132
+ if (delivery !== void 0) pushDelivery(deliveries, command.id, delivery);
133
+ }
134
+ for (const raw of depBatch(ctx, 1) ?? []) {
135
+ const status = raw;
136
+ if (status.state === "rejected" && opts.ackRejected === false) continue;
137
+ if (status.commandId === void 0) continue;
138
+ const delivery = shiftDelivery(deliveries, status.commandId);
139
+ if (delivery === void 0) continue;
140
+ ctx.down([
141
+ ["DATA", ackCommand(delivery, ackCommandId("orchestration", delivery, "status"))]
142
+ ]);
143
+ }
144
+ if (opts.issues !== void 0) {
145
+ for (const raw of depBatch(ctx, 2) ?? []) {
146
+ const delivery = issueDelivery(raw);
147
+ if (delivery !== void 0) {
148
+ ctx.down([
149
+ ["DATA", ackCommand(delivery, ackCommandId("orchestration", delivery, "issue"))]
150
+ ]);
151
+ }
152
+ }
153
+ }
154
+ ctx.state.set(deliveries);
155
+ },
156
+ {
157
+ name: opts.name ?? "orchestrationMessaging/ackCommands",
158
+ factory: "orchestrationMessagingAckCommands",
159
+ partial: true,
160
+ completeWhenDepsComplete: false,
161
+ errorWhenDepsError: false
162
+ }
163
+ );
164
+ }
165
+ function processEventOutboxCommands(graph, events, topic, opts = {}) {
166
+ return graph.node(
167
+ [events],
168
+ (ctx) => {
169
+ for (const event of depBatch(ctx, 0) ?? []) {
170
+ const typed = event;
171
+ ctx.down([
172
+ [
173
+ "DATA",
174
+ {
175
+ kind: "publish",
176
+ topic,
177
+ payload: typed,
178
+ key: typed.processId,
179
+ commandId: `${typed.id}:process-outbox`,
180
+ idempotencyKey: typed.id
181
+ }
182
+ ]
183
+ ]);
184
+ }
185
+ },
186
+ {
187
+ name: opts.name ?? "orchestrationMessaging/outboxCommands",
188
+ factory: "orchestrationMessagingOutboxCommands",
189
+ completeWhenDepsComplete: false,
190
+ errorWhenDepsError: false
191
+ }
192
+ );
193
+ }
194
+ function project(graph, runtime, name, factory, pick) {
195
+ return graph.node(
196
+ [runtime],
197
+ (ctx) => {
198
+ for (const fact of depBatch(ctx, 0) ?? []) {
199
+ const value = pick(fact);
200
+ if (value !== void 0) ctx.down([["DATA", value]]);
201
+ }
202
+ },
203
+ { name, factory, partial: true, completeWhenDepsComplete: false, errorWhenDepsError: false }
204
+ );
205
+ }
206
+ function messageIssue(message, delivery) {
207
+ return {
208
+ kind: "issue",
209
+ code: "orchestration-message-lowering-rejected",
210
+ message: "Orchestration messaging recipe could not lower retained message to a command fact",
211
+ severity: "error",
212
+ source: "orchestration.messaging",
213
+ metadata: {
214
+ messageBus: {
215
+ topic: delivery.topic,
216
+ seq: delivery.seq,
217
+ subscriptionId: delivery.subscriptionId,
218
+ commandId: delivery.commandId
219
+ }
220
+ },
221
+ details: message
222
+ };
223
+ }
224
+ function ackCommand(delivery, commandId) {
225
+ return {
226
+ kind: "ack",
227
+ topic: delivery.topic,
228
+ subscriptionId: delivery.subscriptionId,
229
+ seq: delivery.seq,
230
+ commandId
231
+ };
232
+ }
233
+ function ackCommandId(namespace, delivery, reason) {
234
+ return `${namespace}:${delivery.topic}:${delivery.subscriptionId}:${delivery.seq}:${reason}-ack`;
235
+ }
236
+ function commandWithDelivery(command, delivery) {
237
+ return {
238
+ ...command,
239
+ metadata: {
240
+ ...command.metadata ?? {},
241
+ messageBus: delivery
242
+ }
243
+ };
244
+ }
245
+ function messageDelivery(page, message) {
246
+ return {
247
+ topic: page.topic,
248
+ seq: message.seq,
249
+ subscriptionId: page.subscriptionId,
250
+ commandId: isObjectRecord(message.payload) && typeof message.payload.id === "string" ? message.payload.id : message.commandId ?? `${page.topic}:${message.seq}`
251
+ };
252
+ }
253
+ function pushDelivery(deliveries, commandId, delivery) {
254
+ const queue = deliveries.get(commandId) ?? [];
255
+ deliveries.set(commandId, [...queue, delivery]);
256
+ }
257
+ function shiftDelivery(deliveries, commandId) {
258
+ const queue = deliveries.get(commandId);
259
+ if (queue === void 0 || queue.length === 0) return void 0;
260
+ const [first, ...rest] = queue;
261
+ if (rest.length === 0) deliveries.delete(commandId);
262
+ else deliveries.set(commandId, rest);
263
+ return first;
264
+ }
265
+ function issueDelivery(issue) {
266
+ const metadata = isObjectRecord(issue.metadata) ? issue.metadata : void 0;
267
+ const messageBus = isObjectRecord(metadata?.messageBus) ? metadata.messageBus : void 0;
268
+ if (messageBus === void 0) return void 0;
269
+ if (typeof messageBus.topic !== "string" || typeof messageBus.seq !== "number") return void 0;
270
+ if (typeof messageBus.subscriptionId !== "string") return void 0;
271
+ if (typeof messageBus.commandId !== "string") return void 0;
272
+ return {
273
+ topic: messageBus.topic,
274
+ seq: messageBus.seq,
275
+ subscriptionId: messageBus.subscriptionId,
276
+ commandId: messageBus.commandId
277
+ };
278
+ }
279
+ function commandDelivery(command) {
280
+ const metadata = isObjectRecord(command.metadata) ? command.metadata : void 0;
281
+ const messageBus = isObjectRecord(metadata?.messageBus) ? metadata.messageBus : void 0;
282
+ if (messageBus === void 0) return void 0;
283
+ return messageBusDelivery(messageBus);
284
+ }
285
+ function messageBusDelivery(messageBus) {
286
+ if (typeof messageBus.topic !== "string" || typeof messageBus.seq !== "number") return void 0;
287
+ if (typeof messageBus.subscriptionId !== "string") return void 0;
288
+ const commandId = typeof messageBus.commandId === "string" ? messageBus.commandId : "";
289
+ return {
290
+ topic: messageBus.topic,
291
+ seq: messageBus.seq,
292
+ subscriptionId: messageBus.subscriptionId,
293
+ commandId
294
+ };
295
+ }
296
+ function stringField(record, key) {
297
+ const value = record[key];
298
+ return typeof value === "string" && value.length > 0 ? value : void 0;
299
+ }
300
+ function objectField(record, key) {
301
+ const value = record[key];
302
+ return isObjectRecord(value) ? value : void 0;
303
+ }
304
+ function isObjectRecord(value) {
305
+ return typeof value === "object" && value !== null;
306
+ }
307
+ // Annotate the CommonJS export names for ESM import in node:
308
+ 0 && (module.exports = {
309
+ orchestrationMessageAckCommands,
310
+ orchestrationMessageCommand,
311
+ orchestrationMessagingRecipe,
312
+ processEventOutboxCommands
313
+ });
314
+ //# sourceMappingURL=messaging.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/orchestration/messaging.ts","../../src/protocol/messages.ts","../../src/ctx/types.ts"],"sourcesContent":["/**\n * Optional orchestration-over-messageBus recipe (D349/D351/D353).\n *\n * Ack commands are graph-derived from visible ProcessBundle accepted/rejected\n * material; retained delivery receipt is never an ack.\n */\n\nimport { depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type {\n\tMessageBusAvailablePage,\n\tMessageBusCommand,\n\tMessageBusMessage,\n} from \"../messaging/index.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { ProcessCommand, ProcessEvent, ProcessStatus } from \"../orchestration/index.js\";\n\nexport interface OrchestrationMessagingPolicy<TPayload = unknown, TCommand = unknown> {\n\treadonly command?: (\n\t\tmessage: MessageBusMessage<TPayload>,\n\t\tdelivery: MessageBusDelivery,\n\t) => ProcessCommand<TCommand> | undefined;\n\treadonly ackRejected?: boolean;\n\treadonly outboxTopic?: string;\n}\n\nexport interface OrchestrationMessagingRecipeOptions<\n\tTPayload = unknown,\n\tTCommand = unknown,\n\tTEvent = unknown,\n> {\n\treadonly name?: string;\n\treadonly deliveries: Node<MessageBusAvailablePage<TPayload>>;\n\treadonly status: Node<ProcessStatus>;\n\treadonly events?: Node<ProcessEvent<TEvent>>;\n\treadonly policy?: OrchestrationMessagingPolicy<TPayload, TCommand>;\n}\n\nexport interface OrchestrationMessagingRecipeBundle<TCommand = unknown> {\n\treadonly commands: Node<ProcessCommand<TCommand>>;\n\treadonly ackCommands: Node<MessageBusCommand>;\n\treadonly outboxCommands?: Node<MessageBusCommand>;\n\treadonly issues: Node<DataIssue>;\n}\n\ntype OrchestrationMessagingFact<TCommand> =\n\t| { readonly kind: \"command\"; readonly command: ProcessCommand<TCommand> }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue };\n\nexport interface MessageBusDelivery {\n\treadonly topic: string;\n\treadonly seq: number;\n\treadonly subscriptionId: string;\n\treadonly commandId: string;\n}\n\n/** Build the optional D349/D351 orchestration messaging recipe. */\nexport function orchestrationMessagingRecipe<\n\tTPayload = unknown,\n\tTCommand = unknown,\n\tTEvent = unknown,\n>(\n\tgraph: Graph,\n\topts: OrchestrationMessagingRecipeOptions<TPayload, TCommand, TEvent>,\n): OrchestrationMessagingRecipeBundle<TCommand> {\n\tconst name = opts.name ?? \"orchestrationMessaging\";\n\tconst runtime = graph.node<OrchestrationMessagingFact<TCommand>>(\n\t\t[opts.deliveries],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst page = raw as MessageBusAvailablePage<TPayload>;\n\t\t\t\tfor (const message of page.messages) {\n\t\t\t\t\tconst delivery = messageDelivery(page, message);\n\t\t\t\t\tconst command = orchestrationMessageCommand(message, delivery, opts.policy);\n\t\t\t\t\tif (command === undefined) {\n\t\t\t\t\t\tctx.down([[\"DATA\", { kind: \"issue\", issue: messageIssue(message, delivery) }]]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tctx.down([[\"DATA\", { kind: \"command\", command }]]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"orchestrationMessagingRuntime\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst issues = project(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/issues`,\n\t\t\"orchestrationMessagingIssues\",\n\t\t(fact) => (fact.kind === \"issue\" ? fact.issue : undefined),\n\t);\n\tconst commands = project(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/commands`,\n\t\t\"orchestrationMessagingCommands\",\n\t\t(fact) => (fact.kind === \"command\" ? fact.command : undefined),\n\t);\n\treturn {\n\t\tcommands,\n\t\tackCommands: orchestrationMessageAckCommands(graph, {\n\t\t\tname: `${name}/ackCommands`,\n\t\t\tcommands,\n\t\t\tstatus: opts.status,\n\t\t\tissues,\n\t\t\tackRejected: opts.policy?.ackRejected ?? true,\n\t\t}),\n\t\t...(opts.events === undefined || opts.policy?.outboxTopic === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\toutboxCommands: processEventOutboxCommands(graph, opts.events, opts.policy.outboxTopic, {\n\t\t\t\t\t\tname: `${name}/outboxCommands`,\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\tissues,\n\t};\n}\n\nexport function orchestrationMessageCommand<TPayload = unknown, TCommand = unknown>(\n\tmessage: MessageBusMessage<TPayload>,\n\tdelivery: MessageBusDelivery,\n\tpolicy?: OrchestrationMessagingPolicy<TPayload, TCommand>,\n): ProcessCommand<TCommand> | undefined {\n\tconst mapped = policy?.command?.(message, delivery);\n\tif (mapped !== undefined) return commandWithDelivery(mapped, delivery);\n\tif (!isObjectRecord(message.payload)) return undefined;\n\tconst id = stringField(message.payload, \"id\") ?? delivery.commandId;\n\tconst type = stringField(message.payload, \"type\");\n\tif (type === undefined) return undefined;\n\treturn commandWithDelivery(\n\t\t{\n\t\t\tid,\n\t\t\ttype,\n\t\t\tpayload: message.payload.payload as TCommand,\n\t\t\tprocessId: stringField(message.payload, \"processId\"),\n\t\t\tcorrelationId: stringField(message.payload, \"correlationId\"),\n\t\t\tcausationId: stringField(message.payload, \"causationId\"),\n\t\t\tmetadata: {\n\t\t\t\t...(objectField(message.payload, \"metadata\") ?? {}),\n\t\t\t},\n\t\t},\n\t\tdelivery,\n\t);\n}\n\nexport function orchestrationMessageAckCommands(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly commands: Node<ProcessCommand>;\n\t\treadonly status: Node<ProcessStatus>;\n\t\treadonly issues?: Node<DataIssue>;\n\t\treadonly ackRejected?: boolean;\n\t},\n): Node<MessageBusCommand> {\n\treturn graph.node<MessageBusCommand>(\n\t\topts.issues === undefined\n\t\t\t? [opts.commands, opts.status]\n\t\t\t: [opts.commands, opts.status, opts.issues],\n\t\t(ctx) => {\n\t\t\tconst deliveries =\n\t\t\t\tctx.state.get<Map<string, MessageBusDelivery[]>>() ??\n\t\t\t\tnew Map<string, MessageBusDelivery[]>();\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst command = raw as ProcessCommand;\n\t\t\t\tconst delivery = commandDelivery(command);\n\t\t\t\tif (delivery !== undefined) pushDelivery(deliveries, command.id, delivery);\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\tconst status = raw as ProcessStatus;\n\t\t\t\tif (status.state === \"rejected\" && opts.ackRejected === false) continue;\n\t\t\t\tif (status.commandId === undefined) continue;\n\t\t\t\tconst delivery = shiftDelivery(deliveries, status.commandId);\n\t\t\t\tif (delivery === undefined) continue;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\"DATA\", ackCommand(delivery, ackCommandId(\"orchestration\", delivery, \"status\"))],\n\t\t\t\t]);\n\t\t\t}\n\t\t\tif (opts.issues !== undefined) {\n\t\t\t\tfor (const raw of depBatch(ctx, 2) ?? []) {\n\t\t\t\t\tconst delivery = issueDelivery(raw as DataIssue);\n\t\t\t\t\tif (delivery !== undefined) {\n\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t[\"DATA\", ackCommand(delivery, ackCommandId(\"orchestration\", delivery, \"issue\"))],\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(deliveries);\n\t\t},\n\t\t{\n\t\t\tname: opts.name ?? \"orchestrationMessaging/ackCommands\",\n\t\t\tfactory: \"orchestrationMessagingAckCommands\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nexport function processEventOutboxCommands<TEvent>(\n\tgraph: Graph,\n\tevents: Node<ProcessEvent<TEvent>>,\n\ttopic: string,\n\topts: { readonly name?: string } = {},\n): Node<MessageBusCommand> {\n\treturn graph.node<MessageBusCommand>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as ProcessEvent<TEvent>;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"publish\",\n\t\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t\tpayload: typed,\n\t\t\t\t\t\t\tkey: typed.processId,\n\t\t\t\t\t\t\tcommandId: `${typed.id}:process-outbox`,\n\t\t\t\t\t\t\tidempotencyKey: typed.id,\n\t\t\t\t\t\t} satisfies MessageBusCommand,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: opts.name ?? \"orchestrationMessaging/outboxCommands\",\n\t\t\tfactory: \"orchestrationMessagingOutboxCommands\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\nfunction project<T, TCommand>(\n\tgraph: Graph,\n\truntime: Node<OrchestrationMessagingFact<TCommand>>,\n\tname: string,\n\tfactory: string,\n\tpick: (fact: OrchestrationMessagingFact<TCommand>) => T | undefined,\n): Node<T> {\n\treturn graph.node<T>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst value = pick(fact as OrchestrationMessagingFact<TCommand>);\n\t\t\t\tif (value !== undefined) ctx.down([[\"DATA\", value]]);\n\t\t\t}\n\t\t},\n\t\t{ name, factory, partial: true, completeWhenDepsComplete: false, errorWhenDepsError: false },\n\t);\n}\n\nfunction messageIssue(message: MessageBusMessage, delivery: MessageBusDelivery): DataIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode: \"orchestration-message-lowering-rejected\",\n\t\tmessage: \"Orchestration messaging recipe could not lower retained message to a command fact\",\n\t\tseverity: \"error\",\n\t\tsource: \"orchestration.messaging\",\n\t\tmetadata: {\n\t\t\tmessageBus: {\n\t\t\t\ttopic: delivery.topic,\n\t\t\t\tseq: delivery.seq,\n\t\t\t\tsubscriptionId: delivery.subscriptionId,\n\t\t\t\tcommandId: delivery.commandId,\n\t\t\t},\n\t\t},\n\t\tdetails: message,\n\t};\n}\n\nfunction ackCommand(delivery: MessageBusDelivery, commandId: string): MessageBusCommand {\n\treturn {\n\t\tkind: \"ack\",\n\t\ttopic: delivery.topic,\n\t\tsubscriptionId: delivery.subscriptionId,\n\t\tseq: delivery.seq,\n\t\tcommandId,\n\t};\n}\n\nfunction ackCommandId(namespace: string, delivery: MessageBusDelivery, reason: string): string {\n\treturn `${namespace}:${delivery.topic}:${delivery.subscriptionId}:${delivery.seq}:${reason}-ack`;\n}\n\nfunction commandWithDelivery<TCommand>(\n\tcommand: ProcessCommand<TCommand>,\n\tdelivery: MessageBusDelivery,\n): ProcessCommand<TCommand> {\n\treturn {\n\t\t...command,\n\t\tmetadata: {\n\t\t\t...(command.metadata ?? {}),\n\t\t\tmessageBus: delivery,\n\t\t},\n\t};\n}\n\nfunction messageDelivery(\n\tpage: MessageBusAvailablePage,\n\tmessage: MessageBusMessage,\n): MessageBusDelivery {\n\treturn {\n\t\ttopic: page.topic,\n\t\tseq: message.seq,\n\t\tsubscriptionId: page.subscriptionId,\n\t\tcommandId:\n\t\t\tisObjectRecord(message.payload) && typeof message.payload.id === \"string\"\n\t\t\t\t? message.payload.id\n\t\t\t\t: (message.commandId ?? `${page.topic}:${message.seq}`),\n\t};\n}\n\nfunction pushDelivery(\n\tdeliveries: Map<string, MessageBusDelivery[]>,\n\tcommandId: string,\n\tdelivery: MessageBusDelivery,\n): void {\n\tconst queue = deliveries.get(commandId) ?? [];\n\tdeliveries.set(commandId, [...queue, delivery]);\n}\n\nfunction shiftDelivery(\n\tdeliveries: Map<string, MessageBusDelivery[]>,\n\tcommandId: string,\n): MessageBusDelivery | undefined {\n\tconst queue = deliveries.get(commandId);\n\tif (queue === undefined || queue.length === 0) return undefined;\n\tconst [first, ...rest] = queue;\n\tif (rest.length === 0) deliveries.delete(commandId);\n\telse deliveries.set(commandId, rest);\n\treturn first;\n}\n\nfunction issueDelivery(issue: DataIssue): MessageBusDelivery | undefined {\n\tconst metadata = isObjectRecord(issue.metadata) ? issue.metadata : undefined;\n\tconst messageBus = isObjectRecord(metadata?.messageBus) ? metadata.messageBus : undefined;\n\tif (messageBus === undefined) return undefined;\n\tif (typeof messageBus.topic !== \"string\" || typeof messageBus.seq !== \"number\") return undefined;\n\tif (typeof messageBus.subscriptionId !== \"string\") return undefined;\n\tif (typeof messageBus.commandId !== \"string\") return undefined;\n\treturn {\n\t\ttopic: messageBus.topic,\n\t\tseq: messageBus.seq,\n\t\tsubscriptionId: messageBus.subscriptionId,\n\t\tcommandId: messageBus.commandId,\n\t};\n}\n\nfunction commandDelivery(command: ProcessCommand): MessageBusDelivery | undefined {\n\tconst metadata = isObjectRecord(command.metadata) ? command.metadata : undefined;\n\tconst messageBus = isObjectRecord(metadata?.messageBus) ? metadata.messageBus : undefined;\n\tif (messageBus === undefined) return undefined;\n\treturn messageBusDelivery(messageBus);\n}\n\nfunction messageBusDelivery(messageBus: Record<string, unknown>): MessageBusDelivery | undefined {\n\tif (typeof messageBus.topic !== \"string\" || typeof messageBus.seq !== \"number\") return undefined;\n\tif (typeof messageBus.subscriptionId !== \"string\") return undefined;\n\tconst commandId = typeof messageBus.commandId === \"string\" ? messageBus.commandId : \"\";\n\treturn {\n\t\ttopic: messageBus.topic,\n\t\tseq: messageBus.seq,\n\t\tsubscriptionId: messageBus.subscriptionId,\n\t\tcommandId,\n\t};\n}\n\nfunction stringField(record: Record<string, unknown>, key: string): string | undefined {\n\tconst value = record[key];\n\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction objectField(\n\trecord: Record<string, unknown>,\n\tkey: string,\n): Record<string, unknown> | undefined {\n\tconst value = record[key];\n\treturn isObjectRecord(value) ? value : undefined;\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n","/**\n * Wave-protocol message types and the tier const table.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-msg-format, R-msg-closed-set, R-tier (D34), R-data-payload, R-sentinel.\n */\n\n/** Opaque pause-lock / pull identifier (R-pause-lockset, R-pull). */\nexport type LockId = string | symbol;\n\n/** Explicit pull demand payload (D269/D272). Params are holder-visible context, never DATA-up. */\nexport interface PullDemand {\n\treadonly pullId: LockId;\n\treadonly params?: unknown;\n}\n\n/**\n * The CLOSED set of 11 message types (R-msg-closed-set / D9 + D269 + START handshake).\n * No open set, no user-defined custom types. Adding a type is a spec change.\n */\nexport type Message =\n\t| readonly [\"START\"]\n\t| readonly [\"DIRTY\"]\n\t| readonly [\"DATA\", unknown]\n\t| readonly [\"RESOLVED\"]\n\t| readonly [\"INVALIDATE\"]\n\t| readonly [\"COMPLETE\"]\n\t| readonly [\"ERROR\", unknown]\n\t| readonly [\"TEARDOWN\"]\n\t| readonly [\"PAUSE\", LockId]\n\t| readonly [\"RESUME\", LockId]\n\t| readonly [\"PULL\", PullDemand];\n\n/** One array of messages delivered in one call = one Wave (R-wave-boundary). */\nexport type Wave = readonly Message[];\n\n/** The message-type tag (the first tuple element). */\nexport type MessageType = Message[0];\n\n/**\n * SENTINEL = absence-of-DATA (R-sentinel / D16). TS representation is `undefined`.\n * Never a valid DATA payload; `null` IS a valid DATA value (domain-level absence).\n */\nexport const SENTINEL = undefined;\n\n/** R-data-payload: ERROR payloads must not collide with terminal metadata shorthand. */\nexport function isInvalidErrorPayload(v: unknown): boolean {\n\treturn v === SENTINEL || typeof v === \"boolean\";\n}\n\n/** R-data-payload / D78: host-language failures that collide with ctx.terminal shorthand become diagnostics. */\nexport function errorPayload(reason: unknown, fallback = \"error without a valid payload\"): unknown {\n\treturn isInvalidErrorPayload(reason) ? new Error(fallback) : reason;\n}\n\nexport const TIER_START = 0;\nexport const TIER_CONTROL = 1;\nexport const TIER_NOTIFICATION = 2;\nexport const TIER_VALUE = 3;\nexport const TIER_SETTLE = 4;\nexport const TIER_TERMINAL = 5;\nexport const TIER_TEARDOWN = 6;\n\n/**\n * Tier const table (R-tier / D34). Tiers below value dispatch immediately; value\n * and above are batch-deferred. This is a compile-time const table (D18), not runtime config.\n */\nconst TIER: Record<MessageType, number> = {\n\tSTART: TIER_START,\n\tPAUSE: TIER_CONTROL,\n\tRESUME: TIER_CONTROL,\n\tPULL: TIER_CONTROL,\n\tDIRTY: TIER_NOTIFICATION,\n\tDATA: TIER_VALUE,\n\tRESOLVED: TIER_VALUE,\n\tINVALIDATE: TIER_SETTLE,\n\tCOMPLETE: TIER_TERMINAL,\n\tERROR: TIER_TERMINAL,\n\tTEARDOWN: TIER_TEARDOWN,\n};\n\nexport function messageTier(t: MessageType): number {\n\treturn TIER[t];\n}\n\n/** Value and above are deferred inside a batch (DATA/RESOLVED/INVALIDATE/terminal/teardown). */\nexport function isDeferredTier(t: MessageType): boolean {\n\treturn TIER[t] >= TIER_VALUE;\n}\n\n/** Value-tier messages (DATA/RESOLVED) occupy the tier-3 slot. */\nexport function isValueTier(t: MessageType): boolean {\n\treturn TIER[t] === TIER_VALUE;\n}\n\n/** The pause buffer holds the settle slice only: value-tier DATA/RESOLVED plus INVALIDATE. */\nexport function isPauseBufferedTier(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier === TIER_VALUE || tier === TIER_SETTLE;\n}\n\n/**\n * A TERMINAL message = tier 5 (COMPLETE | ERROR), R-tier / D34. Detected via the CENTRAL tier\n * table, NOT a per-variant `=== \"COMPLETE\" || === \"ERROR\"` check — so terminal routing stays\n * driven by the one const table (feedback_use_tier_for_signal_routing); discriminate COMPLETE vs\n * ERROR within the tier by the message type only where the handling actually differs.\n */\nexport function isTerminal(t: MessageType): boolean {\n\treturn TIER[t] === TIER_TERMINAL;\n}\n\n/**\n * ctx.up carries control/demand tiers only (R-ctx-up / D269): DIRTY, PAUSE, RESUME, PULL,\n * INVALIDATE, TEARDOWN. DATA/RESOLVED (tier 3) and COMPLETE/ERROR (tier 5) are\n * down-only.\n */\nexport function isUpAllowed(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier !== TIER_VALUE && tier !== TIER_TERMINAL;\n}\n","/**\n * The fn-invocation context and per-dep input shapes.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-fn-contract (D8/D27), R-ctx-state (D23/D29), R-cleanup-hooks (D28), R-ctx-up.\n */\n\nimport type { Dispatcher } from \"../dispatcher/index.js\";\nimport type { EnvironmentDrivers } from \"../graph/environment.js\";\nimport type { Node } from \"../node/node.js\";\nimport { type Message, type PullDemand, SENTINEL, type Wave } from \"../protocol/messages.js\";\n\n/** A downstream sink callback (the only way to connect to a node's output). */\nexport type Sink = (msg: Message, delivery?: DeliveryMeta) => void;\n\n/** Internal delivery metadata used to preserve the upstream `ctx.down(msgs)` wave boundary. */\nexport interface DeliveryMeta {\n\treadonly wave: object;\n\treadonly last: boolean;\n}\n\n/**\n * Internal current-value reader. It is deliberately a symbol-backed implementation detail:\n * raw ctx exposes `waveData` + `terminal`; helpers below derive from that plus this dep cache.\n */\nexport const CTX_DEP_CACHE: unique symbol = Symbol(\"graphrefly.ctx.depCache\");\n\nexport interface CtxDepCache {\n\treadonly latest: readonly unknown[];\n}\n\n/** Internal node-construction binding for graph-local helper-created deps. */\nexport const CTX_NODE_BINDING: unique symbol = Symbol(\"graphrefly.ctx.nodeBinding\");\n\nexport interface CtxNodeBinding {\n\treadonly dispatcher: Dispatcher;\n\tcreate<T>(factory: () => Node<T>): Node<T>;\n}\n\n/** Per-dep wave projections: dep -> waves -> values/SENTINEL markers. */\nexport type WaveData = readonly (readonly (readonly unknown[])[])[];\n\n/** Terminal metadata parallel to `waveData`: false = none, true = COMPLETE, otherwise ERROR payload. */\nexport type TerminalData = readonly unknown[];\n\nexport function isTerminalNone(t: unknown): boolean {\n\treturn t === false || t === undefined;\n}\n\nexport function isTerminalComplete(t: unknown): t is true {\n\treturn t === true;\n}\n\nexport function isTerminalError(t: unknown): boolean {\n\treturn !isTerminalNone(t) && !isTerminalComplete(t);\n}\n\nexport function terminalErrorValue(t: unknown): unknown {\n\treturn isTerminalError(t) ? t : undefined;\n}\n\n/**\n * Per-node private cross-wave state (R-ctx-state / D23,D29). Default fresh-lifecycle\n * wipe; `persist(true)` keeps it across lifecycle transitions.\n */\nexport interface CtxState {\n\tget<S = unknown>(): S | undefined;\n\tset<S = unknown>(v: S): void;\n\tpersist(on?: boolean): void;\n}\n\n/**\n * Deferred SELF-rewire (R-rewire-deferred / D47). A node fn may, DURING its run, request a\n * mutation of its OWN dep set; the request is QUEUED and applied at the committed wave boundary\n * (after the current wave settles / batch commit / final-lock RESUME) as a fresh wave, reusing\n * R-rewire surgical/Option-C semantics (D42). This is the ONLY legal self-triggered rewire — an\n * IMMEDIATE in-fn `node.subscribeDep/unsubscribeDep/replaceDeps` is the D37 mid-fn feedback-cycle ERROR. An\n * added cached dep pushes `[DIRTY,DATA]` on the boundary wave (R-push-subscribe); a removed dep\n * is drained and, if it loses its last subscriber, `_deactivate`s + fires `onDeactivation`\n * (input-side teardown — the basis for higher-order operator cancellation / abortInFlight).\n */\nexport interface RewireNext {\n\t/** Defer subscribing to a dep (paired with the re-supplied fn — positional fn-deps lock, SD-1). */\n\tsubscribeDep(dep: Node<unknown>, fn: NodeFn): void;\n\t/** Defer unsubscribing from a dep (its source is torn down if it loses its last subscriber). */\n\tunsubscribeDep(dep: Node<unknown>, fn: NodeFn): void;\n\t/** Defer replacing the whole dep set (surgical: kept deps untouched, removed drained, added fresh-subscribe). */\n\treplaceDeps(deps: Node<unknown>[], fn: NodeFn): void;\n}\n\n/**\n * The single argument to a node fn: `(ctx) => void` (R-fn-contract / D8). All emission\n * is explicit via `ctx.down`; there is no return-value framing.\n */\nexport interface Ctx {\n\t/**\n\t * Emit upstream toward deps — control tiers only (R-ctx-up). IMMEDIATE. `towardDep` (a dep index)\n\t * routes the wave up ONE declared edge (R-up-routing directed-up); omitted = broadcast up all deps.\n\t * A pull DEMAND is `up([[PULL, { pullId, params }]])` — but for a SELF-demand (demanding a dep\n\t * this fn also reads) use {@link Ctx.upNext} instead, since an immediate demand whose delivery loops back\n\t * re-enters this fn mid-wave (D37 / R-reentrancy).\n\t */\n\tup(msgs: Wave, towardDep?: number): void;\n\t/** Emit downstream toward sinks. */\n\tdown(msgs: Wave): void;\n\t/**\n\t * The single raw dep-value input surface (R-ctx-wave-data / D77): dep -> upstream waves ->\n\t * per-wave DATA payloads and INVALIDATE/SENTINEL markers. `waveData[i] = []` means dep i\n\t * delivered no wave to this invocation; `waveData[i] = [[]]` means RESOLVED-only.\n\t */\n\twaveData: WaveData;\n\t/** Terminal metadata for the same invocation; terminal values never enter `waveData`. */\n\tterminal: TerminalData;\n\tstate: CtxState;\n\t/** Release external resources on deactivation (R-cleanup-hooks). */\n\tonDeactivation(fn: () => void): void;\n\t/** Flush on INVALIDATE (R-cleanup-hooks). */\n\tonInvalidate(fn: () => void): void;\n\t/** Graph-owned environment drivers for source/adapter boundaries (D130/D131). */\n\tenvironment(): EnvironmentDrivers;\n\t/** Holder-visible context for a PULL-caused invocation (D272); absent for ordinary waves. */\n\treadonly pull?: PullDemand;\n\t/**\n\t * Deferred SELF-rewire (R-rewire-deferred / D47) — the substrate affordance higher-order\n\t * operators (switchMap/mergeMap/concatMap/exhaustMap/flatMap) use to grow/shrink their own\n\t * inner-source dep set in response to their own data. Always present; see {@link RewireNext}.\n\t */\n\trewireNext: RewireNext;\n\t/**\n\t * Deferred up — the boundary-deferred form of {@link Ctx.up} (R-up-routing / R-pull / D59). Routes\n\t * `msgs` up from this node at the COMMITTED wave boundary (broadcast, or up the single `towardDep`\n\t * edge), riding the same R-rewire-deferred (D47) drain as {@link RewireNext}. This is the\n\t * SELF-DEMAND path: a consumer issues `ctx.upNext([[PULL, { pullId, params }]])` to demand a pull\n\t * dep it ALSO reads — the cone-routed PULL reaches the pullId-holder, whose delivery loops back as a\n\t * FRESH wave (not a mid-fn re-entry → no D37). The consumer accepts one-wave latency (the\n\t * HTTP-request model). No node reference needed: the author writes the pullId verbatim.\n\t */\n\tupNext(msgs: Wave, towardDep?: number): void;\n\t/**\n\t * Read a dep's latest value by index (dynamicNode only, R-dynamic-node / D35).\n\t * Present only on dynamicNode fns; all declared deps still participate in wave\n\t * tracking. Under D49/R-resolved-undirty an unread dep's change still fires the fn,\n\t * which re-emits its (unchanged) output as a DATA occurrence — there is NO equals-\n\t * absorption; pair with distinctUntilChanged to suppress unchanged re-emits (opt-in).\n\t */\n\ttrack?(depIndex: number): unknown;\n\t[CTX_DEP_CACHE]?: CtxDepCache;\n\t[CTX_NODE_BINDING]?: CtxNodeBinding;\n}\n\n/** A node fn (R-fn-contract). Registered in a dispatcher pool, indexed by Handle. */\nexport type NodeFn = (ctx: Ctx) => void;\n\n/** Number of declared dep slots visible in this invocation. */\nexport function depCount(ctx: Ctx): number {\n\treturn ctx.waveData.length;\n}\n\n/** DATA/SENTINEL projection batches delivered by one dep in this invocation. */\nexport function depWaves(ctx: Ctx, depIndex: number): readonly (readonly unknown[])[] {\n\treturn ctx.waveData[depIndex] ?? [];\n}\n\n/** Flattened DATA projection for old event-counting operator bodies; null = no wave. */\nexport function depBatch(ctx: Ctx, depIndex: number): readonly unknown[] | null {\n\tconst waves = depWaves(ctx, depIndex);\n\tif (waves.length === 0) return null;\n\tconst flattened = waves.flat().filter((v) => v !== SENTINEL);\n\treturn flattened.length === 0 ? [] : flattened;\n}\n\n/** Latest cached DATA for a dep, derived from implementation-owned dep cache. */\nexport function depLatest(ctx: Ctx, depIndex: number): unknown {\n\treturn ctx[CTX_DEP_CACHE]?.latest[depIndex];\n}\n\n/** Terminal metadata for one dep: false = none, true = COMPLETE, otherwise ERROR payload. */\nexport function depTerminal(ctx: Ctx, depIndex: number): unknown {\n\tconst t = ctx.terminal[depIndex];\n\treturn t === undefined ? false : t;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2CO,IAAM,WAAW;;;ACoHjB,SAAS,SAAS,KAAU,UAAmD;AACrF,SAAO,IAAI,SAAS,QAAQ,KAAK,CAAC;AACnC;AAGO,SAAS,SAAS,KAAU,UAA6C;AAC/E,QAAM,QAAQ,SAAS,KAAK,QAAQ;AACpC,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,YAAY,MAAM,KAAK,EAAE,OAAO,CAAC,MAAM,MAAM,QAAQ;AAC3D,SAAO,UAAU,WAAW,IAAI,CAAC,IAAI;AACtC;;;AF/GO,SAAS,6BAKf,OACA,MAC+C;AAC/C,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,UAAU,MAAM;AAAA,IACrB,CAAC,KAAK,UAAU;AAAA,IAChB,CAAC,QAAQ;AACR,iBAAW,OAAO,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG;AACzC,cAAM,OAAO;AACb,mBAAW,WAAW,KAAK,UAAU;AACpC,gBAAM,WAAW,gBAAgB,MAAM,OAAO;AAC9C,gBAAM,UAAU,4BAA4B,SAAS,UAAU,KAAK,MAAM;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,QAAM,YAAY,OAAO,WAAW,cAAc,WAAW,WAAW,YAAY;AACpF,SAAO;AAAA,IACN,OAAO,WAAW;AAAA,IAClB,KAAK,WAAW;AAAA,IAChB,gBAAgB,WAAW;AAAA,IAC3B;AAAA,EACD;AACD;AAEA,SAAS,YAAY,QAAiC,KAAiC;AACtF,QAAM,QAAQ,OAAO,GAAG;AACxB,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AAChE;AAEA,SAAS,YACR,QACA,KACsC;AACtC,QAAM,QAAQ,OAAO,GAAG;AACxB,SAAO,eAAe,KAAK,IAAI,QAAQ;AACxC;AAEA,SAAS,eAAe,OAAkD;AACzE,SAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;","names":[]}
@@ -0,0 +1,56 @@
1
+ import { DataIssue } from '../data/index.cjs';
2
+ import { d as Graph } from '../graph-CWK3HLPB.cjs';
3
+ import { N as Node } from '../types-BS6CyR-x.cjs';
4
+ import { M as MessageBusMessage, a as MessageBusCommand, b as MessageBusAvailablePage } from '../types-BhveCMg5.cjs';
5
+ import { P as ProcessCommand, a as ProcessStatus, b as ProcessEvent } from '../process-types-h3uRlzDc.cjs';
6
+ import '../core/index.cjs';
7
+ import '../messages-CAzUPPJM.cjs';
8
+ import '../codec-BB7p8fJc.cjs';
9
+ import '../describe-CQRrkv-Q.cjs';
10
+
11
+ /**
12
+ * Optional orchestration-over-messageBus recipe (D349/D351/D353).
13
+ *
14
+ * Ack commands are graph-derived from visible ProcessBundle accepted/rejected
15
+ * material; retained delivery receipt is never an ack.
16
+ */
17
+
18
+ interface OrchestrationMessagingPolicy<TPayload = unknown, TCommand = unknown> {
19
+ readonly command?: (message: MessageBusMessage<TPayload>, delivery: MessageBusDelivery) => ProcessCommand<TCommand> | undefined;
20
+ readonly ackRejected?: boolean;
21
+ readonly outboxTopic?: string;
22
+ }
23
+ interface OrchestrationMessagingRecipeOptions<TPayload = unknown, TCommand = unknown, TEvent = unknown> {
24
+ readonly name?: string;
25
+ readonly deliveries: Node<MessageBusAvailablePage<TPayload>>;
26
+ readonly status: Node<ProcessStatus>;
27
+ readonly events?: Node<ProcessEvent<TEvent>>;
28
+ readonly policy?: OrchestrationMessagingPolicy<TPayload, TCommand>;
29
+ }
30
+ interface OrchestrationMessagingRecipeBundle<TCommand = unknown> {
31
+ readonly commands: Node<ProcessCommand<TCommand>>;
32
+ readonly ackCommands: Node<MessageBusCommand>;
33
+ readonly outboxCommands?: Node<MessageBusCommand>;
34
+ readonly issues: Node<DataIssue>;
35
+ }
36
+ interface MessageBusDelivery {
37
+ readonly topic: string;
38
+ readonly seq: number;
39
+ readonly subscriptionId: string;
40
+ readonly commandId: string;
41
+ }
42
+ /** Build the optional D349/D351 orchestration messaging recipe. */
43
+ declare function orchestrationMessagingRecipe<TPayload = unknown, TCommand = unknown, TEvent = unknown>(graph: Graph, opts: OrchestrationMessagingRecipeOptions<TPayload, TCommand, TEvent>): OrchestrationMessagingRecipeBundle<TCommand>;
44
+ declare function orchestrationMessageCommand<TPayload = unknown, TCommand = unknown>(message: MessageBusMessage<TPayload>, delivery: MessageBusDelivery, policy?: OrchestrationMessagingPolicy<TPayload, TCommand>): ProcessCommand<TCommand> | undefined;
45
+ declare function orchestrationMessageAckCommands(graph: Graph, opts: {
46
+ readonly name?: string;
47
+ readonly commands: Node<ProcessCommand>;
48
+ readonly status: Node<ProcessStatus>;
49
+ readonly issues?: Node<DataIssue>;
50
+ readonly ackRejected?: boolean;
51
+ }): Node<MessageBusCommand>;
52
+ declare function processEventOutboxCommands<TEvent>(graph: Graph, events: Node<ProcessEvent<TEvent>>, topic: string, opts?: {
53
+ readonly name?: string;
54
+ }): Node<MessageBusCommand>;
55
+
56
+ export { type MessageBusDelivery, type OrchestrationMessagingPolicy, type OrchestrationMessagingRecipeBundle, type OrchestrationMessagingRecipeOptions, orchestrationMessageAckCommands, orchestrationMessageCommand, orchestrationMessagingRecipe, processEventOutboxCommands };