@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors raised by the dynamic workflow source pipeline (WFT-15/16):
|
|
3
|
+
* {@link DynamicWorkflowSourceUnavailableError} at an execution entry point
|
|
4
|
+
* — `start`, `startOrSignal`, `schedule`, `fork`, `resume`, recovery, and
|
|
5
|
+
* bulk-retry — when a registered source's revision is ambiguous or its
|
|
6
|
+
* load fails; {@link WorkflowSourceNotRegisteredError} by
|
|
7
|
+
* `engine.resolveWorkflowSource()` / `engine.workflows.preload()` directly.
|
|
8
|
+
* Split out of `errors.ts`, which is at the repository's 500-line
|
|
9
|
+
* implementation-file ceiling with no headroom for two more documented
|
|
10
|
+
* classes; kept alongside `lease-errors.ts` and `source/errors.ts` as this
|
|
11
|
+
* file family's precedent for a domain-scoped errors module.
|
|
12
|
+
*
|
|
13
|
+
* @module core/engine/dynamic-source-errors
|
|
14
|
+
*/
|
|
15
|
+
import { WeftError } from '../weft-error.ts';
|
|
16
|
+
/**
|
|
17
|
+
* Thrown by `engine.resolveWorkflowSource()` (and its
|
|
18
|
+
* `engine.workflows.preload()` alias) when called against a specific
|
|
19
|
+
* `(name, revision)` that `registerSource()` never recorded — a
|
|
20
|
+
* programmer-error contract, not untrusted-input rejection. `revision` is
|
|
21
|
+
* therefore always defined in practice.
|
|
22
|
+
*
|
|
23
|
+
* This is a DIFFERENT case from a workflow `type` with no eager
|
|
24
|
+
* registration AND no dynamic source at all: every execution entry point
|
|
25
|
+
* (`start`, `startOrSignal`, `schedule`, `fork`, `resume`, recovery,
|
|
26
|
+
* bulk-retry) keeps throwing the pre-existing
|
|
27
|
+
* {@link WorkflowNotRegisteredError} for that case instead, preserving the
|
|
28
|
+
* fault classification and wire code callers already depended on before
|
|
29
|
+
* WFT-15/16 — see `dynamic-source-execution.ts`'s
|
|
30
|
+
* `resolveExecutableRegistration()`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { Engine, WorkflowSourceNotRegisteredError } from '@lostgradient/weft';
|
|
35
|
+
*
|
|
36
|
+
* const engine = new Engine();
|
|
37
|
+
* try {
|
|
38
|
+
* await engine.resolveWorkflowSource('checkout', 'r-never-registered');
|
|
39
|
+
* } catch (err) {
|
|
40
|
+
* if (err instanceof WorkflowSourceNotRegisteredError) {
|
|
41
|
+
* console.error('registerSource() it first:', err.workflowType, err.revision);
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class WorkflowSourceNotRegisteredError extends WeftError<'WorkflowSourceNotRegisteredError'> {
|
|
47
|
+
readonly workflowType: string;
|
|
48
|
+
readonly revision: string | undefined;
|
|
49
|
+
constructor(workflowType: string, revision?: string);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when a registered dynamic workflow source cannot be turned into an
|
|
53
|
+
* executable registration: either its load failed (`reason: 'load-failed'`,
|
|
54
|
+
* `cause` carries the underlying error) or which revision to resolve could
|
|
55
|
+
* not be determined (`reason: 'ambiguous-revision'` — two or more revisions
|
|
56
|
+
* are registered for `workflowType` and the catalog has no active pointer
|
|
57
|
+
* naming one of them). Recovery classifies the affected type `unavailable`:
|
|
58
|
+
* only its runs fail, with this error as the `system` failure cause;
|
|
59
|
+
* sibling types continue.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { Engine, DynamicWorkflowSourceUnavailableError } from '@lostgradient/weft';
|
|
64
|
+
*
|
|
65
|
+
* const engine = new Engine();
|
|
66
|
+
* try {
|
|
67
|
+
* await engine.start('checkout', { orderId: 'order-1' });
|
|
68
|
+
* } catch (err) {
|
|
69
|
+
* if (err instanceof DynamicWorkflowSourceUnavailableError) {
|
|
70
|
+
* console.error(err.workflowType, err.reason);
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare class DynamicWorkflowSourceUnavailableError extends WeftError<'DynamicWorkflowSourceUnavailableError'> {
|
|
76
|
+
readonly workflowType: string;
|
|
77
|
+
readonly revision: string | undefined;
|
|
78
|
+
readonly reason: 'load-failed' | 'ambiguous-revision';
|
|
79
|
+
readonly cause: unknown;
|
|
80
|
+
constructor(workflowType: string, revision: string | undefined, reason: 'load-failed' | 'ambiguous-revision', cause?: unknown);
|
|
81
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WeftError } from "../weft-error.js";
|
|
2
|
+
|
|
3
|
+
export class WorkflowSourceNotRegisteredError extends WeftError {
|
|
4
|
+
workflowType;
|
|
5
|
+
revision;
|
|
6
|
+
constructor(workflowType, revision) {
|
|
7
|
+
super("WorkflowSourceNotRegisteredError", revision === void 0 ? `No workflow registered with name "${workflowType}"` : `resolveWorkflowSource("${workflowType}", "${revision}") was called before registerSource() ` + "registered this exact (name, revision) \u2014 call engine.registerSource() first.");
|
|
8
|
+
this.workflowType = workflowType;
|
|
9
|
+
this.revision = revision;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class DynamicWorkflowSourceUnavailableError extends WeftError {
|
|
14
|
+
workflowType;
|
|
15
|
+
revision;
|
|
16
|
+
reason;
|
|
17
|
+
cause;
|
|
18
|
+
constructor(workflowType, revision, reason, cause) {
|
|
19
|
+
super("DynamicWorkflowSourceUnavailableError", reason === "ambiguous-revision" ? `Cannot resolve dynamic workflow source "${workflowType}": multiple revisions are registered and none is the catalog active revision. Activate one via engine.workflows.activate(), or register only one revision at a time.` : `Dynamic workflow source "${workflowType}"${revision === void 0 ? "" : ` revision "${revision}"`} failed to load: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
20
|
+
this.workflowType = workflowType;
|
|
21
|
+
this.revision = revision;
|
|
22
|
+
this.reason = reason;
|
|
23
|
+
this.cause = cause;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveExecutableRegistration()` — the single async helper every
|
|
3
|
+
* execution entry point that can launch or resume a workflow
|
|
4
|
+
* (`start`/`startOrSignal`/`schedule`/`fork`/`resume`/recovery/bulk-retry)
|
|
5
|
+
* funnels through to turn a workflow `type` into a `RegistrationEntry` it
|
|
6
|
+
* can actually run (WFT-15/16).
|
|
7
|
+
*
|
|
8
|
+
* Fast path: an eagerly `engine.register()`-ed type resolves synchronously
|
|
9
|
+
* from `internals.registrations` and never touches `internals.sources` —
|
|
10
|
+
* this is what makes "starting the eager workflow does not import the lazy
|
|
11
|
+
* module" true. Slow path: a `engine.registerSource()`-registered type is
|
|
12
|
+
* resolved via `resolveWorkflowSourceForExecution()`, which awaits the
|
|
13
|
+
* loader (single-flight, shared with any other concurrent caller for the
|
|
14
|
+
* same key) and installs the result durably before this returns — so no
|
|
15
|
+
* workflow handler ever runs while its definition is still a catalog
|
|
16
|
+
* candidate.
|
|
17
|
+
*
|
|
18
|
+
* @module core/engine/dynamic-source-execution
|
|
19
|
+
*/
|
|
20
|
+
import type { Engine } from './index.ts';
|
|
21
|
+
import type { EngineInternals } from './internals.ts';
|
|
22
|
+
type RegistrationEntry = EngineInternals['registrations'] extends Map<string, infer Entry> ? Entry : never;
|
|
23
|
+
/** The outcome of {@link resolveExecutableRegistration}. */
|
|
24
|
+
export type ExecutableRegistration = {
|
|
25
|
+
entry: RegistrationEntry;
|
|
26
|
+
/** The dynamic source revision resolved, or `undefined` for an eager registration. */
|
|
27
|
+
revision: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Turn workflow `type` into an executable {@link RegistrationEntry}, awaiting
|
|
31
|
+
* dynamic-source resolution when `type` is not eagerly registered. Throws
|
|
32
|
+
* {@link WorkflowNotRegisteredError} when `type` is neither an eager
|
|
33
|
+
* registration nor a registered source (the pre-existing error — see the
|
|
34
|
+
* call site below for why); {@link DynamicWorkflowSourceUnavailableError}
|
|
35
|
+
* when a registered source's target revision is ambiguous or its load
|
|
36
|
+
* fails; {@link EngineDisposedError} unwrapped when the engine is disposed
|
|
37
|
+
* during resolution.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveExecutableRegistration(engine: Engine, internals: EngineInternals, type: string, onRevisionChosen?: (revision: string) => void): Promise<ExecutableRegistration>;
|
|
40
|
+
/**
|
|
41
|
+
* The shared classification `resolveExecutableRegistrationForRevision()`'s
|
|
42
|
+
* throw-vs-proceed decision and the ADR-0002 workflow-lease reclaim-
|
|
43
|
+
* eligibility gate (`index.ts`'s `isWorkflowTypeRegistered`) both delegate
|
|
44
|
+
* to, so the two decisions can never drift out of sync — an engine that
|
|
45
|
+
* cannot locally resolve a run's exact pin must never win that run's claim
|
|
46
|
+
* either (see `workflow-claim-reclaim-target.ts`'s own doc for why that
|
|
47
|
+
* would strand the run under a permanently-failing `onReclaimed` drive).
|
|
48
|
+
*
|
|
49
|
+
* - An eager registration is always resolvable, regardless of `revision`
|
|
50
|
+
* (eager has no ambiguity to pin against).
|
|
51
|
+
* - `type` with no eager registration and no registered source at all is
|
|
52
|
+
* never resolvable.
|
|
53
|
+
* - A dynamic source with `revision === undefined` (legacy/pre-pinning) is
|
|
54
|
+
* resolvable only when it has exactly one registered candidate —
|
|
55
|
+
* unambiguous by construction. Two or more is ambiguous; zero is
|
|
56
|
+
* impossible (an empty `byRevision` map does not exist — the type
|
|
57
|
+
* wouldn't be in `sources.byName` at all).
|
|
58
|
+
* - A dynamic source with a defined `revision` is resolvable exactly when
|
|
59
|
+
* that revision is among this process's currently registered candidates.
|
|
60
|
+
*/
|
|
61
|
+
export declare function canResolveRevisionLocally(internals: EngineInternals, type: string, revision: string | undefined): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Resolve workflow `type` against its EXACT pinned `revision` — the
|
|
64
|
+
* `WorkflowState.revision` a run persisted at start (WFT-17) — instead of
|
|
65
|
+
* whichever revision the catalog currently considers active. This is the
|
|
66
|
+
* resolver `resumeWorkflowFromStorage()` (`lifecycle/resume.ts`) uses for
|
|
67
|
+
* EVERY resume (both `recoverAll()`'s batch and a standalone
|
|
68
|
+
* `engine.resume(id)`), so "recovery never falls back from a missing exact
|
|
69
|
+
* revision to the active revision" (WFT-17/WFT-18's acceptance criterion)
|
|
70
|
+
* holds uniformly, not just inside the batch preflight.
|
|
71
|
+
*
|
|
72
|
+
* Classification:
|
|
73
|
+
* - An eager registration is always resolved from `internals.registrations`
|
|
74
|
+
* regardless of `revision` — eager has no ambiguity to pin against (the
|
|
75
|
+
* process runs whatever code it has loaded), so a stale or absent pin on
|
|
76
|
+
* an eager type is harmless and must not block the common redeploy path.
|
|
77
|
+
* - A dynamic source with `revision === undefined` (a legacy, pre-pinning
|
|
78
|
+
* record) falls through to the ordinary {@link resolveExecutableRegistration}
|
|
79
|
+
* active-pointer resolution when the type has at most one registered
|
|
80
|
+
* candidate (unambiguous by construction), or throws
|
|
81
|
+
* {@link WorkflowRevisionUnavailableError} with `reason: 'legacy-ambiguous'`
|
|
82
|
+
* when it has two or more (there is no way to tell which one the run
|
|
83
|
+
* actually started against).
|
|
84
|
+
* - A dynamic source with a defined `revision` throws
|
|
85
|
+
* {@link WorkflowRevisionUnavailableError} with `reason: 'not-registered'`
|
|
86
|
+
* when that exact revision is not among this process's registered
|
|
87
|
+
* candidates (covers both "never registered at all" and "was the sole
|
|
88
|
+
* candidate, but a different one is registered now") — otherwise it is
|
|
89
|
+
* loaded and installed exactly like {@link resolveExecutableRegistration}'s
|
|
90
|
+
* own dynamic path.
|
|
91
|
+
* - `type` with neither an eager registration nor any registered source
|
|
92
|
+
* throws the pre-existing {@link WorkflowNotRegisteredError}, matching
|
|
93
|
+
* {@link resolveExecutableRegistration}.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveExecutableRegistrationForRevision(engine: Engine, internals: EngineInternals, type: string, revision: string | undefined): Promise<ExecutableRegistration>;
|
|
96
|
+
/**
|
|
97
|
+
* Wraps `callbacks.resolveExecutableRegistration(type)`, remapping ONLY the
|
|
98
|
+
* "no source registered at all" case (a {@link WorkflowNotRegisteredError})
|
|
99
|
+
* to `notFoundError` — a caller's own, more-specific "no workflow
|
|
100
|
+
* registered" message (naming the workflow ID it was
|
|
101
|
+
* resuming/forking/retrying, for example) instead of the generic one. Every
|
|
102
|
+
* other error (including a source found but unresolvable) propagates
|
|
103
|
+
* unwrapped. Shared by `resume.ts`, `transition.ts`'s `fork()`, and
|
|
104
|
+
* `bulk-operations.ts`'s retry path so each keeps a single, low-complexity
|
|
105
|
+
* call site instead of its own try/catch.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveExecutableRegistrationOrRenamedNotFound(resolve: (type: string) => Promise<ExecutableRegistration>, type: string, notFoundError: () => Error): Promise<ExecutableRegistration>;
|
|
108
|
+
/**
|
|
109
|
+
* {@link resolveExecutableRegistrationOrRenamedNotFound}, pre-bound to
|
|
110
|
+
* `bulk-operations.ts`'s retry-failed message shape. Resolves against the
|
|
111
|
+
* failed run's own EXACT pinned `revision` (`WorkflowState.revision`, WFT-17)
|
|
112
|
+
* via {@link resolveExecutableRegistrationForRevision} — never the catalog's
|
|
113
|
+
* active pointer — so a bulk retry's pre-reactivation concurrency-admission
|
|
114
|
+
* lookup agrees with the exact-revision resolve the subsequent
|
|
115
|
+
* `engine.resume()` performs. Resolving against the active pointer here
|
|
116
|
+
* instead would let a retry commit the failed->running reactivation batch
|
|
117
|
+
* against the WRONG registration's `concurrency` config, and then — if the
|
|
118
|
+
* pinned revision is unavailable while a different revision is active —
|
|
119
|
+
* only discover that after the reactivation already committed, leaving the
|
|
120
|
+
* run stranded `running` with no generator ever resuming. Kept here (with
|
|
121
|
+
* the bulk of the logic off `bulk-operations.ts`, already at its own
|
|
122
|
+
* oxlint `max-lines` ceiling) rather than inlined at that one call site.
|
|
123
|
+
*/
|
|
124
|
+
export declare function resolveExecutableRegistrationForRetry(internals: EngineInternals, type: string, revision: string | undefined, workflowId: string): Promise<ExecutableRegistration>;
|
|
125
|
+
/**
|
|
126
|
+
* Sync-only fallback lookup for PER-INSTANCE call sites that run after a
|
|
127
|
+
* workflow is already executing (or is being swept from storage) and must
|
|
128
|
+
* never trigger a new resolve — finalizer, constraint, retention, and
|
|
129
|
+
* search-attribute-schema resolution (`termination/finalizer-registration.ts`,
|
|
130
|
+
* `constraints.ts`, `workflow-retention-deadline.ts`, `listing.ts`). Reads
|
|
131
|
+
* the eager registration first (an eager type resolves the same regardless
|
|
132
|
+
* of `revision` — see {@link canResolveRevisionLocally}'s doc). Otherwise:
|
|
133
|
+
*
|
|
134
|
+
* - A defined `revision` reads `internals.sources.resolved.get(type)?.get(revision)`
|
|
135
|
+
* directly — the running instance's OWN exact pin — with NO fallback to a
|
|
136
|
+
* different revision when that exact one is not locally resolved (returns
|
|
137
|
+
* `undefined` instead, matching {@link resolveExecutableRegistrationForRevision}'s
|
|
138
|
+
* "never silently substitute a different revision" contract).
|
|
139
|
+
* - `revision === undefined` (a legacy pre-pinning record) falls back to
|
|
140
|
+
* `internals.sources.lastResolvedRevisionByName` ONLY when
|
|
141
|
+
* {@link canResolveRevisionLocally} classifies that as unambiguous —
|
|
142
|
+
* exactly one registered candidate for `type`. With two or more
|
|
143
|
+
* registered candidates this is genuinely ambiguous for a SPECIFIC
|
|
144
|
+
* instance (WFT-19 review round 6, Codex, P1): silently substituting
|
|
145
|
+
* whichever sibling revision this process last resolved could validate
|
|
146
|
+
* `setAttributes()` against a sibling's schema, run a sibling's
|
|
147
|
+
* finalizer, or — worst, since purge is irreversible — purge a run early
|
|
148
|
+
* under a sibling's shorter retention window. Returns `undefined` in that
|
|
149
|
+
* case instead, forcing the caller's async fallback
|
|
150
|
+
* (`resolveExecutableRegistrationForRevision()`) to reach the
|
|
151
|
+
* `legacy-ambiguous` classification and fail closed the same way it
|
|
152
|
+
* already does for resume/recovery. {@link resolveLastKnownDynamicRegistration}
|
|
153
|
+
* is the deliberate exception for the one genuinely TYPE-level caller
|
|
154
|
+
* that wants the permissive last-resolved-wins answer even when
|
|
155
|
+
* ambiguous.
|
|
156
|
+
*
|
|
157
|
+
* Returns `undefined` when no source has a matching entry.
|
|
158
|
+
*/
|
|
159
|
+
export declare function getResolvedDynamicRegistration(internals: EngineInternals, type: string, revision: string | undefined): RegistrationEntry | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* TYPE-level, sync-only "whatever this process last resolved" lookup —
|
|
162
|
+
* used ONLY by `retention.ts`'s `resolveWorkflowTypeRetention()`, an
|
|
163
|
+
* across-all-registered-types OVERVIEW API (`getRetentionOverview()`) with
|
|
164
|
+
* no single running instance to pin against, unlike every caller of
|
|
165
|
+
* {@link getResolvedDynamicRegistration} above. Deliberately does NOT fail
|
|
166
|
+
* closed when 2+ candidates are registered for `type`: for an overview,
|
|
167
|
+
* showing the last-resolved candidate's policy is a more useful signal
|
|
168
|
+
* than showing nothing, and — unlike `getResolvedDynamicRegistration`'s
|
|
169
|
+
* per-instance callers — no irreversible action (purge, finalizer run,
|
|
170
|
+
* schema validation) hangs off this call (WFT-19 review round 6, Codex).
|
|
171
|
+
*/
|
|
172
|
+
export declare function resolveLastKnownDynamicRegistration(internals: EngineInternals, type: string): RegistrationEntry | undefined;
|
|
173
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ensureWorkflowCatalogReady, getWorkflowCatalog } from "./catalog-readiness.js";
|
|
2
|
+
import { DynamicWorkflowSourceUnavailableError } from "./dynamic-source-errors.js";
|
|
3
|
+
import { EngineDisposedError, WorkflowNotRegisteredError } from "./errors.js";
|
|
4
|
+
import { assertConstraintsSupported, buildRegistrationEntry } from "./registration.js";
|
|
5
|
+
import { WorkflowRevisionUnavailableError } from "./revision-errors.js";
|
|
6
|
+
import { resolveWorkflowSourceForExecution } from "./source-resolution.js";
|
|
7
|
+
async function resolveActiveSourceRevision(engine, type, byRevision) {
|
|
8
|
+
await ensureWorkflowCatalogReady(engine);
|
|
9
|
+
const activeRevision = (await getWorkflowCatalog(engine).resolveActiveDurable(type))?.revision;
|
|
10
|
+
if (activeRevision !== void 0 && byRevision.has(activeRevision))
|
|
11
|
+
return activeRevision;
|
|
12
|
+
throw new DynamicWorkflowSourceUnavailableError(type, void 0, "ambiguous-revision");
|
|
13
|
+
}
|
|
14
|
+
export async function resolveExecutableRegistration(engine, internals, type, onRevisionChosen) {
|
|
15
|
+
const eager = internals.registrations.get(type);
|
|
16
|
+
if (eager !== void 0)
|
|
17
|
+
return { entry: eager, revision: void 0 };
|
|
18
|
+
const byRevision = internals.sources.byName.get(type);
|
|
19
|
+
if (byRevision === void 0)
|
|
20
|
+
throw new WorkflowNotRegisteredError(type);
|
|
21
|
+
let revision;
|
|
22
|
+
if (byRevision.size === 1) {
|
|
23
|
+
revision = [...byRevision.keys()][0];
|
|
24
|
+
onRevisionChosen?.(revision);
|
|
25
|
+
} else {
|
|
26
|
+
revision = await resolveActiveSourceRevision(engine, type, byRevision);
|
|
27
|
+
onRevisionChosen?.(revision);
|
|
28
|
+
}
|
|
29
|
+
return loadAndInstallSourceRevision(engine, internals, type, revision);
|
|
30
|
+
}
|
|
31
|
+
async function loadAndInstallSourceRevision(engine, internals, type, revision) {
|
|
32
|
+
try {
|
|
33
|
+
await resolveWorkflowSourceForExecution(engine, type, revision);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof EngineDisposedError)
|
|
36
|
+
throw error;
|
|
37
|
+
throw new DynamicWorkflowSourceUnavailableError(type, revision, "load-failed", error);
|
|
38
|
+
}
|
|
39
|
+
const resolved = internals.sources.resolved.get(type)?.get(revision);
|
|
40
|
+
if (resolved === void 0)
|
|
41
|
+
throw new DynamicWorkflowSourceUnavailableError(type, revision, "load-failed", Error("Dynamic workflow source resolved without populating a local definition"));
|
|
42
|
+
assertConstraintsSupported(internals, type, resolved.definition);
|
|
43
|
+
const entry = buildRegistrationEntry(type, resolved.definition);
|
|
44
|
+
internals.workflowTypesByHandler.set(resolved.definition.handler, type);
|
|
45
|
+
internals.sources.lastResolvedRevisionByName.set(type, revision);
|
|
46
|
+
return { entry, revision };
|
|
47
|
+
}
|
|
48
|
+
export function canResolveRevisionLocally(internals, type, revision) {
|
|
49
|
+
if (internals.registrations.has(type))
|
|
50
|
+
return !0;
|
|
51
|
+
const byRevision = internals.sources.byName.get(type);
|
|
52
|
+
if (byRevision === void 0)
|
|
53
|
+
return !1;
|
|
54
|
+
if (revision === void 0)
|
|
55
|
+
return byRevision.size === 1;
|
|
56
|
+
return byRevision.has(revision);
|
|
57
|
+
}
|
|
58
|
+
export async function resolveExecutableRegistrationForRevision(engine, internals, type, revision) {
|
|
59
|
+
const eager = internals.registrations.get(type);
|
|
60
|
+
if (eager !== void 0)
|
|
61
|
+
return { entry: eager, revision: void 0 };
|
|
62
|
+
if (internals.sources.byName.get(type) === void 0)
|
|
63
|
+
throw new WorkflowNotRegisteredError(type);
|
|
64
|
+
if (!canResolveRevisionLocally(internals, type, revision)) {
|
|
65
|
+
if (revision === void 0)
|
|
66
|
+
throw new WorkflowRevisionUnavailableError(type, void 0, "legacy-ambiguous");
|
|
67
|
+
throw new WorkflowRevisionUnavailableError(type, revision, "not-registered");
|
|
68
|
+
}
|
|
69
|
+
if (revision === void 0)
|
|
70
|
+
return resolveExecutableRegistration(engine, internals, type);
|
|
71
|
+
return loadAndInstallSourceRevision(engine, internals, type, revision);
|
|
72
|
+
}
|
|
73
|
+
export async function resolveExecutableRegistrationOrRenamedNotFound(resolve, type, notFoundError) {
|
|
74
|
+
return resolve(type).catch((error) => {
|
|
75
|
+
if (error instanceof WorkflowNotRegisteredError)
|
|
76
|
+
throw notFoundError();
|
|
77
|
+
throw error;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export async function resolveExecutableRegistrationForRetry(internals, type, revision, workflowId) {
|
|
81
|
+
return resolveExecutableRegistrationOrRenamedNotFound((t) => resolveExecutableRegistrationForRevision(internals.engine, internals, t, revision), type, () => Error(`No workflow registered with name "${type}" (needed to retry "${workflowId}")`));
|
|
82
|
+
}
|
|
83
|
+
export function getResolvedDynamicRegistration(internals, type, revision) {
|
|
84
|
+
const eager = internals.registrations.get(type);
|
|
85
|
+
if (eager !== void 0)
|
|
86
|
+
return eager;
|
|
87
|
+
if (revision !== void 0) {
|
|
88
|
+
const resolved = internals.sources.resolved.get(type)?.get(revision);
|
|
89
|
+
if (resolved === void 0)
|
|
90
|
+
return;
|
|
91
|
+
return buildRegistrationEntry(type, resolved.definition);
|
|
92
|
+
}
|
|
93
|
+
if (!canResolveRevisionLocally(internals, type, void 0))
|
|
94
|
+
return;
|
|
95
|
+
return resolveLastKnownDynamicRegistration(internals, type);
|
|
96
|
+
}
|
|
97
|
+
export function resolveLastKnownDynamicRegistration(internals, type) {
|
|
98
|
+
const eager = internals.registrations.get(type);
|
|
99
|
+
if (eager !== void 0)
|
|
100
|
+
return eager;
|
|
101
|
+
const targetRevision = internals.sources.lastResolvedRevisionByName.get(type);
|
|
102
|
+
if (targetRevision === void 0)
|
|
103
|
+
return;
|
|
104
|
+
const resolved = internals.sources.resolved.get(type)?.get(targetRevision);
|
|
105
|
+
if (resolved === void 0)
|
|
106
|
+
return;
|
|
107
|
+
return buildRegistrationEntry(type, resolved.definition);
|
|
108
|
+
}
|
|
@@ -3,6 +3,20 @@ import type { ConstraintDefinition } from '../constraint.ts';
|
|
|
3
3
|
import type { ExecutionStrategy } from '../execution-strategy.ts';
|
|
4
4
|
import type { InlineExecutionStrategy } from '../inline-execution-strategy.ts';
|
|
5
5
|
import type { AnyActivityDefinition, ArchiveAdapter, Checkpoint, DefinitionSchema, EngineOptions, NormalizedHistoryPolicy, NormalizedPayloadSizePolicy, NormalizedRetentionPolicy, QueryDefinition, SearchAttributeSchema, SignalDefinition, UpdateDefinition, WorkflowConcurrencyOptions, WorkflowFunction, WorkflowTimelineEntry } from '../types.ts';
|
|
6
|
+
/**
|
|
7
|
+
* The identity a running workflow instance was launched under, cached by
|
|
8
|
+
* `EngineInternals.workflowTypeByWorkflowId` for the lifetime of its
|
|
9
|
+
* execution (WFT-19). `revision` is the exact `WorkflowState.revision` this
|
|
10
|
+
* instance is pinned to (WFT-17) — `undefined` for an eager registration or
|
|
11
|
+
* a legacy (pre-pinning) record — so a process-local lookup keyed by
|
|
12
|
+
* `workflowId` can resolve THIS instance's own dynamic-source revision
|
|
13
|
+
* rather than falling back to whichever revision this process resolved
|
|
14
|
+
* last.
|
|
15
|
+
*/
|
|
16
|
+
export type WorkflowExecutionIdentity = {
|
|
17
|
+
type: string;
|
|
18
|
+
revision: string | undefined;
|
|
19
|
+
};
|
|
6
20
|
export interface RegistrationEntry {
|
|
7
21
|
handler: WorkflowFunction;
|
|
8
22
|
version: string;
|
|
@@ -103,6 +117,8 @@ export type QueuedInlineWorkflowExecutionStart = {
|
|
|
103
117
|
nestingDepth: number;
|
|
104
118
|
executionDeadline: number | undefined;
|
|
105
119
|
executionStateOwnerId: string;
|
|
120
|
+
/** The exact revision this queued start is pinned to (WFT-17/WFT-19). */
|
|
121
|
+
revision: string | undefined;
|
|
106
122
|
/**
|
|
107
123
|
* Liveness callback invoked once this queued start has actually begun
|
|
108
124
|
* executing (its generator has been driven). Set only for `defer: false`
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public promotion of the durable workflow catalog (WFT-9/WFT-10) to
|
|
3
|
+
* `engine.workflows` (WFT-11).
|
|
4
|
+
*
|
|
5
|
+
* This namespace is catalog bookkeeping and promotion control ONLY —
|
|
6
|
+
* `install()`/`activate()` change what {@link import('../registry-snapshot.ts').RegistrySnapshot}
|
|
7
|
+
* reports as the active revision, never which in-process handler
|
|
8
|
+
* `engine.start()` dispatches to. Execution routing resolves purely via
|
|
9
|
+
* `internals.registrations` (the workflow the process actually has code
|
|
10
|
+
* for), a concern dynamic module loading (WFT-13+) will connect to catalog
|
|
11
|
+
* activation. Until then, activating a different installed revision is
|
|
12
|
+
* observable only through this namespace, `getActive()`, and
|
|
13
|
+
* `buildRegistrySnapshot()` — starting a new run of `name` still executes
|
|
14
|
+
* whatever `engine.register()` last registered in this process.
|
|
15
|
+
*
|
|
16
|
+
* A later `engine.register()` call (or the restart-drain path that replays
|
|
17
|
+
* `pendingCatalogInstalls`) can silently revert a manual `activate()` here —
|
|
18
|
+
* `WorkflowCatalog.activateRegistered` is unconditional by design (see its
|
|
19
|
+
* own JSDoc) and does not consult or preserve a prior candidate activation.
|
|
20
|
+
* Reconciling loader-driven and registration-driven activation is WFT-13's
|
|
21
|
+
* job; this namespace does not attempt it.
|
|
22
|
+
*
|
|
23
|
+
* Every method awaits {@link ensureWorkflowCatalogReady} first (skipping the
|
|
24
|
+
* `await` entirely when {@link isWorkflowCatalogReady} already reports warm,
|
|
25
|
+
* matching every other catalog-observing entry point in `index.ts`), so the
|
|
26
|
+
* catalog is always restored from storage and every pending
|
|
27
|
+
* `engine.register()` install is drained before this namespace reads or
|
|
28
|
+
* writes it.
|
|
29
|
+
*
|
|
30
|
+
* @module core/engine/engine-workflows-namespace
|
|
31
|
+
*/
|
|
32
|
+
import { type WorkflowCatalogActivationResult, type WorkflowCatalogActivePointer, type WorkflowRevisionRecord } from '../catalog/index.ts';
|
|
33
|
+
import type { WorkflowCompatibilityPolicy } from '../contract/compatibility.ts';
|
|
34
|
+
import type { WorkflowRevisionManifest } from '../contract/types.ts';
|
|
35
|
+
import type { Engine } from './index.ts';
|
|
36
|
+
import { type ResolveWorkflowSourceOptions } from './source-resolution.ts';
|
|
37
|
+
/**
|
|
38
|
+
* Options accepted by {@link EngineWorkflowsNamespace.activate}.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { Engine } from '@lostgradient/weft';
|
|
43
|
+
* import type { ActivateWorkflowRevisionOptions } from '@lostgradient/weft';
|
|
44
|
+
*
|
|
45
|
+
* const engine = new Engine();
|
|
46
|
+
* const active = await engine.workflows.getActive('checkout');
|
|
47
|
+
* const options: ActivateWorkflowRevisionOptions = {
|
|
48
|
+
* ...(active === null ? {} : { expectedGeneration: active.generation }),
|
|
49
|
+
* policy: { requireExactRevision: false },
|
|
50
|
+
* };
|
|
51
|
+
* console.log(options.expectedGeneration);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export type ActivateWorkflowRevisionOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* The generation this caller last observed. Required once `name` has an
|
|
57
|
+
* active pointer — an omitted value there refuses with
|
|
58
|
+
* `expected-generation-required` rather than silently activating, which
|
|
59
|
+
* is what prevents two refreshers from racing to last-write-win. Omit (or
|
|
60
|
+
* pass `0`) for the very first activation of a name, which has no prior
|
|
61
|
+
* generation to name.
|
|
62
|
+
*/
|
|
63
|
+
expectedGeneration?: number;
|
|
64
|
+
/** Compatibility policy; defaults to `DEFAULT_WORKFLOW_COMPATIBILITY_POLICY`. */
|
|
65
|
+
policy?: WorkflowCompatibilityPolicy;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Admin-facing surface over the durable workflow catalog: install a
|
|
69
|
+
* revision's manifest, activate an installed revision as the advertised
|
|
70
|
+
* active one, and read back installed/active state. Workflow code never
|
|
71
|
+
* touches this — it is an external maintenance and deployment-tooling
|
|
72
|
+
* surface, the same audience `engine.state.*` serves.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { Engine, buildWorkflowContract, buildWorkflowRevisionManifest } from '@lostgradient/weft';
|
|
77
|
+
* import { workflow, type WorkflowContext } from '@lostgradient/weft';
|
|
78
|
+
* import type { EngineWorkflowsNamespace } from '@lostgradient/weft';
|
|
79
|
+
*
|
|
80
|
+
* const checkout = workflow({ name: 'checkout', version: '1.0.0' }).execute(
|
|
81
|
+
* async function* (_ctx: WorkflowContext, input: string) {
|
|
82
|
+
* return input;
|
|
83
|
+
* },
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* const engine = new Engine();
|
|
87
|
+
* engine.register(checkout);
|
|
88
|
+
* const workflows: EngineWorkflowsNamespace = engine.workflows;
|
|
89
|
+
*
|
|
90
|
+
* const contract = buildWorkflowContract({ name: 'checkout', version: '1.0.0' });
|
|
91
|
+
* const manifest = await buildWorkflowRevisionManifest(contract);
|
|
92
|
+
* const record = await workflows.install(manifest);
|
|
93
|
+
* const result = await workflows.activate('checkout', record.manifest.revision);
|
|
94
|
+
* console.log(result.applied);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export interface EngineWorkflowsNamespace {
|
|
98
|
+
/**
|
|
99
|
+
* Install `manifest` for durable tracking. Requires
|
|
100
|
+
* `engine.getWorkflowDefinition(manifest.name)` to already resolve
|
|
101
|
+
* in-process — this namespace installs bookkeeping for a definition the
|
|
102
|
+
* engine already has, it does not load one (that is WFT-13+'s job).
|
|
103
|
+
* Idempotent on a byte-identical reinstall; throws
|
|
104
|
+
* {@link WorkflowCatalogConflictError} when `(manifest.name, manifest.revision)`
|
|
105
|
+
* is already installed with different contract content, and
|
|
106
|
+
* {@link WorkflowNotRegisteredError} when no in-process definition exists.
|
|
107
|
+
*/
|
|
108
|
+
install(manifest: WorkflowRevisionManifest): Promise<WorkflowRevisionRecord>;
|
|
109
|
+
/**
|
|
110
|
+
* Activate an already-installed `(name, revision)` as the durably
|
|
111
|
+
* advertised active revision. Throws
|
|
112
|
+
* {@link WorkflowRevisionNotInstalledError} when that revision was never
|
|
113
|
+
* installed; otherwise delegates to the catalog's guarded
|
|
114
|
+
* `activateCandidate` and returns its structured result verbatim,
|
|
115
|
+
* including every `applied: false` refusal variant.
|
|
116
|
+
*/
|
|
117
|
+
activate(name: string, revision: string, options?: ActivateWorkflowRevisionOptions): Promise<WorkflowCatalogActivationResult>;
|
|
118
|
+
/**
|
|
119
|
+
* The current active pointer for `name`, or `null` when never activated.
|
|
120
|
+
* In-memory only, matching {@link import('../registry-snapshot.ts').RegistrySnapshot}'s
|
|
121
|
+
* `activeRevisions` staleness contract exactly — the property that makes
|
|
122
|
+
* "operations and the registry snapshot agree" true by construction.
|
|
123
|
+
*/
|
|
124
|
+
getActive(name: string): Promise<WorkflowCatalogActivePointer | null>;
|
|
125
|
+
/** One installed `(name, revision)` record, or `null` when not installed. */
|
|
126
|
+
getRevision(name: string, revision: string): Promise<WorkflowRevisionRecord | null>;
|
|
127
|
+
/** Every installed revision of `name`, sorted deterministically by revision. */
|
|
128
|
+
listRevisions(name: string): Promise<readonly WorkflowRevisionRecord[]>;
|
|
129
|
+
/**
|
|
130
|
+
* Load, validate, and install one dynamic workflow source revision
|
|
131
|
+
* previously recorded via `engine.registerSource()` (WFT-15/16). A thin,
|
|
132
|
+
* documented alias for `engine.resolveWorkflowSource()` — identical
|
|
133
|
+
* single-flight, cancellation, and error contract — offered here so
|
|
134
|
+
* deployment tooling that already reaches for `engine.workflows.*` for
|
|
135
|
+
* every other catalog operation does not need a second entry point.
|
|
136
|
+
*/
|
|
137
|
+
preload(name: string, revision: string, options?: ResolveWorkflowSourceOptions): Promise<WorkflowRevisionRecord>;
|
|
138
|
+
}
|
|
139
|
+
/** Build the `engine.workflows` namespace object for `engine`. */
|
|
140
|
+
export declare function createEngineWorkflowsNamespace(engine: Engine): EngineWorkflowsNamespace;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WorkflowRevisionNotInstalledError
|
|
3
|
+
} from "../catalog/index.js";
|
|
4
|
+
import { activateCatalogRevisionCandidate } from "./catalog-activation.js";
|
|
5
|
+
import {
|
|
6
|
+
ensureWorkflowCatalogReady,
|
|
7
|
+
getWorkflowCatalog,
|
|
8
|
+
isWorkflowCatalogReady
|
|
9
|
+
} from "./catalog-readiness.js";
|
|
10
|
+
import { WorkflowNotRegisteredError } from "./errors.js";
|
|
11
|
+
import { resolveWorkflowSource } from "./source-resolution.js";
|
|
12
|
+
async function ensureCatalogReady(engine) {
|
|
13
|
+
if (!isWorkflowCatalogReady(engine))
|
|
14
|
+
await ensureWorkflowCatalogReady(engine);
|
|
15
|
+
}
|
|
16
|
+
async function installWorkflowRevision(engine, manifest) {
|
|
17
|
+
await ensureCatalogReady(engine);
|
|
18
|
+
if (engine.getWorkflowDefinition(manifest.name) === void 0)
|
|
19
|
+
throw new WorkflowNotRegisteredError(manifest.name);
|
|
20
|
+
const entry = await getWorkflowCatalog(engine).install(manifest);
|
|
21
|
+
return { manifest: entry.manifest, installedAt: entry.installedAt };
|
|
22
|
+
}
|
|
23
|
+
async function activateWorkflowRevision(engine, name, revision, options) {
|
|
24
|
+
await ensureCatalogReady(engine);
|
|
25
|
+
const entry = await getWorkflowCatalog(engine).resolveEntry(name, revision);
|
|
26
|
+
if (entry === void 0)
|
|
27
|
+
throw new WorkflowRevisionNotInstalledError(name, revision);
|
|
28
|
+
return activateCatalogRevisionCandidate(engine, name, entry.manifest, options);
|
|
29
|
+
}
|
|
30
|
+
async function getActiveWorkflowRevision(engine, name) {
|
|
31
|
+
await ensureCatalogReady(engine);
|
|
32
|
+
return getWorkflowCatalog(engine).resolveActive(name) ?? null;
|
|
33
|
+
}
|
|
34
|
+
async function getInstalledWorkflowRevision(engine, name, revision) {
|
|
35
|
+
await ensureCatalogReady(engine);
|
|
36
|
+
return await getWorkflowCatalog(engine).resolveEntry(name, revision) ?? null;
|
|
37
|
+
}
|
|
38
|
+
async function listInstalledWorkflowRevisions(engine, name) {
|
|
39
|
+
await ensureCatalogReady(engine);
|
|
40
|
+
return getWorkflowCatalog(engine).listInstalledRevisions(name);
|
|
41
|
+
}
|
|
42
|
+
export function createEngineWorkflowsNamespace(engine) {
|
|
43
|
+
return {
|
|
44
|
+
install: (manifest) => installWorkflowRevision(engine, manifest),
|
|
45
|
+
activate: (name, revision, options) => activateWorkflowRevision(engine, name, revision, options),
|
|
46
|
+
getActive: (name) => getActiveWorkflowRevision(engine, name),
|
|
47
|
+
getRevision: (name, revision) => getInstalledWorkflowRevision(engine, name, revision),
|
|
48
|
+
listRevisions: (name) => listInstalledWorkflowRevisions(engine, name),
|
|
49
|
+
preload: (name, revision, options) => resolveWorkflowSource(engine, name, revision, options)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project a registration's stored definition-level finalizer onto the
|
|
3
|
+
* public, schema-only shape {@link RegisteredWorkflowDefinition.finalizer}
|
|
4
|
+
* exposes — split out of `construction.ts` so `copyWorkflowDefinition` stays
|
|
5
|
+
* under the repository's per-function complexity ceiling.
|
|
6
|
+
*
|
|
7
|
+
* @module core/engine/finalizer-metadata
|
|
8
|
+
*/
|
|
9
|
+
import type { AnyActivityDefinition } from '../types.ts';
|
|
10
|
+
import type { RegisteredWorkflowDefinition } from '../types/workflow-registry.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Convert a stored `RegistrationEntry.finalizer` (when present) to a
|
|
13
|
+
* directly spreadable `{ finalizer: {...} } | {}` carrying the narrower
|
|
14
|
+
* schema-only shape `RegisteredWorkflowDefinition.finalizer` exposes — never
|
|
15
|
+
* the finalizer's `execute` handler, matching this interface's read-only
|
|
16
|
+
* introspection contract (the workflow's own handler is likewise never
|
|
17
|
+
* exposed). Returning the already-branched spread target (rather than
|
|
18
|
+
* `finalizer | undefined`, which would push a `=== undefined` ternary back
|
|
19
|
+
* onto the caller) keeps `copyWorkflowDefinition` under the repository's
|
|
20
|
+
* per-function complexity ceiling.
|
|
21
|
+
*/
|
|
22
|
+
export declare function copyFinalizerMetadata(finalizer: AnyActivityDefinition | undefined): Partial<Pick<RegisteredWorkflowDefinition, 'finalizer'>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function copyFinalizerMetadata(finalizer) {
|
|
2
|
+
if (finalizer === void 0)
|
|
3
|
+
return {};
|
|
4
|
+
const source = finalizer;
|
|
5
|
+
return {
|
|
6
|
+
finalizer: {
|
|
7
|
+
name: source.name,
|
|
8
|
+
...source.inputSchema === void 0 ? {} : { inputSchema: source.inputSchema },
|
|
9
|
+
...source.outputSchema === void 0 ? {} : { outputSchema: source.outputSchema }
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -34,9 +34,11 @@ function fenceResultOnParentGeneration(internals, parentWorkflowId, promise) {
|
|
|
34
34
|
promise.then(async (value) => {
|
|
35
35
|
if (await parentStillOwnsGeneration(internals, parentWorkflowId))
|
|
36
36
|
gate.resolve(value);
|
|
37
|
+
return;
|
|
37
38
|
}, async (error) => {
|
|
38
39
|
if (await parentStillOwnsGeneration(internals, parentWorkflowId))
|
|
39
40
|
gate.reject(error);
|
|
41
|
+
return;
|
|
40
42
|
});
|
|
41
43
|
return gate.promise;
|
|
42
44
|
}
|