@bastani/atomic 0.9.38-alpha.2 → 0.9.38-alpha.4

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 (249) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/CHANGELOG.md +24 -0
  7. package/dist/builtin/workflows/README.md +5 -10
  8. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  9. package/dist/builtin/workflows/builtin/{chunk-94f8zfz1.js → chunk-454hz1qt.js} +1 -1
  10. package/dist/builtin/workflows/builtin/{chunk-wf876n16.js → chunk-4bwtzyjq.js} +1 -1
  11. package/dist/builtin/workflows/builtin/{chunk-kb7s3gx2.js → chunk-5eh0brtd.js} +1 -1
  12. package/dist/builtin/workflows/builtin/{chunk-r97ndfvt.js → chunk-bjva9j5k.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-x6az1sxp.js → chunk-h5fn47y5.js} +1 -1
  14. package/dist/builtin/workflows/builtin/chunk-na3wpwzh.js +3115 -0
  15. package/dist/builtin/workflows/builtin/{chunk-nkj4qhj6.js → chunk-q7dx7kh7.js} +1 -1
  16. package/dist/builtin/workflows/builtin/{chunk-a1ar035d.js → chunk-qdd897wm.js} +1 -1
  17. package/dist/builtin/workflows/builtin/{chunk-gyjck9z8.js → chunk-qjqn389g.js} +1 -1
  18. package/dist/builtin/workflows/builtin/{chunk-ad83gc5p.js → chunk-qrrkfg9v.js} +5 -12
  19. package/dist/builtin/workflows/builtin/{chunk-632fxeb8.js → chunk-x0vvjyzg.js} +1 -1
  20. package/dist/builtin/workflows/builtin/{chunk-3n2bnz64.js → chunk-xg7kkgf8.js} +2 -2
  21. package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
  22. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
  23. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  24. package/dist/builtin/workflows/builtin/goal.js +3 -3
  25. package/dist/builtin/workflows/builtin/index.js +11 -11
  26. package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
  27. package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
  28. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  29. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  30. package/dist/builtin/workflows/package.json +1 -1
  31. package/dist/builtin/workflows/src/authoring.d.ts +8 -6
  32. package/dist/builtin/workflows/src/durable/journal/conformance.d.ts +4 -0
  33. package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +27 -0
  34. package/dist/builtin/workflows/src/durable/journal/node-sqlite.d.ts +20 -0
  35. package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +21 -0
  36. package/dist/builtin/workflows/src/durable/journal/sqlite-run-journal.d.ts +49 -0
  37. package/dist/builtin/workflows/src/durable/journal/types.d.ts +200 -0
  38. package/dist/builtin/workflows/src/durable/journal/values.d.ts +3 -0
  39. package/dist/builtin/workflows/src/extension/index.bundle.mjs +51916 -88191
  40. package/dist/builtin/workflows/src/index.js +9393 -45371
  41. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -6
  42. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +4 -6
  43. package/dist/bun/split-loader.js +0 -13
  44. package/dist/bun/split-loader.js.map +1 -1
  45. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  46. package/dist/core/agent-session-compaction.js +1 -0
  47. package/dist/core/agent-session-compaction.js.map +1 -1
  48. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  49. package/dist/core/agent-session-extension-bindings.js +4 -0
  50. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  51. package/dist/core/agent-session-tree.d.ts.map +1 -1
  52. package/dist/core/agent-session-tree.js +1 -0
  53. package/dist/core/agent-session-tree.js.map +1 -1
  54. package/dist/core/agent-session-types.d.ts +2 -0
  55. package/dist/core/agent-session-types.d.ts.map +1 -1
  56. package/dist/core/agent-session-types.js.map +1 -1
  57. package/dist/core/compaction/branch-summarization.d.ts +2 -1
  58. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  59. package/dist/core/compaction/branch-summarization.js +6 -6
  60. package/dist/core/compaction/branch-summarization.js.map +1 -1
  61. package/dist/core/compaction/compaction-runner.d.ts +1 -0
  62. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  63. package/dist/core/compaction/compaction-runner.js +4 -1
  64. package/dist/core/compaction/compaction-runner.js.map +1 -1
  65. package/dist/core/compaction/pi-summary-fallback.d.ts +2 -1
  66. package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
  67. package/dist/core/compaction/pi-summary-fallback.js +5 -5
  68. package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
  69. package/dist/core/compaction/utils.d.ts +2 -1
  70. package/dist/core/compaction/utils.d.ts.map +1 -1
  71. package/dist/core/compaction/utils.js +32 -7
  72. package/dist/core/compaction/utils.js.map +1 -1
  73. package/dist/core/extensions/index.d.ts +1 -1
  74. package/dist/core/extensions/index.d.ts.map +1 -1
  75. package/dist/core/extensions/index.js +1 -1
  76. package/dist/core/extensions/index.js.map +1 -1
  77. package/dist/core/extensions/runner.d.ts +2 -0
  78. package/dist/core/extensions/runner.d.ts.map +1 -1
  79. package/dist/core/extensions/runner.js +8 -0
  80. package/dist/core/extensions/runner.js.map +1 -1
  81. package/dist/core/extensions/workflow-events.d.ts +2 -0
  82. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  83. package/dist/core/extensions/workflow-events.js.map +1 -1
  84. package/dist/core/extensions/workflow-run-control.d.ts +3 -3
  85. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  86. package/dist/core/extensions/workflow-run-control.js +4 -4
  87. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  88. package/dist/core/model-resolver-defaults.js +4 -4
  89. package/dist/core/model-resolver-defaults.js.map +1 -1
  90. package/dist/core/session-manager-archive.d.ts.map +1 -1
  91. package/dist/core/session-manager-archive.js +3 -8
  92. package/dist/core/session-manager-archive.js.map +1 -1
  93. package/dist/core/session-manager-core.d.ts.map +1 -1
  94. package/dist/core/session-manager-core.js +14 -20
  95. package/dist/core/session-manager-core.js.map +1 -1
  96. package/dist/core/session-manager-list.d.ts.map +1 -1
  97. package/dist/core/session-manager-list.js +4 -13
  98. package/dist/core/session-manager-list.js.map +1 -1
  99. package/dist/core/session-manager-storage.d.ts +1 -0
  100. package/dist/core/session-manager-storage.d.ts.map +1 -1
  101. package/dist/core/session-manager-storage.js +49 -24
  102. package/dist/core/session-manager-storage.js.map +1 -1
  103. package/dist/core/session-manager-types.d.ts +2 -2
  104. package/dist/core/session-manager-types.d.ts.map +1 -1
  105. package/dist/core/session-manager-types.js +2 -1
  106. package/dist/core/session-manager-types.js.map +1 -1
  107. package/dist/core/session-manager-validation.d.ts +3 -0
  108. package/dist/core/session-manager-validation.d.ts.map +1 -1
  109. package/dist/core/session-manager-validation.js +16 -0
  110. package/dist/core/session-manager-validation.js.map +1 -1
  111. package/dist/core/session-manager.d.ts +1 -2
  112. package/dist/core/session-manager.d.ts.map +1 -1
  113. package/dist/core/session-manager.js +1 -2
  114. package/dist/core/session-manager.js.map +1 -1
  115. package/dist/core/settings-schema.d.ts +4 -0
  116. package/dist/core/settings-schema.d.ts.map +1 -1
  117. package/dist/core/settings-schema.js +9 -0
  118. package/dist/core/settings-schema.js.map +1 -1
  119. package/dist/core/storage/database.d.ts +21 -0
  120. package/dist/core/storage/database.d.ts.map +1 -0
  121. package/dist/core/storage/database.js +2 -0
  122. package/dist/core/storage/database.js.map +1 -0
  123. package/dist/core/storage/errors.d.ts +63 -0
  124. package/dist/core/storage/errors.d.ts.map +1 -0
  125. package/dist/core/storage/errors.js +103 -0
  126. package/dist/core/storage/errors.js.map +1 -0
  127. package/dist/core/storage/index.d.ts +6 -0
  128. package/dist/core/storage/index.d.ts.map +1 -0
  129. package/dist/core/storage/index.js +5 -0
  130. package/dist/core/storage/index.js.map +1 -0
  131. package/dist/core/storage/node-sqlite.d.ts +5 -0
  132. package/dist/core/storage/node-sqlite.d.ts.map +1 -0
  133. package/dist/core/storage/node-sqlite.js +161 -0
  134. package/dist/core/storage/node-sqlite.js.map +1 -0
  135. package/dist/core/storage/prefix.d.ts +5 -0
  136. package/dist/core/storage/prefix.d.ts.map +1 -0
  137. package/dist/core/storage/prefix.js +15 -0
  138. package/dist/core/storage/prefix.js.map +1 -0
  139. package/dist/core/storage/schema.d.ts +3 -0
  140. package/dist/core/storage/schema.d.ts.map +1 -0
  141. package/dist/core/storage/schema.js +6 -0
  142. package/dist/core/storage/schema.js.map +1 -0
  143. package/dist/core/storage/session/conformance.d.ts +12 -0
  144. package/dist/core/storage/session/conformance.d.ts.map +1 -0
  145. package/dist/core/storage/session/conformance.js +674 -0
  146. package/dist/core/storage/session/conformance.js.map +1 -0
  147. package/dist/core/storage/session/entry-structure.d.ts +4 -0
  148. package/dist/core/storage/session/entry-structure.d.ts.map +1 -0
  149. package/dist/core/storage/session/entry-structure.js +83 -0
  150. package/dist/core/storage/session/entry-structure.js.map +1 -0
  151. package/dist/core/storage/session/errors.d.ts +54 -0
  152. package/dist/core/storage/session/errors.d.ts.map +1 -0
  153. package/dist/core/storage/session/errors.js +95 -0
  154. package/dist/core/storage/session/errors.js.map +1 -0
  155. package/dist/core/storage/session/jsonl-session-store.d.ts +57 -0
  156. package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -0
  157. package/dist/core/storage/session/jsonl-session-store.js +482 -0
  158. package/dist/core/storage/session/jsonl-session-store.js.map +1 -0
  159. package/dist/core/storage/session/memory-session-store.d.ts +31 -0
  160. package/dist/core/storage/session/memory-session-store.d.ts.map +1 -0
  161. package/dist/core/storage/session/memory-session-store.js +113 -0
  162. package/dist/core/storage/session/memory-session-store.js.map +1 -0
  163. package/dist/core/storage/session/scratch-directory.d.ts +2 -0
  164. package/dist/core/storage/session/scratch-directory.d.ts.map +1 -0
  165. package/dist/core/storage/session/scratch-directory.js +5 -0
  166. package/dist/core/storage/session/scratch-directory.js.map +1 -0
  167. package/dist/core/storage/session/session-summary.d.ts +24 -0
  168. package/dist/core/storage/session/session-summary.d.ts.map +1 -0
  169. package/dist/core/storage/session/session-summary.js +79 -0
  170. package/dist/core/storage/session/session-summary.js.map +1 -0
  171. package/dist/core/storage/session/sql-session-store.d.ts +46 -0
  172. package/dist/core/storage/session/sql-session-store.d.ts.map +1 -0
  173. package/dist/core/storage/session/sql-session-store.js +227 -0
  174. package/dist/core/storage/session/sql-session-store.js.map +1 -0
  175. package/dist/core/storage/session/types.d.ts +68 -0
  176. package/dist/core/storage/session/types.d.ts.map +1 -0
  177. package/dist/core/storage/session/types.js +2 -0
  178. package/dist/core/storage/session/types.js.map +1 -0
  179. package/dist/core/storage/session/validation.d.ts +7 -0
  180. package/dist/core/storage/session/validation.d.ts.map +1 -0
  181. package/dist/core/storage/session/validation.js +47 -0
  182. package/dist/core/storage/session/validation.js.map +1 -0
  183. package/dist/core/storage/testing.d.ts +13 -0
  184. package/dist/core/storage/testing.d.ts.map +1 -0
  185. package/dist/core/storage/testing.js +264 -0
  186. package/dist/core/storage/testing.js.map +1 -0
  187. package/dist/index-extensions.d.ts +1 -1
  188. package/dist/index-extensions.d.ts.map +1 -1
  189. package/dist/index-extensions.js +1 -1
  190. package/dist/index-extensions.js.map +1 -1
  191. package/dist/index.d.ts +2 -1
  192. package/dist/index.d.ts.map +1 -1
  193. package/dist/index.js +2 -1
  194. package/dist/index.js.map +1 -1
  195. package/dist/modes/interactive/components/chat-session-host.d.ts +1 -1
  196. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  197. package/dist/modes/interactive/components/chat-session-host.js +8 -4
  198. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  199. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  200. package/dist/modes/interactive/components/scoped-models-selector.js +5 -4
  201. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  202. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  203. package/dist/modes/interactive/interactive-mode-base.js +2 -1
  204. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  205. package/dist/modes/interactive/interactive-queueing.js +8 -5
  206. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  207. package/dist/modes/interactive/interactive-session-runtime.js +6 -0
  208. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  209. package/dist/modes/interactive/interactive-tui.d.ts +1 -0
  210. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  211. package/dist/modes/interactive/interactive-tui.js +9 -2
  212. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  213. package/dist/modes/interactive/program-status-reporter.d.ts +4 -0
  214. package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -1
  215. package/dist/modes/interactive/program-status-reporter.js +45 -6
  216. package/dist/modes/interactive/program-status-reporter.js.map +1 -1
  217. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -1
  218. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  219. package/dist/modes/interactive-engine/extension-ui-bridge.js +9 -1
  220. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  221. package/dist/modes/interactive-engine/protocol.d.ts +4 -0
  222. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  223. package/dist/modes/interactive-engine/protocol.js +39 -1
  224. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  225. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  226. package/dist/modes/rpc/rpc-session-binding.js +10 -0
  227. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  228. package/docs/docs.json +1 -0
  229. package/docs/getting-started/installation.md +1 -2
  230. package/docs/json.md +1 -1
  231. package/docs/packages/authoring.md +1 -1
  232. package/docs/sdk/reference.md +1 -1
  233. package/docs/sdk/web-server.md +5 -5
  234. package/docs/sdk.md +11 -25
  235. package/docs/session-format.md +4 -10
  236. package/docs/settings.md +5 -29
  237. package/docs/storage.md +43 -0
  238. package/docs/workflows/api-reference.md +17 -55
  239. package/docs/workflows/authoring.md +2 -1
  240. package/docs/workflows/operations.md +31 -175
  241. package/docs/workflows/reliable-design.md +1 -1
  242. package/npm-shrinkwrap.json +32 -448
  243. package/package.json +13 -6
  244. package/schemas/settings.schema.json +27 -0
  245. package/dist/builtin/workflows/builtin/chunk-ymwq372z.js +0 -11609
  246. package/dist/core/session-manager-migrations.d.ts +0 -11
  247. package/dist/core/session-manager-migrations.d.ts.map +0 -1
  248. package/dist/core/session-manager-migrations.js +0 -80
  249. package/dist/core/session-manager-migrations.js.map +0 -1
