Skip to content

claim-pr rejects open draft pull requests as PR_NOT_OPEN #436

Description

@nic-kahuna

Bug

ao session claim-pr rejects an open draft pull request with PR_NOT_OPEN. Draft is an open work/review state and should remain claimable; only merged or closed pull requests are terminal for ownership.

Reported by: Nic Huzella during a local AO control-plane reconciliation
Date: 2026-07-19
Analyzed against: 9ae05735d6f06ac989857534bae2766392772c71
Installed AO: 0.10.3
Latest checked release: v0.10.4-nightly.202607191400
Confidence: High — reproduced live and traced to the exact service condition.

Reproduction

  1. Start a worker session associated with a repository issue.
  2. Open a draft pull request from that worker's branch.
  3. Confirm GitHub reports the pull request as OPEN and isDraft=true.
  4. Run:
    ao session claim-pr <session> <pr-number> --project <project> --no-takeover --json
  5. AO returns PR_NOT_OPEN.

The same result occurs with the full pull-request URL.

Root cause

backend/internal/service/session/claim_pr.go currently defines draft, merged, and closed as equally unclaimable:

if obs.PR.Draft || obs.PR.Merged || obs.PR.Closed {
    return ClaimPRResult{}, ErrPRNotOpen
}

This conflates two separate lifecycle concerns:

  • Ownership: an open draft pull request is valid work that a session should own.
  • Integration readiness: a draft pull request must not be treated as merge-ready.

The service already persists Draft as a PR fact, so downstream status/integration logic can continue to enforce the second concern without blocking ownership.

Minimum fix

  • Reject only merged or closed pull requests in ClaimPR.
  • Update the ErrPRNotOpen comment accordingly.
  • Add focused regression coverage proving:
    • an open draft PR can be claimed and retains Draft=true;
    • merged and closed PRs remain rejected.

No API, storage, schema, CLI, or frontend change is required.

Impact

AO cannot durably associate normal work-in-progress draft PRs with their existing workers. Controllers then see false missing-PR state, cannot route review/recovery correctly, and may leave technically active work stale.

Priority: high — core session/PR ownership is broken for the normal draft-PR workflow, with no sound local workaround.

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