@bastani/atomic 0.10.11-alpha.1 → 0.10.11-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/README.md +5 -8
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +9 -9
  7. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +8 -8
  8. package/dist/_shared/mode-shared-2QJSCUM6.js +9 -9
  9. package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
  10. package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
  12. package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
  13. package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +14 -2
  14. package/dist/_shared/{p1b-elig-ENCUPKKJ.js.map → p1b-elig-TVB5CBLL.js.map} +1 -1
  15. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  16. package/dist/_shared/{sdk-AVFII7NK.js → sdk-B5LEWGGI.js} +2633 -488
  17. package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
  18. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  19. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  20. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
  21. package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
  22. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
  23. package/dist/_shared/{startup-0-0-57KF6LZH.js → startup-0-0-EZUKEP4Q.js} +436 -51
  24. package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
  25. package/dist/_shared/{startup-0-1-GIY75K46.js → startup-0-1-RTOHJFDJ.js} +240 -279
  26. package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
  27. package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +254 -46
  28. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
  29. package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
  30. package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
  31. package/dist/_shared/startup-0-4-ZMJV547D.js +14 -9
  32. package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
  33. package/dist/_shared/startup-0-5-YDW47QX6.js +10 -10
  34. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
  35. package/dist/_shared/startup-10-0-TDQNBDDL.js +9 -9
  36. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  37. package/dist/_shared/startup-14-0-MLX36RBG.js +6 -7
  38. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  39. package/dist/_shared/startup-15-0-YUKGAC63.js +7 -7
  40. package/dist/_shared/startup-15-1-4S7FLMNG.js +22 -30
  41. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  42. package/dist/_shared/startup-8-0-34CBHPZH.js +455 -102
  43. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  44. package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +162 -1184
  45. package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
  46. package/dist/_shared/storage-command-7MGXLJGZ.js +189 -36
  47. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  48. package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
  49. package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
  50. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  51. package/dist/_shared/team-DOQKICG2.js +376 -0
  52. package/dist/_shared/team-DOQKICG2.js.map +1 -0
  53. package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
  54. package/dist/builtin/intercom/CHANGELOG.md +34 -0
  55. package/dist/builtin/intercom/README.md +2 -2
  56. package/dist/builtin/intercom/broker/broker.bundle.mjs +1091 -344
  57. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
  58. package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
  59. package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
  60. package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
  61. package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
  62. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
  63. package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
  64. package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
  65. package/dist/builtin/intercom/broker/sql-lease-store.ts +208 -101
  66. package/dist/builtin/intercom/broker/sql-outbox-store.ts +516 -102
  67. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
  68. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
  69. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
  70. package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
  71. package/dist/builtin/intercom/broker/sql-schema.ts +199 -27
  72. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
  73. package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
  74. package/dist/builtin/intercom/index.bundle.mjs +2 -3
  75. package/dist/builtin/intercom/package.json +1 -1
  76. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  77. package/dist/builtin/mcp/package.json +1 -1
  78. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  79. package/dist/builtin/subagents/package.json +1 -1
  80. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  81. package/dist/builtin/web-access/index.bundle.mjs +2 -10
  82. package/dist/builtin/web-access/package.json +1 -1
  83. package/dist/bun/bundled-sqlite.js +41 -0
  84. package/dist/bun/bundled-sqlite.js.map +1 -0
  85. package/dist/cli/args.js +2 -2
  86. package/dist/cli/auth-cli.code.js +6 -6
  87. package/dist/cli/auth-cli.impl.js +3 -3
  88. package/dist/cli/auth-cli.js +3 -3
  89. package/dist/cli/blueprint-command.code.js +4 -4
  90. package/dist/cli/blueprint-command.impl.js +3 -3
  91. package/dist/cli/blueprint-command.js +3 -3
  92. package/dist/cli/intercom-command.code.js +4 -4
  93. package/dist/cli/intercom-command.code.js.map +1 -1
  94. package/dist/cli/intercom-command.impl.js +3 -3
  95. package/dist/cli/intercom-command.js +3 -3
  96. package/dist/cli/list-models.code.js +2 -2
  97. package/dist/cli/list-models.impl.js +3 -3
  98. package/dist/cli/list-models.js +3 -3
  99. package/dist/cli/session-picker.code.js +2 -2
  100. package/dist/cli/session-picker.impl.js +3 -3
  101. package/dist/cli/session-picker.js +3 -3
  102. package/dist/cli/startup-ui.code.js +2 -2
  103. package/dist/cli/startup-ui.impl.js +3 -3
  104. package/dist/cli/startup-ui.js +3 -3
  105. package/dist/cli/storage-command.impl.js +3 -3
  106. package/dist/cli/storage-command.js +3 -3
  107. package/dist/cli/storage-search-session.code.js +3 -3
  108. package/dist/cli/storage-search-session.impl.js +3 -3
  109. package/dist/cli/storage-search-session.js +3 -3
  110. package/dist/cli/team-command.code.js +20 -114
  111. package/dist/cli/team-command.code.js.map +1 -1
  112. package/dist/cli/team-command.impl.js +3 -3
  113. package/dist/cli/team-command.js +3 -3
  114. package/dist/cli.js +5 -18
  115. package/dist/cli.js.map +1 -1
  116. package/dist/core/agent-rehydrate-errors.d.ts +4 -9
  117. package/dist/core/compaction/compactor.d.ts +3 -3
  118. package/dist/core/debug.code.js +1 -1
  119. package/dist/core/debug.impl.js +3 -3
  120. package/dist/core/debug.js +3 -3
  121. package/dist/core/export-html/card-projection.impl.js +3 -3
  122. package/dist/core/export-html/card-projection.js +3 -3
  123. package/dist/core/export-html/index.code.js +2 -2
  124. package/dist/core/export-html/index.impl.js +3 -3
  125. package/dist/core/export-html/index.js +3 -3
  126. package/dist/core/export-html/json-spans.impl.js +3 -3
  127. package/dist/core/export-html/json-spans.js +3 -3
  128. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  129. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  130. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  131. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  132. package/dist/core/export-html/tool-renderer.js +3 -3
  133. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  134. package/dist/core/extensions/jiti-loader.js +3 -3
  135. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  136. package/dist/core/extensions/jiti-static-loader.js +3 -3
  137. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  138. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  139. package/dist/core/extensions/loader-host-modules.js +3 -3
  140. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  141. package/dist/core/extensions/runner-context.js +3 -3
  142. package/dist/core/intercom-broker-control-host.code.js +2 -2
  143. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  144. package/dist/core/intercom-broker-control-host.js +3 -3
  145. package/dist/core/intercom-broker-control.code.js +3 -3
  146. package/dist/core/intercom-broker-control.impl.js +3 -3
  147. package/dist/core/intercom-broker-control.js +3 -3
  148. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  149. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  150. package/dist/core/package-manager-storage-adapters.js +3 -3
  151. package/dist/core/process-start-token.d.ts +8 -0
  152. package/dist/core/process-tree-containment.d.ts +16 -0
  153. package/dist/core/sdk-types.d.ts +1 -2
  154. package/dist/core/sdk-types.js.map +1 -1
  155. package/dist/core/sdk.code.js +4 -4
  156. package/dist/core/sdk.impl.js +3 -3
  157. package/dist/core/sdk.js +3 -3
  158. package/dist/core/session-manager-core.js +27 -15
  159. package/dist/core/session-manager-core.js.map +1 -1
  160. package/dist/core/session-manager-list.impl.js +3 -3
  161. package/dist/core/session-manager-list.js +3 -3
  162. package/dist/core/session-manager.code.js +3 -3
  163. package/dist/core/session-manager.impl.js +3 -3
  164. package/dist/core/session-manager.js +3 -3
  165. package/dist/core/session-open-markers.js +3 -0
  166. package/dist/core/session-open-markers.js.map +1 -0
  167. package/dist/core/session-storage.code.js +1 -1
  168. package/dist/core/session-storage.impl.js +3 -3
  169. package/dist/core/session-storage.js +3 -3
  170. package/dist/core/settings-schema.d.ts +0 -3
  171. package/dist/core/storage/added-exports-0-10-11.js +19 -0
  172. package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
  173. package/dist/core/storage/added-exports.js +3 -0
  174. package/dist/core/storage/added-exports.js.map +1 -1
  175. package/dist/core/storage/creation-time.js +105 -0
  176. package/dist/core/storage/creation-time.js.map +1 -0
  177. package/dist/core/storage/database.d.ts +56 -5
  178. package/dist/core/storage/database.js.map +1 -1
  179. package/dist/core/storage/dialect.d.ts +1 -1
  180. package/dist/core/storage/dialect.js +1 -1
  181. package/dist/core/storage/dialect.js.map +1 -1
  182. package/dist/core/storage/errors.d.ts +13 -13
  183. package/dist/core/storage/errors.js +10 -16
  184. package/dist/core/storage/errors.js.map +1 -1
  185. package/dist/core/storage/fenced-paths.d.ts +11 -0
  186. package/dist/core/storage/fenced-paths.js +11 -0
  187. package/dist/core/storage/fenced-paths.js.map +1 -1
  188. package/dist/core/storage/file-identity.d.ts +2 -0
  189. package/dist/core/storage/file-identity.js +24 -8
  190. package/dist/core/storage/file-identity.js.map +1 -1
  191. package/dist/core/storage/index.d.ts +4 -3
  192. package/dist/core/storage/index.js +5 -3
  193. package/dist/core/storage/index.js.map +1 -1
  194. package/dist/core/storage/libsql-removed.d.ts +71 -0
  195. package/dist/core/storage/libsql-removed.js +123 -0
  196. package/dist/core/storage/libsql-removed.js.map +1 -0
  197. package/dist/core/storage/migrations.d.ts +81 -8
  198. package/dist/core/storage/migrations.js +386 -47
  199. package/dist/core/storage/migrations.js.map +1 -1
  200. package/dist/core/storage/node-sqlite-file-gate.js +0 -15
  201. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
  202. package/dist/core/storage/node-sqlite-thread.js +36 -12
  203. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  204. package/dist/core/storage/node-sqlite.js +135 -3
  205. package/dist/core/storage/node-sqlite.js.map +1 -1
  206. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  207. package/dist/core/storage/offline-snapshot-file.js +3 -3
  208. package/dist/core/storage/prefix.d.ts +1 -1
  209. package/dist/core/storage/prefix.js +14 -2
  210. package/dist/core/storage/prefix.js.map +1 -1
  211. package/dist/core/storage/process-selection.d.ts +5 -5
  212. package/dist/core/storage/provider.js +2 -2
  213. package/dist/core/storage/schema-catalog.d.ts +82 -5
  214. package/dist/core/storage/schema-catalog.js +244 -34
  215. package/dist/core/storage/schema-catalog.js.map +1 -1
  216. package/dist/core/storage/selection.d.ts +7 -82
  217. package/dist/core/storage/selection.js +20 -235
  218. package/dist/core/storage/selection.js.map +1 -1
  219. package/dist/core/storage/session/branch-fork-source.code.js +9 -8
  220. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  221. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  222. package/dist/core/storage/session/branch-fork-source.js +3 -3
  223. package/dist/core/storage/session/card-view.impl.js +3 -3
  224. package/dist/core/storage/session/card-view.js +3 -3
  225. package/dist/core/storage/session/child-reader.code.js +4 -4
  226. package/dist/core/storage/session/child-reader.impl.js +3 -3
  227. package/dist/core/storage/session/child-reader.js +3 -3
  228. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  229. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  230. package/dist/core/storage/session/errors.js +1 -1
  231. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  232. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  233. package/dist/core/storage/session/expanded-child-details.js +3 -3
  234. package/dist/core/storage/session/fork-detach.d.ts +118 -0
  235. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  236. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  237. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  238. package/dist/core/storage/session/fork-row-index.js +3 -3
  239. package/dist/core/storage/session/fork-schema.js +53 -0
  240. package/dist/core/storage/session/fork-schema.js.map +1 -0
  241. package/dist/core/storage/session/fork-segments.d.ts +58 -0
  242. package/dist/core/storage/session/fork-staging.code.js +5 -8
  243. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  244. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  245. package/dist/core/storage/session/fork-staging.js +3 -3
  246. package/dist/core/storage/session/fork-sweep.js +61 -0
  247. package/dist/core/storage/session/fork-sweep.js.map +1 -0
  248. package/dist/core/storage/session/fork-window.code.js +4 -4
  249. package/dist/core/storage/session/fork-window.impl.js +3 -3
  250. package/dist/core/storage/session/fork-window.js +3 -3
  251. package/dist/core/storage/session/history-pages.impl.js +3 -3
  252. package/dist/core/storage/session/history-pages.js +3 -3
  253. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  254. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  255. package/dist/core/storage/session/jsonl-session-store.d.ts +42 -2
  256. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  257. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  258. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  259. package/dist/core/storage/session/memory-session-store.js +3 -3
  260. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  261. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  262. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  263. package/dist/core/storage/session/released-history-files.code.js +4 -4
  264. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  265. package/dist/core/storage/session/released-history-files.js +3 -3
  266. package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
  267. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  268. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  269. package/dist/core/storage/session/session-resume.impl.js +3 -3
  270. package/dist/core/storage/session/session-resume.js +3 -3
  271. package/dist/core/storage/session/session-search-index.d.ts +43 -4
  272. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  273. package/dist/core/storage/session/snapshot-cut.js +3 -3
  274. package/dist/core/storage/session/snapshot-history.code.js +4 -4
  275. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  276. package/dist/core/storage/session/snapshot-history.js +3 -3
  277. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  278. package/dist/core/storage/session/sql-session-store.d.ts +394 -20
  279. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  280. package/dist/core/storage/session/sql-session-store.js +4 -4
  281. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  282. package/dist/core/storage/session/tree-outline.js +3 -3
  283. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  284. package/dist/core/storage/session/tree-presentation.js +3 -3
  285. package/dist/core/storage/session/types.d.ts +22 -0
  286. package/dist/core/storage/sqlite-facade.d.ts +23 -2
  287. package/dist/core/storage/sqlite-facade.js +34 -0
  288. package/dist/core/storage/sqlite-facade.js.map +1 -1
  289. package/dist/core/storage/storage-status.code.js +1 -1
  290. package/dist/core/storage/storage-status.impl.js +3 -3
  291. package/dist/core/storage/storage-status.js +3 -3
  292. package/dist/core/storage/team.code.js +1 -1
  293. package/dist/core/storage/team.d.ts +26 -115
  294. package/dist/core/storage/team.impl.js +3 -3
  295. package/dist/core/storage/team.js +3 -3
  296. package/dist/core/structured-output/index.code.js +1 -1
  297. package/dist/core/structured-output/index.impl.js +3 -3
  298. package/dist/core/structured-output/index.js +3 -3
  299. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  300. package/dist/core/tasks/task-completion-entry.js +3 -3
  301. package/dist/core/tasks/task-file-history.code.js +4 -4
  302. package/dist/core/tasks/task-file-history.impl.js +3 -3
  303. package/dist/core/tasks/task-file-history.js +3 -3
  304. package/dist/core/tasks/task-reference-archive.code.js +5 -5
  305. package/dist/core/tasks/task-reference-archive.js +3 -3
  306. package/dist/core/tasks/task-reference-identity.js +3 -3
  307. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  308. package/dist/core/tasks/task-reference-stream.js +3 -3
  309. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  310. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  311. package/dist/core/tasks/task-view-source.code.js +1 -1
  312. package/dist/core/tasks/task-view-source.impl.js +3 -3
  313. package/dist/core/tasks/task-view-source.js +3 -3
  314. package/dist/core/tools/history-session.d.ts +2 -0
  315. package/dist/core/tools/history-tasks.d.ts +3 -2
  316. package/dist/core/tools/read-url.code.js +4 -4
  317. package/dist/core/tools/read-url.impl.js +3 -3
  318. package/dist/core/tools/read-url.js +3 -3
  319. package/dist/core/worktree-snapshot/blob-store.d.ts +71 -3
  320. package/dist/core/worktree-snapshot/blob-store.js +575 -67
  321. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  322. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  323. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  324. package/dist/core/worktree-snapshot/errors.js +3 -3
  325. package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
  326. package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
  327. package/dist/core/worktree-snapshot/fork-snapshot-index.js +162 -0
  328. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
  329. package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
  330. package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
  331. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  332. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  333. package/dist/extensions/codemode/execute.code.js +2 -2
  334. package/dist/extensions/codemode/execute.impl.js +3 -3
  335. package/dist/extensions/codemode/execute.js +3 -3
  336. package/dist/extensions/codemode/renderer.code.js +2 -2
  337. package/dist/extensions/codemode/renderer.impl.js +3 -3
  338. package/dist/extensions/codemode/renderer.js +3 -3
  339. package/dist/extensions/mcp/cli.code.js +3 -3
  340. package/dist/extensions/mcp/cli.impl.js +3 -3
  341. package/dist/extensions/mcp/cli.js +3 -3
  342. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  343. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  344. package/dist/extensions/mcp/cli.lazy.js +3 -3
  345. package/dist/extensions/mcp/runtime.code.js +1 -1
  346. package/dist/extensions/mcp/runtime.impl.js +3 -3
  347. package/dist/extensions/mcp/runtime.js +3 -3
  348. package/dist/index.d.ts +3 -1
  349. package/dist/index.js +8 -8
  350. package/dist/main-first-time-setup.code.js +2 -2
  351. package/dist/main-first-time-setup.impl.js +3 -3
  352. package/dist/main-first-time-setup.js +3 -3
  353. package/dist/main.js +1 -1
  354. package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
  355. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  356. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  357. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  358. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  359. package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
  360. package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
  361. package/dist/modes/print-mode.js +1 -1
  362. package/dist/package-manager-cli.code.js +7 -7
  363. package/dist/package-manager-cli.impl.js +3 -3
  364. package/dist/package-manager-cli.js +3 -3
  365. package/dist/rpc-entry.js +1 -1
  366. package/dist/startup-files.json +1 -1
  367. package/dist/startup-stages/10.js +1 -1
  368. package/dist/startup-stages/11.js +1 -1
  369. package/dist/startup-stages/12.js +1 -1
  370. package/dist/startup-stages/2.js +2 -3
  371. package/dist/startup-stages/3.js +1 -3
  372. package/dist/startup-stages/4.js +1 -2
  373. package/dist/startup-stages/5.js +1 -1
  374. package/dist/startup-stages/6.js +5 -7
  375. package/dist/startup-stages/7.js +3 -6
  376. package/dist/startup-stages/8.js +7 -2
  377. package/dist/startup-stages/9.js +1 -7
  378. package/dist/startup-stages/stages.json +1 -1
  379. package/dist/utils/compile-cache-deferral.js +8 -13
  380. package/dist/utils/compile-cache-deferral.js.map +1 -1
  381. package/dist/utils/compile-cache-warmup-host.js +3 -4
  382. package/dist/utils/compile-cache-warmup-host.js.map +1 -1
  383. package/dist/utils/compile-cache.js +12 -100
  384. package/dist/utils/compile-cache.js.map +1 -1
  385. package/dist/utils/startup-database-spare.code.js +3 -3
  386. package/dist/utils/startup-database-spare.impl.js +3 -3
  387. package/dist/utils/startup-database-spare.js +3 -3
  388. package/dist/utils/tools-manager.code.js +1 -1
  389. package/dist/utils/tools-manager.impl.js +3 -3
  390. package/dist/utils/tools-manager.js +3 -3
  391. package/dist/utils/worker-threads.js +2 -15
  392. package/dist/utils/worker-threads.js.map +1 -1
  393. package/docs/build.md +3 -3
  394. package/docs/changelog.mdx +1421 -69
  395. package/docs/compaction/reference.md +5 -5
  396. package/docs/compaction.md +7 -9
  397. package/docs/containerization.md +2 -2
  398. package/docs/custom-provider/api-reference.md +1 -1
  399. package/docs/docs.json +37 -10
  400. package/docs/environment-variables.md +0 -2
  401. package/docs/extensions/api-reference.md +4 -4
  402. package/docs/getting-started/installation.md +3 -0
  403. package/docs/guides/configuration.md +1 -1
  404. package/docs/guides/non-interactive.md +1 -1
  405. package/docs/guides/resume-on-any-machine.md +14 -22
  406. package/docs/guides/team-setup.md +56 -83
  407. package/docs/guides.md +2 -4
  408. package/docs/herdr.md +1 -1
  409. package/docs/index.md +1 -1
  410. package/docs/intercom/operations.md +26 -21
  411. package/docs/intercom/reference.md +2 -2
  412. package/docs/intercom.md +1 -1
  413. package/docs/libraries/storage-postgres.md +9 -9
  414. package/docs/libraries.md +2 -3
  415. package/docs/models-configuration.md +2 -2
  416. package/docs/models.md +2 -3
  417. package/docs/packages/authoring.md +7 -7
  418. package/docs/packages.md +1 -1
  419. package/docs/programmatic.md +2 -2
  420. package/docs/quickstart.md +1 -1
  421. package/docs/reference/cli.md +6 -11
  422. package/docs/reference.md +2 -2
  423. package/docs/rpc/extension-ui.md +2 -2
  424. package/docs/sdk/reference.md +5 -4
  425. package/docs/sdk/storage.md +8 -92
  426. package/docs/sdk/structured-decisions.md +1 -1
  427. package/docs/sdk/web-server.md +3 -3
  428. package/docs/sdk.md +14 -4
  429. package/docs/security.md +1 -1
  430. package/docs/session-format.md +5 -5
  431. package/docs/sessions.md +31 -42
  432. package/docs/settings.md +7 -8
  433. package/docs/storage/custom-adapters.md +255 -0
  434. package/docs/storage/jsonl.md +117 -0
  435. package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +73 -68
  436. package/docs/storage/postgres/tuning.md +337 -0
  437. package/docs/storage/postgres.md +556 -0
  438. package/docs/storage/sqlite.md +99 -0
  439. package/docs/storage.md +333 -956
  440. package/docs/subagents/authoring.md +1 -1
  441. package/docs/subagents.md +2 -2
  442. package/docs/tools.md +1 -1
  443. package/docs/worktree-snapshots.md +2 -2
  444. package/package.json +9 -9
  445. package/schemas/models.schema.json +2 -2
  446. package/schemas/settings.schema.json +0 -14
  447. package/dist/_shared/sdk-AVFII7NK.js.map +0 -1
  448. package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
  449. package/dist/_shared/startup-0-0-57KF6LZH.js.map +0 -1
  450. package/dist/_shared/startup-0-1-GIY75K46.js.map +0 -1
  451. package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
  452. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
  453. package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
  454. package/dist/core/intercom-broker-control.d.ts +0 -129
  455. package/dist/startup-stages/13.js +0 -1
  456. package/docs/guides/postgres-tuning.md +0 -311
  457. package/docs/libraries/storage-libsql.md +0 -97
