Skip to content

fix(release): close superseded old-version release PRs - #20

Merged
chhoumann merged 1 commit into
mainfrom
fix/supersede-stale-release-prs
Jul 12, 2026
Merged

fix(release): close superseded old-version release PRs#20
chhoumann merged 1 commit into
mainfrom
fix/supersede-stale-release-prs

Conversation

@chhoumann

Copy link
Copy Markdown
Owner

Stage 1 (release-prepare) promises exactly one standing release PR, but its dedupe was keyed on the release/<version> head branch. When the planned version changed while a release PR stood - a feat: landing during a fix series bumps 0.6.7 to 0.7.0 - the workflow opened a new PR on a new branch and left the old-version PR open forever. The stale PR could never merge again (its recorded base can never again be the branch head), so it was pure noise requiring manual triage. Seen live as notetweet_obsidian #52 (0.6.7) and #53 (0.7.0), open simultaneously.

After creating or refreshing the standing PR, the open-pr script now enumerates open PRs in the release/<semver> namespace targeting the default branch and, for each one other than the standing PR:

  • verifies the same machine-generated provenance the branch-overwrite path requires (bot author, PR body marker, single-parent commit with the exact generated message, bot committer email, version files only, all modified);
  • comments "Superseded by release PR #N ..." with the reasoning, closes the PR, and deletes its branch;
  • leaves non-generated PRs in the namespace open with a warning (a human's branch is not ours to close);
  • fails the run loudly if a bot-authored release PR's branch commit is not machine-generated - that is a tampered generated branch and deserves manual triage. The new standing PR is created before this check, so a tampered stale branch never blocks the release itself.

The "different version" criterion (rather than "lower version") is deliberate: the current run plans from the verified current default-branch head, so its version is authoritative in both directions, including a revert that shrinks the planned version.

An alternative was a single fixed branch (structurally duplicate-proof), but the branch name is load-bearing: release-validate derives the version from the merged PR's head ref, and consumer release-trigger stubs filter on startsWith(head.ref, 'release/'). Supersede-on-prepare fixes the invariant without breaking the forensic contract or any consumer stub. This also heals existing repos: the next prepare run in a consumer closes any stale PR already sitting open.

Since the orchestration lives in an inline github-script block, the new test (scripts/release-prepare-pr.test.mjs) extracts that script from the workflow YAML and executes it against a mocked GitHub API - the shipped code is what runs under test. It covers fresh creation, same-version refresh, supersede, the non-generated skip, and the tampered-branch rejection.

Review focus: the provenance ladder in the supersede loop mirrors the existing branch-overwrite checks; confirm the fail-loud choice for tampered bot branches (versus skip-with-warning) matches the pipeline's philosophy.

The dedupe in the open-pr job was keyed on the release/<version> head
branch, so a version bump while a release PR stood (a feat landing
during a fix series) opened a second PR and left the old-version PR
open forever, even though its recorded base could never again be the
branch head. Seen live as notetweet_obsidian PRs #52 (0.6.7) and #53
(0.7.0), which required manual triage.

After creating or refreshing the standing PR, the script now lists
open bot-authored PRs in the release/<version> namespace, verifies the
same machine-generated provenance the branch-overwrite path requires,
and closes each superseded PR with an explanatory comment before
deleting its branch. Non-generated PRs in the namespace are left open
with a warning; a bot PR whose branch commit fails provenance fails
the run loudly for manual triage.

The new test extracts the real open-pr github-script from the workflow
and executes it against a mocked GitHub API, covering fresh creation,
same-version refresh, supersede, the non-generated skip, and the
tampered-branch rejection.
@chhoumann
chhoumann marked this pull request as ready for review July 12, 2026 21:24
@chhoumann
chhoumann merged commit 69b85e5 into main Jul 12, 2026
1 check passed
@chhoumann
chhoumann deleted the fix/supersede-stale-release-prs branch July 12, 2026 21:31
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.

1 participant