@effect-agent/storage-sqlite 0.1.0-beta.9 → 0.1.0-beta.90

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.
Files changed (61) hide show
  1. package/dist/SqliteActivityStore.d.mts +14 -0
  2. package/dist/SqliteActivityStore.mjs +310 -0
  3. package/dist/SqliteActivityStore.mjs.map +1 -0
  4. package/dist/SqliteMessageDeliveryStore.d.mts +14 -0
  5. package/dist/SqliteMessageDeliveryStore.mjs +24 -0
  6. package/dist/SqliteMessageDeliveryStore.mjs.map +1 -0
  7. package/dist/SqliteScheduleStore.d.mts +14 -0
  8. package/dist/SqliteScheduleStore.mjs +255 -0
  9. package/dist/SqliteScheduleStore.mjs.map +1 -0
  10. package/dist/SqliteStorageConfig.d.mts +34 -0
  11. package/dist/SqliteStorageConfig.mjs +39 -0
  12. package/dist/SqliteStorageConfig.mjs.map +1 -0
  13. package/dist/SqliteStorageError-DVWeaWLm.d.mts +86 -0
  14. package/dist/SqliteStorageError.d.mts +2 -0
  15. package/dist/SqliteStorageError.mjs +150 -0
  16. package/dist/SqliteStorageError.mjs.map +1 -0
  17. package/dist/SqliteStorageFailpoint.d.mts +17 -0
  18. package/dist/SqliteStorageFailpoint.mjs +14 -0
  19. package/dist/SqliteStorageFailpoint.mjs.map +1 -0
  20. package/dist/SqliteStorageFailpointTesting.d.mts +15 -0
  21. package/dist/SqliteStorageFailpointTesting.mjs +19 -0
  22. package/dist/SqliteStorageFailpointTesting.mjs.map +1 -0
  23. package/dist/SqliteStorageVersion-BqmqX0CI.d.mts +11 -0
  24. package/dist/SqliteStorageVersion.d.mts +2 -0
  25. package/dist/SqliteStorageVersion.mjs +8 -0
  26. package/dist/SqliteStorageVersion.mjs.map +1 -0
  27. package/dist/SqliteSubmissionLedger.d.mts +23 -0
  28. package/dist/SqliteSubmissionLedger.mjs +1788 -0
  29. package/dist/SqliteSubmissionLedger.mjs.map +1 -0
  30. package/dist/SqliteSubscriptionStore.d.mts +13 -0
  31. package/dist/SqliteSubscriptionStore.mjs +28 -0
  32. package/dist/SqliteSubscriptionStore.mjs.map +1 -0
  33. package/dist/SqliteThreadStore.d.mts +49 -0
  34. package/dist/SqliteThreadStore.mjs +460 -0
  35. package/dist/SqliteThreadStore.mjs.map +1 -0
  36. package/dist/index.d.mts +11 -193
  37. package/dist/index.mjs +11 -3082
  38. package/dist/migrations-Dy5v0HGe.mjs +346 -0
  39. package/dist/migrations-Dy5v0HGe.mjs.map +1 -0
  40. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  41. package/dist/sqlite-journal-CBOQDySe.mjs +998 -0
  42. package/dist/sqlite-journal-CBOQDySe.mjs.map +1 -0
  43. package/package.json +1 -41
  44. package/src/SqliteActivityStore.ts +556 -0
  45. package/src/SqliteMessageDeliveryStore.ts +42 -0
  46. package/src/SqliteScheduleStore.ts +404 -0
  47. package/src/{sqlite-storage-config.ts → SqliteStorageConfig.ts} +1 -1
  48. package/src/{errors.ts → SqliteStorageError.ts} +10 -3
  49. package/src/SqliteStorageFailpoint.ts +23 -0
  50. package/src/{sqlite-storage-failpoint.ts → SqliteStorageFailpointTesting.ts} +7 -18
  51. package/src/SqliteStorageVersion.ts +2 -0
  52. package/src/{sqlite-ledger.ts → SqliteSubmissionLedger.ts} +912 -212
  53. package/src/SqliteSubscriptionStore.ts +55 -0
  54. package/src/SqliteThreadStore.ts +999 -0
  55. package/src/index.ts +10 -6
  56. package/src/internal/message-delivery-schema.ts +24 -0
  57. package/src/{migrations.ts → internal/migrations.ts} +156 -79
  58. package/src/internal/recovery-checkpoint-schema.ts +17 -0
  59. package/src/{sqlite-journal.ts → internal/sqlite-journal.ts} +751 -241
  60. package/dist/index.mjs.map +0 -1
  61. package/src/sqlite-conversation-store.ts +0 -841
