@bastani/atomic 0.10.19 → 0.10.20-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.
- package/CHANGELOG.md +72 -0
- package/dist/_shared/adapter-open-DXXV6ATH.js +22 -0
- package/dist/_shared/adapter-open-DXXV6ATH.js.map +1 -0
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js +484 -229
- package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +63 -16
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +61 -16
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/p0-cli-BB45ZQY6.js +2 -2
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/p1b-elig-BY2G5BUE.js +6 -3
- package/dist/_shared/p1b-elig-BY2G5BUE.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-BHX35EPK.js → sdk-5ZFNDXUJ.js} +319 -86
- package/dist/_shared/sdk-5ZFNDXUJ.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +15 -7
- package/dist/_shared/session-data-AHTU7IS6.js.map +1 -1
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-HXQLSUWM.js +2 -2
- package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -1
- package/dist/_shared/{startup-0-0-4EDVBK5P.js → startup-0-0-OWBJIX35.js} +162 -44
- package/dist/_shared/startup-0-0-OWBJIX35.js.map +1 -0
- package/dist/_shared/{startup-0-1-H5IXVRXQ.js → startup-0-1-DZYE4E5Z.js} +462 -37
- package/dist/_shared/startup-0-1-DZYE4E5Z.js.map +1 -0
- package/dist/_shared/{startup-0-2-YZZOC22D.js → startup-0-2-WFLTE4SC.js} +147 -6
- package/dist/_shared/startup-0-2-WFLTE4SC.js.map +1 -0
- package/dist/_shared/startup-0-3-DE2NCS6A.js +59 -50
- package/dist/_shared/startup-0-3-DE2NCS6A.js.map +1 -1
- package/dist/_shared/{startup-0-4-ZMJV547D.js → startup-0-4-6XXL4JMZ.js} +115 -25
- package/dist/_shared/startup-0-4-6XXL4JMZ.js.map +1 -0
- package/dist/_shared/{startup-0-5-HZX3ZPTP.js → startup-0-5-DNS6FYS7.js} +229 -156
- package/dist/_shared/startup-0-5-DNS6FYS7.js.map +1 -0
- package/dist/_shared/{startup-10-0-TDQNBDDL.js → startup-10-0-O6DAT7U4.js} +131 -162
- package/dist/_shared/startup-10-0-O6DAT7U4.js.map +1 -0
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +9 -6
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/{startup-15-0-YUKGAC63.js → startup-15-0-E7RYG5YF.js} +9 -9
- package/dist/_shared/{startup-15-0-YUKGAC63.js.map → startup-15-0-E7RYG5YF.js.map} +1 -1
- package/dist/_shared/startup-15-1-WQZBOTMZ.js +340 -128
- package/dist/_shared/startup-15-1-WQZBOTMZ.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +279 -151
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-QZMXUGHI.js → startup-8-1-VXBL37AI.js} +352 -27
- package/dist/_shared/startup-8-1-VXBL37AI.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +15 -273
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/{storage-status-K7PX2RXA.js → storage-status-T6FUXRIM.js} +8 -24
- package/dist/_shared/{storage-status-K7PX2RXA.js.map → storage-status-T6FUXRIM.js.map} +1 -1
- package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +4 -3
- package/dist/_shared/team-DOQKICG2.js.map +1 -1
- package/dist/_shared/tree-outline-MUEPK5B7.js +9 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js.map +1 -1
- package/dist/binary-self-update.js +3 -3
- package/dist/builtin/intercom/broker/broker.bundle.mjs +46 -8
- package/dist/builtin/intercom/broker/broker.ts +1 -0
- package/dist/builtin/intercom/broker/client.ts +5 -1
- package/dist/builtin/intercom/broker/departed-children.ts +12 -6
- package/dist/builtin/intercom/broker/ended-child-wakes.ts +2 -0
- package/dist/builtin/intercom/index.bundle.mjs +130 -264
- package/dist/builtin/intercom/message-display.ts +42 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/types.ts +1 -0
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +99 -20
- package/dist/builtin/web-access/index.bundle.mjs +15 -9
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +6 -6
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +4 -4
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +3 -3
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session-runtime.d.ts +16 -4
- package/dist/core/agent-session-types.d.ts +5 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.code.js +74 -72
- package/dist/core/export-html/card-projection.code.js.map +1 -1
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +52 -41
- package/dist/core/export-html/index.code.js.map +1 -1
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/template.js +27 -39
- package/dist/core/export-html/tool-renderer.code.js +1 -1
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/context-types.d.ts +3 -0
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +2 -2
- package/dist/core/extensions/runner-context.d.ts +1 -0
- package/dist/core/extensions/runner-context.js +18 -2
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runtime-types.d.ts +1 -0
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/model-registry.js +2 -2
- package/dist/core/model-runtime-streaming.d.ts +3 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/resume/failure.d.ts +1 -1
- package/dist/core/sdk.code.js +4 -4
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-claims.d.ts +13 -2
- package/dist/core/session-load-events.d.ts +42 -0
- package/dist/core/session-manager-core.d.ts +17 -2
- package/dist/core/session-manager-core.js +234 -93
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-errors.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts +1 -1
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +2 -2
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-manager.js +2 -2
- package/dist/core/storage/adapter-open.js +3 -0
- package/dist/core/storage/adapter-open.js.map +1 -0
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.js +1 -0
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +2 -1
- package/dist/core/storage/schema-catalog.js +25 -6
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +17 -4
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +7 -7
- package/dist/core/storage/session/child-reader.code.js.map +1 -1
- package/dist/core/storage/session/child-reader.d.ts +1 -0
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +3 -3
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +9 -5
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +29 -13
- package/dist/core/storage/session/fork-window.code.js.map +1 -1
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.d.ts +8 -4
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.d.ts +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/parent-links.d.ts +122 -0
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +3 -3
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +5 -6
- package/dist/core/storage/session/snapshot-history.code.js.map +1 -1
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +7 -20
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.code.js +1 -1
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/session/types.d.ts +11 -3
- package/dist/core/storage/session/usage-observations.d.ts +27 -0
- package/dist/core/storage/session/usage-observations.js +3 -0
- package/dist/core/storage/session/usage-observations.js.map +1 -0
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/subscription-usage-identity.d.ts +9 -0
- package/dist/core/subscription-usage-observations.d.ts +15 -0
- package/dist/core/subscription-usage-storage.js +3 -0
- package/dist/core/subscription-usage-storage.js.map +1 -0
- package/dist/core/subscription-usage.d.ts +20 -3
- package/dist/core/tasks/task-completion-entry.code.js +1 -1
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +5 -5
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.code.js +1 -1
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +3 -3
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +2 -2
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +12 -7
- package/dist/extensions/codemode/renderer.code.js.map +1 -1
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +10 -10
- package/dist/main-first-time-setup.code.js +2 -2
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/interactive/components/intercom-wake-notice.d.ts +4 -0
- package/dist/modes/interactive/components/notice-line.d.ts +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +6 -5
- package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/tool-block.d.ts +5 -1
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -3
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +5 -0
- package/dist/modes/rpc/rpc-client.d.ts +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +26 -3
- package/dist/package-manager-cli.code.js +7 -7
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/13.js +2 -1
- package/dist/startup-stages/14.js +1 -0
- package/dist/startup-stages/4.js +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/.agents/context/DESIGN.md +30 -0
- package/docs/changelog.mdx +46 -0
- package/docs/docs.json +1 -1
- package/docs/extensions/api-reference.md +6 -0
- package/docs/guides/subscription-usage.md +28 -82
- package/docs/intercom.md +3 -1
- package/docs/json.md +3 -3
- package/docs/providers.md +2 -0
- package/docs/reference/cli.md +3 -1
- package/docs/rpc/protocol.md +31 -3
- package/docs/sdk/reference.md +26 -1
- package/docs/sdk.md +2 -0
- package/docs/sessions.md +38 -1
- package/docs/slash-commands.md +1 -1
- package/docs/subagents.md +2 -0
- package/docs/usage.md +1 -1
- package/package.json +8 -8
- package/dist/_shared/sdk-BHX35EPK.js.map +0 -1
- package/dist/_shared/startup-0-0-4EDVBK5P.js.map +0 -1
- package/dist/_shared/startup-0-1-H5IXVRXQ.js.map +0 -1
- package/dist/_shared/startup-0-2-YZZOC22D.js.map +0 -1
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +0 -1
- package/dist/_shared/startup-0-5-HZX3ZPTP.js.map +0 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js.map +0 -1
- package/dist/_shared/startup-8-1-QZMXUGHI.js.map +0 -1
|
@@ -2773,7 +2773,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
2773
2773
|
return (async () => {
|
|
2774
2774
|
const root = new URL("../../", import.meta.url);
|
|
2775
2775
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
2776
|
-
const key = `${root.href}#0.10.
|
|
2776
|
+
const key = `${root.href}#0.10.20-alpha.2`;
|
|
2777
2777
|
let release = releases.get(key);
|
|
2778
2778
|
if (release === undefined) {
|
|
2779
2779
|
const current = (async () => {
|
|
@@ -2801,7 +2801,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
2801
2801
|
} catch {
|
|
2802
2802
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
2803
2803
|
}
|
|
2804
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.
|
|
2804
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.20-alpha.2" ? installed : running !== undefined && running.version !== "0.10.20-alpha.2" ? "0.10.20-alpha.2" : undefined;
|
|
2805
2805
|
if (updatedTo === undefined) throw error;
|
|
2806
2806
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
2807
2807
|
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.
|
|
9
|
+
const key = `${root.href}#0.10.20-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.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.20-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.20-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.
|
|
9
|
+
const key = `${root.href}#0.10.20-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.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.20-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.20-alpha.2 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -100,6 +100,7 @@ export const POSTGRES_STORAGE_IDENTIFIER_SUFFIXES = Object.freeze([
|
|
|
100
100
|
"session_search_texts",
|
|
101
101
|
"session_search_trgm",
|
|
102
102
|
"session_sessions",
|
|
103
|
+
"session_usage_observations",
|
|
103
104
|
"snapshot_blob_chunks",
|
|
104
105
|
"snapshot_blobs",
|
|
105
106
|
"snapshot_blobs_age",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix.js","sourceRoot":"","sources":["../../../src/core/storage/prefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2B,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAsB,MAAM,CAAC,MAAM,CAAC;IACpF,mBAAmB;IACnB,6BAA6B;IAC7B,2BAA2B;IAC3B,4BAA4B;IAC5B,sCAAsC;IACtC,iCAAiC;IACjC,4BAA4B;IAC5B,iCAAiC;IACjC,qBAAqB;IACrB,iCAAiC;IACjC,yBAAyB;IACzB,kCAAkC;IAClC,mCAAmC;IACnC,qCAAqC;IACrC,8BAA8B;IAC9B,8BAA8B;IAC9B,kCAAkC;IAClC,iBAAiB;IACjB,uBAAuB;IACvB,gCAAgC;IAChC,+BAA+B;IAC/B,6BAA6B;IAC7B,kCAAkC;IAClC,+BAA+B;IAC/B,iBAAiB;IACjB,yBAAyB;IACzB,wBAAwB;IACxB,8BAA8B;IAC9B,6BAA6B;IAC7B,uBAAuB;IACvB,6BAA6B;IAC7B,8BAA8B;IAC9B,wBAAwB;IACxB,gCAAgC;IAChC,yCAAyC;IACzC,iCAAiC;IACjC,wCAAwC;IACxC,uCAAuC;IACvC,sCAAsC;IACtC,gCAAgC;IAChC,wBAAwB;IACxB,iCAAiC;IACjC,2BAA2B;IAC3B,oCAAoC;IACpC,uBAAuB;IACvB,0BAA0B;IAC1B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wB,CACvC,MAA8B,EAC9B,KAAQ,EACR,MAAM,GAAG,EAAE;IAEX,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;IAC/D,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CACnE,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAM,GAAG,EAAE;IAChD,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,mBAAmB,CAAC;AAC5D,CAAC","sourcesContent":["import { postgresDialect, type StorageDialectName } from \"./dialect.js\";\nimport { StoragePrefixError } from \"./errors.js\";\n\n/**\n * What follows the prefix in every identifier Atomic names on PostgreSQL: the tables, indexes, triggers and trigger\n * functions of sessions, worktree snapshots and the Intercom broker state (#5067), the Intercom lease order sequence\n * and the lease table's address indexes (#6560), and those the workflow run journal and\n * worker pools (#4793) of earlier releases left under the same prefix, pooled-stage sessions under\n * `POSTGRES_POOL_SESSION_PREFIX` included. Prefixes stay checked against them all, so a database those releases share\n * keeps every name whole. The storage adapters name none of their own, and\n * Postgres chooses constraint names and the sequences of serial columns itself. Longer pool names are in\n * `POSTGRES_HASHED_STORAGE_IDENTIFIER_SUFFIXES`.\n */\nexport const POSTGRES_STORAGE_IDENTIFIER_SUFFIXES: readonly string[] = Object.freeze([\n\t\"atomic_migrations\",\n\t\"intercom_ended_child_bodies\",\n\t\"intercom_ended_child_meta\",\n\t\"intercom_ended_child_queue\",\n\t\"intercom_ended_child_queue_departure\",\n\t\"intercom_ended_child_queue_home\",\n\t\"intercom_ended_child_wakes\",\n\t\"intercom_ended_child_wakes_home\",\n\t\"intercom_held_sends\",\n\t\"intercom_held_sends_reservation\",\n\t\"intercom_known_sessions\",\n\t\"intercom_known_sessions_alias_id\",\n\t\"intercom_known_sessions_atomic_id\",\n\t\"intercom_known_sessions_intercom_id\",\n\t\"intercom_known_sessions_lost\",\n\t\"intercom_known_sessions_name\",\n\t\"intercom_known_sessions_recorded\",\n\t\"intercom_leases\",\n\t\"intercom_leases_order\",\n\t\"intercom_leases_presence_alias\",\n\t\"intercom_leases_presence_host\",\n\t\"intercom_leases_presence_id\",\n\t\"intercom_leases_presence_id_head\",\n\t\"intercom_leases_presence_name\",\n\t\"intercom_outbox\",\n\t\"intercom_outbox_settled\",\n\t\"intercom_outbox_target\",\n\t\"intercom_outbox_target_bytes\",\n\t\"intercom_outbox_undelivered\",\n\t\"intercom_pending_asks\",\n\t\"intercom_pending_asks_ended\",\n\t\"intercom_pending_asks_target\",\n\t\"intercom_released_asks\",\n\t\"intercom_released_asks_expires\",\n\t\"intercom_restoring_reservation_counters\",\n\t\"intercom_restoring_reservations\",\n\t\"intercom_restoring_reservations_active\",\n\t\"intercom_restoring_reservations_child\",\n\t\"intercom_restoring_reservations_wake\",\n\t\"intercom_restoring_wake_claims\",\n\t\"intercom_sent_messages\",\n\t\"intercom_sent_messages_recorded\",\n\t\"intercom_session_bindings\",\n\t\"intercom_session_bindings_recorded\",\n\t\"intercom_settled_asks\",\n\t\"intercom_settled_asks_at\",\n\t\"intercom_wakeups\",\n\t\"intercom_wakeups_broker\",\n\t\"intercom_wakeups_created\",\n\t\"session_blob_chunks\",\n\t\"session_blobs\",\n\t\"session_capture_headings\",\n\t\"session_chat_v1\",\n\t\"session_chat_v1_anchor\",\n\t\"session_entries\",\n\t\"session_entries_capture_del\",\n\t\"session_entries_capture_del_fn\",\n\t\"session_entries_capture_head\",\n\t\"session_entries_capture_head_fn\",\n\t\"session_entries_capture_heading\",\n\t\"session_entries_capture_ins\",\n\t\"session_entries_capture_ins_fn\",\n\t\"session_entries_capture_upd\",\n\t\"session_entries_capture_upd_fn\",\n\t\"session_entries_search_forget\",\n\t\"session_entries_search_forget_fn\",\n\t\"session_entries_snapshot_links\",\n\t\"session_entries_snapshot_links_fn\",\n\t\"session_entries_snapshot_pending\",\n\t\"session_entries_snapshot_pending_fn\",\n\t\"session_entries_snapshot_refs\",\n\t\"session_entries_snapshot_refs_delete\",\n\t\"session_entries_snapshot_refs_delete_fn\",\n\t\"session_entries_snapshot_refs_fn\",\n\t\"session_entry_chunks\",\n\t\"session_fork_detach\",\n\t\"session_fork_lineage\",\n\t\"session_fork_segments\",\n\t\"session_fork_segments_source\",\n\t\"session_fork_staging\",\n\t\"session_fork_staging_name\",\n\t\"session_fork_tombstones\",\n\t\"session_meta\",\n\t\"session_open\",\n\t\"session_search_entries\",\n\t\"session_search_state\",\n\t\"session_search_texts\",\n\t\"session_search_trgm\",\n\t\"session_sessions\",\n\t\"snapshot_blob_chunks\",\n\t\"snapshot_blobs\",\n\t\"snapshot_blobs_age\",\n\t\"snapshot_blobs_chunks_delete_all\",\n\t\"snapshot_blobs_chunks_delete_all_fn\",\n\t\"snapshot_blobs_fork_keep\",\n\t\"snapshot_blobs_fork_keep_fn\",\n\t\"snapshot_blobs_inline_size\",\n\t\"snapshot_carried_refs\",\n\t\"snapshot_carried_refs_hash\",\n\t\"snapshot_collection\",\n\t\"snapshot_index_sources\",\n\t\"snapshot_run_refs\",\n\t\"snapshot_run_refs_hash\",\n\t\"snapshot_run_state\",\n\t\"snapshot_session_links\",\n\t\"snapshot_session_links_anchored\",\n\t\"snapshot_session_links_broken\",\n\t\"snapshot_session_links_entry\",\n\t\"snapshot_session_records\",\n\t\"snapshot_session_records_hash\",\n\t\"snapshot_session_refs\",\n\t\"wf_event_chunks\",\n\t\"wf_events\",\n\t\"wf_events_snapshot_refs\",\n\t\"wf_events_snapshot_refs_fn\",\n\t\"wf_events_snapshot_state\",\n\t\"wf_events_snapshot_state_fn\",\n\t\"wf_lease_builds\",\n\t\"wf_leases\",\n\t\"wf_meta\",\n\t\"wf_ps_atomic_migrations\",\n\t\"wf_ps_session_blob_chunks\",\n\t\"wf_ps_session_blobs\",\n\t\"wf_ps_session_entries\",\n\t\"wf_ps_session_entries_search_forget\",\n\t\"wf_ps_session_entries_search_forget_fn\",\n\t\"wf_ps_session_entries_snapshot_links\",\n\t\"wf_ps_session_entries_snapshot_links_fn\",\n\t\"wf_ps_session_entries_snapshot_pending\",\n\t\"wf_ps_session_entries_snapshot_refs\",\n\t\"wf_ps_session_entries_snapshot_refs_fn\",\n\t\"wf_ps_session_entry_chunks\",\n\t\"wf_ps_session_meta\",\n\t\"wf_ps_session_open\",\n\t\"wf_ps_session_owners\",\n\t\"wf_ps_session_search_entries\",\n\t\"wf_ps_session_search_state\",\n\t\"wf_ps_session_search_texts\",\n\t\"wf_ps_session_search_trgm\",\n\t\"wf_ps_session_sessions\",\n\t\"wf_ps_snapshot_blob_chunks\",\n\t\"wf_ps_snapshot_blobs\",\n\t\"wf_ps_snapshot_blobs_age\",\n\t\"wf_ps_snapshot_blobs_chunks_delete_all\",\n\t\"wf_ps_snapshot_blobs_inline_size\",\n\t\"wf_ps_snapshot_carried_refs\",\n\t\"wf_ps_snapshot_carried_refs_hash\",\n\t\"wf_ps_snapshot_collection\",\n\t\"wf_ps_snapshot_index_sources\",\n\t\"wf_ps_snapshot_run_refs\",\n\t\"wf_ps_snapshot_run_refs_hash\",\n\t\"wf_ps_snapshot_run_state\",\n\t\"wf_ps_snapshot_session_links\",\n\t\"wf_ps_snapshot_session_links_broken\",\n\t\"wf_ps_snapshot_session_links_entry\",\n\t\"wf_ps_snapshot_session_links_leaves\",\n\t\"wf_ps_snapshot_session_records\",\n\t\"wf_ps_snapshot_session_records_hash\",\n\t\"wf_ps_snapshot_session_refs\",\n\t\"wf_runs\",\n\t\"wf_runs_fleet_controller\",\n\t\"wf_runs_fleet_drains\",\n\t\"wf_runs_fleet_events\",\n\t\"wf_runs_pool\",\n\t\"wf_runs_pool_activity\",\n\t\"wf_runs_pool_activity_version\",\n\t\"wf_runs_pool_control\",\n\t\"wf_runs_pool_fence\",\n\t\"wf_runs_pool_fence_abort\",\n\t\"wf_runs_pool_fence_abort_fn\",\n\t\"wf_runs_pool_hosts\",\n\t\"wf_runs_pool_meta\",\n\t\"wf_runs_pool_operations\",\n\t\"wf_runs_pool_restore_backoffs\",\n\t\"wf_runs_pool_root_snapshot\",\n\t\"wf_runs_pool_shared\",\n\t\"wf_runs_pool_usage\",\n\t\"wf_runs_pool_usage_totals\",\n\t\"wf_runs_pool_usage_totals_delete\",\n\t\"wf_runs_pool_usage_totals_delete_fn\",\n\t\"wf_runs_pool_usage_totals_insert\",\n\t\"wf_runs_pool_usage_totals_insert_fn\",\n\t\"wf_runs_pool_usage_totals_update\",\n\t\"wf_runs_pool_usage_totals_update_fn\",\n\t\"wf_runs_pool_usage_totals_work_delete\",\n\t\"wf_runs_rate_buckets\",\n\t\"wf_runs_rate_waiting\",\n\t\"wf_runs_rate_waiting_age\",\n\t\"wf_runs_resource_limits\",\n\t\"wf_runs_resource_owners\",\n\t\"wf_runs_resource_permits\",\n\t\"wf_runs_resource_permits_active\",\n\t\"wf_runs_resource_permits_owner\",\n\t\"wf_runs_resource_permits_state\",\n\t\"wf_runs_ship_batches\",\n\t\"wf_runs_ship_batches_work\",\n\t\"wf_runs_ship_watermarks\",\n\t\"wf_runs_snapshot_refs_delete\",\n\t\"wf_runs_snapshot_refs_delete_fn\",\n\t\"wf_runs_snapshot_state_insert\",\n\t\"wf_runs_snapshot_state_insert_fn\",\n\t\"wf_runs_snapshot_state_status\",\n\t\"wf_runs_snapshot_state_status_fn\",\n\t\"wf_runs_stage_inputs\",\n\t\"wf_runs_stage_inputs_pending\",\n\t\"wf_runs_stage_leases\",\n\t\"wf_runs_stage_workspaces\",\n\t\"wf_runs_work\",\n\t\"wf_runs_work_child\",\n\t\"wf_runs_work_expiry\",\n\t\"wf_runs_work_input_chunks\",\n\t\"wf_runs_work_ready\",\n\t\"wf_runs_work_result_chunks\",\n\t\"wf_runs_work_results\",\n\t\"wf_runs_work_scope\",\n\t\"wf_runs_work_snapshot_carried_delete\",\n\t\"wf_runs_work_snapshot_carried_delete_fn\",\n\t\"wf_runs_work_snapshot_carried_insert\",\n\t\"wf_runs_work_snapshot_carried_insert_fn\",\n\t\"wf_runs_work_snapshot_carried_update\",\n\t\"wf_runs_work_snapshot_carried_update_fn\",\n]);\n\n/**\n * What follows the prefix in the triggers and trigger functions of a worker pool (#4793) whose names are longer than\n * `POSTGRES_STORAGE_IDENTIFIER_SUFFIXES` allows. Under a prefix that makes one longer than 63 bytes, Postgres knows it by\n * `postgresDialect.identifier` of the whole name (its head and a hash), in every statement and catalog probe alike; under\n * a shorter prefix, by the whole name. They do not limit the prefix.\n */\nexport const POSTGRES_HASHED_STORAGE_IDENTIFIER_SUFFIXES: readonly string[] = Object.freeze([\n\t\"wf_ps_session_entries_snapshot_pending_fn\",\n\t\"wf_ps_session_entries_snapshot_refs_delete\",\n\t\"wf_ps_session_entries_snapshot_refs_delete_fn\",\n\t\"wf_ps_snapshot_blobs_chunks_delete_all_fn\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_delete\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_delete_fn\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_insert\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_insert_fn\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_update\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_update_fn\",\n\t\"wf_runs_pool_usage_totals_work_delete_fn\",\n]);\n\n/**\n * The longest storage prefix PostgreSQL takes: Postgres truncates an identifier longer than 63 bytes, so a longer\n * prefix would cut the longest name Atomic gives it, or make two names one. Prefixes are ASCII, one byte a character.\n */\nexport const POSTGRES_MAX_STORAGE_PREFIX_LENGTH =\n\t63 - Math.max(...POSTGRES_STORAGE_IDENTIFIER_SUFFIXES.map((suffix) => suffix.length));\n\n/**\n * What a worker pool of an earlier release added to the journal's prefix for the stores it carried on PostgreSQL: its\n * pooled-stage sessions and their snapshot index live under `<prefix>wf_ps_` (#4793). The length limit applies to the\n * prefix before it.\n */\nexport const POSTGRES_POOL_SESSION_PREFIX = \"wf_ps_\";\n\n/**\n * Check a storage prefix, and with `dialect`, that the backend can name every identifier under it. SQLite\n * have no identifier limit. On PostgreSQL the limit applies to the prefix a user chose: a worker pool's session prefix\n * (`<prefix>wf_ps_`) is checked as the prefix before it.\n */\nexport function validateStoragePrefix(prefix = \"\", dialect?: StorageDialectName): string {\n\tif (prefix !== \"\" && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(prefix)) {\n\t\tthrow new StoragePrefixError(prefix, \"pattern\");\n\t}\n\tif (/^sqlite_/i.test(prefix)) throw new StoragePrefixError(prefix, \"reserved\");\n\tconst chosen = prefix.endsWith(POSTGRES_POOL_SESSION_PREFIX)\n\t\t? prefix.slice(0, -POSTGRES_POOL_SESSION_PREFIX.length)\n\t\t: prefix;\n\tif (dialect === \"postgres\" && /[A-Z]/.test(prefix)) throw new StoragePrefixError(prefix, \"uppercase\");\n\tif (dialect === \"postgres\" && chosen.length > POSTGRES_MAX_STORAGE_PREFIX_LENGTH)\n\t\tthrow new StoragePrefixError(prefix, \"too-long\", POSTGRES_MAX_STORAGE_PREFIX_LENGTH);\n\tif (dialect === \"postgres\") {\n\t\tconst collision = postgresIdentifierCollision(chosen);\n\t\tif (collision !== undefined) throw new StoragePrefixError(prefix, \"identifier-collision\", undefined, collision);\n\t}\n\treturn prefix;\n}\n\nconst postgresCollisions = new Map<string, string | undefined>();\n\n/**\n * The identifier PostgreSQL would know two of the names under `prefix` by, if any (#5219): a name too long to keep whole\n * is its head and a hash of the whole name, so two names that share their head differ only in that hash.\n */\nfunction postgresIdentifierCollision(prefix: string): string | undefined {\n\tif (postgresCollisions.has(prefix)) return postgresCollisions.get(prefix);\n\tconst seen = new Set<string>();\n\tlet collision: string | undefined;\n\tfor (const suffix of [...POSTGRES_STORAGE_IDENTIFIER_SUFFIXES, ...POSTGRES_HASHED_STORAGE_IDENTIFIER_SUFFIXES]) {\n\t\tconst identifier = postgresDialect.identifier(`${prefix}${suffix}`);\n\t\tif (seen.has(identifier)) {\n\t\t\tcollision = identifier;\n\t\t\tbreak;\n\t\t}\n\t\tseen.add(identifier);\n\t}\n\tpostgresCollisions.set(prefix, collision);\n\treturn collision;\n}\n\nexport function renderStorageIdentifiers<T extends Readonly<Record<string, string>>>(\n\tdomain: \"journal\" | \"sessions\",\n\tnames: T,\n\tprefix = \"\",\n): Readonly<{ [K in keyof T]: string }> {\n\tconst validated = validateStoragePrefix(prefix);\n\tconst domainPrefix = domain === \"journal\" ? \"wf_\" : \"session_\";\n\treturn Object.freeze(\n\t\tObject.fromEntries(Object.entries(names).map(([key, name]) => [key, `${validated}${domainPrefix}${name}`])),\n\t) as Readonly<{ [K in keyof T]: string }>;\n}\n\n/**\n * The ledger `applyStorageMigrations` records each domain's applied versions in, one per prefix: the Postgres schema\n * of every domain under `prefix` (#4793). SQLite keeps no ledger, so its schema is unchanged.\n */\nexport function storageMigrationTable(prefix = \"\"): string {\n\treturn `${validateStoragePrefix(prefix)}atomic_migrations`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prefix.js","sourceRoot":"","sources":["../../../src/core/storage/prefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2B,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAsB,MAAM,CAAC,MAAM,CAAC;IACpF,mBAAmB;IACnB,6BAA6B;IAC7B,2BAA2B;IAC3B,4BAA4B;IAC5B,sCAAsC;IACtC,iCAAiC;IACjC,4BAA4B;IAC5B,iCAAiC;IACjC,qBAAqB;IACrB,iCAAiC;IACjC,yBAA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,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,SAA6B,CAAC;IAClC,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,oCAAoC,EAAE,GAAG,2CAA2C,CAAC,EAAE,CAAC;QAChH,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;QACpE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1B,SAAS,GAAG,UAAU,CAAC;YACvB,MAAM;QACP,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IACD,kBAAkB,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,wBAAwB,CACvC,MAA8B,EAC9B,KAAQ,EACR,MAAM,GAAG,EAAE;IAEX,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;IAC/D,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CACnE,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAM,GAAG,EAAE;IAChD,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,mBAAmB,CAAC;AAC5D,CAAC","sourcesContent":["import { postgresDialect, type StorageDialectName } from \"./dialect.js\";\nimport { StoragePrefixError } from \"./errors.js\";\n\n/**\n * What follows the prefix in every identifier Atomic names on PostgreSQL: the tables, indexes, triggers and trigger\n * functions of sessions, worktree snapshots and the Intercom broker state (#5067), the Intercom lease order sequence\n * and the lease table's address indexes (#6560), and those the workflow run journal and\n * worker pools (#4793) of earlier releases left under the same prefix, pooled-stage sessions under\n * `POSTGRES_POOL_SESSION_PREFIX` included. Prefixes stay checked against them all, so a database those releases share\n * keeps every name whole. The storage adapters name none of their own, and\n * Postgres chooses constraint names and the sequences of serial columns itself. Longer pool names are in\n * `POSTGRES_HASHED_STORAGE_IDENTIFIER_SUFFIXES`.\n */\nexport const POSTGRES_STORAGE_IDENTIFIER_SUFFIXES: readonly string[] = Object.freeze([\n\t\"atomic_migrations\",\n\t\"intercom_ended_child_bodies\",\n\t\"intercom_ended_child_meta\",\n\t\"intercom_ended_child_queue\",\n\t\"intercom_ended_child_queue_departure\",\n\t\"intercom_ended_child_queue_home\",\n\t\"intercom_ended_child_wakes\",\n\t\"intercom_ended_child_wakes_home\",\n\t\"intercom_held_sends\",\n\t\"intercom_held_sends_reservation\",\n\t\"intercom_known_sessions\",\n\t\"intercom_known_sessions_alias_id\",\n\t\"intercom_known_sessions_atomic_id\",\n\t\"intercom_known_sessions_intercom_id\",\n\t\"intercom_known_sessions_lost\",\n\t\"intercom_known_sessions_name\",\n\t\"intercom_known_sessions_recorded\",\n\t\"intercom_leases\",\n\t\"intercom_leases_order\",\n\t\"intercom_leases_presence_alias\",\n\t\"intercom_leases_presence_host\",\n\t\"intercom_leases_presence_id\",\n\t\"intercom_leases_presence_id_head\",\n\t\"intercom_leases_presence_name\",\n\t\"intercom_outbox\",\n\t\"intercom_outbox_settled\",\n\t\"intercom_outbox_target\",\n\t\"intercom_outbox_target_bytes\",\n\t\"intercom_outbox_undelivered\",\n\t\"intercom_pending_asks\",\n\t\"intercom_pending_asks_ended\",\n\t\"intercom_pending_asks_target\",\n\t\"intercom_released_asks\",\n\t\"intercom_released_asks_expires\",\n\t\"intercom_restoring_reservation_counters\",\n\t\"intercom_restoring_reservations\",\n\t\"intercom_restoring_reservations_active\",\n\t\"intercom_restoring_reservations_child\",\n\t\"intercom_restoring_reservations_wake\",\n\t\"intercom_restoring_wake_claims\",\n\t\"intercom_sent_messages\",\n\t\"intercom_sent_messages_recorded\",\n\t\"intercom_session_bindings\",\n\t\"intercom_session_bindings_recorded\",\n\t\"intercom_settled_asks\",\n\t\"intercom_settled_asks_at\",\n\t\"intercom_wakeups\",\n\t\"intercom_wakeups_broker\",\n\t\"intercom_wakeups_created\",\n\t\"session_blob_chunks\",\n\t\"session_blobs\",\n\t\"session_capture_headings\",\n\t\"session_chat_v1\",\n\t\"session_chat_v1_anchor\",\n\t\"session_entries\",\n\t\"session_entries_capture_del\",\n\t\"session_entries_capture_del_fn\",\n\t\"session_entries_capture_head\",\n\t\"session_entries_capture_head_fn\",\n\t\"session_entries_capture_heading\",\n\t\"session_entries_capture_ins\",\n\t\"session_entries_capture_ins_fn\",\n\t\"session_entries_capture_upd\",\n\t\"session_entries_capture_upd_fn\",\n\t\"session_entries_search_forget\",\n\t\"session_entries_search_forget_fn\",\n\t\"session_entries_snapshot_links\",\n\t\"session_entries_snapshot_links_fn\",\n\t\"session_entries_snapshot_pending\",\n\t\"session_entries_snapshot_pending_fn\",\n\t\"session_entries_snapshot_refs\",\n\t\"session_entries_snapshot_refs_delete\",\n\t\"session_entries_snapshot_refs_delete_fn\",\n\t\"session_entries_snapshot_refs_fn\",\n\t\"session_entry_chunks\",\n\t\"session_fork_detach\",\n\t\"session_fork_lineage\",\n\t\"session_fork_segments\",\n\t\"session_fork_segments_source\",\n\t\"session_fork_staging\",\n\t\"session_fork_staging_name\",\n\t\"session_fork_tombstones\",\n\t\"session_meta\",\n\t\"session_open\",\n\t\"session_search_entries\",\n\t\"session_search_state\",\n\t\"session_search_texts\",\n\t\"session_search_trgm\",\n\t\"session_sessions\",\n\t\"session_usage_observations\",\n\t\"snapshot_blob_chunks\",\n\t\"snapshot_blobs\",\n\t\"snapshot_blobs_age\",\n\t\"snapshot_blobs_chunks_delete_all\",\n\t\"snapshot_blobs_chunks_delete_all_fn\",\n\t\"snapshot_blobs_fork_keep\",\n\t\"snapshot_blobs_fork_keep_fn\",\n\t\"snapshot_blobs_inline_size\",\n\t\"snapshot_carried_refs\",\n\t\"snapshot_carried_refs_hash\",\n\t\"snapshot_collection\",\n\t\"snapshot_index_sources\",\n\t\"snapshot_run_refs\",\n\t\"snapshot_run_refs_hash\",\n\t\"snapshot_run_state\",\n\t\"snapshot_session_links\",\n\t\"snapshot_session_links_anchored\",\n\t\"snapshot_session_links_broken\",\n\t\"snapshot_session_links_entry\",\n\t\"snapshot_session_records\",\n\t\"snapshot_session_records_hash\",\n\t\"snapshot_session_refs\",\n\t\"wf_event_chunks\",\n\t\"wf_events\",\n\t\"wf_events_snapshot_refs\",\n\t\"wf_events_snapshot_refs_fn\",\n\t\"wf_events_snapshot_state\",\n\t\"wf_events_snapshot_state_fn\",\n\t\"wf_lease_builds\",\n\t\"wf_leases\",\n\t\"wf_meta\",\n\t\"wf_ps_atomic_migrations\",\n\t\"wf_ps_session_blob_chunks\",\n\t\"wf_ps_session_blobs\",\n\t\"wf_ps_session_entries\",\n\t\"wf_ps_session_entries_search_forget\",\n\t\"wf_ps_session_entries_search_forget_fn\",\n\t\"wf_ps_session_entries_snapshot_links\",\n\t\"wf_ps_session_entries_snapshot_links_fn\",\n\t\"wf_ps_session_entries_snapshot_pending\",\n\t\"wf_ps_session_entries_snapshot_refs\",\n\t\"wf_ps_session_entries_snapshot_refs_fn\",\n\t\"wf_ps_session_entry_chunks\",\n\t\"wf_ps_session_meta\",\n\t\"wf_ps_session_open\",\n\t\"wf_ps_session_owners\",\n\t\"wf_ps_session_search_entries\",\n\t\"wf_ps_session_search_state\",\n\t\"wf_ps_session_search_texts\",\n\t\"wf_ps_session_search_trgm\",\n\t\"wf_ps_session_sessions\",\n\t\"wf_ps_snapshot_blob_chunks\",\n\t\"wf_ps_snapshot_blobs\",\n\t\"wf_ps_snapshot_blobs_age\",\n\t\"wf_ps_snapshot_blobs_chunks_delete_all\",\n\t\"wf_ps_snapshot_blobs_inline_size\",\n\t\"wf_ps_snapshot_carried_refs\",\n\t\"wf_ps_snapshot_carried_refs_hash\",\n\t\"wf_ps_snapshot_collection\",\n\t\"wf_ps_snapshot_index_sources\",\n\t\"wf_ps_snapshot_run_refs\",\n\t\"wf_ps_snapshot_run_refs_hash\",\n\t\"wf_ps_snapshot_run_state\",\n\t\"wf_ps_snapshot_session_links\",\n\t\"wf_ps_snapshot_session_links_broken\",\n\t\"wf_ps_snapshot_session_links_entry\",\n\t\"wf_ps_snapshot_session_links_leaves\",\n\t\"wf_ps_snapshot_session_records\",\n\t\"wf_ps_snapshot_session_records_hash\",\n\t\"wf_ps_snapshot_session_refs\",\n\t\"wf_runs\",\n\t\"wf_runs_fleet_controller\",\n\t\"wf_runs_fleet_drains\",\n\t\"wf_runs_fleet_events\",\n\t\"wf_runs_pool\",\n\t\"wf_runs_pool_activity\",\n\t\"wf_runs_pool_activity_version\",\n\t\"wf_runs_pool_control\",\n\t\"wf_runs_pool_fence\",\n\t\"wf_runs_pool_fence_abort\",\n\t\"wf_runs_pool_fence_abort_fn\",\n\t\"wf_runs_pool_hosts\",\n\t\"wf_runs_pool_meta\",\n\t\"wf_runs_pool_operations\",\n\t\"wf_runs_pool_restore_backoffs\",\n\t\"wf_runs_pool_root_snapshot\",\n\t\"wf_runs_pool_shared\",\n\t\"wf_runs_pool_usage\",\n\t\"wf_runs_pool_usage_totals\",\n\t\"wf_runs_pool_usage_totals_delete\",\n\t\"wf_runs_pool_usage_totals_delete_fn\",\n\t\"wf_runs_pool_usage_totals_insert\",\n\t\"wf_runs_pool_usage_totals_insert_fn\",\n\t\"wf_runs_pool_usage_totals_update\",\n\t\"wf_runs_pool_usage_totals_update_fn\",\n\t\"wf_runs_pool_usage_totals_work_delete\",\n\t\"wf_runs_rate_buckets\",\n\t\"wf_runs_rate_waiting\",\n\t\"wf_runs_rate_waiting_age\",\n\t\"wf_runs_resource_limits\",\n\t\"wf_runs_resource_owners\",\n\t\"wf_runs_resource_permits\",\n\t\"wf_runs_resource_permits_active\",\n\t\"wf_runs_resource_permits_owner\",\n\t\"wf_runs_resource_permits_state\",\n\t\"wf_runs_ship_batches\",\n\t\"wf_runs_ship_batches_work\",\n\t\"wf_runs_ship_watermarks\",\n\t\"wf_runs_snapshot_refs_delete\",\n\t\"wf_runs_snapshot_refs_delete_fn\",\n\t\"wf_runs_snapshot_state_insert\",\n\t\"wf_runs_snapshot_state_insert_fn\",\n\t\"wf_runs_snapshot_state_status\",\n\t\"wf_runs_snapshot_state_status_fn\",\n\t\"wf_runs_stage_inputs\",\n\t\"wf_runs_stage_inputs_pending\",\n\t\"wf_runs_stage_leases\",\n\t\"wf_runs_stage_workspaces\",\n\t\"wf_runs_work\",\n\t\"wf_runs_work_child\",\n\t\"wf_runs_work_expiry\",\n\t\"wf_runs_work_input_chunks\",\n\t\"wf_runs_work_ready\",\n\t\"wf_runs_work_result_chunks\",\n\t\"wf_runs_work_results\",\n\t\"wf_runs_work_scope\",\n\t\"wf_runs_work_snapshot_carried_delete\",\n\t\"wf_runs_work_snapshot_carried_delete_fn\",\n\t\"wf_runs_work_snapshot_carried_insert\",\n\t\"wf_runs_work_snapshot_carried_insert_fn\",\n\t\"wf_runs_work_snapshot_carried_update\",\n\t\"wf_runs_work_snapshot_carried_update_fn\",\n]);\n\n/**\n * What follows the prefix in the triggers and trigger functions of a worker pool (#4793) whose names are longer than\n * `POSTGRES_STORAGE_IDENTIFIER_SUFFIXES` allows. Under a prefix that makes one longer than 63 bytes, Postgres knows it by\n * `postgresDialect.identifier` of the whole name (its head and a hash), in every statement and catalog probe alike; under\n * a shorter prefix, by the whole name. They do not limit the prefix.\n */\nexport const POSTGRES_HASHED_STORAGE_IDENTIFIER_SUFFIXES: readonly string[] = Object.freeze([\n\t\"wf_ps_session_entries_snapshot_pending_fn\",\n\t\"wf_ps_session_entries_snapshot_refs_delete\",\n\t\"wf_ps_session_entries_snapshot_refs_delete_fn\",\n\t\"wf_ps_snapshot_blobs_chunks_delete_all_fn\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_delete\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_delete_fn\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_insert\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_insert_fn\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_update\",\n\t\"wf_runs_pool_root_snapshot_snapshot_carried_update_fn\",\n\t\"wf_runs_pool_usage_totals_work_delete_fn\",\n]);\n\n/**\n * The longest storage prefix PostgreSQL takes: Postgres truncates an identifier longer than 63 bytes, so a longer\n * prefix would cut the longest name Atomic gives it, or make two names one. Prefixes are ASCII, one byte a character.\n */\nexport const POSTGRES_MAX_STORAGE_PREFIX_LENGTH =\n\t63 - Math.max(...POSTGRES_STORAGE_IDENTIFIER_SUFFIXES.map((suffix) => suffix.length));\n\n/**\n * What a worker pool of an earlier release added to the journal's prefix for the stores it carried on PostgreSQL: its\n * pooled-stage sessions and their snapshot index live under `<prefix>wf_ps_` (#4793). The length limit applies to the\n * prefix before it.\n */\nexport const POSTGRES_POOL_SESSION_PREFIX = \"wf_ps_\";\n\n/**\n * Check a storage prefix, and with `dialect`, that the backend can name every identifier under it. SQLite\n * have no identifier limit. On PostgreSQL the limit applies to the prefix a user chose: a worker pool's session prefix\n * (`<prefix>wf_ps_`) is checked as the prefix before it.\n */\nexport function validateStoragePrefix(prefix = \"\", dialect?: StorageDialectName): string {\n\tif (prefix !== \"\" && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(prefix)) {\n\t\tthrow new StoragePrefixError(prefix, \"pattern\");\n\t}\n\tif (/^sqlite_/i.test(prefix)) throw new StoragePrefixError(prefix, \"reserved\");\n\tconst chosen = prefix.endsWith(POSTGRES_POOL_SESSION_PREFIX)\n\t\t? prefix.slice(0, -POSTGRES_POOL_SESSION_PREFIX.length)\n\t\t: prefix;\n\tif (dialect === \"postgres\" && /[A-Z]/.test(prefix)) throw new StoragePrefixError(prefix, \"uppercase\");\n\tif (dialect === \"postgres\" && chosen.length > POSTGRES_MAX_STORAGE_PREFIX_LENGTH)\n\t\tthrow new StoragePrefixError(prefix, \"too-long\", POSTGRES_MAX_STORAGE_PREFIX_LENGTH);\n\tif (dialect === \"postgres\") {\n\t\tconst collision = postgresIdentifierCollision(chosen);\n\t\tif (collision !== undefined) throw new StoragePrefixError(prefix, \"identifier-collision\", undefined, collision);\n\t}\n\treturn prefix;\n}\n\nconst postgresCollisions = new Map<string, string | undefined>();\n\n/**\n * The identifier PostgreSQL would know two of the names under `prefix` by, if any (#5219): a name too long to keep whole\n * is its head and a hash of the whole name, so two names that share their head differ only in that hash.\n */\nfunction postgresIdentifierCollision(prefix: string): string | undefined {\n\tif (postgresCollisions.has(prefix)) return postgresCollisions.get(prefix);\n\tconst seen = new Set<string>();\n\tlet collision: string | undefined;\n\tfor (const suffix of [...POSTGRES_STORAGE_IDENTIFIER_SUFFIXES, ...POSTGRES_HASHED_STORAGE_IDENTIFIER_SUFFIXES]) {\n\t\tconst identifier = postgresDialect.identifier(`${prefix}${suffix}`);\n\t\tif (seen.has(identifier)) {\n\t\t\tcollision = identifier;\n\t\t\tbreak;\n\t\t}\n\t\tseen.add(identifier);\n\t}\n\tpostgresCollisions.set(prefix, collision);\n\treturn collision;\n}\n\nexport function renderStorageIdentifiers<T extends Readonly<Record<string, string>>>(\n\tdomain: \"journal\" | \"sessions\",\n\tnames: T,\n\tprefix = \"\",\n): Readonly<{ [K in keyof T]: string }> {\n\tconst validated = validateStoragePrefix(prefix);\n\tconst domainPrefix = domain === \"journal\" ? \"wf_\" : \"session_\";\n\treturn Object.freeze(\n\t\tObject.fromEntries(Object.entries(names).map(([key, name]) => [key, `${validated}${domainPrefix}${name}`])),\n\t) as Readonly<{ [K in keyof T]: string }>;\n}\n\n/**\n * The ledger `applyStorageMigrations` records each domain's applied versions in, one per prefix: the Postgres schema\n * of every domain under `prefix` (#4793). SQLite keeps no ledger, so its schema is unchanged.\n */\nexport function storageMigrationTable(prefix = \"\"): string {\n\treturn `${validateStoragePrefix(prefix)}atomic_migrations`;\n}\n"]}
|
|
@@ -443,7 +443,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
443
443
|
return (async () => {
|
|
444
444
|
const root = new URL("../../", import.meta.url);
|
|
445
445
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
446
|
-
const key = `${root.href}#0.10.
|
|
446
|
+
const key = `${root.href}#0.10.20-alpha.2`;
|
|
447
447
|
let release = releases.get(key);
|
|
448
448
|
if (release === undefined) {
|
|
449
449
|
const current = (async () => {
|
|
@@ -471,7 +471,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
471
471
|
} catch {
|
|
472
472
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
473
473
|
}
|
|
474
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.
|
|
474
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.20-alpha.2" ? installed : running !== undefined && running.version !== "0.10.20-alpha.2" ? "0.10.20-alpha.2" : undefined;
|
|
475
475
|
if (updatedTo === undefined) throw error;
|
|
476
476
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
477
477
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|
|
@@ -166,8 +166,9 @@ export declare function queueSqliteSchemaSetup(database: SqliteDatabase, ledger:
|
|
|
166
166
|
/**
|
|
167
167
|
* @internal Executes and commits any SQLite schema setups queued so far in the active open scope, before the open
|
|
168
168
|
* needs their committed tables or evaluated outcomes (#6709). No-op when nothing is queued or outside a SQLite open.
|
|
169
|
+
* Pass `unaffectedStampPrefix` only for domains whose schema and seed data none of the queued setups can change.
|
|
169
170
|
*/
|
|
170
|
-
export declare function flushStorageSchemaSetups(database: SqliteDatabase, ledger?: string): Promise<void>;
|
|
171
|
+
export declare function flushStorageSchemaSetups(database: SqliteDatabase, ledger?: string, unaffectedStampPrefix?: string): Promise<void>;
|
|
171
172
|
/**
|
|
172
173
|
* @internal Tells the open of `database` in progress that it checked `setup`, the schema setup `stamp` names, without
|
|
173
174
|
* its stamp (SQLite only): it ran it in a transaction that stamped it, found every object it creates in the
|
|
@@ -35,6 +35,7 @@ UNION ALL SELECT 'function', p.proname::text, CASE WHEN has_function_privilege(p
|
|
|
35
35
|
const SQLITE_CATALOG_SQL = `SELECT 'object' AS kind, name, type AS detail FROM sqlite_master
|
|
36
36
|
UNION ALL SELECT 'column', m.name, c.name FROM sqlite_master AS m JOIN pragma_table_xinfo(m.name) AS c
|
|
37
37
|
WHERE m.type = 'table'`;
|
|
38
|
+
const SQLITE_CATALOG_VERSION_SQL = "UNION ALL SELECT 'version', '', CAST(schema_version AS TEXT) FROM pragma_schema_version";
|
|
38
39
|
/**
|
|
39
40
|
* @internal The table under `ledger`'s prefix where SQLite record which revision of each store's schema
|
|
40
41
|
* setup ran, and the database's schema version (`PRAGMA schema_version`) once it had: `domain`, `revision`,
|
|
@@ -109,24 +110,28 @@ export async function recordSqliteSchemaStamps(tx, stamps, options = {}) {
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
/** The catalog of a SQLite database, or undefined when it cannot be read, such as on a SQLite too old. */
|
|
112
|
-
async function readSqliteCatalog(database, ledger) {
|
|
113
|
+
async function readSqliteCatalog(database, ledger, includeVersion = false) {
|
|
113
114
|
let rows;
|
|
114
115
|
try {
|
|
115
|
-
rows = await database.all(SQLITE_CATALOG_SQL);
|
|
116
|
+
rows = await database.all(includeVersion ? `${SQLITE_CATALOG_SQL}\n${SQLITE_CATALOG_VERSION_SQL}` : SQLITE_CATALOG_SQL);
|
|
116
117
|
}
|
|
117
118
|
catch {
|
|
118
119
|
return undefined;
|
|
119
120
|
}
|
|
120
121
|
const types = new Map();
|
|
121
122
|
const columns = new Set();
|
|
123
|
+
let schemaVersion;
|
|
122
124
|
for (const row of rows) {
|
|
123
125
|
if (row.kind === "column")
|
|
124
126
|
columns.add(`${row.name}\0${row.detail}`);
|
|
127
|
+
else if (row.kind === "version")
|
|
128
|
+
schemaVersion = Number(row.detail);
|
|
125
129
|
else
|
|
126
130
|
types.set(row.name, String(row.detail));
|
|
127
131
|
}
|
|
128
132
|
return {
|
|
129
133
|
ledger,
|
|
134
|
+
...(schemaVersion === undefined ? {} : { schemaVersion }),
|
|
130
135
|
// SQLite records no versions: its stores' stamps are read on their own (`sqliteSchemaStampsOf`).
|
|
131
136
|
recordedVersion: () => 0,
|
|
132
137
|
hasTable: (table) => types.get(table) === "table",
|
|
@@ -378,14 +383,15 @@ export function queueSqliteSchemaSetup(database, ledger, setup) {
|
|
|
378
383
|
/**
|
|
379
384
|
* @internal Executes and commits any SQLite schema setups queued so far in the active open scope, before the open
|
|
380
385
|
* needs their committed tables or evaluated outcomes (#6709). No-op when nothing is queued or outside a SQLite open.
|
|
386
|
+
* Pass `unaffectedStampPrefix` only for domains whose schema and seed data none of the queued setups can change.
|
|
381
387
|
*/
|
|
382
|
-
export async function flushStorageSchemaSetups(database, ledger) {
|
|
388
|
+
export async function flushStorageSchemaSetups(database, ledger, unaffectedStampPrefix) {
|
|
383
389
|
const active = activeBatchFor(database, ledger);
|
|
384
390
|
if (active === undefined)
|
|
385
391
|
return;
|
|
386
392
|
if (active.batch.setups.length === 0 && active.batch.restamp.size === 0)
|
|
387
393
|
return;
|
|
388
|
-
await flushOpenBatch(database, active.scope, active.batch);
|
|
394
|
+
await flushOpenBatch(database, active.scope, active.batch, unaffectedStampPrefix);
|
|
389
395
|
}
|
|
390
396
|
/**
|
|
391
397
|
* @internal Tells the open of `database` in progress that it checked `setup`, the schema setup `stamp` names, without
|
|
@@ -479,7 +485,7 @@ async function batchCompletedElsewhere(database, scope, setups, restamps) {
|
|
|
479
485
|
* `batchCompletedElsewhere` when another host holds the lock and falling back to a normal serial transaction after
|
|
480
486
|
* {@link SQLITE_BATCH_WAIT_MS} (#6709).
|
|
481
487
|
*/
|
|
482
|
-
async function flushOpenBatch(database, scope, batch) {
|
|
488
|
+
async function flushOpenBatch(database, scope, batch, unaffectedStampPrefix) {
|
|
483
489
|
const setups = batch.setups.splice(0);
|
|
484
490
|
const pendingRestamps = [...batch.restamp.values()];
|
|
485
491
|
batch.restamp.clear();
|
|
@@ -495,7 +501,7 @@ async function flushOpenBatch(database, scope, batch) {
|
|
|
495
501
|
usedFinisher = false;
|
|
496
502
|
for (const entry of setups)
|
|
497
503
|
entry.reset?.();
|
|
498
|
-
const catalog = await readSqliteCatalog(tx, scope.ledger);
|
|
504
|
+
const catalog = await readSqliteCatalog(tx, scope.ledger, unaffectedStampPrefix !== undefined);
|
|
499
505
|
const writes = [];
|
|
500
506
|
const addedColumns = new Set();
|
|
501
507
|
const createdTables = new Set();
|
|
@@ -577,6 +583,19 @@ async function flushOpenBatch(database, scope, batch) {
|
|
|
577
583
|
for (const statement of stampStmts)
|
|
578
584
|
writes.push({ statement });
|
|
579
585
|
}
|
|
586
|
+
// SQLite's schema version is database-wide. Carry still-valid stamps for untouched domains through our own DDL.
|
|
587
|
+
// The starting version was read under this write lock, so changes by older builds or external tools still
|
|
588
|
+
// invalidate stamps: a stamp already stale when we took the lock must stay stale (#6886).
|
|
589
|
+
if (unaffectedStampPrefix !== undefined && catalog?.schemaVersion !== undefined && catalog.hasTable(stampTable)) {
|
|
590
|
+
const version = "(SELECT schema_version FROM pragma_schema_version)";
|
|
591
|
+
writes.push({
|
|
592
|
+
statement: {
|
|
593
|
+
sql: `UPDATE ${stampTable} SET schema_version = ${version}
|
|
594
|
+
WHERE schema_version = ? AND schema_version <> ${version} AND instr(domain, ?) = 1`,
|
|
595
|
+
params: [catalog.schemaVersion, stampKey(unaffectedStampPrefix)],
|
|
596
|
+
},
|
|
597
|
+
});
|
|
598
|
+
}
|
|
580
599
|
usedFinisher = await sendBatchWrites(tx, writes.splice(0), !isolateOptional);
|
|
581
600
|
};
|
|
582
601
|
const executeOnce = async (isolateOptional) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-catalog.js","sourceRoot":"","sources":["../../../src/core/storage/schema-catalog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,SAAS,GACd,iBAAiB,CAAC;AAQnB,SAAS,qBAAqB;IAC7B,MAAM,IAAI,GACT,UAGA,CAAC,OAAO,CAAC;IACV,MAAM,IAAI,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACxE,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,EAAK,CAAC;AACvD,CAAC;AA6BD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,GAAG;;;;;;;;iFAQ6D,CAAC;AAIlF;;;GAGG;AACH,MAAM,kBAAkB,GAAG;;wBAEH,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC1C,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,sBAAsB;QACvE,CAAC,CAAC,GAAG,MAAM,gBAAgB,CAAC;AAC9B,CAAC;AAED,qFAAqF;AACrF,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,UAAU,MAAM,EAAE,CAAC;AAIxD;;;GAGG;AACH,KAAK,UAAU,sBAAsB,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,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAC1E,CAAC;YACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;QACjC,CAAC;QACD,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,YAAY,GAAG,YAAY,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACzF,IAAI,CAAC,WAAW,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,yBAAyB,CAAC,EAAE,CAAC;YACpF,IAAI,CAAC;gBACJ,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO;YACR,CAAC;YAAC,OAAO,UAAU,EAAE,CAAC;gBACrB,IAAI,QAAQ;oBAAE,MAAM,UAAU,CAAC;gBAC/B,OAAO;YACR,CAAC;QACF,CAAC;QACD,IAAI,QAAQ;YAAE,MAAM,KAAK,CAAC;QAC1B,8EAA8E;IAC/E,CAAC;AACF,CAAC","sourcesContent":["import type { SqliteDatabase, SqliteExecutor, SqliteRow } from \"./database.js\";\nimport { dialectOf } from \"./dialect.js\";\nimport { StorageSchemaVersionError } from \"./errors.js\";\nimport type { SequencedStatement } from \"./statement-sequence.js\";\nimport * as statementSequence from \"./statement-sequence.js\";\n\n/**\n * `transactionFinisher`, `sequenceRunner` and `statementBatch` of `statement-sequence.ts`, which the copies 0.10.3 and\n * 0.10.4 loaded lack: a process an in-place update caught keeps those copies, where a named import would fail to link.\n * Without `statementBatch`, 0.10.3's connection thread cannot run `{ script: true }` entries inside a sequence request,\n * so multi-statement scripts run via `tx.exec` instead.\n */\nconst finishers: Partial<Pick<typeof statementSequence, \"transactionFinisher\" | \"sequenceRunner\" | \"statementBatch\">> =\n\tstatementSequence;\n\n/** Minimal AsyncLocalStorage surface, resolved portably without a static `node:` import. */\ninterface AsyncScopeStore<T> {\n\tgetStore(): T | undefined;\n\trun<R>(store: T, callback: () => R): R;\n}\n\nfunction createAsyncScopeStore<T>(): AsyncScopeStore<T> | undefined {\n\tconst proc = (\n\t\tglobalThis as {\n\t\t\tprocess?: { getBuiltinModule?: (id: string) => { AsyncLocalStorage?: new <V>() => AsyncScopeStore<V> } };\n\t\t}\n\t).process;\n\tconst Ctor = proc?.getBuiltinModule?.(\"async_hooks\")?.AsyncLocalStorage;\n\treturn Ctor === undefined ? undefined : new Ctor<T>();\n}\n\n/**\n * What a schema held when one open read it: its relations, triggers and columns, and on PostgreSQL the versions its\n * ledger records. Only a positive answer is final: the schema only moves forward, so what existed then still exists,\n * while something missing may have been created since and is checked again under the store's lock.\n */\nexport interface StorageSchemaCatalog {\n\t/** The ledger the versions were read from. */\n\treadonly ledger: string;\n\t/** The highest version `ledger` recorded for `domain`; 0 when none, or when the ledger did not exist. */\n\trecordedVersion(domain: string): number;\n\t/** Whether a table (or view) named `table` existed. */\n\thasTable(table: string): boolean;\n\t/** Whether a relation (table, index, sequence…) or a trigger named `name` existed. */\n\thasObject(name: string): boolean;\n\t/** Whether `table` had a column named `column`. */\n\thasColumn(table: string, column: string): boolean;\n\t/**\n\t * Whether a function named `name` existed in the schema and this role may run it: PostgreSQL only, absent on SQLite.\n\t */\n\treadonly hasFunction?: (name: string) => boolean;\n\t/**\n\t * What kind of object `name` was on SQLite (`table`, `index`, `view` or `trigger`), from one read of\n\t * `sqlite_schema`; undefined when there was none, and always on PostgreSQL.\n\t */\n\treadonly sqliteObjectType?: (name: string) => string | undefined;\n}\n\nconst TABLE_KINDS = new Set([\"r\", \"p\", \"v\", \"m\", \"f\"]);\n\n/**\n * Every relation, trigger, column and function of the schema the statement runs in, in one statement and so one\n * snapshot. The catalog, not information_schema, finds relations, as `tableExists` does; columns come from\n * information_schema, as `columnExists` reads them. A function is listed with whether this role may execute it.\n */\nconst CATALOG_SQL = `SELECT 'relation' AS kind, c.relname::text AS name, c.relkind::text AS detail\n\tFROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace\nUNION ALL SELECT 'trigger', t.tgname::text, NULL\n\tFROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n\tWHERE c.relnamespace = current_schema()::regnamespace AND NOT t.tgisinternal\nUNION ALL SELECT 'column', table_name::text, column_name::text\n\tFROM information_schema.columns WHERE table_schema = current_schema()\nUNION ALL SELECT 'function', p.proname::text, CASE WHEN has_function_privilege(p.oid, 'EXECUTE') THEN 'executable' END\n\tFROM pg_catalog.pg_proc p WHERE p.pronamespace = current_schema()::regnamespace`;\n\ntype CatalogRow = SqliteRow & { kind: string; name: string; detail: string | null };\n\n/**\n * Every object of a SQLite database and every column of its tables, generated ones included, in one\n * statement and so one snapshot: what `tableExists`, `columnExists` and `schemaObjects` ask one at a time (#6560).\n */\nconst SQLITE_CATALOG_SQL = `SELECT 'object' AS kind, name, type AS detail FROM sqlite_master\nUNION ALL SELECT 'column', m.name, c.name FROM sqlite_master AS m JOIN pragma_table_xinfo(m.name) AS c\n\tWHERE m.type = 'table'`;\n\n/**\n * @internal The table under `ledger`'s prefix where SQLite record which revision of each store's schema\n * setup ran, and the database's schema version (`PRAGMA schema_version`) once it had: `domain`, `revision`,\n * `schema_version`. SQLite counts every change to the schema in that version, whoever makes it, an older Atomic that\n * records nothing included; a revision is believed only while the version still matches, so any later change is checked\n * again (#6560). Builds that do not know the table leave it alone.\n */\nexport function sqliteSchemaStampTable(ledger: string): string {\n\treturn ledger.endsWith(\"atomic_migrations\")\n\t\t? `${ledger.slice(0, -\"atomic_migrations\".length)}atomic_schema_stamps`\n\t\t: `${ledger}_schema_stamps`;\n}\n\n/** The key a store's setup is stamped under, as the PostgreSQL ledger records it. */\nconst stampKey = (domain: string) => `schema:${domain}`;\n\ntype StampRow = SqliteRow & { domain: string | null; revision: number | bigint | null; stamped: number | bigint };\n\n/**\n * The revisions `ledger`'s stamps record whose schema version is the database's now, by stamp key, read in one\n * statement so the two agree. Stamps of an older schema version are left out: something changed the schema since.\n */\nasync function readSqliteSchemaStamps(executor: SqliteExecutor, ledger: string): Promise<Map<string, number>> {\n\tconst rows = await executor.all<StampRow>(\n\t\t`SELECT domain, revision, schema_version AS stamped FROM ${sqliteSchemaStampTable(ledger)}\n\t\tUNION ALL SELECT NULL, NULL, schema_version FROM pragma_schema_version`,\n\t);\n\tconst now = rows.find((row) => row.domain === null)?.stamped;\n\tconst stamps = new Map<string, number>();\n\tfor (const row of rows)\n\t\tif (row.domain !== null && now !== undefined && Number(row.stamped) === Number(now))\n\t\t\tstamps.set(row.domain, Number(row.revision ?? 0));\n\treturn stamps;\n}\n\n/** @internal A store's schema setup, as its stamp records it: `ledger` names the prefix, `domain` the store. */\nexport interface SqliteSchemaStamp {\n\treadonly ledger: string;\n\treadonly domain: string;\n\treadonly revision: number;\n}\n\n/** The SQLite statements that create (unless `tableExists`) and upsert `stamps` at the current `PRAGMA schema_version`. */\nfunction sqliteStampStatements(\n\tstamps: readonly SqliteSchemaStamp[],\n\ttableExists: boolean,\n): readonly SequencedStatement[] {\n\tconst ledger = stamps[0]?.ledger;\n\tif (ledger === undefined) return [];\n\tconst table = sqliteSchemaStampTable(ledger);\n\tconst upsert: SequencedStatement = {\n\t\tsql: `INSERT INTO ${table} (domain, revision, schema_version)\n\t\tSELECT column1, column2, (SELECT schema_version FROM pragma_schema_version)\n\t\tFROM (VALUES ${stamps.map(() => \"(?, ?)\").join(\", \")}) WHERE true\n\t\tON CONFLICT(domain) DO UPDATE SET revision = excluded.revision, schema_version = excluded.schema_version`,\n\t\tparams: stamps.flatMap(({ domain, revision }) => [stampKey(domain), revision]),\n\t};\n\tif (tableExists) return [upsert];\n\treturn [\n\t\t{\n\t\t\tsql: `CREATE TABLE IF NOT EXISTS ${table} (domain TEXT NOT NULL PRIMARY KEY, revision INTEGER NOT NULL, schema_version INTEGER NOT NULL)`,\n\t\t\tparams: [],\n\t\t\tscript: true,\n\t\t},\n\t\tupsert,\n\t];\n}\n\n/**\n * @internal Stamps each of `stamps`, in the transaction `tx` that ran their setups, with the schema version as that\n * transaction leaves it: a later open believes their revisions until the schema changes again (#6560). Creates the\n * stamps table first, unless `options.tableExists`, so its own creation is part of the version recorded. With\n * `options.last`, the stamps are the transaction's last statements: where its connection is pipelined, they go out with\n * its commit. SQLite only; every stamp must share a ledger.\n */\nexport async function recordSqliteSchemaStamps(\n\ttx: SqliteExecutor,\n\tstamps: readonly SqliteSchemaStamp[],\n\toptions: { readonly tableExists?: boolean; readonly last?: boolean } = {},\n): Promise<void> {\n\tconst statements = sqliteStampStatements(stamps, options.tableExists === true);\n\tif (statements.length === 0) return;\n\tconst canSequence = finishers.statementBatch !== undefined || statements.every((each) => each.script !== true);\n\tif (options.last === true && canSequence && finishers.transactionFinisher?.(tx)?.(statements) === true) return;\n\tfor (const statement of statements) {\n\t\tif (statement.script === true) await tx.exec(statement.sql);\n\t\telse await tx.run(statement.sql, ...statement.params);\n\t}\n}\n\n/** The catalog of a SQLite database, or undefined when it cannot be read, such as on a SQLite too old. */\nasync function readSqliteCatalog(database: SqliteExecutor, ledger: string): Promise<StorageSchemaCatalog | undefined> {\n\tlet rows: CatalogRow[];\n\ttry {\n\t\trows = await database.all<CatalogRow>(SQLITE_CATALOG_SQL);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst types = new Map<string, string>();\n\tconst columns = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse types.set(row.name, String(row.detail));\n\t}\n\treturn {\n\t\tledger,\n\t\t// SQLite records no versions: its stores' stamps are read on their own (`sqliteSchemaStampsOf`).\n\t\trecordedVersion: () => 0,\n\t\thasTable: (table) => types.get(table) === \"table\",\n\t\thasObject: (name) => types.has(name),\n\t\thasColumn: (table, column) => columns.has(`${table}\\0${column}`),\n\t\tsqliteObjectType: (name) => types.get(name),\n\t};\n}\n\ntype VersionRow = SqliteRow & { domain: string; version: number | string | null };\n\n/** The tables, objects, columns and executable functions of PostgreSQL catalog rows (`CATALOG_SQL`'s). */\nfunction catalogSets(rows: readonly CatalogRow[]) {\n\tconst tables = new Set<string>();\n\tconst objects = new Set<string>();\n\tconst columns = new Set<string>();\n\tconst functions = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse if (row.kind === \"function\") {\n\t\t\tif (row.detail === \"executable\") functions.add(row.name);\n\t\t} else {\n\t\t\tobjects.add(row.name);\n\t\t\tif (row.kind === \"relation\" && TABLE_KINDS.has(String(row.detail))) tables.add(row.name);\n\t\t}\n\t}\n\treturn { tables, objects, columns, functions };\n}\n\n/**\n * The catalog rows and the ledger's versions of `database`'s schema, read in one read-only transaction whose start\n * carries both reads, so they cost one round trip (#6560). The versions are undefined when the ledger did not exist;\n * the whole read is undefined when it failed.\n */\nasync function readPostgresCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tphysicalLedger: string,\n): Promise<{ rows: CatalogRow[]; versions: VersionRow[] | undefined } | undefined> {\n\tconst versionsSql = `SELECT domain, MAX(version) AS version FROM ${ledger} GROUP BY domain`;\n\tlet read: { rows: CatalogRow[]; versions: VersionRow[] | undefined } | undefined;\n\ttry {\n\t\tawait database.transaction(\n\t\t\tasync (tx) => {\n\t\t\t\tread = undefined;\n\t\t\t\tconst rows = await tx.all<CatalogRow>(CATALOG_SQL);\n\t\t\t\t// Taken even where the ledger does not exist and its read failed, so the transaction ends with its commit,\n\t\t\t\t// sent at once, rather than with a rollback after it.\n\t\t\t\tconst ledgerExists = catalogSets(rows).tables.has(physicalLedger);\n\t\t\t\tconst versions = await tx.all<VersionRow>(versionsSql).catch((error: unknown) => {\n\t\t\t\t\tif (ledgerExists) throw error;\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\tread = { rows, versions };\n\t\t\t},\n\t\t\t{\n\t\t\t\treadOnly: true,\n\t\t\t\tretryTransientFailures: true,\n\t\t\t\tleading: [\n\t\t\t\t\t{ sql: CATALOG_SQL, params: [] },\n\t\t\t\t\t{ sql: versionsSql, params: [] },\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn read;\n}\n\n/**\n * Reads `database`'s schema and the versions `ledger` records, in one read-only transaction that takes no lock. On\n * PostgreSQL, an adapter that read them when it opened gives them once (`takeOpenedCatalog`), and the first open reads\n * nothing (#6560). On SQLite, which record no versions, reads the schema alone in one statement. Undefined\n * when a read fails: the stores then check each object themselves.\n */\nexport async function readStorageSchemaCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.name === \"sqlite\") return readSqliteCatalog(database, ledger);\n\tif (!dialect.versionedMigrations || dialect.name !== \"postgres\") return undefined;\n\tconst physicalLedger = dialect.identifier(ledger);\n\tconst opened = database.takeOpenedCatalog?.();\n\tconst read =\n\t\topened !== undefined && opened.ledger === physicalLedger\n\t\t\t? {\n\t\t\t\t\trows: opened.rows as readonly CatalogRow[],\n\t\t\t\t\tversions: opened.versions as readonly VersionRow[] | undefined,\n\t\t\t\t}\n\t\t\t: await readPostgresCatalog(database, ledger, physicalLedger);\n\tif (read === undefined) return undefined;\n\tconst { tables, objects, columns, functions } = catalogSets(read.rows);\n\tconst recorded = new Map<string, number>();\n\tif (tables.has(physicalLedger)) {\n\t\tif (read.versions === undefined) return undefined;\n\t\tfor (const row of read.versions) recorded.set(row.domain, Number(row.version ?? 0));\n\t}\n\treturn {\n\t\tledger,\n\t\trecordedVersion: (domain) => recorded.get(domain) ?? 0,\n\t\thasTable: (table) => tables.has(dialect.identifier(table)),\n\t\thasObject: (name) => objects.has(dialect.identifier(name)),\n\t\thasColumn: (table, column) => columns.has(`${dialect.identifier(table)}\\0${column}`),\n\t\thasFunction: (name) => functions.has(dialect.identifier(name)),\n\t};\n}\n\n/** @internal Context passed to a queued SQLite schema setup inside an open's single write transaction (#6709). */\nexport interface SqliteSchemaBatchContext {\n\t/** The write transaction executor. */\n\treadonly tx: SqliteExecutor;\n\t/** The live schema catalog read at the start of the write transaction, authoritative under the write lock. */\n\treadonly catalog: StorageSchemaCatalog | undefined;\n\t/**\n\t * Queues a SQLite write statement or multi-statement SQL script to run in order inside the transaction. Consecutive\n\t * queued writes go out together to the connection thread, and the final run goes out with `COMMIT`. When\n\t * `options.ignoreError` returns true for a statement's failure, that error is ignored.\n\t */\n\tenqueue(\n\t\tstatement: string | SequencedStatement,\n\t\toptions?: { readonly ignoreError?: (error: unknown) => boolean },\n\t): void;\n\t/** Executes any writes queued so far; call before issuing a read on `tx` that depends on them. */\n\tflushWrites(): Promise<void>;\n\t/** Notes that this transaction added `column` to `table`, so a later queued setup does not add it again. */\n\tnoteColumnAdded(table: string, column: string): void;\n\t/** Whether `table` already has `column` in `catalog` or added earlier in this transaction. */\n\thasColumn(table: string, column: string): boolean;\n\t/** Notes that this transaction created `table`. */\n\tnoteTableCreated(table: string): void;\n\t/** Whether `table` was created earlier in this transaction. */\n\tcreatedTable(table: string): boolean;\n\t/** Whether `table` already existed in `catalog` before this transaction began. */\n\ttableExisted(table: string): boolean;\n}\n\n/** @internal A SQLite schema setup queued inside an open scope (`withStorageSchemaCatalog`) to run in one transaction. */\nexport interface SqliteSchemaBatchSetup {\n\t/** Stamp recorded for this setup once the batched transaction commits, when the store uses SQLite schema stamps. */\n\treadonly stamp?: SqliteSchemaStamp;\n\t/** Whether the schema already holds everything this setup creates (for DDL-only setups without row seeds). */\n\treadonly verify?: (catalog: StorageSchemaCatalog) => boolean;\n\t/**\n\t * Checks outside any write lock whether another host completed this setup while we waited on `tryMaintenance`.\n\t * Throwing (such as `StorageSchemaVersionError` for a newer build's database) immediately rejects the open.\n\t */\n\treadonly done?: (\n\t\tcatalog: StorageSchemaCatalog,\n\t\tstamps: ReadonlyMap<string, number> | undefined,\n\t) => boolean | Promise<boolean>;\n\t/** Reset any mutable per-attempt JS state before each transaction attempt or retry. */\n\treadonly reset?: () => void;\n\t/** Runs this setup inside the batched write transaction. */\n\treadonly run: (context: SqliteSchemaBatchContext) => Promise<void> | void;\n\t/**\n\t * Optional setup (such as an FTS5 search index): if the transaction fails, the open retries with optional setups\n\t * isolated in savepoints, calling `onFailure` instead of failing the open.\n\t */\n\treadonly optional?: boolean;\n\t/** Called when an optional setup fails and its savepoint rolls back. */\n\treadonly onFailure?: () => void;\n}\n\ninterface OpenBatch {\n\treadonly ledger: string;\n\treadonly setups: SqliteSchemaBatchSetup[];\n\treadonly restamp: Map<string, PendingRestamp>;\n}\n\ninterface CatalogScope {\n\treadonly ledger: string;\n\t/** Read when the scope starts on PostgreSQL, whose opens always ask it; on SQLite at the first question. */\n\tcatalog: Promise<StorageSchemaCatalog | undefined> | undefined;\n\treadonly read: () => Promise<StorageSchemaCatalog | undefined>;\n\tusers: number;\n\t/** The stamps valid when read, by stamp key, read at the first question: see {@link sqliteSchemaStampsOf}. */\n\tstamps: Promise<ReadonlyMap<string, number> | undefined> | undefined;\n\t/** Fallback batch used only on runtimes lacking `AsyncLocalStorage`. */\n\treadonly fallbackBatch: OpenBatch;\n}\n\ninterface PendingRestamp extends SchemaStampAtOpenEnd {\n\treadonly stamp: SqliteSchemaStamp;\n\treadonly setup: (tx: SqliteExecutor) => Promise<unknown>;\n}\n\n/** @internal How the end of an open stamps a store's setup: see {@link restampStorageSchemaAtOpenEnd}. */\nexport interface SchemaStampAtOpenEnd {\n\t/**\n\t * Whether the store's schema, as the end's transaction reads the catalog, holds everything `setup` creates. Given,\n\t * the end runs `setup` only where it does not; absent, it runs `setup` whenever the store's stamp is behind.\n\t */\n\treadonly verify?: (catalog: StorageSchemaCatalog) => boolean;\n\t/**\n\t * `setup` has not run in this open and must: the end runs it whatever the stamp, and a failure fails the open, as\n\t * the setup's own transaction would have. For a setup whose objects all exist and whose only other statements seed\n\t * rows nothing in the open reads, such as a counter's: it then shares the end's transaction instead of taking one.\n\t */\n\treadonly deferred?: boolean;\n\t/**\n\t * `setup` ran in this open, in a transaction that stamped nothing: it is stamped only when the end takes a transaction\n\t * for another store, never in one of its own, so a new database's first open takes none.\n\t */\n\treadonly alongside?: boolean;\n}\n\nconst scopes = new WeakMap<SqliteDatabase, CatalogScope>();\n/**\n * Tracks the root open batch active on each `CatalogScope` along the current async call chain: nested opens share their\n * enclosing root's batch and commit together at the root's end, while concurrent sibling opens on the same database\n * handle each own and commit their own batch before returning (#6709).\n */\nconst activeOpenBatches = createAsyncScopeStore<ReadonlyMap<CatalogScope, OpenBatch>>();\n\n/** How long a SQLite open batch polls `done` after `tryMaintenance` finds the lock busy before joining the queue. */\nconst SQLITE_BATCH_WAIT_MS = 1_000;\nconst SQLITE_BATCH_POLL_MS = 20;\nconst SQLITE_BATCH_MAX_POLL_MS = 250;\n\nconst pausePoll = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms * (0.5 + Math.random() / 2)));\n\n/**\n * Runs `body`, an open of one or more stores on `database`, with one catalog read for all of them: the schema checks\n * of the stores it opens ({@link schemaCatalogOf}) answer from it, so an open whose schema is current runs no schema\n * transaction and takes no lock. Opens on `database` that overlap share the read. On SQLite, setups queued inside the\n * open ({@link queueSqliteSchemaSetup}) run in one write transaction before the root open returns (#6709). `views` are\n * other handles on the same connection, such as a borrowed view, whose checks answer from the same read.\n */\nexport async function withStorageSchemaCatalog<T>(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tbody: () => Promise<T>,\n\tviews: readonly SqliteDatabase[] = [],\n): Promise<T> {\n\tlet scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger) {\n\t\tconst read = () => readStorageSchemaCatalog(database, ledger);\n\t\tconst catalog = dialectOf(database).name === \"sqlite\" ? undefined : read();\n\t\tscope = {\n\t\t\tledger,\n\t\t\tcatalog,\n\t\t\tread,\n\t\t\tusers: 0,\n\t\t\tstamps: undefined,\n\t\t\tfallbackBatch: { ledger, setups: [], restamp: new Map() },\n\t\t};\n\t\tscopes.set(database, scope);\n\t}\n\tconst shared = scope;\n\tconst handles = [database, ...views.filter((view) => !scopes.has(view))];\n\tfor (const handle of handles.slice(1)) scopes.set(handle, shared);\n\tshared.users += 1;\n\tconst enclosing = activeOpenBatches?.getStore();\n\tconst isRoot = activeOpenBatches === undefined ? shared.users === 1 : enclosing?.has(shared) !== true;\n\tconst batch: OpenBatch =\n\t\tactiveOpenBatches === undefined\n\t\t\t? shared.fallbackBatch\n\t\t\t: isRoot\n\t\t\t\t? { ledger, setups: [], restamp: new Map() }\n\t\t\t\t: enclosing!.get(shared)!;\n\tconst run = async (): Promise<T> => {\n\t\tconst value = await body();\n\t\tif (isRoot && (batch.setups.length > 0 || batch.restamp.size > 0)) await flushOpenBatch(database, shared, batch);\n\t\treturn value;\n\t};\n\ttry {\n\t\tif (!isRoot || activeOpenBatches === undefined) return await run();\n\t\tconst next = new Map(enclosing);\n\t\tnext.set(shared, batch);\n\t\treturn await activeOpenBatches.run(next, run);\n\t} finally {\n\t\tshared.users -= 1;\n\t\tfor (const handle of handles.slice(1)) if (scopes.get(handle) === shared) scopes.delete(handle);\n\t\tif (shared.users === 0 && scopes.get(database) === shared) scopes.delete(database);\n\t}\n}\n\n/**\n * Drops the catalog an open of `database` in progress read, so the next question reads the schema again: for a step of\n * the open that changed the schema the stores it opens after it ask about.\n */\nexport function refreshStorageSchemaCatalog(database: SqliteDatabase): void {\n\tconst scope = scopes.get(database);\n\tif (scope !== undefined) {\n\t\tscope.catalog = undefined;\n\t\tscope.stamps = undefined;\n\t}\n}\n\n/**\n * Tells the catalog an open of `database` in progress read that the open created `tables` since, so the stores it\n * opens next find them without reading the schema again.\n */\nexport function noteStorageSchemaTables(database: SqliteDatabase, tables: readonly string[]): void {\n\tconst scope = scopes.get(database);\n\tif (scope?.catalog === undefined) return;\n\tconst identifier = dialectOf(database).identifier;\n\tconst created = new Set(tables.map((table) => identifier(table)));\n\tscope.catalog = scope.catalog.then(\n\t\t(catalog) =>\n\t\t\tcatalog && {\n\t\t\t\t...catalog,\n\t\t\t\thasTable: (table) => created.has(identifier(table)) || catalog.hasTable(table),\n\t\t\t\thasObject: (name) => created.has(identifier(name)) || catalog.hasObject(name),\n\t\t\t},\n\t);\n}\n\n/**\n * The catalog an open of `database` in progress read ({@link withStorageSchemaCatalog}), when it read `ledger`'s\n * versions or no `ledger` is named; undefined outside such an open, and when it could not be read.\n */\nexport async function schemaCatalogOf(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || (ledger !== undefined && scope.ledger !== ledger)) return undefined;\n\tscope.catalog ??= scope.read();\n\treturn scope.catalog;\n}\n\n/**\n * @internal The revisions the stamps under `ledger` record for the stores of `database` (SQLite), by stamp\n * key (`schema:<domain>`), as the open of `database` in progress read them; only those whose schema version was the\n * database's then. Undefined outside such an open, and where none could be read, such as before any stamp. The first\n * question reads them after the open's catalog, and only where it holds their table.\n */\nexport async function sqliteSchemaStampsOf(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<ReadonlyMap<string, number> | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger || dialectOf(database).name !== \"sqlite\") return undefined;\n\t// Read once the catalog shows their table: a read of a missing table would fail, which costs a request, and makes a\n\t// driver may replace its connection.\n\tscope.stamps ??= schemaCatalogOf(database, ledger).then((catalog) =>\n\t\tcatalog?.hasTable(sqliteSchemaStampTable(ledger)) === true\n\t\t\t? readSqliteSchemaStamps(database, ledger).then(\n\t\t\t\t\t(read) => read,\n\t\t\t\t\t() => undefined,\n\t\t\t\t)\n\t\t\t: undefined,\n\t);\n\treturn scope.stamps;\n}\n\n/** Active root open batch for `database` on SQLite (matching `ledger` when given), or undefined outside one. */\nfunction activeBatchFor(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n): { readonly scope: CatalogScope; readonly batch: OpenBatch } | undefined {\n\tif (dialectOf(database).name !== \"sqlite\") return undefined;\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || (ledger !== undefined && scope.ledger !== ledger)) return undefined;\n\tconst batch = activeOpenBatches === undefined ? scope.fallbackBatch : activeOpenBatches.getStore()?.get(scope);\n\treturn batch === undefined ? undefined : { scope, batch };\n}\n\n/**\n * @internal Queues `setup` into the active SQLite open scope (`withStorageSchemaCatalog`) so that all needed setups of\n * the open execute in one write transaction before the open returns (#6709). Returns `false` outside a SQLite open\n * scope (or for a different `ledger`), in which case the caller runs `setup` immediately.\n */\nexport function queueSqliteSchemaSetup(\n\tdatabase: SqliteDatabase,\n\tledger: string | undefined,\n\tsetup: SqliteSchemaBatchSetup,\n): boolean {\n\tconst active = activeBatchFor(database, ledger);\n\tif (active === undefined) return false;\n\tactive.batch.setups.push(setup);\n\treturn true;\n}\n\n/**\n * @internal Executes and commits any SQLite schema setups queued so far in the active open scope, before the open\n * needs their committed tables or evaluated outcomes (#6709). No-op when nothing is queued or outside a SQLite open.\n */\nexport async function flushStorageSchemaSetups(database: SqliteDatabase, ledger?: string): Promise<void> {\n\tconst active = activeBatchFor(database, ledger);\n\tif (active === undefined) return;\n\tif (active.batch.setups.length === 0 && active.batch.restamp.size === 0) return;\n\tawait flushOpenBatch(database, active.scope, active.batch);\n}\n\n/**\n * @internal Tells the open of `database` in progress that it checked `setup`, the schema setup `stamp` names, without\n * its stamp (SQLite only): it ran it in a transaction that stamped it, found every object it creates in the\n * catalog (with `verify`), or leaves it to the end (`deferred`). A schema change later in the same open, such as the\n * next store's setup or a column it adds, leaves a stamp behind the schema version, and a store found in the catalog has\n * none that is current, so the next open would check it again. The open's end checks or runs them in one transaction\n * and stamps them all with the version it leaves: the next open of a current schema then takes no write lock and answers\n * every such store from its stamp (#6560, #6709). False, and nothing is kept, outside such an open.\n */\nexport function restampStorageSchemaAtOpenEnd(\n\tdatabase: SqliteDatabase,\n\tstamp: SqliteSchemaStamp,\n\tsetup: (tx: SqliteExecutor) => Promise<unknown>,\n\toptions: SchemaStampAtOpenEnd = {},\n): boolean {\n\tconst active = activeBatchFor(database, stamp.ledger);\n\tif (active === undefined) return false;\n\tactive.batch.restamp.set(stamp.domain, { stamp, setup, ...options });\n\treturn true;\n}\n\ninterface QueuedBatchWrite {\n\treadonly statement: SequencedStatement;\n\treadonly ignoreError?: (error: unknown) => boolean;\n}\n\n/**\n * Sends `writes` on `tx`, piggybacking onto `COMMIT` when `last` is true and the connection supports it. Returns\n * `true` when sent via `transactionFinisher` (without per-statement `ignoreError` handling).\n */\nasync function sendBatchWrites(\n\ttx: SqliteExecutor,\n\twrites: readonly QueuedBatchWrite[],\n\tlast: boolean,\n): Promise<boolean> {\n\tif (writes.length === 0) return false;\n\tconst statements = writes.map(({ statement }) => statement);\n\tconst canSequence = finishers.statementBatch !== undefined || statements.every((each) => each.script !== true);\n\tif (last && canSequence && finishers.transactionFinisher?.(tx)?.(statements) === true) return true;\n\tconst runSequence = canSequence ? finishers.sequenceRunner?.(tx) : undefined;\n\tif (runSequence !== undefined && writes.every(({ ignoreError }) => ignoreError === undefined)) {\n\t\tawait runSequence({ statements });\n\t\treturn false;\n\t}\n\tfor (const { statement, ignoreError } of writes) {\n\t\ttry {\n\t\t\tif (statement.script === true) await tx.exec(statement.sql);\n\t\t\telse await tx.run(statement.sql, ...statement.params);\n\t\t} catch (error) {\n\t\t\tif (ignoreError?.(error) !== true) throw error;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Checks outside any write lock whether another host completed every queued setup and restamp in this open batch.\n * Updates `scope.catalog` and `scope.stamps` when complete so later questions in the same open see the fresh schema.\n */\nasync function batchCompletedElsewhere(\n\tdatabase: SqliteDatabase,\n\tscope: CatalogScope,\n\tsetups: readonly SqliteSchemaBatchSetup[],\n\trestamps: readonly PendingRestamp[],\n): Promise<boolean> {\n\tconst catalog = await readSqliteCatalog(database, scope.ledger);\n\tif (catalog === undefined) return false;\n\tconst stampTable = sqliteSchemaStampTable(scope.ledger);\n\tconst needsStamps = setups.some((each) => each.stamp !== undefined) || restamps.length > 0;\n\tconst stamps =\n\t\tneedsStamps && catalog.hasTable(stampTable)\n\t\t\t? await readSqliteSchemaStamps(database, scope.ledger).catch(() => undefined)\n\t\t\t: undefined;\n\tfor (const entry of setups) {\n\t\tif (entry.done !== undefined) {\n\t\t\tif (!(await entry.done(catalog, stamps))) return false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.stamp !== undefined) {\n\t\t\tif ((stamps?.get(stampKey(entry.stamp.domain)) ?? 0) < entry.stamp.revision) return false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.verify !== undefined) {\n\t\t\tif (!entry.verify(catalog)) return false;\n\t\t\tcontinue;\n\t\t}\n\t\treturn false;\n\t}\n\tfor (const entry of restamps) {\n\t\tif (entry.alongside === true && setups.length === 0) continue;\n\t\tif ((stamps?.get(stampKey(entry.stamp.domain)) ?? 0) < entry.stamp.revision) return false;\n\t}\n\tscope.catalog = Promise.resolve(catalog);\n\tscope.stamps = stamps === undefined ? undefined : Promise.resolve(stamps);\n\treturn true;\n}\n\n/**\n * Runs every queued setup and restamp of `batch` in ONE SQLite write transaction through `tryMaintenance`, polling\n * `batchCompletedElsewhere` when another host holds the lock and falling back to a normal serial transaction after\n * {@link SQLITE_BATCH_WAIT_MS} (#6709).\n */\nasync function flushOpenBatch(database: SqliteDatabase, scope: CatalogScope, batch: OpenBatch): Promise<void> {\n\tconst setups = batch.setups.splice(0);\n\tconst pendingRestamps = [...batch.restamp.values()];\n\tbatch.restamp.clear();\n\tif (setups.length === 0 && pendingRestamps.every((each) => each.alongside === true)) return;\n\tconst required = setups.length > 0 || pendingRestamps.some((each) => each.deferred === true);\n\tconst hasOptional = setups.some((each) => each.optional === true);\n\tconst stampTable = sqliteSchemaStampTable(scope.ledger);\n\n\tlet ignoreErrorPredicates: ((error: unknown) => boolean)[] = [];\n\tlet usedFinisher = false;\n\tconst runTransaction = async (tx: SqliteExecutor, isolateOptional: boolean): Promise<void> => {\n\t\tignoreErrorPredicates = [];\n\t\tusedFinisher = false;\n\t\tfor (const entry of setups) entry.reset?.();\n\t\tconst catalog = await readSqliteCatalog(tx, scope.ledger);\n\t\tconst writes: QueuedBatchWrite[] = [];\n\t\tconst addedColumns = new Set<string>();\n\t\tconst createdTables = new Set<string>();\n\t\tconst flushWrites = async (): Promise<void> => {\n\t\t\tif (writes.length === 0) return;\n\t\t\tconst batchWrites = writes.splice(0);\n\t\t\tawait sendBatchWrites(tx, batchWrites, false);\n\t\t};\n\t\tconst context: SqliteSchemaBatchContext = {\n\t\t\ttx,\n\t\t\tcatalog,\n\t\t\tenqueue(statement, options) {\n\t\t\t\tconst sequenced: SequencedStatement =\n\t\t\t\t\ttypeof statement === \"string\" ? { sql: statement, params: [], script: true } : statement;\n\t\t\t\tif (options?.ignoreError !== undefined) ignoreErrorPredicates.push(options.ignoreError);\n\t\t\t\twrites.push({\n\t\t\t\t\tstatement: sequenced,\n\t\t\t\t\t...(options?.ignoreError === undefined ? {} : { ignoreError: options.ignoreError }),\n\t\t\t\t});\n\t\t\t},\n\t\t\tflushWrites,\n\t\t\tnoteColumnAdded(table, column) {\n\t\t\t\taddedColumns.add(`${table}\\0${column}`);\n\t\t\t},\n\t\t\thasColumn(table, column) {\n\t\t\t\treturn catalog?.hasColumn(table, column) === true || addedColumns.has(`${table}\\0${column}`);\n\t\t\t},\n\t\t\tnoteTableCreated(table) {\n\t\t\t\tcreatedTables.add(table);\n\t\t\t},\n\t\t\tcreatedTable(table) {\n\t\t\t\treturn createdTables.has(table);\n\t\t\t},\n\t\t\ttableExisted(table) {\n\t\t\t\treturn catalog?.hasTable(table) === true;\n\t\t\t},\n\t\t};\n\n\t\tfor (const entry of setups) {\n\t\t\tif (!isolateOptional || entry.optional !== true) {\n\t\t\t\tawait entry.run(context);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait flushWrites();\n\t\t\tawait tx.exec(\"SAVEPOINT atomic_optional_schema_setup\");\n\t\t\ttry {\n\t\t\t\tawait entry.run(context);\n\t\t\t\tawait flushWrites();\n\t\t\t} catch {\n\t\t\t\twrites.length = 0;\n\t\t\t\tawait tx.exec(\"ROLLBACK TO SAVEPOINT atomic_optional_schema_setup\");\n\t\t\t\tentry.onFailure?.();\n\t\t\t}\n\t\t\tawait tx.exec(\"RELEASE SAVEPOINT atomic_optional_schema_setup\");\n\t\t}\n\n\t\tfor (const { setup, verify, deferred } of pendingRestamps) {\n\t\t\tif (deferred === true || verify === undefined || catalog === undefined || !verify(catalog)) {\n\t\t\t\tawait flushWrites();\n\t\t\t\tawait setup(tx);\n\t\t\t}\n\t\t}\n\n\t\t// Collect stamps for every stamped setup and restamp in this batch (deduplicated by domain, keeping highest revision).\n\t\tconst stampByDomain = new Map<string, SqliteSchemaStamp>();\n\t\tfor (const entry of setups) {\n\t\t\tif (entry.stamp === undefined) continue;\n\t\t\tconst prev = stampByDomain.get(entry.stamp.domain);\n\t\t\tif (prev === undefined || entry.stamp.revision > prev.revision)\n\t\t\t\tstampByDomain.set(entry.stamp.domain, entry.stamp);\n\t\t}\n\t\tfor (const entry of pendingRestamps) {\n\t\t\tconst prev = stampByDomain.get(entry.stamp.domain);\n\t\t\tif (prev === undefined || entry.stamp.revision > prev.revision)\n\t\t\t\tstampByDomain.set(entry.stamp.domain, entry.stamp);\n\t\t}\n\t\tif (stampByDomain.size > 0) {\n\t\t\tconst stampStmts = sqliteStampStatements([...stampByDomain.values()], catalog?.hasTable(stampTable) === true);\n\t\t\tfor (const statement of stampStmts) writes.push({ statement });\n\t\t}\n\n\t\tusedFinisher = await sendBatchWrites(tx, writes.splice(0), !isolateOptional);\n\t};\n\n\tconst executeOnce = async (isolateOptional: boolean): Promise<void> => {\n\t\tconst waiting = () =>\n\t\t\tdatabase.transaction((tx) => runTransaction(tx, isolateOptional), {\n\t\t\t\tretryTransientFailures: true,\n\t\t\t\tconcurrency: { kind: \"serial\", domain: scope.ledger },\n\t\t\t});\n\t\tconst tryMaintenance = database.tryMaintenance?.bind(database);\n\t\tif (tryMaintenance === undefined) {\n\t\t\tawait waiting();\n\t\t\tscope.catalog = undefined;\n\t\t\tscope.stamps = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst deadline = performance.now() + SQLITE_BATCH_WAIT_MS;\n\t\tfor (let wait = SQLITE_BATCH_POLL_MS; ; wait = Math.min(wait * 2, SQLITE_BATCH_MAX_POLL_MS)) {\n\t\t\tconst won = await tryMaintenance((tx) => runTransaction(tx, isolateOptional));\n\t\t\tif (won) {\n\t\t\t\tscope.catalog = undefined;\n\t\t\t\tscope.stamps = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (performance.now() >= deadline) {\n\t\t\t\tawait waiting();\n\t\t\t\tscope.catalog = undefined;\n\t\t\t\tscope.stamps = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait pausePoll(wait);\n\t\t\tif (await batchCompletedElsewhere(database, scope, setups, pendingRestamps)) return;\n\t\t}\n\t};\n\n\ttry {\n\t\t// Pure restamp housekeeping (no queued setups, no deferred seeds): check current stamps first if any entry lacks\n\t\t// `verify`, sparing an open that changed nothing since its setups a write transaction.\n\t\tif (setups.length === 0 && !required && pendingRestamps.some((each) => each.verify === undefined)) {\n\t\t\tconst current = await readSqliteSchemaStamps(database, scope.ledger).catch(() => new Map<string, number>());\n\t\t\tconst behind = pendingRestamps.filter(\n\t\t\t\t({ stamp }) => (current.get(stampKey(stamp.domain)) ?? 0) < stamp.revision,\n\t\t\t);\n\t\t\tif (behind.length === 0) return;\n\t\t}\n\t\tawait executeOnce(false);\n\t} catch (error) {\n\t\tconst retryIgnored = usedFinisher && ignoreErrorPredicates.some((match) => match(error));\n\t\tif ((hasOptional || retryIgnored) && !(error instanceof StorageSchemaVersionError)) {\n\t\t\ttry {\n\t\t\t\tawait executeOnce(true);\n\t\t\t\treturn;\n\t\t\t} catch (retryError) {\n\t\t\t\tif (required) throw retryError;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (required) throw error;\n\t\t// Pure housekeeping restamp failure: the next open checks those stores again.\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema-catalog.js","sourceRoot":"","sources":["../../../src/core/storage/schema-catalog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,SAAS,GACd,iBAAiB,CAAC;AAQnB,SAAS,qBAAqB;IAC7B,MAAM,IAAI,GACT,UAGA,CAAC,OAAO,CAAC;IACV,MAAM,IAAI,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACxE,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,EAAK,CAAC;AACvD,CAAC;AA6BD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,GAAG;;;;;;;;iFAQ6D,CAAC;AAIlF;;;GAGG;AACH,MAAM,kBAAkB,GAAG;;wBAEH,CAAC;AACzB,MAAM,0BAA0B,GAC/B,yFAAyF,CAAC;AAE3F;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC1C,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,sBAAsB;QACvE,CAAC,CAAC,GAAG,MAAM,gBAAgB,CAAC;AAC9B,CAAC;AAED,qFAAqF;AACrF,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,UA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AAC,CAAC,CAAC;QACzF,IAAI,CAAC,WAAW,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,yBAAyB,CAAC,EAAE,CAAC;YACpF,IAAI,CAAC;gBACJ,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO;YACR,CAAC;YAAC,OAAO,UAAU,EAAE,CAAC;gBACrB,IAAI,QAAQ;oBAAE,MAAM,UAAU,CAAC;gBAC/B,OAAO;YACR,CAAC;QACF,CAAC;QACD,IAAI,QAAQ;YAAE,MAAM,KAAK,CAAC;QAC1B,8EAA8E;IAC/E,CAAC;AACF,CAAC","sourcesContent":["import type { SqliteDatabase, SqliteExecutor, SqliteRow } from \"./database.js\";\nimport { dialectOf } from \"./dialect.js\";\nimport { StorageSchemaVersionError } from \"./errors.js\";\nimport type { SequencedStatement } from \"./statement-sequence.js\";\nimport * as statementSequence from \"./statement-sequence.js\";\n\n/**\n * `transactionFinisher`, `sequenceRunner` and `statementBatch` of `statement-sequence.ts`, which the copies 0.10.3 and\n * 0.10.4 loaded lack: a process an in-place update caught keeps those copies, where a named import would fail to link.\n * Without `statementBatch`, 0.10.3's connection thread cannot run `{ script: true }` entries inside a sequence request,\n * so multi-statement scripts run via `tx.exec` instead.\n */\nconst finishers: Partial<Pick<typeof statementSequence, \"transactionFinisher\" | \"sequenceRunner\" | \"statementBatch\">> =\n\tstatementSequence;\n\n/** Minimal AsyncLocalStorage surface, resolved portably without a static `node:` import. */\ninterface AsyncScopeStore<T> {\n\tgetStore(): T | undefined;\n\trun<R>(store: T, callback: () => R): R;\n}\n\nfunction createAsyncScopeStore<T>(): AsyncScopeStore<T> | undefined {\n\tconst proc = (\n\t\tglobalThis as {\n\t\t\tprocess?: { getBuiltinModule?: (id: string) => { AsyncLocalStorage?: new <V>() => AsyncScopeStore<V> } };\n\t\t}\n\t).process;\n\tconst Ctor = proc?.getBuiltinModule?.(\"async_hooks\")?.AsyncLocalStorage;\n\treturn Ctor === undefined ? undefined : new Ctor<T>();\n}\n\n/**\n * What a schema held when one open read it: its relations, triggers and columns, and on PostgreSQL the versions its\n * ledger records. Only a positive answer is final: the schema only moves forward, so what existed then still exists,\n * while something missing may have been created since and is checked again under the store's lock.\n */\nexport interface StorageSchemaCatalog {\n\t/** The ledger the versions were read from. */\n\treadonly ledger: string;\n\t/** The highest version `ledger` recorded for `domain`; 0 when none, or when the ledger did not exist. */\n\trecordedVersion(domain: string): number;\n\t/** Whether a table (or view) named `table` existed. */\n\thasTable(table: string): boolean;\n\t/** Whether a relation (table, index, sequence…) or a trigger named `name` existed. */\n\thasObject(name: string): boolean;\n\t/** Whether `table` had a column named `column`. */\n\thasColumn(table: string, column: string): boolean;\n\t/**\n\t * Whether a function named `name` existed in the schema and this role may run it: PostgreSQL only, absent on SQLite.\n\t */\n\treadonly hasFunction?: (name: string) => boolean;\n\t/**\n\t * What kind of object `name` was on SQLite (`table`, `index`, `view` or `trigger`), from one read of\n\t * `sqlite_schema`; undefined when there was none, and always on PostgreSQL.\n\t */\n\treadonly sqliteObjectType?: (name: string) => string | undefined;\n}\n\nconst TABLE_KINDS = new Set([\"r\", \"p\", \"v\", \"m\", \"f\"]);\n\n/**\n * Every relation, trigger, column and function of the schema the statement runs in, in one statement and so one\n * snapshot. The catalog, not information_schema, finds relations, as `tableExists` does; columns come from\n * information_schema, as `columnExists` reads them. A function is listed with whether this role may execute it.\n */\nconst CATALOG_SQL = `SELECT 'relation' AS kind, c.relname::text AS name, c.relkind::text AS detail\n\tFROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace\nUNION ALL SELECT 'trigger', t.tgname::text, NULL\n\tFROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n\tWHERE c.relnamespace = current_schema()::regnamespace AND NOT t.tgisinternal\nUNION ALL SELECT 'column', table_name::text, column_name::text\n\tFROM information_schema.columns WHERE table_schema = current_schema()\nUNION ALL SELECT 'function', p.proname::text, CASE WHEN has_function_privilege(p.oid, 'EXECUTE') THEN 'executable' END\n\tFROM pg_catalog.pg_proc p WHERE p.pronamespace = current_schema()::regnamespace`;\n\ntype CatalogRow = SqliteRow & { kind: string; name: string; detail: string | null };\n\n/**\n * Every object of a SQLite database and every column of its tables, generated ones included, in one\n * statement and so one snapshot: what `tableExists`, `columnExists` and `schemaObjects` ask one at a time (#6560).\n */\nconst SQLITE_CATALOG_SQL = `SELECT 'object' AS kind, name, type AS detail FROM sqlite_master\nUNION ALL SELECT 'column', m.name, c.name FROM sqlite_master AS m JOIN pragma_table_xinfo(m.name) AS c\n\tWHERE m.type = 'table'`;\nconst SQLITE_CATALOG_VERSION_SQL =\n\t\"UNION ALL SELECT 'version', '', CAST(schema_version AS TEXT) FROM pragma_schema_version\";\n\n/**\n * @internal The table under `ledger`'s prefix where SQLite record which revision of each store's schema\n * setup ran, and the database's schema version (`PRAGMA schema_version`) once it had: `domain`, `revision`,\n * `schema_version`. SQLite counts every change to the schema in that version, whoever makes it, an older Atomic that\n * records nothing included; a revision is believed only while the version still matches, so any later change is checked\n * again (#6560). Builds that do not know the table leave it alone.\n */\nexport function sqliteSchemaStampTable(ledger: string): string {\n\treturn ledger.endsWith(\"atomic_migrations\")\n\t\t? `${ledger.slice(0, -\"atomic_migrations\".length)}atomic_schema_stamps`\n\t\t: `${ledger}_schema_stamps`;\n}\n\n/** The key a store's setup is stamped under, as the PostgreSQL ledger records it. */\nconst stampKey = (domain: string) => `schema:${domain}`;\n\ntype StampRow = SqliteRow & { domain: string | null; revision: number | bigint | null; stamped: number | bigint };\n\n/**\n * The revisions `ledger`'s stamps record whose schema version is the database's now, by stamp key, read in one\n * statement so the two agree. Stamps of an older schema version are left out: something changed the schema since.\n */\nasync function readSqliteSchemaStamps(executor: SqliteExecutor, ledger: string): Promise<Map<string, number>> {\n\tconst rows = await executor.all<StampRow>(\n\t\t`SELECT domain, revision, schema_version AS stamped FROM ${sqliteSchemaStampTable(ledger)}\n\t\tUNION ALL SELECT NULL, NULL, schema_version FROM pragma_schema_version`,\n\t);\n\tconst now = rows.find((row) => row.domain === null)?.stamped;\n\tconst stamps = new Map<string, number>();\n\tfor (const row of rows)\n\t\tif (row.domain !== null && now !== undefined && Number(row.stamped) === Number(now))\n\t\t\tstamps.set(row.domain, Number(row.revision ?? 0));\n\treturn stamps;\n}\n\n/** @internal A store's schema setup, as its stamp records it: `ledger` names the prefix, `domain` the store. */\nexport interface SqliteSchemaStamp {\n\treadonly ledger: string;\n\treadonly domain: string;\n\treadonly revision: number;\n}\n\n/** The SQLite statements that create (unless `tableExists`) and upsert `stamps` at the current `PRAGMA schema_version`. */\nfunction sqliteStampStatements(\n\tstamps: readonly SqliteSchemaStamp[],\n\ttableExists: boolean,\n): readonly SequencedStatement[] {\n\tconst ledger = stamps[0]?.ledger;\n\tif (ledger === undefined) return [];\n\tconst table = sqliteSchemaStampTable(ledger);\n\tconst upsert: SequencedStatement = {\n\t\tsql: `INSERT INTO ${table} (domain, revision, schema_version)\n\t\tSELECT column1, column2, (SELECT schema_version FROM pragma_schema_version)\n\t\tFROM (VALUES ${stamps.map(() => \"(?, ?)\").join(\", \")}) WHERE true\n\t\tON CONFLICT(domain) DO UPDATE SET revision = excluded.revision, schema_version = excluded.schema_version`,\n\t\tparams: stamps.flatMap(({ domain, revision }) => [stampKey(domain), revision]),\n\t};\n\tif (tableExists) return [upsert];\n\treturn [\n\t\t{\n\t\t\tsql: `CREATE TABLE IF NOT EXISTS ${table} (domain TEXT NOT NULL PRIMARY KEY, revision INTEGER NOT NULL, schema_version INTEGER NOT NULL)`,\n\t\t\tparams: [],\n\t\t\tscript: true,\n\t\t},\n\t\tupsert,\n\t];\n}\n\n/**\n * @internal Stamps each of `stamps`, in the transaction `tx` that ran their setups, with the schema version as that\n * transaction leaves it: a later open believes their revisions until the schema changes again (#6560). Creates the\n * stamps table first, unless `options.tableExists`, so its own creation is part of the version recorded. With\n * `options.last`, the stamps are the transaction's last statements: where its connection is pipelined, they go out with\n * its commit. SQLite only; every stamp must share a ledger.\n */\nexport async function recordSqliteSchemaStamps(\n\ttx: SqliteExecutor,\n\tstamps: readonly SqliteSchemaStamp[],\n\toptions: { readonly tableExists?: boolean; readonly last?: boolean } = {},\n): Promise<void> {\n\tconst statements = sqliteStampStatements(stamps, options.tableExists === true);\n\tif (statements.length === 0) return;\n\tconst canSequence = finishers.statementBatch !== undefined || statements.every((each) => each.script !== true);\n\tif (options.last === true && canSequence && finishers.transactionFinisher?.(tx)?.(statements) === true) return;\n\tfor (const statement of statements) {\n\t\tif (statement.script === true) await tx.exec(statement.sql);\n\t\telse await tx.run(statement.sql, ...statement.params);\n\t}\n}\n\n/** The catalog of a SQLite database, or undefined when it cannot be read, such as on a SQLite too old. */\nasync function readSqliteCatalog(\n\tdatabase: SqliteExecutor,\n\tledger: string,\n\tincludeVersion = false,\n): Promise<(StorageSchemaCatalog & { readonly schemaVersion?: number }) | undefined> {\n\tlet rows: CatalogRow[];\n\ttry {\n\t\trows = await database.all<CatalogRow>(\n\t\t\tincludeVersion ? `${SQLITE_CATALOG_SQL}\\n${SQLITE_CATALOG_VERSION_SQL}` : SQLITE_CATALOG_SQL,\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst types = new Map<string, string>();\n\tconst columns = new Set<string>();\n\tlet schemaVersion: number | undefined;\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse if (row.kind === \"version\") schemaVersion = Number(row.detail);\n\t\telse types.set(row.name, String(row.detail));\n\t}\n\treturn {\n\t\tledger,\n\t\t...(schemaVersion === undefined ? {} : { schemaVersion }),\n\t\t// SQLite records no versions: its stores' stamps are read on their own (`sqliteSchemaStampsOf`).\n\t\trecordedVersion: () => 0,\n\t\thasTable: (table) => types.get(table) === \"table\",\n\t\thasObject: (name) => types.has(name),\n\t\thasColumn: (table, column) => columns.has(`${table}\\0${column}`),\n\t\tsqliteObjectType: (name) => types.get(name),\n\t};\n}\n\ntype VersionRow = SqliteRow & { domain: string; version: number | string | null };\n\n/** The tables, objects, columns and executable functions of PostgreSQL catalog rows (`CATALOG_SQL`'s). */\nfunction catalogSets(rows: readonly CatalogRow[]) {\n\tconst tables = new Set<string>();\n\tconst objects = new Set<string>();\n\tconst columns = new Set<string>();\n\tconst functions = new Set<string>();\n\tfor (const row of rows) {\n\t\tif (row.kind === \"column\") columns.add(`${row.name}\\0${row.detail}`);\n\t\telse if (row.kind === \"function\") {\n\t\t\tif (row.detail === \"executable\") functions.add(row.name);\n\t\t} else {\n\t\t\tobjects.add(row.name);\n\t\t\tif (row.kind === \"relation\" && TABLE_KINDS.has(String(row.detail))) tables.add(row.name);\n\t\t}\n\t}\n\treturn { tables, objects, columns, functions };\n}\n\n/**\n * The catalog rows and the ledger's versions of `database`'s schema, read in one read-only transaction whose start\n * carries both reads, so they cost one round trip (#6560). The versions are undefined when the ledger did not exist;\n * the whole read is undefined when it failed.\n */\nasync function readPostgresCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tphysicalLedger: string,\n): Promise<{ rows: CatalogRow[]; versions: VersionRow[] | undefined } | undefined> {\n\tconst versionsSql = `SELECT domain, MAX(version) AS version FROM ${ledger} GROUP BY domain`;\n\tlet read: { rows: CatalogRow[]; versions: VersionRow[] | undefined } | undefined;\n\ttry {\n\t\tawait database.transaction(\n\t\t\tasync (tx) => {\n\t\t\t\tread = undefined;\n\t\t\t\tconst rows = await tx.all<CatalogRow>(CATALOG_SQL);\n\t\t\t\t// Taken even where the ledger does not exist and its read failed, so the transaction ends with its commit,\n\t\t\t\t// sent at once, rather than with a rollback after it.\n\t\t\t\tconst ledgerExists = catalogSets(rows).tables.has(physicalLedger);\n\t\t\t\tconst versions = await tx.all<VersionRow>(versionsSql).catch((error: unknown) => {\n\t\t\t\t\tif (ledgerExists) throw error;\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\tread = { rows, versions };\n\t\t\t},\n\t\t\t{\n\t\t\t\treadOnly: true,\n\t\t\t\tretryTransientFailures: true,\n\t\t\t\tleading: [\n\t\t\t\t\t{ sql: CATALOG_SQL, params: [] },\n\t\t\t\t\t{ sql: versionsSql, params: [] },\n\t\t\t\t],\n\t\t\t},\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn read;\n}\n\n/**\n * Reads `database`'s schema and the versions `ledger` records, in one read-only transaction that takes no lock. On\n * PostgreSQL, an adapter that read them when it opened gives them once (`takeOpenedCatalog`), and the first open reads\n * nothing (#6560). On SQLite, which record no versions, reads the schema alone in one statement. Undefined\n * when a read fails: the stores then check each object themselves.\n */\nexport async function readStorageSchemaCatalog(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.name === \"sqlite\") return readSqliteCatalog(database, ledger);\n\tif (!dialect.versionedMigrations || dialect.name !== \"postgres\") return undefined;\n\tconst physicalLedger = dialect.identifier(ledger);\n\tconst opened = database.takeOpenedCatalog?.();\n\tconst read =\n\t\topened !== undefined && opened.ledger === physicalLedger\n\t\t\t? {\n\t\t\t\t\trows: opened.rows as readonly CatalogRow[],\n\t\t\t\t\tversions: opened.versions as readonly VersionRow[] | undefined,\n\t\t\t\t}\n\t\t\t: await readPostgresCatalog(database, ledger, physicalLedger);\n\tif (read === undefined) return undefined;\n\tconst { tables, objects, columns, functions } = catalogSets(read.rows);\n\tconst recorded = new Map<string, number>();\n\tif (tables.has(physicalLedger)) {\n\t\tif (read.versions === undefined) return undefined;\n\t\tfor (const row of read.versions) recorded.set(row.domain, Number(row.version ?? 0));\n\t}\n\treturn {\n\t\tledger,\n\t\trecordedVersion: (domain) => recorded.get(domain) ?? 0,\n\t\thasTable: (table) => tables.has(dialect.identifier(table)),\n\t\thasObject: (name) => objects.has(dialect.identifier(name)),\n\t\thasColumn: (table, column) => columns.has(`${dialect.identifier(table)}\\0${column}`),\n\t\thasFunction: (name) => functions.has(dialect.identifier(name)),\n\t};\n}\n\n/** @internal Context passed to a queued SQLite schema setup inside an open's single write transaction (#6709). */\nexport interface SqliteSchemaBatchContext {\n\t/** The write transaction executor. */\n\treadonly tx: SqliteExecutor;\n\t/** The live schema catalog read at the start of the write transaction, authoritative under the write lock. */\n\treadonly catalog: StorageSchemaCatalog | undefined;\n\t/**\n\t * Queues a SQLite write statement or multi-statement SQL script to run in order inside the transaction. Consecutive\n\t * queued writes go out together to the connection thread, and the final run goes out with `COMMIT`. When\n\t * `options.ignoreError` returns true for a statement's failure, that error is ignored.\n\t */\n\tenqueue(\n\t\tstatement: string | SequencedStatement,\n\t\toptions?: { readonly ignoreError?: (error: unknown) => boolean },\n\t): void;\n\t/** Executes any writes queued so far; call before issuing a read on `tx` that depends on them. */\n\tflushWrites(): Promise<void>;\n\t/** Notes that this transaction added `column` to `table`, so a later queued setup does not add it again. */\n\tnoteColumnAdded(table: string, column: string): void;\n\t/** Whether `table` already has `column` in `catalog` or added earlier in this transaction. */\n\thasColumn(table: string, column: string): boolean;\n\t/** Notes that this transaction created `table`. */\n\tnoteTableCreated(table: string): void;\n\t/** Whether `table` was created earlier in this transaction. */\n\tcreatedTable(table: string): boolean;\n\t/** Whether `table` already existed in `catalog` before this transaction began. */\n\ttableExisted(table: string): boolean;\n}\n\n/** @internal A SQLite schema setup queued inside an open scope (`withStorageSchemaCatalog`) to run in one transaction. */\nexport interface SqliteSchemaBatchSetup {\n\t/** Stamp recorded for this setup once the batched transaction commits, when the store uses SQLite schema stamps. */\n\treadonly stamp?: SqliteSchemaStamp;\n\t/** Whether the schema already holds everything this setup creates (for DDL-only setups without row seeds). */\n\treadonly verify?: (catalog: StorageSchemaCatalog) => boolean;\n\t/**\n\t * Checks outside any write lock whether another host completed this setup while we waited on `tryMaintenance`.\n\t * Throwing (such as `StorageSchemaVersionError` for a newer build's database) immediately rejects the open.\n\t */\n\treadonly done?: (\n\t\tcatalog: StorageSchemaCatalog,\n\t\tstamps: ReadonlyMap<string, number> | undefined,\n\t) => boolean | Promise<boolean>;\n\t/** Reset any mutable per-attempt JS state before each transaction attempt or retry. */\n\treadonly reset?: () => void;\n\t/** Runs this setup inside the batched write transaction. */\n\treadonly run: (context: SqliteSchemaBatchContext) => Promise<void> | void;\n\t/**\n\t * Optional setup (such as an FTS5 search index): if the transaction fails, the open retries with optional setups\n\t * isolated in savepoints, calling `onFailure` instead of failing the open.\n\t */\n\treadonly optional?: boolean;\n\t/** Called when an optional setup fails and its savepoint rolls back. */\n\treadonly onFailure?: () => void;\n}\n\ninterface OpenBatch {\n\treadonly ledger: string;\n\treadonly setups: SqliteSchemaBatchSetup[];\n\treadonly restamp: Map<string, PendingRestamp>;\n}\n\ninterface CatalogScope {\n\treadonly ledger: string;\n\t/** Read when the scope starts on PostgreSQL, whose opens always ask it; on SQLite at the first question. */\n\tcatalog: Promise<StorageSchemaCatalog | undefined> | undefined;\n\treadonly read: () => Promise<StorageSchemaCatalog | undefined>;\n\tusers: number;\n\t/** The stamps valid when read, by stamp key, read at the first question: see {@link sqliteSchemaStampsOf}. */\n\tstamps: Promise<ReadonlyMap<string, number> | undefined> | undefined;\n\t/** Fallback batch used only on runtimes lacking `AsyncLocalStorage`. */\n\treadonly fallbackBatch: OpenBatch;\n}\n\ninterface PendingRestamp extends SchemaStampAtOpenEnd {\n\treadonly stamp: SqliteSchemaStamp;\n\treadonly setup: (tx: SqliteExecutor) => Promise<unknown>;\n}\n\n/** @internal How the end of an open stamps a store's setup: see {@link restampStorageSchemaAtOpenEnd}. */\nexport interface SchemaStampAtOpenEnd {\n\t/**\n\t * Whether the store's schema, as the end's transaction reads the catalog, holds everything `setup` creates. Given,\n\t * the end runs `setup` only where it does not; absent, it runs `setup` whenever the store's stamp is behind.\n\t */\n\treadonly verify?: (catalog: StorageSchemaCatalog) => boolean;\n\t/**\n\t * `setup` has not run in this open and must: the end runs it whatever the stamp, and a failure fails the open, as\n\t * the setup's own transaction would have. For a setup whose objects all exist and whose only other statements seed\n\t * rows nothing in the open reads, such as a counter's: it then shares the end's transaction instead of taking one.\n\t */\n\treadonly deferred?: boolean;\n\t/**\n\t * `setup` ran in this open, in a transaction that stamped nothing: it is stamped only when the end takes a transaction\n\t * for another store, never in one of its own, so a new database's first open takes none.\n\t */\n\treadonly alongside?: boolean;\n}\n\nconst scopes = new WeakMap<SqliteDatabase, CatalogScope>();\n/**\n * Tracks the root open batch active on each `CatalogScope` along the current async call chain: nested opens share their\n * enclosing root's batch and commit together at the root's end, while concurrent sibling opens on the same database\n * handle each own and commit their own batch before returning (#6709).\n */\nconst activeOpenBatches = createAsyncScopeStore<ReadonlyMap<CatalogScope, OpenBatch>>();\n\n/** How long a SQLite open batch polls `done` after `tryMaintenance` finds the lock busy before joining the queue. */\nconst SQLITE_BATCH_WAIT_MS = 1_000;\nconst SQLITE_BATCH_POLL_MS = 20;\nconst SQLITE_BATCH_MAX_POLL_MS = 250;\n\nconst pausePoll = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms * (0.5 + Math.random() / 2)));\n\n/**\n * Runs `body`, an open of one or more stores on `database`, with one catalog read for all of them: the schema checks\n * of the stores it opens ({@link schemaCatalogOf}) answer from it, so an open whose schema is current runs no schema\n * transaction and takes no lock. Opens on `database` that overlap share the read. On SQLite, setups queued inside the\n * open ({@link queueSqliteSchemaSetup}) run in one write transaction before the root open returns (#6709). `views` are\n * other handles on the same connection, such as a borrowed view, whose checks answer from the same read.\n */\nexport async function withStorageSchemaCatalog<T>(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tbody: () => Promise<T>,\n\tviews: readonly SqliteDatabase[] = [],\n): Promise<T> {\n\tlet scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger) {\n\t\tconst read = () => readStorageSchemaCatalog(database, ledger);\n\t\tconst catalog = dialectOf(database).name === \"sqlite\" ? undefined : read();\n\t\tscope = {\n\t\t\tledger,\n\t\t\tcatalog,\n\t\t\tread,\n\t\t\tusers: 0,\n\t\t\tstamps: undefined,\n\t\t\tfallbackBatch: { ledger, setups: [], restamp: new Map() },\n\t\t};\n\t\tscopes.set(database, scope);\n\t}\n\tconst shared = scope;\n\tconst handles = [database, ...views.filter((view) => !scopes.has(view))];\n\tfor (const handle of handles.slice(1)) scopes.set(handle, shared);\n\tshared.users += 1;\n\tconst enclosing = activeOpenBatches?.getStore();\n\tconst isRoot = activeOpenBatches === undefined ? shared.users === 1 : enclosing?.has(shared) !== true;\n\tconst batch: OpenBatch =\n\t\tactiveOpenBatches === undefined\n\t\t\t? shared.fallbackBatch\n\t\t\t: isRoot\n\t\t\t\t? { ledger, setups: [], restamp: new Map() }\n\t\t\t\t: enclosing!.get(shared)!;\n\tconst run = async (): Promise<T> => {\n\t\tconst value = await body();\n\t\tif (isRoot && (batch.setups.length > 0 || batch.restamp.size > 0)) await flushOpenBatch(database, shared, batch);\n\t\treturn value;\n\t};\n\ttry {\n\t\tif (!isRoot || activeOpenBatches === undefined) return await run();\n\t\tconst next = new Map(enclosing);\n\t\tnext.set(shared, batch);\n\t\treturn await activeOpenBatches.run(next, run);\n\t} finally {\n\t\tshared.users -= 1;\n\t\tfor (const handle of handles.slice(1)) if (scopes.get(handle) === shared) scopes.delete(handle);\n\t\tif (shared.users === 0 && scopes.get(database) === shared) scopes.delete(database);\n\t}\n}\n\n/**\n * Drops the catalog an open of `database` in progress read, so the next question reads the schema again: for a step of\n * the open that changed the schema the stores it opens after it ask about.\n */\nexport function refreshStorageSchemaCatalog(database: SqliteDatabase): void {\n\tconst scope = scopes.get(database);\n\tif (scope !== undefined) {\n\t\tscope.catalog = undefined;\n\t\tscope.stamps = undefined;\n\t}\n}\n\n/**\n * Tells the catalog an open of `database` in progress read that the open created `tables` since, so the stores it\n * opens next find them without reading the schema again.\n */\nexport function noteStorageSchemaTables(database: SqliteDatabase, tables: readonly string[]): void {\n\tconst scope = scopes.get(database);\n\tif (scope?.catalog === undefined) return;\n\tconst identifier = dialectOf(database).identifier;\n\tconst created = new Set(tables.map((table) => identifier(table)));\n\tscope.catalog = scope.catalog.then(\n\t\t(catalog) =>\n\t\t\tcatalog && {\n\t\t\t\t...catalog,\n\t\t\t\thasTable: (table) => created.has(identifier(table)) || catalog.hasTable(table),\n\t\t\t\thasObject: (name) => created.has(identifier(name)) || catalog.hasObject(name),\n\t\t\t},\n\t);\n}\n\n/**\n * The catalog an open of `database` in progress read ({@link withStorageSchemaCatalog}), when it read `ledger`'s\n * versions or no `ledger` is named; undefined outside such an open, and when it could not be read.\n */\nexport async function schemaCatalogOf(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n): Promise<StorageSchemaCatalog | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || (ledger !== undefined && scope.ledger !== ledger)) return undefined;\n\tscope.catalog ??= scope.read();\n\treturn scope.catalog;\n}\n\n/**\n * @internal The revisions the stamps under `ledger` record for the stores of `database` (SQLite), by stamp\n * key (`schema:<domain>`), as the open of `database` in progress read them; only those whose schema version was the\n * database's then. Undefined outside such an open, and where none could be read, such as before any stamp. The first\n * question reads them after the open's catalog, and only where it holds their table.\n */\nexport async function sqliteSchemaStampsOf(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n): Promise<ReadonlyMap<string, number> | undefined> {\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || scope.ledger !== ledger || dialectOf(database).name !== \"sqlite\") return undefined;\n\t// Read once the catalog shows their table: a read of a missing table would fail, which costs a request, and makes a\n\t// driver may replace its connection.\n\tscope.stamps ??= schemaCatalogOf(database, ledger).then((catalog) =>\n\t\tcatalog?.hasTable(sqliteSchemaStampTable(ledger)) === true\n\t\t\t? readSqliteSchemaStamps(database, ledger).then(\n\t\t\t\t\t(read) => read,\n\t\t\t\t\t() => undefined,\n\t\t\t\t)\n\t\t\t: undefined,\n\t);\n\treturn scope.stamps;\n}\n\n/** Active root open batch for `database` on SQLite (matching `ledger` when given), or undefined outside one. */\nfunction activeBatchFor(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n): { readonly scope: CatalogScope; readonly batch: OpenBatch } | undefined {\n\tif (dialectOf(database).name !== \"sqlite\") return undefined;\n\tconst scope = scopes.get(database);\n\tif (scope === undefined || (ledger !== undefined && scope.ledger !== ledger)) return undefined;\n\tconst batch = activeOpenBatches === undefined ? scope.fallbackBatch : activeOpenBatches.getStore()?.get(scope);\n\treturn batch === undefined ? undefined : { scope, batch };\n}\n\n/**\n * @internal Queues `setup` into the active SQLite open scope (`withStorageSchemaCatalog`) so that all needed setups of\n * the open execute in one write transaction before the open returns (#6709). Returns `false` outside a SQLite open\n * scope (or for a different `ledger`), in which case the caller runs `setup` immediately.\n */\nexport function queueSqliteSchemaSetup(\n\tdatabase: SqliteDatabase,\n\tledger: string | undefined,\n\tsetup: SqliteSchemaBatchSetup,\n): boolean {\n\tconst active = activeBatchFor(database, ledger);\n\tif (active === undefined) return false;\n\tactive.batch.setups.push(setup);\n\treturn true;\n}\n\n/**\n * @internal Executes and commits any SQLite schema setups queued so far in the active open scope, before the open\n * needs their committed tables or evaluated outcomes (#6709). No-op when nothing is queued or outside a SQLite open.\n * Pass `unaffectedStampPrefix` only for domains whose schema and seed data none of the queued setups can change.\n */\nexport async function flushStorageSchemaSetups(\n\tdatabase: SqliteDatabase,\n\tledger?: string,\n\tunaffectedStampPrefix?: string,\n): Promise<void> {\n\tconst active = activeBatchFor(database, ledger);\n\tif (active === undefined) return;\n\tif (active.batch.setups.length === 0 && active.batch.restamp.size === 0) return;\n\tawait flushOpenBatch(database, active.scope, active.batch, unaffectedStampPrefix);\n}\n\n/**\n * @internal Tells the open of `database` in progress that it checked `setup`, the schema setup `stamp` names, without\n * its stamp (SQLite only): it ran it in a transaction that stamped it, found every object it creates in the\n * catalog (with `verify`), or leaves it to the end (`deferred`). A schema change later in the same open, such as the\n * next store's setup or a column it adds, leaves a stamp behind the schema version, and a store found in the catalog has\n * none that is current, so the next open would check it again. The open's end checks or runs them in one transaction\n * and stamps them all with the version it leaves: the next open of a current schema then takes no write lock and answers\n * every such store from its stamp (#6560, #6709). False, and nothing is kept, outside such an open.\n */\nexport function restampStorageSchemaAtOpenEnd(\n\tdatabase: SqliteDatabase,\n\tstamp: SqliteSchemaStamp,\n\tsetup: (tx: SqliteExecutor) => Promise<unknown>,\n\toptions: SchemaStampAtOpenEnd = {},\n): boolean {\n\tconst active = activeBatchFor(database, stamp.ledger);\n\tif (active === undefined) return false;\n\tactive.batch.restamp.set(stamp.domain, { stamp, setup, ...options });\n\treturn true;\n}\n\ninterface QueuedBatchWrite {\n\treadonly statement: SequencedStatement;\n\treadonly ignoreError?: (error: unknown) => boolean;\n}\n\n/**\n * Sends `writes` on `tx`, piggybacking onto `COMMIT` when `last` is true and the connection supports it. Returns\n * `true` when sent via `transactionFinisher` (without per-statement `ignoreError` handling).\n */\nasync function sendBatchWrites(\n\ttx: SqliteExecutor,\n\twrites: readonly QueuedBatchWrite[],\n\tlast: boolean,\n): Promise<boolean> {\n\tif (writes.length === 0) return false;\n\tconst statements = writes.map(({ statement }) => statement);\n\tconst canSequence = finishers.statementBatch !== undefined || statements.every((each) => each.script !== true);\n\tif (last && canSequence && finishers.transactionFinisher?.(tx)?.(statements) === true) return true;\n\tconst runSequence = canSequence ? finishers.sequenceRunner?.(tx) : undefined;\n\tif (runSequence !== undefined && writes.every(({ ignoreError }) => ignoreError === undefined)) {\n\t\tawait runSequence({ statements });\n\t\treturn false;\n\t}\n\tfor (const { statement, ignoreError } of writes) {\n\t\ttry {\n\t\t\tif (statement.script === true) await tx.exec(statement.sql);\n\t\t\telse await tx.run(statement.sql, ...statement.params);\n\t\t} catch (error) {\n\t\t\tif (ignoreError?.(error) !== true) throw error;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Checks outside any write lock whether another host completed every queued setup and restamp in this open batch.\n * Updates `scope.catalog` and `scope.stamps` when complete so later questions in the same open see the fresh schema.\n */\nasync function batchCompletedElsewhere(\n\tdatabase: SqliteDatabase,\n\tscope: CatalogScope,\n\tsetups: readonly SqliteSchemaBatchSetup[],\n\trestamps: readonly PendingRestamp[],\n): Promise<boolean> {\n\tconst catalog = await readSqliteCatalog(database, scope.ledger);\n\tif (catalog === undefined) return false;\n\tconst stampTable = sqliteSchemaStampTable(scope.ledger);\n\tconst needsStamps = setups.some((each) => each.stamp !== undefined) || restamps.length > 0;\n\tconst stamps =\n\t\tneedsStamps && catalog.hasTable(stampTable)\n\t\t\t? await readSqliteSchemaStamps(database, scope.ledger).catch(() => undefined)\n\t\t\t: undefined;\n\tfor (const entry of setups) {\n\t\tif (entry.done !== undefined) {\n\t\t\tif (!(await entry.done(catalog, stamps))) return false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.stamp !== undefined) {\n\t\t\tif ((stamps?.get(stampKey(entry.stamp.domain)) ?? 0) < entry.stamp.revision) return false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.verify !== undefined) {\n\t\t\tif (!entry.verify(catalog)) return false;\n\t\t\tcontinue;\n\t\t}\n\t\treturn false;\n\t}\n\tfor (const entry of restamps) {\n\t\tif (entry.alongside === true && setups.length === 0) continue;\n\t\tif ((stamps?.get(stampKey(entry.stamp.domain)) ?? 0) < entry.stamp.revision) return false;\n\t}\n\tscope.catalog = Promise.resolve(catalog);\n\tscope.stamps = stamps === undefined ? undefined : Promise.resolve(stamps);\n\treturn true;\n}\n\n/**\n * Runs every queued setup and restamp of `batch` in ONE SQLite write transaction through `tryMaintenance`, polling\n * `batchCompletedElsewhere` when another host holds the lock and falling back to a normal serial transaction after\n * {@link SQLITE_BATCH_WAIT_MS} (#6709).\n */\nasync function flushOpenBatch(\n\tdatabase: SqliteDatabase,\n\tscope: CatalogScope,\n\tbatch: OpenBatch,\n\tunaffectedStampPrefix?: string,\n): Promise<void> {\n\tconst setups = batch.setups.splice(0);\n\tconst pendingRestamps = [...batch.restamp.values()];\n\tbatch.restamp.clear();\n\tif (setups.length === 0 && pendingRestamps.every((each) => each.alongside === true)) return;\n\tconst required = setups.length > 0 || pendingRestamps.some((each) => each.deferred === true);\n\tconst hasOptional = setups.some((each) => each.optional === true);\n\tconst stampTable = sqliteSchemaStampTable(scope.ledger);\n\n\tlet ignoreErrorPredicates: ((error: unknown) => boolean)[] = [];\n\tlet usedFinisher = false;\n\tconst runTransaction = async (tx: SqliteExecutor, isolateOptional: boolean): Promise<void> => {\n\t\tignoreErrorPredicates = [];\n\t\tusedFinisher = false;\n\t\tfor (const entry of setups) entry.reset?.();\n\t\tconst catalog = await readSqliteCatalog(tx, scope.ledger, unaffectedStampPrefix !== undefined);\n\t\tconst writes: QueuedBatchWrite[] = [];\n\t\tconst addedColumns = new Set<string>();\n\t\tconst createdTables = new Set<string>();\n\t\tconst flushWrites = async (): Promise<void> => {\n\t\t\tif (writes.length === 0) return;\n\t\t\tconst batchWrites = writes.splice(0);\n\t\t\tawait sendBatchWrites(tx, batchWrites, false);\n\t\t};\n\t\tconst context: SqliteSchemaBatchContext = {\n\t\t\ttx,\n\t\t\tcatalog,\n\t\t\tenqueue(statement, options) {\n\t\t\t\tconst sequenced: SequencedStatement =\n\t\t\t\t\ttypeof statement === \"string\" ? { sql: statement, params: [], script: true } : statement;\n\t\t\t\tif (options?.ignoreError !== undefined) ignoreErrorPredicates.push(options.ignoreError);\n\t\t\t\twrites.push({\n\t\t\t\t\tstatement: sequenced,\n\t\t\t\t\t...(options?.ignoreError === undefined ? {} : { ignoreError: options.ignoreError }),\n\t\t\t\t});\n\t\t\t},\n\t\t\tflushWrites,\n\t\t\tnoteColumnAdded(table, column) {\n\t\t\t\taddedColumns.add(`${table}\\0${column}`);\n\t\t\t},\n\t\t\thasColumn(table, column) {\n\t\t\t\treturn catalog?.hasColumn(table, column) === true || addedColumns.has(`${table}\\0${column}`);\n\t\t\t},\n\t\t\tnoteTableCreated(table) {\n\t\t\t\tcreatedTables.add(table);\n\t\t\t},\n\t\t\tcreatedTable(table) {\n\t\t\t\treturn createdTables.has(table);\n\t\t\t},\n\t\t\ttableExisted(table) {\n\t\t\t\treturn catalog?.hasTable(table) === true;\n\t\t\t},\n\t\t};\n\n\t\tfor (const entry of setups) {\n\t\t\tif (!isolateOptional || entry.optional !== true) {\n\t\t\t\tawait entry.run(context);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait flushWrites();\n\t\t\tawait tx.exec(\"SAVEPOINT atomic_optional_schema_setup\");\n\t\t\ttry {\n\t\t\t\tawait entry.run(context);\n\t\t\t\tawait flushWrites();\n\t\t\t} catch {\n\t\t\t\twrites.length = 0;\n\t\t\t\tawait tx.exec(\"ROLLBACK TO SAVEPOINT atomic_optional_schema_setup\");\n\t\t\t\tentry.onFailure?.();\n\t\t\t}\n\t\t\tawait tx.exec(\"RELEASE SAVEPOINT atomic_optional_schema_setup\");\n\t\t}\n\n\t\tfor (const { setup, verify, deferred } of pendingRestamps) {\n\t\t\tif (deferred === true || verify === undefined || catalog === undefined || !verify(catalog)) {\n\t\t\t\tawait flushWrites();\n\t\t\t\tawait setup(tx);\n\t\t\t}\n\t\t}\n\n\t\t// Collect stamps for every stamped setup and restamp in this batch (deduplicated by domain, keeping highest revision).\n\t\tconst stampByDomain = new Map<string, SqliteSchemaStamp>();\n\t\tfor (const entry of setups) {\n\t\t\tif (entry.stamp === undefined) continue;\n\t\t\tconst prev = stampByDomain.get(entry.stamp.domain);\n\t\t\tif (prev === undefined || entry.stamp.revision > prev.revision)\n\t\t\t\tstampByDomain.set(entry.stamp.domain, entry.stamp);\n\t\t}\n\t\tfor (const entry of pendingRestamps) {\n\t\t\tconst prev = stampByDomain.get(entry.stamp.domain);\n\t\t\tif (prev === undefined || entry.stamp.revision > prev.revision)\n\t\t\t\tstampByDomain.set(entry.stamp.domain, entry.stamp);\n\t\t}\n\t\tif (stampByDomain.size > 0) {\n\t\t\tconst stampStmts = sqliteStampStatements([...stampByDomain.values()], catalog?.hasTable(stampTable) === true);\n\t\t\tfor (const statement of stampStmts) writes.push({ statement });\n\t\t}\n\n\t\t// SQLite's schema version is database-wide. Carry still-valid stamps for untouched domains through our own DDL.\n\t\t// The starting version was read under this write lock, so changes by older builds or external tools still\n\t\t// invalidate stamps: a stamp already stale when we took the lock must stay stale (#6886).\n\t\tif (unaffectedStampPrefix !== undefined && catalog?.schemaVersion !== undefined && catalog.hasTable(stampTable)) {\n\t\t\tconst version = \"(SELECT schema_version FROM pragma_schema_version)\";\n\t\t\twrites.push({\n\t\t\t\tstatement: {\n\t\t\t\t\tsql: `UPDATE ${stampTable} SET schema_version = ${version}\n\t\t\t\t\tWHERE schema_version = ? AND schema_version <> ${version} AND instr(domain, ?) = 1`,\n\t\t\t\t\tparams: [catalog.schemaVersion, stampKey(unaffectedStampPrefix)],\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tusedFinisher = await sendBatchWrites(tx, writes.splice(0), !isolateOptional);\n\t};\n\n\tconst executeOnce = async (isolateOptional: boolean): Promise<void> => {\n\t\tconst waiting = () =>\n\t\t\tdatabase.transaction((tx) => runTransaction(tx, isolateOptional), {\n\t\t\t\tretryTransientFailures: true,\n\t\t\t\tconcurrency: { kind: \"serial\", domain: scope.ledger },\n\t\t\t});\n\t\tconst tryMaintenance = database.tryMaintenance?.bind(database);\n\t\tif (tryMaintenance === undefined) {\n\t\t\tawait waiting();\n\t\t\tscope.catalog = undefined;\n\t\t\tscope.stamps = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst deadline = performance.now() + SQLITE_BATCH_WAIT_MS;\n\t\tfor (let wait = SQLITE_BATCH_POLL_MS; ; wait = Math.min(wait * 2, SQLITE_BATCH_MAX_POLL_MS)) {\n\t\t\tconst won = await tryMaintenance((tx) => runTransaction(tx, isolateOptional));\n\t\t\tif (won) {\n\t\t\t\tscope.catalog = undefined;\n\t\t\t\tscope.stamps = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (performance.now() >= deadline) {\n\t\t\t\tawait waiting();\n\t\t\t\tscope.catalog = undefined;\n\t\t\t\tscope.stamps = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait pausePoll(wait);\n\t\t\tif (await batchCompletedElsewhere(database, scope, setups, pendingRestamps)) return;\n\t\t}\n\t};\n\n\ttry {\n\t\t// Pure restamp housekeeping (no queued setups, no deferred seeds): check current stamps first if any entry lacks\n\t\t// `verify`, sparing an open that changed nothing since its setups a write transaction.\n\t\tif (setups.length === 0 && !required && pendingRestamps.some((each) => each.verify === undefined)) {\n\t\t\tconst current = await readSqliteSchemaStamps(database, scope.ledger).catch(() => new Map<string, number>());\n\t\t\tconst behind = pendingRestamps.filter(\n\t\t\t\t({ stamp }) => (current.get(stampKey(stamp.domain)) ?? 0) < stamp.revision,\n\t\t\t);\n\t\t\tif (behind.length === 0) return;\n\t\t}\n\t\tawait executeOnce(false);\n\t} catch (error) {\n\t\tconst retryIgnored = usedFinisher && ignoreErrorPredicates.some((match) => match(error));\n\t\tif ((hasOptional || retryIgnored) && !(error instanceof StorageSchemaVersionError)) {\n\t\t\ttry {\n\t\t\t\tawait executeOnce(true);\n\t\t\t\treturn;\n\t\t\t} catch (retryError) {\n\t\t\t\tif (required) throw retryError;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (required) throw error;\n\t\t// Pure housekeeping restamp failure: the next open checks those stores again.\n\t}\n}\n"]}
|