@shipfox/api-workflows 2.0.0
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/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +311 -0
- package/LICENSE +21 -0
- package/dist/core/agent-tool-capability-warning.d.ts +7 -0
- package/dist/core/agent-tool-capability-warning.d.ts.map +1 -0
- package/dist/core/agent-tool-capability-warning.js +149 -0
- package/dist/core/agent-tool-capability-warning.js.map +1 -0
- package/dist/core/agent-tools.d.ts +51 -0
- package/dist/core/agent-tools.d.ts.map +1 -0
- package/dist/core/agent-tools.js +296 -0
- package/dist/core/agent-tools.js.map +1 -0
- package/dist/core/checkout.d.ts +29 -0
- package/dist/core/checkout.d.ts.map +1 -0
- package/dist/core/checkout.js +42 -0
- package/dist/core/checkout.js.map +1 -0
- package/dist/core/condition-trace.d.ts +13 -0
- package/dist/core/condition-trace.d.ts.map +1 -0
- package/dist/core/condition-trace.js +51 -0
- package/dist/core/condition-trace.js.map +1 -0
- package/dist/core/entities/index.d.ts +5 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/job-execution.d.ts +30 -0
- package/dist/core/entities/job-execution.d.ts.map +1 -0
- package/dist/core/entities/job-execution.js +3 -0
- package/dist/core/entities/job-execution.js.map +1 -0
- package/dist/core/entities/job-listener-event.d.ts +15 -0
- package/dist/core/entities/job-listener-event.d.ts.map +1 -0
- package/dist/core/entities/job-listener-event.js +3 -0
- package/dist/core/entities/job-listener-event.js.map +1 -0
- package/dist/core/entities/job.d.ts +54 -0
- package/dist/core/entities/job.d.ts.map +1 -0
- package/dist/core/entities/job.js +29 -0
- package/dist/core/entities/job.js.map +1 -0
- package/dist/core/entities/step.d.ts +86 -0
- package/dist/core/entities/step.d.ts.map +1 -0
- package/dist/core/entities/step.js +12 -0
- package/dist/core/entities/step.js.map +1 -0
- package/dist/core/entities/workflow-run-attempt.d.ts +20 -0
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -0
- package/dist/core/entities/workflow-run-attempt.js +3 -0
- package/dist/core/entities/workflow-run-attempt.js.map +1 -0
- package/dist/core/entities/workflow-run.d.ts +66 -0
- package/dist/core/entities/workflow-run.d.ts.map +1 -0
- package/dist/core/entities/workflow-run.js +10 -0
- package/dist/core/entities/workflow-run.js.map +1 -0
- package/dist/core/errors.d.ts +85 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +134 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/job-execution-outcome.d.ts +29 -0
- package/dist/core/job-execution-outcome.d.ts.map +1 -0
- package/dist/core/job-execution-outcome.js +31 -0
- package/dist/core/job-execution-outcome.js.map +1 -0
- package/dist/core/job-execution.d.ts +37 -0
- package/dist/core/job-execution.d.ts.map +1 -0
- package/dist/core/job-execution.js +425 -0
- package/dist/core/job-execution.js.map +1 -0
- package/dist/core/job-transition/decide-job-activation.d.ts +29 -0
- package/dist/core/job-transition/decide-job-activation.d.ts.map +1 -0
- package/dist/core/job-transition/decide-job-activation.js +51 -0
- package/dist/core/job-transition/decide-job-activation.js.map +1 -0
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts +18 -0
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -0
- package/dist/core/job-transition/derive-job-execution-outputs.js +23 -0
- package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -0
- package/dist/core/job-transition/derive-job-success.d.ts +16 -0
- package/dist/core/job-transition/derive-job-success.d.ts.map +1 -0
- package/dist/core/job-transition/derive-job-success.js +47 -0
- package/dist/core/job-transition/derive-job-success.js.map +1 -0
- package/dist/core/job-transition/index.d.ts +5 -0
- package/dist/core/job-transition/index.d.ts.map +1 -0
- package/dist/core/job-transition/index.js +6 -0
- package/dist/core/job-transition/index.js.map +1 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.d.ts +4 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.d.ts.map +1 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.js +8 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.js.map +1 -0
- package/dist/core/listener-execution-materialization.d.ts +30 -0
- package/dist/core/listener-execution-materialization.d.ts.map +1 -0
- package/dist/core/listener-execution-materialization.js +87 -0
- package/dist/core/listener-execution-materialization.js.map +1 -0
- package/dist/core/run-workflow.d.ts +11 -0
- package/dist/core/run-workflow.d.ts.map +1 -0
- package/dist/core/run-workflow.js +28 -0
- package/dist/core/run-workflow.js.map +1 -0
- package/dist/core/source-control.d.ts +5 -0
- package/dist/core/source-control.d.ts.map +1 -0
- package/dist/core/source-control.js +19 -0
- package/dist/core/source-control.js.map +1 -0
- package/dist/core/step-config/agent.d.ts +49 -0
- package/dist/core/step-config/agent.d.ts.map +1 -0
- package/dist/core/step-config/agent.js +337 -0
- package/dist/core/step-config/agent.js.map +1 -0
- package/dist/core/step-config/assemble-run-context.d.ts +94 -0
- package/dist/core/step-config/assemble-run-context.d.ts.map +1 -0
- package/dist/core/step-config/assemble-run-context.js +393 -0
- package/dist/core/step-config/assemble-run-context.js.map +1 -0
- package/dist/core/step-config/complete-step-dispatch-config.d.ts +13 -0
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -0
- package/dist/core/step-config/complete-step-dispatch-config.js +38 -0
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -0
- package/dist/core/step-config/fields.d.ts +38 -0
- package/dist/core/step-config/fields.d.ts.map +1 -0
- package/dist/core/step-config/fields.js +72 -0
- package/dist/core/step-config/fields.js.map +1 -0
- package/dist/core/step-config/index.d.ts +8 -0
- package/dist/core/step-config/index.d.ts.map +1 -0
- package/dist/core/step-config/index.js +7 -0
- package/dist/core/step-config/index.js.map +1 -0
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +35 -0
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -0
- package/dist/core/step-config/materialize-job-execution-steps.js +92 -0
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -0
- package/dist/core/step-config/materialize-workflow-model.d.ts +42 -0
- package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -0
- package/dist/core/step-config/materialize-workflow-model.js +96 -0
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -0
- package/dist/core/step-config/resolve-job-execution-name.d.ts +18 -0
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -0
- package/dist/core/step-config/resolve-job-execution-name.js +36 -0
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -0
- package/dist/core/step-config/resolve-step-config.d.ts +33 -0
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -0
- package/dist/core/step-config/resolve-step-config.js +164 -0
- package/dist/core/step-config/resolve-step-config.js.map +1 -0
- package/dist/core/step-config/run.d.ts +39 -0
- package/dist/core/step-config/run.d.ts.map +1 -0
- package/dist/core/step-config/run.js +360 -0
- package/dist/core/step-config/run.js.map +1 -0
- package/dist/core/step-config/workflow-evaluation-context.d.ts +6 -0
- package/dist/core/step-config/workflow-evaluation-context.d.ts.map +1 -0
- package/dist/core/step-config/workflow-evaluation-context.js +3 -0
- package/dist/core/step-config/workflow-evaluation-context.js.map +1 -0
- package/dist/core/step-transition/apply-step-transition.d.ts +26 -0
- package/dist/core/step-transition/apply-step-transition.d.ts.map +1 -0
- package/dist/core/step-transition/apply-step-transition.js +141 -0
- package/dist/core/step-transition/apply-step-transition.js.map +1 -0
- package/dist/core/step-transition/decide-step-transition.d.ts +71 -0
- package/dist/core/step-transition/decide-step-transition.d.ts.map +1 -0
- package/dist/core/step-transition/decide-step-transition.js +110 -0
- package/dist/core/step-transition/decide-step-transition.js.map +1 -0
- package/dist/core/step-transition/evaluate-gate.d.ts +28 -0
- package/dist/core/step-transition/evaluate-gate.d.ts.map +1 -0
- package/dist/core/step-transition/evaluate-gate.js +159 -0
- package/dist/core/step-transition/evaluate-gate.js.map +1 -0
- package/dist/core/step-transition/read-step-outputs.d.ts +3 -0
- package/dist/core/step-transition/read-step-outputs.d.ts.map +1 -0
- package/dist/core/step-transition/read-step-outputs.js +24 -0
- package/dist/core/step-transition/read-step-outputs.js.map +1 -0
- package/dist/core/workflow-run-creation.d.ts +43 -0
- package/dist/core/workflow-run-creation.d.ts.map +1 -0
- package/dist/core/workflow-run-creation.js +80 -0
- package/dist/core/workflow-run-creation.js.map +1 -0
- package/dist/core/workflow-scheduling/index.d.ts +5 -0
- package/dist/core/workflow-scheduling/index.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/index.js +4 -0
- package/dist/core/workflow-scheduling/index.js.map +1 -0
- package/dist/core/workflow-scheduling/run-progress.d.ts +20 -0
- package/dist/core/workflow-scheduling/run-progress.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/run-progress.js +40 -0
- package/dist/core/workflow-scheduling/run-progress.js.map +1 -0
- package/dist/core/workflow-scheduling/runtime-dag.d.ts +10 -0
- package/dist/core/workflow-scheduling/runtime-dag.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/runtime-dag.js +3 -0
- package/dist/core/workflow-scheduling/runtime-dag.js.map +1 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts +16 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.js +3 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.js.map +1 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts +9 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.js +72 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.js.map +1 -0
- package/dist/db/db.d.ts +4959 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +37 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/index.d.ts +9 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/job-listener-events.d.ts +18 -0
- package/dist/db/job-listener-events.d.ts.map +1 -0
- package/dist/db/job-listener-events.js +59 -0
- package/dist/db/job-listener-events.js.map +1 -0
- package/dist/db/job-listeners.d.ts +55 -0
- package/dist/db/job-listeners.d.ts.map +1 -0
- package/dist/db/job-listeners.js +358 -0
- package/dist/db/job-listeners.js.map +1 -0
- package/dist/db/outbox-writes.d.ts +12 -0
- package/dist/db/outbox-writes.d.ts.map +1 -0
- package/dist/db/outbox-writes.js +20 -0
- package/dist/db/outbox-writes.js.map +1 -0
- package/dist/db/runner-lease-table.d.ts +469 -0
- package/dist/db/runner-lease-table.d.ts.map +1 -0
- package/dist/db/runner-lease-table.js +42 -0
- package/dist/db/runner-lease-table.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/job-executions.d.ts +311 -0
- package/dist/db/schema/job-executions.d.ts.map +1 -0
- package/dist/db/schema/job-executions.js +76 -0
- package/dist/db/schema/job-executions.js.map +1 -0
- package/dist/db/schema/job-listener-events.d.ts +200 -0
- package/dist/db/schema/job-listener-events.d.ts.map +1 -0
- package/dist/db/schema/job-listener-events.js +50 -0
- package/dist/db/schema/job-listener-events.js.map +1 -0
- package/dist/db/schema/jobs.d.ts +542 -0
- package/dist/db/schema/jobs.d.ts.map +1 -0
- package/dist/db/schema/jobs.js +121 -0
- package/dist/db/schema/jobs.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/step-attempts.d.ts +330 -0
- package/dist/db/schema/step-attempts.d.ts.map +1 -0
- package/dist/db/schema/step-attempts.js +80 -0
- package/dist/db/schema/step-attempts.js.map +1 -0
- package/dist/db/schema/steps.d.ts +352 -0
- package/dist/db/schema/steps.d.ts.map +1 -0
- package/dist/db/schema/steps.js +80 -0
- package/dist/db/schema/steps.js.map +1 -0
- package/dist/db/schema/workflow-run-attempts.d.ts +239 -0
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -0
- package/dist/db/schema/workflow-run-attempts.js +53 -0
- package/dist/db/schema/workflow-run-attempts.js.map +1 -0
- package/dist/db/schema/workflow-runs.d.ts +360 -0
- package/dist/db/schema/workflow-runs.d.ts.map +1 -0
- package/dist/db/schema/workflow-runs.js +85 -0
- package/dist/db/schema/workflow-runs.js.map +1 -0
- package/dist/db/workflow-runs/job-executions.d.ts +49 -0
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -0
- package/dist/db/workflow-runs/job-executions.js +271 -0
- package/dist/db/workflow-runs/job-executions.js.map +1 -0
- package/dist/db/workflow-runs/jobs.d.ts +60 -0
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -0
- package/dist/db/workflow-runs/jobs.js +288 -0
- package/dist/db/workflow-runs/jobs.js.map +1 -0
- package/dist/db/workflow-runs/outbox.d.ts +20 -0
- package/dist/db/workflow-runs/outbox.d.ts.map +1 -0
- package/dist/db/workflow-runs/outbox.js +68 -0
- package/dist/db/workflow-runs/outbox.js.map +1 -0
- package/dist/db/workflow-runs/queries.d.ts +71 -0
- package/dist/db/workflow-runs/queries.d.ts.map +1 -0
- package/dist/db/workflow-runs/queries.js +253 -0
- package/dist/db/workflow-runs/queries.js.map +1 -0
- package/dist/db/workflow-runs/run-create.d.ts +32 -0
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-create.js +288 -0
- package/dist/db/workflow-runs/run-create.js.map +1 -0
- package/dist/db/workflow-runs/run-graph.d.ts +27 -0
- package/dist/db/workflow-runs/run-graph.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-graph.js +63 -0
- package/dist/db/workflow-runs/run-graph.js.map +1 -0
- package/dist/db/workflow-runs/run-rerun.d.ts +8 -0
- package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-rerun.js +207 -0
- package/dist/db/workflow-runs/run-rerun.js.map +1 -0
- package/dist/db/workflow-runs/run-status.d.ts +24 -0
- package/dist/db/workflow-runs/run-status.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-status.js +249 -0
- package/dist/db/workflow-runs/run-status.js.map +1 -0
- package/dist/db/workflow-runs/runs.d.ts +7 -0
- package/dist/db/workflow-runs/runs.d.ts.map +1 -0
- package/dist/db/workflow-runs/runs.js +5 -0
- package/dist/db/workflow-runs/runs.js.map +1 -0
- package/dist/db/workflow-runs/shared.d.ts +24 -0
- package/dist/db/workflow-runs/shared.d.ts.map +1 -0
- package/dist/db/workflow-runs/shared.js +50 -0
- package/dist/db/workflow-runs/shared.js.map +1 -0
- package/dist/db/workflow-runs/steps.d.ts +83 -0
- package/dist/db/workflow-runs/steps.d.ts.map +1 -0
- package/dist/db/workflow-runs/steps.js +246 -0
- package/dist/db/workflow-runs/steps.js.map +1 -0
- package/dist/db/workflow-runs.d.ts +12 -0
- package/dist/db/workflow-runs.d.ts.map +1 -0
- package/dist/db/workflow-runs.js +8 -0
- package/dist/db/workflow-runs.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +20 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +127 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +30 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/dto/checkout-token.d.ts +6 -0
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -0
- package/dist/presentation/dto/checkout-token.js +74 -0
- package/dist/presentation/dto/checkout-token.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +4 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +5 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/dto/job.d.ts +6 -0
- package/dist/presentation/dto/job.d.ts.map +1 -0
- package/dist/presentation/dto/job.js +59 -0
- package/dist/presentation/dto/job.js.map +1 -0
- package/dist/presentation/dto/step.d.ts +6 -0
- package/dist/presentation/dto/step.d.ts.map +1 -0
- package/dist/presentation/dto/step.js +162 -0
- package/dist/presentation/dto/step.js.map +1 -0
- package/dist/presentation/dto/workflow-run.d.ts +6 -0
- package/dist/presentation/dto/workflow-run.d.ts.map +1 -0
- package/dist/presentation/dto/workflow-run.js +35 -0
- package/dist/presentation/dto/workflow-run.js.map +1 -0
- package/dist/presentation/index.d.ts +3 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +4 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts +2 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.js +71 -0
- package/dist/presentation/routes/agent-runtime-config.js.map +1 -0
- package/dist/presentation/routes/cancel-run.d.ts +2 -0
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -0
- package/dist/presentation/routes/cancel-run.js +46 -0
- package/dist/presentation/routes/cancel-run.js.map +1 -0
- package/dist/presentation/routes/checkout-token.d.ts +2 -0
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -0
- package/dist/presentation/routes/checkout-token.js +64 -0
- package/dist/presentation/routes/checkout-token.js.map +1 -0
- package/dist/presentation/routes/get-run-aggregates.d.ts +2 -0
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -0
- package/dist/presentation/routes/get-run-aggregates.js +60 -0
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -0
- package/dist/presentation/routes/get-run.d.ts +2 -0
- package/dist/presentation/routes/get-run.d.ts.map +1 -0
- package/dist/presentation/routes/get-run.js +60 -0
- package/dist/presentation/routes/get-run.js.map +1 -0
- package/dist/presentation/routes/get-step-secrets.d.ts +2 -0
- package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -0
- package/dist/presentation/routes/get-step-secrets.js +115 -0
- package/dist/presentation/routes/get-step-secrets.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +4 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +41 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/leased-step.d.ts +14 -0
- package/dist/presentation/routes/leased-step.d.ts.map +1 -0
- package/dist/presentation/routes/leased-step.js +50 -0
- package/dist/presentation/routes/leased-step.js.map +1 -0
- package/dist/presentation/routes/list-run-attempts.d.ts +2 -0
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -0
- package/dist/presentation/routes/list-run-attempts.js +35 -0
- package/dist/presentation/routes/list-run-attempts.js.map +1 -0
- package/dist/presentation/routes/list-runs.d.ts +2 -0
- package/dist/presentation/routes/list-runs.d.ts.map +1 -0
- package/dist/presentation/routes/list-runs.js +70 -0
- package/dist/presentation/routes/list-runs.js.map +1 -0
- package/dist/presentation/routes/next-step.d.ts +2 -0
- package/dist/presentation/routes/next-step.d.ts.map +1 -0
- package/dist/presentation/routes/next-step.js +65 -0
- package/dist/presentation/routes/next-step.js.map +1 -0
- package/dist/presentation/routes/report-step.d.ts +2 -0
- package/dist/presentation/routes/report-step.d.ts.map +1 -0
- package/dist/presentation/routes/report-step.js +73 -0
- package/dist/presentation/routes/report-step.js.map +1 -0
- package/dist/presentation/routes/require-accessible-run.d.ts +7 -0
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -0
- package/dist/presentation/routes/require-accessible-run.js +25 -0
- package/dist/presentation/routes/require-accessible-run.js.map +1 -0
- package/dist/presentation/routes/rerun-run.d.ts +2 -0
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -0
- package/dist/presentation/routes/rerun-run.js +56 -0
- package/dist/presentation/routes/rerun-run.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +8 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +9 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-job-event-delivered.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-event-delivered.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-event-delivered.js +24 -0
- package/dist/presentation/subscribers/on-job-event-delivered.js.map +1 -0
- package/dist/presentation/subscribers/on-job-steps-settled.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-steps-settled.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-steps-settled.js +36 -0
- package/dist/presentation/subscribers/on-job-steps-settled.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js +20 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.js +35 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-queued.js +20 -0
- package/dist/presentation/subscribers/on-runner-job-queued.js.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.js +35 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.js.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.js +25 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +23 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +26 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/orchestration-activities.d.ts +130 -0
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -0
- package/dist/temporal/activities/orchestration-activities.js +188 -0
- package/dist/temporal/activities/orchestration-activities.js.map +1 -0
- package/dist/temporal/constants.d.ts +7 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +8 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/index.d.ts +3 -0
- package/dist/temporal/index.d.ts.map +1 -0
- package/dist/temporal/index.js +4 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/workflow-not-found.d.ts +2 -0
- package/dist/temporal/workflow-not-found.d.ts.map +1 -0
- package/dist/temporal/workflow-not-found.js +10 -0
- package/dist/temporal/workflow-not-found.js.map +1 -0
- package/dist/temporal/workflows/deadline.d.ts +3 -0
- package/dist/temporal/workflows/deadline.d.ts.map +1 -0
- package/dist/temporal/workflows/deadline.js +8 -0
- package/dist/temporal/workflows/deadline.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +4 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +5 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts +27 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/job-execution-orchestration.js +265 -0
- package/dist/temporal/workflows/job-execution-orchestration.js.map +1 -0
- package/dist/temporal/workflows/job-listener-orchestration.d.ts +40 -0
- package/dist/temporal/workflows/job-listener-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/job-listener-orchestration.js +332 -0
- package/dist/temporal/workflows/job-listener-orchestration.js.map +1 -0
- package/dist/temporal/workflows/run-orchestration.d.ts +8 -0
- package/dist/temporal/workflows/run-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/run-orchestration.js +243 -0
- package/dist/temporal/workflows/run-orchestration.js.map +1 -0
- package/dist/temporal/workflows/test-env.d.ts +114 -0
- package/dist/temporal/workflows/test-env.d.ts.map +1 -0
- package/dist/temporal/workflows/test-env.js +323 -0
- package/dist/temporal/workflows/test-env.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +211 -0
- package/drizzle/0001_agent_tool_materialization.sql +1 -0
- package/drizzle/meta/0000_snapshot.json +1613 -0
- package/drizzle/meta/_journal.json +20 -0
- package/drizzle.config.ts +7 -0
- package/package.json +91 -0
- package/src/core/README.md +79 -0
- package/src/core/agent-tool-capability-warning.test.ts +280 -0
- package/src/core/agent-tool-capability-warning.ts +200 -0
- package/src/core/agent-tools.ts +422 -0
- package/src/core/checkout.test.ts +112 -0
- package/src/core/checkout.ts +63 -0
- package/src/core/condition-trace.ts +64 -0
- package/src/core/entities/index.ts +9 -0
- package/src/core/entities/job-execution.ts +32 -0
- package/src/core/entities/job-listener-event.ts +15 -0
- package/src/core/entities/job.ts +91 -0
- package/src/core/entities/step.ts +126 -0
- package/src/core/entities/workflow-run-attempt.ts +21 -0
- package/src/core/entities/workflow-run.ts +94 -0
- package/src/core/errors.test.ts +45 -0
- package/src/core/errors.ts +209 -0
- package/src/core/index.ts +54 -0
- package/src/core/job-execution-outcome.ts +64 -0
- package/src/core/job-execution.test.ts +1560 -0
- package/src/core/job-execution.ts +581 -0
- package/src/core/job-transition/decide-job-activation.test.ts +196 -0
- package/src/core/job-transition/decide-job-activation.ts +79 -0
- package/src/core/job-transition/derive-job-execution-outputs.ts +41 -0
- package/src/core/job-transition/derive-job-success.test.ts +133 -0
- package/src/core/job-transition/derive-job-success.ts +67 -0
- package/src/core/job-transition/index.ts +11 -0
- package/src/core/job-transition/runtime-completion-status-for-job.ts +14 -0
- package/src/core/listener-execution-materialization.test.ts +49 -0
- package/src/core/listener-execution-materialization.ts +162 -0
- package/src/core/run-workflow.test.ts +229 -0
- package/src/core/run-workflow.ts +41 -0
- package/src/core/source-control.test.ts +17 -0
- package/src/core/source-control.ts +22 -0
- package/src/core/step-config/agent.ts +459 -0
- package/src/core/step-config/assemble-run-context.test.ts +1021 -0
- package/src/core/step-config/assemble-run-context.ts +535 -0
- package/src/core/step-config/complete-step-dispatch-config.test.ts +354 -0
- package/src/core/step-config/complete-step-dispatch-config.ts +40 -0
- package/src/core/step-config/fields.ts +111 -0
- package/src/core/step-config/index.ts +41 -0
- package/src/core/step-config/materialize-job-execution-steps.test.ts +494 -0
- package/src/core/step-config/materialize-job-execution-steps.ts +136 -0
- package/src/core/step-config/materialize-workflow-model.test.ts +1214 -0
- package/src/core/step-config/materialize-workflow-model.ts +140 -0
- package/src/core/step-config/resolve-job-execution-name.test.ts +94 -0
- package/src/core/step-config/resolve-job-execution-name.ts +51 -0
- package/src/core/step-config/resolve-step-config.ts +199 -0
- package/src/core/step-config/run.ts +467 -0
- package/src/core/step-config/workflow-evaluation-context.ts +6 -0
- package/src/core/step-transition/apply-step-transition.ts +163 -0
- package/src/core/step-transition/decide-step-transition.test.ts +307 -0
- package/src/core/step-transition/decide-step-transition.ts +200 -0
- package/src/core/step-transition/evaluate-gate.test.ts +317 -0
- package/src/core/step-transition/evaluate-gate.ts +168 -0
- package/src/core/step-transition/read-step-outputs.ts +27 -0
- package/src/core/workflow-run-creation.test.ts +155 -0
- package/src/core/workflow-run-creation.ts +131 -0
- package/src/core/workflow-scheduling/index.ts +15 -0
- package/src/core/workflow-scheduling/run-progress.test.ts +46 -0
- package/src/core/workflow-scheduling/run-progress.ts +68 -0
- package/src/core/workflow-scheduling/runtime-dag.ts +10 -0
- package/src/core/workflow-scheduling/runtime-scheduling-command.ts +20 -0
- package/src/core/workflow-scheduling/schedule-runtime-dag.test.ts +197 -0
- package/src/core/workflow-scheduling/schedule-runtime-dag.ts +115 -0
- package/src/db/db.ts +40 -0
- package/src/db/index.ts +86 -0
- package/src/db/job-listener-events.test.ts +113 -0
- package/src/db/job-listener-events.ts +73 -0
- package/src/db/job-listeners.test.ts +865 -0
- package/src/db/job-listeners.ts +564 -0
- package/src/db/outbox-writes.ts +40 -0
- package/src/db/rerun-listener.test.ts +64 -0
- package/src/db/run-timeout.test.ts +102 -0
- package/src/db/runner-lease-table.ts +39 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/job-executions.ts +85 -0
- package/src/db/schema/job-listener-events.ts +58 -0
- package/src/db/schema/jobs.ts +136 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/step-attempts.ts +99 -0
- package/src/db/schema/steps.ts +99 -0
- package/src/db/schema/workflow-run-attempts.ts +59 -0
- package/src/db/schema/workflow-runs.ts +112 -0
- package/src/db/workflow-runs/job-executions.test.ts +99 -0
- package/src/db/workflow-runs/job-executions.ts +421 -0
- package/src/db/workflow-runs/job-status.test.ts +532 -0
- package/src/db/workflow-runs/jobs.test.ts +194 -0
- package/src/db/workflow-runs/jobs.ts +418 -0
- package/src/db/workflow-runs/outbox.ts +109 -0
- package/src/db/workflow-runs/queries.test.ts +256 -0
- package/src/db/workflow-runs/queries.ts +437 -0
- package/src/db/workflow-runs/run-create.test.ts +1281 -0
- package/src/db/workflow-runs/run-create.ts +373 -0
- package/src/db/workflow-runs/run-graph.ts +95 -0
- package/src/db/workflow-runs/run-rerun.test.ts +625 -0
- package/src/db/workflow-runs/run-rerun.ts +266 -0
- package/src/db/workflow-runs/run-status.test.ts +425 -0
- package/src/db/workflow-runs/run-status.ts +391 -0
- package/src/db/workflow-runs/runs.ts +17 -0
- package/src/db/workflow-runs/shared.ts +84 -0
- package/src/db/workflow-runs/steps.test.ts +191 -0
- package/src/db/workflow-runs/steps.ts +476 -0
- package/src/db/workflow-runs.ts +111 -0
- package/src/index.ts +99 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/instance.ts +160 -0
- package/src/metrics/service.ts +30 -0
- package/src/presentation/dto/checkout-token.test.ts +107 -0
- package/src/presentation/dto/checkout-token.ts +85 -0
- package/src/presentation/dto/index.ts +3 -0
- package/src/presentation/dto/job.test.ts +108 -0
- package/src/presentation/dto/job.ts +64 -0
- package/src/presentation/dto/step.test.ts +307 -0
- package/src/presentation/dto/step.ts +145 -0
- package/src/presentation/dto/workflow-run.ts +38 -0
- package/src/presentation/index.ts +10 -0
- package/src/presentation/routes/agent-runtime-config.test.ts +478 -0
- package/src/presentation/routes/agent-runtime-config.ts +81 -0
- package/src/presentation/routes/cancel-run.test.ts +156 -0
- package/src/presentation/routes/cancel-run.ts +37 -0
- package/src/presentation/routes/checkout-token.test.ts +366 -0
- package/src/presentation/routes/checkout-token.ts +61 -0
- package/src/presentation/routes/get-run-aggregates.test.ts +114 -0
- package/src/presentation/routes/get-run-aggregates.ts +69 -0
- package/src/presentation/routes/get-run.test.ts +604 -0
- package/src/presentation/routes/get-run.ts +66 -0
- package/src/presentation/routes/get-step-secrets.test.ts +260 -0
- package/src/presentation/routes/get-step-secrets.ts +117 -0
- package/src/presentation/routes/index.test.ts +71 -0
- package/src/presentation/routes/index.ts +42 -0
- package/src/presentation/routes/leased-step.ts +54 -0
- package/src/presentation/routes/list-run-attempts.test.ts +163 -0
- package/src/presentation/routes/list-run-attempts.ts +27 -0
- package/src/presentation/routes/list-runs.test.ts +244 -0
- package/src/presentation/routes/list-runs.ts +83 -0
- package/src/presentation/routes/next-step.test.ts +366 -0
- package/src/presentation/routes/next-step.ts +62 -0
- package/src/presentation/routes/report-step.test.ts +374 -0
- package/src/presentation/routes/report-step.ts +61 -0
- package/src/presentation/routes/require-accessible-run.ts +27 -0
- package/src/presentation/routes/rerun-run.test.ts +202 -0
- package/src/presentation/routes/rerun-run.ts +48 -0
- package/src/presentation/subscribers/index.ts +7 -0
- package/src/presentation/subscribers/on-job-event-delivered.test.ts +71 -0
- package/src/presentation/subscribers/on-job-event-delivered.ts +30 -0
- package/src/presentation/subscribers/on-job-steps-settled.test.ts +75 -0
- package/src/presentation/subscribers/on-job-steps-settled.ts +42 -0
- package/src/presentation/subscribers/on-runner-job-claimed.test.ts +57 -0
- package/src/presentation/subscribers/on-runner-job-claimed.ts +23 -0
- package/src/presentation/subscribers/on-runner-job-lease-expired.test.ts +73 -0
- package/src/presentation/subscribers/on-runner-job-lease-expired.ts +36 -0
- package/src/presentation/subscribers/on-runner-job-queued.test.ts +57 -0
- package/src/presentation/subscribers/on-runner-job-queued.ts +23 -0
- package/src/presentation/subscribers/on-workflow-run-attempt-created.test.ts +69 -0
- package/src/presentation/subscribers/on-workflow-run-attempt-created.ts +40 -0
- package/src/presentation/subscribers/on-workflow-run-cancelled.test.ts +59 -0
- package/src/presentation/subscribers/on-workflow-run-cancelled.ts +29 -0
- package/src/temporal/activities/index.ts +45 -0
- package/src/temporal/activities/orchestration-activities.test.ts +115 -0
- package/src/temporal/activities/orchestration-activities.ts +305 -0
- package/src/temporal/constants.ts +6 -0
- package/src/temporal/index.ts +6 -0
- package/src/temporal/workflow-not-found.ts +9 -0
- package/src/temporal/workflows/deadline.ts +7 -0
- package/src/temporal/workflows/index.ts +11 -0
- package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +165 -0
- package/src/temporal/workflows/job-execution-orchestration.test.ts +311 -0
- package/src/temporal/workflows/job-execution-orchestration.ts +314 -0
- package/src/temporal/workflows/job-listener-orchestration-continuation.test.ts +93 -0
- package/src/temporal/workflows/job-listener-orchestration.test.ts +406 -0
- package/src/temporal/workflows/job-listener-orchestration.ts +490 -0
- package/src/temporal/workflows/run-orchestration.test.ts +409 -0
- package/src/temporal/workflows/run-orchestration.ts +283 -0
- package/src/temporal/workflows/test-env.ts +409 -0
- package/test/env.ts +11 -0
- package/test/factories/job.ts +83 -0
- package/test/factories/project.ts +16 -0
- package/test/factories/workflow-model.test.ts +26 -0
- package/test/factories/workflow-model.ts +268 -0
- package/test/factories/workflow-run.ts +58 -0
- package/test/fixtures/active-lease-token.ts +85 -0
- package/test/fixtures/job-with-steps.ts +42 -0
- package/test/fixtures/lease-token.ts +44 -0
- package/test/fixtures/strip-setup-step.ts +23 -0
- package/test/globalSetup.ts +54 -0
- package/test/helpers/workflow-runs.ts +210 -0
- package/test/index.ts +3 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/job-execution-orchestration.ts"],"sourcesContent":["import {ApplicationFailure} from '@temporalio/common';\nimport {condition, defineSignal, log, proxyActivities, setHandler} from '@temporalio/workflow';\nimport {\n hasNoRequiredRunnerLabels,\n type JobExecutionOutcomeSignals,\n jobExecutionStartOutcome,\n resolveJobExecutionOutcomeSignal,\n} from '#core/job-execution-outcome.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\n\nimport type {createOrchestrationActivities} from '../activities/index.js';\nimport {JOB_FINISHED_SIGNAL, JOB_LEASE_EXPIRED_SIGNAL} from '../constants.js';\n\n/**\n * Two signals, one precedence ladder, then best-effort lease release:\n *\n * job-finished (recordStepResult exhausted the steps) ─┐\n * job-lease-expired (runner heartbeat went stale) ─────┤\n * ▼\n * condition(finished ∥ leaseExpired, executionTimeout)\n * ├─ finished → setJobExecutionStatus(status) + resolve job status ─┐\n * ├─ leaseExpired → resolveLeaseExpiredJobExecutionActivity ─┤→ releaseLease\n * └─ neither (6h) → failJobExecutionAsTimedOutActivity + sweep steps (NO release; the\n * TIMED_OUT event drives cooperative cancel, the detector reaps)\n *\n * Both signals can be delivered before condition() resumes (independent outboxes,\n * no ordering), so finished is evaluated FIRST: a genuinely-finished job is never\n * flipped to failed by a late lease-expiry. releaseLease is best-effort — a runners\n * DB outage must never block the child workflow from returning the job outcome to\n * run-orchestration; a leftover lease row is reaped by the stuck detector.\n */\n\nconst {\n setJobStatus,\n setJobExecutionStatus,\n enqueueJobExecutionForRunner,\n bulkSetStepStatuses,\n failJobExecutionAsTimedOutActivity,\n resolveLeaseExpiredJobExecutionActivity,\n} = proxyActivities<ReturnType<typeof createOrchestrationActivities>>({\n startToCloseTimeout: '30s',\n});\n\nconst {resolveJobStatusFromJobExecutionsActivity} = proxyActivities<\n ReturnType<typeof createOrchestrationActivities>\n>({\n startToCloseTimeout: '30s',\n retry: {maximumAttempts: 5},\n});\n\n// Lease cleanup gets a bounded retry policy of its own: after a few attempts the\n// workflow stops waiting on it (see releaseLeaseBestEffort) rather than blocking\n// the DAG on runners-side availability.\nconst {releaseLeaseActivity} = proxyActivities<ReturnType<typeof createOrchestrationActivities>>({\n startToCloseTimeout: '30s',\n retry: {maximumAttempts: 5},\n});\n\nconst DEFAULT_EXECUTION_MAX_DURATION_MS = 6 * 60 * 60 * 1000;\n\nexport const jobFinishedSignal =\n defineSignal<[{status: RuntimeCompletionStatus; jobExecutionId?: string | undefined}]>(\n JOB_FINISHED_SIGNAL,\n );\nexport const jobLeaseExpiredSignal =\n defineSignal<[{jobExecutionId?: string | undefined}]>(JOB_LEASE_EXPIRED_SIGNAL);\n\nexport interface JobExecutionOrchestrationInput {\n workspaceId: string;\n workflowRunId: string;\n runAttemptId: string;\n jobId: string;\n jobExecutionId: string;\n projectId: string;\n jobVersion: number;\n executionVersion: number;\n executionTimeoutMs?: number | null | undefined;\n resolveJobStatus?: boolean | undefined;\n requiredLabels: string[];\n}\n\nexport interface JobExecutionOrchestrationResult {\n status: RuntimeCompletionStatus;\n jobVersion: number;\n}\n\nasync function releaseLeaseBestEffort(jobExecutionId: string): Promise<void> {\n try {\n await releaseLeaseActivity({jobExecutionId});\n } catch (err) {\n log.warn('lease release failed; stuck detector will reap the row', {\n jobExecutionId,\n error: String(err),\n });\n }\n}\n\nasync function resolveJobStatusOrFailClosed(\n input: JobExecutionOrchestrationInput,\n): Promise<{status: RuntimeCompletionStatus; jobVersion: number}> {\n try {\n return await resolveJobStatusFromJobExecutionsActivity({jobId: input.jobId});\n } catch (err) {\n log.error('job status resolution failed; failing job closed', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n error: String(err),\n });\n const {newVersion} = await setJobStatus({\n jobId: input.jobId,\n status: 'failed',\n version: input.jobVersion,\n statusReason: 'step_failed',\n });\n return {status: 'failed', jobVersion: newVersion};\n }\n}\n\nasync function markJobExecutionRunningAndEnqueue(\n input: JobExecutionOrchestrationInput,\n): Promise<\n | {kind: 'running'; runningVersion: number}\n | {kind: 'terminal'; result: JobExecutionOrchestrationResult}\n> {\n if (hasNoRequiredRunnerLabels(input.requiredLabels)) {\n throw ApplicationFailure.nonRetryable(\n `Job ${input.jobId} has no required runner labels`,\n 'EmptyRequiredLabelsError',\n );\n }\n\n const {newVersion: runningVersion, status} = await setJobExecutionStatus({\n jobExecutionId: input.jobExecutionId,\n status: 'running',\n version: input.executionVersion,\n });\n\n const start = jobExecutionStartOutcome({newVersion: runningVersion, status});\n if (start.kind === 'terminal') return start;\n\n await enqueueJobExecutionForRunner({\n workspaceId: input.workspaceId,\n workflowRunId: input.workflowRunId,\n runAttemptId: input.runAttemptId,\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n projectId: input.projectId,\n requiredLabels: input.requiredLabels,\n });\n\n return {kind: 'running', runningVersion};\n}\n\n// Both signals can arrive before condition() resumes (independent outboxes, no\n// ordering), so callers must evaluate `finished` before `leaseExpired`.\nasync function awaitJobOutcome(\n jobExecutionId: string,\n timeoutMs: number,\n): Promise<JobExecutionOutcomeSignals> {\n let finished: {status: RuntimeCompletionStatus; jobExecutionId?: string | undefined} | undefined;\n let leaseExpired = false;\n setHandler(jobFinishedSignal, (payload) => {\n if (payload.jobExecutionId !== undefined && payload.jobExecutionId !== jobExecutionId) return;\n finished ??= payload;\n });\n setHandler(jobLeaseExpiredSignal, (payload = {}) => {\n if (payload.jobExecutionId !== undefined && payload.jobExecutionId !== jobExecutionId) return;\n leaseExpired = true;\n });\n\n await condition(() => finished !== undefined || leaseExpired, timeoutMs);\n\n return {finished, leaseExpired};\n}\n\ninterface JobExecutionResolution {\n input: JobExecutionOrchestrationInput;\n runningVersion: number;\n}\n\nasync function resolveFinishedJobExecution({\n input,\n runningVersion,\n status,\n}: JobExecutionResolution & {\n status: RuntimeCompletionStatus;\n}): Promise<JobExecutionOrchestrationResult> {\n await setJobExecutionStatus({\n jobExecutionId: input.jobExecutionId,\n status: jobExecutionStatusForRuntimeStatus(status),\n version: runningVersion,\n statusReason: status === 'failed' ? 'step_failed' : null,\n });\n if (input.resolveJobStatus === false) {\n log.info('job execution terminated', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n terminationReason: 'finished',\n status,\n });\n await releaseLeaseBestEffort(input.jobExecutionId);\n return {status, jobVersion: input.jobVersion};\n }\n const resolved = await resolveJobStatusOrFailClosed(input);\n log.info('job execution terminated', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n terminationReason: 'finished',\n status: resolved.status,\n });\n await releaseLeaseBestEffort(input.jobExecutionId);\n return resolved;\n}\n\nfunction jobExecutionStatusForRuntimeStatus(\n status: RuntimeCompletionStatus,\n): 'succeeded' | 'failed' | 'cancelled' {\n if (status === 'succeeded' || status === 'failed' || status === 'cancelled') return status;\n throw ApplicationFailure.nonRetryable(\n `Job execution cannot be marked ${status}`,\n 'InvalidJobExecutionStatusError',\n );\n}\n\nasync function resolveLeaseExpiredJobExecution({\n input,\n runningVersion,\n}: JobExecutionResolution): Promise<JobExecutionOrchestrationResult> {\n const leaseExpired = await resolveLeaseExpiredJobExecutionActivity({\n jobExecutionId: input.jobExecutionId,\n expectedVersion: runningVersion,\n });\n if (input.resolveJobStatus === false) {\n log.info('job execution terminated', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n terminationReason: 'lease_expired',\n status: leaseExpired.status,\n });\n await releaseLeaseBestEffort(input.jobExecutionId);\n return {status: leaseExpired.status, jobVersion: input.jobVersion};\n }\n const {status, jobVersion} = await resolveJobStatusOrFailClosed(input);\n log.info('job execution terminated', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n terminationReason: 'lease_expired',\n status,\n });\n await releaseLeaseBestEffort(input.jobExecutionId);\n return {status, jobVersion};\n}\n\n// Timeout backstop. The activity atomically fails the execution, marks\n// `timed_out_at`, and enqueues WORKFLOWS_JOB_EXECUTION_TIMED_OUT; the runners subscriber\n// then asks the runner to cancel. The lease is intentionally NOT released here.\nasync function resolveTimedOutJobExecution({\n input,\n runningVersion,\n}: JobExecutionResolution): Promise<JobExecutionOrchestrationResult> {\n await failJobExecutionAsTimedOutActivity({\n jobExecutionId: input.jobExecutionId,\n runAttemptId: input.runAttemptId,\n expectedVersion: runningVersion,\n });\n await bulkSetStepStatuses({jobExecutionId: input.jobExecutionId, status: 'failed'});\n if (input.resolveJobStatus === false) {\n log.info('job execution terminated', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n terminationReason: 'max_duration',\n status: 'failed',\n });\n return {status: 'failed', jobVersion: input.jobVersion};\n }\n const {jobVersion} = await resolveJobStatusOrFailClosed(input);\n log.info('job execution terminated', {\n jobId: input.jobId,\n jobExecutionId: input.jobExecutionId,\n terminationReason: 'max_duration',\n status: 'failed',\n });\n return {status: 'failed', jobVersion};\n}\n\nexport async function jobExecutionOrchestration(\n input: JobExecutionOrchestrationInput,\n): Promise<JobExecutionOrchestrationResult> {\n const running = await markJobExecutionRunningAndEnqueue(input);\n if (running.kind === 'terminal') {\n if (input.resolveJobStatus === false) {\n return {status: running.result.status, jobVersion: input.jobVersion};\n }\n return running.result;\n }\n const {runningVersion} = running;\n\n const timeoutMs = input.executionTimeoutMs ?? DEFAULT_EXECUTION_MAX_DURATION_MS;\n const signals = await awaitJobOutcome(input.jobExecutionId, timeoutMs);\n\n // Precedence ladder: a genuinely-finished job is never flipped to failed by a\n // late lease-expiry, so `finished` wins over `leaseExpired`.\n const resolution = resolveJobExecutionOutcomeSignal(signals);\n if (resolution === 'finished') {\n const {finished} = signals;\n if (finished === undefined) throw new Error('Missing finished signal for finished resolution');\n\n return resolveFinishedJobExecution({input, runningVersion, status: finished.status});\n }\n if (resolution === 'lease-expired') {\n return resolveLeaseExpiredJobExecution({input, runningVersion});\n }\n return resolveTimedOutJobExecution({input, runningVersion});\n}\n"],"names":["ApplicationFailure","condition","defineSignal","log","proxyActivities","setHandler","hasNoRequiredRunnerLabels","jobExecutionStartOutcome","resolveJobExecutionOutcomeSignal","JOB_FINISHED_SIGNAL","JOB_LEASE_EXPIRED_SIGNAL","setJobStatus","setJobExecutionStatus","enqueueJobExecutionForRunner","bulkSetStepStatuses","failJobExecutionAsTimedOutActivity","resolveLeaseExpiredJobExecutionActivity","startToCloseTimeout","resolveJobStatusFromJobExecutionsActivity","retry","maximumAttempts","releaseLeaseActivity","DEFAULT_EXECUTION_MAX_DURATION_MS","jobFinishedSignal","jobLeaseExpiredSignal","releaseLeaseBestEffort","jobExecutionId","err","warn","error","String","resolveJobStatusOrFailClosed","input","jobId","newVersion","status","version","jobVersion","statusReason","markJobExecutionRunningAndEnqueue","requiredLabels","nonRetryable","runningVersion","executionVersion","start","kind","workspaceId","workflowRunId","runAttemptId","projectId","awaitJobOutcome","timeoutMs","finished","leaseExpired","payload","undefined","resolveFinishedJobExecution","jobExecutionStatusForRuntimeStatus","resolveJobStatus","info","terminationReason","resolved","resolveLeaseExpiredJobExecution","expectedVersion","resolveTimedOutJobExecution","jobExecutionOrchestration","running","result","executionTimeoutMs","signals","resolution","Error"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,qBAAqB;AACtD,SAAQC,SAAS,EAAEC,YAAY,EAAEC,GAAG,EAAEC,eAAe,EAAEC,UAAU,QAAO,uBAAuB;AAC/F,SACEC,yBAAyB,EAEzBC,wBAAwB,EACxBC,gCAAgC,QAC3B,iCAAiC;AAIxC,SAAQC,mBAAmB,EAAEC,wBAAwB,QAAO,kBAAkB;AAE9E;;;;;;;;;;;;;;;;;CAiBC,GAED,MAAM,EACJC,YAAY,EACZC,qBAAqB,EACrBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,kCAAkC,EAClCC,uCAAuC,EACxC,GAAGZ,gBAAkE;IACpEa,qBAAqB;AACvB;AAEA,MAAM,EAACC,yCAAyC,EAAC,GAAGd,gBAElD;IACAa,qBAAqB;IACrBE,OAAO;QAACC,iBAAiB;IAAC;AAC5B;AAEA,iFAAiF;AACjF,iFAAiF;AACjF,wCAAwC;AACxC,MAAM,EAACC,oBAAoB,EAAC,GAAGjB,gBAAkE;IAC/Fa,qBAAqB;IACrBE,OAAO;QAACC,iBAAiB;IAAC;AAC5B;AAEA,MAAME,oCAAoC,IAAI,KAAK,KAAK;AAExD,OAAO,MAAMC,oBACXrB,aACEO,qBACA;AACJ,OAAO,MAAMe,wBACXtB,aAAsDQ,0BAA0B;AAqBlF,eAAee,uBAAuBC,cAAsB;IAC1D,IAAI;QACF,MAAML,qBAAqB;YAACK;QAAc;IAC5C,EAAE,OAAOC,KAAK;QACZxB,IAAIyB,IAAI,CAAC,0DAA0D;YACjEF;YACAG,OAAOC,OAAOH;QAChB;IACF;AACF;AAEA,eAAeI,6BACbC,KAAqC;IAErC,IAAI;QACF,OAAO,MAAMd,0CAA0C;YAACe,OAAOD,MAAMC,KAAK;QAAA;IAC5E,EAAE,OAAON,KAAK;QACZxB,IAAI0B,KAAK,CAAC,oDAAoD;YAC5DI,OAAOD,M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,MAAMN,cAAc;QACpCkC,mBAAmB;QACnBzB,QAAQ;IACV;IACA,OAAO;QAACA,QAAQ;QAAUE;IAAU;AACtC;AAEA,OAAO,eAAe4B,0BACpBjC,KAAqC;IAErC,MAAMkC,UAAU,MAAM3B,kCAAkCP;IACxD,IAAIkC,QAAQrB,IAAI,KAAK,YAAY;QAC/B,IAAIb,MAAM0B,gBAAgB,KAAK,OAAO;YACpC,OAAO;gBAACvB,QAAQ+B,QAAQC,MAAM,CAAChC,MAAM;gBAAEE,YAAYL,MAAMK,UAAU;YAAA;QACrE;QACA,OAAO6B,QAAQC,MAAM;IACvB;IACA,MAAM,EAACzB,cAAc,EAAC,GAAGwB;IAEzB,MAAMf,YAAYnB,MAAMoC,kBAAkB,IAAI9C;IAC9C,MAAM+C,UAAU,MAAMnB,gBAAgBlB,MAAMN,cAAc,EAAEyB;IAE5D,8EAA8E;IAC9E,6DAA6D;IAC7D,MAAMmB,aAAa9D,iCAAiC6D;IACpD,IAAIC,eAAe,YAAY;QAC7B,MAAM,EAAClB,QAAQ,EAAC,GAAGiB;QACnB,IAAIjB,aAAaG,WAAW,MAAM,IAAIgB,MAAM;QAE5C,OAAOf,4BAA4B;YAACxB;YAAOU;YAAgBP,QAAQiB,SAASjB,MAAM;QAAA;IACpF;IACA,IAAImC,eAAe,iBAAiB;QAClC,OAAOR,gCAAgC;YAAC9B;YAAOU;QAAc;IAC/D;IACA,OAAOsB,4BAA4B;QAAChC;QAAOU;IAAc;AAC3D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ResolutionReason } from '#core/entities/job.js';
|
|
2
|
+
import type { RuntimeCompletionStatus } from '#core/workflow-scheduling/runtime-dag.js';
|
|
3
|
+
export declare const listenerEventsAvailableSignal: import("@temporalio/workflow").SignalDefinition<[], string>;
|
|
4
|
+
export declare const listenerResolveSignal: import("@temporalio/workflow").SignalDefinition<[], string>;
|
|
5
|
+
export interface JobListenerOrchestrationInput {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
workflowRunId: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
runAttemptId: string;
|
|
10
|
+
jobId: string;
|
|
11
|
+
jobVersion: number;
|
|
12
|
+
requiredLabels: string[];
|
|
13
|
+
executionTimeoutMs?: number | null | undefined;
|
|
14
|
+
listeningTimeoutMs?: number | null | undefined;
|
|
15
|
+
maxExecutions?: number | null | undefined;
|
|
16
|
+
onResolve?: 'finish' | 'cancel' | null | undefined;
|
|
17
|
+
batchDebounceMs?: number | null | undefined;
|
|
18
|
+
batchMaxSize?: number | null | undefined;
|
|
19
|
+
batchMaxWaitMs?: number | null | undefined;
|
|
20
|
+
continuation?: ListenerContinuationState | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface JobListenerOrchestrationResult {
|
|
23
|
+
status: RuntimeCompletionStatus;
|
|
24
|
+
jobVersion: number;
|
|
25
|
+
}
|
|
26
|
+
type ResolutionLatch = Exclude<ResolutionReason, 'cancelled'> | undefined;
|
|
27
|
+
export interface ListenerContinuationState {
|
|
28
|
+
nextSequence: number;
|
|
29
|
+
latchedReason?: ResolutionLatch;
|
|
30
|
+
listenerDeadline?: number | undefined;
|
|
31
|
+
}
|
|
32
|
+
export declare const LISTENER_CONTINUE_AS_NEW_FIRING_LIMIT = 500;
|
|
33
|
+
export declare function jobListenerOrchestration(input: JobListenerOrchestrationInput): Promise<JobListenerOrchestrationResult>;
|
|
34
|
+
export declare function shouldContinueListenerAsNew(params: {
|
|
35
|
+
firingsInCurrentRun: number;
|
|
36
|
+
continueAsNewSuggested: boolean;
|
|
37
|
+
}): boolean;
|
|
38
|
+
export declare function listenerContinuationInput(input: JobListenerOrchestrationInput, continuation: ListenerContinuationState): JobListenerOrchestrationInput;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=job-listener-orchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-listener-orchestration.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/job-listener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eAAe,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,qCAAqC,MAAM,CAAC;AAwBzD,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,8BAA8B,CAAC,CAuIzC;AAiCD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;CACjC,GAAG,OAAO,CAKV;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,6BAA6B,EACpC,YAAY,EAAE,yBAAyB,GACtC,6BAA6B,CAE/B"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { CancellationScope, condition, continueAsNew, defineSignal, executeChild, log, ParentClosePolicy, proxyActivities, setHandler, workflowInfo } from '@temporalio/workflow';
|
|
2
|
+
import { runtimeStatusForTerminalJobExecutionStatus } from '#core/job-execution-outcome.js';
|
|
3
|
+
import { LISTENER_EVENTS_AVAILABLE_SIGNAL, LISTENER_RESOLVE_SIGNAL } from '../constants.js';
|
|
4
|
+
import { deadlineReached, remainingMs } from './deadline.js';
|
|
5
|
+
import { jobExecutionOrchestration } from './job-execution-orchestration.js';
|
|
6
|
+
const { activateJobListenerActivity, drainListenerEventsActivity, peekListenerBufferActivity, resolveJobListenerActivity, settleListenerJobExecutionActivity, recordListenerFiringOutcomeActivity, cancelRunnerJobsActivity } = proxyActivities({
|
|
7
|
+
startToCloseTimeout: '30s'
|
|
8
|
+
});
|
|
9
|
+
export const listenerEventsAvailableSignal = defineSignal(LISTENER_EVENTS_AVAILABLE_SIGNAL);
|
|
10
|
+
export const listenerResolveSignal = defineSignal(LISTENER_RESOLVE_SIGNAL);
|
|
11
|
+
export const LISTENER_CONTINUE_AS_NEW_FIRING_LIMIT = 500;
|
|
12
|
+
export async function jobListenerOrchestration(input) {
|
|
13
|
+
let eventsAvailable = false;
|
|
14
|
+
let latchedReason = input.continuation?.latchedReason;
|
|
15
|
+
setHandler(listenerEventsAvailableSignal, ()=>{
|
|
16
|
+
eventsAvailable = true;
|
|
17
|
+
});
|
|
18
|
+
setHandler(listenerResolveSignal, ()=>{
|
|
19
|
+
latchedReason = 'until';
|
|
20
|
+
});
|
|
21
|
+
const listenerDeadline = input.continuation?.listenerDeadline ?? initialListenerDeadline(input);
|
|
22
|
+
let nextSequence;
|
|
23
|
+
if (input.continuation) {
|
|
24
|
+
nextSequence = input.continuation.nextSequence;
|
|
25
|
+
} else {
|
|
26
|
+
const activated = await activateJobListenerActivity({
|
|
27
|
+
jobId: input.jobId,
|
|
28
|
+
expectedVersion: input.jobVersion
|
|
29
|
+
});
|
|
30
|
+
if (activated.status === 'terminal') {
|
|
31
|
+
return {
|
|
32
|
+
status: runtimeStatusForTerminalJobExecutionStatus(activated.jobStatus),
|
|
33
|
+
jobVersion: activated.jobVersion
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
nextSequence = activated.executionCount + 1;
|
|
37
|
+
}
|
|
38
|
+
let firingsInCurrentRun = 0;
|
|
39
|
+
const maxExecutions = input.maxExecutions ?? undefined;
|
|
40
|
+
const batchConfig = listenerBatchConfig(input);
|
|
41
|
+
while(true){
|
|
42
|
+
if (deadlineReached(listenerDeadline)) latchedReason ??= 'timeout';
|
|
43
|
+
await continueListenerAsNewIfNeeded({
|
|
44
|
+
input,
|
|
45
|
+
nextSequence,
|
|
46
|
+
latchedReason,
|
|
47
|
+
listenerDeadline,
|
|
48
|
+
firingsInCurrentRun
|
|
49
|
+
});
|
|
50
|
+
if (latchedReason !== undefined) break;
|
|
51
|
+
if (maxExecutions !== undefined) {
|
|
52
|
+
if (nextSequence > maxExecutions) {
|
|
53
|
+
latchedReason = 'max_executions';
|
|
54
|
+
await continueListenerAsNewIfNeeded({
|
|
55
|
+
input,
|
|
56
|
+
nextSequence,
|
|
57
|
+
latchedReason,
|
|
58
|
+
listenerDeadline,
|
|
59
|
+
firingsInCurrentRun
|
|
60
|
+
});
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (batchConfig !== undefined) {
|
|
65
|
+
const decision = await awaitBatchFiringWindow({
|
|
66
|
+
jobId: input.jobId,
|
|
67
|
+
batchConfig,
|
|
68
|
+
listenerDeadline,
|
|
69
|
+
hasEventsHint: ()=>eventsAvailable,
|
|
70
|
+
clearEventsHint: ()=>{
|
|
71
|
+
eventsAvailable = false;
|
|
72
|
+
},
|
|
73
|
+
hasResolutionHint: ()=>latchedReason !== undefined
|
|
74
|
+
});
|
|
75
|
+
if (decision === 'resolve') {
|
|
76
|
+
latchedReason ??= 'until';
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
if (decision === 'deadline') {
|
|
80
|
+
latchedReason ??= 'timeout';
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
eventsAvailable = false;
|
|
85
|
+
const drained = await drainListenerEventsActivity({
|
|
86
|
+
jobId: input.jobId,
|
|
87
|
+
expectedSequence: nextSequence,
|
|
88
|
+
...batchConfig?.maxSizeEvents === undefined ? {} : {
|
|
89
|
+
maxSize: batchConfig.maxSizeEvents
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (drained.kind === 'resolve-requested') {
|
|
93
|
+
latchedReason = 'until';
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
if (drained.kind === 'empty') {
|
|
97
|
+
const woke = await waitForListenerWakeup(()=>eventsAvailable || latchedReason !== undefined, {
|
|
98
|
+
deadline: listenerDeadline
|
|
99
|
+
});
|
|
100
|
+
if (!woke && deadlineReached(listenerDeadline)) latchedReason = 'timeout';
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (drained.status === 'failed') {
|
|
104
|
+
await recordListenerFiringOutcomeActivity({
|
|
105
|
+
outcome: 'failed'
|
|
106
|
+
});
|
|
107
|
+
nextSequence = drained.sequence + 1;
|
|
108
|
+
firingsInCurrentRun += 1;
|
|
109
|
+
if (maxExecutions !== undefined && drained.sequence >= maxExecutions) {
|
|
110
|
+
latchedReason = 'max_executions';
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
await runListenerExecution({
|
|
115
|
+
input,
|
|
116
|
+
jobExecutionId: drained.jobExecutionId,
|
|
117
|
+
executionVersion: drained.executionVersion,
|
|
118
|
+
requiredLabels: drained.requiredLabels,
|
|
119
|
+
shouldCancelForResolution: ()=>input.onResolve === 'cancel' && (latchedReason !== undefined || deadlineReached(listenerDeadline)),
|
|
120
|
+
waitForResolution: ()=>waitForListenerWakeup(()=>latchedReason !== undefined || deadlineReached(listenerDeadline), {
|
|
121
|
+
deadline: listenerDeadline
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
if (deadlineReached(listenerDeadline)) latchedReason ??= 'timeout';
|
|
125
|
+
nextSequence = drained.sequence + 1;
|
|
126
|
+
firingsInCurrentRun += 1;
|
|
127
|
+
if (maxExecutions !== undefined && drained.sequence >= maxExecutions) {
|
|
128
|
+
latchedReason = 'max_executions';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const reason = latchedReason ?? 'timeout';
|
|
132
|
+
const resolved = await resolveJobListenerActivity({
|
|
133
|
+
jobId: input.jobId,
|
|
134
|
+
reason
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
status: resolved.status,
|
|
138
|
+
jobVersion: resolved.jobVersion
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function initialListenerDeadline(input) {
|
|
142
|
+
return input.listeningTimeoutMs === undefined || input.listeningTimeoutMs === null ? undefined : Date.now() + input.listeningTimeoutMs;
|
|
143
|
+
}
|
|
144
|
+
async function continueListenerAsNewIfNeeded(params) {
|
|
145
|
+
if (!shouldContinueListenerAsNew({
|
|
146
|
+
firingsInCurrentRun: params.firingsInCurrentRun,
|
|
147
|
+
continueAsNewSuggested: workflowInfo().continueAsNewSuggested
|
|
148
|
+
})) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
await continueAsNew(listenerContinuationInput(params.input, {
|
|
152
|
+
nextSequence: params.nextSequence,
|
|
153
|
+
latchedReason: params.latchedReason,
|
|
154
|
+
listenerDeadline: params.listenerDeadline
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
export function shouldContinueListenerAsNew(params) {
|
|
158
|
+
return params.continueAsNewSuggested || params.firingsInCurrentRun >= LISTENER_CONTINUE_AS_NEW_FIRING_LIMIT;
|
|
159
|
+
}
|
|
160
|
+
export function listenerContinuationInput(input, continuation) {
|
|
161
|
+
return {
|
|
162
|
+
...input,
|
|
163
|
+
continuation
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function listenerBatchConfig(input) {
|
|
167
|
+
const debounceMs = positiveNumber(input.batchDebounceMs);
|
|
168
|
+
const maxSizeEvents = positiveNumber(input.batchMaxSize);
|
|
169
|
+
const maxWaitMs = positiveNumber(input.batchMaxWaitMs);
|
|
170
|
+
if (debounceMs === undefined && maxSizeEvents === undefined && maxWaitMs === undefined) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
debounceMs,
|
|
175
|
+
maxSizeEvents,
|
|
176
|
+
maxWaitMs
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async function awaitBatchFiringWindow(params) {
|
|
180
|
+
while(true){
|
|
181
|
+
const prePeekDecision = resolutionOrDeadlineDecision(params);
|
|
182
|
+
if (prePeekDecision !== undefined) return prePeekDecision;
|
|
183
|
+
const peek = await peekBatchBuffer(params);
|
|
184
|
+
const peekDecision = bufferedResolveOrDeadlineDecision(params, peek);
|
|
185
|
+
if (peekDecision !== undefined) return peekDecision;
|
|
186
|
+
if (peek.fireCount === 0) {
|
|
187
|
+
const waitDecision = await waitForAnyBatchWakeup(params);
|
|
188
|
+
if (waitDecision !== undefined) return waitDecision;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (batchIsReadyToFire(params.batchConfig, peek)) return 'fire';
|
|
192
|
+
const sleepMs = nextBatchWindowMs(params.batchConfig, peek);
|
|
193
|
+
if (sleepMs === undefined) {
|
|
194
|
+
const waitDecision = await waitForAnyBatchWakeup(params);
|
|
195
|
+
if (waitDecision !== undefined) return waitDecision;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const waitDecision = await waitForBatchWindow(params, sleepMs);
|
|
199
|
+
if (waitDecision !== undefined) return waitDecision;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function resolutionOrDeadlineDecision(params) {
|
|
203
|
+
if (params.hasResolutionHint()) return 'resolve';
|
|
204
|
+
if (deadlineReached(params.listenerDeadline)) return 'deadline';
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
async function peekBatchBuffer(params) {
|
|
208
|
+
params.clearEventsHint();
|
|
209
|
+
return await peekListenerBufferActivity({
|
|
210
|
+
jobId: params.jobId
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function bufferedResolveOrDeadlineDecision(params, peek) {
|
|
214
|
+
if (peek.resolvePending || params.hasResolutionHint()) return 'resolve';
|
|
215
|
+
if (deadlineReached(params.listenerDeadline)) return 'deadline';
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
function batchIsReadyToFire(config, peek) {
|
|
219
|
+
const sizeReached = config.maxSizeEvents !== undefined && peek.fireCount >= config.maxSizeEvents;
|
|
220
|
+
const debounceQuiet = config.debounceMs !== undefined && peek.newestAgeMs >= config.debounceMs;
|
|
221
|
+
const maxWaitReached = config.maxWaitMs !== undefined && peek.oldestAgeMs >= config.maxWaitMs;
|
|
222
|
+
return sizeReached || debounceQuiet || maxWaitReached;
|
|
223
|
+
}
|
|
224
|
+
function nextBatchWindowMs(config, peek) {
|
|
225
|
+
const timeWindows = [
|
|
226
|
+
remainingWindowMs(config.debounceMs, peek.newestAgeMs),
|
|
227
|
+
remainingWindowMs(config.maxWaitMs, peek.oldestAgeMs)
|
|
228
|
+
].filter((value)=>value !== undefined);
|
|
229
|
+
return timeWindows.length === 0 ? undefined : Math.min(...timeWindows);
|
|
230
|
+
}
|
|
231
|
+
async function waitForAnyBatchWakeup(params) {
|
|
232
|
+
const woke = await waitForListenerWakeup(()=>params.hasEventsHint() || params.hasResolutionHint(), {
|
|
233
|
+
deadline: params.listenerDeadline
|
|
234
|
+
});
|
|
235
|
+
if (!woke && deadlineReached(params.listenerDeadline)) return 'deadline';
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
async function waitForBatchWindow(params, sleepMs) {
|
|
239
|
+
const deadlineRemaining = remainingMs(params.listenerDeadline);
|
|
240
|
+
const boundedSleepMs = deadlineRemaining === undefined ? sleepMs : Math.min(sleepMs, deadlineRemaining);
|
|
241
|
+
const wakesOnEvents = params.batchConfig.debounceMs !== undefined || params.batchConfig.maxSizeEvents !== undefined;
|
|
242
|
+
const woke = await condition(()=>params.hasResolutionHint() || wakesOnEvents && params.hasEventsHint() || deadlineReached(params.listenerDeadline), boundedSleepMs);
|
|
243
|
+
if (!woke && deadlineReached(params.listenerDeadline)) return 'deadline';
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
function positiveNumber(value) {
|
|
247
|
+
return value === undefined || value === null || value <= 0 ? undefined : value;
|
|
248
|
+
}
|
|
249
|
+
function remainingWindowMs(limitMs, ageMs) {
|
|
250
|
+
return limitMs === undefined ? undefined : Math.max(0, limitMs - ageMs);
|
|
251
|
+
}
|
|
252
|
+
async function runListenerExecution(params) {
|
|
253
|
+
const scope = new CancellationScope();
|
|
254
|
+
const child = scope.run(()=>executeChild(jobExecutionOrchestration, {
|
|
255
|
+
workflowId: `job:${params.input.jobId}`,
|
|
256
|
+
workflowIdReusePolicy: 'ALLOW_DUPLICATE',
|
|
257
|
+
args: [
|
|
258
|
+
{
|
|
259
|
+
workspaceId: params.input.workspaceId,
|
|
260
|
+
workflowRunId: params.input.workflowRunId,
|
|
261
|
+
projectId: params.input.projectId,
|
|
262
|
+
jobId: params.input.jobId,
|
|
263
|
+
jobExecutionId: params.jobExecutionId,
|
|
264
|
+
runAttemptId: params.input.runAttemptId,
|
|
265
|
+
jobVersion: params.input.jobVersion,
|
|
266
|
+
executionVersion: params.executionVersion,
|
|
267
|
+
...params.input.executionTimeoutMs === undefined ? {} : {
|
|
268
|
+
executionTimeoutMs: params.input.executionTimeoutMs
|
|
269
|
+
},
|
|
270
|
+
resolveJobStatus: false,
|
|
271
|
+
requiredLabels: params.requiredLabels
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
parentClosePolicy: ParentClosePolicy.TERMINATE
|
|
275
|
+
}));
|
|
276
|
+
if (params.input.onResolve === 'cancel') {
|
|
277
|
+
const winner = await Promise.race([
|
|
278
|
+
child.then(()=>'child', ()=>'child-failed'),
|
|
279
|
+
params.waitForResolution().then(()=>'resolution')
|
|
280
|
+
]);
|
|
281
|
+
if (winner === 'resolution' && params.shouldCancelForResolution()) {
|
|
282
|
+
scope.cancel();
|
|
283
|
+
await settleListenerJobExecutionActivity({
|
|
284
|
+
jobExecutionId: params.jobExecutionId,
|
|
285
|
+
status: 'cancelled'
|
|
286
|
+
});
|
|
287
|
+
await recordListenerFiringOutcomeActivity({
|
|
288
|
+
outcome: 'cancelled'
|
|
289
|
+
});
|
|
290
|
+
await cancelRunnerJobsActivity({
|
|
291
|
+
jobIds: [
|
|
292
|
+
params.input.jobId
|
|
293
|
+
]
|
|
294
|
+
});
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
try {
|
|
299
|
+
const result = await child;
|
|
300
|
+
await recordListenerFiringOutcomeActivity({
|
|
301
|
+
outcome: listenerFiringOutcome(result.status)
|
|
302
|
+
});
|
|
303
|
+
} catch (error) {
|
|
304
|
+
log.warn('listener execution child failed; recording failed firing and continuing', {
|
|
305
|
+
jobId: params.input.jobId,
|
|
306
|
+
jobExecutionId: params.jobExecutionId,
|
|
307
|
+
error: String(error)
|
|
308
|
+
});
|
|
309
|
+
await settleListenerJobExecutionActivity({
|
|
310
|
+
jobExecutionId: params.jobExecutionId,
|
|
311
|
+
status: 'failed'
|
|
312
|
+
});
|
|
313
|
+
await recordListenerFiringOutcomeActivity({
|
|
314
|
+
outcome: 'failed'
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function listenerFiringOutcome(status) {
|
|
319
|
+
if (status === 'succeeded' || status === 'failed' || status === 'cancelled') return status;
|
|
320
|
+
throw new Error(`Listener execution cannot finish with status: ${status}`);
|
|
321
|
+
}
|
|
322
|
+
async function waitForListenerWakeup(predicate, options) {
|
|
323
|
+
const remaining = remainingMs(options.deadline);
|
|
324
|
+
if (remaining !== undefined && remaining <= 0) return false;
|
|
325
|
+
if (remaining === undefined) {
|
|
326
|
+
await condition(predicate);
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
return await condition(predicate, remaining);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
//# sourceMappingURL=job-listener-orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/job-listener-orchestration.ts"],"sourcesContent":["import {\n CancellationScope,\n condition,\n continueAsNew,\n defineSignal,\n executeChild,\n log,\n ParentClosePolicy,\n proxyActivities,\n setHandler,\n workflowInfo,\n} from '@temporalio/workflow';\nimport type {ResolutionReason} from '#core/entities/job.js';\nimport {runtimeStatusForTerminalJobExecutionStatus} from '#core/job-execution-outcome.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport type {createOrchestrationActivities} from '../activities/index.js';\nimport {LISTENER_EVENTS_AVAILABLE_SIGNAL, LISTENER_RESOLVE_SIGNAL} from '../constants.js';\nimport {deadlineReached, remainingMs} from './deadline.js';\nimport {jobExecutionOrchestration} from './job-execution-orchestration.js';\n\nconst {\n activateJobListenerActivity,\n drainListenerEventsActivity,\n peekListenerBufferActivity,\n resolveJobListenerActivity,\n settleListenerJobExecutionActivity,\n recordListenerFiringOutcomeActivity,\n cancelRunnerJobsActivity,\n} = proxyActivities<ReturnType<typeof createOrchestrationActivities>>({\n startToCloseTimeout: '30s',\n});\n\nexport const listenerEventsAvailableSignal = defineSignal<[]>(LISTENER_EVENTS_AVAILABLE_SIGNAL);\nexport const listenerResolveSignal = defineSignal<[]>(LISTENER_RESOLVE_SIGNAL);\n\nexport interface JobListenerOrchestrationInput {\n workspaceId: string;\n workflowRunId: string;\n projectId: string;\n runAttemptId: string;\n jobId: string;\n jobVersion: number;\n requiredLabels: string[];\n executionTimeoutMs?: number | null | undefined;\n listeningTimeoutMs?: number | null | undefined;\n maxExecutions?: number | null | undefined;\n onResolve?: 'finish' | 'cancel' | null | undefined;\n batchDebounceMs?: number | null | undefined;\n batchMaxSize?: number | null | undefined;\n batchMaxWaitMs?: number | null | undefined;\n continuation?: ListenerContinuationState | undefined;\n}\n\nexport interface JobListenerOrchestrationResult {\n status: RuntimeCompletionStatus;\n jobVersion: number;\n}\n\ntype ResolutionLatch = Exclude<ResolutionReason, 'cancelled'> | undefined;\ntype BatchFiringDecision = 'fire' | 'resolve' | 'deadline';\n\nexport interface ListenerContinuationState {\n nextSequence: number;\n latchedReason?: ResolutionLatch;\n listenerDeadline?: number | undefined;\n}\n\nexport const LISTENER_CONTINUE_AS_NEW_FIRING_LIMIT = 500;\n\ninterface ListenerBatchConfig {\n debounceMs?: number | undefined;\n maxSizeEvents?: number | undefined;\n maxWaitMs?: number | undefined;\n}\n\ninterface BatchFiringWindowParams {\n jobId: string;\n batchConfig: ListenerBatchConfig;\n listenerDeadline: number | undefined;\n hasEventsHint: () => boolean;\n clearEventsHint: () => void;\n hasResolutionHint: () => boolean;\n}\n\ninterface ListenerBufferPeek {\n fireCount: number;\n resolvePending: boolean;\n oldestAgeMs: number;\n newestAgeMs: number;\n}\n\nexport async function jobListenerOrchestration(\n input: JobListenerOrchestrationInput,\n): Promise<JobListenerOrchestrationResult> {\n let eventsAvailable = false;\n let latchedReason = input.continuation?.latchedReason;\n\n setHandler(listenerEventsAvailableSignal, () => {\n eventsAvailable = true;\n });\n setHandler(listenerResolveSignal, () => {\n latchedReason = 'until';\n });\n\n const listenerDeadline = input.continuation?.listenerDeadline ?? initialListenerDeadline(input);\n\n let nextSequence: number;\n if (input.continuation) {\n nextSequence = input.continuation.nextSequence;\n } else {\n const activated = await activateJobListenerActivity({\n jobId: input.jobId,\n expectedVersion: input.jobVersion,\n });\n if (activated.status === 'terminal') {\n return {\n status: runtimeStatusForTerminalJobExecutionStatus(activated.jobStatus),\n jobVersion: activated.jobVersion,\n };\n }\n nextSequence = activated.executionCount + 1;\n }\n\n let firingsInCurrentRun = 0;\n const maxExecutions = input.maxExecutions ?? undefined;\n const batchConfig = listenerBatchConfig(input);\n while (true) {\n if (deadlineReached(listenerDeadline)) latchedReason ??= 'timeout';\n await continueListenerAsNewIfNeeded({\n input,\n nextSequence,\n latchedReason,\n listenerDeadline,\n firingsInCurrentRun,\n });\n if (latchedReason !== undefined) break;\n if (maxExecutions !== undefined) {\n if (nextSequence > maxExecutions) {\n latchedReason = 'max_executions';\n await continueListenerAsNewIfNeeded({\n input,\n nextSequence,\n latchedReason,\n listenerDeadline,\n firingsInCurrentRun,\n });\n break;\n }\n }\n\n if (batchConfig !== undefined) {\n const decision = await awaitBatchFiringWindow({\n jobId: input.jobId,\n batchConfig,\n listenerDeadline,\n hasEventsHint: () => eventsAvailable,\n clearEventsHint: () => {\n eventsAvailable = false;\n },\n hasResolutionHint: () => latchedReason !== undefined,\n });\n if (decision === 'resolve') {\n latchedReason ??= 'until';\n break;\n }\n if (decision === 'deadline') {\n latchedReason ??= 'timeout';\n break;\n }\n }\n\n eventsAvailable = false;\n const drained = await drainListenerEventsActivity({\n jobId: input.jobId,\n expectedSequence: nextSequence,\n ...(batchConfig?.maxSizeEvents === undefined ? {} : {maxSize: batchConfig.maxSizeEvents}),\n });\n\n if (drained.kind === 'resolve-requested') {\n latchedReason = 'until';\n break;\n }\n\n if (drained.kind === 'empty') {\n const woke = await waitForListenerWakeup(\n () => eventsAvailable || latchedReason !== undefined,\n {deadline: listenerDeadline},\n );\n if (!woke && deadlineReached(listenerDeadline)) latchedReason = 'timeout';\n continue;\n }\n\n if (drained.status === 'failed') {\n await recordListenerFiringOutcomeActivity({outcome: 'failed'});\n nextSequence = drained.sequence + 1;\n firingsInCurrentRun += 1;\n if (maxExecutions !== undefined && drained.sequence >= maxExecutions) {\n latchedReason = 'max_executions';\n }\n continue;\n }\n\n await runListenerExecution({\n input,\n jobExecutionId: drained.jobExecutionId,\n executionVersion: drained.executionVersion,\n requiredLabels: drained.requiredLabels,\n shouldCancelForResolution: () =>\n input.onResolve === 'cancel' &&\n (latchedReason !== undefined || deadlineReached(listenerDeadline)),\n waitForResolution: () =>\n waitForListenerWakeup(\n () => latchedReason !== undefined || deadlineReached(listenerDeadline),\n {deadline: listenerDeadline},\n ),\n });\n\n if (deadlineReached(listenerDeadline)) latchedReason ??= 'timeout';\n nextSequence = drained.sequence + 1;\n firingsInCurrentRun += 1;\n if (maxExecutions !== undefined && drained.sequence >= maxExecutions) {\n latchedReason = 'max_executions';\n }\n }\n\n const reason = latchedReason ?? 'timeout';\n const resolved = await resolveJobListenerActivity({jobId: input.jobId, reason});\n return {status: resolved.status, jobVersion: resolved.jobVersion};\n}\n\nfunction initialListenerDeadline(input: JobListenerOrchestrationInput): number | undefined {\n return input.listeningTimeoutMs === undefined || input.listeningTimeoutMs === null\n ? undefined\n : Date.now() + input.listeningTimeoutMs;\n}\n\nasync function continueListenerAsNewIfNeeded(params: {\n input: JobListenerOrchestrationInput;\n nextSequence: number;\n latchedReason: ResolutionLatch;\n listenerDeadline: number | undefined;\n firingsInCurrentRun: number;\n}): Promise<void> {\n if (\n !shouldContinueListenerAsNew({\n firingsInCurrentRun: params.firingsInCurrentRun,\n continueAsNewSuggested: workflowInfo().continueAsNewSuggested,\n })\n ) {\n return;\n }\n\n await continueAsNew<typeof jobListenerOrchestration>(\n listenerContinuationInput(params.input, {\n nextSequence: params.nextSequence,\n latchedReason: params.latchedReason,\n listenerDeadline: params.listenerDeadline,\n }),\n );\n}\n\nexport function shouldContinueListenerAsNew(params: {\n firingsInCurrentRun: number;\n continueAsNewSuggested: boolean;\n}): boolean {\n return (\n params.continueAsNewSuggested ||\n params.firingsInCurrentRun >= LISTENER_CONTINUE_AS_NEW_FIRING_LIMIT\n );\n}\n\nexport function listenerContinuationInput(\n input: JobListenerOrchestrationInput,\n continuation: ListenerContinuationState,\n): JobListenerOrchestrationInput {\n return {...input, continuation};\n}\n\nfunction listenerBatchConfig(\n input: JobListenerOrchestrationInput,\n): ListenerBatchConfig | undefined {\n const debounceMs = positiveNumber(input.batchDebounceMs);\n const maxSizeEvents = positiveNumber(input.batchMaxSize);\n const maxWaitMs = positiveNumber(input.batchMaxWaitMs);\n if (debounceMs === undefined && maxSizeEvents === undefined && maxWaitMs === undefined) {\n return undefined;\n }\n return {debounceMs, maxSizeEvents, maxWaitMs};\n}\n\nasync function awaitBatchFiringWindow(\n params: BatchFiringWindowParams,\n): Promise<BatchFiringDecision> {\n while (true) {\n const prePeekDecision = resolutionOrDeadlineDecision(params);\n if (prePeekDecision !== undefined) return prePeekDecision;\n\n const peek = await peekBatchBuffer(params);\n const peekDecision = bufferedResolveOrDeadlineDecision(params, peek);\n if (peekDecision !== undefined) return peekDecision;\n\n if (peek.fireCount === 0) {\n const waitDecision = await waitForAnyBatchWakeup(params);\n if (waitDecision !== undefined) return waitDecision;\n continue;\n }\n\n if (batchIsReadyToFire(params.batchConfig, peek)) return 'fire';\n\n const sleepMs = nextBatchWindowMs(params.batchConfig, peek);\n if (sleepMs === undefined) {\n const waitDecision = await waitForAnyBatchWakeup(params);\n if (waitDecision !== undefined) return waitDecision;\n continue;\n }\n\n const waitDecision = await waitForBatchWindow(params, sleepMs);\n if (waitDecision !== undefined) return waitDecision;\n }\n}\n\nfunction resolutionOrDeadlineDecision(\n params: BatchFiringWindowParams,\n): Exclude<BatchFiringDecision, 'fire'> | undefined {\n if (params.hasResolutionHint()) return 'resolve';\n if (deadlineReached(params.listenerDeadline)) return 'deadline';\n return undefined;\n}\n\nasync function peekBatchBuffer(params: BatchFiringWindowParams): Promise<ListenerBufferPeek> {\n params.clearEventsHint();\n return await peekListenerBufferActivity({jobId: params.jobId});\n}\n\nfunction bufferedResolveOrDeadlineDecision(\n params: BatchFiringWindowParams,\n peek: ListenerBufferPeek,\n): Exclude<BatchFiringDecision, 'fire'> | undefined {\n if (peek.resolvePending || params.hasResolutionHint()) return 'resolve';\n if (deadlineReached(params.listenerDeadline)) return 'deadline';\n return undefined;\n}\n\nfunction batchIsReadyToFire(config: ListenerBatchConfig, peek: ListenerBufferPeek): boolean {\n const sizeReached = config.maxSizeEvents !== undefined && peek.fireCount >= config.maxSizeEvents;\n const debounceQuiet = config.debounceMs !== undefined && peek.newestAgeMs >= config.debounceMs;\n const maxWaitReached = config.maxWaitMs !== undefined && peek.oldestAgeMs >= config.maxWaitMs;\n return sizeReached || debounceQuiet || maxWaitReached;\n}\n\nfunction nextBatchWindowMs(\n config: ListenerBatchConfig,\n peek: ListenerBufferPeek,\n): number | undefined {\n const timeWindows = [\n remainingWindowMs(config.debounceMs, peek.newestAgeMs),\n remainingWindowMs(config.maxWaitMs, peek.oldestAgeMs),\n ].filter((value): value is number => value !== undefined);\n return timeWindows.length === 0 ? undefined : Math.min(...timeWindows);\n}\n\nasync function waitForAnyBatchWakeup(\n params: BatchFiringWindowParams,\n): Promise<Exclude<BatchFiringDecision, 'fire'> | undefined> {\n const woke = await waitForListenerWakeup(\n () => params.hasEventsHint() || params.hasResolutionHint(),\n {deadline: params.listenerDeadline},\n );\n if (!woke && deadlineReached(params.listenerDeadline)) return 'deadline';\n return undefined;\n}\n\nasync function waitForBatchWindow(\n params: BatchFiringWindowParams,\n sleepMs: number,\n): Promise<Exclude<BatchFiringDecision, 'fire'> | undefined> {\n const deadlineRemaining = remainingMs(params.listenerDeadline);\n const boundedSleepMs =\n deadlineRemaining === undefined ? sleepMs : Math.min(sleepMs, deadlineRemaining);\n const wakesOnEvents =\n params.batchConfig.debounceMs !== undefined || params.batchConfig.maxSizeEvents !== undefined;\n const woke = await condition(\n () =>\n params.hasResolutionHint() ||\n (wakesOnEvents && params.hasEventsHint()) ||\n deadlineReached(params.listenerDeadline),\n boundedSleepMs,\n );\n if (!woke && deadlineReached(params.listenerDeadline)) return 'deadline';\n return undefined;\n}\n\nfunction positiveNumber(value: number | null | undefined): number | undefined {\n return value === undefined || value === null || value <= 0 ? undefined : value;\n}\n\nfunction remainingWindowMs(limitMs: number | undefined, ageMs: number): number | undefined {\n return limitMs === undefined ? undefined : Math.max(0, limitMs - ageMs);\n}\n\nasync function runListenerExecution(params: {\n input: JobListenerOrchestrationInput;\n jobExecutionId: string;\n executionVersion: number;\n requiredLabels: string[];\n shouldCancelForResolution: () => boolean;\n waitForResolution: () => Promise<boolean>;\n}): Promise<void> {\n const scope = new CancellationScope();\n const child = scope.run(() =>\n executeChild(jobExecutionOrchestration, {\n workflowId: `job:${params.input.jobId}`,\n workflowIdReusePolicy: 'ALLOW_DUPLICATE',\n args: [\n {\n workspaceId: params.input.workspaceId,\n workflowRunId: params.input.workflowRunId,\n projectId: params.input.projectId,\n jobId: params.input.jobId,\n jobExecutionId: params.jobExecutionId,\n runAttemptId: params.input.runAttemptId,\n jobVersion: params.input.jobVersion,\n executionVersion: params.executionVersion,\n ...(params.input.executionTimeoutMs === undefined\n ? {}\n : {executionTimeoutMs: params.input.executionTimeoutMs}),\n resolveJobStatus: false,\n requiredLabels: params.requiredLabels,\n },\n ],\n parentClosePolicy: ParentClosePolicy.TERMINATE,\n }),\n );\n\n if (params.input.onResolve === 'cancel') {\n const winner = await Promise.race([\n child.then(\n () => 'child' as const,\n () => 'child-failed' as const,\n ),\n params.waitForResolution().then(() => 'resolution' as const),\n ]);\n if (winner === 'resolution' && params.shouldCancelForResolution()) {\n scope.cancel();\n await settleListenerJobExecutionActivity({\n jobExecutionId: params.jobExecutionId,\n status: 'cancelled',\n });\n await recordListenerFiringOutcomeActivity({outcome: 'cancelled'});\n await cancelRunnerJobsActivity({jobIds: [params.input.jobId]});\n return;\n }\n }\n\n try {\n const result = await child;\n await recordListenerFiringOutcomeActivity({outcome: listenerFiringOutcome(result.status)});\n } catch (error) {\n log.warn('listener execution child failed; recording failed firing and continuing', {\n jobId: params.input.jobId,\n jobExecutionId: params.jobExecutionId,\n error: String(error),\n });\n await settleListenerJobExecutionActivity({\n jobExecutionId: params.jobExecutionId,\n status: 'failed',\n });\n await recordListenerFiringOutcomeActivity({outcome: 'failed'});\n }\n}\n\nfunction listenerFiringOutcome(\n status: RuntimeCompletionStatus,\n): 'succeeded' | 'failed' | 'cancelled' {\n if (status === 'succeeded' || status === 'failed' || status === 'cancelled') return status;\n throw new Error(`Listener execution cannot finish with status: ${status}`);\n}\n\nasync function waitForListenerWakeup(\n predicate: () => boolean,\n options: {deadline: number | undefined},\n): Promise<boolean> {\n const remaining = remainingMs(options.deadline);\n if (remaining !== undefined && remaining <= 0) return false;\n if (remaining === undefined) {\n await condition(predicate);\n return true;\n }\n return await condition(predicate, remaining);\n}\n"],"names":["CancellationScope","condition","continueAsNew","defineSignal","executeChild","log","ParentClosePolicy","proxyActivities","setHandler","workflowInfo","runtimeStatusForTerminalJobExecutionStatus","LISTENER_EVENTS_AVAILABLE_SIGNAL","LISTENER_RESOLVE_SIGNAL","deadlineReached","remainingMs","jobExecutionOrchestration","activateJobListenerActivity","drainListenerEventsActivity","peekListenerBufferActivity","resolveJobListenerActivity","settleListenerJobExecutionActivity","recordListenerFiringOutcomeActivity","cancelRunnerJobsActivity","startToCloseTimeout","listenerEventsAvailableSignal","listenerResolveSignal","LISTENER_CONTINUE_AS_NEW_FIRING_LIMIT","jobListenerOrchestration","input","eventsAvailable","latchedReason","continuation","listenerDeadline","initialListenerDeadline","nextSequence","activated","jobId","expectedVersion","jobVersion","status","jobStatus","executionCount","firingsInCurrentRun","maxExecutions","undefined","batchConfig","listenerBatchConfig","continueListenerAsNewIfNeeded","decision","awaitBatchFiringWindow","hasEventsHint","clearEventsHint","hasResolutionHint","drained","expectedSequence","maxSizeEvents","maxSize","kind","woke","waitForListenerWakeup","deadline","outcome","sequence","runListenerExecution","jobExecutionId","executionVersion","requiredLabels","shouldCancelForResolution","onResolve","waitForResolution","reason","resolved","listeningTimeoutMs","Date","now","params","shouldContinueListenerAsNew","continueAsNewSuggested","listenerContinuationInput","debounceMs","positiveNumber","batchDebounceMs","batchMaxSize","maxWaitMs","batchMaxWaitMs","prePeekDecision","resolutionOrDeadlineDecision","peek","peekBatchBuffer","peekDecision","bufferedResolveOrDeadlineDecision","fireCount","waitDecision","waitForAnyBatchWakeup","batchIsReadyToFire","sleepMs","nextBatchWindowMs","waitForBatchWindow","resolvePending","config","sizeReached","debounceQuiet","newestAgeMs","maxWaitReached","oldestAgeMs","timeWindows","remainingWindowMs","filter","value","length","Math","min","deadlineRemaining","boundedSleepMs","wakesOnEvents","limitMs","ageMs","max","scope","child","run","workflowId","workflowIdReusePolicy","args","workspaceId","workflowRunId","projectId","runAttemptId","executionTimeoutMs","resolveJobStatus","parentClosePolicy","TERMINATE","winner","Promise","race","then","cancel","jobIds","result","listenerFiringOutcome","error","warn","String","Error","predicate","options","remaining"],"mappings":"AAAA,SACEA,iBAAiB,EACjBC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,GAAG,EACHC,iBAAiB,EACjBC,eAAe,EACfC,UAAU,EACVC,YAAY,QACP,uBAAuB;AAE9B,SAAQC,0CAA0C,QAAO,iCAAiC;AAG1F,SAAQC,gCAAgC,EAAEC,uBAAuB,QAAO,kBAAkB;AAC1F,SAAQC,eAAe,EAAEC,WAAW,QAAO,gBAAgB;AAC3D,SAAQC,yBAAyB,QAAO,mCAAmC;AAE3E,MAAM,EACJC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,0BAA0B,EAC1B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YmI,QAAQrF,QAAQ;IAC9C,IAAIsF,cAActG,aAAasG,aAAa,GAAG,OAAO;IACtD,IAAIA,cAActG,WAAW;QAC3B,MAAM3C,UAAU+I;QAChB,OAAO;IACT;IACA,OAAO,MAAM/I,UAAU+I,WAAWE;AACpC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const runCancelSignal: import("@temporalio/workflow").SignalDefinition<[], string>;
|
|
2
|
+
export interface RunOrchestrationInput {
|
|
3
|
+
workflowRunId: string;
|
|
4
|
+
runAttemptId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function runOrchestration(input: RunOrchestrationInput): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=run-orchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-orchestration.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/run-orchestration.ts"],"names":[],"mappings":"AA6CA,eAAO,MAAM,eAAe,6DAAsC,CAAC;AAEnE,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwGlF"}
|