@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,117 @@
|
|
|
1
|
+
import type { WorkflowCompatibilityReason } from '../contract/compatibility.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Fired on the {@link Engine} when a `(name, revision)` is durably installed
|
|
4
|
+
* into the workflow catalog for the first time. Never fired for a
|
|
5
|
+
* byte-identical reinstall of an already-installed revision. Read
|
|
6
|
+
* `e.workflowType` and `e.revision` directly off the event.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Engine, WorkflowRevisionInstalledEvent, workflow } from '@lostgradient/weft';
|
|
11
|
+
*
|
|
12
|
+
* const engine = new Engine();
|
|
13
|
+
* engine.addEventListener(WorkflowRevisionInstalledEvent.type, (event) => {
|
|
14
|
+
* console.log('installed:', event.workflowType, event.revision);
|
|
15
|
+
* });
|
|
16
|
+
* engine.register(workflow({ name: 'ping' }).execute(async function* () { return 'pong'; }));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class WorkflowRevisionInstalledEvent extends Event {
|
|
20
|
+
static readonly type: "catalog:revision-installed";
|
|
21
|
+
readonly workflowType: string;
|
|
22
|
+
readonly revision: string;
|
|
23
|
+
constructor(workflowType: string, revision: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fired on the {@link Engine} when a `(name, revision)` becomes the active
|
|
27
|
+
* revision for its name — bumping the catalog's per-name `generation`
|
|
28
|
+
* counter. `previousRevision` is `undefined` on a name's first-ever
|
|
29
|
+
* activation, and set to the revision this activation replaced otherwise.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { Engine, WorkflowRevisionActivatedEvent, workflow } from '@lostgradient/weft';
|
|
34
|
+
*
|
|
35
|
+
* const engine = new Engine();
|
|
36
|
+
* engine.addEventListener(WorkflowRevisionActivatedEvent.type, (event) => {
|
|
37
|
+
* console.log('activated:', event.workflowType, event.revision, 'gen', event.generation);
|
|
38
|
+
* });
|
|
39
|
+
* engine.register(workflow({ name: 'ping' }).execute(async function* () { return 'pong'; }));
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class WorkflowRevisionActivatedEvent extends Event {
|
|
43
|
+
static readonly type: "catalog:revision-activated";
|
|
44
|
+
readonly workflowType: string;
|
|
45
|
+
readonly revision: string;
|
|
46
|
+
readonly generation: number;
|
|
47
|
+
readonly previousRevision: string | undefined;
|
|
48
|
+
constructor(workflowType: string, revision: string, generation: number, previousRevision: string | undefined);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fired on the {@link Engine} when a candidate activation
|
|
52
|
+
* (`activateCatalogRevisionCandidate`, the guarded primitive) is refused.
|
|
53
|
+
* `reason` is a closed, low-cardinality union safe to use as a metric label;
|
|
54
|
+
* `incompatibilityReasons` is populated only when `reason === 'incompatible'`,
|
|
55
|
+
* carrying every applicable {@link WorkflowCompatibilityReason} — never the
|
|
56
|
+
* full compatibility verdict object.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { Engine, WorkflowRevisionActivationRejectedEvent } from '@lostgradient/weft';
|
|
61
|
+
*
|
|
62
|
+
* const engine = new Engine();
|
|
63
|
+
* engine.addEventListener(WorkflowRevisionActivationRejectedEvent.type, (event) => {
|
|
64
|
+
* console.log('rejected:', event.workflowType, event.candidateRevision, event.reason);
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare class WorkflowRevisionActivationRejectedEvent extends Event {
|
|
69
|
+
static readonly type: "catalog:activation-rejected";
|
|
70
|
+
readonly workflowType: string;
|
|
71
|
+
readonly candidateRevision: string;
|
|
72
|
+
readonly reason: 'incompatible' | 'stale-generation' | 'conflict' | 'expected-generation-required';
|
|
73
|
+
readonly incompatibilityReasons: readonly WorkflowCompatibilityReason[] | undefined;
|
|
74
|
+
constructor(workflowType: string, candidateRevision: string, reason: 'incompatible' | 'stale-generation' | 'conflict' | 'expected-generation-required', incompatibilityReasons?: readonly WorkflowCompatibilityReason[]);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fired on the {@link Engine} alongside {@link WorkflowRevisionActivatedEvent}
|
|
78
|
+
* when activating a new revision displaces a previously active one for the
|
|
79
|
+
* same name. Never fired on a name's first-ever activation (there is
|
|
80
|
+
* nothing to drain).
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { Engine, WorkflowRevisionDrainingEvent } from '@lostgradient/weft';
|
|
85
|
+
*
|
|
86
|
+
* const engine = new Engine();
|
|
87
|
+
* engine.addEventListener(WorkflowRevisionDrainingEvent.type, (event) => {
|
|
88
|
+
* console.log('draining:', event.workflowType, event.revision);
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare class WorkflowRevisionDrainingEvent extends Event {
|
|
93
|
+
static readonly type: "catalog:revision-draining";
|
|
94
|
+
readonly workflowType: string;
|
|
95
|
+
readonly revision: string;
|
|
96
|
+
constructor(workflowType: string, revision: string);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fired on the {@link Engine} when a `(name, revision)` is durably removed
|
|
100
|
+
* from the workflow catalog via `removeWorkflowRevision`.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { Engine, WorkflowRevisionRemovedEvent } from '@lostgradient/weft';
|
|
105
|
+
*
|
|
106
|
+
* const engine = new Engine();
|
|
107
|
+
* engine.addEventListener(WorkflowRevisionRemovedEvent.type, (event) => {
|
|
108
|
+
* console.log('removed:', event.workflowType, event.revision);
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare class WorkflowRevisionRemovedEvent extends Event {
|
|
113
|
+
static readonly type: "catalog:revision-removed";
|
|
114
|
+
readonly workflowType: string;
|
|
115
|
+
readonly revision: string;
|
|
116
|
+
constructor(workflowType: string, revision: string);
|
|
117
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class WorkflowRevisionInstalledEvent extends Event {
|
|
2
|
+
static type = "catalog:revision-installed";
|
|
3
|
+
workflowType;
|
|
4
|
+
revision;
|
|
5
|
+
constructor(workflowType, revision) {
|
|
6
|
+
super(WorkflowRevisionInstalledEvent.type);
|
|
7
|
+
this.workflowType = workflowType;
|
|
8
|
+
this.revision = revision;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class WorkflowRevisionActivatedEvent extends Event {
|
|
13
|
+
static type = "catalog:revision-activated";
|
|
14
|
+
workflowType;
|
|
15
|
+
revision;
|
|
16
|
+
generation;
|
|
17
|
+
previousRevision;
|
|
18
|
+
constructor(workflowType, revision, generation, previousRevision) {
|
|
19
|
+
super(WorkflowRevisionActivatedEvent.type);
|
|
20
|
+
this.workflowType = workflowType;
|
|
21
|
+
this.revision = revision;
|
|
22
|
+
this.generation = generation;
|
|
23
|
+
this.previousRevision = previousRevision;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class WorkflowRevisionActivationRejectedEvent extends Event {
|
|
28
|
+
static type = "catalog:activation-rejected";
|
|
29
|
+
workflowType;
|
|
30
|
+
candidateRevision;
|
|
31
|
+
reason;
|
|
32
|
+
incompatibilityReasons;
|
|
33
|
+
constructor(workflowType, candidateRevision, reason, incompatibilityReasons) {
|
|
34
|
+
super(WorkflowRevisionActivationRejectedEvent.type);
|
|
35
|
+
this.workflowType = workflowType;
|
|
36
|
+
this.candidateRevision = candidateRevision;
|
|
37
|
+
this.reason = reason;
|
|
38
|
+
this.incompatibilityReasons = incompatibilityReasons;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class WorkflowRevisionDrainingEvent extends Event {
|
|
43
|
+
static type = "catalog:revision-draining";
|
|
44
|
+
workflowType;
|
|
45
|
+
revision;
|
|
46
|
+
constructor(workflowType, revision) {
|
|
47
|
+
super(WorkflowRevisionDrainingEvent.type);
|
|
48
|
+
this.workflowType = workflowType;
|
|
49
|
+
this.revision = revision;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class WorkflowRevisionRemovedEvent extends Event {
|
|
54
|
+
static type = "catalog:revision-removed";
|
|
55
|
+
workflowType;
|
|
56
|
+
revision;
|
|
57
|
+
constructor(workflowType, revision) {
|
|
58
|
+
super(WorkflowRevisionRemovedEvent.type);
|
|
59
|
+
this.workflowType = workflowType;
|
|
60
|
+
this.revision = revision;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ReviewCompletedEvent, ReviewRequestedEvent } from '../review/events.ts';
|
|
2
2
|
import type { ActivityAsyncPendingEvent, ActivityCompletedEvent, ActivityFailedEvent, ActivityStartedEvent, TaskResultDeadLetteredEvent } from './activity-events.ts';
|
|
3
3
|
import type { AttributesChangedEvent } from './attribute-events.ts';
|
|
4
|
+
import type { WorkflowRevisionActivatedEvent, WorkflowRevisionActivationRejectedEvent, WorkflowRevisionDrainingEvent, WorkflowRevisionInstalledEvent, WorkflowRevisionRemovedEvent } from './catalog-events.ts';
|
|
4
5
|
import type { ScheduleFiredEvent, ScheduleMissedFireEvent } from './schedule-events.ts';
|
|
5
6
|
import type { SignalDeliveredEvent, SignalReceivedEvent } from './signal-events.ts';
|
|
6
7
|
import type { AlertFiredEvent, AlertResolvedEvent, CheckpointSizeWarningEvent, CleanupWarningEvent, ConstraintViolatedEvent, DevelopmentWarningEvent, StorageSizeReportedEvent, WorkerConnectedEvent, WorkerDisconnectedEvent } from './system-events.ts';
|
|
7
8
|
import type { UpdateCompletedEvent, UpdateReceivedEvent } from './update-events.ts';
|
|
8
9
|
import type { WorkflowCancelledEvent, WorkflowCompletedEvent, WorkflowDefinitionRegisteredEvent, WorkflowFailedEvent, WorkflowRecoverySkippedEvent, WorkflowResumedEvent, WorkflowStartedEvent, WorkflowSuspendedEvent, WorkflowTeardownEvent, WorkflowTimedOutEvent } from './workflow-events.ts';
|
|
10
|
+
import type { WorkflowSourceLoadCancelledEvent, WorkflowSourceLoadFailedEvent, WorkflowSourceLoadReadyEvent, WorkflowSourceLoadStartedEvent } from './workflow-source-events.ts';
|
|
9
11
|
/**
|
|
10
12
|
* Record mapping each event-name string the {@link Engine} dispatches to its
|
|
11
13
|
* corresponding typed `Event` subclass.
|
|
@@ -57,6 +59,15 @@ export type WeftEventMap = {
|
|
|
57
59
|
'alert:fired': AlertFiredEvent;
|
|
58
60
|
'alert:resolved': AlertResolvedEvent;
|
|
59
61
|
'constraint:violated': ConstraintViolatedEvent;
|
|
62
|
+
'catalog:revision-installed': WorkflowRevisionInstalledEvent;
|
|
63
|
+
'catalog:revision-activated': WorkflowRevisionActivatedEvent;
|
|
64
|
+
'catalog:activation-rejected': WorkflowRevisionActivationRejectedEvent;
|
|
65
|
+
'catalog:revision-draining': WorkflowRevisionDrainingEvent;
|
|
66
|
+
'catalog:revision-removed': WorkflowRevisionRemovedEvent;
|
|
67
|
+
'workflow-source:load-started': WorkflowSourceLoadStartedEvent;
|
|
68
|
+
'workflow-source:load-ready': WorkflowSourceLoadReadyEvent;
|
|
69
|
+
'workflow-source:load-failed': WorkflowSourceLoadFailedEvent;
|
|
70
|
+
'workflow-source:load-cancelled': WorkflowSourceLoadCancelledEvent;
|
|
60
71
|
};
|
|
61
72
|
/**
|
|
62
73
|
* Typed version of the `EventTarget` interface that constrains
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './activity-events.ts';
|
|
2
2
|
export * from './attribute-events.ts';
|
|
3
|
+
export * from './catalog-events.ts';
|
|
3
4
|
export * from './event-map.ts';
|
|
4
5
|
export * from './schedule-events.ts';
|
|
5
6
|
export * from './signal-events.ts';
|
|
6
7
|
export * from './system-events.ts';
|
|
7
8
|
export * from './update-events.ts';
|
|
8
9
|
export * from './workflow-events.ts';
|
|
10
|
+
export * from './workflow-source-events.ts';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from "./activity-events.js";
|
|
2
2
|
export * from "./attribute-events.js";
|
|
3
|
+
export * from "./catalog-events.js";
|
|
3
4
|
export * from "./event-map.js";
|
|
4
5
|
export * from "./schedule-events.js";
|
|
5
6
|
export * from "./signal-events.js";
|
|
6
7
|
export * from "./system-events.js";
|
|
7
8
|
export * from "./update-events.js";
|
|
8
9
|
export * from "./workflow-events.js";
|
|
10
|
+
export * from "./workflow-source-events.js";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { FailureCategory } from '../types/identity.ts';
|
|
2
|
+
type WorkflowSourceKind = import('../source/index.ts').WorkflowSourceKind;
|
|
3
|
+
/**
|
|
4
|
+
* Fired on the {@link Engine} when a dynamic workflow source's single-flight
|
|
5
|
+
* load for `(workflowType, revision)` starts — the loader is about to be
|
|
6
|
+
* invoked. Never fired for a cache hit (an already-installed revision
|
|
7
|
+
* `resolveWorkflowSource()` returns without invoking the loader).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Engine, WorkflowSourceLoadStartedEvent } from '@lostgradient/weft';
|
|
12
|
+
*
|
|
13
|
+
* const engine = new Engine();
|
|
14
|
+
* engine.addEventListener(WorkflowSourceLoadStartedEvent.type, (event) => {
|
|
15
|
+
* console.log('loading:', event.workflowType, event.revision);
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class WorkflowSourceLoadStartedEvent extends Event {
|
|
20
|
+
static readonly type: "workflow-source:load-started";
|
|
21
|
+
readonly workflowType: string;
|
|
22
|
+
readonly revision: string;
|
|
23
|
+
readonly kind: WorkflowSourceKind;
|
|
24
|
+
constructor(workflowType: string, revision: string, kind: WorkflowSourceKind);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Fired on the {@link Engine} when a dynamic workflow source's load for
|
|
28
|
+
* `(workflowType, revision)` completes successfully — the loader ran,
|
|
29
|
+
* validation passed, and the manifest is durably installed.
|
|
30
|
+
* `loadDurationMs` is measured via the engine's own injected clock.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { Engine, WorkflowSourceLoadReadyEvent } from '@lostgradient/weft';
|
|
35
|
+
*
|
|
36
|
+
* const engine = new Engine();
|
|
37
|
+
* engine.addEventListener(WorkflowSourceLoadReadyEvent.type, (event) => {
|
|
38
|
+
* console.log('ready:', event.workflowType, event.revision, event.loadDurationMs);
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class WorkflowSourceLoadReadyEvent extends Event {
|
|
43
|
+
static readonly type: "workflow-source:load-ready";
|
|
44
|
+
readonly workflowType: string;
|
|
45
|
+
readonly revision: string;
|
|
46
|
+
readonly kind: WorkflowSourceKind;
|
|
47
|
+
readonly loadDurationMs: number;
|
|
48
|
+
constructor(workflowType: string, revision: string, kind: WorkflowSourceKind, loadDurationMs: number);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fired on the {@link Engine} when a dynamic workflow source's load for
|
|
52
|
+
* `(workflowType, revision)` fails — the loader threw, validation rejected
|
|
53
|
+
* the loaded module, or the durable install failed. `failureCategory` is
|
|
54
|
+
* the closed, low-cardinality {@link FailureCategory} classification, safe
|
|
55
|
+
* to use as a metric label; the underlying error itself is never included.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { Engine, WorkflowSourceLoadFailedEvent } from '@lostgradient/weft';
|
|
60
|
+
*
|
|
61
|
+
* const engine = new Engine();
|
|
62
|
+
* engine.addEventListener(WorkflowSourceLoadFailedEvent.type, (event) => {
|
|
63
|
+
* console.log('failed:', event.workflowType, event.revision, event.failureCategory);
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class WorkflowSourceLoadFailedEvent extends Event {
|
|
68
|
+
static readonly type: "workflow-source:load-failed";
|
|
69
|
+
readonly workflowType: string;
|
|
70
|
+
readonly revision: string;
|
|
71
|
+
readonly kind: WorkflowSourceKind;
|
|
72
|
+
readonly loadDurationMs: number;
|
|
73
|
+
readonly failureCategory: FailureCategory;
|
|
74
|
+
constructor(workflowType: string, revision: string, kind: WorkflowSourceKind, loadDurationMs: number, failureCategory: FailureCategory);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fired on the {@link Engine} when the LAST outstanding
|
|
78
|
+
* `resolveWorkflowSource()` waiter for `(workflowType, revision)` releases
|
|
79
|
+
* (its own abort, or engine disposal) while the shared load is still
|
|
80
|
+
* unsettled. The shared load itself is never aborted — a fresh caller
|
|
81
|
+
* starting a new attempt for the same key re-fires
|
|
82
|
+
* {@link WorkflowSourceLoadStartedEvent}, not this event again for the
|
|
83
|
+
* orphaned attempt.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { Engine, WorkflowSourceLoadCancelledEvent } from '@lostgradient/weft';
|
|
88
|
+
*
|
|
89
|
+
* const engine = new Engine();
|
|
90
|
+
* engine.addEventListener(WorkflowSourceLoadCancelledEvent.type, (event) => {
|
|
91
|
+
* console.log('cancelled:', event.workflowType, event.revision);
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare class WorkflowSourceLoadCancelledEvent extends Event {
|
|
96
|
+
static readonly type: "workflow-source:load-cancelled";
|
|
97
|
+
readonly workflowType: string;
|
|
98
|
+
readonly revision: string;
|
|
99
|
+
readonly kind: WorkflowSourceKind;
|
|
100
|
+
constructor(workflowType: string, revision: string, kind: WorkflowSourceKind);
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export class WorkflowSourceLoadStartedEvent extends Event {
|
|
2
|
+
static type = "workflow-source:load-started";
|
|
3
|
+
workflowType;
|
|
4
|
+
revision;
|
|
5
|
+
kind;
|
|
6
|
+
constructor(workflowType, revision, kind) {
|
|
7
|
+
super(WorkflowSourceLoadStartedEvent.type);
|
|
8
|
+
this.workflowType = workflowType;
|
|
9
|
+
this.revision = revision;
|
|
10
|
+
this.kind = kind;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class WorkflowSourceLoadReadyEvent extends Event {
|
|
15
|
+
static type = "workflow-source:load-ready";
|
|
16
|
+
workflowType;
|
|
17
|
+
revision;
|
|
18
|
+
kind;
|
|
19
|
+
loadDurationMs;
|
|
20
|
+
constructor(workflowType, revision, kind, loadDurationMs) {
|
|
21
|
+
super(WorkflowSourceLoadReadyEvent.type);
|
|
22
|
+
this.workflowType = workflowType;
|
|
23
|
+
this.revision = revision;
|
|
24
|
+
this.kind = kind;
|
|
25
|
+
this.loadDurationMs = loadDurationMs;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class WorkflowSourceLoadFailedEvent extends Event {
|
|
30
|
+
static type = "workflow-source:load-failed";
|
|
31
|
+
workflowType;
|
|
32
|
+
revision;
|
|
33
|
+
kind;
|
|
34
|
+
loadDurationMs;
|
|
35
|
+
failureCategory;
|
|
36
|
+
constructor(workflowType, revision, kind, loadDurationMs, failureCategory) {
|
|
37
|
+
super(WorkflowSourceLoadFailedEvent.type);
|
|
38
|
+
this.workflowType = workflowType;
|
|
39
|
+
this.revision = revision;
|
|
40
|
+
this.kind = kind;
|
|
41
|
+
this.loadDurationMs = loadDurationMs;
|
|
42
|
+
this.failureCategory = failureCategory;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class WorkflowSourceLoadCancelledEvent extends Event {
|
|
47
|
+
static type = "workflow-source:load-cancelled";
|
|
48
|
+
workflowType;
|
|
49
|
+
revision;
|
|
50
|
+
kind;
|
|
51
|
+
constructor(workflowType, revision, kind) {
|
|
52
|
+
super(WorkflowSourceLoadCancelledEvent.type);
|
|
53
|
+
this.workflowType = workflowType;
|
|
54
|
+
this.revision = revision;
|
|
55
|
+
this.kind = kind;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -85,6 +85,13 @@ export interface ExecutionStrategy extends Disposable, AsyncDisposable {
|
|
|
85
85
|
startWorkflow(parameters: {
|
|
86
86
|
workflowId: string;
|
|
87
87
|
workflowExecutionToken?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The starting run's persisted `WorkflowState.revision` (WFT-20). Threaded
|
|
90
|
+
* through to the worker strategy's outbound echo/validation; an inline
|
|
91
|
+
* strategy accepts and ignores it — inline execution crosses no trust
|
|
92
|
+
* boundary this field needs to police.
|
|
93
|
+
*/
|
|
94
|
+
revision?: string;
|
|
88
95
|
workflowType: string;
|
|
89
96
|
input: unknown;
|
|
90
97
|
checkpoint: ArrayBuffer | Uint8Array;
|
|
@@ -11,7 +11,7 @@ import type { SearchAttributeSchema, WorkflowFunction } from './types.ts';
|
|
|
11
11
|
import type { WorkflowLogRecord } from './types/workflow-log.ts';
|
|
12
12
|
/** Capabilities the engine injects into the inline strategy at construction. */
|
|
13
13
|
export interface InlineExecutionDependencies {
|
|
14
|
-
getRegistration: (workflowType: string) => {
|
|
14
|
+
getRegistration: (workflowType: string, workflowId: string) => {
|
|
15
15
|
handler: WorkflowFunction;
|
|
16
16
|
version: string;
|
|
17
17
|
searchAttributes?: SearchAttributeSchema;
|
|
@@ -30,7 +30,7 @@ export class InlineExecutionStrategy {
|
|
|
30
30
|
this.#messageHandler = handler;
|
|
31
31
|
}
|
|
32
32
|
startWorkflow(parameters) {
|
|
33
|
-
const registration = this.#dependencies.getRegistration(parameters.workflowType);
|
|
33
|
+
const registration = this.#dependencies.getRegistration(parameters.workflowType, parameters.workflowId);
|
|
34
34
|
if (!registration) {
|
|
35
35
|
this.#emit({
|
|
36
36
|
type: "failed",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admission for the application command mailbox (WFT-84): validating an offered
|
|
3
|
+
* command, resolving its idempotency identity, enforcing backlog capacity, and
|
|
4
|
+
* committing the record with its indexes and fleet event.
|
|
5
|
+
*
|
|
6
|
+
* Admission is the one transition that also allocates: it advances the mailbox
|
|
7
|
+
* header's FIFO sequence and open count in the same conditional batch as the
|
|
8
|
+
* record itself, so backlog accounting can never drift from the records it
|
|
9
|
+
* describes.
|
|
10
|
+
*
|
|
11
|
+
* @module core/mailbox-admission
|
|
12
|
+
*/
|
|
13
|
+
import type { ApplicationCommandAdmission, ApplicationCommandInput, MailboxCapacity } from './mailbox-contract.ts';
|
|
14
|
+
import { type MailboxRuntime } from './mailbox-internals.ts';
|
|
15
|
+
/** Backlog accounting, shared by admission rejection and the public `capacity()`. */
|
|
16
|
+
export declare function capacityOf(runtime: MailboxRuntime, open: number, admitted: number): MailboxCapacity;
|
|
17
|
+
/**
|
|
18
|
+
* Offer a command to the mailbox.
|
|
19
|
+
*
|
|
20
|
+
* An exact retry of the same idempotency identity returns the original
|
|
21
|
+
* receipt without creating a second command. Reusing the key with a different
|
|
22
|
+
* caller, target, kind, or payload digest returns a conflict and leaves the
|
|
23
|
+
* original command untouched. A full backlog is rejected before anything is
|
|
24
|
+
* persisted.
|
|
25
|
+
*/
|
|
26
|
+
export declare function admitCommand(runtime: MailboxRuntime, command: ApplicationCommandInput): Promise<ApplicationCommandAdmission>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { computeIdentityDigest } from "./application-payload-digest.js";
|
|
2
|
+
import {
|
|
3
|
+
encodeApplicationCommandIdempotencyRecord,
|
|
4
|
+
encodeApplicationReadyEntry
|
|
5
|
+
} from "./mailbox-index-codec.js";
|
|
6
|
+
import {
|
|
7
|
+
describeCommandTransition,
|
|
8
|
+
MailboxContentionError,
|
|
9
|
+
MAX_MAILBOX_TRANSITION_ATTEMPTS,
|
|
10
|
+
toApplicationCommandReceipt
|
|
11
|
+
} from "./mailbox-internals.js";
|
|
12
|
+
import {
|
|
13
|
+
commitMailboxTransition,
|
|
14
|
+
headerOperation,
|
|
15
|
+
loadCommand,
|
|
16
|
+
loadIdempotencyBinding,
|
|
17
|
+
loadMailboxHeader,
|
|
18
|
+
planCommandTransition
|
|
19
|
+
} from "./mailbox-storage.js";
|
|
20
|
+
import { createAdmittedCommandRecord } from "./mailbox-transitions.js";
|
|
21
|
+
import { MAILBOX_RECORD_VERSION } from "./mailbox-types.js";
|
|
22
|
+
import {
|
|
23
|
+
ApplicationCommandValidationError,
|
|
24
|
+
requireGeneratedIdentifier,
|
|
25
|
+
validateCommandInput
|
|
26
|
+
} from "./mailbox-validation.js";
|
|
27
|
+
import { PersistedDataCorruptError } from "./persisted-data-incompatible-error.js";
|
|
28
|
+
export function capacityOf(runtime, open, admitted) {
|
|
29
|
+
const limit = runtime.policy.maxBacklog;
|
|
30
|
+
return Object.freeze({ open, limit, remaining: Math.max(0, limit - open), admitted });
|
|
31
|
+
}
|
|
32
|
+
export async function admitCommand(runtime, command) {
|
|
33
|
+
const input = await validateCommandInput(command, runtime.policy), identityDigest = await computeIdentityDigest([
|
|
34
|
+
input.caller,
|
|
35
|
+
input.target,
|
|
36
|
+
input.kind,
|
|
37
|
+
input.payloadDigest
|
|
38
|
+
]);
|
|
39
|
+
for (let attempt = 1;attempt <= MAX_MAILBOX_TRANSITION_ATTEMPTS; attempt += 1) {
|
|
40
|
+
let expectedBinding = null;
|
|
41
|
+
if (input.idempotencyKey !== void 0) {
|
|
42
|
+
const resolved = await resolveIdempotency(runtime, input.idempotencyKey, identityDigest);
|
|
43
|
+
if (resolved.admission !== null)
|
|
44
|
+
return resolved.admission;
|
|
45
|
+
expectedBinding = resolved.staleBindingBytes;
|
|
46
|
+
}
|
|
47
|
+
const header = await loadMailboxHeader(runtime.storage, runtime.keys, runtime.policy.namespace, runtime.policy.resourceId);
|
|
48
|
+
if (header.record.openCount >= runtime.policy.maxBacklog)
|
|
49
|
+
return {
|
|
50
|
+
status: "rejected",
|
|
51
|
+
reason: "backlog-full",
|
|
52
|
+
capacity: capacityOf(runtime, header.record.openCount, header.record.admittedCount)
|
|
53
|
+
};
|
|
54
|
+
if (header.record.nextSequence >= Number.MAX_SAFE_INTEGER)
|
|
55
|
+
throw new ApplicationCommandValidationError("This mailbox has exhausted its FIFO sequence allocator; no further commands can be admitted under this namespace and resource id.");
|
|
56
|
+
const now = runtime.now(), record = createAdmittedCommandRecord(input, {
|
|
57
|
+
namespace: runtime.policy.namespace,
|
|
58
|
+
resourceId: runtime.policy.resourceId,
|
|
59
|
+
commandId: requireGeneratedIdentifier(runtime.generateId(), "commandId"),
|
|
60
|
+
sequence: header.record.nextSequence,
|
|
61
|
+
now
|
|
62
|
+
});
|
|
63
|
+
if (!await commitMailboxTransition(runtime.storage, runtime.events, planCommandTransition(runtime.keys, {
|
|
64
|
+
previous: null,
|
|
65
|
+
expectedBytes: null,
|
|
66
|
+
next: record,
|
|
67
|
+
event: describeCommandTransition(null, record),
|
|
68
|
+
now,
|
|
69
|
+
extraConditions: [
|
|
70
|
+
{ key: runtime.keys.header, expectedValue: header.bytes },
|
|
71
|
+
...input.idempotencyKey === void 0 ? [] : [
|
|
72
|
+
{
|
|
73
|
+
key: runtime.keys.idempotency(input.idempotencyKey),
|
|
74
|
+
expectedValue: expectedBinding
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
],
|
|
78
|
+
extraOperations: [
|
|
79
|
+
{
|
|
80
|
+
type: "put",
|
|
81
|
+
key: runtime.keys.bySequence(record.sequence),
|
|
82
|
+
value: encodeApplicationReadyEntry(record.commandId)
|
|
83
|
+
},
|
|
84
|
+
headerOperation(runtime.keys, {
|
|
85
|
+
...header.record,
|
|
86
|
+
nextSequence: header.record.nextSequence + 1,
|
|
87
|
+
openCount: header.record.openCount + 1,
|
|
88
|
+
admittedCount: header.record.admittedCount + 1
|
|
89
|
+
}),
|
|
90
|
+
...input.idempotencyKey === void 0 ? [] : [
|
|
91
|
+
{
|
|
92
|
+
type: "put",
|
|
93
|
+
key: runtime.keys.idempotency(input.idempotencyKey),
|
|
94
|
+
value: encodeApplicationCommandIdempotencyRecord({
|
|
95
|
+
recordVersion: MAILBOX_RECORD_VERSION,
|
|
96
|
+
commandId: record.commandId,
|
|
97
|
+
identityDigest
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
]
|
|
102
|
+
})))
|
|
103
|
+
continue;
|
|
104
|
+
return { status: "admitted", receipt: toApplicationCommandReceipt(record) };
|
|
105
|
+
}
|
|
106
|
+
throw new MailboxContentionError("admit", null);
|
|
107
|
+
}
|
|
108
|
+
async function resolveIdempotency(runtime, idempotencyKey, identityDigest) {
|
|
109
|
+
const binding = await loadIdempotencyBinding(runtime.storage, runtime.keys, idempotencyKey);
|
|
110
|
+
if (binding === null)
|
|
111
|
+
return { admission: null, staleBindingBytes: null };
|
|
112
|
+
const loaded = await loadCommand(runtime.storage, runtime.keys, binding.record.commandId);
|
|
113
|
+
if (loaded === null)
|
|
114
|
+
return { admission: null, staleBindingBytes: binding.bytes };
|
|
115
|
+
const ownDigest = await computeIdentityDigest([
|
|
116
|
+
loaded.record.caller,
|
|
117
|
+
loaded.record.target,
|
|
118
|
+
loaded.record.kind,
|
|
119
|
+
loaded.record.payloadDigest
|
|
120
|
+
]);
|
|
121
|
+
if (loaded.record.idempotencyKey !== idempotencyKey || ownDigest !== binding.record.identityDigest)
|
|
122
|
+
throw new PersistedDataCorruptError(runtime.keys.idempotency(idempotencyKey));
|
|
123
|
+
const receipt = toApplicationCommandReceipt(loaded.record);
|
|
124
|
+
if (binding.record.identityDigest !== identityDigest)
|
|
125
|
+
return {
|
|
126
|
+
admission: { status: "conflict", receipt, reason: "idempotency-identity-mismatch" },
|
|
127
|
+
staleBindingBytes: null
|
|
128
|
+
};
|
|
129
|
+
return { admission: { status: "duplicate", receipt }, staleBindingBytes: null };
|
|
130
|
+
}
|