@bastani/atomic 0.10.10 → 0.10.11-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -0
- package/README.md +1 -1
- 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 +11 -13
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +9 -9
- package/dist/_shared/mode-shared-2QJSCUM6.js +55 -18
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-RRLVN7ER.js → sdk-IQMULKFU.js} +2962 -470
- package/dist/_shared/sdk-IQMULKFU.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +4 -4
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
- package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
- package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
- package/dist/_shared/{startup-0-0-4VG2G44V.js → startup-0-0-3IXNMFM2.js} +482 -53
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +1 -0
- package/dist/_shared/{startup-0-1-XTIL65D4.js → startup-0-1-7T2IAE7J.js} +121 -251
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +1 -0
- package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +293 -10
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
- package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
- package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
- package/dist/_shared/startup-0-4-ZMJV547D.js +6 -6
- package/dist/_shared/{startup-0-5-FD2P735I.js → startup-0-5-YDW47QX6.js} +29 -71
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -0
- package/dist/_shared/startup-10-0-TDQNBDDL.js +9 -9
- package/dist/_shared/startup-12-0-55AAXBJZ.js +4 -4
- package/dist/_shared/startup-14-0-MLX36RBG.js +6 -6
- package/dist/_shared/startup-15-0-YUKGAC63.js +34 -10
- package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +10 -9
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +421 -84
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-4KANEHRA.js → startup-8-1-X32CYSXB.js} +1291 -722
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +17 -9
- package/dist/_shared/storage-command-7MGXLJGZ.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/tree-outline-MUEPK5B7.js +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +29 -0
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1138 -384
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +103 -24
- package/dist/builtin/intercom/broker/multinode-router.ts +42 -21
- package/dist/builtin/intercom/broker/multinode-state-store.ts +22 -1
- package/dist/builtin/intercom/broker/open-broker-state.ts +82 -31
- package/dist/builtin/intercom/broker/paths.ts +8 -4
- package/dist/builtin/intercom/broker/released-asker-remote-replies.ts +18 -6
- package/dist/builtin/intercom/broker/sql-add-column.ts +4 -1
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +65 -44
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +11 -3
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +24 -12
- package/dist/builtin/intercom/broker/sql-lease-store.ts +386 -65
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +462 -130
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +20 -9
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +14 -6
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +27 -11
- package/dist/builtin/intercom/broker/sql-schema.ts +198 -5
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +97 -34
- package/dist/builtin/intercom/index.bundle.mjs +11 -8
- 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/CHANGELOG.md +18 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +62 -23
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- 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 +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 +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-methods.d.ts +3 -0
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/compaction/compactor.d.ts +2 -0
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.code.js +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 +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.code.js +2 -2
- 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 +2 -2
- package/dist/core/extensions/runner-context.js +4 -4
- package/dist/core/extensions/runner-context.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 +1 -1
- package/dist/core/model-resolver-defaults.d.ts +3 -2
- 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/sdk.code.js +4 -5
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.d.ts +5 -2
- package/dist/core/session-manager-core.js +39 -23
- package/dist/core/session-manager-core.js.map +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 +3 -3
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-open-markers.js +3 -0
- package/dist/core/session-open-markers.js.map +1 -0
- 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/storage/added-exports.d.ts +6 -0
- package/dist/core/storage/added-exports.js +19 -0
- package/dist/core/storage/added-exports.js.map +1 -0
- package/dist/core/storage/database.d.ts +53 -0
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +47 -0
- package/dist/core/storage/fenced-paths.js +53 -0
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.js +31 -2
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +4 -1
- package/dist/core/storage/index.js +5 -2
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/migrations.d.ts +33 -2
- package/dist/core/storage/migrations.js +73 -5
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +48 -6
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +137 -4
- 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 +3 -2
- package/dist/core/storage/prefix.js +23 -2
- 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 +120 -0
- package/dist/core/storage/schema-catalog.js +351 -0
- package/dist/core/storage/schema-catalog.js.map +1 -0
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +47 -25
- 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 +4 -4
- 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/errors.js +1 -1
- package/dist/core/storage/session/expanded-child-details.code.js +4 -4
- 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-detach.d.ts +118 -0
- 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-schema.js +53 -0
- package/dist/core/storage/session/fork-schema.js.map +1 -0
- package/dist/core/storage/session/fork-segments.d.ts +58 -0
- package/dist/core/storage/session/fork-staging.code.js +176 -36
- 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-sweep.js +61 -0
- package/dist/core/storage/session/fork-sweep.js.map +1 -0
- package/dist/core/storage/session/fork-window.code.js +4 -4
- 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 +37 -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.code.js +1 -1
- 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 +5 -0
- 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 +4 -4
- 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-chat-records.d.ts +15 -0
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +445 -11
- package/dist/core/storage/session/sql-session-store.impl.js +4 -4
- package/dist/core/storage/session/sql-session-store.js +4 -4
- 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 +36 -0
- package/dist/core/storage/sqlite-facade.d.ts +54 -6
- package/dist/core/storage/sqlite-facade.js +384 -18
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/statement-sequence.d.ts +83 -0
- package/dist/core/storage/statement-sequence.js +21 -0
- package/dist/core/storage/statement-sequence.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.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.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 +4 -4
- 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.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/bash.d.ts +8 -4
- package/dist/core/tools/history-session.d.ts +7 -0
- package/dist/core/tools/history-tasks.d.ts +123 -0
- package/dist/core/tools/kill.d.ts +5 -2
- package/dist/core/tools/powershell.d.ts +2 -2
- 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/tools/read.d.ts +12 -2
- package/dist/core/tools/resource-selectors.d.ts +2 -0
- package/dist/core/tools/search.d.ts +12 -2
- package/dist/core/worktree-snapshot/blob-store.d.ts +45 -2
- package/dist/core/worktree-snapshot/blob-store.js +228 -60
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- 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/fork-snapshot-index.js +121 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
- 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 +3 -3
- 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.js +8 -8
- 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/interactive/components/agent-panel.d.ts +1 -0
- package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
- 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/task-inspector.d.ts +2 -0
- 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/interactive-mode-helpers.d.ts +2 -2
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts +5 -0
- 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/0.js +1 -1
- package/dist/startup-stages/1.js +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +9 -1
- package/dist/startup-stages/3.js +1 -6
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +2 -2
- 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/background-tasks.md +123 -23
- package/docs/compaction.md +18 -0
- package/docs/docs.json +2 -0
- package/docs/environment-variables.md +1 -1
- package/docs/getting-started/installation.md +9 -2
- package/docs/guides/postgres-pgbouncer.md +346 -0
- package/docs/guides/postgres-tuning.md +311 -0
- package/docs/guides/resume-on-any-machine.md +2 -2
- package/docs/guides.md +2 -0
- package/docs/index.md +1 -1
- package/docs/libraries/agent-core.md +1 -1
- package/docs/libraries/ai.md +2 -2
- package/docs/libraries/codemode.md +1 -1
- package/docs/libraries/storage-libsql.md +6 -1
- package/docs/libraries/storage-postgres.md +11 -6
- package/docs/libraries/tui.md +1 -1
- package/docs/libraries.md +2 -2
- package/docs/programmatic.md +1 -1
- package/docs/quickstart.md +1 -1
- package/docs/sdk/storage.md +1 -1
- package/docs/sdk/web-server.md +1 -3
- package/docs/sdk.md +1 -7
- package/docs/sessions.md +67 -2
- package/docs/settings.md +20 -1
- package/docs/skills/authoring.md +1 -1
- package/docs/skills.md +79 -6
- package/docs/storage.md +305 -14
- package/docs/subagents/reference.md +2 -2
- package/docs/subagents.md +4 -3
- package/docs/tools.md +44 -10
- package/docs/windows.md +1 -1
- package/package.json +9 -9
- package/dist/_shared/sdk-RRLVN7ER.js.map +0 -1
- package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
- package/dist/_shared/startup-0-0-4VG2G44V.js.map +0 -1
- package/dist/_shared/startup-0-1-XTIL65D4.js.map +0 -1
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
- package/dist/_shared/startup-0-5-FD2P735I.js.map +0 -1
- package/dist/_shared/startup-8-1-4KANEHRA.js.map +0 -1
|
@@ -42,6 +42,29 @@ export interface SqliteTransactionOptions {
|
|
|
42
42
|
* `BEGIN IMMEDIATE` unless `readOnly` is set; only a driver that runs transactions concurrently (Postgres) tells them apart.
|
|
43
43
|
*/
|
|
44
44
|
readonly concurrency?: TransactionConcurrency;
|
|
45
|
+
/**
|
|
46
|
+
* @internal The statements the callback makes first, in this order, before it acts on any answer. A driver whose
|
|
47
|
+
* transactions are pipelined sends them with the transaction's start, so they cost no round trip of their own, and
|
|
48
|
+
* starts the callback once they are answered; each call of the callback that makes the next of them gets its answer.
|
|
49
|
+
* Name only reads: a call that differs from the next of them ends the lead, and the answers of the rest go unused,
|
|
50
|
+
* though they ran. A write may lead only as the callback's first call, made on every run whatever it reads, such as a
|
|
51
|
+
* fenced path's one guarded write: it never runs unused. Other drivers ignore it.
|
|
52
|
+
*/
|
|
53
|
+
readonly leading?: readonly SqliteStatement[];
|
|
54
|
+
/**
|
|
55
|
+
* @internal The callback makes the `leading` calls, all of them in order, and no other. A pipelined driver then sends
|
|
56
|
+
* the commit right behind them, so the whole transaction costs one round trip: a call the callback makes after them
|
|
57
|
+
* fails without being sent. When a leading statement fails, the transaction rolls back and the callback's call of
|
|
58
|
+
* that statement fails. Other drivers ignore it.
|
|
59
|
+
*/
|
|
60
|
+
readonly leadingOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* @internal With `leading`, a `serial` transaction of a domain takes its locks in its first leading statement, a read,
|
|
63
|
+
* and only when that read returns a row, instead of with its start: a transaction whose first read finds nothing
|
|
64
|
+
* takes no lock. Every statement after it starts once the locks are held, so it sees every transaction that held them
|
|
65
|
+
* and committed. A driver that ignores it takes the locks with the start. Other drivers ignore it.
|
|
66
|
+
*/
|
|
67
|
+
readonly lockIfLeadingFinds?: boolean;
|
|
45
68
|
}
|
|
46
69
|
/** How one batch waits for a busy write lock, and whether it goes ahead of the database's queued calls. */
|
|
47
70
|
export interface SqliteBatchOptions {
|
|
@@ -125,6 +148,16 @@ export interface StorageNotifications {
|
|
|
125
148
|
/** Opens the listening connection when it is not open, and resolves with its state once the first attempt settled. */
|
|
126
149
|
state(): Promise<StorageListenerState>;
|
|
127
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* @internal What a driver read of its schema in its open's own round trip (#6560): the rows of the catalog read
|
|
153
|
+
* `readStorageSchemaCatalog` makes (`kind` `relation`, `trigger` or `column`, with `name` and `detail`) and the
|
|
154
|
+
* versions `ledger` records, as rows of `domain` and `version`; `versions` is undefined when the ledger did not exist.
|
|
155
|
+
*/
|
|
156
|
+
export interface StorageOpenedCatalog {
|
|
157
|
+
readonly ledger: string;
|
|
158
|
+
readonly rows: readonly SqliteRow[];
|
|
159
|
+
readonly versions: readonly SqliteRow[] | undefined;
|
|
160
|
+
}
|
|
128
161
|
export interface SqliteDatabase extends SqliteExecutor {
|
|
129
162
|
/**
|
|
130
163
|
* True when the connection refuses writes, as `openNodeSqliteDatabase(path, { readOnly: true })` sets it, so opening a
|
|
@@ -133,6 +166,13 @@ export interface SqliteDatabase extends SqliteExecutor {
|
|
|
133
166
|
*/
|
|
134
167
|
readonly readOnly?: boolean;
|
|
135
168
|
readonly descriptor: StorageDescriptor;
|
|
169
|
+
/**
|
|
170
|
+
* @internal Which database this handle reaches, for comparison only: two handles this process opened answer the same
|
|
171
|
+
* string only when a transaction of either reads and writes the very tables the other does (the same adapter, server
|
|
172
|
+
* or file, database, schema or namespace). Undefined, or absent, where that cannot be told, as for a database in
|
|
173
|
+
* memory: such a handle is the same database as itself alone.
|
|
174
|
+
*/
|
|
175
|
+
databaseIdentity?(): string | undefined;
|
|
136
176
|
/** @internal Checks whether this embedded connection can prepare a JSONB extraction without issuing a read. */
|
|
137
177
|
supportsJsonbExtract?(): Promise<boolean>;
|
|
138
178
|
/** The SQL dialect the database speaks; absent means SQLite. Read it through `dialectOf(database)`. */
|
|
@@ -150,7 +190,20 @@ export interface SqliteDatabase extends SqliteExecutor {
|
|
|
150
190
|
tryMaintenance?(callback: (transaction: SqliteExecutor) => Promise<void>): Promise<boolean>;
|
|
151
191
|
/** Opens a separate handle on this same database for reads. It has its own call queue; the caller must close it. */
|
|
152
192
|
openReader?(): Promise<SqliteDatabase>;
|
|
193
|
+
/**
|
|
194
|
+
* @internal The schema the driver read when it opened, given once: the first store open answers its schema checks
|
|
195
|
+
* from it instead of reading the catalog again. Undefined after the first call, and where the driver read none.
|
|
196
|
+
*/
|
|
197
|
+
takeOpenedCatalog?(): StorageOpenedCatalog | undefined;
|
|
153
198
|
transaction<T>(callback: (transaction: SqliteExecutor) => Promise<T>, options?: SqliteTransactionOptions): Promise<T>;
|
|
199
|
+
/**
|
|
200
|
+
* @internal Runs `statement` by itself as one request that commits on its own, queued in this process as a
|
|
201
|
+
* transaction of `concurrency` is: behind the calls such a transaction waits for, and ahead of the calls that wait
|
|
202
|
+
* for it. The statement takes on the server whatever locks it needs itself, such as a function that takes the
|
|
203
|
+
* domain's advisory locks. A transient failure that applied nothing runs it again. Resolves with its rows. Present
|
|
204
|
+
* only where the driver runs transactions concurrently (PostgreSQL).
|
|
205
|
+
*/
|
|
206
|
+
autocommit?(statement: SqliteStatement, concurrency: TransactionConcurrency): Promise<SqliteRow[]>;
|
|
154
207
|
/**
|
|
155
208
|
* Runs the statements in order, in one write transaction, as one call to the database: all of them commit or none
|
|
156
209
|
* do. Resolves with each statement's rows. Present only when the driver can send a batch in one request, which
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/core/storage/database.ts"],"names":[],"mappings":"","sourcesContent":["import type { StorageDialect } from \"./dialect.js\";\n\nexport type SqliteValue = null | number | bigint | string | Uint8Array;\nexport type SqliteRow = Readonly<Record<string, SqliteValue>>;\n\nexport interface SqliteRunResult {\n\treadonly changes: number;\n}\n\nexport interface SqliteExecutor {\n\texec(sql: string): Promise<void>;\n\trun(sql: string, ...params: readonly SqliteValue[]): Promise<SqliteRunResult>;\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined>;\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]>;\n}\n\nexport interface StorageDescriptor {\n\treadonly adapter: string;\n\treadonly location: string;\n}\n\n/** One statement of a batch: SQL with positional `?` parameters. */\nexport interface SqliteStatement {\n\treadonly sql: string;\n\treadonly params: readonly SqliteValue[];\n}\n\n/** How a transaction takes its snapshot or write lock, and whether it may run again. */\nexport interface SqliteTransactionOptions {\n\t/** @internal A consistent read snapshot without a writer lock. The callback must only read. */\n\treadonly readOnly?: boolean;\n\t/**\n\t * How long the transaction keeps waiting for the write lock while it is held and no other connection commits,\n\t * instead of the connection's own lock wait. A writer whose work must not fail because another process stalled\n\t * with the lock held (starved of CPU, paused by garbage collection, stopped by a signal) waits longer: the holder\n\t * still commits or rolls back once it runs again. Adapters without a lock wait of their own ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Lets a database from `createSqliteDatabase` run the callback again, in a new transaction, when a transient\n\t * failure (`StorageTransientError`) ended the transaction before it committed, so nothing of it was written. Set it\n\t * only for a callback that does nothing but use the transaction handle: anything else it does happens once per run.\n\t * Other databases ignore it.\n\t */\n\treadonly retryTransientFailures?: boolean;\n\t/**\n\t * How the transaction excludes other writers; `{ kind: \"serial\" }` when absent. SQLite runs every kind as\n\t * `BEGIN IMMEDIATE` unless `readOnly` is set; only a driver that runs transactions concurrently (Postgres) tells them apart.\n\t */\n\treadonly concurrency?: TransactionConcurrency;\n}\n\n/** How one batch waits for a busy write lock, and whether it goes ahead of the database's queued calls. */\nexport interface SqliteBatchOptions {\n\t/**\n\t * How long a batch that found the database's write lock busy keeps sending again, with growing randomized waits\n\t * between tries. A busy batch wrote nothing, so sending it again is safe. Adapters without such a retry ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Runs the batch before calls queued on this database that do not set it, and outside any limit the adapter puts on\n\t * concurrent writes: for small writes that must not wait behind others, such as a lease renewal.\n\t */\n\treadonly priority?: boolean;\n}\n\n/**\n * An audited fenced write path. Only `fencedPath(name)` in `fenced-paths.ts` makes one; a plain string is not one. The\n * brand is a string key, not a unique symbol, so the published declarations and the sources stay one type.\n */\nexport type FencedPathId = string & { readonly __atomicFencedPath: true };\n\n/**\n * `serial`: the body runs as if it were the only writer of `domain`, or of the whole database when `domain` is absent:\n * `BEGIN IMMEDIATE` on SQLite, `BEGIN` plus that domain's transaction advisory lock on Postgres. Several prefixes may\n * share one database, so `domain` names the scope in full: a store passes one of its prefixed table names.\n * `fenced`: the body runs under READ COMMITTED and takes the row locks it relies on itself. With `excludesSerial`, it\n * also waits for and excludes `serial` transactions without a domain, as a `serial` transaction with a domain does,\n * for a body whose check a whole-database writer (such as snapshot garbage collection) could otherwise race\n * (`StorageDialect.lockClause`); `audit` names the reviewed path. Identical to `serial` on SQLite.\n */\nexport type TransactionConcurrency =\n\t| { readonly kind: \"serial\"; readonly domain?: string }\n\t| { readonly kind: \"fenced\"; readonly audit: FencedPathId; readonly excludesSerial?: boolean };\n\n/**\n * What a database's listening connection is doing: `listening`, notifications arrive; `connecting`, it is not known yet;\n * `unavailable`, none arrive, and pollers find the work: `pooler` when the endpoint is a transaction pooler (a\n * notification sent through the database did not reach the listening session), `connection-failed` when the listening\n * connection could not be opened or broke.\n */\nexport type StorageListenerState =\n\t| { readonly status: \"listening\" }\n\t| { readonly status: \"connecting\" }\n\t| { readonly status: \"unavailable\"; readonly reason: \"pooler\" | \"connection-failed\" };\n\n/**\n * `notification`: a transaction that ran `notify(channel, payload)` committed. `listening`: the listening connection\n * began listening again after it was unavailable, so notifications sent meanwhile were lost.\n */\nexport type StorageNotificationEvent =\n\t| { readonly kind: \"notification\"; readonly payload: string }\n\t| { readonly kind: \"listening\" };\n\nexport interface StorageNotificationSubscription {\n\t/** Stops delivering events to this listener; idempotent. */\n\tclose(): void;\n}\n\n/**\n * Wake-ups through the database (#5103): Postgres `LISTEN`/`NOTIFY`. A notification is only a hint that a poller would\n * find the same work at its next poll; notifications are lost while the listening connection is down, and through a\n * transaction pooler none arrive, so a store that sends them keeps its poll.\n */\nexport interface StorageNotifications {\n\t/**\n\t * A statement that sends `payload` to the listeners of `channel` when the transaction it runs in commits, and never\n\t * when it rolls back: run it in the transaction of the write it announces. `channel` is a name such as\n\t * `<prefix>pool_ready`; the database shortens a long one the same way for `notify` and `listen`.\n\t */\n\tnotify(channel: string, payload: string): SqliteStatement;\n\t/** Delivers `channel`'s events to `listener`, on one listening connection the database shares between channels. */\n\tlisten(channel: string, listener: (event: StorageNotificationEvent) => void): StorageNotificationSubscription;\n\t/** Opens the listening connection when it is not open, and resolves with its state once the first attempt settled. */\n\tstate(): Promise<StorageListenerState>;\n}\n\nexport interface SqliteDatabase extends SqliteExecutor {\n\t/**\n\t * True when the connection refuses writes, as `openNodeSqliteDatabase(path, { readOnly: true })` sets it, so opening a\n\t * session store skips a cleanup write that would fail. Optional: a read-only connection that leaves it unset still\n\t * opens a session store, whose failed cleanup is ignored.\n\t */\n\treadonly readOnly?: boolean;\n\treadonly descriptor: StorageDescriptor;\n\t/** @internal Checks whether this embedded connection can prepare a JSONB extraction without issuing a read. */\n\tsupportsJsonbExtract?(): Promise<boolean>;\n\t/** The SQL dialect the database speaks; absent means SQLite. Read it through `dialectOf(database)`. */\n\treadonly dialect?: StorageDialect;\n\t/** Wake-ups through the database; present only on a database that delivers them (Postgres). */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * The bytes this process may still write on the file system that holds the database's file (where a link to the file\n\t * points, and where its write-ahead log goes), as a SQLite or libSQL file database reports them. Absent, or resolving\n\t * undefined, when this process cannot see the database's disk (a server, memory) or the file system does not say.\n\t */\n\tfreeBytes?(): Promise<number | undefined>;\n\t/** @internal Run one short maintenance transaction only if this handle, its writer gate and the database lock\n\t * are immediately available. A backend without no-wait admission leaves this absent. */\n\ttryMaintenance?(callback: (transaction: SqliteExecutor) => Promise<void>): Promise<boolean>;\n\t/** Opens a separate handle on this same database for reads. It has its own call queue; the caller must close it. */\n\topenReader?(): Promise<SqliteDatabase>;\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T>;\n\t/**\n\t * Runs the statements in order, in one write transaction, as one call to the database: all of them commit or none\n\t * do. Resolves with each statement's rows. Present only when the driver can send a batch in one request, which\n\t * saves a round trip per statement against a remote database.\n\t */\n\tbatch?(statements: readonly SqliteStatement[], options?: SqliteBatchOptions): Promise<SqliteRow[][]>;\n\tclose(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/core/storage/database.ts"],"names":[],"mappings":"","sourcesContent":["import type { StorageDialect } from \"./dialect.js\";\n\nexport type SqliteValue = null | number | bigint | string | Uint8Array;\nexport type SqliteRow = Readonly<Record<string, SqliteValue>>;\n\nexport interface SqliteRunResult {\n\treadonly changes: number;\n}\n\nexport interface SqliteExecutor {\n\texec(sql: string): Promise<void>;\n\trun(sql: string, ...params: readonly SqliteValue[]): Promise<SqliteRunResult>;\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined>;\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]>;\n}\n\nexport interface StorageDescriptor {\n\treadonly adapter: string;\n\treadonly location: string;\n}\n\n/** One statement of a batch: SQL with positional `?` parameters. */\nexport interface SqliteStatement {\n\treadonly sql: string;\n\treadonly params: readonly SqliteValue[];\n}\n\n/** How a transaction takes its snapshot or write lock, and whether it may run again. */\nexport interface SqliteTransactionOptions {\n\t/** @internal A consistent read snapshot without a writer lock. The callback must only read. */\n\treadonly readOnly?: boolean;\n\t/**\n\t * How long the transaction keeps waiting for the write lock while it is held and no other connection commits,\n\t * instead of the connection's own lock wait. A writer whose work must not fail because another process stalled\n\t * with the lock held (starved of CPU, paused by garbage collection, stopped by a signal) waits longer: the holder\n\t * still commits or rolls back once it runs again. Adapters without a lock wait of their own ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Lets a database from `createSqliteDatabase` run the callback again, in a new transaction, when a transient\n\t * failure (`StorageTransientError`) ended the transaction before it committed, so nothing of it was written. Set it\n\t * only for a callback that does nothing but use the transaction handle: anything else it does happens once per run.\n\t * Other databases ignore it.\n\t */\n\treadonly retryTransientFailures?: boolean;\n\t/**\n\t * How the transaction excludes other writers; `{ kind: \"serial\" }` when absent. SQLite runs every kind as\n\t * `BEGIN IMMEDIATE` unless `readOnly` is set; only a driver that runs transactions concurrently (Postgres) tells them apart.\n\t */\n\treadonly concurrency?: TransactionConcurrency;\n\t/**\n\t * @internal The statements the callback makes first, in this order, before it acts on any answer. A driver whose\n\t * transactions are pipelined sends them with the transaction's start, so they cost no round trip of their own, and\n\t * starts the callback once they are answered; each call of the callback that makes the next of them gets its answer.\n\t * Name only reads: a call that differs from the next of them ends the lead, and the answers of the rest go unused,\n\t * though they ran. A write may lead only as the callback's first call, made on every run whatever it reads, such as a\n\t * fenced path's one guarded write: it never runs unused. Other drivers ignore it.\n\t */\n\treadonly leading?: readonly SqliteStatement[];\n\t/**\n\t * @internal The callback makes the `leading` calls, all of them in order, and no other. A pipelined driver then sends\n\t * the commit right behind them, so the whole transaction costs one round trip: a call the callback makes after them\n\t * fails without being sent. When a leading statement fails, the transaction rolls back and the callback's call of\n\t * that statement fails. Other drivers ignore it.\n\t */\n\treadonly leadingOnly?: boolean;\n\t/**\n\t * @internal With `leading`, a `serial` transaction of a domain takes its locks in its first leading statement, a read,\n\t * and only when that read returns a row, instead of with its start: a transaction whose first read finds nothing\n\t * takes no lock. Every statement after it starts once the locks are held, so it sees every transaction that held them\n\t * and committed. A driver that ignores it takes the locks with the start. Other drivers ignore it.\n\t */\n\treadonly lockIfLeadingFinds?: boolean;\n}\n\n/** How one batch waits for a busy write lock, and whether it goes ahead of the database's queued calls. */\nexport interface SqliteBatchOptions {\n\t/**\n\t * How long a batch that found the database's write lock busy keeps sending again, with growing randomized waits\n\t * between tries. A busy batch wrote nothing, so sending it again is safe. Adapters without such a retry ignore it.\n\t */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Runs the batch before calls queued on this database that do not set it, and outside any limit the adapter puts on\n\t * concurrent writes: for small writes that must not wait behind others, such as a lease renewal.\n\t */\n\treadonly priority?: boolean;\n}\n\n/**\n * An audited fenced write path. Only `fencedPath(name)` in `fenced-paths.ts` makes one; a plain string is not one. The\n * brand is a string key, not a unique symbol, so the published declarations and the sources stay one type.\n */\nexport type FencedPathId = string & { readonly __atomicFencedPath: true };\n\n/**\n * `serial`: the body runs as if it were the only writer of `domain`, or of the whole database when `domain` is absent:\n * `BEGIN IMMEDIATE` on SQLite, `BEGIN` plus that domain's transaction advisory lock on Postgres. Several prefixes may\n * share one database, so `domain` names the scope in full: a store passes one of its prefixed table names.\n * `fenced`: the body runs under READ COMMITTED and takes the row locks it relies on itself. With `excludesSerial`, it\n * also waits for and excludes `serial` transactions without a domain, as a `serial` transaction with a domain does,\n * for a body whose check a whole-database writer (such as snapshot garbage collection) could otherwise race\n * (`StorageDialect.lockClause`); `audit` names the reviewed path. Identical to `serial` on SQLite.\n */\nexport type TransactionConcurrency =\n\t| { readonly kind: \"serial\"; readonly domain?: string }\n\t| { readonly kind: \"fenced\"; readonly audit: FencedPathId; readonly excludesSerial?: boolean };\n\n/**\n * What a database's listening connection is doing: `listening`, notifications arrive; `connecting`, it is not known yet;\n * `unavailable`, none arrive, and pollers find the work: `pooler` when the endpoint is a transaction pooler (a\n * notification sent through the database did not reach the listening session), `connection-failed` when the listening\n * connection could not be opened or broke.\n */\nexport type StorageListenerState =\n\t| { readonly status: \"listening\" }\n\t| { readonly status: \"connecting\" }\n\t| { readonly status: \"unavailable\"; readonly reason: \"pooler\" | \"connection-failed\" };\n\n/**\n * `notification`: a transaction that ran `notify(channel, payload)` committed. `listening`: the listening connection\n * began listening again after it was unavailable, so notifications sent meanwhile were lost.\n */\nexport type StorageNotificationEvent =\n\t| { readonly kind: \"notification\"; readonly payload: string }\n\t| { readonly kind: \"listening\" };\n\nexport interface StorageNotificationSubscription {\n\t/** Stops delivering events to this listener; idempotent. */\n\tclose(): void;\n}\n\n/**\n * Wake-ups through the database (#5103): Postgres `LISTEN`/`NOTIFY`. A notification is only a hint that a poller would\n * find the same work at its next poll; notifications are lost while the listening connection is down, and through a\n * transaction pooler none arrive, so a store that sends them keeps its poll.\n */\nexport interface StorageNotifications {\n\t/**\n\t * A statement that sends `payload` to the listeners of `channel` when the transaction it runs in commits, and never\n\t * when it rolls back: run it in the transaction of the write it announces. `channel` is a name such as\n\t * `<prefix>pool_ready`; the database shortens a long one the same way for `notify` and `listen`.\n\t */\n\tnotify(channel: string, payload: string): SqliteStatement;\n\t/** Delivers `channel`'s events to `listener`, on one listening connection the database shares between channels. */\n\tlisten(channel: string, listener: (event: StorageNotificationEvent) => void): StorageNotificationSubscription;\n\t/** Opens the listening connection when it is not open, and resolves with its state once the first attempt settled. */\n\tstate(): Promise<StorageListenerState>;\n}\n\n/**\n * @internal What a driver read of its schema in its open's own round trip (#6560): the rows of the catalog read\n * `readStorageSchemaCatalog` makes (`kind` `relation`, `trigger` or `column`, with `name` and `detail`) and the\n * versions `ledger` records, as rows of `domain` and `version`; `versions` is undefined when the ledger did not exist.\n */\nexport interface StorageOpenedCatalog {\n\treadonly ledger: string;\n\treadonly rows: readonly SqliteRow[];\n\treadonly versions: readonly SqliteRow[] | undefined;\n}\n\nexport interface SqliteDatabase extends SqliteExecutor {\n\t/**\n\t * True when the connection refuses writes, as `openNodeSqliteDatabase(path, { readOnly: true })` sets it, so opening a\n\t * session store skips a cleanup write that would fail. Optional: a read-only connection that leaves it unset still\n\t * opens a session store, whose failed cleanup is ignored.\n\t */\n\treadonly readOnly?: boolean;\n\treadonly descriptor: StorageDescriptor;\n\t/**\n\t * @internal Which database this handle reaches, for comparison only: two handles this process opened answer the same\n\t * string only when a transaction of either reads and writes the very tables the other does (the same adapter, server\n\t * or file, database, schema or namespace). Undefined, or absent, where that cannot be told, as for a database in\n\t * memory: such a handle is the same database as itself alone.\n\t */\n\tdatabaseIdentity?(): string | undefined;\n\t/** @internal Checks whether this embedded connection can prepare a JSONB extraction without issuing a read. */\n\tsupportsJsonbExtract?(): Promise<boolean>;\n\t/** The SQL dialect the database speaks; absent means SQLite. Read it through `dialectOf(database)`. */\n\treadonly dialect?: StorageDialect;\n\t/** Wake-ups through the database; present only on a database that delivers them (Postgres). */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * The bytes this process may still write on the file system that holds the database's file (where a link to the file\n\t * points, and where its write-ahead log goes), as a SQLite or libSQL file database reports them. Absent, or resolving\n\t * undefined, when this process cannot see the database's disk (a server, memory) or the file system does not say.\n\t */\n\tfreeBytes?(): Promise<number | undefined>;\n\t/** @internal Run one short maintenance transaction only if this handle, its writer gate and the database lock\n\t * are immediately available. A backend without no-wait admission leaves this absent. */\n\ttryMaintenance?(callback: (transaction: SqliteExecutor) => Promise<void>): Promise<boolean>;\n\t/** Opens a separate handle on this same database for reads. It has its own call queue; the caller must close it. */\n\topenReader?(): Promise<SqliteDatabase>;\n\t/**\n\t * @internal The schema the driver read when it opened, given once: the first store open answers its schema checks\n\t * from it instead of reading the catalog again. Undefined after the first call, and where the driver read none.\n\t */\n\ttakeOpenedCatalog?(): StorageOpenedCatalog | undefined;\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T>;\n\t/**\n\t * @internal Runs `statement` by itself as one request that commits on its own, queued in this process as a\n\t * transaction of `concurrency` is: behind the calls such a transaction waits for, and ahead of the calls that wait\n\t * for it. The statement takes on the server whatever locks it needs itself, such as a function that takes the\n\t * domain's advisory locks. A transient failure that applied nothing runs it again. Resolves with its rows. Present\n\t * only where the driver runs transactions concurrently (PostgreSQL).\n\t */\n\tautocommit?(statement: SqliteStatement, concurrency: TransactionConcurrency): Promise<SqliteRow[]>;\n\t/**\n\t * Runs the statements in order, in one write transaction, as one call to the database: all of them commit or none\n\t * do. Resolves with each statement's rows. Present only when the driver can send a batch in one request, which\n\t * saves a round trip per statement against a remote database.\n\t */\n\tbatch?(statements: readonly SqliteStatement[], options?: SqliteBatchOptions): Promise<SqliteRow[][]>;\n\tclose(): Promise<void>;\n}\n"]}
|
|
@@ -31,6 +31,53 @@ declare const FENCED_PATHS: {
|
|
|
31
31
|
readonly fences: readonly ["root lease row FOR KEY SHARE", "attempt's work row FOR UPDATE", "root run row FOR SHARE, then pool control"];
|
|
32
32
|
readonly conformance: "many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)";
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Intercom's broker leases (`openSqlBrokerLeaseStore`): `acquire` is one upsert whose guard takes the row only while
|
|
36
|
+
* it is free, stale or the acquirer's own, `renew` and `release` one `UPDATE` guarded by holder and fencing token, and
|
|
37
|
+
* `renewMany` those updates in (kind, key) order. Each decides on its own row lock, never on an earlier read (#6560).
|
|
38
|
+
* On PostgreSQL a first acquisition takes its order from the lease order sequence, which waits for nothing; where
|
|
39
|
+
* `atomic storage migrate` has not created it yet, `acquire`'s statement first upserts the acquisition-order counter
|
|
40
|
+
* row instead, which no other path locks.
|
|
41
|
+
*/
|
|
42
|
+
readonly "intercom-lease": {
|
|
43
|
+
readonly fences: readonly ["acquire only, without the order sequence: the acquisition-order counter row, by the statement's own upsert", "each lease row, by its own guarded upsert or UPDATE, in (kind, key) order"];
|
|
44
|
+
readonly conformance: "many brokers acquire, renew and release one lease concurrently: never two holders, fencing tokens strictly increase, a stale holder's renewal fails (#6560)";
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Intercom's wake-up hint log (`intercom_wakeups`): a hint is a row inserted once and deleted by its id or its age,
|
|
48
|
+
* and no write reads the log to decide what to write, so its writers take no lock domain: the bus's `publish`
|
|
49
|
+
* inserts a hint and notifies in one transaction that commits both, an outbox enqueue inserts one inside its own
|
|
50
|
+
* transaction, and the bus's poll and pruning delete rows in single statements (#6560).
|
|
51
|
+
*/
|
|
52
|
+
readonly "intercom-wakeup-hint": {
|
|
53
|
+
readonly fences: readonly ["none: the new hint row only, by its own INSERT"];
|
|
54
|
+
readonly conformance: "delivers each hint published at once from several connections exactly once (#6560)";
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Intercom's outbox rows and sent-message reservations (`openSqlOutboxStore`, `openSqlSentMessageAuthority`), which
|
|
58
|
+
* left the outbox's one lock domain (#6560). A claim reads its recipient's undelivered rows `FOR UPDATE` in sequence
|
|
59
|
+
* order, then claims them; a claim's renewal, saving report, release and settlement are each one `UPDATE` guarded by
|
|
60
|
+
* message id, claimant, token and state; expiry and `releaseClaimsOf` lock their rows in sequence order in a
|
|
61
|
+
* subquery; a reservation, an acceptance and a forget are each one statement on the message's row, guarded by its
|
|
62
|
+
* digest. Each decides on the rows it locks, never on an earlier read. They exclude the database-wide transactions an
|
|
63
|
+
* older broker runs on these tables (`excludesSerial`). A send itself is a serial transaction of its recipient's domain.
|
|
64
|
+
*/
|
|
65
|
+
readonly "intercom-outbox-row": {
|
|
66
|
+
readonly fences: readonly ["outbox rows, FOR UPDATE in sequence order (claim, expiry, releaseClaimsOf), or one row by its own guarded UPDATE", "one sent-message row, by its own guarded INSERT, UPDATE or DELETE"];
|
|
67
|
+
readonly conformance: "a send to one recipient does not wait while another recipient's claim holds its rows; sends to one recipient keep their order and suppress duplicates (#6560)";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A cleanup's claim of a lapsed fork staging transfer (`cleanupForkStaging`): it reads one lapsed lease row `FOR
|
|
71
|
+
* UPDATE SKIP LOCKED`, then takes it over with one `UPDATE` guarded by the lease still being lapsed, so it never waits
|
|
72
|
+
* for a live transfer whose writer or publication holds its lease, and two claims never take one transfer. Any lapsed
|
|
73
|
+
* transfer may be claimed in any order. The claim names no transfer before it reads, so it takes no lock domain; the
|
|
74
|
+
* owner's writes and the cleanup's removals are serial transactions of the transfer's own domain, and each decides on
|
|
75
|
+
* the lease row it locks by its token first (#6560).
|
|
76
|
+
*/
|
|
77
|
+
readonly "fork-staging-claim": {
|
|
78
|
+
readonly fences: readonly ["one lapsed lease row of the staging table, FOR UPDATE SKIP LOCKED, then its guarded UPDATE"];
|
|
79
|
+
readonly conformance: "concurrent cleanups take each lapsed transfer over once and never a live one, beside staging clones (#6560)";
|
|
80
|
+
};
|
|
34
81
|
/**
|
|
35
82
|
* `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks
|
|
36
83
|
* no pool row, so it orders after none of them (#4768).
|
|
@@ -37,6 +37,59 @@ const FENCED_PATHS = {
|
|
|
37
37
|
],
|
|
38
38
|
conformance: "many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)",
|
|
39
39
|
},
|
|
40
|
+
/**
|
|
41
|
+
* Intercom's broker leases (`openSqlBrokerLeaseStore`): `acquire` is one upsert whose guard takes the row only while
|
|
42
|
+
* it is free, stale or the acquirer's own, `renew` and `release` one `UPDATE` guarded by holder and fencing token, and
|
|
43
|
+
* `renewMany` those updates in (kind, key) order. Each decides on its own row lock, never on an earlier read (#6560).
|
|
44
|
+
* On PostgreSQL a first acquisition takes its order from the lease order sequence, which waits for nothing; where
|
|
45
|
+
* `atomic storage migrate` has not created it yet, `acquire`'s statement first upserts the acquisition-order counter
|
|
46
|
+
* row instead, which no other path locks.
|
|
47
|
+
*/
|
|
48
|
+
"intercom-lease": {
|
|
49
|
+
fences: [
|
|
50
|
+
"acquire only, without the order sequence: the acquisition-order counter row, by the statement's own upsert",
|
|
51
|
+
"each lease row, by its own guarded upsert or UPDATE, in (kind, key) order",
|
|
52
|
+
],
|
|
53
|
+
conformance: "many brokers acquire, renew and release one lease concurrently: never two holders, fencing tokens strictly increase, a stale holder's renewal fails (#6560)",
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Intercom's wake-up hint log (`intercom_wakeups`): a hint is a row inserted once and deleted by its id or its age,
|
|
57
|
+
* and no write reads the log to decide what to write, so its writers take no lock domain: the bus's `publish`
|
|
58
|
+
* inserts a hint and notifies in one transaction that commits both, an outbox enqueue inserts one inside its own
|
|
59
|
+
* transaction, and the bus's poll and pruning delete rows in single statements (#6560).
|
|
60
|
+
*/
|
|
61
|
+
"intercom-wakeup-hint": {
|
|
62
|
+
fences: ["none: the new hint row only, by its own INSERT"],
|
|
63
|
+
conformance: "delivers each hint published at once from several connections exactly once (#6560)",
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Intercom's outbox rows and sent-message reservations (`openSqlOutboxStore`, `openSqlSentMessageAuthority`), which
|
|
67
|
+
* left the outbox's one lock domain (#6560). A claim reads its recipient's undelivered rows `FOR UPDATE` in sequence
|
|
68
|
+
* order, then claims them; a claim's renewal, saving report, release and settlement are each one `UPDATE` guarded by
|
|
69
|
+
* message id, claimant, token and state; expiry and `releaseClaimsOf` lock their rows in sequence order in a
|
|
70
|
+
* subquery; a reservation, an acceptance and a forget are each one statement on the message's row, guarded by its
|
|
71
|
+
* digest. Each decides on the rows it locks, never on an earlier read. They exclude the database-wide transactions an
|
|
72
|
+
* older broker runs on these tables (`excludesSerial`). A send itself is a serial transaction of its recipient's domain.
|
|
73
|
+
*/
|
|
74
|
+
"intercom-outbox-row": {
|
|
75
|
+
fences: [
|
|
76
|
+
"outbox rows, FOR UPDATE in sequence order (claim, expiry, releaseClaimsOf), or one row by its own guarded UPDATE",
|
|
77
|
+
"one sent-message row, by its own guarded INSERT, UPDATE or DELETE",
|
|
78
|
+
],
|
|
79
|
+
conformance: "a send to one recipient does not wait while another recipient's claim holds its rows; sends to one recipient keep their order and suppress duplicates (#6560)",
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* A cleanup's claim of a lapsed fork staging transfer (`cleanupForkStaging`): it reads one lapsed lease row `FOR
|
|
83
|
+
* UPDATE SKIP LOCKED`, then takes it over with one `UPDATE` guarded by the lease still being lapsed, so it never waits
|
|
84
|
+
* for a live transfer whose writer or publication holds its lease, and two claims never take one transfer. Any lapsed
|
|
85
|
+
* transfer may be claimed in any order. The claim names no transfer before it reads, so it takes no lock domain; the
|
|
86
|
+
* owner's writes and the cleanup's removals are serial transactions of the transfer's own domain, and each decides on
|
|
87
|
+
* the lease row it locks by its token first (#6560).
|
|
88
|
+
*/
|
|
89
|
+
"fork-staging-claim": {
|
|
90
|
+
fences: ["one lapsed lease row of the staging table, FOR UPDATE SKIP LOCKED, then its guarded UPDATE"],
|
|
91
|
+
conformance: "concurrent cleanups take each lapsed transfer over once and never a live one, beside staging clones (#6560)",
|
|
92
|
+
},
|
|
40
93
|
/**
|
|
41
94
|
* `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks
|
|
42
95
|
* no pool row, so it orders after none of them (#4768).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fenced-paths.js","sourceRoot":"","sources":["../../../src/core/storage/fenced-paths.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,YAAY,GAAG;IACpB,gIAAgI;IAChI,YAAY,EAAE;QACb,MAAM,EAAE;YACP,8BAA8B;YAC9B,2CAA2C;YAC3C,uCAAuC;SACvC;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD,oHAAoH;IACpH,gBAAgB,EAAE;QACjB,MAAM,EAAE,CAAC,8BAA8B,EAAE,+BAA+B,EAAE,uBAAuB,CAAC;QAClG,WAAW,EAAE,6FAA6F;KAC1G;IACD,qHAAqH;IACrH,aAAa,EAAE;QACd,MAAM,EAAE;YACP,oHAAoH;YACpH,8BAA8B;YAC9B,+BAA+B;YAC/B,yGAAyG;YACzG,uBAAuB;SACvB;QACD,WAAW,EAAE,8EAA8E;KAC3F;IACD,0EAA0E;IAC1E,eAAe,EAAE;QAChB,MAAM,EAAE;YACP,8BAA8B;YAC9B,+BAA+B;YAC/B,2CAA2C;SAC3C;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD;;;OAGG;IACH,aAAa,EAAE;QACd,MAAM,EAAE,CAAC,gDAAgD,CAAC;QAC1D,WAAW,EAAE,iGAAiG;KAC9G;CAC4D,CAAC;AAI/D,yCAAyC;AACzC,MAAM,UAAU,eAAe,CAAC,IAAoB;IACnD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC9C,OAAO,IAAoB,CAAC;AAC7B,CAAC","sourcesContent":["import type { FencedPathId } from \"./database.js\";\n\n/** What makes a fenced write path correct without the domain's serial lock. */\nexport interface FencedPathAudit {\n\t/** The rows the path locks, in the order it locks them (the same order on every fenced path, so none deadlock). */\n\treadonly fences: readonly string[];\n\t/** The conformance test that runs the path concurrently on every backend. */\n\treadonly conformance: string;\n}\n\n/**\n * Every audited path that may run a `fenced` transaction. A path is added here, with its fences and its test, in the\n * change that makes it fenced; nothing else can name one.\n */\nconst FENCED_PATHS = {\n\t/** `SqlPoolQueue.claim`: one `UPDATE … WHERE id = (SELECT … FOR UPDATE SKIP LOCKED)`, so claimers never wait on one another. */\n\t\"pool-claim\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t\t\"ready work row FOR UPDATE SKIP LOCKED\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/** `SqlPoolQueue.renew`, `extend` and `heartbeat`: the attempt's lease, its claim confirmation and usage report. */\n\t\"pool-heartbeat\": {\n\t\tfences: [\"root lease row FOR KEY SHARE\", \"attempt's work row FOR UPDATE\", \"root usage totals row\"],\n\t\tconformance: \"claim, commit, heartbeat, complete and takeover run concurrently without a deadlock (#5102)\",\n\t},\n\t/** `SqlPoolQueue.commit` of a checkpoint or a session: the event takes the run's next sequence under its run row. */\n\t\"pool-commit\": {\n\t\tfences: [\n\t\t\t\"the database-wide serial lock, shared, only when the checkpoint records worktree snapshots (before every row lock)\",\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR UPDATE (FOR SHARE without an event), then pool control and the snapshots' stored blobs\",\n\t\t\t\"root usage totals row\",\n\t\t],\n\t\tconformance: \"32 concurrent writers commit one event per key with a dense sequence (#5102)\",\n\t},\n\t/** `SqlPoolQueue.complete`: the result and the work row's final state. */\n\t\"pool-complete\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/**\n\t * `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks\n\t * no pool row, so it orders after none of them (#4768).\n\t */\n\t\"rate-bucket\": {\n\t\tfences: [\"the scope's rate bucket row, by its own UPDATE\"],\n\t\tconformance: \"many hosts acquire from one rate bucket concurrently and never take more than it allows (#4768)\",\n\t},\n} as const satisfies Readonly<Record<string, FencedPathAudit>>;\n\nexport type FencedPathName = keyof typeof FENCED_PATHS;\n\n/** The audit record of a fenced path. */\nexport function fencedPathAudit(name: FencedPathName): FencedPathAudit {\n\treturn FENCED_PATHS[name];\n}\n\n/** The `FencedPathId` that lets an audited path run `{ kind: \"fenced\", audit }` transactions. */\nexport function fencedPath(name: FencedPathName): FencedPathId {\n\treturn name as FencedPathId;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fenced-paths.js","sourceRoot":"","sources":["../../../src/core/storage/fenced-paths.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,YAAY,GAAG;IACpB,gIAAgI;IAChI,YAAY,EAAE;QACb,MAAM,EAAE;YACP,8BAA8B;YAC9B,2CAA2C;YAC3C,uCAAuC;SACvC;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD,oHAAoH;IACpH,gBAAgB,EAAE;QACjB,MAAM,EAAE,CAAC,8BAA8B,EAAE,+BAA+B,EAAE,uBAAuB,CAAC;QAClG,WAAW,EAAE,6FAA6F;KAC1G;IACD,qHAAqH;IACrH,aAAa,EAAE;QACd,MAAM,EAAE;YACP,oHAAoH;YACpH,8BAA8B;YAC9B,+BAA+B;YAC/B,yGAAyG;YACzG,uBAAuB;SACvB;QACD,WAAW,EAAE,8EAA8E;KAC3F;IACD,0EAA0E;IAC1E,eAAe,EAAE;QAChB,MAAM,EAAE;YACP,8BAA8B;YAC9B,+BAA+B;YAC/B,2CAA2C;SAC3C;QACD,WAAW,EAAE,6FAA6F;KAC1G;IACD;;;;;;;OAOG;IACH,gBAAgB,EAAE;QACjB,MAAM,EAAE;YACP,4GAA4G;YAC5G,2EAA2E;SAC3E;QACD,WAAW,EACV,6JAA6J;KAC9J;IACD;;;;;OAKG;IACH,sBAAsB,EAAE;QACvB,MAAM,EAAE,CAAC,gDAAgD,CAAC;QAC1D,WAAW,EAAE,oFAAoF;KACjG;IACD;;;;;;;;OAQG;IACH,qBAAqB,EAAE;QACtB,MAAM,EAAE;YACP,kHAAkH;YAClH,mEAAmE;SACnE;QACD,WAAW,EACV,+JAA+J;KAChK;IACD;;;;;;;OAOG;IACH,oBAAoB,EAAE;QACrB,MAAM,EAAE,CAAC,4FAA4F,CAAC;QACtG,WAAW,EACV,6GAA6G;KAC9G;IACD;;;OAGG;IACH,aAAa,EAAE;QACd,MAAM,EAAE,CAAC,gDAAgD,CAAC;QAC1D,WAAW,EAAE,iGAAiG;KAC9G;CAC4D,CAAC;AAI/D,yCAAyC;AACzC,MAAM,UAAU,eAAe,CAAC,IAAoB;IACnD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC9C,OAAO,IAAoB,CAAC;AAC7B,CAAC","sourcesContent":["import type { FencedPathId } from \"./database.js\";\n\n/** What makes a fenced write path correct without the domain's serial lock. */\nexport interface FencedPathAudit {\n\t/** The rows the path locks, in the order it locks them (the same order on every fenced path, so none deadlock). */\n\treadonly fences: readonly string[];\n\t/** The conformance test that runs the path concurrently on every backend. */\n\treadonly conformance: string;\n}\n\n/**\n * Every audited path that may run a `fenced` transaction. A path is added here, with its fences and its test, in the\n * change that makes it fenced; nothing else can name one.\n */\nconst FENCED_PATHS = {\n\t/** `SqlPoolQueue.claim`: one `UPDATE … WHERE id = (SELECT … FOR UPDATE SKIP LOCKED)`, so claimers never wait on one another. */\n\t\"pool-claim\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t\t\"ready work row FOR UPDATE SKIP LOCKED\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/** `SqlPoolQueue.renew`, `extend` and `heartbeat`: the attempt's lease, its claim confirmation and usage report. */\n\t\"pool-heartbeat\": {\n\t\tfences: [\"root lease row FOR KEY SHARE\", \"attempt's work row FOR UPDATE\", \"root usage totals row\"],\n\t\tconformance: \"claim, commit, heartbeat, complete and takeover run concurrently without a deadlock (#5102)\",\n\t},\n\t/** `SqlPoolQueue.commit` of a checkpoint or a session: the event takes the run's next sequence under its run row. */\n\t\"pool-commit\": {\n\t\tfences: [\n\t\t\t\"the database-wide serial lock, shared, only when the checkpoint records worktree snapshots (before every row lock)\",\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR UPDATE (FOR SHARE without an event), then pool control and the snapshots' stored blobs\",\n\t\t\t\"root usage totals row\",\n\t\t],\n\t\tconformance: \"32 concurrent writers commit one event per key with a dense sequence (#5102)\",\n\t},\n\t/** `SqlPoolQueue.complete`: the result and the work row's final state. */\n\t\"pool-complete\": {\n\t\tfences: [\n\t\t\t\"root lease row FOR KEY SHARE\",\n\t\t\t\"attempt's work row FOR UPDATE\",\n\t\t\t\"root run row FOR SHARE, then pool control\",\n\t\t],\n\t\tconformance: \"many hosts claim, commit and complete concurrently: no double claim, no lost settle (#5102)\",\n\t},\n\t/**\n\t * Intercom's broker leases (`openSqlBrokerLeaseStore`): `acquire` is one upsert whose guard takes the row only while\n\t * it is free, stale or the acquirer's own, `renew` and `release` one `UPDATE` guarded by holder and fencing token, and\n\t * `renewMany` those updates in (kind, key) order. Each decides on its own row lock, never on an earlier read (#6560).\n\t * On PostgreSQL a first acquisition takes its order from the lease order sequence, which waits for nothing; where\n\t * `atomic storage migrate` has not created it yet, `acquire`'s statement first upserts the acquisition-order counter\n\t * row instead, which no other path locks.\n\t */\n\t\"intercom-lease\": {\n\t\tfences: [\n\t\t\t\"acquire only, without the order sequence: the acquisition-order counter row, by the statement's own upsert\",\n\t\t\t\"each lease row, by its own guarded upsert or UPDATE, in (kind, key) order\",\n\t\t],\n\t\tconformance:\n\t\t\t\"many brokers acquire, renew and release one lease concurrently: never two holders, fencing tokens strictly increase, a stale holder's renewal fails (#6560)\",\n\t},\n\t/**\n\t * Intercom's wake-up hint log (`intercom_wakeups`): a hint is a row inserted once and deleted by its id or its age,\n\t * and no write reads the log to decide what to write, so its writers take no lock domain: the bus's `publish`\n\t * inserts a hint and notifies in one transaction that commits both, an outbox enqueue inserts one inside its own\n\t * transaction, and the bus's poll and pruning delete rows in single statements (#6560).\n\t */\n\t\"intercom-wakeup-hint\": {\n\t\tfences: [\"none: the new hint row only, by its own INSERT\"],\n\t\tconformance: \"delivers each hint published at once from several connections exactly once (#6560)\",\n\t},\n\t/**\n\t * Intercom's outbox rows and sent-message reservations (`openSqlOutboxStore`, `openSqlSentMessageAuthority`), which\n\t * left the outbox's one lock domain (#6560). A claim reads its recipient's undelivered rows `FOR UPDATE` in sequence\n\t * order, then claims them; a claim's renewal, saving report, release and settlement are each one `UPDATE` guarded by\n\t * message id, claimant, token and state; expiry and `releaseClaimsOf` lock their rows in sequence order in a\n\t * subquery; a reservation, an acceptance and a forget are each one statement on the message's row, guarded by its\n\t * digest. Each decides on the rows it locks, never on an earlier read. They exclude the database-wide transactions an\n\t * older broker runs on these tables (`excludesSerial`). A send itself is a serial transaction of its recipient's domain.\n\t */\n\t\"intercom-outbox-row\": {\n\t\tfences: [\n\t\t\t\"outbox rows, FOR UPDATE in sequence order (claim, expiry, releaseClaimsOf), or one row by its own guarded UPDATE\",\n\t\t\t\"one sent-message row, by its own guarded INSERT, UPDATE or DELETE\",\n\t\t],\n\t\tconformance:\n\t\t\t\"a send to one recipient does not wait while another recipient's claim holds its rows; sends to one recipient keep their order and suppress duplicates (#6560)\",\n\t},\n\t/**\n\t * A cleanup's claim of a lapsed fork staging transfer (`cleanupForkStaging`): it reads one lapsed lease row `FOR\n\t * UPDATE SKIP LOCKED`, then takes it over with one `UPDATE` guarded by the lease still being lapsed, so it never waits\n\t * for a live transfer whose writer or publication holds its lease, and two claims never take one transfer. Any lapsed\n\t * transfer may be claimed in any order. The claim names no transfer before it reads, so it takes no lock domain; the\n\t * owner's writes and the cleanup's removals are serial transactions of the transfer's own domain, and each decides on\n\t * the lease row it locks by its token first (#6560).\n\t */\n\t\"fork-staging-claim\": {\n\t\tfences: [\"one lapsed lease row of the staging table, FOR UPDATE SKIP LOCKED, then its guarded UPDATE\"],\n\t\tconformance:\n\t\t\t\"concurrent cleanups take each lapsed transfer over once and never a live one, beside staging clones (#6560)\",\n\t},\n\t/**\n\t * `SqlRateBuckets.acquire` and `cooldown`: one `UPDATE … RETURNING` (or upsert) of the scope's bucket row, which locks\n\t * no pool row, so it orders after none of them (#4768).\n\t */\n\t\"rate-bucket\": {\n\t\tfences: [\"the scope's rate bucket row, by its own UPDATE\"],\n\t\tconformance: \"many hosts acquire from one rate bucket concurrently and never take more than it allows (#4768)\",\n\t},\n} as const satisfies Readonly<Record<string, FencedPathAudit>>;\n\nexport type FencedPathName = keyof typeof FENCED_PATHS;\n\n/** The audit record of a fenced path. */\nexport function fencedPathAudit(name: FencedPathName): FencedPathAudit {\n\treturn FENCED_PATHS[name];\n}\n\n/** The `FencedPathId` that lets an audited path run `{ kind: \"fenced\", audit }` transactions. */\nexport function fencedPath(name: FencedPathName): FencedPathId {\n\treturn name as FencedPathId;\n}\n"]}
|
|
@@ -1091,6 +1091,29 @@ function* readStorageOwnerSteps(file) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
return owner;
|
|
1093
1093
|
}
|
|
1094
|
+
/** A copied decision can have both the original decision ID and a recycled inode. */
|
|
1095
|
+
function* isReusedParentDecisionInodeSteps(owner, claimDirectory, candidate, decisionStat) {
|
|
1096
|
+
if (!owner.homeIdentity ||
|
|
1097
|
+
owner.decisionId === undefined ||
|
|
1098
|
+
decisionStat === undefined ||
|
|
1099
|
+
decisionStat.birthtimeNs <= 0n ||
|
|
1100
|
+
pathsEqual(candidate, owner.path))
|
|
1101
|
+
return false;
|
|
1102
|
+
let claimStat;
|
|
1103
|
+
try {
|
|
1104
|
+
claimStat = yield* io("stat", join(claimDirectory, PARENT_CLAIM_FILE));
|
|
1105
|
+
}
|
|
1106
|
+
catch {
|
|
1107
|
+
return false;
|
|
1108
|
+
}
|
|
1109
|
+
// The decision file used to publish the claim already existed when the claim was created. Copying the
|
|
1110
|
+
// parent can make the claim file newer, but a subsequent backup can be newer still. A directory inode
|
|
1111
|
+
// match does not overturn that evidence: the backup can reuse the original directory's inode too.
|
|
1112
|
+
return (claimStat.dev === decisionStat.dev &&
|
|
1113
|
+
claimStat.birthtimeNs > 0n &&
|
|
1114
|
+
decisionStat.birthtimeNs > claimStat.birthtimeNs &&
|
|
1115
|
+
(yield* storageDecisionMetadataSteps(candidate))?.id === owner.decisionId);
|
|
1116
|
+
}
|
|
1094
1117
|
function* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, recordedPath, excludedExactCandidate) {
|
|
1095
1118
|
const exact = [];
|
|
1096
1119
|
const recorded = [];
|
|
@@ -1100,7 +1123,11 @@ function* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget,
|
|
|
1100
1123
|
return;
|
|
1101
1124
|
const identityInfo = yield* fileIdentityWithStatSteps(owner.homeIdentity ? storageHomeDecisionFile(candidate) : candidate);
|
|
1102
1125
|
const isExcludedExact = excludedExactCandidate !== undefined && (yield* sameDirectorySteps(candidate, excludedExactCandidate));
|
|
1103
|
-
if (!isExcludedExact &&
|
|
1126
|
+
if (!isExcludedExact &&
|
|
1127
|
+
identityInfo !== undefined &&
|
|
1128
|
+
identityInfo.identity === owner.identity &&
|
|
1129
|
+
(claimedTarget !== undefined ||
|
|
1130
|
+
!(yield* isReusedParentDecisionInodeSteps(owner, claimDirectory, candidate, identityInfo.stat)))) {
|
|
1104
1131
|
for (const match of exact) {
|
|
1105
1132
|
if (yield* sameDirectorySteps(match.path, candidate))
|
|
1106
1133
|
return;
|
|
@@ -1246,7 +1273,9 @@ function* resolveStorageOwnerForCallerSteps(owner, claimDirectory = dirname(owne
|
|
|
1246
1273
|
if (owner.identity === undefined)
|
|
1247
1274
|
return { ownerPath: path };
|
|
1248
1275
|
const fastInfo = yield* fileIdentityWithStatSteps(owner.homeIdentity ? storageHomeDecisionFile(path) : path);
|
|
1249
|
-
if (fastInfo?.identity === owner.identity
|
|
1276
|
+
if (fastInfo?.identity === owner.identity &&
|
|
1277
|
+
(claimedTarget !== undefined ||
|
|
1278
|
+
!(yield* isReusedParentDecisionInodeSteps(owner, claimDirectory, path, fastInfo.stat)))) {
|
|
1250
1279
|
return yield* maybeDisplaceConflictingExactCandidateSteps(owner, claimDirectory, claimedTarget, path, path, fastInfo.stat, context);
|
|
1251
1280
|
}
|
|
1252
1281
|
const scanned = yield* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, path);
|