Skip to content

F: close a task's draft PR on cancel, including one opening during the cancel #111

Closed

Description

@mchwang

Why

From the #103 review (PR #110). A person can cancel a needs-human task while its draft PR is opening. Two cases:

  • Cancel before beginPullRequest: its transaction re-reads the status and refuses, so nothing opens.
  • Cancel while pulls.open is in flight: GitHub opens the PR anyway. recordPullRequestOpened records it and leaves the task cancelled.

The design closes a needs-human task's draft PR on cancel ("What this slice does not do" in docs/implementation/pull-request-opening.md). Nothing does that yet, and #103 makes this reachable in production. The same applies to a draft PR that was already open before the cancel.

Needed

  • On cancel task, close every open PR the task's records name, and record that it was closed. Cover openings in flight too: settle them first through the publisher's recovery, then close.
  • Track the close as an irreversible external action. Order the shutdown and the outcome reporting the same way as a publish.
  • Decide whether cancel-task waits for a publish in progress or closes the PR afterwards.

Tests

  • Cancel during a draft opening: the PR ends up closed, and the task stays cancelled.
  • Cancel with an existing draft PR: the PR is closed.
  • Shutdown during the close: the next start finishes it.

🤖 Generated with Claude Code

Activity

  1. mchwang commented on Oct 3, 2026

    @mchwang
    ContributorAuthor

    Decisions, made 2026-10-03. Implemented in PR #115, which is stacked on #110.

    1. Which PRs: every open PR the task opened is closed, draft or ready, whatever the task's status was when it was cancelled.
    2. Branch: the codeboost/… branch is kept; only the PR is closed.
    3. Cancel during a publish: the cancel goes through at once and stops the publish. Once the publish has settled, the close runs. A PR that GitHub opened in the meantime is found by its marker.
    4. Retry: the close outcome is saved like a publish's. A close that is still owed runs at startup. It also runs once the settle time has passed, if an opening was still unsettled. The new close-pull-requests runner action retries it.

    Known limits, documented in pull-request-opening.md:

    • No re-check after a successful close. Once a close has recorded closed, nothing looks again. An abandoned opening's PR that GitHub shows only later, or a PR a person reopens, stays open until someone runs close-pull-requests.
    • Older cancelled tasks. On the first start with this change, tasks that were cancelled earlier and still have a PR record get their PRs closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions