@smthrs/engine-store 1.0.0-rc.5 → 1.0.0-rc.6

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 (257) hide show
  1. package/README.md +5 -5
  2. package/dist/cjs/ArtifactGc.d.ts +1 -1
  3. package/dist/cjs/ArtifactGc.d.ts.map +1 -1
  4. package/dist/cjs/ArtifactGc.js +1 -1
  5. package/dist/cjs/ArtifactGc.js.map +1 -1
  6. package/dist/cjs/DeferredClockFold.d.ts +4 -4
  7. package/dist/cjs/DeferredClockFold.d.ts.map +1 -1
  8. package/dist/cjs/DeferredClockFold.js +1 -1
  9. package/dist/cjs/DeferredClockFold.js.map +1 -1
  10. package/dist/cjs/DisasterRecovery.d.ts +1 -1
  11. package/dist/cjs/DisasterRecovery.d.ts.map +1 -1
  12. package/dist/cjs/DisasterRecovery.js +1 -1
  13. package/dist/cjs/DisasterRecovery.js.map +1 -1
  14. package/dist/cjs/DurableEngineState.d.ts +1 -1
  15. package/dist/cjs/DurableEngineState.d.ts.map +1 -1
  16. package/dist/cjs/DurableEngineState.js +1 -1
  17. package/dist/cjs/DurableEngineState.js.map +1 -1
  18. package/dist/cjs/ExecutionSnapshot.d.ts +2 -2
  19. package/dist/cjs/ExecutionSnapshot.d.ts.map +1 -1
  20. package/dist/cjs/ExecutionSnapshot.js +1 -1
  21. package/dist/cjs/ExecutionSnapshot.js.map +1 -1
  22. package/dist/cjs/Migrations.d.ts +2 -2
  23. package/dist/cjs/Migrations.d.ts.map +1 -1
  24. package/dist/cjs/OwnerIdentity.js +1 -1
  25. package/dist/cjs/OwnerIdentity.js.map +2 -2
  26. package/dist/cjs/PlanInputStore.d.ts +1 -1
  27. package/dist/cjs/PlanInputStore.d.ts.map +1 -1
  28. package/dist/cjs/PlanInputStore.js +1 -1
  29. package/dist/cjs/PlanInputStore.js.map +1 -1
  30. package/dist/cjs/PlanMergeStore.d.ts +1 -1
  31. package/dist/cjs/PlanMergeStore.d.ts.map +1 -1
  32. package/dist/cjs/PlanMergeStore.js +1 -1
  33. package/dist/cjs/PlanMergeStore.js.map +1 -1
  34. package/dist/cjs/Retention.d.ts +2 -2
  35. package/dist/cjs/Retention.d.ts.map +1 -1
  36. package/dist/cjs/Retention.js +1 -1
  37. package/dist/cjs/Retention.js.map +1 -1
  38. package/dist/cjs/RunChangeFeed.d.ts +1 -1
  39. package/dist/cjs/RunChangeFeed.d.ts.map +1 -1
  40. package/dist/cjs/RunChangeFeed.js +1 -1
  41. package/dist/cjs/RunChangeFeed.js.map +1 -1
  42. package/dist/cjs/SelectionStore.d.ts +1 -1
  43. package/dist/cjs/SelectionStore.d.ts.map +1 -1
  44. package/dist/cjs/SelectionStore.js +1 -1
  45. package/dist/cjs/SelectionStore.js.map +1 -1
  46. package/dist/cjs/StepBoundary.js +3 -3
  47. package/dist/cjs/StepBoundary.js.map +2 -2
  48. package/dist/cjs/StepCacheFold.d.ts +2 -2
  49. package/dist/cjs/StepCacheFold.d.ts.map +1 -1
  50. package/dist/cjs/StepCacheFold.js +1 -1
  51. package/dist/cjs/StepCacheFold.js.map +1 -1
  52. package/dist/cjs/internal/EngineStateSchema.d.ts +1 -1
  53. package/dist/cjs/internal/EngineStateSchema.d.ts.map +1 -1
  54. package/dist/cjs/internal/EngineStateSchema.js.map +1 -1
  55. package/dist/cjs/internal/ExecutionSnapshotRead.d.ts +3 -3
  56. package/dist/cjs/internal/ExecutionSnapshotRead.d.ts.map +1 -1
  57. package/dist/cjs/internal/ExecutionSnapshotRead.js.map +1 -1
  58. package/dist/cjs/internal/ExecutionSnapshotRelations.d.ts +1 -1
  59. package/dist/cjs/internal/ExecutionSnapshotRelations.d.ts.map +1 -1
  60. package/dist/cjs/internal/ExecutionSnapshotRelations.js.map +1 -1
  61. package/dist/cjs/internal/RetentionOps.d.ts +2 -2
  62. package/dist/cjs/internal/RetentionOps.d.ts.map +1 -1
  63. package/dist/cjs/internal/RetentionOps.js +1 -1
  64. package/dist/cjs/internal/RetentionOps.js.map +1 -1
  65. package/dist/cjs/internal/RunCatalogOps.d.ts +1 -1
  66. package/dist/cjs/internal/RunCatalogOps.d.ts.map +1 -1
  67. package/dist/cjs/internal/RunCatalogOps.js +1 -1
  68. package/dist/cjs/internal/RunCatalogOps.js.map +1 -1
  69. package/dist/cjs/internal/RunListing.d.ts +1 -1
  70. package/dist/cjs/internal/RunListing.d.ts.map +1 -1
  71. package/dist/cjs/internal/RunListing.js +1 -1
  72. package/dist/cjs/internal/RunListing.js.map +1 -1
  73. package/dist/cjs/migrations/0001_initial.d.ts +1 -1
  74. package/dist/cjs/migrations/0001_initial.d.ts.map +1 -1
  75. package/dist/cjs/migrations/0001_initial.js +1 -1
  76. package/dist/cjs/migrations/0001_initial.js.map +1 -1
  77. package/dist/cjs/migrations/0002_selection_store.d.ts +1 -1
  78. package/dist/cjs/migrations/0002_selection_store.d.ts.map +1 -1
  79. package/dist/cjs/migrations/0002_selection_store.js +1 -1
  80. package/dist/cjs/migrations/0002_selection_store.js.map +1 -1
  81. package/dist/cjs/migrations/0003_plan_inputs.d.ts +1 -1
  82. package/dist/cjs/migrations/0003_plan_inputs.d.ts.map +1 -1
  83. package/dist/cjs/migrations/0003_plan_inputs.js +1 -1
  84. package/dist/cjs/migrations/0003_plan_inputs.js.map +1 -1
  85. package/dist/cjs/migrations/0004_plan_environment.d.ts +1 -1
  86. package/dist/cjs/migrations/0004_plan_environment.d.ts.map +1 -1
  87. package/dist/cjs/migrations/0004_plan_environment.js +1 -1
  88. package/dist/cjs/migrations/0004_plan_environment.js.map +1 -1
  89. package/dist/cjs/migrations/0005_plan_merges.d.ts +1 -1
  90. package/dist/cjs/migrations/0005_plan_merges.d.ts.map +1 -1
  91. package/dist/cjs/migrations/0005_plan_merges.js +1 -1
  92. package/dist/cjs/migrations/0005_plan_merges.js.map +1 -1
  93. package/dist/cjs/migrations/0006_execution_listing.d.ts +1 -1
  94. package/dist/cjs/migrations/0006_execution_listing.d.ts.map +1 -1
  95. package/dist/cjs/migrations/0006_execution_listing.js +1 -1
  96. package/dist/cjs/migrations/0006_execution_listing.js.map +1 -1
  97. package/dist/cjs/migrations/0007_run_parent_sequence.d.ts +1 -1
  98. package/dist/cjs/migrations/0007_run_parent_sequence.d.ts.map +1 -1
  99. package/dist/cjs/migrations/0007_run_parent_sequence.js +1 -1
  100. package/dist/cjs/migrations/0007_run_parent_sequence.js.map +1 -1
  101. package/dist/cjs/migrations/0008_deferred_consumption.d.ts +1 -1
  102. package/dist/cjs/migrations/0008_deferred_consumption.d.ts.map +1 -1
  103. package/dist/cjs/migrations/0008_deferred_consumption.js +1 -1
  104. package/dist/cjs/migrations/0008_deferred_consumption.js.map +1 -1
  105. package/dist/cjs/migrations/0009_deferred_clock_facts.d.ts +1 -1
  106. package/dist/cjs/migrations/0009_deferred_clock_facts.d.ts.map +1 -1
  107. package/dist/cjs/migrations/0009_deferred_clock_facts.js +1 -1
  108. package/dist/cjs/migrations/0009_deferred_clock_facts.js.map +1 -1
  109. package/dist/cjs/migrations/0010_pending_cancellation.d.ts +1 -1
  110. package/dist/cjs/migrations/0010_pending_cancellation.d.ts.map +1 -1
  111. package/dist/cjs/migrations/0010_pending_cancellation.js +1 -1
  112. package/dist/cjs/migrations/0010_pending_cancellation.js.map +1 -1
  113. package/dist/cjs/test/TestStores.d.ts +4 -4
  114. package/dist/cjs/test/TestStores.d.ts.map +1 -1
  115. package/dist/esm/ArtifactGc.d.ts +1 -1
  116. package/dist/esm/ArtifactGc.d.ts.map +1 -1
  117. package/dist/esm/ArtifactGc.js +1 -1
  118. package/dist/esm/ArtifactGc.js.map +1 -1
  119. package/dist/esm/DeferredClockFold.d.ts +4 -4
  120. package/dist/esm/DeferredClockFold.d.ts.map +1 -1
  121. package/dist/esm/DeferredClockFold.js +1 -1
  122. package/dist/esm/DeferredClockFold.js.map +1 -1
  123. package/dist/esm/DisasterRecovery.d.ts +1 -1
  124. package/dist/esm/DisasterRecovery.d.ts.map +1 -1
  125. package/dist/esm/DisasterRecovery.js +1 -1
  126. package/dist/esm/DisasterRecovery.js.map +1 -1
  127. package/dist/esm/DurableEngineState.d.ts +1 -1
  128. package/dist/esm/DurableEngineState.d.ts.map +1 -1
  129. package/dist/esm/DurableEngineState.js +1 -1
  130. package/dist/esm/DurableEngineState.js.map +1 -1
  131. package/dist/esm/ExecutionSnapshot.d.ts +2 -2
  132. package/dist/esm/ExecutionSnapshot.d.ts.map +1 -1
  133. package/dist/esm/ExecutionSnapshot.js +1 -1
  134. package/dist/esm/ExecutionSnapshot.js.map +1 -1
  135. package/dist/esm/Migrations.d.ts +2 -2
  136. package/dist/esm/Migrations.d.ts.map +1 -1
  137. package/dist/esm/OwnerIdentity.js +1 -1
  138. package/dist/esm/OwnerIdentity.js.map +1 -1
  139. package/dist/esm/PlanInputStore.d.ts +1 -1
  140. package/dist/esm/PlanInputStore.d.ts.map +1 -1
  141. package/dist/esm/PlanInputStore.js +1 -1
  142. package/dist/esm/PlanInputStore.js.map +1 -1
  143. package/dist/esm/PlanMergeStore.d.ts +1 -1
  144. package/dist/esm/PlanMergeStore.d.ts.map +1 -1
  145. package/dist/esm/PlanMergeStore.js +1 -1
  146. package/dist/esm/PlanMergeStore.js.map +1 -1
  147. package/dist/esm/Retention.d.ts +2 -2
  148. package/dist/esm/Retention.d.ts.map +1 -1
  149. package/dist/esm/Retention.js +1 -1
  150. package/dist/esm/Retention.js.map +1 -1
  151. package/dist/esm/RunChangeFeed.d.ts +1 -1
  152. package/dist/esm/RunChangeFeed.d.ts.map +1 -1
  153. package/dist/esm/RunChangeFeed.js +1 -1
  154. package/dist/esm/RunChangeFeed.js.map +1 -1
  155. package/dist/esm/SelectionStore.d.ts +1 -1
  156. package/dist/esm/SelectionStore.d.ts.map +1 -1
  157. package/dist/esm/SelectionStore.js +1 -1
  158. package/dist/esm/SelectionStore.js.map +1 -1
  159. package/dist/esm/StepBoundary.js +3 -3
  160. package/dist/esm/StepBoundary.js.map +1 -1
  161. package/dist/esm/StepCacheFold.d.ts +2 -2
  162. package/dist/esm/StepCacheFold.d.ts.map +1 -1
  163. package/dist/esm/StepCacheFold.js +1 -1
  164. package/dist/esm/StepCacheFold.js.map +1 -1
  165. package/dist/esm/internal/EngineStateSchema.d.ts +1 -1
  166. package/dist/esm/internal/EngineStateSchema.d.ts.map +1 -1
  167. package/dist/esm/internal/EngineStateSchema.js.map +1 -1
  168. package/dist/esm/internal/ExecutionSnapshotRead.d.ts +3 -3
  169. package/dist/esm/internal/ExecutionSnapshotRead.d.ts.map +1 -1
  170. package/dist/esm/internal/ExecutionSnapshotRead.js.map +1 -1
  171. package/dist/esm/internal/ExecutionSnapshotRelations.d.ts +1 -1
  172. package/dist/esm/internal/ExecutionSnapshotRelations.d.ts.map +1 -1
  173. package/dist/esm/internal/ExecutionSnapshotRelations.js.map +1 -1
  174. package/dist/esm/internal/RetentionOps.d.ts +2 -2
  175. package/dist/esm/internal/RetentionOps.d.ts.map +1 -1
  176. package/dist/esm/internal/RetentionOps.js +1 -1
  177. package/dist/esm/internal/RetentionOps.js.map +1 -1
  178. package/dist/esm/internal/RunCatalogOps.d.ts +1 -1
  179. package/dist/esm/internal/RunCatalogOps.d.ts.map +1 -1
  180. package/dist/esm/internal/RunCatalogOps.js +1 -1
  181. package/dist/esm/internal/RunCatalogOps.js.map +1 -1
  182. package/dist/esm/internal/RunListing.d.ts +1 -1
  183. package/dist/esm/internal/RunListing.d.ts.map +1 -1
  184. package/dist/esm/internal/RunListing.js +1 -1
  185. package/dist/esm/internal/RunListing.js.map +1 -1
  186. package/dist/esm/migrations/0001_initial.d.ts +1 -1
  187. package/dist/esm/migrations/0001_initial.d.ts.map +1 -1
  188. package/dist/esm/migrations/0001_initial.js +1 -1
  189. package/dist/esm/migrations/0001_initial.js.map +1 -1
  190. package/dist/esm/migrations/0002_selection_store.d.ts +1 -1
  191. package/dist/esm/migrations/0002_selection_store.d.ts.map +1 -1
  192. package/dist/esm/migrations/0002_selection_store.js +1 -1
  193. package/dist/esm/migrations/0002_selection_store.js.map +1 -1
  194. package/dist/esm/migrations/0003_plan_inputs.d.ts +1 -1
  195. package/dist/esm/migrations/0003_plan_inputs.d.ts.map +1 -1
  196. package/dist/esm/migrations/0003_plan_inputs.js +1 -1
  197. package/dist/esm/migrations/0003_plan_inputs.js.map +1 -1
  198. package/dist/esm/migrations/0004_plan_environment.d.ts +1 -1
  199. package/dist/esm/migrations/0004_plan_environment.d.ts.map +1 -1
  200. package/dist/esm/migrations/0004_plan_environment.js +1 -1
  201. package/dist/esm/migrations/0004_plan_environment.js.map +1 -1
  202. package/dist/esm/migrations/0005_plan_merges.d.ts +1 -1
  203. package/dist/esm/migrations/0005_plan_merges.d.ts.map +1 -1
  204. package/dist/esm/migrations/0005_plan_merges.js +1 -1
  205. package/dist/esm/migrations/0005_plan_merges.js.map +1 -1
  206. package/dist/esm/migrations/0006_execution_listing.d.ts +1 -1
  207. package/dist/esm/migrations/0006_execution_listing.d.ts.map +1 -1
  208. package/dist/esm/migrations/0006_execution_listing.js +1 -1
  209. package/dist/esm/migrations/0006_execution_listing.js.map +1 -1
  210. package/dist/esm/migrations/0007_run_parent_sequence.d.ts +1 -1
  211. package/dist/esm/migrations/0007_run_parent_sequence.d.ts.map +1 -1
  212. package/dist/esm/migrations/0007_run_parent_sequence.js +1 -1
  213. package/dist/esm/migrations/0007_run_parent_sequence.js.map +1 -1
  214. package/dist/esm/migrations/0008_deferred_consumption.d.ts +1 -1
  215. package/dist/esm/migrations/0008_deferred_consumption.d.ts.map +1 -1
  216. package/dist/esm/migrations/0008_deferred_consumption.js +1 -1
  217. package/dist/esm/migrations/0008_deferred_consumption.js.map +1 -1
  218. package/dist/esm/migrations/0009_deferred_clock_facts.d.ts +1 -1
  219. package/dist/esm/migrations/0009_deferred_clock_facts.d.ts.map +1 -1
  220. package/dist/esm/migrations/0009_deferred_clock_facts.js +1 -1
  221. package/dist/esm/migrations/0009_deferred_clock_facts.js.map +1 -1
  222. package/dist/esm/migrations/0010_pending_cancellation.d.ts +1 -1
  223. package/dist/esm/migrations/0010_pending_cancellation.d.ts.map +1 -1
  224. package/dist/esm/migrations/0010_pending_cancellation.js +1 -1
  225. package/dist/esm/migrations/0010_pending_cancellation.js.map +1 -1
  226. package/dist/esm/test/TestStores.d.ts +4 -4
  227. package/dist/esm/test/TestStores.d.ts.map +1 -1
  228. package/package.json +22 -22
  229. package/src/ArtifactGc.ts +1 -1
  230. package/src/DeferredClockFold.ts +1 -1
  231. package/src/DisasterRecovery.ts +1 -1
  232. package/src/DurableEngineState.ts +1 -1
  233. package/src/ExecutionSnapshot.ts +1 -1
  234. package/src/OwnerIdentity.ts +1 -1
  235. package/src/PlanInputStore.ts +1 -1
  236. package/src/PlanMergeStore.ts +1 -1
  237. package/src/Retention.ts +2 -2
  238. package/src/RunChangeFeed.ts +1 -1
  239. package/src/SelectionStore.ts +1 -1
  240. package/src/StepBoundary.ts +3 -3
  241. package/src/StepCacheFold.ts +1 -1
  242. package/src/internal/EngineStateSchema.ts +1 -1
  243. package/src/internal/ExecutionSnapshotRead.ts +1 -1
  244. package/src/internal/ExecutionSnapshotRelations.ts +1 -1
  245. package/src/internal/RetentionOps.ts +2 -2
  246. package/src/internal/RunCatalogOps.ts +1 -1
  247. package/src/internal/RunListing.ts +1 -1
  248. package/src/migrations/0001_initial.ts +1 -1
  249. package/src/migrations/0002_selection_store.ts +1 -1
  250. package/src/migrations/0003_plan_inputs.ts +1 -1
  251. package/src/migrations/0004_plan_environment.ts +1 -1
  252. package/src/migrations/0005_plan_merges.ts +1 -1
  253. package/src/migrations/0006_execution_listing.ts +1 -1
  254. package/src/migrations/0007_run_parent_sequence.ts +1 -1
  255. package/src/migrations/0008_deferred_consumption.ts +1 -1
  256. package/src/migrations/0009_deferred_clock_facts.ts +1 -1
  257. package/src/migrations/0010_pending_cancellation.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"0004_plan_environment.js","sourceRoot":"","sources":["../../../src/migrations/0004_plan_environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACpG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA;yEAC6D,CAAA;IACvE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,6CAA6C;QACnD,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,gCAAgC;QACtC,MAAM,EAAE,sDAAsD;KAC/D,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,8CAA8C;QACpD,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,gEAAgE;QACtE,MAAM,EAAE,8CAA8C;KACvD,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Bind source observations to the runtime identity that admitted them.\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Older heads retain NULL: their original runtime environment is unknowable.\n * New heads require an environment fingerprint, immutable for their lifetime.\n * @since 1.0.0\n * @category migrations\n */\nexport const planEnvironment: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`ALTER TABLE flows_plan_input_heads ADD COLUMN environment_digest TEXT\n CHECK (environment_digest IS NULL OR length(environment_digest) > 0)`\n yield* Dialect.trigger(sql, {\n name: `flows_plan_input_heads_environment_required`,\n table: `flows_plan_input_heads`,\n event: \"BEFORE INSERT\",\n when: `NEW.environment_digest IS NULL`,\n reject: \"new plan input heads require an environment identity\"\n })\n yield* Dialect.trigger(sql, {\n name: `flows_plan_input_heads_environment_immutable`,\n table: `flows_plan_input_heads`,\n event: \"BEFORE UPDATE\",\n when: `NEW.environment_digest IS DISTINCT FROM OLD.environment_digest`,\n reject: \"plan input environment identity is immutable\"\n })\n})\n"]}
