@bastani/atomic 0.10.10 → 0.10.11-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +1 -1
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +8 -10
  7. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  8. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +6 -6
  9. package/dist/_shared/mode-shared-2QJSCUM6.js +52 -15
  10. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  12. package/dist/_shared/runtime-O4KCSG4C.js +3 -3
  13. package/dist/_shared/{sdk-RRLVN7ER.js → sdk-AVFII7NK.js} +757 -233
  14. package/dist/_shared/sdk-AVFII7NK.js.map +1 -0
  15. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  16. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  17. package/dist/_shared/{startup-0-0-4VG2G44V.js → startup-0-0-57KF6LZH.js} +94 -42
  18. package/dist/_shared/startup-0-0-57KF6LZH.js.map +1 -0
  19. package/dist/_shared/{startup-0-1-XTIL65D4.js → startup-0-1-GIY75K46.js} +75 -13
  20. package/dist/_shared/startup-0-1-GIY75K46.js.map +1 -0
  21. package/dist/_shared/startup-0-2-27OWFHV6.js +72 -7
  22. package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -1
  23. package/dist/_shared/startup-0-3-T4DVFYWX.js +4 -4
  24. package/dist/_shared/startup-0-4-ZMJV547D.js +4 -4
  25. package/dist/_shared/{startup-0-5-FD2P735I.js → startup-0-5-YDW47QX6.js} +27 -69
  26. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -0
  27. package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
  28. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  29. package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
  30. package/dist/_shared/startup-15-0-YUKGAC63.js +31 -7
  31. package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
  32. package/dist/_shared/startup-15-1-4S7FLMNG.js +7 -6
  33. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  34. package/dist/_shared/startup-8-0-34CBHPZH.js +4 -4
  35. package/dist/_shared/{startup-8-1-4KANEHRA.js → startup-8-1-X32CYSXB.js} +1219 -714
  36. package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -0
  37. package/dist/_shared/storage-command-7MGXLJGZ.js +14 -8
  38. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  39. package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
  40. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  41. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  42. package/dist/builtin/intercom/CHANGELOG.md +18 -0
  43. package/dist/builtin/intercom/broker/broker.bundle.mjs +993 -362
  44. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +103 -24
  45. package/dist/builtin/intercom/broker/multinode-router.ts +42 -21
  46. package/dist/builtin/intercom/broker/multinode-state-store.ts +22 -1
  47. package/dist/builtin/intercom/broker/open-broker-state.ts +82 -31
  48. package/dist/builtin/intercom/broker/paths.ts +8 -4
  49. package/dist/builtin/intercom/broker/released-asker-remote-replies.ts +18 -6
  50. package/dist/builtin/intercom/broker/sql-add-column.ts +4 -1
  51. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +65 -44
  52. package/dist/builtin/intercom/broker/sql-held-send-store.ts +11 -3
  53. package/dist/builtin/intercom/broker/sql-known-session-store.ts +24 -12
  54. package/dist/builtin/intercom/broker/sql-lease-store.ts +375 -65
  55. package/dist/builtin/intercom/broker/sql-outbox-store.ts +270 -101
  56. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +20 -9
  57. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +14 -6
  58. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +27 -11
  59. package/dist/builtin/intercom/broker/sql-schema.ts +139 -1
  60. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +97 -34
  61. package/dist/builtin/intercom/index.bundle.mjs +11 -8
  62. package/dist/builtin/intercom/package.json +1 -1
  63. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  64. package/dist/builtin/mcp/package.json +1 -1
  65. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  66. package/dist/builtin/subagents/package.json +1 -1
  67. package/dist/builtin/subagents/skills/skill-creator/SKILL.md +1 -1
  68. package/dist/builtin/subagents/src/extension/index.bundle.mjs +62 -23
  69. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  70. package/dist/builtin/web-access/package.json +1 -1
  71. package/dist/cli/args.js +2 -2
  72. package/dist/cli/auth-cli.code.js +4 -4
  73. package/dist/cli/auth-cli.impl.js +3 -3
  74. package/dist/cli/auth-cli.js +3 -3
  75. package/dist/cli/blueprint-command.code.js +3 -3
  76. package/dist/cli/blueprint-command.impl.js +3 -3
  77. package/dist/cli/blueprint-command.js +3 -3
  78. package/dist/cli/intercom-command.code.js +2 -2
  79. package/dist/cli/intercom-command.impl.js +3 -3
  80. package/dist/cli/intercom-command.js +3 -3
  81. package/dist/cli/list-models.code.js +2 -2
  82. package/dist/cli/list-models.impl.js +3 -3
  83. package/dist/cli/list-models.js +3 -3
  84. package/dist/cli/session-picker.code.js +1 -1
  85. package/dist/cli/session-picker.impl.js +3 -3
  86. package/dist/cli/session-picker.js +3 -3
  87. package/dist/cli/startup-ui.code.js +1 -1
  88. package/dist/cli/startup-ui.impl.js +3 -3
  89. package/dist/cli/startup-ui.js +3 -3
  90. package/dist/cli/storage-command.impl.js +3 -3
  91. package/dist/cli/storage-command.js +3 -3
  92. package/dist/cli/storage-search-session.code.js +3 -3
  93. package/dist/cli/storage-search-session.impl.js +3 -3
  94. package/dist/cli/storage-search-session.js +3 -3
  95. package/dist/cli/team-command.code.js +2 -2
  96. package/dist/cli/team-command.impl.js +3 -3
  97. package/dist/cli/team-command.js +3 -3
  98. package/dist/cli.js +2 -2
  99. package/dist/core/agent-session-methods.d.ts +3 -0
  100. package/dist/core/agent-session-methods.js.map +1 -1
  101. package/dist/core/agent-session.d.ts +1 -0
  102. package/dist/core/compaction/compactor.d.ts +2 -0
  103. package/dist/core/debug.impl.js +3 -3
  104. package/dist/core/debug.js +3 -3
  105. package/dist/core/export-html/card-projection.code.js +1 -1
  106. package/dist/core/export-html/card-projection.impl.js +3 -3
  107. package/dist/core/export-html/card-projection.js +3 -3
  108. package/dist/core/export-html/index.code.js +2 -2
  109. package/dist/core/export-html/index.impl.js +3 -3
  110. package/dist/core/export-html/index.js +3 -3
  111. package/dist/core/export-html/json-spans.impl.js +3 -3
  112. package/dist/core/export-html/json-spans.js +3 -3
  113. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  114. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  115. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  116. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  117. package/dist/core/export-html/tool-renderer.js +3 -3
  118. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  119. package/dist/core/extensions/jiti-loader.js +3 -3
  120. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  121. package/dist/core/extensions/jiti-static-loader.js +3 -3
  122. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  123. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  124. package/dist/core/extensions/loader-host-modules.js +3 -3
  125. package/dist/core/extensions/loader-virtual-modules.js +2 -2
  126. package/dist/core/extensions/runner-context.js +3 -3
  127. package/dist/core/extensions/runner-context.js.map +1 -1
  128. package/dist/core/intercom-broker-control-host.code.js +1 -1
  129. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  130. package/dist/core/intercom-broker-control-host.js +3 -3
  131. package/dist/core/intercom-broker-control.code.js +3 -3
  132. package/dist/core/intercom-broker-control.impl.js +3 -3
  133. package/dist/core/intercom-broker-control.js +3 -3
  134. package/dist/core/model-registry.js +1 -1
  135. package/dist/core/model-resolver-defaults.d.ts +3 -2
  136. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  137. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  138. package/dist/core/package-manager-storage-adapters.js +3 -3
  139. package/dist/core/sdk.code.js +3 -4
  140. package/dist/core/sdk.impl.js +3 -3
  141. package/dist/core/sdk.js +3 -3
  142. package/dist/core/session-manager-core.d.ts +5 -2
  143. package/dist/core/session-manager-core.js +17 -13
  144. package/dist/core/session-manager-core.js.map +1 -1
  145. package/dist/core/session-manager-list.impl.js +3 -3
  146. package/dist/core/session-manager-list.js +3 -3
  147. package/dist/core/session-manager.code.js +1 -1
  148. package/dist/core/session-manager.impl.js +3 -3
  149. package/dist/core/session-manager.js +3 -3
  150. package/dist/core/session-storage.code.js +1 -1
  151. package/dist/core/session-storage.impl.js +3 -3
  152. package/dist/core/session-storage.js +3 -3
  153. package/dist/core/storage/added-exports.d.ts +6 -0
  154. package/dist/core/storage/added-exports.js +16 -0
  155. package/dist/core/storage/added-exports.js.map +1 -0
  156. package/dist/core/storage/database.d.ts +16 -0
  157. package/dist/core/storage/database.js.map +1 -1
  158. package/dist/core/storage/fenced-paths.d.ts +47 -0
  159. package/dist/core/storage/fenced-paths.js +53 -0
  160. package/dist/core/storage/fenced-paths.js.map +1 -1
  161. package/dist/core/storage/file-identity.js +31 -2
  162. package/dist/core/storage/file-identity.js.map +1 -1
  163. package/dist/core/storage/index.d.ts +3 -0
  164. package/dist/core/storage/index.js +5 -2
  165. package/dist/core/storage/index.js.map +1 -1
  166. package/dist/core/storage/migrations.d.ts +22 -0
  167. package/dist/core/storage/migrations.js +55 -0
  168. package/dist/core/storage/migrations.js.map +1 -1
  169. package/dist/core/storage/node-sqlite-thread.js +19 -6
  170. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  171. package/dist/core/storage/node-sqlite.js +53 -4
  172. package/dist/core/storage/node-sqlite.js.map +1 -1
  173. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  174. package/dist/core/storage/offline-snapshot-file.js +3 -3
  175. package/dist/core/storage/prefix.d.ts +3 -2
  176. package/dist/core/storage/prefix.js +18 -2
  177. package/dist/core/storage/prefix.js.map +1 -1
  178. package/dist/core/storage/provider.js +2 -2
  179. package/dist/core/storage/schema-catalog.d.ts +42 -0
  180. package/dist/core/storage/schema-catalog.js +141 -0
  181. package/dist/core/storage/schema-catalog.js.map +1 -0
  182. package/dist/core/storage/selection.js +2 -2
  183. package/dist/core/storage/session/branch-fork-source.code.js +41 -20
  184. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  185. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  186. package/dist/core/storage/session/branch-fork-source.js +3 -3
  187. package/dist/core/storage/session/card-view.impl.js +3 -3
  188. package/dist/core/storage/session/card-view.js +3 -3
  189. package/dist/core/storage/session/child-reader.code.js +3 -3
  190. package/dist/core/storage/session/child-reader.impl.js +3 -3
  191. package/dist/core/storage/session/child-reader.js +3 -3
  192. package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
  193. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  194. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  195. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  196. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  197. package/dist/core/storage/session/expanded-child-details.js +3 -3
  198. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  199. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  200. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  201. package/dist/core/storage/session/fork-row-index.js +3 -3
  202. package/dist/core/storage/session/fork-staging.code.js +176 -36
  203. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  204. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  205. package/dist/core/storage/session/fork-staging.js +3 -3
  206. package/dist/core/storage/session/fork-window.code.js +3 -3
  207. package/dist/core/storage/session/fork-window.impl.js +3 -3
  208. package/dist/core/storage/session/fork-window.js +3 -3
  209. package/dist/core/storage/session/history-pages.impl.js +3 -3
  210. package/dist/core/storage/session/history-pages.js +3 -3
  211. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  212. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  213. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  214. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  215. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  216. package/dist/core/storage/session/memory-session-store.js +3 -3
  217. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  218. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  219. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  220. package/dist/core/storage/session/released-history-files.code.js +2 -2
  221. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  222. package/dist/core/storage/session/released-history-files.js +3 -3
  223. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  224. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  225. package/dist/core/storage/session/session-resume.impl.js +3 -3
  226. package/dist/core/storage/session/session-resume.js +3 -3
  227. package/dist/core/storage/session/session-search-index.d.ts +5 -0
  228. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  229. package/dist/core/storage/session/snapshot-cut.js +3 -3
  230. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  231. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  232. package/dist/core/storage/session/snapshot-history.js +3 -3
  233. package/dist/core/storage/session/sql-chat-records.d.ts +15 -0
  234. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  235. package/dist/core/storage/session/sql-session-store.d.ts +102 -5
  236. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  237. package/dist/core/storage/session/sql-session-store.js +4 -4
  238. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  239. package/dist/core/storage/session/tree-outline.js +3 -3
  240. package/dist/core/storage/session/tree-presentation.code.js +1 -1
  241. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  242. package/dist/core/storage/session/tree-presentation.js +3 -3
  243. package/dist/core/storage/session/types.d.ts +14 -0
  244. package/dist/core/storage/sqlite-facade.d.ts +37 -5
  245. package/dist/core/storage/sqlite-facade.js +351 -18
  246. package/dist/core/storage/sqlite-facade.js.map +1 -1
  247. package/dist/core/storage/statement-sequence.d.ts +83 -0
  248. package/dist/core/storage/statement-sequence.js +21 -0
  249. package/dist/core/storage/statement-sequence.js.map +1 -1
  250. package/dist/core/storage/storage-status.code.js +1 -1
  251. package/dist/core/storage/storage-status.impl.js +3 -3
  252. package/dist/core/storage/storage-status.js +3 -3
  253. package/dist/core/storage/team.code.js +1 -1
  254. package/dist/core/storage/team.impl.js +3 -3
  255. package/dist/core/storage/team.js +3 -3
  256. package/dist/core/structured-output/index.code.js +1 -1
  257. package/dist/core/structured-output/index.impl.js +3 -3
  258. package/dist/core/structured-output/index.js +3 -3
  259. package/dist/core/tasks/task-completion-entry.code.js +1 -1
  260. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  261. package/dist/core/tasks/task-completion-entry.js +3 -3
  262. package/dist/core/tasks/task-file-history.code.js +3 -3
  263. package/dist/core/tasks/task-file-history.impl.js +3 -3
  264. package/dist/core/tasks/task-file-history.js +3 -3
  265. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  266. package/dist/core/tasks/task-reference-archive.js +3 -3
  267. package/dist/core/tasks/task-reference-identity.js +3 -3
  268. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  269. package/dist/core/tasks/task-reference-stream.js +3 -3
  270. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  271. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  272. package/dist/core/tasks/task-view-source.code.js +1 -1
  273. package/dist/core/tasks/task-view-source.impl.js +3 -3
  274. package/dist/core/tasks/task-view-source.js +3 -3
  275. package/dist/core/tools/bash.d.ts +8 -4
  276. package/dist/core/tools/history-session.d.ts +5 -0
  277. package/dist/core/tools/history-tasks.d.ts +123 -0
  278. package/dist/core/tools/kill.d.ts +5 -2
  279. package/dist/core/tools/powershell.d.ts +2 -2
  280. package/dist/core/tools/read-url.code.js +3 -3
  281. package/dist/core/tools/read-url.impl.js +3 -3
  282. package/dist/core/tools/read-url.js +3 -3
  283. package/dist/core/tools/read.d.ts +12 -2
  284. package/dist/core/tools/resource-selectors.d.ts +2 -0
  285. package/dist/core/tools/search.d.ts +12 -2
  286. package/dist/core/worktree-snapshot/blob-store.d.ts +14 -2
  287. package/dist/core/worktree-snapshot/blob-store.js +69 -16
  288. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  289. package/dist/core/worktree-snapshot/errors.code.js +2 -2
  290. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  291. package/dist/core/worktree-snapshot/errors.js +3 -3
  292. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  293. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  294. package/dist/extensions/codemode/execute.code.js +2 -2
  295. package/dist/extensions/codemode/execute.impl.js +3 -3
  296. package/dist/extensions/codemode/execute.js +3 -3
  297. package/dist/extensions/codemode/renderer.code.js +2 -2
  298. package/dist/extensions/codemode/renderer.impl.js +3 -3
  299. package/dist/extensions/codemode/renderer.js +3 -3
  300. package/dist/extensions/mcp/cli.code.js +3 -3
  301. package/dist/extensions/mcp/cli.impl.js +3 -3
  302. package/dist/extensions/mcp/cli.js +3 -3
  303. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  304. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  305. package/dist/extensions/mcp/cli.lazy.js +3 -3
  306. package/dist/extensions/mcp/runtime.code.js +1 -1
  307. package/dist/extensions/mcp/runtime.impl.js +3 -3
  308. package/dist/extensions/mcp/runtime.js +3 -3
  309. package/dist/index.js +5 -5
  310. package/dist/main-first-time-setup.code.js +1 -1
  311. package/dist/main-first-time-setup.impl.js +3 -3
  312. package/dist/main-first-time-setup.js +3 -3
  313. package/dist/main.js +1 -1
  314. package/dist/modes/interactive/components/agent-panel.d.ts +1 -0
  315. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  316. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  317. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  318. package/dist/modes/interactive/components/task-inspector.d.ts +2 -0
  319. package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
  320. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  321. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  322. package/dist/modes/interactive/interactive-mode-helpers.d.ts +2 -2
  323. package/dist/modes/print-mode.js +1 -1
  324. package/dist/modes/rpc/agent-panel-bridge.d.ts +5 -0
  325. package/dist/package-manager-cli.code.js +6 -6
  326. package/dist/package-manager-cli.impl.js +3 -3
  327. package/dist/package-manager-cli.js +3 -3
  328. package/dist/rpc-entry.js +1 -1
  329. package/dist/startup-files.json +1 -1
  330. package/dist/startup-stages/0.js +1 -1
  331. package/dist/startup-stages/1.js +1 -1
  332. package/dist/startup-stages/10.js +1 -1
  333. package/dist/startup-stages/12.js +1 -1
  334. package/dist/startup-stages/2.js +8 -1
  335. package/dist/startup-stages/3.js +1 -6
  336. package/dist/startup-stages/5.js +1 -1
  337. package/dist/startup-stages/7.js +1 -5
  338. package/dist/utils/startup-database-spare.code.js +2 -2
  339. package/dist/utils/startup-database-spare.impl.js +3 -3
  340. package/dist/utils/startup-database-spare.js +3 -3
  341. package/dist/utils/tools-manager.code.js +1 -1
  342. package/dist/utils/tools-manager.impl.js +3 -3
  343. package/dist/utils/tools-manager.js +3 -3
  344. package/docs/background-tasks.md +123 -23
  345. package/docs/compaction.md +18 -0
  346. package/docs/docs.json +2 -0
  347. package/docs/environment-variables.md +1 -1
  348. package/docs/getting-started/installation.md +9 -2
  349. package/docs/guides/postgres-pgbouncer.md +339 -0
  350. package/docs/guides/postgres-tuning.md +311 -0
  351. package/docs/guides/resume-on-any-machine.md +2 -2
  352. package/docs/guides.md +2 -0
  353. package/docs/index.md +1 -1
  354. package/docs/libraries/agent-core.md +1 -1
  355. package/docs/libraries/ai.md +2 -2
  356. package/docs/libraries/codemode.md +1 -1
  357. package/docs/libraries/storage-libsql.md +6 -1
  358. package/docs/libraries/storage-postgres.md +11 -6
  359. package/docs/libraries/tui.md +1 -1
  360. package/docs/libraries.md +2 -2
  361. package/docs/programmatic.md +1 -1
  362. package/docs/quickstart.md +1 -1
  363. package/docs/sdk/storage.md +1 -1
  364. package/docs/sdk/web-server.md +1 -3
  365. package/docs/sdk.md +1 -7
  366. package/docs/sessions.md +58 -2
  367. package/docs/settings.md +20 -1
  368. package/docs/skills/authoring.md +1 -1
  369. package/docs/skills.md +79 -6
  370. package/docs/storage.md +262 -12
  371. package/docs/subagents/reference.md +2 -2
  372. package/docs/subagents.md +4 -3
  373. package/docs/tools.md +44 -10
  374. package/docs/windows.md +1 -1
  375. package/package.json +9 -9
  376. package/dist/_shared/sdk-RRLVN7ER.js.map +0 -1
  377. package/dist/_shared/startup-0-0-4VG2G44V.js.map +0 -1
  378. package/dist/_shared/startup-0-1-XTIL65D4.js.map +0 -1
  379. package/dist/_shared/startup-0-5-FD2P735I.js.map +0 -1
  380. package/dist/_shared/startup-8-1-4KANEHRA.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ import * as migrations from "./migrations.js";
