@bastani/atomic 0.10.14-alpha.1 → 0.10.15-alpha.1

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 (341) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/_shared/dist-KOELCESV.js +2 -2
  3. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  4. package/dist/_shared/lib-4PES5P4V.js +2 -2
  5. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +3 -3
  6. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
  7. package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
  8. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  9. package/dist/_shared/runtime-O4KCSG4C.js +2 -2
  10. package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
  11. package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
  12. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  13. package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
  14. package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
  15. package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
  16. package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
  17. package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
  18. package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
  19. package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
  20. package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
  21. package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
  22. package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
  23. package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
  24. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  25. package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
  26. package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
  27. package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
  28. package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
  29. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  30. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  31. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  32. package/dist/builtin/intercom/package.json +1 -1
  33. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  34. package/dist/builtin/mcp/package.json +1 -1
  35. package/dist/builtin/subagents/package.json +1 -1
  36. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  37. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  38. package/dist/builtin/web-access/package.json +1 -1
  39. package/dist/cli/auth-cli.code.js +1 -1
  40. package/dist/cli/auth-cli.impl.js +3 -3
  41. package/dist/cli/auth-cli.js +3 -3
  42. package/dist/cli/blueprint-command.impl.js +3 -3
  43. package/dist/cli/blueprint-command.js +3 -3
  44. package/dist/cli/intercom-command.code.js +3 -3
  45. package/dist/cli/intercom-command.impl.js +3 -3
  46. package/dist/cli/intercom-command.js +3 -3
  47. package/dist/cli/list-models.impl.js +3 -3
  48. package/dist/cli/list-models.js +3 -3
  49. package/dist/cli/session-picker.code.js +1 -1
  50. package/dist/cli/session-picker.impl.js +3 -3
  51. package/dist/cli/session-picker.js +3 -3
  52. package/dist/cli/startup-ui.code.js +1 -1
  53. package/dist/cli/startup-ui.impl.js +3 -3
  54. package/dist/cli/startup-ui.js +3 -3
  55. package/dist/cli/storage-command.impl.js +3 -3
  56. package/dist/cli/storage-command.js +3 -3
  57. package/dist/cli/storage-search-session.code.js +1 -1
  58. package/dist/cli/storage-search-session.impl.js +3 -3
  59. package/dist/cli/storage-search-session.js +3 -3
  60. package/dist/cli/team-command.code.js +1 -1
  61. package/dist/cli/team-command.impl.js +3 -3
  62. package/dist/cli/team-command.js +3 -3
  63. package/dist/cli.js +2 -2
  64. package/dist/core/compaction/compactor.d.ts +0 -8
  65. package/dist/core/debug.impl.js +3 -3
  66. package/dist/core/debug.js +3 -3
  67. package/dist/core/export-html/card-projection.impl.js +3 -3
  68. package/dist/core/export-html/card-projection.js +3 -3
  69. package/dist/core/export-html/index.code.js +2 -2
  70. package/dist/core/export-html/index.impl.js +3 -3
  71. package/dist/core/export-html/index.js +3 -3
  72. package/dist/core/export-html/json-spans.impl.js +3 -3
  73. package/dist/core/export-html/json-spans.js +3 -3
  74. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  75. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  76. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  77. package/dist/core/export-html/tool-renderer.js +3 -3
  78. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  79. package/dist/core/extensions/jiti-loader.js +3 -3
  80. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  81. package/dist/core/extensions/jiti-static-loader.js +3 -3
  82. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  83. package/dist/core/extensions/loader-host-modules.js +3 -3
  84. package/dist/core/intercom-broker-control-host.code.js +1 -1
  85. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  86. package/dist/core/intercom-broker-control-host.js +3 -3
  87. package/dist/core/intercom-broker-control.code.js +2 -2
  88. package/dist/core/intercom-broker-control.impl.js +3 -3
  89. package/dist/core/intercom-broker-control.js +3 -3
  90. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  91. package/dist/core/package-manager-storage-adapters.js +3 -3
  92. package/dist/core/sdk.code.js +1 -1
  93. package/dist/core/sdk.impl.js +3 -3
  94. package/dist/core/sdk.js +3 -3
  95. package/dist/core/session-manager-core.js +3 -3
  96. package/dist/core/session-manager-list.impl.js +3 -3
  97. package/dist/core/session-manager-list.js +3 -3
  98. package/dist/core/session-manager.impl.js +3 -3
  99. package/dist/core/session-manager.js +3 -3
  100. package/dist/core/session-storage.impl.js +3 -3
  101. package/dist/core/session-storage.js +3 -3
  102. package/dist/core/storage/index.js +2 -2
  103. package/dist/core/storage/node-sqlite-thread.js +2 -2
  104. package/dist/core/storage/node-sqlite.js +2 -2
  105. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  106. package/dist/core/storage/offline-snapshot-file.js +3 -3
  107. package/dist/core/storage/provider.js +2 -2
  108. package/dist/core/storage/selection.js +2 -2
  109. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  110. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  111. package/dist/core/storage/session/branch-fork-source.js +3 -3
  112. package/dist/core/storage/session/card-view.impl.js +3 -3
  113. package/dist/core/storage/session/card-view.js +3 -3
  114. package/dist/core/storage/session/child-reader.code.js +2 -2
  115. package/dist/core/storage/session/child-reader.impl.js +3 -3
  116. package/dist/core/storage/session/child-reader.js +3 -3
  117. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  118. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  119. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  120. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  121. package/dist/core/storage/session/expanded-child-details.js +3 -3
  122. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  123. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  124. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  125. package/dist/core/storage/session/fork-row-index.js +3 -3
  126. package/dist/core/storage/session/fork-staging.code.js +1 -1
  127. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  128. package/dist/core/storage/session/fork-staging.js +3 -3
  129. package/dist/core/storage/session/fork-window.code.js +2 -2
  130. package/dist/core/storage/session/fork-window.impl.js +3 -3
  131. package/dist/core/storage/session/fork-window.js +3 -3
  132. package/dist/core/storage/session/history-pages.impl.js +3 -3
  133. package/dist/core/storage/session/history-pages.js +3 -3
  134. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  135. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  136. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  137. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  138. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  139. package/dist/core/storage/session/memory-session-store.js +3 -3
  140. package/dist/core/storage/session/pinned-branch-resume.code.js +2 -2
  141. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  142. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  143. package/dist/core/storage/session/released-history-files.code.js +1 -1
  144. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  145. package/dist/core/storage/session/released-history-files.js +3 -3
  146. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  147. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  148. package/dist/core/storage/session/session-resume.impl.js +3 -3
  149. package/dist/core/storage/session/session-resume.js +3 -3
  150. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  151. package/dist/core/storage/session/snapshot-cut.js +3 -3
  152. package/dist/core/storage/session/snapshot-history.code.js +2 -2
  153. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  154. package/dist/core/storage/session/snapshot-history.js +3 -3
  155. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  156. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  157. package/dist/core/storage/session/sql-session-store.js +3 -3
  158. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  159. package/dist/core/storage/session/tree-outline.js +3 -3
  160. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  161. package/dist/core/storage/session/tree-presentation.js +3 -3
  162. package/dist/core/storage/storage-status.impl.js +3 -3
  163. package/dist/core/storage/storage-status.js +3 -3
  164. package/dist/core/storage/team.impl.js +3 -3
  165. package/dist/core/storage/team.js +3 -3
  166. package/dist/core/structured-output/index.code.js +1 -1
  167. package/dist/core/structured-output/index.impl.js +3 -3
  168. package/dist/core/structured-output/index.js +3 -3
  169. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  170. package/dist/core/tasks/task-completion-entry.js +3 -3
  171. package/dist/core/tasks/task-file-history.code.js +2 -2
  172. package/dist/core/tasks/task-file-history.impl.js +3 -3
  173. package/dist/core/tasks/task-file-history.js +3 -3
  174. package/dist/core/tasks/task-reference-archive.code.js +2 -2
  175. package/dist/core/tasks/task-reference-archive.js +3 -3
  176. package/dist/core/tasks/task-reference-identity.js +3 -3
  177. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  178. package/dist/core/tasks/task-reference-stream.js +3 -3
  179. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  180. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  181. package/dist/core/tasks/task-view-source.impl.js +3 -3
  182. package/dist/core/tasks/task-view-source.js +3 -3
  183. package/dist/core/tools/read-url.impl.js +3 -3
  184. package/dist/core/tools/read-url.js +3 -3
  185. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  186. package/dist/core/worktree-snapshot/errors.code.js +1 -1
  187. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  188. package/dist/core/worktree-snapshot/errors.js +3 -3
  189. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  190. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  191. package/dist/extensions/codemode/execute.impl.js +3 -3
  192. package/dist/extensions/codemode/execute.js +3 -3
  193. package/dist/extensions/codemode/renderer.impl.js +3 -3
  194. package/dist/extensions/codemode/renderer.js +3 -3
  195. package/dist/extensions/mcp/cli.code.js +1 -1
  196. package/dist/extensions/mcp/cli.impl.js +3 -3
  197. package/dist/extensions/mcp/cli.js +3 -3
  198. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  199. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  200. package/dist/extensions/mcp/cli.lazy.js +3 -3
  201. package/dist/extensions/mcp/runtime.code.js +1 -1
  202. package/dist/extensions/mcp/runtime.impl.js +3 -3
  203. package/dist/extensions/mcp/runtime.js +3 -3
  204. package/dist/index.d.ts +21 -1
  205. package/dist/index.js +2 -2
  206. package/dist/main-first-time-setup.code.js +1 -1
  207. package/dist/main-first-time-setup.impl.js +3 -3
  208. package/dist/main-first-time-setup.js +3 -3
  209. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  210. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  211. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  212. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  213. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  214. package/dist/modes/print-mode.js +1 -1
  215. package/dist/package-manager-cli.code.js +2 -2
  216. package/dist/package-manager-cli.impl.js +3 -3
  217. package/dist/package-manager-cli.js +3 -3
  218. package/dist/startup-files.json +1 -1
  219. package/dist/startup-stages/6.js +1 -1
  220. package/dist/utils/startup-database-spare.code.js +1 -1
  221. package/dist/utils/startup-database-spare.impl.js +3 -3
  222. package/dist/utils/startup-database-spare.js +3 -3
  223. package/dist/utils/tools-manager.impl.js +3 -3
  224. package/dist/utils/tools-manager.js +3 -3
  225. package/docs/background-tasks/reference.md +182 -0
  226. package/docs/background-tasks.md +98 -405
  227. package/docs/build.md +67 -27
  228. package/docs/changelog.mdx +9 -0
  229. package/docs/codemode.md +108 -39
  230. package/docs/compaction/branch-summaries.md +54 -0
  231. package/docs/compaction/custom-compactors.md +161 -0
  232. package/docs/compaction/memory-compaction.md +77 -0
  233. package/docs/compaction/reference.md +86 -38
  234. package/docs/compaction.md +51 -252
  235. package/docs/computer-use.md +169 -321
  236. package/docs/containerization.md +71 -57
  237. package/docs/custom-provider/api-reference.md +119 -25
  238. package/docs/custom-provider/oauth.md +114 -132
  239. package/docs/custom-provider/override.md +37 -27
  240. package/docs/custom-provider/registration.md +107 -83
  241. package/docs/custom-provider/streaming.md +85 -71
  242. package/docs/custom-provider.md +85 -52
  243. package/docs/development.md +39 -29
  244. package/docs/docs.json +76 -63
  245. package/docs/environment-variables.md +94 -44
  246. package/docs/extensions/api-reference.md +86 -43
  247. package/docs/extensions/authoring.md +162 -154
  248. package/docs/extensions/events.md +80 -25
  249. package/docs/extensions/examples.md +90 -85
  250. package/docs/extensions/ui.md +206 -82
  251. package/docs/extensions.md +79 -108
  252. package/docs/getting-started/authentication.md +67 -36
  253. package/docs/getting-started/first-session.md +53 -43
  254. package/docs/getting-started/installation.md +116 -89
  255. package/docs/getting-started/project-instructions.md +48 -34
  256. package/docs/guides/configuration.md +82 -20
  257. package/docs/guides/non-interactive.md +66 -24
  258. package/docs/guides/resume-on-any-machine.md +135 -82
  259. package/docs/guides/team-setup.md +114 -105
  260. package/docs/guides.md +76 -32
  261. package/docs/herdr.md +15 -16
  262. package/docs/how-atomic-works.md +140 -0
  263. package/docs/index.md +58 -44
  264. package/docs/intercom/operations.md +141 -151
  265. package/docs/intercom/reference.md +85 -108
  266. package/docs/intercom.md +84 -145
  267. package/docs/json.md +120 -67
  268. package/docs/keybindings.md +85 -49
  269. package/docs/libraries/agent-core.md +137 -275
  270. package/docs/libraries/ai.md +100 -84
  271. package/docs/libraries/codemode.md +210 -300
  272. package/docs/libraries/schema.md +59 -53
  273. package/docs/libraries/storage-postgres.md +49 -35
  274. package/docs/libraries/telemetry.md +153 -354
  275. package/docs/libraries/tui.md +265 -393
  276. package/docs/libraries.md +42 -26
  277. package/docs/llama-cpp.md +171 -161
  278. package/docs/mcp-servers.md +90 -51
  279. package/docs/models/choose-a-model.md +188 -0
  280. package/docs/models/reference.md +74 -30
  281. package/docs/models.md +153 -88
  282. package/docs/orchestration/migrating-workflows.md +23 -16
  283. package/docs/orchestration/patterns.md +39 -44
  284. package/docs/orchestration.md +65 -26
  285. package/docs/packages/authoring.md +51 -29
  286. package/docs/packages/reference.md +42 -21
  287. package/docs/packages.md +69 -58
  288. package/docs/programmatic.md +118 -24
  289. package/docs/prompt-templates.md +84 -83
  290. package/docs/providers/reference.md +43 -48
  291. package/docs/providers.md +219 -451
  292. package/docs/quickstart.md +140 -120
  293. package/docs/reference/cli.md +135 -97
  294. package/docs/reference.md +20 -18
  295. package/docs/rpc/examples.md +76 -20
  296. package/docs/rpc/extension-ui.md +64 -38
  297. package/docs/rpc/protocol.md +361 -110
  298. package/docs/rpc.md +57 -17
  299. package/docs/sdk/reference.md +409 -534
  300. package/docs/sdk/storage.md +53 -13
  301. package/docs/sdk/structured-decisions.md +82 -56
  302. package/docs/sdk/web-server.md +57 -43
  303. package/docs/sdk.md +106 -84
  304. package/docs/security.md +42 -64
  305. package/docs/session-format.md +62 -38
  306. package/docs/sessions.md +99 -214
  307. package/docs/settings.md +165 -195
  308. package/docs/shell-aliases.md +9 -6
  309. package/docs/skills/authoring.md +69 -48
  310. package/docs/skills/reference.md +51 -20
  311. package/docs/skills.md +99 -148
  312. package/docs/slash-commands.md +129 -0
  313. package/docs/storage/custom-adapters.md +160 -85
  314. package/docs/storage/jsonl.md +81 -66
  315. package/docs/storage/postgres/pgbouncer.md +120 -126
  316. package/docs/storage/postgres/tuning.md +120 -143
  317. package/docs/storage/postgres.md +314 -330
  318. package/docs/storage/sqlite.md +71 -42
  319. package/docs/storage.md +298 -302
  320. package/docs/subagents/authoring.md +55 -38
  321. package/docs/subagents/reference.md +73 -33
  322. package/docs/subagents.md +119 -187
  323. package/docs/terminal-setup.md +50 -38
  324. package/docs/termux.md +67 -41
  325. package/docs/themes/reference.md +23 -19
  326. package/docs/themes.md +142 -127
  327. package/docs/tmux.md +47 -55
  328. package/docs/tools.md +147 -109
  329. package/docs/tui/reference.md +166 -214
  330. package/docs/tui.md +196 -341
  331. package/docs/usage.md +118 -138
  332. package/docs/verification.md +79 -51
  333. package/docs/web-access.md +121 -101
  334. package/docs/windows.md +26 -27
  335. package/docs/worktree-snapshots/reference.md +245 -0
  336. package/docs/worktree-snapshots.md +71 -259
  337. package/package.json +8 -8
  338. package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
  339. package/docs/guides/intercom.md +0 -32
  340. package/docs/guides/orchestration.md +0 -28
  341. package/docs/guides/subagents.md +0 -37
