Workflow handoff starts a separate linked run, not another attempt #1791

Open
opened 2026-11-03 09:47:27 +00:00 by sam · 1 comment
Owner

What is wrong: a task is one row per work item, and every requeue bumps attempt on the next claim. A workflow.handoff (triage to implement), an approved plan continuing, a review-gate answer and a remediation round all show as new attempts of one run, so the task page lists triage and implement as attempt 1 and 2, mixed with real retries.

Wanted (maintainer decision): a handoff ends the current run and starts a separate run of the next workflow, linked to it. Attempts mean retries of one run only.

Constraint found: the run and the work item are the same row. tasks is unique on (org, identity, owner, repo, issue_number), and the issue number is what forge steps use (close issue, Implements #n, branch name). workflow.call children dodge the constraint with synthetic chat issue numbers, which would cut a handed-off implement run off from its issue. So this needs the run split from the work item (or the uniqueness keyed by run), not a step change.

Done when:

  • a handoff leaves the triage run finished and a new linked implement run on the same issue, each with its own attempt 1;
  • forge steps in the new run still reference the original issue;
  • the task page shows the linked runs and their order;
  • retry semantics and limits are unchanged.
**What is wrong:** a task is one row per work item, and every requeue bumps `attempt` on the next claim. A `workflow.handoff` (triage to implement), an approved plan continuing, a review-gate answer and a remediation round all show as new attempts of one run, so the task page lists triage and implement as attempt 1 and 2, mixed with real retries. **Wanted (maintainer decision):** a handoff ends the current run and starts a separate run of the next workflow, linked to it. Attempts mean retries of one run only. **Constraint found:** the run and the work item are the same row. `tasks` is unique on (org, identity, owner, repo, issue_number), and the issue number is what forge steps use (close issue, `Implements #n`, branch name). `workflow.call` children dodge the constraint with synthetic chat issue numbers, which would cut a handed-off implement run off from its issue. So this needs the run split from the work item (or the uniqueness keyed by run), not a step change. **Done when:** - a handoff leaves the triage run finished and a new linked implement run on the same issue, each with its own attempt 1; - forge steps in the new run still reference the original issue; - the task page shows the linked runs and their order; - retry semantics and limits are unchanged.
Author
Owner

Landed in c30624a5 and deployed. Migration 0068 adds handoff_from_task_id/handoff_to_task_id and keys the item uniqueness on the current run only. A handoff is one State Store transaction (HandoffTask RPC): the run goes running to completed, points at its successor, and the successor is inserted queued on the same issue with the item's title, body, labels, inputs and plan; attempts, branch and outputs start fresh. TaskByIssue, EnqueueIssue dedupe and chat outcome posting follow the current run; worktree cleanup and archive leave a successor's worktree alone. The task page links "Continues task #n" / "Handed off to task #n". Verified against the e2e Postgres (completed + linked successor, TaskByIssue returns the successor, a second handoff is refused) and in the browser. Not yet seen on a live triage run.

Landed in c30624a5 and deployed. Migration 0068 adds handoff_from_task_id/handoff_to_task_id and keys the item uniqueness on the current run only. A handoff is one State Store transaction (HandoffTask RPC): the run goes running to completed, points at its successor, and the successor is inserted queued on the same issue with the item's title, body, labels, inputs and plan; attempts, branch and outputs start fresh. TaskByIssue, EnqueueIssue dedupe and chat outcome posting follow the current run; worktree cleanup and archive leave a successor's worktree alone. The task page links "Continues task #n" / "Handed off to task #n". Verified against the e2e Postgres (completed + linked successor, TaskByIssue returns the successor, a second handoff is refused) and in the browser. Not yet seen on a live triage run.
sam added the featuremedium labels 2026-11-14 14:45:42 +00:00
sam added the deferred label 2026-11-15 17:26:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1791