effect-agent 0.1.0-beta.96 → 0.1.0-beta.97
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/{DurableAgentRuntime-BGwGUIT-.mjs → DurableAgentRuntime-DbUvZHDZ.mjs} +34 -30
- package/dist/DurableAgentRuntime-DbUvZHDZ.mjs.map +1 -0
- package/dist/{EventSource-tCO_dAff.d.mts → EventSource-D6PAAEyK.d.mts} +3 -3
- package/dist/{PreparedInputAdmission-CFSddiT8.d.mts → PreparedInputAdmission-omMbwd--.d.mts} +4 -4
- package/dist/{Records-BEz5IFUu.mjs → Records-BAutSSnJ.mjs} +3 -1
- package/dist/Records-BAutSSnJ.mjs.map +1 -0
- package/dist/{Records-CMByd1eD.d.mts → Records-CV49DgQK.d.mts} +37 -9
- package/dist/{RunJournal-B_fxe57c.mjs → RunJournal-DRRRZmG7.mjs} +2 -2
- package/dist/{RunJournal-B_fxe57c.mjs.map → RunJournal-DRRRZmG7.mjs.map} +1 -1
- package/dist/{Schedule-BxCfnYr0.d.mts → Schedule-DePbGfgd.d.mts} +2 -2
- package/dist/{Scheduling-BW6BD_TP.mjs → Scheduling-C3QpYn0W.mjs} +2 -2
- package/dist/{Scheduling-BW6BD_TP.mjs.map → Scheduling-C3QpYn0W.mjs.map} +1 -1
- package/dist/{Subscription-CrTIQKZR.d.mts → Subscription-BR_8Cxh3.d.mts} +3 -3
- package/dist/{SubscriptionInput-BVOeFF1L.d.mts → SubscriptionInput-B95sQbuk.d.mts} +3 -3
- package/dist/{agent-registration-BTa5vmQF.mjs → agent-registration-CXGDwvJH.mjs} +151 -26
- package/dist/agent-registration-CXGDwvJH.mjs.map +1 -0
- 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 +2 -2
- package/dist/durable/AgentRegistration.mjs +3 -2
- package/dist/durable/AgentRegistration.mjs.map +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 +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 +3 -3
- package/dist/durable/MessageDelivery.mjs +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +1 -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/Records.d.mts +1 -1
- package/dist/durable/Records.mjs +1 -1
- 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 +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/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/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
- package/src/durable/AgentRegistration.ts +1 -0
- package/src/durable/DurableAgentRuntime.ts +3 -1
- package/src/durable/Records.ts +2 -0
- package/src/durable/internal/agent-registration.ts +274 -36
- package/src/durable/internal/messaging-host.ts +2 -5
- package/src/durable/internal/worker-host.ts +119 -85
- package/dist/DurableAgentRuntime-BGwGUIT-.mjs.map +0 -1
- package/dist/Records-BEz5IFUu.mjs.map +0 -1
- package/dist/agent-registration-BTa5vmQF.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduling-BW6BD_TP.mjs","names":["ScheduleTimingRequestSchema","ScheduleDestinationSchema"],"sources":["../src/durable/internal/schedule-time.ts","../src/durable/Scheduling.ts"],"sourcesContent":["import { Cron, DateTime, Option, Result, Schema } from \"effect\";\n\nimport {\n ScheduleValidationError,\n ScheduleInstant,\n type ScheduleSkippedRange,\n type ScheduleTiming,\n type ScheduleTimingRequest,\n} from \"../Schedule.ts\";\n\nconst invalid = (message: string) => Result.fail(ScheduleValidationError.make({ message }));\n\nconst checkedInstant = (millis: number, label: string) =>\n Schema.decodeResult(ScheduleInstant)(millis).pipe(\n Result.mapError(() =>\n ScheduleValidationError.make({\n message: `${label} is outside the supported ScheduleInstant range`,\n }),\n ),\n );\n\nconst values = (set: ReadonlySet<number>, size: number): ReadonlyArray<number> =>\n set.size === 0 ? Array.from({ length: size }, (_, index) => index) : [...set];\n\n/**\n * Cron frequency proof without calendar enumeration. It checks the minimum circular spacing of\n * the allowed hour/minute pairs. Day restrictions may make a rule sparser, so this deliberately\n * rejects some safe rules when a configured minimum exceeds one minute.\n */\nconst validateCronFrequency = (\n cron: Cron.Cron,\n minimumMillis: number,\n): Result.Result<void, ScheduleValidationError> => {\n if (cron.seconds.size !== 1) {\n return invalid(\"Cron must select exactly one seconds value\");\n }\n if (minimumMillis <= 60_000) return Result.succeed(undefined);\n if (\n Option.isSome(cron.tz) &&\n DateTime.isTimeZoneNamed(cron.tz.value) &&\n cron.tz.value.id !== \"UTC\"\n ) {\n return invalid(\"Cron minimums above one minute require UTC or a fixed-offset time zone\");\n }\n\n const minuteOfDay = values(cron.hours, 24).flatMap((hour) =>\n values(cron.minutes, 60).map((minute) => hour * 60 + minute),\n );\n\n minuteOfDay.sort((left, right) => left - right);\n let minimumGap = 24 * 60;\n\n for (let index = 0; index < minuteOfDay.length; index += 1) {\n const current = minuteOfDay[index];\n const next = minuteOfDay[(index + 1) % minuteOfDay.length];\n\n if (current === undefined || next === undefined) continue;\n const gap = next > current ? next - current : 24 * 60 - current + next;\n\n minimumGap = Math.min(minimumGap, gap);\n }\n\n return minimumGap * 60_000 >= minimumMillis\n ? Result.succeed(undefined)\n : invalid(`Cron may fire more often than the configured ${minimumMillis}ms minimum`);\n};\n\nexport const parseScheduleCron = (\n expression: string,\n timeZone: string,\n minimumMillis: number,\n): Result.Result<Cron.Cron, ScheduleValidationError> => {\n const parsed = Cron.parse(expression, timeZone);\n\n if (Result.isFailure(parsed)) return invalid(parsed.failure.message);\n const frequency = validateCronFrequency(parsed.success, minimumMillis);\n\n return Result.isFailure(frequency)\n ? Result.fail(frequency.failure)\n : Result.succeed(parsed.success);\n};\n\nexport const normalizeScheduleTiming = (\n request: ScheduleTimingRequest,\n nowMillis: number,\n minimumMillis: number,\n): Result.Result<ScheduleTiming, ScheduleValidationError> => {\n switch (request._tag) {\n case \"At\":\n return Result.succeed(request);\n case \"After\": {\n const at = checkedInstant(nowMillis + request.delayMillis, \"Relative deadline\");\n\n return Result.map(at, (atMillis) => ({ _tag: \"At\" as const, atMillis }));\n }\n case \"Interval\": {\n if (request.everyMillis < minimumMillis) {\n return invalid(`Interval must be at least ${minimumMillis}ms`);\n }\n\n const anchor = checkedInstant(\n request.anchorMillis ?? nowMillis + request.everyMillis,\n \"Interval anchor\",\n );\n\n return Result.map(anchor, (anchorMillis) => ({\n _tag: \"Interval\" as const,\n everyMillis: request.everyMillis,\n anchorMillis,\n }));\n }\n case \"Cron\": {\n const timeZone = request.timeZone ?? \"UTC\";\n const cron = parseScheduleCron(request.expression, timeZone, minimumMillis);\n\n if (Result.isFailure(cron)) return Result.fail(cron.failure);\n\n return Result.succeed({ _tag: \"Cron\", expression: request.expression, timeZone });\n }\n }\n};\n\nconst parsedStoredCron = (timing: Extract<ScheduleTiming, { _tag: \"Cron\" }>) => {\n const parsed = Cron.parse(timing.expression, timing.timeZone);\n\n return Result.isFailure(parsed)\n ? invalid(`Stored cron is invalid: ${parsed.failure.message}`)\n : Result.succeed(parsed.success);\n};\n\n/** Strictly selects the first occurrence after an instant. */\nexport const scheduleNextAfter = (\n timing: ScheduleTiming,\n afterMillis: number,\n): Result.Result<number | null, ScheduleValidationError> => {\n switch (timing._tag) {\n case \"At\":\n return Result.succeed(timing.atMillis > afterMillis ? timing.atMillis : null);\n case \"Interval\": {\n if (afterMillis < timing.anchorMillis) return Result.succeed(timing.anchorMillis);\n const steps = Math.floor((afterMillis - timing.anchorMillis) / timing.everyMillis) + 1;\n const next = timing.anchorMillis + steps * timing.everyMillis;\n\n return checkedInstant(next, \"Next interval occurrence\");\n }\n case \"Cron\": {\n const cron = parsedStoredCron(timing);\n\n if (Result.isFailure(cron)) return Result.fail(cron.failure);\n\n return Result.try({\n try: () => {\n let next = Cron.next(cron.success, afterMillis).getTime();\n\n // Inside a fall fold Effect may select the first, already elapsed local instant.\n while (next <= afterMillis) {\n const following = Cron.next(cron.success, next).getTime();\n\n if (following <= next) throw new Error(\"Cron did not advance\");\n next = following;\n }\n\n return next;\n },\n catch: () => ScheduleValidationError.make({ message: \"Cron has no supported next firing\" }),\n }).pipe(Result.flatMap((next) => checkedInstant(next, \"Next cron occurrence\")));\n }\n }\n};\n\n/** Initial cursor. Past one-shots remain due; recurring rules start strictly after registration. */\nexport const scheduleInitialCursor = (\n timing: ScheduleTiming,\n nowMillis: number,\n): Result.Result<number | null, ScheduleValidationError> =>\n timing._tag === \"At\" ? Result.succeed(timing.atMillis) : scheduleNextAfter(timing, nowMillis);\n\nexport interface DueScheduleOccurrence {\n readonly intendedAtMillis: number;\n readonly nextAtMillis: number | null;\n readonly skippedRange: ScheduleSkippedRange | null;\n}\n\n/** Coalesces recurring occurrences using the same forward sequence as registration. */\nexport const scheduleDueOccurrence = (\n timing: ScheduleTiming,\n cursorMillis: number,\n nowMillis: number,\n): Result.Result<DueScheduleOccurrence | null, ScheduleValidationError> => {\n if (cursorMillis > nowMillis) return Result.succeed(null);\n if (timing._tag === \"At\") {\n return Result.succeed({\n intendedAtMillis: cursorMillis,\n nextAtMillis: null,\n skippedRange: null,\n });\n }\n\n let intendedAtMillis: number;\n\n if (timing._tag === \"Interval\") {\n const steps = Math.floor((nowMillis - timing.anchorMillis) / timing.everyMillis);\n\n intendedAtMillis = Math.max(cursorMillis, timing.anchorMillis + steps * timing.everyMillis);\n } else {\n const cron = parsedStoredCron(timing);\n\n if (Result.isFailure(cron)) return Result.fail(cron.failure);\n\n const due = Result.try({\n try: () => {\n let intended = cursorMillis;\n // Reverse traversal is safe only without offset transitions. Named-zone reverse\n // traversal has different gap/fold semantics from the forward occurrence sequence.\n const zone = Option.getOrUndefined(cron.success.tz);\n\n if (zone !== undefined && (DateTime.isTimeZoneOffset(zone) || zone.id === \"UTC\")) {\n intended = Math.max(cursorMillis, Cron.prev(cron.success, nowMillis + 1_000).getTime());\n } else {\n // Seek by calendar date in UTC, where reverse traversal has no DST ambiguity.\n // Include two prior civil days to cover even IANA date-line shifts. There are no\n // matching dates between this seed day and that boundary, so forward traversal\n // visits only the seed day and the recent days, regardless of downtime length.\n const calendar = Cron.make({\n ...cron.success,\n seconds: [0],\n minutes: [0],\n hours: [0],\n tz: DateTime.zoneMakeNamedUnsafe(\"UTC\"),\n });\n\n const localDay = DateTime.makeUnsafe(\n DateTime.toDate(DateTime.makeZonedUnsafe(nowMillis, { timeZone: zone })),\n ).pipe(DateTime.startOf(\"day\"), DateTime.subtract({ days: 2 }));\n\n const seedDay = Cron.prev(calendar, DateTime.toEpochMillis(localDay) + 1_000);\n\n const seed =\n DateTime.makeZonedUnsafe(seedDay, {\n timeZone: zone,\n adjustForTimeZone: true,\n }).pipe(DateTime.toEpochMillis) - 1_000;\n\n if (seed > cursorMillis) {\n const first = Cron.next(cron.success, seed).getTime();\n\n if (first <= nowMillis) intended = Math.max(intended, first);\n }\n }\n let next = Cron.next(cron.success, intended).getTime();\n\n while (next <= nowMillis) {\n if (next <= intended) throw new Error(\"Cron did not advance\");\n intended = next;\n next = Cron.next(cron.success, intended).getTime();\n }\n\n return { intended, next };\n },\n catch: () => ScheduleValidationError.make({ message: \"Cron has no supported due firing\" }),\n });\n\n if (Result.isFailure(due)) return Result.fail(due.failure);\n const next = checkedInstant(due.success.next, \"Next cron occurrence\");\n\n if (Result.isFailure(next)) return Result.fail(next.failure);\n\n return Result.succeed({\n intendedAtMillis: due.success.intended,\n nextAtMillis: next.success,\n skippedRange:\n due.success.intended === cursorMillis\n ? null\n : {\n fromMillis: cursorMillis,\n toMillis: due.success.intended,\n },\n });\n }\n\n const next = scheduleNextAfter(timing, nowMillis);\n\n if (Result.isFailure(next)) return Result.fail(next.failure);\n\n return Result.succeed({\n intendedAtMillis,\n nextAtMillis: next.success,\n skippedRange:\n intendedAtMillis === cursorMillis\n ? null\n : { fromMillis: cursorMillis, toMillis: intendedAtMillis },\n });\n};\n\nexport const scheduleResumeCursor = (\n timing: ScheduleTiming,\n existingCursor: number | null,\n nowMillis: number,\n): Result.Result<number | null, ScheduleValidationError> => {\n if (timing._tag === \"At\") return Result.succeed(existingCursor);\n\n return scheduleNextAfter(timing, nowMillis);\n};\n","import {\n Cause,\n Context,\n Crypto,\n DateTime,\n Effect,\n Layer,\n Option,\n Result,\n Schema,\n Semaphore,\n} from \"effect\";\n\nimport { type AgentId, ThreadId } from \"../core/Identifiers.ts\";\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { digestJson } from \"./Digest.ts\";\nimport type { DurableSubmitAgent } from \"./DurableAgentRuntime.ts\";\nimport {\n normalizeScheduleTiming,\n scheduleDueOccurrence,\n scheduleInitialCursor,\n scheduleNextAfter,\n scheduleResumeCursor,\n} from \"./internal/schedule-time.ts\";\nimport { admitPreparedInput } from \"./PreparedInputAdmission.ts\";\nimport { DefinitionDigests, type Digest, PersistedJson } from \"./Records.ts\";\nimport {\n defaultSchedulingLimits,\n type ScheduleAuthorizationError,\n ScheduleAuthorizer,\n ScheduleConflict,\n type ScheduleConfiguration,\n ScheduleDestination as ScheduleDestinationSchema,\n type ScheduleDestination,\n ScheduleFailpoint,\n type ScheduleId,\n type ScheduleDueCursor,\n ScheduleInstant,\n type ScheduleKey,\n SchedulingLimits,\n ScheduleNotFound,\n type ScheduleOwner,\n type ScheduleRecord,\n type ScheduleRefusal,\n type ScheduleRetryReason,\n type ScheduleScope,\n type ScheduleSnapshot,\n type ScheduleSnapshotPage,\n ScheduleStorageError,\n ScheduleStore,\n type ScheduleStoreFailure,\n ScheduleTimingRequest as ScheduleTimingRequestSchema,\n type ScheduleTimingRequest,\n ScheduleValidationError,\n ScheduledInputAdmission,\n ScheduleWake,\n} from \"./Schedule.ts\";\nimport { type AdmissionFence, IdempotencyKey, type Principal } from \"./SubmissionLedger.ts\";\n\nexport interface ScheduleCreateOptions {\n readonly scope: ScheduleScope;\n readonly scheduleId: ScheduleId;\n readonly timing: ScheduleTimingRequest;\n readonly destination: ScheduleDestination;\n readonly deliveryPrincipal: Principal;\n readonly admissionGroup?: string;\n readonly admissionFence?: AdmissionFence;\n readonly definitions: DefinitionDigests;\n}\n\nexport interface ScheduleUpdateOptions extends ScheduleCreateOptions {\n readonly expectedRevision: number;\n}\n\nexport interface ScheduleListOptions {\n readonly after?: ScheduleId | undefined;\n readonly limit?: number | undefined;\n}\n\nexport type ScheduleManagementFailure =\n | ScheduleValidationError\n | ScheduleAuthorizationError\n | ScheduleStoreFailure;\n\nexport type ScheduleProcessFailure =\n | ScheduleValidationError\n | ScheduleStoreFailure\n | ScheduleStorageError;\n\nconst equivalentDefinitions = Schema.toEquivalence(DefinitionDigests);\nconst equivalentInput = Schema.toEquivalence(PersistedJson);\n\nconst keyOf = (scope: ScheduleScope, scheduleId: ScheduleId): ScheduleKey => ({\n owner: scope.owner,\n scheduleId,\n});\n\nconst notFound = (key: ScheduleKey) => ScheduleNotFound.make({ key });\n\nconst asSnapshot = (record: ScheduleRecord, observedAtMillis: number): ScheduleSnapshot => {\n const intendedAtMillis = record.pending?.envelope.intendedAtMillis ?? record.nextAtMillis;\n\n return {\n owner: record.owner,\n scheduleId: record.scheduleId,\n createdAtMillis: record.createdAtMillis,\n updatedAtMillis: record.updatedAtMillis,\n configurationRevision: record.configurationRevision,\n configuration: {\n timing: record.configuration.timing,\n destination: record.configuration.destination,\n deliveryPrincipal: record.configuration.deliveryPrincipal,\n ...(record.configuration.admissionGroup === undefined\n ? {}\n : { admissionGroup: record.configuration.admissionGroup }),\n ...(record.configuration.admissionFence === undefined\n ? {}\n : { admissionFence: record.configuration.admissionFence }),\n agentId: record.configuration.agentId,\n },\n state: record.state,\n nextAtMillis: record.nextAtMillis,\n pending:\n record.pending === null\n ? null\n : {\n intendedAtMillis: record.pending.envelope.intendedAtMillis,\n preparedAtMillis: record.pending.envelope.preparedAtMillis,\n configurationRevision: record.pending.envelope.configurationRevision,\n occurrenceId: record.pending.envelope.occurrenceId,\n retry: record.pending.retry,\n },\n lastReceipt: record.lastReceipt,\n lastRefusal: record.lastRefusal,\n lastSkippedRange: record.lastSkippedRange,\n observedAtMillis,\n pendingAgeMillis:\n record.pending === null\n ? null\n : Math.max(0, observedAtMillis - record.pending.envelope.preparedAtMillis),\n latenessMillis:\n intendedAtMillis === null ? 0 : Math.max(0, observedAtMillis - intendedAtMillis),\n };\n};\n\nconst inputByteLength = (input: PersistedJson): number => utf8ByteLength(JSON.stringify(input));\n\nconst currentMillis = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));\n\nconst validateRequestedFields = Effect.fn(\"Scheduling.validateRequestedFields\")(function* (\n options: ScheduleCreateOptions,\n) {\n yield* Schema.encodeEffect(ScheduleTimingRequestSchema)(options.timing).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid timing request\" })),\n );\n yield* Schema.encodeEffect(ScheduleDestinationSchema)(options.destination).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid destination\" })),\n );\n yield* Schema.encodeEffect(DefinitionDigests)(options.definitions).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid definition digests\" })),\n );\n});\n\nconst resolveInput = Effect.fn(\"Scheduling.resolveInput\")(function* <\n InputSchema extends Schema.Top,\n>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n maximumBytes: number,\n): Effect.fn.Return<\n { readonly payload: PersistedJson; readonly digest: Digest },\n ScheduleValidationError,\n InputSchema[\"EncodingServices\"] | Crypto.Crypto\n> {\n const encoded = yield* Schema.encodeEffect(agent.definition.input)(input).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Unable to encode Agent input\" }),\n ),\n );\n\n const payload = yield* Schema.decodeUnknownEffect(PersistedJson)(encoded).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({\n message: \"Agent input does not satisfy the canonical persistence bounds\",\n }),\n ),\n );\n\n if (inputByteLength(payload) > maximumBytes) {\n return yield* ScheduleValidationError.make({\n message: `Encoded Agent input exceeds the configured ${maximumBytes} byte limit`,\n });\n }\n\n const digest = yield* digestJson(payload).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Unable to digest encoded Agent input\" }),\n ),\n );\n\n return { payload, digest };\n});\n\nconst makeManagement = (limits: SchedulingLimits) =>\n Effect.gen(function* () {\n const nowMillis = yield* currentMillis;\n\n yield* Schema.decodeEffect(ScheduleInstant)(nowMillis + limits.recoveryPollMillis).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({\n message: \"Scheduling recovery deadline exceeds the supported instant range\",\n }),\n ),\n );\n const store = yield* ScheduleStore;\n const authorizer = yield* ScheduleAuthorizer;\n const wake = yield* ScheduleWake;\n const crypto = yield* Crypto.Crypto;\n\n const withCrypto = <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>) =>\n Effect.provideService(effect, Crypto.Crypto, crypto);\n\n const fingerprint = Effect.fn(\"Scheduling.fingerprint\")(function* (\n agentId: AgentId,\n inputDigest: Digest,\n options: ScheduleCreateOptions,\n ) {\n const timing = yield* Schema.encodeEffect(ScheduleTimingRequestSchema)(options.timing).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid timing request\" })),\n );\n\n const destination = yield* Schema.encodeEffect(ScheduleDestinationSchema)(\n options.destination,\n ).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid destination\" })),\n );\n\n const definitions = yield* Schema.encodeEffect(DefinitionDigests)(options.definitions).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Invalid definition digests\" }),\n ),\n );\n\n return yield* withCrypto(\n digestJson({\n schemaVersion: 1,\n owner: options.scope.owner,\n scheduleId: options.scheduleId,\n registeringPrincipal: options.scope.principal,\n deliveryPrincipal: options.deliveryPrincipal,\n ...(options.admissionGroup === undefined\n ? {}\n : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined\n ? {}\n : { admissionFence: options.admissionFence }),\n agentId,\n definitions,\n destination,\n timing,\n inputDigest,\n }),\n ).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Unable to digest Schedule registration\" }),\n ),\n );\n });\n\n const configuration = (\n agentId: AgentId,\n payload: PersistedJson,\n inputDigest: Digest,\n options: ScheduleCreateOptions,\n timing: ScheduleConfiguration[\"timing\"],\n ): ScheduleConfiguration => ({\n timing,\n destination: options.destination,\n deliveryPrincipal: options.deliveryPrincipal,\n ...(options.admissionGroup === undefined ? {} : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined ? {} : { admissionFence: options.admissionFence }),\n agentId,\n definitions: options.definitions,\n input: payload,\n inputDigest,\n });\n\n const create = Effect.fn(\"Scheduling.create\")(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleCreateOptions,\n ): Effect.fn.Return<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n > {\n const nowMillis = yield* currentMillis;\n\n const resolvedInput = yield* resolveInput(agent, input, limits.maxInputBytes).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n );\n\n const creationFingerprint = yield* fingerprint(\n agent.definition.id,\n resolvedInput.digest,\n options,\n );\n\n const key = keyOf(options.scope, options.scheduleId);\n\n yield* authorizer.manage({\n operation: \"create\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n });\n const existing = yield* store.get(key);\n\n if (existing !== null) {\n if (existing.creationFingerprint !== creationFingerprint) {\n return yield* ScheduleConflict.make({ reason: \"creation\", key });\n }\n yield* authorizer.manage({\n operation: \"create\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n configuration: existing.configuration,\n });\n\n return asSnapshot(existing, nowMillis);\n }\n\n const timing = yield* Effect.fromResult(\n normalizeScheduleTiming(options.timing, nowMillis, limits.minIntervalMillis),\n );\n\n const nextAtMillis = yield* Effect.fromResult(scheduleInitialCursor(timing, nowMillis));\n\n if (nextAtMillis === null) {\n return yield* ScheduleValidationError.make({ message: \"Timing has no next occurrence\" });\n }\n\n const nextConfiguration = configuration(\n agent.definition.id,\n resolvedInput.payload,\n resolvedInput.digest,\n options,\n timing,\n );\n\n yield* authorizer.manage({\n operation: \"create\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n configuration: nextConfiguration,\n });\n\n const record: ScheduleRecord = {\n schemaVersion: 1,\n owner: options.scope.owner,\n scheduleId: options.scheduleId,\n creationFingerprint,\n createdBy: options.scope.principal,\n createdAtMillis: nowMillis,\n updatedAtMillis: nowMillis,\n configurationRevision: 1,\n version: 1,\n configuration: nextConfiguration,\n state: \"active\",\n nextAtMillis,\n pending: null,\n lastReceipt: null,\n lastRefusal: null,\n lastSkippedRange: null,\n };\n\n const inserted = yield* store.insert(record, limits.maxSchedulesPerOwner);\n\n yield* wake.notify;\n\n return asSnapshot(inserted, nowMillis);\n });\n\n const update = Effect.fn(\"Scheduling.update\")(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleUpdateOptions,\n ): Effect.fn.Return<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n > {\n const nowMillis = yield* currentMillis;\n const key = keyOf(options.scope, options.scheduleId);\n\n yield* authorizer.manage({\n operation: \"update\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n });\n yield* validateRequestedFields(options);\n const existing = yield* store.get(key);\n\n if (existing === null) return yield* notFound(key);\n if (existing.configurationRevision !== options.expectedRevision) {\n return yield* ScheduleConflict.make({ reason: \"revision\", key });\n }\n\n const resolvedInput = yield* resolveInput(agent, input, limits.maxInputBytes).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n );\n\n const timingRequest =\n options.timing._tag === \"Interval\" &&\n options.timing.anchorMillis === undefined &&\n existing.configuration.timing._tag === \"Interval\" &&\n existing.configuration.timing.everyMillis === options.timing.everyMillis\n ? { ...options.timing, anchorMillis: existing.configuration.timing.anchorMillis }\n : options.timing;\n\n const timing = yield* Effect.fromResult(\n normalizeScheduleTiming(timingRequest, nowMillis, limits.minIntervalMillis),\n );\n\n const nextAtMillis =\n timing._tag === \"At\"\n ? timing.atMillis\n : yield* Effect.fromResult(scheduleNextAfter(timing, nowMillis));\n\n if (nextAtMillis === null) {\n return yield* ScheduleValidationError.make({ message: \"Timing has no next occurrence\" });\n }\n\n const nextConfiguration = configuration(\n agent.definition.id,\n resolvedInput.payload,\n resolvedInput.digest,\n options,\n timing,\n );\n\n yield* authorizer.manage({\n operation: \"update\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n configuration: nextConfiguration,\n });\n\n const changed = yield* store.change(\n key,\n {\n _tag: \"Update\",\n expectedRevision: options.expectedRevision,\n configuration: nextConfiguration,\n nextAtMillis,\n nowMillis,\n },\n limits.maxSchedulesPerOwner,\n );\n\n yield* wake.notify;\n\n return asSnapshot(changed, nowMillis);\n });\n\n const get = Effect.fn(\"Scheduling.get\")(function* (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n ) {\n yield* authorizer.manage({ operation: \"get\", scope, scheduleId });\n const key = keyOf(scope, scheduleId);\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n\n return asSnapshot(record, yield* currentMillis);\n });\n\n const list = Effect.fn(\"Scheduling.list\")(function* (\n scope: ScheduleScope,\n options: ScheduleListOptions = {},\n ) {\n yield* authorizer.manage({ operation: \"list\", scope });\n const limit = options.limit ?? 50;\n\n if (!Number.isInteger(limit) || limit < 1 || limit > 100) {\n return yield* ScheduleValidationError.make({\n message: \"Schedule page limit must be an integer from 1 through 100\",\n });\n }\n\n const page = yield* store.list({\n owner: scope.owner,\n ...(options.after === undefined ? {} : { after: options.after }),\n limit,\n });\n\n const nowMillis = yield* currentMillis;\n\n return { items: page.items.map((record) => asSnapshot(record, nowMillis)), next: page.next };\n });\n\n const control = Effect.fn(\"Scheduling.control\")(function* (\n operation: \"pause\" | \"resume\" | \"cancel\",\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ): Effect.fn.Return<ScheduleSnapshot, ScheduleManagementFailure> {\n yield* authorizer.manage({ operation, scope, scheduleId });\n const key = keyOf(scope, scheduleId);\n\n const attempt = (): Effect.Effect<ScheduleRecord, ScheduleManagementFailure> =>\n Effect.suspend(() =>\n Effect.gen(function* () {\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n if (record.configurationRevision !== expectedRevision) {\n return yield* ScheduleConflict.make({ reason: \"revision\", key });\n }\n if (operation === \"resume\" && record.state === \"active\") return record;\n const nowMillis = yield* currentMillis;\n\n const nextAtMillis =\n operation === \"resume\"\n ? yield* Effect.fromResult(\n scheduleResumeCursor(\n record.configuration.timing,\n record.nextAtMillis,\n nowMillis,\n ),\n )\n : operation === \"cancel\"\n ? null\n : record.nextAtMillis;\n\n const skippedRange =\n operation === \"resume\" &&\n record.configuration.timing._tag !== \"At\" &&\n record.nextAtMillis !== null &&\n nextAtMillis !== null &&\n nextAtMillis > record.nextAtMillis\n ? { fromMillis: record.nextAtMillis, toMillis: nextAtMillis }\n : null;\n\n return yield* store\n .change(\n key,\n {\n _tag: \"Control\",\n expectedRevision,\n expectedVersion: record.version,\n action: operation,\n nextAtMillis,\n nowMillis,\n skippedRange,\n },\n limits.maxSchedulesPerOwner,\n )\n .pipe(\n Effect.catchTag(\"ScheduleConflict\", (error) =>\n error.reason === \"revision\" ? attempt() : Effect.fail(error),\n ),\n );\n }),\n );\n\n const changed = yield* attempt();\n\n yield* wake.notify;\n\n return asSnapshot(changed, yield* currentMillis);\n });\n\n const recover = Effect.fn(\"Scheduling.recover\")(function* (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n expectedGeneration: number,\n ) {\n yield* authorizer.manage({ operation: \"recover\", scope, scheduleId });\n const key = keyOf(scope, scheduleId);\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n if (record.configurationRevision !== expectedRevision)\n return yield* ScheduleConflict.make({ reason: \"revision\", key });\n const time = yield* currentMillis;\n\n if (record.pending === null) return asSnapshot(record, time);\n\n const recovered = yield* store.change(key, {\n _tag: \"Recover\",\n expectedGeneration,\n expectedRevision,\n occurrenceId: record.pending.envelope.occurrenceId,\n nowMillis: time,\n });\n\n yield* wake.notify;\n\n return asSnapshot(recovered, time);\n });\n\n return Scheduling.of({\n recover,\n create,\n update,\n get,\n list,\n pause: (scope, id, revision) => control(\"pause\", scope, id, revision),\n resume: (scope, id, revision) => control(\"resume\", scope, id, revision),\n cancel: (scope, id, revision) => control(\"cancel\", scope, id, revision),\n });\n });\n\nconst makeDriver = (limits: SchedulingLimits) =>\n Effect.gen(function* () {\n const store = yield* ScheduleStore;\n const authorizer = yield* ScheduleAuthorizer;\n const admission = yield* ScheduledInputAdmission;\n const failpoint = yield* ScheduleFailpoint;\n const crypto = yield* Crypto.Crypto;\n const admissionSemaphore = yield* Semaphore.make(limits.admissionConcurrency);\n\n const withCrypto = <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>) =>\n Effect.provideService(effect, Crypto.Crypto, crypto);\n\n const retry = Effect.fn(\"Scheduling.retry\")(function* (\n key: ScheduleKey,\n record: ScheduleRecord,\n reason: ScheduleRetryReason,\n nowMillis: number,\n ) {\n if (record.pending === null) return record;\n const current = record.pending.retry;\n\n const delay = Math.min(\n limits.retryBaseMillis * 2 ** Math.min(current.attempts, 52),\n limits.retryMaxMillis,\n );\n\n return yield* store.change(key, {\n _tag: \"Retry\",\n occurrenceId: record.pending.envelope.occurrenceId,\n retry: {\n generation: current.generation,\n attempts: current.attempts + 1,\n automaticAttempts: current.automaticAttempts + 1,\n parked: current.automaticAttempts + 1 >= (limits.maxAutomaticAttempts ?? 8),\n nextAttemptAtMillis: Math.min(nowMillis + delay, 8_640_000_000_000_000),\n lastAttemptAtMillis: nowMillis,\n lastFailure: reason,\n },\n nowMillis,\n });\n });\n\n const verifyPending = Effect.fn(\"Scheduling.verifyPending\")(function* (\n key: ScheduleKey,\n record: ScheduleRecord,\n ) {\n const pending = record.pending;\n\n if (pending === null) return;\n const envelope = pending.envelope;\n\n const occurrenceId = yield* withCrypto(\n digestJson({\n schemaVersion: 1,\n owner: envelope.owner,\n scheduleId: envelope.scheduleId,\n configurationRevision: envelope.configurationRevision,\n intendedAtMillis: envelope.intendedAtMillis,\n }),\n ).pipe(Effect.mapError(() => corrupt(\"process\")));\n\n const usesCurrentConfiguration =\n envelope.configurationRevision === record.configurationRevision;\n\n const expectedThreadId = usesCurrentConfiguration\n ? record.configuration.destination._tag === \"ExistingThread\"\n ? record.configuration.destination.threadId\n : Schema.decodeSync(ThreadId)(`schedule-thread:${envelope.occurrenceId}`)\n : null;\n\n const expectedAdmissionKey = Schema.decodeSync(IdempotencyKey)(\n `schedule-occurrence:${envelope.occurrenceId}`,\n );\n\n const digest = yield* withCrypto(digestJson(envelope.input)).pipe(\n Effect.mapError(() => corrupt(\"process\")),\n );\n\n if (\n envelope.schemaVersion !== 1 ||\n envelope.owner.tenantId !== key.owner.tenantId ||\n envelope.owner.ownerId !== key.owner.ownerId ||\n envelope.scheduleId !== key.scheduleId ||\n envelope.configurationRevision > record.configurationRevision ||\n envelope.occurrenceId !== occurrenceId ||\n (usesCurrentConfiguration &&\n (envelope.deliveryPrincipal !== record.configuration.deliveryPrincipal ||\n envelope.agentId !== record.configuration.agentId ||\n !equivalentDefinitions(envelope.definitions, record.configuration.definitions) ||\n !equivalentInput(envelope.input, record.configuration.input) ||\n envelope.inputDigest !== record.configuration.inputDigest)) ||\n envelope.inputDigest !== digest ||\n (expectedThreadId !== null && envelope.threadId !== expectedThreadId) ||\n envelope.admissionKey !== expectedAdmissionKey\n ) {\n return yield* corrupt(\"process\");\n }\n });\n\n const deliverPending = Effect.fn(\"Scheduling.deliverPending\")(function* (\n key: ScheduleKey,\n record: ScheduleRecord,\n nowMillis: number,\n ) {\n if (\n record.pending === null ||\n record.pending.retry.parked === true ||\n record.pending.retry.nextAttemptAtMillis > nowMillis\n ) {\n return record;\n }\n yield* verifyPending(key, record);\n const envelope = record.pending.envelope;\n\n const outcome = yield* admissionSemaphore.withPermit(\n admitPreparedInput(admission.submit(envelope), limits.admissionTimeoutMillis).pipe(\n Effect.tap((outcome) =>\n outcome._tag === \"Receipt\" ? failpoint.hit(\"schedule:admission:after\") : Effect.void,\n ),\n ),\n );\n\n const completedAtMillis = yield* currentMillis;\n\n if (outcome._tag === \"Receipt\") {\n if (outcome.receipt.threadId !== envelope.threadId) {\n return yield* corrupt(\"admission\");\n }\n\n return yield* store\n .change(key, {\n _tag: \"Complete\",\n occurrenceId: envelope.occurrenceId,\n receipt: outcome.receipt,\n nowMillis: completedAtMillis,\n })\n .pipe(\n Effect.catchTag(\"ScheduleStorageError\", (error) =>\n error.reason === \"unavailable\"\n ? retry(key, record, \"storage\", completedAtMillis)\n : Effect.fail(error),\n ),\n );\n }\n if (outcome._tag === \"Refused\") {\n const refusal: ScheduleRefusal = {\n atMillis: completedAtMillis,\n intendedAtMillis: envelope.intendedAtMillis,\n occurrenceId: envelope.occurrenceId,\n phase: \"admission\",\n code: outcome.error.code,\n };\n\n return yield* store\n .change(key, {\n _tag: \"Refuse\",\n occurrenceId: envelope.occurrenceId,\n refusal,\n nowMillis: completedAtMillis,\n })\n .pipe(\n Effect.catchTag(\"ScheduleStorageError\", (error) =>\n error.reason === \"unavailable\"\n ? retry(key, record, \"storage\", completedAtMillis)\n : Effect.fail(error),\n ),\n );\n }\n\n return yield* retry(key, record, outcome.reason, completedAtMillis);\n });\n\n const processRecord = Effect.fn(\"Scheduling.processRecord\")(function* (\n key: ScheduleKey,\n initial: ScheduleRecord,\n nowMillis: number,\n ): Effect.fn.Return<ScheduleRecord, ScheduleProcessFailure> {\n if (initial.pending !== null) return yield* deliverPending(key, initial, nowMillis);\n if (\n initial.state !== \"active\" ||\n initial.nextAtMillis === null ||\n initial.nextAtMillis > nowMillis\n ) {\n return initial;\n }\n\n const currentInputDigest = yield* withCrypto(digestJson(initial.configuration.input)).pipe(\n Effect.mapError(() =>\n ScheduleStorageError.make({ operation: \"prepare\", reason: \"unavailable\" }),\n ),\n );\n\n if (currentInputDigest !== initial.configuration.inputDigest) {\n return yield* corrupt(\"prepare\");\n }\n\n const due = yield* Effect.fromResult(\n scheduleDueOccurrence(initial.configuration.timing, initial.nextAtMillis, nowMillis),\n );\n\n if (due === null) return initial;\n\n const occurrenceId = yield* withCrypto(\n digestJson({\n schemaVersion: 1,\n owner: initial.owner,\n scheduleId: initial.scheduleId,\n configurationRevision: initial.configurationRevision,\n intendedAtMillis: due.intendedAtMillis,\n }),\n ).pipe(Effect.mapError(() => corrupt(\"prepare\")));\n\n const occurrence = {\n key,\n configurationRevision: initial.configurationRevision,\n configuration: initial.configuration,\n intendedAtMillis: due.intendedAtMillis,\n occurrenceId,\n };\n\n const authorization = yield* authorizer.prepare(occurrence).pipe(Effect.result);\n\n if (Result.isFailure(authorization)) {\n if (authorization.failure._tag === \"ScheduleStorageError\") {\n return yield* authorization.failure;\n }\n\n return yield* store.change(key, {\n _tag: \"DenyPreparation\",\n expectedRevision: initial.configurationRevision,\n expectedCursor: initial.nextAtMillis,\n refusal: {\n atMillis: nowMillis,\n intendedAtMillis: due.intendedAtMillis,\n occurrenceId,\n phase: \"preparation\",\n code: authorization.failure.code,\n },\n nowMillis,\n });\n }\n\n const threadId =\n initial.configuration.destination._tag === \"ExistingThread\"\n ? initial.configuration.destination.threadId\n : Schema.decodeSync(ThreadId)(`schedule-thread:${occurrenceId}`);\n\n const admissionKey = Schema.decodeSync(IdempotencyKey)(`schedule-occurrence:${occurrenceId}`);\n\n const prepared = yield* store.change(key, {\n _tag: \"Prepare\",\n expectedRevision: initial.configurationRevision,\n expectedCursor: initial.nextAtMillis,\n envelope: {\n schemaVersion: 1,\n owner: initial.owner,\n scheduleId: initial.scheduleId,\n configurationRevision: initial.configurationRevision,\n intendedAtMillis: due.intendedAtMillis,\n preparedAtMillis: nowMillis,\n occurrenceId,\n threadId,\n deliveryPrincipal: initial.configuration.deliveryPrincipal,\n ...(initial.configuration.admissionGroup === undefined\n ? {}\n : { admissionGroup: initial.configuration.admissionGroup }),\n ...(initial.configuration.admissionFence === undefined\n ? {}\n : { admissionFence: initial.configuration.admissionFence }),\n agentId: initial.configuration.agentId,\n definitions: initial.configuration.definitions,\n input: initial.configuration.input,\n inputDigest: initial.configuration.inputDigest,\n admissionKey,\n authorization: authorization.success,\n },\n nextAtMillis: due.nextAtMillis,\n skippedRange: due.skippedRange,\n nowMillis,\n });\n\n return yield* deliverPending(key, prepared, nowMillis);\n });\n\n const process = Effect.fn(\"Scheduling.process\")(function* (key: ScheduleKey) {\n const nowMillis = yield* currentMillis;\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n\n const processed = yield* processRecord(key, record, nowMillis).pipe(\n Effect.catchTag(\"ScheduleConflict\", () =>\n store\n .get(key)\n .pipe(\n Effect.flatMap((current) =>\n current === null\n ? Effect.fail(notFound(key))\n : processRecord(key, current, nowMillis),\n ),\n ),\n ),\n );\n\n return processed;\n });\n\n const runDue = Effect.fn(\"ScheduleDriver.runDue\")(function* (owner?: ScheduleOwner) {\n const nowMillis = yield* currentMillis;\n let after: ScheduleDueCursor | undefined;\n let processed = 0;\n let failed = 0;\n\n while (true) {\n const due = yield* store.due(nowMillis, limits.dueBatchSize, owner, after);\n\n if (due.length === 0) break;\n yield* Effect.forEach(\n due,\n (key) =>\n process(key).pipe(\n Effect.matchCauseEffect({\n onSuccess: () =>\n Effect.sync(() => {\n processed += 1;\n }),\n onFailure: (cause) =>\n Cause.hasInterrupts(cause)\n ? Effect.interrupt\n : Effect.gen(function* () {\n failed += 1;\n yield* Effect.logWarning(\"Schedule processing failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (error) => error._tag,\n }),\n }),\n );\n }),\n }),\n ),\n { concurrency: limits.admissionConcurrency },\n );\n after = due.at(-1);\n if (due.length < limits.dueBatchSize) break;\n }\n\n return { processed, failed };\n });\n\n return ScheduleDriver.of({ process, runDue });\n });\n\nconst corrupt = (operation: string): ScheduleStorageError =>\n ScheduleStorageError.make({ operation, reason: \"corrupt\" });\n\nconst validateLimits = (limits: SchedulingLimits) =>\n Schema.decodeEffect(SchedulingLimits)(limits).pipe(\n Effect.mapError((error) =>\n ScheduleValidationError.make({ message: `Invalid Scheduling limits: ${error.message}` }),\n ),\n Effect.filterOrFail(\n (validated) => validated.retryBaseMillis <= validated.retryMaxMillis,\n () =>\n ScheduleValidationError.make({\n message: \"Scheduling retryBaseMillis must not exceed retryMaxMillis\",\n }),\n ),\n );\n\nexport class Scheduling extends Context.Service<\n Scheduling,\n {\n readonly create: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleCreateOptions,\n ) => Effect.Effect<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n >;\n readonly update: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleUpdateOptions,\n ) => Effect.Effect<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n >;\n readonly get: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly list: (\n scope: ScheduleScope,\n options?: ScheduleListOptions,\n ) => Effect.Effect<ScheduleSnapshotPage, ScheduleManagementFailure>;\n readonly pause: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly resume: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly recover: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n expectedGeneration: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly cancel: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n }\n>()(\"@effect-agent/thread/Scheduling\") {\n static layer(\n limits: SchedulingLimits = defaultSchedulingLimits,\n ): Layer.Layer<\n Scheduling,\n ScheduleValidationError,\n ScheduleStore | ScheduleAuthorizer | ScheduleWake | Crypto.Crypto\n > {\n return Layer.effect(Scheduling, validateLimits(limits).pipe(Effect.flatMap(makeManagement)));\n }\n}\n\nexport const ScheduleWakeNoop: Layer.Layer<ScheduleWake> = Layer.succeed(ScheduleWake, {\n notify: Effect.void,\n await: Effect.never,\n});\n\n/** Privileged host capability. Never provide this service to management callers or model tools. */\nexport class ScheduleDriver extends Context.Service<\n ScheduleDriver,\n {\n readonly process: (key: ScheduleKey) => Effect.Effect<ScheduleRecord, ScheduleProcessFailure>;\n readonly runDue: (\n owner?: ScheduleOwner,\n ) => Effect.Effect<\n { readonly processed: number; readonly failed: number },\n ScheduleStorageError\n >;\n }\n>()(\"@effect-agent/thread/ScheduleDriver\") {\n static layer(\n limits: SchedulingLimits = defaultSchedulingLimits,\n ): Layer.Layer<\n ScheduleDriver,\n ScheduleValidationError,\n ScheduleStore | ScheduleAuthorizer | ScheduledInputAdmission | Crypto.Crypto\n > {\n return Layer.effect(ScheduleDriver, validateLimits(limits).pipe(Effect.flatMap(makeDriver)));\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,WAAW,YAAoB,OAAO,KAAK,wBAAwB,KAAK,EAAE,QAAQ,CAAC,CAAC;AAE1F,MAAM,kBAAkB,QAAgB,UACtC,OAAO,aAAa,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,KAC3C,OAAO,eACL,wBAAwB,KAAK,EAC3B,SAAS,GAAG,MAAM,iDACpB,CAAC,CACH,CACF;AAEF,MAAM,UAAU,KAA0B,SACxC,IAAI,SAAS,IAAI,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,UAAU,KAAK,IAAI,CAAC,GAAG,GAAG;;;;;;AAO9E,MAAM,yBACJ,MACA,kBACiD;CACjD,IAAI,KAAK,QAAQ,SAAS,GACxB,OAAO,QAAQ,4CAA4C;CAE7D,IAAI,iBAAiB,KAAQ,OAAO,OAAO,QAAQ,KAAA,CAAS;CAC5D,IACE,OAAO,OAAO,KAAK,EAAE,KACrB,SAAS,gBAAgB,KAAK,GAAG,KAAK,KACtC,KAAK,GAAG,MAAM,OAAO,OAErB,OAAO,QAAQ,wEAAwE;CAGzF,MAAM,cAAc,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC,SAAS,SAClD,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,KAAK,WAAW,OAAO,KAAK,MAAM,CAC7D;CAEA,YAAY,MAAM,MAAM,UAAU,OAAO,KAAK;CAC9C,IAAI,aAAa;CAEjB,KAAK,IAAI,QAAQ,GAAG,QAAQ,YA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C,qCAAqC,CAAC,CAAC;CACzC,OAAO,MACL,SAA2B,yBAK3B;EACA,OAAO,MAAM,OAAO,gBAAgB,eAAe,MAAM,CAAC,CAAC,KAAK,OAAO,QAAQ,UAAU,CAAC,CAAC;CAC7F;AACF"}
|
|
1
|
+
{"version":3,"file":"Scheduling-C3QpYn0W.mjs","names":["ScheduleTimingRequestSchema","ScheduleDestinationSchema"],"sources":["../src/durable/internal/schedule-time.ts","../src/durable/Scheduling.ts"],"sourcesContent":["import { Cron, DateTime, Option, Result, Schema } from \"effect\";\n\nimport {\n ScheduleValidationError,\n ScheduleInstant,\n type ScheduleSkippedRange,\n type ScheduleTiming,\n type ScheduleTimingRequest,\n} from \"../Schedule.ts\";\n\nconst invalid = (message: string) => Result.fail(ScheduleValidationError.make({ message }));\n\nconst checkedInstant = (millis: number, label: string) =>\n Schema.decodeResult(ScheduleInstant)(millis).pipe(\n Result.mapError(() =>\n ScheduleValidationError.make({\n message: `${label} is outside the supported ScheduleInstant range`,\n }),\n ),\n );\n\nconst values = (set: ReadonlySet<number>, size: number): ReadonlyArray<number> =>\n set.size === 0 ? Array.from({ length: size }, (_, index) => index) : [...set];\n\n/**\n * Cron frequency proof without calendar enumeration. It checks the minimum circular spacing of\n * the allowed hour/minute pairs. Day restrictions may make a rule sparser, so this deliberately\n * rejects some safe rules when a configured minimum exceeds one minute.\n */\nconst validateCronFrequency = (\n cron: Cron.Cron,\n minimumMillis: number,\n): Result.Result<void, ScheduleValidationError> => {\n if (cron.seconds.size !== 1) {\n return invalid(\"Cron must select exactly one seconds value\");\n }\n if (minimumMillis <= 60_000) return Result.succeed(undefined);\n if (\n Option.isSome(cron.tz) &&\n DateTime.isTimeZoneNamed(cron.tz.value) &&\n cron.tz.value.id !== \"UTC\"\n ) {\n return invalid(\"Cron minimums above one minute require UTC or a fixed-offset time zone\");\n }\n\n const minuteOfDay = values(cron.hours, 24).flatMap((hour) =>\n values(cron.minutes, 60).map((minute) => hour * 60 + minute),\n );\n\n minuteOfDay.sort((left, right) => left - right);\n let minimumGap = 24 * 60;\n\n for (let index = 0; index < minuteOfDay.length; index += 1) {\n const current = minuteOfDay[index];\n const next = minuteOfDay[(index + 1) % minuteOfDay.length];\n\n if (current === undefined || next === undefined) continue;\n const gap = next > current ? next - current : 24 * 60 - current + next;\n\n minimumGap = Math.min(minimumGap, gap);\n }\n\n return minimumGap * 60_000 >= minimumMillis\n ? Result.succeed(undefined)\n : invalid(`Cron may fire more often than the configured ${minimumMillis}ms minimum`);\n};\n\nexport const parseScheduleCron = (\n expression: string,\n timeZone: string,\n minimumMillis: number,\n): Result.Result<Cron.Cron, ScheduleValidationError> => {\n const parsed = Cron.parse(expression, timeZone);\n\n if (Result.isFailure(parsed)) return invalid(parsed.failure.message);\n const frequency = validateCronFrequency(parsed.success, minimumMillis);\n\n return Result.isFailure(frequency)\n ? Result.fail(frequency.failure)\n : Result.succeed(parsed.success);\n};\n\nexport const normalizeScheduleTiming = (\n request: ScheduleTimingRequest,\n nowMillis: number,\n minimumMillis: number,\n): Result.Result<ScheduleTiming, ScheduleValidationError> => {\n switch (request._tag) {\n case \"At\":\n return Result.succeed(request);\n case \"After\": {\n const at = checkedInstant(nowMillis + request.delayMillis, \"Relative deadline\");\n\n return Result.map(at, (atMillis) => ({ _tag: \"At\" as const, atMillis }));\n }\n case \"Interval\": {\n if (request.everyMillis < minimumMillis) {\n return invalid(`Interval must be at least ${minimumMillis}ms`);\n }\n\n const anchor = checkedInstant(\n request.anchorMillis ?? nowMillis + request.everyMillis,\n \"Interval anchor\",\n );\n\n return Result.map(anchor, (anchorMillis) => ({\n _tag: \"Interval\" as const,\n everyMillis: request.everyMillis,\n anchorMillis,\n }));\n }\n case \"Cron\": {\n const timeZone = request.timeZone ?? \"UTC\";\n const cron = parseScheduleCron(request.expression, timeZone, minimumMillis);\n\n if (Result.isFailure(cron)) return Result.fail(cron.failure);\n\n return Result.succeed({ _tag: \"Cron\", expression: request.expression, timeZone });\n }\n }\n};\n\nconst parsedStoredCron = (timing: Extract<ScheduleTiming, { _tag: \"Cron\" }>) => {\n const parsed = Cron.parse(timing.expression, timing.timeZone);\n\n return Result.isFailure(parsed)\n ? invalid(`Stored cron is invalid: ${parsed.failure.message}`)\n : Result.succeed(parsed.success);\n};\n\n/** Strictly selects the first occurrence after an instant. */\nexport const scheduleNextAfter = (\n timing: ScheduleTiming,\n afterMillis: number,\n): Result.Result<number | null, ScheduleValidationError> => {\n switch (timing._tag) {\n case \"At\":\n return Result.succeed(timing.atMillis > afterMillis ? timing.atMillis : null);\n case \"Interval\": {\n if (afterMillis < timing.anchorMillis) return Result.succeed(timing.anchorMillis);\n const steps = Math.floor((afterMillis - timing.anchorMillis) / timing.everyMillis) + 1;\n const next = timing.anchorMillis + steps * timing.everyMillis;\n\n return checkedInstant(next, \"Next interval occurrence\");\n }\n case \"Cron\": {\n const cron = parsedStoredCron(timing);\n\n if (Result.isFailure(cron)) return Result.fail(cron.failure);\n\n return Result.try({\n try: () => {\n let next = Cron.next(cron.success, afterMillis).getTime();\n\n // Inside a fall fold Effect may select the first, already elapsed local instant.\n while (next <= afterMillis) {\n const following = Cron.next(cron.success, next).getTime();\n\n if (following <= next) throw new Error(\"Cron did not advance\");\n next = following;\n }\n\n return next;\n },\n catch: () => ScheduleValidationError.make({ message: \"Cron has no supported next firing\" }),\n }).pipe(Result.flatMap((next) => checkedInstant(next, \"Next cron occurrence\")));\n }\n }\n};\n\n/** Initial cursor. Past one-shots remain due; recurring rules start strictly after registration. */\nexport const scheduleInitialCursor = (\n timing: ScheduleTiming,\n nowMillis: number,\n): Result.Result<number | null, ScheduleValidationError> =>\n timing._tag === \"At\" ? Result.succeed(timing.atMillis) : scheduleNextAfter(timing, nowMillis);\n\nexport interface DueScheduleOccurrence {\n readonly intendedAtMillis: number;\n readonly nextAtMillis: number | null;\n readonly skippedRange: ScheduleSkippedRange | null;\n}\n\n/** Coalesces recurring occurrences using the same forward sequence as registration. */\nexport const scheduleDueOccurrence = (\n timing: ScheduleTiming,\n cursorMillis: number,\n nowMillis: number,\n): Result.Result<DueScheduleOccurrence | null, ScheduleValidationError> => {\n if (cursorMillis > nowMillis) return Result.succeed(null);\n if (timing._tag === \"At\") {\n return Result.succeed({\n intendedAtMillis: cursorMillis,\n nextAtMillis: null,\n skippedRange: null,\n });\n }\n\n let intendedAtMillis: number;\n\n if (timing._tag === \"Interval\") {\n const steps = Math.floor((nowMillis - timing.anchorMillis) / timing.everyMillis);\n\n intendedAtMillis = Math.max(cursorMillis, timing.anchorMillis + steps * timing.everyMillis);\n } else {\n const cron = parsedStoredCron(timing);\n\n if (Result.isFailure(cron)) return Result.fail(cron.failure);\n\n const due = Result.try({\n try: () => {\n let intended = cursorMillis;\n // Reverse traversal is safe only without offset transitions. Named-zone reverse\n // traversal has different gap/fold semantics from the forward occurrence sequence.\n const zone = Option.getOrUndefined(cron.success.tz);\n\n if (zone !== undefined && (DateTime.isTimeZoneOffset(zone) || zone.id === \"UTC\")) {\n intended = Math.max(cursorMillis, Cron.prev(cron.success, nowMillis + 1_000).getTime());\n } else {\n // Seek by calendar date in UTC, where reverse traversal has no DST ambiguity.\n // Include two prior civil days to cover even IANA date-line shifts. There are no\n // matching dates between this seed day and that boundary, so forward traversal\n // visits only the seed day and the recent days, regardless of downtime length.\n const calendar = Cron.make({\n ...cron.success,\n seconds: [0],\n minutes: [0],\n hours: [0],\n tz: DateTime.zoneMakeNamedUnsafe(\"UTC\"),\n });\n\n const localDay = DateTime.makeUnsafe(\n DateTime.toDate(DateTime.makeZonedUnsafe(nowMillis, { timeZone: zone })),\n ).pipe(DateTime.startOf(\"day\"), DateTime.subtract({ days: 2 }));\n\n const seedDay = Cron.prev(calendar, DateTime.toEpochMillis(localDay) + 1_000);\n\n const seed =\n DateTime.makeZonedUnsafe(seedDay, {\n timeZone: zone,\n adjustForTimeZone: true,\n }).pipe(DateTime.toEpochMillis) - 1_000;\n\n if (seed > cursorMillis) {\n const first = Cron.next(cron.success, seed).getTime();\n\n if (first <= nowMillis) intended = Math.max(intended, first);\n }\n }\n let next = Cron.next(cron.success, intended).getTime();\n\n while (next <= nowMillis) {\n if (next <= intended) throw new Error(\"Cron did not advance\");\n intended = next;\n next = Cron.next(cron.success, intended).getTime();\n }\n\n return { intended, next };\n },\n catch: () => ScheduleValidationError.make({ message: \"Cron has no supported due firing\" }),\n });\n\n if (Result.isFailure(due)) return Result.fail(due.failure);\n const next = checkedInstant(due.success.next, \"Next cron occurrence\");\n\n if (Result.isFailure(next)) return Result.fail(next.failure);\n\n return Result.succeed({\n intendedAtMillis: due.success.intended,\n nextAtMillis: next.success,\n skippedRange:\n due.success.intended === cursorMillis\n ? null\n : {\n fromMillis: cursorMillis,\n toMillis: due.success.intended,\n },\n });\n }\n\n const next = scheduleNextAfter(timing, nowMillis);\n\n if (Result.isFailure(next)) return Result.fail(next.failure);\n\n return Result.succeed({\n intendedAtMillis,\n nextAtMillis: next.success,\n skippedRange:\n intendedAtMillis === cursorMillis\n ? null\n : { fromMillis: cursorMillis, toMillis: intendedAtMillis },\n });\n};\n\nexport const scheduleResumeCursor = (\n timing: ScheduleTiming,\n existingCursor: number | null,\n nowMillis: number,\n): Result.Result<number | null, ScheduleValidationError> => {\n if (timing._tag === \"At\") return Result.succeed(existingCursor);\n\n return scheduleNextAfter(timing, nowMillis);\n};\n","import {\n Cause,\n Context,\n Crypto,\n DateTime,\n Effect,\n Layer,\n Option,\n Result,\n Schema,\n Semaphore,\n} from \"effect\";\n\nimport { type AgentId, ThreadId } from \"../core/Identifiers.ts\";\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { digestJson } from \"./Digest.ts\";\nimport type { DurableSubmitAgent } from \"./DurableAgentRuntime.ts\";\nimport {\n normalizeScheduleTiming,\n scheduleDueOccurrence,\n scheduleInitialCursor,\n scheduleNextAfter,\n scheduleResumeCursor,\n} from \"./internal/schedule-time.ts\";\nimport { admitPreparedInput } from \"./PreparedInputAdmission.ts\";\nimport { DefinitionDigests, type Digest, PersistedJson } from \"./Records.ts\";\nimport {\n defaultSchedulingLimits,\n type ScheduleAuthorizationError,\n ScheduleAuthorizer,\n ScheduleConflict,\n type ScheduleConfiguration,\n ScheduleDestination as ScheduleDestinationSchema,\n type ScheduleDestination,\n ScheduleFailpoint,\n type ScheduleId,\n type ScheduleDueCursor,\n ScheduleInstant,\n type ScheduleKey,\n SchedulingLimits,\n ScheduleNotFound,\n type ScheduleOwner,\n type ScheduleRecord,\n type ScheduleRefusal,\n type ScheduleRetryReason,\n type ScheduleScope,\n type ScheduleSnapshot,\n type ScheduleSnapshotPage,\n ScheduleStorageError,\n ScheduleStore,\n type ScheduleStoreFailure,\n ScheduleTimingRequest as ScheduleTimingRequestSchema,\n type ScheduleTimingRequest,\n ScheduleValidationError,\n ScheduledInputAdmission,\n ScheduleWake,\n} from \"./Schedule.ts\";\nimport { type AdmissionFence, IdempotencyKey, type Principal } from \"./SubmissionLedger.ts\";\n\nexport interface ScheduleCreateOptions {\n readonly scope: ScheduleScope;\n readonly scheduleId: ScheduleId;\n readonly timing: ScheduleTimingRequest;\n readonly destination: ScheduleDestination;\n readonly deliveryPrincipal: Principal;\n readonly admissionGroup?: string;\n readonly admissionFence?: AdmissionFence;\n readonly definitions: DefinitionDigests;\n}\n\nexport interface ScheduleUpdateOptions extends ScheduleCreateOptions {\n readonly expectedRevision: number;\n}\n\nexport interface ScheduleListOptions {\n readonly after?: ScheduleId | undefined;\n readonly limit?: number | undefined;\n}\n\nexport type ScheduleManagementFailure =\n | ScheduleValidationError\n | ScheduleAuthorizationError\n | ScheduleStoreFailure;\n\nexport type ScheduleProcessFailure =\n | ScheduleValidationError\n | ScheduleStoreFailure\n | ScheduleStorageError;\n\nconst equivalentDefinitions = Schema.toEquivalence(DefinitionDigests);\nconst equivalentInput = Schema.toEquivalence(PersistedJson);\n\nconst keyOf = (scope: ScheduleScope, scheduleId: ScheduleId): ScheduleKey => ({\n owner: scope.owner,\n scheduleId,\n});\n\nconst notFound = (key: ScheduleKey) => ScheduleNotFound.make({ key });\n\nconst asSnapshot = (record: ScheduleRecord, observedAtMillis: number): ScheduleSnapshot => {\n const intendedAtMillis = record.pending?.envelope.intendedAtMillis ?? record.nextAtMillis;\n\n return {\n owner: record.owner,\n scheduleId: record.scheduleId,\n createdAtMillis: record.createdAtMillis,\n updatedAtMillis: record.updatedAtMillis,\n configurationRevision: record.configurationRevision,\n configuration: {\n timing: record.configuration.timing,\n destination: record.configuration.destination,\n deliveryPrincipal: record.configuration.deliveryPrincipal,\n ...(record.configuration.admissionGroup === undefined\n ? {}\n : { admissionGroup: record.configuration.admissionGroup }),\n ...(record.configuration.admissionFence === undefined\n ? {}\n : { admissionFence: record.configuration.admissionFence }),\n agentId: record.configuration.agentId,\n },\n state: record.state,\n nextAtMillis: record.nextAtMillis,\n pending:\n record.pending === null\n ? null\n : {\n intendedAtMillis: record.pending.envelope.intendedAtMillis,\n preparedAtMillis: record.pending.envelope.preparedAtMillis,\n configurationRevision: record.pending.envelope.configurationRevision,\n occurrenceId: record.pending.envelope.occurrenceId,\n retry: record.pending.retry,\n },\n lastReceipt: record.lastReceipt,\n lastRefusal: record.lastRefusal,\n lastSkippedRange: record.lastSkippedRange,\n observedAtMillis,\n pendingAgeMillis:\n record.pending === null\n ? null\n : Math.max(0, observedAtMillis - record.pending.envelope.preparedAtMillis),\n latenessMillis:\n intendedAtMillis === null ? 0 : Math.max(0, observedAtMillis - intendedAtMillis),\n };\n};\n\nconst inputByteLength = (input: PersistedJson): number => utf8ByteLength(JSON.stringify(input));\n\nconst currentMillis = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));\n\nconst validateRequestedFields = Effect.fn(\"Scheduling.validateRequestedFields\")(function* (\n options: ScheduleCreateOptions,\n) {\n yield* Schema.encodeEffect(ScheduleTimingRequestSchema)(options.timing).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid timing request\" })),\n );\n yield* Schema.encodeEffect(ScheduleDestinationSchema)(options.destination).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid destination\" })),\n );\n yield* Schema.encodeEffect(DefinitionDigests)(options.definitions).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid definition digests\" })),\n );\n});\n\nconst resolveInput = Effect.fn(\"Scheduling.resolveInput\")(function* <\n InputSchema extends Schema.Top,\n>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n maximumBytes: number,\n): Effect.fn.Return<\n { readonly payload: PersistedJson; readonly digest: Digest },\n ScheduleValidationError,\n InputSchema[\"EncodingServices\"] | Crypto.Crypto\n> {\n const encoded = yield* Schema.encodeEffect(agent.definition.input)(input).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Unable to encode Agent input\" }),\n ),\n );\n\n const payload = yield* Schema.decodeUnknownEffect(PersistedJson)(encoded).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({\n message: \"Agent input does not satisfy the canonical persistence bounds\",\n }),\n ),\n );\n\n if (inputByteLength(payload) > maximumBytes) {\n return yield* ScheduleValidationError.make({\n message: `Encoded Agent input exceeds the configured ${maximumBytes} byte limit`,\n });\n }\n\n const digest = yield* digestJson(payload).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Unable to digest encoded Agent input\" }),\n ),\n );\n\n return { payload, digest };\n});\n\nconst makeManagement = (limits: SchedulingLimits) =>\n Effect.gen(function* () {\n const nowMillis = yield* currentMillis;\n\n yield* Schema.decodeEffect(ScheduleInstant)(nowMillis + limits.recoveryPollMillis).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({\n message: \"Scheduling recovery deadline exceeds the supported instant range\",\n }),\n ),\n );\n const store = yield* ScheduleStore;\n const authorizer = yield* ScheduleAuthorizer;\n const wake = yield* ScheduleWake;\n const crypto = yield* Crypto.Crypto;\n\n const withCrypto = <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>) =>\n Effect.provideService(effect, Crypto.Crypto, crypto);\n\n const fingerprint = Effect.fn(\"Scheduling.fingerprint\")(function* (\n agentId: AgentId,\n inputDigest: Digest,\n options: ScheduleCreateOptions,\n ) {\n const timing = yield* Schema.encodeEffect(ScheduleTimingRequestSchema)(options.timing).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid timing request\" })),\n );\n\n const destination = yield* Schema.encodeEffect(ScheduleDestinationSchema)(\n options.destination,\n ).pipe(\n Effect.mapError(() => ScheduleValidationError.make({ message: \"Invalid destination\" })),\n );\n\n const definitions = yield* Schema.encodeEffect(DefinitionDigests)(options.definitions).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Invalid definition digests\" }),\n ),\n );\n\n return yield* withCrypto(\n digestJson({\n schemaVersion: 1,\n owner: options.scope.owner,\n scheduleId: options.scheduleId,\n registeringPrincipal: options.scope.principal,\n deliveryPrincipal: options.deliveryPrincipal,\n ...(options.admissionGroup === undefined\n ? {}\n : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined\n ? {}\n : { admissionFence: options.admissionFence }),\n agentId,\n definitions,\n destination,\n timing,\n inputDigest,\n }),\n ).pipe(\n Effect.mapError(() =>\n ScheduleValidationError.make({ message: \"Unable to digest Schedule registration\" }),\n ),\n );\n });\n\n const configuration = (\n agentId: AgentId,\n payload: PersistedJson,\n inputDigest: Digest,\n options: ScheduleCreateOptions,\n timing: ScheduleConfiguration[\"timing\"],\n ): ScheduleConfiguration => ({\n timing,\n destination: options.destination,\n deliveryPrincipal: options.deliveryPrincipal,\n ...(options.admissionGroup === undefined ? {} : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined ? {} : { admissionFence: options.admissionFence }),\n agentId,\n definitions: options.definitions,\n input: payload,\n inputDigest,\n });\n\n const create = Effect.fn(\"Scheduling.create\")(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleCreateOptions,\n ): Effect.fn.Return<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n > {\n const nowMillis = yield* currentMillis;\n\n const resolvedInput = yield* resolveInput(agent, input, limits.maxInputBytes).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n );\n\n const creationFingerprint = yield* fingerprint(\n agent.definition.id,\n resolvedInput.digest,\n options,\n );\n\n const key = keyOf(options.scope, options.scheduleId);\n\n yield* authorizer.manage({\n operation: \"create\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n });\n const existing = yield* store.get(key);\n\n if (existing !== null) {\n if (existing.creationFingerprint !== creationFingerprint) {\n return yield* ScheduleConflict.make({ reason: \"creation\", key });\n }\n yield* authorizer.manage({\n operation: \"create\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n configuration: existing.configuration,\n });\n\n return asSnapshot(existing, nowMillis);\n }\n\n const timing = yield* Effect.fromResult(\n normalizeScheduleTiming(options.timing, nowMillis, limits.minIntervalMillis),\n );\n\n const nextAtMillis = yield* Effect.fromResult(scheduleInitialCursor(timing, nowMillis));\n\n if (nextAtMillis === null) {\n return yield* ScheduleValidationError.make({ message: \"Timing has no next occurrence\" });\n }\n\n const nextConfiguration = configuration(\n agent.definition.id,\n resolvedInput.payload,\n resolvedInput.digest,\n options,\n timing,\n );\n\n yield* authorizer.manage({\n operation: \"create\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n configuration: nextConfiguration,\n });\n\n const record: ScheduleRecord = {\n schemaVersion: 1,\n owner: options.scope.owner,\n scheduleId: options.scheduleId,\n creationFingerprint,\n createdBy: options.scope.principal,\n createdAtMillis: nowMillis,\n updatedAtMillis: nowMillis,\n configurationRevision: 1,\n version: 1,\n configuration: nextConfiguration,\n state: \"active\",\n nextAtMillis,\n pending: null,\n lastReceipt: null,\n lastRefusal: null,\n lastSkippedRange: null,\n };\n\n const inserted = yield* store.insert(record, limits.maxSchedulesPerOwner);\n\n yield* wake.notify;\n\n return asSnapshot(inserted, nowMillis);\n });\n\n const update = Effect.fn(\"Scheduling.update\")(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleUpdateOptions,\n ): Effect.fn.Return<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n > {\n const nowMillis = yield* currentMillis;\n const key = keyOf(options.scope, options.scheduleId);\n\n yield* authorizer.manage({\n operation: \"update\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n });\n yield* validateRequestedFields(options);\n const existing = yield* store.get(key);\n\n if (existing === null) return yield* notFound(key);\n if (existing.configurationRevision !== options.expectedRevision) {\n return yield* ScheduleConflict.make({ reason: \"revision\", key });\n }\n\n const resolvedInput = yield* resolveInput(agent, input, limits.maxInputBytes).pipe(\n Effect.provideService(Crypto.Crypto, crypto),\n );\n\n const timingRequest =\n options.timing._tag === \"Interval\" &&\n options.timing.anchorMillis === undefined &&\n existing.configuration.timing._tag === \"Interval\" &&\n existing.configuration.timing.everyMillis === options.timing.everyMillis\n ? { ...options.timing, anchorMillis: existing.configuration.timing.anchorMillis }\n : options.timing;\n\n const timing = yield* Effect.fromResult(\n normalizeScheduleTiming(timingRequest, nowMillis, limits.minIntervalMillis),\n );\n\n const nextAtMillis =\n timing._tag === \"At\"\n ? timing.atMillis\n : yield* Effect.fromResult(scheduleNextAfter(timing, nowMillis));\n\n if (nextAtMillis === null) {\n return yield* ScheduleValidationError.make({ message: \"Timing has no next occurrence\" });\n }\n\n const nextConfiguration = configuration(\n agent.definition.id,\n resolvedInput.payload,\n resolvedInput.digest,\n options,\n timing,\n );\n\n yield* authorizer.manage({\n operation: \"update\",\n scope: options.scope,\n scheduleId: options.scheduleId,\n configuration: nextConfiguration,\n });\n\n const changed = yield* store.change(\n key,\n {\n _tag: \"Update\",\n expectedRevision: options.expectedRevision,\n configuration: nextConfiguration,\n nextAtMillis,\n nowMillis,\n },\n limits.maxSchedulesPerOwner,\n );\n\n yield* wake.notify;\n\n return asSnapshot(changed, nowMillis);\n });\n\n const get = Effect.fn(\"Scheduling.get\")(function* (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n ) {\n yield* authorizer.manage({ operation: \"get\", scope, scheduleId });\n const key = keyOf(scope, scheduleId);\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n\n return asSnapshot(record, yield* currentMillis);\n });\n\n const list = Effect.fn(\"Scheduling.list\")(function* (\n scope: ScheduleScope,\n options: ScheduleListOptions = {},\n ) {\n yield* authorizer.manage({ operation: \"list\", scope });\n const limit = options.limit ?? 50;\n\n if (!Number.isInteger(limit) || limit < 1 || limit > 100) {\n return yield* ScheduleValidationError.make({\n message: \"Schedule page limit must be an integer from 1 through 100\",\n });\n }\n\n const page = yield* store.list({\n owner: scope.owner,\n ...(options.after === undefined ? {} : { after: options.after }),\n limit,\n });\n\n const nowMillis = yield* currentMillis;\n\n return { items: page.items.map((record) => asSnapshot(record, nowMillis)), next: page.next };\n });\n\n const control = Effect.fn(\"Scheduling.control\")(function* (\n operation: \"pause\" | \"resume\" | \"cancel\",\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ): Effect.fn.Return<ScheduleSnapshot, ScheduleManagementFailure> {\n yield* authorizer.manage({ operation, scope, scheduleId });\n const key = keyOf(scope, scheduleId);\n\n const attempt = (): Effect.Effect<ScheduleRecord, ScheduleManagementFailure> =>\n Effect.suspend(() =>\n Effect.gen(function* () {\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n if (record.configurationRevision !== expectedRevision) {\n return yield* ScheduleConflict.make({ reason: \"revision\", key });\n }\n if (operation === \"resume\" && record.state === \"active\") return record;\n const nowMillis = yield* currentMillis;\n\n const nextAtMillis =\n operation === \"resume\"\n ? yield* Effect.fromResult(\n scheduleResumeCursor(\n record.configuration.timing,\n record.nextAtMillis,\n nowMillis,\n ),\n )\n : operation === \"cancel\"\n ? null\n : record.nextAtMillis;\n\n const skippedRange =\n operation === \"resume\" &&\n record.configuration.timing._tag !== \"At\" &&\n record.nextAtMillis !== null &&\n nextAtMillis !== null &&\n nextAtMillis > record.nextAtMillis\n ? { fromMillis: record.nextAtMillis, toMillis: nextAtMillis }\n : null;\n\n return yield* store\n .change(\n key,\n {\n _tag: \"Control\",\n expectedRevision,\n expectedVersion: record.version,\n action: operation,\n nextAtMillis,\n nowMillis,\n skippedRange,\n },\n limits.maxSchedulesPerOwner,\n )\n .pipe(\n Effect.catchTag(\"ScheduleConflict\", (error) =>\n error.reason === \"revision\" ? attempt() : Effect.fail(error),\n ),\n );\n }),\n );\n\n const changed = yield* attempt();\n\n yield* wake.notify;\n\n return asSnapshot(changed, yield* currentMillis);\n });\n\n const recover = Effect.fn(\"Scheduling.recover\")(function* (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n expectedGeneration: number,\n ) {\n yield* authorizer.manage({ operation: \"recover\", scope, scheduleId });\n const key = keyOf(scope, scheduleId);\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n if (record.configurationRevision !== expectedRevision)\n return yield* ScheduleConflict.make({ reason: \"revision\", key });\n const time = yield* currentMillis;\n\n if (record.pending === null) return asSnapshot(record, time);\n\n const recovered = yield* store.change(key, {\n _tag: \"Recover\",\n expectedGeneration,\n expectedRevision,\n occurrenceId: record.pending.envelope.occurrenceId,\n nowMillis: time,\n });\n\n yield* wake.notify;\n\n return asSnapshot(recovered, time);\n });\n\n return Scheduling.of({\n recover,\n create,\n update,\n get,\n list,\n pause: (scope, id, revision) => control(\"pause\", scope, id, revision),\n resume: (scope, id, revision) => control(\"resume\", scope, id, revision),\n cancel: (scope, id, revision) => control(\"cancel\", scope, id, revision),\n });\n });\n\nconst makeDriver = (limits: SchedulingLimits) =>\n Effect.gen(function* () {\n const store = yield* ScheduleStore;\n const authorizer = yield* ScheduleAuthorizer;\n const admission = yield* ScheduledInputAdmission;\n const failpoint = yield* ScheduleFailpoint;\n const crypto = yield* Crypto.Crypto;\n const admissionSemaphore = yield* Semaphore.make(limits.admissionConcurrency);\n\n const withCrypto = <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>) =>\n Effect.provideService(effect, Crypto.Crypto, crypto);\n\n const retry = Effect.fn(\"Scheduling.retry\")(function* (\n key: ScheduleKey,\n record: ScheduleRecord,\n reason: ScheduleRetryReason,\n nowMillis: number,\n ) {\n if (record.pending === null) return record;\n const current = record.pending.retry;\n\n const delay = Math.min(\n limits.retryBaseMillis * 2 ** Math.min(current.attempts, 52),\n limits.retryMaxMillis,\n );\n\n return yield* store.change(key, {\n _tag: \"Retry\",\n occurrenceId: record.pending.envelope.occurrenceId,\n retry: {\n generation: current.generation,\n attempts: current.attempts + 1,\n automaticAttempts: current.automaticAttempts + 1,\n parked: current.automaticAttempts + 1 >= (limits.maxAutomaticAttempts ?? 8),\n nextAttemptAtMillis: Math.min(nowMillis + delay, 8_640_000_000_000_000),\n lastAttemptAtMillis: nowMillis,\n lastFailure: reason,\n },\n nowMillis,\n });\n });\n\n const verifyPending = Effect.fn(\"Scheduling.verifyPending\")(function* (\n key: ScheduleKey,\n record: ScheduleRecord,\n ) {\n const pending = record.pending;\n\n if (pending === null) return;\n const envelope = pending.envelope;\n\n const occurrenceId = yield* withCrypto(\n digestJson({\n schemaVersion: 1,\n owner: envelope.owner,\n scheduleId: envelope.scheduleId,\n configurationRevision: envelope.configurationRevision,\n intendedAtMillis: envelope.intendedAtMillis,\n }),\n ).pipe(Effect.mapError(() => corrupt(\"process\")));\n\n const usesCurrentConfiguration =\n envelope.configurationRevision === record.configurationRevision;\n\n const expectedThreadId = usesCurrentConfiguration\n ? record.configuration.destination._tag === \"ExistingThread\"\n ? record.configuration.destination.threadId\n : Schema.decodeSync(ThreadId)(`schedule-thread:${envelope.occurrenceId}`)\n : null;\n\n const expectedAdmissionKey = Schema.decodeSync(IdempotencyKey)(\n `schedule-occurrence:${envelope.occurrenceId}`,\n );\n\n const digest = yield* withCrypto(digestJson(envelope.input)).pipe(\n Effect.mapError(() => corrupt(\"process\")),\n );\n\n if (\n envelope.schemaVersion !== 1 ||\n envelope.owner.tenantId !== key.owner.tenantId ||\n envelope.owner.ownerId !== key.owner.ownerId ||\n envelope.scheduleId !== key.scheduleId ||\n envelope.configurationRevision > record.configurationRevision ||\n envelope.occurrenceId !== occurrenceId ||\n (usesCurrentConfiguration &&\n (envelope.deliveryPrincipal !== record.configuration.deliveryPrincipal ||\n envelope.agentId !== record.configuration.agentId ||\n !equivalentDefinitions(envelope.definitions, record.configuration.definitions) ||\n !equivalentInput(envelope.input, record.configuration.input) ||\n envelope.inputDigest !== record.configuration.inputDigest)) ||\n envelope.inputDigest !== digest ||\n (expectedThreadId !== null && envelope.threadId !== expectedThreadId) ||\n envelope.admissionKey !== expectedAdmissionKey\n ) {\n return yield* corrupt(\"process\");\n }\n });\n\n const deliverPending = Effect.fn(\"Scheduling.deliverPending\")(function* (\n key: ScheduleKey,\n record: ScheduleRecord,\n nowMillis: number,\n ) {\n if (\n record.pending === null ||\n record.pending.retry.parked === true ||\n record.pending.retry.nextAttemptAtMillis > nowMillis\n ) {\n return record;\n }\n yield* verifyPending(key, record);\n const envelope = record.pending.envelope;\n\n const outcome = yield* admissionSemaphore.withPermit(\n admitPreparedInput(admission.submit(envelope), limits.admissionTimeoutMillis).pipe(\n Effect.tap((outcome) =>\n outcome._tag === \"Receipt\" ? failpoint.hit(\"schedule:admission:after\") : Effect.void,\n ),\n ),\n );\n\n const completedAtMillis = yield* currentMillis;\n\n if (outcome._tag === \"Receipt\") {\n if (outcome.receipt.threadId !== envelope.threadId) {\n return yield* corrupt(\"admission\");\n }\n\n return yield* store\n .change(key, {\n _tag: \"Complete\",\n occurrenceId: envelope.occurrenceId,\n receipt: outcome.receipt,\n nowMillis: completedAtMillis,\n })\n .pipe(\n Effect.catchTag(\"ScheduleStorageError\", (error) =>\n error.reason === \"unavailable\"\n ? retry(key, record, \"storage\", completedAtMillis)\n : Effect.fail(error),\n ),\n );\n }\n if (outcome._tag === \"Refused\") {\n const refusal: ScheduleRefusal = {\n atMillis: completedAtMillis,\n intendedAtMillis: envelope.intendedAtMillis,\n occurrenceId: envelope.occurrenceId,\n phase: \"admission\",\n code: outcome.error.code,\n };\n\n return yield* store\n .change(key, {\n _tag: \"Refuse\",\n occurrenceId: envelope.occurrenceId,\n refusal,\n nowMillis: completedAtMillis,\n })\n .pipe(\n Effect.catchTag(\"ScheduleStorageError\", (error) =>\n error.reason === \"unavailable\"\n ? retry(key, record, \"storage\", completedAtMillis)\n : Effect.fail(error),\n ),\n );\n }\n\n return yield* retry(key, record, outcome.reason, completedAtMillis);\n });\n\n const processRecord = Effect.fn(\"Scheduling.processRecord\")(function* (\n key: ScheduleKey,\n initial: ScheduleRecord,\n nowMillis: number,\n ): Effect.fn.Return<ScheduleRecord, ScheduleProcessFailure> {\n if (initial.pending !== null) return yield* deliverPending(key, initial, nowMillis);\n if (\n initial.state !== \"active\" ||\n initial.nextAtMillis === null ||\n initial.nextAtMillis > nowMillis\n ) {\n return initial;\n }\n\n const currentInputDigest = yield* withCrypto(digestJson(initial.configuration.input)).pipe(\n Effect.mapError(() =>\n ScheduleStorageError.make({ operation: \"prepare\", reason: \"unavailable\" }),\n ),\n );\n\n if (currentInputDigest !== initial.configuration.inputDigest) {\n return yield* corrupt(\"prepare\");\n }\n\n const due = yield* Effect.fromResult(\n scheduleDueOccurrence(initial.configuration.timing, initial.nextAtMillis, nowMillis),\n );\n\n if (due === null) return initial;\n\n const occurrenceId = yield* withCrypto(\n digestJson({\n schemaVersion: 1,\n owner: initial.owner,\n scheduleId: initial.scheduleId,\n configurationRevision: initial.configurationRevision,\n intendedAtMillis: due.intendedAtMillis,\n }),\n ).pipe(Effect.mapError(() => corrupt(\"prepare\")));\n\n const occurrence = {\n key,\n configurationRevision: initial.configurationRevision,\n configuration: initial.configuration,\n intendedAtMillis: due.intendedAtMillis,\n occurrenceId,\n };\n\n const authorization = yield* authorizer.prepare(occurrence).pipe(Effect.result);\n\n if (Result.isFailure(authorization)) {\n if (authorization.failure._tag === \"ScheduleStorageError\") {\n return yield* authorization.failure;\n }\n\n return yield* store.change(key, {\n _tag: \"DenyPreparation\",\n expectedRevision: initial.configurationRevision,\n expectedCursor: initial.nextAtMillis,\n refusal: {\n atMillis: nowMillis,\n intendedAtMillis: due.intendedAtMillis,\n occurrenceId,\n phase: \"preparation\",\n code: authorization.failure.code,\n },\n nowMillis,\n });\n }\n\n const threadId =\n initial.configuration.destination._tag === \"ExistingThread\"\n ? initial.configuration.destination.threadId\n : Schema.decodeSync(ThreadId)(`schedule-thread:${occurrenceId}`);\n\n const admissionKey = Schema.decodeSync(IdempotencyKey)(`schedule-occurrence:${occurrenceId}`);\n\n const prepared = yield* store.change(key, {\n _tag: \"Prepare\",\n expectedRevision: initial.configurationRevision,\n expectedCursor: initial.nextAtMillis,\n envelope: {\n schemaVersion: 1,\n owner: initial.owner,\n scheduleId: initial.scheduleId,\n configurationRevision: initial.configurationRevision,\n intendedAtMillis: due.intendedAtMillis,\n preparedAtMillis: nowMillis,\n occurrenceId,\n threadId,\n deliveryPrincipal: initial.configuration.deliveryPrincipal,\n ...(initial.configuration.admissionGroup === undefined\n ? {}\n : { admissionGroup: initial.configuration.admissionGroup }),\n ...(initial.configuration.admissionFence === undefined\n ? {}\n : { admissionFence: initial.configuration.admissionFence }),\n agentId: initial.configuration.agentId,\n definitions: initial.configuration.definitions,\n input: initial.configuration.input,\n inputDigest: initial.configuration.inputDigest,\n admissionKey,\n authorization: authorization.success,\n },\n nextAtMillis: due.nextAtMillis,\n skippedRange: due.skippedRange,\n nowMillis,\n });\n\n return yield* deliverPending(key, prepared, nowMillis);\n });\n\n const process = Effect.fn(\"Scheduling.process\")(function* (key: ScheduleKey) {\n const nowMillis = yield* currentMillis;\n const record = yield* store.get(key);\n\n if (record === null) return yield* notFound(key);\n\n const processed = yield* processRecord(key, record, nowMillis).pipe(\n Effect.catchTag(\"ScheduleConflict\", () =>\n store\n .get(key)\n .pipe(\n Effect.flatMap((current) =>\n current === null\n ? Effect.fail(notFound(key))\n : processRecord(key, current, nowMillis),\n ),\n ),\n ),\n );\n\n return processed;\n });\n\n const runDue = Effect.fn(\"ScheduleDriver.runDue\")(function* (owner?: ScheduleOwner) {\n const nowMillis = yield* currentMillis;\n let after: ScheduleDueCursor | undefined;\n let processed = 0;\n let failed = 0;\n\n while (true) {\n const due = yield* store.due(nowMillis, limits.dueBatchSize, owner, after);\n\n if (due.length === 0) break;\n yield* Effect.forEach(\n due,\n (key) =>\n process(key).pipe(\n Effect.matchCauseEffect({\n onSuccess: () =>\n Effect.sync(() => {\n processed += 1;\n }),\n onFailure: (cause) =>\n Cause.hasInterrupts(cause)\n ? Effect.interrupt\n : Effect.gen(function* () {\n failed += 1;\n yield* Effect.logWarning(\"Schedule processing failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (error) => error._tag,\n }),\n }),\n );\n }),\n }),\n ),\n { concurrency: limits.admissionConcurrency },\n );\n after = due.at(-1);\n if (due.length < limits.dueBatchSize) break;\n }\n\n return { processed, failed };\n });\n\n return ScheduleDriver.of({ process, runDue });\n });\n\nconst corrupt = (operation: string): ScheduleStorageError =>\n ScheduleStorageError.make({ operation, reason: \"corrupt\" });\n\nconst validateLimits = (limits: SchedulingLimits) =>\n Schema.decodeEffect(SchedulingLimits)(limits).pipe(\n Effect.mapError((error) =>\n ScheduleValidationError.make({ message: `Invalid Scheduling limits: ${error.message}` }),\n ),\n Effect.filterOrFail(\n (validated) => validated.retryBaseMillis <= validated.retryMaxMillis,\n () =>\n ScheduleValidationError.make({\n message: \"Scheduling retryBaseMillis must not exceed retryMaxMillis\",\n }),\n ),\n );\n\nexport class Scheduling extends Context.Service<\n Scheduling,\n {\n readonly create: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleCreateOptions,\n ) => Effect.Effect<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n >;\n readonly update: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: ScheduleUpdateOptions,\n ) => Effect.Effect<\n ScheduleSnapshot,\n ScheduleManagementFailure,\n InputSchema[\"EncodingServices\"]\n >;\n readonly get: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly list: (\n scope: ScheduleScope,\n options?: ScheduleListOptions,\n ) => Effect.Effect<ScheduleSnapshotPage, ScheduleManagementFailure>;\n readonly pause: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly resume: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly recover: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n expectedGeneration: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n readonly cancel: (\n scope: ScheduleScope,\n scheduleId: ScheduleId,\n expectedRevision: number,\n ) => Effect.Effect<ScheduleSnapshot, ScheduleManagementFailure>;\n }\n>()(\"@effect-agent/thread/Scheduling\") {\n static layer(\n limits: SchedulingLimits = defaultSchedulingLimits,\n ): Layer.Layer<\n Scheduling,\n ScheduleValidationError,\n ScheduleStore | ScheduleAuthorizer | ScheduleWake | Crypto.Crypto\n > {\n return Layer.effect(Scheduling, validateLimits(limits).pipe(Effect.flatMap(makeManagement)));\n }\n}\n\nexport const ScheduleWakeNoop: Layer.Layer<ScheduleWake> = Layer.succeed(ScheduleWake, {\n notify: Effect.void,\n await: Effect.never,\n});\n\n/** Privileged host capability. Never provide this service to management callers or model tools. */\nexport class ScheduleDriver extends Context.Service<\n ScheduleDriver,\n {\n readonly process: (key: ScheduleKey) => Effect.Effect<ScheduleRecord, ScheduleProcessFailure>;\n readonly runDue: (\n owner?: ScheduleOwner,\n ) => Effect.Effect<\n { readonly processed: number; readonly failed: number },\n ScheduleStorageError\n >;\n }\n>()(\"@effect-agent/thread/ScheduleDriver\") {\n static layer(\n limits: SchedulingLimits = defaultSchedulingLimits,\n ): Layer.Layer<\n ScheduleDriver,\n ScheduleValidationError,\n ScheduleStore | ScheduleAuthorizer | ScheduledInputAdmission | Crypto.Crypto\n > {\n return Layer.effect(ScheduleDriver, validateLimits(limits).pipe(Effect.flatMap(makeDriver)));\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,WAAW,YAAoB,OAAO,KAAK,wBAAwB,KAAK,EAAE,QAAQ,CAAC,CAAC;AAE1F,MAAM,kBAAkB,QAAgB,UACtC,OAAO,aAAa,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,KAC3C,OAAO,eACL,wBAAwB,KAAK,EAC3B,SAAS,GAAG,MAAM,iDACpB,CAAC,CACH,CACF;AAEF,MAAM,UAAU,KAA0B,SACxC,IAAI,SAAS,IAAI,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,UAAU,KAAK,IAAI,CAAC,GAAG,GAAG;;;;;;AAO9E,MAAM,yBACJ,MACA,kBACiD;CACjD,IAAI,KAAK,QAAQ,SAAS,GACxB,OAAO,QAAQ,4CAA4C;CAE7D,IAAI,iBAAiB,KAAQ,OAAO,OAAO,QAAQ,KAAA,CAAS;CAC5D,IACE,OAAO,OAAO,KAAK,EAAE,KACrB,SAAS,gBAAgB,KAAK,GAAG,KAAK,KACtC,KAAK,GAAG,MAAM,OAAO,OAErB,OAAO,QAAQ,wEAAwE;CAGzF,MAAM,cAAc,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC,SAAS,SAClD,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,KAAK,WAAW,OAAO,KAAK,MAAM,CAC7D;CAEA,YAAY,MAAM,MAAM,UAAU,OAAO,KAAK;CAC9C,IAAI,aAAa;CAEjB,KAAK,IAAI,QAAQ,GAAG,QAAQ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,CAAC,qCAAqC,CAAC,CAAC;CACzC,OAAO,MACL,SAA2B,yBAK3B;EACA,OAAO,MAAM,OAAO,gBAAgB,eAAe,MAAM,CAAC,CAAC,KAAK,OAAO,QAAQ,UAAU,CAAC,CAAC;CAC7F;AACF"}
|
|
@@ -2,8 +2,8 @@ import { d as SubagentReservationAmounts, l as SubagentGrant, o as SubagentDeleg
|
|
|
2
2
|
import { a as Receipt, r as Principal } from "./Receipt-BAHyigAF.mjs";
|
|
3
3
|
import { r as Update } from "./AgentUpdates-DMJ-_xow.mjs";
|
|
4
4
|
import { t as AgentPolicy } from "./AgentPolicy-BqDoSXO6.mjs";
|
|
5
|
-
import { _ as Digest, h as DefinitionDigests } from "./Records-
|
|
6
|
-
import { t as ScheduleAuthorizationDecision } from "./Schedule-
|
|
5
|
+
import { _ as Digest, h as DefinitionDigests } from "./Records-CV49DgQK.mjs";
|
|
6
|
+
import { t as ScheduleAuthorizationDecision } from "./Schedule-DePbGfgd.mjs";
|
|
7
7
|
import { Context, Effect, Schema } from "effect";
|
|
8
8
|
declare namespace Subscription_d_exports {
|
|
9
9
|
export { AcceptedEvent, DeliveryChange, EventAcknowledgement, EventSourceVersion, PreparedInput, SourcePartition, SourceRecovery, SubscriptionAuthorizer, SubscriptionChange, SubscriptionConfiguration, SubscriptionDelivery, SubscriptionDeliveryKey, SubscriptionDeliverySnapshot, SubscriptionError, SubscriptionFailpoint, SubscriptionFailpointError, SubscriptionKey, SubscriptionLimits, SubscriptionName, SubscriptionRecord, SubscriptionRefusal, SubscriptionRetentionPolicy, SubscriptionScanCursors, SubscriptionScope, SubscriptionSnapshot, SubscriptionSourceError, SubscriptionStore, SubscriptionStoreFailure, defaultSubscriptionLimits, subscriptionDeliveryKeyString, subscriptionKeyString };
|
|
@@ -918,4 +918,4 @@ declare const subscriptionKeyString: (key: SubscriptionKey) => string;
|
|
|
918
918
|
declare const subscriptionDeliveryKeyString: (key: SubscriptionDeliveryKey) => string;
|
|
919
919
|
//#endregion
|
|
920
920
|
export { defaultSubscriptionLimits as A, SubscriptionScanCursors as C, SubscriptionStore as D, SubscriptionSourceError as E, subscriptionKeyString as M, SubscriptionStoreFailure as O, SubscriptionRetentionPolicy as S, SubscriptionSnapshot as T, SubscriptionKey as _, PreparedInput as a, SubscriptionRecord as b, SubscriptionAuthorizer as c, SubscriptionDelivery as d, SubscriptionDeliveryKey as f, SubscriptionFailpointError as g, SubscriptionFailpoint as h, EventSourceVersion as i, subscriptionDeliveryKeyString as j, Subscription_d_exports as k, SubscriptionChange as l, SubscriptionError as m, DeliveryChange as n, SourcePartition as o, SubscriptionDeliverySnapshot as p, EventAcknowledgement as r, SourceRecovery as s, AcceptedEvent as t, SubscriptionConfiguration as u, SubscriptionLimits as v, SubscriptionScope as w, SubscriptionRefusal as x, SubscriptionName as y };
|
|
921
|
-
//# sourceMappingURL=Subscription-
|
|
921
|
+
//# sourceMappingURL=Subscription-BR_8Cxh3.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AgentId } from "./Identifiers-CN2s30fF.mjs";
|
|
2
|
-
import { O as PersistedJson, h as DefinitionDigests } from "./Records-
|
|
3
|
-
import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-
|
|
2
|
+
import { O as PersistedJson, h as DefinitionDigests } from "./Records-CV49DgQK.mjs";
|
|
3
|
+
import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-BR_8Cxh3.mjs";
|
|
4
4
|
import { Context, Effect, Schema, Scope } from "effect";
|
|
5
5
|
declare namespace SubscriptionInput_d_exports {
|
|
6
6
|
export { SubscriptionInputBinding, SubscriptionInputBindings, makeSubscriptionInputBinding, resolveSubscriptionInput };
|
|
@@ -38,4 +38,4 @@ declare const makeSubscriptionInputBinding: <Event extends Schema.Top, Parameter
|
|
|
38
38
|
}) => Effect.Effect<SubscriptionInputBinding, never, Exclude<R, Scope.Scope> | Exclude<Continuation["DecodingServices"], Scope.Scope> | Exclude<Continuation["EncodingServices"], Scope.Scope> | Exclude<Event["DecodingServices"], Scope.Scope> | Exclude<Input["EncodingServices"], Scope.Scope> | Exclude<Parameters["DecodingServices"], Scope.Scope>>;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { resolveSubscriptionInput as a, makeSubscriptionInputBinding as i, SubscriptionInputBindings as n, SubscriptionInput_d_exports as r, SubscriptionInputBinding as t };
|
|
41
|
-
//# sourceMappingURL=SubscriptionInput-
|
|
41
|
+
//# sourceMappingURL=SubscriptionInput-B95sQbuk.d.mts.map
|
|
@@ -3,10 +3,10 @@ import { getToolExecutionKind } from "./core/SubagentContract.mjs";
|
|
|
3
3
|
import { a as PinnedTool, l as ToolNamespace, n as DiscoveryTool, r as IncludesCatalogDocumentation, t as AdditionalToolCatalog } from "./ToolExposure-C93U1sPu.mjs";
|
|
4
4
|
import { BackgroundReporting, WorkerReportPreparationFailure } from "./engine/SubagentHost.mjs";
|
|
5
5
|
import { getToolExecutionClass } from "./engine/DurableStep.mjs";
|
|
6
|
-
import { M as ReplayContract, f as DefinitionDigestInput, p as DefinitionDigests } from "./Records-
|
|
6
|
+
import { M as ReplayContract, T as PersistedJson, f as DefinitionDigestInput, p as DefinitionDigests } from "./Records-BAutSSnJ.mjs";
|
|
7
7
|
import { DigestError, digestDefinitions, digestJson } from "./durable/Digest.mjs";
|
|
8
8
|
import { Tool } from "effect/unstable/ai";
|
|
9
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
9
|
+
import { Array, Context, Effect, Layer, Schema } from "effect";
|
|
10
10
|
//#region src/durable/internal/agent-registration.ts
|
|
11
11
|
/**
|
|
12
12
|
* No Agent Binding is registered for the requested stable identity. Recovery
|
|
@@ -33,10 +33,35 @@ const definitionDigestsEqual = (left, right) => left.agent === right.agent && le
|
|
|
33
33
|
* manifest from the original release for work admitted before replay contracts were retained.
|
|
34
34
|
* Its original declarations must hash to that admission; a bare old digest is not a manifest.
|
|
35
35
|
*/
|
|
36
|
+
const ToolReplayDeclaration = Schema.Struct({
|
|
37
|
+
version: PersistedJson,
|
|
38
|
+
parameters: PersistedJson,
|
|
39
|
+
success: PersistedJson,
|
|
40
|
+
failure: PersistedJson,
|
|
41
|
+
failureMode: Schema.String,
|
|
42
|
+
needsApproval: Schema.Union([Schema.Boolean, Schema.Literal("dynamic")]),
|
|
43
|
+
executionClass: Schema.String,
|
|
44
|
+
executionKind: Schema.String
|
|
45
|
+
});
|
|
46
|
+
const AgentReplayDeclaration = Schema.Struct({
|
|
47
|
+
version: PersistedJson,
|
|
48
|
+
id: AgentId,
|
|
49
|
+
input: PersistedJson,
|
|
50
|
+
output: PersistedJson,
|
|
51
|
+
updates: Schema.NullOr(PersistedJson),
|
|
52
|
+
completion: Schema.NullOr(Schema.Struct({
|
|
53
|
+
tool: Schema.String,
|
|
54
|
+
required: Schema.Boolean
|
|
55
|
+
})),
|
|
56
|
+
completionFromTools: Schema.Array(Schema.String),
|
|
57
|
+
disposition: Schema.NullOr(PersistedJson)
|
|
58
|
+
});
|
|
36
59
|
var BindingManifest = class extends Schema.Class("BindingManifest")({
|
|
37
60
|
agentId: AgentId,
|
|
38
61
|
definitions: DefinitionDigestInput,
|
|
39
|
-
replay: ReplayContract
|
|
62
|
+
replay: ReplayContract,
|
|
63
|
+
agentContract: Schema.optionalKey(AgentReplayDeclaration),
|
|
64
|
+
toolContracts: Schema.optionalKey(Schema.Record(Schema.String, ToolReplayDeclaration))
|
|
40
65
|
}) {};
|
|
41
66
|
const makeBindingManifest = Effect.fn("AgentRegistration.makeBindingManifest")(function* (definition, definitions, versions) {
|
|
42
67
|
const jsonSchema = (schema) => Schema.decodeUnknownSync(Schema.Json)(Tool.getJsonSchemaFromSchema(schema));
|
|
@@ -76,22 +101,132 @@ const makeBindingManifest = Effect.fn("AgentRegistration.makeBindingManifest")(f
|
|
|
76
101
|
catch: () => DigestError.make({ message: "Replay contracts require serializable codecs and an explicit semantic version for every Tool" })
|
|
77
102
|
});
|
|
78
103
|
const agent = yield* digestJson(contracts.agent);
|
|
104
|
+
const agentBehavior = yield* digestJson({
|
|
105
|
+
...contracts.agent,
|
|
106
|
+
input: null
|
|
107
|
+
});
|
|
79
108
|
const tools = yield* Effect.forEach(contracts.tools, ({ name, contract }) => digestJson(contract).pipe(Effect.map((digest) => [name, digest])));
|
|
80
109
|
return BindingManifest.make({
|
|
81
110
|
agentId: definition.id,
|
|
82
111
|
definitions,
|
|
83
112
|
replay: ReplayContract.make({
|
|
84
113
|
agent,
|
|
114
|
+
agentBehavior,
|
|
85
115
|
tools: Object.fromEntries(tools)
|
|
86
|
-
})
|
|
116
|
+
}),
|
|
117
|
+
agentContract: contracts.agent,
|
|
118
|
+
toolContracts: Object.fromEntries(contracts.tools.map(({ name, contract }) => [name, contract]))
|
|
87
119
|
});
|
|
88
120
|
});
|
|
89
|
-
const
|
|
121
|
+
const jsonEqual = Schema.toEquivalence(PersistedJson);
|
|
122
|
+
const schemasCompatible = (previous, current) => {
|
|
123
|
+
if (jsonEqual(previous, current)) return true;
|
|
124
|
+
const hasNegativeSchema = (value) => {
|
|
125
|
+
if (Array.isArray(value)) return value.some(hasNegativeSchema);
|
|
126
|
+
if (value === null || typeof value !== "object") return false;
|
|
127
|
+
return Object.entries(value).some(([key, child]) => key === "oneOf" || key === "maxContains" || key === "unevaluatedProperties" || key === "unevaluatedItems" || key === "if" || key === "then" || key === "else" || key === "$dynamicRef" || key === "$recursiveRef" || key === "not" && !jsonEqual(child, {}) || hasNegativeSchema(child));
|
|
128
|
+
};
|
|
129
|
+
if (hasNegativeSchema(previous) || hasNegativeSchema(current)) return false;
|
|
130
|
+
const compare = (before, after) => {
|
|
131
|
+
if (jsonEqual(before, after)) return true;
|
|
132
|
+
if (before === null || typeof before !== "object" || Array.isArray(before) || after === null || typeof after !== "object" || Array.isArray(after)) return false;
|
|
133
|
+
if (Object.keys(before).length !== Object.keys(after).length) return false;
|
|
134
|
+
return Object.entries(before).every(([key, value]) => {
|
|
135
|
+
if (!Object.hasOwn(after, key)) return false;
|
|
136
|
+
const next = after[key];
|
|
137
|
+
if (jsonEqual(value, next)) return true;
|
|
138
|
+
if (key === "additionalProperties") return value === false && next === true;
|
|
139
|
+
if (key === "items") return compare(value, next);
|
|
140
|
+
if ((key === "anyOf" || key === "allOf") && Array.isArray(value) && Array.isArray(next)) return value.length === next.length && value.every((entry, index) => compare(entry, next[index]));
|
|
141
|
+
if ((key === "properties" || key === "$defs" || key === "definitions") && value !== null && typeof value === "object" && !Array.isArray(value) && next !== null && typeof next === "object" && !Array.isArray(next)) return Object.keys(value).length === Object.keys(next).length && Object.entries(value).every(([name, schema]) => Object.hasOwn(next, name) && compare(schema, next[name]));
|
|
142
|
+
return false;
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
return compare(previous, current);
|
|
146
|
+
};
|
|
147
|
+
/** Compile audited declaration data once, without acquiring an executable or rewriting receipts.
|
|
148
|
+
* Full input schemas stay in registration metadata, never in each admission's replay contract. */
|
|
149
|
+
const compileBindingManifest = Effect.fn("AgentRegistration.compileBindingManifest")(function* (definition, definitions, versions, retained = []) {
|
|
150
|
+
const manifest = yield* makeBindingManifest(definition, definitions, versions);
|
|
151
|
+
const validContract = Effect.fnUntraced(function* (entry) {
|
|
152
|
+
if (entry.agentContract === void 0) return void 0;
|
|
153
|
+
if (entry.agentContract.id !== entry.agentId || (yield* digestJson(entry.agentContract)) !== entry.replay.agent || entry.replay.agentBehavior !== void 0 && (yield* digestJson({
|
|
154
|
+
...entry.agentContract,
|
|
155
|
+
input: null
|
|
156
|
+
})) !== entry.replay.agentBehavior) return yield* DigestError.make({ message: "A manifest's Agent contract does not match its replay digest" });
|
|
157
|
+
return entry.agentContract;
|
|
158
|
+
});
|
|
159
|
+
const current = manifest.agentContract;
|
|
160
|
+
const acceptsInput = Schema.is(Schema.toEncoded(definition.input));
|
|
161
|
+
const validateTools = Effect.fnUntraced(function* (entry) {
|
|
162
|
+
for (const [name, contract] of Object.entries(entry.toolContracts ?? {})) if ((yield* digestJson(contract)) !== entry.replay.tools[name]) return yield* DigestError.make({ message: "A manifest's Tool contract does not match its replay digest" });
|
|
163
|
+
});
|
|
164
|
+
const digests = yield* digestDefinitions(manifest.definitions);
|
|
165
|
+
const retainedManifests = yield* Effect.forEach(retained, Effect.fnUntraced(function* (entry) {
|
|
166
|
+
if (entry.agentId !== manifest.agentId) return yield* DigestError.make({ message: "A retained manifest belongs to another Agent" });
|
|
167
|
+
const previous = yield* validContract(entry);
|
|
168
|
+
yield* validateTools(entry);
|
|
169
|
+
const compatible = previous !== void 0 && jsonEqual({
|
|
170
|
+
...previous,
|
|
171
|
+
input: null,
|
|
172
|
+
output: null,
|
|
173
|
+
updates: null,
|
|
174
|
+
disposition: null
|
|
175
|
+
}, {
|
|
176
|
+
...current,
|
|
177
|
+
input: null,
|
|
178
|
+
output: null,
|
|
179
|
+
updates: null,
|
|
180
|
+
disposition: null
|
|
181
|
+
}) && schemasCompatible(previous.output, current.output) && schemasCompatible(previous.updates, current.updates) && schemasCompatible(previous.disposition, current.disposition);
|
|
182
|
+
const compatibleTools = {};
|
|
183
|
+
for (const [name, oldTool] of Object.entries(entry.toolContracts ?? {})) {
|
|
184
|
+
const newTool = manifest.toolContracts?.[name];
|
|
185
|
+
if (newTool !== void 0 && jsonEqual({
|
|
186
|
+
...oldTool,
|
|
187
|
+
parameters: null,
|
|
188
|
+
success: null,
|
|
189
|
+
failure: null
|
|
190
|
+
}, {
|
|
191
|
+
...newTool,
|
|
192
|
+
parameters: null,
|
|
193
|
+
success: null,
|
|
194
|
+
failure: null
|
|
195
|
+
}) && schemasCompatible(oldTool.parameters, newTool.parameters) && schemasCompatible(oldTool.success, newTool.success) && schemasCompatible(oldTool.failure, newTool.failure)) compatibleTools[name] = manifest.replay.tools[name];
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
digests: yield* digestDefinitions(entry.definitions),
|
|
199
|
+
replay: entry.replay,
|
|
200
|
+
compatibleTools,
|
|
201
|
+
...compatible ? { compatibleAgent: manifest.replay.agent } : {}
|
|
202
|
+
};
|
|
203
|
+
}));
|
|
204
|
+
return {
|
|
205
|
+
digests: DefinitionDigests.make({
|
|
206
|
+
...digests,
|
|
207
|
+
replay: manifest.replay
|
|
208
|
+
}),
|
|
209
|
+
manifest,
|
|
210
|
+
retainedManifests,
|
|
211
|
+
acceptsInput: (input) => {
|
|
212
|
+
try {
|
|
213
|
+
return acceptsInput(input);
|
|
214
|
+
} catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
const replaySupports = (current, retained, requiredTools, inputCompatible = false, compatibleTools = {}) => (current.agent === retained.agent || inputCompatible) && (requiredTools ?? Object.keys(retained.tools)).every((name) => retained.tools[name] !== void 0 && (current.tools[name] === retained.tools[name] || current.tools[name] !== void 0 && compatibleTools[name] === current.tools[name]));
|
|
90
221
|
/** Resolve executable code only. Admission, delivery, lineage and receipt comparisons stay exact. */
|
|
91
|
-
const bindingSupports = (binding, digests, requiredTools) => {
|
|
222
|
+
const bindingSupports = (binding, digests, requiredTools, input) => {
|
|
92
223
|
if (definitionDigestsEqual(binding.digests, digests)) return true;
|
|
93
|
-
const
|
|
94
|
-
|
|
224
|
+
const manifest = binding.retainedManifests?.find((entry) => definitionDigestsEqual(entry.digests, digests) || definitionDigestsEqual({
|
|
225
|
+
...entry.digests,
|
|
226
|
+
replay: entry.replay
|
|
227
|
+
}, digests));
|
|
228
|
+
const retained = digests.replay ?? manifest?.replay;
|
|
229
|
+
return binding.digests.replay !== void 0 && retained !== void 0 && replaySupports(binding.digests.replay, retained, requiredTools, input !== void 0 && binding.acceptsInput?.(input) === true && (binding.digests.replay.agentBehavior !== void 0 && binding.digests.replay.agentBehavior === retained.agentBehavior || manifest?.compatibleAgent === binding.digests.replay.agent), manifest?.compatibleTools);
|
|
95
230
|
};
|
|
96
231
|
const captureReporting = (reports) => Effect.map(Effect.context(), (context) => reports.map((report) => ({
|
|
97
232
|
...report,
|
|
@@ -133,13 +268,13 @@ const DurableWorkerBinding = { make: (agent, digests, reporting) => Effect.gen(f
|
|
|
133
268
|
}) };
|
|
134
269
|
/** INTERNAL identity-only capture retained for the legacy direct worker path. */
|
|
135
270
|
const makeLegacyWorkerBinding = capture;
|
|
136
|
-
const resolveWorkerBinding = (bindings, agentId, digests, requiredTools) => {
|
|
271
|
+
const resolveWorkerBinding = (bindings, agentId, digests, requiredTools, input) => {
|
|
137
272
|
const registered = bindings.filter((binding) => binding.agentId === agentId);
|
|
138
273
|
if (registered.length === 0) return Effect.fail(BindingUnavailable.make({
|
|
139
274
|
agentId,
|
|
140
275
|
message: `No Agent Binding is registered for ${agentId}; recovery never substitutes different code (SUB-023)`
|
|
141
276
|
}));
|
|
142
|
-
const compatible = registered.find((binding) => definitionDigestsEqual(binding.digests, digests)) ?? (registered.length === 1 && bindingSupports(registered[0], digests, requiredTools) ? registered[0] : void 0);
|
|
277
|
+
const compatible = registered.find((binding) => definitionDigestsEqual(binding.digests, digests)) ?? (registered.length === 1 && bindingSupports(registered[0], digests, requiredTools, input) ? registered[0] : void 0);
|
|
143
278
|
if (compatible === void 0) return Effect.fail(BindingDigestMismatch.make({
|
|
144
279
|
agentId,
|
|
145
280
|
message: `No registered Binding proves the retained replay contracts for ${agentId}; the original request and receipts remain pending`
|
|
@@ -216,7 +351,7 @@ const registrationDefinitions = (entry) => {
|
|
|
216
351
|
const compileRegistration = (entry) => Effect.flatMap(Effect.try({
|
|
217
352
|
try: () => registrationDefinitions(entry),
|
|
218
353
|
catch: () => DigestError.make({ message: "Agent update schema has no serializable wire contract" })
|
|
219
|
-
})
|
|
354
|
+
}), (definitions) => Effect.gen(function* () {
|
|
220
355
|
const binding = yield* capture(entry.model === void 0 ? entry.agent : {
|
|
221
356
|
definition: entry.agent,
|
|
222
357
|
model: entry.model
|
|
@@ -224,23 +359,13 @@ const compileRegistration = (entry) => Effect.flatMap(Effect.try({
|
|
|
224
359
|
const reporting = yield* captureReporting([...entry.reporting ?? [], ...backgroundReports(binding.definition)]);
|
|
225
360
|
if (entry.continuity === void 0) return {
|
|
226
361
|
...binding,
|
|
227
|
-
digests,
|
|
362
|
+
digests: yield* digestDefinitions(definitions),
|
|
228
363
|
reporting
|
|
229
364
|
};
|
|
230
|
-
const manifest = yield* makeBindingManifest(binding.definition, registrationDefinitions(entry), entry.continuity.versions);
|
|
231
|
-
const retainedManifests = yield* Effect.forEach(entry.continuity.retainedManifests ?? [], (retained) => retained.agentId === binding.agentId ? digestDefinitions(retained.definitions).pipe(Effect.map((digests) => ({
|
|
232
|
-
digests,
|
|
233
|
-
replay: retained.replay
|
|
234
|
-
}))) : Effect.fail(DigestError.make({ message: "A retained manifest belongs to another Agent" })));
|
|
235
365
|
return {
|
|
236
366
|
...binding,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
replay: manifest.replay
|
|
240
|
-
}),
|
|
241
|
-
reporting,
|
|
242
|
-
manifest,
|
|
243
|
-
retainedManifests
|
|
367
|
+
...yield* compileBindingManifest(binding.definition, definitions, entry.continuity.versions, entry.continuity.retainedManifests),
|
|
368
|
+
reporting
|
|
244
369
|
};
|
|
245
370
|
}));
|
|
246
371
|
/** Compile heterogeneous Agent descriptors into exact, dependency-closed worker registrations. */
|
|
@@ -249,6 +374,6 @@ const compileRegistrations = (entries) => {
|
|
|
249
374
|
return Effect.forEach(entries, compileEntry);
|
|
250
375
|
};
|
|
251
376
|
//#endregion
|
|
252
|
-
export { bindingSupports as a,
|
|
377
|
+
export { bindingSupports as a, definitionDigestsEqual as c, resolveDefinitionBinding as d, resolveWorkerBinding as f, DurableWorkerBinding as i, makeBindingManifest as l, BindingManifest as n, compileBindingManifest as o, BindingUnavailable as r, compileRegistrations as s, BindingDigestMismatch as t, makeLegacyWorkerBinding as u };
|
|
253
378
|
|
|
254
|
-
//# sourceMappingURL=agent-registration-
|
|
379
|
+
//# sourceMappingURL=agent-registration-CXGDwvJH.mjs.map
|