feat(workflow): resume a parked run from a chosen step
Each finished stage records the run's step results; a retry may name a resume point, and the next attempt skips the steps before it with their results loaded. A run with a repository resumes only on its pushed branch. The canvas offers Resume/Re-run from here on parked runs.
This commit is contained in:
37 files changed
+606
-88
No files matched your search
@@ -40,7 +40,7 @@ FROM step_executions WHERE id = $1 FOR UPDATE;
|
||||
|
||||
-- name: FinishStepExecution :execrows
|
||||
UPDATE step_executions
|
||||
SET status = $1, detail = $2, tokens_used = $3, finished_at = now()
|
||||
SET status = $1, detail = $2, tokens_used = $3, results = $6, finished_at = now()
|
||||
WHERE id = $4 AND status = $5;
|
||||
-- name: CancelAttemptSteps :many
|
||||
-- The half of CancelExecution that cancels the current attempt's
|
||||
@@ -87,3 +87,14 @@ ORDER BY attempt, id;
|
||||
SELECT id, called_execution_id FROM step_executions
|
||||
WHERE execution_id = $1 AND attempt = $2
|
||||
AND kind = 'call' AND status IN ('pending', 'running') AND called_execution_id <> 0;
|
||||
|
||||
-- name: LatestStageResults :one
|
||||
-- The most recent finished run of a root stage, across attempts: a resumed
|
||||
-- attempt skips the stages before its resume point, so the last attempt that
|
||||
-- ran this stage may be an earlier one. NULL results mean that run did not
|
||||
-- move past the stage.
|
||||
SELECT status, results FROM step_executions
|
||||
WHERE execution_id = $1 AND depth = 0 AND kind = 'stage' AND name = $2
|
||||
AND status IN ('succeeded', 'failed')
|
||||
ORDER BY attempt DESC, id DESC
|
||||
LIMIT 1;
|
||||
@@ -155,7 +155,7 @@ RETURNING *;
|
||||
-- A remediation must continue the branch its pull request lives on, so it
|
||||
-- records that dispatch mode explicitly (taskstate.RetryContinuePushedWork)
|
||||
-- rather than leaving prepareWorkspace to infer it from the workflow.
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', updated_at = now()
|
||||
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
|
||||
WHERE id = $1 AND status = 'pr_open';
|
||||
|
||||
-- name: UpdateReviewPayloadTask :execrows
|
||||
@@ -176,6 +176,7 @@ WHERE id = @id AND status = @from_status;
|
||||
UPDATE tasks SET status = 'queued', retry_count = retry_count + 1,
|
||||
workflow = CASE WHEN @workflow::text = '' THEN workflow ELSE @workflow::text END,
|
||||
retry_mode = @retry_mode::text,
|
||||
resume_from = @resume_from::text, resume_results = @resume_results::jsonb,
|
||||
park_reason = '', park_class = 'needs_human', updated_at = now()
|
||||
WHERE id = @id AND status = @from_status;
|
||||
|
||||
|
||||
Reference in new issue
Block a user