2
+ import * as statementSequence from "./statement-sequence.js";
3
+ /**
4
+ * `storageSchemaCurrent` and `ensureTableFillfactor` of `migrations.ts` and `transactionFinisher` of
5
+ * `statement-sequence.ts`, which the copies of those modules (and of `statement-batches.ts`) that 0.10.3 and 0.10.4
6
+ * loaded lack. A process that loaded those copies before an in-place update replaced the installation keeps them, and
7
+ * can load the modules that use these from the update: a named import of any of them would fail to link there, so they
8
+ * take them from here, a path no earlier release has (#6560). Without them every open checks its schema in a
9
+ * transaction, tables keep their default fillfactor, and a transaction's last writes run before its `COMMIT`, as there.
10
+ */
11
+ const schemaChecks = migrations;
12
+ const finishers = statementSequence;
13
+ export const storageSchemaCurrent = schemaChecks.storageSchemaCurrent ?? (async () => false);
14
+ export const ensureTableFillfactor = schemaChecks.ensureTableFillfactor ?? (async () => { });
15
+ export const transactionFinisher = finishers.transactionFinisher ?? (() => undefined);
16
+ //# sourceMappingURL=added-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"added-exports.js","sourceRoot":"","sources":["../../../src/core/storage/added-exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,YAAY,GAAuF,UAAU,CAAC;AACpH,MAAM,SAAS,GAAmE,iBAAiB,CAAC;AAEpG,MAAM,CAAC,MAAM,oBAAoB,GAChC,YAAY,CAAC,oBAAoB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,qBAAqB,GACjC,YAAY,CAAC,qBAAqB,IAAI,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,mBAAmB,GAC/B,SAAS,CAAC,mBAAmB,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import * as migrations from \"./migrations.js\";\nimport * as statementSequence from \"./statement-sequence.js\";\n\n/**\n * `storageSchemaCurrent` and `ensureTableFillfactor` of `migrations.ts` and `transactionFinisher` of\n * `statement-sequence.ts`, which the copies of those modules (and of `statement-batches.ts`) that 0.10.3 and 0.10.4\n * loaded lack. A process that loaded those copies before an in-place update replaced the installation keeps them, and\n * can load the modules that use these from the update: a named import of any of them would fail to link there, so they\n * take them from here, a path no earlier release has (#6560). Without them every open checks its schema in a\n * transaction, tables keep their default fillfactor, and a transaction's last writes run before its `COMMIT`, as there.\n */\nconst schemaChecks: Partial<Pick<typeof migrations, \"storageSchemaCurrent\" | \"ensureTableFillfactor\">> = migrations;\nconst finishers: Partial<Pick<typeof statementSequence, \"transactionFinisher\">> = statementSequence;\n\nexport const storageSchemaCurrent: typeof migrations.storageSchemaCurrent =\n\tschemaChecks.storageSchemaCurrent ?? (async () => false);\n\nexport const ensureTableFillfactor: typeof migrations.ensureTableFillfactor =\n\tschemaChecks.ensureTableFillfactor ?? (async () => {});\n\nexport const transactionFinisher: typeof statementSequence.transactionFinisher =\n\tfinishers.transactionFinisher ?? (() => undefined);\n"]}
@@ -42,6 +42,15 @@ export interface SqliteTransactionOptions {
42
42
  * `BEGIN IMMEDIATE` unless `readOnly` is set; only a driver that runs transactions concurrently (Postgres) tells them apart.
43
43
  */
44
44
  readonly concurrency?: TransactionConcurrency;
45
+ /**
46
+ * @internal The statements the callback makes first, in this order, before it acts on any answer. A driver whose
47
+ * transactions are pipelined sends them with the transaction's start, so they cost no round trip of their own, and
48
+ * starts the callback once they are answered; each call of the callback that makes the next of them gets its answer.
49
+ * Name only reads: a call that differs from the next of them ends the lead, and the answers of the rest go unused,
50
+ * though they ran. A write may lead only as the callback's first call, made on every run whatever it reads, such as a
51
+ * fenced path's one guarded write: it never runs unused. Other drivers ignore it.
52
+ */
53
+ readonly leading?: readonly SqliteStatement[];
45
54
  }
