@yielded/agent-storage-cloudflare 0.1.0-beta.166
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/LICENSE +21 -0
- package/dist/DoMemoryStore.d.mts +30 -0
- package/dist/DoMemoryStore.mjs +66 -0
- package/dist/DoMemoryStore.mjs.map +1 -0
- package/dist/DoMessageDeliveryStore.d.mts +17 -0
- package/dist/DoMessageDeliveryStore.mjs +30 -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-CGuAfSwF.d.mts +101 -0
- package/dist/DoStorageError.d.mts +2 -0
- package/dist/DoStorageError.mjs +167 -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 +24 -0
- package/dist/DoStorageFailpointTesting.mjs +22 -0
- package/dist/DoStorageFailpointTesting.mjs.map +1 -0
- package/dist/DoStorageVersion-iNSyi3cJ.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 +1979 -0
- package/dist/DoSubmissionLedger.mjs.map +1 -0
- package/dist/DoSubscriptionStore.d.mts +25 -0
- package/dist/DoSubscriptionStore.mjs +186 -0
- package/dist/DoSubscriptionStore.mjs.map +1 -0
- package/dist/DoThreadStore-D_83OjCH.d.mts +72 -0
- package/dist/DoThreadStore.d.mts +2 -0
- package/dist/DoThreadStore.mjs +529 -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 +7726 -0
- package/dist/PortProtocol.mjs +234 -0
- package/dist/PortProtocol.mjs.map +1 -0
- package/dist/PortRouting.d.mts +97 -0
- package/dist/PortRouting.mjs +544 -0
- package/dist/PortRouting.mjs.map +1 -0
- package/dist/do-journal-DUhjZkOf.mjs +1352 -0
- package/dist/do-journal-DUhjZkOf.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +14 -0
- package/dist/migrations-DtKz_Gxr.mjs +306 -0
- package/dist/migrations-DtKz_Gxr.mjs.map +1 -0
- package/dist/owned-state-DHm2aRXx.mjs +119 -0
- package/dist/owned-state-DHm2aRXx.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +1 -0
- package/src/DoMemoryStore.ts +73 -0
- package/src/DoMessageDeliveryStore.ts +39 -0
- package/src/DoScheduleStore.ts +622 -0
- package/src/DoStorageConfig.ts +53 -0
- package/src/DoStorageError.ts +180 -0
- package/src/DoStorageFailpoint.ts +20 -0
- package/src/DoStorageFailpointTesting.ts +41 -0
- package/src/DoStorageVersion.ts +2 -0
- package/src/DoSubmissionLedger.ts +4027 -0
- package/src/DoSubscriptionStore.ts +327 -0
- package/src/DoThreadStore.ts +1121 -0
- package/src/MemoryProtocol.ts +355 -0
- package/src/PortProtocol.ts +436 -0
- package/src/PortRouting.ts +1464 -0
- package/src/index.ts +13 -0
- package/src/internal/do-journal.ts +2282 -0
- package/src/internal/message-delivery-schema.ts +24 -0
- package/src/internal/migrations.ts +304 -0
- package/src/internal/owned-state.ts +228 -0
- package/src/internal/recovery-checkpoint-schema.ts +17 -0
- package/src/internal/storage-span.ts +44 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { DurableRuntimeFailpointError } from "@yielded/agent/durable-failpoint";
|
|
2
|
+
import { ThreadId } from "@yielded/agent/identifiers";
|
|
3
|
+
import {
|
|
4
|
+
MessageDeliveryError,
|
|
5
|
+
MessageDeliveryFailpointError,
|
|
6
|
+
MessageDeliveryKey,
|
|
7
|
+
MessageDeliveryCompletion,
|
|
8
|
+
MessageDeliveryRecord,
|
|
9
|
+
MessageDeliveryPageRequest,
|
|
10
|
+
MessageDeliveryPage,
|
|
11
|
+
} from "@yielded/agent/message-delivery";
|
|
12
|
+
import { CanonicalRecordEnvelope } from "@yielded/agent/records";
|
|
13
|
+
import {
|
|
14
|
+
AbortCommand,
|
|
15
|
+
WorkerStopCommand,
|
|
16
|
+
WorkerLedgerState,
|
|
17
|
+
AbortIntent,
|
|
18
|
+
AdmissionConflict,
|
|
19
|
+
AdmissionPolicyError,
|
|
20
|
+
AdmissionRequest,
|
|
21
|
+
AdmissionResolution,
|
|
22
|
+
AdmissionResult,
|
|
23
|
+
ChildSettledNotification,
|
|
24
|
+
ChildSettledOutcome,
|
|
25
|
+
JoinedToHost,
|
|
26
|
+
LedgerError,
|
|
27
|
+
MarkReadyRequest,
|
|
28
|
+
SettlementConflict,
|
|
29
|
+
SubmissionLookup,
|
|
30
|
+
SubmissionLookupByKey,
|
|
31
|
+
SubmissionSnapshot,
|
|
32
|
+
} from "@yielded/agent/submission-ledger";
|
|
33
|
+
import {
|
|
34
|
+
AppendConflict,
|
|
35
|
+
AppendResult,
|
|
36
|
+
ThreadExport,
|
|
37
|
+
ThreadPeerCountRequest,
|
|
38
|
+
ThreadExportRequest,
|
|
39
|
+
ThreadIdentity,
|
|
40
|
+
ThreadIdentityRequest,
|
|
41
|
+
ThreadMaterialization,
|
|
42
|
+
ThreadNotMaterialized,
|
|
43
|
+
ThreadReadRequest,
|
|
44
|
+
ThreadStoreError,
|
|
45
|
+
ThreadTail,
|
|
46
|
+
ThreadTailRequest,
|
|
47
|
+
FenceRejected,
|
|
48
|
+
FencedAppendRequest,
|
|
49
|
+
} from "@yielded/agent/thread-store";
|
|
50
|
+
import { WorkerAdmissionRequest } from "@yielded/agent/worker-admission";
|
|
51
|
+
import { Schema } from "effect";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The cross-Durable-Object port protocol (plan §1.3, D-P6-3): Schema request/response/error
|
|
55
|
+
* envelopes for the CLOSED route-capable subset of the thread ports. One Thread's
|
|
56
|
+
* Durable Object executes another Thread's request against its OWN local facets; the
|
|
57
|
+
* envelopes here are the only values that cross the Object boundary, and they are
|
|
58
|
+
* transport-agnostic — native Durable Object JS RPC is the shipped carrier, fetch-with-JSON
|
|
59
|
+
* the documented fallback, and both move the same Schema-encoded JSON.
|
|
60
|
+
*
|
|
61
|
+
* The closed subset is exactly the set of operations the durable coordinator performs against
|
|
62
|
+
* a FOREIGN Thread (parent/child establishment, status checks, abort propagation,
|
|
63
|
+
* child-settlement notification, and the child-thread store operations used by
|
|
64
|
+
* establishment, `verifySettledChild`, and result projection):
|
|
65
|
+
*
|
|
66
|
+
* - worker: `admitWorker` (ledger admission, materialization, creation, origin, readiness);
|
|
67
|
+
* - ledger: `admit`, `markReady`, `lookup`, `resolveAdmission`, `requestAbort`,
|
|
68
|
+
* `recordChildSettled`;
|
|
69
|
+
* - store: `materialize`, `append`, `read` (one page), `readIdentity`, `inspectTail`, `export`.
|
|
70
|
+
*
|
|
71
|
+
* Every other port operation is lane-local and has no envelope. A foreign disposable
|
|
72
|
+
* recovery-cache load returns a miss so the caller can replay canonical history. Other
|
|
73
|
+
* foreign operations fail fast and typed instead of widening the distributed surface.
|
|
74
|
+
*
|
|
75
|
+
* Failures cross the boundary as the `PortFailure` union and re-decode on the caller side to
|
|
76
|
+
* the SAME tagged error types the local facet would have produced, so routed calls keep
|
|
77
|
+
* error-tag fidelity. `cause` chains inside `LedgerError`/`ThreadStoreError` travel as
|
|
78
|
+
* Schema defects and do not claim instance fidelity across Objects (plan §2.8).
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/** Ceiling for protocol diagnostic strings; matches `AdmissionIndeterminate.reason`. */
|
|
82
|
+
export const MAX_PORT_DIAGNOSTIC_LENGTH = 4_096;
|
|
83
|
+
|
|
84
|
+
const BoundedDiagnostic = Schema.String.check(Schema.isMaxLength(MAX_PORT_DIAGNOSTIC_LENGTH));
|
|
85
|
+
|
|
86
|
+
/** Truncate a diagnostic string to the protocol's bounded diagnostic length. */
|
|
87
|
+
export const boundPortDiagnostic = (value: string): string =>
|
|
88
|
+
value.length > MAX_PORT_DIAGNOSTIC_LENGTH
|
|
89
|
+
? `${value.slice(0, MAX_PORT_DIAGNOSTIC_LENGTH - 3)}...`
|
|
90
|
+
: value;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The envelope itself could not be honored: the receiving Object could not decode the
|
|
94
|
+
* request, or a response could not be encoded/decoded. It never carries port semantics —
|
|
95
|
+
* callers fold it into the operation's base error (`LedgerError`/`ThreadStoreError`),
|
|
96
|
+
* except `resolveAdmission`, which folds it into `AdmissionIndeterminate` because a
|
|
97
|
+
* non-answer is never proof of absence (SUB-031).
|
|
98
|
+
*/
|
|
99
|
+
export class PortProtocolError extends Schema.TaggedError<PortProtocolError>()(
|
|
100
|
+
"PortProtocolError",
|
|
101
|
+
{
|
|
102
|
+
message: BoundedDiagnostic,
|
|
103
|
+
},
|
|
104
|
+
) {}
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// Requests
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
/** One destination-owned worker admission, including canonical initialization and readiness. */
|
|
111
|
+
export class WorkerAdmitCall extends Schema.TaggedClass<WorkerAdmitCall>()("WorkerAdmit", {
|
|
112
|
+
request: WorkerAdmissionRequest,
|
|
113
|
+
}) {}
|
|
114
|
+
|
|
115
|
+
/** Routed `SubmissionLedger.admit` — child establishment admits INTO the owning Object. */
|
|
116
|
+
export class LedgerAdmitCall extends Schema.TaggedClass<LedgerAdmitCall>(
|
|
117
|
+
"@effect-agent/storage-cloudflare/LedgerAdmitCall",
|
|
118
|
+
)("LedgerAdmit", {
|
|
119
|
+
request: AdmissionRequest,
|
|
120
|
+
}) {}
|
|
121
|
+
|
|
122
|
+
/** Routed `SubmissionLedger.markReady` for a Submission owned by another Object. */
|
|
123
|
+
export class LedgerMarkReadyCall extends Schema.TaggedClass<LedgerMarkReadyCall>(
|
|
124
|
+
"@effect-agent/storage-cloudflare/LedgerMarkReadyCall",
|
|
125
|
+
)("LedgerMarkReady", {
|
|
126
|
+
request: MarkReadyRequest,
|
|
127
|
+
}) {}
|
|
128
|
+
|
|
129
|
+
/** Routed `SubmissionLedger.lookup` (by identity or scoped idempotency key). */
|
|
130
|
+
export class LedgerLookupCall extends Schema.TaggedClass<LedgerLookupCall>(
|
|
131
|
+
"@effect-agent/storage-cloudflare/LedgerLookupCall",
|
|
132
|
+
)("LedgerLookup", {
|
|
133
|
+
request: SubmissionLookup,
|
|
134
|
+
}) {}
|
|
135
|
+
|
|
136
|
+
/** Routed `SubmissionLedger.resolveAdmission` — the SUB-031 tri-state authority call. */
|
|
137
|
+
export class LedgerResolveAdmissionCall extends Schema.TaggedClass<LedgerResolveAdmissionCall>(
|
|
138
|
+
"@effect-agent/storage-cloudflare/LedgerResolveAdmissionCall",
|
|
139
|
+
)("LedgerResolveAdmission", {
|
|
140
|
+
request: SubmissionLookupByKey,
|
|
141
|
+
}) {}
|
|
142
|
+
|
|
143
|
+
export class LedgerInspectWorkerCall extends Schema.TaggedClass<LedgerInspectWorkerCall>()(
|
|
144
|
+
"LedgerInspectWorker",
|
|
145
|
+
{ request: Schema.Struct({ threadId: ThreadId }) },
|
|
146
|
+
) {}
|
|
147
|
+
|
|
148
|
+
export class LedgerInspectWorkerResult extends Schema.TaggedClass<LedgerInspectWorkerResult>()(
|
|
149
|
+
"LedgerInspectWorkerResult",
|
|
150
|
+
{ state: WorkerLedgerState },
|
|
151
|
+
) {}
|
|
152
|
+
|
|
153
|
+
export class LedgerStopWorkerCall extends Schema.TaggedClass<LedgerStopWorkerCall>()(
|
|
154
|
+
"LedgerStopWorker",
|
|
155
|
+
{ request: WorkerStopCommand },
|
|
156
|
+
) {}
|
|
157
|
+
|
|
158
|
+
export class LedgerStopWorkerResult extends Schema.TaggedClass<LedgerStopWorkerResult>()(
|
|
159
|
+
"LedgerStopWorkerResult",
|
|
160
|
+
{ owned: Schema.Natural },
|
|
161
|
+
) {}
|
|
162
|
+
|
|
163
|
+
/** Routed `SubmissionLedger.requestAbort` — abort propagation across Objects. */
|
|
164
|
+
export class LedgerRequestAbortCall extends Schema.TaggedClass<LedgerRequestAbortCall>(
|
|
165
|
+
"@effect-agent/storage-cloudflare/LedgerRequestAbortCall",
|
|
166
|
+
)("LedgerRequestAbort", {
|
|
167
|
+
request: AbortCommand,
|
|
168
|
+
}) {}
|
|
169
|
+
|
|
170
|
+
/** Routed `SubmissionLedger.recordChildSettled` — the child→parent durable notification. */
|
|
171
|
+
export class LedgerRecordChildSettledCall extends Schema.TaggedClass<LedgerRecordChildSettledCall>(
|
|
172
|
+
"@effect-agent/storage-cloudflare/LedgerRecordChildSettledCall",
|
|
173
|
+
)("LedgerRecordChildSettled", {
|
|
174
|
+
request: ChildSettledNotification,
|
|
175
|
+
}) {}
|
|
176
|
+
|
|
177
|
+
/** Routed `ThreadStore.materialize` against the owning Object. */
|
|
178
|
+
export class StoreMaterializeCall extends Schema.TaggedClass<StoreMaterializeCall>(
|
|
179
|
+
"@effect-agent/storage-cloudflare/StoreMaterializeCall",
|
|
180
|
+
)("StoreMaterialize", {
|
|
181
|
+
request: ThreadMaterialization,
|
|
182
|
+
}) {}
|
|
183
|
+
|
|
184
|
+
/** Routed `ThreadStore.append` against the owning Object. */
|
|
185
|
+
export class StoreAppendCall extends Schema.TaggedClass<StoreAppendCall>(
|
|
186
|
+
"@effect-agent/storage-cloudflare/StoreAppendCall",
|
|
187
|
+
)("StoreAppend", {
|
|
188
|
+
request: FencedAppendRequest,
|
|
189
|
+
}) {}
|
|
190
|
+
|
|
191
|
+
/** Routed one-page `ThreadStore.read`; the page bound is the request's own `limit`. */
|
|
192
|
+
export class StoreReadPageCall extends Schema.TaggedClass<StoreReadPageCall>(
|
|
193
|
+
"@effect-agent/storage-cloudflare/StoreReadPageCall",
|
|
194
|
+
)("StoreReadPage", {
|
|
195
|
+
request: ThreadReadRequest,
|
|
196
|
+
}) {}
|
|
197
|
+
|
|
198
|
+
/** Routed `ThreadStore.inspectTail` against the owning Object. */
|
|
199
|
+
export class StoreInspectTailCall extends Schema.TaggedClass<StoreInspectTailCall>(
|
|
200
|
+
"@effect-agent/storage-cloudflare/StoreInspectTailCall",
|
|
201
|
+
)("StoreInspectTail", {
|
|
202
|
+
request: ThreadTailRequest,
|
|
203
|
+
}) {}
|
|
204
|
+
|
|
205
|
+
/** Routed bounded `ThreadStore.readIdentity` against the owning Object. */
|
|
206
|
+
export class StoreReadIdentityCall extends Schema.TaggedClass<StoreReadIdentityCall>(
|
|
207
|
+
"@effect-agent/storage-cloudflare/StoreReadIdentityCall",
|
|
208
|
+
)("StoreReadIdentity", {
|
|
209
|
+
request: ThreadIdentityRequest,
|
|
210
|
+
}) {}
|
|
211
|
+
|
|
212
|
+
/** Routed `ThreadStore.export` against the owning Object. */
|
|
213
|
+
export class StoreExportCall extends Schema.TaggedClass<StoreExportCall>(
|
|
214
|
+
"@effect-agent/storage-cloudflare/StoreExportCall",
|
|
215
|
+
)("StoreExport", {
|
|
216
|
+
request: ThreadExportRequest,
|
|
217
|
+
}) {}
|
|
218
|
+
|
|
219
|
+
export class StoreCountPeerMessagesCall extends Schema.TaggedClass<StoreCountPeerMessagesCall>()(
|
|
220
|
+
"StoreCountPeerMessages",
|
|
221
|
+
{ request: ThreadPeerCountRequest },
|
|
222
|
+
) {}
|
|
223
|
+
|
|
224
|
+
export class MessageDeliveryListCall extends Schema.TaggedClass<MessageDeliveryListCall>()(
|
|
225
|
+
"MessageDeliveryList",
|
|
226
|
+
{ request: MessageDeliveryPageRequest },
|
|
227
|
+
) {}
|
|
228
|
+
|
|
229
|
+
export class MessageDeliveryCompleteCall extends Schema.TaggedClass<MessageDeliveryCompleteCall>()(
|
|
230
|
+
"MessageDeliveryComplete",
|
|
231
|
+
{ key: MessageDeliveryKey, completion: MessageDeliveryCompletion },
|
|
232
|
+
) {}
|
|
233
|
+
|
|
234
|
+
/** Every request that may cross a Durable Object boundary — the CLOSED route-capable subset. */
|
|
235
|
+
export const PortRequest = Schema.Union([
|
|
236
|
+
WorkerAdmitCall,
|
|
237
|
+
MessageDeliveryListCall,
|
|
238
|
+
MessageDeliveryCompleteCall,
|
|
239
|
+
LedgerAdmitCall,
|
|
240
|
+
LedgerMarkReadyCall,
|
|
241
|
+
LedgerLookupCall,
|
|
242
|
+
LedgerResolveAdmissionCall,
|
|
243
|
+
LedgerRequestAbortCall,
|
|
244
|
+
LedgerStopWorkerCall,
|
|
245
|
+
LedgerInspectWorkerCall,
|
|
246
|
+
LedgerRecordChildSettledCall,
|
|
247
|
+
StoreMaterializeCall,
|
|
248
|
+
StoreAppendCall,
|
|
249
|
+
StoreReadPageCall,
|
|
250
|
+
StoreInspectTailCall,
|
|
251
|
+
StoreReadIdentityCall,
|
|
252
|
+
StoreExportCall,
|
|
253
|
+
StoreCountPeerMessagesCall,
|
|
254
|
+
]);
|
|
255
|
+
|
|
256
|
+
export type PortRequest = typeof PortRequest.Type;
|
|
257
|
+
|
|
258
|
+
/** The wire form of one port request (what a transport actually carries). */
|
|
259
|
+
export type PortRequestEnvelope = typeof PortRequest.Encoded;
|
|
260
|
+
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
// Results
|
|
263
|
+
// ---------------------------------------------------------------------------
|
|
264
|
+
|
|
265
|
+
export class WorkerAdmitResult extends Schema.TaggedClass<WorkerAdmitResult>()(
|
|
266
|
+
"WorkerAdmitResult",
|
|
267
|
+
{
|
|
268
|
+
result: AdmissionResult,
|
|
269
|
+
},
|
|
270
|
+
) {}
|
|
271
|
+
|
|
272
|
+
export class LedgerAdmitResult extends Schema.TaggedClass<LedgerAdmitResult>(
|
|
273
|
+
"@effect-agent/storage-cloudflare/LedgerAdmitResult",
|
|
274
|
+
)("LedgerAdmitResult", {
|
|
275
|
+
result: AdmissionResult,
|
|
276
|
+
}) {}
|
|
277
|
+
|
|
278
|
+
export class LedgerMarkReadyResult extends Schema.TaggedClass<LedgerMarkReadyResult>(
|
|
279
|
+
"@effect-agent/storage-cloudflare/LedgerMarkReadyResult",
|
|
280
|
+
)("LedgerMarkReadyResult", {}) {}
|
|
281
|
+
|
|
282
|
+
/** `submission` is absent exactly when the lookup answered `Option.none`. */
|
|
283
|
+
export class LedgerLookupResult extends Schema.TaggedClass<LedgerLookupResult>(
|
|
284
|
+
"@effect-agent/storage-cloudflare/LedgerLookupResult",
|
|
285
|
+
)("LedgerLookupResult", {
|
|
286
|
+
submission: Schema.optionalKey(SubmissionSnapshot),
|
|
287
|
+
}) {}
|
|
288
|
+
|
|
289
|
+
export class LedgerResolveAdmissionResult extends Schema.TaggedClass<LedgerResolveAdmissionResult>(
|
|
290
|
+
"@effect-agent/storage-cloudflare/LedgerResolveAdmissionResult",
|
|
291
|
+
)("LedgerResolveAdmissionResult", {
|
|
292
|
+
resolution: AdmissionResolution,
|
|
293
|
+
}) {}
|
|
294
|
+
|
|
295
|
+
export class LedgerRequestAbortResult extends Schema.TaggedClass<LedgerRequestAbortResult>(
|
|
296
|
+
"@effect-agent/storage-cloudflare/LedgerRequestAbortResult",
|
|
297
|
+
)("LedgerRequestAbortResult", {
|
|
298
|
+
intent: AbortIntent,
|
|
299
|
+
}) {}
|
|
300
|
+
|
|
301
|
+
export class LedgerRecordChildSettledResult extends Schema.TaggedClass<LedgerRecordChildSettledResult>(
|
|
302
|
+
"@effect-agent/storage-cloudflare/LedgerRecordChildSettledResult",
|
|
303
|
+
)("LedgerRecordChildSettledResult", {
|
|
304
|
+
outcome: ChildSettledOutcome,
|
|
305
|
+
}) {}
|
|
306
|
+
|
|
307
|
+
export class StoreMaterializeResult extends Schema.TaggedClass<StoreMaterializeResult>(
|
|
308
|
+
"@effect-agent/storage-cloudflare/StoreMaterializeResult",
|
|
309
|
+
)("StoreMaterializeResult", {}) {}
|
|
310
|
+
|
|
311
|
+
export class StoreAppendResult extends Schema.TaggedClass<StoreAppendResult>(
|
|
312
|
+
"@effect-agent/storage-cloudflare/StoreAppendResult",
|
|
313
|
+
)("StoreAppendResult", {
|
|
314
|
+
result: AppendResult,
|
|
315
|
+
}) {}
|
|
316
|
+
|
|
317
|
+
/** One page of canonical records, bounded by the request's `limit` (≤ 1,024). */
|
|
318
|
+
export class StoreReadPageResult extends Schema.TaggedClass<StoreReadPageResult>(
|
|
319
|
+
"@effect-agent/storage-cloudflare/StoreReadPageResult",
|
|
320
|
+
)("StoreReadPageResult", {
|
|
321
|
+
records: Schema.Array(CanonicalRecordEnvelope).check(Schema.isMaxLength(1_024)),
|
|
322
|
+
}) {}
|
|
323
|
+
|
|
324
|
+
export class StoreInspectTailResult extends Schema.TaggedClass<StoreInspectTailResult>(
|
|
325
|
+
"@effect-agent/storage-cloudflare/StoreInspectTailResult",
|
|
326
|
+
)("StoreInspectTailResult", {
|
|
327
|
+
tail: ThreadTail,
|
|
328
|
+
}) {}
|
|
329
|
+
|
|
330
|
+
export class StoreReadIdentityResult extends Schema.TaggedClass<StoreReadIdentityResult>(
|
|
331
|
+
"@effect-agent/storage-cloudflare/StoreReadIdentityResult",
|
|
332
|
+
)("StoreReadIdentityResult", {
|
|
333
|
+
identity: ThreadIdentity,
|
|
334
|
+
}) {}
|
|
335
|
+
|
|
336
|
+
export class StoreExportResult extends Schema.TaggedClass<StoreExportResult>(
|
|
337
|
+
"@effect-agent/storage-cloudflare/StoreExportResult",
|
|
338
|
+
)("StoreExportResult", {
|
|
339
|
+
export: ThreadExport,
|
|
340
|
+
}) {}
|
|
341
|
+
|
|
342
|
+
export class StoreCountPeerMessagesResult extends Schema.TaggedClass<StoreCountPeerMessagesResult>()(
|
|
343
|
+
"StoreCountPeerMessagesResult",
|
|
344
|
+
{ count: Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 1000 })) },
|
|
345
|
+
) {}
|
|
346
|
+
|
|
347
|
+
export class MessageDeliveryListResult extends Schema.TaggedClass<MessageDeliveryListResult>()(
|
|
348
|
+
"MessageDeliveryListResult",
|
|
349
|
+
{ page: MessageDeliveryPage },
|
|
350
|
+
) {}
|
|
351
|
+
|
|
352
|
+
export class MessageDeliveryCompleteResult extends Schema.TaggedClass<MessageDeliveryCompleteResult>()(
|
|
353
|
+
"MessageDeliveryCompleteResult",
|
|
354
|
+
{ record: MessageDeliveryRecord },
|
|
355
|
+
) {}
|
|
356
|
+
|
|
357
|
+
/** Every successful routed result. Callers narrow by the tag their request implies. */
|
|
358
|
+
export const PortResult = Schema.Union([
|
|
359
|
+
WorkerAdmitResult,
|
|
360
|
+
MessageDeliveryListResult,
|
|
361
|
+
MessageDeliveryCompleteResult,
|
|
362
|
+
LedgerAdmitResult,
|
|
363
|
+
LedgerMarkReadyResult,
|
|
364
|
+
LedgerLookupResult,
|
|
365
|
+
LedgerResolveAdmissionResult,
|
|
366
|
+
LedgerRequestAbortResult,
|
|
367
|
+
LedgerStopWorkerResult,
|
|
368
|
+
LedgerInspectWorkerResult,
|
|
369
|
+
LedgerRecordChildSettledResult,
|
|
370
|
+
StoreMaterializeResult,
|
|
371
|
+
StoreAppendResult,
|
|
372
|
+
StoreReadPageResult,
|
|
373
|
+
StoreInspectTailResult,
|
|
374
|
+
StoreReadIdentityResult,
|
|
375
|
+
StoreExportResult,
|
|
376
|
+
StoreCountPeerMessagesResult,
|
|
377
|
+
]);
|
|
378
|
+
|
|
379
|
+
export type PortResult = typeof PortResult.Type;
|
|
380
|
+
|
|
381
|
+
// ---------------------------------------------------------------------------
|
|
382
|
+
// Failures and the response envelope
|
|
383
|
+
// ---------------------------------------------------------------------------
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Every typed failure a route-capable operation can produce on its owning Object, plus the
|
|
387
|
+
* protocol's own `PortProtocolError`. Members re-decode to the SAME tagged classes the
|
|
388
|
+
* thread ports declare, so a routed caller observes identical error tags and fields.
|
|
389
|
+
*/
|
|
390
|
+
export const PortFailure = Schema.Union([
|
|
391
|
+
DurableRuntimeFailpointError,
|
|
392
|
+
MessageDeliveryError,
|
|
393
|
+
MessageDeliveryFailpointError,
|
|
394
|
+
AdmissionConflict,
|
|
395
|
+
AdmissionPolicyError,
|
|
396
|
+
SettlementConflict,
|
|
397
|
+
JoinedToHost,
|
|
398
|
+
LedgerError,
|
|
399
|
+
ThreadStoreError,
|
|
400
|
+
ThreadNotMaterialized,
|
|
401
|
+
AppendConflict,
|
|
402
|
+
FenceRejected,
|
|
403
|
+
PortProtocolError,
|
|
404
|
+
]);
|
|
405
|
+
|
|
406
|
+
export type PortFailure = typeof PortFailure.Type;
|
|
407
|
+
|
|
408
|
+
/** The routed operation succeeded on its owning Object. */
|
|
409
|
+
export class PortSucceeded extends Schema.TaggedClass<PortSucceeded>(
|
|
410
|
+
"@effect-agent/storage-cloudflare/PortSucceeded",
|
|
411
|
+
)("PortSucceeded", {
|
|
412
|
+
result: PortResult,
|
|
413
|
+
}) {}
|
|
414
|
+
|
|
415
|
+
/** The routed operation failed TYPED on its owning Object; the failure re-decodes verbatim. */
|
|
416
|
+
export class PortFailed extends Schema.TaggedClass<PortFailed>(
|
|
417
|
+
"@effect-agent/storage-cloudflare/PortFailed",
|
|
418
|
+
)("PortFailed", {
|
|
419
|
+
failure: PortFailure,
|
|
420
|
+
}) {}
|
|
421
|
+
|
|
422
|
+
/** The uniform answer of one `portCall`: op-specific success or a re-decodable typed failure. */
|
|
423
|
+
export const PortResponse = Schema.Union([PortSucceeded, PortFailed]);
|
|
424
|
+
export type PortResponse = typeof PortResponse.Type;
|
|
425
|
+
|
|
426
|
+
/** The wire form of one port response (what a transport actually carries). */
|
|
427
|
+
export type PortResponseEnvelope = typeof PortResponse.Encoded;
|
|
428
|
+
|
|
429
|
+
// ---------------------------------------------------------------------------
|
|
430
|
+
// Codecs
|
|
431
|
+
// ---------------------------------------------------------------------------
|
|
432
|
+
|
|
433
|
+
export const encodePortRequest = Schema.encodeEffect(PortRequest);
|
|
434
|
+
export const decodePortRequest = Schema.decodeUnknownEffect(PortRequest);
|
|
435
|
+
export const encodePortResponse = Schema.encodeEffect(PortResponse);
|
|
436
|
+
export const decodePortResponse = Schema.decodeUnknownEffect(PortResponse);
|