Parent Epic
#164 — Cancel workflow on unassignment
Description
Add cancellation logic to the dispatcher so an unassignment event can cancel an in-flight workflow when cancel_on_unassign is enabled.
Tasks
- Add a
cancel_workflow method to Dispatcher that:
- Looks up the event's dedup key in the
in_flight set
- If found, signals the running task to cancel (via a
CancellationToken or similar mechanism added per spawned task)
- On cancellation:
- Removes the dedup key from
in_flight and does NOT add it to completed or permanently_failed
- Moves the workspace directory from
<workdir>/<owner>/<repo>/<event_id>/ to <workdir>/<owner>/<repo>/<event_id>/cancelled/
- Logs cancellation
- If the event is not in-flight (already completed or not found), do nothing — log and return
- Update the dispatch loop to handle the new unassign trigger type:
- When a
GithubIssueUnassigned or GitlabIssueUnassigned trigger event arrives, check whether the matching workflow has cancel_on_unassign = true
- If yes, call
cancel_workflow instead of handle_dispatch
- If no, ignore the unassign event (log and return)
- Wire a
CancellationToken (from tokio_util or a custom AtomicBool) into each spawned workflow task so cancellation can be signaled
- When the cancellation token is set, the runner stops between steps (not mid-step) and does not mark the workflow as completed/failed
Exit Criteria
- An in-flight workflow for an assigned issue can be cancelled via an unassign event
- The workspace is moved to
cancelled/
- The dedup key is cleared so re-assignment triggers a fresh run
Dependencies
Parent Epic
#164 — Cancel workflow on unassignment
Description
Add cancellation logic to the dispatcher so an unassignment event can cancel an in-flight workflow when
cancel_on_unassignis enabled.Tasks
cancel_workflowmethod toDispatcherthat:in_flightsetCancellationTokenor similar mechanism added per spawned task)in_flightand does NOT add it tocompletedorpermanently_failed<workdir>/<owner>/<repo>/<event_id>/to<workdir>/<owner>/<repo>/<event_id>/cancelled/GithubIssueUnassignedorGitlabIssueUnassignedtrigger event arrives, check whether the matching workflow hascancel_on_unassign = truecancel_workflowinstead ofhandle_dispatchCancellationToken(fromtokio_utilor a customAtomicBool) into each spawned workflow task so cancellation can be signaledExit Criteria
cancelled/Dependencies