@bastani/atomic 0.10.11-alpha.2 → 0.10.11-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -0
- package/README.md +5 -8
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +14 -2
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js.map → p1b-elig-TVB5CBLL.js.map} +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +340 -163
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-EZUKEP4Q.js} +48 -40
- package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-RTOHJFDJ.js} +195 -42
- package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +33 -43
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +39 -23
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +90 -1176
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +186 -35
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +23 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +913 -289
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
- package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
- package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +170 -74
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +298 -47
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
- package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +136 -19
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +2 -3
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.code.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/process-start-token.d.ts +8 -0
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +19 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +11 -0
- package/dist/core/storage/fenced-paths.js +11 -0
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +8 -13
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +51 -3
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.d.ts +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +7 -8
- package/dist/core/storage/schema-catalog.js +8 -8
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +4 -7
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.d.ts +5 -1
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +3 -3
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/session-search-index.d.ts +43 -4
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +48 -11
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +6 -1
- package/dist/core/storage/sqlite-facade.js +1 -0
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.code.js +1 -1
- package/dist/core/storage/team.d.ts +26 -115
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.d.ts +40 -3
- package/dist/core/worktree-snapshot/blob-store.js +414 -21
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +79 -38
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +6 -6
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- package/dist/utils/startup-database-spare.code.js +2 -2
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1421 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
|
-
import { GitUnavailableError, isGitUnavailableError } from "../../_shared/startup-0-0-
|
|
3
|
-
import { WorkspaceBindingError, WorkspaceCollectionError, WorkspaceConfigError, WorkspaceDriftError, WorkspaceError, WorkspaceGitError, WorkspacePublicationError, WorkspaceRestoreError, WorkspaceSandboxError, WorkspaceSnapshotError, WorkspaceTimeoutError, attachCleanupCause, findWorkspaceError, gitInstallCommand, isRetryableWorkspaceError, isWorkspaceBindingError, isWorkspaceCollectionError, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspacePublicationError, isWorkspaceRestoreError, isWorkspaceSandboxError, isWorkspaceSnapshotError, isWorkspaceTimeoutError, rehydrateWorkspaceError, serializeWorkspaceError, unreadablePathError, unwritablePathError } from "../../_shared/startup-0-1-
|
|
2
|
+
import { GitUnavailableError, isGitUnavailableError } from "../../_shared/startup-0-0-EZUKEP4Q.js";
|
|
3
|
+
import { WorkspaceBindingError, WorkspaceCollectionError, WorkspaceConfigError, WorkspaceDriftError, WorkspaceError, WorkspaceGitError, WorkspacePublicationError, WorkspaceRestoreError, WorkspaceSandboxError, WorkspaceSnapshotError, WorkspaceTimeoutError, attachCleanupCause, findWorkspaceError, gitInstallCommand, isRetryableWorkspaceError, isWorkspaceBindingError, isWorkspaceCollectionError, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspacePublicationError, isWorkspaceRestoreError, isWorkspaceSandboxError, isWorkspaceSnapshotError, isWorkspaceTimeoutError, rehydrateWorkspaceError, serializeWorkspaceError, unreadablePathError, unwritablePathError } from "../../_shared/startup-0-1-RTOHJFDJ.js";
|
|
4
4
|
import "../../_shared/startup-0-2-5QHPCEON.js";
|
|
5
5
|
export { GitUnavailableError, WorkspaceBindingError, WorkspaceCollectionError, WorkspaceConfigError, WorkspaceDriftError, WorkspaceError, WorkspaceGitError, WorkspacePublicationError, WorkspaceRestoreError, WorkspaceSandboxError, WorkspaceSnapshotError, WorkspaceTimeoutError, attachCleanupCause, findWorkspaceError, gitInstallCommand, isGitUnavailableError, isRetryableWorkspaceError, isWorkspaceBindingError, isWorkspaceCollectionError, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspacePublicationError, isWorkspaceRestoreError, isWorkspaceSandboxError, isWorkspaceSnapshotError, isWorkspaceTimeoutError, rehydrateWorkspaceError, serializeWorkspaceError, unreadablePathError, unwritablePathError };
|
|
6
6
|
//# sourceMappingURL=errors.code.js.map
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using worktree snapshots.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using worktree snapshots.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { dialectOf } from "../storage/dialect.js";
|
|
2
|
+
import { withShortSchemaLockWaits } from "../storage/migrations.js";
|
|
3
|
+
import { schemaCatalogOf } from "../storage/schema-catalog.js";
|
|
4
|
+
/** The name of {@link forkInheritedBlobGuard} on the snapshot blob table `blobs`. */
|
|
5
|
+
export function forkInheritedBlobGuardName(blobs) {
|
|
6
|
+
return `${blobs}_fork_keep`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The statements that install, on the snapshot blob table, a trigger that keeps every blob a fork inherits (#6560): a
|
|
10
|
+
* DELETE of the blob's row skips it, as long as a session record names it at a seq a fork segment covers, so that the
|
|
11
|
+
* fork's history still has the snapshot. A release without shared-history forks collects blobs by the snapshots each
|
|
12
|
+
* session retains, which never count the ones a fork inherits, and a process of one that an in-place update caught
|
|
13
|
+
* holds that collection while its session store, from the update, makes shared forks: the database refuses that
|
|
14
|
+
* collection what this build's own collection keeps (`SqlSnapshotBlobStore.sweep`), by the same condition, so that
|
|
15
|
+
* collection never meets it. Once the forks that inherit a blob are deleted, or have their own copy, their segments no
|
|
16
|
+
* longer name it, and the blob goes as any other. Only a DELETE of a blob runs it, and its check reads the session
|
|
17
|
+
* records by hash and the segments by source, through their indexes. The chunks of a blob go with its row, by the
|
|
18
|
+
* trigger that deletes them after it.
|
|
19
|
+
*/
|
|
20
|
+
export function forkInheritedBlobGuard(dialect, tables, forkSegments) {
|
|
21
|
+
return dialect.renderTrigger({
|
|
22
|
+
name: forkInheritedBlobGuardName(tables.blobs),
|
|
23
|
+
table: tables.blobs,
|
|
24
|
+
timing: "BEFORE",
|
|
25
|
+
event: "DELETE",
|
|
26
|
+
when: `EXISTS (SELECT 1 FROM ${tables.sessionRecords} AS record JOIN ${forkSegments} AS segment ON segment.source_id = record.session_id AND record.seq BETWEEN segment.from_seq AND segment.to_seq WHERE record.hash = OLD.hash)`,
|
|
27
|
+
// Skips the row and goes on with the statement: SQLite's RAISE(IGNORE), a PostgreSQL BEFORE trigger's NULL.
|
|
28
|
+
statements: [dialect.name === "postgres" ? "RETURN NULL" : "SELECT RAISE(IGNORE)"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Installs {@link forkInheritedBlobGuard} in the transaction `tx`, unless it is there, or the snapshot tables or the
|
|
33
|
+
* fork segments table are not there yet. The switch to shared-history forks installs it with the fork tables, so no
|
|
34
|
+
* fork shares a history before the database keeps what it inherits; the snapshot store installs it with its tables on
|
|
35
|
+
* a new database, whose fork tables come first.
|
|
36
|
+
*/
|
|
37
|
+
export async function installForkInheritedBlobGuard(tx, dialect, tables, forkSegments) {
|
|
38
|
+
const name = forkInheritedBlobGuardName(tables.blobs);
|
|
39
|
+
const probe = dialect.schemaObjects([tables.blobs, tables.sessionRecords, forkSegments, name]);
|
|
40
|
+
const found = new Set((await tx.all(probe.sql, ...probe.params)).map((row) => row.name));
|
|
41
|
+
if (found.has(name) || ![tables.blobs, tables.sessionRecords, forkSegments].every((table) => found.has(table)))
|
|
42
|
+
return;
|
|
43
|
+
const guard = forkInheritedBlobGuard(dialect, tables, forkSegments);
|
|
44
|
+
await withShortSchemaLockWaits(tx, dialect, () => tx.exec(guard));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Installs {@link forkInheritedBlobGuard} where a session store's open finds forks sharing history, once its snapshot
|
|
48
|
+
* store is open, unless the schema the open read holds it (`schemaCatalogOf`), as it does on every open after the
|
|
49
|
+
* first: a database switched by a build before the guard, or whose snapshot store came from an earlier release, as in
|
|
50
|
+
* a process an in-place update caught, which creates its tables without it. Housekeeping: where it cannot be
|
|
51
|
+
* installed, such as for a PostgreSQL role that does not own the snapshot tables, the open goes on, and
|
|
52
|
+
* `atomic storage migrate`, run as the owner, installs it.
|
|
53
|
+
*/
|
|
54
|
+
export async function ensureForkInheritedBlobGuard(database, tables, forkSegments, ledger) {
|
|
55
|
+
if (database.readOnly === true)
|
|
56
|
+
return;
|
|
57
|
+
const dialect = dialectOf(database);
|
|
58
|
+
const name = forkInheritedBlobGuardName(tables.blobs);
|
|
59
|
+
const catalog = await schemaCatalogOf(database);
|
|
60
|
+
if (catalog !== undefined) {
|
|
61
|
+
if (catalog.hasObject(name))
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const probe = dialect.schemaObjects([name]);
|
|
66
|
+
if ((await database.all(probe.sql, ...probe.params)).length > 0)
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
await database.transaction(async (tx) => {
|
|
71
|
+
// Serialized with the other stores' schema setups under the prefix, so hosts that open together install it once.
|
|
72
|
+
if (dialect.name === "postgres")
|
|
73
|
+
await tx.get("SELECT pg_advisory_xact_lock(hashtextextended(?, 0)) AS locked", `${ledger}:schema`);
|
|
74
|
+
await installForkInheritedBlobGuard(tx, dialect, tables, forkSegments);
|
|
75
|
+
}, { retryTransientFailures: true, concurrency: { kind: "serial", domain: ledger } });
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Left for a later open or `atomic storage migrate`.
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fork-blob-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fork-blob-guard.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/fork-blob-guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAuB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,qFAAqF;AACrF,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACvD,OAAO,GAAG,KAAK,YAAY,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAAuB,EACvB,MAA+B,EAC/B,YAAoB;IAEpB,OAAO,OAAO,CAAC,aAAa,CAAC;QAC5B,IAAI,EAAE,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC;QAC9C,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,yBAAyB,MAAM,CAAC,cAAc,mBAAmB,YAAY,+IAA+I;QAClO,4GAA4G;QAC5G,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,aAA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SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;YAAE,OAAO;IACrC,CAAC;SAAM,CAAC;QACP,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO;IACzE,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,QAAQ,CAAC,WAAW,CACzB,KAAK,EAAE,EAAE,EAAE,EAAE;YACZ,iHAAiH;YACjH,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU;gBAC9B,MAAM,EAAE,CAAC,GAAG,CAAC,gEAAgE,EAAE,GAAG,MAAM,SAAS,CAAC,CAAC;YACpG,MAAM,6BAA6B,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QACxE,CAAC,EACD,EAAE,sBAAsB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CACjF,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,qDAAqD;IACtD,CAAC;AACF,CAAC","sourcesContent":["import type { SqliteDatabase, SqliteExecutor, SqliteRow } from \"../storage/database.js\";\nimport { dialectOf, type StorageDialect } from \"../storage/dialect.js\";\nimport { withShortSchemaLockWaits } from \"../storage/migrations.js\";\nimport { schemaCatalogOf } from \"../storage/schema-catalog.js\";\n\n/** The snapshot blob table and the session records of the snapshot index that {@link forkInheritedBlobGuard} reads. */\nexport interface ForkInheritedBlobTables {\n\treadonly blobs: string;\n\treadonly sessionRecords: string;\n}\n\n/** The name of {@link forkInheritedBlobGuard} on the snapshot blob table `blobs`. */\nexport function forkInheritedBlobGuardName(blobs: string): string {\n\treturn `${blobs}_fork_keep`;\n}\n\n/**\n * The statements that install, on the snapshot blob table, a trigger that keeps every blob a fork inherits (#6560): a\n * DELETE of the blob's row skips it, as long as a session record names it at a seq a fork segment covers, so that the\n * fork's history still has the snapshot. A release without shared-history forks collects blobs by the snapshots each\n * session retains, which never count the ones a fork inherits, and a process of one that an in-place update caught\n * holds that collection while its session store, from the update, makes shared forks: the database refuses that\n * collection what this build's own collection keeps (`SqlSnapshotBlobStore.sweep`), by the same condition, so that\n * collection never meets it. Once the forks that inherit a blob are deleted, or have their own copy, their segments no\n * longer name it, and the blob goes as any other. Only a DELETE of a blob runs it, and its check reads the session\n * records by hash and the segments by source, through their indexes. The chunks of a blob go with its row, by the\n * trigger that deletes them after it.\n */\nexport function forkInheritedBlobGuard(\n\tdialect: StorageDialect,\n\ttables: ForkInheritedBlobTables,\n\tforkSegments: string,\n): string {\n\treturn dialect.renderTrigger({\n\t\tname: forkInheritedBlobGuardName(tables.blobs),\n\t\ttable: tables.blobs,\n\t\ttiming: \"BEFORE\",\n\t\tevent: \"DELETE\",\n\t\twhen: `EXISTS (SELECT 1 FROM ${tables.sessionRecords} AS record JOIN ${forkSegments} AS segment ON segment.source_id = record.session_id AND record.seq BETWEEN segment.from_seq AND segment.to_seq WHERE record.hash = OLD.hash)`,\n\t\t// Skips the row and goes on with the statement: SQLite's RAISE(IGNORE), a PostgreSQL BEFORE trigger's NULL.\n\t\tstatements: [dialect.name === \"postgres\" ? \"RETURN NULL\" : \"SELECT RAISE(IGNORE)\"],\n\t});\n}\n\n/**\n * Installs {@link forkInheritedBlobGuard} in the transaction `tx`, unless it is there, or the snapshot tables or the\n * fork segments table are not there yet. The switch to shared-history forks installs it with the fork tables, so no\n * fork shares a history before the database keeps what it inherits; the snapshot store installs it with its tables on\n * a new database, whose fork tables come first.\n */\nexport async function installForkInheritedBlobGuard(\n\ttx: SqliteExecutor,\n\tdialect: StorageDialect,\n\ttables: ForkInheritedBlobTables,\n\tforkSegments: string,\n): Promise<void> {\n\tconst name = forkInheritedBlobGuardName(tables.blobs);\n\tconst probe = dialect.schemaObjects([tables.blobs, tables.sessionRecords, forkSegments, name]);\n\tconst found = new Set(\n\t\t(await tx.all<SqliteRow & { name: string }>(probe.sql, ...probe.params)).map((row) => row.name),\n\t);\n\tif (found.has(name) || ![tables.blobs, tables.sessionRecords, forkSegments].every((table) => found.has(table)))\n\t\treturn;\n\tconst guard = forkInheritedBlobGuard(dialect, tables, forkSegments);\n\tawait withShortSchemaLockWaits(tx, dialect, () => tx.exec(guard));\n}\n\n/**\n * Installs {@link forkInheritedBlobGuard} where a session store's open finds forks sharing history, once its snapshot\n * store is open, unless the schema the open read holds it (`schemaCatalogOf`), as it does on every open after the\n * first: a database switched by a build before the guard, or whose snapshot store came from an earlier release, as in\n * a process an in-place update caught, which creates its tables without it. Housekeeping: where it cannot be\n * installed, such as for a PostgreSQL role that does not own the snapshot tables, the open goes on, and\n * `atomic storage migrate`, run as the owner, installs it.\n */\nexport async function ensureForkInheritedBlobGuard(\n\tdatabase: SqliteDatabase,\n\ttables: ForkInheritedBlobTables,\n\tforkSegments: string,\n\tledger: string,\n): Promise<void> {\n\tif (database.readOnly === true) return;\n\tconst dialect = dialectOf(database);\n\tconst name = forkInheritedBlobGuardName(tables.blobs);\n\tconst catalog = await schemaCatalogOf(database);\n\tif (catalog !== undefined) {\n\t\tif (catalog.hasObject(name)) return;\n\t} else {\n\t\tconst probe = dialect.schemaObjects([name]);\n\t\tif ((await database.all(probe.sql, ...probe.params)).length > 0) return;\n\t}\n\ttry {\n\t\tawait database.transaction(\n\t\t\tasync (tx) => {\n\t\t\t\t// Serialized with the other stores' schema setups under the prefix, so hosts that open together install it once.\n\t\t\t\tif (dialect.name === \"postgres\")\n\t\t\t\t\tawait tx.get(\"SELECT pg_advisory_xact_lock(hashtextextended(?, 0)) AS locked\", `${ledger}:schema`);\n\t\t\t\tawait installForkInheritedBlobGuard(tx, dialect, tables, forkSegments);\n\t\t\t},\n\t\t\t{ retryTransientFailures: true, concurrency: { kind: \"serial\", domain: ledger } },\n\t\t);\n\t} catch {\n\t\t// Left for a later open or `atomic storage migrate`.\n\t}\n}\n"]}
|
|
@@ -10,81 +10,104 @@ export function forkSegmentsTable(prefix = "") {
|
|
|
10
10
|
/**
|
|
11
11
|
* The trigger that earlier builds of #6560 installed to link each entry a session with fork segments writes. Each
|
|
12
12
|
* INSERT into the session entries table ran it, a plain session's too, so the store now writes those links itself
|
|
13
|
-
* (`
|
|
13
|
+
* (`forkLinkWrites`, `materializedForkLinks`), and a store's open drops the trigger where it finds it.
|
|
14
14
|
*/
|
|
15
15
|
export function legacyForkLinksTriggerName(entries) {
|
|
16
16
|
return `${entries}_fork_links_v1`;
|
|
17
17
|
}
|
|
18
18
|
/** The view seq one past a segment's last, for the segment aliased `alias`. */
|
|
19
19
|
const segmentEnd = (alias) => `${alias}.base_seq + ${alias}.to_seq - ${alias}.from_seq + 1`;
|
|
20
|
+
/**
|
|
21
|
+
* The seq of the link that is the parent of entry `r` among the links its session stores, or null: of the links before
|
|
22
|
+
* `r` with the parent's id, the first. `r` has the columns {@link parentColumns} names. A save and a rebuild of the
|
|
23
|
+
* index both link an entry with this lookup, so an entry whose parent is written after it, or whose parent's id more
|
|
24
|
+
* than one entry has, is linked the same by both (#6560).
|
|
25
|
+
*/
|
|
26
|
+
export function ownParentSeq(links) {
|
|
27
|
+
// `+seq`: the lookup goes by the entry's id, never in seq order, which SQLite would read row by row.
|
|
28
|
+
return `(SELECT min(+p.seq) FROM ${links} AS p WHERE p.session_id = r.session_id AND p.entry_id = r.parent_id AND r.parent_type = 'text' AND +p.seq < r.seq)`;
|
|
29
|
+
}
|
|
30
|
+
/** Whether a link before entry `r` in its session has `r`'s id: such an entry is linked broken, as in a copy. */
|
|
31
|
+
export function ownDuplicate(links) {
|
|
32
|
+
return `EXISTS (SELECT 1 FROM ${links} AS other WHERE other.session_id = r.session_id AND other.entry_id = r.entry_id AND +other.seq < r.seq)`;
|
|
33
|
+
}
|
|
20
34
|
/**
|
|
21
35
|
* The seq in session `child`'s view of the entry at seq `seq` of session `source`'s view, where `source` stores a row
|
|
22
36
|
* `child` inherits. Segments are composed when a fork is made, so a segment's source stores the rows it names itself:
|
|
23
37
|
* `seq` is either a row `source` stores, which a segment of `child` names, or a row `source` inherits, from the source
|
|
24
38
|
* of one of its own segments, which a segment of `child` names by that source. An entry that `child`, or a fork
|
|
25
|
-
* between `source` and `child`, stores itself, such as one a fork edited, is found by its id
|
|
39
|
+
* between `source` and `child`, stores itself, such as one a fork edited, is found by its id among the rows of
|
|
40
|
+
* `child`'s view before `bound`, the entry being linked.
|
|
26
41
|
*/
|
|
27
|
-
function childViewSeq(links, segments, child, source, seq) {
|
|
42
|
+
function childViewSeq(links, segments, child, source, seq, bound) {
|
|
28
43
|
const inheritedBy = `ss.session_id = ${source} AND ${seq} BETWEEN ss.base_seq + 1 AND ${segmentEnd("ss")}`;
|
|
29
44
|
const stored = `${seq} - ss.base_seq - 1 + ss.from_seq`;
|
|
30
45
|
const entryId = `COALESCE((SELECT a.entry_id FROM ${links} AS a WHERE a.session_id = ${source} AND a.seq = ${seq}), (SELECT a.entry_id FROM ${segments} AS ss JOIN ${links} AS a ON a.session_id = ss.source_id AND a.seq = ${stored} WHERE ${inheritedBy}))`;
|
|
31
46
|
return `COALESCE(
|
|
32
47
|
(SELECT ${seq} - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs WHERE cs.session_id = ${child} AND cs.source_id = ${source} AND ${seq} BETWEEN cs.from_seq AND cs.to_seq),
|
|
33
48
|
(SELECT ${stored} - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS ss JOIN ${segments} AS cs ON cs.session_id = ${child} AND cs.source_id = ss.source_id AND ${stored} BETWEEN cs.from_seq AND cs.to_seq WHERE ${inheritedBy}),
|
|
34
|
-
(SELECT own.seq FROM ${links} AS own WHERE own.session_id = ${child} AND own.entry_id = ${entryId}
|
|
35
|
-
(SELECT x.seq - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs JOIN ${links} AS x ON x.session_id = cs.source_id AND x.entry_id = ${entryId} AND x.seq BETWEEN cs.from_seq AND cs.to_seq WHERE cs.session_id = ${child} ORDER BY cs.base_seq, x.seq LIMIT 1)
|
|
49
|
+
(SELECT min(+own.seq) FROM ${links} AS own WHERE own.session_id = ${child} AND own.entry_id = ${entryId} AND +own.seq < ${bound}),
|
|
50
|
+
(SELECT x.seq - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs JOIN ${links} AS x ON x.session_id = cs.source_id AND x.entry_id = ${entryId} AND +x.seq BETWEEN cs.from_seq AND cs.to_seq WHERE cs.session_id = ${child} AND cs.base_seq < ${bound} ORDER BY cs.base_seq, x.seq LIMIT 1)
|
|
36
51
|
)`;
|
|
37
52
|
}
|
|
38
53
|
/**
|
|
39
|
-
* The statement that
|
|
40
|
-
*
|
|
41
|
-
*
|
|
54
|
+
* The statement that links one entry of a session with fork segments, as a copy of the session would have it. `rows`
|
|
55
|
+
* yields that entry as `r`, with its parent's id and JSON type as `parent_id` and `parent_type`; `isSnapshot` tells
|
|
56
|
+
* whether `r` is a snapshot entry. It runs after the released link statement of the entry, and writes over that row's
|
|
57
|
+
* anchor and broken mark; the released statements keep the children count.
|
|
42
58
|
*
|
|
43
59
|
* The released link statement finds an entry's parent only among the links the session stores, so it marks an entry
|
|
44
60
|
* whose parent the session inherits broken, without an anchor. This one also finds the parent among the links of the
|
|
45
61
|
* rows the session's segments name, and takes the parent's anchor in the session's view. An entry whose id an entry
|
|
46
|
-
* the session inherits also has is broken, as in a copy.
|
|
47
|
-
* same whichever of the two runs first.
|
|
62
|
+
* the session inherits also has is broken, as in a copy.
|
|
48
63
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
64
|
+
* It reads only the rows of the session's view before the entry, the links the session stores and those its segments
|
|
65
|
+
* name, as a copy had when it inserted the entry: a parent written after its child, or an entry of the same id after
|
|
66
|
+
* it, changes nothing. A save runs it as it writes an entry, the index's rebuild as it links a stored row again, and
|
|
67
|
+
* both meet the rows before the entry linked already (`relinkSessionEntries`), so both link every entry the same
|
|
68
|
+
* (#6560).
|
|
54
69
|
*
|
|
55
70
|
* The snapshot references of such an entry stay as the released statements index them: a reference's `prev_seq` that
|
|
56
71
|
* would name an inherited entry is empty. Collection walks a session's references only through the rows the session
|
|
57
72
|
* stores, and keeps every snapshot record a segment names (see `SqlSnapshotBlobStore.sweep`), so it never needs it.
|
|
58
73
|
*/
|
|
59
|
-
export function forkSessionLink(links, segments, rows, isSnapshot
|
|
60
|
-
const
|
|
61
|
-
const segmentBefore = written ? " AND seg.base_seq < r.seq" : "";
|
|
62
|
-
const own = (column) => `(SELECT p.${column} FROM ${links} AS p WHERE p.session_id = r.session_id AND p.entry_id = r.parent_id AND r.parent_type = 'text'${before("p")} ORDER BY p.seq LIMIT 1)`;
|
|
63
|
-
const ownParent = `EXISTS (SELECT 1 FROM ${links} AS p WHERE p.session_id = r.session_id AND p.entry_id = r.parent_id AND r.parent_type = 'text'${before("p")})`;
|
|
64
|
-
const inherited = (select) => `(SELECT ${select} FROM ${segments} AS seg JOIN ${links} AS up ON up.session_id = seg.source_id AND up.entry_id = r.parent_id AND up.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id AND r.parent_type = 'text'${segmentBefore} ORDER BY seg.base_seq, up.seq LIMIT 1)`;
|
|
65
|
-
const anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, "r.session_id", "up.session_id", "up.anchor_seq")} END`;
|
|
66
|
-
const duplicate = `EXISTS (SELECT 1 FROM ${links} AS other WHERE other.session_id = r.session_id AND other.entry_id = r.entry_id AND other.seq <> r.seq${before("other")}) OR EXISTS (SELECT 1 FROM ${segments} AS seg JOIN ${links} AS other ON other.session_id = seg.source_id AND other.entry_id = r.entry_id AND other.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id${segmentBefore})`;
|
|
67
|
-
const children = written
|
|
68
|
-
? "0"
|
|
69
|
-
: `CASE WHEN EXISTS (SELECT 1 FROM ${links} AS later WHERE later.session_id = r.session_id AND later.seq > r.seq) THEN (SELECT count(*) FROM ${links} AS c WHERE c.session_id = r.session_id AND c.parent_id = r.entry_id AND c.seq <> r.seq) ELSE 0 END`;
|
|
74
|
+
export function forkSessionLink(links, segments, rows, isSnapshot) {
|
|
75
|
+
const { anchor, broken } = forkLinkValues(links, segments, isSnapshot);
|
|
70
76
|
return `INSERT INTO ${links} (session_id, seq, entry_id, parent_id, anchor_seq, children, broken)
|
|
71
|
-
SELECT r.session_id, r.seq, r.entry_id, CASE WHEN r.parent_type = 'text' THEN r.parent_id END,
|
|
72
|
-
CASE WHEN ${isSnapshot} THEN r.seq WHEN ${ownParent} THEN ${own("anchor_seq")} ELSE ${inherited(anchor)} END,
|
|
73
|
-
${children},
|
|
74
|
-
CASE WHEN ${duplicate} THEN 1 WHEN r.parent_type IS NULL OR r.parent_type = 'null' THEN 0 WHEN ${ownParent} THEN ${own("broken")} ELSE COALESCE(${inherited("up.broken")}, 1) END
|
|
77
|
+
SELECT r.session_id, r.seq, r.entry_id, CASE WHEN r.parent_type = 'text' THEN r.parent_id END, ${anchor}, 0, ${broken}
|
|
75
78
|
FROM ${rows} AS r WHERE EXISTS (SELECT 1 FROM ${segments} AS any_segment WHERE any_segment.session_id = r.session_id)
|
|
76
|
-
ON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq,
|
|
79
|
+
ON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq, broken = excluded.broken`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The anchor and the broken mark of entry `r` as {@link forkSessionLink} links it, from the links before it, its
|
|
83
|
+
* session's and those its segments name: the one function a save, the index's rebuild and the check of a
|
|
84
|
+
* materialization's links ({@link forkLinksCheck}) all compute them with (#6560). For a session without segments it
|
|
85
|
+
* is what the released link statement writes.
|
|
86
|
+
*/
|
|
87
|
+
export function forkLinkValues(links, segments, isSnapshot) {
|
|
88
|
+
const parentSeq = ownParentSeq(links);
|
|
89
|
+
const own = (column) => `(SELECT p.${column} FROM ${links} AS p WHERE p.session_id = r.session_id AND p.seq = ${parentSeq})`;
|
|
90
|
+
const ownParent = `${parentSeq} IS NOT NULL`;
|
|
91
|
+
const inherited = (select) => `(SELECT ${select} FROM ${segments} AS seg JOIN ${links} AS up ON up.session_id = seg.source_id AND up.entry_id = r.parent_id AND +up.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id AND r.parent_type = 'text' AND seg.base_seq < r.seq ORDER BY seg.base_seq, up.seq LIMIT 1)`;
|
|
92
|
+
const anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, "r.session_id", "up.session_id", "up.anchor_seq", "r.seq")} END`;
|
|
93
|
+
const duplicate = `${ownDuplicate(links)} OR EXISTS (SELECT 1 FROM ${segments} AS seg JOIN ${links} AS other ON other.session_id = seg.source_id AND other.entry_id = r.entry_id AND +other.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id AND seg.base_seq < r.seq)`;
|
|
94
|
+
return {
|
|
95
|
+
anchor: `CASE WHEN ${isSnapshot} THEN r.seq WHEN ${ownParent} THEN ${own("anchor_seq")} ELSE ${inherited(anchor)} END`,
|
|
96
|
+
broken: `CASE WHEN ${duplicate} THEN 1 WHEN r.parent_type IS NULL OR r.parent_type = 'null' THEN 0 WHEN ${ownParent} THEN ${own("broken")} ELSE COALESCE(${inherited("up.broken")}, 1) END`,
|
|
97
|
+
};
|
|
77
98
|
}
|
|
78
99
|
/**
|
|
79
100
|
* The statement that links the rows a materialization just copied into a fork (#6560), one piece of one source at a
|
|
80
101
|
* time, all of them in one statement: each row is linked as its source links it, its anchor taken into the fork's
|
|
81
102
|
* view, and its children counted among the rows the fork now stores. It runs after the piece's rows are inserted and
|
|
82
|
-
* before the fork's segments lose the piece, so they still map the source's seqs.
|
|
103
|
+
* before the fork's segments lose the piece, so they still map the source's seqs. These links are what
|
|
104
|
+
* {@link forkLinkValues} computes for every history but a few: {@link forkLinksCheck} tells, once the segments lost
|
|
105
|
+
* the pieces, and the fork is linked again row by row where it does not hold. `complete` is the condition that the
|
|
83
106
|
* index's backfill is done: until then the backfill links the rows. Parameters: the fork's id, the shift from the
|
|
84
107
|
* source's seqs to the fork's, the source's id, the first and last seq of the piece in the source, and the fork's id.
|
|
85
108
|
*/
|
|
86
109
|
export function materializedForkLinks(links, segments, complete, int) {
|
|
87
|
-
const anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, "m.child", "up.session_id", "up.anchor_seq")} END`;
|
|
110
|
+
const anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, "m.child", "up.session_id", "up.anchor_seq", "up.seq + m.shift")} END`;
|
|
88
111
|
return `INSERT INTO ${links} (session_id, seq, entry_id, parent_id, anchor_seq, children, broken)
|
|
89
112
|
SELECT m.child, up.seq + m.shift, up.entry_id, up.parent_id, ${anchor}, COALESCE(kids.n, 0), up.broken
|
|
90
113
|
FROM (SELECT CAST(? AS text) AS child, CAST(? AS ${int}) AS shift) AS m
|
|
@@ -93,6 +116,27 @@ export function materializedForkLinks(links, segments, complete, int) {
|
|
|
93
116
|
WHERE ${complete}
|
|
94
117
|
ON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq, children = excluded.children, broken = excluded.broken`;
|
|
95
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The read that tells whether the links of session `?` from seq `?` on are the ones {@link forkLinkValues} computes,
|
|
121
|
+
* one statement for them all (#6560): `seq`, the first row whose anchor or broken mark is not, or null; `children`,
|
|
122
|
+
* whether a row from that seq on has a child stored before it, whose count {@link materializedForkLinks} and a save
|
|
123
|
+
* may tell apart; and `refs`, whether a snapshot entry's reference names another previous snapshot than its parent's
|
|
124
|
+
* anchor. `rows` yields the session's rows from that seq on as `r`, with their ids, their parents' ids and JSON types
|
|
125
|
+
* (`parent_id`, `parent_type`), bound to the session's id and the seq; `isSnapshot` tells whether `r` is a snapshot
|
|
126
|
+
* entry; `refs` is the snapshot references' table. Nothing is read until the index's backfill is done (`complete`).
|
|
127
|
+
*/
|
|
128
|
+
export function forkLinksCheck(tables, rows, isSnapshot, complete) {
|
|
129
|
+
const { links, segments, refs } = tables;
|
|
130
|
+
const { anchor, broken } = forkLinkValues(links, segments, isSnapshot);
|
|
131
|
+
const parentAnchor = `(SELECT p.anchor_seq FROM ${links} AS p WHERE p.session_id = r.session_id AND p.seq = ${ownParentSeq(links)})`;
|
|
132
|
+
return `SELECT
|
|
133
|
+
(SELECT min(v.seq) FROM (SELECT r.session_id, r.seq, ${anchor} AS anchor_seq, ${broken} AS broken FROM ${rows} AS r) AS v
|
|
134
|
+
JOIN ${links} AS l ON l.session_id = v.session_id AND l.seq = v.seq
|
|
135
|
+
WHERE COALESCE(l.anchor_seq, -1) <> COALESCE(v.anchor_seq, -1) OR l.broken <> v.broken) AS seq,
|
|
136
|
+
CASE WHEN EXISTS (SELECT 1 FROM ${links} AS c WHERE c.session_id = ? AND c.parent_id IS NOT NULL AND EXISTS (SELECT 1 FROM ${links} AS q WHERE q.session_id = c.session_id AND q.entry_id = c.parent_id AND +q.seq > c.seq AND +q.seq >= ?)) THEN 1 ELSE 0 END AS children,
|
|
137
|
+
CASE WHEN EXISTS (SELECT 1 FROM ${rows} AS r JOIN ${refs} AS ref ON ref.session_id = r.session_id AND ref.seq = r.seq WHERE ${isSnapshot} AND COALESCE(ref.prev_seq, -1) <> COALESCE(${parentAnchor}, -1)) THEN 1 ELSE 0 END AS refs
|
|
138
|
+
WHERE ${complete}`;
|
|
139
|
+
}
|
|
96
140
|
/** Whether `column(name)`'s row is a snapshot entry, whose snapshot the index records. */
|
|
97
141
|
export function snapshotEntryCondition(d, column) {
|
|
98
142
|
const entry = column("entry_json");
|
|
@@ -112,10 +156,7 @@ export function entriesIndexComplete(sources) {
|
|
|
112
156
|
export function forkLinkWrites(tables, d) {
|
|
113
157
|
const complete = entriesIndexComplete(tables.sources);
|
|
114
158
|
const rows = `(SELECT session_id, seq, entry_id, entry_json, ${parentColumns(d, "entry_json")} FROM ${tables.entries} WHERE session_id = ? AND seq = ? AND ${complete})`;
|
|
115
|
-
const sql = forkSessionLink(tables.sessionLinks, tables.forkSegments, rows, snapshotEntryCondition(d, (name) => `r.${name}`)
|
|
116
|
-
return {
|
|
117
|
-
entry: (sessionId, seq) => ({ sql, params: [sessionId, seq] }),
|
|
118
|
-
materialized: materializedForkLinks(tables.sessionLinks, tables.forkSegments, complete, d.types.int),
|
|
119
|
-
};
|
|
159
|
+
const sql = forkSessionLink(tables.sessionLinks, tables.forkSegments, rows, snapshotEntryCondition(d, (name) => `r.${name}`));
|
|
160
|
+
return { entry: (sessionId, seq) => ({ sql, params: [sessionId, seq] }) };
|
|
120
161
|
}
|
|
121
162
|
//# sourceMappingURL=fork-snapshot-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-snapshot-index.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/fork-snapshot-index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAM,GAAG,EAAE;IAC5C,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACzD,OAAO,GAAG,OAAO,gBAAgB,CAAC;AACnC,CAAC;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KAAK,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC;QAC9D,YAAY,EAAE,qBAAqB,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;KACpG,CAAC;AACH,CAAC","sourcesContent":["import type { SqliteStatement } from \"../storage/database.js\";\nimport type { StorageDialect } from \"../storage/dialect.js\";\nimport { sessionForkTables } from \"../storage/session/fork-schema.js\";\n\n/**\n * The fork segments of the sessions under `prefix` (#6560): `(session_id, idx, source_id, from_seq, to_seq, base_seq)`,\n * one row per run of a session's view that another session stores. `atomic storage migrate` creates the table when it\n * turns shared-history forks on; until then no session has a segment.\n */\nexport function forkSegmentsTable(prefix = \"\"): string {\n\treturn sessionForkTables(prefix).forkSegments;\n}\n\n/**\n * The trigger that earlier builds of #6560 installed to link each entry a session with fork segments writes. Each\n * INSERT into the session entries table ran it, a plain session's too, so the store now writes those links itself\n * (`forkEntryLink`, `materializedForkLinks`), and a store's open drops the trigger where it finds it.\n */\nexport function legacyForkLinksTriggerName(entries: string): string {\n\treturn `${entries}_fork_links_v1`;\n}\n\n/** The view seq one past a segment's last, for the segment aliased `alias`. */\nconst segmentEnd = (alias: string) => `${alias}.base_seq + ${alias}.to_seq - ${alias}.from_seq + 1`;\n\n/**\n * The seq in session `child`'s view of the entry at seq `seq` of session `source`'s view, where `source` stores a row\n * `child` inherits. Segments are composed when a fork is made, so a segment's source stores the rows it names itself:\n * `seq` is either a row `source` stores, which a segment of `child` names, or a row `source` inherits, from the source\n * of one of its own segments, which a segment of `child` names by that source. An entry that `child`, or a fork\n * between `source` and `child`, stores itself, such as one a fork edited, is found by its id.\n */\nfunction childViewSeq(links: string, segments: string, child: string, source: string, seq: string): string {\n\tconst inheritedBy = `ss.session_id = ${source} AND ${seq} BETWEEN ss.base_seq + 1 AND ${segmentEnd(\"ss\")}`;\n\tconst stored = `${seq} - ss.base_seq - 1 + ss.from_seq`;\n\tconst entryId = `COALESCE((SELECT a.entry_id FROM ${links} AS a WHERE a.session_id = ${source} AND a.seq = ${seq}), (SELECT a.entry_id FROM ${segments} AS ss JOIN ${links} AS a ON a.session_id = ss.source_id AND a.seq = ${stored} WHERE ${inheritedBy}))`;\n\treturn `COALESCE(\n\t\t(SELECT ${seq} - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs WHERE cs.session_id = ${child} AND cs.source_id = ${source} AND ${seq} BETWEEN cs.from_seq AND cs.to_seq),\n\t\t(SELECT ${stored} - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS ss JOIN ${segments} AS cs ON cs.session_id = ${child} AND cs.source_id = ss.source_id AND ${stored} BETWEEN cs.from_seq AND cs.to_seq WHERE ${inheritedBy}),\n\t\t(SELECT own.seq FROM ${links} AS own WHERE own.session_id = ${child} AND own.entry_id = ${entryId} ORDER BY own.seq LIMIT 1),\n\t\t(SELECT x.seq - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs JOIN ${links} AS x ON x.session_id = cs.source_id AND x.entry_id = ${entryId} AND x.seq BETWEEN cs.from_seq AND cs.to_seq WHERE cs.session_id = ${child} ORDER BY cs.base_seq, x.seq LIMIT 1)\n\t)`;\n}\n\n/**\n * The statement that indexes the link of one entry of a session with fork segments, as a copy of the session would\n * have it. `rows` yields that entry as `r`, with its parent's id and JSON type as `parent_id` and `parent_type`;\n * `isSnapshot` tells whether `r` is a snapshot entry.\n *\n * The released link statement finds an entry's parent only among the links the session stores, so it marks an entry\n * whose parent the session inherits broken, without an anchor. This one also finds the parent among the links of the\n * rows the session's segments name, and takes the parent's anchor in the session's view. An entry whose id an entry\n * the session inherits also has is broken, as in a copy. It writes over the released statement's row, so it ends the\n * same whichever of the two runs first.\n *\n * With `written`, the store runs it after the statement that inserted the entry, whose rows and segments after it may\n * be there already (#6560): it then reads only the session's rows and segments before the entry, which are what a copy\n * had when it inserted the entry, and leaves the children count to the released statements, which count each child as\n * it is inserted. Without, as the index's backfill runs it, it counts the children an entry written below the\n * session's last row already has, as when a fork's inherited rows are copied into it.\n *\n * The snapshot references of such an entry stay as the released statements index them: a reference's `prev_seq` that\n * would name an inherited entry is empty. Collection walks a session's references only through the rows the session\n * stores, and keeps every snapshot record a segment names (see `SqlSnapshotBlobStore.sweep`), so it never needs it.\n */\nexport function forkSessionLink(\n\tlinks: string,\n\tsegments: string,\n\trows: string,\n\tisSnapshot: string,\n\twritten = false,\n): string {\n\tconst before = (alias: string) => (written ? ` AND ${alias}.seq < r.seq` : \"\");\n\tconst segmentBefore = written ? \" AND seg.base_seq < r.seq\" : \"\";\n\tconst own = (column: string) =>\n\t\t`(SELECT p.${column} FROM ${links} AS p WHERE p.session_id = r.session_id AND p.entry_id = r.parent_id AND r.parent_type = 'text'${before(\"p\")} ORDER BY p.seq LIMIT 1)`;\n\tconst ownParent = `EXISTS (SELECT 1 FROM ${links} AS p WHERE p.session_id = r.session_id AND p.entry_id = r.parent_id AND r.parent_type = 'text'${before(\"p\")})`;\n\tconst inherited = (select: string) =>\n\t\t`(SELECT ${select} FROM ${segments} AS seg JOIN ${links} AS up ON up.session_id = seg.source_id AND up.entry_id = r.parent_id AND up.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id AND r.parent_type = 'text'${segmentBefore} ORDER BY seg.base_seq, up.seq LIMIT 1)`;\n\tconst anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, \"r.session_id\", \"up.session_id\", \"up.anchor_seq\")} END`;\n\tconst duplicate = `EXISTS (SELECT 1 FROM ${links} AS other WHERE other.session_id = r.session_id AND other.entry_id = r.entry_id AND other.seq <> r.seq${before(\"other\")}) OR EXISTS (SELECT 1 FROM ${segments} AS seg JOIN ${links} AS other ON other.session_id = seg.source_id AND other.entry_id = r.entry_id AND other.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id${segmentBefore})`;\n\tconst children = written\n\t\t? \"0\"\n\t\t: `CASE WHEN EXISTS (SELECT 1 FROM ${links} AS later WHERE later.session_id = r.session_id AND later.seq > r.seq) THEN (SELECT count(*) FROM ${links} AS c WHERE c.session_id = r.session_id AND c.parent_id = r.entry_id AND c.seq <> r.seq) ELSE 0 END`;\n\treturn `INSERT INTO ${links} (session_id, seq, entry_id, parent_id, anchor_seq, children, broken)\n\t\tSELECT r.session_id, r.seq, r.entry_id, CASE WHEN r.parent_type = 'text' THEN r.parent_id END,\n\t\t\tCASE WHEN ${isSnapshot} THEN r.seq WHEN ${ownParent} THEN ${own(\"anchor_seq\")} ELSE ${inherited(anchor)} END,\n\t\t\t${children},\n\t\t\tCASE WHEN ${duplicate} THEN 1 WHEN r.parent_type IS NULL OR r.parent_type = 'null' THEN 0 WHEN ${ownParent} THEN ${own(\"broken\")} ELSE COALESCE(${inherited(\"up.broken\")}, 1) END\n\t\tFROM ${rows} AS r WHERE EXISTS (SELECT 1 FROM ${segments} AS any_segment WHERE any_segment.session_id = r.session_id)\n\t\tON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq, ${written ? \"\" : \"children = excluded.children, \"}broken = excluded.broken`;\n}\n\n/**\n * The statement that links the rows a materialization just copied into a fork (#6560), one piece of one source at a\n * time, all of them in one statement: each row is linked as its source links it, its anchor taken into the fork's\n * view, and its children counted among the rows the fork now stores. It runs after the piece's rows are inserted and\n * before the fork's segments lose the piece, so they still map the source's seqs. `complete` is the condition that the\n * index's backfill is done: until then the backfill links the rows. Parameters: the fork's id, the shift from the\n * source's seqs to the fork's, the source's id, the first and last seq of the piece in the source, and the fork's id.\n */\nexport function materializedForkLinks(links: string, segments: string, complete: string, int: string): string {\n\tconst anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, \"m.child\", \"up.session_id\", \"up.anchor_seq\")} END`;\n\treturn `INSERT INTO ${links} (session_id, seq, entry_id, parent_id, anchor_seq, children, broken)\n\t\tSELECT m.child, up.seq + m.shift, up.entry_id, up.parent_id, ${anchor}, COALESCE(kids.n, 0), up.broken\n\t\tFROM (SELECT CAST(? AS text) AS child, CAST(? AS ${int}) AS shift) AS m\n\t\tJOIN ${links} AS up ON up.session_id = ? AND up.seq BETWEEN ? AND ?\n\t\tLEFT JOIN (SELECT parent_id, count(*) AS n FROM ${links} WHERE session_id = ? GROUP BY parent_id) AS kids ON kids.parent_id = up.entry_id\n\t\tWHERE ${complete}\n\t\tON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq, children = excluded.children, broken = excluded.broken`;\n}\n\n/** Whether `column(name)`'s row is a snapshot entry, whose snapshot the index records. */\nexport function snapshotEntryCondition(d: StorageDialect, column: (name: string) => string): string {\n\tconst entry = column(\"entry_json\");\n\treturn `${d.contains(entry, `'\"worktree_snapshot\"'`)} AND ${d.jsonText(entry, \"type\")} = 'worktree_snapshot' AND ${d.jsonHasType(\"text\", entry, \"root\")} AND ${d.jsonHasType(\"text\", entry, \"snapshotId\")}`;\n}\n\n/** The columns of one entry as `r` that name its parent once, so a statement parses the entry's JSON for it only once. */\nexport function parentColumns(d: StorageDialect, json: string): string {\n\treturn `${d.jsonText(json, \"parentId\")} AS parent_id, ${d.jsonType(json, \"parentId\")} AS parent_type`;\n}\n\n/**\n * Whether the session entries' index is complete, by its progress row in `sources`: until then their backfill indexes\n * what the triggers and the session store do not.\n */\nexport function entriesIndexComplete(sources: string): string {\n\treturn `(SELECT backfilled_through >= watermark FROM ${sources} WHERE source = 'session-entries')`;\n}\n\n/** The tables {@link forkLinkWrites} reads and writes. */\nexport interface ForkLinkTables {\n\t/** The session entries. */\n\treadonly entries: string;\n\t/** The snapshot index's session links and progress rows. */\n\treadonly sessionLinks: string;\n\treadonly sources: string;\n\treadonly forkSegments: string;\n}\n\n/**\n * The statements with which a session store links the entries a session with fork segments stores (#6560). The\n * released triggers, which every entry runs, link an entry whose parent the session inherits as broken, without an\n * anchor, and an entry below it the same; so the store writes the link over theirs in the transaction that writes the\n * entry, behind it and the entries before it, in seq order. A plain session's writes run none of them. Each waits for\n * the index's backfill, which links what they would.\n */\nexport interface ForkLinkWrites {\n\t/** The link of the entry at `seq` of session `sessionId`, run after the statements that wrote it. */\n\tentry(sessionId: string, seq: number): SqliteStatement;\n\t/** The links of a piece a materialization copied into a fork, in one statement: see {@link materializedForkLinks}. */\n\treadonly materialized: string;\n}\n\nexport function forkLinkWrites(tables: ForkLinkTables, d: StorageDialect): ForkLinkWrites {\n\tconst complete = entriesIndexComplete(tables.sources);\n\tconst rows = `(SELECT session_id, seq, entry_id, entry_json, ${parentColumns(d, \"entry_json\")} FROM ${tables.entries} WHERE session_id = ? AND seq = ? AND ${complete})`;\n\tconst sql = forkSessionLink(\n\t\ttables.sessionLinks,\n\t\ttables.forkSegments,\n\t\trows,\n\t\tsnapshotEntryCondition(d, (name) => `r.${name}`),\n\t\ttrue,\n\t);\n\treturn {\n\t\tentry: (sessionId, seq) => ({ sql, params: [sessionId, seq] }),\n\t\tmaterialized: materializedForkLinks(tables.sessionLinks, tables.forkSegments, complete, d.types.int),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fork-snapshot-index.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/fork-snapshot-index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAM,GAAG,EAAE;IAC5C,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACzD,OAAO,GAAG,OAAO,gBAAgB,CAAC;AACnC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,eAAe,KAAK,aAAa,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BAAoB,CAAC,OAAe;IACnD,OAAO,gDAAgD,OAAO,oCAAoC,CAAC;AACpG,CAAC;AAwBD,MAAM,UAAU,cAAc,CAAC,MAAsB,EAAE,CAAiB;IACvE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,kDAAkD,aAAa,CAAC,CAAC,EAAE,YAAY,CAAC,SAAS,MAAM,CAAC,OAAO,yCAAyC,QAAQ,GAAG,CAAC;IACzK,MAAM,GAAG,GAAG,eAAe,CAC1B,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,YAAY,EACnB,IAAI,EACJ,sBAAsB,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAChD,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3E,CAAC","sourcesContent":["import type { SqliteStatement } from \"../storage/database.js\";\nimport type { StorageDialect } from \"../storage/dialect.js\";\nimport { sessionForkTables } from \"../storage/session/fork-schema.js\";\n\n/**\n * The fork segments of the sessions under `prefix` (#6560): `(session_id, idx, source_id, from_seq, to_seq, base_seq)`,\n * one row per run of a session's view that another session stores. `atomic storage migrate` creates the table when it\n * turns shared-history forks on; until then no session has a segment.\n */\nexport function forkSegmentsTable(prefix = \"\"): string {\n\treturn sessionForkTables(prefix).forkSegments;\n}\n\n/**\n * The trigger that earlier builds of #6560 installed to link each entry a session with fork segments writes. Each\n * INSERT into the session entries table ran it, a plain session's too, so the store now writes those links itself\n * (`forkLinkWrites`, `materializedForkLinks`), and a store's open drops the trigger where it finds it.\n */\nexport function legacyForkLinksTriggerName(entries: string): string {\n\treturn `${entries}_fork_links_v1`;\n}\n\n/** The view seq one past a segment's last, for the segment aliased `alias`. */\nconst segmentEnd = (alias: string) => `${alias}.base_seq + ${alias}.to_seq - ${alias}.from_seq + 1`;\n\n/**\n * The seq of the link that is the parent of entry `r` among the links its session stores, or null: of the links before\n * `r` with the parent's id, the first. `r` has the columns {@link parentColumns} names. A save and a rebuild of the\n * index both link an entry with this lookup, so an entry whose parent is written after it, or whose parent's id more\n * than one entry has, is linked the same by both (#6560).\n */\nexport function ownParentSeq(links: string): string {\n\t// `+seq`: the lookup goes by the entry's id, never in seq order, which SQLite would read row by row.\n\treturn `(SELECT min(+p.seq) FROM ${links} AS p WHERE p.session_id = r.session_id AND p.entry_id = r.parent_id AND r.parent_type = 'text' AND +p.seq < r.seq)`;\n}\n\n/** Whether a link before entry `r` in its session has `r`'s id: such an entry is linked broken, as in a copy. */\nexport function ownDuplicate(links: string): string {\n\treturn `EXISTS (SELECT 1 FROM ${links} AS other WHERE other.session_id = r.session_id AND other.entry_id = r.entry_id AND +other.seq < r.seq)`;\n}\n\n/**\n * The seq in session `child`'s view of the entry at seq `seq` of session `source`'s view, where `source` stores a row\n * `child` inherits. Segments are composed when a fork is made, so a segment's source stores the rows it names itself:\n * `seq` is either a row `source` stores, which a segment of `child` names, or a row `source` inherits, from the source\n * of one of its own segments, which a segment of `child` names by that source. An entry that `child`, or a fork\n * between `source` and `child`, stores itself, such as one a fork edited, is found by its id among the rows of\n * `child`'s view before `bound`, the entry being linked.\n */\nfunction childViewSeq(\n\tlinks: string,\n\tsegments: string,\n\tchild: string,\n\tsource: string,\n\tseq: string,\n\tbound: string,\n): string {\n\tconst inheritedBy = `ss.session_id = ${source} AND ${seq} BETWEEN ss.base_seq + 1 AND ${segmentEnd(\"ss\")}`;\n\tconst stored = `${seq} - ss.base_seq - 1 + ss.from_seq`;\n\tconst entryId = `COALESCE((SELECT a.entry_id FROM ${links} AS a WHERE a.session_id = ${source} AND a.seq = ${seq}), (SELECT a.entry_id FROM ${segments} AS ss JOIN ${links} AS a ON a.session_id = ss.source_id AND a.seq = ${stored} WHERE ${inheritedBy}))`;\n\treturn `COALESCE(\n\t\t(SELECT ${seq} - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs WHERE cs.session_id = ${child} AND cs.source_id = ${source} AND ${seq} BETWEEN cs.from_seq AND cs.to_seq),\n\t\t(SELECT ${stored} - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS ss JOIN ${segments} AS cs ON cs.session_id = ${child} AND cs.source_id = ss.source_id AND ${stored} BETWEEN cs.from_seq AND cs.to_seq WHERE ${inheritedBy}),\n\t\t(SELECT min(+own.seq) FROM ${links} AS own WHERE own.session_id = ${child} AND own.entry_id = ${entryId} AND +own.seq < ${bound}),\n\t\t(SELECT x.seq - cs.from_seq + cs.base_seq + 1 FROM ${segments} AS cs JOIN ${links} AS x ON x.session_id = cs.source_id AND x.entry_id = ${entryId} AND +x.seq BETWEEN cs.from_seq AND cs.to_seq WHERE cs.session_id = ${child} AND cs.base_seq < ${bound} ORDER BY cs.base_seq, x.seq LIMIT 1)\n\t)`;\n}\n\n/**\n * The statement that links one entry of a session with fork segments, as a copy of the session would have it. `rows`\n * yields that entry as `r`, with its parent's id and JSON type as `parent_id` and `parent_type`; `isSnapshot` tells\n * whether `r` is a snapshot entry. It runs after the released link statement of the entry, and writes over that row's\n * anchor and broken mark; the released statements keep the children count.\n *\n * The released link statement finds an entry's parent only among the links the session stores, so it marks an entry\n * whose parent the session inherits broken, without an anchor. This one also finds the parent among the links of the\n * rows the session's segments name, and takes the parent's anchor in the session's view. An entry whose id an entry\n * the session inherits also has is broken, as in a copy.\n *\n * It reads only the rows of the session's view before the entry, the links the session stores and those its segments\n * name, as a copy had when it inserted the entry: a parent written after its child, or an entry of the same id after\n * it, changes nothing. A save runs it as it writes an entry, the index's rebuild as it links a stored row again, and\n * both meet the rows before the entry linked already (`relinkSessionEntries`), so both link every entry the same\n * (#6560).\n *\n * The snapshot references of such an entry stay as the released statements index them: a reference's `prev_seq` that\n * would name an inherited entry is empty. Collection walks a session's references only through the rows the session\n * stores, and keeps every snapshot record a segment names (see `SqlSnapshotBlobStore.sweep`), so it never needs it.\n */\nexport function forkSessionLink(links: string, segments: string, rows: string, isSnapshot: string): string {\n\tconst { anchor, broken } = forkLinkValues(links, segments, isSnapshot);\n\treturn `INSERT INTO ${links} (session_id, seq, entry_id, parent_id, anchor_seq, children, broken)\n\t\tSELECT r.session_id, r.seq, r.entry_id, CASE WHEN r.parent_type = 'text' THEN r.parent_id END, ${anchor}, 0, ${broken}\n\t\tFROM ${rows} AS r WHERE EXISTS (SELECT 1 FROM ${segments} AS any_segment WHERE any_segment.session_id = r.session_id)\n\t\tON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq, broken = excluded.broken`;\n}\n\n/**\n * The anchor and the broken mark of entry `r` as {@link forkSessionLink} links it, from the links before it, its\n * session's and those its segments name: the one function a save, the index's rebuild and the check of a\n * materialization's links ({@link forkLinksCheck}) all compute them with (#6560). For a session without segments it\n * is what the released link statement writes.\n */\nexport function forkLinkValues(\n\tlinks: string,\n\tsegments: string,\n\tisSnapshot: string,\n): { readonly anchor: string; readonly broken: string } {\n\tconst parentSeq = ownParentSeq(links);\n\tconst own = (column: string) =>\n\t\t`(SELECT p.${column} FROM ${links} AS p WHERE p.session_id = r.session_id AND p.seq = ${parentSeq})`;\n\tconst ownParent = `${parentSeq} IS NOT NULL`;\n\tconst inherited = (select: string) =>\n\t\t`(SELECT ${select} FROM ${segments} AS seg JOIN ${links} AS up ON up.session_id = seg.source_id AND up.entry_id = r.parent_id AND +up.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id AND r.parent_type = 'text' AND seg.base_seq < r.seq ORDER BY seg.base_seq, up.seq LIMIT 1)`;\n\tconst anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, \"r.session_id\", \"up.session_id\", \"up.anchor_seq\", \"r.seq\")} END`;\n\tconst duplicate = `${ownDuplicate(links)} OR EXISTS (SELECT 1 FROM ${segments} AS seg JOIN ${links} AS other ON other.session_id = seg.source_id AND other.entry_id = r.entry_id AND +other.seq BETWEEN seg.from_seq AND seg.to_seq WHERE seg.session_id = r.session_id AND seg.base_seq < r.seq)`;\n\treturn {\n\t\tanchor: `CASE WHEN ${isSnapshot} THEN r.seq WHEN ${ownParent} THEN ${own(\"anchor_seq\")} ELSE ${inherited(anchor)} END`,\n\t\tbroken: `CASE WHEN ${duplicate} THEN 1 WHEN r.parent_type IS NULL OR r.parent_type = 'null' THEN 0 WHEN ${ownParent} THEN ${own(\"broken\")} ELSE COALESCE(${inherited(\"up.broken\")}, 1) END`,\n\t};\n}\n\n/**\n * The statement that links the rows a materialization just copied into a fork (#6560), one piece of one source at a\n * time, all of them in one statement: each row is linked as its source links it, its anchor taken into the fork's\n * view, and its children counted among the rows the fork now stores. It runs after the piece's rows are inserted and\n * before the fork's segments lose the piece, so they still map the source's seqs. These links are what\n * {@link forkLinkValues} computes for every history but a few: {@link forkLinksCheck} tells, once the segments lost\n * the pieces, and the fork is linked again row by row where it does not hold. `complete` is the condition that the\n * index's backfill is done: until then the backfill links the rows. Parameters: the fork's id, the shift from the\n * source's seqs to the fork's, the source's id, the first and last seq of the piece in the source, and the fork's id.\n */\nexport function materializedForkLinks(links: string, segments: string, complete: string, int: string): string {\n\tconst anchor = `CASE WHEN up.anchor_seq IS NOT NULL THEN ${childViewSeq(links, segments, \"m.child\", \"up.session_id\", \"up.anchor_seq\", \"up.seq + m.shift\")} END`;\n\treturn `INSERT INTO ${links} (session_id, seq, entry_id, parent_id, anchor_seq, children, broken)\n\t\tSELECT m.child, up.seq + m.shift, up.entry_id, up.parent_id, ${anchor}, COALESCE(kids.n, 0), up.broken\n\t\tFROM (SELECT CAST(? AS text) AS child, CAST(? AS ${int}) AS shift) AS m\n\t\tJOIN ${links} AS up ON up.session_id = ? AND up.seq BETWEEN ? AND ?\n\t\tLEFT JOIN (SELECT parent_id, count(*) AS n FROM ${links} WHERE session_id = ? GROUP BY parent_id) AS kids ON kids.parent_id = up.entry_id\n\t\tWHERE ${complete}\n\t\tON CONFLICT (session_id, seq) DO UPDATE SET anchor_seq = excluded.anchor_seq, children = excluded.children, broken = excluded.broken`;\n}\n\n/**\n * The read that tells whether the links of session `?` from seq `?` on are the ones {@link forkLinkValues} computes,\n * one statement for them all (#6560): `seq`, the first row whose anchor or broken mark is not, or null; `children`,\n * whether a row from that seq on has a child stored before it, whose count {@link materializedForkLinks} and a save\n * may tell apart; and `refs`, whether a snapshot entry's reference names another previous snapshot than its parent's\n * anchor. `rows` yields the session's rows from that seq on as `r`, with their ids, their parents' ids and JSON types\n * (`parent_id`, `parent_type`), bound to the session's id and the seq; `isSnapshot` tells whether `r` is a snapshot\n * entry; `refs` is the snapshot references' table. Nothing is read until the index's backfill is done (`complete`).\n */\nexport function forkLinksCheck(\n\ttables: { readonly links: string; readonly segments: string; readonly refs: string },\n\trows: string,\n\tisSnapshot: string,\n\tcomplete: string,\n): string {\n\tconst { links, segments, refs } = tables;\n\tconst { anchor, broken } = forkLinkValues(links, segments, isSnapshot);\n\tconst parentAnchor = `(SELECT p.anchor_seq FROM ${links} AS p WHERE p.session_id = r.session_id AND p.seq = ${ownParentSeq(links)})`;\n\treturn `SELECT\n\t\t(SELECT min(v.seq) FROM (SELECT r.session_id, r.seq, ${anchor} AS anchor_seq, ${broken} AS broken FROM ${rows} AS r) AS v\n\t\t\tJOIN ${links} AS l ON l.session_id = v.session_id AND l.seq = v.seq\n\t\t\tWHERE COALESCE(l.anchor_seq, -1) <> COALESCE(v.anchor_seq, -1) OR l.broken <> v.broken) AS seq,\n\t\tCASE WHEN EXISTS (SELECT 1 FROM ${links} AS c WHERE c.session_id = ? AND c.parent_id IS NOT NULL AND EXISTS (SELECT 1 FROM ${links} AS q WHERE q.session_id = c.session_id AND q.entry_id = c.parent_id AND +q.seq > c.seq AND +q.seq >= ?)) THEN 1 ELSE 0 END AS children,\n\t\tCASE WHEN EXISTS (SELECT 1 FROM ${rows} AS r JOIN ${refs} AS ref ON ref.session_id = r.session_id AND ref.seq = r.seq WHERE ${isSnapshot} AND COALESCE(ref.prev_seq, -1) <> COALESCE(${parentAnchor}, -1)) THEN 1 ELSE 0 END AS refs\n\tWHERE ${complete}`;\n}\n\n/** Whether `column(name)`'s row is a snapshot entry, whose snapshot the index records. */\nexport function snapshotEntryCondition(d: StorageDialect, column: (name: string) => string): string {\n\tconst entry = column(\"entry_json\");\n\treturn `${d.contains(entry, `'\"worktree_snapshot\"'`)} AND ${d.jsonText(entry, \"type\")} = 'worktree_snapshot' AND ${d.jsonHasType(\"text\", entry, \"root\")} AND ${d.jsonHasType(\"text\", entry, \"snapshotId\")}`;\n}\n\n/** The columns of one entry as `r` that name its parent once, so a statement parses the entry's JSON for it only once. */\nexport function parentColumns(d: StorageDialect, json: string): string {\n\treturn `${d.jsonText(json, \"parentId\")} AS parent_id, ${d.jsonType(json, \"parentId\")} AS parent_type`;\n}\n\n/**\n * Whether the session entries' index is complete, by its progress row in `sources`: until then their backfill indexes\n * what the triggers and the session store do not.\n */\nexport function entriesIndexComplete(sources: string): string {\n\treturn `(SELECT backfilled_through >= watermark FROM ${sources} WHERE source = 'session-entries')`;\n}\n\n/** The tables {@link forkLinkWrites} reads and writes. */\nexport interface ForkLinkTables {\n\t/** The session entries. */\n\treadonly entries: string;\n\t/** The snapshot index's session links and progress rows. */\n\treadonly sessionLinks: string;\n\treadonly sources: string;\n\treadonly forkSegments: string;\n}\n\n/**\n * The statement with which a session store links the entries a session with fork segments stores (#6560). The\n * released triggers, which every entry runs, link an entry whose parent the session inherits as broken, without an\n * anchor, and an entry below it the same; so the store writes the link over theirs in the transaction that writes the\n * entry, behind it and the entries before it, in seq order. A plain session's writes run none of them. It waits for\n * the index's backfill, which links what it would.\n */\nexport interface ForkLinkWrites {\n\t/** The link of the entry at `seq` of session `sessionId`, run after the statements that wrote it. */\n\tentry(sessionId: string, seq: number): SqliteStatement;\n}\n\nexport function forkLinkWrites(tables: ForkLinkTables, d: StorageDialect): ForkLinkWrites {\n\tconst complete = entriesIndexComplete(tables.sources);\n\tconst rows = `(SELECT session_id, seq, entry_id, entry_json, ${parentColumns(d, \"entry_json\")} FROM ${tables.entries} WHERE session_id = ? AND seq = ? AND ${complete})`;\n\tconst sql = forkSessionLink(\n\t\ttables.sessionLinks,\n\t\ttables.forkSegments,\n\t\trows,\n\t\tsnapshotEntryCondition(d, (name) => `r.${name}`),\n\t);\n\treturn { entry: (sessionId, seq) => ({ sql, params: [sessionId, seq] }) };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
2
|
import { SESSION_INDEX_RETIRED_PREFIX } from "./blob-store.js";
|
|
3
|
+
import { forkInheritedBlobGuardName } from "./fork-blob-guard.js";
|
|
3
4
|
// dist/core/worktree-snapshot/session-index-reset.js
|
|
4
5
|
/** Old index rows a single cleanup transaction can release. */
|
|
5
6
|
const SESSION_RESET_BATCH = 1e3;
|
|
@@ -99,7 +100,10 @@ async function detachSessionIndex(tx, t, triggers, available) {
|
|
|
99
100
|
let ok = false;
|
|
100
101
|
try {
|
|
101
102
|
for (const name of triggers) await tx.exec(`DROP TRIGGER IF EXISTS ${name}`);
|
|
103
|
+
const carried = await tx.all("SELECT type, name, tbl_name, sql FROM sqlite_schema WHERE type = 'trigger' AND name = ?", forkInheritedBlobGuardName(t.blobs));
|
|
104
|
+
for (const { name } of carried) await tx.exec(`DROP TRIGGER ${name}`);
|
|
102
105
|
for (const family of TYPES) if (!await detach(tx, t, family, token)) return false;
|
|
106
|
+
for (const { sql } of carried) if (sql !== null) await tx.exec(sql);
|
|
103
107
|
ok = true;
|
|
104
108
|
return true;
|
|
105
109
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-index-reset.code.js","names":[],"sources":["../../../src/core/worktree-snapshot/session-index-reset.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-index-reset.code.js","names":[],"sources":["../../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AAc,OAAO;CACpC;CACA,MAAM,GAAG,IAAI,eAAe,EAAE,QAAO,oBAAqB,EAAE,MAAM;CAClE,OAAO;AACR"}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using worktree snapshots.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using worktree snapshots.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -2,7 +2,7 @@ import "../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
|
2
2
|
import { getServiceTierCost, isModelType } from "@bastani/atomic-ai";
|
|
3
3
|
import { CodemodeSandbox, loadQuickJSWasm, parseCodemodeSource, renderToolSample, toCodemodeIdentifier } from "@bastani/atomic-codemode";
|
|
4
4
|
import { ENV_CODEMODE_MAX_WORKERS, getCodemodeWorkerUrlAsync, getEnvValue, getQuickJSWasmPath } from "../../_shared/p0-cli-BB45ZQY6.js";
|
|
5
|
-
import { combineUsage, formatSize, sliceHead, sliceTail, writeOutputFile } from "../../_shared/startup-0-0-
|
|
5
|
+
import { combineUsage, formatSize, sliceHead, sliceTail, writeOutputFile } from "../../_shared/startup-0-0-EZUKEP4Q.js";
|
|
6
6
|
import { Bm25Ranker, createToolSearchDocument, resolveToolNames } from "../../_shared/startup-0-5-YDW47QX6.js";
|
|
7
7
|
import { CODEMODE_DOCS_PATH, CODEMODE_STORE_ENTRY_TYPE, getCodemodeCallableTools, toCodemodeDeclaration } from "../../_shared/startup-0-3-4ZYBYQNM.js";
|
|
8
8
|
// dist/extensions/codemode/execute.js
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using codemode.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using codemode.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
2
|
import { Container, Text, truncateToWidth } from "@bastani/atomic-tui";
|
|
3
|
-
import { getTextOutput, replaceTabs, str } from "../../_shared/startup-0-0-
|
|
3
|
+
import { getTextOutput, replaceTabs, str } from "../../_shared/startup-0-0-EZUKEP4Q.js";
|
|
4
4
|
import { CodeHighlighter, keyHintIfBound, singleLineDisplayText, terminalDisplayText } from "../../_shared/p2-shell-main-B2WIALFD.js";
|
|
5
5
|
import { TOOL_BLOCK_LIMITS, ToolBlock, ToolBlockGroup, ToolBlockRecords, collapseToolBlockLines } from "../../_shared/startup-0-4-ZMJV547D.js";
|
|
6
|
-
import { builtinToolBlockPresentation, formatToolBlockElapsed } from "../../_shared/startup-8-1-
|
|
6
|
+
import { builtinToolBlockPresentation, formatToolBlockElapsed } from "../../_shared/startup-8-1-LZFXSD3Z.js";
|
|
7
7
|
// dist/extensions/codemode/renderer.js
|
|
8
8
|
const SCRIPT_HEADER = /^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;
|
|
9
9
|
var CodemodeCall = class {
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
9
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11-alpha.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.
|
|
30
|
+
if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using codemode.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|