Skip to content

Numbered Issue branches after a merged or closed PR - #21

Merged
JacobStephens2 merged 2 commits into
mainfrom
issue-7
Sep 25, 2026
Merged

JacobStephens2 merged 2 commits into
mainfrom
issue-7

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

Summary

When the highest-numbered Issue branch's PR is merged or closed, the Run now starts fresh on the next number instead of stopping with "numbered Issue branches are not supported yet".

 select(issue)
   highest = max number seen on origin branches ∪ PR heads   # one ls-remote, one pr list
   pr = newest PR for highest
   match (branch on origin?, pr)
+    (_, merged | closed)  → Fresh on issue-<n>-branch-<highest+1>   # even if the branch was deleted
     (yes, none | open)    → Continuation
-    otherwise             → error "not supported yet"
+    (no, open)            → error "has an open PR but is gone from origin"

A Fresh numbered branch gets the fresh prompt, is created from the Base branch, and must not already exist locally, the same as issue-<n>.

Tested seam: the thirdshift CLI (tests/numbered_branches.rs). The tests cover merged → -branch-2, closed → -branch-2, deleted merged issue-7 → -branch-2, open PR on -branch-2 → Continuation, merged -branch-2 → -branch-3 (including when it was deleted), fresh prompt, PR head and "Closes #7", and a local -branch-2 stopping the run.

Evidence

  • Before: issue-7 with a MERGED PR → exit 1: issue-7 can't be continued (its PR …/pull/1 is merged), and numbered Issue branches are not supported yet (7 of 8 new tests failed).
    After: the Run implements on issue-7-branch-2 from main and prints …/pull/2. cargo test: all suites pass (9/9 in numbered_branches).

Merge Danger

Door: two-way

Selection logic only; reverting restores the old error.

Blast Radius: small

Only affects Runs on issues whose latest Issue branch PR is merged or closed. Those Runs used to fail during pre-flight.

Unaddressed findings

Standards

  • Shared parameterised AGENT_COMMITS_AND_OPENS_PR in tests/support (Duplicated Code): refactoring fresh_run.rs is outside this issue. The local helper needs the branch as a parameter.
  • Helper for the repeated ["Add feature", "Initial commit"] assertion (Duplicated Code): the testing guidance asks for expected values spelled out from the scenario, and a literal log reads better than a helper.
  • Scenario::last_pr() helper for gh_state()["prs"]…last() (Message Chain): it has one use, so a helper would be speculative.

Spec

  • New error when the highest branch has an open PR but is gone from origin (not in spec): it replaces the old catch-all error for a case GitHub rarely produces, because deleting a head branch closes its PR. Flagged here so you know about it.
  • The newest PR on a branch decides, and that isn't documented in CONTEXT.md or ADR-0002: this behaviour already existed from Continuation of an existing Issue branch #6, so documenting it is a separate domain-docs decision.
  • A Fresh numbered run bases on the checked-out branch, not the merged PR's base: this is correct under the CONTEXT.md definition of Base branch, so nothing to change.

Closes #7

🤖 Generated with Claude Code

JacobStephens2 and others added 2 commits September 25, 2026 12:17
When the highest-numbered Issue branch's PR is merged or closed, start
fresh on issue-<n>-branch-<k+1> from the Base branch, even if GitHub
deleted the merged branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JacobStephens2
JacobStephens2 merged commit e0408a2 into main Sep 25, 2026
1 check passed
@JacobStephens2
JacobStephens2 deleted the issue-7 branch September 25, 2026 12:21
JacobStephens2 added a commit that referenced this pull request Sep 30, 2026
Parallel Tickets (#143) and the Spec PR's Repair loop and Self-merge
landed on main. The Tickets checklist now follows the parallel loop: it
is written once per batch of Tickets started and whenever one ends, and
the Spec PR opens after the first Ticket lands. Tests that need #21 to
land before #22 starts run with parallel 1, and the Spec PR is found by
its head rather than by its index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numbered Issue branches after a merged or closed PR

1 participant