46
55
  /** How one batch waits for a busy write lock, and whether it goes ahead of the database's queued calls. */
47
56
  export interface SqliteBatchOptions {
@@ -133,6 +142,13 @@ export interface SqliteDatabase extends SqliteExecutor {
133
142
  */
134
143
  readonly readOnly?: boolean;
135
144
  readonly descriptor: StorageDescriptor;
145
+ /**
146
+ * @internal Which database this handle reaches, for comparison only: two handles this process opened answer the same
147
+ * string only when a transaction of either reads and writes the very tables the other does (the same adapter, server
148
+ * or file, database, schema or namespace). Undefined, or absent, where that cannot be told, as for a database in
149
+ * memory: such a handle is the same database as itself alone.
150
+ */
151
+ databaseIdentity?(): string | undefined;
136
152
  /** @internal Checks whether this embedded connection can prepare a JSONB extraction without issuing a read. */
137
153
  supportsJsonbExtract?(): Promise<boolean>;
138
154
  /** The SQL dialect the database speaks; absent means SQLite. Read it through `dialectOf(database)`. */
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/core/storage/database.ts"],"names":[],"mappings":"","sourcesContent":["import type { StorageDialect } from \"./dialect.js\";\n\nexport type SqliteValue = null | number | bigint | string | Uint8Array;\nexport type SqliteRow = Readonly<Record<string, SqliteValue>>;\n\nexport interface SqliteRunResult {\n\treadonly changes: number;\n}\n\nexport interface SqliteExecutor {\n\texec(sql: string): Promise<void>;\n\trun(sql: string, ...params: readonly SqliteValue[]): Promise<SqliteRunResult>;\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined>;\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]>;\n}\n\nexport interface StorageDescriptor {\n\treadonly adapter: string;\n\treadonly location: string;\n}\n\n/** One statement of a batch: SQL with positional `?` parameters. */\nexport interface SqliteStatement {\n\treadonly sql: string;\n\treadonly params: readonly SqliteValue[];\n}\n\n/** How a transaction takes its snapshot or write lock, and whether it may run again. */\nexport interface SqliteTransactionOptions {\n\t/** @internal A consistent read snapshot without a writer lock. The callback must only read. */\n\treadonly readOnly?: boolean;\n\t/**\n\t * How long the transaction keeps waiting for the write lock while it is held and no other connection commits,\n\t * instead of the connection's own lock wait. A writer whose work must not fail because another process stalled\n\t * with the lock held (starved of CPU, paused by garbage collection, stopped by a signal) waits longer: the holder\n\t * still commits or rolls back once it runs again. Adapters without a lock wait of their own ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Lets a database from `createSqliteDatabase` run the callback again, in a new transaction, when a transient\n\t * failure (`StorageTransientError`) ended the transaction before it committed, so nothing of it was written. Set it\n\t * only for a callback that does nothing but use the transaction handle: anything else it does happens once per run.\n\t * Other databases ignore it.\n\t */\n\treadonly retryTransientFailures?: boolean;\n\t/**\n\t * How the transaction excludes other writers; `{ kind: \"serial\" }` when absent. SQLite runs every kind as\n\t * `BEGIN IMMEDIATE` unless `readOnly` is set; only a driver that runs transactions concurrently (Postgres) tells them apart.\n\t */\n\treadonly concurrency?: TransactionConcurrency;\n}\n\n/** How one batch waits for a busy write lock, and whether it goes ahead of the database's queued calls. */\nexport interface SqliteBatchOptions {\n\t/**\n\t * How long a batch that found the database's write lock busy keeps sending again, with growing randomized waits\n\t * between tries. A busy batch wrote nothing, so sending it again is safe. Adapters without such a retry ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Runs the batch before calls queued on this database that do not set it, and outside any limit the adapter puts on\n\t * concurrent writes: for small writes that must not wait behind others, such as a lease renewal.\n\t */\n\treadonly priority?: boolean;\n}\n\n/**\n * An audited fenced write path. Only `fencedPath(name)` in `fenced-paths.ts` makes one; a plain string is not one. The\n * brand is a string key, not a unique symbol, so the published declarations and the sources stay one type.\n */\nexport type FencedPathId = string & { readonly __atomicFencedPath: true };\n\n/**\n * `serial`: the body runs as if it were the only writer of `domain`, or of the whole database when `domain` is absent:\n * `BEGIN IMMEDIATE` on SQLite, `BEGIN` plus that domain's transaction advisory lock on Postgres. Several prefixes may\n * share one database, so `domain` names the scope in full: a store passes one of its prefixed table names.\n * `fenced`: the body runs under READ COMMITTED and takes the row locks it relies on itself. With `excludesSerial`, it\n * also waits for and excludes `serial` transactions without a domain, as a `serial` transaction with a domain does,\n * for a body whose check a whole-database writer (such as snapshot garbage collection) could otherwise race\n * (`StorageDialect.lockClause`); `audit` names the reviewed path. Identical to `serial` on SQLite.\n */\nexport type TransactionConcurrency =\n\t| { readonly kind: \"serial\"; readonly domain?: string }\n\t| { readonly kind: \"fenced\"; readonly audit: FencedPathId; readonly excludesSerial?: boolean };\n\n/**\n * What a database's listening connection is doing: `listening`, notifications arrive; `connecting`, it is not known yet;\n * `unavailable`, none arrive, and pollers find the work: `pooler` when the endpoint is a transaction pooler (a\n * notification sent through the database did not reach the listening session), `connection-failed` when the listening\n * connection could not be opened or broke.\n */\nexport type StorageListenerState =\n\t| { readonly status: \"listening\" }\n\t| { readonly status: \"connecting\" }\n\t| { readonly status: \"unavailable\"; readonly reason: \"pooler\" | \"connection-failed\" };\n\n/**\n * `notification`: a transaction that ran `notify(channel, payload)` committed. `listening`: the listening connection\n * began listening again after it was unavailable, so notifications sent meanwhile were lost.\n */\nexport type StorageNotificationEvent =\n\t| { readonly kind: \"notification\"; readonly payload: string }\n\t| { readonly kind: \"listening\" };\n\nexport interface StorageNotificationSubscription {\n\t/** Stops delivering events to this listener; idempotent. */\n\tclose(): void;\n}\n\n/**\n * Wake-ups through the database (#5103): Postgres `LISTEN`/`NOTIFY`. A notification is only a hint that a poller would\n * find the same work at its next poll; notifications are lost while the listening connection is down, and through a\n * transaction pooler none arrive, so a store that sends them keeps its poll.\n */\nexport interface StorageNotifications {\n\t/**\n\t * A statement that sends `payload` to the listeners of `channel` when the transaction it runs in commits, and never\n\t * when it rolls back: run it in the transaction of the write it announces. `channel` is a name such as\n\t * `<prefix>pool_ready`; the database shortens a long one the same way for `notify` and `listen`.\n\t */\n\tnotify(channel: string, payload: string): SqliteStatement;\n\t/** Delivers `channel`'s events to `listener`, on one listening connection the database shares between channels. */\n\tlisten(channel: string, listener: (event: StorageNotificationEvent) => void): StorageNotificationSubscription;\n\t/** Opens the listening connection when it is not open, and resolves with its state once the first attempt settled. */\n\tstate(): Promise<StorageListenerState>;\n}\n\nexport interface SqliteDatabase extends SqliteExecutor {\n\t/**\n\t * True when the connection refuses writes, as `openNodeSqliteDatabase(path, { readOnly: true })` sets it, so opening a\n\t * session store skips a cleanup write that would fail. Optional: a read-only connection that leaves it unset still\n\t * opens a session store, whose failed cleanup is ignored.\n\t */\n\treadonly readOnly?: boolean;\n\treadonly descriptor: StorageDescriptor;\n\t/** @internal Checks whether this embedded connection can prepare a JSONB extraction without issuing a read. */\n\tsupportsJsonbExtract?(): Promise<boolean>;\n\t/** The SQL dialect the database speaks; absent means SQLite. Read it through `dialectOf(database)`. */\n\treadonly dialect?: StorageDialect;\n\t/** Wake-ups through the database; present only on a database that delivers them (Postgres). */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * The bytes this process may still write on the file system that holds the database's file (where a link to the file\n\t * points, and where its write-ahead log goes), as a SQLite or libSQL file database reports them. Absent, or resolving\n\t * undefined, when this process cannot see the database's disk (a server, memory) or the file system does not say.\n\t */\n\tfreeBytes?(): Promise<number | undefined>;\n\t/** @internal Run one short maintenance transaction only if this handle, its writer gate and the database lock\n\t * are immediately available. A backend without no-wait admission leaves this absent. */\n\ttryMaintenance?(callback: (transaction: SqliteExecutor) => Promise<void>): Promise<boolean>;\n\t/** Opens a separate handle on this same database for reads. It has its own call queue; the caller must close it. */\n\topenReader?(): Promise<SqliteDatabase>;\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T>;\n\t/**\n\t * Runs the statements in order, in one write transaction, as one call to the database: all of them commit or none\n\t * do. Resolves with each statement's rows. Present only when the driver can send a batch in one request, which\n\t * saves a round trip per statement against a remote database.\n\t */\n\tbatch?(statements: readonly SqliteStatement[], options?: SqliteBatchOptions): Promise<SqliteRow[][]>;\n\tclose(): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/core/storage/database.ts"],"names":[],"mappings":"","sourcesContent":["import type { StorageDialect } from \"./dialect.js\";\n\nexport type SqliteValue = null | number | bigint | string | Uint8Array;\nexport type SqliteRow = Readonly<Record<string, SqliteValue>>;\n\nexport interface SqliteRunResult {\n\treadonly changes: number;\n}\n\nexport interface SqliteExecutor {\n\texec(sql: string): Promise<void>;\n\trun(sql: string, ...params: readonly SqliteValue[]): Promise<SqliteRunResult>;\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined>;\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]>;\n}\n\nexport interface StorageDescriptor {\n\treadonly adapter: string;\n\treadonly location: string;\n}\n\n/** One statement of a batch: SQL with positional `?` parameters. */\nexport interface SqliteStatement {\n\treadonly sql: string;\n\treadonly params: readonly SqliteValue[];\n}\n\n/** How a transaction takes its snapshot or write lock, and whether it may run again. */\nexport interface SqliteTransactionOptions {\n\t/** @internal A consistent read snapshot without a writer lock. The callback must only read. */\n\treadonly readOnly?: boolean;\n\t/**\n\t * How long the transaction keeps waiting for the write lock while it is held and no other connection commits,\n\t * instead of the connection's own lock wait. A writer whose work must not fail because another process stalled\n\t * with the lock held (starved of CPU, paused by garbage collection, stopped by a signal) waits longer: the holder\n\t * still commits or rolls back once it runs again. Adapters without a lock wait of their own ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Lets a database from `createSqliteDatabase` run the callback again, in a new transaction, when a transient\n\t * failure (`StorageTransientError`) ended the transaction before it committed, so nothing of it was written. Set it\n\t * only for a callback that does nothing but use the transaction handle: anything else it does happens once per run.\n\t * Other databases ignore it.\n\t */\n\treadonly retryTransientFailures?: boolean;\n\t/**\n\t * How the transaction excludes other writers; `{ kind: \"serial\" }` when absent. SQLite runs every kind as\n\t * `BEGIN IMMEDIATE` unless `readOnly` is set; only a driver that runs transactions concurrently (Postgres) tells them apart.\n\t */\n\treadonly concurrency?: TransactionConcurrency;\n\t/**\n\t * @internal The statements the callback makes first, in this order, before it acts on any answer. A driver whose\n\t * transactions are pipelined sends them with the transaction's start, so they cost no round trip of their own, and\n\t * starts the callback once they are answered; each call of the callback that makes the next of them gets its answer.\n\t * Name only reads: a call that differs from the next of them ends the lead, and the answers of the rest go unused,\n\t * though they ran. A write may lead only as the callback's first call, made on every run whatever it reads, such as a\n\t * fenced path's one guarded write: it never runs unused. Other drivers ignore it.\n\t */\n\treadonly leading?: readonly SqliteStatement[];\n}\n\n/** How one batch waits for a busy write lock, and whether it goes ahead of the database's queued calls. */\nexport interface SqliteBatchOptions {\n\t/**\n\t * How long a batch that found the database's write lock busy keeps sending again, with growing randomized waits\n\t * between tries. A busy batch wrote nothing, so sending it again is safe. Adapters without such a retry ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Runs the batch before calls queued on this database that do not set it, and outside any limit the adapter puts on\n\t * concurrent writes: for small writes that must not wait behind others, such as a lease renewal.\n\t */\n\treadonly priority?: boolean;\n}\n\n/**\n * An audited fenced write path. Only `fencedPath(name)` in `fenced-paths.ts` makes one; a plain string is not one. The\n * brand is a string key, not a unique symbol, so the published declarations and the sources stay one type.\n */\nexport type FencedPathId = string & { readonly __atomicFencedPath: true };\n\n/**\n * `serial`: the body runs as if it were the only writer of `domain`, or of the whole database when `domain` is absent:\n * `BEGIN IMMEDIATE` on SQLite, `BEGIN` plus that domain's transaction advisory lock on Postgres. Several prefixes may\n * share one database, so `domain` names the scope in full: a store passes one of its prefixed table names.\n * `fenced`: the body runs under READ COMMITTED and takes the row locks it relies on itself. With `excludesSerial`, it\n * also waits for and excludes `serial` transactions without a domain, as a `serial` transaction with a domain does,\n * for a body whose check a whole-database writer (such as snapshot garbage collection) could otherwise race\n * (`StorageDialect.lockClause`); `audit` names the reviewed path. Identical to `serial` on SQLite.\n */\nexport type TransactionConcurrency =\n\t| { readonly kind: \"serial\"; readonly domain?: string }\n\t| { readonly kind: \"fenced\"; readonly audit: FencedPathId; readonly excludesSerial?: boolean };\n\n/**\n * What a database's listening connection is doing: `listening`, notifications arrive; `connecting`, it is not known yet;\n * `unavailable`, none arrive, and pollers find the work: `pooler` when the endpoint is a transaction pooler (a\n * notification sent through the database did not reach the listening session), `connection-failed` when the listening\n * connection could not be opened or broke.\n */\nexport type StorageListenerState =\n\t| { readonly status: \"listening\" }\n\t| { readonly status: \"connecting\" }\n\t| { readonly status: \"unavailable\"; readonly reason: \"pooler\" | \"connection-failed\" };\n\n/**\n * `notification`: a transaction that ran `notify(channel, payload)` committed. `listening`: the listening connection\n * began listening again after it was unavailable, so notifications sent meanwhile were lost.\n */\nexport type StorageNotificationEvent =\n\t| { readonly kind: \"notification\"; readonly payload: string }\n\t| { readonly kind: \"listening\" };\n\nexport interface StorageNotificationSubscription {\n\t/** Stops delivering events to this listener; idempotent. */\n\tclose(): void;\n}\n\n/**\n * Wake-ups through the database (#5103): Postgres `LISTEN`/`NOTIFY`. A notification is only a hint that a poller would\n * find the same work at its next poll; notifications are lost while the listening connection is down, and through a\n * transaction pooler none arrive, so a store that sends them keeps its poll.\n */\nexport interface StorageNotifications {\n\t/**\n\t * A statement that sends `payload` to the listeners of `channel` when the transaction it runs in commits, and never\n\t * when it rolls back: run it in the transaction of the write it announces. `channel` is a name such as\n\t * `<prefix>pool_ready`; the database shortens a long one the same way for `notify` and `listen`.\n\t */\n\tnotify(channel: string, payload: string): SqliteStatement;\n\t/** Delivers `channel`'s events to `listener`, on one listening connection the database shares between channels. */\n\tlisten(channel: string, listener: (event: StorageNotificationEvent) => void): StorageNotificationSubscription;\n\t/** Opens the listening connection when it is not open, and resolves with its state once the first attempt settled. */\n\tstate(): Promise<StorageListenerState>;\n}\n\nexport interface SqliteDatabase extends SqliteExecutor {\n\t/**\n\t * True when the connection refuses writes, as `openNodeSqliteDatabase(path, { readOnly: true })` sets it, so opening a\n\t * session store skips a cleanup write that would fail. Optional: a read-only connection that leaves it unset still\n\t * opens a session store, whose failed cleanup is ignored.\n\t */\n\treadonly readOnly?: boolean;\n\treadonly descriptor: StorageDescriptor;\n\t/**\n\t * @internal Which database this handle reaches, for comparison only: two handles this process opened answer the same\n\t * string only when a transaction of either reads and writes the very tables the other does (the same adapter, server\n\t * or file, database, schema or namespace). Undefined, or absent, where that cannot be told, as for a database in\n\t * memory: such a handle is the same database as itself alone.\n\t */\n\tdatabaseIdentity?(): string | undefined;\n\t/** @internal Checks whether this embedded connection can prepare a JSONB extraction without issuing a read. */\n\tsupportsJsonbExtract?(): Promise<boolean>;\n\t/** The SQL dialect the database speaks; absent means SQLite. Read it through `dialectOf(database)`. */\n\treadonly dialect?: StorageDialect;\n\t/** Wake-ups through the database; present only on a database that delivers them (Postgres). */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * The bytes this process may still write on the file system that holds the database's file (where a link to the file\n\t * points, and where its write-ahead log goes), as a SQLite or libSQL file database reports them. Absent, or resolving\n\t * undefined, when this process cannot see the database's disk (a server, memory) or the file system does not say.\n\t */\n\tfreeBytes?(): Promise<number | undefined>;\n\t/** @internal Run one short maintenance transaction only if this handle, its writer gate and the database lock\n\t * are immediately available. A backend without no-wait admission leaves this absent. */\n\ttryMaintenance?(callback: (transaction: SqliteExecutor) => Promise<void>): Promise<boolean>;\n\t/** Opens a separate handle on this same database for reads. It has its own call queue; the caller must close it. */\n\topenReader?(): Promise<SqliteDatabase>;\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T>;\n\t/**\n\t * Runs the statements in order, in one write transaction, as one call to the database: all of them commit or none\n\t * do. Resolves with each statement's rows. Present only when the driver can send a batch in one request, which\n\t * saves a round trip per statement against a remote database.\n\t */\n\tbatch?(statements: readonly SqliteStatement[], options?: SqliteBatchOptions): Promise<SqliteRow[][]>;\n\tclose(): Promise<void>;\n}\n"]}
@@ -31,6 +31,53 @@ declare const FENCED_PATHS: {
31
31
  readonly fences: readonly ["root lease row FOR KEY SHARE", "attempt's work row FOR UPDATE", "root run row FOR SHARE, then pool control"];
32
32
  readonly conformance: "many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)";
33
33
  };