1
+ {"version":3,"file":"0004_plan_environment.js","sourceRoot":"","sources":["../../../src/migrations/0004_plan_environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACpG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA;yEAC6D,CAAA;IACvE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,6CAA6C;QACnD,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,gCAAgC;QACtC,MAAM,EAAE,sDAAsD;KAC/D,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,8CAA8C;QACpD,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,gEAAgE;QACtE,MAAM,EAAE,8CAA8C;KACvD,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Bind source observations to the runtime identity that admitted them.\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Older heads retain NULL: their original runtime environment is unknowable.\n * New heads require an environment fingerprint, immutable for their lifetime.\n * @since 1.0.0\n * @category migrations\n */\nexport const planEnvironment: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`ALTER TABLE flows_plan_input_heads ADD COLUMN environment_digest TEXT\n CHECK (environment_digest IS NULL OR length(environment_digest) > 0)`\n yield* Dialect.trigger(sql, {\n name: `flows_plan_input_heads_environment_required`,\n table: `flows_plan_input_heads`,\n event: \"BEFORE INSERT\",\n when: `NEW.environment_digest IS NULL`,\n reject: \"new plan input heads require an environment identity\"\n })\n yield* Dialect.trigger(sql, {\n name: `flows_plan_input_heads_environment_immutable`,\n table: `flows_plan_input_heads`,\n event: \"BEFORE UPDATE\",\n when: `NEW.environment_digest IS DISTINCT FROM OLD.environment_digest`,\n reject: \"plan input environment identity is immutable\"\n })\n})\n"]}
@@ -3,7 +3,7 @@
3
3
  * @since 1.0.0