@@ -1,33 +1,33 @@
1
1
  ---
2
2
  title: "Run many agents on PostgreSQL with PgBouncer"
3
- sidebarTitle: "PostgreSQL with PgBouncer"
3
+ sidebarTitle: "PgBouncer"
4
4
  description: "Put PgBouncer between Atomic and PostgreSQL when your agents need more connections than the server allows, with a complete configuration, checks, and fixes for common errors."
5
5
  ---
6
6
 
7
7
  PgBouncer is a small server that sits between Atomic and PostgreSQL. Thousands of connections from Atomic go to PgBouncer, and PgBouncer runs their work over a few dozen connections to PostgreSQL. Use it when your agents need more connections than PostgreSQL allows.
8
8
 
9
- This guide assumes you already set up the database and roles as in [PostgreSQL storage](/storage#postgresql). It uses these names, which you replace with your own:
9
+ This guide assumes you already set up the database and roles as in [PostgreSQL setup](/storage/postgres). It uses these names, which you replace with your own:
10
10
 
11
11
  | Name | Meaning |
12
12
  | --- | --- |
13
- | `db.internal` | The PostgreSQL server's host name |
14
- | `pgbouncer.internal` | The PgBouncer server's host name |
13
+ | `db.example.com` | The PostgreSQL server's host name |
14
+ | `pgbouncer.example.com` | The PgBouncer server's host name |
15
15
  | `atomic` | The database Atomic uses |
16
- | `atomic_runtime` | The role Atomic logs in as |
16
+ | `atomic_runtime` | The runtime role, which every Atomic machine logs in as |
17
17
  | `pgbouncer_auth` | A role PgBouncer uses only to look up passwords |
18
18
 
19
19
  ## When you need PgBouncer
20
20
 
21
- Every connection an Atomic process opens counts against PostgreSQL's `max_connections`. [Count the connections Atomic needs](/storage#count-the-connections-atomic-needs) with this rule:
21
+ Every connection an Atomic process opens counts against PostgreSQL's `max_connections`. [Count the connections Atomic needs](/storage/postgres#count-the-connections-atomic-needs) with this rule:
22
22
 
23
23
  - An agent process uses up to `maxConnections` plus `readerMaxConnections`.
24
24
  - An Intercom broker uses the same, plus 1 for wake-ups.
25
25
 
26
- Add these up over every machine. If the total is more than the server has to share, even with `maxConnections` at 2, you need PgBouncer.
26
+ Add these up over every machine. If the server cannot give every process at least 2 connections for `maxConnections`, you need PgBouncer.
27
27
 
28
- For example, 200 CI runners each run one agent process and one Intercom broker. That is 400 processes, of which 200 are brokers. The server has `max_connections = 300`, 3 slots reserved for administrators, and 10 connections used by other clients, so 287 are left for Atomic. With the smallest settings, `maxConnections: 1` and `readerMaxConnections: 0`, the processes need 400 × 1 + 200 = 600 connections. That is twice what the server has.
28
+ For example, 150 CI runners each run one agent process and one Intercom broker. That is 300 processes, of which 150 are brokers. The server has `max_connections = 300`, 3 slots reserved for administrators, and 10 connections used by other clients, so 287 are left for Atomic. With the smallest settings, `maxConnections: 1` and `readerMaxConnections: 0`, the processes need 300 × 1 + 150 = 450 connections. That is more than the server has.
29
29
 
30
- With PgBouncer, those 400 processes connect to PgBouncer instead. PgBouncer shares 80 connections to PostgreSQL between them, and the 200 brokers keep one direct connection each for wake-ups. That fits in 287.
30
+ With PgBouncer, those 300 processes connect to PgBouncer instead. The 150 brokers keep one direct connection each for wake-ups, which leaves 287 − 150 = 137 for PgBouncer. The configuration below shares 85 connections to PostgreSQL between all 300 processes: a pool of 80 plus 5 in reserve. With the brokers' connections, that is 235, which fits in 287.
31
31
 
32
32
  ## How Atomic works with PgBouncer
33
33
 
@@ -43,10 +43,15 @@ So nothing Atomic does depends on keeping the same connection to PostgreSQL betw
43
43
 
44
44
  If you leave out `listenUrl`, Atomic notices that it is behind a pooler and stops waiting for wake-ups. Brokers then check the database for new messages every half second instead of every 5 seconds. Messages still arrive, a little later, and the database gets more queries.
45
45
 
46
- **Prepared statements.** A prepared statement is a query that PostgreSQL parses and plans once, then runs many times. Atomic can keep its frequent queries prepared, which saves the server work, but only if the pooler keeps track of them. The Atomic setting `maxPreparedStatements` controls this:
46
+ **Prepared statements.** A prepared statement is a query that PostgreSQL parses and plans once, then runs many times. Atomic can keep its frequent queries prepared, which saves the server work, but only if the pooler keeps track of them. PgBouncer 1.21 and later does, when its `max_prepared_statements` setting is above `0`. PgBouncer 1.24 and later set it to 200 by default.
47
47
 
48
- - By default, Atomic turns prepared statements off when `listenUrl` is set or the URL's port is 6432 or 6543. Most setups need nothing more.
49
- - To use them through PgBouncer, you need PgBouncer 1.21 or later with `max_prepared_statements` above `0`. PgBouncer 1.24 and later set it to 200 by default. Then set `maxPreparedStatements` in Atomic to `256`.
48
+ Atomic checks on its first connection whether it is talking to such a PgBouncer, and turns prepared statements on only if it is. You do not need to set anything:
49
+
50
+ - **PgBouncer 1.21 or later with `max_prepared_statements` above `0`:** on.
51
+ - **Anything else:** off. That includes PgBouncer before 1.21, PgBouncer with `max_prepared_statements = 0`, Supabase's Supavisor, and any pooler Atomic cannot identify. Off is the safe choice, because a pooler that loses prepared statements makes queries fail.
52
+ - **A pooler on a port other than 6432 or 6543:** Atomic may not notice it. Set `listenUrl`, which a pooler needs for wake-ups anyway, or `maxPreparedStatements: 0`.
53
+
54
+ Atomic's `maxPreparedStatements` setting overrides this. Set it to `0` to keep prepared statements off, or to `256` to turn them on without the check. If you change PgBouncer's `max_prepared_statements` to `0` while Atomic runs, the next query that needs a lost statement fails once and runs again, and Atomic stops preparing statements until it restarts.
50
55
 
51
56
  ```text
52
57
  agent processes ──> PgBouncer :6432 ──> PostgreSQL :5432
@@ -66,17 +71,17 @@ PostgreSQL needs room for:
66
71
 
67
72
  Set `max_connections` to at least their sum. Changing it needs a restart of PostgreSQL. On a managed service, change the server parameter in the service's console.
68
73
 
69
- To stop Atomic's direct wake-up connections from taking slots that PgBouncer needs, you can cap the runtime role. Set the cap to the number of brokers plus a margin:
74
+ To stop Atomic's runtime role from taking every slot, you can cap it. The cap counts every connection the role opens, including PgBouncer's connections for that role. Set it to PgBouncer's pool plus one wake-up connection per broker, plus a margin. In the example in [When you need PgBouncer](#when-you-need-pgbouncer), that is 85 + 150 = 235, plus a margin:
70
75
 
71
76
  ```sql
72
- ALTER ROLE atomic_runtime CONNECTION LIMIT 220;
77
+ ALTER ROLE atomic_runtime CONNECTION LIMIT 250;
73
78
  ```
74
79
 
75
- The cap counts every connection the role opens, including PgBouncer's connections for that role. Raise it if PgBouncer logs `too many connections for role "atomic_runtime"`.
80
+ Raise the cap if PgBouncer logs `too many connections for role "atomic_runtime"`.
76
81
 
77
82
  ### A role for password lookups
78
83
 
79
- PgBouncer checks each client's password against the one PostgreSQL stores, so you do not keep a second copy of every password. It runs a lookup query as a role that can do nothing else. As a superuser, connected to the `atomic` database, run:
84
+ PgBouncer checks each client's password against the one PostgreSQL stores, so you do not keep a second copy of every password. It runs a lookup query as a role that can do nothing else. Creating that lookup needs a superuser. On a managed service without one, use the service's own pooler instead, or list each role's password in PgBouncer's `auth_file`. As a superuser, connected to the `atomic` database, run:
80
85
 
81
86
  ```sql
82
87
  CREATE ROLE pgbouncer_auth LOGIN PASSWORD '<auth role password>';
@@ -96,7 +101,7 @@ REVOKE ALL ON FUNCTION pgbouncer.get_auth(text) FROM PUBLIC;
96
101
  GRANT EXECUTE ON FUNCTION pgbouncer.get_auth(text) TO pgbouncer_auth;
97
102
  ```
98
103
 
99
- The function runs with the rights of the superuser who created it, so `pgbouncer_auth` can read one password at a time without reading the password table itself. It returns only the roles you list, never a superuser, so no one can log in through PgBouncer as any other role. List every role your Atomic machines log in as. Declare the result with `RETURNS TABLE`, as above: PgBouncer refuses a lookup that returns a row of empty values, and logs `auth_query response contained null user name`.
104
+ The function runs with the rights of the superuser who created it, so `pgbouncer_auth` can read one password at a time without reading the password table itself. It returns only the roles you list, never a superuser, so no one can log in through PgBouncer as any other role. List every role your Atomic machines log in as. Declare the result with `RETURNS TABLE`, as above. PgBouncer refuses a lookup that returns a row of empty values, and logs `auth_query response contained null user name`.
100
105
 
101
106
  When you change a role's password with `ALTER ROLE`, PgBouncer uses the new one at once. You do not need to reload it.
102
107
 
@@ -111,19 +116,20 @@ PostgreSQL's `pg_hba.conf` file decides which hosts may log in. Allow PgBouncer'
111
116
  hostssl atomic atomic_runtime 10.0.1.5/32 scram-sha-256
112
117
  hostssl atomic pgbouncer_auth 10.0.1.5/32 scram-sha-256
113
118
  hostssl atomic atomic_runtime 10.0.2.0/24 scram-sha-256
119
+ hostssl atomic atomic_owner 10.0.3.10/32 scram-sha-256
114
120
  ```
115
121
 
116
- Here `10.0.1.5` is PgBouncer and `10.0.2.0/24` is the network of the agent machines. Reload PostgreSQL after editing the file, for example with `SELECT pg_reload_conf();`.
122
+ Here `10.0.1.5` is PgBouncer, `10.0.2.0/24` is the network of the agent machines, and `10.0.3.10` is the machine you run `atomic storage migrate` on. Run `atomic storage migrate` against PostgreSQL directly, on port 5432, not through PgBouncer. Reload PostgreSQL after editing the file, for example with `SELECT pg_reload_conf();`.
117
123
 
118
124
  ## Configure PgBouncer
119
125
 
120
- This configuration was tested with PgBouncer 1.26.1 in Docker, and a configuration like it with PgBouncer 1.25.1 on Ubuntu in front of PostgreSQL 18. Save it as `/etc/pgbouncer/pgbouncer.ini`:
126
+ This configuration is for PgBouncer 1.21 or later, the first version that keeps prepared statements. Save it as `/etc/pgbouncer/pgbouncer.ini`:
121
127
 
122
128
  ```ini
123
129
  ;; Which databases PgBouncer offers, and where each one really is.
124
130
  ;; Atomic connects to "atomic" on PgBouncer, which forwards to PostgreSQL.
125
131
  [databases]
126
- atomic = host=db.internal port=5432 dbname=atomic
132
+ atomic = host=db.example.com port=5432 dbname=atomic
127
133
 
128
134
  [pgbouncer]
129
135
  listen_addr = 0.0.0.0
@@ -140,12 +146,13 @@ auth_query = SELECT usename, passwd FROM pgbouncer.get_auth($1)
140
146
  ;; Holds only pgbouncer_auth's own password.
141
147
  auth_file = /etc/pgbouncer/userlist.txt
142
148
 
143
- ;; TLS between Atomic and PgBouncer. PgBouncer presents this certificate.
149
+ ;; TLS between Atomic and PgBouncer. PgBouncer presents this certificate, which must name pgbouncer.example.com.
144
150
  client_tls_sslmode = require
145
151
  client_tls_cert_file = /etc/pgbouncer/tls/pgbouncer.crt
146
152
  client_tls_key_file = /etc/pgbouncer/tls/pgbouncer.key
147
153
 
148
154
  ;; TLS between PgBouncer and PostgreSQL. verify-full checks the server's certificate and host name.
155
+ ;; root.crt is the certificate authority that signed PostgreSQL's certificate.
149
156
  server_tls_sslmode = verify-full
150
157
  server_tls_ca_file = /etc/pgbouncer/tls/root.crt
151
158
 
@@ -162,7 +169,7 @@ reserve_pool_timeout = 3
162
169
  max_db_connections = 85
163
170
 
164
171
  ;; Remember up to this many prepared statements per PostgreSQL connection.
165
- ;; Atomic uses them only when its maxPreparedStatements setting is above 0.
172
+ ;; Atomic finds this setting and uses prepared statements when it is above 0.
166
173
  max_prepared_statements = 200
167
174
 
168
175
  ;; Close a PostgreSQL connection unused for 10 minutes, and replace any connection after 1 hour.
@@ -186,12 +193,11 @@ PgBouncer needs this password in readable form, because it logs in to PostgreSQL
186
193
 
187
194
  ### Choose the pool sizes
188
195
 
189
- - **`default_pool_size`**: how many connections to PostgreSQL PgBouncer opens for Atomic's role. Start from what PostgreSQL can spare: `max_connections`, minus the reserved slots, minus one per Intercom broker for wake-ups, minus other clients, minus `reserve_pool_size`. More is not always faster. The [PostgreSQL wiki](https://wiki.postgresql.org/wiki/Number_Of_Database_Connections) suggests about twice the number of CPU cores as a starting point, so about 32 on a 16-core server. Raise it while `cl_waiting` in `SHOW POOLS` stays above `0` and the server's CPU has room.
196
+ - **`default_pool_size`**: how many connections to PostgreSQL PgBouncer opens for Atomic's role. It can be at most what PostgreSQL can spare: `max_connections`, minus the reserved slots, minus one per Intercom broker for wake-ups, minus other clients, minus `reserve_pool_size`. In the example in [When you need PgBouncer](#when-you-need-pgbouncer), that is 137 − 5 = 132. More is not always faster. The [PostgreSQL wiki](https://wiki.postgresql.org/wiki/Number_Of_Database_Connections) suggests about twice the number of CPU cores as a starting point, for example 32 on a 16-core server. The configuration above uses 80, for a server of about 40 cores. Raise it while `cl_waiting` in `SHOW POOLS` stays above `0` and the server's CPU has room. A database far from the agents needs a larger pool than a nearby one, because each transaction holds its connection while it waits for the network.
190
197
  - **`reserve_pool_size`**: a few extra connections for bursts. PgBouncer lends them only after a client has waited `reserve_pool_timeout` seconds.
191
198
  - **`max_db_connections`**: a cap on all of PgBouncer's connections to the database. Set it to `default_pool_size` plus `reserve_pool_size`.
192
199
  - **`max_client_conn`**: how many connections PgBouncer accepts from clients. Connections to PgBouncer are cheap, so set it well above the number of Atomic processes times their pools. Each client connection uses a file descriptor, so raise the PgBouncer server's open-file limit (`ulimit -n`, or `LimitNOFILE` in a systemd unit) above `max_client_conn`.
193
-
194
- - **Lock waits hold connections.** In transaction mode, a transaction that waits for a lock keeps its PostgreSQL connection while it waits. When many agents send Intercom messages at once over a slow link, those waits can fill the pool, and every other client queues behind them. If `cl_waiting` climbs while `sv_active` sits at the cap, raise `default_pool_size` and `max_db_connections`, as far as `max_connections` allows.
200
+ - **Lock waits hold connections.** A transaction that waits for a lock keeps its PostgreSQL connection while it waits, so waits can fill the pool. If `cl_waiting` climbs while `sv_active` sits at the cap, raise `default_pool_size` and `max_db_connections`, as far as `max_connections` allows.
195
201
 
196
202
  With PgBouncer in front, keep Atomic's `maxConnections` at its default of 8 or higher. Atomic's connections only reach PgBouncer, which queues them for its pool.
197
203
 
@@ -213,30 +219,47 @@ If PgBouncer runs on the database server and connects to PostgreSQL as `127.0.0.
213
219
 
214
220
  ## Configure Atomic
215
221
 
216
- Point `url` at PgBouncer and `listenUrl` at PostgreSQL. Both use the runtime role and the same password. In `~/.atomic/agent/settings.json`:
222
+ Point `url` at PgBouncer and `listenUrl` at PostgreSQL. Both use the runtime role and the same password. On each machine:
223
+
224
+ 1. Join the database through PgBouncer:
225
+
226
+ ```bash
227
+ (umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
228
+ atomic storage join 'postgresql://atomic_runtime@pgbouncer.example.com:6432/atomic' --password-file ~/atomic-db-password
229
+ rm ~/atomic-db-password # atomic storage join keeps its own copy
230
+ ```
231
+
232
+ 2. Add `listenUrl`, which `atomic storage join` has no option for, to the `storage` setting it wrote:
233
+
234
+ ```bash
235
+ jq '.storage.options.listenUrl = "postgresql://atomic_runtime@db.example.com:5432/atomic"' ~/.atomic/agent/settings.json > ~/.atomic/agent/settings.json.new \
236
+ && mv ~/.atomic/agent/settings.json.new ~/.atomic/agent/settings.json
237
+ ```
238
+
239
+ 3. Restart Intercom, and check that `atomic storage status` reports `wake-ups: LISTEN/NOTIFY`:
240
+
241
+ ```bash
242
+ atomic intercom restart
243
+ atomic storage status
244
+ ```
245
+
246
+ The setting in `~/.atomic/agent/settings.json` then looks like this. `atomic storage join` created the password file and chose its name, shown here as `storage-token.28ab7041-05e2-4ad5-80af-854329035d8c`. The path is relative to `~/.atomic`:
217
247
 
218
248
  ```json
219
249
  {
220
250
  "storage": {
221
251
  "adapter": "@bastani/atomic-storage-postgres",
222
252
  "options": {
223
- "url": "postgresql://atomic_runtime@pgbouncer.internal:6432/atomic",
224
- "listenUrl": "postgresql://atomic_runtime@db.internal:5432/atomic",
253
+ "url": "postgresql://atomic_runtime@pgbouncer.example.com:6432/atomic",
254
+ "listenUrl": "postgresql://atomic_runtime@db.example.com:5432/atomic",
225
255
  "maxConnections": 8
226
256
  },
227
- "secrets": { "password": { "file": "agent/storage-token.3f2a" } }
257
+ "secrets": { "password": { "file": "agent/storage-token.28ab7041-05e2-4ad5-80af-854329035d8c" } }
228
258
  }
229
259
  }
230
260
  ```
231
261
 
232
- The password file is the one `atomic storage join` writes. To create the block, join with the PgBouncer URL, then add `listenUrl` and restart Intercom:
233
-
234
- ```bash
235
- atomic storage join 'postgresql://atomic_runtime@pgbouncer.internal:6432/atomic' --password-file ~/atomic-db-password
236
- atomic intercom restart
237
- ```
238
-
239
- Atomic checks the certificate and host name of both PgBouncer and PostgreSQL. If PgBouncer's certificate comes from a private certificate authority, add `?sslrootcert=/path/to/root.crt` to `url`. See [TLS](/storage#tls).
262
+ Atomic checks the certificate and host name of both PgBouncer and PostgreSQL. If PgBouncer's certificate comes from a private certificate authority, add `?sslrootcert=/path/to/root.crt` to `url`. See [TLS](/storage/postgres#tls).
240
263
 
241
264
  The same options in an SDK app:
242
265
 
@@ -244,8 +267,8 @@ The same options in an SDK app:
244
267
  import { openPostgresDatabase } from "@bastani/atomic-storage-postgres";
245
268
 
246
269
  const database = await openPostgresDatabase({
247
- url: "postgresql://atomic_runtime@pgbouncer.internal:6432/atomic",
248
- listenUrl: "postgresql://atomic_runtime@db.internal:5432/atomic",
270
+ url: "postgresql://atomic_runtime@pgbouncer.example.com:6432/atomic",
271
+ listenUrl: "postgresql://atomic_runtime@db.example.com:5432/atomic",
249
272
  password: process.env.ATOMIC_DB_PASSWORD,
250
273
  maxConnections: 8,
251
274
  });
@@ -253,12 +276,12 @@ const database = await openPostgresDatabase({
253
276
 
254
277
  ## Check that it works
255
278
 
256
- **Atomic.** Run `atomic storage status` on an agent machine. It should report `wake-ups: LISTEN/NOTIFY`. If it reports `wake-ups: polling only, notifications do not pass the URL's transaction pooler`, `listenUrl` is missing or points at PgBouncer.
279
+ **Atomic.** Run `atomic storage status` on an agent machine. It should report `wake-ups: LISTEN/NOTIFY`, or `wake-ups: connecting` for a few seconds after a restart. If it reports `wake-ups: polling only, notifications do not pass the URL's transaction pooler`, `listenUrl` is missing or points at PgBouncer.
257
280
 
258
281
  **PgBouncer.** Connect to PgBouncer's console, a built-in database named `pgbouncer`, as a role listed in `stats_users`:
259
282
 
260
283
  ```bash
261
- psql -h pgbouncer.internal -p 6432 -U pgbouncer_auth pgbouncer -c 'SHOW POOLS'
284
+ psql -h pgbouncer.example.com -p 6432 -U pgbouncer_auth pgbouncer -c 'SHOW POOLS'
262
285
  ```
263
286
 
264
287
  `SHOW POOLS` prints one row per database and role. In the row for `atomic` and `atomic_runtime`:
@@ -286,54 +309,36 @@ ORDER BY 3 DESC;
286
309
 
287
310
  The `atomic` connections should stay at or below PgBouncer's pool size, and there should be one `atomic-listen` connection per broker.
288
311
 
289
- ## Results from a 200-agent test
290
-
291
- We ran 200 simulated agent runners through PgBouncer 1.25.1 to PostgreSQL 18, with a configuration like the one above: `default_pool_size = 80`, `max_db_connections = 90`, and `max_client_conn = 2000`. Each runner opened two Atomic database handles and one Intercom broker, 10 runners to a process.
292
-
293
- | Round trip to the server | Pool | Server connections | Waiting clients | Save entries to a session, p50 / p95 | Errors |
294
- | --- | --- | --- | --- | --- | --- |
295
- | About 10 ms | 80 | 216 to 218: 200 for wake-ups, 13 to 18 pooled | 0 | 23 ms / 32 ms | 0 of 14,870 calls |
296
- | About 90 ms | 80 | Pool full at 90 | Up to 661, waiting up to 14 seconds | 8.9 s / 18 s | |
297
- | About 90 ms | 170 | Up to 170 pooled | Up to 10, no wait | 188 ms / 203 ms | 112 of 10,981 calls, all lock timeouts (`55P03`) on Intercom send, lease, claim and delivery calls |
298
-
299
- What this shows:
300
-
301
- - With the database close to the agents, 80 pooled connections serve 200 agents with room to spare. Only 13 to 18 were in use at a time.
302
- - With the database far away, transactions last longer and lock waits hold connections, so the same pool fills up. A larger pool removed the queue. The remaining errors were lock timeouts between agents sending, claiming and delivering Intercom messages at once, which PgBouncer does not cause.
303
- - Turning on prepared statements (`maxPreparedStatements: 256`) worked through PgBouncer but did not change these times. Leave it unset unless your own measurements show a gain.
304
-
305
312
  ## Common errors
306
313
 
307
- Atomic reports these as `StorageUnavailableError` or `StorageTransientError`. The message below is the error's cause, which Atomic prints with the error. The first four were reproduced through PgBouncer 1.26.1 with the configuration above, and seen again with PgBouncer 1.25.1 on a production server. The two PostgreSQL messages were reproduced against PostgreSQL 16. The `bouncer config error` and file-limit rows were seen on that production server.
314
+ Atomic reports these as `StorageUnavailableError` or `StorageTransientError`. The message below is the error's cause, which Atomic prints with the error.
308
315
 
309
316
  | Message | Cause | Fix |
310
317
  | --- | --- | --- |
311
318
  | `no more connections allowed (max_client_conn)` | More clients connected to PgBouncer than `max_client_conn` allows. | Raise `max_client_conn`, and the open-file limit with it. |
312
- | `query_wait_timeout` | A client waited `query_wait_timeout` seconds for a PostgreSQL connection. | Check `cl_waiting` and `maxwait` in `SHOW POOLS`. Raise `default_pool_size` if PostgreSQL has room, or look for long transactions with the queries in [Tuning](/storage#check-the-effect). |
319
+ | `query_wait_timeout` | A client waited `query_wait_timeout` seconds for a PostgreSQL connection. | Check `cl_waiting` and `maxwait` in `SHOW POOLS`. Raise `default_pool_size` if PostgreSQL has room, or look for long transactions with the queries in [Tuning](/storage/postgres#check-the-effect). |
313
320
  | `SSL required` | Atomic connected without TLS. Atomic leaves TLS off for addresses on the same machine, such as `localhost`. | Add `?sslmode=verify-full&sslrootcert=/path/to/root.crt` to `url`. |
314
321
  | `SASL authentication failed` | The password is wrong, the role does not exist, or the database is not listed in `[databases]`. | Check the password file, the role, and the database name. Check that the lookup function exists in that database. |
315
322
  | `wake-ups: polling only, notifications do not pass the URL's transaction pooler` in `atomic storage status` | `listenUrl` is missing or points at PgBouncer. | Set `listenUrl` to PostgreSQL's own address. |
316
323
  | `too many connections for role "atomic_runtime"` | The role's `CONNECTION LIMIT` is lower than PgBouncer's pool plus the brokers' wake-up connections. | Raise the limit, or lower `default_pool_size`. |
317
324
  | `sorry, too many clients already` | PostgreSQL's `max_connections` is lower than PgBouncer's pool plus the wake-up and other connections. | Raise `max_connections`, or lower `default_pool_size` and `max_db_connections`. |
318
- | `prepared statement "atomic_…" does not exist` | Atomic's `maxPreparedStatements` is above `0`, but PgBouncer does not keep prepared statements: it is older than 1.21, or `max_prepared_statements` is `0`. | Set `max_prepared_statements` above `0` in PgBouncer, or set `maxPreparedStatements` to `0` in Atomic. |
325
+ | `prepared statement "atomic_…" does not exist` | Atomic sends prepared statements, but PgBouncer does not keep them: it is older than 1.21, or `max_prepared_statements` is `0`. Atomic turns them on by itself only behind a PgBouncer that keeps them, so this follows setting `maxPreparedStatements` by hand, or changing `max_prepared_statements` while Atomic runs. | Set `max_prepared_statements` above `0` in PgBouncer, or set `maxPreparedStatements` to `0` in Atomic. |
319
326
  | `unsupported startup parameter: <name>` | A client sent a connection setting that PgBouncer does not forward. Atomic sends only `application_name`, which PgBouncer forwards. | Add the name to `ignore_startup_parameters` for other clients that need it, such as `extra_float_digits` for Java clients. Never add `application_name`. |
320
327
  | `bouncer config error`, with `auth_query response contained null user name` in PgBouncer's log | The lookup function returned a row of empty values for an unknown role. | Declare the function with `RETURNS TABLE`, as in [A role for password lookups](#a-role-for-password-lookups). |
321
328
  | `kernel file descriptor limit: 1024` in PgBouncer's log | The service's open-file limit is below `max_client_conn`. | Raise `LimitNOFILE`, as in [Start PgBouncer](#start-pgbouncer). |
322
329
 
323
330
  ## Managed services
324
331
 
325
- These services include a pooler of their own. We have not tested Atomic through them. The notes come from each service's documentation.
332
+ These services include a pooler of their own. Check the service's documentation for its current host names and ports.
326
333
 
327
- - **Supabase.** The shared pooler, Supavisor, runs transaction mode on port 6543. Point `url` at port 6543 and `listenUrl` at the direct connection on port 5432. Supavisor does not keep prepared statements, so leave `maxPreparedStatements` at its default, which is `0` on port 6543.
334
+ - **Supabase.** The shared pooler, Supavisor, runs transaction mode on port 6543. Point `url` at port 6543 and `listenUrl` at the direct connection on port 5432. Supavisor does not keep prepared statements, so leave `maxPreparedStatements` unset. Atomic keeps them off there, because it does not identify Supavisor as a PgBouncer that keeps them.
328
335
  - **Neon.** The pooled host name ends in `-pooler` and runs PgBouncer in transaction mode. Point `url` at the pooled host and `listenUrl` at the same host name without `-pooler`.
329
336
  - **Azure Database for PostgreSQL Flexible Server.** Turn on the built-in PgBouncer with the `pgbouncer.enabled` server parameter, on General Purpose and Memory Optimized tiers. It listens on port 6432 of the same host. Point `listenUrl` at port 5432.
330
- - **Amazon RDS Proxy.** RDS Proxy does not pass `LISTEN`, so point `listenUrl` at the database instance's own endpoint. RDS Proxy may keep a client on one database connection ("pinning") when it sees session settings. We have not checked whether Atomic's statements cause pinning. Watch the proxy's pinning metrics in CloudWatch.
331
-
332
- On a managed service where you cannot create a superuser function, use the service's pooler instead of `auth_query`, or list each role's password in PgBouncer's `auth_file`.
337
+ - **Amazon RDS Proxy.** RDS Proxy does not pass `LISTEN`, so point `listenUrl` at the database instance's own endpoint. RDS Proxy listens on port 5432, where Atomic does not expect a pooler, so also set `maxPreparedStatements: 0`.
333
338
 
334
339
  ## Related pages
335
340
 
336
- - [Tuning for many concurrent agents](/storage#tuning-for-many-concurrent-agents): count connections and size `maxConnections`.
337
- - [Tune PostgreSQL for many agents](/guides/postgres-tuning): the server-side settings that go with PgBouncer.
338
- - [Connection poolers](/storage#connection-poolers) and [Wake-ups](/storage#wake-ups) in the storage guide.
341
+ - [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents): count connections and size `maxConnections`.
342
+ - [Tune PostgreSQL for many agents](/storage/postgres/tuning): the server-side settings that go with PgBouncer.
343
+ - [Connection poolers](/storage/postgres#connection-poolers) and [Wake-ups](/storage/postgres#wake-ups) on the PostgreSQL setup page.
339
344
  - [PgBouncer's configuration reference](https://www.pgbouncer.org/config.html).