@effect-agent/storage-cloudflare 0.1.0-beta.8 → 0.1.0-beta.80
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/DoMemoryStore.d.mts +29 -0
- package/dist/DoMemoryStore.mjs +55 -0
- package/dist/DoMemoryStore.mjs.map +1 -0
- package/dist/DoMessageDeliveryStore.d.mts +17 -0
- package/dist/DoMessageDeliveryStore.mjs +32 -0
- package/dist/DoMessageDeliveryStore.mjs.map +1 -0
- package/dist/DoScheduleStore.d.mts +36 -0
- package/dist/DoScheduleStore.mjs +388 -0
- package/dist/DoScheduleStore.mjs.map +1 -0
- package/dist/DoStorageConfig.d.mts +45 -0
- package/dist/DoStorageConfig.mjs +52 -0
- package/dist/DoStorageConfig.mjs.map +1 -0
- package/dist/DoStorageError-Cmhvl4TQ.d.mts +98 -0
- package/dist/DoStorageError.d.mts +2 -0
- package/dist/DoStorageError.mjs +164 -0
- package/dist/DoStorageError.mjs.map +1 -0
- package/dist/DoStorageFailpoint.d.mts +17 -0
- package/dist/DoStorageFailpoint.mjs +14 -0
- package/dist/DoStorageFailpoint.mjs.map +1 -0
- package/dist/DoStorageFailpointTesting.d.mts +34 -0
- package/dist/DoStorageFailpointTesting.mjs +35 -0
- package/dist/DoStorageFailpointTesting.mjs.map +1 -0
- package/dist/DoStorageVersion-x5OOurvZ.d.mts +12 -0
- package/dist/DoStorageVersion.d.mts +2 -0
- package/dist/DoStorageVersion.mjs +8 -0
- package/dist/DoStorageVersion.mjs.map +1 -0
- package/dist/DoSubmissionLedger.d.mts +23 -0
- package/dist/DoSubmissionLedger.mjs +1849 -0
- package/dist/DoSubmissionLedger.mjs.map +1 -0
- package/dist/DoSubscriptionStore.d.mts +25 -0
- package/dist/DoSubscriptionStore.mjs +183 -0
- package/dist/DoSubscriptionStore.mjs.map +1 -0
- package/dist/DoThreadStore.d.mts +59 -0
- package/dist/DoThreadStore.mjs +465 -0
- package/dist/DoThreadStore.mjs.map +1 -0
- package/dist/MemoryProtocol.d.mts +38160 -0
- package/dist/MemoryProtocol.mjs +219 -0
- package/dist/MemoryProtocol.mjs.map +1 -0
- package/dist/PortProtocol.d.mts +3207 -0
- package/dist/PortProtocol.mjs +176 -0
- package/dist/PortProtocol.mjs.map +1 -0
- package/dist/PortRouting.d.mts +83 -0
- package/dist/PortRouting.mjs +410 -0
- package/dist/PortRouting.mjs.map +1 -0
- package/dist/do-journal-DHqCQeBU.mjs +991 -0
- package/dist/do-journal-DHqCQeBU.mjs.map +1 -0
- package/dist/index.d.mts +14 -1521
- package/dist/index.mjs +14 -3695
- package/dist/migrations-Ba_kOrSx.mjs +287 -0
- package/dist/migrations-Ba_kOrSx.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +1 -45
- package/src/DoMemoryStore.ts +59 -0
- package/src/DoMessageDeliveryStore.ts +53 -0
- package/src/DoScheduleStore.ts +622 -0
- package/src/{errors.ts → DoStorageError.ts} +10 -3
- package/src/DoStorageFailpoint.ts +20 -0
- package/src/{do-storage-failpoint.ts → DoStorageFailpointTesting.ts} +5 -18
- package/src/DoStorageVersion.ts +2 -0
- package/src/{do-ledger.ts → DoSubmissionLedger.ts} +862 -163
- package/src/DoSubscriptionStore.ts +329 -0
- package/src/DoThreadStore.ts +1014 -0
- package/src/MemoryProtocol.ts +355 -0
- package/src/{port-protocol.ts → PortProtocol.ts} +44 -37
- package/src/{routing.ts → PortRouting.ts} +292 -264
- package/src/index.ts +13 -32
- package/src/{do-journal.ts → internal/do-journal.ts} +716 -232
- package/src/internal/message-delivery-schema.ts +24 -0
- package/src/{migrations.ts → internal/migrations.ts} +51 -35
- package/src/internal/recovery-checkpoint-schema.ts +17 -0
- package/dist/index.mjs.map +0 -1
- package/src/do-conversation-store.ts +0 -850
- /package/src/{do-storage-config.ts → DoStorageConfig.ts} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
3
|
+
|
|
4
|
+
/** Additive storage owned by this adapter; creation participates in its version transaction. */
|
|
5
|
+
export const createMessageDeliveryTables = Effect.gen(function* () {
|
|
6
|
+
const sql = yield* SqlClient.SqlClient;
|
|
7
|
+
|
|
8
|
+
yield* sql`
|
|
9
|
+
CREATE TABLE effect_agent_message_deliveries (
|
|
10
|
+
owner_thread_id TEXT NOT NULL,
|
|
11
|
+
message_id TEXT NOT NULL,
|
|
12
|
+
version INTEGER NOT NULL,
|
|
13
|
+
state TEXT NOT NULL,
|
|
14
|
+
deadline_at_millis INTEGER,
|
|
15
|
+
record_json TEXT NOT NULL,
|
|
16
|
+
PRIMARY KEY (owner_thread_id, message_id)
|
|
17
|
+
)
|
|
18
|
+
`.withoutTransform;
|
|
19
|
+
yield* sql`
|
|
20
|
+
CREATE INDEX effect_agent_message_deliveries_due
|
|
21
|
+
ON effect_agent_message_deliveries (deadline_at_millis, owner_thread_id, message_id)
|
|
22
|
+
WHERE deadline_at_millis IS NOT NULL
|
|
23
|
+
`.withoutTransform;
|
|
24
|
+
});
|
|
@@ -2,35 +2,39 @@ import { SqliteMigrator } from "@effect/sql-sqlite-do";
|
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import { createMessageDeliveryTables } from "./message-delivery-schema.ts";
|
|
6
|
+
import { createRecoveryCheckpointTable } from "./recovery-checkpoint-schema.ts";
|
|
7
|
+
|
|
8
|
+
/** The current storage version recorded in `effect_agent_meta`. */
|
|
9
|
+
export const CurrentDoStorageVersion = 6;
|
|
10
|
+
|
|
11
|
+
/** Index only outstanding obligations, ordered by the recovery scan's stable cursor. */
|
|
12
|
+
export const createNonterminalIndex = Effect.gen(function* () {
|
|
13
|
+
const sql = yield* SqlClient.SqlClient;
|
|
14
|
+
|
|
15
|
+
yield* sql`CREATE INDEX effect_agent_submissions_nonterminal ON effect_agent_submissions (thread_id, queue_sequence) WHERE state <> 'settled'`
|
|
16
|
+
.withoutTransform;
|
|
17
|
+
});
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
* into their final shape) so the shared conformance suites and crash-matrix rows address
|
|
17
|
-
* identical durable state. Two DC-specific additions:
|
|
20
|
+
* The Thread Durable Object schema shares its thread and ledger tables with Node/SQLite.
|
|
21
|
+
* Schedules and subscriptions use separate Durable Objects. Two DC-specific additions:
|
|
18
22
|
*
|
|
19
23
|
* 1. `effect_agent_meta` replaces `PRAGMA user_version` as the exact-or-fresh version gate —
|
|
20
24
|
* a meta table is portable regardless of which PRAGMAs Durable Object SQL storage allows.
|
|
21
25
|
* 2. `effect_agent_child_settlements` is the durable cross-store notification marker the
|
|
22
26
|
* SubmissionLedger port contract mandates for cross-store adapters (`suspend`'s covering
|
|
23
|
-
* check and `recordChildSettled`'s wake both consult it): parent and child
|
|
27
|
+
* check and `recordChildSettled`'s wake both consult it): parent and child Threads
|
|
24
28
|
* live in different Durable Objects, so a child settlement reported before the parent's
|
|
25
29
|
* suspend commits must be observable from the PARENT's own storage.
|
|
26
30
|
*/
|
|
27
31
|
export const doMigrations = SqliteMigrator.fromRecord({
|
|
28
|
-
"
|
|
32
|
+
"1_current_cloudflare_thread_object": Effect.gen(function* () {
|
|
29
33
|
const sql = yield* SqlClient.SqlClient;
|
|
30
34
|
|
|
31
35
|
yield* sql`
|
|
32
|
-
CREATE TABLE
|
|
33
|
-
|
|
36
|
+
CREATE TABLE effect_agent_threads (
|
|
37
|
+
thread_id TEXT PRIMARY KEY NOT NULL,
|
|
34
38
|
created_at TEXT NOT NULL,
|
|
35
39
|
tail_sequence INTEGER NOT NULL,
|
|
36
40
|
tail_digest TEXT NOT NULL,
|
|
@@ -40,59 +44,59 @@ export const doMigrations = SqliteMigrator.fromRecord({
|
|
|
40
44
|
|
|
41
45
|
yield* sql`
|
|
42
46
|
CREATE TABLE effect_agent_canonical_batches (
|
|
43
|
-
|
|
47
|
+
thread_id TEXT NOT NULL,
|
|
44
48
|
batch_id TEXT NOT NULL,
|
|
45
49
|
first_sequence INTEGER NOT NULL,
|
|
46
50
|
last_sequence INTEGER NOT NULL,
|
|
47
51
|
batch_digest TEXT NOT NULL,
|
|
48
52
|
tail_digest TEXT NOT NULL,
|
|
49
53
|
batch_json TEXT NOT NULL,
|
|
50
|
-
PRIMARY KEY (
|
|
51
|
-
FOREIGN KEY (
|
|
52
|
-
REFERENCES
|
|
54
|
+
PRIMARY KEY (thread_id, batch_id),
|
|
55
|
+
FOREIGN KEY (thread_id)
|
|
56
|
+
REFERENCES effect_agent_threads(thread_id)
|
|
53
57
|
ON DELETE RESTRICT
|
|
54
58
|
)
|
|
55
59
|
`.withoutTransform;
|
|
56
60
|
|
|
57
61
|
yield* sql`
|
|
58
62
|
CREATE TABLE effect_agent_canonical_records (
|
|
59
|
-
|
|
63
|
+
thread_id TEXT NOT NULL,
|
|
60
64
|
sequence INTEGER NOT NULL,
|
|
61
65
|
record_id TEXT NOT NULL,
|
|
62
66
|
batch_id TEXT NOT NULL,
|
|
63
67
|
record_json TEXT NOT NULL,
|
|
64
|
-
PRIMARY KEY (
|
|
65
|
-
UNIQUE (
|
|
66
|
-
FOREIGN KEY (
|
|
67
|
-
REFERENCES effect_agent_canonical_batches(
|
|
68
|
+
PRIMARY KEY (thread_id, sequence),
|
|
69
|
+
UNIQUE (thread_id, record_id),
|
|
70
|
+
FOREIGN KEY (thread_id, batch_id)
|
|
71
|
+
REFERENCES effect_agent_canonical_batches(thread_id, batch_id)
|
|
68
72
|
ON DELETE RESTRICT
|
|
69
73
|
)
|
|
70
74
|
`.withoutTransform;
|
|
71
75
|
|
|
72
76
|
yield* sql`
|
|
73
77
|
CREATE INDEX effect_agent_canonical_records_batch
|
|
74
|
-
ON effect_agent_canonical_records (
|
|
78
|
+
ON effect_agent_canonical_records (thread_id, batch_id, sequence)
|
|
75
79
|
`.withoutTransform;
|
|
76
80
|
|
|
77
81
|
yield* sql`
|
|
78
82
|
CREATE TABLE effect_agent_checkpoints (
|
|
79
|
-
|
|
83
|
+
thread_id TEXT NOT NULL,
|
|
80
84
|
through_sequence INTEGER NOT NULL,
|
|
81
85
|
tail_digest TEXT NOT NULL,
|
|
82
86
|
checkpoint_json TEXT NOT NULL,
|
|
83
|
-
PRIMARY KEY (
|
|
84
|
-
FOREIGN KEY (
|
|
85
|
-
REFERENCES
|
|
87
|
+
PRIMARY KEY (thread_id, through_sequence),
|
|
88
|
+
FOREIGN KEY (thread_id)
|
|
89
|
+
REFERENCES effect_agent_threads(thread_id)
|
|
86
90
|
ON DELETE RESTRICT
|
|
87
91
|
)
|
|
88
92
|
`.withoutTransform;
|
|
89
93
|
|
|
90
|
-
// Admission rows exist before
|
|
91
|
-
//
|
|
94
|
+
// Admission rows exist before Thread materialization (durability §4), so
|
|
95
|
+
// thread_id intentionally carries no foreign key into effect_agent_threads.
|
|
92
96
|
yield* sql`
|
|
93
97
|
CREATE TABLE effect_agent_submissions (
|
|
94
98
|
submission_id TEXT PRIMARY KEY NOT NULL,
|
|
95
|
-
|
|
99
|
+
thread_id TEXT NOT NULL,
|
|
96
100
|
queue_sequence INTEGER NOT NULL,
|
|
97
101
|
principal TEXT NOT NULL,
|
|
98
102
|
idempotency_key TEXT NOT NULL,
|
|
@@ -115,8 +119,12 @@ export const doMigrations = SqliteMigrator.fromRecord({
|
|
|
115
119
|
unknown_tool_call_ids_json TEXT,
|
|
116
120
|
parent_submission_id TEXT,
|
|
117
121
|
parent_tool_call_id TEXT,
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
admission_group TEXT,
|
|
123
|
+
admission_fence_json TEXT,
|
|
124
|
+
worker_admission_json TEXT,
|
|
125
|
+
message_admission_json TEXT,
|
|
126
|
+
UNIQUE (thread_id, principal, idempotency_key),
|
|
127
|
+
UNIQUE (thread_id, queue_sequence)
|
|
120
128
|
)
|
|
121
129
|
`.withoutTransform;
|
|
122
130
|
|
|
@@ -130,6 +138,11 @@ export const doMigrations = SqliteMigrator.fromRecord({
|
|
|
130
138
|
ON effect_agent_submissions (parent_submission_id)
|
|
131
139
|
`.withoutTransform;
|
|
132
140
|
|
|
141
|
+
yield* sql`
|
|
142
|
+
CREATE INDEX effect_agent_submissions_group
|
|
143
|
+
ON effect_agent_submissions (thread_id, admission_group, state)
|
|
144
|
+
`.withoutTransform;
|
|
145
|
+
|
|
133
146
|
yield* sql`
|
|
134
147
|
CREATE TABLE effect_agent_submission_ownership (
|
|
135
148
|
submission_id TEXT PRIMARY KEY NOT NULL,
|
|
@@ -148,7 +161,7 @@ export const doMigrations = SqliteMigrator.fromRecord({
|
|
|
148
161
|
CREATE TABLE effect_agent_attempts (
|
|
149
162
|
attempt_id TEXT PRIMARY KEY NOT NULL,
|
|
150
163
|
submission_id TEXT NOT NULL,
|
|
151
|
-
|
|
164
|
+
thread_id TEXT NOT NULL,
|
|
152
165
|
owner_producer_id TEXT NOT NULL,
|
|
153
166
|
producer_epoch INTEGER NOT NULL,
|
|
154
167
|
claimed_at TEXT NOT NULL,
|
|
@@ -252,6 +265,9 @@ export const doMigrations = SqliteMigrator.fromRecord({
|
|
|
252
265
|
)
|
|
253
266
|
`.withoutTransform;
|
|
254
267
|
|
|
268
|
+
yield* createNonterminalIndex;
|
|
269
|
+
yield* createMessageDeliveryTables;
|
|
270
|
+
yield* createRecoveryCheckpointTable;
|
|
255
271
|
yield* sql`
|
|
256
272
|
CREATE TABLE effect_agent_meta (
|
|
257
273
|
key TEXT PRIMARY KEY NOT NULL,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
3
|
+
|
|
4
|
+
/** One disposable recovery snapshot per Thread, independent of generic projections. */
|
|
5
|
+
export const createRecoveryCheckpointTable = Effect.gen(function* () {
|
|
6
|
+
const sql = yield* SqlClient.SqlClient;
|
|
7
|
+
|
|
8
|
+
yield* sql`
|
|
9
|
+
CREATE TABLE effect_agent_recovery_checkpoints (
|
|
10
|
+
thread_id TEXT PRIMARY KEY NOT NULL,
|
|
11
|
+
through_sequence INTEGER NOT NULL,
|
|
12
|
+
tail_digest TEXT NOT NULL,
|
|
13
|
+
checkpoint_json TEXT NOT NULL,
|
|
14
|
+
FOREIGN KEY (thread_id) REFERENCES effect_agent_threads(thread_id) ON DELETE RESTRICT
|
|
15
|
+
)
|
|
16
|
+
`.withoutTransform;
|
|
17
|
+
});
|