4
4
  */
5
5
  import * as Effect from "effect/Effect";
6
- import * as SqlClient from "effect/unstable/sql/SqlClient";
6
+ import * as SqlClient from "effect/sql/SqlClient";
7
7
  /**
8
8
  * Existing heads retain an unknown merge-state version; a later runtime must
9
9
  * not infer its missing control decisions from arbitrary plan-node bodies.
@@ -1 +1 @@
1
- {"version":3,"file":"0005_plan_merges.d.ts","sourceRoot":"","sources":["../../../src/migrations/0005_plan_merges.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CA4CvE,CAAA"}
1
+ {"version":3,"file":"0005_plan_merges.d.ts","sourceRoot":"","sources":["../../../src/migrations/0005_plan_merges.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CA4CvE,CAAA"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import * as Dialect from "@smthrs/database/Dialect";
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Existing heads retain an unknown merge-state version; a later runtime must
10
10
  * not infer its missing control decisions from arbitrary plan-node bodies.
@@ -1 +1 @@
1
- {"version":3,"file":"0005_plan_merges.js","sourceRoot":"","sources":["../../../src/migrations/0005_plan_merges.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC/F,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA,qEAAqE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;mEAClC,CAAA;IACjE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,gDAAgD;QACtD,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,kEAAkE;QACxE,MAAM,EAAE,uCAAuC;KAChD,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,GAAG,CAAA;;;uCAG2B,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,aAAa,CAAC;;;IAG3E,CAAA;IACF,KAAK,CAAC,CAAC,GAAG,CAAA;;;iBAGK,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,YAAY,CAAC;;2CAErD,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,iBAAiB,CAAC;;;;;IAKnF,CAAA;IACF,KAAK,MAAM,KAAK,IAAI,CAAC,0BAA0B,EAAE,8BAA8B,CAAC,EAAE,CAAC;QACjF,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,GAAG,KAAK,YAAY;YAC1B,KAAK,EAAE,GAAG,KAAK,EAAE;YACjB,KAAK,EAAE,eAAe;YACtB,MAAM,EAAE,oCAAoC;SAC7C,CAAC,CAAA;QACF,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,GAAG,KAAK,YAAY;YAC1B,KAAK,EAAE,GAAG,KAAK,EAAE;YACjB,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,6DAA6D;YACnE,MAAM,EAAE,0CAA0C;SACnD,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Durable scheduler merge intentions and their committed plan extensions.\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Existing heads retain an unknown merge-state version; a later runtime must\n * not infer its missing control decisions from arbitrary plan-node bodies.\n * @since 1.0.0\n * @category migrations\n */\nexport const planMerges: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`ALTER TABLE flows_plan_input_heads ADD COLUMN merge_state_version ${Dialect.integer(sql)}\n CHECK (merge_state_version IS NULL OR merge_state_version = 1)`\n yield* Dialect.trigger(sql, {\n name: `flows_plan_input_heads_merge_version_immutable`,\n table: `flows_plan_input_heads`,\n event: \"BEFORE UPDATE\",\n when: `NEW.merge_state_version IS DISTINCT FROM OLD.merge_state_version`,\n reject: \"plan merge state version is immutable\"\n })\n yield* sql`CREATE TABLE flows_plan_merge_intents (\n run_id TEXT NOT NULL REFERENCES flows_runs(run_id) ON DELETE CASCADE,\n stopped_node_id TEXT NOT NULL CHECK (length(stopped_node_id) > 0),\n intent_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`intent_json`)}),\n checksum TEXT NOT NULL CHECK (length(checksum) = 64),\n PRIMARY KEY (run_id, stopped_node_id)\n )`\n yield* sql`CREATE TABLE flows_plan_merge_completions (\n run_id TEXT NOT NULL REFERENCES flows_runs(run_id) ON DELETE CASCADE,\n stopped_node_id TEXT NOT NULL CHECK (length(stopped_node_id) > 0),\n generation ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`generation`)} AND generation > 0),\n merge_node_id TEXT NOT NULL CHECK (length(merge_node_id) > 0),\n completion_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`completion_json`)}),\n checksum TEXT NOT NULL CHECK (length(checksum) = 64),\n PRIMARY KEY (run_id, stopped_node_id),\n UNIQUE (run_id, generation), UNIQUE (run_id, merge_node_id),\n FOREIGN KEY (run_id, stopped_node_id) REFERENCES flows_plan_merge_intents(run_id, stopped_node_id) ON DELETE CASCADE\n )`\n for (const table of [\"flows_plan_merge_intents\", \"flows_plan_merge_completions\"]) {\n yield* Dialect.trigger(sql, {\n name: `${table}_no_update`,\n table: `${table}`,\n event: \"BEFORE UPDATE\",\n reject: \"plan merge decisions are immutable\"\n })\n yield* Dialect.trigger(sql, {\n name: `${table}_no_delete`,\n table: `${table}`,\n event: \"BEFORE DELETE\",\n when: `EXISTS (SELECT 1 FROM flows_runs WHERE run_id = OLD.run_id)`,\n reject: \"plan merge decisions belong to their run\"\n })\n }\n})\n"]}
1
+ {"version":3,"file":"0005_plan_merges.js","sourceRoot":"","sources":["../../../src/migrations/0005_plan_merges.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC/F,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA,qEAAqE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;mEAClC,CAAA;IACjE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,gDAAgD;QACtD,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,kEAAkE;QACxE,MAAM,EAAE,uCAAuC;KAChD,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,GAAG,CAAA;;;uCAG2B,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,aAAa,CAAC;;;IAG3E,CAAA;IACF,KAAK,CAAC,CAAC,GAAG,CAAA;;;iBAGK,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,YAAY,CAAC;;2CAErD,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,iBAAiB,CAAC;;;;;IAKnF,CAAA;IACF,KAAK,MAAM,KAAK,IAAI,CAAC,0BAA0B,EAAE,8BAA8B,CAAC,EAAE,CAAC;QACjF,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,GAAG,KAAK,YAAY;YAC1B,KAAK,EAAE,GAAG,KAAK,EAAE;YACjB,KAAK,EAAE,eAAe;YACtB,MAAM,EAAE,oCAAoC;SAC7C,CAAC,CAAA;QACF,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,GAAG,KAAK,YAAY;YAC1B,KAAK,EAAE,GAAG,KAAK,EAAE;YACjB,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,6DAA6D;YACnE,MAAM,EAAE,0CAA0C;SACnD,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Durable scheduler merge intentions and their committed plan extensions.\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Existing heads retain an unknown merge-state version; a later runtime must\n * not infer its missing control decisions from arbitrary plan-node bodies.\n * @since 1.0.0\n * @category migrations\n */\nexport const planMerges: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`ALTER TABLE flows_plan_input_heads ADD COLUMN merge_state_version ${Dialect.integer(sql)}\n CHECK (merge_state_version IS NULL OR merge_state_version = 1)`\n yield* Dialect.trigger(sql, {\n name: `flows_plan_input_heads_merge_version_immutable`,\n table: `flows_plan_input_heads`,\n event: \"BEFORE UPDATE\",\n when: `NEW.merge_state_version IS DISTINCT FROM OLD.merge_state_version`,\n reject: \"plan merge state version is immutable\"\n })\n yield* sql`CREATE TABLE flows_plan_merge_intents (\n run_id TEXT NOT NULL REFERENCES flows_runs(run_id) ON DELETE CASCADE,\n stopped_node_id TEXT NOT NULL CHECK (length(stopped_node_id) > 0),\n intent_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`intent_json`)}),\n checksum TEXT NOT NULL CHECK (length(checksum) = 64),\n PRIMARY KEY (run_id, stopped_node_id)\n )`\n yield* sql`CREATE TABLE flows_plan_merge_completions (\n run_id TEXT NOT NULL REFERENCES flows_runs(run_id) ON DELETE CASCADE,\n stopped_node_id TEXT NOT NULL CHECK (length(stopped_node_id) > 0),\n generation ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`generation`)} AND generation > 0),\n merge_node_id TEXT NOT NULL CHECK (length(merge_node_id) > 0),\n completion_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`completion_json`)}),\n checksum TEXT NOT NULL CHECK (length(checksum) = 64),\n PRIMARY KEY (run_id, stopped_node_id),\n UNIQUE (run_id, generation), UNIQUE (run_id, merge_node_id),\n FOREIGN KEY (run_id, stopped_node_id) REFERENCES flows_plan_merge_intents(run_id, stopped_node_id) ON DELETE CASCADE\n )`\n for (const table of [\"flows_plan_merge_intents\", \"flows_plan_merge_completions\"]) {\n yield* Dialect.trigger(sql, {\n name: `${table}_no_update`,\n table: `${table}`,\n event: \"BEFORE UPDATE\",\n reject: \"plan merge decisions are immutable\"\n })\n yield* Dialect.trigger(sql, {\n name: `${table}_no_delete`,\n table: `${table}`,\n event: \"BEFORE DELETE\",\n when: `EXISTS (SELECT 1 FROM flows_runs WHERE run_id = OLD.run_id)`,\n reject: \"plan merge decisions belong to their run\"\n })\n }\n})\n"]}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Brings existing spawn edges into the migration ladder and binds changes to
10
10
  * their child's run revision. Run-store owns the shared revision triggers.
