@bastani/atomic 0.10.14 → 0.10.15-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 +31 -0
- package/README.md +1 -1
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +3 -3
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
- package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +2 -2
- package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
- package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
- package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
- package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
- package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
- package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
- package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
- package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
- package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
- package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- 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/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/auth-cli.code.js +1 -1
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- 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/compaction/compactor.d.ts +0 -8
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- 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 +2 -2
- 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 +1 -1
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +3 -3
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- 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/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- 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/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 +2 -2
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +2 -2
- 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.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 +2 -2
- 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 +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/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 +2 -2
- 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.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/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 +2 -2
- 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 +2 -2
- 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.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +1 -1
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- 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.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- 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.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +21 -1
- 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/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +2 -2
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/utils/startup-database-spare.code.js +1 -1
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks/reference.md +182 -0
- package/docs/background-tasks.md +98 -405
- package/docs/build.md +67 -27
- package/docs/changelog.mdx +11 -1
- package/docs/codemode.md +108 -39
- package/docs/compaction/branch-summaries.md +54 -0
- package/docs/compaction/custom-compactors.md +161 -0
- package/docs/compaction/memory-compaction.md +77 -0
- package/docs/compaction/reference.md +86 -38
- package/docs/compaction.md +51 -252
- package/docs/computer-use.md +169 -321
- package/docs/containerization.md +71 -57
- package/docs/custom-provider/api-reference.md +119 -25
- package/docs/custom-provider/oauth.md +114 -132
- package/docs/custom-provider/override.md +37 -27
- package/docs/custom-provider/registration.md +107 -83
- package/docs/custom-provider/streaming.md +85 -71
- package/docs/custom-provider.md +85 -52
- package/docs/development.md +39 -29
- package/docs/docs.json +80 -67
- package/docs/environment-variables.md +94 -44
- package/docs/extensions/api-reference.md +86 -43
- package/docs/extensions/authoring.md +162 -154
- package/docs/extensions/events.md +80 -25
- package/docs/extensions/examples.md +90 -85
- package/docs/extensions/ui.md +206 -82
- package/docs/extensions.md +79 -108
- package/docs/getting-started/authentication.md +67 -36
- package/docs/getting-started/first-session.md +53 -43
- package/docs/getting-started/installation.md +117 -90
- package/docs/getting-started/project-instructions.md +48 -34
- package/docs/guides/configuration.md +82 -20
- package/docs/guides/non-interactive.md +66 -24
- package/docs/guides/resume-on-any-machine.md +135 -82
- package/docs/guides/team-setup.md +114 -105
- package/docs/guides.md +76 -32
- package/docs/herdr.md +16 -17
- package/docs/how-atomic-works.md +140 -0
- package/docs/index.md +58 -44
- package/docs/intercom/operations.md +141 -151
- package/docs/intercom/reference.md +85 -108
- package/docs/intercom.md +84 -145
- package/docs/json.md +120 -67
- package/docs/keybindings.md +85 -49
- package/docs/libraries/agent-core.md +137 -275
- package/docs/libraries/ai.md +100 -84
- package/docs/libraries/codemode.md +210 -300
- package/docs/libraries/schema.md +59 -53
- package/docs/libraries/storage-postgres.md +49 -35
- package/docs/libraries/telemetry.md +153 -354
- package/docs/libraries/tui.md +265 -393
- package/docs/libraries.md +42 -26
- package/docs/llama-cpp.md +171 -161
- package/docs/mcp-servers.md +90 -51
- package/docs/models/choose-a-model.md +188 -0
- package/docs/models/reference.md +74 -30
- package/docs/models.md +153 -88
- package/docs/orchestration/migrating-workflows.md +23 -16
- package/docs/orchestration/patterns.md +39 -44
- package/docs/orchestration.md +65 -26
- package/docs/packages/authoring.md +51 -29
- package/docs/packages/reference.md +42 -21
- package/docs/packages.md +69 -58
- package/docs/programmatic.md +118 -24
- package/docs/prompt-templates.md +84 -83
- package/docs/providers/reference.md +43 -48
- package/docs/providers.md +219 -451
- package/docs/quickstart.md +140 -120
- package/docs/reference/cli.md +135 -97
- package/docs/reference.md +20 -19
- package/docs/rpc/examples.md +76 -20
- package/docs/rpc/extension-ui.md +64 -38
- package/docs/rpc/protocol.md +361 -110
- package/docs/rpc.md +57 -17
- package/docs/sdk/reference.md +409 -534
- package/docs/sdk/storage.md +53 -13
- package/docs/sdk/structured-decisions.md +82 -56
- package/docs/sdk/web-server.md +57 -43
- package/docs/sdk.md +106 -84
- package/docs/security.md +42 -64
- package/docs/session-format.md +62 -38
- package/docs/sessions.md +99 -214
- package/docs/settings.md +165 -195
- package/docs/shell-aliases.md +9 -6
- package/docs/skills/authoring.md +69 -48
- package/docs/skills/reference.md +51 -20
- package/docs/skills.md +99 -148
- package/docs/slash-commands.md +129 -0
- package/docs/storage/custom-adapters.md +160 -85
- package/docs/storage/jsonl.md +81 -66
- package/docs/storage/postgres/pgbouncer.md +120 -126
- package/docs/storage/postgres/tuning.md +120 -143
- package/docs/storage/postgres.md +314 -330
- package/docs/storage/sqlite.md +71 -42
- package/docs/storage.md +298 -302
- package/docs/subagents/authoring.md +55 -38
- package/docs/subagents/reference.md +73 -33
- package/docs/subagents.md +119 -187
- package/docs/terminal-setup.md +51 -39
- package/docs/themes/reference.md +23 -19
- package/docs/themes.md +142 -127
- package/docs/tmux.md +47 -55
- package/docs/tools.md +147 -109
- package/docs/tui/reference.md +166 -214
- package/docs/tui.md +196 -341
- package/docs/usage.md +118 -138
- package/docs/verification.md +79 -51
- package/docs/web-access.md +121 -101
- package/docs/windows.md +26 -27
- package/docs/worktree-snapshots/reference.md +245 -0
- package/docs/worktree-snapshots.md +71 -259
- package/package.json +8 -8
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
- package/docs/guides/intercom.md +0 -32
- package/docs/guides/orchestration.md +0 -28
- package/docs/guides/subagents.md +0 -37
- package/docs/termux.md +0 -118
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Custom storage adapters"
|
|
3
3
|
sidebarTitle: "Custom adapters"
|
|
4
|
-
description: "
|
|
4
|
+
description: "Build, package, configure, and test custom SQL or SessionStore storage adapters for Atomic."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A **storage adapter** is a JavaScript or TypeScript module that connects Atomic to a database backend it does not support out of the box. Atomic's own [PostgreSQL](/storage/postgres) support is implemented as an adapter; only local SQLite, JSONL, and in-memory stores are built in.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Choose the adapter hook that fits your database:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
| Backend type | Implement | Capabilities |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| SQLite-compatible (or PostgreSQL-dialect) SQL database | `openDatabase(options, context)` returning `SqliteDatabase` | Full support for sessions, prefixes, snapshots, and multi-node Intercom |
|
|
14
|
+
| Non-SQL or custom document/KV database | `openSessionStore(options, context, { prefix? })` returning `SessionStore` | Sessions only (Intercom multi-node routing requires a SQL `openDatabase` adapter) |
|
|
15
15
|
|
|
16
16
|
## Selecting an adapter
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
An adapter module's default export satisfies `StorageAdapterModule`:
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
21
|
import type { StorageAdapterModule } from "@bastani/atomic/storage";
|
|
@@ -28,33 +28,31 @@ export default {
|
|
|
28
28
|
} satisfies StorageAdapterModule;
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Select an adapter in `sessions.storage` or top-level `storage` in [settings](/settings#sessions), or pass `sessionStore: { kind: "adapter", module, options, secrets, prefix }` in the SDK. Relative module paths resolve from the agent directory (`~/.atomic/agent` by default). Bare package names resolve from user-scope [Atomic packages](#adapters-from-atomic-packages), host extension directories, or the agent directory, never from an embedding application's `node_modules`. Project settings follow the project trust boundary, and adapter code runs with Atomic's privileges.
|
|
34
|
-
|
|
35
|
-
Choose the installation method that matches how you open the adapter:
|
|
31
|
+
Select an adapter in `sessions.storage` or top-level `storage` in [settings](/settings#sessions), or pass `sessionStore: { kind: "adapter", module, options, secrets, prefix }` in the SDK. Relative module paths resolve from the agent directory (`~/.atomic/agent` by default). Bare package names resolve from user-scope [Atomic packages](#adapters-from-atomic-packages), host extension directories, or the agent directory—never from an embedding app's `node_modules`.
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
<Warning>
|
|
34
|
+
Adapter modules execute code with Atomic's full OS privileges. Project-level storage settings follow Atomic's [project trust boundary](/security)—review adapter packages carefully before trusting a project.
|
|
35
|
+
</Warning>
|
|
39
36
|
|
|
40
|
-
|
|
37
|
+
Match installation method to how you open the adapter:
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
- **Direct SDK handles (`{ kind: "database", database }`):** install the adapter in your app with `npm install`, call its opener (such as `openPostgresDatabase()`), and pass the handle to `sessionStore: { kind: "database", database, prefix? }` or `SqlSessionStore.open(database, { prefix? })`. See [SDK session storage](/sdk/storage).
|
|
40
|
+
- **Adapter-resolved selections (`{ kind: "adapter", module }`, `settings.json`, or `ATOMIC_STORAGE`):** install in user scope with `atomic install npm:<package>` (without `-l`), or register a local package directory via `--extension <dir>` or `DefaultResourceLoader({ additionalExtensionPaths })`.
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
<Note>
|
|
43
|
+
**Packaging imports:** Adapters can import `@bastani/atomic/storage` and `@bastani/atomic` directly in both npm installs and standalone binaries—both in the adapter entry file and in any ES module or TypeScript file it imports relatively (`.ts`, `.mjs`, or `.js` under `"type": "module"`). CommonJS files outside the entry file resolve from `node_modules`. Declare `@bastani/atomic` in `peerDependencies`, never `dependencies`.
|
|
44
|
+
</Note>
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
### Options, secrets, and lifecycle
|
|
47
47
|
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- Missing hooks
|
|
51
|
-
- `new StorageProvider().openSessionStore(selection, context)` opens
|
|
52
|
-
- `StorageProvider` instances share one process-wide map of provider-owned databases across matching selections and close each owned database when its last returned store closes. Caller-owned `database` handles passed through `{ kind: "database", database }` are never closed by the provider.
|
|
53
|
-
- If opening storage fails and closing its owned database also fails, Atomic throws the original opening error with a `cleanupCause` field holding the cleanup failure.
|
|
48
|
+
- **`options` and `secrets`:** `options` accepts `string | number | boolean | null`. `secrets` maps secret names to `{ env }`, `{ file }`, or (SDK only) `inMemorySecret(value)` (`{ value }`), overriding same-named keys in `options`. Atomic strips one trailing `\n` or `\r\n` from `{ file }` secrets and leaves other whitespace intact. `inMemorySecret()` serializes as `[redacted]` and is refused outside the SDK (`in-memory-secret-unsupported`).
|
|
49
|
+
- **`context` and `liveSecrets`:** `context` supplies `{ agentDir, domain: "sessions" | "intercom", signal?, secret(name) }`. Adapters that re-read rotating credentials per connection declare `liveSecrets` on `StorageAdapterModule` (for example `liveSecrets: ["password"]`): Atomic omits those names from `options` and expects the adapter to call `await context.secret(name)`, which throws `StorageConfigError` (`secret-missing`) if absent from `secrets`.
|
|
50
|
+
- **Hook priority and errors:** When an adapter exports both `openDatabase` and `openSessionStore`, `openSessionStore` takes priority for `"sessions"` while `openDatabase` handles `"intercom"`. Missing hooks throw `StorageConfigError` (`adapter-domain-unsupported`); module load failures throw `StorageAdapterLoadError`; connection failures throw `StorageUnavailableError`.
|
|
51
|
+
- **Programmatic pooling (`StorageProvider`):** `new StorageProvider().openSessionStore(selection, context)` opens `"memory"`, `"jsonl"`, `"sqlite"`, `"database"`, or `"adapter"` stores programmatically (`loadStorageAdapter(module, context, hostModules)` loads an adapter module directly). `StorageProvider` shares one process-wide map of provider-owned databases across matching selections and closes an owned database when its last returned store closes. Caller-owned handles (`{ kind: "database", database }`) are never closed by the provider. If opening fails and closing an owned database also fails, Atomic throws the opening error with `cleanupCause` set.
|
|
54
52
|
|
|
55
53
|
### Adapters from Atomic packages
|
|
56
54
|
|
|
57
|
-
An [Atomic package](/packages) can bundle
|
|
55
|
+
An [Atomic package](/packages) can bundle adapters and their driver dependencies under `atomic.storageAdapters` in `package.json`:
|
|
58
56
|
|
|
59
57
|
```json
|
|
60
58
|
{
|
|
@@ -65,7 +63,7 @@ An [Atomic package](/packages) can bundle storage adapters and their driver depe
|
|
|
65
63
|
}
|
|
66
64
|
```
|
|
67
65
|
|
|
68
|
-
Install
|
|
66
|
+
Install with `atomic install npm:@example/atomic-mydb` and reference it by package name:
|
|
69
67
|
|
|
70
68
|
```json
|
|
71
69
|
{
|
|
@@ -77,57 +75,79 @@ Install the package with `atomic install npm:@example/atomic-mydb` and select it
|
|
|
77
75
|
}
|
|
78
76
|
```
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
A bare package name selects the first listed adapter. For multi-adapter packages, select `<package>/<file-stem>` (filename without extension, such as `@example/atomic-mydb/mydb-adapter`).
|
|
81
79
|
|
|
82
|
-
Host applications
|
|
80
|
+
Host applications can expose an adapter without installing it globally by passing the package directory via `--extension <dir>` or `DefaultResourceLoader({ additionalExtensionPaths: [packageRoot] })` before opening storage, then referencing `"@example/app"` or `"@example/app/<name>"`.
|
|
83
81
|
|
|
84
|
-
|
|
82
|
+
Resolution order for bare adapter package names:
|
|
85
83
|
|
|
86
84
|
1. Extension package directories passed to the process (or inherited from the launching Atomic process).
|
|
87
|
-
2. Packages in effective global settings (including
|
|
85
|
+
2. Packages in effective global settings (including legacy `~/.pi/agent/settings.json` for the default agent directory). Project packages are never searched.
|
|
88
86
|
3. Module resolution from the agent directory.
|
|
89
87
|
|
|
90
|
-
Child processes
|
|
88
|
+
Child processes launched by Atomic (subagents and the Intercom broker) inherit resolved host adapters automatically without reloading host packages.
|
|
91
89
|
|
|
92
90
|
## Bring your own driver
|
|
93
91
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
92
|
+
Wrap any SQLite-compatible (or PostgreSQL-dialect) driver into a `SqliteDatabase` with `createSqliteDatabase(driver)` from `@bastani/atomic/storage`. Driver hooks may return sync values or promises.
|
|
93
|
+
|
|
94
|
+
### Required `SqliteDriver` hooks
|
|
95
|
+
|
|
96
|
+
| Hook | Signature / behavior |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `descriptor` | `{ adapter: string; location: string }` for diagnostics (`location` is passed through `redact`). |
|
|
99
|
+
| `execute(sql, params)` | Runs one parameterized statement and returns `{ columns, rows, changes }`. Return integers as `bigint` to preserve 64-bit precision. |
|
|
100
|
+
| `executeMultiple(sql)` | Runs zero or more unparameterized SQL statements. |
|
|
101
|
+
| `beginTransaction(options?)` | Starts a transaction and returns `{ execute, executeMultiple, commit, rollback, close? }`. |
|
|
102
|
+
| `close()` | Releases driver connections after accepted work drains. |
|
|
103
|
+
|
|
104
|
+
### Optional resilience, metadata, and concurrency hooks
|
|
105
|
+
|
|
106
|
+
| Hook | Purpose |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `dialect` | `StorageDialect` spoken by the backend (`sqliteDialect` when omitted, or `postgresDialect` from `@bastani/atomic/storage`). |
|
|
109
|
+
| `batch(statements, options?)` | Runs `{ sql, params }[]` atomically in a single write request (`options`: `{ lockWaitMs?, priority? }`). Provide only when the driver sends the whole batch in one round trip. |
|
|
110
|
+
| `redact(text)` | Strips secrets from diagnostic locations and error text. Build one with `redactSecrets(secrets)` to cover raw, URI-encoded, and decoded forms. |
|
|
111
|
+
| `transientFailure(failure)` | Classifies retryable driver errors from structured fields (never message text) into `{ code, outcome: "not-applied" \| "unknown", hop?: { name, failure } }`. Set `outcome: "not-applied"` only when the database could not have changed; set `hop` when an intermediate proxy failed before reaching the server. |
|
|
112
|
+
| `lockBusy(failure)` | Recognizes a `batch()` write-lock contention error that wrote nothing; Atomic retries outside its queue with randomized backoff up to `lockWaitMs`. |
|
|
113
|
+
| `payloadLimits` | `{ value?: number; response?: number }` byte limits reported in `StoragePayloadTooLargeError`. |
|
|
114
|
+
| `notifications` | `StorageNotifications` (`notify`, `listen`, `state`, optional `send`) for push wake-ups such as PostgreSQL `LISTEN`/`NOTIFY`. |
|
|
115
|
+
| `freeBytes()` | Returns writable free bytes on the filesystem holding a local database file, or `undefined`. |
|
|
116
|
+
| `openReader()` | Returns a read-only driver on dedicated connections (`SqliteDatabase.openReader()`). Reads through it wait for that store's own in-flight writes to the same data so read-your-writes holds, and it closes automatically with the main handle. |
|
|
117
|
+
| `takeOpenedCatalog()` | Returns the schema catalog read during initial connection open once (`StorageOpenedCatalog`), skipping duplicate schema queries on store open. |
|
|
118
|
+
| `databaseIdentity()` | Returns a canonical identity string shared only by handles targeting the exact same database and schema (or `undefined` when unknown, such as in memory). |
|
|
119
|
+
| `concurrentTransactions` | Set `true` if each transaction runs on its own connection (as in PostgreSQL) so non-conflicting transactions run in parallel. |
|
|
120
|
+
| `concurrentReads` | Positive integer capping concurrent read-only transactions and read-only statements on drivers with dedicated read connections/streams. |
|
|
121
|
+
| `readsOnly(sql)` | Returns `true` only when a statement run outside a transaction can never write; enables parallel read execution under `concurrentReads` or `concurrentTransactions`. |
|
|
122
|
+
| `pipelinedTransactions` | Set `true` if a transaction connection accepts statements before prior responses arrive, allowing Atomic to pipeline statements and batch final writes with `COMMIT`. |
|
|
123
|
+
|
|
124
|
+
### Transaction options and concurrency scopes
|
|
125
|
+
|
|
126
|
+
When Atomic calls `beginTransaction(options)`, `options` (`SqliteDriverTransactionOptions`) specifies how to lock and pipeline the transaction:
|
|
127
|
+
|
|
128
|
+
- **`concurrency` (`TransactionConcurrency`, always set):**
|
|
129
|
+
- `{ kind: "serial", domain?: string }` (default): runs as the sole writer for the whole database (when `domain` is absent) or for a named scope `domain` (a store passes a prefixed table name so independent domains or prefixes run in parallel on `concurrentTransactions` drivers).
|
|
130
|
+
- `{ kind: "fenced", audit, excludesSerial?: boolean }`: runs under `READ COMMITTED` and locks only the rows the body touches; with `excludesSerial: true`, also excludes whole-database `serial` transactions. SQLite drivers treat both kinds as `BEGIN IMMEDIATE`.
|
|
131
|
+
- **`readOnly`:** Opens a consistent read snapshot without taking a write lock. On `concurrentTransactions` drivers, a read-only transaction resolves once its reads finish and commits in the background (`close()` awaits it).
|
|
132
|
+
- **`lockWaitMs`:** Per-transaction lock wait override.
|
|
133
|
+
- **`relaxedDurability`:** When `true` (never set on read-only transactions), the write is repeatable and losing it in a server crash is harmless (such as a lease heartbeat), so the driver may acknowledge commit before flushing to disk (for example `synchronous_commit = off` on PostgreSQL).
|
|
134
|
+
- **Pipelining hints (`leading`, `leadingOnly`, `onCommit`, `lockIfLeadingFinds`):** On `pipelinedTransactions` drivers, Atomic may supply initial statements in `leading` to send alongside `BEGIN` (or commit immediately behind them when `leadingOnly: true`, calling `onCommit?.()` right before writing `COMMIT` so any later connection drop keeps `outcome: "unknown"`). `lockIfLeadingFinds` lets a `serial` domain transaction acquire locks in its first leading read only if a row matches. If any pipelined statement fails, `commit()` must fail so nothing commits.
|
|
135
|
+
|
|
136
|
+
### Facade guarantees, retries, and queue bounds
|
|
137
|
+
|
|
138
|
+
`createSqliteDatabase` automatically copies `Uint8Array` bindings on call, rejects NUL (`U+0000`) strings with `StorageInvalidTextError`, converts safe-range integers to `number`, expires transaction handles once settled, wraps unclassified driver errors in `StorageUnavailableError` (redacted), and rejects failed rollbacks with `StorageRollbackError`.
|
|
139
|
+
|
|
140
|
+
- **Transient retries:** Recognized transient failures reject with `StorageTransientError`. Statements and batches that failed before writing make up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` (**5**) total attempts—1 initial attempt plus up to 4 retries—starting at 250 ms with exponential backoff and up to 20% jitter. Writes with `outcome: "unknown"` never retry automatically.
|
|
141
|
+
- **Transaction retries:** Transactions re-run their callback only when called with `{ retryTransientFailures: true }` (use only for side-effect-free callbacks; non-boolean values throw `StorageConfigError`). The first retry on a database emits a one-time process warning.
|
|
142
|
+
- **Call queue scheduling:** Without `concurrentTransactions`, calls execute one at a time. With `concurrentTransactions`, a call waits only for earlier unfinished calls it conflicts with: standalone statements/batches and whole-database `serial` transactions (no `domain`) conflict with all calls; `serial` transactions with a `domain` conflict only with matching domains (and whole-database calls); read-only transactions wait for earlier writes but run in parallel with other reads and later writes.
|
|
143
|
+
- **Stuck-call bounds:** While an active call stalls without settling, queued priority batches (`{ priority: true }`) fail after `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` (10 seconds) and ordinary queued calls fail after `STORAGE_QUEUED_CALL_MAX_WAIT_MS` (60 seconds), both with `StorageUnavailableError` (with `concurrentTransactions`, only calls blocked behind the stalled call fail).
|
|
144
|
+
- **WAL helper for local SQLite files:** Call `switchToWriteAheadLog(exec, busyTimeoutMs)` from `@bastani/atomic/storage` to enable WAL with retries on `SQLITE_BUSY` and Windows `SQLITE_IOERR_TRUNCATE` (up to `min(5000, busyTimeoutMs)` ms).
|
|
145
|
+
|
|
146
|
+
You can also implement `SqliteDatabase` directly. Either way, validate your implementation with the [conformance suite](#adapter-conformance).
|
|
127
147
|
|
|
128
148
|
### Custom driver adapter example
|
|
129
149
|
|
|
130
|
-
This example wraps
|
|
150
|
+
This complete example wraps Node.js's built-in `node:sqlite` driver to show how `createSqliteDatabase` and `StorageAdapterModule` fit together. Save as `custom-adapter.ts`:
|
|
131
151
|
|
|
132
152
|
```typescript
|
|
133
153
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -192,7 +212,7 @@ export default {
|
|
|
192
212
|
} satisfies StorageAdapterModule;
|
|
193
213
|
```
|
|
194
214
|
|
|
195
|
-
|
|
215
|
+
Use it through settings as an [adapter](#selecting-an-adapter), or pass a caller-owned handle directly in the SDK:
|
|
196
216
|
|
|
197
217
|
```typescript
|
|
198
218
|
import { createAgentSession } from "@bastani/atomic";
|
|
@@ -213,22 +233,77 @@ Multiple stores can share one caller-owned `database` without closing it.
|
|
|
213
233
|
|
|
214
234
|
### Custom `SessionStore` contracts
|
|
215
235
|
|
|
216
|
-
Non-SQL backends
|
|
236
|
+
Non-SQL backends implement `openSessionStore` returning a `SessionStore` (imported from `@bastani/atomic/storage`). Required methods are `create`, `append`, `replace`, `load`, `readHeader`, `delete`, `list`, `findMostRecent`, and `close`.
|
|
237
|
+
|
|
238
|
+
#### Required for `history://` reads
|
|
217
239
|
|
|
218
|
-
|
|
219
|
-
- **Optional fast-path methods.** Implementing these avoids loading entire sessions into memory (stores implementing only `load()` still work with higher memory use):
|
|
240
|
+
Implement `readEntryRange` to power `history://` reads and search without loading entire sessions into memory:
|
|
220
241
|
|
|
221
|
-
|
|
242
|
+
```typescript
|
|
243
|
+
import type {
|
|
244
|
+
SessionEntriesPage,
|
|
245
|
+
SessionEntriesQuery,
|
|
246
|
+
SessionStore,
|
|
247
|
+
} from "@bastani/atomic/storage";
|
|
248
|
+
|
|
249
|
+
// Query and response shapes:
|
|
250
|
+
// SessionEntriesQuery: {
|
|
251
|
+
// fromSeq: number;
|
|
252
|
+
// toSeq: number;
|
|
253
|
+
// seqs?: readonly number[]; // specific ascending sequence numbers to return in one call
|
|
254
|
+
// maxChars?: number; // stop page before exceeding this character budget (unless first entry)
|
|
255
|
+
// largeEntryBytes?: number; // byte threshold for streaming rawChunks on oversized entries
|
|
256
|
+
// skipTypes?: readonly string[]; // entry types to omit from the page
|
|
257
|
+
// signal?: AbortSignal;
|
|
258
|
+
// }
|
|
259
|
+
// SessionEntriesPage: {
|
|
260
|
+
// lastSeq: number;
|
|
261
|
+
// throughSeq: number;
|
|
262
|
+
// entries: readonly { seq: number; entry: SessionEntry; rawChunks?: readonly Uint8Array[]; rawFormatVersion?: number }[];
|
|
263
|
+
// }
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
When `query.seqs` is provided, return only entries at those sequence numbers so `history://` search fetches matches and surrounding context in a single call (returning the whole `[fromSeq, toSeq]` range remains valid but reads more). Return freshly owned UTF-8 buffers for `rawChunks` rather than falling back to whole-session `load()`.
|
|
267
|
+
|
|
268
|
+
#### Optional capability hooks
|
|
269
|
+
|
|
270
|
+
| Hook / property | Purpose |
|
|
222
271
|
| --- | --- |
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
272
|
+
| `putBlob(sessionId, data)` / `getBlob(sessionId, hash)` | Store and retrieve SHA-256 content-addressed tool output files (`tool-output://`); omitted stores throw `SessionBlobError` (`blobs-unsupported`). |
|
|
273
|
+
| `snapshotBlobs` (`SnapshotBlobStore`) | Content-addressed storage for [worktree snapshots](/worktree-snapshots); omit to disable snapshots. |
|
|
274
|
+
| `openMarkers` (`SessionOpenMarkerStore`) | Cross-host open-session tracking (`put`, `remove`, `list`) for delete protection and upgrade gating; falls back to local agent-dir files when omitted. |
|
|
275
|
+
| `chatRecords` | Reader-only chat metadata (such as subagent child records) stored outside the conversation tree. |
|
|
276
|
+
| `searchIndex` (`SessionSearchIndex`) | Indexed full-text search backing `history://` queries. |
|
|
277
|
+
| `createFork(header, entries, source, location?)` | Optimized or receipt-preserving fork creation (return `undefined` to fall back to standard copying). |
|
|
278
|
+
| `updateHeader(header, options)` | Update session header metadata in place (rotates `epoch`) without rewriting entries. |
|
|
279
|
+
| `releaseSession(sessionId)` | Advisory hint that no live handle holds the session, allowing in-memory stores to spill history to disk until reopened. |
|
|
280
|
+
|
|
281
|
+
#### Optional fast-path read hooks
|
|
229
282
|
|
|
230
|
-
|
|
231
|
-
|
|
283
|
+
Stores implementing only `load()` still work, but implementing these methods avoids loading full session history into RAM:
|
|
284
|
+
|
|
285
|
+
| Method signature | Purpose |
|
|
286
|
+
| --- | --- |
|
|
287
|
+
| `readTail(sessionId, fromSeq): Promise<SessionTail>` | Header and entries from `fromSeq`, plus prior live state and omitted usage totals. |
|
|
288
|
+
| `readRange(sessionId, startSeq, endSeq, expectedEpoch?): Promise<SessionEntryRange>` | Inclusive 1-based entry range returning `entries`, `seqs`, `lastSeq`, and `epoch`. |
|
|
289
|
+
| `findLatestCompaction(sessionId, leafId?): Promise<SessionCompactionPoint \| undefined>` | Latest active compaction boundary, its sequence, and retained tail start sequence. |
|
|
290
|
+
| `readResume(sessionId, leafId?, options?): Promise<SessionResume>` | Single-call resume snapshot: header, active branch from compaction, live state, omitted totals, `recovery` (`SessionRecoveryState` carrying `admissionDigests`, `intercomDeliveredIds`, and optional `deliveryOpIds` for deduplicating replayed deliveries), `lastSeq`, `lastEntryId`, `leafId`, and `epoch`. |
|
|
291
|
+
| `readResumeAt(sessionId, leafId, throughSeq, options?): Promise<SessionResume>` | Resume snapshot bounded to a specific historical watermark (`throughSeq`). |
|
|
292
|
+
| `findEntrySeq(sessionId, entryId): Promise<number \| undefined>` | 1-based sequence number for an entry ID, or `undefined`. |
|
|
293
|
+
| `readEntrySizes(sessionId, startSeq, endSeq, limit?): Promise<SessionEntrySizes>` | Entry byte sizes for sizing paged history reads before decoding payloads. |
|
|
294
|
+
| `readEntryChunk(reference, offset, bytes?): Promise<Uint8Array>` | Stream raw UTF-8 bytes of an `OversizedSessionEntry` in chunks (rejects stale `epoch`). |
|
|
295
|
+
| `readScanPage(sessionId, startSeq, endSeq, epoch, limit, options?): Promise<SessionScanPage>` | Single-read byte-bounded forward scan page (with header, `epoch`, `lastSeq`, `throughSeq`, and optional oversized references) used by exports and remote readers. |
|
|
296
|
+
| `readTreeOutline(sessionId, fromSeq, toSeq, epoch?)` | Body-free tree structure metadata for `/tree` navigation without reading message content. |
|
|
297
|
+
| `readBranchSpan(sessionId, cut)` | Contiguous range on a single branch without reading sibling branches. |
|
|
298
|
+
| `readSnapshotCut(sessionId, options?)` | Index lookup locating `worktree_snapshot` entries without scanning bodies. |
|
|
299
|
+
| `readSelectedPage(sessionId, seqs, epoch, options?)` | Byte-bounded page of specific ascending sequences (forward or backward). |
|
|
300
|
+
| `readForkWindow(sessionId, entryId, options?)` | Active branch window and labels needed to fork from a specific entry. |
|
|
301
|
+
|
|
302
|
+
#### Epochs, read-only stores, and forks
|
|
303
|
+
|
|
304
|
+
- **Epochs:** Keep `epoch` constant across `append()` calls, rotate it on `replace()`, `updateHeader()`, or recreation, and reject writes with a mismatched `epoch` using `SessionConflictError`.
|
|
305
|
+
- **Read-only and estimated summaries:** Mark read-only stores so cleanup writes are skipped, and set `estimated: true` on `SessionSummary` when metadata is unindexed.
|
|
306
|
+
- **Forks and cloning:** `/fork`, `/clone`, and `SessionManager.forkFrom()` stream entries in pages (same-store forks copy all branches; cross-store forks copy active context and set `parentInOtherStore: true`; see [`/tree`, `/fork`, and `/clone`](/sessions#tree-fork-and-clone)).
|
|
232
307
|
|
|
233
308
|
## Adapter conformance
|
|
234
309
|
|
|
@@ -245,11 +320,11 @@ registerSqliteDatabaseConformance({ describe, it }, "my adapter", withSubject);
|
|
|
245
320
|
registerSqliteConnectionConformance({ describe, it }, "my adapter connections", withConnections);
|
|
246
321
|
```
|
|
247
322
|
|
|
248
|
-
- `withSubject` creates a fresh database per test
|
|
249
|
-
- `withConnections` (for adapters
|
|
323
|
+
- `withSubject` creates a fresh database per test and passes `{ database, reopen, withRollbackFailure }` to the callback, cleaning up afterward (`reopen()` closes and reopens the persistent database; `withRollbackFailure(error, callback)` injects a rollback failure). Verifies parameter binding, 64-bit integer precision, binary snapshots, NUL rejection, transaction ordering/expiration, commit/rollback errors, reopen persistence, and close semantics.
|
|
324
|
+
- `withConnections` (for multi-connection adapters) opens two handles on one fresh database and closes both afterward. Verifies concurrent write queuing and event-loop responsiveness.
|
|
250
325
|
|
|
251
|
-
Helper utilities exported from `@bastani/atomic/storage
|
|
326
|
+
Helper utilities exported from `@bastani/atomic/storage`:
|
|
252
327
|
|
|
253
|
-
- `validateStoragePrefix(prefix, dialect?)
|
|
254
|
-
- `renderStorageIdentifiers("sessions", names, prefix)
|
|
255
|
-
- `assertStorageSchemaVersion(domain, found, supported)
|
|
328
|
+
- `validateStoragePrefix(prefix, dialect?)`: validates optional table prefixes (ASCII letters, digits, `_`; cannot start with `sqlite_`, case-insensitively). Passing `"postgres"` also enforces lowercase and `POSTGRES_MAX_STORAGE_PREFIX_LENGTH` (24).
|
|
329
|
+
- `renderStorageIdentifiers("sessions", names, prefix)`: returns a frozen map of table names with the `session_` prefix applied.
|
|
330
|
+
- `assertStorageSchemaVersion(domain, found, supported)`: throws `StorageSchemaVersionError` when stored and supported versions mismatch.
|