34
+ /**
35
+ * Intercom's broker leases (`openSqlBrokerLeaseStore`): `acquire` is one upsert whose guard takes the row only while
36
+ * it is free, stale or the acquirer's own, `renew` and `release` one `UPDATE` guarded by holder and fencing token, and
37
+ * `renewMany` those updates in (kind, key) order. Each decides on its own row lock, never on an earlier read (#6560).
38
+ * On PostgreSQL a first acquisition takes its order from the lease order sequence, which waits for nothing; where
39
+ * `atomic storage migrate` has not created it yet, `acquire`'s statement first upserts the acquisition-order counter
40
+ * row instead, which no other path locks.
41
+ */
42
+ readonly "intercom-lease": {
43
+ readonly fences: readonly ["acquire only, without the order sequence: the acquisition-order counter row, by the statement's own upsert", "each lease row, by its own guarded upsert or UPDATE, in (kind, key) order"];
44
+ readonly conformance: "many brokers acquire, renew and release one lease concurrently: never two holders, fencing tokens strictly increase, a stale holder's renewal fails (#6560)";
45
+ };
46
+ /**
47
+ * Intercom's wake-up hint log (`intercom_wakeups`): a hint is a row inserted once and deleted by its id or its age,
48
+ * and no write reads the log to decide what to write, so its writers take no lock domain: the bus's `publish`
49
+ * inserts a hint and notifies in one transaction that commits both, an outbox enqueue inserts one inside its own
50
+ * transaction, and the bus's poll and pruning delete rows in single statements (#6560).
51
+ */
52
+ readonly "intercom-wakeup-hint": {
53
+ readonly fences: readonly ["none: the new hint row only, by its own INSERT"];
54
+ readonly conformance: "delivers each hint published at once from several connections exactly once (#6560)";
55
+ };
56
+ /**
57
+ * Intercom's outbox rows and sent-message reservations (`openSqlOutboxStore`, `openSqlSentMessageAuthority`), which
58
+ * left the outbox's one lock domain (#6560). A claim reads its recipient's undelivered rows `FOR UPDATE` in sequence
59
+ * order, then claims them; a claim's renewal, saving report, release and settlement are each one `UPDATE` guarded by
60
+ * message id, claimant, token and state; expiry and `releaseClaimsOf` lock their rows in sequence order in a
61
+ * subquery; a reservation, an acceptance and a forget are each one statement on the message's row, guarded by its
62
+ * digest. Each decides on the rows it locks, never on an earlier read. They exclude the database-wide transactions an
63
+ * older broker runs on these tables (`excludesSerial`). A send itself is a serial transaction of its recipient's domain.
64
+ */
65
+ readonly "intercom-outbox-row": {
66
+ readonly fences: readonly ["outbox rows, FOR UPDATE in sequence order (claim, expiry, releaseClaimsOf), or one row by its own guarded UPDATE", "one sent-message row, by its own guarded INSERT, UPDATE or DELETE"];
67
+ readonly conformance: "a send to one recipient does not wait while another recipient's claim holds its rows; sends to one recipient keep their order and suppress duplicates (#6560)";
68
+ };
69
+ /**
70
+ * A cleanup's claim of a lapsed fork staging transfer (`cleanupForkStaging`): it reads one lapsed lease row `FOR
71
+ * UPDATE SKIP LOCKED`, then takes it over with one `UPDATE` guarded by the lease still being lapsed, so it never waits
72
+ * for a live transfer whose writer or publication holds its lease, and two claims never take one transfer. Any lapsed
73
+ * transfer may be claimed in any order. The claim names no transfer before it reads, so it takes no lock domain; the
74
+ * owner's writes and the cleanup's removals are serial transactions of the transfer's own domain, and each decides on
75
+ * the lease row it locks by its token first (#6560).
76
+ */
77
+ readonly "fork-staging-claim": {
78
+ readonly fences: readonly ["one lapsed lease row of the staging table, FOR UPDATE SKIP LOCKED, then its guarded UPDATE"];
79
+ readonly conformance: "concurrent cleanups take each lapsed transfer over once and never a live one, beside staging clones (#6560)";
80
+ };
34
81
  /**
35
82
  * `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks
36
83
  * no pool row, so it orders after none of them (#4768).
@@ -37,6 +37,59 @@ const FENCED_PATHS = {
37
37
  ],
38
38
  conformance: "many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)",
39
39
  },
40
+ /**
41
+ * Intercom's broker leases (`openSqlBrokerLeaseStore`): `acquire` is one upsert whose guard takes the row only while
42
+ * it is free, stale or the acquirer's own, `renew` and `release` one `UPDATE` guarded by holder and fencing token, and
43
+ * `renewMany` those updates in (kind, key) order. Each decides on its own row lock, never on an earlier read (#6560).
44
+ * On PostgreSQL a first acquisition takes its order from the lease order sequence, which waits for nothing; where
45
+ * `atomic storage migrate` has not created it yet, `acquire`'s statement first upserts the acquisition-order counter
46
+ * row instead, which no other path locks.
47
+ */
48
+ "intercom-lease": {
49
+ fences: [
50
+ "acquire only, without the order sequence: the acquisition-order counter row, by the statement's own upsert",
51
+ "each lease row, by its own guarded upsert or UPDATE, in (kind, key) order",
52
+ ],
53
+ conformance: "many brokers acquire, renew and release one lease concurrently: never two holders, fencing tokens strictly increase, a stale holder's renewal fails (#6560)",
54
+ },
55
+ /**
56
+ * Intercom's wake-up hint log (`intercom_wakeups`): a hint is a row inserted once and deleted by its id or its age,
57
+ * and no write reads the log to decide what to write, so its writers take no lock domain: the bus's `publish`
58
+ * inserts a hint and notifies in one transaction that commits both, an outbox enqueue inserts one inside its own
59
+ * transaction, and the bus's poll and pruning delete rows in single statements (#6560).
60
+ */
61
+ "intercom-wakeup-hint": {
62
+ fences: ["none: the new hint row only, by its own INSERT"],
63
+ conformance: "delivers each hint published at once from several connections exactly once (#6560)",
64
+ },
65
+ /**
66
+ * Intercom's outbox rows and sent-message reservations (`openSqlOutboxStore`, `openSqlSentMessageAuthority`), which
67
+ * left the outbox's one lock domain (#6560). A claim reads its recipient's undelivered rows `FOR UPDATE` in sequence
68
+ * order, then claims them; a claim's renewal, saving report, release and settlement are each one `UPDATE` guarded by
69
+ * message id, claimant, token and state; expiry and `releaseClaimsOf` lock their rows in sequence order in a
70
+ * subquery; a reservation, an acceptance and a forget are each one statement on the message's row, guarded by its
71
+ * digest. Each decides on the rows it locks, never on an earlier read. They exclude the database-wide transactions an
72
+ * older broker runs on these tables (`excludesSerial`). A send itself is a serial transaction of its recipient's domain.
73
+ */
74
+ "intercom-outbox-row": {
75
+ fences: [
76
+ "outbox rows, FOR UPDATE in sequence order (claim, expiry, releaseClaimsOf), or one row by its own guarded UPDATE",
77
+ "one sent-message row, by its own guarded INSERT, UPDATE or DELETE",
78
+ ],
79
+ conformance: "a send to one recipient does not wait while another recipient's claim holds its rows; sends to one recipient keep their order and suppress duplicates (#6560)",
80
+ },
81
+ /**
82
+ * A cleanup's claim of a lapsed fork staging transfer (`cleanupForkStaging`): it reads one lapsed lease row `FOR
83
+ * UPDATE SKIP LOCKED`, then takes it over with one `UPDATE` guarded by the lease still being lapsed, so it never waits
84
+ * for a live transfer whose writer or publication holds its lease, and two claims never take one transfer. Any lapsed
85
+ * transfer may be claimed in any order. The claim names no transfer before it reads, so it takes no lock domain; the
86
+ * owner's writes and the cleanup's removals are serial transactions of the transfer's own domain, and each decides on
87
+ * the lease row it locks by its token first (#6560).
88
+ */
89
+ "fork-staging-claim": {
90
+ fences: ["one lapsed lease row of the staging table, FOR UPDATE SKIP LOCKED, then its guarded UPDATE"],
91
+ conformance: "concurrent cleanups take each lapsed transfer over once and never a live one, beside staging clones (#6560)",
92
+ },
40
93
  /**
41
94
  * `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks
42
95
  * no pool row, so it orders after none of them (#4768).
@@ -1 +1 @@
1
- {"version":3,"file":"fenced-paths.js","sourceRoot":"","sources":["../../../src/core/storage/fenced-paths.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,YAAY,GAAG;IACpB,gIAAgI;IAChI,YAAY,EAAE;QACb,MAAM,EAAE;YACP,8BAA8B;YAC9B,2CAA2C;YAC3C,uCAAuC;SACvC;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD,oHAAoH;IACpH,gBAAgB,EAAE;QACjB,MAAM,EAAE,CAAC,8BAA8B,EAAE,+BAA+B,EAAE,uBAAuB,CAAC;QAClG,WAAW,EAAE,6FAA6F;KAC1G;IACD,qHAAqH;IACrH,aAAa,EAAE;QACd,MAAM,EAAE;YACP,oHAAoH;YACpH,8BAA8B;YAC9B,+BAA+B;YAC/B,yGAAyG;YACzG,uBAAuB;SACvB;QACD,WAAW,EAAE,8EAA8E;KAC3F;IACD,0EAA0E;IAC1E,eAAe,EAAE;QAChB,MAAM,EAAE;YACP,8BAA8B;YAC9B,+BAA+B;YAC/B,2CAA2C;SAC3C;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD;;;OAGG;IACH,aAAa,EAAE;QACd,MAAM,EAAE,CAAC,gDAAgD,CAAC;QAC1D,WAAW,EAAE,iGAAiG;KAC9G;CAC4D,CAAC;AAI/D,yCAAyC;AACzC,MAAM,UAAU,eAAe,CAAC,IAAoB;IACnD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC9C,OAAO,IAAoB,CAAC;AAC7B,CAAC","sourcesContent":["import type { FencedPathId } from \"./database.js\";\n\n/** What makes a fenced write path correct without the domain's serial lock. */\nexport interface FencedPathAudit {\n\t/** The rows the path locks, in the order it locks them (the same order on every fenced path, so none deadlock). */\n\treadonly fences: readonly string[];\n\t/** The conformance test that runs the path concurrently on every backend. */\n\treadonly conformance: string;\n}\n\n/**\n * Every audited path that may run a `fenced` transaction. A path is added here, with its fences and its test, in the\n * change that makes it fenced; nothing else can name one.\n */\nconst FENCED_PATHS = {\n\t/** `SqlPoolQueue.claim`: one `UPDATE … WHERE id = (SELECT … FOR UPDATE SKIP LOCKED)`, so claimers never wait on one another. */\n\t\"pool-claim\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t\t\"ready work row FOR UPDATE SKIP LOCKED\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/** `SqlPoolQueue.renew`, `extend` and `heartbeat`: the attempt's lease, its claim confirmation and usage report. */\n\t\"pool-heartbeat\": {\n\t\tfences: [\"root lease row FOR KEY SHARE\", \"attempt's work row FOR UPDATE\", \"root usage totals row\"],\n\t\tconformance: \"claim, commit, heartbeat, complete and takeover run concurrently without a deadlock (#5102)\",\n\t},\n\t/** `SqlPoolQueue.commit` of a checkpoint or a session: the event takes the run's next sequence under its run row. */\n\t\"pool-commit\": {\n\t\tfences: [\n\t\t\t\"the database-wide serial lock, shared, only when the checkpoint records worktree snapshots (before every row lock)\",\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR UPDATE (FOR SHARE without an event), then pool control and the snapshots' stored blobs\",\n\t\t\t\"root usage totals row\",\n\t\t],\n\t\tconformance: \"32 concurrent writers commit one event per key with a dense sequence (#5102)\",\n\t},\n\t/** `SqlPoolQueue.complete`: the result and the work row's final state. */\n\t\"pool-complete\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/**\n\t * `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks\n\t * no pool row, so it orders after none of them (#4768).\n\t */\n\t\"rate-bucket\": {\n\t\tfences: [\"the scope's rate bucket row, by its own UPDATE\"],\n\t\tconformance: \"many hosts acquire from one rate bucket concurrently and never take more than it allows (#4768)\",\n\t},\n} as const satisfies Readonly<Record<string, FencedPathAudit>>;\n\nexport type FencedPathName = keyof typeof FENCED_PATHS;\n\n/** The audit record of a fenced path. */\nexport function fencedPathAudit(name: FencedPathName): FencedPathAudit {\n\treturn FENCED_PATHS[name];\n}\n\n/** The `FencedPathId` that lets an audited path run `{ kind: \"fenced\", audit }` transactions. */\nexport function fencedPath(name: FencedPathName): FencedPathId {\n\treturn name as FencedPathId;\n}\n"]}
1
+ {"version":3,"file":"fenced-paths.js","sourceRoot":"","sources":["../../../src/core/storage/fenced-paths.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,YAAY,GAAG;IACpB,gIAAgI;IAChI,YAAY,EAAE;QACb,MAAM,EAAE;YACP,8BAA8B;YAC9B,2CAA2C;YAC3C,uCAAuC;SACvC;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD,oHAAoH;IACpH,gBAAgB,EAAE;QACjB,MAAM,EAAE,CAAC,8BAA8B,EAAE,+BAA+B,EAAE,uBAAuB,CAAC;QAClG,WAAW,EAAE,6FAA6F;KAC1G;IACD,qHAAqH;IACrH,aAAa,EAAE;QACd,MAAM,EAAE;YACP,oHAAoH;YACpH,8BAA8B;YAC9B,+BAA+B;YAC/B,yGAAyG;YACzG,uBAAuB;SACvB;QACD,WAAW,EAAE,8EAA8E;KAC3F;IACD,0EAA0E;IAC1E,eAAe,EAAE;QAChB,MAAM,EAAE;YACP,8BAA8B;YAC9B,+BAA+B;YAC/B,2CAA2C;SAC3C;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD;;;;;;;OAOG;IACH,gBAAgB,EAAE;QACjB,MAAM,EAAE;YACP,4GAA4G;YAC5G,2EAA2E;SAC3E;QACD,WAAW,EACV,6JAA6J;KAC9J;IACD;;;;;OAKG;IACH,sBAAsB,EAAE;QACvB,MAAM,EAAE,CAAC,gDAAgD,CAAC;QAC1D,WAAW,EAAE,oFAAoF;KACjG;IACD;;;;;;;;OAQG;IACH,qBAAqB,EAAE;QACtB,MAAM,EAAE;YACP,kHAAkH;YAClH,mEAAmE;SACnE;QACD,WAAW,EACV,+JAA+J;KAChK;IACD;;;;;;;OAOG;IACH,oBAAoB,EAAE;QACrB,MAAM,EAAE,CAAC,4FAA4F,CAAC;QACtG,WAAW,EACV,6GAA6G;KAC9G;IACD;;;OAGG;IACH,aAAa,EAAE;QACd,MAAM,EAAE,CAAC,gDAAgD,CAAC;QAC1D,WAAW,EAAE,iGAAiG;KAC9G;CAC4D,CAAC;AAI/D,yCAAyC;AACzC,MAAM,UAAU,eAAe,CAAC,IAAoB;IACnD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC9C,OAAO,IAAoB,CAAC;AAC7B,CAAC","sourcesContent":["import type { FencedPathId } from \"./database.js\";\n\n/** What makes a fenced write path correct without the domain's serial lock. */\nexport interface FencedPathAudit {\n\t/** The rows the path locks, in the order it locks them (the same order on every fenced path, so none deadlock). */\n\treadonly fences: readonly string[];\n\t/** The conformance test that runs the path concurrently on every backend. */\n\treadonly conformance: string;\n}\n\n/**\n * Every audited path that may run a `fenced` transaction. A path is added here, with its fences and its test, in the\n * change that makes it fenced; nothing else can name one.\n */\nconst FENCED_PATHS = {\n\t/** `SqlPoolQueue.claim`: one `UPDATE … WHERE id = (SELECT … FOR UPDATE SKIP LOCKED)`, so claimers never wait on one another. */\n\t\"pool-claim\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t\t\"ready work row FOR UPDATE SKIP LOCKED\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/** `SqlPoolQueue.renew`, `extend` and `heartbeat`: the attempt's lease, its claim confirmation and usage report. */\n\t\"pool-heartbeat\": {\n\t\tfences: [\"root lease row FOR KEY SHARE\", \"attempt's work row FOR UPDATE\", \"root usage totals row\"],\n\t\tconformance: \"claim, commit, heartbeat, complete and takeover run concurrently without a deadlock (#5102)\",\n\t},\n\t/** `SqlPoolQueue.commit` of a checkpoint or a session: the event takes the run's next sequence under its run row. */\n\t\"pool-commit\": {\n\t\tfences: [\n\t\t\t\"the database-wide serial lock, shared, only when the checkpoint records worktree snapshots (before every row lock)\",\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR UPDATE (FOR SHARE without an event), then pool control and the snapshots' stored blobs\",\n\t\t\t\"root usage totals row\",\n\t\t],\n\t\tconformance: \"32 concurrent writers commit one event per key with a dense sequence (#5102)\",\n\t},\n\t/** `SqlPoolQueue.complete`: the result and the work row's final state. */\n\t\"pool-complete\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/**\n\t * Intercom's broker leases (`openSqlBrokerLeaseStore`): `acquire` is one upsert whose guard takes the row only while\n\t * it is free, stale or the acquirer's own, `renew` and `release` one `UPDATE` guarded by holder and fencing token, and\n\t * `renewMany` those updates in (kind, key) order. Each decides on its own row lock, never on an earlier read (#6560).\n\t * On PostgreSQL a first acquisition takes its order from the lease order sequence, which waits for nothing; where\n\t * `atomic storage migrate` has not created it yet, `acquire`'s statement first upserts the acquisition-order counter\n\t * row instead, which no other path locks.\n\t */\n\t\"intercom-lease\": {\n\t\tfences: [\n\t\t\t\"acquire only, without the order sequence: the acquisition-order counter row, by the statement's own upsert\",\n\t\t\t\"each lease row, by its own guarded upsert or UPDATE, in (kind, key) order\",\n\t\t],\n\t\tconformance:\n\t\t\t\"many brokers acquire, renew and release one lease concurrently: never two holders, fencing tokens strictly increase, a stale holder's renewal fails (#6560)\",\n\t},\n\t/**\n\t * Intercom's wake-up hint log (`intercom_wakeups`): a hint is a row inserted once and deleted by its id or its age,\n\t * and no write reads the log to decide what to write, so its writers take no lock domain: the bus's `publish`\n\t * inserts a hint and notifies in one transaction that commits both, an outbox enqueue inserts one inside its own\n\t * transaction, and the bus's poll and pruning delete rows in single statements (#6560).\n\t */\n\t\"intercom-wakeup-hint\": {\n\t\tfences: [\"none: the new hint row only, by its own INSERT\"],\n\t\tconformance: \"delivers each hint published at once from several connections exactly once (#6560)\",\n\t},\n\t/**\n\t * Intercom's outbox rows and sent-message reservations (`openSqlOutboxStore`, `openSqlSentMessageAuthority`), which\n\t * left the outbox's one lock domain (#6560). A claim reads its recipient's undelivered rows `FOR UPDATE` in sequence\n\t * order, then claims them; a claim's renewal, saving report, release and settlement are each one `UPDATE` guarded by\n\t * message id, claimant, token and state; expiry and `releaseClaimsOf` lock their rows in sequence order in a\n\t * subquery; a reservation, an acceptance and a forget are each one statement on the message's row, guarded by its\n\t * digest. Each decides on the rows it locks, never on an earlier read. They exclude the database-wide transactions an\n\t * older broker runs on these tables (`excludesSerial`). A send itself is a serial transaction of its recipient's domain.\n\t */\n\t\"intercom-outbox-row\": {\n\t\tfences: [\n\t\t\t\"outbox rows, FOR UPDATE in sequence order (claim, expiry, releaseClaimsOf), or one row by its own guarded UPDATE\",\n\t\t\t\"one sent-message row, by its own guarded INSERT, UPDATE or DELETE\",\n\t\t],\n\t\tconformance:\n\t\t\t\"a send to one recipient does not wait while another recipient's claim holds its rows; sends to one recipient keep their order and suppress duplicates (#6560)\",\n\t},\n\t/**\n\t * A cleanup's claim of a lapsed fork staging transfer (`cleanupForkStaging`): it reads one lapsed lease row `FOR\n\t * UPDATE SKIP LOCKED`, then takes it over with one `UPDATE` guarded by the lease still being lapsed, so it never waits\n\t * for a live transfer whose writer or publication holds its lease, and two claims never take one transfer. Any lapsed\n\t * transfer may be claimed in any order. The claim names no transfer before it reads, so it takes no lock domain; the\n\t * owner's writes and the cleanup's removals are serial transactions of the transfer's own domain, and each decides on\n\t * the lease row it locks by its token first (#6560).\n\t */\n\t\"fork-staging-claim\": {\n\t\tfences: [\"one lapsed lease row of the staging table, FOR UPDATE SKIP LOCKED, then its guarded UPDATE\"],\n\t\tconformance:\n\t\t\t\"concurrent cleanups take each lapsed transfer over once and never a live one, beside staging clones (#6560)\",\n\t},\n\t/**\n\t * `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks\n\t * no pool row, so it orders after none of them (#4768).\n\t */\n\t\"rate-bucket\": {\n\t\tfences: [\"the scope's rate bucket row, by its own UPDATE\"],\n\t\tconformance: \"many hosts acquire from one rate bucket concurrently and never take more than it allows (#4768)\",\n\t},\n} as const satisfies Readonly<Record<string, FencedPathAudit>>;\n\nexport type FencedPathName = keyof typeof FENCED_PATHS;\n\n/** The audit record of a fenced path. */\nexport function fencedPathAudit(name: FencedPathName): FencedPathAudit {\n\treturn FENCED_PATHS[name];\n}\n\n/** The `FencedPathId` that lets an audited path run `{ kind: \"fenced\", audit }` transactions. */\nexport function fencedPath(name: FencedPathName): FencedPathId {\n\treturn name as FencedPathId;\n}\n"]}
@@ -1091,6 +1091,29 @@ function* readStorageOwnerSteps(file) {
1091
1091
  }
1092
1092
  return owner;
1093
1093
  }
