@bastani/atomic 0.10.11-alpha.2 → 0.10.11-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -0
- package/README.md +5 -8
- 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-7KXUFI2F.js +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +14 -2
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js.map → p1b-elig-TVB5CBLL.js.map} +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +340 -163
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-EZUKEP4Q.js} +48 -40
- package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-RTOHJFDJ.js} +195 -42
- package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +33 -43
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +39 -23
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +90 -1176
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +186 -35
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +23 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +913 -289
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
- package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
- package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +170 -74
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +298 -47
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
- package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +136 -19
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +2 -3
- package/dist/builtin/intercom/package.json +1 -1
- 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 +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- 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.code.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- 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 +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- 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 +2 -2
- 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.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- 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/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 +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- 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/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/process-start-token.d.ts +8 -0
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- 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 +1 -1
- 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-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +19 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +11 -0
- package/dist/core/storage/fenced-paths.js +11 -0
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +8 -13
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +51 -3
- package/dist/core/storage/node-sqlite.js.map +1 -1
- 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.d.ts +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +7 -8
- package/dist/core/storage/schema-catalog.js +8 -8
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- 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 +3 -3
- 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.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 +2 -2
- 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 +4 -7
- 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 +3 -3
- 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 +5 -1
- 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.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- 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/session-search-index.d.ts +43 -4
- 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 +3 -3
- 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 +48 -11
- 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.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +6 -1
- package/dist/core/storage/sqlite-facade.js +1 -0
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- 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.code.js +1 -1
- package/dist/core/storage/team.d.ts +26 -115
- 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/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 +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- 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/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- 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.d.ts +40 -3
- package/dist/core/worktree-snapshot/blob-store.js +414 -21
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +79 -38
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- 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 +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- 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 +3 -1
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- 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/interactive/components/stored-tree-view.code.js +2 -2
- 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/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +6 -6
- 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/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- package/dist/utils/startup-database-spare.code.js +2 -2
- 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/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1421 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/core/storage/migrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAgCtG,qHAAqH;AACrH,SAAS,eAAe,CAAC,OAAe,EAAE,SAAiB,EAAE,OAAgC;IAC5F,OAAO,OAAO,IAAI,SAAS,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,SAAS,CAAC,CAAC;AAClH,CAAC;AASD,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD,SAAS,UAAU,CAAC,KAAsC;IACzD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,QAAQ;YAClE,MAAM,IAAI,kBAAkB,CAC3B,KAAK,EACL,OAAO,EACP,qBAAqB,EACrB,uDAAuD,CACvD,CAAC;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,mBAAmB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,EAAE,CAAC,IAAI,CAAC,eAAe,KAAK,sBAAsB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACpF,CAAC,CAAC,EACH,EAAE,sBAAsB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CACjF,CAAC;AACH,CAAC","sourcesContent":["import type { SqliteDatabase, SqliteExecutor, SqliteRow } from \"./database.js\";\nimport { dialectOf, type StorageDialect } from \"./dialect.js\";\nimport { StorageConfigError, StorageSchemaVersionError } from \"./errors.js\";\nimport { recordSqliteSchemaStamps, schemaCatalogOf, sqliteSchemaStampsOf } from \"./schema-catalog.js\";\n\n/** One version of a domain's schema. */\nexport interface StorageMigrationStep {\n\t/** A positive integer; a domain's steps are listed in increasing order. */\n\treadonly version: number;\n\t/**\n\t * Brings the schema from the previous version to this one. It may use only `transaction`: the runner may run the\n\t * whole migration again after a transient failure. On a dialect without `versionedMigrations` (SQLite) every step\n\t * runs each time, so its statements must be idempotent (`CREATE … IF NOT EXISTS`).\n\t */\n\tup(transaction: SqliteExecutor, dialect: StorageDialect): Promise<void>;\n}\n\nexport interface StorageMigrationOptions {\n\t/** The ledger table, already prefixed (`renderStorageIdentifiers`); default `atomic_migrations`. */\n\treadonly table?: string;\n\t/**\n\t * A recorded version newer than the last step is accepted, and nothing runs, instead of refusing with\n\t * `StorageSchemaVersionError`. Only for a domain whose later steps stay additive, so a build that knows fewer of\n\t * them still reads and writes it correctly (#5065).\n\t */\n\treadonly acceptNewer?: boolean;\n\t/**\n\t * A recorded version above the last step and at most this one is accepted, and nothing runs; a newer one is still\n\t * refused. For versions that only an explicit command records, never a migration this call would run: the sessions\n\t * domain's version 3, which turns on forks that share their parent's history (#6560), and which builds that do not\n\t * list it refuse.\n\t */\n\treadonly recordedThrough?: number;\n}\n\n/** Whether a recorded `version` above the last step, `supported`, is accepted under `options` instead of refused. */\nfunction acceptsRecorded(version: number, supported: number, options: StorageMigrationOptions): boolean {\n\treturn version <= supported || options.acceptNewer === true || version <= (options.recordedThrough ?? supported);\n}\n\nexport interface StorageMigrationResult {\n\t/** The versions this call ran, in order. */\n\treadonly applied: readonly number[];\n\t/** The domain's schema version after the call. */\n\treadonly version: number;\n}\n\nconst DEFAULT_MIGRATION_TABLE = \"atomic_migrations\";\n\nfunction checkSteps(steps: readonly StorageMigrationStep[]): void {\n\tlet previous = 0;\n\tfor (const step of steps) {\n\t\tif (!Number.isSafeInteger(step.version) || step.version <= previous)\n\t\t\tthrow new StorageConfigError(\n\t\t\t\t\"sdk\",\n\t\t\t\t\"steps\",\n\t\t\t\t\"versions-increasing\",\n\t\t\t\t\"Number migration steps 1, 2, 3, … in increasing order\",\n\t\t\t);\n\t\tprevious = step.version;\n\t}\n}\n\n/** Whether `table` exists, read from the catalog: no DDL, so a role without CREATE can ask (#5218). */\nasync function tableExists(executor: SqliteExecutor, dialect: StorageDialect, table: string): Promise<boolean> {\n\tconst probe = dialect.tableExists(table);\n\treturn (await executor.get(probe.sql, ...probe.params)) !== undefined;\n}\n\n/**\n * Refuses, before any DDL, a role that cannot use the schema the database runs in: the setup would fail with a bare\n * `3F000` or `42501` that names neither the grant nor the role (#5218). PostgreSQL only.\n */\nasync function assertSchemaUsage(executor: SqliteExecutor, dialect: StorageDialect): Promise<void> {\n\tif (dialect.name !== \"postgres\") return;\n\tconst access = await executor.get<SqliteRow & { schema: string; role: string; present: number; usage: number }>(\n\t\t`SELECT s.name AS schema, current_user AS role, (n.oid IS NOT NULL)::int AS present,\n\t\t\tcoalesce(has_schema_privilege(n.oid, 'USAGE'), false)::int AS usage\n\t\tFROM (SELECT trim(both '\"' from split_part(current_setting('search_path'), ',', 1)) AS name) s\n\t\tLEFT JOIN pg_catalog.pg_namespace n ON n.nspname = s.name`,\n\t);\n\tif (access === undefined || Number(access.present) === 0 || Number(access.usage) === 1) return;\n\tthrow new StorageConfigError(\n\t\t\"sdk\",\n\t\t\"privileges\",\n\t\t\"missing-privilege\",\n\t\t`Role \"${access.role}\" has no USAGE on schema ${access.schema}, so it can neither find Atomic's tables there nor create them. Grant it as the schema's owner: GRANT USAGE ON SCHEMA ${access.schema} TO \"${access.role}\"; and, for a runtime role, the table grants in \"Set up the database\" in docs/storage.md`,\n\t);\n}\n\n/** Creates the ledger `table` unless it exists, so a current schema runs no DDL (#5218). */\nasync function createLedger(executor: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void> {\n\tif (await tableExists(executor, dialect, table)) return;\n\tawait assertSchemaUsage(executor, dialect);\n\t// Two stores that set up their schemas at once never race to create the ledger they share.\n\tif (dialect.name === \"postgres\") {\n\t\tawait executor.get(\"SELECT pg_advisory_xact_lock(hashtextextended(?, 0)) AS locked\", `${table}:schema`);\n\t\tif (await tableExists(executor, dialect, table)) return;\n\t}\n\tconst { int, text } = dialect.types;\n\tawait executor.exec(\n\t\t`CREATE TABLE IF NOT EXISTS ${table} (domain ${text} NOT NULL, version ${int} NOT NULL, applied_at ${int} NOT NULL, PRIMARY KEY (domain, version))${dialect.tableOptions}`,\n\t);\n}\n\n/** The highest version `table` records for `domain`, 0 when none or when the ledger does not exist yet. */\nasync function recordedVersion(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttable: string,\n\tdomain: string,\n): Promise<number> {\n\tif (!(await tableExists(executor, dialect, table))) return 0;\n\tconst row = await executor.get<SqliteRow & { version: number | null }>(\n\t\t`SELECT MAX(version) AS version FROM ${table} WHERE domain = ?`,\n\t\tdomain,\n\t);\n\treturn Number(row?.version ?? 0);\n}\n\nasync function applyVersioned(\n\ttransaction: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttable: string,\n\tdomain: string,\n\tsteps: readonly StorageMigrationStep[],\n\toptions: StorageMigrationOptions = {},\n): Promise<StorageMigrationResult> {\n\tconst current = await recordedVersion(transaction, dialect, table, domain);\n\tconst supported = steps.at(-1)?.version ?? 0;\n\tif (current > supported) {\n\t\tif (acceptsRecorded(current, supported, options)) return { applied: [], version: current };\n\t\tthrow new StorageSchemaVersionError(domain, current, supported);\n\t}\n\tconst applied: number[] = [];\n\t// Probed first: a current schema, whose ledger exists, runs no DDL (#5218).\n\tawait createLedger(transaction, dialect, table);\n\tfor (const step of steps) {\n\t\tif (step.version <= current) continue;\n\t\tawait step.up(transaction, dialect);\n\t\tawait transaction.run(`INSERT INTO ${table} VALUES (?, ?, ${dialect.nowMs})`, domain, step.version);\n\t\tapplied.push(step.version);\n\t}\n\treturn { applied, version: Math.max(current, supported) };\n}\n\n/**\n * Advances `domain`'s schema to the last of `steps`, or refuses. Runs in one `serial` transaction whose domain is the ledger\n * table's name, so concurrent migrators under one prefix run one after another and a failed step rolls back the\n * whole call. Where the dialect has `versionedMigrations` (Postgres), applied versions are recorded in `table`: only\n * missing steps run, and a recorded version newer than the last step is a `StorageSchemaVersionError`. On SQLite\n * nothing is recorded (schemas stay what older Atomic versions share) and every step runs, idempotently; the domain's\n * own version row stays authoritative there.\n */\nexport async function applyStorageMigrations(\n\tdatabase: SqliteDatabase,\n\tdomain: string,\n\tsteps: readonly StorageMigrationStep[],\n\toptions: StorageMigrationOptions = {},\n): Promise<StorageMigrationResult> {\n\tcheckSteps(steps);\n\tconst dialect = dialectOf(database);\n\tconst table = options.table ?? DEFAULT_MIGRATION_TABLE;\n\tconst recorded = dialect.versionedMigrations ? await recordedInCatalog(database, table, domain) : undefined;\n\tconst supported = steps.at(-1)?.version ?? 0;\n\tif (recorded !== undefined && recorded >= supported && supported > 0) {\n\t\tif (!acceptsRecorded(recorded, supported, options))\n\t\t\tthrow new StorageSchemaVersionError(domain, recorded, supported);\n\t\treturn { applied: [], version: recorded };\n\t}\n\treturn database.transaction(\n\t\tasync (transaction) => {\n\t\t\tif (dialect.versionedMigrations) return applyVersioned(transaction, dialect, table, domain, steps, options);\n\t\t\tfor (const step of steps) await step.up(transaction, dialect);\n\t\t\treturn { applied: steps.map((step) => step.version), version: steps.at(-1)?.version ?? 0 };\n\t\t},\n\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: table } },\n\t);\n}\n\n/**\n * The version `table` records for `domain` in the catalog an open in progress read, or undefined outside one: an open\n * that finds every step recorded neither locks nor runs a transaction, as the steps would change nothing (#6560).\n */\nasync function recordedInCatalog(database: SqliteDatabase, table: string, domain: string): Promise<number | undefined> {\n\tconst catalog = await schemaCatalogOf(database, table);\n\tif (catalog === undefined || !catalog.hasTable(table)) return undefined;\n\treturn catalog.recordedVersion(domain);\n}\n\n/** One domain's migration for {@link applyStorageMigrationsTogether}: the arguments of {@link applyStorageMigrations}. */\nexport interface StorageDomainMigration {\n\treadonly domain: string;\n\treadonly steps: readonly StorageMigrationStep[];\n\treadonly options?: StorageMigrationOptions;\n}\n\n/**\n * Migrates each of `migrations` in order, as {@link applyStorageMigrations} would, and resolves with each one's result.\n * Where the dialect records no versions (SQLite), every step runs every time, so the domains share one transaction: one\n * turn of the write lock for all of them, and a failure rolls back all of them. Elsewhere each domain migrates in a\n * transaction of its own, as `applyStorageMigrations` runs it.\n */\nexport async function applyStorageMigrationsTogether(\n\tdatabase: SqliteDatabase,\n\tmigrations: readonly StorageDomainMigration[],\n): Promise<StorageMigrationResult[]> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.versionedMigrations) {\n\t\tconst results: StorageMigrationResult[] = [];\n\t\tfor (const { domain, steps, options } of migrations)\n\t\t\tresults.push(await applyStorageMigrations(database, domain, steps, options));\n\t\treturn results;\n\t}\n\tfor (const { steps } of migrations) checkSteps(steps);\n\tconst table = migrations[0]?.options?.table ?? DEFAULT_MIGRATION_TABLE;\n\treturn database.transaction(\n\t\tasync (transaction) => {\n\t\t\tconst results: StorageMigrationResult[] = [];\n\t\t\tfor (const { steps } of migrations) {\n\t\t\t\tfor (const step of steps) await step.up(transaction, dialect);\n\t\t\t\tresults.push({ applied: steps.map((step) => step.version), version: steps.at(-1)?.version ?? 0 });\n\t\t\t}\n\t\t\treturn results;\n\t\t},\n\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: table } },\n\t);\n}\n\n/** How long one schema setup statement waits for a table lock before the setup backs off and tries again (#5218). */\nexport const SCHEMA_SETUP_LOCK_WAIT_MS = 1_000;\n/** How many times a schema setup runs before a lock it keeps waiting for fails it. */\nconst SCHEMA_SETUP_ATTEMPTS = 8;\n/** The first pause between attempts; each later one doubles, up to {@link SCHEMA_SETUP_MAX_BACKOFF_MS}. */\nconst SCHEMA_SETUP_BACKOFF_MS = 100;\nconst SCHEMA_SETUP_MAX_BACKOFF_MS = 2_000;\n\n/** Whether `error`, or what caused it, is PostgreSQL's lock timeout (SQLSTATE `55P03`). */\nfunction isLockTimeout(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < 8 && typeof current === \"object\" && current !== null; depth++) {\n\t\tconst code = (current as { code?: unknown }).code;\n\t\tif (code === \"55P03\" || code === \"lock-conflict\") return true;\n\t\tcurrent = (current as { cause?: unknown }).cause;\n\t}\n\treturn false;\n}\n\n/**\n * Runs `setup`, DDL that takes table locks such as `CREATE OR REPLACE TRIGGER`'s SHARE ROW EXCLUSIVE, with a short\n * `lock_timeout` in a savepoint: a lock it would wait for, such as one a stalled transaction holds, fails it after\n * {@link SCHEMA_SETUP_LOCK_WAIT_MS}, and it rolls back to the savepoint, backs off and tries again. A waiting DDL\n * statement queues every later writer of its table behind it, so it never waits long (#5218).\n */\nexport async function withShortSchemaLockWaits(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\tsetup: () => Promise<void>,\n): Promise<void> {\n\tif (dialect.name !== \"postgres\") return setup();\n\treturn underShortLockWaits(executor, setup);\n}\n\nasync function underShortLockWaits(executor: SqliteExecutor, setup: () => Promise<void>): Promise<void> {\n\tconst previous = await executor.get<SqliteRow & { wait: string }>(\"SELECT current_setting('lock_timeout') AS wait\");\n\tfor (let attempt = 1; ; attempt++) {\n\t\tawait executor.exec(\"SAVEPOINT atomic_schema_setup\");\n\t\tawait executor.exec(`SET LOCAL lock_timeout = ${SCHEMA_SETUP_LOCK_WAIT_MS}`);\n\t\ttry {\n\t\t\tawait setup();\n\t\t\tawait executor.exec(\"RELEASE SAVEPOINT atomic_schema_setup\");\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif (!isLockTimeout(error) || attempt >= SCHEMA_SETUP_ATTEMPTS) throw error;\n\t\t\tawait executor.exec(\"ROLLBACK TO SAVEPOINT atomic_schema_setup\");\n\t\t\tconst pause = Math.min(SCHEMA_SETUP_BACKOFF_MS * 2 ** (attempt - 1), SCHEMA_SETUP_MAX_BACKOFF_MS);\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, pause * (0.5 + Math.random() / 2)));\n\t\t}\n\t}\n\tawait executor.exec(`SET LOCAL lock_timeout = '${String(previous?.wait ?? \"0\").replaceAll(\"'\", \"''\")}'`);\n}\n\n/** What {@link ensureStorageSchema} records a store's schema setup under. */\nexport interface StorageSchemaSetup {\n\t/** The ledger table, already prefixed: `storageMigrationTable(prefix)`. */\n\treadonly ledger: string;\n\t/** The store's name in the ledger, unique among the stores under one prefix, such as `\"pool-queue\"`. */\n\treadonly domain: string;\n\t/**\n\t * The revision of the store's tables, indexes, triggers and columns: raise it whenever `setup` creates or alters\n\t * anything new, so a schema an earlier build set up runs `setup` again. Past ones stay recorded, never lowered.\n\t */\n\treadonly revision: number;\n}\n\n/**\n * Whether the catalog an open in progress read (`withStorageSchemaCatalog`) records `schema.revision` for the\n * store already, so {@link ensureStorageSchema} would run nothing: the store's open then skips its schema transaction\n * and its lock (#6560). On SQLite and libSQL the store's schema stamp records it, and only while nothing changed the\n * schema since (`sqliteSchemaStampTable`). False outside such an open, and when the revision is not recorded.\n */\nexport async function storageSchemaCurrent(database: SqliteDatabase, schema: StorageSchemaSetup): Promise<boolean> {\n\tconst dialect = dialectOf(database);\n\tconst key = `schema:${schema.domain}`;\n\tif (dialect.versionedMigrations) {\n\t\tconst recorded = await recordedInCatalog(database, schema.ledger, key);\n\t\treturn recorded !== undefined && recorded >= schema.revision;\n\t}\n\tif (dialect.name !== \"sqlite\") return false;\n\treturn ((await sqliteSchemaStampsOf(database, schema.ledger))?.get(key) ?? 0) >= schema.revision;\n}\n\n/**\n * Runs `setup`, a store's idempotent schema statements (`CREATE … IF NOT EXISTS`, guarded `ALTER TABLE … ADD COLUMN`),\n * in the caller's transaction `executor` unless the ledger already records `revision` for the store (#5218). On a\n * database with versioned migrations (PostgreSQL) a current schema runs no DDL at all, so a runtime role with only DML\n * privileges opens it; a schema that is behind runs `setup` under the store's advisory lock, then records the revision,\n * so concurrent processes set it up once. A role that may not run the DDL then fails with\n * `StorageConfigError` reason `missing-privilege` from the adapter. On SQLite and libSQL, which keep no ledger, `setup`\n * runs every time it is called, as before, and then stamps the store with the schema version the transaction leaves,\n * which {@link storageSchemaCurrent} believes until the schema changes again (#6560).\n */\nexport async function ensureStorageSchema(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\tschema: StorageSchemaSetup,\n\tsetup: () => Promise<void>,\n): Promise<void> {\n\tif (!dialect.versionedMigrations) {\n\t\tawait setup();\n\t\tif (dialect.name === \"sqlite\") await recordSqliteSchemaStamps(executor, [schema]);\n\t\treturn;\n\t}\n\tconst { ledger, domain, revision } = schema;\n\tconst key = `schema:${domain}`;\n\tif ((await recordedVersion(executor, dialect, ledger, key)) >= revision) return;\n\tif (dialect.name === \"postgres\") {\n\t\t// Serialized per prefix, so hosts that start together on a new database set each store up once, and two stores\n\t\t// that create a table they share never race to create it.\n\t\tawait executor.get(\"SELECT pg_advisory_xact_lock(hashtextextended(?, 0)) AS locked\", `${ledger}:schema`);\n\t\tif ((await recordedVersion(executor, dialect, ledger, key)) >= revision) return;\n\t\tawait assertSchemaUsage(executor, dialect);\n\t\tawait underShortLockWaits(executor, setup);\n\t} else await setup();\n\tawait createLedger(executor, dialect, ledger);\n\tawait executor.run(\n\t\t`INSERT INTO ${ledger} (domain, version, applied_at) VALUES (?, ?, ${dialect.nowMs}) ON CONFLICT DO NOTHING`,\n\t\tkey,\n\t\trevision,\n\t);\n}\n\n/** What {@link ensureTableFillfactor} sets, and records under `schema:<domain>` in the ledger. */\nexport interface StorageFillfactorSetup extends StorageSchemaSetup {\n\t/** The table, already prefixed. */\n\treadonly table: string;\n\t/** The percentage of each new page the table fills on insert, leaving the rest for updated row versions. */\n\treadonly fillfactor: number;\n}\n\n/**\n * Sets `setup.table`'s fillfactor on PostgreSQL, once per database, recorded in the ledger as `schema:<domain>`: each\n * page then keeps room for a new version of the rows on it, so updates of rows that change no indexed column stay on\n * their page as HOT updates and touch no index (#6560). It applies to the pages written from then on; `VACUUM FULL`\n * or pg_repack rewrites the existing ones with it. Nothing runs where the catalog an open read records the step, where\n * the table has a fillfactor already, or where this role does not own the table: a runtime role without DDL opens as\n * before, and `atomic storage migrate`, run as the owner, sets it. Does nothing on SQLite and libSQL.\n */\nexport async function ensureTableFillfactor(database: SqliteDatabase, setup: StorageFillfactorSetup): Promise<void> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.name !== \"postgres\" || database.readOnly === true) return;\n\tconst { ledger, domain, revision, table, fillfactor } = setup;\n\tconst schema = { ledger, domain, revision };\n\tif (await storageSchemaCurrent(database, schema)) return;\n\tconst found = await database.get<SqliteRow & { owned: boolean | number; tuned: boolean | number }>(\n\t\t`SELECT pg_catalog.pg_has_role(current_user, c.relowner, 'USAGE') AS owned,\n\t\t\tcoalesce(array_to_string(c.reloptions, ',') LIKE '%fillfactor=%', false) AS tuned\n\t\tFROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace AND c.relname = ?`,\n\t\tdialect.identifier(table),\n\t);\n\tconst yes = (value: boolean | number | undefined) => value === true || Number(value) === 1;\n\tif (found === undefined || yes(found.tuned) || !yes(found.owned)) return;\n\tawait database.transaction(\n\t\t(tx) =>\n\t\t\tensureStorageSchema(tx, dialect, schema, async () => {\n\t\t\t\tawait tx.exec(`ALTER TABLE ${table} SET (fillfactor = ${Math.trunc(fillfactor)})`);\n\t\t\t}),\n\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: ledger } },\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/core/storage/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEtG,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,MAAM,SAAS,GAAmE,iBAAiB,CAAC;AAgCpG,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD,SAAS,UAAU,CAAC,KAAsC;IACzD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,QAAQ;YAClE,MAAM,IAAI,kBAAkB,CAC3B,KAAK,EACL,OAAO,EACP,qBAAqB,EACrB,uDAAuD,CACvD,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;IACzB,CAAC;AACF,CAAC;AAED,uGAAuG;AACvG,KAAK,UAAU,WAAW,CAAC,QAAwB,EAAE,OAAuB,EAAE,KAAa;IAC1F,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,MAAM,QAAQ,CAAC,GA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EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC9D,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,GAAG,CAC/B;;qGAEmG,EACnG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CACzB,CAAC;IACF,MAAM,GAAG,GAAG,CAAC,KAAmC,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3F,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvD,qGAAqG;IACrG,MAAM,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC5D,MAAM,EAAE,CAAC,IAAI,CAAC,eAAe,KAAK,sBAAsB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { refreshStorageSchemaCatalog } from \"./added-exports-0-10-11.js\";\nimport type { SqliteDatabase, SqliteExecutor, SqliteRow, SqliteStatement, TransactionConcurrency } from \"./database.js\";\nimport { dialectOf, type StorageDialect } from \"./dialect.js\";\nimport { StorageConfigError, StorageSchemaVersionError } from \"./errors.js\";\nimport { fencedPath } from \"./fenced-paths.js\";\nimport { recordSqliteSchemaStamps, schemaCatalogOf, sqliteSchemaStampsOf } from \"./schema-catalog.js\";\nimport type { SequencedStatement } from \"./statement-sequence.js\";\nimport * as statementSequence from \"./statement-sequence.js\";\n\n/**\n * `transactionFinisher` of `statement-sequence.ts`, which the copies 0.10.3 and 0.10.4 loaded lack: taken from the module\n * namespace, so this module links against them too. Without it a setup's last statements go out before its commit.\n */\nconst finishers: Partial<Pick<typeof statementSequence, \"transactionFinisher\">> = statementSequence;\n\n/** One version of a domain's schema. */\nexport interface StorageMigrationStep {\n\t/** A positive integer; a domain's steps are listed in increasing order. */\n\treadonly version: number;\n\t/**\n\t * Brings the schema from the previous version to this one. It may use only `transaction`: the runner may run the\n\t * whole migration again after a transient failure. On a dialect without `versionedMigrations` (SQLite) every step\n\t * runs each time, so its statements must be idempotent (`CREATE … IF NOT EXISTS`).\n\t */\n\tup(transaction: SqliteExecutor, dialect: StorageDialect): Promise<void>;\n}\n\nexport interface StorageMigrationOptions {\n\t/** The ledger table, already prefixed (`renderStorageIdentifiers`); default `atomic_migrations`. */\n\treadonly table?: string;\n\t/**\n\t * A recorded version newer than the last step is accepted, and nothing runs, instead of refusing with\n\t * `StorageSchemaVersionError`. Only for a domain whose later steps stay additive, so a build that knows fewer of\n\t * them still reads and writes it correctly (#5065).\n\t */\n\treadonly acceptNewer?: boolean;\n}\n\nexport interface StorageMigrationResult {\n\t/** The versions this call ran, in order. */\n\treadonly applied: readonly number[];\n\t/** The domain's schema version after the call. */\n\treadonly version: number;\n}\n\nconst DEFAULT_MIGRATION_TABLE = \"atomic_migrations\";\n\nfunction checkSteps(steps: readonly StorageMigrationStep[]): void {\n\tlet previous = 0;\n\tfor (const step of steps) {\n\t\tif (!Number.isSafeInteger(step.version) || step.version <= previous)\n\t\t\tthrow new StorageConfigError(\n\t\t\t\t\"sdk\",\n\t\t\t\t\"steps\",\n\t\t\t\t\"versions-increasing\",\n\t\t\t\t\"Number migration steps 1, 2, 3, … in increasing order\",\n\t\t\t);\n\t\tprevious = step.version;\n\t}\n}\n\n/** Whether `table` exists, read from the catalog: no DDL, so a role without CREATE can ask (#5218). */\nasync function tableExists(executor: SqliteExecutor, dialect: StorageDialect, table: string): Promise<boolean> {\n\tconst probe = dialect.tableExists(table);\n\treturn (await executor.get(probe.sql, ...probe.params)) !== undefined;\n}\n\n/**\n * Refuses, before any DDL, a role that cannot use the schema the database runs in: the setup would fail with a bare\n * `3F000` or `42501` that names neither the grant nor the role (#5218). PostgreSQL only.\n */\nasync function assertSchemaUsage(executor: SqliteExecutor, dialect: StorageDialect): Promise<void> {\n\tif (dialect.name !== \"postgres\") return;\n\trefuseWithoutSchemaUsage(await executor.get<SchemaAccess>(SCHEMA_USAGE_SQL));\n}\n\ntype SchemaAccess = SqliteRow & { schema: string; role: string; present: number; usage: number };\n\n/** The schema the transaction runs in, whether it exists, and whether this role may use it: PostgreSQL only. */\nconst SCHEMA_USAGE_SQL = `SELECT s.name AS schema, current_user AS role, (n.oid IS NOT NULL)::int AS present,\n\t\t\tcoalesce(has_schema_privilege(n.oid, 'USAGE'), false)::int AS usage\n\t\tFROM (SELECT trim(both '\"' from split_part(current_setting('search_path'), ',', 1)) AS name) s\n\t\tLEFT JOIN pg_catalog.pg_namespace n ON n.nspname = s.name`;\n\n/** Throws for `access`, a row of {@link SCHEMA_USAGE_SQL}, where the schema exists and this role may not use it. */\nfunction refuseWithoutSchemaUsage(access: SchemaAccess | undefined): void {\n\tif (access === undefined || Number(access.present) === 0 || Number(access.usage) === 1) return;\n\tthrow new StorageConfigError(\n\t\t\"sdk\",\n\t\t\"privileges\",\n\t\t\"missing-privilege\",\n\t\t`Role \"${access.role}\" has no USAGE on schema ${access.schema}, so it can neither find Atomic's tables there nor create them. Grant it as the schema's owner: GRANT USAGE ON SCHEMA ${access.schema} TO \"${access.role}\"; and, for a runtime role, the table grants in \"Set up the database\" in docs/storage/postgres.md`,\n\t);\n}\n\n/** Creates the ledger `table` unless it exists, so a current schema runs no DDL (#5218). */\nasync function createLedger(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttable: string,\n\t/** The transaction holds the prefix's setup lock, exclusive, already: a {@link setUpStorageOnce} try took it. */\n\tlocked = false,\n): Promise<void> {\n\tif (await tableExists(executor, dialect, table)) return;\n\tawait assertSchemaUsage(executor, dialect);\n\t// Two stores that set up their schemas at once never race to create the ledger they share.\n\tif (dialect.name === \"postgres\" && !locked) {\n\t\tawait executor.get(\"SELECT pg_advisory_xact_lock(hashtextextended(?, 0)) AS locked\", `${table}:schema`);\n\t\tif (await tableExists(executor, dialect, table)) return;\n\t}\n\tconst { int, text } = dialect.types;\n\tawait executor.exec(\n\t\t`CREATE TABLE IF NOT EXISTS ${table} (domain ${text} NOT NULL, version ${int} NOT NULL, applied_at ${int} NOT NULL, PRIMARY KEY (domain, version))${dialect.tableOptions}`,\n\t);\n}\n\n/** The highest version `table` records for `domain`, 0 when none or when the ledger does not exist yet. */\nasync function recordedVersion(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttable: string,\n\tdomain: string,\n\t/** The ledger is known to exist: it is not looked up first. */\n\texists = false,\n): Promise<number> {\n\tif (!exists && !(await tableExists(executor, dialect, table))) return 0;\n\tconst row = await executor.get<SqliteRow & { version: number | null }>(...versionRead(table, domain));\n\treturn Number(row?.version ?? 0);\n}\n\nasync function applyVersioned(\n\ttransaction: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttable: string,\n\tdomain: string,\n\tsteps: readonly StorageMigrationStep[],\n\tacceptNewer = false,\n\t/** The ledger is known to exist, as a catalog read before the transaction found it: it is read, not looked up. */\n\tledgerExists = false,\n\t/** The transaction holds the setup's locks already: see {@link setUpStorageOnce}. */\n\tlocked = false,\n): Promise<StorageMigrationResult> {\n\tconst current = ledgerExists\n\t\t? Number(\n\t\t\t\t(await transaction.get<SqliteRow & { version: number | null }>(...versionRead(table, domain)))?.version ??\n\t\t\t\t\t0,\n\t\t\t)\n\t\t: await recordedVersion(transaction, dialect, table, domain);\n\tconst supported = steps.at(-1)?.version ?? 0;\n\tif (current > supported) {\n\t\tif (acceptNewer) return { applied: [], version: current };\n\t\tthrow new StorageSchemaVersionError(domain, current, supported);\n\t}\n\tconst applied: number[] = [];\n\t// Probed first: a current schema, whose ledger exists, runs no DDL (#5218).\n\tif (!ledgerExists) await createLedger(transaction, dialect, table, locked);\n\t// Each step's record goes out with the next step's first statement, on a connection that pipelines a transaction's\n\t// statements; a failed one fails the migration.\n\tconst records: Promise<unknown>[] = [];\n\tfor (const step of steps) {\n\t\tif (step.version <= current) continue;\n\t\tawait step.up(transaction, dialect);\n\t\tconst recorded = transaction.run(`INSERT INTO ${table} VALUES (?, ?, ${dialect.nowMs})`, domain, step.version);\n\t\trecorded.catch(() => {});\n\t\trecords.push(recorded);\n\t\tapplied.push(step.version);\n\t}\n\tawait Promise.all(records);\n\treturn { applied, version: Math.max(current, supported) };\n}\n\n/** The read of the highest version `table` records for `domain`, as arguments of `get`. */\nfunction versionRead(table: string, domain: string): [string, string] {\n\treturn [`SELECT MAX(version) AS version FROM ${table} WHERE domain = ?`, domain];\n}\n\n/**\n * Advances `domain`'s schema to the last of `steps`, or refuses. Runs in one `serial` transaction whose domain is the ledger\n * table's name, so concurrent migrators under one prefix run one after another and a failed step rolls back the\n * whole call. Where the dialect has `versionedMigrations` (Postgres), applied versions are recorded in `table`: only\n * missing steps run, and a recorded version newer than the last step is a `StorageSchemaVersionError`. On SQLite\n * nothing is recorded (schemas stay what older Atomic versions share) and every step runs, idempotently; the domain's\n * own version row stays authoritative there.\n */\nexport async function applyStorageMigrations(\n\tdatabase: SqliteDatabase,\n\tdomain: string,\n\tsteps: readonly StorageMigrationStep[],\n\toptions: StorageMigrationOptions = {},\n): Promise<StorageMigrationResult> {\n\tcheckSteps(steps);\n\tconst dialect = dialectOf(database);\n\tconst table = options.table ?? DEFAULT_MIGRATION_TABLE;\n\tconst recorded = dialect.versionedMigrations ? await recordedInCatalog(database, table, domain) : undefined;\n\tconst supported = steps.at(-1)?.version ?? 0;\n\tif (recorded !== undefined && recorded >= supported && supported > 0) {\n\t\tif (recorded > supported && !options.acceptNewer)\n\t\t\tthrow new StorageSchemaVersionError(domain, recorded, supported);\n\t\treturn { applied: [], version: recorded };\n\t}\n\t// One process sets a new database up while the others that open it at once wait for it to finish, without holding a\n\t// lock or a connection: the locks are those an earlier build's migration and setup take, so it waits for those too.\n\tif (dialect.name === \"postgres\" && supported > 0) {\n\t\tlet ledgerExists = await ledgerInCatalog(database, table);\n\t\treturn setUpStorageOnce(database, {\n\t\t\t// An earlier build migrates in a serial transaction of the ledger's domain: the database's lock and the domain's,\n\t\t\t// which this takes shared, so the domains migrate beside one another but never beside an earlier build's.\n\t\t\tget locks() {\n\t\t\t\treturn [\n\t\t\t\t\t...setupLocks(table, domain, ledgerExists),\n\t\t\t\t\t{ scope: POSTGRES_DATABASE_LOCK_SCOPE, inSchema: true, shared: true },\n\t\t\t\t\t{ scope: table, inSchema: true, shared: true },\n\t\t\t\t];\n\t\t\t},\n\t\t\tdone: async () => {\n\t\t\t\tconst version = await recordedNow(database, table, domain, ledgerExists);\n\t\t\t\tledgerExists ||= await ledgerInCatalog(database, table);\n\t\t\t\tif (version < supported) return undefined;\n\t\t\t\tif (version > supported && !options.acceptNewer)\n\t\t\t\t\tthrow new StorageSchemaVersionError(domain, version, supported);\n\t\t\t\treturn { applied: [], version };\n\t\t\t},\n\t\t\tget leading() {\n\t\t\t\tconst [sql, key] = versionRead(table, domain);\n\t\t\t\treturn ledgerExists ? [{ sql, params: [key] }] : [];\n\t\t\t},\n\t\t\tsetup: (transaction, locked) =>\n\t\t\t\tapplyVersioned(\n\t\t\t\t\ttransaction,\n\t\t\t\t\tdialect,\n\t\t\t\t\ttable,\n\t\t\t\t\tdomain,\n\t\t\t\t\tsteps,\n\t\t\t\t\toptions.acceptNewer,\n\t\t\t\t\tlocked && ledgerExists,\n\t\t\t\t\tlocked,\n\t\t\t\t),\n\t\t\tconcurrency: { kind: \"serial\", domain: table },\n\t\t});\n\t}\n\treturn database.transaction(\n\t\tasync (transaction) => {\n\t\t\tif (dialect.versionedMigrations)\n\t\t\t\treturn applyVersioned(transaction, dialect, table, domain, steps, options.acceptNewer);\n\t\t\tfor (const step of steps) await step.up(transaction, dialect);\n\t\t\treturn { applied: steps.map((step) => step.version), version: steps.at(-1)?.version ?? 0 };\n\t\t},\n\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: table } },\n\t);\n}\n\n/**\n * The version `table` records for `domain` in the catalog an open in progress read, or undefined outside one: an open\n * that finds every step recorded neither locks nor runs a transaction, as the steps would change nothing (#6560).\n */\nasync function recordedInCatalog(database: SqliteDatabase, table: string, domain: string): Promise<number | undefined> {\n\tconst catalog = await schemaCatalogOf(database, table);\n\tif (catalog === undefined || !catalog.hasTable(table)) return undefined;\n\treturn catalog.recordedVersion(domain);\n}\n\n/**\n * The version `ledger` records for `domain` now, read without a lock or a transaction of its own; 0 where the ledger\n * does not exist. Where `ledgerExists`, one read of the ledger answers; otherwise, inside an open\n * (`withStorageSchemaCatalog`), the open's catalog is read again. Either way, once the version is found, the open's\n * catalog is read again at its next question, so the stores the open sets up next find what another process set up.\n */\nasync function recordedNow(\n\tdatabase: SqliteDatabase,\n\tledger: string,\n\tdomain: string,\n\tledgerExists: boolean,\n): Promise<number> {\n\tif (ledgerExists) {\n\t\tconst version = Number(\n\t\t\t(await database.get<SqliteRow & { version: number | null }>(...versionRead(ledger, domain)))?.version ?? 0,\n\t\t);\n\t\tif (version > 0) refreshStorageSchemaCatalog(database);\n\t\treturn version;\n\t}\n\trefreshStorageSchemaCatalog(database);\n\tconst catalog = await schemaCatalogOf(database, ledger);\n\tif (catalog !== undefined) return catalog.recordedVersion(domain);\n\treturn recordedVersion(database, dialectOf(database), ledger, domain);\n}\n\n/** Whether the catalog of the open in progress on `database` holds `ledger`: once it does, it always will. */\nasync function ledgerInCatalog(database: SqliteDatabase, ledger: string): Promise<boolean> {\n\treturn (await schemaCatalogOf(database, ledger))?.hasTable(ledger) === true;\n}\n\n/**\n * The advisory lock a serial transaction without a domain takes on PostgreSQL, and one with a domain takes shared: the\n * adapter's `DATABASE_LOCK_SCOPE`, named in the transaction's schema.\n */\nconst POSTGRES_DATABASE_LOCK_SCOPE = \"atomic\";\n\n/**\n * How long a setup that another process holds the lock for waits, polling, before it waits for the lock itself: only a\n * holder that stalls keeps it that long on PostgreSQL, since setting a schema up takes a few round trips.\n */\nconst SETUP_WAIT_MS = 15_000;\n/**\n * The same on a SQLite file, whose write lock a try also finds taken while other writers wait in its queue, as every\n * process's own writes do when many open at once: after this long it joins the queue, which hands the lock on in turn.\n */\nconst SQLITE_SETUP_WAIT_MS = 1_000;\n/** The first pause between two polls of a setup that another process runs; each later one doubles, up to the last. */\nconst SETUP_POLL_MS = 20;\nconst SETUP_MAX_POLL_MS = 250;\n\n/** @internal An advisory lock a {@link setUpStorageOnce} setup takes on PostgreSQL, without waiting for it. */\nexport interface StorageSetupLock {\n\t/** The lock's name. */\n\treadonly scope: string;\n\t/**\n\t * The name is qualified by the transaction's schema, as the adapter names the locks of a serial transaction's domain\n\t * (`<schema>:<scope>`, and `<scope>` alone in `public`): one that excludes such transactions, as an earlier build runs.\n\t */\n\treadonly inSchema?: boolean;\n\t/** Taken shared, as a serial transaction with a domain takes the database's lock. */\n\treadonly shared?: boolean;\n}\n\n/** @internal A schema setup that {@link setUpStorageOnce} runs once among the processes that start it together. */\nexport interface StorageSetupOnce<T> {\n\t/**\n\t * The advisory locks the setup holds on PostgreSQL: every lock a setup of the same objects by an earlier build takes,\n\t * so the two never run at once.\n\t */\n\treadonly locks: readonly StorageSetupLock[];\n\t/**\n\t * On PostgreSQL, the reads the setup makes first, in this order, sent with the try's start: see the transaction\n\t * option `leading`. Read, with `locks`, at each try.\n\t */\n\treadonly leading?: readonly SqliteStatement[];\n\t/**\n\t * Reads, without a lock or a transaction, whether the setup is done, such as by another process meanwhile: its answer\n\t * then, or undefined while it is not. Asked only after a try found the lock held.\n\t */\n\treadonly done: () => Promise<T | undefined>;\n\t/**\n\t * The setup, in its transaction: it checks again, under the lock, what it would change, and changes only that.\n\t * `locked` tells that the transaction holds `locks`, which it does not where it waited in the transaction\n\t * `concurrency` names.\n\t */\n\treadonly setup: (transaction: SqliteExecutor, locked: boolean) => Promise<T>;\n\t/** How the setup's transaction waits for the lock after polling for {@link SETUP_WAIT_MS}, as it did before. */\n\treadonly concurrency: TransactionConcurrency;\n}\n\n/** The schema the transaction runs in, as `<schema>:`, and empty in `public`: what the adapter prefixes its locks with. */\nconst SCHEMA_LOCK_PREFIX = `(SELECT CASE WHEN name = 'public' THEN '' ELSE name || ':' END\n\tFROM (SELECT trim(both '\"' from split_part(current_setting('search_path'), ',', 1)) AS name) AS search)`;\n\n/** One read that takes every one of `locks` it can without waiting, and tells whether it took them all. */\nfunction tryLocksStatement(locks: readonly StorageSetupLock[]): SqliteStatement {\n\tconst taken = locks.map(\n\t\t({ inSchema, shared }) =>\n\t\t\t`pg_try_advisory_xact_lock${shared === true ? \"_shared\" : \"\"}(hashtextextended(${inSchema === true ? `${SCHEMA_LOCK_PREFIX} || ` : \"\"}?, 0))`,\n\t);\n\treturn { sql: `SELECT (${taken.join(\" AND \")})::int AS won`, params: locks.map(({ scope }) => scope) };\n}\n\nconst pause = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms * (0.5 + Math.random() / 2)));\n\n/**\n * @internal Runs `once.setup`, a schema setup, so that of the processes that start it at once, on a new database say,\n * one runs it and the others wait for it without queueing for its lock (#6560). The setup's transaction tries its locks\n * without waiting: an advisory lock on PostgreSQL (`once.locks`), the database's write lock on a SQLite file. A process\n * that finds them taken holds no lock and no connection while it waits: it polls `once.done`, with growing pauses,\n * until the setup is done, and tries again whenever it is not, so a holder that set up something else, or failed, or\n * died, leaves the setup to the next try. After {@link SETUP_WAIT_MS} ({@link SQLITE_SETUP_WAIT_MS} on SQLite) it\n * waits for the lock in the transaction `once.concurrency` names, as before. Where the database tries no lock without waiting, the setup runs in that\n * transaction at once.\n */\nexport async function setUpStorageOnce<T>(database: SqliteDatabase, once: StorageSetupOnce<T>): Promise<T> {\n\tconst attempt = trySetup(database, once);\n\tconst waiting = () =>\n\t\tdatabase.transaction((transaction) => once.setup(transaction, false), {\n\t\t\tretryTransientFailures: true,\n\t\t\tconcurrency: once.concurrency,\n\t\t});\n\tif (attempt === undefined) return waiting();\n\tconst deadline =\n\t\tperformance.now() + (dialectOf(database).name === \"postgres\" ? SETUP_WAIT_MS : SQLITE_SETUP_WAIT_MS);\n\tfor (let wait = SETUP_POLL_MS; ; wait = Math.min(wait * 2, SETUP_MAX_POLL_MS)) {\n\t\tconst tried = await attempt();\n\t\tif (tried.won) return tried.value as T;\n\t\tif (performance.now() >= deadline) return waiting();\n\t\tawait pause(wait);\n\t\tconst done = await once.done();\n\t\tif (done !== undefined) return done;\n\t}\n}\n\n/** One try at `once`'s setup that does not wait for its locks, or undefined where `database` cannot try one. */\nfunction trySetup<T>(\n\tdatabase: SqliteDatabase,\n\tonce: StorageSetupOnce<T>,\n): (() => Promise<{ readonly won: boolean; readonly value?: T }>) | undefined {\n\tif (dialectOf(database).name === \"postgres\") {\n\t\t// A fenced transaction takes no lock with its start: the try is its first statement, sent with that start.\n\t\treturn () => {\n\t\t\tconst lock = tryLocksStatement(once.locks);\n\t\t\treturn database.transaction(\n\t\t\t\tasync (transaction) => {\n\t\t\t\t\tconst row = await transaction.get<SqliteRow & { won: number | boolean | null }>(\n\t\t\t\t\t\tlock.sql,\n\t\t\t\t\t\t...lock.params,\n\t\t\t\t\t);\n\t\t\t\t\tif (row?.won !== true && Number(row?.won) !== 1) return { won: false };\n\t\t\t\t\treturn { won: true, value: await once.setup(transaction, true) };\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tretryTransientFailures: true,\n\t\t\t\t\tconcurrency: { kind: \"fenced\", audit: fencedPath(\"schema-setup\") },\n\t\t\t\t\tleading: [lock, ...(once.leading ?? [])],\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\t}\n\tconst tryMaintenance = database.tryMaintenance?.bind(database);\n\tif (tryMaintenance === undefined) return undefined;\n\treturn async () => {\n\t\tlet value: T | undefined;\n\t\tconst won = await tryMaintenance(async (transaction) => {\n\t\t\tvalue = await once.setup(transaction, false);\n\t\t});\n\t\treturn won ? { won, value } : { won };\n\t};\n}\n\n/** One domain's migration for {@link applyStorageMigrationsTogether}: the arguments of {@link applyStorageMigrations}. */\nexport interface StorageDomainMigration {\n\treadonly domain: string;\n\treadonly steps: readonly StorageMigrationStep[];\n\treadonly options?: StorageMigrationOptions;\n}\n\n/**\n * Migrates each of `migrations` in order, as {@link applyStorageMigrations} would, and resolves with each one's result.\n * Where the dialect records no versions (SQLite), every step runs every time, so the domains share one transaction: one\n * turn of the write lock for all of them, and a failure rolls back all of them. Elsewhere each domain migrates in a\n * transaction of its own, as `applyStorageMigrations` runs it.\n */\nexport async function applyStorageMigrationsTogether(\n\tdatabase: SqliteDatabase,\n\tmigrations: readonly StorageDomainMigration[],\n): Promise<StorageMigrationResult[]> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.versionedMigrations) {\n\t\tconst results: StorageMigrationResult[] = [];\n\t\tfor (const { domain, steps, options } of migrations)\n\t\t\tresults.push(await applyStorageMigrations(database, domain, steps, options));\n\t\treturn results;\n\t}\n\tfor (const { steps } of migrations) checkSteps(steps);\n\tconst table = migrations[0]?.options?.table ?? DEFAULT_MIGRATION_TABLE;\n\treturn database.transaction(\n\t\tasync (transaction) => {\n\t\t\tconst results: StorageMigrationResult[] = [];\n\t\t\tfor (const { steps } of migrations) {\n\t\t\t\tfor (const step of steps) await step.up(transaction, dialect);\n\t\t\t\tresults.push({ applied: steps.map((step) => step.version), version: steps.at(-1)?.version ?? 0 });\n\t\t\t}\n\t\t\treturn results;\n\t\t},\n\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: table } },\n\t);\n}\n\n/** How long one schema setup statement waits for a table lock before the setup backs off and tries again (#5218). */\nexport const SCHEMA_SETUP_LOCK_WAIT_MS = 1_000;\n/** How many times a schema setup runs before a lock it keeps waiting for fails it. */\nconst SCHEMA_SETUP_ATTEMPTS = 8;\n/** The first pause between attempts; each later one doubles, up to {@link SCHEMA_SETUP_MAX_BACKOFF_MS}. */\nconst SCHEMA_SETUP_BACKOFF_MS = 100;\nconst SCHEMA_SETUP_MAX_BACKOFF_MS = 2_000;\n\n/** Whether `error`, or what caused it, is PostgreSQL's lock timeout (SQLSTATE `55P03`). */\nfunction isLockTimeout(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < 8 && typeof current === \"object\" && current !== null; depth++) {\n\t\tconst code = (current as { code?: unknown }).code;\n\t\tif (code === \"55P03\" || code === \"lock-conflict\") return true;\n\t\tcurrent = (current as { cause?: unknown }).cause;\n\t}\n\treturn false;\n}\n\n/**\n * Runs `setup`, DDL that takes table locks such as `CREATE OR REPLACE TRIGGER`'s SHARE ROW EXCLUSIVE, with a short\n * `lock_timeout` in a savepoint: a lock it would wait for, such as one a stalled transaction holds, fails it after\n * {@link SCHEMA_SETUP_LOCK_WAIT_MS}, and it rolls back to the savepoint, backs off and tries again. A waiting DDL\n * statement queues every later writer of its table behind it, so it never waits long (#5218).\n */\nexport async function withShortSchemaLockWaits(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\tsetup: () => Promise<void>,\n): Promise<void> {\n\tif (dialect.name !== \"postgres\") return setup();\n\treturn underShortLockWaits(executor, setup);\n}\n\nasync function underShortLockWaits(\n\texecutor: SqliteExecutor,\n\tsetup: () => Promise<void>,\n\tknown?: SqliteRow & { wait: string | null },\n\tafter: readonly SequencedStatement[] = [],\n\tlast = false,\n): Promise<void> {\n\tconst previous = known ?? (await executor.get<SqliteRow & { wait: string }>(LOCK_WAIT_SQL));\n\tfor (let attempt = 1; ; attempt++) {\n\t\t// Sent with the setup's first statement, on a connection that pipelines a transaction's statements: no round trip\n\t\t// of its own. A failure of either fails the setup.\n\t\tconst saved = executor.exec(\n\t\t\t`SAVEPOINT atomic_schema_setup; SET LOCAL lock_timeout = ${SCHEMA_SETUP_LOCK_WAIT_MS}`,\n\t\t);\n\t\tsaved.catch(() => {});\n\t\ttry {\n\t\t\tawait setup();\n\t\t\tawait saved;\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif (!isLockTimeout(error) || attempt >= SCHEMA_SETUP_ATTEMPTS) throw error;\n\t\t\tawait executor.exec(\"ROLLBACK TO SAVEPOINT atomic_schema_setup\");\n\t\t\tconst pause = Math.min(SCHEMA_SETUP_BACKOFF_MS * 2 ** (attempt - 1), SCHEMA_SETUP_MAX_BACKOFF_MS);\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, pause * (0.5 + Math.random() / 2)));\n\t\t}\n\t}\n\t// The savepoint's release, the lock wait restored, unless nothing follows in the transaction, and `after` go out\n\t// together: with the commit, where they are the transaction's `last` statements and its connection allows it.\n\tconst statements: SequencedStatement[] = [\n\t\t{ sql: \"RELEASE SAVEPOINT atomic_schema_setup\", params: [], script: true },\n\t\t...(last\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tsql: `SET LOCAL lock_timeout = '${String(previous?.wait ?? \"0\").replaceAll(\"'\", \"''\")}'`,\n\t\t\t\t\t\tparams: [],\n\t\t\t\t\t\tscript: true,\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t...after,\n\t];\n\tif (last && finishers.transactionFinisher?.(executor)?.(statements) === true) return;\n\tawait Promise.all(\n\t\tstatements.map((statement) =>\n\t\t\tstatement.script === true ? executor.exec(statement.sql) : executor.run(statement.sql, ...statement.params),\n\t\t),\n\t);\n}\n\n/** The transaction's lock wait, which a setup lowers while it runs and then restores. */\nconst LOCK_WAIT_SQL = \"SELECT current_setting('lock_timeout') AS wait\";\n\n/** The prefix's setup lock, which every schema setup holds on PostgreSQL: see {@link ensureStorageSchema}. */\nconst SETUP_LOCK_SQL = \"SELECT pg_advisory_xact_lock(hashtextextended(?, 0)) AS locked\";\n\n/** What {@link ensureStorageSchema} records a store's schema setup under. */\nexport interface StorageSchemaSetup {\n\t/** The ledger table, already prefixed: `storageMigrationTable(prefix)`. */\n\treadonly ledger: string;\n\t/** The store's name in the ledger, unique among the stores under one prefix, such as `\"pool-queue\"`. */\n\treadonly domain: string;\n\t/**\n\t * The revision of the store's tables, indexes, triggers and columns: raise it whenever `setup` creates or alters\n\t * anything new, so a schema an earlier build set up runs `setup` again. Past ones stay recorded, never lowered.\n\t */\n\treadonly revision: number;\n}\n\n/**\n * Whether the catalog an open in progress read (`withStorageSchemaCatalog`) records `schema.revision` for the\n * store already, so {@link ensureStorageSchema} would run nothing: the store's open then skips its schema transaction\n * and its lock (#6560). On SQLite the store's schema stamp records it, and only while nothing changed the\n * schema since (`sqliteSchemaStampTable`). False outside such an open, and when the revision is not recorded.\n */\nexport async function storageSchemaCurrent(database: SqliteDatabase, schema: StorageSchemaSetup): Promise<boolean> {\n\tconst dialect = dialectOf(database);\n\tconst key = `schema:${schema.domain}`;\n\tif (dialect.versionedMigrations) {\n\t\tconst recorded = await recordedInCatalog(database, schema.ledger, key);\n\t\treturn recorded !== undefined && recorded >= schema.revision;\n\t}\n\tif (dialect.name !== \"sqlite\") return false;\n\treturn ((await sqliteSchemaStampsOf(database, schema.ledger))?.get(key) ?? 0) >= schema.revision;\n}\n\n/**\n * Runs `setup`, a store's idempotent schema statements (`CREATE … IF NOT EXISTS`, guarded `ALTER TABLE … ADD COLUMN`),\n * in the caller's transaction `executor` unless the ledger already records `revision` for the store (#5218). On a\n * database with versioned migrations (PostgreSQL) a current schema runs no DDL at all, so a runtime role with only DML\n * privileges opens it; a schema that is behind runs `setup` under the store's advisory lock, then records the revision,\n * so concurrent processes set it up once. A role that may not run the DDL then fails with\n * `StorageConfigError` reason `missing-privilege` from the adapter. On SQLite, which keep no ledger, `setup`\n * runs every time it is called, as before, and then stamps the store with the schema version the transaction leaves,\n * which {@link storageSchemaCurrent} believes until the schema changes again (#6560).\n */\nexport async function ensureStorageSchema(\n\texecutor: SqliteExecutor,\n\tdialect: StorageDialect,\n\tschema: StorageSchemaSetup,\n\tsetup: () => Promise<void>,\n\toptions: EnsureStorageSchemaOptions = {},\n): Promise<void> {\n\tif (!dialect.versionedMigrations) {\n\t\tawait setup();\n\t\tif (dialect.name === \"sqlite\") await recordSqliteSchemaStamps(executor, [schema]);\n\t\treturn;\n\t}\n\tconst { ledger, domain, revision } = schema;\n\tconst key = `schema:${domain}`;\n\tconst record = {\n\t\tsql: `INSERT INTO ${ledger} (domain, version, applied_at) VALUES (?, ?, ${dialect.nowMs}) ON CONFLICT DO NOTHING`,\n\t\tparams: [key, revision],\n\t};\n\tif (dialect.name !== \"postgres\") {\n\t\tif ((await recordedVersion(executor, dialect, ledger, key)) >= revision) return;\n\t\tawait setup();\n\t\tawait createLedger(executor, dialect, ledger);\n\t\tawait executor.run(record.sql, ...record.params);\n\t\treturn;\n\t}\n\tlet ledgerFound = options.locked === true && options.ledgerExists === true;\n\tif (options.locked !== true) {\n\t\tledgerFound = await tableExists(executor, dialect, ledger);\n\t\tif (ledgerFound && (await recordedVersion(executor, dialect, ledger, key, true)) >= revision) return;\n\t}\n\t// Serialized per prefix, so hosts that start together on a new database set each store up once, and two stores\n\t// that create a table they share never race to create it. The reads go out with the lock, and each runs after it:\n\t// what a holder before it recorded, whether this role may use the schema, and the lock wait the setup restores.\n\tconst [first, usage, lockWait] = postgresSetupReads(dialect, ledger, key, ledgerFound);\n\tconst [, found, access, wait] = await Promise.all([\n\t\toptions.locked === true ? undefined : executor.get(SETUP_LOCK_SQL, `${ledger}:schema`),\n\t\texecutor.get<SqliteRow & { version: number | string | null }>(first.sql, ...first.params),\n\t\texecutor.get<SchemaAccess>(usage.sql, ...usage.params),\n\t\texecutor.get<SqliteRow & { wait: string }>(lockWait.sql, ...lockWait.params),\n\t]);\n\tconst ledgerExists = ledgerFound || found !== undefined;\n\tconst recorded = ledgerFound\n\t\t? Number(found?.version ?? 0)\n\t\t: ledgerExists\n\t\t\t? await recordedVersion(executor, dialect, ledger, key, true)\n\t\t\t: 0;\n\tif (recorded >= revision) return;\n\trefuseWithoutSchemaUsage(access);\n\tconst { int, text } = dialect.types;\n\t// The ledger, created where it is missing, and the record go out with the savepoint's release.\n\tconst createLedgerStatement = {\n\t\tsql: `CREATE TABLE IF NOT EXISTS ${ledger} (domain ${text} NOT NULL, version ${int} NOT NULL, applied_at ${int} NOT NULL, PRIMARY KEY (domain, version))${dialect.tableOptions}`,\n\t\tparams: [],\n\t\tscript: true,\n\t};\n\tawait underShortLockWaits(\n\t\texecutor,\n\t\tsetup,\n\t\twait,\n\t\tledgerExists ? [record] : [createLedgerStatement, record],\n\t\toptions.last === true,\n\t);\n}\n\n/** How {@link ensureStorageSchema} runs in a transaction that holds the setup's locks already. */\nexport interface EnsureStorageSchemaOptions {\n\t/**\n\t * The transaction holds the setup's locks already, as a {@link setUpStorageOnce} setup does: the ledger is read only\n\t * under them, and the prefix's setup lock is not taken again.\n\t */\n\treadonly locked?: boolean;\n\t/** With `locked`: the ledger exists, so its version is the first read, as {@link postgresSetupReads} lists them. */\n\treadonly ledgerExists?: boolean;\n\t/** The setup is the transaction's last call: its last statements go out with the commit. */\n\treadonly last?: boolean;\n}\n\n/**\n * The reads a PostgreSQL setup of the ledger key `key` makes first, under its locks, in this order: the version the\n * ledger records, where it is known to exist, or else whether it does; the schema's usage; and the lock wait the setup\n * restores. A {@link setUpStorageOnce} try sends them with its start.\n */\nfunction postgresSetupReads(\n\tdialect: StorageDialect,\n\tledger: string,\n\tkey: string,\n\tledgerExists: boolean,\n): readonly SqliteStatement[] {\n\treturn [\n\t\tledgerExists ? { sql: versionRead(ledger, key)[0], params: [key] } : dialect.tableExists(ledger),\n\t\t{ sql: SCHEMA_USAGE_SQL, params: [] },\n\t\t{ sql: LOCK_WAIT_SQL, params: [] },\n\t];\n}\n\n/**\n * The advisory locks a PostgreSQL setup recorded in `ledger` under `key` tries: the prefix's setup lock, exclusive while\n * the ledger may be missing, so one setup creates it, and shared once it exists, so the setups of other stores run\n * beside it while an earlier build's setup, which takes it exclusive, runs alone; and a lock of the key's own, so one\n * process sets each store up.\n */\nfunction setupLocks(ledger: string, key: string, ledgerExists: boolean): StorageSetupLock[] {\n\treturn [{ scope: `${ledger}:schema`, shared: ledgerExists }, { scope: `${ledger}:schema:${key}` }];\n}\n\n/**\n * Runs `setup`, a store's idempotent schema statements, as {@link ensureStorageSchema} does, in a transaction of its own:\n * of the processes that open a new database at once, one runs it and the others wait for the ledger to record it,\n * without its lock (`setUpStorageOnce`, #6560). Inside an open, a revision the open's catalog records runs nothing; the\n * caller checks that first (`storageSchemaCurrent`). PostgreSQL; elsewhere the setup runs in a serial transaction of the\n * ledger's domain.\n */\nexport async function ensureStorageSchemaOnce(\n\tdatabase: SqliteDatabase,\n\tschema: StorageSchemaSetup,\n\tsetup: (transaction: SqliteExecutor) => Promise<void>,\n): Promise<void> {\n\tconst dialect = dialectOf(database);\n\tconst { ledger, domain, revision } = schema;\n\tconst concurrency = { kind: \"serial\", domain: ledger } as const;\n\tif (dialect.name !== \"postgres\") {\n\t\tawait database.transaction((tx) => ensureStorageSchema(tx, dialect, schema, () => setup(tx)), {\n\t\t\tretryTransientFailures: true,\n\t\t\tconcurrency,\n\t\t});\n\t\treturn;\n\t}\n\tconst key = `schema:${domain}`;\n\tlet ledgerExists = await ledgerInCatalog(database, ledger);\n\tawait setUpStorageOnce(database, {\n\t\tget locks() {\n\t\t\treturn setupLocks(ledger, key, ledgerExists);\n\t\t},\n\t\tget leading() {\n\t\t\treturn postgresSetupReads(dialect, ledger, key, ledgerExists);\n\t\t},\n\t\tdone: async () => {\n\t\t\tconst recorded = await recordedNow(database, ledger, key, ledgerExists);\n\t\t\tledgerExists ||= await ledgerInCatalog(database, ledger);\n\t\t\treturn recorded >= revision ? true : undefined;\n\t\t},\n\t\tsetup: async (tx, locked) => {\n\t\t\tawait ensureStorageSchema(tx, dialect, schema, () => setup(tx), { locked, ledgerExists, last: true });\n\t\t\treturn true;\n\t\t},\n\t\tconcurrency,\n\t});\n}\n\n/** What {@link ensureTableFillfactor} sets, and records under `schema:<domain>` in the ledger. */\nexport interface StorageFillfactorSetup extends StorageSchemaSetup {\n\t/** The table, already prefixed. */\n\treadonly table: string;\n\t/** The percentage of each new page the table fills on insert, leaving the rest for updated row versions. */\n\treadonly fillfactor: number;\n}\n\n/**\n * The fillfactor checks this process made that found nothing for it to do, by database (`databaseIdentity`, which\n * names the role and schema too), ledger and table, and the ones under way: the table had a fillfactor, or this role\n * does not own it (#6560). Such a check is not made again. One that set the fillfactor, or found no table, is.\n */\nconst fillfactorChecks = new Map<string, Promise<boolean>>();\n\n/**\n * Sets `setup.table`'s fillfactor on PostgreSQL, once per database, recorded in the ledger as `schema:<domain>`: each\n * page then keeps room for a new version of the rows on it, so updates of rows that change no indexed column stay on\n * their page as HOT updates and touch no index (#6560). It applies to the pages written from then on; `VACUUM FULL`\n * or pg_repack rewrites the existing ones with it. Nothing runs where the catalog an open read records the step.\n * Otherwise one read of the table's catalog entry decides: nothing runs where the table has a fillfactor already, or\n * where this role does not own the table, so a runtime role without DDL opens as before, and `atomic storage migrate`,\n * run as the owner, sets it. A process reads that once for each database and table, so until migrate records the step\n * only its first open pays the read. Does nothing on SQLite.\n */\nexport async function ensureTableFillfactor(database: SqliteDatabase, setup: StorageFillfactorSetup): Promise<void> {\n\tconst dialect = dialectOf(database);\n\tif (dialect.name !== \"postgres\" || database.readOnly === true) return;\n\tconst { ledger, domain, revision, table } = setup;\n\tif (await storageSchemaCurrent(database, { ledger, domain, revision })) return;\n\tconst identity = database.databaseIdentity?.();\n\tif (identity === undefined) {\n\t\tawait checkTableFillfactor(database, setup);\n\t\treturn;\n\t}\n\tconst key = JSON.stringify([identity, ledger, table]);\n\tlet check = fillfactorChecks.get(key);\n\tif (check === undefined) {\n\t\tconst made = checkTableFillfactor(database, setup);\n\t\tcheck = made;\n\t\tfillfactorChecks.set(key, made);\n\t\tconst forget = () => {\n\t\t\tif (fillfactorChecks.get(key) === made) fillfactorChecks.delete(key);\n\t\t};\n\t\tmade.then((settled) => {\n\t\t\tif (!settled) forget();\n\t\t}, forget);\n\t}\n\tawait check;\n}\n\n/**\n * {@link ensureTableFillfactor}'s read of the table's catalog entry, and the change where it is due. True where it\n * found nothing this role can do: the table has a fillfactor, or this role does not own it.\n */\nasync function checkTableFillfactor(database: SqliteDatabase, setup: StorageFillfactorSetup): Promise<boolean> {\n\tconst dialect = dialectOf(database);\n\tconst { ledger, domain, revision, table, fillfactor } = setup;\n\tconst schema = { ledger, domain, revision };\n\tconst found = await database.get<SqliteRow & { owned: boolean | number; tuned: boolean | number }>(\n\t\t`SELECT pg_catalog.pg_has_role(current_user, c.relowner, 'USAGE') AS owned,\n\t\t\tcoalesce(array_to_string(c.reloptions, ',') LIKE '%fillfactor=%', false) AS tuned\n\t\tFROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace AND c.relname = ?`,\n\t\tdialect.identifier(table),\n\t);\n\tconst yes = (value: boolean | number | undefined) => value === true || Number(value) === 1;\n\tif (found === undefined) return false;\n\tif (yes(found.tuned) || !yes(found.owned)) return true;\n\t// Hosts that open a new database at once set it once, and the others wait for that without the lock.\n\tawait ensureStorageSchemaOnce(database, schema, async (tx) => {\n\t\tawait tx.exec(`ALTER TABLE ${table} SET (fillfactor = ${Math.trunc(fillfactor)})`);\n\t});\n\treturn false;\n}\n"]}
|
|
@@ -105,7 +105,6 @@ export function useWrappedFile(file, owner) {
|
|
|
105
105
|
registry.wrapped.set(file, count);
|
|
106
106
|
else
|
|
107
107
|
registry.wrapped.delete(file);
|
|
108
|
-
leaveScopesIfUnused();
|
|
109
108
|
},
|
|
110
109
|
};
|
|
111
110
|
registry.collected.register(owner, use, use);
|
|
@@ -142,18 +141,6 @@ function scopedHoldOpen(gate) {
|
|
|
142
141
|
return true;
|
|
143
142
|
return false;
|
|
144
143
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Leaves the asynchronous context once no wrapped connection is open and no scoped hold is: nothing reads it then, and
|
|
147
|
-
* on Node 22 an entered context keeps promise hooks on for every later await. It is entered again when needed.
|
|
148
|
-
*/
|
|
149
|
-
function leaveScopesIfUnused() {
|
|
150
|
-
if (registry.wrapped.size > 0)
|
|
151
|
-
return;
|
|
152
|
-
for (const gate of registry.files.values())
|
|
153
|
-
if (scopedHoldOpen(gate))
|
|
154
|
-
return;
|
|
155
|
-
registry.scopes.disable();
|
|
156
|
-
}
|
|
157
144
|
/**
|
|
158
145
|
* Closes `hold`, once. When it was the file's last, the oldest call waiting for the file runs now, if the word is free
|
|
159
146
|
* and no call ran in this turn; the others follow one per turn (see `runNextWaiter`).
|
|
@@ -169,8 +156,6 @@ export function releaseHold(hold) {
|
|
|
169
156
|
if (!scopedHoldOpen(gate))
|
|
170
157
|
runNextWaiter(hold.file, gate);
|
|
171
158
|
forgetIfIdle(hold.file, gate);
|
|
172
|
-
if (hold.scoped)
|
|
173
|
-
leaveScopesIfUnused();
|
|
174
159
|
}
|
|
175
160
|
/**
|
|
176
161
|
* Runs the oldest waiting call if the word is free and no call ran on the file in this turn of the event loop, and
|