@effect-agent/storage-sqlite 0.1.0-beta.38 → 0.1.0-beta.39
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/dist/index.d.mts +17 -114
- package/dist/index.mjs +1036 -393
- package/dist/index.mjs.map +1 -1
- package/dist/sqlite-storage-failpoint-Cr0SXflP.d.mts +95 -0
- package/dist/sqlite-storage-failpoint-DIwWk5dw.mjs +12 -0
- package/dist/sqlite-storage-failpoint-DIwWk5dw.mjs.map +1 -0
- package/dist/testing.d.mts +15 -0
- package/dist/testing.mjs +19 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +12 -5
- package/src/errors.ts +3 -3
- package/src/index.ts +3 -2
- package/src/migrations.ts +105 -24
- package/src/sqlite-journal.ts +147 -156
- package/src/sqlite-ledger.ts +60 -60
- package/src/sqlite-schedule-store.ts +2 -2
- package/src/sqlite-storage-config.ts +1 -1
- package/src/sqlite-storage-failpoint-testing.ts +38 -0
- package/src/sqlite-storage-failpoint.ts +1 -31
- package/src/sqlite-subscription-store.ts +935 -0
- package/src/{sqlite-conversation-store.ts → sqlite-thread-store.ts} +248 -267
- package/src/testing.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,91 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SqliteFenceRejected, c as SqliteStorageCorruptionError, d as SqliteStorageFailpointLocation, f as SqliteWriteContention, i as SqliteCheckpointConflict, l as SqliteStorageError, n as SqliteStorageFailpointHandler, o as SqliteLedgerError, r as SqliteAppendConflict, s as SqliteStorageCompatibilityError, t as SqliteStorageFailpoint, u as SqliteStorageFailpointError } from "./sqlite-storage-failpoint-Cr0SXflP.mjs";
|
|
2
|
+
import { ScheduleStore, SourcePartition, SubmissionLedger, SubscriptionError, SubscriptionStore, ThreadStore, ThreadStoreError } from "@effect-agent/thread";
|
|
2
3
|
import { Context, Crypto, Effect, Layer, Schema } from "effect";
|
|
3
4
|
import { SqliteMigrator } from "@effect/sql-sqlite-node";
|
|
4
5
|
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
6
|
//#region src/migrations.d.ts
|
|
87
|
-
declare const CurrentSqliteStorageVersion =
|
|
88
|
-
declare const sqliteMigrations: SqliteMigrator.Loader<never>;
|
|
7
|
+
declare const CurrentSqliteStorageVersion = 7;
|
|
89
8
|
//#endregion
|
|
90
9
|
//#region src/sqlite-storage-config.d.ts
|
|
91
10
|
declare const SqliteStorageConfigValue_base: Schema.Class<SqliteStorageConfigValue, Schema.Struct<{
|
|
@@ -96,7 +15,7 @@ declare const SqliteStorageConfigValue_base: Schema.Class<SqliteStorageConfigVal
|
|
|
96
15
|
* Submission ownership lease duration in milliseconds (D5). The lease is a liveness hint
|
|
97
16
|
* that makes an abandoned claim reclaimable; correctness never depends on it because every
|
|
98
17
|
* canonical append is fenced by producer epoch. Convenience layers default this to
|
|
99
|
-
* `DEFAULT_OWNERSHIP_LEASE_DURATION` from `@effect-agent/
|
|
18
|
+
* `DEFAULT_OWNERSHIP_LEASE_DURATION` from `@effect-agent/thread`.
|
|
100
19
|
*/
|
|
101
20
|
readonly ownershipLeaseDuration: Schema.Int;
|
|
102
21
|
/**
|
|
@@ -116,26 +35,7 @@ declare const SqliteStorageConfig_base: Context.ServiceClass<SqliteStorageConfig
|
|
|
116
35
|
/** Explicit SQLite storage configuration authority. */
|
|
117
36
|
declare class SqliteStorageConfig extends SqliteStorageConfig_base {}
|
|
118
37
|
//#endregion
|
|
119
|
-
//#region src/sqlite-
|
|
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
|
|
38
|
+
//#region src/sqlite-thread-store.d.ts
|
|
139
39
|
interface SqliteStorageOptions {
|
|
140
40
|
readonly filename: string;
|
|
141
41
|
readonly observationPollInterval?: number | undefined;
|
|
@@ -143,7 +43,7 @@ interface SqliteStorageOptions {
|
|
|
143
43
|
readonly busyTimeout?: number | undefined;
|
|
144
44
|
/**
|
|
145
45
|
* Submission ownership lease duration in milliseconds (D5). Defaults to
|
|
146
|
-
* `DEFAULT_OWNERSHIP_LEASE_DURATION` from `@effect-agent/
|
|
46
|
+
* `DEFAULT_OWNERSHIP_LEASE_DURATION` from `@effect-agent/thread`.
|
|
147
47
|
*/
|
|
148
48
|
readonly ownershipLeaseDuration?: number | undefined;
|
|
149
49
|
/**
|
|
@@ -156,25 +56,25 @@ interface SqliteStorageOptions {
|
|
|
156
56
|
}
|
|
157
57
|
type SqliteStorageInitializationError = SqliteStorageCompatibilityError | SqliteStorageCorruptionError | SqliteStorageError;
|
|
158
58
|
/**
|
|
159
|
-
* SQLite
|
|
59
|
+
* SQLite Thread Store implementation with configuration, failpoint, SQL, and Crypto
|
|
160
60
|
* authority kept visible in its input channel.
|
|
161
61
|
*/
|
|
162
|
-
declare const
|
|
62
|
+
declare const threadStoreLayer: Layer.Layer<ThreadStore, SqliteStorageInitializationError, SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient | Crypto.Crypto>;
|
|
163
63
|
/**
|
|
164
64
|
* Validated SQLite storage configuration Layer with the documented defaults applied. Shared
|
|
165
|
-
* by the
|
|
65
|
+
* by the ThreadStore and SubmissionLedger convenience layers so their defaults cannot
|
|
166
66
|
* drift.
|
|
167
67
|
*/
|
|
168
68
|
declare const storageConfigLayer: (options: SqliteStorageOptions) => Layer.Layer<SqliteStorageConfig, SqliteStorageError>;
|
|
169
69
|
/** The failpoint Layer selected by convenience options: explicit handler or the no-op default. */
|
|
170
70
|
declare const storageFailpointLayer: (options: SqliteStorageOptions) => Layer.Layer<SqliteStorageFailpoint>;
|
|
171
71
|
/**
|
|
172
|
-
* A composition-root convenience Layer for canonical
|
|
72
|
+
* A composition-root convenience Layer for canonical Threads. Durable accepted work is
|
|
173
73
|
* served by the separate SubmissionLedger port.
|
|
174
74
|
*/
|
|
175
|
-
declare const layer: (options: SqliteStorageOptions) => Layer.Layer<
|
|
75
|
+
declare const layer: (options: SqliteStorageOptions) => Layer.Layer<ThreadStore, SqliteStorageInitializationError>;
|
|
176
76
|
/** Create an adapter-owned resumable observation offset for a known canonical sequence. */
|
|
177
|
-
declare const observationOffsetAt: (
|
|
77
|
+
declare const observationOffsetAt: (threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">, sequence: number) => Effect.Effect<string & import("effect/Brand").Brand<"@effect-agent/thread/ObservationOffset">, ThreadStoreError, never>;
|
|
178
78
|
//#endregion
|
|
179
79
|
//#region src/sqlite-ledger.d.ts
|
|
180
80
|
/**
|
|
@@ -185,7 +85,7 @@ declare const observationOffsetAt: (conversationId: string & import("effect/Bran
|
|
|
185
85
|
declare const submissionLedgerLayer: Layer.Layer<SubmissionLedger, SqliteStorageInitializationError, SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient | Crypto.Crypto>;
|
|
186
86
|
/**
|
|
187
87
|
* A composition-root convenience Layer for the durable Submission Ledger. Point it at the
|
|
188
|
-
* same database file as the
|
|
88
|
+
* same database file as the ThreadStore so claims fence the same producer epochs.
|
|
189
89
|
*/
|
|
190
90
|
declare const ledgerLayer: (options: SqliteStorageOptions) => Layer.Layer<SubmissionLedger, SqliteStorageInitializationError>;
|
|
191
91
|
//#endregion
|
|
@@ -193,5 +93,8 @@ declare const ledgerLayer: (options: SqliteStorageOptions) => Layer.Layer<Submis
|
|
|
193
93
|
/** SQLite implementation of the atomic ScheduleStore port. */
|
|
194
94
|
declare const scheduleStoreLayer: Layer.Layer<ScheduleStore, SqliteStorageInitializationError, SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient>;
|
|
195
95
|
//#endregion
|
|
196
|
-
|
|
96
|
+
//#region src/sqlite-subscription-store.d.ts
|
|
97
|
+
declare const subscriptionStoreLayer: (partition: SourcePartition) => Layer.Layer<SubscriptionStore, SqliteStorageInitializationError | SubscriptionError, SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient>;
|
|
98
|
+
//#endregion
|
|
99
|
+
export { CurrentSqliteStorageVersion, SqliteAppendConflict, SqliteCheckpointConflict, SqliteFenceRejected, SqliteLedgerError, SqliteStorageCompatibilityError, SqliteStorageConfig, SqliteStorageConfigValue, SqliteStorageCorruptionError, SqliteStorageError, SqliteStorageFailpoint, SqliteStorageFailpointError, SqliteStorageFailpointHandler, SqliteStorageFailpointLocation, SqliteStorageInitializationError, SqliteStorageOptions, SqliteWriteContention, layer, ledgerLayer, observationOffsetAt, scheduleStoreLayer, storageConfigLayer, storageFailpointLayer, submissionLedgerLayer, subscriptionStoreLayer, threadStoreLayer };
|
|
197
100
|
//# sourceMappingURL=index.d.mts.map
|