@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,409 @@
|
|
|
1
|
+
import {randomUUID} from 'node:crypto';
|
|
2
|
+
import {
|
|
3
|
+
callsNamed,
|
|
4
|
+
dagJob,
|
|
5
|
+
makeDag,
|
|
6
|
+
resetCalls,
|
|
7
|
+
setCfg,
|
|
8
|
+
setJobStatusCalls,
|
|
9
|
+
setRunAttemptStatusCalls,
|
|
10
|
+
setupEnv,
|
|
11
|
+
TASK_QUEUE,
|
|
12
|
+
teardownEnv,
|
|
13
|
+
testEnv,
|
|
14
|
+
} from './test-env.js';
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
await setupEnv();
|
|
18
|
+
}, 60_000);
|
|
19
|
+
|
|
20
|
+
afterAll(async () => {
|
|
21
|
+
await teardownEnv();
|
|
22
|
+
}, 15_000);
|
|
23
|
+
|
|
24
|
+
let workflowRunId: string;
|
|
25
|
+
let workspaceId: string;
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
resetCalls();
|
|
29
|
+
workflowRunId = `run-${randomUUID()}`;
|
|
30
|
+
workspaceId = `workspace-${randomUUID()}`;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
async function executeRun(): Promise<void> {
|
|
34
|
+
await testEnv.client.workflow.execute('runOrchestration', {
|
|
35
|
+
taskQueue: TASK_QUEUE,
|
|
36
|
+
workflowId: `workflow-run-attempt:${workflowRunId}-attempt-1`,
|
|
37
|
+
args: [{workflowRunId, runAttemptId: `${workflowRunId}-attempt-1`, workspaceId}],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function waitForActivity(name: string): Promise<void> {
|
|
42
|
+
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
43
|
+
if (callsNamed(name).length > 0) return;
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Timed out waiting for ${name}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('runOrchestration', () => {
|
|
50
|
+
test('all-pending linear DAG enqueues every job and succeeds', async () => {
|
|
51
|
+
const jobs = [
|
|
52
|
+
dagJob('j1', 'build'),
|
|
53
|
+
dagJob('j2', 'test', ['build']),
|
|
54
|
+
dagJob('j3', 'deploy', ['test']),
|
|
55
|
+
];
|
|
56
|
+
setCfg({dag: makeDag(jobs, 'r1'), jobResults: new Map()});
|
|
57
|
+
|
|
58
|
+
await executeRun();
|
|
59
|
+
|
|
60
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
61
|
+
expect(runAttemptStatuses).toEqual(['running', 'succeeded']);
|
|
62
|
+
const enqueueCalls = callsNamed('enqueueJobExecutionForRunner');
|
|
63
|
+
expect(enqueueCalls).toHaveLength(3);
|
|
64
|
+
// The lease tuple is sourced from the loaded dag (workspace/project/run together).
|
|
65
|
+
for (const call of enqueueCalls) {
|
|
66
|
+
expect(call.params).toMatchObject({
|
|
67
|
+
workspaceId: 'workspace-1',
|
|
68
|
+
projectId: 'project-1',
|
|
69
|
+
runAttemptId: 'r1-attempt-1',
|
|
70
|
+
requiredLabels: ['ubuntu22'],
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('already-succeeded upstream jobs are not re-enqueued', async () => {
|
|
76
|
+
const jobs = [
|
|
77
|
+
dagJob('j1', 'build', [], {status: 'succeeded'}),
|
|
78
|
+
dagJob('j2', 'test', ['build']),
|
|
79
|
+
];
|
|
80
|
+
setCfg({dag: makeDag(jobs, 'r1-carried'), jobResults: new Map([['j2', 'succeeded']])});
|
|
81
|
+
|
|
82
|
+
await executeRun();
|
|
83
|
+
|
|
84
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
85
|
+
expect(runAttemptStatuses).toEqual(['running', 'succeeded']);
|
|
86
|
+
const enqueueCalls = callsNamed('enqueueJobExecutionForRunner');
|
|
87
|
+
expect(enqueueCalls).toHaveLength(1);
|
|
88
|
+
expect(enqueueCalls[0]?.params).toMatchObject({jobId: 'j2'});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('already-succeeded upstream jobs can unblock a failed retry', async () => {
|
|
92
|
+
const jobs = [
|
|
93
|
+
dagJob('j1', 'build', [], {status: 'succeeded'}),
|
|
94
|
+
dagJob('j2', 'test', ['build']),
|
|
95
|
+
];
|
|
96
|
+
setCfg({dag: makeDag(jobs, 'r1-carried-failed'), jobResults: new Map([['j2', 'failed']])});
|
|
97
|
+
|
|
98
|
+
await executeRun();
|
|
99
|
+
|
|
100
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
101
|
+
expect(runAttemptStatuses).toEqual(['running', 'failed']);
|
|
102
|
+
const enqueueCalls = callsNamed('enqueueJobExecutionForRunner');
|
|
103
|
+
expect(enqueueCalls).toHaveLength(1);
|
|
104
|
+
expect(enqueueCalls[0]?.params).toMatchObject({jobId: 'j2'});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('parallel roots both succeed', async () => {
|
|
108
|
+
const jobs = [
|
|
109
|
+
dagJob('j1', 'lint'),
|
|
110
|
+
dagJob('j2', 'test'),
|
|
111
|
+
dagJob('j3', 'deploy', ['lint', 'test']),
|
|
112
|
+
];
|
|
113
|
+
setCfg({dag: makeDag(jobs, 'r2'), jobResults: new Map()});
|
|
114
|
+
|
|
115
|
+
await executeRun();
|
|
116
|
+
|
|
117
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
118
|
+
expect(runAttemptStatuses).toEqual(['running', 'succeeded']);
|
|
119
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(3);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('single job fails, dependents are skipped', async () => {
|
|
123
|
+
const jobs = [
|
|
124
|
+
dagJob('j1', 'build'),
|
|
125
|
+
dagJob('j2', 'test', ['build']),
|
|
126
|
+
dagJob('j3', 'deploy', ['test']),
|
|
127
|
+
];
|
|
128
|
+
setCfg({dag: makeDag(jobs, 'r3'), jobResults: new Map([['j1', 'failed']])});
|
|
129
|
+
|
|
130
|
+
await executeRun();
|
|
131
|
+
|
|
132
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
133
|
+
expect(runAttemptStatuses).toEqual(['running', 'failed']);
|
|
134
|
+
|
|
135
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(1);
|
|
136
|
+
const jobStatuses = setJobStatusCalls().map((c) => ({
|
|
137
|
+
id: c.params.jobId,
|
|
138
|
+
status: c.params.status,
|
|
139
|
+
statusReason: c.params.statusReason ?? null,
|
|
140
|
+
}));
|
|
141
|
+
expect(jobStatuses).toContainEqual({
|
|
142
|
+
id: 'j2',
|
|
143
|
+
status: 'skipped',
|
|
144
|
+
statusReason: 'default_gate_rejected',
|
|
145
|
+
});
|
|
146
|
+
expect(jobStatuses).toContainEqual({
|
|
147
|
+
id: 'j3',
|
|
148
|
+
status: 'skipped',
|
|
149
|
+
statusReason: 'default_gate_rejected',
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('first job fails, all downstream skipped', async () => {
|
|
154
|
+
const jobs = [
|
|
155
|
+
dagJob('j1', 'build'),
|
|
156
|
+
dagJob('j2', 'a', ['build']),
|
|
157
|
+
dagJob('j3', 'b', ['build']),
|
|
158
|
+
];
|
|
159
|
+
setCfg({dag: makeDag(jobs, 'r4'), jobResults: new Map([['j1', 'failed']])});
|
|
160
|
+
|
|
161
|
+
await executeRun();
|
|
162
|
+
|
|
163
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
164
|
+
expect(runAttemptStatuses).toEqual(['running', 'failed']);
|
|
165
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(1);
|
|
166
|
+
|
|
167
|
+
const jobStatuses = setJobStatusCalls().map((c) => ({
|
|
168
|
+
id: c.params.jobId,
|
|
169
|
+
status: c.params.status,
|
|
170
|
+
statusReason: c.params.statusReason ?? null,
|
|
171
|
+
}));
|
|
172
|
+
expect(jobStatuses).toContainEqual({
|
|
173
|
+
id: 'j2',
|
|
174
|
+
status: 'skipped',
|
|
175
|
+
statusReason: 'default_gate_rejected',
|
|
176
|
+
});
|
|
177
|
+
expect(jobStatuses).toContainEqual({
|
|
178
|
+
id: 'j3',
|
|
179
|
+
status: 'skipped',
|
|
180
|
+
statusReason: 'default_gate_rejected',
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('explicit-if failure handler runs after a failed dependency', async () => {
|
|
185
|
+
const jobs = [
|
|
186
|
+
dagJob('j1', 'build'),
|
|
187
|
+
dagJob('j2', 'notify', ['build'], {hasActivationCondition: true}),
|
|
188
|
+
];
|
|
189
|
+
setCfg({dag: makeDag(jobs, 'r-job-if-failed'), jobResults: new Map([['j1', 'failed']])});
|
|
190
|
+
|
|
191
|
+
await executeRun();
|
|
192
|
+
|
|
193
|
+
expect(callsNamed('evaluateJobActivationsActivity')).toEqual([
|
|
194
|
+
{
|
|
195
|
+
name: 'evaluateJobActivationsActivity',
|
|
196
|
+
params: {
|
|
197
|
+
runAttemptId: `${workflowRunId}-attempt-1`,
|
|
198
|
+
jobs: [{jobId: 'j2', expectedVersion: 1}],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
]);
|
|
202
|
+
expect(callsNamed('enqueueJobExecutionForRunner').map((call) => call.params)).toEqual([
|
|
203
|
+
expect.objectContaining({jobId: 'j1'}),
|
|
204
|
+
expect.objectContaining({jobId: 'j2'}),
|
|
205
|
+
]);
|
|
206
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual(['running', 'failed']);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('explicit-if job skips when activation evaluation rejects it', async () => {
|
|
210
|
+
const jobs = [
|
|
211
|
+
dagJob('j1', 'build'),
|
|
212
|
+
dagJob('j2', 'notify', ['build'], {hasActivationCondition: true}),
|
|
213
|
+
];
|
|
214
|
+
setCfg({
|
|
215
|
+
dag: makeDag(jobs, 'r-job-if-rejected'),
|
|
216
|
+
jobResults: new Map(),
|
|
217
|
+
activationDecisions: new Map([
|
|
218
|
+
['j2', {kind: 'terminal-job', jobId: 'j2', status: 'skipped', jobVersion: 7}],
|
|
219
|
+
]),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
await executeRun();
|
|
223
|
+
|
|
224
|
+
expect(callsNamed('enqueueJobExecutionForRunner').map((call) => call.params)).toEqual([
|
|
225
|
+
expect.objectContaining({jobId: 'j1'}),
|
|
226
|
+
]);
|
|
227
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual([
|
|
228
|
+
'running',
|
|
229
|
+
'succeeded',
|
|
230
|
+
]);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test('fan-in explicit-if job activates after every need is terminal', async () => {
|
|
234
|
+
const jobs = [
|
|
235
|
+
dagJob('j1', 'build'),
|
|
236
|
+
dagJob('j2', 'lint'),
|
|
237
|
+
dagJob('j3', 'notify', ['build', 'lint'], {hasActivationCondition: true}),
|
|
238
|
+
];
|
|
239
|
+
setCfg({dag: makeDag(jobs, 'r-job-if-fanin'), jobResults: new Map([['j1', 'failed']])});
|
|
240
|
+
|
|
241
|
+
await executeRun();
|
|
242
|
+
|
|
243
|
+
expect(callsNamed('evaluateJobActivationsActivity')).toEqual([
|
|
244
|
+
{
|
|
245
|
+
name: 'evaluateJobActivationsActivity',
|
|
246
|
+
params: {
|
|
247
|
+
runAttemptId: `${workflowRunId}-attempt-1`,
|
|
248
|
+
jobs: [{jobId: 'j3', expectedVersion: 1}],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
]);
|
|
252
|
+
const enqueuedJobs = callsNamed('enqueueJobExecutionForRunner').map((call) => call.params);
|
|
253
|
+
expect(enqueuedJobs).toHaveLength(3);
|
|
254
|
+
expect(enqueuedJobs).toEqual(
|
|
255
|
+
expect.arrayContaining([
|
|
256
|
+
expect.objectContaining({jobId: 'j1'}),
|
|
257
|
+
expect.objectContaining({jobId: 'j2'}),
|
|
258
|
+
expect.objectContaining({jobId: 'j3'}),
|
|
259
|
+
]),
|
|
260
|
+
);
|
|
261
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual(['running', 'failed']);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test('all-skipped run completes succeeded', async () => {
|
|
265
|
+
const jobs = [dagJob('j1', 'notify', [], {hasActivationCondition: true})];
|
|
266
|
+
setCfg({
|
|
267
|
+
dag: makeDag(jobs, 'r-all-skipped'),
|
|
268
|
+
jobResults: new Map(),
|
|
269
|
+
activationDecisions: new Map([
|
|
270
|
+
['j1', {kind: 'terminal-job', jobId: 'j1', status: 'skipped', jobVersion: 4}],
|
|
271
|
+
]),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
await executeRun();
|
|
275
|
+
|
|
276
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(0);
|
|
277
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual([
|
|
278
|
+
'running',
|
|
279
|
+
'succeeded',
|
|
280
|
+
]);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('explicit-if listening job skips before listener registration', async () => {
|
|
284
|
+
const jobs = [dagJob('j1', 'listen', [], {mode: 'listening', hasActivationCondition: true})];
|
|
285
|
+
setCfg({
|
|
286
|
+
dag: makeDag(jobs, 'r-listen-skipped'),
|
|
287
|
+
jobResults: new Map(),
|
|
288
|
+
activationDecisions: new Map([
|
|
289
|
+
['j1', {kind: 'terminal-job', jobId: 'j1', status: 'skipped', jobVersion: 4}],
|
|
290
|
+
]),
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
await executeRun();
|
|
294
|
+
|
|
295
|
+
expect(callsNamed('activateJobListenerActivity')).toHaveLength(0);
|
|
296
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual([
|
|
297
|
+
'running',
|
|
298
|
+
'succeeded',
|
|
299
|
+
]);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test('version tracking flows through correctly', async () => {
|
|
303
|
+
const jobs = [dagJob('j1', 'build')];
|
|
304
|
+
setCfg({dag: makeDag(jobs, 'r5'), jobResults: new Map()});
|
|
305
|
+
|
|
306
|
+
await executeRun();
|
|
307
|
+
|
|
308
|
+
// The final attempt status update should use the version returned by the first update.
|
|
309
|
+
const finalRunAttemptStatus = setRunAttemptStatusCalls().at(-1);
|
|
310
|
+
expect(finalRunAttemptStatus?.params.version).toBeGreaterThan(0);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test('cancel signal stops scheduling and fans out runner cancellation', async () => {
|
|
314
|
+
const jobs = [dagJob('j1', 'build'), dagJob('j2', 'deploy', ['build'])];
|
|
315
|
+
setCfg({dag: makeDag(jobs, 'r-cancel'), jobResults: new Map(), skipSignal: true});
|
|
316
|
+
|
|
317
|
+
const handle = await testEnv.client.workflow.start('runOrchestration', {
|
|
318
|
+
taskQueue: TASK_QUEUE,
|
|
319
|
+
workflowId: `run:${workflowRunId}`,
|
|
320
|
+
args: [{workflowRunId, workspaceId}],
|
|
321
|
+
});
|
|
322
|
+
await waitForActivity('enqueueJobExecutionForRunner');
|
|
323
|
+
|
|
324
|
+
await handle.signal('run-cancel');
|
|
325
|
+
await handle.result();
|
|
326
|
+
|
|
327
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual(['running']);
|
|
328
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(1);
|
|
329
|
+
expect(callsNamed('cancelRunnerJobsActivity')).toEqual([
|
|
330
|
+
{name: 'cancelRunnerJobsActivity', params: {jobIds: ['j1', 'j2']}},
|
|
331
|
+
]);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test('starts listening jobs and cancels them with the run', async () => {
|
|
335
|
+
const jobs = [dagJob('j1', 'listen', [], {mode: 'listening'})];
|
|
336
|
+
setCfg({dag: makeDag(jobs, 'r-listen'), jobResults: new Map()});
|
|
337
|
+
const runAttemptId = `${workflowRunId}-attempt-listen`;
|
|
338
|
+
|
|
339
|
+
const handle = await testEnv.client.workflow.start('runOrchestration', {
|
|
340
|
+
taskQueue: TASK_QUEUE,
|
|
341
|
+
workflowId: `workflow-run-attempt:${runAttemptId}`,
|
|
342
|
+
args: [{workflowRunId, runAttemptId, workspaceId}],
|
|
343
|
+
});
|
|
344
|
+
await waitForActivity('setRunAttemptStatus');
|
|
345
|
+
|
|
346
|
+
await handle.signal('run-cancel');
|
|
347
|
+
await handle.result();
|
|
348
|
+
|
|
349
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual(['running']);
|
|
350
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(0);
|
|
351
|
+
expect(callsNamed('cancelRunnerJobsActivity')).toEqual([
|
|
352
|
+
{name: 'cancelRunnerJobsActivity', params: {jobIds: ['j1']}},
|
|
353
|
+
]);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test('aborts early when the initial running write reports an already-terminal run', async () => {
|
|
357
|
+
const jobs = [dagJob('j1', 'build')];
|
|
358
|
+
setCfg({
|
|
359
|
+
dag: makeDag(jobs, 'r-terminal'),
|
|
360
|
+
jobResults: new Map(),
|
|
361
|
+
initialRunStatus: 'cancelled',
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
await executeRun();
|
|
365
|
+
|
|
366
|
+
expect(setRunAttemptStatusCalls().map((c) => c.params.status)).toEqual(['running']);
|
|
367
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(0);
|
|
368
|
+
expect(callsNamed('cancelRunnerJobsActivity')).toHaveLength(0);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
test('diamond DAG with partial failure', async () => {
|
|
372
|
+
const jobs = [
|
|
373
|
+
dagJob('j1', 'A'),
|
|
374
|
+
dagJob('j2', 'B', ['A']),
|
|
375
|
+
dagJob('j3', 'C', ['A']),
|
|
376
|
+
dagJob('j4', 'D', ['B', 'C']),
|
|
377
|
+
];
|
|
378
|
+
setCfg({dag: makeDag(jobs, 'r6'), jobResults: new Map([['j2', 'failed']])});
|
|
379
|
+
|
|
380
|
+
await executeRun();
|
|
381
|
+
|
|
382
|
+
const runAttemptStatuses = setRunAttemptStatusCalls().map((c) => c.params.status);
|
|
383
|
+
expect(runAttemptStatuses).toEqual(['running', 'failed']);
|
|
384
|
+
|
|
385
|
+
// A, B, C enqueued — D skipped because B failed
|
|
386
|
+
expect(callsNamed('enqueueJobExecutionForRunner')).toHaveLength(3);
|
|
387
|
+
const jobStatuses = setJobStatusCalls().map((c) => ({
|
|
388
|
+
id: c.params.jobId,
|
|
389
|
+
status: c.params.status,
|
|
390
|
+
statusReason: c.params.statusReason ?? null,
|
|
391
|
+
}));
|
|
392
|
+
expect(jobStatuses).toContainEqual({
|
|
393
|
+
id: 'j4',
|
|
394
|
+
status: 'skipped',
|
|
395
|
+
statusReason: 'default_gate_rejected',
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
test('child workflow crash propagates to parent', async () => {
|
|
400
|
+
const jobs = [dagJob('j1', 'build')];
|
|
401
|
+
setCfg({
|
|
402
|
+
dag: makeDag(jobs, 'r7'),
|
|
403
|
+
jobResults: new Map(),
|
|
404
|
+
enqueueError: 'Runner service unavailable',
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
await expect(executeRun()).rejects.toThrow();
|
|
408
|
+
});
|
|
409
|
+
});
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
condition,
|
|
3
|
+
defineSignal,
|
|
4
|
+
executeChild,
|
|
5
|
+
log,
|
|
6
|
+
ParentClosePolicy,
|
|
7
|
+
proxyActivities,
|
|
8
|
+
setHandler,
|
|
9
|
+
} from '@temporalio/workflow';
|
|
10
|
+
import {
|
|
11
|
+
createRuntimeRunProgress,
|
|
12
|
+
nonCompletedRuntimeJobIds,
|
|
13
|
+
type RuntimeRunProgress,
|
|
14
|
+
recordRuntimeJobResult,
|
|
15
|
+
recordSkippedRuntimeJob,
|
|
16
|
+
runtimeJobVersion,
|
|
17
|
+
shouldContinueStartedRun,
|
|
18
|
+
} from '#core/workflow-scheduling/run-progress.js';
|
|
19
|
+
import type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';
|
|
20
|
+
import {scheduleRuntimeDag} from '#core/workflow-scheduling/schedule-runtime-dag.js';
|
|
21
|
+
|
|
22
|
+
import type {createOrchestrationActivities} from '../activities/index.js';
|
|
23
|
+
import type {DagJob, RunDag} from '../activities/orchestration-activities.js';
|
|
24
|
+
import {RUN_CANCEL_SIGNAL} from '../constants.js';
|
|
25
|
+
import {deadlineReached, remainingMs} from './deadline.js';
|
|
26
|
+
import {jobExecutionOrchestration} from './job-execution-orchestration.js';
|
|
27
|
+
import {jobListenerOrchestration} from './job-listener-orchestration.js';
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
loadRunAttemptDag,
|
|
31
|
+
evaluateJobActivationsActivity,
|
|
32
|
+
setRunAttemptStatus,
|
|
33
|
+
setJobStatus,
|
|
34
|
+
cancelRunnerJobsActivity,
|
|
35
|
+
} = proxyActivities<ReturnType<typeof createOrchestrationActivities>>({
|
|
36
|
+
startToCloseTimeout: '30s',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const {failRunAsTimedOutActivity} = proxyActivities<
|
|
40
|
+
ReturnType<typeof createOrchestrationActivities>
|
|
41
|
+
>({
|
|
42
|
+
startToCloseTimeout: '30s',
|
|
43
|
+
retry: {maximumAttempts: 5},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const runCancelSignal = defineSignal<[]>(RUN_CANCEL_SIGNAL);
|
|
47
|
+
|
|
48
|
+
export interface RunOrchestrationInput {
|
|
49
|
+
workflowRunId: string;
|
|
50
|
+
runAttemptId: string;
|
|
51
|
+
workspaceId: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function runOrchestration(input: RunOrchestrationInput): Promise<void> {
|
|
55
|
+
let cancelRequested = false;
|
|
56
|
+
setHandler(runCancelSignal, () => {
|
|
57
|
+
cancelRequested = true;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const dag = await loadRunAttemptDag(input.runAttemptId);
|
|
61
|
+
const runDeadline = Date.now() + dag.runTimeoutMs;
|
|
62
|
+
|
|
63
|
+
let runVersion = dag.runVersion;
|
|
64
|
+
const {newVersion, status} = await setRunAttemptStatus({
|
|
65
|
+
runAttemptId: input.runAttemptId,
|
|
66
|
+
status: 'running',
|
|
67
|
+
version: runVersion,
|
|
68
|
+
});
|
|
69
|
+
runVersion = newVersion;
|
|
70
|
+
if (!shouldContinueStartedRun(status)) return;
|
|
71
|
+
|
|
72
|
+
const progress = createRuntimeRunProgress(dag.jobs);
|
|
73
|
+
const inFlight = new Map<string, Promise<{job: DagJob; result: LaunchResult}>>();
|
|
74
|
+
|
|
75
|
+
while (true) {
|
|
76
|
+
if (cancelRequested) {
|
|
77
|
+
await cancelNonCompletedRunnerJobs(dag, progress);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (deadlineReached(runDeadline)) {
|
|
81
|
+
await failRunAsTimedOutActivity({runAttemptId: input.runAttemptId});
|
|
82
|
+
await cancelNonCompletedRunnerJobs(dag, progress);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const commands = scheduleRuntimeDag({
|
|
87
|
+
jobs: dag.jobs,
|
|
88
|
+
completed: progress.completed,
|
|
89
|
+
running: new Set(inFlight.keys()),
|
|
90
|
+
});
|
|
91
|
+
const completeRun = commands.find((command) => command.kind === 'complete-run');
|
|
92
|
+
const startJobs = new Map<string, DagJob>();
|
|
93
|
+
|
|
94
|
+
for (const command of commands) {
|
|
95
|
+
if (command.kind !== 'skip-job') continue;
|
|
96
|
+
await skipJob(command.job, progress, command.statusReason);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const command of commands) {
|
|
100
|
+
if (command.kind !== 'evaluate-job-activation') continue;
|
|
101
|
+
const activationJobsById = new Map(command.jobs.map((job) => [job.id, job]));
|
|
102
|
+
const decisions = await evaluateJobActivationsActivity({
|
|
103
|
+
runAttemptId: input.runAttemptId,
|
|
104
|
+
jobs: command.jobs.map((job) => ({
|
|
105
|
+
jobId: job.id,
|
|
106
|
+
expectedVersion: runtimeJobVersion(job, progress),
|
|
107
|
+
})),
|
|
108
|
+
});
|
|
109
|
+
for (const decision of decisions) {
|
|
110
|
+
const job = activationJobsById.get(decision.jobId);
|
|
111
|
+
if (!job) continue;
|
|
112
|
+
if (decision.kind === 'start-job') {
|
|
113
|
+
startJobs.set(job.key, job);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
recordRuntimeJobResult(job, progress, {
|
|
117
|
+
status: decision.status,
|
|
118
|
+
jobVersion: decision.jobVersion,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
for (const command of commands) {
|
|
124
|
+
if (command.kind !== 'start-job') continue;
|
|
125
|
+
startJobs.set(command.job.key, command.job);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const job of startJobs.values()) {
|
|
129
|
+
if (!inFlight.has(job.key)) {
|
|
130
|
+
inFlight.set(job.key, launchJob(job, dag, progress));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (completeRun) {
|
|
135
|
+
await setRunAttemptStatus({
|
|
136
|
+
runAttemptId: input.runAttemptId,
|
|
137
|
+
status: completeRun.status,
|
|
138
|
+
version: runVersion,
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (startJobs.size === 0 && inFlight.size === 0) continue;
|
|
144
|
+
|
|
145
|
+
const settled = await waitForNextSettlement(inFlight, () => cancelRequested, runDeadline);
|
|
146
|
+
if (settled.kind === 'cancelled') {
|
|
147
|
+
await cancelNonCompletedRunnerJobs(dag, progress);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (settled.kind === 'timed-out') {
|
|
151
|
+
await failRunAsTimedOutActivity({runAttemptId: input.runAttemptId});
|
|
152
|
+
await cancelNonCompletedRunnerJobs(dag, progress);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
inFlight.delete(settled.job.key);
|
|
156
|
+
recordRuntimeJobResult(settled.job, progress, settled.result);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function skipJob(
|
|
161
|
+
job: DagJob,
|
|
162
|
+
progress: RuntimeRunProgress,
|
|
163
|
+
statusReason: 'default_gate_rejected',
|
|
164
|
+
): Promise<void> {
|
|
165
|
+
const version = runtimeJobVersion(job, progress);
|
|
166
|
+
const {newVersion} = await setJobStatus({
|
|
167
|
+
jobId: job.id,
|
|
168
|
+
status: 'skipped',
|
|
169
|
+
version,
|
|
170
|
+
statusReason,
|
|
171
|
+
});
|
|
172
|
+
recordSkippedRuntimeJob(job, progress, newVersion);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface LaunchResult {
|
|
176
|
+
status: RuntimeCompletionStatus;
|
|
177
|
+
jobVersion: number;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function launchJob(
|
|
181
|
+
job: DagJob,
|
|
182
|
+
run: RunDag,
|
|
183
|
+
progress: RuntimeRunProgress,
|
|
184
|
+
): Promise<{job: DagJob; result: LaunchResult}> {
|
|
185
|
+
if (job.mode === 'listening') {
|
|
186
|
+
return executeChild(jobListenerOrchestration, {
|
|
187
|
+
workflowId: `job-listener:${job.id}`,
|
|
188
|
+
args: [
|
|
189
|
+
{
|
|
190
|
+
workspaceId: run.workspaceId,
|
|
191
|
+
workflowRunId: run.workflowRunId,
|
|
192
|
+
projectId: run.projectId,
|
|
193
|
+
jobId: job.id,
|
|
194
|
+
runAttemptId: run.runAttemptId,
|
|
195
|
+
jobVersion: runtimeJobVersion(job, progress),
|
|
196
|
+
...(job.executionTimeoutMs === undefined
|
|
197
|
+
? {}
|
|
198
|
+
: {executionTimeoutMs: job.executionTimeoutMs}),
|
|
199
|
+
...(job.listeningTimeoutMs === undefined
|
|
200
|
+
? {}
|
|
201
|
+
: {listeningTimeoutMs: job.listeningTimeoutMs}),
|
|
202
|
+
...(job.maxExecutions === undefined ? {} : {maxExecutions: job.maxExecutions}),
|
|
203
|
+
...(job.onResolve === undefined ? {} : {onResolve: job.onResolve}),
|
|
204
|
+
...(job.batchDebounceMs === undefined ? {} : {batchDebounceMs: job.batchDebounceMs}),
|
|
205
|
+
...(job.batchMaxSize === undefined ? {} : {batchMaxSize: job.batchMaxSize}),
|
|
206
|
+
...(job.batchMaxWaitMs === undefined ? {} : {batchMaxWaitMs: job.batchMaxWaitMs}),
|
|
207
|
+
requiredLabels: job.runner,
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
parentClosePolicy: ParentClosePolicy.TERMINATE,
|
|
211
|
+
})
|
|
212
|
+
.then((result) => ({job, result}))
|
|
213
|
+
.catch(async (error) => {
|
|
214
|
+
log.warn('listener child failed; marking runtime job failed', {
|
|
215
|
+
jobId: job.id,
|
|
216
|
+
error: String(error),
|
|
217
|
+
});
|
|
218
|
+
const failed = await setJobStatus({
|
|
219
|
+
jobId: job.id,
|
|
220
|
+
status: 'failed',
|
|
221
|
+
version: runtimeJobVersion(job, progress),
|
|
222
|
+
statusReason: 'unknown',
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
job,
|
|
226
|
+
result: {status: 'failed' as const, jobVersion: failed.newVersion},
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (job.jobExecutionId === undefined) {
|
|
232
|
+
throw new Error(`Cannot start job without an execution: ${job.id}`);
|
|
233
|
+
}
|
|
234
|
+
return executeChild(jobExecutionOrchestration, {
|
|
235
|
+
workflowId: `job:${job.id}`,
|
|
236
|
+
args: [
|
|
237
|
+
{
|
|
238
|
+
workspaceId: run.workspaceId,
|
|
239
|
+
workflowRunId: run.workflowRunId,
|
|
240
|
+
projectId: run.projectId,
|
|
241
|
+
jobId: job.id,
|
|
242
|
+
jobExecutionId: job.jobExecutionId,
|
|
243
|
+
runAttemptId: run.runAttemptId,
|
|
244
|
+
jobVersion: runtimeJobVersion(job, progress),
|
|
245
|
+
executionVersion: job.executionVersion ?? runtimeJobVersion(job, progress),
|
|
246
|
+
...(job.executionTimeoutMs === undefined
|
|
247
|
+
? {}
|
|
248
|
+
: {executionTimeoutMs: job.executionTimeoutMs}),
|
|
249
|
+
requiredLabels: job.runner,
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
parentClosePolicy: ParentClosePolicy.TERMINATE,
|
|
253
|
+
}).then((result) => ({
|
|
254
|
+
job,
|
|
255
|
+
result: {status: result.status, jobVersion: result.jobVersion},
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async function waitForNextSettlement(
|
|
260
|
+
inFlight: ReadonlyMap<string, Promise<{job: DagJob; result: LaunchResult}>>,
|
|
261
|
+
isCancelRequested: () => boolean,
|
|
262
|
+
runDeadline: number,
|
|
263
|
+
): Promise<
|
|
264
|
+
{kind: 'settled'; job: DagJob; result: LaunchResult} | {kind: 'cancelled'} | {kind: 'timed-out'}
|
|
265
|
+
> {
|
|
266
|
+
const remaining = remainingMs(runDeadline) ?? 0;
|
|
267
|
+
const childSettled = Promise.race([...inFlight.values()]).then((settled) => ({
|
|
268
|
+
kind: 'settled' as const,
|
|
269
|
+
...settled,
|
|
270
|
+
}));
|
|
271
|
+
const cancel = condition(isCancelRequested, remaining).then((woke) =>
|
|
272
|
+
woke ? {kind: 'cancelled' as const} : {kind: 'timed-out' as const},
|
|
273
|
+
);
|
|
274
|
+
return await Promise.race([childSettled, cancel]);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function cancelNonCompletedRunnerJobs(
|
|
278
|
+
dag: RunDag,
|
|
279
|
+
progress: RuntimeRunProgress,
|
|
280
|
+
): Promise<void> {
|
|
281
|
+
const jobIds = nonCompletedRuntimeJobIds(dag.jobs, progress);
|
|
282
|
+
await cancelRunnerJobsActivity({jobIds});
|
|
283
|
+
}
|