effect-agent 0.1.0-beta.103 → 0.1.0-beta.106
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/{Agent-CM6JubNX.d.mts → Agent-Bk-mLtov.d.mts} +2 -2
- package/dist/{AgentError-CggcAQ7V.d.mts → AgentError-Bn1ytXRD.d.mts} +20 -4
- package/dist/{AgentRuntime-B1SXMVN7.d.mts → AgentRuntime-BEXToYl1.d.mts} +8 -8
- package/dist/{AgentRuntime-BWOnNc0d.mjs → AgentRuntime-e2M5UoXn.mjs} +4 -3
- package/dist/AgentRuntime-e2M5UoXn.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-C9eRZS9N.mjs → DurableAgentRuntime-wd1x0TcB.mjs} +67 -36
- package/dist/DurableAgentRuntime-wd1x0TcB.mjs.map +1 -0
- package/dist/{EventSource-K7XUzurY.d.mts → EventSource-pH-v0k42.d.mts} +3 -3
- package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
- package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
- package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
- package/dist/{Messaging-QMYhp297.d.mts → Messaging-Bl4SBKpR.d.mts} +3 -3
- package/dist/{MessagingHost-gAxs5gme.d.mts → MessagingHost-nwBMdRoh.d.mts} +3 -3
- package/dist/{Output-CjocJzsl.d.mts → Output-B6RQ5jRU.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-KLk5rGFI.d.mts → PreparedInputAdmission-D3-BgmA9.d.mts} +8 -4
- package/dist/{Records-Bidb7ByL.d.mts → Records-B4S02MX1.d.mts} +201 -14
- package/dist/{RunJournal-srpbEBEy.mjs → RunJournal-BdIlgAEj.mjs} +2 -2
- package/dist/{RunJournal-srpbEBEy.mjs.map → RunJournal-BdIlgAEj.mjs.map} +1 -1
- package/dist/{RunOptions-Bruk54SE.d.mts → RunOptions-qOcPv08p.d.mts} +10 -5
- package/dist/{Schedule-Cy9up8Uf.d.mts → Schedule-D2TVEu3W.d.mts} +7 -2
- package/dist/{Scheduling-CHCsSCGo.mjs → Scheduling-DPb2QyAK.mjs} +2 -2
- package/dist/{Scheduling-CHCsSCGo.mjs.map → Scheduling-DPb2QyAK.mjs.map} +1 -1
- package/dist/{Subagent-DP0CzO16.d.mts → Subagent-BxuDuCHt.d.mts} +172 -8
- package/dist/{Subagent-C2s8PFrd.mjs → Subagent-uXWHXiKb.mjs} +64 -29
- package/dist/Subagent-uXWHXiKb.mjs.map +1 -0
- package/dist/{SubagentHost-CYcxkpRc.d.mts → SubagentHost-DEPw4YME.d.mts} +6 -3
- package/dist/{Subscription-CHyoQelH.d.mts → Subscription-nX0rz4GQ.d.mts} +3 -3
- package/dist/{SubscriptionInput-DqrHW-Ja.d.mts → SubscriptionInput-CAG3_pyJ.d.mts} +3 -3
- package/dist/{Worker--j87JI__.d.mts → Worker-Bbj9uq5H.d.mts} +5 -2
- package/dist/{agent-registration-ByeHejH3.mjs → agent-registration-B5CI-Ygk.mjs} +7 -5
- package/dist/agent-registration-B5CI-Ygk.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Messaging.d.mts +2 -2
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +2 -2
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/AgentError.d.mts +2 -2
- package/dist/core/AgentError.mjs +19 -2
- package/dist/core/AgentError.mjs.map +1 -1
- package/dist/core/FailureDiagnostic.d.mts +2 -0
- package/dist/core/FailureDiagnostic.mjs +2 -0
- package/dist/core/Worker.d.mts +1 -1
- package/dist/core/Worker.mjs +4 -1
- package/dist/core/Worker.mjs.map +1 -1
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/ActivityStore.mjs +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/Admin.mjs +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/AgentRegistration.mjs +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/CommittedActivity.mjs +1 -1
- package/dist/durable/Digest.d.mts +1 -1
- package/dist/durable/Digest.mjs +7 -7
- package/dist/durable/Digest.mjs.map +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/EventSource.mjs +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/GitHubWorkflowSource.mjs +1 -1
- package/dist/durable/MessageDelivery.d.mts +15 -3
- package/dist/durable/MessageDelivery.mjs +44 -24
- package/dist/durable/MessageDelivery.mjs.map +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +4 -1
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/PreparedInputAdmission.mjs +8 -4
- package/dist/durable/PreparedInputAdmission.mjs.map +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Records.mjs +831 -2
- package/dist/durable/Records.mjs.map +1 -0
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/Recovery.mjs +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/Schedule.mjs +12 -3
- package/dist/durable/Schedule.mjs.map +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleStoreConformance.mjs +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/ScheduleTransition.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +2 -2
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SqlMessageDeliveryStore.mjs +13 -11
- package/dist/durable/SqlMessageDeliveryStore.mjs.map +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +2 -2
- package/dist/durable/SqlStorageV2Upgrade.mjs +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +2 -2
- package/dist/durable/SqlSubscriptionStore.mjs +1 -1
- package/dist/durable/SqlThreadNativeReads.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.mjs +2 -2
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +6 -3
- package/dist/durable/SubmissionLedger.mjs.map +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +1 -1
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +2 -2
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
- package/dist/durable/SubscriptionTools.d.mts +3 -3
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/SubscriptionTransition.mjs +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadInvariants.mjs +2 -2
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjection.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +2 -2
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +1 -1
- package/dist/durable/ToolReconciler.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +3 -3
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/RunOptions.mjs +2 -0
- package/dist/engine/RunOptions.mjs.map +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/engine/SubagentHost.mjs.map +1 -1
- package/dist/index.d.mts +18 -17
- package/dist/index.mjs +8 -7
- package/package.json +1 -1
- package/src/capabilities/internal/subagent-background.ts +66 -23
- package/src/capabilities/internal/subagent-contract.ts +4 -0
- package/src/core/AgentError.ts +20 -0
- package/src/core/FailureDiagnostic.ts +343 -0
- package/src/core/Worker.ts +4 -1
- package/src/durable/Digest.ts +22 -28
- package/src/durable/DurableAgentRuntime.ts +37 -13
- package/src/durable/MessageDelivery.ts +82 -24
- package/src/durable/PreparedInputAdmission.ts +17 -4
- package/src/durable/Records.ts +5 -15
- package/src/durable/Schedule.ts +11 -2
- package/src/durable/SqlMessageDeliveryStore.ts +21 -9
- package/src/durable/SubmissionLedger.ts +4 -1
- package/src/durable/internal/agent-registration.ts +46 -14
- package/src/durable/internal/worker-host.ts +32 -19
- package/src/engine/RunOptions.ts +11 -3
- package/src/engine/SubagentHost.ts +3 -0
- package/src/engine/internal/agent-runtime.ts +23 -16
- package/src/index.ts +1 -0
- package/dist/AgentRuntime-BWOnNc0d.mjs.map +0 -1
- package/dist/DurableAgentRuntime-C9eRZS9N.mjs.map +0 -1
- package/dist/Records-D8167fHn.mjs +0 -844
- package/dist/Records-D8167fHn.mjs.map +0 -1
- package/dist/Subagent-C2s8PFrd.mjs.map +0 -1
- package/dist/agent-registration-ByeHejH3.mjs.map +0 -1
|
@@ -2,10 +2,11 @@ import { u as ThreadId } from "../Identifiers-CN2s30fF.mjs";
|
|
|
2
2
|
import { d as SubagentReservationAmounts, l as SubagentGrant, o as SubagentDelegationCaps, s as SubagentExecutionFailure } from "../SubagentContract-DdT7Cqe6.mjs";
|
|
3
3
|
import { a as Receipt, t as IdempotencyKey } from "../Receipt-BAHyigAF.mjs";
|
|
4
4
|
import { r as Update } from "../AgentUpdates-DMJ-_xow.mjs";
|
|
5
|
+
import { a as FailureDiagnostic_d_exports, r as Diagnostic } from "../FailureDiagnostic-CaAkzGHL.mjs";
|
|
5
6
|
import { t as AgentPolicy } from "../AgentPolicy-BqDoSXO6.mjs";
|
|
6
|
-
import { co as Settlement, h as DefinitionDigests } from "../Records-
|
|
7
|
-
import { a as PreparedInput } from "../Subscription-
|
|
8
|
-
import { t as PreparedInputAdmission } from "../PreparedInputAdmission-
|
|
7
|
+
import { co as Settlement, h as DefinitionDigests } from "../Records-B4S02MX1.mjs";
|
|
8
|
+
import { a as PreparedInput } from "../Subscription-nX0rz4GQ.mjs";
|
|
9
|
+
import { t as PreparedInputAdmission } from "../PreparedInputAdmission-D3-BgmA9.mjs";
|
|
9
10
|
import { Context, Crypto, Effect, Layer, Result, Schema } from "effect";
|
|
10
11
|
declare namespace MessageDelivery_d_exports {
|
|
11
12
|
export { MessageDeliveryChange, MessageDeliveryDriver, MessageDeliveryDriverLimits, MessageDeliveryError, MessageDeliveryFailpoint, MessageDeliveryFailpointError, MessageDeliveryFailure, MessageDeliveryKey, MessageDeliveryPage, MessageDeliveryPageRequest, MessageDeliveryPolicy, MessageDeliveryRecord, MessageDeliveryStore, MessageDeliveryStoreLimits, applyMessageDeliveryChange, defaultMessageDeliveryPolicy, defaultMessageDeliveryStoreLimits, isWorkerUpdateDelivery, messageDeliveryCapacity, messageDeliveryDeadline, messageDeliveryKeyString, messageDeliveryUsesCapacity, prepareMessageDelivery, readPending, sameMessageDeliveryIdentity, validateMessageDelivery };
|
|
@@ -198,9 +199,13 @@ export declare const MessageDeliveryRecord: Schema.Struct<{
|
|
|
198
199
|
readonly lastAttemptAtMillis: Schema.NullOr<Schema.Int>;
|
|
199
200
|
readonly lastFailure: Schema.NullOr<Schema.Literals<readonly ["transport", "capacity", "storage", "host-closed", "timeout", "ambiguous"]>>;
|
|
200
201
|
}>;
|
|
202
|
+
/** Last failed admission/status check, retained across retries and successful recovery. */
|
|
203
|
+
readonly lastFailureDiagnostic: Schema.optionalKey<Schema.Codec<Diagnostic, Diagnostic, never, never>>;
|
|
201
204
|
}>;
|
|
202
205
|
export type MessageDeliveryRecord = typeof MessageDeliveryRecord.Type;
|
|
203
206
|
declare const MessageDeliveryError_base: Schema.Class<MessageDeliveryError, Schema.TaggedStruct<"MessageDeliveryError", {
|
|
207
|
+
readonly cause: Schema.optionalKey<Schema.decodeTo<Schema.Unknown, Schema.Codec<Diagnostic, Diagnostic, never, never>, never, never>>;
|
|
208
|
+
readonly stack: Schema.optionalKey<Schema.String>;
|
|
204
209
|
readonly reason: Schema.Literals<readonly ["validation", "conflict", "capacity", "not-found", "storage", "corrupt"]>;
|
|
205
210
|
readonly operation: Schema.String;
|
|
206
211
|
}>, import("effect/Cause").YieldableError>;
|
|
@@ -236,16 +241,19 @@ export declare const MessageDeliveryChange: Schema.Union<readonly [Schema.Struct
|
|
|
236
241
|
readonly nowMillis: Schema.Int;
|
|
237
242
|
readonly _tag: Schema.Literal<"Refuse">;
|
|
238
243
|
readonly code: Schema.String;
|
|
244
|
+
readonly diagnostic: Schema.optionalKey<Schema.Codec<Diagnostic, Diagnostic, never, never>>;
|
|
239
245
|
}>, Schema.Struct<{
|
|
240
246
|
readonly expectedVersion: Schema.Int;
|
|
241
247
|
readonly nowMillis: Schema.Int;
|
|
242
248
|
readonly _tag: Schema.Literal<"Retry">;
|
|
243
249
|
readonly reason: Schema.Literals<readonly ["transport", "capacity", "storage", "host-closed", "timeout", "ambiguous"]>;
|
|
250
|
+
readonly diagnostic: Schema.optionalKey<Schema.Codec<Diagnostic, Diagnostic, never, never>>;
|
|
244
251
|
}>, Schema.Struct<{
|
|
245
252
|
readonly expectedVersion: Schema.Int;
|
|
246
253
|
readonly nowMillis: Schema.Int;
|
|
247
254
|
readonly _tag: Schema.Literal<"Park">;
|
|
248
255
|
readonly reason: Schema.Literals<readonly ["exhausted", "deadline", "status-unavailable"]>;
|
|
256
|
+
readonly diagnostic: Schema.optionalKey<Schema.Codec<Diagnostic, Diagnostic, never, never>>;
|
|
249
257
|
}>, Schema.Struct<{
|
|
250
258
|
readonly expectedVersion: Schema.Int;
|
|
251
259
|
readonly nowMillis: Schema.Int;
|
|
@@ -430,6 +438,8 @@ export declare const MessageDeliveryPage: Schema.Struct<{
|
|
|
430
438
|
readonly lastAttemptAtMillis: Schema.NullOr<Schema.Int>;
|
|
431
439
|
readonly lastFailure: Schema.NullOr<Schema.Literals<readonly ["transport", "capacity", "storage", "host-closed", "timeout", "ambiguous"]>>;
|
|
432
440
|
}>;
|
|
441
|
+
/** Last failed admission/status check, retained across retries and successful recovery. */
|
|
442
|
+
readonly lastFailureDiagnostic: Schema.optionalKey<Schema.Codec<Diagnostic, Diagnostic, never, never>>;
|
|
433
443
|
}>>;
|
|
434
444
|
readonly next: Schema.NullOr<Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/IdempotencyKey">>;
|
|
435
445
|
}>;
|
|
@@ -624,6 +634,7 @@ export declare const readPending: (request: Pick<{
|
|
|
624
634
|
readonly lastAttemptAtMillis: number | null;
|
|
625
635
|
readonly lastFailure: "ambiguous" | "capacity" | "host-closed" | "storage" | "timeout" | "transport" | null;
|
|
626
636
|
};
|
|
637
|
+
readonly lastFailureDiagnostic?: Diagnostic | undefined;
|
|
627
638
|
}[], MessageDeliveryError, MessageDeliveryStore>;
|
|
628
639
|
export declare const messageDeliveryKeyString: (key: MessageDeliveryKey) => string;
|
|
629
640
|
export declare const messageDeliveryUsesCapacity: (record: MessageDeliveryRecord) => boolean;
|
|
@@ -805,6 +816,7 @@ export declare const prepareMessageDelivery: (options: {
|
|
|
805
816
|
readonly lastAttemptAtMillis: number | null;
|
|
806
817
|
readonly lastFailure: "ambiguous" | "capacity" | "host-closed" | "storage" | "timeout" | "transport" | null;
|
|
807
818
|
};
|
|
819
|
+
readonly lastFailureDiagnostic?: Diagnostic | undefined;
|
|
808
820
|
}, MessageDeliveryError, Crypto.Crypto>;
|
|
809
821
|
/** Pure reducer used under the adapter's atomic compare-and-swap boundary. */
|
|
810
822
|
export declare const applyMessageDeliveryChange: (record: MessageDeliveryRecord, change: MessageDeliveryChange) => Result.Result<MessageDeliveryRecord, MessageDeliveryError>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { ThreadId } from "../core/Identifiers.mjs";
|
|
3
3
|
import { IdempotencyKey, Receipt } from "../core/Receipt.mjs";
|
|
4
|
+
import { o as Value, r as Diagnostic, s as capture } from "../FailureDiagnostic-BElLOoED.mjs";
|
|
4
5
|
import { WorkerUpdate } from "../core/Worker.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { Digest } from "./Records.mjs";
|
|
6
7
|
import { Settlement } from "./SubmissionLedger.mjs";
|
|
7
8
|
import { digestJson } from "./Digest.mjs";
|
|
8
9
|
import { ScheduleInstant, ScheduleRetry, ScheduleRetryReason } from "./Schedule.mjs";
|
|
@@ -103,9 +104,13 @@ const MessageDeliveryRecord = Schema.Struct({
|
|
|
103
104
|
refusal: Schema.NullOr(BoundedName),
|
|
104
105
|
parkReason: Schema.NullOr(ParkReason),
|
|
105
106
|
leaseUntilMillis: Schema.NullOr(ScheduleInstant),
|
|
106
|
-
retry: ScheduleRetry
|
|
107
|
+
retry: ScheduleRetry,
|
|
108
|
+
/** Last failed admission/status check, retained across retries and successful recovery. */
|
|
109
|
+
lastFailureDiagnostic: Schema.optionalKey(Diagnostic)
|
|
107
110
|
}).check(Schema.makeFilter((record) => record.deadlineAtMillis > record.createdAtMillis && record.initialDeadlineAtMillis > record.createdAtMillis && record.predecessor !== record.key.messageId && record.status === "processed" === (record.settlement !== null) && record.status === "refused" === (record.refusal !== null) && record.status === "parked" === (record.parkReason !== null) && record.status === "parked" === record.retry.parked && (record.status === "accepted" || record.status === "processed" ? record.receipt !== null : true) && (record.status === "pending" || record.status === "refused" ? record.receipt === null : true) && (record.receipt === null || record.receipt.threadId === record.envelope.threadId) && (record.settlement === null || record.settlement.receiptId === record.receipt?.receiptId && record.settlement.submissionId === record.receipt.submissionId) && (record.status === "processed" || record.status === "refused" || record.status === "parked" ? record.leaseUntilMillis === null : true)));
|
|
108
111
|
var MessageDeliveryError = class extends Schema.TaggedError()("MessageDeliveryError", {
|
|
112
|
+
cause: Schema.optionalKey(Value),
|
|
113
|
+
stack: Schema.optionalKey(Schema.String),
|
|
109
114
|
reason: Schema.Literals([
|
|
110
115
|
"validation",
|
|
111
116
|
"conflict",
|
|
@@ -144,17 +149,20 @@ const MessageDeliveryChange = Schema.Union([
|
|
|
144
149
|
Schema.Struct({
|
|
145
150
|
_tag: Schema.Literal("Refuse"),
|
|
146
151
|
...fence,
|
|
147
|
-
code: BoundedName
|
|
152
|
+
code: BoundedName,
|
|
153
|
+
diagnostic: Schema.optionalKey(Diagnostic)
|
|
148
154
|
}),
|
|
149
155
|
Schema.Struct({
|
|
150
156
|
_tag: Schema.Literal("Retry"),
|
|
151
157
|
...fence,
|
|
152
|
-
reason: ScheduleRetryReason
|
|
158
|
+
reason: ScheduleRetryReason,
|
|
159
|
+
diagnostic: Schema.optionalKey(Diagnostic)
|
|
153
160
|
}),
|
|
154
161
|
Schema.Struct({
|
|
155
162
|
_tag: Schema.Literal("Park"),
|
|
156
163
|
...fence,
|
|
157
|
-
reason: ParkReason
|
|
164
|
+
reason: ParkReason,
|
|
165
|
+
diagnostic: Schema.optionalKey(Diagnostic)
|
|
158
166
|
}),
|
|
159
167
|
Schema.Struct({
|
|
160
168
|
_tag: Schema.Literal("Recover"),
|
|
@@ -221,9 +229,10 @@ const messageDeliveryCapacity = (limits, update) => ({
|
|
|
221
229
|
const messageDeliveryDeadline = (record) => record.status === "pending" || record.status === "accepted" ? Math.min(record.deadlineAtMillis, record.leaseUntilMillis ?? record.retry.nextAttemptAtMillis) : null;
|
|
222
230
|
/** Creation identity deliberately excludes operational counters and renewed recovery deadlines. */
|
|
223
231
|
const sameMessageDeliveryIdentity = (left, right) => messageDeliveryKeyString(left.key) === messageDeliveryKeyString(right.key) && left.envelopeDigest === right.envelopeDigest && left.predecessor === right.predecessor && Schema.toEquivalence(PreparedInput)(left.envelope, right.envelope) && Schema.toEquivalence(MessageDeliveryPolicy)(left.policy, right.policy) && left.createdAtMillis === right.createdAtMillis && left.initialDeadlineAtMillis === right.initialDeadlineAtMillis;
|
|
224
|
-
const error = (reason, operation) => MessageDeliveryError.make({
|
|
232
|
+
const error = (reason, operation, cause) => MessageDeliveryError.make({
|
|
225
233
|
reason,
|
|
226
|
-
operation
|
|
234
|
+
operation,
|
|
235
|
+
...cause === void 0 ? {} : { cause }
|
|
227
236
|
});
|
|
228
237
|
const validateMessageDelivery = (schema, value, operation) => Schema.decodeUnknownEffect(Schema.toType(schema))(value).pipe(Effect.mapError(() => error("validation", operation)));
|
|
229
238
|
const MessageDeliveryPreparation = Schema.Struct({
|
|
@@ -239,11 +248,11 @@ const prepareMessageDelivery = Effect.fn("MessageDelivery.prepare")(function* (o
|
|
|
239
248
|
const snapshot = yield* Schema.encodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))({
|
|
240
249
|
...options,
|
|
241
250
|
policy: options.policy ?? defaultMessageDeliveryPolicy
|
|
242
|
-
}).pipe(Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))), Effect.mapError(() => error("validation", "prepare")));
|
|
251
|
+
}).pipe(Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))), Effect.mapError((cause) => error("validation", "prepare", cause)));
|
|
243
252
|
const envelope = snapshot.envelope;
|
|
244
|
-
const encoded = yield* Schema.encodeEffect(PreparedInput)(envelope).pipe(Effect.mapError(() => error("validation", "prepare")));
|
|
245
|
-
if ((yield* digestJson(encoded.input).pipe(Effect.mapError(() => error("storage", "digest")))) !== envelope.inputDigest) return yield* error("corrupt", "input-digest");
|
|
246
|
-
const envelopeDigest = yield* digestJson(encoded).pipe(Effect.mapError(() => error("storage", "digest")));
|
|
253
|
+
const encoded = yield* Schema.encodeEffect(PreparedInput)(envelope).pipe(Effect.mapError((cause) => error("validation", "prepare", cause)));
|
|
254
|
+
if ((yield* digestJson(encoded.input).pipe(Effect.mapError((cause) => error("storage", "digest", cause)))) !== envelope.inputDigest) return yield* error("corrupt", "input-digest");
|
|
255
|
+
const envelopeDigest = yield* digestJson(encoded).pipe(Effect.mapError((cause) => error("storage", "digest", cause)));
|
|
247
256
|
return yield* validateMessageDelivery(MessageDeliveryRecord, {
|
|
248
257
|
schemaVersion: 1,
|
|
249
258
|
key: snapshot.key,
|
|
@@ -280,7 +289,8 @@ const applyMessageDeliveryChange = (record, change) => {
|
|
|
280
289
|
const now = change.nowMillis;
|
|
281
290
|
const base = {
|
|
282
291
|
...record,
|
|
283
|
-
version: record.version + 1
|
|
292
|
+
version: record.version + 1,
|
|
293
|
+
..."diagnostic" in change && change.diagnostic !== void 0 ? { lastFailureDiagnostic: change.diagnostic } : {}
|
|
284
294
|
};
|
|
285
295
|
const parked = (reason) => ({
|
|
286
296
|
...base,
|
|
@@ -448,8 +458,8 @@ var MessageDeliveryDriver = class MessageDeliveryDriver extends Context.Service(
|
|
|
448
458
|
nowMillis
|
|
449
459
|
});
|
|
450
460
|
if (claimed.status === "parked") return claimed;
|
|
451
|
-
const envelope = yield* Schema.encodeEffect(PreparedInput)(claimed.envelope).pipe(Effect.mapError(() => error("corrupt", "envelope")));
|
|
452
|
-
if ((yield* digestJson(envelope).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.mapError(() => error("storage", "digest")))) !== claimed.envelopeDigest) return yield* error("corrupt", "envelope-digest");
|
|
461
|
+
const envelope = yield* Schema.encodeEffect(PreparedInput)(claimed.envelope).pipe(Effect.mapError((cause) => error("corrupt", "envelope", cause)));
|
|
462
|
+
if ((yield* digestJson(envelope).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.mapError((cause) => error("storage", "digest", cause)))) !== claimed.envelopeDigest) return yield* error("corrupt", "envelope-digest");
|
|
453
463
|
const timeout = Math.min(claimed.policy.attemptTimeoutMillis, (claimed.leaseUntilMillis ?? claimed.deadlineAtMillis) - (yield* Clock.currentTimeMillis));
|
|
454
464
|
if (timeout <= 0) return claimed;
|
|
455
465
|
const commit = (change) => Clock.currentTimeMillis.pipe(Effect.flatMap((time) => store.change(key, {
|
|
@@ -458,7 +468,7 @@ var MessageDeliveryDriver = class MessageDeliveryDriver extends Context.Service(
|
|
|
458
468
|
nowMillis: time
|
|
459
469
|
})));
|
|
460
470
|
if (claimed.status === "pending") {
|
|
461
|
-
const outcome = yield* admitPreparedInput(admission.submit(claimed.envelope), timeout).pipe(Effect.mapError(() => error("corrupt", "admission")));
|
|
471
|
+
const outcome = yield* admitPreparedInput(admission.submit(claimed.envelope), timeout).pipe(Effect.mapError((cause) => error("corrupt", "admission", cause)));
|
|
462
472
|
yield* failpoint.hit("message-delivery:admission:after");
|
|
463
473
|
if (outcome._tag === "Receipt") return yield* commit({
|
|
464
474
|
_tag: "Accept",
|
|
@@ -466,11 +476,13 @@ var MessageDeliveryDriver = class MessageDeliveryDriver extends Context.Service(
|
|
|
466
476
|
});
|
|
467
477
|
if (outcome._tag === "Refused") return yield* commit({
|
|
468
478
|
_tag: "Refuse",
|
|
469
|
-
code: outcome.error.code
|
|
479
|
+
code: outcome.error.code,
|
|
480
|
+
diagnostic: capture(outcome.error)
|
|
470
481
|
});
|
|
471
482
|
return yield* commit({
|
|
472
483
|
_tag: "Retry",
|
|
473
|
-
reason: outcome.reason
|
|
484
|
+
reason: outcome.reason,
|
|
485
|
+
diagnostic: outcome.diagnostic
|
|
474
486
|
});
|
|
475
487
|
}
|
|
476
488
|
if (claimed.receipt === null) return yield* error("corrupt", "receipt");
|
|
@@ -483,17 +495,24 @@ var MessageDeliveryDriver = class MessageDeliveryDriver extends Context.Service(
|
|
|
483
495
|
status
|
|
484
496
|
})), Effect.catchTag("ScheduledInputRetryable", (failure) => Effect.succeed({
|
|
485
497
|
_tag: "Retry",
|
|
486
|
-
reason: failure.reason
|
|
487
|
-
|
|
498
|
+
reason: failure.reason,
|
|
499
|
+
diagnostic: capture(failure)
|
|
500
|
+
})), Effect.catchTag("ScheduledInputRefused", (failure) => Effect.succeed({
|
|
501
|
+
_tag: "Unavailable",
|
|
502
|
+
diagnostic: capture(failure)
|
|
503
|
+
})), Effect.catchTag("TimeoutError", (failure) => Effect.succeed({
|
|
488
504
|
_tag: "Retry",
|
|
489
|
-
reason: "timeout"
|
|
505
|
+
reason: "timeout",
|
|
506
|
+
diagnostic: capture(failure)
|
|
490
507
|
})), Effect.catchTag("ScheduleStorageError", (failure) => failure.reason === "unavailable" ? Effect.succeed({
|
|
491
508
|
_tag: "Retry",
|
|
492
|
-
reason: "storage"
|
|
493
|
-
|
|
509
|
+
reason: "storage",
|
|
510
|
+
diagnostic: capture(failure)
|
|
511
|
+
}) : Effect.fail(error("corrupt", "status", failure))));
|
|
494
512
|
if (status._tag === "Unavailable") return yield* commit({
|
|
495
513
|
_tag: "Park",
|
|
496
|
-
reason: "status-unavailable"
|
|
514
|
+
reason: "status-unavailable",
|
|
515
|
+
diagnostic: status.diagnostic
|
|
497
516
|
});
|
|
498
517
|
if (status._tag === "Status" && status.status._tag === "settled") return yield* commit({
|
|
499
518
|
_tag: "Process",
|
|
@@ -502,7 +521,8 @@ var MessageDeliveryDriver = class MessageDeliveryDriver extends Context.Service(
|
|
|
502
521
|
if (status._tag === "Status") return yield* commit({ _tag: "ObservePending" });
|
|
503
522
|
return yield* commit({
|
|
504
523
|
_tag: "Retry",
|
|
505
|
-
reason: status.reason
|
|
524
|
+
reason: status.reason,
|
|
525
|
+
diagnostic: status.diagnostic
|
|
506
526
|
});
|
|
507
527
|
})).pipe(Effect.catchTag("MessageDeliveryError", (failure) => failure.reason === "conflict" ? store.get(key).pipe(Effect.filterOrFail((record) => record !== null, () => failure)) : Effect.fail(failure))));
|
|
508
528
|
return MessageDeliveryDriver.of({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageDelivery.mjs","names":[],"sources":["../../src/durable/MessageDelivery.ts"],"sourcesContent":["import { Clock, Context, Crypto, Effect, Layer, Result, Schema, Semaphore } from \"effect\";\n\nimport { ThreadId } from \"../core/Identifiers.ts\";\nimport { Receipt } from \"../core/Receipt.ts\";\nimport { WorkerUpdate } from \"../core/Worker.ts\";\nimport { digestJson } from \"./Digest.ts\";\nimport { admitPreparedInput, PreparedInputAdmission } from \"./PreparedInputAdmission.ts\";\nimport { Digest } from \"./Records.ts\";\nimport { ScheduleInstant, ScheduleRetry, ScheduleRetryReason } from \"./Schedule.ts\";\nimport { IdempotencyKey, Settlement } from \"./SubmissionLedger.ts\";\nimport { PreparedInput } from \"./Subscription.ts\";\n\nconst Positive = Schema.Int.check(Schema.isGreaterThan(0));\nconst BoundedName = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256));\n\n/** An owner is always a source Thread. Destination admission has its own frozen key. */\nexport const MessageDeliveryKey = Schema.Struct({\n ownerThreadId: ThreadId,\n messageId: IdempotencyKey,\n});\n\nexport type MessageDeliveryKey = typeof MessageDeliveryKey.Type;\n\nexport const MessageDeliveryPolicy = Schema.Struct({\n maxAutomaticAttempts: Positive.check(Schema.isLessThanOrEqualTo(100)),\n attemptTimeoutMillis: Positive.check(Schema.isLessThanOrEqualTo(300_000)),\n retryBaseMillis: Positive,\n retryMaxMillis: Positive,\n settlementPollMillis: Positive,\n}).check(Schema.makeFilter((value) => value.retryBaseMillis <= value.retryMaxMillis));\n\nexport type MessageDeliveryPolicy = typeof MessageDeliveryPolicy.Type;\n\nexport const defaultMessageDeliveryPolicy: MessageDeliveryPolicy = {\n maxAutomaticAttempts: 8,\n attemptTimeoutMillis: 30_000,\n retryBaseMillis: 1_000,\n retryMaxMillis: 60_000,\n settlementPollMillis: 5_000,\n};\n\nexport const MessageDeliveryStoreLimits = Schema.Struct({\n maxPendingPerOwner: Positive,\n maxRetainedPerOwner: Positive,\n maxEnvelopeBytes: Positive,\n /** Separate update capacity preserves the full ordinary allowance for terminal reports. */\n maxPendingUpdatesPerOwner: Schema.optionalKey(Positive),\n maxRetainedUpdatesPerOwner: Schema.optionalKey(Positive),\n}).check(\n Schema.makeFilter(\n (value) =>\n value.maxPendingPerOwner <= value.maxRetainedPerOwner &&\n (value.maxPendingUpdatesPerOwner ?? 32) <= (value.maxRetainedUpdatesPerOwner ?? 256),\n ),\n);\n\nexport type MessageDeliveryStoreLimits = typeof MessageDeliveryStoreLimits.Type;\n\nexport const defaultMessageDeliveryStoreLimits: MessageDeliveryStoreLimits = {\n maxPendingPerOwner: 100,\n maxRetainedPerOwner: 1_000,\n maxEnvelopeBytes: 262_144,\n maxPendingUpdatesPerOwner: 32,\n maxRetainedUpdatesPerOwner: 256,\n};\n\nconst ParkReason = Schema.Literals([\"exhausted\", \"deadline\", \"status-unavailable\"]);\n\nexport const MessageDeliveryRecord = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n envelopeDigest: Digest,\n /** Same-owner predecessor whose admission must be known before this message is submitted. */\n predecessor: Schema.optionalKey(IdempotencyKey),\n createdAtMillis: ScheduleInstant,\n /** Immutable creation identity; explicit recovery only renews deadlineAtMillis. */\n initialDeadlineAtMillis: ScheduleInstant,\n deadlineAtMillis: ScheduleInstant,\n policy: MessageDeliveryPolicy,\n version: Positive,\n status: Schema.Literals([\"pending\", \"accepted\", \"processed\", \"refused\", \"parked\"]),\n receipt: Schema.NullOr(Receipt),\n settlement: Schema.NullOr(Settlement),\n refusal: Schema.NullOr(BoundedName),\n parkReason: Schema.NullOr(ParkReason),\n leaseUntilMillis: Schema.NullOr(ScheduleInstant),\n retry: ScheduleRetry,\n}).check(\n Schema.makeFilter(\n (record) =>\n record.deadlineAtMillis > record.createdAtMillis &&\n record.initialDeadlineAtMillis > record.createdAtMillis &&\n record.predecessor !== record.key.messageId &&\n (record.status === \"processed\") === (record.settlement !== null) &&\n (record.status === \"refused\") === (record.refusal !== null) &&\n (record.status === \"parked\") === (record.parkReason !== null) &&\n (record.status === \"parked\") === record.retry.parked &&\n (record.status === \"accepted\" || record.status === \"processed\"\n ? record.receipt !== null\n : true) &&\n (record.status === \"pending\" || record.status === \"refused\"\n ? record.receipt === null\n : true) &&\n (record.receipt === null || record.receipt.threadId === record.envelope.threadId) &&\n (record.settlement === null ||\n (record.settlement.receiptId === record.receipt?.receiptId &&\n record.settlement.submissionId === record.receipt.submissionId)) &&\n (record.status === \"processed\" || record.status === \"refused\" || record.status === \"parked\"\n ? record.leaseUntilMillis === null\n : true),\n ),\n);\n\nexport type MessageDeliveryRecord = typeof MessageDeliveryRecord.Type;\n\nexport class MessageDeliveryError extends Schema.TaggedError<MessageDeliveryError>()(\n \"MessageDeliveryError\",\n {\n reason: Schema.Literals([\n \"validation\",\n \"conflict\",\n \"capacity\",\n \"not-found\",\n \"storage\",\n \"corrupt\",\n ]),\n operation: Schema.String,\n },\n) {}\n\nexport class MessageDeliveryFailpointError extends Schema.TaggedError<MessageDeliveryFailpointError>()(\n \"MessageDeliveryFailpointError\",\n {\n point: Schema.String,\n },\n) {}\n\nexport type MessageDeliveryFailure = MessageDeliveryError | MessageDeliveryFailpointError;\n\nexport const MessageDeliveryFailpoint = Context.Reference<{\n readonly hit: (point: string) => Effect.Effect<void, MessageDeliveryFailpointError>;\n}>(\"@effect-agent/thread/MessageDeliveryFailpoint\", {\n defaultValue: () => ({ hit: () => Effect.void }),\n});\n\nconst fence = { expectedVersion: Positive, nowMillis: ScheduleInstant };\n\nexport const MessageDeliveryChange = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Claim\"), ...fence }),\n Schema.Struct({ _tag: Schema.Literal(\"Accept\"), ...fence, receipt: Receipt }),\n Schema.Struct({ _tag: Schema.Literal(\"Process\"), ...fence, settlement: Settlement }),\n Schema.Struct({ _tag: Schema.Literal(\"ObservePending\"), ...fence }),\n Schema.Struct({ _tag: Schema.Literal(\"Refuse\"), ...fence, code: BoundedName }),\n Schema.Struct({ _tag: Schema.Literal(\"Retry\"), ...fence, reason: ScheduleRetryReason }),\n Schema.Struct({ _tag: Schema.Literal(\"Park\"), ...fence, reason: ParkReason }),\n Schema.Struct({ _tag: Schema.Literal(\"Recover\"), ...fence, deadlineAtMillis: ScheduleInstant }),\n /** Waiting for earlier admission never spends an automatic transport attempt. */\n Schema.Struct({ _tag: Schema.Literal(\"Defer\"), ...fence, untilMillis: ScheduleInstant }),\n]);\n\nexport type MessageDeliveryChange = typeof MessageDeliveryChange.Type;\n\nexport const MessageDeliveryPageRequest = Schema.Struct({\n ownerThreadId: ThreadId,\n limit: Positive.check(Schema.isLessThanOrEqualTo(4096)),\n after: Schema.optionalKey(IdempotencyKey),\n /** Native pending index, including accepted, future-due and parked obligations. */\n pendingOnly: Schema.optionalKey(Schema.Boolean),\n});\n\nexport type MessageDeliveryPageRequest = typeof MessageDeliveryPageRequest.Type;\n\nexport const MessageDeliveryPage = Schema.Struct({\n items: Schema.Array(MessageDeliveryRecord),\n next: Schema.NullOr(IdempotencyKey),\n});\n\nexport type MessageDeliveryPage = typeof MessageDeliveryPage.Type;\n\n/**\n * Trusted host port, independent of either Thread's active Submission. List/get require an owner.\n * Inserts and changes are atomic; identical inserts return current state even after completion.\n * No automatic deletion: completed rows retain deduplication evidence and count toward retention.\n * `due`/`nextDeadline` are bounded host recovery seams, never model-facing management operations.\n */\nexport class MessageDeliveryStore extends Context.Service<\n MessageDeliveryStore,\n {\n readonly limits: MessageDeliveryStoreLimits;\n readonly maxStoredValueBytes: number;\n readonly insert: (\n record: MessageDeliveryRecord,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n readonly get: (\n key: MessageDeliveryKey,\n ) => Effect.Effect<MessageDeliveryRecord | null, MessageDeliveryError>;\n readonly list: (\n request: MessageDeliveryPageRequest,\n ) => Effect.Effect<MessageDeliveryPage, MessageDeliveryError>;\n readonly change: (\n key: MessageDeliveryKey,\n change: MessageDeliveryChange,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n readonly due: (\n nowMillis: number,\n limit: number,\n ownerThreadId?: ThreadId,\n ) => Effect.Effect<ReadonlyArray<MessageDeliveryKey>, MessageDeliveryError>;\n readonly nextDeadline: (\n ownerThreadId?: ThreadId,\n ) => Effect.Effect<number | null, MessageDeliveryError>;\n }\n>()(\"@effect-agent/thread/MessageDeliveryStore\") {}\n\n/**\n * Read current source-owned obligations without acquiring a runtime or scanning completed history.\n * A retained receipt is native accepted-admission evidence, not proof of destination materialization.\n * Shipped worker admission reserves the source input before returning that receipt. Policy can\n * therefore leave accepted worker discovery to canonical outstanding inputs; a no-receipt action\n * delivery remains uncertain, including when parked or due in the future.\n */\nexport const readPending = Effect.fn(\"MessageDelivery.readPending\")(function* (\n request: Pick<MessageDeliveryPageRequest, \"ownerThreadId\" | \"limit\">,\n) {\n const store = yield* MessageDeliveryStore;\n\n const input = yield* validateMessageDelivery(\n MessageDeliveryPageRequest,\n {\n ownerThreadId: request.ownerThreadId,\n limit: request.limit,\n pendingOnly: true,\n },\n \"read-pending\",\n );\n\n const page = yield* validateMessageDelivery(\n MessageDeliveryPage,\n yield* store.list(input),\n \"read-pending result\",\n );\n\n if (page.next !== null || page.items.length > input.limit)\n return yield* MessageDeliveryError.make({ reason: \"capacity\", operation: \"read-pending\" });\n const records = page.items;\n\n if (\n records.some(\n (record) =>\n record.key.ownerThreadId !== input.ownerThreadId || !messageDeliveryUsesCapacity(record),\n ) ||\n new Set(records.map((record) => record.key.messageId)).size !== records.length\n )\n return yield* MessageDeliveryError.make({\n reason: \"corrupt\",\n operation: \"read-pending result\",\n });\n\n return records;\n});\n\nexport const messageDeliveryKeyString = (key: MessageDeliveryKey): string =>\n JSON.stringify([key.ownerThreadId, key.messageId]);\n\nexport const messageDeliveryUsesCapacity = (record: MessageDeliveryRecord): boolean =>\n record.status !== \"processed\" && record.status !== \"refused\";\n\nexport const isWorkerUpdateDelivery = (record: MessageDeliveryRecord): boolean =>\n Schema.is(WorkerUpdate)(record.envelope.messageAdmission);\n\nexport const messageDeliveryCapacity = (limits: MessageDeliveryStoreLimits, update: boolean) => ({\n pending: update ? (limits.maxPendingUpdatesPerOwner ?? 32) : limits.maxPendingPerOwner,\n retained: update ? (limits.maxRetainedUpdatesPerOwner ?? 256) : limits.maxRetainedPerOwner,\n});\n\nexport const messageDeliveryDeadline = (record: MessageDeliveryRecord): number | null =>\n record.status === \"pending\" || record.status === \"accepted\"\n ? Math.min(record.deadlineAtMillis, record.leaseUntilMillis ?? record.retry.nextAttemptAtMillis)\n : null;\n\n/** Creation identity deliberately excludes operational counters and renewed recovery deadlines. */\nexport const sameMessageDeliveryIdentity = (\n left: MessageDeliveryRecord,\n right: MessageDeliveryRecord,\n): boolean =>\n messageDeliveryKeyString(left.key) === messageDeliveryKeyString(right.key) &&\n left.envelopeDigest === right.envelopeDigest &&\n left.predecessor === right.predecessor &&\n Schema.toEquivalence(PreparedInput)(left.envelope, right.envelope) &&\n Schema.toEquivalence(MessageDeliveryPolicy)(left.policy, right.policy) &&\n left.createdAtMillis === right.createdAtMillis &&\n left.initialDeadlineAtMillis === right.initialDeadlineAtMillis;\n\nconst error = (reason: MessageDeliveryError[\"reason\"], operation: string) =>\n MessageDeliveryError.make({ reason, operation });\n\nexport const validateMessageDelivery = <A, I>(\n schema: Schema.Codec<A, I>,\n value: unknown,\n operation: string,\n) =>\n Schema.decodeUnknownEffect(Schema.toType(schema))(value).pipe(\n Effect.mapError(() => error(\"validation\", operation)),\n );\n\nconst MessageDeliveryPreparation = Schema.Struct({\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n createdAtMillis: ScheduleInstant,\n deadlineAtMillis: ScheduleInstant,\n policy: MessageDeliveryPolicy,\n predecessor: Schema.optionalKey(IdempotencyKey),\n});\n\n/** Freeze and digest the complete admission envelope before publishing the obligation. */\nexport const prepareMessageDelivery = Effect.fn(\"MessageDelivery.prepare\")(function* (options: {\n readonly key: MessageDeliveryKey;\n readonly envelope: PreparedInput;\n readonly createdAtMillis: number;\n readonly deadlineAtMillis: number;\n readonly policy?: MessageDeliveryPolicy;\n readonly predecessor?: IdempotencyKey;\n}): Effect.fn.Return<MessageDeliveryRecord, MessageDeliveryError, Crypto.Crypto> {\n // JSON detaches every caller-owned value before Crypto can suspend preparation.\n const snapshot = yield* Schema.encodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))({\n ...options,\n policy: options.policy ?? defaultMessageDeliveryPolicy,\n }).pipe(\n Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))),\n Effect.mapError(() => error(\"validation\", \"prepare\")),\n );\n\n const envelope = snapshot.envelope;\n\n const encoded = yield* Schema.encodeEffect(PreparedInput)(envelope).pipe(\n Effect.mapError(() => error(\"validation\", \"prepare\")),\n );\n\n const inputDigest = yield* digestJson(encoded.input).pipe(\n Effect.mapError(() => error(\"storage\", \"digest\")),\n );\n\n if (inputDigest !== envelope.inputDigest) return yield* error(\"corrupt\", \"input-digest\");\n\n const envelopeDigest = yield* digestJson(encoded).pipe(\n Effect.mapError(() => error(\"storage\", \"digest\")),\n );\n\n return yield* validateMessageDelivery(\n MessageDeliveryRecord,\n {\n schemaVersion: 1,\n key: snapshot.key,\n envelope,\n envelopeDigest,\n ...(snapshot.predecessor === undefined ? {} : { predecessor: snapshot.predecessor }),\n createdAtMillis: snapshot.createdAtMillis,\n initialDeadlineAtMillis: snapshot.deadlineAtMillis,\n deadlineAtMillis: snapshot.deadlineAtMillis,\n policy: snapshot.policy,\n version: 1,\n status: \"pending\",\n receipt: null,\n settlement: null,\n refusal: null,\n parkReason: null,\n leaseUntilMillis: null,\n retry: {\n attempts: 0,\n generation: 0,\n automaticAttempts: 0,\n parked: false,\n nextAttemptAtMillis: snapshot.createdAtMillis,\n lastAttemptAtMillis: null,\n lastFailure: null,\n },\n },\n \"prepare\",\n );\n});\n\n/** Pure reducer used under the adapter's atomic compare-and-swap boundary. */\nexport const applyMessageDeliveryChange = (\n record: MessageDeliveryRecord,\n change: MessageDeliveryChange,\n): Result.Result<MessageDeliveryRecord, MessageDeliveryError> => {\n const conflict = () => Result.fail(error(\"conflict\", change._tag));\n\n if (record.version !== change.expectedVersion) return conflict();\n if (record.status === \"processed\" || record.status === \"refused\") return conflict();\n const now = change.nowMillis;\n const base = { ...record, version: record.version + 1 };\n\n const parked = (reason: typeof ParkReason.Type): MessageDeliveryRecord => ({\n ...base,\n status: \"parked\",\n parkReason: reason,\n leaseUntilMillis: null,\n retry: { ...record.retry, parked: true },\n });\n\n if (change._tag === \"Defer\") {\n if (\n record.status !== \"pending\" ||\n (record.leaseUntilMillis !== null && record.leaseUntilMillis > now)\n )\n return conflict();\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n if (change.untilMillis <= now) return conflict();\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n nextAttemptAtMillis: Math.min(change.untilMillis, record.deadlineAtMillis),\n },\n });\n }\n\n if (change._tag === \"Recover\") {\n if (record.status !== \"parked\" || change.deadlineAtMillis <= now) return conflict();\n\n return Result.succeed({\n ...base,\n deadlineAtMillis: change.deadlineAtMillis,\n status: record.receipt === null ? \"pending\" : \"accepted\",\n parkReason: null,\n retry: {\n ...record.retry,\n generation: record.retry.generation + 1,\n automaticAttempts: 0,\n parked: false,\n nextAttemptAtMillis: now,\n },\n });\n }\n if (record.status === \"parked\") return conflict();\n if (change._tag === \"Park\") return Result.succeed(parked(change.reason));\n if (change._tag === \"Claim\") {\n const due = messageDeliveryDeadline(record);\n\n if (due === null || due > now) return conflict();\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n if (record.retry.automaticAttempts >= record.policy.maxAutomaticAttempts)\n return Result.succeed(parked(\"exhausted\"));\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: Math.min(now + record.policy.attemptTimeoutMillis, record.deadlineAtMillis),\n retry: {\n ...record.retry,\n attempts: record.retry.attempts + 1,\n automaticAttempts: record.retry.automaticAttempts + 1,\n lastAttemptAtMillis: now,\n },\n });\n }\n if (record.leaseUntilMillis === null || now > record.leaseUntilMillis) return conflict();\n if (change._tag === \"Accept\") {\n if (record.status !== \"pending\") return conflict();\n if (change.receipt.threadId !== record.envelope.threadId)\n return Result.fail(error(\"corrupt\", \"receipt-identity\"));\n\n return Result.succeed({\n ...base,\n status: \"accepted\",\n receipt: change.receipt,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n automaticAttempts: 0,\n nextAttemptAtMillis: Math.min(\n now + record.policy.settlementPollMillis,\n record.deadlineAtMillis,\n ),\n lastFailure: null,\n },\n });\n }\n if (change._tag === \"Process\") {\n if (record.status !== \"accepted\") return conflict();\n if (\n change.settlement.submissionId !== record.receipt?.submissionId ||\n change.settlement.receiptId !== record.receipt.receiptId\n )\n return Result.fail(error(\"corrupt\", \"settlement-identity\"));\n\n return Result.succeed({\n ...base,\n status: \"processed\",\n settlement: change.settlement,\n leaseUntilMillis: null,\n });\n }\n if (change._tag === \"ObservePending\") {\n if (record.status !== \"accepted\") return conflict();\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n automaticAttempts: 0,\n lastFailure: null,\n nextAttemptAtMillis: Math.min(\n now + record.policy.settlementPollMillis,\n record.deadlineAtMillis,\n ),\n },\n });\n }\n if (change._tag === \"Refuse\") {\n if (record.status !== \"pending\") return conflict();\n\n return Result.succeed({\n ...base,\n status: \"refused\",\n refusal: change.code,\n leaseUntilMillis: null,\n });\n }\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n if (record.retry.automaticAttempts >= record.policy.maxAutomaticAttempts)\n return Result.succeed(parked(\"exhausted\"));\n\n const delay = Math.min(\n record.policy.retryBaseMillis * 2 ** Math.min(record.retry.automaticAttempts - 1, 52),\n record.policy.retryMaxMillis,\n );\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n nextAttemptAtMillis: Math.min(\n now + (record.status === \"accepted\" ? record.policy.settlementPollMillis : delay),\n record.deadlineAtMillis,\n ),\n lastFailure: change.reason,\n },\n });\n};\n\nexport const MessageDeliveryDriverLimits = Schema.Struct({\n batchSize: Positive.check(Schema.isLessThanOrEqualTo(100)),\n concurrency: Positive.check(Schema.isLessThanOrEqualTo(32)),\n});\n\nexport type MessageDeliveryDriverLimits = typeof MessageDeliveryDriverLimits.Type;\n\n/**\n * Finite, structured host pump. The host owns its Scope and wakes it from nextDeadline even\n * after source/receiver settlement. Failed or interrupted calls retain their expiring claim;\n * no ordinary tool is replayed here, only idempotent PreparedInput admission/status lookup.\n * Spans expose operation names; envelopes, principals, and message contents are never logged.\n */\nexport class MessageDeliveryDriver extends Context.Service<\n MessageDeliveryDriver,\n {\n readonly process: (\n key: MessageDeliveryKey,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n readonly runDue: (\n ownerThreadId?: ThreadId,\n ) => Effect.Effect<ReadonlyArray<MessageDeliveryRecord>, MessageDeliveryFailure>;\n readonly retry: (\n key: MessageDeliveryKey,\n expectedVersion: number,\n deadlineAtMillis: number,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n }\n>()(\"@effect-agent/thread/MessageDeliveryDriver\") {\n static layer(\n limits: MessageDeliveryDriverLimits = { batchSize: 100, concurrency: 4 },\n ): Layer.Layer<\n MessageDeliveryDriver,\n MessageDeliveryError,\n MessageDeliveryStore | PreparedInputAdmission | Crypto.Crypto\n > {\n return Layer.effect(\n MessageDeliveryDriver,\n Effect.gen(function* () {\n const config = yield* validateMessageDelivery(\n MessageDeliveryDriverLimits,\n limits,\n \"driver-limits\",\n );\n\n const store = yield* MessageDeliveryStore;\n const admission = yield* PreparedInputAdmission;\n const crypto = yield* Crypto.Crypto;\n const failpoint = yield* MessageDeliveryFailpoint;\n const semaphore = yield* Semaphore.make(config.concurrency);\n\n const process = Effect.fn(\"MessageDelivery.process\")((key: MessageDeliveryKey) =>\n semaphore\n .withPermit(\n Effect.gen(function* () {\n const current = yield* store.get(key);\n\n if (current === null) return yield* error(\"not-found\", \"process\");\n const nowMillis = yield* Clock.currentTimeMillis;\n const due = messageDeliveryDeadline(current);\n\n if (due === null || due > nowMillis) return current;\n\n if (current.status === \"pending\" && current.predecessor !== undefined) {\n const previous = yield* store.get({\n ownerThreadId: key.ownerThreadId,\n messageId: current.predecessor,\n });\n\n if (\n previous === null ||\n (previous.receipt === null && previous.status !== \"refused\")\n ) {\n return yield* store.change(key, {\n _tag: \"Defer\",\n expectedVersion: current.version,\n nowMillis,\n untilMillis: nowMillis + current.policy.settlementPollMillis,\n });\n }\n }\n\n const claimed = yield* store.change(key, {\n _tag: \"Claim\",\n expectedVersion: current.version,\n nowMillis,\n });\n\n if (claimed.status === \"parked\") return claimed;\n\n const envelope = yield* Schema.encodeEffect(PreparedInput)(claimed.envelope).pipe(\n Effect.mapError(() => error(\"corrupt\", \"envelope\")),\n );\n\n const digest = yield* digestJson(envelope).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n Effect.mapError(() => error(\"storage\", \"digest\")),\n );\n\n if (digest !== claimed.envelopeDigest)\n return yield* error(\"corrupt\", \"envelope-digest\");\n\n const timeout = Math.min(\n claimed.policy.attemptTimeoutMillis,\n (claimed.leaseUntilMillis ?? claimed.deadlineAtMillis) -\n (yield* Clock.currentTimeMillis),\n );\n\n // Digest computation cannot extend this claim's admission authority.\n if (timeout <= 0) return claimed;\n\n type WithoutFence<T> = T extends MessageDeliveryChange\n ? Omit<T, \"expectedVersion\" | \"nowMillis\">\n : never;\n\n const commit = (change: WithoutFence<MessageDeliveryChange>) =>\n Clock.currentTimeMillis.pipe(\n Effect.flatMap((time) =>\n store.change(key, {\n ...change,\n expectedVersion: claimed.version,\n nowMillis: time,\n }),\n ),\n );\n\n if (claimed.status === \"pending\") {\n const outcome = yield* admitPreparedInput(\n admission.submit(claimed.envelope),\n timeout,\n ).pipe(Effect.mapError(() => error(\"corrupt\", \"admission\")));\n\n yield* failpoint.hit(\"message-delivery:admission:after\");\n if (outcome._tag === \"Receipt\")\n return yield* commit({ _tag: \"Accept\", receipt: outcome.receipt });\n if (outcome._tag === \"Refused\")\n return yield* commit({ _tag: \"Refuse\", code: outcome.error.code });\n\n return yield* commit({ _tag: \"Retry\", reason: outcome.reason });\n }\n if (claimed.receipt === null) return yield* error(\"corrupt\", \"receipt\");\n if (admission.submissionStatus === undefined)\n return yield* commit({ _tag: \"Park\", reason: \"status-unavailable\" });\n\n const status = yield* admission.submissionStatus(claimed.receipt).pipe(\n Effect.timeout(timeout),\n Effect.map((status) => ({ _tag: \"Status\" as const, status })),\n Effect.catchTag(\"ScheduledInputRetryable\", (failure) =>\n Effect.succeed({ _tag: \"Retry\" as const, reason: failure.reason }),\n ),\n Effect.catchTag(\"ScheduledInputRefused\", () =>\n Effect.succeed({ _tag: \"Unavailable\" as const }),\n ),\n Effect.catchTag(\"TimeoutError\", () =>\n Effect.succeed({ _tag: \"Retry\" as const, reason: \"timeout\" as const }),\n ),\n Effect.catchTag(\"ScheduleStorageError\", (failure) =>\n failure.reason === \"unavailable\"\n ? Effect.succeed({ _tag: \"Retry\" as const, reason: \"storage\" as const })\n : Effect.fail(error(\"corrupt\", \"status\")),\n ),\n );\n\n if (status._tag === \"Unavailable\")\n return yield* commit({ _tag: \"Park\", reason: \"status-unavailable\" });\n if (status._tag === \"Status\" && status.status._tag === \"settled\")\n return yield* commit({ _tag: \"Process\", settlement: status.status.settlement });\n if (status._tag === \"Status\") return yield* commit({ _tag: \"ObservePending\" });\n\n return yield* commit({ _tag: \"Retry\", reason: status.reason });\n }),\n )\n .pipe(\n Effect.catchTag(\"MessageDeliveryError\", (failure) =>\n failure.reason === \"conflict\"\n ? store.get(key).pipe(\n Effect.filterOrFail(\n (record) => record !== null,\n () => failure,\n ),\n )\n : Effect.fail(failure),\n ),\n ),\n );\n\n return MessageDeliveryDriver.of({\n process,\n runDue: Effect.fn(\"MessageDelivery.runDue\")(function* (ownerThreadId) {\n const keys = yield* store.due(\n yield* Clock.currentTimeMillis,\n config.batchSize,\n ownerThreadId,\n );\n\n return yield* Effect.forEach(keys, process, { concurrency: config.concurrency });\n }),\n retry: Effect.fn(\"MessageDelivery.retry\")(\n function* (key, expectedVersion, deadlineAtMillis) {\n return yield* store.change(key, {\n _tag: \"Recover\",\n expectedVersion,\n deadlineAtMillis,\n nowMillis: yield* Clock.currentTimeMillis,\n });\n },\n ),\n });\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,WAAW,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AACzD,MAAM,cAAc,OAAO,OAAO,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,GAAG,CAAC;;AAGtF,MAAa,qBAAqB,OAAO,OAAO;CAC9C,eAAe;CACf,WAAW;AACb,CAAC;AAID,MAAa,wBAAwB,OAAO,OAAO;CACjD,sBAAsB,SAAS,MAAM,OAAO,oBAAoB,GAAG,CAAC;CACpE,sBAAsB,SAAS,MAAM,OAAO,oBAAoB,GAAO,CAAC;CACxE,iBAAiB;CACjB,gBAAgB;CAChB,sBAAsB;AACxB,CAAC,CAAC,CAAC,MAAM,OAAO,YAAY,UAAU,MAAM,mBAAmB,MAAM,cAAc,CAAC;AAIpF,MAAa,+BAAsD;CACjE,sBAAsB;CACtB,sBAAsB;CACtB,iBAAiB;CACjB,gBAAgB;CAChB,sBAAsB;AACxB;AAEA,MAA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ACN;MACA;MACA,WAAW,OAAO,MAAM;KAC1B,CAAC;IACH,CACF;GACF,CAAC;EACH,CAAC,CACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"MessageDelivery.mjs","names":["FailureDiagnostic.Diagnostic","FailureDiagnostic.Value","FailureDiagnostic.capture"],"sources":["../../src/durable/MessageDelivery.ts"],"sourcesContent":["import { Clock, Context, Crypto, Effect, Layer, Result, Schema, Semaphore } from \"effect\";\n\nimport * as FailureDiagnostic from \"../core/FailureDiagnostic.ts\";\nimport { ThreadId } from \"../core/Identifiers.ts\";\nimport { Receipt } from \"../core/Receipt.ts\";\nimport { WorkerUpdate } from \"../core/Worker.ts\";\nimport { digestJson } from \"./Digest.ts\";\nimport { admitPreparedInput, PreparedInputAdmission } from \"./PreparedInputAdmission.ts\";\nimport { Digest } from \"./Records.ts\";\nimport { ScheduleInstant, ScheduleRetry, ScheduleRetryReason } from \"./Schedule.ts\";\nimport { IdempotencyKey, Settlement } from \"./SubmissionLedger.ts\";\nimport { PreparedInput } from \"./Subscription.ts\";\n\nconst Positive = Schema.Int.check(Schema.isGreaterThan(0));\nconst BoundedName = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256));\n\n/** An owner is always a source Thread. Destination admission has its own frozen key. */\nexport const MessageDeliveryKey = Schema.Struct({\n ownerThreadId: ThreadId,\n messageId: IdempotencyKey,\n});\n\nexport type MessageDeliveryKey = typeof MessageDeliveryKey.Type;\n\nexport const MessageDeliveryPolicy = Schema.Struct({\n maxAutomaticAttempts: Positive.check(Schema.isLessThanOrEqualTo(100)),\n attemptTimeoutMillis: Positive.check(Schema.isLessThanOrEqualTo(300_000)),\n retryBaseMillis: Positive,\n retryMaxMillis: Positive,\n settlementPollMillis: Positive,\n}).check(Schema.makeFilter((value) => value.retryBaseMillis <= value.retryMaxMillis));\n\nexport type MessageDeliveryPolicy = typeof MessageDeliveryPolicy.Type;\n\nexport const defaultMessageDeliveryPolicy: MessageDeliveryPolicy = {\n maxAutomaticAttempts: 8,\n attemptTimeoutMillis: 30_000,\n retryBaseMillis: 1_000,\n retryMaxMillis: 60_000,\n settlementPollMillis: 5_000,\n};\n\nexport const MessageDeliveryStoreLimits = Schema.Struct({\n maxPendingPerOwner: Positive,\n maxRetainedPerOwner: Positive,\n maxEnvelopeBytes: Positive,\n /** Separate update capacity preserves the full ordinary allowance for terminal reports. */\n maxPendingUpdatesPerOwner: Schema.optionalKey(Positive),\n maxRetainedUpdatesPerOwner: Schema.optionalKey(Positive),\n}).check(\n Schema.makeFilter(\n (value) =>\n value.maxPendingPerOwner <= value.maxRetainedPerOwner &&\n (value.maxPendingUpdatesPerOwner ?? 32) <= (value.maxRetainedUpdatesPerOwner ?? 256),\n ),\n);\n\nexport type MessageDeliveryStoreLimits = typeof MessageDeliveryStoreLimits.Type;\n\nexport const defaultMessageDeliveryStoreLimits: MessageDeliveryStoreLimits = {\n maxPendingPerOwner: 100,\n maxRetainedPerOwner: 1_000,\n maxEnvelopeBytes: 262_144,\n maxPendingUpdatesPerOwner: 32,\n maxRetainedUpdatesPerOwner: 256,\n};\n\nconst ParkReason = Schema.Literals([\"exhausted\", \"deadline\", \"status-unavailable\"]);\n\nexport const MessageDeliveryRecord = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n envelopeDigest: Digest,\n /** Same-owner predecessor whose admission must be known before this message is submitted. */\n predecessor: Schema.optionalKey(IdempotencyKey),\n createdAtMillis: ScheduleInstant,\n /** Immutable creation identity; explicit recovery only renews deadlineAtMillis. */\n initialDeadlineAtMillis: ScheduleInstant,\n deadlineAtMillis: ScheduleInstant,\n policy: MessageDeliveryPolicy,\n version: Positive,\n status: Schema.Literals([\"pending\", \"accepted\", \"processed\", \"refused\", \"parked\"]),\n receipt: Schema.NullOr(Receipt),\n settlement: Schema.NullOr(Settlement),\n refusal: Schema.NullOr(BoundedName),\n parkReason: Schema.NullOr(ParkReason),\n leaseUntilMillis: Schema.NullOr(ScheduleInstant),\n retry: ScheduleRetry,\n /** Last failed admission/status check, retained across retries and successful recovery. */\n lastFailureDiagnostic: Schema.optionalKey(FailureDiagnostic.Diagnostic),\n}).check(\n Schema.makeFilter(\n (record) =>\n record.deadlineAtMillis > record.createdAtMillis &&\n record.initialDeadlineAtMillis > record.createdAtMillis &&\n record.predecessor !== record.key.messageId &&\n (record.status === \"processed\") === (record.settlement !== null) &&\n (record.status === \"refused\") === (record.refusal !== null) &&\n (record.status === \"parked\") === (record.parkReason !== null) &&\n (record.status === \"parked\") === record.retry.parked &&\n (record.status === \"accepted\" || record.status === \"processed\"\n ? record.receipt !== null\n : true) &&\n (record.status === \"pending\" || record.status === \"refused\"\n ? record.receipt === null\n : true) &&\n (record.receipt === null || record.receipt.threadId === record.envelope.threadId) &&\n (record.settlement === null ||\n (record.settlement.receiptId === record.receipt?.receiptId &&\n record.settlement.submissionId === record.receipt.submissionId)) &&\n (record.status === \"processed\" || record.status === \"refused\" || record.status === \"parked\"\n ? record.leaseUntilMillis === null\n : true),\n ),\n);\n\nexport type MessageDeliveryRecord = typeof MessageDeliveryRecord.Type;\n\nexport class MessageDeliveryError extends Schema.TaggedError<MessageDeliveryError>()(\n \"MessageDeliveryError\",\n {\n cause: Schema.optionalKey(FailureDiagnostic.Value),\n stack: Schema.optionalKey(Schema.String),\n reason: Schema.Literals([\n \"validation\",\n \"conflict\",\n \"capacity\",\n \"not-found\",\n \"storage\",\n \"corrupt\",\n ]),\n operation: Schema.String,\n },\n) {}\n\nexport class MessageDeliveryFailpointError extends Schema.TaggedError<MessageDeliveryFailpointError>()(\n \"MessageDeliveryFailpointError\",\n {\n point: Schema.String,\n },\n) {}\n\nexport type MessageDeliveryFailure = MessageDeliveryError | MessageDeliveryFailpointError;\n\nexport const MessageDeliveryFailpoint = Context.Reference<{\n readonly hit: (point: string) => Effect.Effect<void, MessageDeliveryFailpointError>;\n}>(\"@effect-agent/thread/MessageDeliveryFailpoint\", {\n defaultValue: () => ({ hit: () => Effect.void }),\n});\n\nconst fence = { expectedVersion: Positive, nowMillis: ScheduleInstant };\n\nexport const MessageDeliveryChange = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Claim\"), ...fence }),\n Schema.Struct({ _tag: Schema.Literal(\"Accept\"), ...fence, receipt: Receipt }),\n Schema.Struct({ _tag: Schema.Literal(\"Process\"), ...fence, settlement: Settlement }),\n Schema.Struct({ _tag: Schema.Literal(\"ObservePending\"), ...fence }),\n Schema.Struct({\n _tag: Schema.Literal(\"Refuse\"),\n ...fence,\n code: BoundedName,\n diagnostic: Schema.optionalKey(FailureDiagnostic.Diagnostic),\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Retry\"),\n ...fence,\n reason: ScheduleRetryReason,\n diagnostic: Schema.optionalKey(FailureDiagnostic.Diagnostic),\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Park\"),\n ...fence,\n reason: ParkReason,\n diagnostic: Schema.optionalKey(FailureDiagnostic.Diagnostic),\n }),\n Schema.Struct({ _tag: Schema.Literal(\"Recover\"), ...fence, deadlineAtMillis: ScheduleInstant }),\n /** Waiting for earlier admission never spends an automatic transport attempt. */\n Schema.Struct({ _tag: Schema.Literal(\"Defer\"), ...fence, untilMillis: ScheduleInstant }),\n]);\n\nexport type MessageDeliveryChange = typeof MessageDeliveryChange.Type;\n\nexport const MessageDeliveryPageRequest = Schema.Struct({\n ownerThreadId: ThreadId,\n limit: Positive.check(Schema.isLessThanOrEqualTo(4096)),\n after: Schema.optionalKey(IdempotencyKey),\n /** Native pending index, including accepted, future-due and parked obligations. */\n pendingOnly: Schema.optionalKey(Schema.Boolean),\n});\n\nexport type MessageDeliveryPageRequest = typeof MessageDeliveryPageRequest.Type;\n\nexport const MessageDeliveryPage = Schema.Struct({\n items: Schema.Array(MessageDeliveryRecord),\n next: Schema.NullOr(IdempotencyKey),\n});\n\nexport type MessageDeliveryPage = typeof MessageDeliveryPage.Type;\n\n/**\n * Trusted host port, independent of either Thread's active Submission. List/get require an owner.\n * Inserts and changes are atomic; identical inserts return current state even after completion.\n * No automatic deletion: completed rows retain deduplication evidence and count toward retention.\n * `due`/`nextDeadline` are bounded host recovery seams, never model-facing management operations.\n */\nexport class MessageDeliveryStore extends Context.Service<\n MessageDeliveryStore,\n {\n readonly limits: MessageDeliveryStoreLimits;\n readonly maxStoredValueBytes: number;\n readonly insert: (\n record: MessageDeliveryRecord,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n readonly get: (\n key: MessageDeliveryKey,\n ) => Effect.Effect<MessageDeliveryRecord | null, MessageDeliveryError>;\n readonly list: (\n request: MessageDeliveryPageRequest,\n ) => Effect.Effect<MessageDeliveryPage, MessageDeliveryError>;\n readonly change: (\n key: MessageDeliveryKey,\n change: MessageDeliveryChange,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n readonly due: (\n nowMillis: number,\n limit: number,\n ownerThreadId?: ThreadId,\n ) => Effect.Effect<ReadonlyArray<MessageDeliveryKey>, MessageDeliveryError>;\n readonly nextDeadline: (\n ownerThreadId?: ThreadId,\n ) => Effect.Effect<number | null, MessageDeliveryError>;\n }\n>()(\"@effect-agent/thread/MessageDeliveryStore\") {}\n\n/**\n * Read current source-owned obligations without acquiring a runtime or scanning completed history.\n * A retained receipt is native accepted-admission evidence, not proof of destination materialization.\n * Shipped worker admission reserves the source input before returning that receipt. Policy can\n * therefore leave accepted worker discovery to canonical outstanding inputs; a no-receipt action\n * delivery remains uncertain, including when parked or due in the future.\n */\nexport const readPending = Effect.fn(\"MessageDelivery.readPending\")(function* (\n request: Pick<MessageDeliveryPageRequest, \"ownerThreadId\" | \"limit\">,\n) {\n const store = yield* MessageDeliveryStore;\n\n const input = yield* validateMessageDelivery(\n MessageDeliveryPageRequest,\n {\n ownerThreadId: request.ownerThreadId,\n limit: request.limit,\n pendingOnly: true,\n },\n \"read-pending\",\n );\n\n const page = yield* validateMessageDelivery(\n MessageDeliveryPage,\n yield* store.list(input),\n \"read-pending result\",\n );\n\n if (page.next !== null || page.items.length > input.limit)\n return yield* MessageDeliveryError.make({ reason: \"capacity\", operation: \"read-pending\" });\n const records = page.items;\n\n if (\n records.some(\n (record) =>\n record.key.ownerThreadId !== input.ownerThreadId || !messageDeliveryUsesCapacity(record),\n ) ||\n new Set(records.map((record) => record.key.messageId)).size !== records.length\n )\n return yield* MessageDeliveryError.make({\n reason: \"corrupt\",\n operation: \"read-pending result\",\n });\n\n return records;\n});\n\nexport const messageDeliveryKeyString = (key: MessageDeliveryKey): string =>\n JSON.stringify([key.ownerThreadId, key.messageId]);\n\nexport const messageDeliveryUsesCapacity = (record: MessageDeliveryRecord): boolean =>\n record.status !== \"processed\" && record.status !== \"refused\";\n\nexport const isWorkerUpdateDelivery = (record: MessageDeliveryRecord): boolean =>\n Schema.is(WorkerUpdate)(record.envelope.messageAdmission);\n\nexport const messageDeliveryCapacity = (limits: MessageDeliveryStoreLimits, update: boolean) => ({\n pending: update ? (limits.maxPendingUpdatesPerOwner ?? 32) : limits.maxPendingPerOwner,\n retained: update ? (limits.maxRetainedUpdatesPerOwner ?? 256) : limits.maxRetainedPerOwner,\n});\n\nexport const messageDeliveryDeadline = (record: MessageDeliveryRecord): number | null =>\n record.status === \"pending\" || record.status === \"accepted\"\n ? Math.min(record.deadlineAtMillis, record.leaseUntilMillis ?? record.retry.nextAttemptAtMillis)\n : null;\n\n/** Creation identity deliberately excludes operational counters and renewed recovery deadlines. */\nexport const sameMessageDeliveryIdentity = (\n left: MessageDeliveryRecord,\n right: MessageDeliveryRecord,\n): boolean =>\n messageDeliveryKeyString(left.key) === messageDeliveryKeyString(right.key) &&\n left.envelopeDigest === right.envelopeDigest &&\n left.predecessor === right.predecessor &&\n Schema.toEquivalence(PreparedInput)(left.envelope, right.envelope) &&\n Schema.toEquivalence(MessageDeliveryPolicy)(left.policy, right.policy) &&\n left.createdAtMillis === right.createdAtMillis &&\n left.initialDeadlineAtMillis === right.initialDeadlineAtMillis;\n\nconst error = (reason: MessageDeliveryError[\"reason\"], operation: string, cause?: unknown) =>\n MessageDeliveryError.make({ reason, operation, ...(cause === undefined ? {} : { cause }) });\n\nexport const validateMessageDelivery = <A, I>(\n schema: Schema.Codec<A, I>,\n value: unknown,\n operation: string,\n) =>\n Schema.decodeUnknownEffect(Schema.toType(schema))(value).pipe(\n Effect.mapError(() => error(\"validation\", operation)),\n );\n\nconst MessageDeliveryPreparation = Schema.Struct({\n key: MessageDeliveryKey,\n envelope: PreparedInput,\n createdAtMillis: ScheduleInstant,\n deadlineAtMillis: ScheduleInstant,\n policy: MessageDeliveryPolicy,\n predecessor: Schema.optionalKey(IdempotencyKey),\n});\n\n/** Freeze and digest the complete admission envelope before publishing the obligation. */\nexport const prepareMessageDelivery = Effect.fn(\"MessageDelivery.prepare\")(function* (options: {\n readonly key: MessageDeliveryKey;\n readonly envelope: PreparedInput;\n readonly createdAtMillis: number;\n readonly deadlineAtMillis: number;\n readonly policy?: MessageDeliveryPolicy;\n readonly predecessor?: IdempotencyKey;\n}): Effect.fn.Return<MessageDeliveryRecord, MessageDeliveryError, Crypto.Crypto> {\n // JSON detaches every caller-owned value before Crypto can suspend preparation.\n const snapshot = yield* Schema.encodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))({\n ...options,\n policy: options.policy ?? defaultMessageDeliveryPolicy,\n }).pipe(\n Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(MessageDeliveryPreparation))),\n Effect.mapError((cause) => error(\"validation\", \"prepare\", cause)),\n );\n\n const envelope = snapshot.envelope;\n\n const encoded = yield* Schema.encodeEffect(PreparedInput)(envelope).pipe(\n Effect.mapError((cause) => error(\"validation\", \"prepare\", cause)),\n );\n\n const inputDigest = yield* digestJson(encoded.input).pipe(\n Effect.mapError((cause) => error(\"storage\", \"digest\", cause)),\n );\n\n if (inputDigest !== envelope.inputDigest) return yield* error(\"corrupt\", \"input-digest\");\n\n const envelopeDigest = yield* digestJson(encoded).pipe(\n Effect.mapError((cause) => error(\"storage\", \"digest\", cause)),\n );\n\n return yield* validateMessageDelivery(\n MessageDeliveryRecord,\n {\n schemaVersion: 1,\n key: snapshot.key,\n envelope,\n envelopeDigest,\n ...(snapshot.predecessor === undefined ? {} : { predecessor: snapshot.predecessor }),\n createdAtMillis: snapshot.createdAtMillis,\n initialDeadlineAtMillis: snapshot.deadlineAtMillis,\n deadlineAtMillis: snapshot.deadlineAtMillis,\n policy: snapshot.policy,\n version: 1,\n status: \"pending\",\n receipt: null,\n settlement: null,\n refusal: null,\n parkReason: null,\n leaseUntilMillis: null,\n retry: {\n attempts: 0,\n generation: 0,\n automaticAttempts: 0,\n parked: false,\n nextAttemptAtMillis: snapshot.createdAtMillis,\n lastAttemptAtMillis: null,\n lastFailure: null,\n },\n },\n \"prepare\",\n );\n});\n\n/** Pure reducer used under the adapter's atomic compare-and-swap boundary. */\nexport const applyMessageDeliveryChange = (\n record: MessageDeliveryRecord,\n change: MessageDeliveryChange,\n): Result.Result<MessageDeliveryRecord, MessageDeliveryError> => {\n const conflict = () => Result.fail(error(\"conflict\", change._tag));\n\n if (record.version !== change.expectedVersion) return conflict();\n if (record.status === \"processed\" || record.status === \"refused\") return conflict();\n const now = change.nowMillis;\n\n const base = {\n ...record,\n version: record.version + 1,\n ...(\"diagnostic\" in change && change.diagnostic !== undefined\n ? { lastFailureDiagnostic: change.diagnostic }\n : {}),\n };\n\n const parked = (reason: typeof ParkReason.Type): MessageDeliveryRecord => ({\n ...base,\n status: \"parked\",\n parkReason: reason,\n leaseUntilMillis: null,\n retry: { ...record.retry, parked: true },\n });\n\n if (change._tag === \"Defer\") {\n if (\n record.status !== \"pending\" ||\n (record.leaseUntilMillis !== null && record.leaseUntilMillis > now)\n )\n return conflict();\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n if (change.untilMillis <= now) return conflict();\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n nextAttemptAtMillis: Math.min(change.untilMillis, record.deadlineAtMillis),\n },\n });\n }\n\n if (change._tag === \"Recover\") {\n if (record.status !== \"parked\" || change.deadlineAtMillis <= now) return conflict();\n\n return Result.succeed({\n ...base,\n deadlineAtMillis: change.deadlineAtMillis,\n status: record.receipt === null ? \"pending\" : \"accepted\",\n parkReason: null,\n retry: {\n ...record.retry,\n generation: record.retry.generation + 1,\n automaticAttempts: 0,\n parked: false,\n nextAttemptAtMillis: now,\n },\n });\n }\n if (record.status === \"parked\") return conflict();\n if (change._tag === \"Park\") return Result.succeed(parked(change.reason));\n if (change._tag === \"Claim\") {\n const due = messageDeliveryDeadline(record);\n\n if (due === null || due > now) return conflict();\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n if (record.retry.automaticAttempts >= record.policy.maxAutomaticAttempts)\n return Result.succeed(parked(\"exhausted\"));\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: Math.min(now + record.policy.attemptTimeoutMillis, record.deadlineAtMillis),\n retry: {\n ...record.retry,\n attempts: record.retry.attempts + 1,\n automaticAttempts: record.retry.automaticAttempts + 1,\n lastAttemptAtMillis: now,\n },\n });\n }\n if (record.leaseUntilMillis === null || now > record.leaseUntilMillis) return conflict();\n if (change._tag === \"Accept\") {\n if (record.status !== \"pending\") return conflict();\n if (change.receipt.threadId !== record.envelope.threadId)\n return Result.fail(error(\"corrupt\", \"receipt-identity\"));\n\n return Result.succeed({\n ...base,\n status: \"accepted\",\n receipt: change.receipt,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n automaticAttempts: 0,\n nextAttemptAtMillis: Math.min(\n now + record.policy.settlementPollMillis,\n record.deadlineAtMillis,\n ),\n lastFailure: null,\n },\n });\n }\n if (change._tag === \"Process\") {\n if (record.status !== \"accepted\") return conflict();\n if (\n change.settlement.submissionId !== record.receipt?.submissionId ||\n change.settlement.receiptId !== record.receipt.receiptId\n )\n return Result.fail(error(\"corrupt\", \"settlement-identity\"));\n\n return Result.succeed({\n ...base,\n status: \"processed\",\n settlement: change.settlement,\n leaseUntilMillis: null,\n });\n }\n if (change._tag === \"ObservePending\") {\n if (record.status !== \"accepted\") return conflict();\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n automaticAttempts: 0,\n lastFailure: null,\n nextAttemptAtMillis: Math.min(\n now + record.policy.settlementPollMillis,\n record.deadlineAtMillis,\n ),\n },\n });\n }\n if (change._tag === \"Refuse\") {\n if (record.status !== \"pending\") return conflict();\n\n return Result.succeed({\n ...base,\n status: \"refused\",\n refusal: change.code,\n leaseUntilMillis: null,\n });\n }\n if (now >= record.deadlineAtMillis) return Result.succeed(parked(\"deadline\"));\n if (record.retry.automaticAttempts >= record.policy.maxAutomaticAttempts)\n return Result.succeed(parked(\"exhausted\"));\n\n const delay = Math.min(\n record.policy.retryBaseMillis * 2 ** Math.min(record.retry.automaticAttempts - 1, 52),\n record.policy.retryMaxMillis,\n );\n\n return Result.succeed({\n ...base,\n leaseUntilMillis: null,\n retry: {\n ...record.retry,\n nextAttemptAtMillis: Math.min(\n now + (record.status === \"accepted\" ? record.policy.settlementPollMillis : delay),\n record.deadlineAtMillis,\n ),\n lastFailure: change.reason,\n },\n });\n};\n\nexport const MessageDeliveryDriverLimits = Schema.Struct({\n batchSize: Positive.check(Schema.isLessThanOrEqualTo(100)),\n concurrency: Positive.check(Schema.isLessThanOrEqualTo(32)),\n});\n\nexport type MessageDeliveryDriverLimits = typeof MessageDeliveryDriverLimits.Type;\n\n/**\n * Finite, structured host pump. The host owns its Scope and wakes it from nextDeadline even\n * after source/receiver settlement. Failed or interrupted calls retain their expiring claim;\n * no ordinary tool is replayed here, only idempotent PreparedInput admission/status lookup.\n * Spans expose operation names; envelopes, principals, and message contents are never logged.\n */\nexport class MessageDeliveryDriver extends Context.Service<\n MessageDeliveryDriver,\n {\n readonly process: (\n key: MessageDeliveryKey,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n readonly runDue: (\n ownerThreadId?: ThreadId,\n ) => Effect.Effect<ReadonlyArray<MessageDeliveryRecord>, MessageDeliveryFailure>;\n readonly retry: (\n key: MessageDeliveryKey,\n expectedVersion: number,\n deadlineAtMillis: number,\n ) => Effect.Effect<MessageDeliveryRecord, MessageDeliveryFailure>;\n }\n>()(\"@effect-agent/thread/MessageDeliveryDriver\") {\n static layer(\n limits: MessageDeliveryDriverLimits = { batchSize: 100, concurrency: 4 },\n ): Layer.Layer<\n MessageDeliveryDriver,\n MessageDeliveryError,\n MessageDeliveryStore | PreparedInputAdmission | Crypto.Crypto\n > {\n return Layer.effect(\n MessageDeliveryDriver,\n Effect.gen(function* () {\n const config = yield* validateMessageDelivery(\n MessageDeliveryDriverLimits,\n limits,\n \"driver-limits\",\n );\n\n const store = yield* MessageDeliveryStore;\n const admission = yield* PreparedInputAdmission;\n const crypto = yield* Crypto.Crypto;\n const failpoint = yield* MessageDeliveryFailpoint;\n const semaphore = yield* Semaphore.make(config.concurrency);\n\n const process = Effect.fn(\"MessageDelivery.process\")((key: MessageDeliveryKey) =>\n semaphore\n .withPermit(\n Effect.gen(function* () {\n const current = yield* store.get(key);\n\n if (current === null) return yield* error(\"not-found\", \"process\");\n const nowMillis = yield* Clock.currentTimeMillis;\n const due = messageDeliveryDeadline(current);\n\n if (due === null || due > nowMillis) return current;\n\n if (current.status === \"pending\" && current.predecessor !== undefined) {\n const previous = yield* store.get({\n ownerThreadId: key.ownerThreadId,\n messageId: current.predecessor,\n });\n\n if (\n previous === null ||\n (previous.receipt === null && previous.status !== \"refused\")\n ) {\n return yield* store.change(key, {\n _tag: \"Defer\",\n expectedVersion: current.version,\n nowMillis,\n untilMillis: nowMillis + current.policy.settlementPollMillis,\n });\n }\n }\n\n const claimed = yield* store.change(key, {\n _tag: \"Claim\",\n expectedVersion: current.version,\n nowMillis,\n });\n\n if (claimed.status === \"parked\") return claimed;\n\n const envelope = yield* Schema.encodeEffect(PreparedInput)(claimed.envelope).pipe(\n Effect.mapError((cause) => error(\"corrupt\", \"envelope\", cause)),\n );\n\n const digest = yield* digestJson(envelope).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n Effect.mapError((cause) => error(\"storage\", \"digest\", cause)),\n );\n\n if (digest !== claimed.envelopeDigest)\n return yield* error(\"corrupt\", \"envelope-digest\");\n\n const timeout = Math.min(\n claimed.policy.attemptTimeoutMillis,\n (claimed.leaseUntilMillis ?? claimed.deadlineAtMillis) -\n (yield* Clock.currentTimeMillis),\n );\n\n // Digest computation cannot extend this claim's admission authority.\n if (timeout <= 0) return claimed;\n\n type WithoutFence<T> = T extends MessageDeliveryChange\n ? Omit<T, \"expectedVersion\" | \"nowMillis\">\n : never;\n\n const commit = (change: WithoutFence<MessageDeliveryChange>) =>\n Clock.currentTimeMillis.pipe(\n Effect.flatMap((time) =>\n store.change(key, {\n ...change,\n expectedVersion: claimed.version,\n nowMillis: time,\n }),\n ),\n );\n\n if (claimed.status === \"pending\") {\n const outcome = yield* admitPreparedInput(\n admission.submit(claimed.envelope),\n timeout,\n ).pipe(Effect.mapError((cause) => error(\"corrupt\", \"admission\", cause)));\n\n yield* failpoint.hit(\"message-delivery:admission:after\");\n if (outcome._tag === \"Receipt\")\n return yield* commit({ _tag: \"Accept\", receipt: outcome.receipt });\n if (outcome._tag === \"Refused\")\n return yield* commit({\n _tag: \"Refuse\",\n code: outcome.error.code,\n diagnostic: FailureDiagnostic.capture(outcome.error),\n });\n\n return yield* commit({\n _tag: \"Retry\",\n reason: outcome.reason,\n diagnostic: outcome.diagnostic,\n });\n }\n if (claimed.receipt === null) return yield* error(\"corrupt\", \"receipt\");\n if (admission.submissionStatus === undefined)\n return yield* commit({ _tag: \"Park\", reason: \"status-unavailable\" });\n\n const status = yield* admission.submissionStatus(claimed.receipt).pipe(\n Effect.timeout(timeout),\n Effect.map((status) => ({ _tag: \"Status\" as const, status })),\n Effect.catchTag(\"ScheduledInputRetryable\", (failure) =>\n Effect.succeed({\n _tag: \"Retry\" as const,\n reason: failure.reason,\n diagnostic: FailureDiagnostic.capture(failure),\n }),\n ),\n Effect.catchTag(\"ScheduledInputRefused\", (failure) =>\n Effect.succeed({\n _tag: \"Unavailable\" as const,\n diagnostic: FailureDiagnostic.capture(failure),\n }),\n ),\n Effect.catchTag(\"TimeoutError\", (failure) =>\n Effect.succeed({\n _tag: \"Retry\" as const,\n reason: \"timeout\" as const,\n diagnostic: FailureDiagnostic.capture(failure),\n }),\n ),\n Effect.catchTag(\"ScheduleStorageError\", (failure) =>\n failure.reason === \"unavailable\"\n ? Effect.succeed({\n _tag: \"Retry\" as const,\n reason: \"storage\" as const,\n diagnostic: FailureDiagnostic.capture(failure),\n })\n : Effect.fail(error(\"corrupt\", \"status\", failure)),\n ),\n );\n\n if (status._tag === \"Unavailable\")\n return yield* commit({\n _tag: \"Park\",\n reason: \"status-unavailable\",\n diagnostic: status.diagnostic,\n });\n if (status._tag === \"Status\" && status.status._tag === \"settled\")\n return yield* commit({ _tag: \"Process\", settlement: status.status.settlement });\n if (status._tag === \"Status\") return yield* commit({ _tag: \"ObservePending\" });\n\n return yield* commit({\n _tag: \"Retry\",\n reason: status.reason,\n diagnostic: status.diagnostic,\n });\n }),\n )\n .pipe(\n Effect.catchTag(\"MessageDeliveryError\", (failure) =>\n failure.reason === \"conflict\"\n ? store.get(key).pipe(\n Effect.filterOrFail(\n (record) => record !== null,\n () => failure,\n ),\n )\n : Effect.fail(failure),\n ),\n ),\n );\n\n return MessageDeliveryDriver.of({\n process,\n runDue: Effect.fn(\"MessageDelivery.runDue\")(function* (ownerThreadId) {\n const keys = yield* store.due(\n yield* Clock.currentTimeMillis,\n config.batchSize,\n ownerThreadId,\n );\n\n return yield* Effect.forEach(keys, process, { concurrency: config.concurrency });\n }),\n retry: Effect.fn(\"MessageDelivery.retry\")(\n function* (key, expectedVersion, deadlineAtMillis) {\n return yield* store.change(key, {\n _tag: \"Recover\",\n expectedVersion,\n deadlineAtMillis,\n nowMillis: yield* Clock.currentTimeMillis,\n });\n },\n ),\n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OAAO,MAAM,OAAO,KAAK;MAC9B,MAAM;MACN;MACA;MACA,WAAW,OAAO,MAAM;KAC1B,CAAC;IACH,CACF;GACF,CAAC;EACH,CAAC,CACH;CACF;AACF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { d as SubagentReservationAmounts, l as SubagentGrant, o as SubagentDelegationCaps, s as SubagentExecutionFailure } from "../SubagentContract-DdT7Cqe6.mjs";
|
|
2
2
|
import { a as Receipt } from "../Receipt-BAHyigAF.mjs";
|
|
3
3
|
import { r as Update } from "../AgentUpdates-DMJ-_xow.mjs";
|
|
4
|
+
import { r as Diagnostic } from "../FailureDiagnostic-CaAkzGHL.mjs";
|
|
4
5
|
import { t as AgentPolicy } from "../AgentPolicy-BqDoSXO6.mjs";
|
|
5
|
-
import { co as Settlement, h as DefinitionDigests, mi as DigestError } from "../Records-
|
|
6
|
+
import { co as Settlement, h as DefinitionDigests, mi as DigestError } from "../Records-B4S02MX1.mjs";
|
|
6
7
|
import { MessageDeliveryError, MessageDeliveryFailure, MessageDeliveryStore } from "./MessageDelivery.mjs";
|
|
7
8
|
import { Effect, Schema } from "effect";
|
|
8
9
|
//#region src/durable/MessageDeliveryStoreConformance.d.ts
|
|
@@ -172,6 +173,7 @@ export declare const makeMessageDeliveryFixture: (messageId?: any, owner?: any,
|
|
|
172
173
|
readonly lastAttemptAtMillis: number | null;
|
|
173
174
|
readonly lastFailure: "ambiguous" | "capacity" | "host-closed" | "storage" | "timeout" | "transport" | null;
|
|
174
175
|
};
|
|
176
|
+
readonly lastFailureDiagnostic?: Diagnostic | undefined;
|
|
175
177
|
}, DigestError | MessageDeliveryError, import("effect/Crypto").Crypto>;
|
|
176
178
|
export declare const messageDeliveryFixtureReceipt: Receipt;
|
|
177
179
|
export declare const makeWorkerUpdateDeliveryFixture: (id: string) => Effect.Effect<{
|
|
@@ -335,6 +337,7 @@ export declare const makeWorkerUpdateDeliveryFixture: (id: string) => Effect.Eff
|
|
|
335
337
|
readonly lastAttemptAtMillis: number | null;
|
|
336
338
|
readonly lastFailure: "ambiguous" | "capacity" | "host-closed" | "storage" | "timeout" | "transport" | null;
|
|
337
339
|
};
|
|
340
|
+
readonly lastFailureDiagnostic?: Diagnostic | undefined;
|
|
338
341
|
}, DigestError | MessageDeliveryError, import("effect/Crypto").Crypto>;
|
|
339
342
|
/** Every case starts with an empty store; all clocks and expected values are explicit. */
|
|
340
343
|
export declare const messageDeliveryStoreConformanceCases: readonly [{
|
|
@@ -2,7 +2,7 @@ import { AgentId, DelegationId, ReceiptId, RunId, SettlementId, SubmissionId, Th
|
|
|
2
2
|
import { IdempotencyKey, Principal, QueueSequence, Receipt } from "../core/Receipt.mjs";
|
|
3
3
|
import { Update } from "../core/AgentUpdates.mjs";
|
|
4
4
|
import { WorkerUpdate } from "../core/Worker.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { DefinitionDigests, Digest } from "./Records.mjs";
|
|
6
6
|
import { Settlement } from "./SubmissionLedger.mjs";
|
|
7
7
|
import { digestJson } from "./Digest.mjs";
|
|
8
8
|
import { MessageDeliveryStore, messageDeliveryCapacity, prepareMessageDelivery, readPending } from "./MessageDelivery.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ThreadHistory } from "../ThreadHistory-tS1KwxHR.mjs";
|
|
2
|
-
import { mn as ThreadStore } from "../Records-
|
|
2
|
+
import { mn as ThreadStore } from "../Records-B4S02MX1.mjs";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
4
|
declare namespace PersistentHistory_d_exports {
|
|
5
5
|
export { layer };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { ThreadHistory, ThreadHistoryError } from "../engine/ThreadHistory.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { _ as promptFromCanonicalRecords } from "../RunJournal-
|
|
3
|
+
import { BatchId, CanonicalBatch, DeploymentId, ModelCompleted, PersistedJson, ProducerEpoch, ProducerId, RecordEnvelope, RecordId, RunCompleted, UserInputRecorded } from "./Records.mjs";
|
|
4
|
+
import { _ as promptFromCanonicalRecords } from "../RunJournal-BdIlgAEj.mjs";
|
|
5
5
|
import { FencedAppendRequest, MAX_THREAD_EXPORT_RECORDS, ThreadExportRequest, ThreadMaterialization, ThreadStore } from "./ThreadStore.mjs";
|
|
6
6
|
import { Prompt } from "effect/unstable/ai";
|
|
7
7
|
import { DateTime, Effect, Layer, Schema } from "effect";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as admitPreparedInput, t as PreparedInputAdmission } from "../PreparedInputAdmission-
|
|
1
|
+
import { r as admitPreparedInput, t as PreparedInputAdmission } from "../PreparedInputAdmission-D3-BgmA9.mjs";
|
|
2
2
|
export { PreparedInputAdmission, admitPreparedInput };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { s as capture } from "../FailureDiagnostic-BElLOoED.mjs";
|
|
2
3
|
import { ScheduleStorageError } from "./Schedule.mjs";
|
|
3
4
|
import { Context, Effect } from "effect";
|
|
4
5
|
//#region src/durable/PreparedInputAdmission.ts
|
|
@@ -20,13 +21,16 @@ const admitPreparedInput = Effect.fn("Thread.admitPreparedInput")((submit, timeo
|
|
|
20
21
|
error
|
|
21
22
|
})), Effect.catchTag("ScheduledInputRetryable", (error) => Effect.succeed({
|
|
22
23
|
_tag: "Retry",
|
|
23
|
-
reason: error.reason
|
|
24
|
-
|
|
24
|
+
reason: error.reason,
|
|
25
|
+
diagnostic: capture(error)
|
|
26
|
+
})), Effect.catchTag("TimeoutError", (error) => Effect.succeed({
|
|
25
27
|
_tag: "Retry",
|
|
26
|
-
reason: "timeout"
|
|
28
|
+
reason: "timeout",
|
|
29
|
+
diagnostic: capture(error)
|
|
27
30
|
})), Effect.catchTag("ScheduleStorageError", (error) => error.reason === "unavailable" ? Effect.succeed({
|
|
28
31
|
_tag: "Retry",
|
|
29
|
-
reason: "storage"
|
|
32
|
+
reason: "storage",
|
|
33
|
+
diagnostic: capture(error)
|
|
30
34
|
}) : Effect.fail(ScheduleStorageError.make(error)))));
|
|
31
35
|
//#endregion
|
|
32
36
|
export { PreparedInputAdmission, admitPreparedInput, PreparedInputAdmission_exports as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreparedInputAdmission.mjs","names":[],"sources":["../../src/durable/PreparedInputAdmission.ts"],"sourcesContent":["import { Context, Effect } from \"effect\";\n\nimport type { Receipt } from \"./DurableAgentRuntime.ts\";\nimport { type ScheduledInputFailure, ScheduleStorageError } from \"./Schedule.ts\";\nimport type { SubmissionStatus } from \"./SubmissionStatus.ts\";\nimport type { PreparedInput } from \"./Subscription.ts\";\n\n/** Host admission shared by event deliveries and scheduling adapters. */\nexport class PreparedInputAdmission extends Context.Service<\n PreparedInputAdmission,\n {\n /** Required when retention is configured; reports canonical settlement without releasing group ownership itself. */\n readonly submissionStatus?: (\n receipt: Receipt,\n ) => Effect.Effect<SubmissionStatus, ScheduledInputFailure>;\n readonly submit: (envelope: PreparedInput) => Effect.Effect<Receipt, ScheduledInputFailure>;\n }\n>()(\"@effect-agent/thread/PreparedInputAdmission\") {}\n\n/**\n * Reduce one bounded admission attempt. The caller owns concurrency, durable retry state,\n * and completion fencing. Interruption and defects propagate without claiming a refusal.\n */\nexport const admitPreparedInput = Effect.fn(\"Thread.admitPreparedInput\")(\n <R>(submit: Effect.Effect<Receipt, ScheduledInputFailure, R>, timeoutMillis: number) =>\n submit.pipe(\n Effect.timeout(timeoutMillis),\n Effect.map((receipt) => ({ _tag: \"Receipt\" as const, receipt })),\n Effect.catchTag(\"ScheduledInputRefused\", (error) =>\n Effect.succeed({ _tag: \"Refused\" as const, error }),\n ),\n Effect.catchTag(\"ScheduledInputRetryable\", (error) =>\n Effect.succeed({
|
|
1
|
+
{"version":3,"file":"PreparedInputAdmission.mjs","names":["FailureDiagnostic.capture"],"sources":["../../src/durable/PreparedInputAdmission.ts"],"sourcesContent":["import { Context, Effect } from \"effect\";\n\nimport * as FailureDiagnostic from \"../core/FailureDiagnostic.ts\";\nimport type { Receipt } from \"./DurableAgentRuntime.ts\";\nimport { type ScheduledInputFailure, ScheduleStorageError } from \"./Schedule.ts\";\nimport type { SubmissionStatus } from \"./SubmissionStatus.ts\";\nimport type { PreparedInput } from \"./Subscription.ts\";\n\n/** Host admission shared by event deliveries and scheduling adapters. */\nexport class PreparedInputAdmission extends Context.Service<\n PreparedInputAdmission,\n {\n /** Required when retention is configured; reports canonical settlement without releasing group ownership itself. */\n readonly submissionStatus?: (\n receipt: Receipt,\n ) => Effect.Effect<SubmissionStatus, ScheduledInputFailure>;\n readonly submit: (envelope: PreparedInput) => Effect.Effect<Receipt, ScheduledInputFailure>;\n }\n>()(\"@effect-agent/thread/PreparedInputAdmission\") {}\n\n/**\n * Reduce one bounded admission attempt. The caller owns concurrency, durable retry state,\n * and completion fencing. Interruption and defects propagate without claiming a refusal.\n */\nexport const admitPreparedInput = Effect.fn(\"Thread.admitPreparedInput\")(\n <R>(submit: Effect.Effect<Receipt, ScheduledInputFailure, R>, timeoutMillis: number) =>\n submit.pipe(\n Effect.timeout(timeoutMillis),\n Effect.map((receipt) => ({ _tag: \"Receipt\" as const, receipt })),\n Effect.catchTag(\"ScheduledInputRefused\", (error) =>\n Effect.succeed({ _tag: \"Refused\" as const, error }),\n ),\n Effect.catchTag(\"ScheduledInputRetryable\", (error) =>\n Effect.succeed({\n _tag: \"Retry\" as const,\n reason: error.reason,\n diagnostic: FailureDiagnostic.capture(error),\n }),\n ),\n Effect.catchTag(\"TimeoutError\", (error) =>\n Effect.succeed({\n _tag: \"Retry\" as const,\n reason: \"timeout\" as const,\n diagnostic: FailureDiagnostic.capture(error),\n }),\n ),\n Effect.catchTag(\"ScheduleStorageError\", (error) =>\n error.reason === \"unavailable\"\n ? Effect.succeed({\n _tag: \"Retry\" as const,\n reason: \"storage\" as const,\n diagnostic: FailureDiagnostic.capture(error),\n })\n : Effect.fail(ScheduleStorageError.make(error)),\n ),\n ),\n);\n"],"mappings":";;;;;;;;;;AASA,IAAa,yBAAb,cAA4C,QAAQ,QASlD,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC;;;;;AAMpD,MAAa,qBAAqB,OAAO,GAAG,2BAA2B,CAAC,EAClE,QAA0D,kBAC5D,OAAO,KACL,OAAO,QAAQ,aAAa,GAC5B,OAAO,KAAK,aAAa;CAAE,MAAM;CAAoB;AAAQ,EAAE,GAC/D,OAAO,SAAS,0BAA0B,UACxC,OAAO,QAAQ;CAAE,MAAM;CAAoB;AAAM,CAAC,CACpD,GACA,OAAO,SAAS,4BAA4B,UAC1C,OAAO,QAAQ;CACb,MAAM;CACN,QAAQ,MAAM;CACd,YAAYA,QAA0B,KAAK;AAC7C,CAAC,CACH,GACA,OAAO,SAAS,iBAAiB,UAC/B,OAAO,QAAQ;CACb,MAAM;CACN,QAAQ;CACR,YAAYA,QAA0B,KAAK;AAC7C,CAAC,CACH,GACA,OAAO,SAAS,yBAAyB,UACvC,MAAM,WAAW,gBACb,OAAO,QAAQ;CACb,MAAM;CACN,QAAQ;CACR,YAAYA,QAA0B,KAAK;AAC7C,CAAC,IACD,OAAO,KAAK,qBAAqB,KAAK,KAAK,CAAC,CAClD,CACF,CACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ToolCallPrepared, A as ProducerId, B as RunStartedRecord, C as ModelCompleted, D as PeerMessagePrepared, E as ObservationOffset, F as ReplayContract, G as SubagentRequested, H as SettlementOutcome, I as RunCompleted, J as SubmissionSettledRecord, K as SubagentStarted, L as RunDurationExhausted, M as RecordId, O as PersistedJson, P as RepairAnnotated, Q as ToolApprovalRequested, R as RunFailed, S as MAX_PERSISTED_JSON_NODES, T as ModelResponseRecorded, U as SubagentJoined, V as SettlementFailureDiagnostic, W as SubagentLineageRecorded, X as ThreadCreated, Y as SubtreeBudgetReserved, Z as ToolApprovalDecided, _ as Digest, a as BatchId, at as ToolStepSettled, b as MAX_PERSISTED_JSON_COLLECTION_LENGTH, c as CanonicalRecord, ct as WorkerAdmission, d as CanonicalSequence, dt as WorkerOrigin, et as ToolCallResolution, f as CompactionCreated, ft as WorkerOriginRecorded, g as DeploymentId, h as DefinitionDigests, ht as WorkerReportingIntent, i as ApprovalDecision, it as ToolOperation, j as RecordEnvelope, k as ProducerEpoch, l as CanonicalRecordEnvelope, lt as WorkerInputCompleted, m as DefinitionDigestInput, mt as WorkerReportRefused, n as AbortedSubmissionSettled, nt as ToolCallSettled, o as CURRENT_CANONICAL_SCHEMA_VERSION, ot as ToolUnavailable, p as CompletedSubmissionSettled, pt as WorkerReportPrepared, q as SubmissionSettled, r as AgentUpdateEmitted, rt as ToolCallUnknown, s as CanonicalBatch, st as UserInputRecorded, t as AbortRequested, tt as ToolCallResolved, u as CanonicalRecordPayload, ut as WorkerInputRequested, v as FailedSubmissionSettled, w as ModelResponseInterrupted, x as MAX_PERSISTED_JSON_DEPTH, y as MAX_PERSISTED_JSON_BYTES, z as RunPolicyUsageReserved } from "../Records-
|
|
1
|
+
import { $ as ToolCallPrepared, A as ProducerId, B as RunStartedRecord, C as ModelCompleted, D as PeerMessagePrepared, E as ObservationOffset, F as ReplayContract, G as SubagentRequested, H as SettlementOutcome, I as RunCompleted, J as SubmissionSettledRecord, K as SubagentStarted, L as RunDurationExhausted, M as RecordId, O as PersistedJson, P as RepairAnnotated, Q as ToolApprovalRequested, R as RunFailed, S as MAX_PERSISTED_JSON_NODES, T as ModelResponseRecorded, U as SubagentJoined, V as SettlementFailureDiagnostic, W as SubagentLineageRecorded, X as ThreadCreated, Y as SubtreeBudgetReserved, Z as ToolApprovalDecided, _ as Digest, a as BatchId, at as ToolStepSettled, b as MAX_PERSISTED_JSON_COLLECTION_LENGTH, c as CanonicalRecord, ct as WorkerAdmission, d as CanonicalSequence, dt as WorkerOrigin, et as ToolCallResolution, f as CompactionCreated, ft as WorkerOriginRecorded, g as DeploymentId, h as DefinitionDigests, ht as WorkerReportingIntent, i as ApprovalDecision, it as ToolOperation, j as RecordEnvelope, k as ProducerEpoch, l as CanonicalRecordEnvelope, lt as WorkerInputCompleted, m as DefinitionDigestInput, mt as WorkerReportRefused, n as AbortedSubmissionSettled, nt as ToolCallSettled, o as CURRENT_CANONICAL_SCHEMA_VERSION, ot as ToolUnavailable, p as CompletedSubmissionSettled, pt as WorkerReportPrepared, q as SubmissionSettled, r as AgentUpdateEmitted, rt as ToolCallUnknown, s as CanonicalBatch, st as UserInputRecorded, t as AbortRequested, tt as ToolCallResolved, u as CanonicalRecordPayload, ut as WorkerInputRequested, v as FailedSubmissionSettled, w as ModelResponseInterrupted, x as MAX_PERSISTED_JSON_DEPTH, y as MAX_PERSISTED_JSON_BYTES, z as RunPolicyUsageReserved } from "../Records-B4S02MX1.mjs";
|
|
2
2
|
export { AbortRequested, AbortedSubmissionSettled, AgentUpdateEmitted, ApprovalDecision, BatchId, CURRENT_CANONICAL_SCHEMA_VERSION, CanonicalBatch, CanonicalRecord, CanonicalRecordEnvelope, CanonicalRecordPayload, CanonicalSequence, CompactionCreated, CompletedSubmissionSettled, DefinitionDigestInput, DefinitionDigests, DeploymentId, Digest, FailedSubmissionSettled, MAX_PERSISTED_JSON_BYTES, MAX_PERSISTED_JSON_COLLECTION_LENGTH, MAX_PERSISTED_JSON_DEPTH, MAX_PERSISTED_JSON_NODES, ModelCompleted, ModelResponseInterrupted, ModelResponseRecorded, ObservationOffset, PeerMessagePrepared, PersistedJson, ProducerEpoch, ProducerId, RecordEnvelope, RecordId, RepairAnnotated, ReplayContract, RunCompleted, RunDurationExhausted, RunFailed, RunPolicyUsageReserved, RunStartedRecord, SettlementFailureDiagnostic, SettlementOutcome, SubagentJoined, SubagentLineageRecorded, SubagentRequested, SubagentStarted, SubmissionSettled, SubmissionSettledRecord, SubtreeBudgetReserved, ThreadCreated, ToolApprovalDecided, ToolApprovalRequested, ToolCallPrepared, ToolCallResolution, ToolCallResolved, ToolCallSettled, ToolCallUnknown, ToolOperation, ToolStepSettled, ToolUnavailable, UserInputRecorded, WorkerAdmission, WorkerInputCompleted, WorkerInputRequested, WorkerOrigin, WorkerOriginRecorded, WorkerReportPrepared, WorkerReportRefused, WorkerReportingIntent };
|