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

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 (303) hide show
  1. package/CHANGELOG.md +56 -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 +7 -7
  6. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +7 -7
  7. package/dist/_shared/mode-shared-2QJSCUM6.js +7 -7
  8. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  9. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  10. package/dist/_shared/{sdk-AVFII7NK.js → sdk-IQMULKFU.js} +2438 -470
  11. package/dist/_shared/sdk-IQMULKFU.js.map +1 -0
  12. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  13. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  14. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
  15. package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
  16. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
  17. package/dist/_shared/{startup-0-0-57KF6LZH.js → startup-0-0-3IXNMFM2.js} +392 -15
  18. package/dist/_shared/startup-0-0-3IXNMFM2.js.map +1 -0
  19. package/dist/_shared/{startup-0-1-GIY75K46.js → startup-0-1-7T2IAE7J.js} +51 -243
  20. package/dist/_shared/startup-0-1-7T2IAE7J.js.map +1 -0
  21. package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +225 -7
  22. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
  23. package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
  24. package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
  25. package/dist/_shared/startup-0-4-ZMJV547D.js +6 -6
  26. package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
  27. package/dist/_shared/startup-10-0-TDQNBDDL.js +7 -7
  28. package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
  29. package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
  30. package/dist/_shared/startup-15-0-YUKGAC63.js +5 -5
  31. package/dist/_shared/startup-15-1-4S7FLMNG.js +7 -7
  32. package/dist/_shared/startup-8-0-34CBHPZH.js +421 -84
  33. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  34. package/dist/_shared/startup-8-1-X32CYSXB.js +77 -13
  35. package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -1
  36. package/dist/_shared/storage-command-7MGXLJGZ.js +7 -5
  37. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  38. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  39. package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
  40. package/dist/builtin/intercom/CHANGELOG.md +11 -0
  41. package/dist/builtin/intercom/broker/broker.bundle.mjs +205 -82
  42. package/dist/builtin/intercom/broker/sql-lease-store.ts +38 -27
  43. package/dist/builtin/intercom/broker/sql-outbox-store.ts +228 -65
  44. package/dist/builtin/intercom/broker/sql-schema.ts +82 -27
  45. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  46. package/dist/builtin/intercom/package.json +1 -1
  47. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  48. package/dist/builtin/mcp/package.json +1 -1
  49. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  50. package/dist/builtin/subagents/package.json +1 -1
  51. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  52. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  53. package/dist/builtin/web-access/package.json +1 -1
  54. package/dist/cli/args.js +2 -2
  55. package/dist/cli/auth-cli.code.js +4 -4
  56. package/dist/cli/auth-cli.impl.js +3 -3
  57. package/dist/cli/auth-cli.js +3 -3
  58. package/dist/cli/blueprint-command.code.js +2 -2
  59. package/dist/cli/blueprint-command.impl.js +3 -3
  60. package/dist/cli/blueprint-command.js +3 -3
  61. package/dist/cli/intercom-command.code.js +3 -3
  62. package/dist/cli/intercom-command.impl.js +3 -3
  63. package/dist/cli/intercom-command.js +3 -3
  64. package/dist/cli/list-models.code.js +2 -2
  65. package/dist/cli/list-models.impl.js +3 -3
  66. package/dist/cli/list-models.js +3 -3
  67. package/dist/cli/session-picker.code.js +2 -2
  68. package/dist/cli/session-picker.impl.js +3 -3
  69. package/dist/cli/session-picker.js +3 -3
  70. package/dist/cli/startup-ui.code.js +2 -2
  71. package/dist/cli/startup-ui.impl.js +3 -3
  72. package/dist/cli/startup-ui.js +3 -3
  73. package/dist/cli/storage-command.impl.js +3 -3
  74. package/dist/cli/storage-command.js +3 -3
  75. package/dist/cli/storage-search-session.code.js +2 -2
  76. package/dist/cli/storage-search-session.impl.js +3 -3
  77. package/dist/cli/storage-search-session.js +3 -3
  78. package/dist/cli/team-command.code.js +2 -2
  79. package/dist/cli/team-command.impl.js +3 -3
  80. package/dist/cli/team-command.js +3 -3
  81. package/dist/cli.js +2 -2
  82. package/dist/core/debug.impl.js +3 -3
  83. package/dist/core/debug.js +3 -3
  84. package/dist/core/export-html/card-projection.impl.js +3 -3
  85. package/dist/core/export-html/card-projection.js +3 -3
  86. package/dist/core/export-html/index.code.js +2 -2
  87. package/dist/core/export-html/index.impl.js +3 -3
  88. package/dist/core/export-html/index.js +3 -3
  89. package/dist/core/export-html/json-spans.impl.js +3 -3
  90. package/dist/core/export-html/json-spans.js +3 -3
  91. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  92. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  93. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  94. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  95. package/dist/core/export-html/tool-renderer.js +3 -3
  96. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  97. package/dist/core/extensions/jiti-loader.js +3 -3
  98. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  99. package/dist/core/extensions/jiti-static-loader.js +3 -3
  100. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  101. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  102. package/dist/core/extensions/loader-host-modules.js +3 -3
  103. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  104. package/dist/core/extensions/runner-context.js +2 -2
  105. package/dist/core/intercom-broker-control-host.code.js +1 -1
  106. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  107. package/dist/core/intercom-broker-control-host.js +3 -3
  108. package/dist/core/intercom-broker-control.code.js +3 -3
  109. package/dist/core/intercom-broker-control.impl.js +3 -3
  110. package/dist/core/intercom-broker-control.js +3 -3
  111. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  112. package/dist/core/package-manager-storage-adapters.js +3 -3
  113. package/dist/core/sdk.code.js +3 -3
  114. package/dist/core/sdk.impl.js +3 -3
  115. package/dist/core/sdk.js +3 -3
  116. package/dist/core/session-manager-core.js +26 -14
  117. package/dist/core/session-manager-core.js.map +1 -1
  118. package/dist/core/session-manager-list.impl.js +3 -3
  119. package/dist/core/session-manager-list.js +3 -3
  120. package/dist/core/session-manager.code.js +3 -3
  121. package/dist/core/session-manager.impl.js +3 -3
  122. package/dist/core/session-manager.js +3 -3
  123. package/dist/core/session-open-markers.js +3 -0
  124. package/dist/core/session-open-markers.js.map +1 -0
  125. package/dist/core/session-storage.impl.js +3 -3
  126. package/dist/core/session-storage.js +3 -3
  127. package/dist/core/storage/added-exports.js +3 -0
  128. package/dist/core/storage/added-exports.js.map +1 -1
  129. package/dist/core/storage/database.d.ts +37 -0
  130. package/dist/core/storage/database.js.map +1 -1
  131. package/dist/core/storage/index.d.ts +1 -1
  132. package/dist/core/storage/index.js +2 -2
  133. package/dist/core/storage/index.js.map +1 -1
  134. package/dist/core/storage/migrations.d.ts +12 -3
  135. package/dist/core/storage/migrations.js +24 -11
  136. package/dist/core/storage/migrations.js.map +1 -1
  137. package/dist/core/storage/node-sqlite-thread.js +31 -2
  138. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  139. package/dist/core/storage/node-sqlite.js +86 -2
  140. package/dist/core/storage/node-sqlite.js.map +1 -1
  141. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  142. package/dist/core/storage/offline-snapshot-file.js +3 -3
  143. package/dist/core/storage/prefix.js +5 -0
  144. package/dist/core/storage/prefix.js.map +1 -1
  145. package/dist/core/storage/provider.js +2 -2
  146. package/dist/core/storage/schema-catalog.d.ts +82 -4
  147. package/dist/core/storage/schema-catalog.js +242 -32
  148. package/dist/core/storage/schema-catalog.js.map +1 -1
  149. package/dist/core/storage/selection.js +2 -2
  150. package/dist/core/storage/session/branch-fork-source.code.js +9 -8
  151. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  152. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  153. package/dist/core/storage/session/branch-fork-source.js +3 -3
  154. package/dist/core/storage/session/card-view.impl.js +3 -3
  155. package/dist/core/storage/session/card-view.js +3 -3
  156. package/dist/core/storage/session/child-reader.code.js +4 -4
  157. package/dist/core/storage/session/child-reader.impl.js +3 -3
  158. package/dist/core/storage/session/child-reader.js +3 -3
  159. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  160. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  161. package/dist/core/storage/session/errors.js +1 -1
  162. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  163. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  164. package/dist/core/storage/session/expanded-child-details.js +3 -3
  165. package/dist/core/storage/session/fork-detach.d.ts +118 -0
  166. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  167. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  168. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  169. package/dist/core/storage/session/fork-row-index.js +3 -3
  170. package/dist/core/storage/session/fork-schema.js +53 -0
  171. package/dist/core/storage/session/fork-schema.js.map +1 -0
  172. package/dist/core/storage/session/fork-segments.d.ts +58 -0
  173. package/dist/core/storage/session/fork-staging.code.js +3 -3
  174. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  175. package/dist/core/storage/session/fork-staging.js +3 -3
  176. package/dist/core/storage/session/fork-sweep.js +61 -0
  177. package/dist/core/storage/session/fork-sweep.js.map +1 -0
  178. package/dist/core/storage/session/fork-window.code.js +4 -4
  179. package/dist/core/storage/session/fork-window.impl.js +3 -3
  180. package/dist/core/storage/session/fork-window.js +3 -3
  181. package/dist/core/storage/session/history-pages.impl.js +3 -3
  182. package/dist/core/storage/session/history-pages.js +3 -3
  183. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  184. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  185. package/dist/core/storage/session/jsonl-session-store.d.ts +37 -1
  186. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  187. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  188. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  189. package/dist/core/storage/session/memory-session-store.js +3 -3
  190. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  191. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  192. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  193. package/dist/core/storage/session/released-history-files.code.js +3 -3
  194. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  195. package/dist/core/storage/session/released-history-files.js +3 -3
  196. package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
  197. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  198. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  199. package/dist/core/storage/session/session-resume.impl.js +3 -3
  200. package/dist/core/storage/session/session-resume.js +3 -3
  201. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  202. package/dist/core/storage/session/snapshot-cut.js +3 -3
  203. package/dist/core/storage/session/snapshot-history.code.js +4 -4
  204. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  205. package/dist/core/storage/session/snapshot-history.js +3 -3
  206. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  207. package/dist/core/storage/session/sql-session-store.d.ts +349 -12
  208. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  209. package/dist/core/storage/session/sql-session-store.js +4 -4
  210. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  211. package/dist/core/storage/session/tree-outline.js +3 -3
  212. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  213. package/dist/core/storage/session/tree-presentation.js +3 -3
  214. package/dist/core/storage/session/types.d.ts +22 -0
  215. package/dist/core/storage/sqlite-facade.d.ts +17 -1
  216. package/dist/core/storage/sqlite-facade.js +33 -0
  217. package/dist/core/storage/sqlite-facade.js.map +1 -1
  218. package/dist/core/storage/storage-status.impl.js +3 -3
  219. package/dist/core/storage/storage-status.js +3 -3
  220. package/dist/core/storage/team.impl.js +3 -3
  221. package/dist/core/storage/team.js +3 -3
  222. package/dist/core/structured-output/index.code.js +1 -1
  223. package/dist/core/structured-output/index.impl.js +3 -3
  224. package/dist/core/structured-output/index.js +3 -3
  225. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  226. package/dist/core/tasks/task-completion-entry.js +3 -3
  227. package/dist/core/tasks/task-file-history.code.js +4 -4
  228. package/dist/core/tasks/task-file-history.impl.js +3 -3
  229. package/dist/core/tasks/task-file-history.js +3 -3
  230. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  231. package/dist/core/tasks/task-reference-archive.js +3 -3
  232. package/dist/core/tasks/task-reference-identity.js +3 -3
  233. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  234. package/dist/core/tasks/task-reference-stream.js +3 -3
  235. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  236. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  237. package/dist/core/tasks/task-view-source.impl.js +3 -3
  238. package/dist/core/tasks/task-view-source.js +3 -3
  239. package/dist/core/tools/history-session.d.ts +2 -0
  240. package/dist/core/tools/read-url.code.js +2 -2
  241. package/dist/core/tools/read-url.impl.js +3 -3
  242. package/dist/core/tools/read-url.js +3 -3
  243. package/dist/core/worktree-snapshot/blob-store.d.ts +31 -0
  244. package/dist/core/worktree-snapshot/blob-store.js +164 -49
  245. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  246. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  247. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  248. package/dist/core/worktree-snapshot/errors.js +3 -3
  249. package/dist/core/worktree-snapshot/fork-snapshot-index.js +121 -0
  250. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
  251. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  252. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  253. package/dist/extensions/codemode/execute.code.js +2 -2
  254. package/dist/extensions/codemode/execute.impl.js +3 -3
  255. package/dist/extensions/codemode/execute.js +3 -3
  256. package/dist/extensions/codemode/renderer.code.js +1 -1
  257. package/dist/extensions/codemode/renderer.impl.js +3 -3
  258. package/dist/extensions/codemode/renderer.js +3 -3
  259. package/dist/extensions/mcp/cli.code.js +2 -2
  260. package/dist/extensions/mcp/cli.impl.js +3 -3
  261. package/dist/extensions/mcp/cli.js +3 -3
  262. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  263. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  264. package/dist/extensions/mcp/cli.lazy.js +3 -3
  265. package/dist/extensions/mcp/runtime.code.js +1 -1
  266. package/dist/extensions/mcp/runtime.impl.js +3 -3
  267. package/dist/extensions/mcp/runtime.js +3 -3
  268. package/dist/index.js +6 -6
  269. package/dist/main-first-time-setup.code.js +2 -2
  270. package/dist/main-first-time-setup.impl.js +3 -3
  271. package/dist/main-first-time-setup.js +3 -3
  272. package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
  273. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  274. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  275. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  276. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  277. package/dist/modes/print-mode.js +1 -1
  278. package/dist/package-manager-cli.code.js +5 -5
  279. package/dist/package-manager-cli.impl.js +3 -3
  280. package/dist/package-manager-cli.js +3 -3
  281. package/dist/rpc-entry.js +1 -1
  282. package/dist/startup-files.json +1 -1
  283. package/dist/startup-stages/2.js +1 -0
  284. package/dist/startup-stages/5.js +1 -1
  285. package/dist/startup-stages/7.js +5 -1
  286. package/dist/startup-stages/8.js +2 -2
  287. package/dist/utils/startup-database-spare.code.js +3 -3
  288. package/dist/utils/startup-database-spare.impl.js +3 -3
  289. package/dist/utils/startup-database-spare.js +3 -3
  290. package/dist/utils/tools-manager.code.js +1 -1
  291. package/dist/utils/tools-manager.impl.js +3 -3
  292. package/dist/utils/tools-manager.js +3 -3
  293. package/docs/guides/postgres-pgbouncer.md +14 -7
  294. package/docs/guides/postgres-tuning.md +9 -9
  295. package/docs/sessions.md +9 -0
  296. package/docs/storage.md +47 -6
  297. package/package.json +8 -8
  298. package/dist/_shared/sdk-AVFII7NK.js.map +0 -1
  299. package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
  300. package/dist/_shared/startup-0-0-57KF6LZH.js.map +0 -1
  301. package/dist/_shared/startup-0-1-GIY75K46.js.map +0 -1
  302. package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
  303. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"schema-catalog.js","sourceRoot":"","sources":["../../../src/core/storage/schema-catalog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAyBzC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,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CAAC,KAAK,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,MAAM;YAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpF,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,QAAwB,EACxB,MAAe;IAEf,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/F,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC;AACtB,CAAC","sourcesContent":["import type { SqliteDatabase, SqliteRow } from \"./database.js\";\nimport { dialectOf } from \"./dialect.js\";\n\n/**\n * What a schema held when one open read it: its relations, triggers and columns, and on PostgreSQL the versions its\n * ledger records. Only a positive answer is final: the schema only moves forward, so what existed then still exists,\n * while something missing may have been created since and is checked again under the store's lock.\n */\nexport interface StorageSchemaCatalog {\n\t/** The ledger the versions were read from. */\n\treadonly ledger: string;\n\t/** The highest version `ledger` recorded for `domain`; 0 when none, or when the ledger did not exist. */\n\trecordedVersion(domain: string): number;\n\t/** Whether a table (or view) named `table` existed. */\n\thasTable(table: string): boolean;\n\t/** Whether a relation (table, index, sequence…) or a trigger named `name` existed. */\n\thasObject(name: string): boolean;\n\t/** Whether `table` had a column named `column`. */\n\thasColumn(table: string, column: string): boolean;\n\t/**\n\t * What kind of object `name` was on SQLite and libSQL (`table`, `index`, `view` or `trigger`), from one read of\n\t * `sqlite_schema`; undefined when there was none, and always on PostgreSQL.\n\t */\n\treadonly sqliteObjectType?: (name: string) => string | undefined;\n}\n\nconst TABLE_KINDS = new Set([\"r\", \"p\", \"v\", \"m\", \"f\"]);\n\n/**\n * Every relation, trigger and column of the schema the statement runs in, in one statement and so one snapshot. The\n * catalog, not information_schema, finds relations, as `tableExists` does; columns come from information_schema, as\n * `columnExists` reads them.\n */\nconst CATALOG_SQL = `SELECT 'relation' AS kind, c.relname::text AS name, c.relkind::text AS detail\n\tFROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace\nUNION ALL SELECT 'trigger', t.tgname::text, NULL\n\tFROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n\tWHERE c.relnamespace = current_schema()::regnamespace AND NOT t.tgisinternal\nUNION ALL SELECT 'column', table_name::text, column_name::text\n\tFROM information_schema.columns WHERE table_schema = current_schema()`;\n\ntype CatalogRow = SqliteRow & { kind: string; name: string; detail: string | null };\n\n/**\n * Every object of a SQLite or libSQL database and every column of its tables, generated ones included, in one\n * statement and so one snapshot: what `tableExists`, `columnExists` and `schemaObjects` ask one at a time (#6560).\n */\nconst SQLITE_CATALOG_SQL = `SELECT 'object' AS kind, name, type AS detail FROM sqlite_master\nUNION ALL SELECT 'column', m.name, c.name FROM sqlite_master AS m JOIN pragma_table_xinfo(m.name) AS c\n\tWHERE m.type = 'table'`;\n\n/** The catalog of a SQLite or libSQL database, or undefined when it cannot be read, such as on a SQLite too old. */\nasync function readSqliteCatalog(database: SqliteDatabase, ledger: string): Promise<StorageSchemaCatalog | undefined> {\n\tlet rows: CatalogRow[];\n\ttry {\n\t\trows = await database.all<CatalogRow>(SQLITE_CATALOG_SQL);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst types = new Map<string, string>();\n\tconst columns = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse types.set(row.name, String(row.detail));\n\t}\n\treturn {\n\t\tledger,\n\t\t// SQLite records no versions: its stores set their schemas up as before, checked against what exists.\n\t\trecordedVersion: () => 0,\n\t\thasTable: (table) => types.get(table) === \"table\",\n\t\thasObject: (name) => types.has(name),\n\t\thasColumn: (table, column) => columns.has(`${table}\\0${column}`),\n\t\tsqliteObjectType: (name) => types.get(name),\n\t};\n}\n\n/**\n * Reads `database`'s schema and the versions `ledger` records, in two statements sent at once, without a transaction\n * or a lock. On SQLite and libSQL, which record no versions, reads the schema alone in one statement. Undefined when a\n * read fails: the stores then check each object themselves.\n */\nexport async function readStorageSchemaCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.name === \"sqlite\") return readSqliteCatalog(database, ledger);\n\tif (!dialect.versionedMigrations || dialect.name !== \"postgres\") return undefined;\n\tconst physicalLedger = dialect.identifier(ledger);\n\tconst versions = database\n\t\t.all<SqliteRow & { domain: string; version: number | string | null }>(\n\t\t\t`SELECT domain, MAX(version) AS version FROM ${ledger} GROUP BY domain`,\n\t\t)\n\t\t.then(\n\t\t\t(rows) => rows,\n\t\t\t() => undefined,\n\t\t);\n\tlet rows: CatalogRow[];\n\ttry {\n\t\trows = await database.all<CatalogRow>(CATALOG_SQL);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst tables = new Set<string>();\n\tconst objects = new Set<string>();\n\tconst columns = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse {\n\t\t\tobjects.add(row.name);\n\t\t\tif (row.kind === \"relation\" && TABLE_KINDS.has(String(row.detail))) tables.add(row.name);\n\t\t}\n\t}\n\tconst recorded = new Map<string, number>();\n\tif (tables.has(physicalLedger)) {\n\t\tconst read = await versions;\n\t\tif (read === undefined) return undefined;\n\t\tfor (const row of read) recorded.set(row.domain, Number(row.version ?? 0));\n\t}\n\treturn {\n\t\tledger,\n\t\trecordedVersion: (domain) => recorded.get(domain) ?? 0,\n\t\thasTable: (table) => tables.has(dialect.identifier(table)),\n\t\thasObject: (name) => objects.has(dialect.identifier(name)),\n\t\thasColumn: (table, column) => columns.has(`${dialect.identifier(table)}\\0${column}`),\n\t};\n}\n\ninterface CatalogScope {\n\treadonly ledger: string;\n\t/** Read when the scope starts on PostgreSQL, whose opens always ask it; on SQLite at the first question. */\n\tcatalog: Promise<StorageSchemaCatalog | undefined> | undefined;\n\treadonly read: () => Promise<StorageSchemaCatalog | undefined>;\n\tusers: number;\n}\n\nconst scopes = new WeakMap<SqliteDatabase, CatalogScope>();\n\n/**\n * Runs `body`, an open of one or more stores on `database`, with one catalog read for all of them: the schema checks\n * of the stores it opens ({@link schemaCatalogOf}) answer from it, so an open whose schema is current runs no schema\n * transaction and takes no lock. Opens on `database` that overlap share the read. `views` are other handles on the\n * same connection, such as a borrowed view, whose checks answer from the same read.\n */\nexport async function withStorageSchemaCatalog<T>(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tbody: () => Promise<T>,\n\tviews: readonly SqliteDatabase[] = [],\n): Promise<T> {\n\tlet scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger) {\n\t\tconst read = () => readStorageSchemaCatalog(database, ledger);\n\t\tscope = { ledger, catalog: dialectOf(database).name === \"sqlite\" ? undefined : read(), read, users: 0 };\n\t\tscopes.set(database, scope);\n\t}\n\tconst shared = scope;\n\tconst handles = [database, ...views.filter((view) => !scopes.has(view))];\n\tfor (const handle of handles.slice(1)) scopes.set(handle, shared);\n\tshared.users += 1;\n\ttry {\n\t\treturn await body();\n\t} finally {\n\t\tshared.users -= 1;\n\t\tfor (const handle of handles.slice(1)) if (scopes.get(handle) === shared) scopes.delete(handle);\n\t\tif (shared.users === 0 && scopes.get(database) === shared) scopes.delete(database);\n\t}\n}\n\n/**\n * The catalog an open of `database` in progress read ({@link withStorageSchemaCatalog}), when it read `ledger`'s\n * versions or no `ledger` is named; undefined outside such an open, and when it could not be read.\n */\nexport async function schemaCatalogOf(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || (ledger !== undefined && scope.ledger !== ledger)) return undefined;\n\tscope.catalog ??= scope.read();\n\treturn scope.catalog;\n}\n"]}