package/dist/index.d.mts CHANGED
@@ -1,193 +1,11 @@
1
- import { ConversationStore, ConversationStoreError, SubmissionLedger } from "@effect-agent/session";
2
- import { Context, Crypto, Effect, Layer, Schema } from "effect";
3
- import { SqliteMigrator } from "@effect/sql-sqlite-node";
4
- import * as SqlClientService from "effect/unstable/sql/SqlClient";
5
- //#region src/errors.d.ts
6
- declare const SqliteStorageCompatibilityError_base: Schema.Class<SqliteStorageCompatibilityError, Schema.TaggedStruct<"SqliteStorageCompatibilityError", {
7
- readonly actualVersion: Schema.Int;
8
- readonly message: Schema.String;
9
- readonly supportedVersion: Schema.Int;
10
- }>, import("effect/Cause").YieldableError>;
11
- /** The SQLite file uses a private-development format this adapter cannot read. */
12
- declare class SqliteStorageCompatibilityError extends SqliteStorageCompatibilityError_base {}
13
- declare const SqliteStorageCorruptionError_base: Schema.Class<SqliteStorageCorruptionError, Schema.TaggedStruct<"SqliteStorageCorruptionError", {
14
- readonly message: Schema.String;
15
- readonly rowKey: Schema.String;
16
- readonly table: Schema.String;
17
- }>, import("effect/Cause").YieldableError>;
18
- /** Stored bytes failed the current Schema and cannot be used as recovery truth. */
19
- declare class SqliteStorageCorruptionError extends SqliteStorageCorruptionError_base {}
20
- declare const SqliteStorageError_base: Schema.Class<SqliteStorageError, Schema.TaggedStruct<"SqliteStorageError", {
21
- readonly cause: Schema.optionalKey<Schema.Defect>;
22
- readonly message: Schema.String;
23
- readonly operation: Schema.String;
24
- }>, import("effect/Cause").YieldableError>;
25
- /** SQLite infrastructure failed while opening or operating the store. */
26
- declare class SqliteStorageError extends SqliteStorageError_base {}
27
- declare const SqliteLedgerError_base: Schema.Class<SqliteLedgerError, Schema.TaggedStruct<"SqliteLedgerError", {
28
- readonly cause: Schema.optionalKey<Schema.Defect>;
29
- readonly message: Schema.String;
30
- readonly operation: Schema.String;
31
- }>, import("effect/Cause").YieldableError>;
32
- /**
33
- * SQLite infrastructure failed while operating the Submission Ledger. Surfaces at the
34
- * SubmissionLedger port as the typed `LedgerError` with this error preserved as its cause,
35
- * so the adapter-level tag is never erased.
36
- */
37
- declare class SqliteLedgerError extends SqliteLedgerError_base {}
38
- declare const SqliteAppendConflict_base: Schema.Class<SqliteAppendConflict, Schema.TaggedStruct<"SqliteAppendConflict", {
39
- readonly message: Schema.String;
40
- readonly reason: Schema.Literals<readonly ["batch-digest", "record-identity", "tail"]>;
41
- readonly actualTailSequence: Schema.optionalKey<Schema.brand<Schema.Natural, "@effect-agent/session/CanonicalSequence">>;
42
- readonly actualTailDigest: Schema.optionalKey<Schema.String>;
43
- }>, import("effect/Cause").YieldableError>;
44
- /**
45
- * A canonical batch retry conflicts with existing append state. Tail conflicts carry the
46
- * actual committed tail as a diagnostic resume hint.
47
- */
48
- declare class SqliteAppendConflict extends SqliteAppendConflict_base {}
49
- declare const SqliteFenceRejected_base: Schema.Class<SqliteFenceRejected, Schema.TaggedStruct<"SqliteFenceRejected", {
50
- readonly actualEpoch: Schema.brand<Schema.Natural, "@effect-agent/session/ProducerEpoch">;
51
- readonly message: Schema.String;
52
- readonly producerEpoch: Schema.brand<Schema.Natural, "@effect-agent/session/ProducerEpoch">;
53
- }>, import("effect/Cause").YieldableError>;
54
- /**
55
- * A producer epoch does not match the Conversation's current writer registration. Appends
56
- * require the exact registered epoch, so both older and newer unregistered epochs are fenced;
57
- * a newer epoch takes over by materializing first.
58
- */
59
- declare class SqliteFenceRejected extends SqliteFenceRejected_base {}
60
- declare const SqliteWriteContention_base: Schema.Class<SqliteWriteContention, Schema.TaggedStruct<"SqliteWriteContention", {
61
- readonly cause: Schema.optionalKey<Schema.Defect>;
62
- readonly message: Schema.String;
63
- readonly operation: Schema.String;
64
- }>, import("effect/Cause").YieldableError>;
65
- /**
66
- * A write transaction could not acquire the SQLite write lock within the configured busy
67
- * timeout (SQLITE_BUSY / SQLITE_LOCKED). Another transiently coexisting owner is writing;
68
- * the operation did not mutate canonical state and is safe to retry.
69
- */
70
- declare class SqliteWriteContention extends SqliteWriteContention_base {}
71
- declare const SqliteCheckpointConflict_base: Schema.Class<SqliteCheckpointConflict, Schema.TaggedStruct<"SqliteCheckpointConflict", {
72
- readonly message: Schema.String;
73
- }>, import("effect/Cause").YieldableError>;
74
- /** A checkpoint conflicts with a previously stored checkpoint at the same offset. */
75
- declare class SqliteCheckpointConflict extends SqliteCheckpointConflict_base {}
76
- declare const SqliteStorageFailpointLocation: Schema.Literals<readonly ["materialize:before", "materialize:after", "append:before", "append:after-batch-insert", "append:after-record-insert", "append:after-tail-update", "append:after", "export:after-conversation-read", "save-checkpoint:before", "save-checkpoint:after", "ledger:admit:before", "ledger:admit:after", "ledger:mark-ready:before", "ledger:mark-ready:after", "ledger:claim:before", "ledger:claim:after", "ledger:mark-input-applied:before", "ledger:mark-input-applied:after", "ledger:renew:before", "ledger:renew:after", "ledger:reserve-settlement:before", "ledger:reserve-settlement:after", "ledger:finalize-settlement:before", "ledger:finalize-settlement:after", "ledger:request-abort:before", "ledger:request-abort:after", "ledger:release:before", "ledger:release:after", "ledger:claim-joining:before", "ledger:claim-joining:after", "ledger:mark-joined:before", "ledger:mark-joined:after", "ledger:revert-joining:before", "ledger:revert-joining:after", "ledger:suspend:before", "ledger:suspend:after", "ledger:approval-decision:before", "ledger:approval-decision:after", "ledger:mark-unknown:before", "ledger:mark-unknown:after", "ledger:unknown-resolution:before", "ledger:unknown-resolution:after", "ledger:child-reservation:before", "ledger:child-reservation:after", "ledger:child-attach:before", "ledger:child-attach:after", "ledger:child-release-pending:before", "ledger:child-release-pending:after", "ledger:child-release:before", "ledger:child-release:after", "ledger:child-settled:before", "ledger:child-settled:after"]>;
77
- type SqliteStorageFailpointLocation = typeof SqliteStorageFailpointLocation.Type;
78
- declare const SqliteStorageFailpointError_base: Schema.Class<SqliteStorageFailpointError, Schema.TaggedStruct<"SqliteStorageFailpointError", {
79
- readonly location: Schema.Literals<readonly ["materialize:before", "materialize:after", "append:before", "append:after-batch-insert", "append:after-record-insert", "append:after-tail-update", "append:after", "export:after-conversation-read", "save-checkpoint:before", "save-checkpoint:after", "ledger:admit:before", "ledger:admit:after", "ledger:mark-ready:before", "ledger:mark-ready:after", "ledger:claim:before", "ledger:claim:after", "ledger:mark-input-applied:before", "ledger:mark-input-applied:after", "ledger:renew:before", "ledger:renew:after", "ledger:reserve-settlement:before", "ledger:reserve-settlement:after", "ledger:finalize-settlement:before", "ledger:finalize-settlement:after", "ledger:request-abort:before", "ledger:request-abort:after", "ledger:release:before", "ledger:release:after", "ledger:claim-joining:before", "ledger:claim-joining:after", "ledger:mark-joined:before", "ledger:mark-joined:after", "ledger:revert-joining:before", "ledger:revert-joining:after", "ledger:suspend:before", "ledger:suspend:after", "ledger:approval-decision:before", "ledger:approval-decision:after", "ledger:mark-unknown:before", "ledger:mark-unknown:after", "ledger:unknown-resolution:before", "ledger:unknown-resolution:after", "ledger:child-reservation:before", "ledger:child-reservation:after", "ledger:child-attach:before", "ledger:child-attach:after", "ledger:child-release-pending:before", "ledger:child-release-pending:after", "ledger:child-release:before", "ledger:child-release:after", "ledger:child-settled:before", "ledger:child-settled:after"]>;
80
- }>, import("effect/Cause").YieldableError>;
81
- /** Deterministic test-only fault or pause injected at a SQLite operation boundary. */
82
- declare class SqliteStorageFailpointError extends SqliteStorageFailpointError_base {
83
- get message(): string;
84
- }
85
- //#endregion
86
- //#region src/migrations.d.ts
87
- declare const CurrentSqliteStorageVersion = 4;
88
- declare const sqliteMigrations: SqliteMigrator.Loader<never>;
89
- //#endregion
90
- //#region src/sqlite-storage-config.d.ts
91
- declare const SqliteStorageConfigValue_base: Schema.Class<SqliteStorageConfigValue, Schema.Struct<{
92
- readonly observationPollInterval: Schema.Int;
93
- /** Bounded SQLITE_BUSY retry window for write-lock acquisition, in milliseconds. */
94
- readonly busyTimeout: Schema.Int;
95
- /**
96
- * Submission ownership lease duration in milliseconds (D5). The lease is a liveness hint
97
- * that makes an abandoned claim reclaimable; correctness never depends on it because every
98
- * canonical append is fenced by producer epoch. Convenience layers default this to
99
- * `DEFAULT_OWNERSHIP_LEASE_DURATION` from `@effect-agent/session`.
100
- */
101
- readonly ownershipLeaseDuration: Schema.Int;
102
- /**
103
- * Re-verify every stored payload and digest chain while opening the store. Per-operation
104
- * Schema decoding and the digest chain already fail clearly on corrupt rows, so the full
105
- * scan is an explicit opt-in integrity audit rather than a startup requirement.
106
- */
107
- readonly verifyOnOpen: Schema.Boolean;
108
- }>, {}>;
109
- /**
110
- * Validated construction configuration consumed by the SQLite storage Layer. The database
111
- * identity itself belongs to the SqlClient Layer; duplicating it here could silently diverge
112
- * from the connection actually in use.
113
- */
114
- declare class SqliteStorageConfigValue extends SqliteStorageConfigValue_base {}
115
- declare const SqliteStorageConfig_base: Context.ServiceClass<SqliteStorageConfig, "@effect-agent/storage-sqlite/SqliteStorageConfig", SqliteStorageConfigValue>;
116
- /** Explicit SQLite storage configuration authority. */
117
- declare class SqliteStorageConfig extends SqliteStorageConfig_base {}
118
- //#endregion
119
- //#region src/sqlite-storage-failpoint.d.ts
120
- type SqliteStorageFailpointHandler = (location: SqliteStorageFailpointLocation) => Effect.Effect<void, SqliteStorageFailpointError>;
121
- declare const SqliteStorageFailpointTestControl_base: Context.ServiceClass<SqliteStorageFailpointTestControl, "@effect-agent/storage-sqlite/SqliteStorageFailpointTestControl", {
122
- readonly clear: Effect.Effect<void>;
123
- readonly setHandler: (handler: SqliteStorageFailpointHandler) => Effect.Effect<void>;
124
- }>;
125
- /** Test-only control for replacing the active SQLite failpoint handler. */
126
- declare class SqliteStorageFailpointTestControl extends SqliteStorageFailpointTestControl_base {}
127
- declare const SqliteStorageFailpoint_base: Context.ServiceClass<SqliteStorageFailpoint, "@effect-agent/storage-sqlite/SqliteStorageFailpoint", {
128
- readonly hit: SqliteStorageFailpointHandler;
129
- }>;
130
- /** Explicit fault-injection authority used at SQLite operation boundaries. */
131
- declare class SqliteStorageFailpoint extends SqliteStorageFailpoint_base {
132
- /** Production default: no fault injection. */
133
- static readonly layer: Layer.Layer<SqliteStorageFailpoint, never, never>;
134
- /** Reusable test Layer with a control service backed by the same handler Ref. */
135
- static readonly layerTest: Layer.Layer<SqliteStorageFailpoint | SqliteStorageFailpointTestControl, never, never>;
136
- }
137
- //#endregion
138
- //#region src/sqlite-conversation-store.d.ts
139
- interface SqliteStorageOptions {
140
- readonly filename: string;
141
- readonly observationPollInterval?: number | undefined;
142
- /** Bounded SQLITE_BUSY retry window for write-lock acquisition, in milliseconds. */
143
- readonly busyTimeout?: number | undefined;
144
- /**
145
- * Submission ownership lease duration in milliseconds (D5). Defaults to
146
- * `DEFAULT_OWNERSHIP_LEASE_DURATION` from `@effect-agent/session`.
147
- */
148
- readonly ownershipLeaseDuration?: number | undefined;
149
- /**
150
- * Re-verify every stored payload and digest chain while opening the store. Defaults to
151
- * off: per-operation Schema decoding and the digest chain already fail clearly on corrupt
152
- * rows without scanning the whole database on every open.
153
- */
154
- readonly verifyOnOpen?: boolean | undefined;
155
- readonly failpoint?: SqliteStorageFailpointHandler | undefined;
156
- }
157
- type SqliteStorageInitializationError = SqliteStorageCompatibilityError | SqliteStorageCorruptionError | SqliteStorageError;
158
- /**
159
- * SQLite Conversation Store implementation with configuration, failpoint, SQL, and Crypto
160
- * authority kept visible in its input channel.
161
- */
162
- declare const conversationStoreLayer: Layer.Layer<ConversationStore, SqliteStorageInitializationError, SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient | Crypto.Crypto>;
163
- /**
164
- * Validated SQLite storage configuration Layer with the documented defaults applied. Shared
165
- * by the ConversationStore and SubmissionLedger convenience layers so their defaults cannot
166
- * drift.
167
- */
168
- declare const storageConfigLayer: (options: SqliteStorageOptions) => Layer.Layer<SqliteStorageConfig, SqliteStorageError>;
169
- /** The failpoint Layer selected by convenience options: explicit handler or the no-op default. */
170
- declare const storageFailpointLayer: (options: SqliteStorageOptions) => Layer.Layer<SqliteStorageFailpoint>;
171
- /**
172
- * A composition-root convenience Layer for canonical Conversations. Durable accepted work is
173
- * served by the separate SubmissionLedger port.
174
- */
175
- declare const layer: (options: SqliteStorageOptions) => Layer.Layer<ConversationStore, SqliteStorageInitializationError>;
176
- /** Create an adapter-owned resumable observation offset for a known canonical sequence. */
177
- declare const observationOffsetAt: (conversationId: string & import("effect/Brand").Brand<"@effect-agent/core/ConversationId">, sequence: number) => Effect.Effect<string & import("effect/Brand").Brand<"@effect-agent/session/ObservationOffset">, ConversationStoreError, never>;
178
- //#endregion
179
- //#region src/sqlite-ledger.d.ts
180
- /**
181
- * SQLite SubmissionLedger implementation sharing the journal's database file, write
182
- * transaction discipline, and producer-epoch fencing substrate. Configuration, failpoint,
183
- * SQL, and Crypto authority stay visible in the input channel.
184
- */
185
- declare const submissionLedgerLayer: Layer.Layer<SubmissionLedger, SqliteStorageInitializationError, SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient | Crypto.Crypto>;
186
- /**
187
- * A composition-root convenience Layer for the durable Submission Ledger. Point it at the
188
- * same database file as the ConversationStore so claims fence the same producer epochs.
189
- */
190
- declare const ledgerLayer: (options: SqliteStorageOptions) => Layer.Layer<SubmissionLedger, SqliteStorageInitializationError>;
191
- //#endregion
192
- export { CurrentSqliteStorageVersion, SqliteAppendConflict, SqliteCheckpointConflict, SqliteFenceRejected, SqliteLedgerError, SqliteStorageCompatibilityError, SqliteStorageConfig, SqliteStorageConfigValue, SqliteStorageCorruptionError, SqliteStorageError, SqliteStorageFailpoint, SqliteStorageFailpointError, SqliteStorageFailpointHandler, SqliteStorageFailpointLocation, SqliteStorageFailpointTestControl, SqliteStorageInitializationError, SqliteStorageOptions, SqliteWriteContention, conversationStoreLayer, layer, ledgerLayer, observationOffsetAt, sqliteMigrations, storageConfigLayer, storageFailpointLayer, submissionLedgerLayer };
193
- //# sourceMappingURL=index.d.mts.map
1
+ import { t as SqliteActivityStore_d_exports } from "./SqliteActivityStore.mjs";
2
+ import { c as SqliteStorageError_d_exports } from "./SqliteStorageError-DVWeaWLm.mjs";
3
+ import { t as SqliteStorageConfig_d_exports } from "./SqliteStorageConfig.mjs";
4
+ import { t as SqliteStorageFailpoint_d_exports } from "./SqliteStorageFailpoint.mjs";
5
+ import { t as SqliteMessageDeliveryStore_d_exports } from "./SqliteMessageDeliveryStore.mjs";
6
+ import { t as SqliteThreadStore_d_exports } from "./SqliteThreadStore.mjs";
7
+ import { t as SqliteScheduleStore_d_exports } from "./SqliteScheduleStore.mjs";
8
+ import { t as SqliteStorageVersion_d_exports } from "./SqliteStorageVersion-BqmqX0CI.mjs";
9
+ import { t as SqliteSubmissionLedger_d_exports } from "./SqliteSubmissionLedger.mjs";
10
+ import { t as SqliteSubscriptionStore_d_exports } from "./SqliteSubscriptionStore.mjs";
11
+ export { SqliteActivityStore_d_exports as SqliteActivityStore, SqliteMessageDeliveryStore_d_exports as SqliteMessageDeliveryStore, SqliteScheduleStore_d_exports as SqliteScheduleStore, SqliteStorageConfig_d_exports as SqliteStorageConfig, SqliteStorageError_d_exports as SqliteStorageError, SqliteStorageFailpoint_d_exports as SqliteStorageFailpoint, SqliteStorageVersion_d_exports as SqliteStorageVersion, SqliteSubmissionLedger_d_exports as SqliteSubmissionLedger, SqliteSubscriptionStore_d_exports as SqliteSubscriptionStore, SqliteThreadStore_d_exports as SqliteThreadStore };