@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,467 @@
|
|
|
1
|
+
import type {WorkflowModel} from '@shipfox/api-definitions';
|
|
2
|
+
import {
|
|
3
|
+
type MaterializedSecretBindingDto,
|
|
4
|
+
materializedSecretBindingSchema,
|
|
5
|
+
type SecretBindingSegmentDto,
|
|
6
|
+
secretStoreSchema,
|
|
7
|
+
} from '@shipfox/api-secrets-dto';
|
|
8
|
+
import {
|
|
9
|
+
analyzeContextKeyAccess,
|
|
10
|
+
type EvaluationTraceEntry,
|
|
11
|
+
evaluationTraceEntry,
|
|
12
|
+
hoistPlannedRunCommand,
|
|
13
|
+
type ResolvedField,
|
|
14
|
+
type ResolvedFieldSegment,
|
|
15
|
+
runnerFillTarget,
|
|
16
|
+
UnsafeRunInterpolationError,
|
|
17
|
+
} from '@shipfox/expression';
|
|
18
|
+
import type {PersistedEvaluationTraceEntry, StepConfigDispatchPlan} from '#core/entities/step.js';
|
|
19
|
+
import {InterpolationUnresolvableError} from '#core/errors.js';
|
|
20
|
+
import {
|
|
21
|
+
resolveStepField,
|
|
22
|
+
type StepConfigField,
|
|
23
|
+
stepConfigInterpolationError,
|
|
24
|
+
type WorkflowStepEvaluationTraceEntry,
|
|
25
|
+
type WorkflowStepTemplateDiagnostic,
|
|
26
|
+
} from './fields.js';
|
|
27
|
+
import type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';
|
|
28
|
+
|
|
29
|
+
type WorkflowModelJob = WorkflowModel['jobs'][number];
|
|
30
|
+
type WorkflowModelStep = WorkflowModelJob['steps'][number];
|
|
31
|
+
type WorkflowModelRunStep = Extract<WorkflowModelStep, {kind: 'run'}>;
|
|
32
|
+
|
|
33
|
+
export type StepConfigMode = 'effective' | 'authored';
|
|
34
|
+
|
|
35
|
+
interface WinningEnvValue {
|
|
36
|
+
readonly value: string;
|
|
37
|
+
readonly template?: ResolvedField['segments'];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ResolveRunStepConfigParams {
|
|
41
|
+
readonly step: WorkflowModelRunStep;
|
|
42
|
+
readonly workflowEnv: WorkflowModel['env'];
|
|
43
|
+
readonly workflowEnvTemplates: WorkflowEnvTemplates | undefined;
|
|
44
|
+
readonly jobEnv: WorkflowModelJob['env'];
|
|
45
|
+
readonly jobEnvTemplates: WorkflowEnvTemplates | undefined;
|
|
46
|
+
readonly context: WorkflowEvaluationContext;
|
|
47
|
+
readonly mode: StepConfigMode;
|
|
48
|
+
readonly definitionId: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type WorkflowEnvTemplates = Readonly<Record<string, ResolvedField['segments']>>;
|
|
52
|
+
|
|
53
|
+
export interface RunStepConfig {
|
|
54
|
+
readonly config: Record<string, unknown>;
|
|
55
|
+
readonly configPlan: StepConfigDispatchPlan | null;
|
|
56
|
+
readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];
|
|
57
|
+
readonly trace: readonly WorkflowStepEvaluationTraceEntry[];
|
|
58
|
+
readonly hasTemplates: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function resolveRunStepConfig(params: ResolveRunStepConfigParams): RunStepConfig {
|
|
62
|
+
const env = winningEnv(params);
|
|
63
|
+
const envResolution = resolveEnv(env, params.context, params.mode, params.definitionId);
|
|
64
|
+
const commandResolution = resolveCommand({
|
|
65
|
+
step: params.step,
|
|
66
|
+
envKeys: [...Object.keys(envResolution.env), ...Object.keys(envResolution.configPlan)],
|
|
67
|
+
context: params.context,
|
|
68
|
+
mode: params.mode,
|
|
69
|
+
definitionId: params.definitionId,
|
|
70
|
+
});
|
|
71
|
+
const mergedEnv = {...envResolution.env, ...commandResolution.env};
|
|
72
|
+
const hasEnvConfig = Object.keys(mergedEnv).length > 0;
|
|
73
|
+
const envConfig = hasEnvConfig ? {env: mergedEnv} : {};
|
|
74
|
+
const planEnv = {...envResolution.configPlan, ...commandResolution.configPlan};
|
|
75
|
+
const hasConfigPlan = Object.keys(planEnv).length > 0;
|
|
76
|
+
const configPlan = hasConfigPlan ? ({env: planEnv} satisfies StepConfigDispatchPlan) : null;
|
|
77
|
+
const hasTemplates = envResolution.hasTemplates || commandResolution.hasTemplate;
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
config: {run: commandResolution.command, ...envConfig},
|
|
81
|
+
configPlan,
|
|
82
|
+
diagnostics: [...envResolution.diagnostics, ...commandResolution.diagnostics],
|
|
83
|
+
trace: [...envResolution.trace, ...commandResolution.trace],
|
|
84
|
+
hasTemplates,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function completeRunDispatchConfig(params: {
|
|
89
|
+
readonly config: Record<string, unknown>;
|
|
90
|
+
readonly plan: StepConfigDispatchPlan;
|
|
91
|
+
readonly context: WorkflowEvaluationContext;
|
|
92
|
+
readonly definitionId: string;
|
|
93
|
+
readonly trace: PersistedEvaluationTraceEntry[];
|
|
94
|
+
}): void {
|
|
95
|
+
const env = {...readConfigEnv(params.config)};
|
|
96
|
+
const secretBindings: MaterializedSecretBindingDto[] = [];
|
|
97
|
+
|
|
98
|
+
if (params.plan.run !== undefined) {
|
|
99
|
+
const resolved = completeRunCommand({
|
|
100
|
+
field: params.plan.run,
|
|
101
|
+
context: params.context,
|
|
102
|
+
definitionId: params.definitionId,
|
|
103
|
+
reservedNames: Object.keys(env),
|
|
104
|
+
trace: params.trace,
|
|
105
|
+
});
|
|
106
|
+
params.config.run = resolved.command;
|
|
107
|
+
Object.assign(env, resolved.env);
|
|
108
|
+
secretBindings.push(...resolved.secretBindings);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (params.plan.env !== undefined) {
|
|
112
|
+
for (const [key, field] of Object.entries(params.plan.env)) {
|
|
113
|
+
const completed = completeDispatchField({
|
|
114
|
+
field: 'env.value',
|
|
115
|
+
traceField: 'env',
|
|
116
|
+
errorField: 'env',
|
|
117
|
+
template: field,
|
|
118
|
+
context: params.context,
|
|
119
|
+
definitionId: params.definitionId,
|
|
120
|
+
envKey: key,
|
|
121
|
+
trace: params.trace,
|
|
122
|
+
});
|
|
123
|
+
if (completed.kind === 'binding') secretBindings.push(completed.binding);
|
|
124
|
+
else env[key] = completed.value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (Object.keys(env).length > 0) params.config.env = env;
|
|
129
|
+
if (secretBindings.length > 0) params.config.secret_bindings = secretBindings;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function completeRunCommand(params: {
|
|
133
|
+
readonly field: ResolvedField;
|
|
134
|
+
readonly context: WorkflowEvaluationContext;
|
|
135
|
+
readonly definitionId: string;
|
|
136
|
+
readonly reservedNames: Iterable<string>;
|
|
137
|
+
readonly trace: PersistedEvaluationTraceEntry[];
|
|
138
|
+
}): {
|
|
139
|
+
readonly command: string;
|
|
140
|
+
readonly env: Readonly<Record<string, string>>;
|
|
141
|
+
readonly secretBindings: readonly MaterializedSecretBindingDto[];
|
|
142
|
+
} {
|
|
143
|
+
const hoisted = hoistPlannedRunCommand({
|
|
144
|
+
field: params.field,
|
|
145
|
+
reservedNames: params.reservedNames,
|
|
146
|
+
});
|
|
147
|
+
const env: Record<string, string> = {};
|
|
148
|
+
const secretBindings: MaterializedSecretBindingDto[] = [];
|
|
149
|
+
|
|
150
|
+
for (const binding of hoisted.bindings) {
|
|
151
|
+
const completed = completeDispatchField({
|
|
152
|
+
field: 'run',
|
|
153
|
+
traceField: 'run',
|
|
154
|
+
errorField: 'run',
|
|
155
|
+
template: {segments: [binding.segment]},
|
|
156
|
+
context: params.context,
|
|
157
|
+
definitionId: params.definitionId,
|
|
158
|
+
envKey: binding.name,
|
|
159
|
+
trace: params.trace,
|
|
160
|
+
});
|
|
161
|
+
if (completed.kind === 'binding') secretBindings.push(completed.binding);
|
|
162
|
+
else env[binding.name] = completed.value;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {command: hoisted.command, env, secretBindings};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
type CompletedDispatchField =
|
|
169
|
+
| {readonly kind: 'value'; readonly value: string}
|
|
170
|
+
| {readonly kind: 'binding'; readonly binding: MaterializedSecretBindingDto};
|
|
171
|
+
|
|
172
|
+
function completeDispatchField(params: {
|
|
173
|
+
readonly field: 'run' | 'env.value';
|
|
174
|
+
readonly traceField: StepConfigField;
|
|
175
|
+
readonly errorField: StepConfigField;
|
|
176
|
+
readonly template: ResolvedField;
|
|
177
|
+
readonly context: WorkflowEvaluationContext;
|
|
178
|
+
readonly definitionId: string;
|
|
179
|
+
readonly envKey?: string;
|
|
180
|
+
readonly trace: PersistedEvaluationTraceEntry[];
|
|
181
|
+
}): CompletedDispatchField {
|
|
182
|
+
const resolved = resolveStepField(params);
|
|
183
|
+
params.trace.push(...tagTrace(resolved.trace, params.traceField, params.envKey));
|
|
184
|
+
if (resolved.kind === 'frozen') return {kind: 'value', value: resolved.value};
|
|
185
|
+
if (params.envKey !== undefined && containsOnlyRunnerSecretSegments(resolved.field)) {
|
|
186
|
+
params.trace.push(
|
|
187
|
+
...runnerSecretReferenceTrace(resolved.field, params.traceField, params.envKey),
|
|
188
|
+
);
|
|
189
|
+
return {
|
|
190
|
+
kind: 'binding',
|
|
191
|
+
binding: secretBindingFromField(params.envKey, resolved.field),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const source = resolved.field.segments.find((segment) => segment.kind === 'deferred')?.expression
|
|
196
|
+
.source;
|
|
197
|
+
throw new InterpolationUnresolvableError(params.definitionId, {
|
|
198
|
+
field: params.errorField,
|
|
199
|
+
source: source ?? params.field,
|
|
200
|
+
...(params.envKey === undefined ? {} : {envKey: params.envKey}),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function containsOnlyRunnerSecretSegments(field: ResolvedField): boolean {
|
|
205
|
+
return field.segments.every((segment) => {
|
|
206
|
+
if (segment.kind === 'literal') return true;
|
|
207
|
+
return (
|
|
208
|
+
segment.fillTarget === runnerFillTarget &&
|
|
209
|
+
segment.roots.length === 1 &&
|
|
210
|
+
segment.roots[0] === 'secrets'
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function secretBindingFromField(
|
|
216
|
+
target: string,
|
|
217
|
+
field: ResolvedField,
|
|
218
|
+
): MaterializedSecretBindingDto {
|
|
219
|
+
const binding = {
|
|
220
|
+
target,
|
|
221
|
+
segments: field.segments.map(secretBindingSegment),
|
|
222
|
+
};
|
|
223
|
+
return materializedSecretBindingSchema.parse(binding);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function secretBindingSegment(segment: ResolvedFieldSegment): SecretBindingSegmentDto {
|
|
227
|
+
if (segment.kind === 'literal') return {kind: 'literal', value: segment.value};
|
|
228
|
+
|
|
229
|
+
const keyAccess = analyzeContextKeyAccess(segment.expression);
|
|
230
|
+
const reference = keyAccess.references.find((candidate) => candidate.root === 'secrets');
|
|
231
|
+
if (reference === undefined) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
`Runner secret segment did not contain a secret reference: ${segment.expression.source}`,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
kind: 'secret',
|
|
239
|
+
store: secretStoreSchema.parse(reference.store ?? 'local'),
|
|
240
|
+
key: reference.key,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function resolveCommand(params: {
|
|
245
|
+
readonly step: WorkflowModelRunStep;
|
|
246
|
+
readonly envKeys: readonly string[];
|
|
247
|
+
readonly context: WorkflowEvaluationContext;
|
|
248
|
+
readonly mode: StepConfigMode;
|
|
249
|
+
readonly definitionId: string;
|
|
250
|
+
}): {
|
|
251
|
+
readonly command: string;
|
|
252
|
+
readonly env: Readonly<Record<string, string>>;
|
|
253
|
+
readonly configPlan: Readonly<Record<string, ResolvedField>>;
|
|
254
|
+
readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];
|
|
255
|
+
readonly trace: readonly WorkflowStepEvaluationTraceEntry[];
|
|
256
|
+
readonly hasTemplate: boolean;
|
|
257
|
+
} {
|
|
258
|
+
const template = params.step.templates?.command;
|
|
259
|
+
const hasTemplate = template !== undefined;
|
|
260
|
+
if (!hasTemplate) {
|
|
261
|
+
return {
|
|
262
|
+
command: params.step.command.value,
|
|
263
|
+
env: {},
|
|
264
|
+
configPlan: {},
|
|
265
|
+
diagnostics: [],
|
|
266
|
+
trace: [],
|
|
267
|
+
hasTemplate: false,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const usesAuthoredMode = params.mode === 'authored';
|
|
272
|
+
if (usesAuthoredMode) {
|
|
273
|
+
return {
|
|
274
|
+
command: params.step.command.value,
|
|
275
|
+
env: {},
|
|
276
|
+
configPlan: {},
|
|
277
|
+
diagnostics: [],
|
|
278
|
+
trace: [],
|
|
279
|
+
hasTemplate: true,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const env: Record<string, string> = {};
|
|
284
|
+
const configPlan: Record<string, ResolvedField> = {};
|
|
285
|
+
const diagnostics: WorkflowStepTemplateDiagnostic[] = [];
|
|
286
|
+
const trace: WorkflowStepEvaluationTraceEntry[] = [];
|
|
287
|
+
const hoisted = hoistCommand(template, params.envKeys, params.definitionId);
|
|
288
|
+
|
|
289
|
+
for (const binding of hoisted.bindings) {
|
|
290
|
+
const resolved = resolveStepField({
|
|
291
|
+
field: 'run',
|
|
292
|
+
template: {segments: [binding.segment]},
|
|
293
|
+
context: params.context,
|
|
294
|
+
definitionId: params.definitionId,
|
|
295
|
+
errorField: 'run',
|
|
296
|
+
});
|
|
297
|
+
const resolvedToDispatchPlan = resolved.kind === 'residual';
|
|
298
|
+
if (resolvedToDispatchPlan) configPlan[binding.name] = resolved.field;
|
|
299
|
+
else env[binding.name] = resolved.value;
|
|
300
|
+
diagnostics.push(
|
|
301
|
+
...resolved.diagnostics.map((diagnostic) => ({...diagnostic, field: 'run' as const})),
|
|
302
|
+
);
|
|
303
|
+
trace.push(...tagTrace(resolved.trace, 'run'));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return {
|
|
307
|
+
command: hoisted.command,
|
|
308
|
+
env,
|
|
309
|
+
configPlan,
|
|
310
|
+
diagnostics,
|
|
311
|
+
trace,
|
|
312
|
+
hasTemplate: true,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function hoistCommand(
|
|
317
|
+
template: ResolvedField['segments'],
|
|
318
|
+
reservedNames: readonly string[],
|
|
319
|
+
definitionId: string,
|
|
320
|
+
): ReturnType<typeof hoistPlannedRunCommand> {
|
|
321
|
+
try {
|
|
322
|
+
return hoistPlannedRunCommand({
|
|
323
|
+
field: {segments: template},
|
|
324
|
+
reservedNames,
|
|
325
|
+
});
|
|
326
|
+
} catch (error) {
|
|
327
|
+
if (error instanceof UnsafeRunInterpolationError) {
|
|
328
|
+
throw stepConfigInterpolationError({definitionId, errorField: 'run'}, error);
|
|
329
|
+
}
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function resolveEnv(
|
|
335
|
+
env: Readonly<Record<string, WinningEnvValue>>,
|
|
336
|
+
context: WorkflowEvaluationContext,
|
|
337
|
+
mode: StepConfigMode,
|
|
338
|
+
definitionId: string,
|
|
339
|
+
): {
|
|
340
|
+
readonly env: Readonly<Record<string, string>>;
|
|
341
|
+
readonly configPlan: Readonly<Record<string, ResolvedField>>;
|
|
342
|
+
readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];
|
|
343
|
+
readonly trace: readonly WorkflowStepEvaluationTraceEntry[];
|
|
344
|
+
readonly hasTemplates: boolean;
|
|
345
|
+
} {
|
|
346
|
+
const resolvedEnv: Record<string, string> = {};
|
|
347
|
+
const configPlan: Record<string, ResolvedField> = {};
|
|
348
|
+
const diagnostics: WorkflowStepTemplateDiagnostic[] = [];
|
|
349
|
+
const trace: WorkflowStepEvaluationTraceEntry[] = [];
|
|
350
|
+
let hasTemplates = false;
|
|
351
|
+
|
|
352
|
+
for (const [key, entry] of Object.entries(env)) {
|
|
353
|
+
const template = entry.template;
|
|
354
|
+
const hasTemplate = template !== undefined;
|
|
355
|
+
const usesAuthoredMode = mode === 'authored';
|
|
356
|
+
const shouldUseAuthoredValue = !hasTemplate || usesAuthoredMode;
|
|
357
|
+
|
|
358
|
+
if (shouldUseAuthoredValue) {
|
|
359
|
+
resolvedEnv[key] = entry.value;
|
|
360
|
+
hasTemplates ||= hasTemplate;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
hasTemplates = true;
|
|
365
|
+
const resolved = resolveStepField({
|
|
366
|
+
field: 'env.value',
|
|
367
|
+
template: {segments: template},
|
|
368
|
+
context,
|
|
369
|
+
definitionId,
|
|
370
|
+
errorField: 'env',
|
|
371
|
+
envKey: key,
|
|
372
|
+
});
|
|
373
|
+
const resolvedToDispatchPlan = resolved.kind === 'residual';
|
|
374
|
+
if (resolvedToDispatchPlan) configPlan[key] = resolved.field;
|
|
375
|
+
else resolvedEnv[key] = resolved.value;
|
|
376
|
+
diagnostics.push(
|
|
377
|
+
...resolved.diagnostics.map((diagnostic) => ({
|
|
378
|
+
...diagnostic,
|
|
379
|
+
field: 'env' as const,
|
|
380
|
+
envKey: key,
|
|
381
|
+
})),
|
|
382
|
+
);
|
|
383
|
+
trace.push(...tagTrace(resolved.trace, 'env', key));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return {env: resolvedEnv, configPlan, diagnostics, trace, hasTemplates};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function tagTrace(
|
|
390
|
+
trace: readonly EvaluationTraceEntry[],
|
|
391
|
+
field: StepConfigField,
|
|
392
|
+
envKey?: string,
|
|
393
|
+
): WorkflowStepEvaluationTraceEntry[] {
|
|
394
|
+
return trace.map((entry) => ({
|
|
395
|
+
...entry,
|
|
396
|
+
field,
|
|
397
|
+
...(envKey === undefined ? {} : {envKey}),
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function runnerSecretReferenceTrace(
|
|
402
|
+
field: ResolvedField,
|
|
403
|
+
stepField: StepConfigField,
|
|
404
|
+
envKey: string,
|
|
405
|
+
): WorkflowStepEvaluationTraceEntry[] {
|
|
406
|
+
return field.segments.flatMap((segment) => {
|
|
407
|
+
if (segment.kind === 'literal') return [];
|
|
408
|
+
return [
|
|
409
|
+
{
|
|
410
|
+
...evaluationTraceEntry({
|
|
411
|
+
expression: segment.expression.source,
|
|
412
|
+
roots: segment.roots,
|
|
413
|
+
fillTarget: runnerFillTarget,
|
|
414
|
+
evaluatedAt: 'step-dispatch',
|
|
415
|
+
reference: true,
|
|
416
|
+
}),
|
|
417
|
+
field: stepField,
|
|
418
|
+
envKey,
|
|
419
|
+
},
|
|
420
|
+
];
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function winningEnv(params: {
|
|
425
|
+
readonly workflowEnv: WorkflowModel['env'];
|
|
426
|
+
readonly workflowEnvTemplates: WorkflowEnvTemplates | undefined;
|
|
427
|
+
readonly jobEnv: WorkflowModelJob['env'];
|
|
428
|
+
readonly jobEnvTemplates: WorkflowEnvTemplates | undefined;
|
|
429
|
+
readonly step: WorkflowModelStep;
|
|
430
|
+
}): Readonly<Record<string, WinningEnvValue>> {
|
|
431
|
+
if (params.step.kind !== 'run') return {};
|
|
432
|
+
|
|
433
|
+
return mergeEnvLayers(
|
|
434
|
+
{env: params.workflowEnv, templates: params.workflowEnvTemplates},
|
|
435
|
+
{env: params.jobEnv, templates: params.jobEnvTemplates},
|
|
436
|
+
{env: params.step.env, templates: params.step.templates?.env},
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function mergeEnvLayers(
|
|
441
|
+
...layers: readonly {
|
|
442
|
+
readonly env: Readonly<Record<string, string>> | undefined;
|
|
443
|
+
readonly templates: WorkflowEnvTemplates | undefined;
|
|
444
|
+
}[]
|
|
445
|
+
): Readonly<Record<string, WinningEnvValue>> {
|
|
446
|
+
const merged: Record<string, WinningEnvValue> = {};
|
|
447
|
+
|
|
448
|
+
for (const layer of layers) {
|
|
449
|
+
for (const [key, value] of Object.entries(layer.env ?? {})) {
|
|
450
|
+
const template = layer.templates?.[key];
|
|
451
|
+
const hasTemplate = template !== undefined;
|
|
452
|
+
merged[key] = hasTemplate ? {value, template} : {value};
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return merged;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function readConfigEnv(config: Record<string, unknown>): Record<string, string> {
|
|
460
|
+
const env = config.env;
|
|
461
|
+
if (env === null || typeof env !== 'object' || Array.isArray(env)) return {};
|
|
462
|
+
return Object.fromEntries(
|
|
463
|
+
Object.entries(env).flatMap(([key, value]) =>
|
|
464
|
+
typeof value === 'string' ? [[key, value]] : [],
|
|
465
|
+
),
|
|
466
|
+
);
|
|
467
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type {LogOutcomeDto} from '@shipfox/api-workflows-dto';
|
|
2
|
+
import type {Tx} from '#db/db.js';
|
|
3
|
+
import {
|
|
4
|
+
applyStepResult,
|
|
5
|
+
finishStepAttempt,
|
|
6
|
+
getStepsByJobExecutionIdForUpdate,
|
|
7
|
+
rewindStepsToPending,
|
|
8
|
+
settleJobFailed,
|
|
9
|
+
writeJobStepsSettledOutbox,
|
|
10
|
+
writeStepRestartEnqueuedOutbox,
|
|
11
|
+
} from '#db/workflow-runs.js';
|
|
12
|
+
import {
|
|
13
|
+
deriveCompletion,
|
|
14
|
+
isTerminal,
|
|
15
|
+
type StepReport,
|
|
16
|
+
type StepTransitionDecision,
|
|
17
|
+
} from './decide-step-transition.js';
|
|
18
|
+
|
|
19
|
+
export type StepProgressionOutcome =
|
|
20
|
+
| {jobFinished: false}
|
|
21
|
+
| {jobFinished: true; status: 'succeeded' | 'failed'};
|
|
22
|
+
|
|
23
|
+
export interface StepProgressionMetrics {
|
|
24
|
+
jobStepsSettledStatus?: 'succeeded' | 'failed';
|
|
25
|
+
stepRestartEnqueued?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface StepProgressionResult {
|
|
29
|
+
outcome: StepProgressionOutcome;
|
|
30
|
+
metrics: StepProgressionMetrics;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ApplyStepTransitionContext {
|
|
34
|
+
jobId: string;
|
|
35
|
+
jobExecutionId: string;
|
|
36
|
+
result: StepReport;
|
|
37
|
+
logOutcome: LogOutcomeDto;
|
|
38
|
+
// Gate evaluation audit payload to record on the attempt, when a gate ran.
|
|
39
|
+
gateResult?: Record<string, unknown> | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Durable side of the decision: writes the attempt + projection for a transition,
|
|
43
|
+
// then derives job completion from the post-apply projection and enqueues the
|
|
44
|
+
// completion event in the same transaction. Only called for a running target, so
|
|
45
|
+
// every path here is an actual state change (idempotent no-ops are handled by the
|
|
46
|
+
// caller before deciding).
|
|
47
|
+
export async function applyStepTransition(
|
|
48
|
+
decision: StepTransitionDecision,
|
|
49
|
+
ctx: ApplyStepTransitionContext,
|
|
50
|
+
tx: Tx,
|
|
51
|
+
): Promise<StepProgressionResult> {
|
|
52
|
+
switch (decision.kind) {
|
|
53
|
+
case 'complete-step':
|
|
54
|
+
case 'complete-job': {
|
|
55
|
+
// A passing gate makes a step succeed even if the raw command status was
|
|
56
|
+
// 'failed', so the projection error is cleared regardless of the report.
|
|
57
|
+
await finishStepAttempt(
|
|
58
|
+
{
|
|
59
|
+
stepId: decision.stepId,
|
|
60
|
+
attempt: decision.attempt,
|
|
61
|
+
status: 'succeeded',
|
|
62
|
+
output: ctx.result.output ?? null,
|
|
63
|
+
response: ctx.result.response ?? null,
|
|
64
|
+
exitCode: ctx.result.exitCode ?? null,
|
|
65
|
+
logOutcome: ctx.logOutcome,
|
|
66
|
+
gateResult: ctx.gateResult ?? null,
|
|
67
|
+
},
|
|
68
|
+
tx,
|
|
69
|
+
);
|
|
70
|
+
await applyStepResult(
|
|
71
|
+
{
|
|
72
|
+
jobExecutionId: ctx.jobExecutionId,
|
|
73
|
+
stepId: decision.stepId,
|
|
74
|
+
status: 'succeeded',
|
|
75
|
+
error: null,
|
|
76
|
+
},
|
|
77
|
+
tx,
|
|
78
|
+
);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'fail-job':
|
|
82
|
+
case 'fail-job-restart-exhausted': {
|
|
83
|
+
await finishStepAttempt(
|
|
84
|
+
{
|
|
85
|
+
stepId: decision.failedStepId,
|
|
86
|
+
attempt: decision.attempt,
|
|
87
|
+
status: 'failed',
|
|
88
|
+
output: ctx.result.output ?? null,
|
|
89
|
+
response: ctx.result.response ?? null,
|
|
90
|
+
error: decision.failureError,
|
|
91
|
+
exitCode: ctx.result.exitCode ?? null,
|
|
92
|
+
logOutcome: ctx.logOutcome,
|
|
93
|
+
gateResult: ctx.gateResult ?? null,
|
|
94
|
+
},
|
|
95
|
+
tx,
|
|
96
|
+
);
|
|
97
|
+
const status = await settleJobFailed(tx, {
|
|
98
|
+
jobId: ctx.jobId,
|
|
99
|
+
jobExecutionId: ctx.jobExecutionId,
|
|
100
|
+
failedStepId: decision.failedStepId,
|
|
101
|
+
error: decision.failureError ?? {message: 'Step failed'},
|
|
102
|
+
});
|
|
103
|
+
if (status !== null) {
|
|
104
|
+
return {
|
|
105
|
+
outcome: {jobFinished: true, status},
|
|
106
|
+
metrics: {jobStepsSettledStatus: status},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {outcome: {jobFinished: false}, metrics: {}};
|
|
110
|
+
}
|
|
111
|
+
case 'restart-job-from-step': {
|
|
112
|
+
// Record the failed attempt FIRST (audit, with the restart feedback), then
|
|
113
|
+
// rewind the projection from restart_from so the prior result is preserved
|
|
114
|
+
// only in the attempt history. All in one transaction with the report.
|
|
115
|
+
await finishStepAttempt(
|
|
116
|
+
{
|
|
117
|
+
stepId: decision.failedStepId,
|
|
118
|
+
attempt: decision.attempt,
|
|
119
|
+
status: 'failed',
|
|
120
|
+
output: ctx.result.output ?? null,
|
|
121
|
+
response: ctx.result.response ?? null,
|
|
122
|
+
error: decision.failureError,
|
|
123
|
+
exitCode: ctx.result.exitCode ?? null,
|
|
124
|
+
logOutcome: ctx.logOutcome,
|
|
125
|
+
gateResult: ctx.gateResult ?? null,
|
|
126
|
+
restartFeedback: decision.feedback,
|
|
127
|
+
},
|
|
128
|
+
tx,
|
|
129
|
+
);
|
|
130
|
+
await rewindStepsToPending(
|
|
131
|
+
{jobExecutionId: ctx.jobExecutionId, fromPosition: decision.restartFromPosition},
|
|
132
|
+
tx,
|
|
133
|
+
);
|
|
134
|
+
await writeStepRestartEnqueuedOutbox(tx, {
|
|
135
|
+
jobId: ctx.jobId,
|
|
136
|
+
failedStepId: decision.failedStepId,
|
|
137
|
+
failedStepAttempt: decision.attempt,
|
|
138
|
+
restartFromStepId: decision.restartFromStepId,
|
|
139
|
+
feedback: decision.feedback,
|
|
140
|
+
});
|
|
141
|
+
// The job stays running; the next pull re-dispatches restart_from. Do not
|
|
142
|
+
// derive completion or emit a completion event.
|
|
143
|
+
return {outcome: {jobFinished: false}, metrics: {stepRestartEnqueued: true}};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Re-derive completion from the post-apply projection and emit the
|
|
148
|
+
// steps-settled signal exactly once, here on the applied path.
|
|
149
|
+
const after = await getStepsByJobExecutionIdForUpdate(ctx.jobExecutionId, tx);
|
|
150
|
+
if (after.every((step) => isTerminal(step.status))) {
|
|
151
|
+
const status = deriveCompletion(after);
|
|
152
|
+
await writeJobStepsSettledOutbox(tx, {
|
|
153
|
+
jobId: ctx.jobId,
|
|
154
|
+
jobExecutionId: ctx.jobExecutionId,
|
|
155
|
+
status,
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
outcome: {jobFinished: true, status},
|
|
159
|
+
metrics: {jobStepsSettledStatus: status},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {outcome: {jobFinished: false}, metrics: {}};
|
|
163
|
+
}
|