1
+ {"version":3,"file":"schema-catalog.js","sourceRoot":"","sources":["../../../src/core/storage/schema-catalog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,SAAS,GAAmE,iBAAiB,CAAC;AA8BpG,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,GAAG;;;;;;;;iFAQ6D,CAAC;AAIlF;;;GAGG;AACH,MAAM,kBAAkB,GAAG;;wBAEH,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC1C,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,sBAAsB;QACvE,CAAC,CAAC,GAAG,MAAM,gBAAgB,CAAC;AAC9B,CAAC;AAED,qFAAqF;AACrF,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,UAAU,MAAM,EAAE,CAAC;AAIxD;;;GAGG;AACH,KAAK,UAAU,sBAAsB,CAAC,QAAwB,EAAE,MAAc;IAC7E,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,GAAG,CAC9B,2DAA2D,sBAAsB,CAAC,MAAM,CAAC;yEAClB,CACvE,CAAC;IACF,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,OAAO,CAAC;IAC7D,MAAM,MAAM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QAAQ,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;oBACzF,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,MAAM,wBAAwB,CAC7B,EAAE,EACF,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAChC,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAC9D,CAAC;QACH,CAAC,EACD,EAAE,sBAAsB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CACvF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,QAAQ;YAAE,MAAM,KAAK,CAAC;QAC1B,mCAAmC;IACpC,CAAC;AACF,CAAC","sourcesContent":["import type { SqliteDatabase, SqliteExecutor, SqliteRow } from \"./database.js\";\nimport { dialectOf } from \"./dialect.js\";\nimport * as statementSequence from \"./statement-sequence.js\";\n\n/**\n * `transactionFinisher` of `statement-sequence.ts`, which the copy of that module 0.10.3 and 0.10.4 loaded lacks: a\n * process an in-place update caught keeps that copy, where a named import would fail to link. Without it the stamps\n * go out on their own, before the commit.\n */\nconst finishers: Partial<Pick<typeof statementSequence, \"transactionFinisher\">> = statementSequence;\n\n/**\n * What a schema held when one open read it: its relations, triggers and columns, and on PostgreSQL the versions its\n * ledger records. Only a positive answer is final: the schema only moves forward, so what existed then still exists,\n * while something missing may have been created since and is checked again under the store's lock.\n */\nexport interface StorageSchemaCatalog {\n\t/** The ledger the versions were read from. */\n\treadonly ledger: string;\n\t/** The highest version `ledger` recorded for `domain`; 0 when none, or when the ledger did not exist. */\n\trecordedVersion(domain: string): number;\n\t/** Whether a table (or view) named `table` existed. */\n\thasTable(table: string): boolean;\n\t/** Whether a relation (table, index, sequence…) or a trigger named `name` existed. */\n\thasObject(name: string): boolean;\n\t/** Whether `table` had a column named `column`. */\n\thasColumn(table: string, column: string): boolean;\n\t/**\n\t * Whether a function named `name` existed in the schema and this role may run it: PostgreSQL only, absent on SQLite\n\t * and libSQL.\n\t */\n\treadonly hasFunction?: (name: string) => boolean;\n\t/**\n\t * What kind of object `name` was on SQLite and libSQL (`table`, `index`, `view` or `trigger`), from one read of\n\t * `sqlite_schema`; undefined when there was none, and always on PostgreSQL.\n\t */\n\treadonly sqliteObjectType?: (name: string) => string | undefined;\n}\n\nconst TABLE_KINDS = new Set([\"r\", \"p\", \"v\", \"m\", \"f\"]);\n\n/**\n * Every relation, trigger, column and function of the schema the statement runs in, in one statement and so one\n * snapshot. The catalog, not information_schema, finds relations, as `tableExists` does; columns come from\n * information_schema, as `columnExists` reads them. A function is listed with whether this role may execute it.\n */\nconst CATALOG_SQL = `SELECT 'relation' AS kind, c.relname::text AS name, c.relkind::text AS detail\n\tFROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace\nUNION ALL SELECT 'trigger', t.tgname::text, NULL\n\tFROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n\tWHERE c.relnamespace = current_schema()::regnamespace AND NOT t.tgisinternal\nUNION ALL SELECT 'column', table_name::text, column_name::text\n\tFROM information_schema.columns WHERE table_schema = current_schema()\nUNION ALL SELECT 'function', p.proname::text, CASE WHEN has_function_privilege(p.oid, 'EXECUTE') THEN 'executable' END\n\tFROM pg_catalog.pg_proc p WHERE p.pronamespace = current_schema()::regnamespace`;\n\ntype CatalogRow = SqliteRow & { kind: string; name: string; detail: string | null };\n\n/**\n * Every object of a SQLite or libSQL database and every column of its tables, generated ones included, in one\n * statement and so one snapshot: what `tableExists`, `columnExists` and `schemaObjects` ask one at a time (#6560).\n */\nconst SQLITE_CATALOG_SQL = `SELECT 'object' AS kind, name, type AS detail FROM sqlite_master\nUNION ALL SELECT 'column', m.name, c.name FROM sqlite_master AS m JOIN pragma_table_xinfo(m.name) AS c\n\tWHERE m.type = 'table'`;\n\n/**\n * @internal The table under `ledger`'s prefix where SQLite and libSQL record which revision of each store's schema\n * setup ran, and the database's schema version (`PRAGMA schema_version`) once it had: `domain`, `revision`,\n * `schema_version`. SQLite counts every change to the schema in that version, whoever makes it, an older Atomic that\n * records nothing included; a revision is believed only while the version still matches, so any later change is checked\n * again (#6560). Builds that do not know the table leave it alone.\n */\nexport function sqliteSchemaStampTable(ledger: string): string {\n\treturn ledger.endsWith(\"atomic_migrations\")\n\t\t? `${ledger.slice(0, -\"atomic_migrations\".length)}atomic_schema_stamps`\n\t\t: `${ledger}_schema_stamps`;\n}\n\n/** The key a store's setup is stamped under, as the PostgreSQL ledger records it. */\nconst stampKey = (domain: string) => `schema:${domain}`;\n\ntype StampRow = SqliteRow & { domain: string | null; revision: number | bigint | null; stamped: number | bigint };\n\n/**\n * The revisions `ledger`'s stamps record whose schema version is the database's now, by stamp key, read in one\n * statement so the two agree. Stamps of an older schema version are left out: something changed the schema since.\n */\nasync function readSqliteSchemaStamps(executor: SqliteExecutor, ledger: string): Promise<Map<string, number>> {\n\tconst rows = await executor.all<StampRow>(\n\t\t`SELECT domain, revision, schema_version AS stamped FROM ${sqliteSchemaStampTable(ledger)}\n\t\tUNION ALL SELECT NULL, NULL, schema_version FROM pragma_schema_version`,\n\t);\n\tconst now = rows.find((row) => row.domain === null)?.stamped;\n\tconst stamps = new Map<string, number>();\n\tfor (const row of rows)\n\t\tif (row.domain !== null && now !== undefined && Number(row.stamped) === Number(now))\n\t\t\tstamps.set(row.domain, Number(row.revision ?? 0));\n\treturn stamps;\n}\n\n/** @internal A store's schema setup, as its stamp records it: `ledger` names the prefix, `domain` the store. */\nexport interface SqliteSchemaStamp {\n\treadonly ledger: string;\n\treadonly domain: string;\n\treadonly revision: number;\n}\n\n/**\n * @internal Stamps each of `stamps`, in the transaction `tx` that ran their setups, with the schema version as that\n * transaction leaves it: a later open believes their revisions until the schema changes again (#6560). Creates the\n * stamps table first, unless `options.tableExists`, so its own creation is part of the version recorded. With\n * `options.last`, the stamps are the transaction's last statement: where its connection is pipelined, they go out with\n * its commit. SQLite and libSQL only; every stamp must share a ledger.\n */\nexport async function recordSqliteSchemaStamps(\n\ttx: SqliteExecutor,\n\tstamps: readonly SqliteSchemaStamp[],\n\toptions: { readonly tableExists?: boolean; readonly last?: boolean } = {},\n): Promise<void> {\n\tconst ledger = stamps[0]?.ledger;\n\tif (ledger === undefined) return;\n\tconst table = sqliteSchemaStampTable(ledger);\n\tif (options.tableExists !== true)\n\t\tawait tx.exec(\n\t\t\t`CREATE TABLE IF NOT EXISTS ${table} (domain TEXT NOT NULL PRIMARY KEY, revision INTEGER NOT NULL, schema_version INTEGER NOT NULL)`,\n\t\t);\n\t// The revision this transaction set up, even below a newer build's: the stamp says what was checked at this version.\n\t// One statement for them all, so a server pays one request.\n\tconst upsert = {\n\t\tsql: `INSERT INTO ${table} (domain, revision, schema_version)\n\t\tSELECT column1, column2, (SELECT schema_version FROM pragma_schema_version)\n\t\tFROM (VALUES ${stamps.map(() => \"(?, ?)\").join(\", \")}) WHERE true\n\t\tON CONFLICT(domain) DO UPDATE SET revision = excluded.revision, schema_version = excluded.schema_version`,\n\t\tparams: stamps.flatMap(({ domain, revision }) => [stampKey(domain), revision]),\n\t};\n\tif (options.last === true && finishers.transactionFinisher?.(tx)?.([upsert]) === true) return;\n\tawait tx.run(upsert.sql, ...upsert.params);\n}\n\n/** The catalog of a SQLite or libSQL database, or undefined when it cannot be read, such as on a SQLite too old. */\nasync function readSqliteCatalog(database: SqliteExecutor, ledger: string): Promise<StorageSchemaCatalog | undefined> {\n\tlet rows: CatalogRow[];\n\ttry {\n\t\trows = await database.all<CatalogRow>(SQLITE_CATALOG_SQL);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst types = new Map<string, string>();\n\tconst columns = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse types.set(row.name, String(row.detail));\n\t}\n\treturn {\n\t\tledger,\n\t\t// SQLite records no versions: its stores' stamps are read on their own (`sqliteSchemaStampsOf`).\n\t\trecordedVersion: () => 0,\n\t\thasTable: (table) => types.get(table) === \"table\",\n\t\thasObject: (name) => types.has(name),\n\t\thasColumn: (table, column) => columns.has(`${table}\\0${column}`),\n\t\tsqliteObjectType: (name) => types.get(name),\n\t};\n}\n\ntype VersionRow = SqliteRow & { domain: string; version: number | string | null };\n\n/** The tables, objects, columns and executable functions of PostgreSQL catalog rows (`CATALOG_SQL`'s). */\nfunction catalogSets(rows: readonly CatalogRow[]) {\n\tconst tables = new Set<string>();\n\tconst objects = new Set<string>();\n\tconst columns = new Set<string>();\n\tconst functions = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse if (row.kind === \"function\") {\n\t\t\tif (row.detail === \"executable\") functions.add(row.name);\n\t\t} else {\n\t\t\tobjects.add(row.name);\n\t\t\tif (row.kind === \"relation\" && TABLE_KINDS.has(String(row.detail))) tables.add(row.name);\n\t\t}\n\t}\n\treturn { tables, objects, columns, functions };\n}\n\n/**\n * The catalog rows and the ledger's versions of `database`'s schema, read in one read-only transaction whose start\n * carries both reads, so they cost one round trip (#6560). The versions are undefined when the ledger did not exist;\n * the whole read is undefined when it failed.\n */\nasync function readPostgresCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tphysicalLedger: string,\n): Promise<{ rows: CatalogRow[]; versions: VersionRow[] | undefined } | undefined> {\n\tconst versionsSql = `SELECT domain, MAX(version) AS version FROM ${ledger} GROUP BY domain`;\n\tlet read: { rows: CatalogRow[]; versions: VersionRow[] | undefined } | undefined;\n\ttry {\n\t\tawait database.transaction(\n\t\t\tasync (tx) => {\n\t\t\t\tread = undefined;\n\t\t\t\tconst rows = await tx.all<CatalogRow>(CATALOG_SQL);\n\t\t\t\t// Taken even where the ledger does not exist and its read failed, so the transaction ends with its commit,\n\t\t\t\t// sent at once, rather than with a rollback after it.\n\t\t\t\tconst ledgerExists = catalogSets(rows).tables.has(physicalLedger);\n\t\t\t\tconst versions = await tx.all<VersionRow>(versionsSql).catch((error: unknown) => {\n\t\t\t\t\tif (ledgerExists) throw error;\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\tread = { rows, versions };\n\t\t\t},\n\t\t\t{\n\t\t\t\treadOnly: true,\n\t\t\t\tretryTransientFailures: true,\n\t\t\t\tleading: [\n\t\t\t\t\t{ sql: CATALOG_SQL, params: [] },\n\t\t\t\t\t{ sql: versionsSql, params: [] },\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn read;\n}\n\n/**\n * Reads `database`'s schema and the versions `ledger` records, in one read-only transaction that takes no lock. On\n * PostgreSQL, an adapter that read them when it opened gives them once (`takeOpenedCatalog`), and the first open reads\n * nothing (#6560). On SQLite and libSQL, which record no versions, reads the schema alone in one statement. Undefined\n * when a read fails: the stores then check each object themselves.\n */\nexport async function readStorageSchemaCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.name === \"sqlite\") return readSqliteCatalog(database, ledger);\n\tif (!dialect.versionedMigrations || dialect.name !== \"postgres\") return undefined;\n\tconst physicalLedger = dialect.identifier(ledger);\n\tconst opened = database.takeOpenedCatalog?.();\n\tconst read =\n\t\topened !== undefined && opened.ledger === physicalLedger\n\t\t\t? {\n\t\t\t\t\trows: opened.rows as readonly CatalogRow[],\n\t\t\t\t\tversions: opened.versions as readonly VersionRow[] | undefined,\n\t\t\t\t}\n\t\t\t: await readPostgresCatalog(database, ledger, physicalLedger);\n\tif (read === undefined) return undefined;\n\tconst { tables, objects, columns, functions } = catalogSets(read.rows);\n\tconst recorded = new Map<string, number>();\n\tif (tables.has(physicalLedger)) {\n\t\tif (read.versions === undefined) return undefined;\n\t\tfor (const row of read.versions) recorded.set(row.domain, Number(row.version ?? 0));\n\t}\n\treturn {\n\t\tledger,\n\t\trecordedVersion: (domain) => recorded.get(domain) ?? 0,\n\t\thasTable: (table) => tables.has(dialect.identifier(table)),\n\t\thasObject: (name) => objects.has(dialect.identifier(name)),\n\t\thasColumn: (table, column) => columns.has(`${dialect.identifier(table)}\\0${column}`),\n\t\thasFunction: (name) => functions.has(dialect.identifier(name)),\n\t};\n}\n\ninterface CatalogScope {\n\treadonly ledger: string;\n\t/** Read when the scope starts on PostgreSQL, whose opens always ask it; on SQLite at the first question. */\n\tcatalog: Promise<StorageSchemaCatalog | undefined> | undefined;\n\treadonly read: () => Promise<StorageSchemaCatalog | undefined>;\n\tusers: number;\n\t/** The stamps valid when read, by stamp key, read at the first question: see {@link sqliteSchemaStampsOf}. */\n\tstamps: Promise<ReadonlyMap<string, number> | undefined> | undefined;\n\t/** The setups this open ran on SQLite, by domain, to stamp again at its end ({@link restampStorageSchemaAtOpenEnd}). */\n\treadonly restamp: Map<string, PendingRestamp>;\n}\n\ninterface PendingRestamp extends SchemaStampAtOpenEnd {\n\treadonly stamp: SqliteSchemaStamp;\n\treadonly setup: (tx: SqliteExecutor) => Promise<unknown>;\n}\n\n/** @internal How the end of an open stamps a store's setup: see {@link restampStorageSchemaAtOpenEnd}. */\nexport interface SchemaStampAtOpenEnd {\n\t/**\n\t * Whether the store's schema, as the end's transaction reads the catalog, holds everything `setup` creates. Given,\n\t * the end runs `setup` only where it does not; absent, it runs `setup` whenever the store's stamp is behind.\n\t */\n\treadonly verify?: (catalog: StorageSchemaCatalog) => boolean;\n\t/**\n\t * `setup` has not run in this open and must: the end runs it whatever the stamp, and a failure fails the open, as\n\t * the setup's own transaction would have. For a setup whose objects all exist and whose only other statements seed\n\t * rows nothing in the open reads, such as a counter's: it then shares the end's transaction instead of taking one.\n\t */\n\treadonly deferred?: boolean;\n\t/**\n\t * `setup` ran in this open, in a transaction that stamped nothing: it is stamped only when the end takes a transaction\n\t * for another store, never in one of its own, so a new database's first open takes none.\n\t */\n\treadonly alongside?: boolean;\n}\n\nconst scopes = new WeakMap<SqliteDatabase, CatalogScope>();\n\n/**\n * Runs `body`, an open of one or more stores on `database`, with one catalog read for all of them: the schema checks\n * of the stores it opens ({@link schemaCatalogOf}) answer from it, so an open whose schema is current runs no schema\n * transaction and takes no lock. Opens on `database` that overlap share the read. `views` are other handles on the\n * same connection, such as a borrowed view, whose checks answer from the same read.\n */\nexport async function withStorageSchemaCatalog<T>(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tbody: () => Promise<T>,\n\tviews: readonly SqliteDatabase[] = [],\n): Promise<T> {\n\tlet scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger) {\n\t\tconst read = () => readStorageSchemaCatalog(database, ledger);\n\t\tconst catalog = dialectOf(database).name === \"sqlite\" ? undefined : read();\n\t\tscope = { ledger, catalog, read, users: 0, stamps: undefined, restamp: new Map() };\n\t\tscopes.set(database, scope);\n\t}\n\tconst shared = scope;\n\tconst handles = [database, ...views.filter((view) => !scopes.has(view))];\n\tfor (const handle of handles.slice(1)) scopes.set(handle, shared);\n\tshared.users += 1;\n\ttry {\n\t\tconst value = await body();\n\t\tif (shared.users === 1 && shared.restamp.size > 0) await restamp(database, shared);\n\t\treturn value;\n\t} finally {\n\t\tshared.users -= 1;\n\t\tfor (const handle of handles.slice(1)) if (scopes.get(handle) === shared) scopes.delete(handle);\n\t\tif (shared.users === 0 && scopes.get(database) === shared) scopes.delete(database);\n\t}\n}\n\n/**\n * Drops the catalog an open of `database` in progress read, so the next question reads the schema again: for a step of\n * the open that changed the schema the stores it opens after it ask about.\n */\nexport function refreshStorageSchemaCatalog(database: SqliteDatabase): void {\n\tconst scope = scopes.get(database);\n\tif (scope !== undefined) scope.catalog = undefined;\n}\n\n/**\n * Tells the catalog an open of `database` in progress read that the open created `tables` since, so the stores it\n * opens next find them without reading the schema again.\n */\nexport function noteStorageSchemaTables(database: SqliteDatabase, tables: readonly string[]): void {\n\tconst scope = scopes.get(database);\n\tif (scope?.catalog === undefined) return;\n\tconst identifier = dialectOf(database).identifier;\n\tconst created = new Set(tables.map((table) => identifier(table)));\n\tscope.catalog = scope.catalog.then(\n\t\t(catalog) =>\n\t\t\tcatalog && {\n\t\t\t\t...catalog,\n\t\t\t\thasTable: (table) => created.has(identifier(table)) || catalog.hasTable(table),\n\t\t\t\thasObject: (name) => created.has(identifier(name)) || catalog.hasObject(name),\n\t\t\t},\n\t);\n}\n\n/**\n * The catalog an open of `database` in progress read ({@link withStorageSchemaCatalog}), when it read `ledger`'s\n * versions or no `ledger` is named; undefined outside such an open, and when it could not be read.\n */\nexport async function schemaCatalogOf(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || (ledger !== undefined && scope.ledger !== ledger)) return undefined;\n\tscope.catalog ??= scope.read();\n\treturn scope.catalog;\n}\n\n/**\n * @internal The revisions the stamps under `ledger` record for the stores of `database` (SQLite and libSQL), by stamp\n * key (`schema:<domain>`), as the open of `database` in progress read them; only those whose schema version was the\n * database's then. Undefined outside such an open, and where none could be read, such as before any stamp. The first\n * question reads them after the open's catalog, and only where it holds their table.\n */\nexport async function sqliteSchemaStampsOf(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<ReadonlyMap<string, number> | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger || dialectOf(database).name !== \"sqlite\") return undefined;\n\t// Read once the catalog shows their table: a read of a missing table would fail, which costs a request, and makes a\n\t// libSQL file driver replace its connection.\n\tscope.stamps ??= schemaCatalogOf(database, ledger).then((catalog) =>\n\t\tcatalog?.hasTable(sqliteSchemaStampTable(ledger)) === true\n\t\t\t? readSqliteSchemaStamps(database, ledger).then(\n\t\t\t\t\t(read) => read,\n\t\t\t\t\t() => undefined,\n\t\t\t\t)\n\t\t\t: undefined,\n\t);\n\treturn scope.stamps;\n}\n\n/**\n * @internal Tells the open of `database` in progress that it checked `setup`, the schema setup `stamp` names, without\n * its stamp (SQLite and libSQL only): it ran it in a transaction that stamped it, found every object it creates in the\n * catalog (with `verify`), or leaves it to the end (`deferred`). A schema change later in the same open, such as the\n * next store's setup or a column it adds, leaves a stamp behind the schema version, and a store found in the catalog has\n * none that is current, so the next open would check it again. The open's end reads the stamps once more and, where any\n * of these is behind, checks or runs them in one transaction and stamps them all with the version it leaves: the next\n * open of a current schema then takes no write lock and answers every such store from its stamp (#6560). False, and\n * nothing is kept, outside such an open: the caller then runs `setup` as it would without stamps.\n */\nexport function restampStorageSchemaAtOpenEnd(\n\tdatabase: SqliteDatabase,\n\tstamp: SqliteSchemaStamp,\n\tsetup: (tx: SqliteExecutor) => Promise<unknown>,\n\toptions: SchemaStampAtOpenEnd = {},\n): boolean {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== stamp.ledger || dialectOf(database).name !== \"sqlite\") return false;\n\tscope.restamp.set(stamp.domain, { stamp, setup, ...options });\n\treturn true;\n}\n\n/**\n * Stamps again, in one transaction, the setups `scope`'s open checked whose stamps are behind: each with `verify` is\n * checked against the catalog the transaction reads, and runs where that finds something missing; each without runs.\n * Every deferred setup runs, and fails the open where the transaction fails. Otherwise housekeeping: a failure leaves the\n * stamps behind, and the next open checks those stores as it would without them.\n */\nasync function restamp(database: SqliteDatabase, scope: CatalogScope): Promise<void> {\n\tconst pending = [...scope.restamp.values()];\n\tscope.restamp.clear();\n\tif (pending.every((each) => each.alongside === true)) return;\n\tconst deferred = pending.some((each) => each.deferred === true);\n\ttry {\n\t\t// Every setup this open checked was behind when it began. Where each is deferred or checked against the catalog,\n\t\t// the end's transaction checks it again anyway, so the stamps are not read again; otherwise they are, to spare an\n\t\t// open that changed nothing since its setups a transaction. None where no setup made the table yet.\n\t\tconst reread = pending.some((each) => each.deferred !== true && each.verify === undefined);\n\t\tconst current = reread\n\t\t\t? await readSqliteSchemaStamps(database, scope.ledger).catch(() => new Map<string, number>())\n\t\t\t: new Map<string, number>();\n\t\tconst behind = pending.filter(\n\t\t\t({ stamp, deferred }) => deferred === true || (current.get(stampKey(stamp.domain)) ?? 0) < stamp.revision,\n\t\t);\n\t\tif (behind.length === 0) return;\n\t\tconst table = sqliteSchemaStampTable(scope.ledger);\n\t\tawait database.transaction(\n\t\t\tasync (tx) => {\n\t\t\t\tconst catalog = await readSqliteCatalog(tx, scope.ledger);\n\t\t\t\tfor (const { setup, verify, deferred } of behind)\n\t\t\t\t\tif (deferred === true || verify === undefined || catalog === undefined || !verify(catalog))\n\t\t\t\t\t\tawait setup(tx);\n\t\t\t\tawait recordSqliteSchemaStamps(\n\t\t\t\t\ttx,\n\t\t\t\t\tbehind.map(({ stamp }) => stamp),\n\t\t\t\t\t{ tableExists: catalog?.hasTable(table) === true, last: true },\n\t\t\t\t);\n\t\t\t},\n\t\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: scope.ledger } },\n\t\t);\n\t} catch (error) {\n\t\tif (deferred) throw error;\n\t\t// The next open checks them again.\n\t}\n}\n"]}
@@ -500,7 +500,7 @@ function __atomicOnDemandFailed(error, feature) {
500
500
  return (async () => {
501
501
  const root = new URL("../../", import.meta.url);
502
502
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
503
- const key = `${root.href}#0.10.11-alpha.1`;
503
+ const key = `${root.href}#0.10.11-alpha.2`;
504
504
  let release = releases.get(key);
505
505
  if (release === undefined) {
506
506
  const current = (async () => {
@@ -528,7 +528,7 @@ function __atomicOnDemandFailed(error, feature) {
528
528
  } catch {
529
529
  // No installation to read, as in a bundle of the package: the release the process runs decides.
530
530
  }
531
- const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.1" ? installed : running !== undefined && running.version !== "0.10.11-alpha.1" ? "0.10.11-alpha.1" : undefined;
531
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
532
532
  if (updatedTo === undefined) throw error;
533
533
  const application = typeof running?.name === "string" ? running.name : "atomic";
534
534
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
@@ -1,6 +1,6 @@
1
1
  import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
2
  import { createLabelEntry, historyPages, readSessionHistoryChunks } from "../../../_shared/startup-8-0-34CBHPZH.js";
3
- import { SESSION_HISTORY_SCAN_ENTRIES, SessionEntryError } from "../../../_shared/settings-startup-4QCVCI53.js";
3
+ import { SESSION_HISTORY_SCAN_ENTRIES, SessionEntryError } from "../../../_shared/settings-startup-HXQLSUWM.js";
4
4
  // dist/core/storage/session/branch-fork-source.js
5
5
  /** The row of `item`, which the stream read from session `id` and yields as the source stores it. */
6
6
  async function forkRow(reader, id, item) {
@@ -21,14 +21,15 @@ async function forkRow(reader, id, item) {
21
21
  }
22
22
  /** The SDK/CLI same-store clone keeps the original append log, including abandoned branches,
23
23
  * raw labels and recorded leaf moves. Unlike an interactive /fork it never edits structural links. */
24
- function completeSessionForkStream(id, epoch, through, resident) {
24
+ function completeSessionForkStream(id, epoch, through) {
25
25
  return {
26
26
  kind: "complete-session",
27
+ prefix: {
28
+ sessionId: id,
29
+ epoch,
30
+ through
31
+ },
27
32
  async *read(reader, _hasWritten, inlineSnapshot) {
28
- if (resident) {
29
- for (const entry of resident) yield { entry };
30
- return;
31
- }
32
33
  for await (const { items } of historyPages(reader, id, epoch, through, { pageEntries: SESSION_HISTORY_SCAN_ENTRIES })) for (const item of items) {
33
34
  if ("kind" in item && inlineSnapshot) {
34
35
  const entry = await inlineSnapshot(item);
@@ -126,7 +127,7 @@ function __atomicOnDemandFailed(error, feature) {
126
127
  return (async () => {
127
128
  const root = new URL("../../../", import.meta.url);
128
129
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
129
- const key = `${root.href}#0.10.11-alpha.1`;
130
+ const key = `${root.href}#0.10.11-alpha.2`;
130
131
  let release = releases.get(key);
131
132
  if (release === undefined) {
132
133
  const current = (async () => {
@@ -154,7 +155,7 @@ function __atomicOnDemandFailed(error, feature) {
154
155
  } catch {
155
156
  // No installation to read, as in a bundle of the package: the release the process runs decides.
156
157
  }
157
- const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.1" ? installed : running !== undefined && running.version !== "0.10.11-alpha.1" ? "0.10.11-alpha.1" : undefined;
158
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
158
159
  if (updatedTo === undefined) throw error;
159
160
  const application = typeof running?.name === "string" ? running.name : "atomic";
160
161
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
@@ -1 +1 @@
1
- {"version":3,"file":"branch-fork-source.code.js","names":[],"sources":["../../../../src/core/storage/session/branch-fork-source.ts"],"mappings":";;;;;AAaA,eAAe,QAAQ,QAAsB,IAAY,MAAwB;CAChF,MAAM,SAAS;EAAE,WAAW;EAAI,KAAK,KAAK;CAAG;CAC7C,IAAI,WAAW,MAAM,OAAO;EAAE,OAAO,KAAK;EAAO;CAAM;CACvD,MAAM,EAAE,mBAAmB,MAAM,OAAO;CACxC,OAAO;EAAE,GAAI,MAAM,qBAAqB,yBAAyB,QAAQ,IAAI,CAAC;EAAI,WAAW;EAAM;CAAM;AAC1G;;;AAIA,SAAgB,0BACf,IACA,OACA,SACA,UAAkC;CAElC,OAAO;EACN,MAAM;EACN,OAAO,KAAK,QAAQ,aAAa,gBAAc;GAG9C,IAAI,UAAU;IACb,KAAK,MAAM,SAAS,UAAU,MAAM,EAAE,MAAK;IAC3C;GACD;GAEA,WAAW,MAAM,EAAE,WAAW,aAAa,QAAQ,IAAI,OAAO,SAAS,EACtE,aAAa,6BACb,CAAA,GACA,K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AM,WAAW,EAAE,EAAE,GAC3B,IAAI,iBAAiB,QAAQ,uBAAO,IAAI,IAAG,GAAI,UAAU,WAAW,IAAI,MAAM,CAAC;GAChF,WAAW,EAAE;GACb,MAAM,EAAE,OAAO,EAAC;EACjB;CACD,EACA;AACF"}
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -1,9 +1,9 @@
1
1
  import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
- import { ChildCatalog } from "../../../_shared/startup-0-1-GIY75K46.js";
2
+ import { ChildCatalog } from "../../../_shared/startup-0-1-7T2IAE7J.js";
3
3
  import { SessionConflictError } from "./errors.js";
4
4
  import { historyChunks, historyPages, readSessionRange } from "../../../_shared/startup-8-0-34CBHPZH.js";
5
5
  import { treeOutlinePages } from "../../../_shared/tree-outline-MUEPK5B7.js";
6
- import "../../../_shared/settings-startup-4QCVCI53.js";
6
+ import "../../../_shared/settings-startup-HXQLSUWM.js";
7
7
  // dist/core/storage/session/child-reader.js
8
8
  async function* headings(store, id, epoch, through, seqs, signal) {
9
9
  for (let at = 0; at < seqs.length;) {
@@ -99,7 +99,7 @@ function __atomicOnDemandFailed(error, feature) {
99
99
  return (async () => {
100
100
  const root = new URL("../../../", import.meta.url);
101
101
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
102
- const key = `${root.href}#0.10.11-alpha.1`;
102
+ const key = `${root.href}#0.10.11-alpha.2`;
103
103
  let release = releases.get(key);
104
104
  if (release === undefined) {
105
105
  const current = (async () => {
@@ -127,7 +127,7 @@ function __atomicOnDemandFailed(error, feature) {
127
127
  } catch {
128
128
  // No installation to read, as in a bundle of the package: the release the process runs decides.
129
129
  }
130
- const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.1" ? installed : running !== undefined && running.version !== "0.10.11-alpha.1" ? "0.10.11-alpha.1" : undefined;
130
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
131
131
  if (updatedTo === undefined) throw error;
132
132
  const application = typeof running?.name === "string" ? running.name : "atomic";
133
133
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -1,5 +1,5 @@
1
1
  import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
- import "../../../_shared/settings-startup-4QCVCI53.js";
2
+ import "../../../_shared/settings-startup-HXQLSUWM.js";
3
3
  // dist/core/storage/session/errors.js
4
4
  var SessionFormatVersionError = class extends Error {
5
5
  path;
@@ -2,7 +2,7 @@ import { __name } from "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
2
  import { read, skip, stringValue } from "../../../_shared/startup-0-5-YDW47QX6.js";
3
3
  import { SessionConflictError } from "./errors.js";
4
4
  import { historyChunks } from "../../../_shared/startup-8-0-34CBHPZH.js";
5
- import { SESSION_HISTORY_CHUNK_BYTES, yieldSessionTurn } from "../../../_shared/settings-startup-4QCVCI53.js";
5
+ import { SESSION_HISTORY_CHUNK_BYTES, yieldSessionTurn } from "../../../_shared/settings-startup-HXQLSUWM.js";
6
6
  // dist/core/storage/session/card-message-projection.js
7
7
  function* object(first, fields) {
8
8
  if (first.name !== "startObject") {
@@ -643,7 +643,7 @@ function __atomicOnDemandFailed(error, feature) {
643
643
  return (async () => {
644
644
  const root = new URL("../../../", import.meta.url);
645
645
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
646
- const key = `${root.href}#0.10.11-alpha.1`;
646
+ const key = `${root.href}#0.10.11-alpha.2`;
647
647
  let release = releases.get(key);
648
648
  if (release === undefined) {
649
649
  const current = (async () => {
@@ -671,7 +671,7 @@ function __atomicOnDemandFailed(error, feature) {
671
671
  } catch {
672
672
  // No installation to read, as in a bundle of the package: the release the process runs decides.
673
673
  }
674
- const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.1" ? installed : running !== undefined && running.version !== "0.10.11-alpha.1" ? "0.10.11-alpha.1" : undefined;
674
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
675
675
  if (updatedTo === undefined) throw error;
676
676
  const application = typeof running?.name === "string" ? running.name : "atomic";
677
677
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Detaching lazy forks from a session (Neon's detach_ancestor). A fork in a SQL store reads the rows it inherited
3
+ * through segments that point at the sessions owning them, which keep those rows while any segment points at them. To
4
+ * really delete or rewrite such a session, every fork still pointing at it first gets its own copy of those rows:
5
+ *
6
+ * 1. Block: the segments pin the parent's rows, and a progress row records the detach and the child's original map.
7
+ * 2. Copy: a page of the parent's rows moves into the child at the global seqs the segment gave them, and in the same
8
+ * transaction the segment shrinks past them, so every seq is covered by a segment or by a row of the child's own,
9
+ * never both, and the child reads the same at every commit.
10
+ * 3. Publish: each page commits; the segments are the progress, so a crash resumes with the segments that remain.
11
+ * 4-6. The last page also removes the child's last segment on the parent, re-points at the child's copy each other
12
+ * fork of the parent that reads only rows the child's prefix holds (its cut-off at or below the child's), and
13
+ * removes the progress row, in one transaction.
14
+ *
15
+ * A detach locks the sessions whose segments it changes for update, in ID order, and never the parent. The store's
16
+ * delete and replace lock a session for update before they list the references to it, and a fork locks every session
17
+ * its segments name for key share, so neither misses a reference another transaction is adding. Re-pointing a fork at
18
+ * the child adds a reference to the child, which the detach already holds for update. Locking the parent instead
19
+ * would deadlock against the parent's replace, which holds the parent's row while it waits for its forks' rows.
20
+ */
21
+ import type { SqliteExecutor } from "../database.js";
22
+ import { type ForkSegment } from "./fork-segments.js";
23
+ export declare function setForkCopyRefusalNote(note: (fields: Readonly<Record<string, string | number>>) => void): void;
24
+ /** Notes `error` once when it is a refused copy of shared rows; resolves nothing and never throws. */
25
+ export declare function noteForkCopyRefusal(error: unknown, operation: string): void;
26
+ /** Rows a detach copies in one transaction, which bounds how long it holds the write lock. */
27
+ export declare const FORK_DETACH_PAGE_ROWS = 2000;
28
+ /** The tables a session's stored rows are in, and the tombstones of deleted sessions forks still read. */
29
+ export interface ForkPinTables {
30
+ readonly entries: string;
31
+ readonly entryChunks: string;
32
+ readonly searchTexts: string;
33
+ readonly blobs: string;
34
+ readonly blobChunks: string;
35
+ readonly tombstones: string;
36
+ readonly forkSegments: string;
37
+ readonly forkLineage: string;
38
+ }
39
+ /** What a SQL session store gives detach: its fork segments, and transactions to change them in. */
40
+ export interface ForkDetachHost {
41
+ readonly pinTables: ForkPinTables;
42
+ /** `<prefix>session_fork_detach`, created with the other fork tables: detaches in progress. */
43
+ readonly forkDetachTable: string;
44
+ /** Runs `body` in one write transaction of the store. */
45
+ forkTransaction<T>(body: (tx: SqliteExecutor) => Promise<T>): Promise<T>;
46
+ /** The session's segments, ordered by `baseSeq`. */
47
+ forkSegments(tx: SqliteExecutor, sessionId: string): Promise<readonly ForkSegment[]>;
48
+ /** The sessions with a segment pointing at `sourceId`, ordered by ID. */
49
+ forkChildren(tx: SqliteExecutor, sourceId: string): Promise<readonly string[]>;
50
+ /**
51
+ * Copies the rows `pieces` map, in seq order with their chunks, search texts and blobs, into the child at the seqs of
52
+ * its view they cover, then removes them from the child's segments. Each piece lies within one of the child's
53
+ * segments, so the child's view is the same before and after.
54
+ */
55
+ materializeForkSegments(tx: SqliteExecutor, childId: string, pieces: readonly ForkSegment[]): Promise<void>;
56
+ /** Replaces the session's segments with `segments`, and moves its fork generation on. */
57
+ writeForkSegments(tx: SqliteExecutor, sessionId: string, segments: readonly ForkSegment[]): Promise<void>;
58
+ /**
59
+ * Locks the sessions `ids` in ID order: `key-share` to add a reference to them (which leaves their appends free),
60
+ * `update` to drop one they hold or to delete them.
61
+ */
62
+ lockForkSources(tx: SqliteExecutor, ids: readonly string[], mode: "key-share" | "update"): Promise<void>;
63
+ /** The clause that locks the rows a read selects, for update or for key share; none where writers run one at a time. */
64
+ lockClause(mode: "key-share" | "update"): string;
65
+ /** The session's rewrite epoch, which a replace or a truncation changes and an append does not. */
66
+ forkRewriteEpoch(tx: SqliteExecutor, sessionId: string): Promise<string | undefined>;
67
+ }
68
+ export interface ForkDetachOptions {
69
+ /** Re-point the parent's other forks at the child's copy of the rows it holds. Default true. */
70
+ readonly reparent?: boolean;
71
+ /** Rows copied a transaction. Default {@link FORK_DETACH_PAGE_ROWS}. */
72
+ readonly pageRows?: number;
73
+ }
74
+ export interface ForkDetachReport {
75
+ /** Forks that copied the parent's rows they read. */
76
+ readonly detached: readonly string[];
77
+ /** Forks re-pointed at a detached fork's copy instead. */
78
+ readonly reparented: readonly string[];
79
+ }
80
+ interface DetachProgress {
81
+ readonly reparent: boolean;
82
+ /** The child's segments on the parent when the detach started: where its copy of each parent row is. */
83
+ readonly original: readonly ForkSegment[];
84
+ /**
85
+ * The parent's and the child's rewrite epochs when the detach started. `original` describes the child's rows only
86
+ * while neither was rewritten: a rewritten parent's seq is another row, a rewritten child's row is another row.
87
+ */
88
+ readonly epochs: readonly [string | undefined, string | undefined];
89
+ }
90
+ /** The forks whose segments name `sessionId`, after locking it for update. */
91
+ export declare function lockedReferrers(host: ForkDetachHost, tx: SqliteExecutor, sessionId: string): Promise<readonly string[]>;
92
+ /** Removes the rows a session stores and its tombstone: nothing names them, and the session is gone or replaced. */
93
+ export declare function removeStoredRows(host: ForkDetachHost, tx: SqliteExecutor, sessionId: string): Promise<void>;
94
+ export declare function isTombstoned(host: ForkDetachHost, tx: SqliteExecutor, sessionId: string): Promise<boolean>;
95
+ /**
96
+ * Within `tx`, copies every row of `parentId` the child reads into the child and removes its segments on the parent,
97
+ * as a caller about to rewrite the parent in the same transaction needs. With `reparent`, the parent's other forks are
98
+ * re-pointed at the child's copy when it holds every row they read of the parent at the same seqs. `started` is how a detach a page at a time found
99
+ * the child when it started; its map of the child's rows holds only while neither session was rewritten since, so
100
+ * a rewrite of either skips the re-pointing, and the other forks keep reading the parent. Resolves with the forks
101
+ * re-pointed.
102
+ */
103
+ export declare function detachForkWithin(host: ForkDetachHost, tx: SqliteExecutor, parentId: string, childId: string, reparent: boolean, started?: Pick<DetachProgress, "original" | "epochs">): Promise<string[]>;
104
+ /**
105
+ * Detaches `childId` from `parentId` a page at a time, each page its own transaction; see the module comment. A detach
106
+ * a crash stopped resumes where it stopped when it runs again, with the options it started with.
107
+ */
108
+ export declare function detachFork(host: ForkDetachHost, parentId: string, childId: string, options?: ForkDetachOptions): Promise<ForkDetachReport>;
109
+ /**
110
+ * Detaches every fork still pointing at `parentId`, so the parent's rows can go: first the fork that holds most of the
111
+ * parent's rows, re-pointing the others at its copy when it holds all they read, then any fork that still reads
112
+ * rows only the parent has. Detaches a crash stopped are finished first.
113
+ */
114
+ export declare function detachForkChildren(host: ForkDetachHost, parentId: string, options?: ForkDetachOptions): Promise<ForkDetachReport>;
115
+ /** Finishes every detach a crash stopped, as each started. */
116
+ export declare function resumeForkDetaches(host: ForkDetachHost): Promise<ForkDetachReport>;
117
+ export {};
118
+ //# sourceMappingURL=fork-detach.d.ts.map
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }