Conversation
…ranches
Defense-in-depth backstop so a double-merge is harmless even with no PR to
probe. Complements the already-landed `AlreadyMerged` path (which advances a
`review -> done` transition when GitHub reports the branch's PR already
MERGED): that path needs a visible merged PR. This adds the PR-less case —
the branch's content is already on the base but no merged PR records it (a
purely-local project with no `gh`, or content that landed under another SHA).
Previously the hub-side fetch path failed two ways and stranded the card:
- "no commits beyond target" -> hard error.
- branch re-pushed but content already in base -> empty `git merge --squash`
stages nothing, so `git commit` exits 1 and the transition aborts.
`merge_hub_side` now returns `HubMerge::{Merged(sha), AlreadyIntegrated}`. It
reports `AlreadyIntegrated` when the branch is an ancestor of the target
(no commits beyond) or when the squash stages nothing, instead of erroring.
`merge()` maps that to a new `MergeOutcome::AlreadyIntegrated { target }`
no-op variant so the transition proceeds (delete_branch runs, the card
advances). Wire format: `already-integrated:<target>`.
Key decisions (not asked about):
- Kept the existing "branch not on origin -> run push_branch first" error.
A missing branch with no merged PR is a genuinely different situation
(never pushed) from merged+deleted; the AlreadyMerged path already advances
the real merged+deleted case via its merged-PR probe, so this path only
fires for a branch that never reached origin.
- `AlreadyIntegrated` carries no PR number (unlike `AlreadyMerged`): this
path is reached only after both the open- and merged-PR probes came back
empty, so there is no PR to record.
- Rebase note: an earlier version of this commit also added a merged-PR probe
and an `AlreadyIntegrated { pr }` field; that overlapped with `AlreadyMerged`
which landed on main first, so it was dropped in favor of main's richer
MergedPr lookup. This commit is now only the hub-side backstop.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jlong
deleted the
jlong/actions-make-the-merge-action-idempotent-so-an-already-merged-branch-advances-instead-of-stranding-the-card
branch
August 16, 2026 21:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
Defense-in-depth fix that protects every project regardless of orchestrator instructions. Complements the instruction-port task
zen-finalize-merges-via-the-review-done-transition-not-zen-pr-merge-...(which stops the orchestrator from double-merging in the first place). This task makes the double-merge harmless if it ever happens again.Current Behavior
The workflow
mergeaction (used by transitions likereview -> done: [merge, delete_branch]) does a hub-side squash-merge of the task branch into the base and commits. If the branch's content is ALREADY on the base (e.g. a priorzen pr-merge, or a human already merged the PR), the action fails two ways and leaves the card stuck in its pre-merge status:merge for <task> failed ... branch <b> is not on origin — run the push_branch action first.git -C /tmp/shelbi-merge-... commit -m "shelbi: merge <task> from <branch>"exits 1 (nothing to commit → empty squash), so the transition aborts and the card never reachesdoneeven though the work shipped.Reproduced 2026-08-16 on task
installer-suppress-cosmetic-launchd-boot-out-...(PR #570) after azen pr-mergehad already landed the squash commit192cf32onmain. Recovery required hand-editing the workflow to drop themergeaction.Expected Behavior
The
mergeaction is idempotent. Before merging it checks whether the branch is already integrated into the base — either the branch tip's content is already present on the base (no diff to merge / empty squash), or the branch's PR is already in the MERGED state. In that case the action treats the merge as a satisfied no-op and lets the transition proceed (sodelete_branchruns and the card advances todone), instead of erroring.Technical Details
Likely in the actions layer (
crates/.../actions—mergeprimitive) and/or the task-move transition runner. Suggested checks before attempting the hub-side merge:Bonus (separate consideration, note if out of scope): when an open PR exists for the branch, the transition merge could prefer
gh pr merge --squashso the PR shows as MERGED rather than being closed-unmerged by the branch deletion.Acceptance Criteria
reviewtodonewhen its branch is already merged into the base advances the card todone(runs remaining actions likedelete_branch) instead of failing.push_branch.mergeaction).Auto-opened by Shelbi — review at: /Users/jlong/.shelbi/projects/shelbi/tasks/actions-make-the-merge-action-idempotent-so-an-already-merged-branch-advances-instead-of-stranding-the-card.md