@bastani/atomic 0.10.11-alpha.3 → 0.10.11-alpha.4
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 +51 -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 +4 -4
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +4 -4
- package/dist/_shared/mode-shared-2QJSCUM6.js +4 -4
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/p1b-elig-TVB5CBLL.js +22 -6
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +6 -3
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +2 -2
- package/dist/_shared/sdk-B5LEWGGI.js +899 -515
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -1
- 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-EZUKEP4Q.js → startup-0-0-XJJDOIEC.js} +6 -12
- package/dist/_shared/{startup-0-0-EZUKEP4Q.js.map → startup-0-0-XJJDOIEC.js.map} +1 -1
- package/dist/_shared/{startup-0-1-RTOHJFDJ.js → startup-0-1-M6OWAYHH.js} +354 -103
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +18 -9
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +4 -4
- package/dist/_shared/startup-0-4-ZMJV547D.js +4 -4
- package/dist/_shared/startup-0-5-YDW47QX6.js +4 -4
- package/dist/_shared/startup-10-0-TDQNBDDL.js +4 -4
- package/dist/_shared/startup-12-0-55AAXBJZ.js +1 -1
- package/dist/_shared/startup-14-0-MLX36RBG.js +2 -2
- package/dist/_shared/startup-15-0-YUKGAC63.js +2 -2
- package/dist/_shared/startup-15-1-4S7FLMNG.js +4 -4
- package/dist/_shared/startup-8-0-34CBHPZH.js +2114 -235
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +12 -12
- package/dist/_shared/storage-command-7MGXLJGZ.js +6 -6
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +2 -2
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +1 -1
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +19 -0
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1020 -108
- package/dist/builtin/intercom/broker/client.ts +8 -0
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +91 -14
- package/dist/builtin/intercom/broker/multinode-router.ts +102 -17
- package/dist/builtin/intercom/broker/multinode-state-store.ts +41 -2
- package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
- package/dist/builtin/intercom/broker/sql-add-column.ts +22 -1
- package/dist/builtin/intercom/broker/sql-lease-store.ts +304 -48
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +541 -50
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +239 -8
- package/dist/builtin/intercom/broker/sql-retention.ts +11 -2
- package/dist/builtin/intercom/broker/sql-schema.ts +42 -8
- package/dist/builtin/intercom/index.bundle.mjs +13 -2
- 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/skills/skill-creator/eval-viewer/generate_review.py +8 -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 +2 -2
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +1 -1
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +2 -2
- 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 +1 -1
- 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 +1 -1
- 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 +4 -4
- package/dist/core/export-html/index.code.js.map +1 -1
- 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 +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/process-start-token.d.ts +5 -4
- package/dist/core/sdk.code.js +2 -2
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +4 -4
- 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.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/storage/database.d.ts +6 -0
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +7 -6
- package/dist/core/storage/fenced-paths.js +7 -6
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +209 -19
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +435 -71
- 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/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +69 -7
- package/dist/core/storage/schema-catalog.js +352 -61
- 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 +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-detach.d.ts +11 -1
- 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 +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-sweep.js +31 -7
- package/dist/core/storage/session/fork-sweep.js.map +1 -1
- 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-lock.d.ts +100 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +41 -23
- 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 +8 -8
- package/dist/core/storage/session/released-history-files.code.js.map +1 -1
- 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 +9 -1
- 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.d.ts +51 -7
- 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 -0
- package/dist/core/storage/sqlite-facade.js +309 -33
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/sqlite-open-batch.js +10 -0
- package/dist/core/storage/sqlite-open-batch.js.map +1 -0
- 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.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 +3 -3
- 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/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 +5 -3
- package/dist/core/worktree-snapshot/blob-store.js +151 -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-snapshot-index.js +158 -41
- package/dist/core/worktree-snapshot/fork-snapshot-index.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 +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 +1 -1
- 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.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.js +2 -2
- 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/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/package-manager-cli.code.js +4 -4
- 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/3.js +1 -1
- package/dist/startup-stages/5.js +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/docs/changelog.mdx +49 -0
- package/docs/storage/jsonl.md +3 -3
- package/package.json +8 -8
- package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +0 -1
|
@@ -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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
2
|
import { transactionFinisher } from "../added-exports.js";
|
|
3
|
-
import { applySessionSummaryEntries, attachCleanupCause } from "../../../_shared/startup-0-0-
|
|
3
|
+
import { applySessionSummaryEntries, attachCleanupCause } from "../../../_shared/startup-0-0-XJJDOIEC.js";
|
|
4
4
|
import { SessionBlobError, StorageError } from "../errors.js";
|
|
5
5
|
import { fencedPath } from "../fenced-paths.js";
|
|
6
6
|
import { statementBatch } from "../statement-batches.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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
|
-
import { isTombstoned, lockedReferrers } from "../../../_shared/startup-0-2-5QHPCEON.js";
|
|
3
2
|
// dist/core/storage/session/fork-sweep.js
|
|
4
3
|
/**
|
|
5
4
|
* Removing the rows of deleted sessions once no fork reads them (#6560). A session deleted while forks still read its
|
|
@@ -17,10 +16,17 @@ const FORK_SWEEP_BATCH_ENTRIES = 2e3;
|
|
|
17
16
|
const FORK_SWEEP_BATCH_BLOBS = 64;
|
|
18
17
|
/** Tombstones no fork reads any more that a sweep also finishes: ones an earlier sweep left when it stopped. */
|
|
19
18
|
const LEFTOVER_TOMBSTONES = 16;
|
|
19
|
+
/** The statement that checks and locks `sessionId`'s tombstone for update before sweeping its stored rows. */
|
|
20
|
+
function tombstoneLockRead(host, sessionId) {
|
|
21
|
+
return {
|
|
22
|
+
sql: `SELECT session_id FROM ${host.pinTables.tombstones} WHERE session_id = ?${host.lockClause("update")}`,
|
|
23
|
+
params: [sessionId]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
20
26
|
/** One batch of the sweep of `sessionId`: whether the tombstone is gone, still read, or has rows left. */
|
|
21
|
-
async function sweepBatch(host, tx, sessionId, entries) {
|
|
22
|
-
if (
|
|
23
|
-
if ((await
|
|
27
|
+
async function sweepBatch(host, tx, sessionId, entries, tombstoneRead) {
|
|
28
|
+
if (await tx.get(tombstoneRead.sql, ...tombstoneRead.params) === void 0) return "absent";
|
|
29
|
+
if ((await host.forkChildren(tx, sessionId)).some((id) => id !== sessionId)) return "kept";
|
|
24
30
|
const tables = host.pinTables;
|
|
25
31
|
const bound = await tx.get(`SELECT seq FROM ${tables.entries} WHERE session_id = ? ORDER BY seq LIMIT 1 OFFSET ?`, sessionId, entries - 1);
|
|
26
32
|
for (const table of [
|
|
@@ -45,12 +51,30 @@ async function sweepBatch(host, tx, sessionId, entries) {
|
|
|
45
51
|
async function sweepForkTombstones(host, sessionIds = [], options = {}) {
|
|
46
52
|
const entries = Math.max(1, Math.floor(options.batchEntries ?? 2e3));
|
|
47
53
|
const tables = host.pinTables;
|
|
48
|
-
const
|
|
54
|
+
const requested = [...new Set(sessionIds)];
|
|
55
|
+
const candidatesQuery = requested.length === 0 || requested.length > 500 ? {
|
|
56
|
+
sql: `SELECT session_id FROM ${tables.tombstones} t WHERE NOT EXISTS (SELECT 1 FROM ${tables.forkSegments} s WHERE s.source_id = t.session_id) ORDER BY session_id LIMIT ?`,
|
|
57
|
+
params: [LEFTOVER_TOMBSTONES]
|
|
58
|
+
} : {
|
|
59
|
+
sql: `SELECT session_id FROM ${tables.tombstones} WHERE session_id IN (${requested.map(() => "?").join(", ")})
|
|
60
|
+
UNION
|
|
61
|
+
SELECT session_id FROM (
|
|
62
|
+
SELECT session_id FROM ${tables.tombstones} t
|
|
63
|
+
WHERE NOT EXISTS (SELECT 1 FROM ${tables.forkSegments} s WHERE s.source_id = t.session_id)
|
|
64
|
+
ORDER BY session_id LIMIT ?
|
|
65
|
+
) AS leftover
|
|
66
|
+
ORDER BY session_id`,
|
|
67
|
+
params: [...requested, LEFTOVER_TOMBSTONES]
|
|
68
|
+
};
|
|
69
|
+
const found = await (host.forkReadTransaction === void 0 ? host.forkTransaction((tx) => tx.all(candidatesQuery.sql, ...candidatesQuery.params)) : host.forkReadTransaction((tx) => tx.all(candidatesQuery.sql, ...candidatesQuery.params), [candidatesQuery], true));
|
|
70
|
+
const candidates = requested.length > 500 ? /* @__PURE__ */ new Set([...requested, ...found.map((row) => String(row.session_id))]) : new Set(found.map((row) => String(row.session_id)));
|
|
49
71
|
const swept = [];
|
|
50
|
-
for (const sessionId of
|
|
72
|
+
for (const sessionId of candidates) {
|
|
73
|
+
const tombstoneRead = tombstoneLockRead(host, sessionId);
|
|
74
|
+
const runBatch = (body) => host.forkSessionTransaction === void 0 ? host.forkTransaction(body) : host.forkSessionTransaction(sessionId, body, [tombstoneRead]);
|
|
51
75
|
let outcome;
|
|
52
76
|
do
|
|
53
|
-
outcome = await
|
|
77
|
+
outcome = await runBatch((tx) => sweepBatch(host, tx, sessionId, entries, tombstoneRead));
|
|
54
78
|
while (outcome === "more");
|
|
55
79
|
if (outcome === "done") swept.push(sessionId);
|
|
56
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-sweep.js","names":[],"sources":["../../../../src/core/storage/session/fork-sweep.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fork-sweep.js","names":[],"sources":["../../../../src/core/storage/session/fork-sweep.ts"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
|
-
import { VERBATIM_COMPACTION_PREFIX, convertToLlm, legacyCompletionTarget, resolvesCompletionHeader, verbatimRecallHint } from "../../../_shared/startup-0-1-
|
|
2
|
+
import { VERBATIM_COMPACTION_PREFIX, convertToLlm, legacyCompletionTarget, resolvesCompletionHeader, verbatimRecallHint } from "../../../_shared/startup-0-1-M6OWAYHH.js";
|
|
3
3
|
import { buildSessionProjection, getBranchPath } from "../../../_shared/startup-0-3-4ZYBYQNM.js";
|
|
4
4
|
import { branchRanges, completionIdOf, intentForAcknowledgement, isBranchCustomState, isExtensionCustomState, latestCompactionOf } from "../../../_shared/startup-8-0-34CBHPZH.js";
|
|
5
5
|
// dist/core/storage/session/fork-window.js
|
|
@@ -481,7 +481,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
481
481
|
return (async () => {
|
|
482
482
|
const root = new URL("../../../", import.meta.url);
|
|
483
483
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
484
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
484
|
+
const key = `${root.href}#0.10.11-alpha.4`;
|
|
485
485
|
let release = releases.get(key);
|
|
486
486
|
if (release === undefined) {
|
|
487
487
|
const current = (async () => {
|
|
@@ -509,7 +509,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
509
509
|
} catch {
|
|
510
510
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
511
511
|
}
|
|
512
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.
|
|
512
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.4" ? installed : running !== undefined && running.version !== "0.10.11-alpha.4" ? "0.10.11-alpha.4" : undefined;
|
|
513
513
|
if (updatedTo === undefined) throw error;
|
|
514
514
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
515
515
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|
|
@@ -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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type BigIntStats } from "node:fs";
|
|
2
|
+
/**
|
|
3
|
+
* File-system calls used to manage the `<dir>/.session.lock` directory, replaceable so tests can fault
|
|
4
|
+
* directory creation, inspection, timestamp updates, and removal (such as transient Windows `EPERM` errors).
|
|
5
|
+
*/
|
|
6
|
+
export interface SessionLockFs {
|
|
7
|
+
mkdir: typeof import("node:fs").mkdir;
|
|
8
|
+
rmdir: typeof import("node:fs").rmdir;
|
|
9
|
+
stat: typeof import("node:fs").stat;
|
|
10
|
+
utimes: typeof import("node:fs").utimes;
|
|
11
|
+
realpath: typeof import("node:fs").realpath;
|
|
12
|
+
}
|
|
13
|
+
/** An operating-system advisory lock handle held on an open file descriptor until `release()` or process exit. */
|
|
14
|
+
export interface AdvisoryLockHandle {
|
|
15
|
+
release(): void;
|
|
16
|
+
}
|
|
17
|
+
/** Native advisory locking and atomic non-replacing rename bindings from `@bastani/atomic-natives`. */
|
|
18
|
+
export interface NativeSessionLocks {
|
|
19
|
+
tryAdvisoryLockAsync(path: string, waitMs: number): Promise<AdvisoryLockHandle | null>;
|
|
20
|
+
trySharedAdvisoryLockAsync(path: string, waitMs: number): Promise<AdvisoryLockHandle | null>;
|
|
21
|
+
renameNoReplaceAsync(from: string, to: string): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
/** Fixed number of per-session-file stripe lock files kept in a JSONL store directory. */
|
|
24
|
+
export declare const SESSION_LOCK_STRIPE_COUNT = 32;
|
|
25
|
+
/** Formats `path` for native advisory lock and rename calls, using `\\?\` extended-length paths on Windows when long. */
|
|
26
|
+
export declare function nativeLockPath(path: string, platform?: NodeJS.Platform): string;
|
|
27
|
+
/** Removing a lock directory fails with these on Windows while another handle, such as a scanner or indexer, holds it. */
|
|
28
|
+
export declare const TRANSIENT_RELEASE_CODES: Set<string>;
|
|
29
|
+
/** Waits between attempts to take or remove a lock directory, about 1.5 s in all, far inside the 10 s stale window. */
|
|
30
|
+
export declare const LOCK_BACKOFF_MS: number[];
|
|
31
|
+
/** Loads `@bastani/atomic-natives`'s async advisory lock and non-replacing rename bindings, or null if absent. */
|
|
32
|
+
export declare function loadNativeSessionLocks(): NativeSessionLocks | null;
|
|
33
|
+
/** Replaces the native advisory lock bindings for tests: `null` simulates absence, `undefined` reloads the real module. */
|
|
34
|
+
export declare function setNativeSessionLocksForTesting(value: NativeSessionLocks | null | undefined): void;
|
|
35
|
+
/** Deterministic FNV-1a stripe index in `[0, SESSION_LOCK_STRIPE_COUNT)` for a session file basename. */
|
|
36
|
+
export declare function sessionLockStripe(name: string): number;
|
|
37
|
+
/** Distinct stripe indices for `paths`, sorted in strictly ascending order to prevent lock-order cycles. */
|
|
38
|
+
export declare function sortedStripesForPaths(paths: readonly string[]): number[];
|
|
39
|
+
/** Scope of fine-grained locks held inside the mixed-version group lock. */
|
|
40
|
+
export type SessionLockScope = {
|
|
41
|
+
readonly kind: "full";
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "list";
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: "create";
|
|
46
|
+
readonly path: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "files";
|
|
49
|
+
readonly paths: readonly string[];
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "stripes";
|
|
52
|
+
readonly stripes: readonly number[];
|
|
53
|
+
readonly create: boolean;
|
|
54
|
+
};
|
|
55
|
+
/** Internal sentinel thrown when a cached session path resolved to a file outside the currently held stripes. */
|
|
56
|
+
export declare class RelockRequiredError extends Error {
|
|
57
|
+
readonly path: string;
|
|
58
|
+
constructor(path: string);
|
|
59
|
+
}
|
|
60
|
+
export interface HeldGroupLock {
|
|
61
|
+
readonly lockPath: string;
|
|
62
|
+
release(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
export interface HeldFineLocks {
|
|
65
|
+
readonly stripes: ReadonlySet<number>;
|
|
66
|
+
release(): void;
|
|
67
|
+
}
|
|
68
|
+
export declare function removeDirectory(fs: Pick<SessionLockFs, "rmdir">, path: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Removes `path` with Windows transient-error backoff (1 initial attempt + 7 retries).
|
|
71
|
+
* Returns `true` if the directory is gone, `false` if transient Windows errors persisted through all retries.
|
|
72
|
+
*/
|
|
73
|
+
export declare function removeDirectoryWithBackoff(fs: Pick<SessionLockFs, "rmdir">, path: string): Promise<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Clears an abandoned `<dir>/.session.lock` while holding `.gate` and exclusive `.members` (proving zero other
|
|
76
|
+
* new-version members are alive).
|
|
77
|
+
*
|
|
78
|
+
* - Fresh lock matching `.group` (crashed new group or failed Windows `rmdir`): removed immediately without waiting
|
|
79
|
+
* for the 10 s legacy stale window.
|
|
80
|
+
* - Stale lock (old crashed new group or stale legacy lock): atomically moved aside to `.dead`, re-verified against
|
|
81
|
+
* the judged `(generation, mtimeNs)`, and deleted only if unchanged; if a live legacy writer replaced it first,
|
|
82
|
+
* the directory is placed back via `renameNoReplace` and never deleted.
|
|
83
|
+
* - Live legacy lock: left untouched and returns `false`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function clearUnreleasedGroupLock(native: NativeSessionLocks, fs: Pick<SessionLockFs, "rmdir" | "stat">, lockPath: string, dirStats: BigIntStats, signal?: AbortSignal): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Joins the mixed-version group holding `<dir>/.session.lock`, excluding older proper-lockfile writers while
|
|
88
|
+
* allowing concurrent new-version writers to proceed to per-session-file locks.
|
|
89
|
+
*/
|
|
90
|
+
export declare function acquireSessionGroupLock(native: NativeSessionLocks, directory: string, options: {
|
|
91
|
+
readonly lockFs?: SessionLockFs;
|
|
92
|
+
readonly signal?: AbortSignal;
|
|
93
|
+
readonly onCompromised: (cause: Error) => void;
|
|
94
|
+
}): Promise<HeldGroupLock>;
|
|
95
|
+
/**
|
|
96
|
+
* Acquires the fine-grained locks for `scope` in strict global lock order:
|
|
97
|
+
* `.create` (if needed), then target `.stripe.<i>` files in strictly ascending index order.
|
|
98
|
+
*/
|
|
99
|
+
export declare function acquireFineSessionLocks(native: NativeSessionLocks, lockPath: string, scope: SessionLockScope, signal?: AbortSignal): Promise<HeldFineLocks>;
|
|
100
|
+
//# sourceMappingURL=jsonl-session-lock.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SessionEntry } from "../../session-manager-types.ts";
|
|
2
2
|
import { type SessionChatRecords } from "./chat-records.js";
|
|
3
3
|
import type { SessionHistorySource } from "./history-pages.js";
|
|
4
|
+
import { type SessionLockFs } from "./jsonl-session-lock.js";
|
|
4
5
|
import type { ChildDisplayLaunch, ForkArchiveSource, OversizedSessionEntry, SessionBranchPageCut, SessionCompactionPoint, SessionEntriesPage, SessionEntriesQuery, SessionEntryRange, SessionEntrySizes, SessionForkSeed, SessionHistoryPage, SessionListQuery, SessionRecordHeader, SessionResume, SessionSnapshot, SessionSnapshotCut, SessionStore, SessionSummary, SessionTail, SessionWriteOptions, SessionWriteResult, StorageDescriptor } from "./types.js";
|
|
5
6
|
/**
|
|
6
7
|
* The newest sidecar version. A sidecar whose epoch leaves out the creation time is written as version 3, so an older
|
|
@@ -19,17 +20,7 @@ export declare class JsonlStoragePoisonedError extends Error {
|
|
|
19
20
|
readonly rollbackCause: Error;
|
|
20
21
|
constructor(location: string, cause: Error, rollbackCause: Error);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
* The file-system calls the session lock makes, replaceable so a test can fail the ones that only
|
|
24
|
-
* fail on Windows. `rmdir` and `stat` are also what this store uses to clear a lock it could not release.
|
|
25
|
-
*/
|
|
26
|
-
export interface SessionLockFs {
|
|
27
|
-
mkdir: typeof import("node:fs").mkdir;
|
|
28
|
-
rmdir: typeof import("node:fs").rmdir;
|
|
29
|
-
stat: typeof import("node:fs").stat;
|
|
30
|
-
utimes: typeof import("node:fs").utimes;
|
|
31
|
-
realpath: typeof import("node:fs").realpath;
|
|
32
|
-
}
|
|
23
|
+
export type { SessionLockFs } from "./jsonl-session-lock.js";
|
|
33
24
|
/** Internal exact-file input for a fork, not a way to open a live or writable session by ID. */
|
|
34
25
|
export declare const withForkFileWindow: unique symbol;
|
|
35
26
|
/** Used only by the owner of a view opened at an explicit file path, not by ordinary directory listings. */
|
|
@@ -41,21 +32,28 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
41
32
|
/** Operations queued so far, counted so an append joins only a group that is still the last thing queued. */
|
|
42
33
|
private queued;
|
|
43
34
|
private appendGroup;
|
|
35
|
+
private chatAppendGroup;
|
|
44
36
|
private readonly keptFiles;
|
|
37
|
+
/** Paths whose kept handles are currently in use by an in-flight write or sync, so LRU eviction skips them. */
|
|
38
|
+
private readonly pinnedKeptFiles;
|
|
45
39
|
private closed;
|
|
46
40
|
private poisoned;
|
|
47
41
|
private readonly directory;
|
|
48
42
|
private chatStore?;
|
|
49
43
|
get chatRecords(): SessionChatRecords;
|
|
44
|
+
private appendChatRecord;
|
|
45
|
+
private commitChatAppends;
|
|
50
46
|
private readonly fileStates;
|
|
51
47
|
private readonly rangeIndexes;
|
|
52
48
|
private readonly indexes;
|
|
53
49
|
private readonly exactDirectory;
|
|
54
50
|
private readonly lockFs;
|
|
51
|
+
/** Stripes currently held by this store's active locked operation in `heldLockDirectory`, if narrowed. */
|
|
52
|
+
private heldStripes;
|
|
53
|
+
private heldLockDirectory;
|
|
55
54
|
/**
|
|
56
|
-
* Lock directories this store acquired and could not remove
|
|
57
|
-
*
|
|
58
|
-
* then the store removes its own, recognised by that time, rather than waiting out the stale window.
|
|
55
|
+
* Lock directories this store acquired and could not remove (fallback path when native advisory locks are
|
|
56
|
+
* unavailable), by path, with the modification time they had then.
|
|
59
57
|
*/
|
|
60
58
|
private readonly unreleased;
|
|
61
59
|
private constructor();
|
|
@@ -76,8 +74,10 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
76
74
|
/**
|
|
77
75
|
* Appends made while an earlier one waits its turn join it and commit together, as a LevelDB log writer's queue does:
|
|
78
76
|
* under one lock, each is checked against the session as the appends before it leave it, and each file gets one write
|
|
79
|
-
* of all their lines
|
|
80
|
-
*
|
|
77
|
+
* of all their lines and one sync of them, as PostgreSQL's WAL flush covers every commit queued behind it (#6686).
|
|
78
|
+
* Every append is answered once the sync covering its lines has finished and the lock is released, as it was alone,
|
|
79
|
+
* and one that conflicts or fails validation rejects alone. The sync is made under the lock, so a failed one is cut
|
|
80
|
+
* back before any other writer can append after lines a crash may have lost.
|
|
81
81
|
*/
|
|
82
82
|
append(sessionId: string, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<{
|
|
83
83
|
readonly lastSeq: number;
|
|
@@ -87,7 +87,8 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
87
87
|
private stageAppend;
|
|
88
88
|
/**
|
|
89
89
|
* Writes the lines staged for `file` through its kept handle, then decides the appends they came from: false when the
|
|
90
|
-
* write failed and they fail. A failed write is cut off again; when that fails too the store is poisoned
|
|
90
|
+
* write failed and they fail. A failed write or sync is cut off again; when that fails too the store is poisoned,
|
|
91
|
+
* without failing sibling files in the same group that already synced.
|
|
91
92
|
*/
|
|
92
93
|
private writeStaged;
|
|
93
94
|
replace(sessionId: string, header: SessionRecordHeader, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<SessionWriteResult>;
|
|
@@ -147,6 +148,8 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
147
148
|
private windowFromIndex;
|
|
148
149
|
findEntrySeq(sessionId: string, entryId: string): Promise<number | undefined>;
|
|
149
150
|
private indexed;
|
|
151
|
+
private commitIndexed;
|
|
152
|
+
private persistSidecarUnderLock;
|
|
150
153
|
private indexFor;
|
|
151
154
|
private keepIndex;
|
|
152
155
|
private forgetIndex;
|
|
@@ -183,6 +186,8 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
183
186
|
* is used only while the caller holds the directory lock and has found that the path still names that file.
|
|
184
187
|
*/
|
|
185
188
|
private keptFile;
|
|
189
|
+
/** Closes the least recently used unpinned handles until the cache is back within {@link KEPT_FILES}. */
|
|
190
|
+
private trimKeptFiles;
|
|
186
191
|
/** The kept handle of the file at `path`, while it is the file `identity` names, to read through. */
|
|
187
192
|
private keptFor;
|
|
188
193
|
private closeKept;
|
|
@@ -191,14 +196,15 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
191
196
|
private run;
|
|
192
197
|
/** What an operation rejects with for `cause`: the session errors as they are, any other as the store unavailable. */
|
|
193
198
|
private failure;
|
|
199
|
+
private resolveLockScope;
|
|
200
|
+
private assertStripeHeld;
|
|
194
201
|
private exclusive;
|
|
202
|
+
private exclusiveLegacy;
|
|
195
203
|
/**
|
|
196
|
-
* Releases
|
|
197
|
-
* succeeds the work is still done, so the failure is not reported over it: the lock is remembered so this
|
|
198
|
-
* store's next acquire removes it at once, instead of waiting for it to go stale.
|
|
204
|
+
* Releases a fallback proper-lockfile directory lock when native advisory locks are unavailable.
|
|
199
205
|
*/
|
|
200
206
|
private release;
|
|
201
|
-
/** Removes a lock directory this store failed to release, if it still has the time it had then. */
|
|
207
|
+
/** Removes a fallback lock directory this store failed to release, if it still has the time it had then. */
|
|
202
208
|
private clearUnreleased;
|
|
203
209
|
private checkAbort;
|
|
204
210
|
private paths;
|
|
@@ -220,10 +226,22 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
220
226
|
private readSnapshot;
|
|
221
227
|
/**
|
|
222
228
|
* The entries after the header line. A last line without a newline is read when it is a complete record and
|
|
223
|
-
* left out when it is torn;
|
|
224
|
-
* the
|
|
229
|
+
* left out when it is torn; a line containing raw NUL bytes (an unwritten zero-filled page from out-of-order
|
|
230
|
+
* writeback and power loss) ends the readable prefix right before it as a torn tail. `size` and `witness` then
|
|
231
|
+
* end at the last complete line before that tail. Any other malformed complete line is still a parse failure.
|
|
225
232
|
*/
|
|
226
233
|
private readEntries;
|
|
234
|
+
private isDirectoryLockPresent;
|
|
235
|
+
/**
|
|
236
|
+
* Checks that no writer held the lock and the file at `path` still matches `before`.
|
|
237
|
+
* The lock check must run strictly before `stat(path)`: checking `stat(path)` first could match an
|
|
238
|
+
* unsynced write right before a failed sync rolls it back and releases the lock.
|
|
239
|
+
*/
|
|
240
|
+
private unlockedReadValid;
|
|
241
|
+
private readUnlocked;
|
|
242
|
+
private openCandidate;
|
|
243
|
+
private locateOpen;
|
|
244
|
+
private readEntriesFrom;
|
|
227
245
|
private stamp;
|
|
228
246
|
private contentState;
|
|
229
247
|
/**
|
|
@@ -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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
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.4`;
|
|
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.4") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|