@smthrs/run-store 0.0.0-stage → 1.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/LICENSE +21 -0
  3. package/README.md +195 -2
  4. package/dist/cjs/AttemptStore.d.ts +359 -0
  5. package/dist/cjs/AttemptStore.d.ts.map +1 -0
  6. package/dist/cjs/AttemptStore.js +731 -0
  7. package/dist/cjs/AttemptStore.js.map +7 -0
  8. package/dist/cjs/Heartbeat.d.ts +46 -0
  9. package/dist/cjs/Heartbeat.d.ts.map +1 -0
  10. package/dist/cjs/Heartbeat.js +28 -0
  11. package/dist/cjs/Heartbeat.js.map +7 -0
  12. package/dist/cjs/Migrations.d.ts +42 -0
  13. package/dist/cjs/Migrations.d.ts.map +1 -0
  14. package/dist/cjs/Migrations.js +55 -0
  15. package/dist/cjs/Migrations.js.map +7 -0
  16. package/dist/cjs/Ownership.d.ts +275 -0
  17. package/dist/cjs/Ownership.d.ts.map +1 -0
  18. package/dist/cjs/Ownership.js +129 -0
  19. package/dist/cjs/Ownership.js.map +7 -0
  20. package/dist/cjs/RunStore.d.ts +571 -0
  21. package/dist/cjs/RunStore.d.ts.map +1 -0
  22. package/dist/cjs/RunStore.js +1079 -0
  23. package/dist/cjs/RunStore.js.map +7 -0
  24. package/dist/cjs/RunStoreMetrics.d.ts +151 -0
  25. package/dist/cjs/RunStoreMetrics.d.ts.map +1 -0
  26. package/dist/cjs/RunStoreMetrics.js +91 -0
  27. package/dist/cjs/RunStoreMetrics.js.map +7 -0
  28. package/dist/cjs/index.d.ts +47 -0
  29. package/dist/cjs/index.d.ts.map +1 -0
  30. package/dist/cjs/index.js +43 -0
  31. package/dist/cjs/index.js.map +7 -0
  32. package/dist/cjs/internal/Boundary.d.ts +80 -0
  33. package/dist/cjs/internal/Boundary.d.ts.map +1 -0
  34. package/dist/cjs/internal/Boundary.js +92 -0
  35. package/dist/cjs/internal/Boundary.js.map +7 -0
  36. package/dist/cjs/internal/Companion.d.ts +44 -0
  37. package/dist/cjs/internal/Companion.d.ts.map +1 -0
  38. package/dist/cjs/internal/Companion.js +50 -0
  39. package/dist/cjs/internal/Companion.js.map +7 -0
  40. package/dist/cjs/internal/SpanOutcome.d.ts +37 -0
  41. package/dist/cjs/internal/SpanOutcome.d.ts.map +1 -0
  42. package/dist/cjs/internal/SpanOutcome.js +62 -0
  43. package/dist/cjs/internal/SpanOutcome.js.map +7 -0
  44. package/dist/cjs/migrations/0001_initial.d.ts +15 -0
  45. package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
  46. package/dist/cjs/migrations/0001_initial.js +110 -0
  47. package/dist/cjs/migrations/0001_initial.js.map +7 -0
  48. package/dist/cjs/migrations/0002_lineage.d.ts +27 -0
  49. package/dist/cjs/migrations/0002_lineage.d.ts.map +1 -0
  50. package/dist/cjs/migrations/0002_lineage.js +43 -0
  51. package/dist/cjs/migrations/0002_lineage.js.map +7 -0
  52. package/dist/cjs/migrations/0003_execution_revisions.d.ts +15 -0
  53. package/dist/cjs/migrations/0003_execution_revisions.d.ts.map +1 -0
  54. package/dist/cjs/migrations/0003_execution_revisions.js +77 -0
  55. package/dist/cjs/migrations/0003_execution_revisions.js.map +7 -0
  56. package/dist/cjs/migrations/0004_waiting_request.d.ts +32 -0
  57. package/dist/cjs/migrations/0004_waiting_request.d.ts.map +1 -0
  58. package/dist/cjs/migrations/0004_waiting_request.js +42 -0
  59. package/dist/cjs/migrations/0004_waiting_request.js.map +7 -0
  60. package/dist/cjs/package.json +1 -0
  61. package/dist/cjs/test/TestRunStore.d.ts +17 -0
  62. package/dist/cjs/test/TestRunStore.d.ts.map +1 -0
  63. package/dist/cjs/test/TestRunStore.js +42 -0
  64. package/dist/cjs/test/TestRunStore.js.map +7 -0
  65. package/dist/esm/AttemptStore.d.ts +359 -0
  66. package/dist/esm/AttemptStore.d.ts.map +1 -0
  67. package/dist/esm/AttemptStore.js +835 -0
  68. package/dist/esm/AttemptStore.js.map +1 -0
  69. package/dist/esm/Heartbeat.d.ts +46 -0
  70. package/dist/esm/Heartbeat.d.ts.map +1 -0
  71. package/dist/esm/Heartbeat.js +46 -0
  72. package/dist/esm/Heartbeat.js.map +1 -0
  73. package/dist/esm/Migrations.d.ts +42 -0
  74. package/dist/esm/Migrations.d.ts.map +1 -0
  75. package/dist/esm/Migrations.js +56 -0
  76. package/dist/esm/Migrations.js.map +1 -0
  77. package/dist/esm/Ownership.d.ts +275 -0
  78. package/dist/esm/Ownership.d.ts.map +1 -0
  79. package/dist/esm/Ownership.js +299 -0
  80. package/dist/esm/Ownership.js.map +1 -0
  81. package/dist/esm/RunStore.d.ts +571 -0
  82. package/dist/esm/RunStore.d.ts.map +1 -0
  83. package/dist/esm/RunStore.js +1287 -0
  84. package/dist/esm/RunStore.js.map +1 -0
  85. package/dist/esm/RunStoreMetrics.d.ts +151 -0
  86. package/dist/esm/RunStoreMetrics.d.ts.map +1 -0
  87. package/dist/esm/RunStoreMetrics.js +120 -0
  88. package/dist/esm/RunStoreMetrics.js.map +1 -0
  89. package/dist/esm/index.d.ts +47 -0
  90. package/dist/esm/index.d.ts.map +1 -0
  91. package/dist/esm/index.js +47 -0
  92. package/dist/esm/index.js.map +1 -0
  93. package/dist/esm/internal/Boundary.d.ts +80 -0
  94. package/dist/esm/internal/Boundary.d.ts.map +1 -0
  95. package/dist/esm/internal/Boundary.js +109 -0
  96. package/dist/esm/internal/Boundary.js.map +1 -0
  97. package/dist/esm/internal/Companion.d.ts +44 -0
  98. package/dist/esm/internal/Companion.d.ts.map +1 -0
  99. package/dist/esm/internal/Companion.js +53 -0
  100. package/dist/esm/internal/Companion.js.map +1 -0
  101. package/dist/esm/internal/SpanOutcome.d.ts +37 -0
  102. package/dist/esm/internal/SpanOutcome.d.ts.map +1 -0
  103. package/dist/esm/internal/SpanOutcome.js +48 -0
  104. package/dist/esm/internal/SpanOutcome.js.map +1 -0
  105. package/dist/esm/migrations/0001_initial.d.ts +15 -0
  106. package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
  107. package/dist/esm/migrations/0001_initial.js +88 -0
  108. package/dist/esm/migrations/0001_initial.js.map +1 -0
  109. package/dist/esm/migrations/0002_lineage.d.ts +27 -0
  110. package/dist/esm/migrations/0002_lineage.d.ts.map +1 -0
  111. package/dist/esm/migrations/0002_lineage.js +33 -0
  112. package/dist/esm/migrations/0002_lineage.js.map +1 -0
  113. package/dist/esm/migrations/0003_execution_revisions.d.ts +15 -0
  114. package/dist/esm/migrations/0003_execution_revisions.d.ts.map +1 -0
  115. package/dist/esm/migrations/0003_execution_revisions.js +58 -0
  116. package/dist/esm/migrations/0003_execution_revisions.js.map +1 -0
  117. package/dist/esm/migrations/0004_waiting_request.d.ts +32 -0
  118. package/dist/esm/migrations/0004_waiting_request.d.ts.map +1 -0
  119. package/dist/esm/migrations/0004_waiting_request.js +37 -0
  120. package/dist/esm/migrations/0004_waiting_request.js.map +1 -0
  121. package/dist/esm/test/TestRunStore.d.ts +17 -0
  122. package/dist/esm/test/TestRunStore.d.ts.map +1 -0
  123. package/dist/esm/test/TestRunStore.js +19 -0
  124. package/dist/esm/test/TestRunStore.js.map +1 -0
  125. package/docs/README.md +142 -0
  126. package/docs/api.md +901 -0
  127. package/docs/concepts/durable-values.md +140 -0
  128. package/docs/concepts/execution-revisions.md +53 -0
  129. package/docs/concepts/fencing.md +146 -0
  130. package/docs/concepts/leases.md +154 -0
  131. package/docs/concepts/liveness-evidence.md +142 -0
  132. package/docs/guides/cancel-a-run.md +156 -0
  133. package/docs/guides/claim-and-finish-a-run.md +175 -0
  134. package/docs/guides/compose-the-stores.md +142 -0
  135. package/docs/guides/observe-outcomes.md +182 -0
  136. package/docs/guides/record-step-attempts.md +170 -0
  137. package/docs/guides/recover-a-stalled-run.md +173 -0
  138. package/docs/guides/testing.md +141 -0
  139. package/docs/installation.md +109 -0
  140. package/docs/quickstart.md +201 -0
  141. package/docs/troubleshooting.md +255 -0
  142. package/package.json +183 -3
  143. package/src/AttemptStore.ts +1195 -0
  144. package/src/Heartbeat.ts +47 -0
  145. package/src/Migrations.ts +59 -0
  146. package/src/Ownership.ts +407 -0
  147. package/src/RunStore.ts +2063 -0
  148. package/src/RunStoreMetrics.ts +165 -0
  149. package/src/index.ts +51 -0
  150. package/src/internal/Boundary.ts +130 -0
  151. package/src/internal/Companion.ts +64 -0
  152. package/src/internal/SpanOutcome.ts +71 -0
  153. package/src/migrations/0001_initial.ts +114 -0
  154. package/src/migrations/0002_lineage.ts +38 -0
  155. package/src/migrations/0003_execution_revisions.ts +69 -0
  156. package/src/migrations/0004_waiting_request.ts +39 -0
  157. package/src/test/TestRunStore.ts +22 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttemptStore.js","sourceRoot":"","sources":["../../src/AttemptStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAE3F,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAC1D,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAA;AACxD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAEvE,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CACzC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAChC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC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AC,CACpH,IAAI,CACL,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,OAAgB,EACmE,EAAE,CACrF,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Durable storage for individual step attempts.\n *\n * Attempt metadata is deliberately opaque to this module. Its shape belongs to\n * the step executor, and is persisted unchanged across attempt state changes.\n *\n * The running-state and owner fences mean stale attempts and repeated terminal\n * transitions never overwrite the winning row.\n *\n * @since 0.1.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport { DatabaseError, DurableWriter, fromSqlError } from \"@smthrs/database/DurableWriter\"\nimport type { OwnerId } from \"@smthrs/journal/OwnerId\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Option from \"effect/Option\"\nimport * as Schema from \"effect/Schema\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\nimport * as SqlError from \"effect/unstable/sql/SqlError\"\nimport * as Boundary from \"./internal/Boundary.ts\"\nimport { observeExit, observeOutcome } from \"./internal/SpanOutcome.ts\"\n\nconst NonNegativeSafeInt = Schema.Int.check(\n Schema.isGreaterThanOrEqualTo(0),\n Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)\n)\n\nconst durableIdentifier = Schema.NonEmptyString.check(\n Schema.isMaxLength(Boundary.maximumIdentifierLength),\n Schema.makeFilter((value: string) => Boundary.isDurableText(value), { title: \"durableIdentifier\" })\n)\n\n/**\n * Absolute ceiling for {@link Options.maxCheckpointBytes}.\n *\n * This bounds only the configured checkpoint policy; metadata, errors, and\n * outcomes have no byte ceiling.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumCheckpointBytes = 16 * 1024 * 1024\n\n/**\n * Maximum nesting admitted for durable attempt JSON.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumJsonDepth = 128\n\n/**\n * Maximum values and members admitted for durable attempt JSON.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumJsonNodes = 100_000\n\nconst jsonLimits = (maxBytes?: number | undefined): Boundary.JsonLimits => ({\n ...(maxBytes === undefined ? {} : { maxBytes, maxStringBytes: maxBytes }),\n maxDepth: maximumJsonDepth,\n maxMembers: maximumJsonNodes,\n maxNodes: maximumJsonNodes\n})\n\n/**\n * Strict JSON value accepted as executable attempt state.\n *\n * The store still takes an inert snapshot at effect start; this schema is the\n * public declaration contract shared by `Attempt`, `FinishAttempt`, and\n * `AttemptPatch`.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const JsonValue = Schema.declare<Boundary.Json>(\n (value): value is Boundary.Json => Boundary.admitJson(value, jsonLimits()).ok,\n { identifier: \"@smthrs/run-store/JsonValue\" }\n)\n\n/**\n * Strict JSON value accepted as executable attempt state.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type JsonValue = typeof JsonValue.Type\n\n/**\n * Stable error codes returned by attempt persistence operations.\n *\n * @category models\n * @since 0.1.0\n */\nexport const AttemptStoreErrorCode = Schema.Literals([\n \"invalid_attempt\",\n \"constraint\",\n \"decode_failed\",\n \"persistence_failed\",\n \"unknown\"\n])\n\n/**\n * Stable error codes returned by attempt persistence operations.\n *\n * @category models\n * @since 0.1.0\n */\nexport type AttemptStoreErrorCode = typeof AttemptStoreErrorCode.Type\n\n/**\n * Error raised by attempt persistence operations.\n *\n * The identity string equals the defining module path, which is how every\n * tagged identity in this package is named.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class AttemptStoreError extends Schema.TaggedError<AttemptStoreError>()(\n \"@smthrs/run-store/AttemptStoreError\",\n {\n code: AttemptStoreErrorCode,\n method: Schema.String,\n message: Schema.String,\n cause: Schema.optional(Schema.Unknown)\n }\n) {}\n\n/**\n * Identifies one execution of a content-addressed step within a run.\n *\n * @category models\n * @since 0.1.0\n */\nexport const AttemptId = Schema.Struct({\n runId: durableIdentifier,\n stepKeyDigest: durableIdentifier,\n attempt: NonNegativeSafeInt\n})\n\n/**\n * Identifies one execution of a content-addressed step within a run.\n *\n * @category models\n * @since 0.1.0\n */\nexport type AttemptId = typeof AttemptId.Type\n\n/**\n * A durable attempt row.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Attempt = Schema.Struct({\n ...AttemptId.fields,\n state: durableIdentifier,\n startedAtMs: NonNegativeSafeInt,\n finishedAtMs: Schema.optionalKey(NonNegativeSafeInt),\n heartbeatAtMs: Schema.optionalKey(NonNegativeSafeInt),\n checkpoint: Schema.optionalKey(JsonValue),\n error: Schema.optionalKey(JsonValue),\n outcome: Schema.optionalKey(JsonValue),\n meta: JsonValue\n})\n\n/**\n * A durable attempt row.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Attempt = typeof Attempt.Type\n\n/**\n * Input used to finish an existing attempt. `error`, `outcome`, and `meta`\n * follow the same rule as {@link AttemptPatch}: an omitted field is left as\n * recorded, so a terminal transition never erases a value written mid-flight\n * by `put` or `patch`. Supplying one replaces it atomically with the terminal\n * state, which lets an executor durably record what it discovered while\n * handling a failure.\n *\n * @category models\n * @since 0.1.0\n */\nexport const FinishAttempt = Schema.Struct({\n ...AttemptId.fields,\n state: durableIdentifier,\n finishedAtMs: NonNegativeSafeInt,\n error: Schema.optionalKey(JsonValue),\n outcome: Schema.optionalKey(JsonValue),\n meta: Schema.optionalKey(JsonValue)\n})\n\n/**\n * Input used to finish an existing attempt.\n *\n * @category models\n * @since 0.1.0\n */\nexport type FinishAttempt = typeof FinishAttempt.Type\n\n/**\n * Result of starting an owner-fenced attempt.\n *\n * @category models\n * @since 0.1.0\n */\nexport type PutResult =\n | { readonly _tag: \"Inserted\" }\n | { readonly _tag: \"Upserted\" }\n | { readonly _tag: \"ExistingSame\" }\n | { readonly _tag: \"Conflict\" }\n | { readonly _tag: \"FenceLost\" }\n | { readonly _tag: \"RunNotFound\" }\n\n/**\n * Fields a patch may rewrite.\n *\n * A patch never touches `state`, `started_at_ms`, or `finished_at_ms`: those\n * are the lifecycle, and only `put`/`heartbeat`/`finish` move them. An\n * omitted field is left as recorded.\n *\n * @category models\n * @since 0.1.0\n */\nexport const AttemptPatch = Schema.Struct({\n checkpoint: Schema.optionalKey(JsonValue),\n error: Schema.optionalKey(JsonValue),\n outcome: Schema.optionalKey(JsonValue),\n meta: Schema.optionalKey(JsonValue)\n})\n\n/**\n * Fields a patch may rewrite.\n *\n * @category models\n * @since 0.1.0\n */\nexport type AttemptPatch = typeof AttemptPatch.Type\n\n/**\n * Result of an owner-fenced attempt patch.\n *\n * @category models\n * @since 0.1.0\n */\nexport type PatchResult =\n | { readonly _tag: \"Patched\" }\n | { readonly _tag: \"NotFound\" }\n | { readonly _tag: \"FenceLost\" }\n\n/**\n * Store-wide policy.\n *\n * Defaults treat only `running` attempts as in progress, cap checkpoints at\n * 1 MiB, and make attempt insertion first-writer-wins.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Options {\n /**\n * States the store treats as \"attempt still in progress\". `heartbeat` and\n * `finish` fence on membership, and `finish` refuses them as targets.\n * Defaults to `[\"running\"]`.\n */\n readonly inProgressStates?: ReadonlyArray<string> | undefined\n /**\n * Largest encoded checkpoint accepted, in bytes. Defaults to 1 MiB and may\n * not exceed {@link maximumCheckpointBytes}.\n */\n readonly maxCheckpointBytes?: number | undefined\n /**\n * `\"insert\"` (the default) is first-writer-wins: a re-put with different\n * content reports `Conflict`. `\"upsert\"` overwrites it and reports\n * `Upserted` only while the existing row is still in progress. A terminal\n * row remains immutable. Both modes keep the run-ownership fence.\n */\n readonly putMode?: \"insert\" | \"upsert\" | undefined\n}\n\n/**\n * Result of a fenced attempt heartbeat.\n *\n * @category models\n * @since 0.1.0\n */\nexport type HeartbeatResult =\n | { readonly _tag: \"Updated\" }\n | { readonly _tag: \"FenceLost\" }\n | { readonly _tag: \"NotFound\" }\n | { readonly _tag: \"StateChanged\" }\n\n/**\n * Result of a fenced terminal attempt transition.\n *\n * @category models\n * @since 0.1.0\n */\nexport type FinishResult =\n | { readonly _tag: \"Finished\" }\n | { readonly _tag: \"FenceLost\" }\n | { readonly _tag: \"NotFound\" }\n | { readonly _tag: \"StateChanged\" }\n\n/**\n * Attempt persistence operations.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n readonly put: (attempt: Attempt, owner: OwnerId) => Effect.Effect<PutResult, AttemptStoreError>\n readonly get: (id: AttemptId) => Effect.Effect<Option.Option<Attempt>, AttemptStoreError>\n readonly heartbeat: (\n runId: string,\n stepKeyDigest: string,\n attempt: number,\n owner: OwnerId,\n nowMs: number,\n checkpoint?: JsonValue\n ) => Effect.Effect<HeartbeatResult, AttemptStoreError>\n readonly finish: (attempt: FinishAttempt, owner: OwnerId) => Effect.Effect<FinishResult, AttemptStoreError>\n /**\n * Rewrites opaque fields without competing for the attempt lifecycle: a\n * patch never moves `state`, so executors record response text, worktree\n * pointers, or cache flags on running *and* terminal rows. It is fenced on\n * run ownership like every other write — `outcome` is replayed verbatim as\n * the attempt's result, so a delayed patch from an owner that lost the run\n * (or from any writer after the run reached a terminal status and its\n * owner columns were cleared) reports `FenceLost` instead of rewriting the\n * winning row. Prior art: Temporal conditions every persistence write on\n * the shard `rangeID` (`reference/temporal/service/history/shard/`); there\n * is no unfenced write surface.\n */\n readonly patch: (\n id: AttemptId,\n patch: AttemptPatch,\n owner: OwnerId\n ) => Effect.Effect<PatchResult, AttemptStoreError>\n}\n\n/**\n * Service tag for durable step attempts.\n *\n * The identity string equals the defining module path, which is how every\n * service in this package is named.\n *\n * @category services\n * @since 0.1.0\n */\nexport class AttemptStore extends Context.Service<AttemptStore, Service>()(\"@smthrs/run-store/AttemptStore\") {}\n\nconst AttemptRow = Schema.Struct({\n run_id: durableIdentifier,\n step_key_digest: durableIdentifier,\n attempt: NonNegativeSafeInt,\n state: durableIdentifier,\n started_at_ms: NonNegativeSafeInt,\n finished_at_ms: Schema.NullOr(NonNegativeSafeInt),\n heartbeat_at_ms: Schema.NullOr(NonNegativeSafeInt),\n checkpoint_json: Schema.NullOr(Schema.String),\n error_json: Schema.NullOr(Schema.String),\n outcome_json: Schema.NullOr(Schema.String),\n meta_json: Schema.String\n})\n\ntype AttemptRow = typeof AttemptRow.Type\n\ninterface RunFenceRow {\n readonly status: string\n readonly owner_host_id: string | null\n readonly owner_pid: number | null\n readonly owner_nonce: string | null\n}\n\ntype AttemptStoreMethod = \"makeWith\" | keyof Service\n\nconst attemptStoreError = (\n method: AttemptStoreMethod,\n code: AttemptStoreErrorCode,\n detail: string,\n cause?: unknown\n): AttemptStoreError =>\n new AttemptStoreError({\n code,\n method,\n message: `${code}: AttemptStore.${method}: ${detail}`,\n cause\n })\n\nconst error = (method: AttemptStoreMethod, code: AttemptStoreErrorCode, detail: string): AttemptStoreError =>\n attemptStoreError(method, code, detail)\n\nconst encode = (\n method: AttemptStoreMethod,\n value: unknown,\n field: string,\n maxBytes?: number | undefined\n): Effect.Effect<string, AttemptStoreError> =>\n Effect.suspend(() => {\n const admitted = Boundary.admitJson(value, jsonLimits(maxBytes))\n return admitted.ok\n ? Effect.succeed(JSON.stringify(admitted.value))\n : Effect.fail(error(method, \"invalid_attempt\", `${field} ${admitted.complaint}`))\n })\n\nconst encodeOptionalWith =\n (method: AttemptStoreMethod) =>\n (value: unknown | undefined, field: string): Effect.Effect<string | null, AttemptStoreError> =>\n value === undefined ? Effect.succeed(null) : encode(method, value, field)\n\nconst defaultMaxCheckpointBytes = 1024 * 1024\n\nconst defaultInProgressStates: ReadonlyArray<string> = [\"running\"]\n\nconst encodeCheckpointWith =\n (method: AttemptStoreMethod, maxBytes: number) =>\n (value: unknown | undefined): Effect.Effect<string | null, AttemptStoreError> =>\n value === undefined ? Effect.succeed(null) : encode(method, value, \"checkpoint\", maxBytes)\n\nconst decode = (\n method: AttemptStoreMethod,\n value: string | null,\n field: string,\n maxBytes?: number | undefined\n): Effect.Effect<JsonValue | undefined, AttemptStoreError> =>\n Effect.suspend(() => {\n if (value === null) return Effect.succeed(undefined)\n const admitted = Boundary.admitJsonText(value, jsonLimits(maxBytes))\n return admitted.ok\n ? Effect.succeed(admitted.json)\n : Effect.fail(error(method, \"decode_failed\", `${field} ${admitted.complaint}`))\n })\n\nconst decodeRequired = (\n method: AttemptStoreMethod,\n value: string,\n field: string,\n maxBytes?: number | undefined\n): Effect.Effect<JsonValue, AttemptStoreError> =>\n // A non-null SQL column cannot take `decode`'s missing-value branch.\n decode(method, value, field, maxBytes) as Effect.Effect<JsonValue, AttemptStoreError>\n\nconst validateId = (method: AttemptStoreMethod, id: AttemptId): Effect.Effect<void, AttemptStoreError> =>\n Boundary.isDurableText(id.runId) &&\n Boundary.isDurableText(id.stepKeyDigest) &&\n Number.isSafeInteger(id.attempt) &&\n id.attempt >= 0\n ? Effect.void\n : Effect.fail(\n error(method, \"invalid_attempt\", \"attempt identity violates the durable identifier contract\")\n )\n\nconst inspectRecord = (\n input: unknown,\n required: ReadonlyArray<string>,\n optional: ReadonlyArray<string>,\n field: string\n): Readonly<Record<string, unknown>> => {\n if (typeof input !== \"object\" || input === null) throw new TypeError(field)\n const prototype = Object.getPrototypeOf(input)\n if (prototype !== Object.prototype && prototype !== null) throw new TypeError(field)\n const allowed = new Set([...required, ...optional])\n const output = Object.create(null) as Record<string, unknown>\n for (const name of required) {\n const descriptor = Object.getOwnPropertyDescriptor(input, name)\n if (descriptor === undefined || !(\"value\" in descriptor) || !descriptor.enumerable) throw new TypeError(field)\n output[name] = descriptor.value\n }\n for (const name of optional) {\n const descriptor = Object.getOwnPropertyDescriptor(input, name)\n if (descriptor === undefined) continue\n if (!(\"value\" in descriptor) || !descriptor.enumerable) throw new TypeError(field)\n if (descriptor.value !== undefined) output[name] = descriptor.value\n }\n for (const key of Reflect.ownKeys(input)) {\n if (typeof key !== \"string\" || !allowed.has(key)) {\n if (Object.getOwnPropertyDescriptor(input, key)?.enumerable) throw new TypeError(field)\n }\n }\n return output\n}\n\n/**\n * Captures the fencing owner once, as a frozen inert record. Every span, SQL\n * predicate, and fence comparison reads this copy, so an accessor, a proxy, or\n * a mutation during an await cannot put two different owners into one write.\n */\nconst snapshotOwner = (method: AttemptStoreMethod, input: OwnerId): Effect.Effect<OwnerId, AttemptStoreError> =>\n Effect.suspend(() => {\n try {\n const values = inspectRecord(input, [\"hostId\", \"pid\", \"nonce\"], [], \"owner\")\n const owner = Object.freeze({ hostId: values.hostId, pid: values.pid, nonce: values.nonce })\n if (\n Boundary.isDurableText(owner.hostId) && Boundary.isDurableText(owner.nonce) &&\n Number.isSafeInteger(owner.pid) && (owner.pid as number) >= 0\n ) {\n return Effect.succeed(owner as OwnerId)\n }\n } catch {\n // Falls through to the one refusal below.\n }\n return Effect.fail(error(method, \"invalid_attempt\", \"owner must be an inert, valid owner identity\"))\n })\n\nconst snapshotJson = (\n method: AttemptStoreMethod,\n value: unknown,\n field: string,\n maxBytes?: number | undefined\n): { readonly ok: true; readonly value: JsonValue } | { readonly ok: false; readonly error: AttemptStoreError } => {\n const admitted = Boundary.admitJson(value, jsonLimits(maxBytes))\n return admitted.ok\n ? { ok: true, value: admitted.value }\n : { ok: false, error: error(method, \"invalid_attempt\", `${field} ${admitted.complaint}`) }\n}\n\n/**\n * Structural admission for an attempt identity. `Attempt` and `FinishAttempt`\n * extend `AttemptId`, so a stored attempt must pass wherever an id is typed:\n * extra own data fields are ignored, while a non-plain prototype, any\n * enumerable accessor, or a missing or inherited required field is refused.\n */\nconst inspectIdRecord = (input: unknown, field: string): Readonly<Record<string, unknown>> => {\n if (typeof input !== \"object\" || input === null) throw new TypeError(field)\n const prototype = Object.getPrototypeOf(input)\n if (prototype !== Object.prototype && prototype !== null) throw new TypeError(field)\n for (const key of Reflect.ownKeys(input)) {\n const descriptor = Object.getOwnPropertyDescriptor(input, key)\n if (descriptor !== undefined && descriptor.enumerable && !(\"value\" in descriptor)) throw new TypeError(field)\n }\n const output = Object.create(null) as Record<string, unknown>\n for (const name of [\"runId\", \"stepKeyDigest\", \"attempt\"]) {\n const descriptor = Object.getOwnPropertyDescriptor(input, name)\n if (descriptor === undefined || !(\"value\" in descriptor) || !descriptor.enumerable) throw new TypeError(field)\n output[name] = descriptor.value\n }\n return output\n}\n\nconst snapshotId = (method: AttemptStoreMethod, input: AttemptId): Effect.Effect<AttemptId, AttemptStoreError> =>\n Effect.suspend(() => {\n try {\n const values = inspectIdRecord(input, \"attempt id\")\n const id = Object.freeze({\n runId: values.runId,\n stepKeyDigest: values.stepKeyDigest,\n attempt: values.attempt\n }) as AttemptId\n return Effect.as(validateId(method, id), id)\n } catch {\n return Effect.fail(error(method, \"invalid_attempt\", \"attempt id must be an inert data record\"))\n }\n })\n\nconst snapshotAttempt = (method: AttemptStoreMethod, input: Attempt): Effect.Effect<Attempt, AttemptStoreError> =>\n Effect.suspend(() => {\n try {\n const values = inspectRecord(\n input,\n [\"runId\", \"stepKeyDigest\", \"attempt\", \"state\", \"startedAtMs\", \"meta\"],\n [\"finishedAtMs\", \"heartbeatAtMs\", \"checkpoint\", \"error\", \"outcome\"],\n \"attempt\"\n )\n const checkpoint = values.checkpoint === undefined\n ? undefined\n : snapshotJson(method, values.checkpoint, \"checkpoint\", maximumCheckpointBytes)\n const attemptError = values.error === undefined ? undefined : snapshotJson(method, values.error, \"error\")\n const outcome = values.outcome === undefined ? undefined : snapshotJson(method, values.outcome, \"outcome\")\n const meta = snapshotJson(method, values.meta, \"meta\")\n if (checkpoint !== undefined && !checkpoint.ok) return Effect.fail(checkpoint.error)\n if (attemptError !== undefined && !attemptError.ok) return Effect.fail(attemptError.error)\n if (outcome !== undefined && !outcome.ok) return Effect.fail(outcome.error)\n if (!meta.ok) return Effect.fail(meta.error)\n const candidate = Object.freeze({\n runId: values.runId,\n stepKeyDigest: values.stepKeyDigest,\n attempt: values.attempt,\n state: values.state,\n startedAtMs: values.startedAtMs,\n ...(values.finishedAtMs === undefined ? {} : { finishedAtMs: values.finishedAtMs }),\n ...(values.heartbeatAtMs === undefined ? {} : { heartbeatAtMs: values.heartbeatAtMs }),\n ...(checkpoint === undefined ? {} : { checkpoint: checkpoint.value }),\n ...(attemptError === undefined ? {} : { error: attemptError.value }),\n ...(outcome === undefined ? {} : { outcome: outcome.value }),\n meta: meta.value\n })\n return Schema.decodeUnknownEffect(Attempt)(candidate).pipe(\n Effect.mapError(() => error(method, \"invalid_attempt\", \"attempt violates the persistence contract\"))\n )\n } catch {\n return Effect.fail(error(method, \"invalid_attempt\", \"attempt must be an inert data record\"))\n }\n })\n\nconst snapshotFinish = (\n method: AttemptStoreMethod,\n input: FinishAttempt\n): Effect.Effect<FinishAttempt, AttemptStoreError> =>\n Effect.suspend(() => {\n try {\n const values = inspectRecord(\n input,\n [\"runId\", \"stepKeyDigest\", \"attempt\", \"state\", \"finishedAtMs\"],\n [\"error\", \"outcome\", \"meta\"],\n \"finished attempt\"\n )\n const attemptError = values.error === undefined ? undefined : snapshotJson(method, values.error, \"error\")\n const outcome = values.outcome === undefined ? undefined : snapshotJson(method, values.outcome, \"outcome\")\n const meta = values.meta === undefined ? undefined : snapshotJson(method, values.meta, \"meta\")\n if (attemptError !== undefined && !attemptError.ok) return Effect.fail(attemptError.error)\n if (outcome !== undefined && !outcome.ok) return Effect.fail(outcome.error)\n if (meta !== undefined && !meta.ok) return Effect.fail(meta.error)\n return Schema.decodeUnknownEffect(FinishAttempt)(Object.freeze({\n runId: values.runId,\n stepKeyDigest: values.stepKeyDigest,\n attempt: values.attempt,\n state: values.state,\n finishedAtMs: values.finishedAtMs,\n ...(attemptError === undefined ? {} : { error: attemptError.value }),\n ...(outcome === undefined ? {} : { outcome: outcome.value }),\n ...(meta === undefined ? {} : { meta: meta.value })\n })).pipe(Effect.mapError(() => error(method, \"invalid_attempt\", \"finished attempt violates the contract\")))\n } catch {\n return Effect.fail(error(method, \"invalid_attempt\", \"finished attempt must be an inert data record\"))\n }\n })\n\nconst snapshotPatch = (\n method: AttemptStoreMethod,\n input: AttemptPatch\n): Effect.Effect<AttemptPatch, AttemptStoreError> =>\n Effect.suspend(() => {\n try {\n const values = inspectRecord(input, [], [\"checkpoint\", \"error\", \"outcome\", \"meta\"], \"attempt patch\")\n const checkpoint = values.checkpoint === undefined\n ? undefined\n : snapshotJson(method, values.checkpoint, \"checkpoint\", maximumCheckpointBytes)\n const attemptError = values.error === undefined ? undefined : snapshotJson(method, values.error, \"error\")\n const outcome = values.outcome === undefined ? undefined : snapshotJson(method, values.outcome, \"outcome\")\n const meta = values.meta === undefined ? undefined : snapshotJson(method, values.meta, \"meta\")\n if (checkpoint !== undefined && !checkpoint.ok) return Effect.fail(checkpoint.error)\n if (attemptError !== undefined && !attemptError.ok) return Effect.fail(attemptError.error)\n if (outcome !== undefined && !outcome.ok) return Effect.fail(outcome.error)\n if (meta !== undefined && !meta.ok) return Effect.fail(meta.error)\n return Effect.succeed(Object.freeze({\n ...(checkpoint === undefined ? {} : { checkpoint: checkpoint.value }),\n ...(attemptError === undefined ? {} : { error: attemptError.value }),\n ...(outcome === undefined ? {} : { outcome: outcome.value }),\n ...(meta === undefined ? {} : { meta: meta.value })\n }))\n } catch {\n return Effect.fail(error(method, \"invalid_attempt\", \"attempt patch must be an inert data record\"))\n }\n })\n\ninterface ResolvedOptions {\n readonly inProgressStates: ReadonlyArray<string>\n readonly maxCheckpointBytes: number\n readonly putMode: \"insert\" | \"upsert\"\n}\n\nconst snapshotOptions = (\n method: AttemptStoreMethod,\n input: Options\n): Effect.Effect<ResolvedOptions, AttemptStoreError> =>\n Effect.suspend(() => {\n try {\n const values = inspectRecord(\n input,\n [],\n [\"inProgressStates\", \"maxCheckpointBytes\", \"putMode\"],\n \"attempt store options\"\n )\n const rawStates = values.inProgressStates ?? defaultInProgressStates\n const admitted = Boundary.admitJson(rawStates, {\n ...jsonLimits(64 * 1024),\n maxDepth: 2,\n maxMembers: 256,\n maxNodes: 257\n })\n if (!admitted.ok || !Array.isArray(admitted.value)) {\n return Effect.fail(error(method, \"invalid_attempt\", \"inProgressStates must be an inert string array\"))\n }\n const states = admitted.value\n if (\n states.length === 0 ||\n states.some((state) => !Boundary.isDurableText(state)) ||\n new Set(states).size !== states.length\n ) {\n return Effect.fail(\n error(method, \"invalid_attempt\", \"inProgressStates must contain unique durable state names\")\n )\n }\n const maxCheckpointBytes = values.maxCheckpointBytes ?? defaultMaxCheckpointBytes\n if (\n typeof maxCheckpointBytes !== \"number\" || !Number.isSafeInteger(maxCheckpointBytes) ||\n maxCheckpointBytes <= 0 ||\n maxCheckpointBytes > maximumCheckpointBytes\n ) {\n return Effect.fail(\n error(method, \"invalid_attempt\", `maxCheckpointBytes must be between 1 and ${maximumCheckpointBytes}`)\n )\n }\n const putMode = values.putMode ?? \"insert\"\n if (putMode !== \"insert\" && putMode !== \"upsert\") {\n return Effect.fail(error(method, \"invalid_attempt\", \"putMode must be insert or upsert\"))\n }\n return Effect.succeed(Object.freeze({\n inProgressStates: Object.freeze([...states]) as ReadonlyArray<string>,\n maxCheckpointBytes,\n putMode\n }))\n } catch {\n return Effect.fail(error(method, \"invalid_attempt\", \"attempt store options must be an inert data record\"))\n }\n })\n\nconst ownsRunningRun = (row: RunFenceRow, owner: OwnerId): boolean =>\n row.status === \"running\" &&\n row.owner_host_id === owner.hostId &&\n row.owner_pid === owner.pid &&\n row.owner_nonce === owner.nonce\n\nconst sameAttempt = (stored: Attempt, expected: Attempt): boolean =>\n stored.state === expected.state &&\n stored.startedAtMs === expected.startedAtMs &&\n stored.finishedAtMs === expected.finishedAtMs &&\n stored.heartbeatAtMs === expected.heartbeatAtMs &&\n Boundary.sameJson(stored.checkpoint, expected.checkpoint) &&\n Boundary.sameJson(stored.error, expected.error) &&\n Boundary.sameJson(stored.outcome, expected.outcome) &&\n Boundary.sameJson(stored.meta, expected.meta)\n\n/**\n * Curried so each operation names itself once at construction and every\n * failure travels through the one mapper, rather than through a per-call-site\n * closure that only that operation's failing test could ever reach.\n */\nconst mapPersistenceError = (method: AttemptStoreMethod) => (cause: unknown): AttemptStoreError => {\n if (Schema.is(AttemptStoreError)(cause)) {\n return cause\n }\n const sqlError = SqlError.isSqlError(cause)\n const databaseError = Schema.is(DatabaseError)(cause)\n const constraint = sqlError\n ? cause.reason instanceof SqlError.ConstraintError || cause.reason instanceof SqlError.UniqueViolation\n : databaseError && cause.code === \"constraint\"\n const code = constraint ? \"constraint\" : \"persistence_failed\"\n // Causes reach logs and telemetry. Driver failures may retain bound attempt\n // payloads, so publish only a stable, payload-free descriptor.\n return attemptStoreError(\n method,\n code,\n \"attempt persistence failed\",\n {\n category: code,\n reason: sqlError ? cause.reason._tag : databaseError ? cause.code : \"unknown\",\n // The outer writer must still recognize a nested savepoint's conflict.\n ...(sqlError || databaseError\n ? { cause: new DatabaseError({ code: sqlError ? fromSqlError(cause).code : cause.code }) }\n : {})\n }\n )\n}\n\nconst decodeRow = (method: AttemptStoreMethod, input: unknown): Effect.Effect<Attempt, AttemptStoreError> =>\n Schema.decodeUnknownEffect(AttemptRow)(input).pipe(\n Effect.mapError(() => error(method, \"decode_failed\", \"could not decode flows_attempts row\")),\n Effect.flatMap((row) =>\n Effect.all({\n checkpoint: decode(method, row.checkpoint_json, \"checkpoint_json\", maximumCheckpointBytes),\n error: decode(method, row.error_json, \"error_json\"),\n outcome: decode(method, row.outcome_json, \"outcome_json\"),\n meta: decodeRequired(method, row.meta_json, \"meta_json\")\n }).pipe(\n Effect.map(({ checkpoint, error: attemptError, outcome, meta }) =>\n Object.freeze({\n runId: row.run_id,\n stepKeyDigest: row.step_key_digest,\n attempt: row.attempt,\n state: row.state,\n startedAtMs: row.started_at_ms,\n ...(row.finished_at_ms === null ? {} : { finishedAtMs: row.finished_at_ms }),\n ...(row.heartbeat_at_ms === null ? {} : { heartbeatAtMs: row.heartbeat_at_ms }),\n ...(checkpoint === undefined ? {} : { checkpoint }),\n ...(attemptError === undefined ? {} : { error: attemptError }),\n ...(outcome === undefined ? {} : { outcome }),\n meta\n })\n )\n )\n )\n )\n\n/**\n * Builds the SQL-backed attempt store under an explicit policy.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const makeWith = (\n options: Options = {}\n): Effect.Effect<Service, AttemptStoreError, DurableWriter | SqlClient.SqlClient> =>\n Effect.gen(function*() {\n const sql = yield* Effect.service(SqlClient.SqlClient)\n const writer = yield* DurableWriter\n\n const configured = yield* snapshotOptions(\"makeWith\", options)\n const inProgressStates = configured.inProgressStates\n const maxCheckpointBytes = configured.maxCheckpointBytes\n const upsert = configured.putMode === \"upsert\"\n const putEncodeOptional = encodeOptionalWith(\"put\")\n const putEncodeCheckpoint = encodeCheckpointWith(\"put\", maxCheckpointBytes)\n const heartbeatEncodeCheckpoint = encodeCheckpointWith(\"heartbeat\", maxCheckpointBytes)\n const finishEncodeOptional = encodeOptionalWith(\"finish\")\n const patchEncodeOptional = encodeOptionalWith(\"patch\")\n const patchEncodeCheckpoint = encodeCheckpointWith(\"patch\", maxCheckpointBytes)\n const inProgress = sql.in(\"state\", [...inProgressStates])\n\n const put: Service[\"put\"] = Effect.fn(\"AttemptStore.put\")((input, ownerInput) =>\n Effect.gen(function*() {\n const owner = yield* snapshotOwner(\"put\", ownerInput)\n const attempt = yield* snapshotAttempt(\"put\", input)\n yield* Effect.annotateCurrentSpan({\n runId: attempt.runId,\n stepKeyDigest: attempt.stepKeyDigest,\n attempt: attempt.attempt,\n ownerHostId: owner.hostId\n })\n const checkpoint = yield* putEncodeCheckpoint(attempt.checkpoint)\n const attemptError = yield* putEncodeOptional(attempt.error, \"error\")\n const outcome = yield* putEncodeOptional(attempt.outcome, \"outcome\")\n const meta = yield* encode(\"put\", attempt.meta, \"meta\")\n return yield* writer.write(\n Effect.gen(function*() {\n const inserted = yield* sql<{ readonly attempt: number }>`\n INSERT INTO flows_attempts (\n run_id, step_key_digest, attempt, state, started_at_ms, finished_at_ms,\n heartbeat_at_ms, checkpoint_json, error_json, outcome_json, meta_json\n )\n SELECT\n ${attempt.runId}, ${attempt.stepKeyDigest}, ${attempt.attempt}, ${attempt.state},\n ${attempt.startedAtMs}, ${attempt.finishedAtMs ?? null}, ${attempt.heartbeatAtMs ?? null},\n ${checkpoint}, ${attemptError}, ${outcome}, ${meta}\n WHERE EXISTS (\n SELECT 1 FROM flows_runs\n WHERE run_id = ${attempt.runId}\n AND status = 'running'\n AND owner_host_id = ${owner.hostId}\n AND owner_pid = ${owner.pid}\n AND owner_nonce = ${owner.nonce}\n )\n ON CONFLICT (run_id, step_key_digest, attempt) DO NOTHING\n RETURNING attempt\n `\n if (inserted.length > 0) {\n return { _tag: \"Inserted\" } as const\n }\n\n if (upsert) {\n const replaced = yield* sql<{ readonly attempt: number }>`\n UPDATE flows_attempts\n SET\n state = ${attempt.state},\n started_at_ms = ${attempt.startedAtMs},\n finished_at_ms = ${attempt.finishedAtMs ?? null},\n heartbeat_at_ms = ${attempt.heartbeatAtMs ?? null},\n checkpoint_json = ${checkpoint},\n error_json = ${attemptError},\n outcome_json = ${outcome},\n meta_json = ${meta}\n WHERE run_id = ${attempt.runId}\n AND step_key_digest = ${attempt.stepKeyDigest}\n AND attempt = ${attempt.attempt}\n AND ${inProgress}\n AND EXISTS (\n SELECT 1 FROM flows_runs\n WHERE run_id = ${attempt.runId}\n AND status = 'running'\n AND owner_host_id = ${owner.hostId}\n AND owner_pid = ${owner.pid}\n AND owner_nonce = ${owner.nonce}\n )\n RETURNING attempt\n `\n if (replaced.length > 0) {\n return { _tag: \"Upserted\" } as const\n }\n }\n\n const runRows = yield* sql<RunFenceRow>`\n SELECT status, owner_host_id, owner_pid, owner_nonce\n FROM flows_runs WHERE run_id = ${attempt.runId}\n `\n if (runRows.length === 0) {\n return { _tag: \"RunNotFound\" } as const\n }\n if (!ownsRunningRun(runRows[0]!, owner)) {\n return { _tag: \"FenceLost\" } as const\n }\n\n const rows = yield* sql<AttemptRow>`\n SELECT run_id, step_key_digest, attempt, state, started_at_ms, finished_at_ms,\n heartbeat_at_ms, checkpoint_json, error_json, outcome_json, meta_json\n FROM flows_attempts\n WHERE run_id = ${attempt.runId}\n AND step_key_digest = ${attempt.stepKeyDigest}\n AND attempt = ${attempt.attempt}\n `\n /* v8 ignore next -- the owned run and conflicting row are read in the same serialized write transaction */\n if (rows.length === 0) {\n return yield* Effect.fail(error(\"put\", \"unknown\", \"attempt disappeared during put\"))\n }\n const stored = yield* decodeRow(\"put\", rows[0]!)\n return sameAttempt(stored, attempt)\n ? { _tag: \"ExistingSame\" } as const\n : { _tag: \"Conflict\" } as const\n })\n ).pipe(Effect.mapError(mapPersistenceError(\"put\")))\n }).pipe(observeOutcome<PutResult>())\n )\n\n const get: Service[\"get\"] = Effect.fn(\"AttemptStore.get\")((input) =>\n Effect.gen(function*() {\n const id = yield* snapshotId(\"get\", input)\n yield* Effect.annotateCurrentSpan({\n runId: id.runId,\n stepKeyDigest: id.stepKeyDigest,\n attempt: id.attempt\n })\n const rows = yield* sql<Record<string, unknown>>`\n SELECT run_id, step_key_digest, attempt, state, started_at_ms, finished_at_ms,\n heartbeat_at_ms, checkpoint_json, error_json, outcome_json, meta_json\n FROM flows_attempts\n WHERE run_id = ${id.runId} AND step_key_digest = ${id.stepKeyDigest} AND attempt = ${id.attempt}\n `.pipe(Effect.mapError(mapPersistenceError(\"get\")))\n return rows.length === 0 ? Option.none() : yield* Effect.map(decodeRow(\"get\", rows[0]!), Option.some)\n }).pipe(observeExit)\n )\n\n const heartbeat: Service[\"heartbeat\"] = Effect.fn(\"AttemptStore.heartbeat\")((\n runId,\n stepKeyDigest,\n attempt,\n ownerInput,\n nowMs,\n checkpointValue\n ) =>\n Effect.gen(function*() {\n const owner = yield* snapshotOwner(\"heartbeat\", ownerInput)\n yield* validateId(\"heartbeat\", { runId, stepKeyDigest, attempt })\n if (!Number.isSafeInteger(nowMs) || nowMs < 0) {\n return yield* Effect.fail(\n error(\"heartbeat\", \"invalid_attempt\", \"nowMs must be a non-negative safe integer\")\n )\n }\n yield* Effect.annotateCurrentSpan({ runId, stepKeyDigest, attempt, ownerHostId: owner.hostId })\n const checkpoint = yield* heartbeatEncodeCheckpoint(checkpointValue)\n return yield* writer.write(\n Effect.gen(function*() {\n const updated = yield* sql<{ readonly attempt: number }>`\n UPDATE flows_attempts\n SET\n heartbeat_at_ms = ${Dialect.greatest(sql)}(COALESCE(heartbeat_at_ms, ${nowMs}), ${nowMs}),\n checkpoint_json = COALESCE(${checkpoint}, checkpoint_json)\n WHERE run_id = ${runId}\n AND step_key_digest = ${stepKeyDigest}\n AND attempt = ${attempt}\n AND ${inProgress}\n AND EXISTS (\n SELECT 1 FROM flows_runs\n WHERE run_id = ${runId}\n AND status = 'running'\n AND owner_host_id = ${owner.hostId}\n AND owner_pid = ${owner.pid}\n AND owner_nonce = ${owner.nonce}\n )\n RETURNING attempt\n `\n if (updated.length > 0) {\n return { _tag: \"Updated\" } as const\n }\n const found = yield* sql<Pick<AttemptRow, \"state\">>`\n SELECT state FROM flows_attempts\n WHERE run_id = ${runId} AND step_key_digest = ${stepKeyDigest} AND attempt = ${attempt}\n `\n if (found.length === 0) {\n return { _tag: \"NotFound\" } as const\n }\n const runRows = yield* sql<RunFenceRow>`\n SELECT status, owner_host_id, owner_pid, owner_nonce\n FROM flows_runs WHERE run_id = ${runId}\n `\n if (runRows.length === 0 || !ownsRunningRun(runRows[0]!, owner)) {\n return { _tag: \"FenceLost\" } as const\n }\n return { _tag: \"StateChanged\" } as const\n })\n ).pipe(Effect.mapError(mapPersistenceError(\"heartbeat\")))\n }).pipe(observeOutcome<HeartbeatResult>())\n )\n\n const finish: Service[\"finish\"] = Effect.fn(\"AttemptStore.finish\")((input, ownerInput) =>\n Effect.gen(function*() {\n const owner = yield* snapshotOwner(\"finish\", ownerInput)\n const attempt = yield* snapshotFinish(\"finish\", input)\n yield* Effect.annotateCurrentSpan({\n runId: attempt.runId,\n stepKeyDigest: attempt.stepKeyDigest,\n attempt: attempt.attempt,\n ownerHostId: owner.hostId\n })\n if (\n inProgressStates.includes(attempt.state) ||\n !Boundary.isDurableText(attempt.state)\n ) {\n return yield* Effect.fail(\n error(\"finish\", \"invalid_attempt\", \"finish requires a terminal state and valid timestamp\")\n )\n }\n const attemptError = yield* finishEncodeOptional(attempt.error, \"error\")\n const outcome = yield* finishEncodeOptional(attempt.outcome, \"outcome\")\n const meta = yield* finishEncodeOptional(attempt.meta, \"meta\")\n return yield* writer.write(\n Effect.gen(function*() {\n const updated = yield* sql<{ readonly attempt: number }>`\n UPDATE flows_attempts\n SET\n state = ${attempt.state},\n finished_at_ms = ${attempt.finishedAtMs},\n error_json = COALESCE(${attemptError}, error_json),\n outcome_json = COALESCE(${outcome}, outcome_json),\n meta_json = COALESCE(${meta}, meta_json)\n WHERE run_id = ${attempt.runId}\n AND step_key_digest = ${attempt.stepKeyDigest}\n AND attempt = ${attempt.attempt}\n AND ${inProgress}\n AND EXISTS (\n SELECT 1 FROM flows_runs\n WHERE run_id = ${attempt.runId}\n AND status = 'running'\n AND owner_host_id = ${owner.hostId}\n AND owner_pid = ${owner.pid}\n AND owner_nonce = ${owner.nonce}\n )\n RETURNING attempt\n `\n if (updated.length > 0) {\n return { _tag: \"Finished\" } as const\n }\n const found = yield* sql<Pick<AttemptRow, \"state\">>`\n SELECT state FROM flows_attempts\n WHERE run_id = ${attempt.runId}\n AND step_key_digest = ${attempt.stepKeyDigest}\n AND attempt = ${attempt.attempt}\n `\n if (found.length === 0) {\n return { _tag: \"NotFound\" } as const\n }\n const runRows = yield* sql<RunFenceRow>`\n SELECT status, owner_host_id, owner_pid, owner_nonce\n FROM flows_runs WHERE run_id = ${attempt.runId}\n `\n if (runRows.length === 0 || !ownsRunningRun(runRows[0]!, owner)) {\n return { _tag: \"FenceLost\" } as const\n }\n return { _tag: \"StateChanged\" } as const\n })\n ).pipe(Effect.mapError(mapPersistenceError(\"finish\")))\n }).pipe(observeOutcome<FinishResult>())\n )\n\n const patch: Service[\"patch\"] = Effect.fn(\"AttemptStore.patch\")((idInput, patchInput, ownerInput) =>\n Effect.gen(function*() {\n const owner = yield* snapshotOwner(\"patch\", ownerInput)\n const id = yield* snapshotId(\"patch\", idInput)\n const fields = yield* snapshotPatch(\"patch\", patchInput)\n yield* Effect.annotateCurrentSpan({\n runId: id.runId,\n stepKeyDigest: id.stepKeyDigest,\n attempt: id.attempt,\n ownerHostId: owner.hostId\n })\n const checkpoint = yield* patchEncodeCheckpoint(fields.checkpoint)\n const attemptError = yield* patchEncodeOptional(fields.error, \"error\")\n const outcome = yield* patchEncodeOptional(fields.outcome, \"outcome\")\n const meta = yield* patchEncodeOptional(fields.meta, \"meta\")\n return yield* writer.write(\n Effect.gen(function*() {\n // Unlike `heartbeat`/`finish` there is no state predicate: a patch\n // may touch a terminal row (evidence quarantine does), so the run\n // fence is the only gate. After a terminal run transition the\n // owner columns are cleared and every patch is refused.\n const updated = yield* sql<{ readonly attempt: number }>`\n UPDATE flows_attempts\n SET\n checkpoint_json = COALESCE(${checkpoint}, checkpoint_json),\n error_json = COALESCE(${attemptError}, error_json),\n outcome_json = COALESCE(${outcome}, outcome_json),\n meta_json = COALESCE(${meta}, meta_json)\n WHERE run_id = ${id.runId}\n AND step_key_digest = ${id.stepKeyDigest}\n AND attempt = ${id.attempt}\n AND EXISTS (\n SELECT 1 FROM flows_runs\n WHERE run_id = ${id.runId}\n AND status = 'running'\n AND owner_host_id = ${owner.hostId}\n AND owner_pid = ${owner.pid}\n AND owner_nonce = ${owner.nonce}\n )\n RETURNING attempt\n `\n if (updated.length > 0) {\n return { _tag: \"Patched\" } as const\n }\n const found = yield* sql<Pick<AttemptRow, \"state\">>`\n SELECT state FROM flows_attempts\n WHERE run_id = ${id.runId} AND step_key_digest = ${id.stepKeyDigest} AND attempt = ${id.attempt}\n `\n return found.length === 0\n ? { _tag: \"NotFound\" } as const\n : { _tag: \"FenceLost\" } as const\n })\n ).pipe(Effect.mapError(mapPersistenceError(\"patch\")))\n }).pipe(observeOutcome<PatchResult>())\n )\n\n return { put, get, heartbeat, finish, patch }\n })\n\n/**\n * Builds the SQL-backed attempt store with default policy.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make: Effect.Effect<Service, never, DurableWriter | SqlClient.SqlClient> = Effect.orDie(makeWith())\n\n/**\n * Creates an attempt store from an implementation.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const makeNoop = (overrides: Partial<Service> = {}): Service => {\n const unavailable = (method: Exclude<AttemptStoreMethod, \"makeWith\">) =>\n Effect.fail(attemptStoreError(method, \"unknown\", \"the store is unavailable in this environment\"))\n return {\n put: Effect.fn(\"AttemptStore.put\")(() => unavailable(\"put\")),\n get: Effect.fn(\"AttemptStore.get\")(() => unavailable(\"get\")),\n heartbeat: Effect.fn(\"AttemptStore.heartbeat\")(() => unavailable(\"heartbeat\")),\n finish: Effect.fn(\"AttemptStore.finish\")(() => unavailable(\"finish\")),\n patch: Effect.fn(\"AttemptStore.patch\")(() => unavailable(\"patch\")),\n ...overrides\n }\n}\n\n/**\n * Provides a no-op attempt store.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerNoop = (overrides: Partial<Service> = {}): Layer.Layer<AttemptStore> =>\n Layer.succeed(AttemptStore)(makeNoop(overrides))\n\n/**\n * Provides the SQL-backed attempt store.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer: Layer.Layer<AttemptStore, never, DurableWriter | SqlClient.SqlClient> = Layer.effect(AttemptStore)(\n make\n)\n\n/**\n * Provides the SQL-backed attempt store under an explicit policy.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerWith = (\n options: Options\n): Layer.Layer<AttemptStore, AttemptStoreError, DurableWriter | SqlClient.SqlClient> =>\n Layer.effect(AttemptStore)(makeWith(options))\n"]}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The heartbeat lease constants, re-exported from the journal's consensus
3
+ * module.
4
+ *
5
+ * A leaf module on purpose. `RunStore` needs the staleness cutoff for its
6
+ * claim predicates and `Ownership` needs all four for the supervision loop,
7
+ * but `Ownership` imports `RunStore`, so neither could own the constants
8
+ * without the other restating them. The definitions themselves live in
9
+ * `@smthrs/journal`'s `Consensus`: every consensus strategy judges R5
10
+ * staleness against the same cutoff this store uses, and one definition is
11
+ * what keeps that structural.
12
+ *
13
+ * @since 0.1.0
14
+ */
15
+ export {
16
+ /**
17
+ * How often the supervision loop pulses to renew the owner's lease.
18
+ *
19
+ * @since 0.1.0
20
+ * @category constants
21
+ */
22
+ heartbeatInterval,
23
+ /**
24
+ * How far the owner's wall clock may run behind a peer's before the lease
25
+ * reasoning stops holding.
26
+ *
27
+ * @since 0.1.0
28
+ * @category constants
29
+ */
30
+ heartbeatSkewAllowance,
31
+ /**
32
+ * How old a persisted heartbeat must be before a peer may steal the run.
33
+ *
34
+ * @since 0.1.0
35
+ * @category constants
36
+ */
37
+ heartbeatStaleAfter,
38
+ /**
39
+ * How long the owner may keep working through failing or stalled heartbeat
40
+ * writes.
41
+ *
42
+ * @since 0.1.0
43
+ * @category constants
44
+ */
45
+ heartbeatWriteTolerance } from "@smthrs/journal/Consensus";
46
+ //# sourceMappingURL=Heartbeat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Heartbeat.d.ts","sourceRoot":"","sources":["../../src/Heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO;AACL;;;;;GAKG;AACH,iBAAiB;AACjB;;;;;;GAMG;AACH,sBAAsB;AACtB;;;;;GAKG;AACH,mBAAmB;AACnB;;;;;;GAMG;AACH,uBAAuB,EACxB,MAAM,2BAA2B,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The heartbeat lease constants, re-exported from the journal's consensus
3
+ * module.
4
+ *
5
+ * A leaf module on purpose. `RunStore` needs the staleness cutoff for its
6
+ * claim predicates and `Ownership` needs all four for the supervision loop,
7
+ * but `Ownership` imports `RunStore`, so neither could own the constants
8
+ * without the other restating them. The definitions themselves live in
9
+ * `@smthrs/journal`'s `Consensus`: every consensus strategy judges R5
10
+ * staleness against the same cutoff this store uses, and one definition is
11
+ * what keeps that structural.
12
+ *
13
+ * @since 0.1.0
14
+ */
15
+ export {
16
+ /**
17
+ * How often the supervision loop pulses to renew the owner's lease.
18
+ *
19
+ * @since 0.1.0
20
+ * @category constants
21
+ */
22
+ heartbeatInterval,
23
+ /**
24
+ * How far the owner's wall clock may run behind a peer's before the lease
25
+ * reasoning stops holding.
26
+ *
27
+ * @since 0.1.0
28
+ * @category constants
29
+ */
30
+ heartbeatSkewAllowance,
31
+ /**
32
+ * How old a persisted heartbeat must be before a peer may steal the run.
33
+ *
34
+ * @since 0.1.0
35
+ * @category constants
36
+ */
37
+ heartbeatStaleAfter,
38
+ /**
39
+ * How long the owner may keep working through failing or stalled heartbeat
40
+ * writes.
41
+ *
42
+ * @since 0.1.0
43
+ * @category constants
44
+ */
45
+ heartbeatWriteTolerance } from "@smthrs/journal/Consensus";
46
+ //# sourceMappingURL=Heartbeat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Heartbeat.js","sourceRoot":"","sources":["../../src/Heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO;AACL;;;;;GAKG;AACH,iBAAiB;AACjB;;;;;;GAMG;AACH,sBAAsB;AACtB;;;;;GAKG;AACH,mBAAmB;AACnB;;;;;;GAMG;AACH,uBAAuB,EACxB,MAAM,2BAA2B,CAAA","sourcesContent":["/**\n * The heartbeat lease constants, re-exported from the journal's consensus\n * module.\n *\n * A leaf module on purpose. `RunStore` needs the staleness cutoff for its\n * claim predicates and `Ownership` needs all four for the supervision loop,\n * but `Ownership` imports `RunStore`, so neither could own the constants\n * without the other restating them. The definitions themselves live in\n * `@smthrs/journal`'s `Consensus`: every consensus strategy judges R5\n * staleness against the same cutoff this store uses, and one definition is\n * what keeps that structural.\n *\n * @since 0.1.0\n */\n\nexport {\n /**\n * How often the supervision loop pulses to renew the owner's lease.\n *\n * @since 0.1.0\n * @category constants\n */\n heartbeatInterval,\n /**\n * How far the owner's wall clock may run behind a peer's before the lease\n * reasoning stops holding.\n *\n * @since 0.1.0\n * @category constants\n */\n heartbeatSkewAllowance,\n /**\n * How old a persisted heartbeat must be before a peer may steal the run.\n *\n * @since 0.1.0\n * @category constants\n */\n heartbeatStaleAfter,\n /**\n * How long the owner may keep working through failing or stalled heartbeat\n * writes.\n *\n * @since 0.1.0\n * @category constants\n */\n heartbeatWriteTolerance\n} from \"@smthrs/journal/Consensus\"\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Run and attempt schema migrations.
3
+ *
4
+ * This package owns `flows_runs` and `flows_attempts`. It reserves migration
5
+ * id block `1000` so its ids can never collide with the journal's or the step
6
+ * cache's — see `@smthrs/database`'s `Migrations` for how the blocks compose.
7
+ *
8
+ * The SQL `RunStore` arbitrates ownership through `@smthrs/journal`'s
9
+ * `SqlConsensus`, whose lease table the journal's migration set creates, so
10
+ * {@link run} and {@link layer} install the journal's set ahead of this one.
11
+ * {@link set} stays scoped to the run-store tables for compositions that list
12
+ * every set themselves, such as `@smthrs/engine-store/Migrations`.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import * as DatabaseMigrations from "@smthrs/database/Migrations";
17
+ import * as Layer from "effect/Layer";
18
+ /**
19
+ * The run store's namespaced migration set, for composition with the other
20
+ * storage packages.
21
+ *
22
+ * @category migrations
23
+ * @since 0.1.0
24
+ */
25
+ export declare const set: DatabaseMigrations.MigrationSet;
26
+ /**
27
+ * Creates the run and attempt schema, and the journal schema whose consensus
28
+ * lease table the SQL `RunStore` fences through.
29
+ *
30
+ * @category migrations
31
+ * @since 0.1.0
32
+ */
33
+ export declare const run: import("effect/Effect").Effect<readonly (readonly [id: number, name: string])[], import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError, import("effect/unstable/sql/SqlClient").SqlClient>;
34
+ /**
35
+ * Layer that runs run-store migrations before exposing the database to the run
36
+ * and attempt services.
37
+ *
38
+ * @category layers
39
+ * @since 0.1.0
40
+ */
41
+ export declare const layer: Layer.Layer<never, import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError, import("effect/unstable/sql/SqlClient").SqlClient>;
42
+ //# sourceMappingURL=Migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migrations.d.ts","sourceRoot":"","sources":["../../src/Migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,kBAAkB,MAAM,6BAA6B,CAAA;AAEjE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAMrC;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,kBAAkB,CAAC,YASpC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,8OAAuD,CAAA;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,gLAA2B,CAAA"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Run and attempt schema migrations.
3
+ *
4
+ * This package owns `flows_runs` and `flows_attempts`. It reserves migration
5
+ * id block `1000` so its ids can never collide with the journal's or the step
6
+ * cache's — see `@smthrs/database`'s `Migrations` for how the blocks compose.
7
+ *
8
+ * The SQL `RunStore` arbitrates ownership through `@smthrs/journal`'s
9
+ * `SqlConsensus`, whose lease table the journal's migration set creates, so
10
+ * {@link run} and {@link layer} install the journal's set ahead of this one.
11
+ * {@link set} stays scoped to the run-store tables for compositions that list
12
+ * every set themselves, such as `@smthrs/engine-store/Migrations`.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import * as DatabaseMigrations from "@smthrs/database/Migrations";
17
+ import * as JournalMigrations from "@smthrs/journal/Migrations";
18
+ import * as Layer from "effect/Layer";
19
+ import { initial } from "./migrations/0001_initial.js";
20
+ import { lineage } from "./migrations/0002_lineage.js";
21
+ import { executionRevisions } from "./migrations/0003_execution_revisions.js";
22
+ import { waitingRequest } from "./migrations/0004_waiting_request.js";
23
+ /**
24
+ * The run store's namespaced migration set, for composition with the other
25
+ * storage packages.
26
+ *
27
+ * @category migrations
28
+ * @since 0.1.0
29
+ */
30
+ export const set = {
31
+ namespace: "run-store",
32
+ idOffset: DatabaseMigrations.idBlock,
33
+ migrations: {
34
+ "0001_initial": initial,
35
+ "0002_lineage": lineage,
36
+ "0003_execution_revisions": executionRevisions,
37
+ "0004_waiting_request": waitingRequest
38
+ }
39
+ };
40
+ /**
41
+ * Creates the run and attempt schema, and the journal schema whose consensus
42
+ * lease table the SQL `RunStore` fences through.
43
+ *
44
+ * @category migrations
45
+ * @since 0.1.0
46
+ */
47
+ export const run = DatabaseMigrations.run([JournalMigrations.set, set]);
48
+ /**
49
+ * Layer that runs run-store migrations before exposing the database to the run
50
+ * and attempt services.
51
+ *
52
+ * @category layers
53
+ * @since 0.1.0
54
+ */
55
+ export const layer = Layer.effectDiscard(run);
56
+ //# sourceMappingURL=Migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migrations.js","sourceRoot":"","sources":["../../src/Migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,kBAAkB,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,GAAG,GAAoC;IAClD,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,kBAAkB,CAAC,OAAO;IACpC,UAAU,EAAE;QACV,cAAc,EAAE,OAAO;QACvB,cAAc,EAAE,OAAO;QACvB,0BAA0B,EAAE,kBAAkB;QAC9C,sBAAsB,EAAE,cAAc;KACvC;CACF,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA","sourcesContent":["/**\n * Run and attempt schema migrations.\n *\n * This package owns `flows_runs` and `flows_attempts`. It reserves migration\n * id block `1000` so its ids can never collide with the journal's or the step\n * cache's — see `@smthrs/database`'s `Migrations` for how the blocks compose.\n *\n * The SQL `RunStore` arbitrates ownership through `@smthrs/journal`'s\n * `SqlConsensus`, whose lease table the journal's migration set creates, so\n * {@link run} and {@link layer} install the journal's set ahead of this one.\n * {@link set} stays scoped to the run-store tables for compositions that list\n * every set themselves, such as `@smthrs/engine-store/Migrations`.\n *\n * @since 0.1.0\n */\n\nimport * as DatabaseMigrations from \"@smthrs/database/Migrations\"\nimport * as JournalMigrations from \"@smthrs/journal/Migrations\"\nimport * as Layer from \"effect/Layer\"\nimport { initial } from \"./migrations/0001_initial.ts\"\nimport { lineage } from \"./migrations/0002_lineage.ts\"\nimport { executionRevisions } from \"./migrations/0003_execution_revisions.ts\"\nimport { waitingRequest } from \"./migrations/0004_waiting_request.ts\"\n\n/**\n * The run store's namespaced migration set, for composition with the other\n * storage packages.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const set: DatabaseMigrations.MigrationSet = {\n namespace: \"run-store\",\n idOffset: DatabaseMigrations.idBlock,\n migrations: {\n \"0001_initial\": initial,\n \"0002_lineage\": lineage,\n \"0003_execution_revisions\": executionRevisions,\n \"0004_waiting_request\": waitingRequest\n }\n}\n\n/**\n * Creates the run and attempt schema, and the journal schema whose consensus\n * lease table the SQL `RunStore` fences through.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const run = DatabaseMigrations.run([JournalMigrations.set, set])\n\n/**\n * Layer that runs run-store migrations before exposing the database to the run\n * and attempt services.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = Layer.effectDiscard(run)\n"]}