@@ -1,380 +1,370 @@
1
1
  ---
2
2
  title: "PostgreSQL setup"
3
- sidebarTitle: "Setup"
4
- description: "Share Atomic's sessions and Intercom across machines, a team, or CI with one PostgreSQL database: set up roles, join machines, connect through TLS, proxies, and poolers, size connections, and fix common errors."
3
+ sidebarTitle: "PostgreSQL setup"
4
+ description: "Share Atomic sessions and Intercom across machines, teams, or CI with PostgreSQL 16+: create roles, run migrations, join machines, configure TLS, proxies, poolers, cloud identities, and size connections."
5
5
  ---
6
6
 
7
- Use PostgreSQL when more than one machine should see the same sessions and Intercom messages: a team, a CI fleet, or one person on several computers. Every machine that joins the database sees the same sessions, and its agents can message agents on the other machines. For one person on one machine, the default [local SQLite](/storage/sqlite) store needs no setup and is the better choice.
7
+ Use PostgreSQL when multiple machines need to share sessions and Intercom messages—such as a team, a CI fleet, or one person working across several computers. Every joined machine sees the same sessions and can message agents on other joined machines. For one person on one machine, keep the zero-setup [local SQLite](/storage/sqlite) store.
8
8
 
9
- This page is for the person who sets up the database and the people who connect their machines to it. It covers:
9
+ **Requirements:**
10
10
 