@@ -632,7 +632,8 @@ The workflow runs a readiness preflight as its own `ctx.tool` first, so a missin
632
632
  import { spawn } from "node:child_process";
633
633
  import { homedir } from "node:os";
634
634
  import { join } from "node:path";
635
- import { Type, workflow } from "@bastani/workflows";
635
+ import { workflow } from "@bastani/atomic/workflows";
636
+ import { Type } from "typebox";
636
637
 
637
638
  const sdkDir = join(homedir(), ".cache", "atomic-cua");
638
639
  const cuaEnv = { ...process.env, CUA_DRIVER_RS_TELEMETRY_ENABLED: "false" };
@@ -108,7 +108,7 @@ The workflow tool action surface is:
108
108
  - prompt response: `answer`; run control: `pause`, `quit`, `resume`; free-form stage communication: ordinary Intercom `send`/live `ask` to `workflow:<rootRunId>/<segment>[/<segment>...]` path targets, including `*` and `**` globs
109
109
  - rediscovery: `reload`
110
110
 
111
- Every registered `workflow` tool call has one hard 150-second wall-clock deadline at the shared public tool boundary, leaving startup and acknowledgement headroom beyond the two-minute database admission budget. The deadline covers request handling through the returned result; for background `run` and `resume`, it therefore covers startup/resume admission and acknowledgement only, not the workflow execution that continues after acknowledgement. A deadline returns one structured result:
111
+ Every registered `workflow` tool call has a hard 150-second wall-clock deadline at the public tool boundary. It covers request handling through the returned result; for background `run` and `resume`, it covers startup and acknowledgement, not the workflow execution that continues afterward. A deadline returns one structured result:
112
112
 
