@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
@@ -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
  }
@@ -0,0 +1,53 @@
1
+ import { renderStorageIdentifiers } from "../prefix.js";
2
+ /**
3
+ * The tables of forks that share their parent's history instead of copying it (#6560): `<prefix>session_fork_segments`,
4
+ * which maps a fork's inherited seqs onto the rows its sources store, and `<prefix>session_fork_lineage`, one row per
5
+ * such fork; `<prefix>session_fork_tombstones`, one row per deleted session whose rows forks still read, which those
6
+ * forks and the sweep that removes the rows lock; and `<prefix>session_fork_detach`, the progress of a fork copying
7
+ * the rows it read from a source into its own. They exist only in a store whose sessions schema was raised to version 3
8
+ * by the switch a store's open or `atomic storage migrate` makes once no older build runs a session there, in the same
9
+ * transaction; a store that was not switched keeps only the tables every older build reads.
10
+ */
11
+ export const SESSION_FORK_TABLES = Object.freeze({
12
+ forkSegments: "fork_segments",
13
+ forkLineage: "fork_lineage",
14
+ forkTombstones: "fork_tombstones",
15
+ forkDetach: "fork_detach",
16
+ });
17
+ /** The fork tables under `prefix`. */
18
+ export function sessionForkTables(prefix) {
19
+ return renderStorageIdentifiers("sessions", SESSION_FORK_TABLES, prefix);
20
+ }
21
+ /**
22
+ * The statements that create the fork tables, idempotently: in the transaction that raises the sessions schema to the
23
+ * version that turns shared-history forks on, or in the one that creates a new database's sessions schema at that
24
+ * version. `generation` is a token that changes with every change to a fork's segments and never repeats for an id, so
25
+ * a reader's cached segments are keyed by it.
26
+ */
27
+ export function sharedHistoryTablesScript(dialect, tables) {
28
+ const { int, text } = dialect.types;
29
+ return `
30
+ CREATE TABLE IF NOT EXISTS ${tables.forkSegments} (
31
+ session_id ${text} NOT NULL, idx ${int} NOT NULL, source_id ${text} NOT NULL,
32
+ from_seq ${int} NOT NULL, to_seq ${int} NOT NULL, base_seq ${int} NOT NULL,
33
+ PRIMARY KEY(session_id, idx)
34
+ )${dialect.tableOptions};
35
+ CREATE INDEX IF NOT EXISTS ${tables.forkSegments}_source ON ${tables.forkSegments} (source_id);
36
+ CREATE TABLE IF NOT EXISTS ${tables.forkLineage} (
37
+ session_id ${text} NOT NULL PRIMARY KEY, parent_id ${text}, cut_seq ${int}, generation ${text} NOT NULL
38
+ )${dialect.tableOptions};
39
+ CREATE TABLE IF NOT EXISTS ${tables.forkTombstones} (
40
+ session_id ${text} NOT NULL PRIMARY KEY, deleted_at ${text} NOT NULL
41
+ )${dialect.tableOptions};
42
+ CREATE TABLE IF NOT EXISTS ${tables.forkDetach} (
43
+ parent_id ${text} NOT NULL, child_id ${text} NOT NULL, reparent ${int} NOT NULL,
44
+ original_segments ${text} NOT NULL, parent_epoch ${text}, child_epoch ${text},
45
+ PRIMARY KEY(parent_id, child_id)
46
+ )${dialect.tableOptions};
47
+ `;
48
+ }
49
+ /** Creates the fork tables in `tx`: see {@link sharedHistoryTablesScript}. */
50
+ export async function createSharedHistoryTables(tx, dialect, tables) {
51
+ await tx.exec(sharedHistoryTablesScript(dialect, tables));
52
+ }
53
+ //# sourceMappingURL=fork-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork-schema.js","sourceRoot":"","sources":["../../../../src/core/storage/session/fork-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IAChD,YAAY,EAAE,eAAe;IAC7B,WAAW,EAAE,cAAc;IAC3B,cAAc,EAAE,iBAAiB;IACjC,UAAU,EAAE,aAAa;CACzB,CAAC,CAAC;AAIH,sCAAsC;AACtC,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAChD,OAAO,wBAAwB,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAuB,EAAE,MAAyB;IAC3F,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IACpC,OAAO;+BACuB,MAAM,CAAC,YAAY;gBAClC,IAAI,kBAAkB,GAAG,wBAAwB,IAAI;cACvD,GAAG,qBAAqB,GAAG,uBAAuB,GAAG;;KAE9D,OAAO,CAAC,YAAY;+BACM,MAAM,CAAC,YAAY,cAAc,MAAM,CAAC,YAAY;+BACpD,MAAM,CAAC,WAAW;gBACjC,IAAI,oCAAoC,IAAI,aAAa,GAAG,gBAAgB,IAAI;KAC3F,OAAO,CAAC,YAAY;+BACM,MAAM,CAAC,cAAc;gBACpC,IAAI,qCAAqC,IAAI;KACxD,OAAO,CAAC,YAAY;+BACM,MAAM,CAAC,UAAU;eACjC,IAAI,uBAAuB,IAAI,uBAAuB,GAAG;uBACjD,IAAI,2BAA2B,IAAI,iBAAiB,IAAI;;KAE1E,OAAO,CAAC,YAAY;EACvB,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,EAAkB,EAClB,OAAuB,EACvB,MAAyB;IAEzB,MAAM,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import type { SqliteExecutor } from \"../database.js\";\nimport type { StorageDialect } from \"../dialect.js\";\nimport { renderStorageIdentifiers } from \"../prefix.js\";\n\n/**\n * The tables of forks that share their parent's history instead of copying it (#6560): `<prefix>session_fork_segments`,\n * which maps a fork's inherited seqs onto the rows its sources store, and `<prefix>session_fork_lineage`, one row per\n * such fork; `<prefix>session_fork_tombstones`, one row per deleted session whose rows forks still read, which those\n * forks and the sweep that removes the rows lock; and `<prefix>session_fork_detach`, the progress of a fork copying\n * the rows it read from a source into its own. They exist only in a store whose sessions schema was raised to version 3\n * by the switch a store's open or `atomic storage migrate` makes once no older build runs a session there, in the same\n * transaction; a store that was not switched keeps only the tables every older build reads.\n */\nexport const SESSION_FORK_TABLES = Object.freeze({\n\tforkSegments: \"fork_segments\",\n\tforkLineage: \"fork_lineage\",\n\tforkTombstones: \"fork_tombstones\",\n\tforkDetach: \"fork_detach\",\n});\n\nexport type SessionForkTables = Readonly<Record<keyof typeof SESSION_FORK_TABLES, string>>;\n\n/** The fork tables under `prefix`. */\nexport function sessionForkTables(prefix?: string): SessionForkTables {\n\treturn renderStorageIdentifiers(\"sessions\", SESSION_FORK_TABLES, prefix);\n}\n\n/**\n * The statements that create the fork tables, idempotently: in the transaction that raises the sessions schema to the\n * version that turns shared-history forks on, or in the one that creates a new database's sessions schema at that\n * version. `generation` is a token that changes with every change to a fork's segments and never repeats for an id, so\n * a reader's cached segments are keyed by it.\n */\nexport function sharedHistoryTablesScript(dialect: StorageDialect, tables: SessionForkTables): string {\n\tconst { int, text } = dialect.types;\n\treturn `\n\t\tCREATE TABLE IF NOT EXISTS ${tables.forkSegments} (\n\t\t\tsession_id ${text} NOT NULL, idx ${int} NOT NULL, source_id ${text} NOT NULL,\n\t\t\tfrom_seq ${int} NOT NULL, to_seq ${int} NOT NULL, base_seq ${int} NOT NULL,\n\t\t\tPRIMARY KEY(session_id, idx)\n\t\t)${dialect.tableOptions};\n\t\tCREATE INDEX IF NOT EXISTS ${tables.forkSegments}_source ON ${tables.forkSegments} (source_id);\n\t\tCREATE TABLE IF NOT EXISTS ${tables.forkLineage} (\n\t\t\tsession_id ${text} NOT NULL PRIMARY KEY, parent_id ${text}, cut_seq ${int}, generation ${text} NOT NULL\n\t\t)${dialect.tableOptions};\n\t\tCREATE TABLE IF NOT EXISTS ${tables.forkTombstones} (\n\t\t\tsession_id ${text} NOT NULL PRIMARY KEY, deleted_at ${text} NOT NULL\n\t\t)${dialect.tableOptions};\n\t\tCREATE TABLE IF NOT EXISTS ${tables.forkDetach} (\n\t\t\tparent_id ${text} NOT NULL, child_id ${text} NOT NULL, reparent ${int} NOT NULL,\n\t\t\toriginal_segments ${text} NOT NULL, parent_epoch ${text}, child_epoch ${text},\n\t\t\tPRIMARY KEY(parent_id, child_id)\n\t\t)${dialect.tableOptions};\n\t`;\n}\n\n/** Creates the fork tables in `tx`: see {@link sharedHistoryTablesScript}. */\nexport async function createSharedHistoryTables(\n\ttx: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttables: SessionForkTables,\n): Promise<void> {\n\tawait tx.exec(sharedHistoryTablesScript(dialect, tables));\n}\n"]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Where a forked session's inherited entries live, when a fork shares its parent's stored history instead of copying it
3
+ * (#6560). Seqs are 1-based and dense in every session's view. A segment says that the view's seqs `baseSeq + 1` through
4
+ * `baseSeq + (toSeq - fromSeq + 1)` are the rows `fromSeq` through `toSeq`, inclusive, that session `sourceId` stores
5
+ * under its own id. Every seq of a view that no segment covers is a row the session stores itself, under that same seq.
6
+ *
7
+ * Segments are composed when a fork is made, so a source always stores the rows a segment names itself: reading a
8
+ * session never walks a chain of ancestors, whatever the depth of its forks.
9
+ */
10
+ export interface ForkSegment {
11
+ readonly sourceId: string;
12
+ readonly fromSeq: number;
13
+ readonly toSeq: number;
14
+ readonly baseSeq: number;
15
+ }
16
+ /** A run of a session's view in one place: view seqs `firstSeq` on are `sessionId`'s stored seqs `fromSeq` to `toSeq`. */
17
+ export interface ForkPiece {
18
+ readonly sessionId: string;
19
+ readonly fromSeq: number;
20
+ readonly toSeq: number;
21
+ readonly firstSeq: number;
22
+ }
23
+ export declare function segmentLength(segment: ForkSegment): number;
24
+ /**
25
+ * Throws unless `segments` are well formed for the view of session `sessionId`, of `length` seqs: each non-empty, within
26
+ * the view, of another session, with its source rows from seq 1 on, in view order and disjoint, and each source's rows
27
+ * in increasing order, so no stored row is read at two seqs of the view.
28
+ */
29
+ export declare function assertForkSegments(sessionId: string, segments: readonly ForkSegment[], length: number): void;
30
+ /** Where view seq `seq` of session `sessionId` is stored. */
31
+ export declare function locateForkSeq(sessionId: string, segments: readonly ForkSegment[], seq: number): {
32
+ readonly sessionId: string;
33
+ readonly seq: number;
34
+ };
35
+ /**
36
+ * The view seqs `fromSeq` through `toSeq` of session `sessionId` as runs stored in one place each, in view order: what a
37
+ * read of that range reads, one statement a piece.
38
+ */
39
+ export declare function forkPieces(sessionId: string, segments: readonly ForkSegment[], fromSeq: number, toSeq: number): ForkPiece[];
40
+ /**
41
+ * The segments a fork of session `parentId`, whose view has `parentLength` seqs and inherits `parent`, keeps when it
42
+ * takes the parent's view seqs `fromSeq` through `toSeq` as its own view seqs from `baseSeq + 1` on: the parent's own rows
43
+ * as segments of the parent, and its inherited rows as segments of their sources, so no source of the result inherits
44
+ * the rows it names. Throws when the range is not in the parent's view.
45
+ */
46
+ export declare function forkRunSegments(parentId: string, parent: readonly ForkSegment[], parentLength: number, run: {
47
+ readonly fromSeq: number;
48
+ readonly toSeq: number;
49
+ readonly baseSeq: number;
50
+ }): ForkSegment[];
51
+ /**
52
+ * `segments` with each segment that continues the one before it in both its source and its view joined to it: the same
53
+ * view in fewer segments.
54
+ */
55
+ export declare function joinForkSegments(segments: readonly ForkSegment[]): ForkSegment[];
56
+ /** The segments of a fork that keeps the first `cut` seqs of a parent's view, as a prefix of its own view. */
57
+ export declare function prefixForkSegments(parentId: string, parent: readonly ForkSegment[], parentLength: number, cut: number): ForkSegment[];
58
+ //# sourceMappingURL=fork-segments.d.ts.map
@@ -1,15 +1,15 @@
1
1
  import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
2
  import { transactionFinisher } from "../added-exports.js";
3
- import { applySessionSummaryEntries, attachCleanupCause } from "../../../_shared/startup-0-0-57KF6LZH.js";
3
+ import { applySessionSummaryEntries, attachCleanupCause } from "../../../_shared/startup-0-0-3IXNMFM2.js";
4
4
  import { SessionBlobError, StorageError } from "../errors.js";
5
5
  import { fencedPath } from "../fenced-paths.js";
6
6
  import { statementBatch } from "../statement-batches.js";
7
7
  import { SessionExistsError } from "./errors.js";
8
8
  import { encodedForkRow } from "../../../_shared/fork-row-bytes-7L76ATDA.js";
9
9
  import { foldForkRow } from "../../../_shared/fork-row-index-UAUAQRD5.js";
10
- import "../../../_shared/sdk-AVFII7NK.js";
10
+ import "../../../_shared/sdk-IQMULKFU.js";
11
11
  import { foldSessionResume, validateSessionEntries } from "../../../_shared/startup-8-0-34CBHPZH.js";
12
- import { SESSION_HISTORY_CHUNK_BYTES, SESSION_HISTORY_PAGE_BYTES } from "../../../_shared/settings-startup-4QCVCI53.js";
12
+ import { SESSION_HISTORY_CHUNK_BYTES, SESSION_HISTORY_PAGE_BYTES } from "../../../_shared/settings-startup-HXQLSUWM.js";
13
13
  // dist/core/storage/session/fork-staging.js
14
14
  /**
15
15
  * How long a transfer holds its rows after its last write, on the database's clock. A transfer renews it with every
@@ -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,61 @@
1
+ import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
+ import { isTombstoned, lockedReferrers } from "../../../_shared/startup-0-2-5QHPCEON.js";
3
+ // dist/core/storage/session/fork-sweep.js
4
+ /**
5
+ * Removing the rows of deleted sessions once no fork reads them (#6560). A session deleted while forks still read its
6
+ * rows leaves a tombstone; when the last of them stops reading the rows (it is deleted, replaced or detached), a sweep
7
+ * removes them, a batch per transaction, and the tombstone with the last batch. Each batch locks the tombstone and
8
+ * checks again that no fork reads the rows, so a stopped sweep leaves only a tombstone the next sweep finishes, and it
9
+ * touches no other session's rows.
10
+ *
11
+ * No fork can start reading a swept session's rows: a fork names a source only by composing the segments of the
12
+ * session it forks, and once no segment names the source, none ever will again.
13
+ */
14
+ /** Entries a sweep removes in one transaction, with their chunks and search texts. */
15
+ const FORK_SWEEP_BATCH_ENTRIES = 2e3;
16
+ /** Blobs a sweep removes in one transaction, with their chunks. */
17
+ const FORK_SWEEP_BATCH_BLOBS = 64;
18
+ /** Tombstones no fork reads any more that a sweep also finishes: ones an earlier sweep left when it stopped. */
19
+ const LEFTOVER_TOMBSTONES = 16;
20
+ /** One batch of the sweep of `sessionId`: whether the tombstone is gone, still read, or has rows left. */
21
+ async function sweepBatch(host, tx, sessionId, entries) {
22
+ if (!await isTombstoned(host, tx, sessionId)) return "absent";
23
+ if ((await lockedReferrers(host, tx, sessionId)).length > 0) return "kept";
24
+ const tables = host.pinTables;
25
+ const bound = await tx.get(`SELECT seq FROM ${tables.entries} WHERE session_id = ? ORDER BY seq LIMIT 1 OFFSET ?`, sessionId, entries - 1);
26
+ for (const table of [
27
+ tables.entryChunks,
28
+ tables.searchTexts,
29
+ tables.entries
30
+ ]) await (bound === void 0 ? tx.run(`DELETE FROM ${table} WHERE session_id = ?`, sessionId) : tx.run(`DELETE FROM ${table} WHERE session_id = ? AND seq <= ?`, sessionId, Number(bound.seq)));
31
+ if (bound !== void 0) return "more";
32
+ const hashes = (await tx.all(`SELECT hash FROM ${tables.blobs} WHERE session_id = ? UNION SELECT hash FROM ${tables.blobChunks} WHERE session_id = ? ORDER BY hash LIMIT ?`, sessionId, sessionId, FORK_SWEEP_BATCH_BLOBS)).map((row) => String(row.hash));
33
+ if (hashes.length > 0) {
34
+ const list = hashes.map(() => "?").join(", ");
35
+ for (const table of [tables.blobChunks, tables.blobs]) await tx.run(`DELETE FROM ${table} WHERE session_id = ? AND hash IN (${list})`, sessionId, ...hashes);
36
+ if (hashes.length === FORK_SWEEP_BATCH_BLOBS) return "more";
37
+ }
38
+ await tx.run(`DELETE FROM ${tables.tombstones} WHERE session_id = ?`, sessionId);
39
+ return "done";
40
+ }
41
+ /**
42
+ * Removes the rows of the tombstones `sessionIds` that no fork reads any more, and of up to a few others an earlier
43
+ * sweep left, a batch per transaction. A tombstone a fork still reads is kept. Resolves with the sessions removed.
44
+ */
45
+ async function sweepForkTombstones(host, sessionIds = [], options = {}) {
46
+ const entries = Math.max(1, Math.floor(options.batchEntries ?? 2e3));
47
+ const tables = host.pinTables;
48
+ const leftover = await host.forkTransaction((tx) => tx.all(`SELECT session_id FROM ${tables.tombstones} t WHERE NOT EXISTS (SELECT 1 FROM ${tables.forkSegments} s WHERE s.source_id = t.session_id) ORDER BY session_id LIMIT ?`, LEFTOVER_TOMBSTONES));
49
+ const swept = [];
50
+ for (const sessionId of /* @__PURE__ */ new Set([...sessionIds, ...leftover.map((row) => String(row.session_id))])) {
51
+ let outcome;
52
+ do
53
+ outcome = await host.forkTransaction((tx) => sweepBatch(host, tx, sessionId, entries));
54
+ while (outcome === "more");
55
+ if (outcome === "done") swept.push(sessionId);
56
+ }
57
+ return swept;
58
+ }
59
+ export { FORK_SWEEP_BATCH_ENTRIES, sweepForkTombstones };
60
+
61
+ //# sourceMappingURL=fork-sweep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork-sweep.js","names":[],"sources":["../../../../src/core/storage/session/fork-sweep.ts"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,2BAA2B;;AAExC,MAAM,yBAAyB;;AAE/B,MAAM,sBAAsB;;AAG5B,eAAe,WACd,MACA,IACA,WACA,SAAe;CAEf,IAAI,CAAE,MAAM,aAAa,MAAM,IAAI,SAAS,GAAI,OAAO;CACvD,KAAK,MAAM,gBAAgB,MAAM,IAAI,SAAS,EAAA,CAAG,SAAS,GAAG,OAAO;CACpE,MAAM,SAAS,KAAK;CACpB,MAAM,QAAQ,MAAM,GAAG,IACtB,mBAAmB,OAAO,QAAO,sDACjC,WACA,UAAU,CAAC;CAEZ,KAAK,MAAM,SAAS;EAAC,OAAO;EAAa,OAAO;EAAa,OAAO;CAAO,GAC1E,OAAO,UAAU,KAAA,IACd,GAAG,IAAI,eAAe,MAAK,wBAAyB,SAAS,IAC7D,GAAG,IAAI,eAAe,MAAK,qCAAsC,WAAW,OAAO,MAAM,GAAG,CAAC;CACjG,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,UACL,MAAM,GAAG,IACR,oBAAoB,OAAO,MAAK,+CAAgD,OAAO,WAAU,8CACjG,WACA,WACA,sBAAsB,EAAA,CAEtB,KAAK,QAAQ,OAAO,IAAI,IAAI,CAAC;CAC/B,IAAI,OAAO,SAAS,GAAG;EACtB,MAAM,OAAO,OAAO,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI;EAC5C,KAAK,MAAM,SAAS,CAAC,OAAO,YAAY,OAAO,KAAK,GACnD,MAAM,GAAG,IAAI,eAAe,MAAK,qCAAsC,KAAI,IAAK,WAAW,GAAG,MAAM;EACrG,IAAI,OAAO,WAAW,wBAAwB,OAAO;CACtD;CACA,MAAM,GAAG,IAAI,eAAe,OAAO,WAAU,wBAAyB,SAAS;CAC/E,OAAO;AACR;;;;;AAMA,eAAsB,oBACrB,MACA,aAA+B,CAAA,GAC/B,UAA8C,CAAA,GAAE;CAEhD,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,gBAAA,GAAwC,CAAC;CACxF,MAAM,SAAS,KAAK;CACpB,MAAM,WAAW,MAAM,KAAK,iBAAiB,OAC5C,GAAG,IACF,0BAA0B,OAAO,WAAU,qCAAsC,OAAO,aAAY,mEACpG,mBAAmB,CACnB;CAEF,MAAM,QAAkB,CAAA;CACxB,KAAK,MAAM,6BAAa,IAAI,IAAI,CAAC,GAAG,YAAY,GAAG,SAAS,KAAK,QAAQ,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG;EACnG,IAAI;EACJ;GAAG,UAAU,MAAM,KAAK,iBAAiB,OAAO,WAAW,MAAM,IAAI,WAAW,OAAO,CAAC;SACjF,YAAY;EACnB,IAAI,YAAY,QAAQ,MAAM,KAAK,SAAS;CAC7C;CACA,OAAO;AACR"}
@@ -1,6 +1,6 @@
1
1
  import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
2
- import { VERBATIM_COMPACTION_PREFIX, convertToLlm, legacyCompletionTarget, resolvesCompletionHeader, verbatimRecallHint } from "../../../_shared/startup-0-1-GIY75K46.js";
3
- import { buildSessionProjection, getBranchPath } from "../../../_shared/startup-0-3-T4DVFYWX.js";
2
+ import { VERBATIM_COMPACTION_PREFIX, convertToLlm, legacyCompletionTarget, resolvesCompletionHeader, verbatimRecallHint } from "../../../_shared/startup-0-1-7T2IAE7J.js";
3
+ import { buildSessionProjection, getBranchPath } from "../../../_shared/startup-0-3-4ZYBYQNM.js";
4
4
  import { branchRanges, completionIdOf, intentForAcknowledgement, isBranchCustomState, isExtensionCustomState, latestCompactionOf } from "../../../_shared/startup-8-0-34CBHPZH.js";
5
5
  // dist/core/storage/session/fork-window.js
6
6
  function forkMetadata(seq, entry) {
@@ -481,7 +481,7 @@ function __atomicOnDemandFailed(error, feature) {
481
481
  return (async () => {
482
482
  const root = new URL("../../../", import.meta.url);
483
483
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
484
- const key = `${root.href}#0.10.11-alpha.1`;
484
+ const key = `${root.href}#0.10.11-alpha.2`;
485
485
  let release = releases.get(key);
486
486
  if (release === undefined) {
487
487
  const current = (async () => {
@@ -509,7 +509,7 @@ function __atomicOnDemandFailed(error, feature) {
509
509
  } catch {
510
510
  // No installation to read, as in a bundle of the package: the release the process runs decides.
511
511
  }
512
- 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;
512
+ 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;
513
513
  if (updatedTo === undefined) throw error;
514
514
  const application = typeof running?.name === "string" ? running.name : "atomic";
515
515
  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
  }
@@ -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
  }
@@ -34,6 +34,10 @@ export declare class JsonlSessionStore implements SessionStore {
34
34
  private selectedFile?;
35
35
  [bindSessionFile](id: string, path: string): void;
36
36
  private queue;
37
+ /** Operations queued so far, counted so an append joins only a group that is still the last thing queued. */
38
+ private queued;
39
+ private appendGroup;
40
+ private readonly keptFiles;
37
41
  private closed;
38
42
  private poisoned;
39
43
  private readonly directory;
@@ -65,9 +69,23 @@ export declare class JsonlSessionStore implements SessionStore {
65
69
  get descriptor(): StorageDescriptor;
66
70
  create(header: SessionRecordHeader, entries: readonly SessionEntry[], location?: string): Promise<SessionWriteResult>;
67
71
  createFork(header: SessionRecordHeader, entries: SessionForkSeed, source: ForkArchiveSource, location?: string): Promise<SessionWriteResult | undefined>;
72
+ /**
73
+ * Appends made while an earlier one waits its turn join it and commit together, as a LevelDB log writer's queue does:
74
+ * under one lock, each is checked against the session as the appends before it leave it, and each file gets one write
75
+ * of all their lines. Every append is answered once its lines are written and the lock is released, as it was alone,
76
+ * and one that conflicts or fails validation rejects alone. Nothing is synced, as before.
77
+ */
68
78
  append(sessionId: string, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<{
69
79
  readonly lastSeq: number;
70
80
  }>;
81
+ private commitAppends;
82
+ /** Checks one append against its session as the appends staged before it leave it, and stages its lines. */
83
+ private stageAppend;
84
+ /**
85
+ * Writes the lines staged for `file` through its kept handle, then decides the appends they came from: false when the
86
+ * write failed and they fail. A failed write is cut off again; when that fails too the store is poisoned.
87
+ */
88
+ private writeStaged;
71
89
  replace(sessionId: string, header: SessionRecordHeader, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<SessionWriteResult>;
72
90
  updateHeader(header: SessionRecordHeader, options: SessionWriteOptions): Promise<SessionWriteResult>;
73
91
  private commit;
@@ -154,7 +172,21 @@ export declare class JsonlSessionStore implements SessionStore {
154
172
  readonly includeInternal?: boolean;
155
173
  }): Promise<SessionSummary | undefined>;
156
174
  close(): Promise<void>;
175
+ /** Closes the handles kept for the session's files: nothing live writes it any more. */
176
+ releaseSession(sessionId: string): Promise<void>;
177
+ /**
178
+ * The handle kept open to append to the file at `path`, opened when there is none for the file `identity` names. It
179
+ * is used only while the caller holds the directory lock and has found that the path still names that file.
180
+ */
181
+ private keptFile;
182
+ /** The kept handle of the file at `path`, while it is the file `identity` names, to read through. */
183
+ private keptFor;
184
+ private closeKept;
185
+ /** Closes the handle once it goes unused for {@link KEPT_FILE_IDLE_MS}, between two of this store's operations. */
186
+ private armIdle;
157
187
  private run;
188
+ /** What an operation rejects with for `cause`: the session errors as they are, any other as the store unavailable. */
189
+ private failure;
158
190
  private exclusive;
159
191
  /**
160
192
  * Releases the lock. The directory removal is retried when Windows refuses it for a moment. If it never
@@ -190,8 +222,12 @@ export declare class JsonlSessionStore implements SessionStore {
190
222
  private readEntries;
191
223
  private stamp;
192
224
  private contentState;
193
- /** Records the file as it is now; `size` ends it before a torn last line. */
225
+ /**
226
+ * Records the file as it is now; `size` ends it before a torn last line. `stats` are the file's, taken since its last
227
+ * change, when the caller has them.
228
+ */
194
229
  private remember;
230
+ private keepFileState;
195
231
  /**
196
232
  * Foreign appends read only the header, at most 64 known boundary bytes, and new bytes.
197
233
  * The witness detects a changed append boundary, not arbitrary edits in old history.
@@ -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
  }