Skip to content

afx spawn: open-PR collision guard counts merged PRs since #1619 widened pr-search to --state all #1637

Closed

Description

@amrmelsayed

Symptom (field report, peer workspace, 2026-09-05 on 3.3.3)

afx spawn for an issue refused with "Found N open PR(s) referencing issue #X" where the referenced PRs were merged, forcing --force after manual verification. Reported occurrence: spawning for their issue 4750 tripped on merged PRs 4747/4766.

Root cause — a #1619 side effect (3.3.3 regression)

The spawn collision guard (spawn-worktree.ts:590 area, "Check for open PRs referencing this issue") calls the pr-search forge concept and treats every result as an open PR.

PR #1619 (shipped in 3.3.3) deliberately changed pr-search to --state all so consult --type pr could find merged PRs (#759). Correct fix for consult — but the spawn guard consumed the same concept and inherited merged/closed PRs into its "open" count.

Compounding detail: scripts/forge/github/pr-search.sh outputs only number,headRefName,baseRefName — no state field — so the guard cannot filter client-side today.

Fix

Add state to the pr-search JSON fields (github + gitlab scripts, and the PrSearchResult contract if typed), and have the spawn guard filter to state == "OPEN" before counting. Keep --state all in the script — consult needs it; the guard filters. A regression test pairing the two consumers (consult wants merged visible, spawn guard ignores them) would pin the contract so the next state-filter change can't whipsaw one consumer again.

Origin

Reported by a peer workspace's security architect with --force + manual-verification workaround; same report also carried #1567 delivery-truncation specimens (tracked there, not here).

Activity

  1. added
    area/tower
    on Sep 7, 2026
  2. amrmelsayed commented on Sep 10, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  3. added 11 commits that reference this issue on Sep 10, 2026
    64bf843
    b268b2e
    a3b072a
    84ce1fb
    a834106
    7b26c76
    0e252cb
    48df843
    e292b18
    fced6d1
    2c97825
  4. added a commit that references this issue on Sep 11, 2026
    c88bc9c
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

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions