@effect-agent/platform-cloudflare 0.1.0-beta.111 → 0.1.0-beta.113
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/Alarm.d.mts +65 -15
- package/dist/Alarm.mjs +326 -50
- package/dist/Alarm.mjs.map +1 -1
- package/dist/CloudflareThreadClient.d.mts +19 -12
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{ThreadObject-BGla_Obk.mjs → ThreadObject-BPt5uByD.mjs} +18 -9
- package/dist/ThreadObject-BPt5uByD.mjs.map +1 -0
- package/dist/{ThreadObject-Cmn8pAQ3.d.mts → ThreadObject-DAuaRyGl.d.mts} +37 -30
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/Alarm.ts +642 -84
- package/src/ThreadObject.ts +2 -2
- package/src/internal/message-delivery.ts +33 -23
- package/dist/ThreadObject-BGla_Obk.mjs.map +0 -1
package/dist/Alarm.d.mts
CHANGED
|
@@ -2,13 +2,15 @@ import { DurableObjectContext } from "./CloudflareBindings.mjs";
|
|
|
2
2
|
import { s as CloudflareDurableRuntimeConfig } from "./CloudflareConfig-DKXGo8L3.mjs";
|
|
3
3
|
import { Cause, Context, DateTime, Effect, Layer, Option, Schema, Scope } from "effect";
|
|
4
4
|
import { DurableBindingFailure } from "effect-agent/agent-registration";
|
|
5
|
-
import { DurableAgentRuntime, DurableWorkerFailure } from "effect-agent/durable-agent-runtime";
|
|
5
|
+
import { DurableAgentRuntime, DurableRuntimeConfig, DurableWorkerFailure, RecoveryFailure } from "effect-agent/durable-agent-runtime";
|
|
6
|
+
import { ThreadId } from "effect-agent/identifiers";
|
|
7
|
+
import { OperationDenied } from "effect-agent/operation-authorizer";
|
|
6
8
|
import { SubmissionLedger } from "effect-agent/submission-ledger";
|
|
7
9
|
import { ThreadProjectionError, ThreadProjectionMaintenance } from "effect-agent/thread-projection-maintenance";
|
|
8
10
|
import { WakeScheduler } from "effect-agent/wake-scheduler";
|
|
9
11
|
import { SqlClient } from "effect/unstable/sql/SqlClient";
|
|
10
12
|
declare namespace Alarm_d_exports {
|
|
11
|
-
export { DurableAlarmError, DurableAlarmService, MaintenancePassFailure, MaintenancePassReport, ThreadHostMaintenance, ThreadMaintenance, ThreadMaintenanceFailpoint, ThreadMaintenanceFailpointHandler, ThreadMaintenanceFailpointLocation, ThreadMessageDelivery, ThreadMutationGate, ThreadPublication, ThreadPublicationService, publishCommitted };
|
|
13
|
+
export { DurableAlarmError, DurableAlarmService, MaintenancePassFailure, MaintenancePassReport, ThreadHostMaintenance, ThreadMaintenance, ThreadMaintenanceActivity, ThreadMaintenanceFailpoint, ThreadMaintenanceFailpointHandler, ThreadMaintenanceFailpointLocation, ThreadMessageDelivery, ThreadMutationGate, ThreadPublication, ThreadPublicationService, ThreadRecoveryFault, publishCommitted };
|
|
12
14
|
}
|
|
13
15
|
declare const DurableAlarmError_base: Schema.Class<DurableAlarmError, Schema.TaggedStruct<"DurableAlarmError", {
|
|
14
16
|
readonly operation: Schema.String;
|
|
@@ -64,7 +66,7 @@ export declare class DurableAlarmService extends DurableAlarmService_base {
|
|
|
64
66
|
declare const MaintenancePassReport_base: Schema.Class<MaintenancePassReport, Schema.Struct<{
|
|
65
67
|
/** `caught-up` ran no runtime work (publication may be pending); `actionable` ran recovery. */
|
|
66
68
|
readonly phase: Schema.Literals<readonly ["caught-up", "actionable"]>;
|
|
67
|
-
/** Recovery decisions
|
|
69
|
+
/** Recovery decisions and Thread faults observed during this event. */
|
|
68
70
|
readonly recovered: Schema.Int;
|
|
69
71
|
/** Head Attempts settled during the event. Joined input may settle with each head. */
|
|
70
72
|
readonly settled: Schema.Int;
|
|
@@ -76,7 +78,7 @@ declare const MaintenancePassReport_base: Schema.Class<MaintenancePassReport, Sc
|
|
|
76
78
|
/** What one maintenance pass did — auditable evidence mirroring `NodeDurableHost`'s report. */
|
|
77
79
|
export declare class MaintenancePassReport extends MaintenancePassReport_base {}
|
|
78
80
|
/** Fault boundaries around every maintenance-owned durable mutation. */
|
|
79
|
-
export type ThreadMaintenanceFailpointLocation = "maintenance:dirty:before" | "maintenance:dirty:after" | "maintenance:mutation:armed" | "maintenance:mutation:finished" | "maintenance:ensure:before" | "maintenance:ensure:after" | "maintenance:begin:before" | "maintenance:begin:after" | "maintenance:select:before" | "maintenance:select:after" | "maintenance:binding-retry:before" | "maintenance:binding-retry:after" | "maintenance:retry:before" | "maintenance:retry:after" | "maintenance:checkpoint:before" | "maintenance:checkpoint:after" | "maintenance:finish:before" | "maintenance:finish:after";
|
|
81
|
+
export type ThreadMaintenanceFailpointLocation = "maintenance:dirty:before" | "maintenance:dirty:after" | "maintenance:mutation:armed" | "maintenance:mutation:finished" | "maintenance:ensure:before" | "maintenance:ensure:after" | "maintenance:begin:before" | "maintenance:begin:after" | "maintenance:select:before" | "maintenance:select:after" | "maintenance:binding-retry:before" | "maintenance:binding-retry:after" | "maintenance:recovery-status:before" | "maintenance:recovery-status:after" | "maintenance:retry:before" | "maintenance:retry:after" | "maintenance:checkpoint:before" | "maintenance:checkpoint:after" | "maintenance:finish:before" | "maintenance:finish:after";
|
|
80
82
|
export type ThreadMaintenanceFailpointHandler = (location: ThreadMaintenanceFailpointLocation) => Effect.Effect<void>;
|
|
81
83
|
declare const ThreadMaintenanceFailpoint_base: Context.ServiceClass<ThreadMaintenanceFailpoint, "@effect-agent/platform-cloudflare/ThreadMaintenanceFailpoint", {
|
|
82
84
|
readonly hit: ThreadMaintenanceFailpointHandler;
|
|
@@ -112,25 +114,49 @@ declare const ThreadPublication_base: Context.ServiceClass<ThreadPublication, "@
|
|
|
112
114
|
export declare class ThreadPublication extends ThreadPublication_base {
|
|
113
115
|
static readonly layer: Layer.Layer<ThreadPublication, never, never>;
|
|
114
116
|
}
|
|
117
|
+
declare const ThreadMaintenanceActivity_base: Context.ServiceClass<ThreadMaintenanceActivity, "@effect-agent/platform-cloudflare/ThreadMaintenanceActivity", {
|
|
118
|
+
/**
|
|
119
|
+
* Account for one finite selection/dispatch, through joined completion or interruption.
|
|
120
|
+
* Register before reading/claiming work. After dispatch closes the body is not started.
|
|
121
|
+
* Host waves retain their declared allowance from this call; message Claims keep the driver's
|
|
122
|
+
* own deadline. Waiting for notifications belongs outside this bracket.
|
|
123
|
+
*/
|
|
124
|
+
readonly run: <R>(wave: Effect.Effect<void, DurableAlarmError, R>) => Effect.Effect<void, DurableAlarmError, R>;
|
|
125
|
+
/** Acknowledge all initial subscriptions/scans. Composite hosts use `all` below. */
|
|
126
|
+
readonly ready: Effect.Effect<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Acquire an independent scoped subscription before the initial scan and `ready`.
|
|
129
|
+
* The returned wait observes coalesced native scan hints, including those published before
|
|
130
|
+
* its first execution. Each hint requests a current local due-work check.
|
|
131
|
+
*/
|
|
132
|
+
readonly subscribeChanges: Effect.Effect<Effect.Effect<void>, never, Scope.Scope>;
|
|
133
|
+
}>;
|
|
134
|
+
/** Event-local accounting shared by the existing maintenance pumps and native scheduler. */
|
|
135
|
+
export declare class ThreadMaintenanceActivity extends ThreadMaintenanceActivity_base {
|
|
136
|
+
/** Join child pumps; acknowledge the parent only after every child is ready or has exited. */
|
|
137
|
+
static readonly all: <A, E, R>(lanes: readonly Effect.Effect<A, E, R>[]) => Effect.Effect<readonly A[], E, R | ThreadMaintenanceActivity>;
|
|
138
|
+
}
|
|
115
139
|
/**
|
|
116
140
|
* Host-assembled native message recovery. The driver bounds each actual Claim and persists its
|
|
117
141
|
* timeout/retry before this pump returns. Do not add a second timer starting at batch selection:
|
|
118
142
|
* local Claim setup may take time, and expiration still owes the driver's local retry commit.
|
|
119
143
|
*/
|
|
120
144
|
export declare const ThreadMessageDelivery: Context.Reference<{
|
|
121
|
-
readonly drainUntil: (dispatchClosed: Effect.Effect<void>, dispatchUntil: DateTime.Utc) => Effect.Effect<void, DurableAlarmError, Scope.Scope>;
|
|
145
|
+
readonly drainUntil: (dispatchClosed: Effect.Effect<void>, dispatchUntil: DateTime.Utc) => Effect.Effect<void, DurableAlarmError, Scope.Scope | ThreadMaintenanceActivity>;
|
|
122
146
|
readonly pendingDeadline: Effect.Effect<Option.Option<number>, DurableAlarmError>;
|
|
123
147
|
}>;
|
|
124
148
|
/**
|
|
125
149
|
* Application obligations sharing this Object's alarm. Admit one initial external wave even on
|
|
126
|
-
* a caught-up pass, then respond to wakes
|
|
127
|
-
*
|
|
128
|
-
*
|
|
150
|
+
* a caught-up pass, then respond to wakes and ThreadMaintenanceActivity.subscribeChanges until
|
|
151
|
+
* dispatchClosed. Yield the event's ThreadMaintenanceActivity to bracket each finite lane with
|
|
152
|
+
* run and acknowledge initial setup with ready.
|
|
153
|
+
* Passive subscriptions do not count as active work. Closure stops both new waves and native
|
|
154
|
+
* Attempts; local admission/control subscriptions belong to the event Scope until teardown.
|
|
129
155
|
* No deadline sleeps or automatic retry loops. Return after already-admitted waves finish.
|
|
130
156
|
*
|
|
131
157
|
* Declare a finite whole-wave allowance (1..300000ms): maximum for parallel lanes, sum for
|
|
132
158
|
* sequential operations. Admit a wave only if its allowance fits before dispatchUntil. Later
|
|
133
|
-
* arrivals cannot renew
|
|
159
|
+
* arrivals cannot renew an admitted wave's allowance. Maintenance bounds each registered wave,
|
|
134
160
|
* interrupts and joins event Scope, then reads local deadlines under the mutation gate.
|
|
135
161
|
*
|
|
136
162
|
* Setup and pendingDeadline are bounded local operations. Persist claims/envelopes before
|
|
@@ -141,11 +167,28 @@ export declare const ThreadMessageDelivery: Context.Reference<{
|
|
|
141
167
|
*/
|
|
142
168
|
export declare const ThreadHostMaintenance: Context.Reference<{
|
|
143
169
|
readonly dispatchTimeoutMillis: number;
|
|
144
|
-
readonly drainUntil: (dispatchClosed: Effect.Effect<void>, dispatchUntil: DateTime.Utc) => Effect.Effect<void, DurableAlarmError, Scope.Scope>;
|
|
170
|
+
readonly drainUntil: (dispatchClosed: Effect.Effect<void>, dispatchUntil: DateTime.Utc) => Effect.Effect<void, DurableAlarmError, Scope.Scope | ThreadMaintenanceActivity>;
|
|
145
171
|
readonly pendingDeadline: Effect.Effect<Option.Option<number>, DurableAlarmError>;
|
|
146
172
|
}>;
|
|
147
173
|
/** @internal A committed source operation must not become a failed operation because delivery failed. */
|
|
148
174
|
export declare const publishCommitted: Effect.Effect<void, never, ThreadPublication>;
|
|
175
|
+
declare const ThreadRecoveryFault_base: Schema.Class<ThreadRecoveryFault, Schema.Struct<{
|
|
176
|
+
readonly schemaVersion: Schema.Literal<1>;
|
|
177
|
+
readonly threadId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ThreadId">;
|
|
178
|
+
readonly firstFailedAt: Schema.Finite;
|
|
179
|
+
readonly lastFailedAt: Schema.Finite;
|
|
180
|
+
/** Earliest automatic recovery retry; new admissions do not erase this deadline. */
|
|
181
|
+
readonly retryAt: Schema.Finite;
|
|
182
|
+
/** Saturates at 2^31 - 1; one observation per Thread per recovery sweep. */
|
|
183
|
+
readonly attempts: Schema.Int;
|
|
184
|
+
readonly failure: typeof RecoveryFailure;
|
|
185
|
+
}>, {}>;
|
|
186
|
+
/**
|
|
187
|
+
* A durable observation of blocked recovery, independent of the execution journal. This is
|
|
188
|
+
* neither a Settlement nor proof that external effects did not happen. A successful recovery
|
|
189
|
+
* sweep clears it; repair must preserve canonical history and the original admission identity.
|
|
190
|
+
*/
|
|
191
|
+
export declare class ThreadRecoveryFault extends ThreadRecoveryFault_base {}
|
|
149
192
|
declare const ThreadMutationGate_base: Context.ServiceClass<ThreadMutationGate, "@effect-agent/platform-cloudflare/internal/ThreadMutationGate", {
|
|
150
193
|
readonly withMutation: <A, E, R>(body: Effect.Effect<A, E, R>,
|
|
151
194
|
/**
|
|
@@ -175,6 +218,13 @@ declare const ThreadMaintenance_base: Context.ServiceClass<ThreadMaintenance, "@
|
|
|
175
218
|
* generation has an alarm. It never scans the ledger or canonical history.
|
|
176
219
|
*/
|
|
177
220
|
readonly ensureAlarm: Effect.Effect<void, MaintenancePassFailure>;
|
|
221
|
+
/**
|
|
222
|
+
* Authorize `explain`, then read one bounded local record without reading execution history.
|
|
223
|
+
* None means no recorded fault, not proof of health or settlement. The host authenticates
|
|
224
|
+
* callers and verifies local Thread membership before exposing this service across RPC.
|
|
225
|
+
* Provide OperationAuthorizer when constructing this Layer, as for DurableAgentRuntime.
|
|
226
|
+
*/
|
|
227
|
+
readonly recoveryStatus: (threadId: ThreadId) => Effect.Effect<Option.Option<ThreadRecoveryFault>, DurableAlarmError | OperationDenied>;
|
|
178
228
|
/**
|
|
179
229
|
* Serialize the pre-arm boundary with pass acknowledgement, advance the durable dirty
|
|
180
230
|
* generation and arm the alarm in one transaction BEFORE running the caller's mutation.
|
|
@@ -191,17 +241,17 @@ declare const ThreadMaintenance_base: Context.ServiceClass<ThreadMaintenance, "@
|
|
|
191
241
|
* recovery, ledger scans or canonical-history reads.
|
|
192
242
|
* 2. Reconcile before each head Attempt, then checkpoint only the observed generation. A racing
|
|
193
243
|
* producer keeps its newer generation dirty. Native retries retain their durable backoff.
|
|
194
|
-
* 3.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* 4. Native message delivery retains its driver-owned Claim deadline. Host/backfill
|
|
244
|
+
* 3. Keep native and delivery admission open together while finite waves remain active, so
|
|
245
|
+
* fresh replies and abort controls can progress during unrelated cleanup. Close atomically
|
|
246
|
+
* at quiescence, or at the original ten-minute yield deadline, before retiring listeners.
|
|
247
|
+
* 4. Native message delivery retains its driver-owned Claim deadline. Host/backfill waves are
|
|
198
248
|
* bounded independently; incoming native work never restarts or cancels their attempts.
|
|
199
249
|
* Auxiliary failures are reported after the current native opportunity.
|
|
200
250
|
* 5. Close every event resource before the final gated deadline snapshot and alarm decision.
|
|
201
251
|
* The whole event retains one fourteen-minute cooperative timeout.
|
|
202
252
|
*/
|
|
203
253
|
export declare class ThreadMaintenance extends ThreadMaintenance_base {
|
|
204
|
-
static readonly layer: Layer.Layer<ThreadMaintenance, never, ThreadMutationGate | ThreadPublication | ThreadProjectionMaintenance | DurableAgentRuntime | SubmissionLedger | WakeScheduler | DurableAlarmService | ThreadMaintenanceFailpoint | CloudflareDurableRuntimeConfig | DurableObjectContext | SqlClient>;
|
|
254
|
+
static readonly layer: Layer.Layer<ThreadMaintenance, never, ThreadMutationGate | ThreadPublication | ThreadProjectionMaintenance | DurableAgentRuntime | DurableRuntimeConfig | SubmissionLedger | WakeScheduler | DurableAlarmService | ThreadMaintenanceFailpoint | CloudflareDurableRuntimeConfig | DurableObjectContext | SqlClient>;
|
|
205
255
|
}
|
|
206
256
|
//#endregion
|
|
207
257
|
export { Alarm_d_exports as t };
|