@@ -1 +1 @@
1
- {"version":3,"file":"0006_execution_listing.d.ts","sourceRoot":"","sources":["../../../src/migrations/0006_execution_listing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAqE7E,CAAA"}
1
+ {"version":3,"file":"0006_execution_listing.d.ts","sourceRoot":"","sources":["../../../src/migrations/0006_execution_listing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAqE7E,CAAA"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import * as Dialect from "@smthrs/database/Dialect";
7
7
  import * as Effect from "effect/Effect";
8
- import * as SqlClient from "effect/unstable/sql/SqlClient";
8
+ import * as SqlClient from "effect/sql/SqlClient";
9
9
  /**
10
10
  * Brings existing spawn edges into the migration ladder and binds changes to
11
11
  * their child's run revision. Run-store owns the shared revision triggers.
@@ -1 +1 @@
1
- {"version":3,"file":"0006_execution_listing.js","sourceRoot":"","sources":["../../../src/migrations/0006_execution_listing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,S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,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;QACxE,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,mCAAmC,IAAI;SACpD,CAAC,GAAG,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Indexed engine execution observation and ordering.\n *\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Brings existing spawn edges into the migration ladder and binds changes to\n * their child's run revision. Run-store owns the shared revision triggers.\n * @category migrations\n * @since 1.0.0\n */\nexport const executionListing: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE TABLE IF NOT EXISTS flows_run_parents (\n child_id TEXT NOT NULL CHECK (length(child_id) > 0),\n parent_id TEXT NOT NULL CHECK (length(parent_id) > 0),\n seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`seq`)\n } AND seq >= 0 AND seq <= 9007199254740991),\n PRIMARY KEY (child_id, parent_id)\n )`\n yield* sql`CREATE INDEX IF NOT EXISTS flows_run_parents_parent_idx ON flows_run_parents (parent_id)`\n yield* sql`CREATE INDEX flows_run_parents_first_idx ON flows_run_parents (child_id, seq, parent_id)`\n yield* sql`CREATE INDEX flows_run_parents_children_idx ON flows_run_parents (parent_id, seq, child_id)`\n yield* Dialect.trigger(sql, {\n name: \"flows_run_parents_gc\",\n table: \"flows_runs\",\n event: \"AFTER DELETE\",\n body: \"DELETE FROM flows_run_parents WHERE child_id = OLD.run_id OR parent_id = OLD.run_id;\"\n })\n yield* sql`ALTER TABLE flows_runs ADD COLUMN execution_parent_id TEXT`\n yield* sql`ALTER TABLE flows_runs ADD COLUMN execution_flow TEXT\n GENERATED ALWAYS AS (${Dialect.jsonText(sql, sql`state_json`, \"$.flowName\")}) ${\n sql.literal(Dialect.isPostgres(sql) ? \"STORED\" : \"VIRTUAL\")\n }`\n yield* sql`ALTER TABLE flows_runs ADD COLUMN execution_lineage TEXT\n GENERATED ALWAYS AS (COALESCE(lineage_id, run_id)) ${sql.literal(Dialect.isPostgres(sql) ? \"STORED\" : \"VIRTUAL\")}`\n yield* sql`CREATE INDEX flows_runs_round_page_idx ON flows_runs (execution_lineage, COALESCE(round_ordinal, 0), run_id)`\n yield* Dialect.trigger(sql, {\n name: `flows_runs_creation_immutable`,\n table: `flows_runs`,\n event: \"BEFORE UPDATE OF created_at_ms\",\n when: `NEW.created_at_ms <> OLD.created_at_ms`,\n reject: \"execution creation key is immutable\"\n })\n yield* sql`UPDATE flows_runs SET execution_parent_id = COALESCE(parent_run_id,\n (SELECT parent_id FROM flows_run_parents WHERE child_id = run_id ORDER BY seq, parent_id LIMIT 1))`\n for (const operation of [\"INSERT\", \"UPDATE OF parent_run_id\"] as const) {\n yield* Dialect.trigger(sql, {\n name: `flows_runs_effective_parent_${operation === \"INSERT\" ? \"insert\" : \"update\"}`,\n table: \"flows_runs\",\n event: `AFTER ${operation}`,\n body: `\n UPDATE flows_runs SET execution_parent_id = COALESCE(NEW.parent_run_id,\n (SELECT parent_id FROM flows_run_parents WHERE child_id = NEW.run_id ORDER BY seq, parent_id LIMIT 1))\n WHERE run_id = NEW.run_id;\n `\n })\n }\n for (const operation of [\"INSERT\", \"UPDATE\", \"DELETE\"] as const) {\n const row = operation === \"DELETE\" ? \"OLD\" : \"NEW\"\n yield* Dialect.trigger(sql, {\n name: `flows_run_parents_revision_${operation.toLowerCase()}`,\n table: \"flows_run_parents\",\n event: `AFTER ${operation}`,\n body: `\n UPDATE flows_runs SET execution_parent_id = COALESCE(parent_run_id,\n (SELECT parent_id FROM flows_run_parents WHERE child_id = run_id ORDER BY seq, parent_id LIMIT 1))\n WHERE run_id = ${row}.child_id ${operation === \"UPDATE\" ? \"OR run_id = OLD.child_id\" : \"\"};\n `\n })\n }\n // Every subset of the five equality filters has its creation-order suffix.\n // This avoids rare combined predicates degrading to whole-history scans.\n const fields = [\"status\", \"execution_flow\", \"execution_parent_id\", \"execution_lineage\", \"waiting_reason\"]\n for (let mask = 0; mask < 32; mask++) {\n const columns = fields.filter((_, index) => (mask & (1 << index)) !== 0)\n yield* sql.unsafe(`CREATE INDEX flows_runs_listing_${mask} ON flows_runs\n (${[...columns, \"created_at_ms\", \"run_id\"].join(\", \")})`)\n }\n})\n"]}
1
+ {"version":3,"file":"0006_execution_listing.js","sourceRoot":"","sources":["../../../src/migrations/0006_execution_listing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA;;;UAGF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAC1B,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,KAAK,CACjC;;IAEE,CAAA;IACF,KAAK,CAAC,CAAC,GAAG,CAAA,0FAA0F,CAAA;IACpG,KAAK,CAAC,CAAC,GAAG,CAAA,0FAA0F,CAAA;IACpG,KAAK,CAAC,CAAC,GAAG,CAAA,6FAA6F,CAAA;IACvG,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,YAAY;QACnB,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,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,EAAE,CAAC;QAChE,MAAM,GAAG,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;QAClD,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,8BAA8B,SAAS,CAAC,WAAW,EAAE,EAAE;YAC7D,KAAK,EAAE,mBAAmB;YAC1B,KAAK,EAAE,SAAS,SAAS,EAAE;YAC3B,IAAI,EAAE;;;yBAGa,GAAG,aAAa,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE;OAC1F;SACF,CAAC,CAAA;IACJ,CAAC;IACD,2EAA2E;IAC3E,yEAAyE;IACzE,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,CAAA;IACzG,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;QACxE,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,mCAAmC,IAAI;SACpD,CAAC,GAAG,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Indexed engine execution observation and ordering.\n *\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Brings existing spawn edges into the migration ladder and binds changes to\n * their child's run revision. Run-store owns the shared revision triggers.\n * @category migrations\n * @since 1.0.0\n */\nexport const executionListing: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE TABLE IF NOT EXISTS flows_run_parents (\n child_id TEXT NOT NULL CHECK (length(child_id) > 0),\n parent_id TEXT NOT NULL CHECK (length(parent_id) > 0),\n seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`seq`)\n } AND seq >= 0 AND seq <= 9007199254740991),\n PRIMARY KEY (child_id, parent_id)\n )`\n yield* sql`CREATE INDEX IF NOT EXISTS flows_run_parents_parent_idx ON flows_run_parents (parent_id)`\n yield* sql`CREATE INDEX flows_run_parents_first_idx ON flows_run_parents (child_id, seq, parent_id)`\n yield* sql`CREATE INDEX flows_run_parents_children_idx ON flows_run_parents (parent_id, seq, child_id)`\n yield* Dialect.trigger(sql, {\n name: \"flows_run_parents_gc\",\n table: \"flows_runs\",\n event: \"AFTER DELETE\",\n body: \"DELETE FROM flows_run_parents WHERE child_id = OLD.run_id OR parent_id = OLD.run_id;\"\n })\n yield* sql`ALTER TABLE flows_runs ADD COLUMN execution_parent_id TEXT`\n yield* sql`ALTER TABLE flows_runs ADD COLUMN execution_flow TEXT\n GENERATED ALWAYS AS (${Dialect.jsonText(sql, sql`state_json`, \"$.flowName\")}) ${\n sql.literal(Dialect.isPostgres(sql) ? \"STORED\" : \"VIRTUAL\")\n }`\n yield* sql`ALTER TABLE flows_runs ADD COLUMN execution_lineage TEXT\n GENERATED ALWAYS AS (COALESCE(lineage_id, run_id)) ${sql.literal(Dialect.isPostgres(sql) ? \"STORED\" : \"VIRTUAL\")}`\n yield* sql`CREATE INDEX flows_runs_round_page_idx ON flows_runs (execution_lineage, COALESCE(round_ordinal, 0), run_id)`\n yield* Dialect.trigger(sql, {\n name: `flows_runs_creation_immutable`,\n table: `flows_runs`,\n event: \"BEFORE UPDATE OF created_at_ms\",\n when: `NEW.created_at_ms <> OLD.created_at_ms`,\n reject: \"execution creation key is immutable\"\n })\n yield* sql`UPDATE flows_runs SET execution_parent_id = COALESCE(parent_run_id,\n (SELECT parent_id FROM flows_run_parents WHERE child_id = run_id ORDER BY seq, parent_id LIMIT 1))`\n for (const operation of [\"INSERT\", \"UPDATE OF parent_run_id\"] as const) {\n yield* Dialect.trigger(sql, {\n name: `flows_runs_effective_parent_${operation === \"INSERT\" ? \"insert\" : \"update\"}`,\n table: \"flows_runs\",\n event: `AFTER ${operation}`,\n body: `\n UPDATE flows_runs SET execution_parent_id = COALESCE(NEW.parent_run_id,\n (SELECT parent_id FROM flows_run_parents WHERE child_id = NEW.run_id ORDER BY seq, parent_id LIMIT 1))\n WHERE run_id = NEW.run_id;\n `\n })\n }\n for (const operation of [\"INSERT\", \"UPDATE\", \"DELETE\"] as const) {\n const row = operation === \"DELETE\" ? \"OLD\" : \"NEW\"\n yield* Dialect.trigger(sql, {\n name: `flows_run_parents_revision_${operation.toLowerCase()}`,\n table: \"flows_run_parents\",\n event: `AFTER ${operation}`,\n body: `\n UPDATE flows_runs SET execution_parent_id = COALESCE(parent_run_id,\n (SELECT parent_id FROM flows_run_parents WHERE child_id = run_id ORDER BY seq, parent_id LIMIT 1))\n WHERE run_id = ${row}.child_id ${operation === \"UPDATE\" ? \"OR run_id = OLD.child_id\" : \"\"};\n `\n })\n }\n // Every subset of the five equality filters has its creation-order suffix.\n // This avoids rare combined predicates degrading to whole-history scans.\n const fields = [\"status\", \"execution_flow\", \"execution_parent_id\", \"execution_lineage\", \"waiting_reason\"]\n for (let mask = 0; mask < 32; mask++) {\n const columns = fields.filter((_, index) => (mask & (1 << index)) !== 0)\n yield* sql.unsafe(`CREATE INDEX flows_runs_listing_${mask} ON flows_runs\n (${[...columns, \"created_at_ms\", \"run_id\"].join(\", \")})`)\n }\n})\n"]}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Supports MAX(seq) without scanning retained edges from unrelated runs.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"0007_run_parent_sequence.d.ts","sourceRoot":"","sources":["../../../src/migrations/0007_run_parent_sequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAG9E,CAAA"}
1
+ {"version":3,"file":"0007_run_parent_sequence.d.ts","sourceRoot":"","sources":["../../../src/migrations/0007_run_parent_sequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAG9E,CAAA"}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Supports MAX(seq) without scanning retained edges from unrelated runs.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"0007_run_parent_sequence.js","sourceRoot":"","sources":["../../../src/migrations/0007_run_parent_sequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA,mEAAmE,CAAA;AAC/E,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Indexed allocation of the global run-parent sequence.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Supports MAX(seq) without scanning retained edges from unrelated runs.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const runParentSequence: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE INDEX flows_run_parents_seq_idx ON flows_run_parents (seq)`\n})\n"]}
1
+ {"version":3,"file":"0007_run_parent_sequence.js","sourceRoot":"","sources":["../../../src/migrations/0007_run_parent_sequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA,mEAAmE,CAAA;AAC/E,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Indexed allocation of the global run-parent sequence.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Supports MAX(seq) without scanning retained edges from unrelated runs.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const runParentSequence: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE INDEX flows_run_parents_seq_idx ON flows_run_parents (seq)`\n})\n"]}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Retains completion values for replay while removing consumed rows from sweeps.
10
10
  * Existing completions stay eligible until first read by the upgraded engine.
@@ -1 +1 @@
1
- {"version":3,"file":"0008_deferred_consumption.d.ts","sourceRoot":"","sources":["../../../src/migrations/0008_deferred_consumption.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAShF,CAAA"}
1
+ {"version":3,"file":"0008_deferred_consumption.d.ts","sourceRoot":"","sources":["../../../src/migrations/0008_deferred_consumption.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAShF,CAAA"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import * as Dialect from "@smthrs/database/Dialect";
7
7
  import * as Effect from "effect/Effect";
8
- import * as SqlClient from "effect/unstable/sql/SqlClient";
8
+ import * as SqlClient from "effect/sql/SqlClient";
9
9
  /**
10
10
  * Retains completion values for replay while removing consumed rows from sweeps.
11
11
  * Existing completions stay eligible until first read by the upgraded engine.
@@ -1 +1 @@
1
- {"version":3,"file":"0008_deferred_consumption.js","sourceRoot":"","sources":["../../../src/migrations/0008_deferred_consumption.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA,oEAAoE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;wCAEhG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,gBAAgB,CAC5C,mEAAmE,CAAA;IACnE,KAAK,CAAC,CAAC,GAAG,CAAA;;iCAEqB,CAAA;AACjC,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Registration recovery only needs completions the run has not observed.\n *\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Retains completion values for replay while removing consumed rows from sweeps.\n * Existing completions stay eligible until first read by the upgraded engine.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const deferredConsumption: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`ALTER TABLE flows_deferred_completions ADD COLUMN consumed_at_ms ${Dialect.integer(sql)}\n CHECK (consumed_at_ms IS NULL OR (${\n Dialect.isInteger(sql, sql`consumed_at_ms`)\n } AND consumed_at_ms >= 0 AND consumed_at_ms <= 9007199254740991))`\n yield* sql`CREATE INDEX flows_deferred_completions_unconsumed_idx\n ON flows_deferred_completions (flow_name, execution_id, deferred_name)\n WHERE consumed_at_ms IS NULL`\n})\n"]}
1
+ {"version":3,"file":"0008_deferred_consumption.js","sourceRoot":"","sources":["../../../src/migrations/0008_deferred_consumption.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA,oEAAoE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;wCAEhG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA,gBAAgB,CAC5C,mEAAmE,CAAA;IACnE,KAAK,CAAC,CAAC,GAAG,CAAA;;iCAEqB,CAAA;AACjC,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Registration recovery only needs completions the run has not observed.\n *\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Retains completion values for replay while removing consumed rows from sweeps.\n * Existing completions stay eligible until first read by the upgraded engine.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const deferredConsumption: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`ALTER TABLE flows_deferred_completions ADD COLUMN consumed_at_ms ${Dialect.integer(sql)}\n CHECK (consumed_at_ms IS NULL OR (${\n Dialect.isInteger(sql, sql`consumed_at_ms`)\n } AND consumed_at_ms >= 0 AND consumed_at_ms <= 9007199254740991))`\n yield* sql`CREATE INDEX flows_deferred_completions_unconsumed_idx\n ON flows_deferred_completions (flow_name, execution_id, deferred_name)\n WHERE consumed_at_ms IS NULL`\n})\n"]}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Journals every deferred/clock change written before the fold's records
10
10
  * existed: a clock row with no `clock-scheduled` record, a completed clock
@@ -1 +1 @@
1
- {"version":3,"file":"0009_deferred_clock_facts.d.ts","sourceRoot":"","sources":["../../../src/migrations/0009_deferred_clock_facts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAwB1D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAkH/E,CAAA"}
1
+ {"version":3,"file":"0009_deferred_clock_facts.d.ts","sourceRoot":"","sources":["../../../src/migrations/0009_deferred_clock_facts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAwBjD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAkH/E,CAAA"}
@@ -6,7 +6,7 @@
6
6
  import { FlowEngine } from "@smthrs/engine";
7
7
  import * as JournalEvent from "@smthrs/journal/JournalEvent";
8
8
  import * as Effect from "effect/Effect";
9
- import * as SqlClient from "effect/unstable/sql/SqlClient";
9
+ import * as SqlClient from "effect/sql/SqlClient";
10
10
  import { EventTypes } from "../EventTypes.js";
11
11
  const optionalTime = (value) => value === null ? null : Number(value);
12
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"0009_deferred_clock_facts.js","sourceRoot":"","sources":["../../../src/migrations/0009_deferred_clock_facts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAqB7C,MAAM,YAAY,GAAG,CAAC,KAA6B,EAAiB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAE5G;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACvG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAClC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,GAAG,CAAyF;;YAGhH,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE;QACnB,UAAU,CAAC,cAAc;QACzB,UAAU,CAAC,cAAc;QACzB,UAAU,CAAC,iBAAiB;QAC5B,UAAU,CAAC,gBAAgB;KAC5B,CACH;GACC,CAAA;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAA4B,CAAA;QACzE,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,cAAc,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,cAAc;YAC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,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;QACtD,MAAM,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QAC1D,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,aAAa,EAAE,aAAa,EAAE;YACxG,QAAQ,EAAE,QAAQ,CAAC,SAAS;YAC5B,WAAW,EAAE,QAAQ,CAAC,YAAY;YAClC,YAAY,EAAE,QAAQ,CAAC,aAAa;YACpC,aAAa;YACb,UAAU,EAAE,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC1D,cAAc,EAAE,QAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC;SAC5G,CAAC,CAAA;QACF,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;YAC1B,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE;gBACtG,QAAQ,EAAE,QAAQ,CAAC,SAAS;gBAC5B,WAAW,EAAE,QAAQ,CAAC,YAAY;gBAClC,YAAY,EAAE,QAAQ,CAAC,aAAa;gBACpC,YAAY;aACb,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Backfills the journal records the deferred/clock fold reads.\n *\n * @since 1.0.0\n */\n\nimport { FlowEngine } from \"@smthrs/engine\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\nimport { EventTypes } from \"../EventTypes.ts\"\n\ninterface ClockRow {\n readonly flow_name: string\n readonly execution_id: string\n readonly clock_name: string\n readonly deferred_name: string\n readonly due_at_ms: number | string\n readonly completed_at_ms: number | string | null\n}\n\ninterface DeferredRow {\n readonly flow_name: string\n readonly execution_id: string\n readonly deferred_name: string\n readonly exit_json: string\n readonly metadata_json: string | null\n readonly completed_at_ms: number | string\n readonly consumed_at_ms: number | string | null\n}\n\nconst optionalTime = (value: number | string | null): number | null => value === null ? null : Number(value)\n\n/**\n * Journals every deferred/clock change written before the fold's records\n * existed: a clock row with no `clock-scheduled` record, a completed clock\n * with no `clock-completed` record, a completion with no `deferred-completed`\n * record, and a consumed completion with no `deferred-consumed` record. Without\n * them a rebuild would drop the clock, or re-arm a completed one and wake a run\n * for a result it already observed (issue #2037).\n *\n * Each backfilled record is appended at the run's next sequence under a\n * `flows.engine.backfill:` producer whose identity names the row, with the\n * lineage meta every engine record carries.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const deferredClockFacts: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n const recorded = new Set<string>()\n const events = yield* sql<{ readonly run_id: string; readonly event_type: string; readonly payload_json: string }>`\n SELECT run_id, event_type, payload_json FROM flows_journal_events\n WHERE ${\n sql.in(\"event_type\", [\n EventTypes.clockScheduled,\n EventTypes.clockCompleted,\n EventTypes.deferredCompleted,\n EventTypes.deferredConsumed\n ])\n }\n `\n for (const event of events) {\n const payload = JSON.parse(event.payload_json) as Record<string, unknown>\n const name = event.event_type === EventTypes.clockScheduled || event.event_type === EventTypes.clockCompleted\n ? payload.clockName\n : payload.deferredName\n recorded.add(JSON.stringify([event.event_type, payload.flowName, payload.executionId, name]))\n }\n const next = new Map<string, number>()\n const append = (\n eventType: string,\n executionId: string,\n name: string,\n emittedAtMs: number,\n payload: Readonly<Record<string, unknown>>\n ) =>\n Effect.gen(function*() {\n const identity = JSON.stringify([eventType, payload.flowName, executionId, name])\n if (recorded.has(identity)) return\n recorded.add(identity)\n let seq = next.get(executionId)\n if (seq === undefined) {\n const rows = yield* sql<{ readonly next: number | string | null }>`\n SELECT MAX(seq) + 1 AS next FROM flows_journal_events WHERE run_id = ${executionId}\n `\n seq = Number(rows[0]?.next ?? 0)\n }\n next.set(executionId, seq + 1)\n const sourceId = `flows.engine.backfill:${JournalEvent.contentDigest(identity)}`\n yield* sql`\n INSERT INTO flows_journal_events (\n run_id, seq, event_id, source_id, source_seq, emitted_at_ms, event_type, payload_json, meta_json\n ) VALUES (\n ${executionId},\n ${seq},\n ${\n JournalEvent.makeEventId(\n executionId as JournalEvent.RunId,\n sourceId as JournalEvent.SourceId,\n 0 as JournalEvent.SourceSeq\n )\n },\n ${sourceId},\n ${0},\n ${emittedAtMs},\n ${eventType},\n ${JSON.stringify(payload)},\n ${JSON.stringify({ lineageId: FlowEngine.Lineage.root(executionId) })}\n )\n `\n })\n\n const clocks = yield* sql<ClockRow>`\n SELECT flow_name, execution_id, clock_name, deferred_name, due_at_ms, completed_at_ms\n FROM flows_clock_deadlines\n ORDER BY execution_id, flow_name, clock_name\n `\n for (const clock of clocks) {\n const dueAtMs = Number(clock.due_at_ms)\n const completedAtMs = optionalTime(clock.completed_at_ms)\n yield* append(EventTypes.clockScheduled, clock.execution_id, clock.clock_name, completedAtMs ?? dueAtMs, {\n flowName: clock.flow_name,\n executionId: clock.execution_id,\n clockName: clock.clock_name,\n deferredName: clock.deferred_name,\n dueAtMs\n })\n if (completedAtMs !== null) {\n yield* append(EventTypes.clockCompleted, clock.execution_id, clock.clock_name, completedAtMs, {\n flowName: clock.flow_name,\n executionId: clock.execution_id,\n clockName: clock.clock_name,\n completedAtMs\n })\n }\n }\n const deferreds = yield* sql<DeferredRow>`\n SELECT flow_name, execution_id, deferred_name, exit_json, metadata_json, completed_at_ms, consumed_at_ms\n FROM flows_deferred_completions\n ORDER BY execution_id, flow_name, deferred_name\n `\n for (const deferred of deferreds) {\n const completedAtMs = Number(deferred.completed_at_ms)\n const consumedAtMs = optionalTime(deferred.consumed_at_ms)\n yield* append(EventTypes.deferredCompleted, deferred.execution_id, deferred.deferred_name, completedAtMs, {\n flowName: deferred.flow_name,\n executionId: deferred.execution_id,\n deferredName: deferred.deferred_name,\n completedAtMs,\n exitDigest: JournalEvent.contentDigest(deferred.exit_json),\n metadataDigest: deferred.metadata_json === null ? null : JournalEvent.contentDigest(deferred.metadata_json)\n })\n if (consumedAtMs !== null) {\n yield* append(EventTypes.deferredConsumed, deferred.execution_id, deferred.deferred_name, consumedAtMs, {\n flowName: deferred.flow_name,\n executionId: deferred.execution_id,\n deferredName: deferred.deferred_name,\n consumedAtMs\n })\n }\n }\n})\n"]}
1
+ {"version":3,"file":"0009_deferred_clock_facts.js","sourceRoot":"","sources":["../../../src/migrations/0009_deferred_clock_facts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAqB7C,MAAM,YAAY,GAAG,CAAC,KAA6B,EAAiB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAE5G;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACvG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAClC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,GAAG,CAAyF;;YAGhH,GAAG,CAAC,EAAE,CAAC,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AQ,CAAC,SAAS;gBAC5B,WAAW,EAAE,QAAQ,CAAC,YAAY;gBAClC,YAAY,EAAE,QAAQ,CAAC,aAAa;gBACpC,YAAY;aACb,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Backfills the journal records the deferred/clock fold reads.\n *\n * @since 1.0.0\n */\n\nimport { FlowEngine } from \"@smthrs/engine\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\nimport { EventTypes } from \"../EventTypes.ts\"\n\ninterface ClockRow {\n readonly flow_name: string\n readonly execution_id: string\n readonly clock_name: string\n readonly deferred_name: string\n readonly due_at_ms: number | string\n readonly completed_at_ms: number | string | null\n}\n\ninterface DeferredRow {\n readonly flow_name: string\n readonly execution_id: string\n readonly deferred_name: string\n readonly exit_json: string\n readonly metadata_json: string | null\n readonly completed_at_ms: number | string\n readonly consumed_at_ms: number | string | null\n}\n\nconst optionalTime = (value: number | string | null): number | null => value === null ? null : Number(value)\n\n/**\n * Journals every deferred/clock change written before the fold's records\n * existed: a clock row with no `clock-scheduled` record, a completed clock\n * with no `clock-completed` record, a completion with no `deferred-completed`\n * record, and a consumed completion with no `deferred-consumed` record. Without\n * them a rebuild would drop the clock, or re-arm a completed one and wake a run\n * for a result it already observed (issue #2037).\n *\n * Each backfilled record is appended at the run's next sequence under a\n * `flows.engine.backfill:` producer whose identity names the row, with the\n * lineage meta every engine record carries.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const deferredClockFacts: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n const recorded = new Set<string>()\n const events = yield* sql<{ readonly run_id: string; readonly event_type: string; readonly payload_json: string }>`\n SELECT run_id, event_type, payload_json FROM flows_journal_events\n WHERE ${\n sql.in(\"event_type\", [\n EventTypes.clockScheduled,\n EventTypes.clockCompleted,\n EventTypes.deferredCompleted,\n EventTypes.deferredConsumed\n ])\n }\n `\n for (const event of events) {\n const payload = JSON.parse(event.payload_json) as Record<string, unknown>\n const name = event.event_type === EventTypes.clockScheduled || event.event_type === EventTypes.clockCompleted\n ? payload.clockName\n : payload.deferredName\n recorded.add(JSON.stringify([event.event_type, payload.flowName, payload.executionId, name]))\n }\n const next = new Map<string, number>()\n const append = (\n eventType: string,\n executionId: string,\n name: string,\n emittedAtMs: number,\n payload: Readonly<Record<string, unknown>>\n ) =>\n Effect.gen(function*() {\n const identity = JSON.stringify([eventType, payload.flowName, executionId, name])\n if (recorded.has(identity)) return\n recorded.add(identity)\n let seq = next.get(executionId)\n if (seq === undefined) {\n const rows = yield* sql<{ readonly next: number | string | null }>`\n SELECT MAX(seq) + 1 AS next FROM flows_journal_events WHERE run_id = ${executionId}\n `\n seq = Number(rows[0]?.next ?? 0)\n }\n next.set(executionId, seq + 1)\n const sourceId = `flows.engine.backfill:${JournalEvent.contentDigest(identity)}`\n yield* sql`\n INSERT INTO flows_journal_events (\n run_id, seq, event_id, source_id, source_seq, emitted_at_ms, event_type, payload_json, meta_json\n ) VALUES (\n ${executionId},\n ${seq},\n ${\n JournalEvent.makeEventId(\n executionId as JournalEvent.RunId,\n sourceId as JournalEvent.SourceId,\n 0 as JournalEvent.SourceSeq\n )\n },\n ${sourceId},\n ${0},\n ${emittedAtMs},\n ${eventType},\n ${JSON.stringify(payload)},\n ${JSON.stringify({ lineageId: FlowEngine.Lineage.root(executionId) })}\n )\n `\n })\n\n const clocks = yield* sql<ClockRow>`\n SELECT flow_name, execution_id, clock_name, deferred_name, due_at_ms, completed_at_ms\n FROM flows_clock_deadlines\n ORDER BY execution_id, flow_name, clock_name\n `\n for (const clock of clocks) {\n const dueAtMs = Number(clock.due_at_ms)\n const completedAtMs = optionalTime(clock.completed_at_ms)\n yield* append(EventTypes.clockScheduled, clock.execution_id, clock.clock_name, completedAtMs ?? dueAtMs, {\n flowName: clock.flow_name,\n executionId: clock.execution_id,\n clockName: clock.clock_name,\n deferredName: clock.deferred_name,\n dueAtMs\n })\n if (completedAtMs !== null) {\n yield* append(EventTypes.clockCompleted, clock.execution_id, clock.clock_name, completedAtMs, {\n flowName: clock.flow_name,\n executionId: clock.execution_id,\n clockName: clock.clock_name,\n completedAtMs\n })\n }\n }\n const deferreds = yield* sql<DeferredRow>`\n SELECT flow_name, execution_id, deferred_name, exit_json, metadata_json, completed_at_ms, consumed_at_ms\n FROM flows_deferred_completions\n ORDER BY execution_id, flow_name, deferred_name\n `\n for (const deferred of deferreds) {\n const completedAtMs = Number(deferred.completed_at_ms)\n const consumedAtMs = optionalTime(deferred.consumed_at_ms)\n yield* append(EventTypes.deferredCompleted, deferred.execution_id, deferred.deferred_name, completedAtMs, {\n flowName: deferred.flow_name,\n executionId: deferred.execution_id,\n deferredName: deferred.deferred_name,\n completedAtMs,\n exitDigest: JournalEvent.contentDigest(deferred.exit_json),\n metadataDigest: deferred.metadata_json === null ? null : JournalEvent.contentDigest(deferred.metadata_json)\n })\n if (consumedAtMs !== null) {\n yield* append(EventTypes.deferredConsumed, deferred.execution_id, deferred.deferred_name, consumedAtMs, {\n flowName: deferred.flow_name,\n executionId: deferred.execution_id,\n deferredName: deferred.deferred_name,\n consumedAtMs\n })\n }\n }\n})\n"]}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Bounds cleanup reads to requested pending rows.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"0010_pending_cancellation.d.ts","sourceRoot":"","sources":["../../../src/migrations/0010_pending_cancellation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAIhF,CAAA"}
1
+ {"version":3,"file":"0010_pending_cancellation.d.ts","sourceRoot":"","sources":["../../../src/migrations/0010_pending_cancellation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAIhF,CAAA"}
@@ -4,7 +4,7 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
  import * as Effect from "effect/Effect";
7
- import * as SqlClient from "effect/unstable/sql/SqlClient";
7
+ import * as SqlClient from "effect/sql/SqlClient";
8
8
  /**
9
9
  * Bounds cleanup reads to requested pending rows.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"0010_pending_cancellation.js","sourceRoot":"","sources":["../../../src/migrations/0010_pending_cancellation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA;oEACwD,CAAA;AACpE,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Indexed cancellation cleanup for admissions whose handler is unavailable.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Bounds cleanup reads to requested pending rows.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const pendingCancellation: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE INDEX flows_runs_pending_cancel_idx ON flows_runs (created_at_ms, run_id)\n WHERE status = 'pending' AND cancel_requested_at_ms IS NOT NULL`\n})\n"]}
1
+ {"version":3,"file":"0010_pending_cancellation.js","sourceRoot":"","sources":["../../../src/migrations/0010_pending_cancellation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxG,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAA;IACtC,KAAK,CAAC,CAAC,GAAG,CAAA;oEACwD,CAAA;AACpE,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Indexed cancellation cleanup for admissions whose handler is unavailable.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Bounds cleanup reads to requested pending rows.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const pendingCancellation: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE INDEX flows_runs_pending_cancel_idx ON flows_runs (created_at_ms, run_id)\n WHERE status = 'pending' AND cancel_requested_at_ms IS NOT NULL`\n})\n"]}
@@ -39,7 +39,7 @@ export interface TestStoresOptions {
39
39
  * @category layers
40
40
  * @since 0.1.0
41
41
  */
42
- export declare const database: Layer.Layer<import("effect/unstable/sql/SqlClient").SqlClient | DurableWriter.DurableWriter, import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError, never>;
42
+ export declare const database: Layer.Layer<import("effect/sql/SqlClient").SqlClient | DurableWriter.DurableWriter, import("effect/sql/SqlError").SqlError | import("effect/sql/Migrator").MigrationError, never>;
43
43
  /**
44
44
  * Provides the production SQLite journal, run, attempt, and cache services
45
45
  * over one in-memory database. Migrations run before any durable service is
@@ -54,7 +54,7 @@ export declare const database: Layer.Layer<import("effect/unstable/sql/SqlClient
54
54
  * @category layers
55
55
  * @since 0.1.0
56
56
  */
57
- export declare const layer: (options?: TestStoresOptions) => Layer.Layer<DurableWriter.DurableWriter | CacheStore.CacheStore | import("@smthrs/journal/Journal").Journal | RunStore.RunStore | AttemptStore.AttemptStore | OwnerIdentity.OwnerIdentity | PlanInputStore.PlanInputStore | PlanMergeStore.PlanMergeStore | PlanStore.PlanStore, import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError | import("@smthrs/journal/Journal").JournalError, import("effect/Crypto").Crypto>;
57
+ export declare const layer: (options?: TestStoresOptions) => Layer.Layer<DurableWriter.DurableWriter | CacheStore.CacheStore | import("@smthrs/journal/Journal").Journal | RunStore.RunStore | AttemptStore.AttemptStore | OwnerIdentity.OwnerIdentity | PlanInputStore.PlanInputStore | PlanMergeStore.PlanMergeStore | PlanStore.PlanStore, import("effect/sql/SqlError").SqlError | import("effect/sql/Migrator").MigrationError | import("@smthrs/journal/Journal").JournalError, import("effect/Crypto").Crypto>;
58
58
  /**
59
59
  * The same schema over a named SQLite database or PostgreSQL URL, with the connection exposed.
60
60
  *
@@ -68,7 +68,7 @@ export declare const layer: (options?: TestStoresOptions) => Layer.Layer<Durable
68
68
  * @category layers
69
69
  * @since 0.1.0
70
70
  */
71
- export declare const databaseAt: (filename: string) => Layer.Layer<import("effect/unstable/sql/SqlClient").SqlClient | DurableWriter.DurableWriter, import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError, never>;
71
+ export declare const databaseAt: (filename: string) => Layer.Layer<import("effect/sql/SqlClient").SqlClient | DurableWriter.DurableWriter, import("effect/sql/SqlError").SqlError | import("effect/sql/Migrator").MigrationError, never>;
72
72
  /**
73
73
  * Every durable engine service over one named database, connection included.
74
74
  *
@@ -85,5 +85,5 @@ export declare const databaseAt: (filename: string) => Layer.Layer<import("effec
85
85
  * @category layers
86
86
  * @since 0.1.0
87
87
  */
88
- export declare const layerAt: (filename: string, options?: TestStoresOptions) => Layer.Layer<import("effect/unstable/sql/SqlClient").SqlClient | DurableWriter.DurableWriter | CacheStore.CacheStore | import("@smthrs/journal/Journal").Journal | RunStore.RunStore | DurableEngineState.DurableEngineState | AttemptStore.AttemptStore | OwnerIdentity.OwnerIdentity | PlanInputStore.PlanInputStore | PlanMergeStore.PlanMergeStore | PlanStore.PlanStore, import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError | import("@smthrs/journal/Journal").JournalError, import("effect/Crypto").Crypto>;
88
+ export declare const layerAt: (filename: string, options?: TestStoresOptions) => Layer.Layer<import("effect/sql/SqlClient").SqlClient | DurableWriter.DurableWriter | CacheStore.CacheStore | import("@smthrs/journal/Journal").Journal | RunStore.RunStore | DurableEngineState.DurableEngineState | AttemptStore.AttemptStore | OwnerIdentity.OwnerIdentity | PlanInputStore.PlanInputStore | PlanMergeStore.PlanMergeStore | PlanStore.PlanStore, import("effect/sql/SqlError").SqlError | import("effect/sql/Migrator").MigrationError | import("@smthrs/journal/Journal").JournalError, import("effect/Crypto").Crypto>;
89
89
  //# sourceMappingURL=TestStores.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TestStores.d.ts","sourceRoot":"","sources":["../../../src/test/TestStores.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,aAAa,MAAM,gCAAgC,CAAA;AAI/D,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AAC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0B,CAAA;AAE9D,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,aAAa,GAAG,aAAa,CAAA;IAC5D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,mLAA2D,CAAA;AAEhF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,GAAI,UAAU,iBAAiB,6bAckB,CAAA;AAEnE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,sLAkB1C,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,MAAM,EAAE,UAAU,iBAAiB,ghBAce,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@smthrs/engine-store",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.5",
4
+ "version": "1.0.0-rc.6",
5
5
  "license": "MIT",
6
6
  "smthrs": {
7
7
  "group": "engine"
@@ -386,33 +386,33 @@
386
386
  "tag": "next"
387
387
  },
388
388
  "dependencies": {
389
- "@smthrs/artifacts": "1.0.0-rc.5",
390
- "@smthrs/canonical": "1.0.0-rc.5",
391
- "@smthrs/crypto": "1.0.0-rc.5",
392
- "@smthrs/database": "1.0.0-rc.5",
393
- "@smthrs/engine": "1.0.0-rc.5",
394
- "@smthrs/flow": "1.0.0-rc.5",
395
- "@smthrs/journal": "1.0.0-rc.5",
396
- "@smthrs/kernel": "1.0.0-rc.5",
397
- "@smthrs/keys": "1.0.0-rc.5",
398
- "@smthrs/plan": "1.0.0-rc.5",
399
- "@smthrs/plan-store": "1.0.0-rc.5",
400
- "@smthrs/run-store": "1.0.0-rc.5",
401
- "@smthrs/step-cache": "1.0.0-rc.5",
402
- "@smthrs/capability": "1.0.0-rc.5"
389
+ "@smthrs/artifacts": "1.0.0-rc.6",
390
+ "@smthrs/canonical": "1.0.0-rc.6",
391
+ "@smthrs/crypto": "1.0.0-rc.6",
392
+ "@smthrs/database": "1.0.0-rc.6",
393
+ "@smthrs/engine": "1.0.0-rc.6",
394
+ "@smthrs/flow": "1.0.0-rc.6",
395
+ "@smthrs/journal": "1.0.0-rc.6",
396
+ "@smthrs/kernel": "1.0.0-rc.6",
397
+ "@smthrs/keys": "1.0.0-rc.6",
398
+ "@smthrs/plan": "1.0.0-rc.6",
399
+ "@smthrs/plan-store": "1.0.0-rc.6",
400
+ "@smthrs/run-store": "1.0.0-rc.6",
401
+ "@smthrs/step-cache": "1.0.0-rc.6",
402
+ "@smthrs/capability": "1.0.0-rc.6"
403
403
  },
404
404
  "devDependencies": {
405
405
  "@effect/language-service": "0.87.2",
406
- "@effect/platform-node": "4.0.0-rc.115",
407
- "@effect/vitest": "4.0.0-rc.115",
406
+ "@effect/platform-node": "4.0.4",
407
+ "@effect/vitest": "4.0.4",
408
408
  "@eslint/js": "9.39.5",
409
- "@smthrs/core": "1.0.0-rc.5",
410
- "@smthrs/patterns": "1.0.0-rc.5",
411
- "@smthrs/platform-node": "1.0.0-rc.5",
409
+ "@smthrs/core": "1.0.0-rc.6",
410
+ "@smthrs/patterns": "1.0.0-rc.6",
411
+ "@smthrs/platform-node": "1.0.0-rc.6",
412
412
  "@types/node": "26.4.1",
413
413
  "@vitest/coverage-v8": "5.0.0",
414
414
  "dprint": "0.57.1",
415
- "effect": "4.0.0-rc.115",
415
+ "effect": "4.0.4",
416
416
  "esbuild": "0.28.2",
417
417
  "eslint": "9.39.5",
418
418
  "eslint-import-resolver-typescript": "4.4.5",
@@ -426,7 +426,7 @@
426
426
  "vitest": "5.0.0"
427
427
  },
428
428
  "peerDependencies": {
429
- "effect": "4.0.0-rc.115"
429
+ "effect": "^4.0.4"
430
430
  },
431
431
  "scripts": {
432
432
  "lint": "eslint src --max-warnings=0 && dprint check",
package/src/ArtifactGc.ts CHANGED
@@ -46,7 +46,7 @@ import type * as FileSystem from "effect/FileSystem"
46
46
  import * as Layer from "effect/Layer"
47
47
  import * as Option from "effect/Option"
48
48
  import * as Schema from "effect/Schema"
49
- import * as SqlClient from "effect/unstable/sql/SqlClient"
49
+ import * as SqlClient from "effect/sql/SqlClient"
50
50
  import * as ArtifactRoots from "./internal/ArtifactRoots.ts"
51
51
 
52
52
  /**
@@ -37,7 +37,7 @@ import { Journal, JournalEvent, Projection } from "@smthrs/journal"
37
37
  import * as Effect from "effect/Effect"
38
38
  import * as Option from "effect/Option"
39
39
  import * as Schema from "effect/Schema"
40
- import * as SqlClient from "effect/unstable/sql/SqlClient"
40
+ import * as SqlClient from "effect/sql/SqlClient"
41
41
  import { EventTypes } from "./EventTypes.ts"
42
42
 
43
43
  /**
@@ -46,7 +46,7 @@ import * as Effect from "effect/Effect"
46
46
  import * as FileSystem from "effect/FileSystem"
47
47
  import type * as Layer from "effect/Layer"
48
48
  import * as Schema from "effect/Schema"
49
- import * as SqlClient from "effect/unstable/sql/SqlClient"
49
+ import * as SqlClient from "effect/sql/SqlClient"
50
50
  import * as ArtifactRoots from "./internal/ArtifactRoots.ts"
51
51
 
52
52
  /**
@@ -24,7 +24,7 @@ import * as Option from "effect/Option"
24
24
  import * as Result from "effect/Result"
25
25
  import * as Schema from "effect/Schema"
26
26
  import * as Semaphore from "effect/Semaphore"
27
- import * as SqlClient from "effect/unstable/sql/SqlClient"
27
+ import * as SqlClient from "effect/sql/SqlClient"
28
28
  import * as EngineStateSchema from "./internal/EngineStateSchema.ts"
29
29
  import { compareText } from "./internal/Ordering.ts"
30
30
  import type { OnParentExit } from "./RunState.ts"
@@ -7,7 +7,7 @@
7
7
  import * as Dialect from "@smthrs/database/Dialect"
8
8
  import type { RunStoreError } from "@smthrs/run-store/RunStore"
9
9
  import { Context, Effect, Layer, Schema } from "effect"
10
- import * as SqlClient from "effect/unstable/sql/SqlClient"
10
+ import * as SqlClient from "effect/sql/SqlClient"
11
11
  import * as Read from "./internal/ExecutionSnapshotRead.ts"
12
12
  import * as Relations from "./internal/ExecutionSnapshotRelations.ts"
13
13
 
@@ -94,7 +94,7 @@ export const makeIncarnation = (pid: number | undefined, crypto: Crypto.Crypto):
94
94
  return {
95
95
  hostId,
96
96
  pid: yield* incarnationId,
97
- nonce: yield* crypto.randomUUIDv4.pipe(Effect.orDie)
97
+ nonce: yield* crypto.randomUUIDv4().pipe(Effect.orDie)
98
98
  } satisfies OwnerId
99
99
  })
100
100
  })
@@ -10,7 +10,7 @@ import { FileSet, Plan } from "@smthrs/plan"
10
10
  import { OwnerId } from "@smthrs/run-store/Ownership"
11
11
  import { Context, Effect, Layer, Option, Schema } from "effect"
12
12
  import type * as Crypto from "effect/Crypto"
13
- import * as SqlClient from "effect/unstable/sql/SqlClient"
13
+ import * as SqlClient from "effect/sql/SqlClient"
14
14
 
15
15
  const Natural = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
16
16
 
@@ -10,7 +10,7 @@ import { Plan } from "@smthrs/plan"
10
10
  import { OwnerId } from "@smthrs/run-store/Ownership"
11
11
  import { Context, Effect, Layer, Option, Schema } from "effect"
12
12
  import type * as Crypto from "effect/Crypto"
13
- import * as SqlClient from "effect/unstable/sql/SqlClient"
13
+ import * as SqlClient from "effect/sql/SqlClient"
14
14
 
15
15
  const Natural = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
16
16
  const Positive = Schema.Int.check(Schema.isGreaterThan(0))
package/src/Retention.ts CHANGED
@@ -34,8 +34,8 @@
34
34
  import * as Dialect from "@smthrs/database/Dialect"
35
35
  import * as DurableWriter from "@smthrs/database/DurableWriter"
36
36
  import * as Effect from "effect/Effect"
37
- import * as SqlClient from "effect/unstable/sql/SqlClient"
38
- import type { SqlError } from "effect/unstable/sql/SqlError"
37
+ import * as SqlClient from "effect/sql/SqlClient"
38
+ import type { SqlError } from "effect/sql/SqlError"
39
39
  import * as RetentionOps from "./internal/RetentionOps.ts"
40
40
 
41
41
  export {
@@ -6,7 +6,7 @@
6
6
 
7
7
  import { RunStoreError } from "@smthrs/run-store/RunStore"
8
8
  import { Context, Effect, Layer, Schema } from "effect"
9
- import * as SqlClient from "effect/unstable/sql/SqlClient"
9
+ import * as SqlClient from "effect/sql/SqlClient"
10
10
  import type { Position } from "./ExecutionSnapshot.ts"
11
11
  import * as Read from "./internal/ExecutionSnapshotRead.ts"
12
12
 
@@ -26,7 +26,7 @@ import * as Context from "effect/Context"
26
26
  import * as Effect from "effect/Effect"
27
27
  import * as Layer from "effect/Layer"
28
28
  import * as Schema from "effect/Schema"
29
- import * as SqlClient from "effect/unstable/sql/SqlClient"
29
+ import * as SqlClient from "effect/sql/SqlClient"
30
30
  import * as Selection from "./Selection.ts"
31
31
 
32
32
  /**
@@ -16,7 +16,7 @@ import * as FileSet from "@smthrs/plan/FileSet"
16
16
  import * as Context from "effect/Context"
17
17
  import type * as Crypto from "effect/Crypto"
18
18
  import * as Effect from "effect/Effect"
19
- import * as Encoding from "effect/Encoding"
19
+ import * as Base64 from "effect/encoding/Base64"
20
20
  import * as FileSystem from "effect/FileSystem"
21
21
  import * as Layer from "effect/Layer"
22
22
  import * as Path from "effect/Path"
@@ -680,7 +680,7 @@ export const makeFileSystem = (
680
680
  path,
681
681
  digest,
682
682
  sizeBytes: bytes.length,
683
- content: Encoding.encodeBase64(bytes)
683
+ content: Base64.encode(bytes)
684
684
  } satisfies MaterializedOutput,
685
685
  inlinedBytes: bytes.length
686
686
  }
@@ -720,7 +720,7 @@ export const makeFileSystem = (
720
720
  if (current) return
721
721
  let bytes: Uint8Array
722
722
  if (output.content !== undefined) {
723
- const decoded = Encoding.decodeBase64(output.content)
723
+ const decoded = Base64.decode(output.content)
724
724
  if (Result.isFailure(decoded)) {
725
725
  // Inline content is cache-origin bytes: an undecodable payload is a
726
726
  // tampered durable row, classified exactly like a digest mismatch so
@@ -42,7 +42,7 @@ import { CacheStore } from "@smthrs/step-cache"
42
42
  import * as Effect from "effect/Effect"
43
43
  import * as HashMap from "effect/HashMap"
44
44
  import * as HashSet from "effect/HashSet"
45
- import * as SqlClient from "effect/unstable/sql/SqlClient"
45
+ import * as SqlClient from "effect/sql/SqlClient"
46
46
 
47
47
  /**
48
48
  * The journal event type the fold reads.
@@ -20,7 +20,7 @@
20
20
  import { isReadOnly } from "@smthrs/database/Dialect"
21
21
  import type { Service as WriterService } from "@smthrs/database/DurableWriter"
22
22
  import * as Effect from "effect/Effect"
23
- import type * as SqlClient from "effect/unstable/sql/SqlClient"
23
+ import type * as SqlClient from "effect/sql/SqlClient"
24
24
 
25
25
  /**
26
26
  * SQL dialects a statement is known to be accepted by, verbatim.