1094
+ /** A copied decision can have both the original decision ID and a recycled inode. */
1095
+ function* isReusedParentDecisionInodeSteps(owner, claimDirectory, candidate, decisionStat) {
1096
+ if (!owner.homeIdentity ||
1097
+ owner.decisionId === undefined ||
1098
+ decisionStat === undefined ||
1099
+ decisionStat.birthtimeNs <= 0n ||
1100
+ pathsEqual(candidate, owner.path))
1101
+ return false;
1102
+ let claimStat;
1103
+ try {
1104
+ claimStat = yield* io("stat", join(claimDirectory, PARENT_CLAIM_FILE));
1105
+ }
1106
+ catch {
1107
+ return false;
1108
+ }
1109
+ // The decision file used to publish the claim already existed when the claim was created. Copying the
1110
+ // parent can make the claim file newer, but a subsequent backup can be newer still. A directory inode
1111
+ // match does not overturn that evidence: the backup can reuse the original directory's inode too.
1112
+ return (claimStat.dev === decisionStat.dev &&
1113
+ claimStat.birthtimeNs > 0n &&
1114
+ decisionStat.birthtimeNs > claimStat.birthtimeNs &&
1115
+ (yield* storageDecisionMetadataSteps(candidate))?.id === owner.decisionId);
1116
+ }
1094
1117
  function* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, recordedPath, excludedExactCandidate) {
1095
1118
  const exact = [];
1096
1119
  const recorded = [];
@@ -1100,7 +1123,11 @@ function* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget,
1100
1123
  return;
1101
1124
  const identityInfo = yield* fileIdentityWithStatSteps(owner.homeIdentity ? storageHomeDecisionFile(candidate) : candidate);
1102
1125
  const isExcludedExact = excludedExactCandidate !== undefined && (yield* sameDirectorySteps(candidate, excludedExactCandidate));
1103
- if (!isExcludedExact && identityInfo !== undefined && identityInfo.identity === owner.identity) {
1126
+ if (!isExcludedExact &&
1127
+ identityInfo !== undefined &&
1128
+ identityInfo.identity === owner.identity &&
1129
+ (claimedTarget !== undefined ||
1130
+ !(yield* isReusedParentDecisionInodeSteps(owner, claimDirectory, candidate, identityInfo.stat)))) {
1104
1131
  for (const match of exact) {
1105
1132
  if (yield* sameDirectorySteps(match.path, candidate))
1106
1133
  return;
@@ -1246,7 +1273,9 @@ function* resolveStorageOwnerForCallerSteps(owner, claimDirectory = dirname(owne
1246
1273
  if (owner.identity === undefined)
1247
1274
  return { ownerPath: path };
1248
1275
  const fastInfo = yield* fileIdentityWithStatSteps(owner.homeIdentity ? storageHomeDecisionFile(path) : path);
1249
- if (fastInfo?.identity === owner.identity) {
1276
+ if (fastInfo?.identity === owner.identity &&
1277
+ (claimedTarget !== undefined ||
1278
+ !(yield* isReusedParentDecisionInodeSteps(owner, claimDirectory, path, fastInfo.stat)))) {
1250
1279
  return yield* maybeDisplaceConflictingExactCandidateSteps(owner, claimDirectory, claimedTarget, path, path, fastInfo.stat, context);
1251
1280
  }
1252
1281
  const scanned = yield* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, path);