@bastani/atomic 0.10.11-alpha.1 → 0.10.11-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +7 -7
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +7 -7
- package/dist/_shared/mode-shared-2QJSCUM6.js +7 -7
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-AVFII7NK.js → sdk-IQMULKFU.js} +2438 -470
- package/dist/_shared/sdk-IQMULKFU.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +3 -3
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
- package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
- package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
- package/dist/_shared/{startup-0-0-57KF6LZH.js → startup-0-0-3IXNMFM2.js} +392 -15
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +1 -0
- package/dist/_shared/{startup-0-1-GIY75K46.js → startup-0-1-7T2IAE7J.js} +51 -243
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +1 -0
- package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +225 -7
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
- package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
- package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
- package/dist/_shared/startup-0-4-ZMJV547D.js +6 -6
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-10-0-TDQNBDDL.js +7 -7
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
- package/dist/_shared/startup-15-0-YUKGAC63.js +5 -5
- package/dist/_shared/startup-15-1-4S7FLMNG.js +7 -7
- package/dist/_shared/startup-8-0-34CBHPZH.js +421 -84
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js +77 -13
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -1
- package/dist/_shared/storage-command-7MGXLJGZ.js +7 -5
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +11 -0
- package/dist/builtin/intercom/broker/broker.bundle.mjs +205 -82
- package/dist/builtin/intercom/broker/sql-lease-store.ts +38 -27
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +228 -65
- package/dist/builtin/intercom/broker/sql-schema.ts +82 -27
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- 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 +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +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 +2 -2
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +2 -2
- 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 +2 -2
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/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.code.js +1 -1
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/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 +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- 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 +26 -14
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +3 -3
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-open-markers.js +3 -0
- package/dist/core/session-open-markers.js.map +1 -0
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/storage/added-exports.js +3 -0
- package/dist/core/storage/added-exports.js.map +1 -1
- package/dist/core/storage/database.d.ts +37 -0
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -1
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/migrations.d.ts +12 -3
- package/dist/core/storage/migrations.js +24 -11
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +31 -2
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +86 -2
- 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.js +5 -0
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +82 -4
- package/dist/core/storage/schema-catalog.js +242 -32
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +9 -8
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +4 -4
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/errors.js +1 -1
- package/dist/core/storage/session/expanded-child-details.code.js +3 -3
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-detach.d.ts +118 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-schema.js +53 -0
- package/dist/core/storage/session/fork-schema.js.map +1 -0
- package/dist/core/storage/session/fork-segments.d.ts +58 -0
- package/dist/core/storage/session/fork-staging.code.js +3 -3
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-sweep.js +61 -0
- package/dist/core/storage/session/fork-sweep.js.map +1 -0
- package/dist/core/storage/session/fork-window.code.js +4 -4
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.d.ts +37 -1
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +3 -3
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +4 -4
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +349 -12
- package/dist/core/storage/session/sql-session-store.impl.js +4 -4
- package/dist/core/storage/session/sql-session-store.js +4 -4
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/session/types.d.ts +22 -0
- package/dist/core/storage/sqlite-facade.d.ts +17 -1
- package/dist/core/storage/sqlite-facade.js +33 -0
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +4 -4
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +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.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/history-session.d.ts +2 -0
- package/dist/core/tools/read-url.code.js +2 -2
- 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 +31 -0
- package/dist/core/worktree-snapshot/blob-store.js +164 -49
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +121 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +2 -2
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +1 -1
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +2 -2
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.js +6 -6
- package/dist/main-first-time-setup.code.js +2 -2
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +5 -5
- 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/2.js +1 -0
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/7.js +5 -1
- package/dist/startup-stages/8.js +2 -2
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/guides/postgres-pgbouncer.md +14 -7
- package/docs/guides/postgres-tuning.md +9 -9
- package/docs/sessions.md +9 -0
- package/docs/storage.md +47 -6
- package/package.json +8 -8
- package/dist/_shared/sdk-AVFII7NK.js.map +0 -1
- package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
- package/dist/_shared/startup-0-0-57KF6LZH.js.map +0 -1
- package/dist/_shared/startup-0-1-GIY75K46.js.map +0 -1
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
|
@@ -5,6 +5,7 @@ import { applyStorageMigrations, withShortSchemaLockWaits } from "../storage/mig
|
|
|
5
5
|
import { renderStorageIdentifiers, storageMigrationTable, validateStoragePrefix } from "../storage/prefix.js";
|
|
6
6
|
import { schemaCatalogOf } from "../storage/schema-catalog.js";
|
|
7
7
|
import { statementBatch } from "../storage/statement-batches.js";
|
|
8
|
+
import { entriesIndexComplete, forkSegmentsTable, forkSessionLink, legacyForkLinksTriggerName, parentColumns, snapshotEntryCondition, } from "./fork-snapshot-index.js";
|
|
8
9
|
/**
|
|
9
10
|
* The key under which a failed rename's error carries the trigger or view that stopped it, once confirmed in the
|
|
10
11
|
* database (#5622); `WorkspaceCollectionError` names it in its hint. A `Symbol.for` key, shared without an import.
|
|
@@ -428,10 +429,6 @@ function statusCondition(d, column) {
|
|
|
428
429
|
const payload = column("payload");
|
|
429
430
|
return `${column("type")} IN (${STATUS_EVENTS}) AND ${whenValidJson(d, payload, `${d.jsonHasType("text", payload, "workflowId")} AND ${d.jsonHasType("text", payload, "status")} AND ${d.jsonType(payload, "completedCheckpoints")} IN ('integer', 'real') AND ${d.jsonType(payload, "pendingPrompts")} IN ('integer', 'real')`)}`;
|
|
430
431
|
}
|
|
431
|
-
function snapshotEntryCondition(d, column) {
|
|
432
|
-
const entry = column("entry_json");
|
|
433
|
-
return `${d.contains(entry, `'"worktree_snapshot"'`)} AND ${d.jsonText(entry, "type")} = 'worktree_snapshot' AND ${d.jsonHasType("text", entry, "root")} AND ${d.jsonHasType("text", entry, "snapshotId")}`;
|
|
434
|
-
}
|
|
435
432
|
/**
|
|
436
433
|
* The SQL form of `isDurableWorkflowResumable` for the status payload `payload`, given that the run has a snapshot
|
|
437
434
|
* reference and so at least one checkpoint: a root run keeps its snapshots while it is failed or blocked, or running or
|
|
@@ -499,7 +496,12 @@ function withMarker(trigger, marker) {
|
|
|
499
496
|
const [first, ...rest] = trigger.statements;
|
|
500
497
|
return { ...trigger, statements: [`/* ${marker} */ ${first}`, ...rest] };
|
|
501
498
|
}
|
|
502
|
-
|
|
499
|
+
/**
|
|
500
|
+
* The tables whose rows reference snapshot blobs, and how each is indexed. `forkSegments` names the sessions' fork
|
|
501
|
+
* segments table when it exists (#6560): the backfill of the session entries then also links an entry whose parent
|
|
502
|
+
* the session inherits, as the session store does when it writes one (`forkLinkWrites`).
|
|
503
|
+
*/
|
|
504
|
+
function indexSources(prefix, t, d, forkSegments) {
|
|
503
505
|
const { events, runs } = renderStorageIdentifiers("journal", { events: "events", runs: "runs" }, prefix);
|
|
504
506
|
const { entries } = renderStorageIdentifiers("sessions", { entries: "entries" }, prefix);
|
|
505
507
|
const payload = { column: "r.payload" };
|
|
@@ -582,11 +584,11 @@ function indexSources(prefix, t, d) {
|
|
|
582
584
|
};
|
|
583
585
|
const entryColumns = ["session_id", "seq", "entry_id", "entry_json"];
|
|
584
586
|
/** One entry as `r`, with its parent named once, so that each statement parses the entry's JSON for it only once. */
|
|
585
|
-
const
|
|
586
|
-
const
|
|
587
|
-
const
|
|
588
|
-
const indexComplete = `(SELECT backfilled_through >= watermark FROM ${t.sources} WHERE source = 'session-entries')`;
|
|
587
|
+
const triggerEntry = `(SELECT ${entryColumns.map((name) => `NEW.${name} AS ${name}`).join(", ")}, ${parentColumns(d, "NEW.entry_json")})`;
|
|
588
|
+
const storedEntry = `(SELECT ${entryColumns.join(", ")}, ${parentColumns(d, "entry_json")} FROM ${entries} WHERE ${d.rowOrder()} = ?)`;
|
|
589
|
+
const indexComplete = entriesIndexComplete(t.sources);
|
|
589
590
|
const newRowOrder = d.rowOrder("NEW");
|
|
591
|
+
const forkLink = (rows) => forkSegments === undefined ? [] : [forkSessionLink(t.sessionLinks, forkSegments, rows, isSnapshot)];
|
|
590
592
|
const entriesSource = {
|
|
591
593
|
name: "session-entries",
|
|
592
594
|
table: entries,
|
|
@@ -612,7 +614,7 @@ function indexSources(prefix, t, d) {
|
|
|
612
614
|
]),
|
|
613
615
|
].map((trigger) => withMarker(trigger, ENTRIES_OWN_PROGRESS)),
|
|
614
616
|
backfill: [],
|
|
615
|
-
rowwise: [...sessionLink(storedEntry), ...sessionRecord(storedEntry)],
|
|
617
|
+
rowwise: [...sessionLink(storedEntry), ...forkLink(storedEntry), ...sessionRecord(storedEntry)],
|
|
616
618
|
// The triggers that index degraded pins (#4922). Older builds install theirs under the same names (#5065).
|
|
617
619
|
version: "session-entries@degraded-pins",
|
|
618
620
|
own: ENTRIES_OWN_PROGRESS,
|
|
@@ -793,8 +795,12 @@ async function installSource(transaction, dialect, t, source, reset) {
|
|
|
793
795
|
? []
|
|
794
796
|
: [
|
|
795
797
|
...(source.reset ?? []).map((sql) => ({ sql, params: [] })),
|
|
796
|
-
// Triggers of these names that an older build installed are replaced, not kept (#5065)
|
|
797
|
-
|
|
798
|
+
// Triggers of these names that an older build installed are replaced, not kept (#5065): dropped in one
|
|
799
|
+
// script, as they are created, so a source with more triggers costs a driver no more calls.
|
|
800
|
+
source.triggers.length > 0 &&
|
|
801
|
+
source.triggers
|
|
802
|
+
.map((trigger) => `${dialect.dropTrigger(trigger.name, trigger.table)};`)
|
|
803
|
+
.join("\n"),
|
|
798
804
|
]),
|
|
799
805
|
source.triggers.map((trigger) => dialect.renderTrigger(trigger)).join("\n"),
|
|
800
806
|
{
|
|
@@ -846,9 +852,22 @@ async function installMissingSources(transaction, t, prefix, dialect, reset) {
|
|
|
846
852
|
await installSource(transaction, dialect, t, source, reset);
|
|
847
853
|
}
|
|
848
854
|
}
|
|
849
|
-
/**
|
|
850
|
-
|
|
851
|
-
|
|
855
|
+
/** The names of `sources`' tables and triggers, whose presence `readSourceStates` reads. */
|
|
856
|
+
function sourceObjectNames(sources) {
|
|
857
|
+
return sources.flatMap((source) => [source.table, ...source.triggers.map((trigger) => trigger.name)]);
|
|
858
|
+
}
|
|
859
|
+
/** The read of every source's progress rows. */
|
|
860
|
+
function sourceProgressRead(t) {
|
|
861
|
+
return { sql: `SELECT source, watermark, backfilled_through FROM ${t.sources}`, params: [] };
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Which referencing tables exist, whether each has all its triggers and a source row, and whether its backfill is done.
|
|
865
|
+
* `present`, when given, holds every table and trigger of `sources`, as an open's catalog found them: the objects are
|
|
866
|
+
* not read then (#6560).
|
|
867
|
+
*/
|
|
868
|
+
async function readSourceStates(executor, dialect, t, sources, listRetired = false, present, also) {
|
|
869
|
+
// `also` asks, in the same statement, which of other objects exist, as `also.found` tells.
|
|
870
|
+
const names = [...sourceObjectNames(sources), ...(also?.names ?? [])];
|
|
852
871
|
// Builds before 0.9.88 open SQLite and libSQL databases only, so only there can a trigger of this build's name be
|
|
853
872
|
// one that indexes less.
|
|
854
873
|
const sqlite = dialect.name === "sqlite";
|
|
@@ -865,12 +884,18 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
865
884
|
sql: `SELECT name, ${holds(signatures)} AS signed, ${holds(markers)} AS marked FROM sqlite_schema WHERE name IN (${names.map(() => "?").join(", ")})`,
|
|
866
885
|
params: [...signatures, ...markers].flatMap((check) => [check.trigger, check.text]).concat(names),
|
|
867
886
|
};
|
|
887
|
+
const progressRead = sourceProgressRead(t);
|
|
868
888
|
// Read together: the progress rows do not depend on the objects.
|
|
869
889
|
const [objectRows, progressRows] = await statementBatch(executor, [], [
|
|
870
|
-
() =>
|
|
871
|
-
|
|
890
|
+
() => present === undefined
|
|
891
|
+
? executor.all(objects.sql, ...objects.params)
|
|
892
|
+
: Promise.resolve(names.filter((name) => present.has(name)).map((name) => ({ name }))),
|
|
893
|
+
() => executor.all(progressRead.sql, ...progressRead.params),
|
|
872
894
|
]);
|
|
873
|
-
const
|
|
895
|
+
const found = new Set(objectRows.map((row) => row.name));
|
|
896
|
+
for (const name of also?.names ?? [])
|
|
897
|
+
if (found.has(name))
|
|
898
|
+
also?.found.add(name);
|
|
874
899
|
// Whether each checked trigger's SQL holds this build's text; every other object reads null.
|
|
875
900
|
const checked = (column) => new Map(objectRows
|
|
876
901
|
.filter((row) => row[column] !== null && row[column] !== undefined)
|
|
@@ -889,7 +914,7 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
889
914
|
return [row.source, row];
|
|
890
915
|
}));
|
|
891
916
|
return sources
|
|
892
|
-
.filter((source) =>
|
|
917
|
+
.filter((source) => found.has(source.table))
|
|
893
918
|
.map((source) => {
|
|
894
919
|
const row = progress.get(source.name);
|
|
895
920
|
const version = source.version === undefined ? undefined : progress.get(source.version);
|
|
@@ -903,7 +928,7 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
903
928
|
// Every trigger the source has is this build's. One a build before 0.9.88 installed again after it went
|
|
904
929
|
// missing is not, even when its SQL is the same in every build otherwise (#5558).
|
|
905
930
|
const mine = source.marker !== undefined &&
|
|
906
|
-
source.triggers.every((trigger) => !
|
|
931
|
+
source.triggers.every((trigger) => !found.has(trigger.name) || marked.get(trigger.name) === true);
|
|
907
932
|
let foreign;
|
|
908
933
|
// Whether the backfill is done for this build, besides the source's own progress row.
|
|
909
934
|
let trusted;
|
|
@@ -926,7 +951,7 @@ async function readSourceStates(executor, dialect, t, sources, listRetired = fal
|
|
|
926
951
|
const installed = row !== undefined &&
|
|
927
952
|
!foreign &&
|
|
928
953
|
Number(row.watermark) >= 0 &&
|
|
929
|
-
source.triggers.every((trigger) =>
|
|
954
|
+
source.triggers.every((trigger) => found.has(trigger.name));
|
|
930
955
|
const backfilled = row !== undefined &&
|
|
931
956
|
!foreign &&
|
|
932
957
|
trusted &&
|
|
@@ -953,12 +978,15 @@ export class SqlSnapshotBlobStore {
|
|
|
953
978
|
tables;
|
|
954
979
|
sources;
|
|
955
980
|
dialect;
|
|
981
|
+
/** The sessions' fork segments table (#6560), which exists once shared-history forks are on. */
|
|
982
|
+
forkSegments;
|
|
956
983
|
table;
|
|
957
|
-
constructor(database, dialect, tables, sources) {
|
|
984
|
+
constructor(database, dialect, tables, sources, forkSegments = forkSegmentsTable()) {
|
|
958
985
|
this.database = database;
|
|
959
986
|
this.dialect = dialect;
|
|
960
987
|
this.tables = tables;
|
|
961
988
|
this.sources = sources;
|
|
989
|
+
this.forkSegments = forkSegments;
|
|
962
990
|
this.table = tables.blobs;
|
|
963
991
|
}
|
|
964
992
|
/** Which table this store collects, for telling stores of one database and prefix apart from others. */
|
|
@@ -984,9 +1012,18 @@ export class SqlSnapshotBlobStore {
|
|
|
984
1012
|
...columns.map(([table, column]) => dialect.columnExists(table, column)),
|
|
985
1013
|
dialect.schemaObjects(triggers),
|
|
986
1014
|
];
|
|
1015
|
+
// One catalog read answers the schema questions where an open read it (#6560): always on Postgres, at the first
|
|
1016
|
+
// question on SQLite.
|
|
1017
|
+
const catalog = await schemaCatalogOf(database);
|
|
1018
|
+
// Whether shared-history forks are on (#6560), from that catalog or asked beside the probes.
|
|
1019
|
+
const segments = forkSegmentsTable(prefix);
|
|
1020
|
+
const segmentsProbe = dialect.tableExists(segments);
|
|
1021
|
+
const shared = catalog !== undefined
|
|
1022
|
+
? Promise.resolve(catalog.hasTable(segments))
|
|
1023
|
+
: database.get(segmentsProbe.sql, ...segmentsProbe.params).then((row) => row !== undefined);
|
|
1024
|
+
shared.catch(() => { });
|
|
987
1025
|
// A versioned database checks its ledger whatever the probes find, so it does not ask them. Elsewhere the catalog
|
|
988
|
-
//
|
|
989
|
-
const catalog = dialect.versionedMigrations ? undefined : await schemaCatalogOf(database);
|
|
1026
|
+
// answers them all, in one read instead of a read each.
|
|
990
1027
|
const current = dialect.versionedMigrations
|
|
991
1028
|
? false
|
|
992
1029
|
: catalog !== undefined
|
|
@@ -1028,8 +1065,8 @@ export class SqlSnapshotBlobStore {
|
|
|
1028
1065
|
: []),
|
|
1029
1066
|
], { table: storageMigrationTable(prefix) });
|
|
1030
1067
|
}
|
|
1031
|
-
const store = new SqlSnapshotBlobStore(database, dialect, t, indexSources(prefix, t, dialect));
|
|
1032
|
-
await store.installIndex();
|
|
1068
|
+
const store = new SqlSnapshotBlobStore(database, dialect, t, indexSources(prefix, t, dialect, (await shared) ? segments : undefined), segments);
|
|
1069
|
+
await store.installIndex(undefined, false, await schemaCatalogOf(database));
|
|
1033
1070
|
return store;
|
|
1034
1071
|
}
|
|
1035
1072
|
/** Runs only layout maintenance on the offline command's dedicated, exclusively locked SQLite file connection. */
|
|
@@ -1222,11 +1259,26 @@ export class SqlSnapshotBlobStore {
|
|
|
1222
1259
|
*/
|
|
1223
1260
|
async assertStored(transaction, snapshots) {
|
|
1224
1261
|
const missing = await this.missingBlob(transaction, snapshots);
|
|
1225
|
-
if (missing
|
|
1226
|
-
|
|
1262
|
+
if (missing !== undefined)
|
|
1263
|
+
await this.refuseCollected(missing);
|
|
1264
|
+
}
|
|
1265
|
+
/** The `blobs-collected` {@link WorkspaceSnapshotError} `assertStored` rejects with for `hash`. */
|
|
1266
|
+
async refuseCollected(hash) {
|
|
1227
1267
|
// Loaded only when a write is refused, so the storage entry does not load the workspace error family.
|
|
1228
1268
|
const { WorkspaceSnapshotError } = await import("./errors.code.js").catch((error) => __atomicOnDemandFailed(error, "worktree snapshots"));
|
|
1229
|
-
throw new WorkspaceSnapshotError("blobs-collected",
|
|
1269
|
+
throw new WorkspaceSnapshotError("blobs-collected", hash);
|
|
1270
|
+
}
|
|
1271
|
+
/** The blobs of `snapshots` that `assertStored` checks, each once, in the order it reports the first missing one. */
|
|
1272
|
+
storedHashes(snapshots) {
|
|
1273
|
+
return [...new Set(snapshots.flatMap(wellFormedBlobHashes))];
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* The query `missingBlob` reads, for the blobs named by `source`, an SQL expression of a JSON array of hashes: the
|
|
1277
|
+
* hashes this table holds in full, locked FOR SHARE in hash order. A statement that checks the blobs on the server,
|
|
1278
|
+
* such as the session append function, runs it as it is (#6599).
|
|
1279
|
+
*/
|
|
1280
|
+
storedBlobsQuery(source) {
|
|
1281
|
+
return `SELECT hash FROM ${this.table} AS b WHERE hash IN (SELECT value FROM ${this.dialect.jsonValues(source)}) AND (chunks = 0 OR chunks = (SELECT COUNT(*) FROM ${this.tables.blobChunks} AS c WHERE c.hash = b.hash)) ORDER BY hash${this.dialect.byteOrderCollation}${this.dialect.lockClause("share")}`;
|
|
1230
1282
|
}
|
|
1231
1283
|
/**
|
|
1232
1284
|
* A query that returns a row only while this table holds every blob of `snapshots` in full, for a write planned
|
|
@@ -1246,10 +1298,10 @@ export class SqlSnapshotBlobStore {
|
|
|
1246
1298
|
* rows it finds stay locked FOR SHARE until the transaction ends, taken in hash order as a blob write takes them.
|
|
1247
1299
|
*/
|
|
1248
1300
|
async missingBlob(transaction, snapshots) {
|
|
1249
|
-
const hashes =
|
|
1301
|
+
const hashes = this.storedHashes(snapshots);
|
|
1250
1302
|
if (hashes.length === 0)
|
|
1251
1303
|
return undefined;
|
|
1252
|
-
const rows = await transaction.all(
|
|
1304
|
+
const rows = await transaction.all(this.storedBlobsQuery("?"), JSON.stringify(hashes));
|
|
1253
1305
|
const stored = new Set(rows.map((row) => row.hash));
|
|
1254
1306
|
return hashes.find((hash) => !stored.has(hash));
|
|
1255
1307
|
}
|
|
@@ -1259,14 +1311,27 @@ export class SqlSnapshotBlobStore {
|
|
|
1259
1311
|
* above it, indexed by the triggers. A table that has none yet, an empty one included, costs one watermark of 0.
|
|
1260
1312
|
* Resolves with the state of every referencing table.
|
|
1261
1313
|
*/
|
|
1262
|
-
async installIndex(pace, includeDeferred = false) {
|
|
1263
|
-
|
|
1314
|
+
async installIndex(pace, includeDeferred = false, catalog) {
|
|
1315
|
+
// The fork links trigger earlier builds of #6560 installed, asked for in the same read: dropped where found, in the
|
|
1316
|
+
// first write below, so a database that has it runs it no longer once a store of this build opened it.
|
|
1317
|
+
const legacy = this.legacyForkLinks();
|
|
1318
|
+
const found = new Set();
|
|
1319
|
+
const states = await this.readStates(includeDeferred, catalog, legacy && { names: [legacy.name], found });
|
|
1320
|
+
let drop = legacy !== undefined && found.has(legacy.name) ? legacy : undefined;
|
|
1321
|
+
const dropLegacy = async (transaction) => {
|
|
1322
|
+
if (drop === undefined)
|
|
1323
|
+
return;
|
|
1324
|
+
const { name, table } = drop;
|
|
1325
|
+
await withShortSchemaLockWaits(transaction, this.dialect, () => transaction.exec(this.dialect.dropTrigger(name, table, true)));
|
|
1326
|
+
drop = undefined;
|
|
1327
|
+
};
|
|
1264
1328
|
const missing = states.filter((state) => !state.installed && (includeDeferred || !state.deferred));
|
|
1265
1329
|
for (const { source } of missing) {
|
|
1266
1330
|
const reset = source.name === "session-entries"
|
|
1267
1331
|
? await SqlSnapshotBlobStore.prepareSessionIndexReset(this.database)
|
|
1268
1332
|
: undefined;
|
|
1269
1333
|
await this.write(pace, async (transaction) => {
|
|
1334
|
+
await dropLegacy(transaction);
|
|
1270
1335
|
const [current] = await readSourceStates(transaction, this.dialect, this.tables, [source]);
|
|
1271
1336
|
if (current === undefined || current.installed || (current.deferred && !includeDeferred))
|
|
1272
1337
|
return;
|
|
@@ -1274,9 +1339,37 @@ export class SqlSnapshotBlobStore {
|
|
|
1274
1339
|
await withShortSchemaLockWaits(transaction, this.dialect, () => installSource(transaction, this.dialect, this.tables, source, reset));
|
|
1275
1340
|
});
|
|
1276
1341
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1342
|
+
if (drop !== undefined)
|
|
1343
|
+
await this.write(pace, dropLegacy);
|
|
1344
|
+
return missing.length === 0 ? states : this.readStates(includeDeferred);
|
|
1345
|
+
}
|
|
1346
|
+
/** The fork links trigger earlier builds of #6560 installed on the session entries, and its table. */
|
|
1347
|
+
legacyForkLinks() {
|
|
1348
|
+
const entries = this.sources.find((source) => source.name === "session-entries");
|
|
1349
|
+
return entries && { name: legacyForkLinksTriggerName(entries.table), table: entries.table };
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* The state of every source, read outside a transaction. On PostgreSQL the objects and the progress rows are read in
|
|
1353
|
+
* one read-only transaction whose start carries both, so they cost one round trip, not one each. An open's
|
|
1354
|
+
* `catalog` answers which objects exist only when it found every one: only its positive answers are final, and a
|
|
1355
|
+
* source table it lacks may have been created since (#6560). `also` asks which of other objects exist in the same
|
|
1356
|
+
* read, as `readSourceStates` does.
|
|
1357
|
+
*/
|
|
1358
|
+
readStates(includeDeferred, catalog, also) {
|
|
1359
|
+
if (this.dialect.name !== "postgres")
|
|
1360
|
+
return readSourceStates(this.database, this.dialect, this.tables, this.sources, includeDeferred, undefined, also);
|
|
1361
|
+
const names = sourceObjectNames(this.sources);
|
|
1362
|
+
const present = catalog !== undefined && names.every((name) => catalog.hasObject(name))
|
|
1363
|
+
? new Set([...names, ...(also?.names ?? []).filter((name) => catalog.hasObject(name))])
|
|
1364
|
+
: undefined;
|
|
1365
|
+
return this.database.transaction((transaction) => readSourceStates(transaction, this.dialect, this.tables, this.sources, includeDeferred, present, also), {
|
|
1366
|
+
readOnly: true,
|
|
1367
|
+
retryTransientFailures: true,
|
|
1368
|
+
leading: [
|
|
1369
|
+
...(present === undefined ? [this.dialect.schemaObjects([...names, ...(also?.names ?? [])])] : []),
|
|
1370
|
+
sourceProgressRead(this.tables),
|
|
1371
|
+
],
|
|
1372
|
+
});
|
|
1280
1373
|
}
|
|
1281
1374
|
/**
|
|
1282
1375
|
* Indexes the rows that referencing tables held before their triggers were installed, in transactions of
|
|
@@ -1429,9 +1522,11 @@ export class SqlSnapshotBlobStore {
|
|
|
1429
1522
|
options.signal?.throwIfAborted();
|
|
1430
1523
|
const trigger = `${t.blobs}_chunks_delete_all`;
|
|
1431
1524
|
const required = [trigger, `${t.blobs}_age`, `${t.blobs}_inline_size`];
|
|
1432
|
-
|
|
1525
|
+
// Asked with them: whether forks share their parents' histories, whose inherited snapshots the sweep keeps (#6560).
|
|
1526
|
+
const schema = this.dialect.schemaObjects([...required, this.forkSegments]);
|
|
1433
1527
|
const present = new Set((await this.database.all(schema.sql, ...schema.params)).map((row) => row.name));
|
|
1434
|
-
|
|
1528
|
+
const forks = present.has(this.forkSegments);
|
|
1529
|
+
if (!required.every((name) => present.has(name))) {
|
|
1435
1530
|
options.signal?.throwIfAborted();
|
|
1436
1531
|
await this.write(options.pace, async (transaction) => {
|
|
1437
1532
|
if (options.holder !== undefined)
|
|
@@ -1461,7 +1556,7 @@ export class SqlSnapshotBlobStore {
|
|
|
1461
1556
|
renewedAt = performance.now();
|
|
1462
1557
|
}
|
|
1463
1558
|
const page = await this.page(minimumAge, cursor);
|
|
1464
|
-
const candidates = await this.unretainedOf(page.map((row) => row.hash), sessions, turns);
|
|
1559
|
+
const candidates = await this.unretainedOf(page.map((row) => row.hash), sessions, turns, forks);
|
|
1465
1560
|
let incomplete = false;
|
|
1466
1561
|
for (const batch of sessions.batches(candidates)) {
|
|
1467
1562
|
// Every delete batch starts on a turn of its own and ends with one: never a turn while it holds the write lock.
|
|
@@ -1501,7 +1596,7 @@ export class SqlSnapshotBlobStore {
|
|
|
1501
1596
|
* references one of them and that `sessions` has not walked yet, in statements of at most
|
|
1502
1597
|
* {@link SNAPSHOT_COLLECTION_SESSION_REFS} snapshot entries, with a turn between them.
|
|
1503
1598
|
*/
|
|
1504
|
-
async unretainedOf(hashes, sessions, turns) {
|
|
1599
|
+
async unretainedOf(hashes, sessions, turns, forks) {
|
|
1505
1600
|
if (hashes.length === 0)
|
|
1506
1601
|
return [];
|
|
1507
1602
|
const t = this.tables;
|
|
@@ -1517,7 +1612,7 @@ export class SqlSnapshotBlobStore {
|
|
|
1517
1612
|
sessions.cost(costs);
|
|
1518
1613
|
for (const group of sessionGroups(costs)) {
|
|
1519
1614
|
await turns.next();
|
|
1520
|
-
sessions.retain(group, await this.retainedBySessions(group));
|
|
1615
|
+
sessions.retain(group, await this.retainedBySessions(group, forks));
|
|
1521
1616
|
turns.held();
|
|
1522
1617
|
}
|
|
1523
1618
|
}
|
|
@@ -1537,12 +1632,16 @@ export class SqlSnapshotBlobStore {
|
|
|
1537
1632
|
deleteUnretained(batch, minimumAge, options) {
|
|
1538
1633
|
const t = this.tables;
|
|
1539
1634
|
return this.write(options.pace, async (transaction) => {
|
|
1540
|
-
const
|
|
1635
|
+
const found = new Set();
|
|
1636
|
+
const states = await readSourceStates(transaction, this.dialect, this.tables, this.sources, false, undefined, {
|
|
1637
|
+
names: [this.forkSegments],
|
|
1638
|
+
found,
|
|
1639
|
+
});
|
|
1541
1640
|
if (!states.every((state) => state.installed && state.backfilled))
|
|
1542
1641
|
return undefined;
|
|
1543
1642
|
if (options.holder !== undefined)
|
|
1544
1643
|
await this.renewClaim(transaction, options.holder);
|
|
1545
|
-
const kept = new Set(await this.keptBySessions(transaction, batch));
|
|
1644
|
+
const kept = new Set(await this.keptBySessions(transaction, batch, found.has(this.forkSegments)));
|
|
1546
1645
|
const unretained = batch.hashes.filter((hash) => !kept.has(hash));
|
|
1547
1646
|
if (unretained.length === 0)
|
|
1548
1647
|
return [];
|
|
@@ -1580,32 +1679,48 @@ export class SqlSnapshotBlobStore {
|
|
|
1580
1679
|
* The blobs that the snapshots `sessions` retain reference, in one statement. A session whose tree the index could
|
|
1581
1680
|
* not follow retains every snapshot it records.
|
|
1582
1681
|
*/
|
|
1583
|
-
async retainedBySessions(sessions) {
|
|
1682
|
+
async retainedBySessions(sessions, forks) {
|
|
1584
1683
|
const t = this.tables;
|
|
1585
1684
|
const ids = JSON.stringify(sessions);
|
|
1685
|
+
const inherited = this.inheritedRecord(forks);
|
|
1586
1686
|
const rows = await this.database.all(`SELECT DISTINCT record.hash FROM ${t.sessionRecords} AS record
|
|
1587
1687
|
WHERE record.session_id IN (SELECT value FROM ${this.dialect.jsonValues("?")})
|
|
1588
1688
|
AND (
|
|
1589
1689
|
(record.session_id, record.snapshot_id) IN (${this.sessionHeads(`session_id IN (SELECT value FROM ${this.dialect.jsonValues("?")})`)})
|
|
1590
|
-
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)
|
|
1690
|
+
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)${inherited}
|
|
1591
1691
|
)`, ids, ids);
|
|
1592
1692
|
return rows.map((row) => row.hash);
|
|
1593
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* A condition, after `OR`, that another session inherits the session record `record` through a fork segment
|
|
1696
|
+
* (#6560); empty when `forks` says the fork segments table is not there, as while shared-history forks are off. A
|
|
1697
|
+
* fork that shares its parent's history stores none of the entries it inherits, so its own references never name
|
|
1698
|
+
* their snapshots: a record a segment names is kept whatever its session retains, as long as the segment lasts. A
|
|
1699
|
+
* delete batch reads whether the table exists in its own transaction, so it sees the segments that hold when it
|
|
1700
|
+
* commits.
|
|
1701
|
+
*/
|
|
1702
|
+
inheritedRecord(forks) {
|
|
1703
|
+
if (!forks)
|
|
1704
|
+
return "";
|
|
1705
|
+
return `
|
|
1706
|
+
OR EXISTS (SELECT 1 FROM ${this.forkSegments} AS segment WHERE segment.source_id = record.session_id AND record.seq BETWEEN segment.from_seq AND segment.to_seq)`;
|
|
1707
|
+
}
|
|
1594
1708
|
/**
|
|
1595
1709
|
* The blobs of `batch` that a session records and that the delete must keep, in one statement: those the snapshots
|
|
1596
1710
|
* of `batch.sessions` retain, and those a session not among them records, whose snapshots the sweep did not walk.
|
|
1597
1711
|
* Walks only `batch.sessions`, whose snapshot entries the sweep bounded when it made the batch (#5530).
|
|
1598
1712
|
*/
|
|
1599
|
-
async keptBySessions(executor, batch) {
|
|
1713
|
+
async keptBySessions(executor, batch, forks) {
|
|
1600
1714
|
const t = this.tables;
|
|
1601
1715
|
const ids = JSON.stringify(batch.sessions);
|
|
1602
1716
|
const walked = `(SELECT value FROM ${this.dialect.jsonValues("?")})`;
|
|
1717
|
+
const inherited = this.inheritedRecord(forks);
|
|
1603
1718
|
const rows = await executor.all(`SELECT DISTINCT record.hash FROM ${t.sessionRecords} AS record
|
|
1604
1719
|
WHERE record.hash IN (SELECT value FROM ${this.dialect.jsonValues("?")})
|
|
1605
1720
|
AND (
|
|
1606
1721
|
record.session_id NOT IN ${walked}
|
|
1607
1722
|
OR (record.session_id, record.snapshot_id) IN (${this.sessionHeads(`session_id IN ${walked}`)})
|
|
1608
|
-
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)
|
|
1723
|
+
OR EXISTS (SELECT 1 FROM ${t.sessionLinks} AS broken WHERE broken.session_id = record.session_id AND broken.broken = 1)${inherited}
|
|
1609
1724
|
)`, JSON.stringify(batch.hashes), ids, ids);
|
|
1610
1725
|
return rows.map((row) => row.hash);
|
|
1611
1726
|
}
|
|
@@ -2046,7 +2161,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
2046
2161
|
return (async () => {
|
|
2047
2162
|
const root = new URL("../../", import.meta.url);
|
|
2048
2163
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
2049
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
2164
|
+
const key = `${root.href}#0.10.11-alpha.2`;
|
|
2050
2165
|
let release = releases.get(key);
|
|
2051
2166
|
if (release === undefined) {
|
|
2052
2167
|
const current = (async () => {
|
|
@@ -2074,7 +2189,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
2074
2189
|
} catch {
|
|
2075
2190
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
2076
2191
|
}
|
|
2077
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.
|
|
2192
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
|
|
2078
2193
|
if (updatedTo === undefined) throw error;
|
|
2079
2194
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
2080
2195
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|