@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
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { transactionFinisher } from "../storage/added-exports.js";
|
|
1
2
|
import { dialectOf } from "../storage/dialect.js";
|
|
2
3
|
import { StorageWriteLockTimeoutError } from "../storage/errors.js";
|
|
3
4
|
import { applyStorageMigrations, withShortSchemaLockWaits } from "../storage/migrations.js";
|
|
4
5
|
import { renderStorageIdentifiers, storageMigrationTable, validateStoragePrefix } from "../storage/prefix.js";
|
|
6
|
+
import { schemaCatalogOf } from "../storage/schema-catalog.js";
|
|
5
7
|
import { statementBatch } from "../storage/statement-batches.js";
|
|
8
|
+
import { entriesIndexComplete, forkSegmentsTable, forkSessionLink, legacyForkLinksTriggerName, parentColumns, snapshotEntryCondition, } from "./fork-snapshot-index.js";
|
|
6
9
|
/**
|
|
7
10
|
* The key under which a failed rename's error carries the trigger or view that stopped it, once confirmed in the
|
|
8
11
|
* database (#5622); `WorkspaceCollectionError` names it in its hint. A `Symbol.for` key, shared without an import.
|
|
@@ -40,6 +43,13 @@ export function snapshotBlobHashes(snapshot) {
|
|
|
40
43
|
hashes.push(snapshot.bundle.blob);
|
|
41
44
|
return [...new Set(hashes)];
|
|
42
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Compares two blob hashes as `ORDER BY hash` with the dialect's `byteOrderCollation` does: the hashes are ASCII (hex
|
|
48
|
+
* digests), whose UTF-16 code unit order is their byte order.
|
|
49
|
+
*/
|
|
50
|
+
function byteOrder(first, second) {
|
|
51
|
+
return first < second ? -1 : first > second ? 1 : 0;
|
|
52
|
+
}
|
|
43
53
|
/**
|
|
44
54
|
* The blob hashes a recorded snapshot names, read as the reference index reads them: a write never fails on a record
|
|
45
55
|
* whose chain or bundle is not well formed, which references nothing it cannot read.
|
|
@@ -419,10 +429,6 @@ function statusCondition(d, column) {
|
|
|
419
429
|
const payload = column("payload");
|
|
420
430
|
return `${column("type")} IN (${STATUS_EVENTS}) AND ${whenValidJson(d, payload, `${d.jsonHasType("text", payload, "workflowId")} AND ${d.jsonHasType("text", payload, "status")} AND ${d.jsonType(payload, "completedCheckpoints")} IN ('integer', 'real') AND ${d.jsonType(payload, "pendingPrompts")} IN ('integer', 'real')`)}`;
|
|
421
431
|
}
|
|
422
|
-
function snapshotEntryCondition(d, column) {
|
|
423
|
-
const entry = column("entry_json");
|
|
424
|
-
return `${d.contains(entry, `'"worktree_snapshot"'`)} AND ${d.jsonText(entry, "type")} = 'worktree_snapshot' AND ${d.jsonHasType("text", entry, "root")} AND ${d.jsonHasType("text", entry, "snapshotId")}`;
|
|
425
|
-
}
|
|
426
432
|
/**
|
|
427
433
|
* The SQL form of `isDurableWorkflowResumable` for the status payload `payload`, given that the run has a snapshot
|
|
428
434
|
* reference and so at least one checkpoint: a root run keeps its snapshots while it is failed or blocked, or running or
|
|
@@ -490,7 +496,12 @@ function withMarker(trigger, marker) {
|
|
|
490
496
|
const [first, ...rest] = trigger.statements;
|
|
491
497
|
return { ...trigger, statements: [`/* ${marker} */ ${first}`, ...rest] };
|
|
492
498
|
}
|
|
493
|
-
|
|
499
|
+
/**
|
|
500
|
+
* The tables whose rows reference snapshot blobs, and how each is indexed. `forkSegments` names the sessions' fork
|
|
501
|
+
* segments table when it exists (#6560): the backfill of the session entries then also links an entry whose parent
|
|
502
|
+
* the session inherits, as the session store does when it writes one (`forkLinkWrites`).
|
|
503
|
+
*/
|
|
504
|
+
function indexSources(prefix, t, d, forkSegments) {
|
|
494
505
|
const { events, runs } = renderStorageIdentifiers("journal", { events: "events", runs: "runs" }, prefix);
|
|
495
506
|
const { entries } = renderStorageIdentifiers("sessions", { entries: "entries" }, prefix);
|
|
496
507
|
const payload = { column: "r.payload" };
|
|
@@ -573,11 +584,11 @@ function indexSources(prefix, t, d) {
|
|
|
573
584
|
};
|
|
574
585
|
const entryColumns = ["session_id", "seq", "entry_id", "entry_json"];
|
|
575
586
|
/** One entry as `r`, with its parent named once, so that each statement parses the entry's JSON for it only once. */
|
|
576
|
-
const
|
|
577
|
-
const
|
|
578
|
-
const
|
|
579
|
-
const indexComplete = `(SELECT backfilled_through >= watermark FROM ${t.sources} WHERE source = 'session-entries')`;
|
|
587
|
+
const triggerEntry = `(SELECT ${entryColumns.map((name) => `NEW.${name} AS ${name}`).join(", ")}, ${parentColumns(d, "NEW.entry_json")})`;
|
|
588
|
+
const storedEntry = `(SELECT ${entryColumns.join(", ")}, ${parentColumns(d, "entry_json")} FROM ${entries} WHERE ${d.rowOrder()} = ?)`;
|
|
589
|
+
const indexComplete = entriesIndexComplete(t.sources);
|
|
580
590
|
const newRowOrder = d.rowOrder("NEW");
|
|
591
|
+
const forkLink = (rows) => forkSegments === undefined ? [] : [forkSessionLink(t.sessionLinks, forkSegments, rows, isSnapshot)];
|
|
581
592
|
const entriesSource = {
|
|
582
593
|
name: "session-entries",
|
|
583
594
|
table: entries,
|
|
@@ -603,7 +614,7 @@ function indexSources(prefix, t, d) {
|
|
|
603
614
|
]),
|
|
604
615
|
].map((trigger) => withMarker(trigger, ENTRIES_OWN_PROGRESS)),
|
|
605
616
|
backfill: [],
|
|
606
|
-
rowwise: [...sessionLink(storedEntry), ...sessionRecord(storedEntry)],
|
|
617
|
+
rowwise: [...sessionLink(storedEntry), ...forkLink(storedEntry), ...sessionRecord(storedEntry)],
|
|
607
618
|
// The triggers that index degraded pins (#4922). Older builds install theirs under the same names (#5065).
|
|
608
619
|
version: "session-entries@degraded-pins",
|
|
609
620
|
own: ENTRIES_OWN_PROGRESS,
|
|
@@ -784,8 +795,12 @@ async function installSource(transaction, dialect, t, source, reset) {
|
|
|
784
795
|
? []
|
|
785
796
|
: [
|
|
786
797
|
...(source.reset ?? []).map((sql) => ({ sql, params: [] })),
|
|
787
|
-
// Triggers of these names that an older build installed are replaced, not kept (#5065)
|
|
788
|
-
|
|
798
|
+
// Triggers of these names that an older build installed are replaced, not kept (#5065): dropped in one
|
|
799
|
+
// script, as they are created, so a source with more triggers costs a driver no more calls.
|
|
800
|
+
source.triggers.length > 0 &&
|
|
801
|
+
source.triggers
|
|
802
|
+
.map((trigger) => `${dialect.dropTrigger(trigger.name, trigger.table)};`)
|
|
803
|
+
.join("\n"),
|
|
789
804
|
]),
|
|
790
805
|
source.triggers.map((trigger) => dialect.renderTrigger(trigger)).join("\n"),
|
|
791
806
|
{
|
|
@@ -837,9 +852,22 @@ async function installMissingSources(transaction, t, prefix, dialect, reset) {
|
|
|
837
852
|
await installSource(transaction, dialect, t, source, reset);
|
|
838
853
|
}
|
|
839
854
|
}
|
|
840
|
-
/**
|
|
841
|
-
|
|
842
|
-
|
|
855
|
+
/** The names of `sources`' tables and triggers, whose presence `readSourceStates` reads. */
|
|
856
|
+
function sourceObjectNames(sources) {
|
|
857
|
+
return sources.flatMap((source) => [source.table, ...source.triggers.map((trigger) => trigger.name)]);
|
|
858
|
+
}
|
|
859
|
+
/** The read of every source's progress rows. */
|
|
860
|
+
function sourceProgressRead(t) {
|
|
861
|
+
return { sql: `SELECT source, watermark, backfilled_through FROM ${t.sources}`, params: [] };
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Which referencing tables exist, whether each has all its triggers and a source row, and whether its backfill is done.
|
|
865
|
+
* `present`, when given, holds every table and trigger of `sources`, as an open's catalog found them: the objects are
|
|
866
|
+
* not read then (#6560).
|
|
867
|
+
*/
|
|
868
|
+
async function readSourceStates(executor, dialect, t, sources, listRetired = false, present, also) {
|
|
869
|
+
// `also` asks, in the same statement, which of other objects exist, as `also.found` tells.
|
|
870
|
+
const names = [...sourceObjectNames(sources), ...(also?.names ?? [])];
|
|
843
871
|
// Builds before 0.9.88 open SQLite and libSQL databases only, so only there can a trigger of this build's name be
|
|
844
872
|
// one that indexes less.
|
|
845
873
|
const sqlite = dialect.name === "sqlite";
|
|
@@ -856,12 +884,18 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
856
884
|
sql: `SELECT name, ${holds(signatures)} AS signed, ${holds(markers)} AS marked FROM sqlite_schema WHERE name IN (${names.map(() => "?").join(", ")})`,
|
|
857
885
|
params: [...signatures, ...markers].flatMap((check) => [check.trigger, check.text]).concat(names),
|
|
858
886
|
};
|
|
887
|
+
const progressRead = sourceProgressRead(t);
|
|
859
888
|
// Read together: the progress rows do not depend on the objects.
|
|
860
889
|
const [objectRows, progressRows] = await statementBatch(executor, [], [
|
|
861
|
-
() =>
|
|
862
|
-
|
|
890
|
+
() => present === undefined
|
|
891
|
+
? executor.all(objects.sql, ...objects.params)
|
|
892
|
+
: Promise.resolve(names.filter((name) => present.has(name)).map((name) => ({ name }))),
|
|
893
|
+
() => executor.all(progressRead.sql, ...progressRead.params),
|
|
863
894
|
]);
|
|
864
|
-
const
|
|
895
|
+
const found = new Set(objectRows.map((row) => row.name));
|
|
896
|
+
for (const name of also?.names ?? [])
|
|
897
|
+
if (found.has(name))
|
|
898
|
+
also?.found.add(name);
|
|
865
899
|
// Whether each checked trigger's SQL holds this build's text; every other object reads null.
|
|
866
900
|
const checked = (column) => new Map(objectRows
|
|
867
901
|
.filter((row) => row[column] !== null && row[column] !== undefined)
|
|
@@ -880,7 +914,7 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
880
914
|
return [row.source, row];
|
|
881
915
|
}));
|
|
882
916
|
return sources
|
|
883
|
-
.filter((source) =>
|
|
917
|
+
.filter((source) => found.has(source.table))
|
|
884
918
|
.map((source) => {
|
|
885
919
|
const row = progress.get(source.name);
|
|
886
920
|
const version = source.version === undefined ? undefined : progress.get(source.version);
|
|
@@ -894,7 +928,7 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
894
928
|
// Every trigger the source has is this build's. One a build before 0.9.88 installed again after it went
|
|
895
929
|
// missing is not, even when its SQL is the same in every build otherwise (#5558).
|
|
896
930
|
const mine = source.marker !== undefined &&
|
|
897
|
-
source.triggers.every((trigger) => !
|
|
931
|
+
source.triggers.every((trigger) => !found.has(trigger.name) || marked.get(trigger.name) === true);
|
|
898
932
|
let foreign;
|
|
899
933
|
// Whether the backfill is done for this build, besides the source's own progress row.
|
|
900
934
|
let trusted;
|
|
@@ -917,7 +951,7 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
917
951
|
const installed = row !== undefined &&
|
|
918
952
|
!foreign &&
|
|
919
953
|
Number(row.watermark) >= 0 &&
|
|
920
|
-
source.triggers.every((trigger) =>
|
|
954
|
+
source.triggers.every((trigger) => found.has(trigger.name));
|
|
921
955
|
const backfilled = row !== undefined &&
|
|
922
956
|
!foreign &&
|
|
923
957
|
trusted &&
|
|
@@ -944,12 +978,15 @@ export class SqlSnapshotBlobStore {
|
|
|
944
978
|
tables;
|
|
945
979
|
sources;
|
|
946
980
|
dialect;
|
|
981
|
+
/** The sessions' fork segments table (#6560), which exists once shared-history forks are on. */
|
|
982
|
+
forkSegments;
|
|
947
983
|
table;
|
|
948
|
-
constructor(database, dialect, tables, sources) {
|
|
984
|
+
constructor(database, dialect, tables, sources, forkSegments = forkSegmentsTable()) {
|
|
949
985
|
this.database = database;
|
|
950
986
|
this.dialect = dialect;
|
|
951
987
|
this.tables = tables;
|
|
952
988
|
this.sources = sources;
|
|
989
|
+
this.forkSegments = forkSegments;
|
|
953
990
|
this.table = tables.blobs;
|
|
954
991
|
}
|
|
955
992
|
/** Which table this store collects, for telling stores of one database and prefix apart from others. */
|
|
@@ -964,17 +1001,39 @@ export class SqlSnapshotBlobStore {
|
|
|
964
1001
|
static async open(database, prefix = "") {
|
|
965
1002
|
const t = snapshotIndexTables(prefix);
|
|
966
1003
|
const dialect = dialectOf(database);
|
|
1004
|
+
const columns = [
|
|
1005
|
+
[t.blobs, "created_at"],
|
|
1006
|
+
[t.blobs, "chunks"],
|
|
1007
|
+
...SESSION_REF_COLUMNS.map((column) => [t.sessionRefs, column]),
|
|
1008
|
+
];
|
|
1009
|
+
const triggers = [`${t.blobs}_chunks_delete_all`, `${t.blobs}_chunks_delete`];
|
|
967
1010
|
const probes = [
|
|
968
1011
|
...Object.values(t).map((table) => dialect.tableExists(table)),
|
|
969
|
-
dialect.columnExists(
|
|
970
|
-
dialect.
|
|
971
|
-
dialect.schemaObjects([`${t.blobs}_chunks_delete_all`, `${t.blobs}_chunks_delete`]),
|
|
972
|
-
...SESSION_REF_COLUMNS.map((column) => dialect.columnExists(t.sessionRefs, column)),
|
|
1012
|
+
...columns.map(([table, column]) => dialect.columnExists(table, column)),
|
|
1013
|
+
dialect.schemaObjects(triggers),
|
|
973
1014
|
];
|
|
974
|
-
|
|
1015
|
+
// One catalog read answers the schema questions where an open read it (#6560): always on Postgres, at the first
|
|
1016
|
+
// question on SQLite.
|
|
1017
|
+
const catalog = await schemaCatalogOf(database);
|
|
1018
|
+
// Whether shared-history forks are on (#6560), from that catalog or asked beside the probes.
|
|
1019
|
+
const segments = forkSegmentsTable(prefix);
|
|
1020
|
+
const segmentsProbe = dialect.tableExists(segments);
|
|
1021
|
+
const shared = catalog !== undefined
|
|
1022
|
+
? Promise.resolve(catalog.hasTable(segments))
|
|
1023
|
+
: database.get(segmentsProbe.sql, ...segmentsProbe.params).then((row) => row !== undefined);
|
|
1024
|
+
shared.catch(() => { });
|
|
1025
|
+
// A versioned database checks its ledger whatever the probes find, so it does not ask them. Elsewhere the catalog
|
|
1026
|
+
// answers them all, in one read instead of a read each.
|
|
1027
|
+
const current = dialect.versionedMigrations
|
|
1028
|
+
? false
|
|
1029
|
+
: catalog !== undefined
|
|
1030
|
+
? Object.values(t).every((table) => catalog.hasTable(table)) &&
|
|
1031
|
+
columns.every(([table, column]) => catalog.hasColumn(table, column)) &&
|
|
1032
|
+
triggers.some((trigger) => catalog.hasObject(trigger))
|
|
1033
|
+
: (await Promise.all(probes.map((probe) => database.get(probe.sql, ...probe.params)))).every((row) => row !== undefined);
|
|
975
1034
|
// A versioned database always checks its ledger: a newer schema with the same tables is refused, and a step it
|
|
976
1035
|
// lacks, such as the index triggers, runs even when every table exists.
|
|
977
|
-
if (
|
|
1036
|
+
if (!current) {
|
|
978
1037
|
await applyStorageMigrations(database, SNAPSHOT_BLOB_DOMAIN, [
|
|
979
1038
|
{ version: 1, up: (transaction, dialect) => createSnapshotIndexTables(transaction, t, prefix, dialect) },
|
|
980
1039
|
// Where a ledger records the steps, it records the index triggers too, installed under the migration lock.
|
|
@@ -1006,8 +1065,8 @@ export class SqlSnapshotBlobStore {
|
|
|
1006
1065
|
: []),
|
|
1007
1066
|
], { table: storageMigrationTable(prefix) });
|
|
1008
1067
|
}
|
|
1009
|
-
const store = new SqlSnapshotBlobStore(database, dialect, t, indexSources(prefix, t, dialect));
|
|
1010
|
-
await store.installIndex();
|
|
1068
|
+
const store = new SqlSnapshotBlobStore(database, dialect, t, indexSources(prefix, t, dialect, (await shared) ? segments : undefined), segments);
|
|
1069
|
+
await store.installIndex(undefined, false, await schemaCatalogOf(database));
|
|
1011
1070
|
return store;
|
|
1012
1071
|
}
|
|
1013
1072
|
/** Runs only layout maintenance on the offline command's dedicated, exclusively locked SQLite file connection. */
|
|
@@ -1085,9 +1144,11 @@ export class SqlSnapshotBlobStore {
|
|
|
1085
1144
|
* binds more than one chunk (#4954); the chunks of a blob stored already are not written again. Unknown ages
|
|
1086
1145
|
* remain protected until collection stamps them.
|
|
1087
1146
|
*/
|
|
1088
|
-
async putBlobs(
|
|
1089
|
-
if (
|
|
1147
|
+
async putBlobs(unordered) {
|
|
1148
|
+
if (unordered.length === 0)
|
|
1090
1149
|
return;
|
|
1150
|
+
// In hash order, so the rows it locks are taken in the order every other write of them takes them.
|
|
1151
|
+
const blobs = [...unordered].sort((first, second) => byteOrder(first.hash, second.hash));
|
|
1091
1152
|
const now = this.dialect.nowSeconds;
|
|
1092
1153
|
const header = `INSERT INTO ${this.table} (hash, bytes, data, created_at, chunks) VALUES (?, ?, ?, ${now}, ?) ON CONFLICT(hash) DO UPDATE SET created_at = ${now} WHERE ${this.table}.created_at > 0`;
|
|
1093
1154
|
const chunk = `INSERT INTO ${this.tables.blobChunks} (hash, idx, data) SELECT ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM ${this.table} WHERE hash = ?) ON CONFLICT DO NOTHING`;
|
|
@@ -1112,9 +1173,27 @@ export class SqlSnapshotBlobStore {
|
|
|
1112
1173
|
return;
|
|
1113
1174
|
}
|
|
1114
1175
|
await this.database.transaction(async (transaction) => {
|
|
1176
|
+
// On a pipelined connection the statements go out with the commit: one round trip after the locks.
|
|
1177
|
+
if (transactionFinisher(transaction)?.(statements) === true)
|
|
1178
|
+
return;
|
|
1115
1179
|
for (const statement of statements)
|
|
1116
1180
|
await transaction.run(statement.sql, ...statement.params);
|
|
1117
|
-
});
|
|
1181
|
+
}, this.blobWrite());
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* How a put or a refresh of this table's blobs runs: a serial transaction of the blob table's own domain (#6560). On
|
|
1185
|
+
* PostgreSQL it holds the database-wide lock shared, so it waits for and excludes collection, whose writes hold that
|
|
1186
|
+
* lock exclusively, and the blob writers of this table exclude one another, but session writes, which hold the
|
|
1187
|
+
* database-wide lock shared with their session's domain, run beside it. Rows it writes again (`created_at`) are locked
|
|
1188
|
+
* in hash order, as an append's check of the blobs it records locks them (`missingBlob`), so neither waits on the
|
|
1189
|
+
* other in a cycle. Its callback only uses the transaction, so a transient failure runs it again.
|
|
1190
|
+
*/
|
|
1191
|
+
blobWrite(leading) {
|
|
1192
|
+
return {
|
|
1193
|
+
retryTransientFailures: true,
|
|
1194
|
+
concurrency: { kind: "serial", domain: this.table },
|
|
1195
|
+
...(leading === undefined ? {} : { leading }),
|
|
1196
|
+
};
|
|
1118
1197
|
}
|
|
1119
1198
|
/**
|
|
1120
1199
|
* The blob's bytes, read a chunk per statement when it has chunks, so no response holds more than one chunk. A
|
|
@@ -1154,10 +1233,18 @@ export class SqlSnapshotBlobStore {
|
|
|
1154
1233
|
]);
|
|
1155
1234
|
return rows.length === unique.length;
|
|
1156
1235
|
}
|
|
1236
|
+
// The rows present, locked in hash order before the update writes them (see `blobWrite`). On a pipelined connection
|
|
1237
|
+
// this read goes out with the transaction's start and the update with its commit.
|
|
1238
|
+
const locked = {
|
|
1239
|
+
sql: `${present} ORDER BY hash${this.dialect.byteOrderCollation}${this.dialect.lockClause("update")}`,
|
|
1240
|
+
params,
|
|
1241
|
+
};
|
|
1157
1242
|
return this.database.transaction(async (transaction) => {
|
|
1158
|
-
await transaction.
|
|
1159
|
-
|
|
1160
|
-
|
|
1243
|
+
const rows = await transaction.all(locked.sql, ...locked.params);
|
|
1244
|
+
if (transactionFinisher(transaction)?.([{ sql: update, params }]) !== true)
|
|
1245
|
+
await transaction.run(update, ...params);
|
|
1246
|
+
return rows.length === unique.length;
|
|
1247
|
+
}, this.blobWrite([locked]));
|
|
1161
1248
|
}
|
|
1162
1249
|
async listBlobHashes() {
|
|
1163
1250
|
const rows = await this.database.all(`SELECT hash FROM ${this.table}`);
|
|
@@ -1172,11 +1259,26 @@ export class SqlSnapshotBlobStore {
|
|
|
1172
1259
|
*/
|
|
1173
1260
|
async assertStored(transaction, snapshots) {
|
|
1174
1261
|
const missing = await this.missingBlob(transaction, snapshots);
|
|
1175
|
-
if (missing
|
|
1176
|
-
|
|
1262
|
+
if (missing !== undefined)
|
|
1263
|
+
await this.refuseCollected(missing);
|
|
1264
|
+
}
|
|
1265
|
+
/** The `blobs-collected` {@link WorkspaceSnapshotError} `assertStored` rejects with for `hash`. */
|
|
1266
|
+
async refuseCollected(hash) {
|
|
1177
1267
|
// Loaded only when a write is refused, so the storage entry does not load the workspace error family.
|
|
1178
1268
|
const { WorkspaceSnapshotError } = await import("./errors.code.js").catch((error) => __atomicOnDemandFailed(error, "worktree snapshots"));
|
|
1179
|
-
throw new WorkspaceSnapshotError("blobs-collected",
|
|
1269
|
+
throw new WorkspaceSnapshotError("blobs-collected", hash);
|
|
1270
|
+
}
|
|
1271
|
+
/** The blobs of `snapshots` that `assertStored` checks, each once, in the order it reports the first missing one. */
|
|
1272
|
+
storedHashes(snapshots) {
|
|
1273
|
+
return [...new Set(snapshots.flatMap(wellFormedBlobHashes))];
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* The query `missingBlob` reads, for the blobs named by `source`, an SQL expression of a JSON array of hashes: the
|
|
1277
|
+
* hashes this table holds in full, locked FOR SHARE in hash order. A statement that checks the blobs on the server,
|
|
1278
|
+
* such as the session append function, runs it as it is (#6599).
|
|
1279
|
+
*/
|
|
1280
|
+
storedBlobsQuery(source) {
|
|
1281
|
+
return `SELECT hash FROM ${this.table} AS b WHERE hash IN (SELECT value FROM ${this.dialect.jsonValues(source)}) AND (chunks = 0 OR chunks = (SELECT COUNT(*) FROM ${this.tables.blobChunks} AS c WHERE c.hash = b.hash)) ORDER BY hash${this.dialect.byteOrderCollation}${this.dialect.lockClause("share")}`;
|
|
1180
1282
|
}
|
|
1181
1283
|
/**
|
|
1182
1284
|
* A query that returns a row only while this table holds every blob of `snapshots` in full, for a write planned
|
|
@@ -1191,12 +1293,15 @@ export class SqlSnapshotBlobStore {
|
|
|
1191
1293
|
params: [JSON.stringify(hashes), hashes.length],
|
|
1192
1294
|
};
|
|
1193
1295
|
}
|
|
1194
|
-
/**
|
|
1296
|
+
/**
|
|
1297
|
+
* The first of `snapshots`' blobs this table does not hold in full, read in `transaction`; undefined when none. The
|
|
1298
|
+
* rows it finds stay locked FOR SHARE until the transaction ends, taken in hash order as a blob write takes them.
|
|
1299
|
+
*/
|
|
1195
1300
|
async missingBlob(transaction, snapshots) {
|
|
1196
|
-
const hashes =
|
|
1301
|
+
const hashes = this.storedHashes(snapshots);
|
|
1197
1302
|
if (hashes.length === 0)
|
|
1198
1303
|
return undefined;
|
|
1199
|
-
const rows = await transaction.all(
|
|
1304
|
+
const rows = await transaction.all(this.storedBlobsQuery("?"), JSON.stringify(hashes));
|
|
1200
1305
|
const stored = new Set(rows.map((row) => row.hash));
|
|
1201
1306
|
return hashes.find((hash) => !stored.has(hash));
|
|
1202
1307
|
}
|
|
@@ -1206,14 +1311,27 @@ export class SqlSnapshotBlobStore {
|
|
|
1206
1311
|
* above it, indexed by the triggers. A table that has none yet, an empty one included, costs one watermark of 0.
|
|
1207
1312
|
* Resolves with the state of every referencing table.
|
|
1208
1313
|
*/
|
|
1209
|
-
async installIndex(pace, includeDeferred = false) {
|
|
1210
|
-
|
|
1314
|
+
async installIndex(pace, includeDeferred = false, catalog) {
|
|
1315
|
+
// The fork links trigger earlier builds of #6560 installed, asked for in the same read: dropped where found, in the
|
|
1316
|
+
// first write below, so a database that has it runs it no longer once a store of this build opened it.
|
|
1317
|
+
const legacy = this.legacyForkLinks();
|
|
1318
|
+
const found = new Set();
|
|
1319
|
+
const states = await this.readStates(includeDeferred, catalog, legacy && { names: [legacy.name], found });
|
|
1320
|
+
let drop = legacy !== undefined && found.has(legacy.name) ? legacy : undefined;
|
|
1321
|
+
const dropLegacy = async (transaction) => {
|
|
1322
|
+
if (drop === undefined)
|
|
1323
|
+
return;
|
|
1324
|
+
const { name, table } = drop;
|
|
1325
|
+
await withShortSchemaLockWaits(transaction, this.dialect, () => transaction.exec(this.dialect.dropTrigger(name, table, true)));
|
|
1326
|
+
drop = undefined;
|
|
1327
|
+
};
|
|
1211
1328
|
const missing = states.filter((state) => !state.installed && (includeDeferred || !state.deferred));
|
|
1212
1329
|
for (const { source } of missing) {
|
|
1213
1330
|
const reset = source.name === "session-entries"
|
|
1214
1331
|
? await SqlSnapshotBlobStore.prepareSessionIndexReset(this.database)
|
|
1215
1332
|
: undefined;
|
|
1216
1333
|
await this.write(pace, async (transaction) => {
|
|
1334
|
+
await dropLegacy(transaction);
|
|
1217
1335
|
const [current] = await readSourceStates(transaction, this.dialect, this.tables, [source]);
|
|
1218
1336
|
if (current === undefined || current.installed || (current.deferred && !includeDeferred))
|
|
1219
1337
|
return;
|
|
@@ -1221,9 +1339,37 @@ export class SqlSnapshotBlobStore {
|
|
|
1221
1339
|
await withShortSchemaLockWaits(transaction, this.dialect, () => installSource(transaction, this.dialect, this.tables, source, reset));
|
|
1222
1340
|
});
|
|
1223
1341
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1342
|
+
if (drop !== undefined)
|
|
1343
|
+
await this.write(pace, dropLegacy);
|
|
1344
|
+
return missing.length === 0 ? states : this.readStates(includeDeferred);
|
|
1345
|
+
}
|
|
1346
|
+
/** The fork links trigger earlier builds of #6560 installed on the session entries, and its table. */
|
|
1347
|
+
legacyForkLinks() {
|
|
1348
|
+
const entries = this.sources.find((source) => source.name === "session-entries");
|
|
1349
|
+
return entries && { name: legacyForkLinksTriggerName(entries.table), table: entries.table };
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* The state of every source, read outside a transaction. On PostgreSQL the objects and the progress rows are read in
|
|
1353
|
+
* one read-only transaction whose start carries both, so they cost one round trip, not one each. An open's
|
|
1354
|
+
* `catalog` answers which objects exist only when it found every one: only its positive answers are final, and a
|
|
1355
|
+
* source table it lacks may have been created since (#6560). `also` asks which of other objects exist in the same
|
|
1356
|
+
* read, as `readSourceStates` does.
|
|
1357
|
+
*/
|
|
1358
|
+
readStates(includeDeferred, catalog, also) {
|
|
1359
|
+
if (this.dialect.name !== "postgres")
|
|
1360
|
+
return readSourceStates(this.database, this.dialect, this.tables, this.sources, includeDeferred, undefined, also);
|
|
1361
|
+
const names = sourceObjectNames(this.sources);
|
|
1362
|
+
const present = catalog !== undefined && names.every((name) => catalog.hasObject(name))
|
|
1363
|
+
? new Set([...names, ...(also?.names ?? []).filter((name) => catalog.hasObject(name))])
|
|
1364
|
+
: undefined;
|
|
1365
|
+
return this.database.transaction((transaction) => readSourceStates(transaction, this.dialect, this.tables, this.sources, includeDeferred, present, also), {
|
|
1366
|
+
readOnly: true,
|
|
1367
|
+
retryTransientFailures: true,
|
|
1368
|
+
leading: [
|
|
1369
|
+
...(present === undefined ? [this.dialect.schemaObjects([...names, ...(also?.names ?? [])])] : []),
|
|
1370
|
+
sourceProgressRead(this.tables),
|
|
1371
|
+
],
|
|
1372
|
+
});
|
|
1227
1373
|
}
|
|
1228
1374
|
/**
|
|
1229
1375
|
* Indexes the rows that referencing tables held before their triggers were installed, in transactions of
|
|
@@ -1376,9 +1522,11 @@ export class SqlSnapshotBlobStore {
|
|
|
1376
1522
|
options.signal?.throwIfAborted();
|
|
1377
1523
|
const trigger = `${t.blobs}_chunks_delete_all`;
|
|
1378
1524
|
const required = [trigger, `${t.blobs}_age`, `${t.blobs}_inline_size`];
|
|
1379
|
-
|
|
1525
|
+
// Asked with them: whether forks share their parents' histories, whose inherited snapshots the sweep keeps (#6560).
|
|
1526
|
+
const schema = this.dialect.schemaObjects([...required, this.forkSegments]);
|
|
1380
1527
|
const present = new Set((await this.database.all(schema.sql, ...schema.params)).map((row) => row.name));
|
|
1381
|
-
|
|
1528
|
+
const forks = present.has(this.forkSegments);
|
|
1529
|
+
if (!required.every((name) => present.has(name))) {
|
|
1382
1530
|
options.signal?.throwIfAborted();
|
|
1383
1531
|
await this.write(options.pace, async (transaction) => {
|
|
1384
1532
|
if (options.holder !== undefined)
|
|
@@ -1408,7 +1556,7 @@ export class SqlSnapshotBlobStore {
|
|
|
1408
1556
|
renewedAt = performance.now();
|
|
1409
1557
|
}
|
|
1410
1558
|
const page = await this.page(minimumAge, cursor);
|
|
1411
|
-
const candidates = await this.unretainedOf(page.map((row) => row.hash), sessions, turns);
|
|
1559
|
+
const candidates = await this.unretainedOf(page.map((row) => row.hash), sessions, turns, forks);
|
|
1412
1560
|
let incomplete = false;
|
|
1413
1561
|
for (const batch of sessions.batches(candidates)) {
|
|
1414
1562
|
// Every delete batch starts on a turn of its own and ends with one: never a turn while it holds the write lock.
|
|
@@ -1448,7 +1596,7 @@ export class SqlSnapshotBlobStore {
|
|
|
1448
1596
|
* references one of them and that `sessions` has not walked yet, in statements of at most
|
|
1449
1597
|
* {@link SNAPSHOT_COLLECTION_SESSION_REFS} snapshot entries, with a turn between them.
|
|
1450
1598
|
*/
|
|
1451
|
-
async unretainedOf(hashes, sessions, turns) {
|
|
1599
|
+
async unretainedOf(hashes, sessions, turns, forks) {
|
|
1452
1600
|
if (hashes.length === 0)
|
|
1453
1601
|
return [];
|
|
1454
1602
|
const t = this.tables;
|
|
@@ -1464,7 +1612,7 @@ export class SqlSnapshotBlobStore {
|
|
|
1464
1612
|
sessions.cost(costs);
|
|
1465
1613
|
for (const group of sessionGroups(costs)) {
|
|
1466
1614
|
await turns.next();
|
|
1467
|
-
sessions.retain(group, await this.retainedBySessions(group));
|
|
1615
|
+
sessions.retain(group, await this.retainedBySessions(group, forks));
|
|
1468
1616
|
turns.held();
|
|
1469
1617
|
}
|
|
1470
1618
|
}
|
|
@@ -1484,12 +1632,16 @@ export class SqlSnapshotBlobStore {
|
|
|
1484
1632
|
deleteUnretained(batch, minimumAge, options) {
|
|
1485
1633
|
const t = this.tables;
|
|
1486
1634
|
return this.write(options.pace, async (transaction) => {
|
|
1487
|
-
const
|
|
1635
|
+
const found = new Set();
|
|
1636
|
+
const states = await readSourceStates(transaction, this.dialect, this.tables, this.sources, false, undefined, {
|
|
1637
|
+
names: [this.forkSegments],
|
|
1638
|
+
found,
|
|
1639
|
+
});
|
|
1488
1640
|
if (!states.every((state) => state.installed && state.backfilled))
|
|
1489
1641
|
return undefined;
|
|
1490
1642
|
if (options.holder !== undefined)
|
|
1491
1643
|
await this.renewClaim(transaction, options.holder);
|
|
1492
|
-
const kept = new Set(await this.keptBySessions(transaction, batch));
|
|
1644
|
+
const kept = new Set(await this.keptBySessions(transaction, batch, found.has(this.forkSegments)));
|
|
1493
1645
|
const unretained = batch.hashes.filter((hash) => !kept.has(hash));
|
|
1494
1646
|
if (unretained.length === 0)
|
|
1495
1647
|
return [];
|
|
@@ -1527,32 +1679,48 @@ export class SqlSnapshotBlobStore {
|
|
|
1527
1679
|
* The blobs that the snapshots `sessions` retain reference, in one statement. A session whose tree the index could
|
|
1528
1680
|
* not follow retains every snapshot it records.
|
|
1529
1681
|
*/
|
|
1530
|
-
async retainedBySessions(sessions) {
|
|
1682
|
+
async retainedBySessions(sessions, forks) {
|
|
1531
1683
|
const t = this.tables;
|
|
1532
1684
|
const ids = JSON.stringify(sessions);
|
|
1685
|
+
const inherited = this.inheritedRecord(forks);
|
|
1533
1686
|
const rows = await this.database.all(`SELECT DISTINCT record.hash FROM ${t.sessionRecords} AS record
|
|
1534
1687
|
WHERE record.session_id IN (SELECT value FROM ${this.dialect.jsonValues("?")})
|
|
1535
1688
|
AND (
|
|
1536
1689
|
(record.session_id, record.snapshot_id) IN (${this.sessionHeads(`session_id IN (SELECT value FROM ${this.dialect.jsonValues("?")})`)})
|
|
1537
|
-
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)
|
|
1690
|
+
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)${inherited}
|
|
1538
1691
|
)`, ids, ids);
|
|
1539
1692
|
return rows.map((row) => row.hash);
|
|
1540
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* A condition, after `OR`, that another session inherits the session record `record` through a fork segment
|
|
1696
|
+
* (#6560); empty when `forks` says the fork segments table is not there, as while shared-history forks are off. A
|
|
1697
|
+
* fork that shares its parent's history stores none of the entries it inherits, so its own references never name
|
|
1698
|
+
* their snapshots: a record a segment names is kept whatever its session retains, as long as the segment lasts. A
|
|
1699
|
+
* delete batch reads whether the table exists in its own transaction, so it sees the segments that hold when it
|
|
1700
|
+
* commits.
|
|
1701
|
+
*/
|
|
1702
|
+
inheritedRecord(forks) {
|
|
1703
|
+
if (!forks)
|
|
1704
|
+
return "";
|
|
1705
|
+
return `
|
|
1706
|
+
OR EXISTS (SELECT 1 FROM ${this.forkSegments} AS segment WHERE segment.source_id = record.session_id AND record.seq BETWEEN segment.from_seq AND segment.to_seq)`;
|
|
1707
|
+
}
|
|
1541
1708
|
/**
|
|
1542
1709
|
* The blobs of `batch` that a session records and that the delete must keep, in one statement: those the snapshots
|
|
1543
1710
|
* of `batch.sessions` retain, and those a session not among them records, whose snapshots the sweep did not walk.
|
|
1544
1711
|
* Walks only `batch.sessions`, whose snapshot entries the sweep bounded when it made the batch (#5530).
|
|
1545
1712
|
*/
|
|
1546
|
-
async keptBySessions(executor, batch) {
|
|
1713
|
+
async keptBySessions(executor, batch, forks) {
|
|
1547
1714
|
const t = this.tables;
|
|
1548
1715
|
const ids = JSON.stringify(batch.sessions);
|
|
1549
1716
|
const walked = `(SELECT value FROM ${this.dialect.jsonValues("?")})`;
|
|
1717
|
+
const inherited = this.inheritedRecord(forks);
|
|
1550
1718
|
const rows = await executor.all(`SELECT DISTINCT record.hash FROM ${t.sessionRecords} AS record
|
|
1551
1719
|
WHERE record.hash IN (SELECT value FROM ${this.dialect.jsonValues("?")})
|
|
1552
1720
|
AND (
|
|
1553
1721
|
record.session_id NOT IN ${walked}
|
|
1554
1722
|
OR (record.session_id, record.snapshot_id) IN (${this.sessionHeads(`session_id IN ${walked}`)})
|
|
1555
|
-
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)
|
|
1723
|
+
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)${inherited}
|
|
1556
1724
|
)`, JSON.stringify(batch.hashes), ids, ids);
|
|
1557
1725
|
return rows.map((row) => row.hash);
|
|
1558
1726
|
}
|
|
@@ -1993,7 +2161,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
1993
2161
|
return (async () => {
|
|
1994
2162
|
const root = new URL("../../", import.meta.url);
|
|
1995
2163
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
1996
|
-
const key = `${root.href}#0.10.
|
|
2164
|
+
const key = `${root.href}#0.10.11-alpha.2`;
|
|
1997
2165
|
let release = releases.get(key);
|
|
1998
2166
|
if (release === undefined) {
|
|
1999
2167
|
const current = (async () => {
|
|
@@ -2021,7 +2189,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
2021
2189
|
} catch {
|
|
2022
2190
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
2023
2191
|
}
|
|
2024
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.
|
|
2192
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
|
|
2025
2193
|
if (updatedTo === undefined) throw error;
|
|
2026
2194
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
2027
2195
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|