@lostgradient/weft 0.23.1 → 0.24.1
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/README.md +72 -4
- package/dist/cli/codegen-emit-dedup.d.ts +81 -0
- package/dist/cli/codegen-emit-dedup.js +45 -0
- package/dist/cli/codegen-emit-registry.d.ts +90 -0
- package/dist/cli/codegen-emit-registry.js +50 -0
- package/dist/cli/codegen-emit.d.ts +26 -39
- package/dist/cli/codegen-emit.js +4 -27
- package/dist/cli/codegen-validate.d.ts +49 -0
- package/dist/cli/codegen-validate.js +186 -0
- package/dist/cli/codegen.js +6 -87
- package/dist/cli/conformance.js +5 -2
- package/dist/cli/generated/operation-catalog.snapshot.json +381 -3
- package/dist/cli/generated/operation-client.generated.d.ts +350 -10
- package/dist/cli/generated/operation-client.generated.js +14 -0
- package/dist/cli/output.js +1 -1
- package/dist/cli/parse-schedule-arguments.js +15 -3
- package/dist/cli/schedule.js +2 -1
- package/dist/cli/storage-factory.js +2 -0
- package/dist/cli/types.d.ts +2 -1
- package/dist/cli/workflow-commands.js +2 -0
- package/dist/cli-main.js +1 -1
- package/dist/client/http-client-requests.js +6 -9
- package/dist/client/start-body.js +1 -0
- package/dist/core/application-payload-digest.d.ts +42 -0
- package/dist/core/application-payload-digest.js +76 -0
- package/dist/core/application-primitive-abort.d.ts +50 -0
- package/dist/core/application-primitive-abort.js +40 -0
- package/dist/core/application-primitive-attempt-registry.d.ts +74 -0
- package/dist/core/application-primitive-attempt-registry.js +73 -0
- package/dist/core/application-primitive-codec.d.ts +36 -0
- package/dist/core/application-primitive-codec.js +56 -0
- package/dist/core/application-primitive-commit.d.ts +67 -0
- package/dist/core/application-primitive-commit.js +66 -0
- package/dist/core/application-primitive-guards.d.ts +62 -0
- package/dist/core/application-primitive-guards.js +89 -0
- package/dist/core/application-primitive-payload.d.ts +29 -0
- package/dist/core/application-primitive-payload.js +65 -0
- package/dist/core/application-primitive-timing.d.ts +18 -0
- package/dist/core/application-primitive-timing.js +22 -0
- package/dist/core/atomic-state.js +2 -0
- package/dist/core/catalog/codec.d.ts +40 -0
- package/dist/core/catalog/codec.js +45 -0
- package/dist/core/catalog/errors.d.ts +104 -0
- package/dist/core/catalog/errors.js +41 -0
- package/dist/core/catalog/index.d.ts +25 -0
- package/dist/core/catalog/index.js +22 -0
- package/dist/core/catalog/reference-counts.d.ts +120 -0
- package/dist/core/catalog/reference-counts.js +28 -0
- package/dist/core/catalog/removal.d.ts +105 -0
- package/dist/core/catalog/removal.js +30 -0
- package/dist/core/catalog/storage-io.d.ts +101 -0
- package/dist/core/catalog/storage-io.js +106 -0
- package/dist/core/catalog/types.d.ts +108 -0
- package/dist/core/catalog/types.js +0 -0
- package/dist/core/catalog/workflow-catalog.d.ts +165 -0
- package/dist/core/catalog/workflow-catalog.js +198 -0
- package/dist/core/compare-codepoint.d.ts +13 -0
- package/dist/core/compare-codepoint.js +7 -0
- package/dist/core/compression.js +2 -0
- package/dist/core/context/attributes.d.ts +1 -1
- package/dist/core/context/durable-operations.d.ts +2 -2
- package/dist/core/context/index.js +5 -3
- package/dist/core/context/state-namespace.d.ts +1 -1
- package/dist/core/contract/build.d.ts +64 -0
- package/dist/core/contract/build.js +99 -0
- package/dist/core/contract/compatibility.d.ts +187 -0
- package/dist/core/contract/compatibility.js +37 -0
- package/dist/core/contract/failure.d.ts +64 -0
- package/dist/core/contract/failure.js +4 -0
- package/dist/core/contract/hash.d.ts +92 -0
- package/dist/core/contract/hash.js +34 -0
- package/dist/core/contract/index.d.ts +21 -0
- package/dist/core/contract/index.js +22 -0
- package/dist/core/contract/limits.d.ts +74 -0
- package/dist/core/contract/limits.js +1 -0
- package/dist/core/contract/manifest-parse-schema.d.ts +37 -0
- package/dist/core/contract/manifest-parse-schema.js +106 -0
- package/dist/core/contract/manifest-parse.d.ts +76 -0
- package/dist/core/contract/manifest-parse.js +189 -0
- package/dist/core/contract/manifest.d.ts +56 -0
- package/dist/core/contract/manifest.js +31 -0
- package/dist/core/contract/normalize.d.ts +97 -0
- package/dist/core/contract/normalize.js +127 -0
- package/dist/core/contract/revision.d.ts +29 -0
- package/dist/core/contract/revision.js +5 -0
- package/dist/core/contract/types.d.ts +274 -0
- package/dist/core/contract/types.js +1 -0
- package/dist/core/engine/activity-resolution.js +17 -17
- package/dist/core/engine/bulk-operations-purge.js +14 -20
- package/dist/core/engine/bulk-operations-retry.d.ts +9 -0
- package/dist/core/engine/bulk-operations-retry.js +177 -0
- package/dist/core/engine/bulk-operations-shared.d.ts +18 -0
- package/dist/core/engine/bulk-operations-shared.js +14 -0
- package/dist/core/engine/bulk-operations.js +8 -167
- package/dist/core/engine/callback-creators-bundles.js +4 -2
- package/dist/core/engine/callback-creators-core.js +9 -1
- package/dist/core/engine/callback-creators-schedule.js +2 -2
- package/dist/core/engine/catalog-activation.d.ts +40 -0
- package/dist/core/engine/catalog-activation.js +17 -0
- package/dist/core/engine/catalog-events.d.ts +36 -0
- package/dist/core/engine/catalog-events.js +15 -0
- package/dist/core/engine/catalog-readiness.d.ts +49 -0
- package/dist/core/engine/catalog-readiness.js +61 -0
- package/dist/core/engine/catalog-removal.d.ts +236 -0
- package/dist/core/engine/catalog-removal.js +123 -0
- package/dist/core/engine/catalog-tombstone-recovery.d.ts +56 -0
- package/dist/core/engine/catalog-tombstone-recovery.js +39 -0
- package/dist/core/engine/constraints.js +5 -1
- package/dist/core/engine/construction.d.ts +2 -2
- package/dist/core/engine/construction.js +4 -2
- package/dist/core/engine/decode-revision.d.ts +32 -0
- package/dist/core/engine/decode-revision.js +9 -0
- package/dist/core/engine/disposal.d.ts +6 -2
- package/dist/core/engine/disposal.js +26 -3
- package/dist/core/engine/dynamic-source-errors.d.ts +81 -0
- package/dist/core/engine/dynamic-source-errors.js +25 -0
- package/dist/core/engine/dynamic-source-execution.d.ts +173 -0
- package/dist/core/engine/dynamic-source-execution.js +108 -0
- package/dist/core/engine/engine-internal-types.d.ts +16 -0
- package/dist/core/engine/engine-workflows-namespace.d.ts +140 -0
- package/dist/core/engine/engine-workflows-namespace.js +51 -0
- package/dist/core/engine/finalizer-metadata.d.ts +22 -0
- package/dist/core/engine/finalizer-metadata.js +12 -0
- package/dist/core/engine/handle-result.js +2 -0
- package/dist/core/engine/index.d.ts +91 -0
- package/dist/core/engine/index.js +78 -6
- package/dist/core/engine/inline-launch-queue.js +1 -1
- package/dist/core/engine/internals.d.ts +54 -15
- package/dist/core/engine/internals.js +6 -0
- package/dist/core/engine/lifecycle/checkpoint-launch.d.ts +29 -0
- package/dist/core/engine/lifecycle/checkpoint-launch.js +75 -0
- package/dist/core/engine/lifecycle/delayed-start-registration.d.ts +30 -0
- package/dist/core/engine/lifecycle/delayed-start-registration.js +11 -0
- package/dist/core/engine/lifecycle/fork-helpers.d.ts +33 -1
- package/dist/core/engine/lifecycle/fork-helpers.js +3 -1
- package/dist/core/engine/lifecycle/recovery-revision-groups.d.ts +75 -0
- package/dist/core/engine/lifecycle/recovery-revision-groups.js +64 -0
- package/dist/core/engine/lifecycle/resume-generation-guard.d.ts +58 -0
- package/dist/core/engine/lifecycle/resume-generation-guard.js +11 -0
- package/dist/core/engine/lifecycle/resume.js +18 -9
- package/dist/core/engine/lifecycle/shared.d.ts +43 -0
- package/dist/core/engine/lifecycle/standalone-claim-acquire.d.ts +12 -0
- package/dist/core/engine/lifecycle/standalone-claim-acquire.js +6 -0
- package/dist/core/engine/lifecycle/start-commit-errors.d.ts +12 -0
- package/dist/core/engine/lifecycle/start-commit-errors.js +6 -0
- package/dist/core/engine/lifecycle/start-commit.d.ts +22 -7
- package/dist/core/engine/lifecycle/start-commit.js +49 -15
- package/dist/core/engine/lifecycle/start-exec.d.ts +18 -2
- package/dist/core/engine/lifecycle/start-exec.js +7 -5
- package/dist/core/engine/lifecycle/start-or-signal-create.js +1 -3
- package/dist/core/engine/lifecycle/start-or-signal.js +1 -1
- package/dist/core/engine/lifecycle/start-precondition-attribution.d.ts +49 -0
- package/dist/core/engine/lifecycle/start-precondition-attribution.js +13 -0
- package/dist/core/engine/lifecycle/start-revision-resolution.d.ts +34 -0
- package/dist/core/engine/lifecycle/start-revision-resolution.js +11 -0
- package/dist/core/engine/lifecycle/start-state.d.ts +16 -0
- package/dist/core/engine/lifecycle/start-state.js +60 -0
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +66 -3
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +13 -3
- package/dist/core/engine/lifecycle/start.d.ts +16 -6
- package/dist/core/engine/lifecycle/start.js +39 -66
- package/dist/core/engine/lifecycle/transition.d.ts +3 -4
- package/dist/core/engine/lifecycle/transition.js +30 -80
- package/dist/core/engine/lifecycle.d.ts +4 -2
- package/dist/core/engine/lifecycle.js +6 -6
- package/dist/core/engine/listing.js +15 -1
- package/dist/core/engine/memo-durable-activity.js +4 -1
- package/dist/core/engine/nonterminal-revision-count.d.ts +25 -0
- package/dist/core/engine/nonterminal-revision-count.js +16 -0
- package/dist/core/engine/operations-time.d.ts +5 -23
- package/dist/core/engine/operations-time.js +13 -11
- package/dist/core/engine/ownership-bootstrap.d.ts +1 -1
- package/dist/core/engine/pinned-schedule-revision-count.d.ts +26 -0
- package/dist/core/engine/pinned-schedule-revision-count.js +19 -0
- package/dist/core/engine/pinned-schedule-revision.d.ts +76 -0
- package/dist/core/engine/pinned-schedule-revision.js +53 -0
- package/dist/core/engine/registration.d.ts +106 -0
- package/dist/core/engine/registration.js +28 -7
- package/dist/core/engine/retention.js +9 -2
- package/dist/core/engine/revision-errors.d.ts +71 -0
- package/dist/core/engine/revision-errors.js +13 -0
- package/dist/core/engine/schedule-revision-fire.d.ts +17 -0
- package/dist/core/engine/schedule-revision-fire.js +3 -0
- package/dist/core/engine/schedule-run.js +2 -1
- package/dist/core/engine/schedules.d.ts +2 -1
- package/dist/core/engine/schedules.js +28 -9
- package/dist/core/engine/source-diagnostics.d.ts +76 -0
- package/dist/core/engine/source-diagnostics.js +105 -0
- package/dist/core/engine/source-registration.d.ts +42 -0
- package/dist/core/engine/source-registration.js +38 -0
- package/dist/core/engine/source-resolution.d.ts +101 -0
- package/dist/core/engine/source-resolution.js +154 -0
- package/dist/core/engine/source-runtime-state.d.ts +92 -0
- package/dist/core/engine/source-runtime-state.js +36 -0
- package/dist/core/engine/storage-io.d.ts +19 -2
- package/dist/core/engine/storage-io.js +21 -2
- package/dist/core/engine/termination/finalizer-registration.d.ts +18 -0
- package/dist/core/engine/termination/finalizer-registration.js +21 -0
- package/dist/core/engine/termination/finalizer.d.ts +16 -19
- package/dist/core/engine/termination/finalizer.js +3 -3
- package/dist/core/engine/time-operation-callbacks.d.ts +32 -0
- package/dist/core/engine/time-operation-callbacks.js +0 -0
- package/dist/core/engine/validation/schedule-cadence.d.ts +16 -0
- package/dist/core/engine/validation/schedule-cadence.js +20 -0
- package/dist/core/engine/validation/schedule-options.d.ts +4 -1
- package/dist/core/engine/validation/schedule-options.js +14 -0
- package/dist/core/engine/validation/schedule-revision.d.ts +24 -0
- package/dist/core/engine/validation/schedule-revision.js +21 -0
- package/dist/core/engine/validation/schedule-warnings.d.ts +11 -0
- package/dist/core/engine/validation/schedule-warnings.js +5 -0
- package/dist/core/engine/validation/schedule.d.ts +4 -3
- package/dist/core/engine/validation/schedule.js +15 -26
- package/dist/core/engine/validation.js +5 -2
- package/dist/core/engine/workflow-claim-reclaim-target.d.ts +1 -1
- package/dist/core/engine/workflow-claim-reclaim-target.js +16 -2
- package/dist/core/engine/workflow-retention-deadline.d.ts +16 -0
- package/dist/core/engine/workflow-retention-deadline.js +33 -0
- package/dist/core/events/catalog-events.d.ts +117 -0
- package/dist/core/events/catalog-events.js +62 -0
- package/dist/core/events/event-map.d.ts +11 -0
- package/dist/core/events/index.d.ts +2 -0
- package/dist/core/events/index.js +2 -0
- package/dist/core/events/workflow-source-events.d.ts +102 -0
- package/dist/core/events/workflow-source-events.js +57 -0
- package/dist/core/execution-strategy.d.ts +7 -0
- package/dist/core/inline-execution-strategy.context-options.d.ts +1 -1
- package/dist/core/inline-execution-strategy.js +1 -1
- package/dist/core/mailbox-admission.d.ts +26 -0
- package/dist/core/mailbox-admission.js +130 -0
- package/dist/core/mailbox-claims.d.ts +251 -0
- package/dist/core/mailbox-claims.js +0 -0
- package/dist/core/mailbox-codec.d.ts +32 -0
- package/dist/core/mailbox-codec.js +221 -0
- package/dist/core/mailbox-contract.d.ts +290 -0
- package/dist/core/mailbox-contract.js +0 -0
- package/dist/core/mailbox-delivery.d.ts +37 -0
- package/dist/core/mailbox-delivery.js +193 -0
- package/dist/core/mailbox-guards.d.ts +78 -0
- package/dist/core/mailbox-guards.js +58 -0
- package/dist/core/mailbox-index-codec.d.ts +41 -0
- package/dist/core/mailbox-index-codec.js +71 -0
- package/dist/core/mailbox-internals.d.ts +156 -0
- package/dist/core/mailbox-internals.js +154 -0
- package/dist/core/mailbox-maintenance.d.ts +29 -0
- package/dist/core/mailbox-maintenance.js +196 -0
- package/dist/core/mailbox-settlement.d.ts +69 -0
- package/dist/core/mailbox-settlement.js +206 -0
- package/dist/core/mailbox-storage.d.ts +117 -0
- package/dist/core/mailbox-storage.js +115 -0
- package/dist/core/mailbox-transition-helpers.d.ts +70 -0
- package/dist/core/mailbox-transition-helpers.js +43 -0
- package/dist/core/mailbox-transitions-recovery.d.ts +28 -0
- package/dist/core/mailbox-transitions-recovery.js +64 -0
- package/dist/core/mailbox-transitions.d.ts +138 -0
- package/dist/core/mailbox-transitions.js +180 -0
- package/dist/core/mailbox-types.d.ts +406 -0
- package/dist/core/mailbox-types.js +16 -0
- package/dist/core/mailbox-validation.d.ts +65 -0
- package/dist/core/mailbox-validation.js +73 -0
- package/dist/core/mailbox-waits.d.ts +50 -0
- package/dist/core/mailbox-waits.js +97 -0
- package/dist/core/mailbox.d.ts +163 -0
- package/dist/core/mailbox.js +211 -0
- package/dist/core/outbox-claims.d.ts +307 -0
- package/dist/core/outbox-claims.js +0 -0
- package/dist/core/outbox-codec.d.ts +24 -0
- package/dist/core/outbox-codec.js +257 -0
- package/dist/core/outbox-contract.d.ts +346 -0
- package/dist/core/outbox-contract.js +0 -0
- package/dist/core/outbox-delivery.d.ts +34 -0
- package/dist/core/outbox-delivery.js +149 -0
- package/dist/core/outbox-drain.d.ts +29 -0
- package/dist/core/outbox-drain.js +158 -0
- package/dist/core/outbox-enqueue.d.ts +24 -0
- package/dist/core/outbox-enqueue.js +115 -0
- package/dist/core/outbox-guards.d.ts +76 -0
- package/dist/core/outbox-guards.js +60 -0
- package/dist/core/outbox-index-codec.d.ts +33 -0
- package/dist/core/outbox-index-codec.js +71 -0
- package/dist/core/outbox-internals.d.ts +99 -0
- package/dist/core/outbox-internals.js +159 -0
- package/dist/core/outbox-listing.d.ts +12 -0
- package/dist/core/outbox-listing.js +38 -0
- package/dist/core/outbox-maintenance.d.ts +28 -0
- package/dist/core/outbox-maintenance.js +191 -0
- package/dist/core/outbox-operations.d.ts +18 -0
- package/dist/core/outbox-operations.js +46 -0
- package/dist/core/outbox-runner.d.ts +30 -0
- package/dist/core/outbox-runner.js +217 -0
- package/dist/core/outbox-settlement.d.ts +57 -0
- package/dist/core/outbox-settlement.js +183 -0
- package/dist/core/outbox-storage.d.ts +107 -0
- package/dist/core/outbox-storage.js +127 -0
- package/dist/core/outbox-transition-helpers.d.ts +83 -0
- package/dist/core/outbox-transition-helpers.js +63 -0
- package/dist/core/outbox-transitions-recovery.d.ts +30 -0
- package/dist/core/outbox-transitions-recovery.js +42 -0
- package/dist/core/outbox-transitions.d.ts +145 -0
- package/dist/core/outbox-transitions.js +236 -0
- package/dist/core/outbox-types.d.ts +400 -0
- package/dist/core/outbox-types.js +20 -0
- package/dist/core/outbox-validation.d.ts +101 -0
- package/dist/core/outbox-validation.js +127 -0
- package/dist/core/outbox-waits.d.ts +39 -0
- package/dist/core/outbox-waits.js +88 -0
- package/dist/core/outbox.d.ts +156 -0
- package/dist/core/outbox.js +234 -0
- package/dist/core/registry-limits.d.ts +49 -0
- package/dist/core/registry-limits.js +10 -0
- package/dist/core/registry-schema-conversion.d.ts +20 -0
- package/dist/core/registry-schema-conversion.js +22 -0
- package/dist/core/registry-snapshot.d.ts +91 -42
- package/dist/core/registry-snapshot.js +39 -77
- package/dist/core/registry-workflow-contract-draft.d.ts +32 -0
- package/dist/core/registry-workflow-contract-draft.js +28 -0
- package/dist/core/registry-workflow-manifest.d.ts +122 -0
- package/dist/core/registry-workflow-manifest.js +92 -0
- package/dist/core/source/errors.d.ts +55 -0
- package/dist/core/source/errors.js +13 -0
- package/dist/core/source/index.d.ts +19 -0
- package/dist/core/source/index.js +4 -0
- package/dist/core/source/resolvers.d.ts +45 -0
- package/dist/core/source/resolvers.js +9 -0
- package/dist/core/source/types.d.ts +211 -0
- package/dist/core/source/types.js +0 -0
- package/dist/core/source/validate.d.ts +91 -0
- package/dist/core/source/validate.js +62 -0
- package/dist/core/source/workflow-source.d.ts +43 -0
- package/dist/core/source/workflow-source.js +16 -0
- package/dist/core/types/checkpoint.d.ts +14 -0
- package/dist/core/types/schedules.d.ts +52 -1
- package/dist/core/types/state.d.ts +16 -0
- package/dist/core/types/workflow-registries.d.ts +7 -0
- package/dist/core/types/workflow-registry.d.ts +12 -0
- package/dist/core/versioning.js +2 -0
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +12 -1
- package/dist/core/worker-execution-strategy.d.ts +1 -0
- package/dist/core/worker-execution-strategy.js +13 -1
- package/dist/core/worker-fault-handling.d.ts +10 -0
- package/dist/core/worker-fault-handling.js +1 -0
- package/dist/core/worker-inbound-message.d.ts +1 -0
- package/dist/core/worker-inbound-message.js +1 -0
- package/dist/core/worker-protocol-guard.js +4 -0
- package/dist/core/worker-protocol.d.ts +7 -0
- package/dist/core/worker-protocol.js +2 -1
- package/dist/core/worker-turn-watchdog.d.ts +8 -1
- package/dist/core/worker-turn-watchdog.js +3 -2
- package/dist/diagnostics/format.js +5 -0
- package/dist/diagnostics/types.d.ts +24 -0
- package/dist/diagnostics/version-check.js +8 -2
- package/dist/http.js +2 -2
- package/dist/index.d.ts +25 -4
- package/dist/index.js +57 -0
- package/dist/indexeddb.js +1 -1
- package/dist/json-schema.js +3 -3
- package/dist/mcp/resources.js +2 -0
- package/dist/runtime/portable.d.ts +9 -1
- package/dist/server/fault-to-json-rpc.js +4 -1
- package/dist/server/handler/auth-context-principal.js +4 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/json-rpc-http.js +2 -0
- package/dist/server/json-rpc-websocket.js +6 -4
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +2 -0
- package/dist/server/operation-catalog/types.d.ts +17 -0
- package/dist/server/operation-fault.d.ts +5 -0
- package/dist/server/operation-fault.js +4 -1
- package/dist/server/operations/activate-workflow-revision.d.ts +30 -0
- package/dist/server/operations/activate-workflow-revision.js +69 -0
- package/dist/server/operations/create-schedule.d.ts +2 -0
- package/dist/server/operations/create-schedule.js +10 -6
- package/dist/server/operations/fleet-events-subscription.js +1 -1
- package/dist/server/operations/fork-workflow.js +1 -1
- package/dist/server/operations/get-active-workflow-revision.d.ts +32 -0
- package/dist/server/operations/get-active-workflow-revision.js +46 -0
- package/dist/server/operations/get-catalog-diagnostics.d.ts +113 -0
- package/dist/server/operations/get-catalog-diagnostics.js +65 -0
- package/dist/server/operations/get-registry.js +17 -4
- package/dist/server/operations/get-task-detail-schema.d.ts +8 -0
- package/dist/server/operations/get-task-detail-schema.js +1 -0
- package/dist/server/operations/get-task-detail.d.ts +8 -0
- package/dist/server/operations/get-task-detail.js +1 -0
- package/dist/server/operations/get-task-diagnostics.d.ts +4 -4
- package/dist/server/operations/get-workflow-revision.d.ts +25 -0
- package/dist/server/operations/get-workflow-revision.js +50 -0
- package/dist/server/operations/install-workflow-revision.d.ts +27 -0
- package/dist/server/operations/install-workflow-revision.js +46 -0
- package/dist/server/operations/list-workflow-revisions.d.ts +20 -0
- package/dist/server/operations/list-workflow-revisions.js +40 -0
- package/dist/server/operations/preload-workflow-revision.d.ts +28 -0
- package/dist/server/operations/preload-workflow-revision.js +60 -0
- package/dist/server/operations/schedule-faults.d.ts +1 -0
- package/dist/server/operations/schedule-faults.js +32 -4
- package/dist/server/operations/schedule-rest-body.d.ts +1 -0
- package/dist/server/operations/schedule-rest-body.js +2 -1
- package/dist/server/operations/start-or-signal-workflow.js +1 -1
- package/dist/server/operations/start-workflow.js +1 -1
- package/dist/server/operations/static-registrations.js +42 -0
- package/dist/server/operations/storage.js +2 -2
- package/dist/server/operations/submit-review-decision.js +1 -1
- package/dist/server/operations/update-schedule.d.ts +2 -0
- package/dist/server/operations/update-schedule.js +4 -2
- package/dist/server/operations/workflow-catalog-operation-helpers.d.ts +59 -0
- package/dist/server/operations/workflow-catalog-operation-helpers.js +162 -0
- package/dist/server/runtime/task-dispatch-envelope.d.ts +14 -0
- package/dist/server/runtime/task-dispatch-envelope.js +32 -0
- package/dist/server/runtime/task-dispatch-revision.d.ts +29 -0
- package/dist/server/runtime/task-dispatch-revision.js +13 -0
- package/dist/server/runtime/task-dispatch.js +12 -37
- package/dist/server/runtime/task-ledger-recovery.js +1 -1
- package/dist/server/runtime/task-ledger-runtime.d.ts +14 -2
- package/dist/server/runtime/task-ledger-runtime.js +5 -3
- package/dist/server/runtime/task-polling.js +9 -3
- package/dist/server/runtime/task-reconciliation.js +2 -1
- package/dist/server/runtime/websocket-upgrade.js +2 -0
- package/dist/server/runtime/websocket-worker.js +9 -0
- package/dist/server/task-ledger-codec.d.ts +9 -0
- package/dist/server/task-ledger-codec.js +4 -1
- package/dist/server/task-ledger-transition-helpers.js +1 -0
- package/dist/server/task-ledger-types.d.ts +9 -0
- package/dist/server/task-ledger.d.ts +1 -1
- package/dist/server/task-ledger.js +2 -1
- package/dist/server/task-queue-types.d.ts +2 -0
- package/dist/storage/bun-sql.js +51 -6
- package/dist/storage/catalog-keys.d.ts +64 -0
- package/dist/storage/catalog-keys.js +8 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/derived-operations.js +1 -1
- package/dist/storage/index.d.ts +28 -1
- package/dist/storage/interface.d.ts +28 -1
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-encoding.d.ts +15 -0
- package/dist/storage/key-encoding.js +3 -0
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +16 -0
- package/dist/storage/lmdb.d.ts +54 -1
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/mailbox-keys.d.ts +80 -0
- package/dist/storage/mailbox-keys.js +14 -0
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +2 -2
- package/dist/storage/node-sqlite-loader.d.ts +1 -1
- package/dist/storage/node-sqlite.js +51 -6
- package/dist/storage/outbox-keys.d.ts +77 -0
- package/dist/storage/outbox-keys.js +14 -0
- package/dist/storage/postgres.js +2 -2
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/storage-configuration.d.ts +6 -0
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/manifest/registry-contract-builder.d.ts +21 -3
- package/dist/worker/manifest/registry-contract-builder.js +40 -31
- package/dist/worker/protocol-messages.d.ts +17 -0
- package/dist/worker/protocol-schemas.d.ts +32 -0
- package/dist/worker/protocol-schemas.js +7 -3
- package/dist/worker/protocol-task-result.js +35 -3
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/types.d.ts +2 -0
- package/dist/worker/registry.d.ts +1 -1
- package/dist/worker/registry.js +3 -1
- package/dist/workers/workflow-runner.d.ts +9 -0
- package/dist/workers/workflow-runner.js +9 -2
- package/dist/workers/workflow-worker-entry.js +9 -4
- package/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createCheckpoint } from "../../checkpoint.js";
|
|
2
1
|
import { assertPayloadWithinLimit } from "../../payload-size.js";
|
|
3
2
|
import { normalizeStorageTimestamp } from "../../scheduler.js";
|
|
4
3
|
import {
|
|
@@ -6,12 +5,16 @@ import {
|
|
|
6
5
|
assertExclusiveStartWorkflowOptions,
|
|
7
6
|
assertValidOnTerminalConflict,
|
|
8
7
|
coerceStartWorkflowId,
|
|
9
|
-
coerceStartWorkflowTimestamp
|
|
10
|
-
parseStartWorkflowDuration
|
|
8
|
+
coerceStartWorkflowTimestamp
|
|
11
9
|
} from "../../start-workflow-validation.js";
|
|
10
|
+
import {
|
|
11
|
+
releaseInFlightStart,
|
|
12
|
+
resolveAndReserveExecutableRegistration
|
|
13
|
+
} from "../catalog-removal.js";
|
|
12
14
|
import { forgetCommittedCheckpointBytes } from "../checkpoint-commit-snapshots.js";
|
|
13
|
-
import { WorkflowAlreadyExistsError
|
|
15
|
+
import { WorkflowAlreadyExistsError } from "../errors.js";
|
|
14
16
|
import { createDelayedStartTimerEntry } from "../operations-time.js";
|
|
17
|
+
import { resolveAndReservePinnedExecutableRegistration } from "../pinned-schedule-revision.js";
|
|
15
18
|
import { selectPersistedWorkflowStartHeaders } from "../state-utilities.js";
|
|
16
19
|
import { buildWorkflowConcurrencyStartOperations } from "../workflow-concurrency.js";
|
|
17
20
|
import { createWorkflowVersionTuple } from "./persist.js";
|
|
@@ -27,6 +30,17 @@ import {
|
|
|
27
30
|
runWorkflowStartInterceptor
|
|
28
31
|
} from "./start-exec.js";
|
|
29
32
|
import {
|
|
33
|
+
resolveCachedStartRevision,
|
|
34
|
+
resolveStartRevisionUncached
|
|
35
|
+
} from "./start-revision-resolution.js";
|
|
36
|
+
import {
|
|
37
|
+
applyRestartLineage,
|
|
38
|
+
createInitialCheckpoint,
|
|
39
|
+
createInitialWorkflowState,
|
|
40
|
+
parseStartOptionDuration
|
|
41
|
+
} from "./start-state.js";
|
|
42
|
+
import {
|
|
43
|
+
GENERATED_ID_START_DECISION,
|
|
30
44
|
prepareTerminalRunPurge,
|
|
31
45
|
resolveTerminalConflictForRestart
|
|
32
46
|
} from "./start-terminal-conflict-purge.js";
|
|
@@ -69,11 +83,16 @@ function assertServicesSupportedForMode(internals, options) {
|
|
|
69
83
|
if (options?.services !== void 0 && internals.inlineStrategy === null)
|
|
70
84
|
throw Error('options.services is only supported in inline execution mode; it cannot be serialized to a Worker. Remove services or use workflowExecutionMode: "inline".');
|
|
71
85
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
function resolveAndReserveStartRegistration(internals, type, revisionOverride, callbacks) {
|
|
87
|
+
if (revisionOverride === void 0)
|
|
88
|
+
return resolveAndReserveExecutableRegistration(internals, type, callbacks.resolveExecutableRegistration);
|
|
89
|
+
return resolveAndReservePinnedExecutableRegistration(internals.engine, internals, type, revisionOverride).then(({ registration, inFlightRevision }) => ({
|
|
90
|
+
registration,
|
|
91
|
+
inFlightRevision,
|
|
92
|
+
resolvedRevision: revisionOverride
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
export async function startWorkflow(internals, type, input, options, additionalStartOperations, callbacks, buildIdempotentStartOperations, revisionOverride) {
|
|
77
96
|
assertServicesSupportedForMode(internals, options);
|
|
78
97
|
assertValidOnTerminalConflict(options);
|
|
79
98
|
const preparation = prepareStartWorkflow(internals, options, callbacks), {
|
|
@@ -89,11 +108,16 @@ export async function startWorkflow(internals, type, input, options, additionalS
|
|
|
89
108
|
if (internals.pendingStarts.has(workflowId))
|
|
90
109
|
throw new WorkflowAlreadyExistsError(workflowId);
|
|
91
110
|
internals.pendingStarts.add(workflowId);
|
|
92
|
-
let startSucceeded = !1;
|
|
111
|
+
let startSucceeded = !1, inFlightRevision;
|
|
93
112
|
try {
|
|
94
|
-
const terminalRunToPurge = callerProvidedId ? await resolveTerminalConflictForRestart(internals, workflowId, options) : null;
|
|
95
113
|
assertPayloadWithinLimit(input, internals.options.payloadSizePolicy.maxBytes, "workflow input");
|
|
96
|
-
const
|
|
114
|
+
const {
|
|
115
|
+
registration,
|
|
116
|
+
inFlightRevision: reservedRevision,
|
|
117
|
+
resolvedRevision
|
|
118
|
+
} = await resolveAndReserveStartRegistration(internals, type, revisionOverride, callbacks);
|
|
119
|
+
inFlightRevision = reservedRevision;
|
|
120
|
+
const workflowConcurrency = registration.concurrency, revision = resolveCachedStartRevision(internals, type, resolvedRevision) ?? await resolveStartRevisionUncached(internals, type), { terminalRunToPurge, duplicateIdCondition } = callerProvidedId ? await resolveTerminalConflictForRestart(internals, workflowId, options) : GENERATED_ID_START_DECISION, versionTuple = createWorkflowVersionTuple(internals, registration, callbacks), state = createInitialWorkflowState(internals, workflowId, type, input, versionTuple, revision, options, preparation.normalizedTags, executionStateOwnerId, parentWorkflowId, parentWorkflowExecutionToken, delayedStartTimer, callbacks);
|
|
97
121
|
applyRestartLineage(state, terminalRunToPurge);
|
|
98
122
|
const checkpoint = createInitialCheckpoint(internals, workflowId, versionTuple.workflowVersion, options, callbacks), workflowStartHeaders = runWorkflowStartInterceptor(internals, workflowId, type, input, parentHeaders, callbacks), persistedWorkflowStartHeaders = selectPersistedWorkflowStartHeaders(workflowStartHeaders), purgeDeleteOperations = terminalRunToPurge !== null ? await prepareTerminalRunPurge(internals, terminalRunToPurge, callbacks) : void 0;
|
|
99
123
|
internals.checkpoints.set(workflowId, checkpoint);
|
|
@@ -111,7 +135,8 @@ export async function startWorkflow(internals, type, input, options, additionalS
|
|
|
111
135
|
additionalStartOperations,
|
|
112
136
|
buildWorkflowConcurrencyStartOperations: workflowConcurrency === void 0 ? void 0 : () => buildWorkflowConcurrencyStartOperations(internals, type, workflowId, input, workflowConcurrency),
|
|
113
137
|
callbacks,
|
|
114
|
-
purgeDeleteOperations
|
|
138
|
+
purgeDeleteOperations,
|
|
139
|
+
duplicateIdCondition
|
|
115
140
|
}, buildIdempotentStartOperations);
|
|
116
141
|
if (options?.services !== void 0) {
|
|
117
142
|
internals.workflowServices.set(workflowId, options.services);
|
|
@@ -133,21 +158,11 @@ export async function startWorkflow(internals, type, input, options, additionalS
|
|
|
133
158
|
return handle;
|
|
134
159
|
} finally {
|
|
135
160
|
internals.pendingStarts.delete(workflowId);
|
|
161
|
+
releaseInFlightStart(internals, type, inFlightRevision);
|
|
136
162
|
if (!startSucceeded)
|
|
137
163
|
rollbackTransientStartState(internals, workflowId);
|
|
138
164
|
}
|
|
139
165
|
}
|
|
140
|
-
function applyRestartLineage(state, displacedState) {
|
|
141
|
-
if (displacedState === null)
|
|
142
|
-
return;
|
|
143
|
-
state.restartedFrom = {
|
|
144
|
-
workflowId: displacedState.id,
|
|
145
|
-
...displacedState.workflowExecutionToken !== void 0 && {
|
|
146
|
-
workflowExecutionToken: displacedState.workflowExecutionToken
|
|
147
|
-
},
|
|
148
|
-
replacedAt: state.createdAt
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
166
|
export function resolveScheduledStartAt(internals, options, submissionTime, callbacks) {
|
|
152
167
|
assertExclusiveStartWorkflowOptions(options?.startAt, options?.startAfter);
|
|
153
168
|
if (options?.startAt !== void 0)
|
|
@@ -162,45 +177,3 @@ export function resolveScheduledStartAt(internals, options, submissionTime, call
|
|
|
162
177
|
}
|
|
163
178
|
return;
|
|
164
179
|
}
|
|
165
|
-
export function parseStartOptionDuration(_internals, duration, fieldName, _callbacks) {
|
|
166
|
-
return parseStartWorkflowDuration(duration, fieldName);
|
|
167
|
-
}
|
|
168
|
-
function buildInitialIdentitySlice(workflowId, type, input, versionTuple, executionStateOwnerId, parentWorkflowId, parentWorkflowExecutionToken, delayedStartTimer, now, tags) {
|
|
169
|
-
return {
|
|
170
|
-
id: workflowId,
|
|
171
|
-
type,
|
|
172
|
-
status: delayedStartTimer ? "pending" : "running",
|
|
173
|
-
input,
|
|
174
|
-
versionTuple,
|
|
175
|
-
workflowExecutionToken: crypto.randomUUID(),
|
|
176
|
-
...executionStateOwnerId !== void 0 && { executionStateOwnerId },
|
|
177
|
-
...parentWorkflowId !== void 0 && { parentWorkflowId },
|
|
178
|
-
...parentWorkflowExecutionToken !== void 0 && { parentWorkflowExecutionToken },
|
|
179
|
-
createdAt: now,
|
|
180
|
-
...!delayedStartTimer && { startedAt: now },
|
|
181
|
-
updatedAt: now,
|
|
182
|
-
...tags !== void 0 && { tags }
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function resolveInitialExecutionDeadline(internals, options, delayedStartTimer, now, callbacks) {
|
|
186
|
-
if (options?.executionTimeout === void 0 || delayedStartTimer)
|
|
187
|
-
return;
|
|
188
|
-
const executionTimeoutMilliseconds = parseStartOptionDuration(internals, options.executionTimeout, "options.executionTimeout", callbacks);
|
|
189
|
-
try {
|
|
190
|
-
return normalizeStorageTimestamp(now + executionTimeoutMilliseconds, "options.executionTimeout");
|
|
191
|
-
} catch {
|
|
192
|
-
throw new StartWorkflowValidationError("options.executionTimeout must resolve to a finite, non-negative deadline");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export function createInitialWorkflowState(internals, workflowId, type, input, versionTuple, options, tags, executionStateOwnerId, parentWorkflowId, parentWorkflowExecutionToken, delayedStartTimer, callbacks) {
|
|
196
|
-
const now = internals.options.getNow(), state = buildInitialIdentitySlice(workflowId, type, input, versionTuple, executionStateOwnerId, parentWorkflowId, parentWorkflowExecutionToken, delayedStartTimer, now, tags), executionDeadline = resolveInitialExecutionDeadline(internals, options, delayedStartTimer, now, callbacks);
|
|
197
|
-
if (executionDeadline !== void 0)
|
|
198
|
-
state.executionDeadline = executionDeadline;
|
|
199
|
-
return state;
|
|
200
|
-
}
|
|
201
|
-
export function createInitialCheckpoint(internals, workflowId, workflowVersion, options, _callbacks) {
|
|
202
|
-
const checkpoint = createCheckpoint(workflowId, workflowVersion, internals.options.getNow());
|
|
203
|
-
if (options?.searchAttributes)
|
|
204
|
-
checkpoint.searchAttributes = { ...options.searchAttributes };
|
|
205
|
-
return checkpoint;
|
|
206
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { ForkOptions } from '../../types.ts';
|
|
2
|
+
import type { WorkflowHandle } from '../handles.ts';
|
|
3
3
|
import type { EngineInternals } from '../internals.ts';
|
|
4
|
-
import { type LifecycleCallbacks, type RecoverAllOptions
|
|
4
|
+
import { type LifecycleCallbacks, type RecoverAllOptions } from './shared.ts';
|
|
5
5
|
export declare function recoverAll(internals: EngineInternals, callbacks: LifecycleCallbacks, options?: RecoverAllOptions): Promise<WorkflowHandle[]>;
|
|
6
6
|
/** Options for {@link resume}. */
|
|
7
7
|
export type ResumeOptions = {
|
|
@@ -19,4 +19,3 @@ export type ResumeOptions = {
|
|
|
19
19
|
};
|
|
20
20
|
export declare function resume(internals: EngineInternals, workflowId: string, callbacks: LifecycleCallbacks, onRecoveredWorkflow?: RecoverAllOptions['onRecoveredWorkflow'], options?: ResumeOptions): Promise<WorkflowHandle>;
|
|
21
21
|
export declare function fork(internals: EngineInternals, sourceWorkflowId: string, options: ForkOptions | undefined, callbacks: LifecycleCallbacks): Promise<WorkflowHandle>;
|
|
22
|
-
export declare function launchWorkflowFromCheckpoint(internals: EngineInternals, workflowId: string, state: WorkflowState, checkpoint: Checkpoint, registration: RegistrationEntry, callbacks: LifecycleCallbacks): WorkflowHandle;
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
import { KEYS } from "../../../storage/interface.js";
|
|
2
2
|
import { deserializeCheckpoint, serializeCheckpoint } from "../../checkpoint.js";
|
|
3
3
|
import { RegExpExtensionDecodeError } from "../../codec/extension-codec.js";
|
|
4
|
-
import { Context, setContextWorkflowInterceptor } from "../../context.js";
|
|
5
4
|
import { EMPTY_EVENT_HEAD } from "../../event-log.js";
|
|
6
|
-
import { WorkflowRecoverySkippedEvent
|
|
5
|
+
import { WorkflowRecoverySkippedEvent } from "../../events.js";
|
|
7
6
|
import { VersionMismatchError } from "../../versioning.js";
|
|
8
|
-
import { createCancelHandlerRegistration, resetCancelHandlers } from "../cancel-handlers.js";
|
|
9
7
|
import { forgetCommittedCheckpointBytes } from "../checkpoint-commit-snapshots.js";
|
|
10
8
|
import { hydrateCheckpointReplayState } from "../checkpoint-replay.js";
|
|
9
|
+
import { DynamicWorkflowSourceUnavailableError } from "../dynamic-source-errors.js";
|
|
10
|
+
import { resolveExecutableRegistrationOrRenamedNotFound } from "../dynamic-source-execution.js";
|
|
11
11
|
import { WorkflowTypeNotRegisteredForRecoveryError } from "../errors.js";
|
|
12
12
|
import { commitFencedEngineWrite } from "../fenced-write.js";
|
|
13
|
-
import { getWorkflowExecutionStartedAt } from "../handles.js";
|
|
14
13
|
import { WorkflowClaimUnavailableError } from "../lease-errors.js";
|
|
14
|
+
import { WorkflowRevisionUnavailableError } from "../revision-errors.js";
|
|
15
15
|
import { normalizeForkStep, selectPersistedWorkflowStartHeaders } from "../state-utilities.js";
|
|
16
16
|
import { loadWorkflowState } from "../storage-io.js";
|
|
17
|
-
import { getComposedWorkflowInterceptor } from "../strategy-helpers.js";
|
|
18
17
|
import { decodeWorkflowState } from "../validation.js";
|
|
18
|
+
import { launchWorkflowFromCheckpoint } from "./checkpoint-launch.js";
|
|
19
19
|
import {
|
|
20
20
|
buildForkBatchOperations,
|
|
21
21
|
buildForkSearchAttributes,
|
|
22
22
|
createForkLineage,
|
|
23
23
|
createForkedWorkflowState
|
|
24
24
|
} from "./fork-helpers.js";
|
|
25
|
-
import {
|
|
25
|
+
import { derivePreparedExecutionState } from "./persist.js";
|
|
26
|
+
import {
|
|
27
|
+
buildRecoveryRevisionGroups,
|
|
28
|
+
classifyRevisionGroups,
|
|
29
|
+
createRecoveryScopedRevisionCallbacks
|
|
30
|
+
} from "./recovery-revision-groups.js";
|
|
26
31
|
import { resumeWorkflowFromStorage } from "./resume.js";
|
|
27
32
|
import {
|
|
28
|
-
createWorkflowHandle,
|
|
29
33
|
enforceHistoryPolicyBeforeReplayById,
|
|
30
34
|
loadWorkflowStartHeaders,
|
|
31
35
|
setWorkflowStartHeaders
|
|
@@ -39,9 +43,9 @@ function classifyRecoveryState(internals, callbacks, state) {
|
|
|
39
43
|
return { kind: "local", workflowId: state.id };
|
|
40
44
|
if (state.status !== "running")
|
|
41
45
|
return { kind: "ignored" };
|
|
42
|
-
if (!internals.registrations.has(state.type))
|
|
46
|
+
if (!internals.registrations.has(state.type) && !internals.sources.byName.has(state.type))
|
|
43
47
|
return { kind: "missing", workflow: { type: state.type, workflowId: state.id } };
|
|
44
|
-
return { kind: "recoverable", workflowId: state.id };
|
|
48
|
+
return { kind: "recoverable", workflowId: state.id, type: state.type, revision: state.revision };
|
|
45
49
|
}
|
|
46
50
|
function appendRecoveryClassification(result, classification) {
|
|
47
51
|
if (classification.kind === "ignored")
|
|
@@ -76,6 +80,14 @@ async function recoverEntryOrIsolateFailure(internals, workflowId, callbacks, op
|
|
|
76
80
|
}
|
|
77
81
|
if (error instanceof WorkflowClaimUnavailableError)
|
|
78
82
|
return null;
|
|
83
|
+
if (error instanceof WorkflowRevisionUnavailableError) {
|
|
84
|
+
await callbacks.failWorkflowForRevisionUnavailable(workflowId, error);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (error instanceof DynamicWorkflowSourceUnavailableError) {
|
|
88
|
+
await callbacks.failWorkflowForUnavailableDynamicSource(workflowId, error);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
79
91
|
throw error;
|
|
80
92
|
}
|
|
81
93
|
}
|
|
@@ -83,9 +95,13 @@ export async function recoverAll(internals, callbacks, options) {
|
|
|
83
95
|
const preflight = await preflightRecoverAll(internals, callbacks), handles = [];
|
|
84
96
|
if (preflight.missingWorkflows.length > 0 && options?.acknowledgeUnknownWorkflowTypes !== !0)
|
|
85
97
|
throw new WorkflowTypeNotRegisteredForRecoveryError({
|
|
86
|
-
registeredTypes:
|
|
98
|
+
registeredTypes: new Set([
|
|
99
|
+
...internals.registrations.keys(),
|
|
100
|
+
...internals.sources.byName.keys()
|
|
101
|
+
]),
|
|
87
102
|
missingWorkflows: preflight.missingWorkflows
|
|
88
103
|
});
|
|
104
|
+
const recoverableEntries = preflight.entries.filter((entry) => entry.kind === "recoverable"), revisionGroups = buildRecoveryRevisionGroups(recoverableEntries), revisionClassifications = await classifyRevisionGroups(internals, callbacks, revisionGroups), recoveryScopedCallbacks = createRecoveryScopedRevisionCallbacks(callbacks, revisionClassifications);
|
|
89
105
|
for (const entry of preflight.entries) {
|
|
90
106
|
if (entry.kind === "local") {
|
|
91
107
|
handles.push(callbacks.getHandle(entry.workflowId));
|
|
@@ -95,7 +111,7 @@ export async function recoverAll(internals, callbacks, options) {
|
|
|
95
111
|
callbacks.dispatchEvent(new WorkflowRecoverySkippedEvent(entry.workflow.workflowId, entry.workflow.type, "type-not-registered"));
|
|
96
112
|
continue;
|
|
97
113
|
}
|
|
98
|
-
const handle = await recoverEntryOrIsolateFailure(internals, entry.workflowId,
|
|
114
|
+
const handle = await recoverEntryOrIsolateFailure(internals, entry.workflowId, recoveryScopedCallbacks, options);
|
|
99
115
|
if (handle !== null)
|
|
100
116
|
handles.push(handle);
|
|
101
117
|
}
|
|
@@ -115,10 +131,7 @@ export async function fork(internals, sourceWorkflowId, options, callbacks) {
|
|
|
115
131
|
const sourceState = await loadWorkflowState(internals, sourceWorkflowId);
|
|
116
132
|
if (!sourceState)
|
|
117
133
|
throw Error(`Workflow "${sourceWorkflowId}" not found`);
|
|
118
|
-
const registration =
|
|
119
|
-
if (!registration)
|
|
120
|
-
throw Error(`No workflow registered with name "${sourceState.type}" (needed to fork "${sourceWorkflowId}")`);
|
|
121
|
-
const fromStep = options?.fromStep !== void 0 ? normalizeForkStep(options.fromStep) : void 0, checkpointKey = fromStep !== void 0 ? KEYS.checkpointHistory(sourceWorkflowId, fromStep) : KEYS.checkpoint(sourceWorkflowId), checkpointBytes = await internals.storage.get(checkpointKey);
|
|
134
|
+
const { entry: registration, revision: resolvedRevision } = await resolveExecutableRegistrationOrRenamedNotFound((type) => callbacks.resolveExecutableRegistrationForRevision(type, sourceState.revision), sourceState.type, () => Error(`No workflow registered with name "${sourceState.type}" (needed to fork "${sourceWorkflowId}")`)), fromStep = options?.fromStep !== void 0 ? normalizeForkStep(options.fromStep) : void 0, checkpointKey = fromStep !== void 0 ? KEYS.checkpointHistory(sourceWorkflowId, fromStep) : KEYS.checkpoint(sourceWorkflowId), checkpointBytes = await internals.storage.get(checkpointKey);
|
|
122
135
|
if (!checkpointBytes) {
|
|
123
136
|
if (fromStep !== void 0)
|
|
124
137
|
throw Error(`Checkpoint not found at step ${String(fromStep)} for workflow "${sourceWorkflowId}"`);
|
|
@@ -129,14 +142,14 @@ export async function fork(internals, sourceWorkflowId, options, callbacks) {
|
|
|
129
142
|
createdAt: forkedAt,
|
|
130
143
|
workflowId,
|
|
131
144
|
searchAttributes: buildForkSearchAttributes(internals, preparedExecutionState.checkpoint, lineage, callbacks)
|
|
132
|
-
}, forkState = createForkedWorkflowState(internals, workflowId, preparedExecutionState.state, preparedExecutionState.versionTuple, lineage, forkedAt, callbacks);
|
|
145
|
+
}, forkState = createForkedWorkflowState(internals, workflowId, preparedExecutionState.state, preparedExecutionState.versionTuple, lineage, forkedAt, callbacks, resolvedRevision);
|
|
133
146
|
let forkStarted = !1;
|
|
134
147
|
try {
|
|
135
148
|
const forkCheckpointBytes = serializeCheckpoint(forkCheckpoint);
|
|
136
149
|
await commitFencedEngineWrite(internals, workflowId, buildForkBatchOperations(internals, workflowId, forkState, forkCheckpoint, forkCheckpointBytes, persistedWorkflowStartHeaders, callbacks), [], () => Error(`Fork of workflow "${workflowId}" lost its CAS race.`));
|
|
137
150
|
internals.eventLogHeads.set(workflowId, EMPTY_EVENT_HEAD);
|
|
138
151
|
setWorkflowStartHeaders(internals, workflowId, persistedWorkflowStartHeaders, callbacks);
|
|
139
|
-
const handle = launchWorkflowFromCheckpoint(internals, workflowId, forkState, forkCheckpoint, registration, callbacks);
|
|
152
|
+
const handle = launchWorkflowFromCheckpoint(internals, workflowId, forkState, forkCheckpoint, registration, resolvedRevision, callbacks);
|
|
140
153
|
forkStarted = !0;
|
|
141
154
|
return handle;
|
|
142
155
|
} finally {
|
|
@@ -149,66 +162,3 @@ export async function fork(internals, sourceWorkflowId, options, callbacks) {
|
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
164
|
}
|
|
152
|
-
function launchInlineWorkflowFromCheckpoint(internals, workflowId, state, checkpoint, registration, callbacks) {
|
|
153
|
-
const inlineStrategy = internals.inlineStrategy;
|
|
154
|
-
if (!inlineStrategy)
|
|
155
|
-
throw Error("Inline workflow launch requested without an inline strategy.");
|
|
156
|
-
const accumulatedResults = new Map(checkpoint.accumulatedResults), workflowAbort = new AbortController;
|
|
157
|
-
resetCancelHandlers(internals, workflowId);
|
|
158
|
-
const context = new Context({
|
|
159
|
-
workflowId,
|
|
160
|
-
...state.workflowExecutionToken !== void 0 && {
|
|
161
|
-
workflowExecutionToken: state.workflowExecutionToken
|
|
162
|
-
},
|
|
163
|
-
workflowType: state.type,
|
|
164
|
-
startedAt: getWorkflowExecutionStartedAt(state),
|
|
165
|
-
abortController: workflowAbort,
|
|
166
|
-
getNow: internals.options.getNow,
|
|
167
|
-
resolveWorkflowType: callbacks.resolveWorkflowTypeTarget,
|
|
168
|
-
executionStateOwnerId: state.executionStateOwnerId ?? workflowId,
|
|
169
|
-
accumulatedResults,
|
|
170
|
-
searchAttributes: checkpoint.searchAttributes,
|
|
171
|
-
registerCancelHandler: createCancelHandlerRegistration(internals, workflowId),
|
|
172
|
-
...registration.searchAttributes && {
|
|
173
|
-
searchAttributeSchema: registration.searchAttributes
|
|
174
|
-
},
|
|
175
|
-
sleepReferenceTime: checkpoint.createdAt,
|
|
176
|
-
...state.executionDeadline !== void 0 && { deadline: state.executionDeadline },
|
|
177
|
-
...internals.options.onLog != null && { logSink: internals.options.onLog }
|
|
178
|
-
});
|
|
179
|
-
setContextWorkflowInterceptor(context, getComposedWorkflowInterceptor(internals));
|
|
180
|
-
if (internals.options.development)
|
|
181
|
-
context.explain(!0);
|
|
182
|
-
const generator = registration.handler(context, state.input);
|
|
183
|
-
inlineStrategy.adoptWorkflow(workflowId, generator, context, workflowAbort);
|
|
184
|
-
inlineStrategy.continueWorkflow(workflowId, void 0);
|
|
185
|
-
callbacks.swallowPromiseRejection(callbacks.processPendingUpdatesAfterInlineAdvance(workflowId));
|
|
186
|
-
}
|
|
187
|
-
function launchWorkerWorkflowFromCheckpoint(internals, workflowId, state, checkpoint) {
|
|
188
|
-
const serialized = serializeCheckpoint(checkpoint);
|
|
189
|
-
internals.strategy.startWorkflow({
|
|
190
|
-
workflowId,
|
|
191
|
-
...state.workflowExecutionToken !== void 0 && {
|
|
192
|
-
workflowExecutionToken: state.workflowExecutionToken
|
|
193
|
-
},
|
|
194
|
-
workflowType: state.type,
|
|
195
|
-
input: state.input,
|
|
196
|
-
checkpoint: serialized,
|
|
197
|
-
executionStateOwnerId: state.executionStateOwnerId ?? workflowId,
|
|
198
|
-
...state.executionDeadline !== void 0 && { deadline: state.executionDeadline },
|
|
199
|
-
...internals.workflowHeaders.has(workflowId) && {
|
|
200
|
-
headers: [...internals.workflowHeaders.get(workflowId)]
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
export function launchWorkflowFromCheckpoint(internals, workflowId, state, checkpoint, registration, callbacks) {
|
|
205
|
-
internals.checkpoints.set(workflowId, checkpoint);
|
|
206
|
-
internals.workflowVersionTuples.set(workflowId, createWorkflowVersionTuple(internals, registration, callbacks));
|
|
207
|
-
const handle = createWorkflowHandle(internals, workflowId, callbacks);
|
|
208
|
-
callbacks.dispatchEvent(new WorkflowStartedEvent(workflowId, state.type, state.input));
|
|
209
|
-
if (internals.inlineStrategy)
|
|
210
|
-
launchInlineWorkflowFromCheckpoint(internals, workflowId, state, checkpoint, registration, callbacks);
|
|
211
|
-
else
|
|
212
|
-
launchWorkerWorkflowFromCheckpoint(internals, workflowId, state, checkpoint);
|
|
213
|
-
return handle;
|
|
214
|
-
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { EMPTY_STORAGE_VALUE, createWorkflowHandle, loadTerminalCleanupTrackedState, loadWorkflowStartHeaders, normalizeStartWorkflowTags, processPendingUpdatesAfterReplay, setWorkflowStartHeaders, type LifecycleCallbacks, type RecoverAllOptions, type RecoveredWorkflowInfo, } from './lifecycle/shared.ts';
|
|
2
2
|
export { createWorkflowVersionTuple, derivePreparedExecutionState, prepareResumeState, throwVersionMismatch, workflowStateWithVersionTuple, workflowVersionTupleFromState, } from './lifecycle/persist.ts';
|
|
3
|
-
export {
|
|
3
|
+
export { resolveScheduledStartAt, start, startWorkflow } from './lifecycle/start.ts';
|
|
4
|
+
export { applyRestartLineage, createInitialCheckpoint, createInitialWorkflowState, parseStartOptionDuration, } from './lifecycle/start-state.ts';
|
|
4
5
|
export { startOrSignal, startWithIdempotency, type StartOrSignalCallbacks, type StartOrSignalResult, } from './lifecycle/start-or-signal.ts';
|
|
5
6
|
export { buildInitialSearchAttributeOperations, buildStartBatchOperations, validateSearchAttributes, } from './lifecycle/start-batch.ts';
|
|
6
7
|
export { beginWorkflowExecution, runWorkflowStartInterceptor, startWorkflowExecution, } from './lifecycle/start-exec.ts';
|
|
7
8
|
export { buildForkBatchOperations, buildForkSearchAttributes, createForkLineage, createForkedWorkflowState, } from './lifecycle/fork-helpers.ts';
|
|
8
|
-
export {
|
|
9
|
+
export { launchWorkflowFromCheckpoint } from './lifecycle/checkpoint-launch.ts';
|
|
10
|
+
export { fork, recoverAll, resume } from './lifecycle/transition.ts';
|
|
9
11
|
export { resumeWorkflowFromStorage } from './lifecycle/resume.ts';
|
|
@@ -15,14 +15,13 @@ export {
|
|
|
15
15
|
workflowStateWithVersionTuple,
|
|
16
16
|
workflowVersionTupleFromState
|
|
17
17
|
} from "./lifecycle/persist.js";
|
|
18
|
+
export { resolveScheduledStartAt, start, startWorkflow } from "./lifecycle/start.js";
|
|
18
19
|
export {
|
|
20
|
+
applyRestartLineage,
|
|
19
21
|
createInitialCheckpoint,
|
|
20
22
|
createInitialWorkflowState,
|
|
21
|
-
parseStartOptionDuration
|
|
22
|
-
|
|
23
|
-
start,
|
|
24
|
-
startWorkflow
|
|
25
|
-
} from "./lifecycle/start.js";
|
|
23
|
+
parseStartOptionDuration
|
|
24
|
+
} from "./lifecycle/start-state.js";
|
|
26
25
|
export {
|
|
27
26
|
startOrSignal,
|
|
28
27
|
startWithIdempotency
|
|
@@ -43,5 +42,6 @@ export {
|
|
|
43
42
|
createForkLineage,
|
|
44
43
|
createForkedWorkflowState
|
|
45
44
|
} from "./lifecycle/fork-helpers.js";
|
|
46
|
-
export {
|
|
45
|
+
export { launchWorkflowFromCheckpoint } from "./lifecycle/checkpoint-launch.js";
|
|
46
|
+
export { fork, recoverAll, resume } from "./lifecycle/transition.js";
|
|
47
47
|
export { resumeWorkflowFromStorage } from "./lifecycle/resume.js";
|
|
@@ -6,6 +6,10 @@ import { buildIndexOperations, validateAttributeType } from "../search-attribute
|
|
|
6
6
|
import { normalizeWorkflowTags } from "../workflow-tags.js";
|
|
7
7
|
import { mutateWorkflowTags, validateAttributeValueSizes } from "./attributes-tags.js";
|
|
8
8
|
import { CONSTRAINED_ID_CHUNK_SIZE } from "./candidate-read-batching.js";
|
|
9
|
+
import {
|
|
10
|
+
getResolvedDynamicRegistration,
|
|
11
|
+
resolveExecutableRegistrationForRevision
|
|
12
|
+
} from "./dynamic-source-execution.js";
|
|
9
13
|
import { resolveListCandidateIds } from "./list-candidate-resolution.js";
|
|
10
14
|
import {
|
|
11
15
|
readSearchAttributesForFilter,
|
|
@@ -95,6 +99,7 @@ function summaryFromState(state, attributeFailureCategory) {
|
|
|
95
99
|
status: state.status,
|
|
96
100
|
...state.tags !== void 0 && { tags: state.tags },
|
|
97
101
|
version: state.versionTuple.workflowVersion,
|
|
102
|
+
...state.revision !== void 0 && { revision: state.revision },
|
|
98
103
|
createdAt: state.createdAt,
|
|
99
104
|
updatedAt: state.updatedAt,
|
|
100
105
|
...state.executionDeadline !== void 0 && { executionDeadline: state.executionDeadline },
|
|
@@ -164,10 +169,19 @@ export async function getAttributes(internals, workflowId) {
|
|
|
164
169
|
return null;
|
|
165
170
|
return decoded;
|
|
166
171
|
}
|
|
172
|
+
async function resolveAttributeSchemaRegistration(internals, state) {
|
|
173
|
+
const eagerOrAlreadyResolved = getResolvedDynamicRegistration(internals, state.type, state.revision);
|
|
174
|
+
if (eagerOrAlreadyResolved !== void 0)
|
|
175
|
+
return eagerOrAlreadyResolved;
|
|
176
|
+
if (!internals.sources.byName.has(state.type))
|
|
177
|
+
return;
|
|
178
|
+
const { entry } = await resolveExecutableRegistrationForRevision(internals.engine, internals, state.type, state.revision);
|
|
179
|
+
return entry;
|
|
180
|
+
}
|
|
167
181
|
export async function setAttributes(internals, workflowId, attributes) {
|
|
168
182
|
const stateBytes = await internals.storage.get(KEYS.workflow(workflowId));
|
|
169
183
|
if (stateBytes) {
|
|
170
|
-
const state = decodeWorkflowState(stateBytes), registration = internals
|
|
184
|
+
const state = decodeWorkflowState(stateBytes), registration = await resolveAttributeSchemaRegistration(internals, state);
|
|
171
185
|
if (registration?.searchAttributes) {
|
|
172
186
|
const schema = registration.searchAttributes;
|
|
173
187
|
for (const [key, value] of Object.entries(attributes)) {
|
|
@@ -45,7 +45,10 @@ class MemoDurableActivityScope {
|
|
|
45
45
|
this.#activityCallbacks = activityCallbacks;
|
|
46
46
|
this.#persistCheckpoint = persistCheckpoint;
|
|
47
47
|
this.#identityPrefix = `memo:${operation.step}:${hashString(operation.key)}`;
|
|
48
|
-
this.#internals.workflowTypeByWorkflowId.set(workflowId,
|
|
48
|
+
this.#internals.workflowTypeByWorkflowId.set(workflowId, {
|
|
49
|
+
type: context.workflowType,
|
|
50
|
+
revision: this.#internals.workflowTypeByWorkflowId.get(workflowId)?.revision
|
|
51
|
+
});
|
|
49
52
|
}
|
|
50
53
|
async run(execute) {
|
|
51
54
|
const cleanupAbortForwarding = this.#forwardAbortSignals();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Count non-terminal (`running`, `pending`, or `suspended`) workflow runs
|
|
3
|
+
* pinned to an exact `(type, revision)` (WFT-17). Wired into
|
|
4
|
+
* `catalog-removal.ts`'s `countWorkflowRevisionReferences()`, replacing the
|
|
5
|
+
* `nonTerminalRuns: 0` stub WFT-12 left in place pending this batch (see
|
|
6
|
+
* that changelog entry: "stays 0 until run-level revision pinning (WFT-17)
|
|
7
|
+
* exists to count against").
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `diagnostics/version-check.ts`'s `groupActiveWorkflowsByType()`
|
|
10
|
+
* bounded-scan shape: only top-level `wf:{id}` records are workflow states
|
|
11
|
+
* (`wf:{id}:ckpt`, `:offload`, `:archive`, `:timeline:`, and index keys all
|
|
12
|
+
* share the `wf:` prefix but are not).
|
|
13
|
+
*
|
|
14
|
+
* @module core/engine/nonterminal-revision-count
|
|
15
|
+
*/
|
|
16
|
+
import type { Storage } from '../../storage/interface.ts';
|
|
17
|
+
/**
|
|
18
|
+
* Scan `storage` for non-terminal workflow states whose `type` and
|
|
19
|
+
* `revision` match exactly, returning the count. A legacy record with no
|
|
20
|
+
* persisted `revision` never matches (a defined `revision` argument cannot
|
|
21
|
+
* equal `undefined`), consistent with recovery's own "a legacy record is a
|
|
22
|
+
* distinct, unresolved pin" treatment — it is not silently folded into
|
|
23
|
+
* whichever revision happens to be active.
|
|
24
|
+
*/
|
|
25
|
+
export declare function countNonTerminalRunsForRevision(storage: Storage, type: string, revision: string): Promise<number>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { decodeWorkflowState, isTerminalWorkflowStatus } from "./validation.js";
|
|
2
|
+
import { isTopLevelWorkflowStateKey } from "./workflow-state-stream.js";
|
|
3
|
+
export async function countNonTerminalRunsForRevision(storage, type, revision) {
|
|
4
|
+
let count = 0;
|
|
5
|
+
for await (const [key, bytes] of storage.scan("wf:")) {
|
|
6
|
+
if (!isTopLevelWorkflowStateKey(key))
|
|
7
|
+
continue;
|
|
8
|
+
const state = decodeWorkflowState(bytes);
|
|
9
|
+
if (state.type !== type || state.revision !== revision)
|
|
10
|
+
continue;
|
|
11
|
+
if (isTerminalWorkflowStatus(state.status))
|
|
12
|
+
continue;
|
|
13
|
+
count += 1;
|
|
14
|
+
}
|
|
15
|
+
return count;
|
|
16
|
+
}
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
import type { ContextOperationRequest } from '../context.ts';
|
|
2
|
-
import type {
|
|
3
|
-
import type { WorkflowVersionTuple } from '../workflow-version-tuple.ts';
|
|
2
|
+
import type { StartOptions, TimerEntry } from '../types.ts';
|
|
4
3
|
import type { EngineInternals } from './internals.ts';
|
|
5
|
-
type
|
|
4
|
+
import { type TimeOperationCallbacks } from './time-operation-callbacks.ts';
|
|
6
5
|
type SleepOperation = Extract<ContextOperationRequest, {
|
|
7
6
|
type: 'sleep';
|
|
8
7
|
}>;
|
|
9
|
-
export type TimeOperationCallbacks
|
|
10
|
-
completeOperation: (workflowId: string, value: unknown) => void;
|
|
11
|
-
dispatchEvent: (event: Event) => void;
|
|
12
|
-
loadWorkflowState: (workflowId: string) => Promise<WorkflowState | null>;
|
|
13
|
-
failWorkflow: (workflowId: string, error: Error) => Promise<void>;
|
|
14
|
-
runSerializedWorkflowStateWrite: <Result>(workflowId: string, writeOperation: () => Promise<Result>) => Promise<Result>;
|
|
15
|
-
beginWorkflowExecution: (workflowId: string, workflowExecutionToken: string | undefined, workflowType: string, input: unknown, checkpoint: Checkpoint, executionDeadline: number | undefined, executionStateOwnerId: string, registration: RegistrationEntry) => void;
|
|
16
|
-
workflowVersionTupleFromState: (state: WorkflowState) => WorkflowVersionTuple;
|
|
17
|
-
setWorkflowStartHeaders: (workflowId: string, headers: Map<string, string> | undefined) => void;
|
|
18
|
-
loadWorkflowStartHeaders: (workflowId: string) => Promise<Map<string, string> | undefined>;
|
|
19
|
-
parseStartOptionDuration: (value: Duration, fieldName: 'options.executionTimeout' | 'options.startAfter') => number;
|
|
20
|
-
runDeferredTerminalCleanup: (workflowId: string, timerId: string) => Promise<void>;
|
|
21
|
-
runWorkflowFinalizer: (workflowId: string, timerId: string) => Promise<void>;
|
|
22
|
-
handleScheduleTimer: (entry: TimerEntry) => Promise<void>;
|
|
23
|
-
timeout: (workflowId: string) => Promise<void>;
|
|
24
|
-
handleCleanupError: (source: string, error: unknown, workflowId: string) => void;
|
|
25
|
-
};
|
|
8
|
+
export type { TimeOperationCallbacks };
|
|
26
9
|
export declare function createDelayedStartTimerEntry(_internals: EngineInternals, workflowId: string, scheduledStartAt: number, options: StartOptions | undefined, callbacks: Pick<TimeOperationCallbacks, 'parseStartOptionDuration'>): TimerEntry;
|
|
27
10
|
export declare function processSleepOperation(internals: EngineInternals, workflowId: string, operation: SleepOperation, callbacks: Pick<TimeOperationCallbacks, 'completeOperation' | 'loadWorkflowState'>): Promise<void>;
|
|
28
11
|
export declare function registerSleepResolver(internals: EngineInternals, workflowId: string, operationId: string, resolve: () => void, scheduledFireAt: number): void;
|
|
29
|
-
export declare function startDelayedWorkflow(internals: EngineInternals, entry: TimerEntry, callbacks: Pick<TimeOperationCallbacks, 'beginWorkflowExecution' | 'dispatchEvent' | 'failWorkflow' | 'handleCleanupError' | 'loadWorkflowStartHeaders' | 'loadWorkflowState' | 'runSerializedWorkflowStateWrite' | 'setWorkflowStartHeaders' | 'workflowVersionTupleFromState'>): Promise<void>;
|
|
30
|
-
export declare function handleTimerFired(internals: EngineInternals, entry: TimerEntry, callbacks: Pick<TimeOperationCallbacks, 'failWorkflow' | 'handleCleanupError' | 'loadWorkflowStartHeaders' | 'loadWorkflowState' | 'runDeferredTerminalCleanup' | 'runWorkflowFinalizer' | 'runSerializedWorkflowStateWrite' | 'handleScheduleTimer' | 'setWorkflowStartHeaders' | 'timeout' | 'beginWorkflowExecution' | 'dispatchEvent' | 'workflowVersionTupleFromState'>): Promise<void>;
|
|
31
|
-
export {};
|
|
12
|
+
export declare function startDelayedWorkflow(internals: EngineInternals, entry: TimerEntry, callbacks: Pick<TimeOperationCallbacks, 'beginWorkflowExecution' | 'dispatchEvent' | 'failWorkflow' | 'handleCleanupError' | 'loadWorkflowStartHeaders' | 'loadWorkflowState' | 'resolveExecutableRegistrationForRevision' | 'runSerializedWorkflowStateWrite' | 'setWorkflowStartHeaders' | 'workflowVersionTupleFromState'>): Promise<void>;
|
|
13
|
+
export declare function handleTimerFired(internals: EngineInternals, entry: TimerEntry, callbacks: Pick<TimeOperationCallbacks, 'failWorkflow' | 'handleCleanupError' | 'loadWorkflowStartHeaders' | 'loadWorkflowState' | 'runDeferredTerminalCleanup' | 'runWorkflowFinalizer' | 'runSerializedWorkflowStateWrite' | 'handleScheduleTimer' | 'setWorkflowStartHeaders' | 'timeout' | 'beginWorkflowExecution' | 'dispatchEvent' | 'resolveExecutableRegistrationForRevision' | 'workflowVersionTupleFromState'>): Promise<void>;
|
|
@@ -4,7 +4,9 @@ import { encode } from "../codec.js";
|
|
|
4
4
|
import { buildTimerBatchOperations, normalizeStorageTimestamp } from "../scheduler.js";
|
|
5
5
|
import { notifyConditionWaiters, notifyConditionWaitersForTimerFire } from "./condition-waiters.js";
|
|
6
6
|
import { commitFencedEngineWrite } from "./fenced-write.js";
|
|
7
|
+
import { resolveDelayedStartRegistrationOrFail } from "./lifecycle/delayed-start-registration.js";
|
|
7
8
|
import { reprovideRecoveredServices } from "./lifecycle/recovered-services.js";
|
|
9
|
+
import { ensureDelayedStartClaimAndCleanupBeforeFailure } from "./lifecycle/standalone-claim-acquire.js";
|
|
8
10
|
import {
|
|
9
11
|
acknowledgeSupersededSleepTimers,
|
|
10
12
|
handleSleepTimerWithAcknowledgement,
|
|
@@ -88,23 +90,22 @@ export async function startDelayedWorkflow(internals, entry, callbacks) {
|
|
|
88
90
|
const checkpoint = await loadDelayedWorkflowCheckpoint(internals, entry, callbacks);
|
|
89
91
|
if (!checkpoint)
|
|
90
92
|
return;
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
await callbacks.failWorkflow(entry.workflowId, Error(`No workflow registered with name "${state.type}"`));
|
|
93
|
+
const resolvedRegistration = await resolveDelayedStartRegistrationOrFail(internals, entry, state.type, state.revision, callbacks);
|
|
94
|
+
if (resolvedRegistration === null)
|
|
94
95
|
return;
|
|
95
|
-
}
|
|
96
|
-
const now = internals.options.getNow(), executionDeadline = await resolveDelayedExecutionDeadline(entry, now, callbacks);
|
|
96
|
+
const { entry: registration, revision: resolvedRevision } = resolvedRegistration, now = internals.options.getNow(), executionDeadline = await resolveDelayedExecutionDeadline(internals, entry, now, callbacks);
|
|
97
97
|
if (executionDeadline === "invalid")
|
|
98
98
|
return;
|
|
99
99
|
const runningState = await callbacks.runSerializedWorkflowStateWrite(entry.workflowId, async () => {
|
|
100
100
|
const latestState = await callbacks.loadWorkflowState(entry.workflowId);
|
|
101
101
|
if (!latestState || latestState.status !== "pending")
|
|
102
102
|
return null;
|
|
103
|
-
const nextRunningState = {
|
|
103
|
+
const effectiveRevision = latestState.revision ?? resolvedRevision, nextRunningState = {
|
|
104
104
|
...latestState,
|
|
105
105
|
status: "running",
|
|
106
106
|
startedAt: now,
|
|
107
107
|
updatedAt: now,
|
|
108
|
+
...effectiveRevision !== void 0 && { revision: effectiveRevision },
|
|
108
109
|
...executionDeadline !== void 0 && { executionDeadline }
|
|
109
110
|
}, operations = [
|
|
110
111
|
{
|
|
@@ -136,7 +137,7 @@ export async function startDelayedWorkflow(internals, entry, callbacks) {
|
|
|
136
137
|
internals.checkpoints.set(entry.workflowId, checkpoint);
|
|
137
138
|
internals.workflowVersionTuples.set(entry.workflowId, callbacks.workflowVersionTupleFromState(runningState));
|
|
138
139
|
callbacks.setWorkflowStartHeaders(entry.workflowId, await callbacks.loadWorkflowStartHeaders(entry.workflowId));
|
|
139
|
-
callbacks.beginWorkflowExecution(entry.workflowId, runningState.workflowExecutionToken, runningState.type, runningState.input, checkpoint, executionDeadline, runningState.executionStateOwnerId ?? entry.workflowId, registration);
|
|
140
|
+
callbacks.beginWorkflowExecution(entry.workflowId, runningState.workflowExecutionToken, runningState.type, runningState.revision, runningState.input, checkpoint, executionDeadline, runningState.executionStateOwnerId ?? entry.workflowId, registration);
|
|
140
141
|
}
|
|
141
142
|
async function loadDelayedWorkflowCheckpoint(internals, entry, callbacks) {
|
|
142
143
|
const checkpointBytes = await internals.storage.get(KEYS.checkpoint(entry.workflowId));
|
|
@@ -146,21 +147,22 @@ async function loadDelayedWorkflowCheckpoint(internals, entry, callbacks) {
|
|
|
146
147
|
}
|
|
147
148
|
return deserializeCheckpoint(checkpointBytes);
|
|
148
149
|
}
|
|
149
|
-
async function resolveDelayedExecutionDeadline(entry, now, callbacks) {
|
|
150
|
+
async function resolveDelayedExecutionDeadline(internals, entry, now, callbacks) {
|
|
150
151
|
if (entry.executionTimeoutMs === void 0)
|
|
151
152
|
return;
|
|
152
153
|
if (!Number.isFinite(entry.executionTimeoutMs) || entry.executionTimeoutMs < 0) {
|
|
153
|
-
await failInvalidDelayedExecutionTimeout(entry, callbacks);
|
|
154
|
+
await failInvalidDelayedExecutionTimeout(internals, entry, callbacks);
|
|
154
155
|
return "invalid";
|
|
155
156
|
}
|
|
156
157
|
try {
|
|
157
158
|
return normalizeStorageTimestamp(now + entry.executionTimeoutMs, `Delayed execution timeout for workflow "${entry.workflowId}"`);
|
|
158
159
|
} catch {
|
|
159
|
-
await failInvalidDelayedExecutionTimeout(entry, callbacks);
|
|
160
|
+
await failInvalidDelayedExecutionTimeout(internals, entry, callbacks);
|
|
160
161
|
return "invalid";
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
async function failInvalidDelayedExecutionTimeout(entry, callbacks) {
|
|
164
|
+
async function failInvalidDelayedExecutionTimeout(internals, entry, callbacks) {
|
|
165
|
+
await ensureDelayedStartClaimAndCleanupBeforeFailure(internals, entry.workflowId);
|
|
164
166
|
await callbacks.failWorkflow(entry.workflowId, Error(`Invalid delayed execution timeout for workflow "${entry.workflowId}"`));
|
|
165
167
|
}
|
|
166
168
|
export async function handleTimerFired(internals, entry, callbacks) {
|
|
@@ -85,7 +85,7 @@ export type WorkflowLeaseOwnershipBootstrapOptions = {
|
|
|
85
85
|
* doc for why an engine that cannot execute a candidate's registered type
|
|
86
86
|
* must never win its claim in the first place.
|
|
87
87
|
*/
|
|
88
|
-
isWorkflowTypeRegistered?: (workflowType: string) => boolean;
|
|
88
|
+
isWorkflowTypeRegistered?: (workflowType: string, revision: string | undefined) => boolean;
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* Everything `Engine` needs to hold on `EngineInternals` once bootstrap
|