113
113
  ```json
114
114
  {
@@ -125,9 +125,9 @@ Expiry aborts the request operation signal so work that supports cancellation ca
125
125
 
126
126
  Explicit user interruption is different from the request deadline. Before startup acknowledgement, interrupting a `run` tool call cancels its initialization owner, records an allocated root as locally `killed`, and prevents delayed setup from starting workflow code. An already-aborted request starts no action. Interrupted resume preparation releases a claim it has acquired instead of dispatching later. After startup acknowledgement, the workflow is detached: aborting the original caller does not stop it; use run-level controls.
127
127
 
128
- Cancellation does not undo mutations that already happened. If registration metadata may already have reached PostgreSQL, Atomic makes a separate bounded attempt to persist cancellation. If that attempt fails, a warning says that cancellation is local and database state is unknown. Inspect status and external effects before retrying an interrupted mutation. Request timeout retains its unknown-outcome behavior and does not cancel an accepted detached launch.
128
+ Cancellation does not undo committed journal writes or external effects. Inspect status and external effects before retrying an interrupted mutation. A request timeout does not cancel an already accepted detached launch.
129
129
 
130
- Run-level `quit` is different from interrupting the startup request: it preserves a paused run rather than cancelling its durable record. During database admission, `quit` acknowledges the local stop immediately, without waiting for registration. Registration continues under its two-minute deadline, and the database pause is saved after registration succeeds. The acknowledgement is not confirmation that the database saved the pause. If settlement fails, inspect `/workflow status <run-id>` for the original error; the local run stays paused and any saved durable progress remains resumable. Without usable durable progress, the run is nonresumable. Restore database availability and inspect status before retrying or starting a new run.
130
+ Run-level `quit` preserves eligible checkpointed work as a paused run instead of cancelling its durable record. Inspect `/workflow status <run-id>` if it reports a storage error; local suspension alone is not proof that the journal saved the pause.
131
131
 
132
132
  From interactive chat, named workflow launches run in the background so the parent chat stays available. Run `/workflow connect <run>` to see agents working and chat with and steer each stage. Inspection, prompt-response, and control calls (`status`, `stages`, `stage`, `transcript`, `answer`, `pause`, `resume`, `quit`) remain available while work runs.
133
133
 
@@ -288,7 +288,7 @@ workflow({ action: "reload", reason: "added team workflow" })
288
288
  Control behavior:
289
289
 
290
290
  - `runId` accepts the full UUID or a unique 8-character hexadecimal prefix for lifecycle and inspection actions, including `status`. Status lists and run pickers show top-level user-launched workflows; nested child runs remain part of the expanded parent graph.
291
- - `status`, `stages`, `stage`, and `transcript` with an explicit full `runId` first use the current session store, then perform one exact DBOS hydration when that id is absent locally. This is inspection only: Atomic does not claim ownership, change status, run workflow code, or resume the workflow. A stale durable `running` root is shown as `crashed` with its resumability and an explicit `/workflow resume <id>` hint; fresh work owned by another Atomic process remains `running`, offers read-only status guidance, and stays protected from local control or resume. Deleted/tombstoned, absent, malformed, cyclic, orphaned, nonreciprocal, out-of-scope, and duplicate-node records report distinct failures instead of inventing a partial graph. `status` without `runId` remains current-session-only and never scans durable history.
291
+ - `status`, `stages`, `stage`, and `transcript` with a full `runId` use the session store, then read the journal if the run is absent locally. Inspection never claims ownership or executes workflow code. A running root with an expired lease appears as `crashed`; a live foreign lease remains protected.
292
292
  - `status` without `runId` lists every top-level run in the session with a concise per-run summary: the full run id, workflow name, run status, started/ended timing with pause-adjusted elapsed time, currently active stages, and awaiting-input details (count plus the stage, prompt id, kind, and message for each pending human prompt). In-flight runs are listed first. The summaries carry the exact identifiers that `answer`, `pause`, `resume`, and `quit` accept, so an orchestrating agent can list runs and act on them directly.
293
293
  - `statusFilter` narrows the `status` run listing: run statuses (`pending`, `running`, `paused`, `blocked`, `completed`, `failed`, `skipped`, `cancelled`, `killed`) match runs directly, `awaiting_input` selects runs with at least one stage awaiting input or pending human prompt, and `all` (the default) includes everything.
294
294
  - `format: "json"` on data-bearing inspection actions (`status`, `stages`, `stage`, `transcript`) returns the full structured result; the default text output for `status` is the concise per-run summary list.
@@ -311,7 +311,7 @@ Control behavior:
311
311
  - A whole-run executor-only pause also holds already-live owned child workflows, including children with no tracked node yet. Resume persists the root's running transition before releasing those child executors; a child-scoped control leaves sibling workflows alone.
312
312
  - Live executor resume does not require a checkpoint. Cross-process resume still requires durable checkpoint or pending-prompt progress: losing a zero-progress live owner cannot reconstruct its JavaScript continuation. Cancelling the original startup request before acknowledgement remains terminal cancellation, not this live pause.
313
313
  - `resume` can target a live paused stage with `stageId`; the target may be an exact stage id or an exact stage name. `message` is forwarded to paused work. Durable/cross-process resume is whole-run only and refuses a stage selector before dispatch rather than resuming the entire root. For a live interrupted streaming prompt, Atomic preserves the existing prompt loop without duplicating the user message and injects `Continue where you left off. If you believe you are finished with your original task (or a redefined task if the user told you), stop.` when required before normal readiness-gate completion. For a paused stage that was idle waiting for a new stage-chat turn, a non-empty message resumes the stage and starts exactly one fresh prompt containing that message; an empty resume releases the pause without creating a prompt.
314
- - An explicit workflow-tool `resume` target absent locally triggers DBOS discovery. Prefixes require successful discovery across live, resumable, and completed catalogs before selecting a unique canonical UUID; discovery failure cannot select a local prefix match. Malformed targets are rejected before lookup. Ordinary `status` listing remains session-local.
314
+ - An explicit workflow-tool `resume` target absent locally triggers journal discovery. Prefixes require successful discovery before selecting a unique UUID; discovery failure cannot select a local prefix match. Malformed targets are rejected before lookup. Ordinary `status` listing remains session-local.
315
315
  - Exact-id durable inspection is separate from resume. `status`, `stages`, `stage`, and `transcript` may hydrate one missing-local root for read-only inspection, but they never claim it or execute replay. Only an explicit `resume` action enters the claim-and-dispatch path.
316
316
  - Run-level `quit` gracefully pauses in-flight work and preserves eligible checkpointed runs for `/workflow resume`. Runs waiting during initialization or between nodes are also controllable, even with no active stage or tool. An executor-only quit retires the owner (including one already paused); without usable durable progress it is nonresumable and offers no resume hint.
317
317
  - `reload` refreshes discovered workflow resources in-process; the optional `reason` is echoed in the result.
@@ -338,7 +338,7 @@ Pause holds the live executor, while quit retires it at a durability boundary. N
338
338
 
339
339
  Quit stops admitting tool calls, cancels owned in-flight calls, and waits a bounded time for cleanup. The result lists `cancelledTools` and any `abandonedTools` with their owning `{runId, nodeId}`. An abandoned callback may still have external effects. Inspect those effects before resuming; unfinished callbacks run again, while completed checkpoints replay.
340
340
 
341
- If the database pause cannot be saved, the run remains locally paused. That is not proof of a durable pause. Preserve the run ID, restore database availability, and inspect status. After successful admission, repeating quit retries a failed pause write; during admission, later failures appear in status. Existing durable progress remains available, but a failed write does not create progress.
341
+ If the journal pause cannot be saved, the run remains locally paused. Preserve the run ID, restore storage access, and inspect status. Retrying quit can save the pause; resume retries the running transition before releasing the executor. Existing checkpoints remain available, but a failed write does not create durable progress.
342
342
 
343
343
  Catching a tool cancellation cannot turn whole-run quit into completion. To abort one tool and continue the workflow, target the tool node instead.
344
344
 
@@ -458,145 +458,33 @@ The readiness prompt can be answered in the attached stage UI or with `workflow(
458
458
 
459
459
  ## Durable Workflows and Cross-Session Resume
460
460
 
461
- Atomic workflows use **DBOS/Postgres as their sole persistent workflow backend**. Atomic configures and launches DBOS lazily on the first workflow action, reuses that process-wide instance, and awaits readiness before workflow execution, resume, inspection, or deletion can access durable state. `DBOS_SYSTEM_DATABASE_URL` or `workflows.durability` in settings may select an existing database. Once DBOS is ready, query and write failures fail the workflow action and never switch backends.
461
+ Atomic workflows use a **local SQLite journal as their only persistent store**. It opens on the first workflow action and commits registrations, checkpoints, and control transitions before reporting them as durable. The default file is `~/.atomic/workflows/journal.sqlite`; set `ATOMIC_WORKFLOW_JOURNAL_PATH` before starting Atomic to select another file. Keep it on durable local storage. Storage failures stop the action rather than selecting another store.
462
462
 
463
- SDK callers can choose the backend and database for each `run()` call, and require durable state so a run fails fast instead of using the in-memory fallback; see [Choosing the durable backend](/workflows/api-reference#choosing-the-durable-backend).
463
+ SDK callers can explicitly choose per-call non-durable execution; see [Choosing the durable backend](/workflows/api-reference#choosing-the-durable-backend).
464
464
 
465
- Root database registration has a two-minute deadline. First-time database provisioning and DBOS initialization are outside that deadline and can take longer. If registration fails or is cancelled, that attempt cannot start workflow code later when PostgreSQL returns. For an outage, restore the database before retrying; do not delete its data to bypass the failure. Authentication and schema errors keep their original diagnostics so you can correct the reported problem. A failed admission can remain a local same-ID retry target, but it is not confirmation that the run was saved for cross-session resume. A previously initialized durable backend does not fall back to in-memory execution after losing its connection.
465
+ ### Storage failures and recovery
466
466
 
467
- Pausing during startup acknowledges the local pause immediately and retains the live executor for resume, without waiting for database admission. Workflow code stays held until explicit resume. Registration continues under its two-minute deadline; inspect `/workflow status <run-id>` for a later persistence error. Do not start a replacement run or delete database records to bypass the error.
467
+ Preserve the journal and full run ID when storage fails. Check the reported file, directory permissions, available space, and filesystem health. Restore access, inspect `/workflow status <full-run-uuid>`, and explicitly resume an eligible run. Do not delete the journal to bypass an error. A failed pause leaves the local executor paused; resume retries the durable running transition before releasing it. If that write also fails, the executor stays paused and the error is reported.
468
468
 
469
- For a PostgreSQL `permission denied` admission error, check the configured database user's grants on the named schema or table, not the model-provider credentials. Authentication failures require correcting the database credentials. When Atomic can verify that rejected registration saved no durable records or identity, it removes the local startup entry. If that verification fails, cleanup reports an error without deleting database records; retain the full run ID and correct the database problem before retrying.
469
+ If recovery reports `Workflow definition not found`, restore the matching definition, run `/workflow reload`, and retry with the same full run ID. Changing a definition or its call order can invalidate checkpoint replay.
470
470
 
471
- If the result says `startup cleanup skipped: database admission unavailable`, Atomic has kept the failed run in the current session and has not attempted to delete its PostgreSQL identity. This also applies when PostgreSQL stops answering rather than refusing connections: cleanup does not extend the admission failure to the 150-second request timeout. Keep the full run ID and restore PostgreSQL before retrying. Current-session `status` can show the local failure, but it does not prove what was saved in PostgreSQL or that cross-session resume is available.
471
+ ### Multiple sessions
472
472
 
473
- If a resume continuation reports `cleanup skipped: database admission unavailable`, the source run stays resumable and no database cleanup is attempted for the failed continuation. Restore PostgreSQL before retrying resume on the source run ID.
473
+ A run with a live journal lease cannot be claimed by another executor, even when a long-running tool has not updated its progress. After a process crashes and its lease expires (about two minutes without renewal), inspection reports `crashed`. Concurrent resume attempts admit one executor.
474
474
 
475
- While root registration is pending, status shows `pending` with phase `starting`, not healthy execution. Status listing and exact-run detail include `phase`, `phaseAgeMs`, `dependencyError`, and `lastProgressAt`. Last progress records admission or a tracked node starting/settling, not polling or a heartbeat. Database failures report `blocked_dependency`; a paused run still reports `paused`. Starting and dependency-blocked runs do not emit "still running" heartbeats.
475
+ SDK recovery requires the original working directory and journal. `session.workflows.getRun(runId)` and `getStages(runId)` inspect saved state without taking ownership; `resume(runId)` explicitly claims eligible work. Save the full UUID. An owning session can also release checkpointed paused runs through `await session.dispose()` or a session switch, allowing another authorized session to adopt them. See [SDK run control](/sdk#workflow-run-control).
476
476
 
477
- For an admitted live executor with no active stage or tool, pause installs a local barrier immediately and acknowledges within 500ms of starting database settlement. The acknowledgement and status distinguish `observed` from `durable` control persistence. If confirmation is still pending at acknowledgement, settlement continues in the background for up to two minutes total. Status becomes `durable` on success; only a settlement failure or deadline reports `blocked_dependency`. `observed` is not proof of a saved pause and does not guarantee cross-process resume. During registration, pause acknowledges immediately while database settlement continues in the background. After registration, resume allows up to two minutes for database confirmation before releasing the barrier, and a resume requested while the pause's confirmation is still pending waits for it within that same two minutes instead of cancelling it. A failed resume leaves the executor paused; restore database availability and retry the same run. These limits do not cover stage cancellation or arbitrary external I/O.
478
-
479
- If registration times out or reports an unavailable database while the run is paused, restore the existing database without resetting data, then resume that same run in the same Atomic process. Resume retries registration with the original identity and releases the existing executor once; repeated concurrent resume requests share the retry and do not start another executor. If the run was not paused, admission failure ends the attempt. A non-retryable admission rejection, such as a permission error, is reported on resume instead of retrying the live executor. Retain the full run ID and inspect it before retrying. Completed checkpoints remain reusable, but an external side effect whose checkpoint was never confirmed can still repeat after a crash; make such operations idempotent.
480
-
481
- Cancellation or the deadline can leave a stored run identity without valid admission metadata, even when PostgreSQL is healthy but slow. After an unavailable-database failure, keep the original Atomic process open, restore PostgreSQL, and explicitly resume the same full run ID. Atomic can reconcile its retained pre-execution identity with the database before admission, without running workflow code during reconciliation. Missing records are repaired only for that known failed admission; conflicting, deleted, or malformed records are refused. A fresh process without valid admission metadata still cannot safely reconstruct the invocation. Keep the ID and report that failure rather than deleting or resetting records. Cancelled and explicitly nonresumable runs are not revived.
482
-
483
- A repeated registration timeout can mean the original registration never finished. Atomic waits within the database admission deadline and does not start workflow code or publish resumable state while that registration remains unresolved. Restoring PostgreSQL alone may not complete a registration abandoned by its original request. Keep the run ID and report the repeated timeout; do not delete database records to force admission. An identity without saved admission metadata is omitted from durable history and cannot be resumed from a fresh process.
484
-
485
- Awaited checkpoint writes also have a two-minute database deadline, including time waiting behind earlier writes for the same run. If a checkpoint fails because PostgreSQL is unavailable, the run keeps its local failure without waiting on another database write to finalize it. Restore PostgreSQL and explicitly resume the same ID; Atomic reads saved receipts before executing unfinished work. A committed checkpoint is reused even if its acknowledgement was lost. If no receipt was saved, the external operation's outcome remains unknown and its callback may run again. Reconcile external outcomes or use idempotency keys before resuming operations that must not repeat. Inspection alone never repairs records or starts execution.
486
-
487
- If recovery reports `Workflow definition not found`, restore the matching workflow definition and run `/workflow reload`, then retry resume with the same full run ID. A failed resume preparation does not discard the recovery target or saved receipts. Do not start a new run to bypass the missing definition.
488
-
489
- **Zero-configuration local database.** Without an explicit database URL from the environment or settings, Atomic uses its own embedded Postgres for DBOS. It requires no Docker daemon, system Postgres install, install lifecycle script, or first-run download.
490
-
491
- Supported targets are Linux x64/ARM64 with glibc or musl, macOS x64/ARM64, and Windows x64/ARM64 using x64 emulation. Linux musl uses PostgreSQL 18.6; other targets use 18.4. Both use the compatible major-version-18 cluster at `~/.atomic/postgres/v18`, with preferred port `5439`.
492
-
493
- The first workflow action initializes and starts the database. Concurrent Atomic sessions share it. Once ready, it stays running after Atomic exits, including after the last client closes.
494
-
495
- Cluster ownership records live beside the data in `~/.atomic/postgres/v18.shared`, outside Atomic installation/version directories. On Linux root installs, use `/var/lib/atomic-postgres/v18.shared`. Preserve these records and the existing data if Atomic reports an identity mismatch or missing `PG_VERSION`; do not delete either to force initialization. An identity mismatch names the fields that differ, for example `(inode)` or `(systemIdentifier)`. A data directory whose filesystem device number changed after a reboot, as can happen on macOS APFS volumes, is not a mismatch: Atomic attaches the cluster and updates the record when the directory inode, path, and PostgreSQL system identifier still match. Closing or reloading an updated Atomic client does not stop a ready shared server. Older clients without this lifetime behavior can still stop servers they started, so finish and close those sessions before relying on the updated behavior for long-running work. An explicit `DBOS_SYSTEM_DATABASE_URL` remains outside managed-cluster lifecycle operations.
496
-
497
- New managed PostgreSQL servers start from a complete, immutable runtime under
498
- `~/.atomic/postgres/pg-runtime` (or `/var/lib/atomic-postgres/pg-runtime` when
499
- running as root on Linux), separate from data and project checkouts. Removing
500
- the original worktree or reinstalling packages does not remove files needed by
501
- a server already using that runtime. Do not delete a runtime generation,
502
- including a damaged one, while a managed server may still use it.
503
- Set `ATOMIC_POSTGRES_RUNTIME_CACHE_DIR` before starting Atomic to share retained runtime generations across separate cluster homes; only the runtime cache moves, not cluster data or ownership records. Keep this directory private to a trusted account and do not remove generations while a server may use them.
504
-
505
- Atomic only uses a runtime cache whose parent folders other accounts can't write to. A folder that only its group can write to is accepted when that group is your own private group: no other account in `/etc/passwd` uses that group as its primary group, and `/etc/group` lists no member other than you. That's the default on Ubuntu and Debian, where umask 002 makes `~/.atomic` group-writable. If Atomic reports an **Untrusted embedded Postgres runtime cache directory ancestor** and falls back to in-memory workflows, run `chmod go-w` on the folder named in the message and restart Atomic.
506
-
507
- **Running as root on Linux.** Atomic needs an available unprivileged account, `postgres`, `nobody`, or `daemon`, because PostgreSQL cannot run as root. The cluster is stored under `/var/lib/atomic-postgres`. If privilege or runtime preparation fails, inspect the diagnostic rather than changing data ownership blindly.
508
-
509
- **Administrator accounts (Windows).** Atomic can start embedded Postgres from an elevated terminal or an administrative account without changing your account or system permissions. The server runs with reduced privileges, as it does under PostgreSQL's own launcher. Regular Windows accounts remain supported.
510
-
511
- Managed PostgreSQL writes startup output to `~/.atomic/postgres/v18.log` and, after startup, server logs to `~/.atomic/postgres/v18/log/postgresql-<Day>.log`, rotating daily through seven weekday files. If Postgres exits during startup, Atomic reports recent output from both logs. Check these logs for configuration or cluster errors; do not delete the cluster while a server may still be using it.
512
-
513
- Set `ATOMIC_POSTGRES_PORT` before starting Atomic to choose a preferred loopback port, for example `ATOMIC_POSTGRES_PORT=15439 atomic`. The default is `5439`; valid values are integers from 1 through 65535. An occupied port causes Atomic to choose another loopback port without changing or stopping the listener. Concurrent sessions use one elected starter and discover the verified actual port from `v18.shared/cluster.json`. A persisted port takes precedence over a changed preference. Startup bind races have at most three attempts; inspect `v18.log` if they fail.
514
-
515
- Atomic checks PostgreSQL readiness and matches the server to the managed data and process identity before attachment. A listening TCP port alone is not sufficient. If an existing cluster has no trusted ownership records, Atomic registers it only when it is the embedded cluster an older Atomic (0.9.10–0.9.19) provisioned, recognized by PostgreSQL major version 18 and the loopback launch of that exact data directory recorded in `postmaster.opts`; registration never reinitializes or modifies the data. Any other unregistered data is refused, and recovery never registers a cluster. Preserve refused data and use an explicit `DBOS_SYSTEM_DATABASE_URL` for that database instead. An explicit URL uses only that endpoint, never alternate managed ports.
516
-
517
- After attachment, Atomic checks the managed server's SQL and process identity before borrowing database connections and every five seconds while idle. Lost health discards old connections. One elected process may restart the existing managed cluster under the shared setup lock; other sessions reconnect to its verified, persisted port. Recovery never initializes missing data, signals an unrelated listener, switches to Docker, or restarts the DBOS executor.
518
-
519
- If the managed server has stopped, the next workflow database action can restart the existing cluster even when `postmaster.opts` is missing. Atomic still requires trusted ownership records, the original cluster identity, and a verified runtime. A hard identity, ownership, or filesystem failure refuses recovery rather than guessing which server or data to use.
520
-
521
- Each process makes at most three recovery attempts per check, with short
522
- backoffs. Later health checks retry after a cooldown if the problem persists.
523
- If the retained PostgreSQL runtime is damaged or missing, reinstall a complete
524
- healthy Atomic package or repair your `ATOMIC_POSTGRES_RUNTIME_DIR` override,
525
- then inspect `v18.log`. Atomic can select a verified replacement, including
526
- after a same-version reinstall, even when the damaged runtime prevents new
527
- database connections. A running server must pass process-identity verification
528
- before Atomic stops it; if the server has already exited, Atomic starts from
529
- the replacement without stopping anything. If a present server's identity
530
- cannot be verified, automatic restart is refused; preserve the data,
531
- `v18.shared`, and damaged runtime, and report the diagnostic for help instead
532
- of deleting files or starting another server. Identity mismatches and database
533
- corruption require investigation, not a package reinstall.
534
- New admission keeps its
535
- two-minute deadline even if shared recovery takes longer. Restoring the
536
- connection does not automatically resume a paused run or prove that an
537
- interrupted write or external side effect committed. Inspect the original run
538
- before retrying. External database URLs receive no managed recovery; restore
539
- that exact endpoint yourself.
540
-
541
- Restart Atomic after upgrading to enable health supervision in a session whose database executor was already initialized by an older version.
542
-
543
- Custom Windows launchers can still use executable names resolved through `PATH` or relative executable paths. `.cmd` and `.bat` launchers accept arguments on administrative accounts, including when the launcher path contains spaces. Explicit `cmd.exe` invocations retain their usual argument handling. Working directories with a `\\?\` prefix are supported when removing the prefix preserves the exact path; if `cmd.exe` reports an unsupported UNC working directory, use an ordinary local directory path. If startup reports that batch file arguments are invalid, remove carriage returns and line breaks from those arguments. If it reports that a string contains NUL characters, check the supplied paths, arguments, and environment entries. Remove the embedded NUL rather than retrying with a truncated value; no server is started for that request.
544
-
545
- If embedded provisioning fails without leaving retained-process cleanup pending, Atomic tries DBOS's reusable `dbos-db` Docker container. A published TCP port is not enough: Atomic waits until PostgreSQL on that container's selected endpoint answers a query before initializing DBOS. Transient startup resets and connection refusals are retried until that bounded wait expires. If DBOS still cannot become ready, workflows **degrade to a process-local in-memory backend with a loud warning** instead of refusing to run: the run executes normally, but its state does not survive the process and `/workflow resume` after exit has nothing to restore. Fix the configured database or set `DBOS_SYSTEM_DATABASE_URL` to a working Postgres to restore durability.
546
-
547
- The Docker readiness query uses the same `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, and `PGSSLMODE` settings as DBOS. If startup reports an invalid `PGPORT`, supply an integer from 1 through 65535. Authentication, TLS, schema and statement-timeout failures are not retried as database startup delays; correct the reported configuration or database problem.
548
-
549
- New Docker fallback containers publish PostgreSQL on `127.0.0.1` at `PGPORT`, or port 5432 when unset. Atomic does not change an existing container's port mapping. When reusing `dbos-db`, keep `PGPORT` consistent with its published port, or set `DBOS_SYSTEM_DATABASE_URL` to the intended database endpoint.
550
-
551
- Fallback starts only after failed DBOS initialization has been cleaned up. If Atomic reports `Workflow backend cleanup failed`, workflow startup stops rather than starting another backend alongside an unconfirmed executor. Correct the reported shutdown problem and restart Atomic; do not delete database data to bypass it.
552
-
553
- **Multiple concurrent Atomic sessions.** A workflow with a healthy connected owner is not a resume target. Fresh progress and database ownership are checked independently, so a quiet long-running tool stays protected. After the owning connection is lost and progress becomes stale in about two minutes, inspection reports `crashed`. Concurrent attempts to resume the same run admit one executor; a stale request reports that the run changed.
554
-
555
- For SDK crash recovery, save the full run UUID and create a fresh authorized session with the original working directory and workflow database configuration. `session.workflows.getRun(runId)` and `getStages(runId)` inspect its durable state without taking ownership. Once `getRun()` reports `crashed`, `session.workflows.resume(runId)` can adopt the root after the database excludes its previous owner and unfinished database writes. A healthy connected owner stays protected despite stale tool progress or copied VM boot/PID identity. This works with `SessionManager.inMemory()` without reopening a session file. Competing adopters cannot both claim the same generation. Missing ownership metadata, another working directory, or unavailable ownership verification keeps the run read-only; older unfenced runs cannot use distributed adoption.
556
-
557
- A paused run launched by the model-facing `workflow` tool is also adoptable once its owning session has left it: the session was disposed, or the host switched to another session with `/new`, `/fork`, or `/resume`. Leaving quits the session's in-flight runs at their last checkpoint and records in the workflow database that the session released its checkpointed paused runs, so `session.workflows.resume(runId)` from another authorized session, or the `workflow` tool's `resume` action in the new session, can adopt them, in the same process or after the owning process exits. The `/workflow resume <id>` command the new session prints does the same and makes the resuming session the owner. Before adopting, the new session's model can inspect a released run with the `workflow` tool's `status` and `stages` actions; pausing, quitting, or answering it still requires owning it. The first adopter becomes the owner; a later attempt is refused, and in the process that released the run the message says the run is now owned by another session (another process sharing the database gets the generic ownership error). A run whose owner crashed without leaving, or whose owning session is still open, stays owned by that session. See [SDK run control](/sdk#workflow-run-control).
558
-
559
- For live-cloned SDK hosts, configure one shared authoritative PostgreSQL server/database. A copied managed PostgreSQL directory in another VM is a separate coordinator, not a shared database, even when its `localhost` connection URL is identical. Independent database copies cannot coordinate ownership across VMs.
560
-
561
- The workflow database endpoint must preserve database sessions. Use direct PostgreSQL connections or session-mode pooling, not transaction-mode or statement-mode pooling. Ownership locks and write authorization depend on that session affinity.
562
-
563
- Ownership fencing prevents a disconnected executor from saving later checkpoints or workflow metadata. It does not stop arbitrary external code already running in that executor. After connection loss, the replacement may retry an unfinished `ctx.tool` while the old callback is still active. Use idempotent external effects and stable operation keys; do not assume exactly-once callback execution. Completed durable checkpoints still replay without executing those callbacks again.
564
-
565
- If Atomic reports that its database ownership connection was lost, restore database availability, inspect the retained run UUID, and resume explicitly. Recovery uses a fresh execution generation; it does not restore the disconnected executor's mutation authority. Preserve the workflow database and completed checkpoints.
566
-
567
- Older unfenced runs require controlled enrollment rather than automatic foreign-owner adoption. Stop all older Atomic workers using that workflow database, upgrade the recovery host, and keep the original database and workflow definition. In an authorized SDK session with the original working directory, use the full UUID with `session.workflows.resume(runId, { legacyRecovery: { olderWorkersStopped: true } })`. This explicit assertion enrolls the legacy root and preserves its completed checkpoints; it does not stop workers itself. Do not use it while an older worker may still be running. Reads and existing owner-scoped controls do not require enrollment. See [SDK run control](/sdk#workflow-run-control) for the recovery example.
568
-
569
- If the recovery host crashes between enrollment and execution, inspect the full UUID and retry that explicit SDK option from a fresh session after its database ownership connection is gone. Only an interrupted enrollment is eligible for this retry; healthy owners and other fenced paused or blocked runs remain protected.
570
-
571
- Independent root workflows persist independently. Nested workflows share their root's ordering.
572
-
573
- ### Workflow database recovery
574
-
575
- Atomic monitors the managed PostgreSQL server and coordinates recovery when it
576
- loses health. The shared cluster keeps its data and ownership records; database
577
- recovery neither starts a replacement workflow nor proves an unfinished external
578
- effect succeeded. Inspect `/workflow status <full-run-uuid>` for the original run
579
- and explicitly resume it when eligible. Do not start a duplicate run or delete
580
- `v18` or `v18.shared` to bypass an identity or availability error.
581
-
582
- Database-unavailable admission errors and status `dependencyError` include the selected database provider, its endpoint without credentials or URL options, and the last retained health-probe or recovery failure. A cooldown error keeps the recovery failure visible. Use that reason to repair a missing runtime or configuration; preserve data and ownership records when identity or filesystem checks fail. After repair, inspect and explicitly resume the original run ID.
583
-
584
- For an explicit `DBOS_SYSTEM_DATABASE_URL`, Atomic does not manage the external
585
- database. Restore that endpoint or correct its credentials and TLS settings,
586
- then inspect and resume the original workflow. If the Docker fallback is in use,
587
- inspect `dbos-db` and correct its service configuration. A database repair does
588
- not automatically resume a paused workflow or establish whether an interrupted
589
- write committed.
477
+ Fencing prevents a displaced executor from saving new checkpoints, not from finishing arbitrary external effects already underway. Use idempotent effects and stable operation keys. Completed checkpoints replay; an unfinished callback may run again.
590
478
 
591
479
  ### How it works
592
480
 
593
481
  - Only `ctx.*` work is checkpointed. Plain TypeScript outside those calls is not durable.
594
- - Completed tool, stage, prompt, and child-workflow checkpoints replay without repeating the completed work. Unfinished work may run again.
595
- - Resume and inspection use DBOS, not chat transcripts as a recovery catalog.
482
+ - Completed tool, stage, prompt, and child-workflow checkpoints replay without repeating completed work. Unfinished work may run again.
483
+ - Resume and inspection read the journal, not chat transcripts, as the recovery catalog.
596
484
  - Unsupported or inconsistent saved topology is refused rather than repaired by guessing. Preserve the run ID and diagnostic.
597
- - Running workflows cannot be resumed elsewhere. Explicit resume claims one owner before dispatch.
485
+ - Independent roots persist independently; nested workflows share their root's ordering.
598
486
 
599
- **Privacy and retention.** DBOS persists workflow inputs, completed tool outputs, UI responses, stage outputs, message delivery receipts, and chat-session paths. Treat the configured database as sensitive. Atomic compacts superseded workflow metadata after saving a recoverable replacement. It keeps up to 50 recent settled messages across the root and all child runs in the root's metadata. Older delivery receipts remain separately so retrying a message ID does not deliver it again. Sticky messages remain available to future matching stages until the root finishes. Atomic archives receipts for completed, skipped, and failed stages before removing them from pending state, along with superseded session receipts. This compaction does not delete checkpoint history or independent chat transcripts. History does not automatically delete workflow records by age or count; confirmed picker deletion removes inactive DBOS workflow state while preserving independent chat transcripts.
487
+ **Privacy and retention.** The journal contains workflow inputs, completed tool outputs, UI responses, stage outputs, message delivery receipts, and chat-session paths. Treat the file and its SQLite sidecar files as sensitive. History does not automatically delete runs by age or count. Confirmed picker deletion removes inactive workflow records while preserving independent chat transcripts.
600
488
 
601
489
  Sticky receipts suppress repeat delivery to the same recipient session, whether the message arrived as pre-start context or through live Intercom forwarding. This also holds after a failed stage retries or a cold resume. Repeated confirmations do not increase the delivery count. Delivery without an explicit recipient uses the stage's previous receipts; delivery to a new recipient session remains eligible.
602
490
 
@@ -685,7 +573,7 @@ Changing `iteration` makes each loop pass a distinct durable call. Reusing the s
685
573
 
686
574
  ### `/workflow resume` — cross-session resume selector
687
575
 
688
- The `/workflow resume` command mirrors `/resume` ergonomics and `/workflows` is its alias. With no id, it builds one newest-first picker from live runs that satisfy the shared resumability predicate and current DBOS resumable/completed records. DBOS is the authoritative catalog; selected records are hydrated and revalidated before resume or inspection. Running workflows never appear: fresh-heartbeat rows are excluded in every session to prevent double dispatch, and stale ones surface as `crashed`. A row whose durable checkpoint or referenced artifact is missing is not resumable and is omitted rather than offered and rejected later. Naming such an id explicitly still produces the existing clear no-checkpoint/not-resumable error.
576
+ The `/workflow resume` command mirrors `/resume` ergonomics and `/workflows` is its alias. With no ID, it builds a newest-first picker from eligible live runs and journal records. Selected records are revalidated before resume or inspection. Runs with live leases are excluded; expired running leases appear as `crashed`.
689
577
 
690
578
  Picker rows use the run label when set, otherwise a one-line objective or prompt input, falling back to the workflow ID. When a generated progress summary is available, it has its own column; status and workflow name precede the identity in the other column. Live rows also show completed/total stages. Without a generated summary, the adjacent column shows those status details instead. Search matches the identity, summary, and full run ID.
691
579
 
@@ -699,9 +587,9 @@ Only runs with usable durable checkpoints or pending prompts can resume. Deleted
699
587
 
700
588
  Rows carry semantic colors — completed green, paused yellow, failed/blocked/crashed red. The open picker live-updates on local run changes plus a bounded cross-session poll, so state transitions appear (and freshly running workflows disappear) without reopening it.
701
589
 
702
- Ctrl+D deletes a highlighted inactive durable or completed row after confirmation. Deletion rechecks same-process activity and the authoritative DBOS status, refuses a `running` workflow, and leaves host and stage chat transcripts untouched. The history surface matches `/resume` retention semantics: eligible runs remain searchable regardless of age or count. Aged-out history is driven by the state-aware `WORKFLOW_ARTIFACT_RETENTION_MS` policy: only terminal or unowned directories older than the policy are pruned, and pruning deletes the durable entry first, removing the artifact directory only when that deletion succeeds — a refused or unavailable deletion preserves both. Running, paused, quit, blocked, and awaiting-input runs retain their artifacts and durable records so they remain resumable. The picker mounts before asynchronous catalog hydration completes and merges DBOS rows when ready.
590
+ Ctrl+D deletes a highlighted inactive durable or completed row after confirmation. Deletion rechecks same-process activity and journal ownership, refuses running workflows, and leaves chat transcripts untouched. Eligible runs remain searchable regardless of age or count.
703
591
 
704
- Only current-format DBOS records are selectable. Atomic hides unsupported or malformed records without reinterpreting them.
592
+ Only valid current-format journal records are selectable. Unsupported or malformed records are not reinterpreted.
705
593
 
706
594
  Selecting a paused, resumable failed, blocked, or crash-recovery target from the current project re-dispatches the workflow with its cached inputs and the **original workflow id**. Every nested invocation validates and reuses its durable boundary and child identity before dispatch. Previously completed `ctx.tool`, `ctx.ui`, stage/task/chain/parallel items, and child boundaries replay from checkpoints instead of executing again; only incomplete work continues.
707
595
 
@@ -728,7 +616,7 @@ Fresh completed inspection does not currently persist the workflow's declared ro
728
616
 
729
617
  Targets resolve across top-level live, resumable durable, and completed entries as one namespace using full UUIDs or unique 8-hex prefixes. Exact loadable paused live targets retain direct in-session precedence. Prefixes require successful catalog discovery and reject collisions. A root appearing in both resumable and read-only history remains resumable. Nested child runs remain excluded from this top-level resume namespace.
730
618
 
731
- The non-interactive `workflow` surface uses exact targeted DBOS lookup for explicit ids. `resume` loads workflow resources, queries and revalidates the authoritative resumable record, then claims and dispatches only when the caller explicitly requested resume. `status`, `stages`, `stage`, and `transcript` hydrate one exact missing-local root into an isolated read-only snapshot and never dispatch. This targeted path does not change `workflow({ action: "status" })` without a run id: an empty session-local listing neither scans DBOS nor implies that DBOS deleted the workflow.
619
+ The non-interactive `workflow` surface reads the journal for explicit IDs. `resume` loads the definition, revalidates eligibility, then claims and dispatches the run. `status`, `stages`, `stage`, and `transcript` read a missing-local root without dispatching it. `status` without a run ID remains session-local.
732
620
 
733
621
  Targets other than full UUIDs or 8-hex prefixes are rejected before catalog lookup. Durable read-only prefix inspection includes actively running roots owned by other sessions, without claiming or resuming them. Once resolved, subsequent stage and transcript inspection uses the canonical root UUID, even when a nested child shares its prefix. Completed or failed roots with valid checkpoints remain inspectable when retained conversations are unavailable; invalid transcript paths are stripped while the graph remains visible.
734
622
 
@@ -742,7 +630,7 @@ Recovery requires saved checkpoints proving one unfinished tool and its complete
742
630
 
743
631
  A tool-frontier continuation must reach and consume the exact unfinished tool before reporting `completed`, whether the body returns normally or calls `ctx.exit({ status: "completed" })`. Omitting the call, including by changing control flow, fails with `insufficient_state: replay topology mismatch` and the pending tool's exact ID. A substituted tool is rejected before its callback runs. While that frontier is pending, completed model and child-workflow predecessors can replay, but new model stages, tasks, and child workflows cannot execute in its place. Stage and task worktree setup also waits for live admission. Replaying completed predecessors alone is not proof of completion. Failed replay publishes no successful result; inspect the same ID and restore the matching flow before another supported resume. Quit, kill, caught targeted cancellation, and intentional non-completed exits retain their existing behavior.
744
632
 
745
- After upgrading Atomic itself or applying a code fix, start a new Atomic process; `/workflow reload` refreshes definitions, not loaded code. A process-local non-durable warning means cross-process recovery is unavailable.
633
+ After upgrading Atomic itself or applying a code fix, start a new Atomic process; `/workflow reload` refreshes definitions, not loaded code.
746
634
 
747
635
  If saved state cannot prove safe replay, reconcile the original run and external effects before choosing recovery. Do not restart the original workflow from the beginning to bypass the error. A separately authorized recovery-only workflow may perform verified remaining operations, but must not repeat completed side effects or fabricate checkpoints.
748
636
 
@@ -763,47 +651,13 @@ That history does not authorize any live release action.
763
651
  | **Abandoned `ctx.tool` callback** | Quit reports callbacks that ignored cancellation by `{runId, nodeId}`. They may still cause external effects but cannot save a late checkpoint. Reconcile effects before same-ID resume retries unfinished work. |
764
652
  | **`ctx.ui` pending prompt** | If a UI prompt was not answered before interruption, resume leaves off on that prompt — the user must answer it to continue. |
765
653
 
766
- ### Configuring DBOS/Postgres
767
-
768
- Choose a hosted or separately managed database persistently in `~/.atomic/agent/settings.json` or trusted project `.atomic/settings.json`:
769
-
770
- ```json
771
- {
772
- "workflows": {
773
- "durability": {
774
- "systemDatabaseUrlFile": "~/.atomic/neon/direct.url"
775
- }
776
- }
777
- }
778
- ```
779
-
780
- The file contains only the PostgreSQL connection URL; surrounding whitespace and a trailing newline are trimmed. Use `systemDatabaseUrl` instead for an inline URL, but do not set both. Relative file paths resolve beside the settings file that declares them, such as the global agent directory or project `.atomic` directory. Protect the file from other accounts and keep credentials out of version control. Existing workflow path arrays remain supported; when using the object form, put resource paths in `workflows.paths`.
781
-
782
- `DBOS_SYSTEM_DATABASE_URL` overrides settings. A trusted project `durability` object replaces the global selection. Without either, Atomic provisions managed PostgreSQL, then tries Docker if provisioning fails. An explicit URL uses only its chosen endpoint, even on connection failure. Invalid settings, including unrecognized `durability` keys, and unreadable or empty credential files stop initialization rather than choosing another database. Restart Atomic to change the selection; existing runs stay in their original database and are not migrated.
783
-
784
- On first database initialization, interactive and RPC sessions display the selected provider and host without credentials or URL options. A Docker selection is labelled `Docker fallback`. Headless sessions, including SDK hosts without a UI, write only the Docker fallback notice to stderr; managed and configured selections stay silent there. In-memory degradation retains its existing warning. See [Workflow database settings](/settings#workflow-database).
785
-
786
- **Linux musl and Windows ARM64.** Musl installations include Alpine/musl PostgreSQL 18.6. Windows ARM64 runs PostgreSQL 18.4 x64 through emulation and requires Windows 11 plus the Microsoft Visual C++ x64 v14 Redistributable. This is not native PostgreSQL ARM64; Windows 10 on ARM is unsupported.
787
-
788
- Set `ATOMIC_POSTGRES_RUNTIME_DIR` to a complete extracted runtime containing `bin/initdb`, `bin/pg_ctl`, and `bin/postgres` to override packaged runtime discovery, including in air-gapped deployments. Otherwise DBOS/Postgres durability requires no setup on supported local platforms. To use an existing Postgres database, set `DBOS_SYSTEM_DATABASE_URL` before starting Atomic; that explicit URL retains precedence over embedded provisioning. Atomic provisions embedded Postgres next (with drop-privilege support when running as root on Linux), then Docker as a platform fallback. The DBOS SDK ships with `@bastani/atomic`. If no durable backend can be provisioned, workflows run on a process-local in-memory backend with a loud non-durable warning — never on the legacy per-workflow file store under `~/.atomic/workflow-durable` — and cross-process resume is unavailable until Postgres provisioning is fixed. Interactive and RPC actions show the warning as a display-only notification that is not added to agent/model context. Print and other headless actions, where no usable UI exists, write the actionable diagnostic to the console instead.
789
-
790
- Keep the complete extracted archive, not only the `atomic` executable. `ATOMIC_POSTGRES_RUNTIME_DIR` accepts complete legacy runtimes without provenance; an incomplete override falls through to installed candidates. Packaging failures do not require deleting or reinitializing the v18 cluster.
654
+ ### Configuring journal storage
791
655
 
792
- If starting workflows reports a missing PostgreSQL executable or library, such as `libzstd.1.dylib` on macOS, download a repaired release and reinstall the complete archive. The installers do not check the bundled PostgreSQL runtime, so the problem shows up the first time Atomic starts its embedded database. With an explicit database URL from the environment or settings, Atomic never uses the bundled runtime. If embedded startup fails and the Docker fallback succeeds, workflows run on Docker and the backend notice identifies that fallback. Check `~/.atomic/postgres/v18.log` if the managed database never starts. Do not copy libraries from another version or delete your PostgreSQL data directory: this is an installation problem, not database corruption. An already-running server does not prove that the new installation is usable.
793
-
794
- To check an archive runtime, set `runtime` to its `node_modules/@bastani/atomic-natives/postgres-runtime`, then run `"$runtime/bin/postgres" --version` and `"$runtime/bin/pg_ctl" --version`. On Windows use the corresponding `.exe` files in PowerShell. Both must succeed. If a library-link or copy error is reported, repair the complete installation instead of mixing libraries from different releases.
795
-
796
- Optional PostgreSQL OAuth and procedural-language modules may have upstream dependency gaps. Atomic does not bundle supplemental libcurl or Perl/Python/Tcl runtimes for those modules. They are not needed for normal workflow database operation; use a separately managed PostgreSQL server if you require them.
656
+ Set `ATOMIC_WORKFLOW_JOURNAL_PATH` before starting Atomic to select a durable local file. Otherwise Atomic uses `~/.atomic/workflows/journal.sqlite`. Preserve that file and its SQLite sidecar files; use the same journal and working directory to resume an existing run. See [Workflow storage settings](/settings#workflow-storage).
797
657
 
798
658
  Pending-stage Intercom cleanup checks durable ownership only for runs with messages that need settlement. Repeated failures with the same message produce one warning per extension instance. Interactive hosts receive a display-only notification, never a console stack trace, even if notification delivery fails; headless hosts retain a console diagnostic. Pending messages are not discarded when cleanup fails.
799
659
 
800
- ```bash
801
- export DBOS_SYSTEM_DATABASE_URL="postgresql://user:password@localhost:5432/atomic_dbos_sys"
802
- ```
803
-
804
- Fresh-process resume and inspection read authoritative checkpoints from DBOS. Unsupported records are not treated as successful cached work. Keep the original diagnostic and run ID if decoding fails.
805
-
806
- Atomic does not use the legacy file backend under `~/.atomic/workflow-durable`; cross-session `/workflow resume` reads DBOS only.
660
+ Fresh-process resume and inspection read authoritative checkpoints from the journal. Unsupported records are not treated as successful cached work. Keep the original diagnostic and run ID if decoding fails.
807
661
 
808
662
  ## Workflow Locations
809
663
 
@@ -812,12 +666,14 @@ Atomic discovers workflow definitions in this order:
812
666
  | Location | Scope | Notes |
813
667
  |----------|-------|-------|
814
668
  | `.atomic/extensions/workflow/config.json` | Project | `workflows.<name>.path`; project entries override global entries |
815
- | `.atomic/workflows/*.{ts,js,mjs,cjs}` | Project | Legacy `.pi/workflows/` is also checked |
669
+ | `.atomic/workflows/*.{ts,js,mjs,cjs}` | Project | Current project workflow directory |
816
670
  | `~/.atomic/agent/extensions/workflow/config.json` | Global | `workflows.<name>.path` for user-wide configured paths |
817
- | `~/.atomic/agent/workflows/*.{ts,js,mjs,cjs}` | Global | Legacy `~/.pi/agent/workflows/` is also checked |
671
+ | `~/.atomic/agent/workflows/*.{ts,js,mjs,cjs}` | Global | Current user workflow directory |
818
672
  | Installed Atomic packages | Package | Uses package metadata or conventional `workflows/` directories |
819
673
  | Bundled workflows | Built-in | Shipped with `@bastani/atomic/workflows` |
820
674
 
675
+ Workflow configuration and discovery use only the current `.atomic` roots by default. `ATOMIC_CODING_AGENT_DIR` overrides the user agent directory. Import workflow APIs from `@bastani/atomic/workflows` and schemas from `typebox`.
676
+
821
677
  A workflow module may export one default workflow definition and/or named workflow definitions. Discovery checks the default export first, then named exports.
822
678
 
823
679
  Discovery validates every runtime export of a discovered workflow file as a workflow definition. Discovery rejects a named export that is not a workflow definition — a widget factory, shared constant, or utility function — with an `INVALID_DEFINITION` discovery diagnostic (`export is not an object`), even when the module also has a valid default export (the valid workflow still loads; the diagnostic flags the extra export as skipped). TypeScript erases type-only exports (`export type` / `export interface`) at runtime, so discovery never flags them.
@@ -1096,7 +1096,7 @@ Good workflows are information-flow systems, not just prompt sequences. Keep sta
1096
1096
  - Do not pass strings or path objects to `ctx.workflow(...)`; import the workflow definition from `@bastani/atomic/workflows/builtin` or another TypeScript module first.
1097
1097
  - Do not create a self-edge or a dependency edge from the current frontier to an existing ancestor. Cyclic workflow graphs are unsupported; redesign or stop before launch when a cycle cannot be removed.
1098
1098
  - Do not model a bounded loop by reopening an earlier node beneath its downstream work. Create distinct tracked work per iteration and keep retained-session follow-up as non-topological activity when it adds no dependency work.
1099
- - Do not claim TypeScript or workflow discovery proves a dynamic workflow acyclic. Discovery diagnoses imports and definition shape; execution, replay, and DBOS hydration are the runtime topology boundary.
1099
+ - Do not claim TypeScript or workflow discovery proves a dynamic workflow acyclic. Discovery diagnoses imports and definition shape; execution, replay, and journal hydration are the runtime topology boundary.
1100
1100
  - Do not rely on undeclared child outputs; returning a key that is not declared in `outputs` fails the run. Declare every child-workflow field you expose in `outputs` — including `result` — and return values matching those schemas from `run` (see [Outputs](/workflows/authoring#outputs)).
1101
1101
  - Do not expect to select or rename child outputs at the call site; parent workflows receive the child's declared output contract as `child.outputs` after checking `child.exited === false`, and a partial declared-output map when `child.exited === true`.
1102
1102
  - Do not expect named workflow runs to block the chat turn; they are background tasks.