11
- - creating the database and its roles;
12
- - joining a machine;
13
- - TLS, HTTP proxies, poolers, and cloud identities;
14
- - how many connections Atomic opens, and how to size them for many agents;
15
- - fixes for common errors.
11
+ - **PostgreSQL 16 or newer.** While the standalone `@bastani/atomic-storage-postgres` adapter connects to PostgreSQL 14+, Atomic's session store requires PostgreSQL 16 or newer (for `IS JSON` and `pg_input_is_valid`).
12
+ - **`@bastani/atomic-storage-postgres`** installed on every machine that connects (see [Join a machine](#join-a-machine)).
16
13
 
17
- Requirements:
14
+ Self-hosted PostgreSQL and managed services (Azure Database for PostgreSQL Flexible Server, Azure HorizonDB, Amazon RDS/Aurora, Google Cloud SQL, AlloyDB, Neon, and Supabase) are supported.
18
15
 
19
- - **PostgreSQL 16 or newer.** Atomic keeps sessions only on PostgreSQL 16 or newer.
20
- - **The PostgreSQL adapter, `@bastani/atomic-storage-postgres`,** installed on every machine that connects. [Join a machine](#join-a-machine) shows how.
16
+ <Columns cols={2}>
17
+ <Card title="PostgreSQL with PgBouncer" href="/storage/postgres/pgbouncer">
18
+ Put PgBouncer in front when agent processes exceed PostgreSQL's connection limit.
19
+ </Card>
20
+ <Card title="Tune PostgreSQL for many agents" href="/storage/postgres/tuning">
21
+ Server-side memory, huge pages, `pg_stat_statements`, busy tables, and `lz4` compression.
22
+ </Card>
23
+ </Columns>
21
24
 
22
- Self-hosted PostgreSQL works, and so do managed services: Azure Database for PostgreSQL Flexible Server, Azure HorizonDB, Amazon RDS and Aurora PostgreSQL, Google Cloud SQL, AlloyDB, Neon, and Supabase.
23
-
24
- A new PostgreSQL server allows 100 connections, and each Atomic process can open up to 10, or 11 for an Intercom broker. If you will run more than a few Atomic processes, read [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents) before you start. When your agents need more connections than the server allows, put [PgBouncer](/storage/postgres/pgbouncer) in front of it. To tune the server itself, see [Server tuning](/storage/postgres/tuning).
25
+ <Note>
26
+ A default PostgreSQL server allows 100 connections, and each Atomic process opens up to 10 (11 for an Intercom broker). If you plan to run more than ~8 processes, read [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents) before scaling out.
27
+ </Note>
25
28
 
26
29
  ## Set up the database
27
30
 
28
- Atomic keeps its tables in their own schema, `atomic`, rather than `public`. A shared deployment uses two roles:
29
-
30
- - **The owner role** owns the database and the `atomic` schema. It creates and upgrades Atomic's tables with `atomic storage migrate`.
31
- - **The runtime role** is the role every machine connects as. It reads and writes rows, and cannot change the schema.
32
-
33
- With two roles, a machine that connects as the runtime role can never change or drop Atomic's tables. Every machine can use the same runtime role, or you can create one login role per person with the same grants as `atomic_runtime`. For one person testing on one machine, a single role that owns the database is enough. Atomic then creates its tables the first time it opens the database.
34
-
35
- Run `atomic storage migrate` once before you start many agents on a new database. Agents that then start together find every table already there and run no setup. Without it, the first agents to open the empty database set it up between them: for each table, one agent creates it while the others wait for it without holding a lock or a connection. At 80 ms from the server, behind PgBouncer, 25 agents that each opened a session store and an Intercom broker on an empty database at once took about 15 seconds to open, and 100 took about 24 seconds. With the schema in place, the same 25 agents opened in about 1.3 seconds.
36
-
37
- 1. **Create the roles and the database.** Connect as the server's administrator, a superuser or the managed service's administrator role, and run:
38
-
39
- ```sql
40
- CREATE ROLE atomic_owner LOGIN PASSWORD '<owner password>';
41
- CREATE ROLE atomic_runtime LOGIN PASSWORD '<runtime password>';
42
- -- On a managed service whose administrator is not a superuser, such as Azure, RDS, or Cloud SQL:
43
- -- GRANT atomic_owner TO <administrator>;
44
- CREATE DATABASE atomic OWNER atomic_owner;
45
- REVOKE ALL ON DATABASE atomic FROM PUBLIC;
46
- GRANT CONNECT ON DATABASE atomic TO atomic_owner, atomic_runtime;
47
- ```
48
-
49
- Owning the database lets `atomic_owner` create the `atomic` schema. On a managed service whose administrator is not a superuser, remove the `--` before the `GRANT` line, so the administrator may create a database owned by `atomic_owner`.
50
-
51
- 2. **Allow the machines to connect, over TLS.** On a self-hosted server, turn TLS on first, as [TLS](#tls) explains, because Atomic checks the server's certificate by default. Then `pg_hba.conf` decides who may log in. Allow the agent machines as the runtime role, and the machine you run `atomic storage migrate` on as the owner role. Then reload the server, for example with `SELECT pg_reload_conf();`:
52
-
53
- ```text
54
- # TYPE DATABASE USER ADDRESS METHOD
55
- hostssl atomic atomic_runtime 10.0.2.0/24 scram-sha-256
56
- hostssl atomic atomic_owner 10.0.3.10/32 scram-sha-256
57
- ```
58
-
59
- Managed services use firewall rules instead, and have TLS on already.
60
-
61
- 3. **Create Atomic's tables.** On a machine with Atomic installed, install the PostgreSQL adapter, save the owner's password in a file that only you can read, and run `atomic storage migrate` as the owner role. Connect to PostgreSQL directly, not through a pooler:
62
-
63
- ```bash
64
- atomic install npm:@bastani/atomic-storage-postgres
65
- (umask 077; printf 'Owner password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-owner-password)
66
- atomic storage migrate --db 'postgresql://atomic_owner@db.example.com:5432/atomic' --password-file ~/atomic-owner-password
67
- ```
68
-
69
- It prints what it set up:
70
-
71
- ```text
72
- Atomic's tables in PostgreSQL postgresql://db.example.com:5432/atomic via @bastani/atomic-storage-postgres are set up for this version: sessions and Intercom.
73
- ```
74
-
75
- `--password-file`, `--token-file`, `--auth`, and `--prefix` only work together with `--db`. Without `--db`, `atomic storage migrate` upgrades the database this machine's `storage` setting names.
76
-
77
- 4. **Give the runtime role its privileges.** Connect to the `atomic` database as `atomic_owner` and run:
78
-
79
- ```sql
80
- GRANT USAGE ON SCHEMA atomic TO atomic_runtime;
81
- GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA atomic TO atomic_runtime;
82
- GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA atomic TO atomic_runtime;
83
- GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA atomic TO atomic_runtime;
84
- ALTER DEFAULT PRIVILEGES FOR ROLE atomic_owner IN SCHEMA atomic GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO atomic_runtime;
85
- ALTER DEFAULT PRIVILEGES FOR ROLE atomic_owner IN SCHEMA atomic GRANT USAGE, SELECT ON SEQUENCES TO atomic_runtime;
86
- ALTER DEFAULT PRIVILEGES FOR ROLE atomic_owner IN SCHEMA atomic GRANT EXECUTE ON FUNCTIONS TO atomic_runtime;
87
- ```
88
-
89
- These are all the privileges the runtime role needs. The `ALTER DEFAULT PRIVILEGES` statements cover tables that later Atomic upgrades add, so you run them once. Intercom's notifications and locks need no extra grants.
90
-
91
- 5. **Join each machine as the runtime role.** See [Join a machine](#join-a-machine). If you will put PgBouncer in front of the server, set it up first and join with its address, as [Configure Atomic](/storage/postgres/pgbouncer#configure-atomic) shows.
92
-
93
- Notes for managed services:
94
-
95
- - **Azure Database for PostgreSQL Flexible Server.** Run the statements as the server administrator, a member of `azure_pg_admin`. If you set the `schema` option to `public`, also run `GRANT CREATE ON SCHEMA public TO atomic_owner;`.
96
- - **Google Cloud SQL.** Run the statements as `postgres` or another member of `cloudsqlsuperuser`.
97
-
98
- If the runtime role lacks a privilege, or the tables are older than the Atomic release that opens them, opening the database fails with `StorageConfigError` and reason `missing-privilege`. The error names the `GRANT` statement or the `atomic storage migrate` command to run.
31
+ Atomic stores its tables in a dedicated schema named `atomic` rather than `public`. Production deployments use two roles:
32
+
33
+ - **Owner role (`atomic_owner`):** owns the database and `atomic` schema; runs `atomic storage migrate` to create and upgrade tables.
34
+ - **Runtime role (`atomic_runtime`):** used by agent machines; reads and writes rows only and cannot alter or drop schema objects.
35
+
36
+ Every machine can share one runtime role, or you can create one login role per person with the same grants. For quick single-user testing, one role that owns the database is sufficient and creates tables automatically on first open.
37
+
38
+ <Tip>
39
+ Run `atomic storage migrate` once as the owner role before starting a fleet of agents on an empty database. With the schema already in place, agents skip first-open DDL coordination and open in a couple of round trips instead of waiting on each other to initialize tables.
40
+ </Tip>
41
+
42
+ <Steps>
43
+ <Step title="Create the roles and database">
44
+ Connect as a superuser (or your managed service's administrator role) and run:
45
+
46
+ ```sql
47
+ CREATE ROLE atomic_owner LOGIN PASSWORD '<owner password>';
48
+ CREATE ROLE atomic_runtime LOGIN PASSWORD '<runtime password>';
49
+ -- On a managed service whose administrator is not a superuser (Azure, RDS, Cloud SQL):
50
+ -- GRANT atomic_owner TO <administrator>;
51
+ CREATE DATABASE atomic OWNER atomic_owner;
52
+ REVOKE ALL ON DATABASE atomic FROM PUBLIC;
53
+ GRANT CONNECT ON DATABASE atomic TO atomic_owner, atomic_runtime;
54
+ ```
55
+
56
+ On managed services where the admin role is not a superuser, uncomment the `GRANT` line so the admin can create a database owned by `atomic_owner`.
57
+ </Step>
58
+ <Step title="Allow TLS connections">
59
+ On self-hosted servers, enable TLS first (see [TLS](#tls))—Atomic verifies the server's certificate and hostname by default. Allow agent machines as `atomic_runtime` and your migration host as `atomic_owner` in `pg_hba.conf`, then reload with `SELECT pg_reload_conf();`:
60
+
61
+ ```text
62
+ # TYPE DATABASE USER ADDRESS METHOD
63
+ hostssl atomic atomic_runtime 10.0.2.0/24 scram-sha-256
64
+ hostssl atomic atomic_owner 10.0.3.10/32 scram-sha-256
65
+ ```
66
+
67
+ Managed services enable TLS by default and use firewall or private-network rules instead of `pg_hba.conf`.
68
+ </Step>
69
+ <Step title="Create Atomic's tables with atomic storage migrate">
70
+ On a machine with Atomic installed, install the PostgreSQL adapter, save the owner password in an owner-only file, and run `atomic storage migrate` directly against PostgreSQL (not through a connection pooler):
71
+
72
+ ```bash
73
+ atomic install npm:@bastani/atomic-storage-postgres
74
+ (umask 077; printf 'Owner password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-owner-password)
75
+ atomic storage migrate --db 'postgresql://atomic_owner@db.example.com:5432/atomic' --password-file ~/atomic-owner-password
76
+ ```
77
+
78
+ `--password-file`, `--token-file`, `--auth`, and `--prefix` work only alongside `--db`. Without `--db`, `atomic storage migrate` targets the database configured in this machine's `storage` setting.
79
+ </Step>
80
+ <Step title="Grant runtime privileges">
81
+ Connect to the `atomic` database as `atomic_owner` and run:
82
+
83
+ ```sql
84
+ GRANT USAGE ON SCHEMA atomic TO atomic_runtime;
85
+ GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA atomic TO atomic_runtime;
86
+ GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA atomic TO atomic_runtime;
87
+ GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA atomic TO atomic_runtime;
88
+ ALTER DEFAULT PRIVILEGES FOR ROLE atomic_owner IN SCHEMA atomic GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO atomic_runtime;
89
+ ALTER DEFAULT PRIVILEGES FOR ROLE atomic_owner IN SCHEMA atomic GRANT USAGE, SELECT ON SEQUENCES TO atomic_runtime;
90
+ ALTER DEFAULT PRIVILEGES FOR ROLE atomic_owner IN SCHEMA atomic GRANT EXECUTE ON FUNCTIONS TO atomic_runtime;
91
+ ```
92
+
93
+ `ALTER DEFAULT PRIVILEGES` covers objects added by future Atomic upgrades, so you only need to run this step once. Intercom `LISTEN`/`NOTIFY` and advisory locks require no extra grants.
94
+ </Step>
95
+ <Step title="Join agent machines as the runtime role">
96
+ Follow [Join a machine](#join-a-machine) on each host. If you are deploying PgBouncer in front of PostgreSQL, configure PgBouncer first and join with its endpoint (see [Configure Atomic](/storage/postgres/pgbouncer#configure-atomic)).
97
+ </Step>
98
+ </Steps>
99
+
100
+ If the runtime role lacks a required grant—or tables are behind the running Atomic version—opening fails with `StorageConfigError` (`reason: "missing-privilege"`), naming the exact `GRANT` or `atomic storage migrate` command to run.
99
101
 
100
102
  ### After each Atomic upgrade
101
103
 
102
- Run `atomic storage migrate` as the owner role once after you upgrade Atomic, before you start many agents. The runtime role cannot change the schema. If an upgrade needs new tables, machines that connect as the runtime role fail with `missing-privilege` until you run it. Otherwise they keep working, but without the improvements only the owner can apply:
104
+ Run `atomic storage migrate` once as the owner role after upgrading Atomic and before scaling up agents. Because the runtime role cannot run DDL, running `migrate` handles everything that requires table ownership:
103
105
 
104
- - Saving new entries to a session waits for the server once instead of twice, so saves are faster.
105
- - The busy sessions and Intercom tables leave room on each page for updates, which keeps them faster to update and smaller. See [Server tuning](/storage/postgres/tuning#updates-that-stay-on-their-page).
106
- - Autovacuum cleans the busy tables sooner, and large values use the faster `lz4` compression where the server supports it. See [Server tuning](/storage/postgres/tuning).
107
- - On Azure, session history search gets its index once the `pg_trgm` extension is allowed. See [Azure](#azure).
106
+ - **Schema and lazy objects:** creates new tables, lazily initialized tables/functions (fork staging, chat records, the single-round-trip session append function, and Intercom's ended-child queue tables), and shared-history fork upgrades.
107
+ - **Non-blocking index rebuilds:** rebuilds the `snapshot_session_links` index concurrently without blocking writes (with a 6-hour statement timeout for large tables).
108
+ - **Table tuning:** applies `fillfactor`, autovacuum thresholds, search index parameters, unlogged wake-up notices, and `lz4` compression where supported (see [Server tuning](/storage/postgres/tuning)). Each table tuning statement uses a 2-second `lock_timeout` and gracefully skips busy tables rather than failing the migration—re-run later if any table was reported busy.
109
+ - **Search trigram index:** installs `pg_trgm` once allowed on managed providers (see [Managed PostgreSQL services](#managed-postgresql-services)).
108
110
 
109
- Running it on a database that is already current changes nothing.
111
+ Running `atomic storage migrate` on an already up-to-date database is a no-op.
110
112
 
111
113
  ### Share one database between teams
112
114
 
113
- Give each team or project its own database, or its own `prefix`. A prefix starts the name of every table Atomic creates, so several groups can use one database without seeing each other's sessions. There is no prefix by default. Pass the same `--prefix` to `atomic storage migrate` and to every `atomic storage join` of that group. A machine with another prefix sees none of the group's sessions.
115
+ Isolate teams or projects either in separate databases or with a table `prefix` (no prefix by default). Pass the same `--prefix` to `atomic storage migrate` and to every `atomic storage join` in that group; hosts with a different prefix cannot see those sessions.
114
116
 
115
- On PostgreSQL, a prefix is at most 24 lowercase ASCII characters. A longer prefix fails with `StoragePrefixError` and reason `too-long`. Uppercase letters fail with reason `uppercase`.
117
+ On PostgreSQL, a prefix may contain at most **24 lowercase ASCII characters**. Longer prefixes fail with `StoragePrefixError` (`too-long`), and uppercase letters fail with `uppercase`.
116
118
 
117
119
  ### Upgrading from tables in `public`
118
120
 
119
- Older releases created Atomic's tables in the `public` schema. Atomic keeps using those tables until you move them:
121
+ Older Atomic releases placed tables in the `public` schema. Atomic continues using them until you migrate them to `atomic`:
120
122
 
121
- 1. Upgrade Atomic on every machine.
122
- 2. Run `atomic storage migrate` once, as the role that owns the tables in `public`. It moves every Atomic table to the `atomic` schema in one transaction.
123
- 3. Give the runtime role its privileges on `atomic`, as in step 4 of [Set up the database](#set-up-the-database).
123
+ 1. Upgrade Atomic on every machine sharing the database.
124
+ 2. Run `atomic storage migrate` once as the owner of the tables in `public` (moves all Atomic tables—and any legacy `wf_*` tables—to `atomic` in one transaction).
125
+ 3. Grant runtime privileges on `atomic` as in step 4 of [Set up the database](#set-up-the-database).
124
126
  4. Restart every Atomic process that opened the database before the move.
125
127
 
126
- A process that still writes to `public` after the move is refused, so no data lands in the wrong schema. If an older process created a table in `public` after the move anyway, the next `atomic storage migrate` names it and fails rather than lose it.
128
+ Processes still targeting `public` after the move are refused so data never splits across schemas. If an older process creates a stray table in `public` afterward, the next `atomic storage migrate` names it and stops rather than discarding it.
127
129
 
128
130
  ## Join a machine
129
131
 
130
- Joining points a machine's Atomic at the shared database. Run these steps on every machine, as the user who runs Atomic:
131
-
132
- 1. **Install the PostgreSQL adapter.** It is a separate package, so you install it once per machine.
133
-
134
- ```bash
135
- atomic install npm:@bastani/atomic-storage-postgres
136
- ```
137
-
138
- 2. **Save the runtime role's password in a file** that only you can read. This command asks for the password, so it stays out of your shell history:
139
-
140
- ```bash
141
- (umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
142
- ```
143
-
144
- 3. **Join the database.**
145
-
146
- ```bash
147
- atomic storage join 'postgresql://atomic_runtime@db.example.com:5432/atomic' --password-file ~/atomic-db-password
148
- ```
149
-
150
- It prints what it did:
151
-
152
- ```text
153
- Connected to postgresql://atomic_runtime@db.example.com:5432/atomic.
154
- Stored the password in /home/me/.atomic/agent/storage-token.28ab7041-05e2-4ad5-80af-854329035d8c (mode 600).
155
- Set `storage` in /home/me/.atomic/agent/settings.json; other settings are unchanged.
156
- Run `atomic storage status` to check each domain.
157
- ```
158
-
159
- 4. **Restart Intercom and check the result.** The Intercom broker is the background process on each machine that passes messages between agents. Restart it so it uses the shared database. The command is safe when no broker is running. Sessions that are already open keep their old store until you restart them.
160
-
161
- ```bash
162
- atomic intercom restart
163
- atomic storage status
164
- ```
165
-
166
- `atomic storage status` exits with code `0` when everything answered, and prints something like this:
167
-
168
- ```text
169
- Sessions: PostgreSQL postgresql://db.example.com:5432/atomic via @bastani/atomic-storage-postgres
170
- source: global settings: storage
171
- adapter: loaded (from /home/me/.atomic/agent/npm/node_modules/@bastani/atomic-storage-postgres/postgres.js)
172
- connection: ok (postgres postgresql://db.example.com:5432/atomic answered in 20 ms, PostgreSQL 17.12; wake-ups: LISTEN/NOTIFY)
173
-
174
- Intercom: PostgreSQL postgresql://db.example.com:5432/atomic via @bastani/atomic-storage-postgres
175
- source: global settings: storage
176
- adapter: loaded (from /home/me/.atomic/agent/npm/node_modules/@bastani/atomic-storage-postgres/postgres.js)
177
- connection: ok (postgres postgresql://db.example.com:5432/atomic answered in 11 ms, PostgreSQL 17.12; wake-ups: LISTEN/NOTIFY)
178
- multi-node: on
179
- brokers: 0 live in the database
180
-
181
- Intercom broker: not running (the next session that uses Intercom starts one with the selection above)
182
- ```
183
-
184
- `multi-node: on` means agents on this machine can message agents on the other machines that joined. A broker starts with the first session that uses Intercom, so right after a restart `brokers` can show `0` and the broker `not running`. Once sessions run on the joined machines, `brokers` counts their brokers.
185
-
186
- 5. **Delete your password file**, `~/atomic-db-password`. `atomic storage join` keeps its own copy.
187
-
188
- `atomic storage join` takes a `postgres://` or `postgresql://` URL that names the user and never the password. Pass exactly one way to log in:
189
-
190
- | Option | What Atomic does |
132
+ Run these steps on each machine as the user who runs Atomic:
133
+
134
+ <Steps>
135
+ <Step title="Install the PostgreSQL adapter">
136
+ ```bash
137
+ atomic install npm:@bastani/atomic-storage-postgres
138
+ ```
139
+ </Step>
140
+ <Step title="Save the runtime password to a private file">
141
+ Reading from stdin keeps the password out of shell history:
142
+
143
+ ```bash
144
+ (umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
145
+ ```
146
+ </Step>
147
+ <Step title="Join the database">
148
+ ```bash
149
+ atomic storage join 'postgresql://atomic_runtime@db.example.com:5432/atomic' --password-file ~/atomic-db-password
150
+ ```
151
+
152
+ Atomic validates the URL, adapter, credentials, and a `SELECT 1` probe (15-second timeout) before writing anything, copies the password to an owner-only `~/.atomic/agent/storage-token.<id>` file (mode `600`), and updates only the top-level `storage` key in `~/.atomic/agent/settings.json`.
153
+ </Step>
154
+ <Step title="Restart Intercom and verify status">
155
+ Restart the local Intercom broker so it adopts the shared database (safe if no broker is running; already-open sessions keep their old store until restarted):
156
+
157
+ ```bash
158
+ atomic intercom restart
159
+ atomic storage status
160
+ ```
161
+
162
+ `atomic storage status` exits `0` when both sessions and Intercom connect, reporting `multi-node: on` and `wake-ups: LISTEN/NOTIFY`. The broker starts on demand with the first session that uses Intercom, so `brokers: 0 live` right after a restart is expected.
163
+ </Step>
164
+ <Step title="Delete your temporary password file">
165
+ ```bash
166
+ rm ~/atomic-db-password
167
+ ```
168
+
169
+ `atomic storage join` already saved its own private copy inside `~/.atomic/agent/`.
170
+ </Step>
171
+ </Steps>
172
+
173
+ `atomic storage join` accepts a `postgres://` or `postgresql://` URL with the username and **never** a password. Supply exactly one credential flag:
174
+
175
+ | Option | Behavior |
191
176
  | --- | --- |
192
- | `--password-file <path>` | Copies the password into a private file in the agent directory, `~/.atomic/agent/storage-token.<id>`, readable only by you. You can delete your own file afterwards. |
193
- | `--token-file <path>` | Remembers the path and reads the file again for every new connection. Use it when another program, such as a Vault agent, keeps a short-lived password in that file. Atomic removes one trailing line break, so write no other trailing spaces or blank lines. |
194
- | `--auth azure`, `--auth aws`, or `--auth gcp` | Logs in with the machine's cloud identity. See [Cloud identities](#cloud-identities). |
177
+ | `--password-file <path>` | Copies the password into `~/.atomic/agent/storage-token.<id>` (mode `600`). Safe to delete your source file afterward. |
178
+ | `--token-file <path>` | Stores the path and re-reads the file for every new connection—ideal for Vault agents or rotating token sidecars. Strips one trailing newline only. |
179
+ | `--auth azure`, `--auth aws`, or `--auth gcp` | Authenticates with the machine's [cloud identity](#cloud-identities). |
180
+
181
+ <Note>
182
+ `atomic storage join` overwrites any existing top-level `storage` setting without keeping a backup. Save your previous `storage` value first if you need it.
183
+ </Note>
195
184
 
196
- `atomic storage join` checks the URL, the adapter, and the password, and runs `SELECT 1` on the database, within 15 seconds. If any check fails, it changes nothing. Then it writes only the `storage` setting in `~/.atomic/agent/settings.json`, and replaces any `storage` value that was there. Save the old value first if you still need it. The setting looks like this:
185
+ The written `~/.atomic/agent/settings.json` entry looks like this (keep the exact `storage-token.<id>` filename that `atomic storage join` generated on your machine; `storage-token.example` is a placeholder in the examples below):
197
186
 
198
187
  ```json
199
188
  {
200
189
  "storage": {
201
190
  "adapter": "@bastani/atomic-storage-postgres",
202
191
  "options": { "url": "postgresql://atomic_runtime@db.example.com:5432/atomic" },
203
- "secrets": { "password": { "file": "agent/storage-token.28ab7041-05e2-4ad5-80af-854329035d8c" } }
192
+ "secrets": { "password": { "file": "agent/storage-token.example" } }
204
193
  }
205
194
  }
206
195
  ```
207
196
 
208
- `atomic storage join` created the password file and chose its name. `storage-token.28ab7041-05e2-4ad5-80af-854329035d8c` stands for that name here and in the examples below, so keep the name your machine has. The path is relative to the [storage home](/storage#storage-home), `~/.atomic`.
209
-
210
- You can write this setting yourself instead, or pass the same object in `ATOMIC_STORAGE` or `--storage`. Give the password in `secrets.password`, as `{ "file": "<path>" }` or `{ "env": "<variable>" }`. Atomic reads it again for every new connection, so a rotated password takes effect without a restart. A password in `options` is ignored, and a missing `secrets.password` fails with `StorageConfigError` and reason `secret-missing`.
197
+ Relative `secrets.password.file` paths resolve against the [storage home](/storage#storage-home) (`~/.atomic`). You can also author this object directly in `settings.json`, `ATOMIC_STORAGE`, or `--storage` using `{ "file": "<path>" }` or `{ "env": "<VAR>" }`. Atomic re-reads `secrets.password` on every new connection, so rotated passwords take effect without restarts. A password placed in `options` is ignored, and missing `secrets.password` fails with `StorageConfigError` (`secret-missing`).
211
198
 
212
199
  ### Connection options
213
200
 
214
- Put these in `options`. The defaults suit a few machines. [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents) explains when to change them.
201
+ Configure these under `options` (defaults suit small deployments; see [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents) for larger fleets):
215
202
 
216
203
  | Option | Default | What it does |
217
204
  | --- | --- | --- |
218
- | `url` | Required | The `postgres://` or `postgresql://` URL, with the user name and no password. |
219
- | `auth` | `"password"` | `"azure-entra"`, `"aws-iam"`, or `"gcp-iam"` to log in with a [cloud identity](#cloud-identities). |
220
- | `maxConnections` | `8` | The most connections one Atomic process opens to this database for its work. A positive whole number. |
221
- | `readerMaxConnections` | `2` | The most extra connections one process opens only for reads, so reads never wait behind writes. At most `maxConnections`. `0` turns the extra connections off. |
222
- | `statementTimeoutMs` | `30000` | How long one statement may run before the server cancels it, in milliseconds. If the server stops answering, Atomic drops the connection 5 seconds later. |
223
- | `connectTimeoutMs` | `10000` | How long opening a connection, or waiting for a free one, may take, in milliseconds. |
224
- | `idleTimeoutMs` | `300000` | How long a process keeps its last idle connection open, in milliseconds. Extra connections opened for a burst close after 10 seconds idle. |
225
- | `keepAliveIdleMs` | `60000` | How long a connection sits unused before Atomic sends TCP keepalive probes on it, in milliseconds. |
226
- | `maxPreparedStatements` | `256`, or `0` behind a pooler | How many queries each connection keeps prepared, so the server plans each one once. `0` turns this off. Atomic turns it off by itself behind a pooler, unless it finds a PgBouncer that supports it. See [Prepared statements](/storage/postgres/pgbouncer#how-atomic-works-with-pgbouncer). |
227
- | `listenUrl` | Same as `url` | The server's own address, for [wake-ups](#wake-ups): the instant notice of new Intercom messages. Set it when `url` points at a pooler, which cannot pass wake-ups. Follows the same rules as `url`. |
228
- | `schema` | `"atomic"` | The schema Atomic's tables live in. Lowercase letters, digits, and `_`, starting with a letter or `_`, at most 63 characters. To migrate a custom schema, put it in the `storage` setting and run `atomic storage migrate` without `--db`. |
229
- | `proxy` | From the environment | An `http://` or `https://` proxy for every connection, or `"none"` to ignore proxy variables. See [Through an HTTP proxy](#through-an-http-proxy). |
230
-
231
- For a Node.js or TypeScript app built on the SDK, install `@bastani/atomic-storage-postgres` with `npm install` and call `openPostgresDatabase` with the same options. See [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) and [SDK session storage](/sdk/storage).
205
+ | `url` | Required | `postgres://` or `postgresql://` URL containing the username and no password. |
206
+ | `auth` | `"password"` | `"azure-entra"`, `"aws-iam"`, or `"gcp-iam"` for [cloud identities](#cloud-identities). |
207
+ | `maxConnections` | `8` | Maximum main-pool connections opened by one Atomic process (positive integer). |
208
+ | `readerMaxConnections` | `2` | Maximum dedicated read-only connections per process (capped at `maxConnections`; `0` disables the read pool). |
209
+ | `statementTimeoutMs` | `30000` | Server-side statement cancellation timeout (ms). Atomic drops an unresponsive connection 5 seconds past this limit. |
210
+ | `connectTimeoutMs` | `10000` | Timeout for establishing a connection or waiting for a free pool slot (ms). |
211
+ | `idleTimeoutMs` | `300000` | How long the last idle connection in a pool stays open (ms). Burst connections close after 10 seconds idle. |
212
+ | `keepAliveIdleMs` | `60000` | Idle period before sending TCP keepalive probes (ms). |
213
+ | `maxPreparedStatements` | `256` (or `0` behind unsupported poolers) | Prepared statements cached per connection (`0` disables). Auto-detected behind PgBouncer; see [Prepared statements](/storage/postgres/pgbouncer#how-atomic-works-with-pgbouncer). |
214
+ | `listenUrl` | Same as `url` | Direct PostgreSQL endpoint for Intercom [wake-ups](#wake-ups) when `url` points at a transaction pooler. |
215
+ | `schema` | `"atomic"` | Schema for Atomic's tables (lowercase letters, digits, `_`, starting with letter/`_`, max 63 chars). To migrate a custom schema, put it in `storage` and run `atomic storage migrate` without `--db`. |
216
+ | `proxy` | From env | Explicit `http://` or `https://` proxy URL, or `"none"` to bypass proxy variables. See [Through an HTTP proxy](#through-an-http-proxy). |
217
+
218
+ For SDK apps using `openPostgresDatabase()`, see [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) and [SDK session storage](/sdk/storage).
232
219
 
233
220
  ## TLS
234
221
 
235
- Atomic encrypts every connection to a remote server and checks both the server's certificate and its host name, as `sslmode=verify-full` does. Connections to `localhost`, a loopback address, or a Unix socket use no TLS unless the URL sets `sslmode`. If the URL names no host, Atomic uses `PGHOST`.
222
+ Atomic encrypts every remote connection and verifies both the server's certificate and hostname (`sslmode=verify-full`) by default. Connections to `localhost`, loopback addresses, and Unix sockets skip TLS unless `sslmode` is specified in the URL. When the URL omits a host, Atomic reads `PGHOST`.
236
223
 
237
- To change this, add `sslmode` to the URL, in lowercase:
224
+ Override TLS behavior with a lowercase `sslmode` query parameter in `url`:
238
225
 
239
- | `sslmode` | Encrypts | Checks the certificate | Checks the host name |
226
+ | `sslmode` | Encrypts | Verifies certificate | Verifies hostname |
240
227
  | --- | --- | --- | --- |
241
- | `verify-full`, the default | Yes | Yes | Yes |
228
+ | `verify-full` (default) | Yes | Yes | Yes |
242
229
  | `verify-ca` | Yes | Yes | No |
243
230
  | `require` with `sslrootcert` | Yes | Yes | No |
244
231
  | `require` without `sslrootcert` | Yes | Yes | Yes |
245
232
  | `prefer` or `allow` | Yes | No | No |
246
233
  | `disable` | No | No | No |
247
234
 
248
- `require` without `sslrootcert` checks more than the PostgreSQL command-line tools do. An unknown `sslmode`, or a TLS parameter written in uppercase, fails with `StorageConfigError`.
235
+ Note that `require` without `sslrootcert` verifies more strictly than `psql`. Unknown `sslmode` values or uppercase TLS parameter names fail with `StorageConfigError`.
249
236
 
250
- Where to find the certificate authority, the certificate that signed the server's certificate:
237
+ **Certificate authorities (`sslrootcert`):**
251
238
 
252
- - **Self-hosted PostgreSQL.** Turn TLS on in `postgresql.conf` with `ssl = on`, `ssl_cert_file`, and `ssl_key_file`, using a certificate whose name matches the host in `url`. If your own certificate authority signed it, add `?sslrootcert=/path/to/root.crt` to the URL. The self-signed certificate that some Linux packages install, such as Debian's `snakeoil` certificate, does not pass the default check.
253
- - **Azure Database for PostgreSQL, Azure HorizonDB, and Neon.** Their certificates are trusted by Node.js already. Add nothing.
254
- - **Supabase.** Download the project's CA certificate from Project Settings > Database > SSL Configuration, and add `?sslrootcert=/path/to/supabase-ca.pem` to the URL.
255
- - **Amazon RDS and Aurora.** Download your region's bundle from `https://truststore.pki.rds.amazonaws.com/<region>/<region>-bundle.pem`, and add `?sslrootcert=/path/to/bundle.pem`.
256
- - **Google Cloud SQL.** Save the server's CA with `gcloud sql instances describe <instance> --format='value(serverCaCert.cert)'`. Over a private IP address, add `?sslmode=verify-ca&sslrootcert=/path/to/server-ca.pem`, because the certificate does not list private addresses.
239
+ - **Self-hosted PostgreSQL:** Enable `ssl = on`, `ssl_cert_file`, and `ssl_key_file` in `postgresql.conf` with a certificate matching the hostname in `url`. For a private CA, append `?sslrootcert=/path/to/root.crt`. Default distro self-signed certificates (like Debian's `snakeoil`) fail default verification.
240
+ - **Azure Flexible Server, Azure HorizonDB, and Neon:** Trusted by Node.js's built-in CA store; no `sslrootcert` needed.
241
+ - **Supabase:** Download the project CA from Project Settings → Database → SSL Configuration and pass `?sslrootcert=/path/to/supabase-ca.pem`.
242
+ - **Amazon RDS / Aurora:** Download `https://truststore.pki.rds.amazonaws.com/<region>/<region>-bundle.pem` and pass `?sslrootcert=/path/to/bundle.pem`.
243
+ - **Google Cloud SQL:** Export the server CA with `gcloud sql instances describe <instance> --format='value(serverCaCert.cert)'`. Over private IP, pass `?sslmode=verify-ca&sslrootcert=/path/to/server-ca.pem` (the certificate does not list private IPs).
257
244
 
258
245
  ## Through an HTTP proxy
259
246
 
260
- Where outbound traffic must go through an HTTP proxy, Atomic tunnels every database connection through it with HTTP `CONNECT`. Allow `<database host>:5432`, or your server's port, on the proxy.
247
+ When outbound network traffic must traverse an HTTP proxy, Atomic tunnels PostgreSQL connections using HTTP `CONNECT`. Allow `<database-host>:5432` (or your server port) on the proxy.
261
248
 
262
- - **Which proxy.** Atomic reads `HTTPS_PROXY` or `https_proxy` first, then `ALL_PROXY` when it names an `http://` or `https://` proxy, then `HTTP_PROXY`. A user name and password in the proxy URL are sent to the proxy and hidden from logs and errors.
263
- - **Hosts that skip the proxy.** `NO_PROXY` or `no_proxy` lists hosts to reach directly, such as `db.example.com`, `.example.com`, `*.example.com`, `host:port`, or `*`. `localhost`, loopback addresses, and Unix sockets never use the proxy.
264
- - **One store only.** Set the `proxy` option to a proxy URL to use it for this database, or to `"none"` to ignore the proxy variables.
265
- - **TLS stays end to end.** Atomic's TLS session runs inside the tunnel, so the proxy sees only encrypted traffic. With `verify-full`, the default, the certificate must match the database's host name. `verify-ca` protects against a proxy that intercepts traffic only when `sslrootcert` names a certificate authority used for nothing but your database servers.
249
+ - **Proxy selection:** Reads `HTTPS_PROXY` / `https_proxy`, then `ALL_PROXY` (for `http://` or `https://`), then `HTTP_PROXY`. Embedded proxy credentials are sent to the proxy and redacted from logs and errors.
250
+ - **Bypass rules:** `NO_PROXY` / `no_proxy` accepts hostnames, `.example.com`, `*.example.com`, `host:port`, or `*`. `localhost`, loopback addresses, and Unix sockets always connect directly.
251
+ - **Per-store override:** Set `options.proxy` to a proxy URL for one store, or `"none"` to ignore environment proxy variables.
252
+ - **End-to-end TLS:** TLS runs inside the tunnel so the proxy sees encrypted bytes only. With `verify-full`, the certificate must match the database hostname; `verify-ca` defends against proxy interception only when `sslrootcert` trusts solely your database CA.
266
253
 
267
- If the proxy refuses the tunnel with `403` or `407`, opening fails at once with `StorageUnavailableError`. A refused or dropped connection, or a `502` or `503` answer, is retried like an unreachable server, with a warning that names the proxy and the reason.
254
+ A `403` or `407` proxy rejection fails immediately with `StorageUnavailableError`. Connection drops or `502`/`503` responses retry like an unreachable server and log a warning naming the proxy.
268
255
 
269
256
  ## Connection budget
270
257
 
271
- Connections are counted per process. What counts as one Atomic process:
258
+ Connections are pooled **per Atomic process**. Each of the following counts as one process:
272
259
 
273
- - each `atomic` you start, interactive or with `-p`;
274
- - each `atomic --mode rpc` child that a program starts;
275
- - the Intercom broker: Atomic runs one Intercom broker per agent directory, usually one per machine or container.
260
+ - every interactive `atomic` or `atomic -p` invocation;
261
+ - every `atomic --mode rpc` subprocess;
262
+ - each Intercom broker (one per agent directory, typically one per host or container).
276
263
 
277
- Subagents run inside the process that launched them and share its connections, so they add none.
264
+ Subagents run inside their parent process and share its pools without opening extra connections.
278
265
 
279
- Each Atomic process shares one set of connections per database between everything it opens there: its sessions, its subagents' sessions, search, and Intercom. The set holds:
266
+ Within a process, sessions, subagents, search, and Intercom share one pool per identical database configuration:
280
267
 
281
- | Connections | How many | `application_name` in `pg_stat_activity` |
268
+ | Pool | Max connections | `application_name` in `pg_stat_activity` |
282
269
  | --- | --- | --- |
283
- | Main pool | Up to `maxConnections`, 8 by default | `atomic` |
284
- | Read pool | Up to `readerMaxConnections`, 2 by default. Only reads use it | `atomic-reader` |
285
- | Wake-up connection | 1, only in a process that listens for [wake-ups](#wake-ups), such as an Intercom broker | `atomic-listen` |
286
-
287
- So a process opens at most `maxConnections` + `readerMaxConnections` connections, 10 with the defaults, and a process that listens, such as an Intercom broker, 1 more: 11.
270
+ | Main pool | `maxConnections` (default `8`) | `atomic` |
271
+ | Read pool | `readerMaxConnections` (default `2`; reads only) | `atomic-reader` |
272
+ | Wake-up listener | `1` (listening processes such as Intercom brokers only) | `atomic-listen` |
288
273
 
289
- Atomic opens connections only when it needs them, and closes them again. An extra connection opened for a burst closes after 10 seconds unused. The last connection of each pool stays open for `idleTimeoutMs`, 5 minutes by default, so the next call after a pause does not wait for a new connection. So between bursts, a process holds 1 main connection, 1 read connection if it read recently, and its wake-up connection if it listens. Open connections never keep a process from exiting.
274
+ At defaults, one agent process opens at most **10** connections, and an Intercom broker opens at most **11**.
290
275
 
291
- Size the settings by how many processes you run:
276
+ Connections open lazily and scale back down automatically: burst connections close after 10 seconds idle, while the final connection in each pool stays warm for `idleTimeoutMs` (5 minutes by default). Open connections never prevent a process from exiting.
292
277
 
293
- - **A few long-lived processes**, such as one interactive session per machine. Keep the defaults.
294
- - **Many processes, such as a swarm of agent runners.** Work out `maxConnections` with [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents). If the processes often sit idle, set `idleTimeoutMs` between `10000` and `30000`, so idle processes give their connections back sooner.
295
- - **More processes than the server can take.** Connect through [PgBouncer](/storage/postgres/pgbouncer) in transaction mode, and set `listenUrl` to the server's own address. Then only the wake-up connections go to the server directly.
278
+ - **Small team / interactive use:** keep the defaults.
279
+ - **Large fleet with idle periods:** size `maxConnections` via [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents) and lower `idleTimeoutMs` (for example `10000`–`30000`) so idle processes release connections faster.
280
+ - **More processes than `max_connections` allows:** deploy [PgBouncer](/storage/postgres/pgbouncer) in transaction mode and point `listenUrl` directly at PostgreSQL.
296
281
 
297
282
  ## Connection poolers
298
283
 
299
- A pooler lets many clients share a few server connections. Atomic works with poolers in transaction mode or session mode, never statement mode. That includes PgBouncer, Azure's built-in PgBouncer on port 6432, Supabase's Supavisor on port 6543, and Neon's `-pooler` host.
284
+ Atomic supports connection poolers in **transaction mode** or **session mode** (never statement mode), including self-hosted PgBouncer, Azure Flexible Server's built-in PgBouncer (port 6432), Supabase Supavisor (port 6543), and Neon's `-pooler` endpoint.
300
285
 
301
- A pooler in transaction mode cannot pass notifications, so set `listenUrl` to the server's own address, such as port 5432 on Azure or Neon's host without `-pooler`. Without it, Intercom still works, by checking for new messages every half second. See [Wake-ups](#wake-ups).
286
+ Transaction poolers cannot forward PostgreSQL `LISTEN`/`NOTIFY` notifications, so set `listenUrl` to PostgreSQL's direct endpoint (for example port 5432 on Azure, or Neon's non-`-pooler` host). Without `listenUrl`, Intercom still delivers messages by polling every 0.5 seconds (see [Wake-ups](#wake-ups)).
302
287
 
303
- To run your own PgBouncer, follow the [PgBouncer guide](/storage/postgres/pgbouncer). It has a complete configuration with TLS and SCRAM, how to size the pools, and how to check that it works.
288
+ For a complete TLS + SCRAM PgBouncer setup, see [PostgreSQL with PgBouncer](/storage/postgres/pgbouncer).
304
289
 
305
290
  ## Wake-ups
306
291
 
307
- When one machine sends an Intercom message, the receiving machine's broker learns about it at once through PostgreSQL's `LISTEN` and `NOTIFY` commands. Each process that listens, such as an Intercom broker, holds one wake-up connection per database.
292
+ When a machine sends a cross-host Intercom message, the receiving broker learns about it immediately through PostgreSQL `LISTEN`/`NOTIFY`. Each listening process (such as an Intercom broker) holds one dedicated `atomic-listen` connection per database.
308
293
 
309
- While wake-ups work, each broker also checks for missed messages every 5 seconds. If the wake-up connection drops, or `url` points at a transaction pooler and `listenUrl` is not set, brokers check every half second instead, so no message is lost. Atomic checks the wake-up connection every 30 seconds and reconnects it. Behind a transaction pooler, it stops trying until the process restarts.
294
+ Atomic backs up real-time notifications with two independent polling safety nets:
310
295
 
311
- `atomic storage status` shows the state:
296
+ - **Wake-up hint poll (`intercom_wakeups`):** While `LISTEN/NOTIFY` is live, each broker polls wake-up hints every **5 seconds** to catch any missed notification. If the `LISTEN` connection drops—or `url` points at a transaction pooler without `listenUrl`—brokers poll wake-up hints every **0.5 seconds** (500 ms) instead. Atomic retries reconnecting a dropped `LISTEN` connection every 30 seconds (behind a transaction pooler without `listenUrl`, it stays in polling mode until restart).
297
+ - **Backup outbox scan (`intercom_outbox`):** Independently of wake-up hints, every broker scans the durable outbox table directly every **30 seconds**. Even if a server crash or failover empties the unlogged `intercom_wakeups` table, every message still arrives within 30 seconds (see [Intercom's wake-up notices](/storage/postgres/tuning#intercoms-wake-up-notices)).
298
+
299
+ Check wake-up health with `atomic storage status`:
312
300
 
313
301
  | Status line | Meaning |
314
302
  | --- | --- |
315
- | `wake-ups: LISTEN/NOTIFY` | Wake-ups work. |
316
- | `wake-ups: connecting` | The wake-up connection is opening. |
317
- | `wake-ups: polling only, notifications do not pass the URL's transaction pooler (set listenUrl to a direct endpoint)` | `url` points at a pooler. Set `listenUrl` to the server's own address. |
318
- | `wake-ups: polling only, the listen connection failed` | The wake-up connection could not connect or log in. Check `listenUrl` and the server's connection limit. |
303
+ | `wake-ups: LISTEN/NOTIFY` | Instant notifications are active. |
304
+ | `wake-ups: connecting` | Listener connection is opening. |
305
+ | `wake-ups: polling only, notifications do not pass the URL's transaction pooler (set listenUrl to a direct endpoint)` | `url` hits a transaction pooler; set `listenUrl` to the direct server endpoint. |
306
+ | `wake-ups: polling only, the listen connection failed` | Listener failed to connect or authenticate; check `listenUrl` and `max_connections`. |
307
+
308
+ ## Managed PostgreSQL services
309
+
310
+ All major managed PostgreSQL services work with the roles in [Set up the database](#set-up-the-database). Provider-specific notes:
311
+
312
+ ### Azure
313
+
314
+ - **Azure Database for PostgreSQL Flexible Server:** Connect to `<server>.postgres.database.azure.com:5432` (TLS trusted automatically). Run role setup as a member of `azure_pg_admin` (if using `schema: "public"`, also run `GRANT CREATE ON SCHEMA public TO atomic_owner;`). On General Purpose / Memory Optimized tiers, enable built-in PgBouncer (`pgbouncer.enabled`, port 6432) and point `listenUrl` at port 5432. Allow `PG_TRGM` in `azure.extensions` and run `atomic storage migrate` for indexed history search. Note smaller tiers like Burstable B1ms allow only 50 connections (with 15 reserved for admins).
315
+ - **Azure HorizonDB (preview, PostgreSQL 17):** Connect to the read/write endpoint (`<cluster>.rw.<id>.<region>.horizondb.azure.com:5432`); read-only endpoints are unsupported because Atomic writes on open. Wake-ups work on the read/write endpoint. Allow `pg_trgm` in the compute pool's parameter group, then run `atomic storage migrate`.
316
+ - Both support Microsoft Entra ID via `--auth azure`.
319
317
 
320
- ## Azure
318
+ ### Amazon RDS and Aurora
321
319
 
322
- **Azure Database for PostgreSQL Flexible Server:**
320
+ - Connect to the writer endpoint (never a read-only replica) and pass the regional CA bundle via `?sslrootcert=/path/to/<region>-bundle.pem` (see [TLS](#tls)).
321
+ - If using Amazon RDS Proxy, point `listenUrl` at the DB instance endpoint and set `maxPreparedStatements: 0` (RDS Proxy listens on port 5432 and does not preserve prepared statements or `LISTEN`).
322
+ - Supports IAM authentication via `--auth aws`.
323
323
 
324
- - Connect to `<server>.postgres.database.azure.com` on port 5432.
325
- - On General Purpose and Memory Optimized tiers, you can turn on the built-in PgBouncer with the `pgbouncer.enabled` server parameter. It listens on port 6432. Point `url` at port 6432 and `listenUrl` at port 5432.
326
- - Add `PG_TRGM` to the `azure.extensions` server parameter, then run `atomic storage migrate`, so Atomic can index session history search. Without it, search still works but reads sessions one page at a time, and `atomic storage migrate` tells you to run it again once the extension is allowed.
327
- - Watch the connection limit. A Burstable B1ms server allows 50 connections and keeps 15 of them for administrators. With the defaults, one Atomic process can open 10, and an Intercom broker 11. Lower `maxConnections`, use PgBouncer, or pick a larger server. See [Connection budget](#connection-budget).
328
- - Allow your machines' addresses in the firewall rules, or use private access.
324
+ ### Google Cloud SQL
329
325
 
330
- **Azure HorizonDB (preview, PostgreSQL 17):**
326
+ - Run initial role creation as `postgres` or a member of `cloudsqlsuperuser`, and pass the exported server CA via `sslrootcert` (use `sslmode=verify-ca` over private IP; see [TLS](#tls)).
327
+ - Supports IAM authentication via `--auth gcp`.
331
328
 
332
- - Connect to the cluster's read/write endpoint, `<cluster>.rw.<id>.<region>.horizondb.azure.com`, on port 5432. A read-only endpoint does not work, because Atomic writes on every connection. Wake-ups work on the read/write endpoint.
333
- - Add `pg_trgm` to `azure.extensions` in the compute pool's parameter group, then run `atomic storage migrate`.
334
- - Allow your machines' addresses in the firewall rules, or connect over a private endpoint.
329
+ ### Neon and Supabase
335
330
 
336
- Both services use certificates Node.js trusts, work with the roles from [Set up the database](#set-up-the-database), and support Microsoft Entra ID with `--auth azure`.
331
+ - **Neon:** Built-in TLS CA is trusted automatically. For pooled connections, point `url` at the `-pooler` host and `listenUrl` at the direct host without `-pooler`.
332
+ - **Supabase:** Download the project CA certificate for `sslrootcert` (see [TLS](#tls)). For Supavisor transaction pooling, point `url` at port 6543 and `listenUrl` at port 5432; leave `maxPreparedStatements` unset so Atomic keeps prepared statements off behind Supavisor.
337
333
 
338
334
  ## Cloud identities
339
335
 
340
- A machine on Azure, AWS, or Google Cloud can log in with its cloud identity instead of a password. Atomic asks the cloud for a short-lived token for each new connection and keeps it only in memory. Install the cloud provider's library first:
336
+ Machines on Azure, AWS, or Google Cloud can authenticate using short-lived cloud IAM tokens instead of static passwords. Tokens are requested per new connection and kept in memory only. Install the provider's library once per machine:
341
337
 
342
- | `--auth` | `options.auth` | Install | Where the identity comes from |
338
+ | `--auth` | `options.auth` | Install command | Identity source |
343
339
  | --- | --- | --- | --- |
344
- | `azure` or `azure-entra` | `"azure-entra"` | `atomic install npm:@azure/identity` | `AZURE_*` variables, AKS workload identity, the managed identity of a VM, App Service, or Container App (`AZURE_CLIENT_ID` picks a user-assigned one), or `az login` |
345
- | `aws` or `aws-iam` | `"aws-iam"` | `atomic install npm:@aws-sdk/rds-signer` | The default AWS credentials: `AWS_*` variables, profiles, IRSA, or the instance profile |
346
- | `gcp` or `gcp-iam` | `"gcp-iam"` | `atomic install npm:google-auth-library` | Application Default Credentials: `GOOGLE_APPLICATION_CREDENTIALS`, the Compute Engine, GKE, or Cloud Run metadata server, or `gcloud auth application-default login` |
340
+ | `azure` / `azure-entra` | `"azure-entra"` | `atomic install npm:@azure/identity` | `AZURE_*` env vars, AKS workload identity, VM/App Service/Container App managed identity (`AZURE_CLIENT_ID`), or `az login` |
341
+ | `aws` / `aws-iam` | `"aws-iam"` | `atomic install npm:@aws-sdk/rds-signer` | Standard AWS credential chain (`AWS_*`, profiles, IRSA, instance profile) |
342
+ | `gcp` / `gcp-iam` | `"gcp-iam"` | `atomic install npm:google-auth-library` | Application Default Credentials (`GOOGLE_APPLICATION_CREDENTIALS`, GCE/GKE/Cloud Run metadata, or `gcloud auth application-default login`) |
347
343
 
348
- If the library is missing or cannot get a token, opening fails with `StorageConfigError` and reason `auth-unavailable`. Cloud tokens need TLS, so keep the default `sslmode`.
344
+ `atomic install` places these libraries in `~/.atomic/agent/npm`, where `@bastani/atomic-storage-postgres` discovers them. Missing libraries or unavailable credentials fail immediately with `StorageConfigError` (`auth-unavailable`). Cloud IAM tokens require TLS, so keep the default `sslmode`.
349
345
 
350
- Then map the identity to a PostgreSQL role:
346
+ Map the cloud identity to a PostgreSQL role and grant it the runtime privileges from [Set up the database](#set-up-the-database):
351
347
 
352
- - **Azure, Flexible Server or HorizonDB.** Turn on Microsoft Entra authentication and add an Entra administrator. Connected to the `postgres` database as that administrator, run `SELECT * FROM pgaadauth_create_principal('<identity name>', false, false);` and grant the new role `CONNECT` on the Atomic database. Use the identity name as the user in the URL.
353
- - **AWS.** Turn on IAM database authentication. Run `CREATE USER atomic; GRANT rds_iam TO atomic;`, and allow the IAM identity `rds-db:connect` on `arn:aws:rds-db:<region>:<account>:dbuser:<DbiResourceId>/atomic`.
354
- - **Google Cloud.** Set `cloudsql.iam_authentication=on`, add the service account as an IAM database user, and grant it `roles/cloudsql.instanceUser`. Use the service account's email without `.gserviceaccount.com` as the user in the URL. Compute Engine VMs need the `cloud-platform` scope.
348
+ - **Azure:** Enable Microsoft Entra authentication, connect to `postgres` as the Entra admin, run `SELECT * FROM pgaadauth_create_principal('<identity name>', false, false);`, grant `CONNECT` on the `atomic` database, and use `<identity name>` as the URL user.
349
+ - **AWS:** Enable IAM database authentication, run `CREATE USER atomic; GRANT rds_iam TO atomic;`, and grant the IAM identity `rds-db:connect` on `arn:aws:rds-db:<region>:<account>:dbuser:<DbiResourceId>/atomic`.
350
+ - **Google Cloud:** Enable `cloudsql.iam_authentication=on`, add the service account as an IAM database user with `roles/cloudsql.instanceUser`, and use the service account email without `.gserviceaccount.com` as the URL user (Compute Engine VMs need the `cloud-platform` scope).
355
351
 
356
- Give the mapped role the runtime privileges from [Set up the database](#set-up-the-database), and run `atomic storage migrate` as the owner role. For more detail per service, see [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres).
357
-
358
- `atomic install` puts these libraries in `~/.atomic/agent/npm`, where the PostgreSQL adapter looks for them.
352
+ See [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) for full SDK options.
359
353
 
360
354
  ## Tuning for many concurrent agents
361
355
 
362
- How many agents can write at once depends on how many connections each process may open. Writes to different sessions run side by side, each on its own connection. Writes to the same session wait for each other.
363
-
364
- This section covers Atomic's settings. For the server side, such as memory, monitoring, and the busiest tables, see [Server tuning](/storage/postgres/tuning).
356
+ Write parallelism scales with each process's connection pool: writes to different sessions run concurrently on separate connections, while writes to the same session serialize. This section covers client-side Atomic settings; for server memory, autovacuum, and monitoring, see [Server tuning](/storage/postgres/tuning).
365
357
 
366
- Every Atomic process on every machine shares the server's `max_connections`. Give each process as many connections as the server can spare, and no more. The steps below work out that number.
358
+ Every Atomic process across all hosts shares PostgreSQL's `max_connections`. Give each process as many connections as the server can safely spare, and no more.
367
359
 
368
360
  ### Count the connections Atomic needs
369
361
 
370
- Each Atomic process, as [Connection budget](#connection-budget) defines it, opens up to this many connections:
371
-
372
- - **An agent process**, including each `atomic --mode rpc` child: `maxConnections` plus `readerMaxConnections`.
373
- - **An Intercom broker**: `maxConnections` plus `readerMaxConnections`, plus 1 for [wake-ups](#wake-ups).
362
+ Plan for each process's peak connection count (from [Connection budget](#connection-budget)):
374
363
 
375
- A quiet process holds fewer. Plan for the maximum anyway, because busy processes reach it.
364
+ - **Agent process** (including each `atomic --mode rpc` child): `maxConnections + readerMaxConnections`
365
+ - **Intercom broker:** `maxConnections + readerMaxConnections + 1` (for wake-ups)
376
366
 
377
- Find what the server has to share. Run these as an administrator:
367
+ Check available slots on the server as an administrator:
378
368
 
379
369
  ```sql
380
370
  SHOW max_connections;
@@ -384,24 +374,24 @@ SELECT count(*) FROM pg_stat_activity
384
374
  WHERE backend_type = 'client backend' AND application_name NOT LIKE 'atomic%';
385
375
  ```
386
376
 
387
- Then work out `maxConnections`:
377
+ Calculate `maxConnections`:
388
378
 
389
- 1. Take `max_connections`. Subtract both reserved counts and the connections other clients use. Call the result *available*.
390
- 2. Count *P*, the number of Atomic processes on all machines, and *B*, the number of those that are Intercom brokers. Atomic runs one Intercom broker per agent directory, usually one per machine or container.
391
- 3. Each process may use (*available* − *B*) / *P* connections, rounded down.
392
- 4. Set `maxConnections` to that number minus `readerMaxConnections`.
379
+ 1. Compute *available* = `max_connections` − reserved slots − non-Atomic client connections.
380
+ 2. Count *P* (total Atomic processes across all hosts) and *B* (Intercom brokers—usually one per host or container).
381
+ 3. Each process gets `floor((available − B) / P)` connections.
382
+ 4. Set `maxConnections` = that budget minus `readerMaxConnections`.
393
383
 
394
- If step 4 gives `maxConnections` below 2, the server cannot give each process enough connections. Use a pooler, as in the second example below.
384
+ If step 4 produces `maxConnections` below `2`, put [PgBouncer](/storage/postgres/pgbouncer) in front of the server (see the second example below).
395
385
 
396
- A new PostgreSQL server has `max_connections = 100` with 3 slots reserved for superusers. With Atomic's defaults, each process may need 10 connections and each broker 11, so such a server holds about 8 processes. For example, 20 agent processes on 4 machines, with one broker each, can open up to 20 × 10 + 4 × 11 = 244 connections. Raise `max_connections`, lower `maxConnections`, or use PgBouncer.
386
+ A default server (`max_connections = 100`, 3 superuser slots) fits about 8 processes at default settings (10 per agent, 11 per broker). For example, 20 agents across 4 machines (4 brokers) can open up to `20 × 10 + 4 × 11 = 244` connections—requiring higher `max_connections`, lower `maxConnections`, or PgBouncer.
397
387
 
398
388
  ### Example: 24 processes on a large server
399
389
 
400
- Four machines each run five agent processes and one Intercom broker, so *P* is 24 and *B* is 4. The server has `max_connections = 500`, 3 superuser slots, no other reserved slots, and 20 connections used by other clients.
390
+ Four machines each run 5 agent processes and 1 Intercom broker (*P* = 24, *B* = 4). The server has `max_connections = 500`, 3 superuser slots, 0 other reserved slots, and 20 non-Atomic connections:
401
391
 
402
- - *available* is 500 − 3 − 0 − 20 = 477.
403
- - Each process may use (477 − 4) / 24 = 19.7, rounded down to 19.
404
- - With the default `readerMaxConnections` of 2, set `maxConnections` to 19 − 2 = 17.
392
+ - *available* = 500 − 3 − 0 − 20 = 477
393
+ - Per-process budget = `floor((477 − 4) / 24)` = 19
394
+ - With default `readerMaxConnections: 2`, set `maxConnections: 17`.
405
395
 
406
396
  In `~/.atomic/agent/settings.json` on each machine:
407
397
 
@@ -414,12 +404,12 @@ In `~/.atomic/agent/settings.json` on each machine:
414
404
  "maxConnections": 17,
415
405
  "readerMaxConnections": 2
416
406
  },
417
- "secrets": { "password": { "file": "agent/storage-token.28ab7041-05e2-4ad5-80af-854329035d8c" } }
407
+ "secrets": { "password": { "file": "agent/storage-token.example" } }
418
408
  }
419
409
  }
420
410
  ```
421
411
 
422
- The same options in an SDK app:
412
+ Equivalent SDK configuration:
423
413
 
424
414
  ```typescript
425
415
  import { openPostgresDatabase } from "@bastani/atomic-storage-postgres";
@@ -434,13 +424,13 @@ const database = await openPostgresDatabase({
434
424
 
435
425
  ### Example: 150 machines on a smaller server
436
426
 
437
- Here, 150 CI runners each run one agent process and one Intercom broker, so *P* is 300 and *B* is 150. The server has `max_connections = 300`, 3 superuser slots, and 10 connections used by other clients, so *available* is 287.
427
+ Here, 150 CI runners each run 1 agent process and 1 Intercom broker (*P* = 300, *B* = 150) against a server with `max_connections = 300`, 3 superuser slots, and 10 other clients (*available* = 287).
438
428
 
439
- Even at the smallest settings, `maxConnections: 1` and `readerMaxConnections: 0`, the processes need 300 × 1 + 150 = 450 connections. That is more than 287, so connect through a pooler such as PgBouncer in transaction mode, on port 6432:
429
+ Even with `maxConnections: 1` and `readerMaxConnections: 0`, 300 processes need `300 + 150 = 450` connections—more than 287. Route traffic through [PgBouncer](/storage/postgres/pgbouncer) in transaction mode on port 6432:
440
430
 
441
- - **Point `url` at PgBouncer.** Connections to PgBouncer do not count against the server, so keep `maxConnections` at its default of 8. Set PgBouncer's `max_client_conn` to at least *P* × (`maxConnections` + `readerMaxConnections`), here 300 × 10 = 3000.
442
- - **Point `listenUrl` at the server**, or leave it out. PgBouncer cannot pass wake-ups. With `listenUrl`, each broker holds one direct connection, learns of new messages at once, and checks for missed ones every 5 seconds. Without it, brokers check the database every half second, 10 times as often.
443
- - **Size PgBouncer's pool** to fit in what is left. With `listenUrl`, PgBouncer's pool and its reserve together may use at most 287 − 150 = 137 connections. Without `listenUrl`, up to 287. A smaller pool is often faster. The [PgBouncer guide](/storage/postgres/pgbouncer#choose-the-pool-sizes) starts at 80 plus 5 in reserve.
431
+ - **Point `url` at PgBouncer** and keep `maxConnections: 8`. Set PgBouncer's `max_client_conn` above `P × (maxConnections + readerMaxConnections)` (`300 × 10 = 3000`).
432
+ - **Point `listenUrl` directly at PostgreSQL** (optional). With `listenUrl`, each broker holds 1 direct connection for instant wake-ups and polls hints every 5 seconds; without it, brokers poll every 0.5 seconds.
433
+ - **Cap PgBouncer's server pool** within remaining capacity (`287 − 150 = 137` with `listenUrl`, or `287` without). A smaller pool (such as 80 + 5 reserve in the [PgBouncer guide](/storage/postgres/pgbouncer#choose-the-pool-sizes)) often outperforms a larger one.
444
434
 
445
435
  ```json
446
436
  {
@@ -451,12 +441,12 @@ Even at the smallest settings, `maxConnections: 1` and `readerMaxConnections: 0`
451
441
  "listenUrl": "postgresql://atomic_runtime@db.example.com:5432/atomic",
452
442
  "maxConnections": 8
453
443
  },
454
- "secrets": { "password": { "file": "agent/storage-token.28ab7041-05e2-4ad5-80af-854329035d8c" } }
444
+ "secrets": { "password": { "file": "agent/storage-token.example" } }
455
445
  }
456
446
  }
457
447
  ```
458
448
 
459
- The same options in an SDK app:
449
+ Equivalent SDK configuration:
460
450
 
461
451
  ```typescript
462
452
  const database = await openPostgresDatabase({
@@ -467,24 +457,22 @@ const database = await openPostgresDatabase({
467
457
  });
468
458
  ```
469
459
 
470
- The [PgBouncer guide](/storage/postgres/pgbouncer) has a complete PgBouncer configuration, the PostgreSQL and Atomic settings that go with it, and how to check that it works.
471
-
472
460
  ### Other settings
473
461
 
474
- Set these in the same `options` object, or pass them to `openPostgresDatabase`. Each takes a whole number of milliseconds, except `maxPreparedStatements`.
462
+ Tune these under `options` (all timeouts are integers in milliseconds):
475
463
 
476
- - **Distance comes first.** Each save waits for at least one round trip to the server, so a machine 80 ms away spends at least 80 ms on each save. Put the database in the same region as the agents. Saves are slower until the owner has run `atomic storage migrate` after an upgrade.
477
- - **`idleTimeoutMs`** (default `300000`, 5 minutes). Lower it, for example to `30000`, when long-running processes sit idle and the server is near its connection limit.
478
- - **`statementTimeoutMs`** (default `30000`). Raise it only if statements fail with `StorageTransientError` code `transaction-timeout` on a slow server. A lower value does not make anything faster.
479
- - **`connectTimeoutMs`** (default `10000`). Raise it for a distant server or one that is slow to accept connections.
480
- - **`keepAliveIdleMs`** (default `60000`). Lower it if calls fail with `StorageTransientError` code `connection-lost` after a pause. That error after a pause usually means a firewall, NAT, or load balancer dropped the idle connection.
481
- - **`maxPreparedStatements`** (default `256`, or `0` behind a pooler). Lower it if the server is short of memory per connection. Atomic expects a pooler on ports 6432 and 6543. Behind a pooler on any other port, set `listenUrl` or `maxPreparedStatements: 0`. See [Prepared statements](/storage/postgres/pgbouncer#how-atomic-works-with-pgbouncer).
464
+ - **Colocate database and agents.** Every save waits for at least one network round trip—run PostgreSQL in the same region as your agents, and run `atomic storage migrate` after upgrades so saves use the single-round-trip append path.
465
+ - **`idleTimeoutMs`** (default `300000`): lower (for example `30000`) when idle processes hold connections on a busy server.
466
+ - **`statementTimeoutMs`** (default `30000`): raise only if legitimate queries hit `StorageTransientError` (`transaction-timeout`).
467
+ - **`connectTimeoutMs`** (default `10000`): raise for high-latency or slow-accepting servers.
468
+ - **`keepAliveIdleMs`** (default `60000`): lower if connections fail with `connection-lost` after idle periods (NAT, firewall, or load balancer dropping idle TCP sockets).
469
+ - **`maxPreparedStatements`** (default `256`, or `0` behind unsupported poolers): lower if server per-connection memory is tight. Atomic auto-detects poolers on ports `6432` and `6543`; behind a pooler on another port, set `listenUrl` or `maxPreparedStatements: 0`. See [Prepared statements](/storage/postgres/pgbouncer#how-atomic-works-with-pgbouncer).
482
470
 
483
471
  ### Check the effect
484
472
 
485
- Run these as an administrator. Replace `atomic` with your database name. Atomic's connections report the application name `atomic`, `atomic-reader`, or `atomic-listen`.
473
+ Run these queries as an administrator (replace `atomic` with your database name):
486
474
 
487
- How many connections Atomic holds, and what they are doing:
475
+ Connections by Atomic pool and state:
488
476
 
489
477
  ```sql
490
478
  SELECT application_name, state, count(*)
@@ -494,7 +482,7 @@ GROUP BY 1, 2
494
482
  ORDER BY 3 DESC;
495
483
  ```
496
484
 
497
- What busy connections are waiting for:
485
+ What active connections are waiting on:
498
486
 
499
487
  ```sql
500
488
  SELECT wait_event_type, wait_event, count(*)
@@ -504,7 +492,7 @@ GROUP BY 1, 2
504
492
  ORDER BY 3 DESC;
505
493
  ```
506
494
 
507
- How close the server is to its limit:
495
+ Total client connections vs. `max_connections`:
508
496
 
509
497
  ```sql
510
498
  SELECT count(*) AS used, current_setting('max_connections')::int AS max
@@ -512,45 +500,41 @@ FROM pg_stat_activity
512
500
  WHERE backend_type = 'client backend';
513
501
  ```
514
502
 
515
- What to change:
516
-
517
- | You see | It means | Change |
503
+ | Symptom | Cause | Action |
518
504
  | --- | --- | --- |
519
- | `sorry, too many clients already`, `remaining connection slots are reserved for roles with the SUPERUSER attribute`, or `too many connections for role "<role>"` | The processes asked for more connections than the server or the role allows. | Lower `maxConnections` or `readerMaxConnections`, raise `max_connections` or the role's `CONNECTION LIMIT`, or [put PgBouncer in front](/storage/postgres/pgbouncer). |
520
- | `timeout exceeded when trying to connect` | Every connection in a process's pool stayed busy for `connectTimeoutMs`. | Raise `maxConnections` if the server has connections to spare. Otherwise raise `connectTimeoutMs`. |
521
- | `the call was queued behind an earlier call that ran 60 seconds without settling, and did not run; nothing was written, retry it` | An earlier call ran for a minute, usually because it waited on a lock or on an overloaded server, and this call waited behind it. | Check what busy connections wait for. More connections do not help. |
522
- | Many connections with `wait_event_type` `Lock` | Agents write to the same sessions at once and wait for each other. | More connections do not help. Spread agents over more sessions. |
523
- | Most `atomic` connections are `idle` and the server is near its limit | Idle processes keep connections open. | Lower `idleTimeoutMs`. |
524
- | `wake-ups: polling only, the listen connection failed` in `atomic storage status` | A broker could not open its wake-up connection, often because the server has none left. | Count the connections again with the steps above. |
505
+ | `sorry, too many clients already`, `remaining connection slots are reserved…`, or `too many connections for role "<role>"` | Processes exceeded server or role connection limits. | Lower `maxConnections`/`readerMaxConnections`, raise `max_connections` or role `CONNECTION LIMIT`, or deploy [PgBouncer](/storage/postgres/pgbouncer). |
506
+ | `timeout exceeded when trying to connect` | All connections in a process's pool stayed busy for `connectTimeoutMs`. | Raise `maxConnections` if server capacity allows, or raise `connectTimeoutMs`. |
507
+ | `the call was queued behind an earlier call that ran 60 seconds without settling…` | An earlier query stalled for 60s (lock wait or overloaded server); the queued call failed without writing. | Inspect `wait_event_type` on active sessions; adding connections will not resolve lock contention. |
508
+ | Many connections waiting on `wait_event_type = 'Lock'` | Multiple agents writing to the same session simultaneously. | Spread concurrent agents across distinct sessions. |
509
+ | Mostly `idle` `atomic` connections near server limit | Idle processes holding warm pool slots. | Lower `idleTimeoutMs`. |
510
+ | `wake-ups: polling only, the listen connection failed` | Broker could not open its `atomic-listen` connection (often out of slots). | Recount connections above and check `listenUrl`. |
525
511
 
526
- Atomic reports the first two rows as `StorageTransientError` with code `connection-refused`, and the quoted text is the error's cause. The third row is a `StorageUnavailableError` whose message ends with the quoted text.
512
+ The first two rows surface as `StorageTransientError` (`connection-refused`) with the quoted message as `cause`; the third surfaces as `StorageUnavailableError`.
527
513
 
528
514
  ## Troubleshooting
529
515
 
530
- Errors from `atomic storage join`, `atomic storage migrate`, and opening the database, with what to do:
531
-
532
516
  | Error | Fix |
533
517
  | --- | --- |
534
- | `credential-in-url` | Remove the password from the URL. Pass `--password-file` or `--token-file` instead. |
535
- | `libsql-removed` | The URL is a libSQL one, such as `libsql://`, `https://`, `wss://`, or `file:`, or the command is `atomic team join`. Use a `postgres://` URL with `atomic storage join`. To move existing sessions, see [Moving off libSQL](/storage#moving-off-libsql). |
536
- | `unsupported-auth` | `--auth` accepts `azure`, `aws`, or `gcp`, or the long forms `azure-entra`, `aws-iam`, and `gcp-iam`. |
537
- | `adapter-not-installed` | Run `atomic install npm:@bastani/atomic-storage-postgres` as the user who runs Atomic. |
538
- | `auth-unavailable` | Install the cloud library the error names, and check that the machine has a cloud identity. Atomic does not retry this error. |
539
- | `missing-privilege`, with PostgreSQL code `42501` or `3F000` | Run the `GRANT` the error names, as in [Set up the database](#set-up-the-database). If the error mentions ownership or `CREATE`, run `atomic storage migrate` as the owner role. |
540
- | `This database was upgraded since this process started` | `atomic storage migrate` moved the tables from `public` to `atomic` while this process ran. Restart the process. |
541
- | A refused password or token, with PostgreSQL code `28P01`, or `28000` on Azure | The token expired, names the wrong user, or has the wrong format. On Azure, use `--auth azure`, or get a token for `https://ossrdbms-aad.database.windows.net` with `az account get-access-token --resource-type oss-rdbms`. |
542
- | `StorageUnavailableError` on open | The server refused the login (`28P01` or `28000`), the database does not exist (`3D000`), or the server is too old. Use PostgreSQL 16 or newer. |
543
- | `self-signed certificate in certificate chain` or `unable to get local issuer certificate` | Set `sslrootcert` to your server's certificate authority. See [TLS](#tls). |
544
- | `INVALID_PURPOSE` | The certificate in `sslrootcert` is not a certificate authority (`basicConstraints=CA:TRUE`), or may only be used for clients. Point `sslrootcert` at the authority that signed the server's certificate. |
545
- | `PATH_LENGTH_EXCEEDED` | The certificate chain is longer than the root certificate allows. Reissue the root without that limit, or sign the server certificate with the root directly. |
546
- | `UNSPECIFIED` with a reason, such as `key usage does not include certificate signing` | Node.js reports some certificate problems this way. Follow the reason, for example reissue the certificate authority with `keyCertSign`. |
547
- | The proxy's own certificate is refused | An `https://` proxy's certificate is checked against Node.js's certificate authorities, never `sslrootcert`. Add your proxy's authority to [`NODE_EXTRA_CA_CERTS`](/environment-variables#tls-certificates). |
548
- | The proxy refused the tunnel, or cannot be reached | Allow the database's `host:port` on the proxy, give proxy credentials for a `407`, check `HTTPS_PROXY`, or skip the proxy with `NO_PROXY` or `proxy: "none"`. See [Through an HTTP proxy](#through-an-http-proxy). |
549
- | `unsupported-proxy` | Use an `http://` or `https://` proxy. Atomic does not support `socks5://`. |
550
- | `StorageTransientError` with code `read-only-server`, PostgreSQL code `25006` | `url` points at a read-only replica, or the server is failing over or out of disk. Point `url` at the read/write endpoint, or retry once the server recovers. |
551
- | `sorry, too many clients already`, `remaining connection slots are reserved for roles with the SUPERUSER attribute`, or `too many connections for role "<role>"`, PostgreSQL code `53300` | The server, or the role's `CONNECTION LIMIT`, has no connection left. Atomic reports `StorageTransientError` with code `connection-refused`. Lower `maxConnections` or `readerMaxConnections`, raise `max_connections`, or put [PgBouncer](/storage/postgres/pgbouncer) in front. See [Tuning for many concurrent agents](#tuning-for-many-concurrent-agents). |
552
- | `timeout exceeded when trying to connect` | Every connection in the process's pool stayed busy, or a new connection took longer than `connectTimeoutMs`. Atomic reports `StorageTransientError` with code `connection-refused`. Raise `maxConnections` if the server has connections to spare, or raise `connectTimeoutMs` for a distant or slow server. |
553
- | `prepared statement "atomic_…" does not exist` or `already exists`, behind a pooler | The pooler does not keep prepared statements. Atomic stops preparing statements for the rest of the process and retries, so you usually see only a one-time warning. Set `maxPreparedStatements` to `0`, or on PgBouncer 1.21 or later set `max_prepared_statements` above `0`. |
554
- | `StorageTransientError` with code `lock-conflict` or `transaction-timeout` | The server cancelled a statement that waited too long or ran past `statementTimeoutMs`. Nothing was written. If it keeps happening, the server is overloaded. |
555
- | `wake-ups: polling only` in `atomic storage status` | Messages still arrive, by polling. See [Wake-ups](#wake-ups). |
556
- | `StorageTransientError` with code `connection-lost` after a failover or pooler restart | The server or pooler closed the connection. Retry. |
518
+ | `credential-in-url` | Strip the password from `url` and pass `--password-file` or `--token-file`. |
519
+ | `libsql-removed` | Legacy libSQL URL or removed `atomic team join` command; use `postgres://` with `atomic storage join`, or see [Moving off libSQL](/storage#moving-off-libsql). |
520
+ | `unsupported-auth` | Use `azure`, `aws`, or `gcp` (or `azure-entra`, `aws-iam`, `gcp-iam`). |
521
+ | `adapter-not-installed` | Run `atomic install npm:@bastani/atomic-storage-postgres` as the Atomic user. |
522
+ | `auth-unavailable` | Install the cloud SDK library named in the error and confirm the host has a valid cloud identity (not retried). |
523
+ | `missing-privilege` (PG `42501` or `3F000`) | Run the named `GRANT` (see [Set up the database](#set-up-the-database)) or run `atomic storage migrate` as the owner role. |
524
+ | `This database was upgraded since this process started` | `atomic storage migrate` moved tables from `public` to `atomic` while this process was open; restart the process. |
525
+ | Password/token refused (PG `28P01`, or `28000` on Azure) | Check username, token expiry, or token format. On Azure, use `--auth azure` or request a token for `https://ossrdbms-aad.database.windows.net` (`az account get-access-token --resource-type oss-rdbms`). |
526
+ | `StorageUnavailableError` on open | Invalid credentials (`28P01`/`28000`), missing database (`3D000`), or server older than PostgreSQL 16. |
527
+ | `self-signed certificate in certificate chain` / `unable to get local issuer certificate` | Add `?sslrootcert=/path/to/root.crt` (see [TLS](#tls)). |
528
+ | `INVALID_PURPOSE` | Certificate in `sslrootcert` is not a CA (`basicConstraints=CA:TRUE`) or is client-only; supply the signing CA certificate. |
529
+ | `PATH_LENGTH_EXCEEDED` | Certificate chain exceeds the root CA's path length constraint; reissue or sign directly with the root CA. |
530
+ | `UNSPECIFIED` (for example `key usage does not include certificate signing`) | Follow the reported TLS reason (such as reissuing the CA with `keyCertSign`). |
531
+ | `https://` proxy certificate rejected | Proxy TLS uses Node.js's CA store, never `sslrootcert`; add the proxy CA to [`NODE_EXTRA_CA_CERTS`](/environment-variables#tls-certificates). |
532
+ | Proxy refused tunnel or unreachable | Allow `<db-host>:<port>` on the proxy, supply credentials for `407`, verify `HTTPS_PROXY`, or bypass with `NO_PROXY` / `proxy: "none"`. |
533
+ | `unsupported-proxy` | Use an `http://` or `https://` proxy (`socks5://` is unsupported). |
534
+ | `StorageTransientError` (`read-only-server`, PG `25006`) | `url` hits a read replica, or the server is failing over / out of disk. Use the read/write endpoint or retry after failover. |
535
+ | `sorry, too many clients already` / `too many connections for role` (PG `53300`) | Server or role hit its connection cap (`connection-refused`). Lower `maxConnections`/`readerMaxConnections`, raise server limits, or deploy [PgBouncer](/storage/postgres/pgbouncer). |
536
+ | `timeout exceeded when trying to connect` | Local pool saturated or connection handshake exceeded `connectTimeoutMs` (`connection-refused`). Raise `maxConnections` or `connectTimeoutMs`. |
537
+ | `prepared statement "atomic_…" does not exist` / `already exists` behind a pooler | Pooler does not retain prepared statements. Atomic disables them automatically for the rest of the process and retries; set `maxPreparedStatements: 0`, or enable `max_prepared_statements > 0` on PgBouncer 1.21+. |
538
+ | `StorageTransientError` (`lock-conflict` / `transaction-timeout`) | Statement waited too long or exceeded `statementTimeoutMs`; nothing was written. Investigate server load if frequent. |
539
+ | `wake-ups: polling only` in `atomic storage status` | Messages still arrive via polling; see [Wake-ups](#wake-ups). |
540
+ | `StorageTransientError` (`connection-lost`) | Server or pooler closed the socket (failover, restart, or idle firewall drop); retry, or lower `keepAliveIdleMs`. |