Skip to content

docs: Harden stacked-PR recovery to resolve merge SHA from the PR#60

Merged
thecodedrift merged 2 commits into
mainfrom
jakob/harden-stack-recovery-doc
Jul 11, 2026
Merged

docs: Harden stacked-PR recovery to resolve merge SHA from the PR#60
thecodedrift merged 2 commits into
mainfrom
jakob/harden-stack-recovery-doc

Conversation

@thecodedrift

Copy link
Copy Markdown
Member

Harden the "Recovery if a child PR gets closed by base-branch deletion" step in the stacked-PR runbook so it resolves the correct SHA regardless of what has landed on main since.

The restore command used git rev-parse origin/main^2 to recover the child's merge-commit second parent. That's only correct while the child's merge is still main's tip — once any later PR merges, or the tip is a squash/rebase commit, origin/main^2 points at an unrelated merge's second parent and restores the wrong branch head. The step now resolves the merge commit from the closed PR itself (gh pr view <n> --json mergeCommit) and takes its second parent.

Surfaced by Copilot on the marketing team's port of this same runbook (taskless/public#9). Fixing it here since this CLAUDE.md is the upstream copy — it flows down to public and taskless/taskless. The two other Copilot findings on that PR (the github.paginate workflow_runs/jobs comments) were false positives — paginate normalizes namespaced list responses to flat arrays — and were replied to and resolved there.

Docs-only; no release note (carries skip-changeset).

@thecodedrift thecodedrift added the skip-changeset PR intentionally ships no release note (bypasses the changeset requirement) label Jul 11, 2026
@thecodedrift
thecodedrift marked this pull request as ready for review July 11, 2026 07:39
Copilot AI review requested due to automatic review settings July 11, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the stacked-PR runbook in CLAUDE.md to make “recovery after base-branch deletion” resolve the correct restore SHA via GitHub PR metadata instead of relying on origin/main^2, which can drift after subsequent merges.

Changes:

  • Replaces git rev-parse origin/main^2 with a flow that looks up the merge commit SHA via gh pr view ... --json mergeCommit.
  • Expands the runbook guidance to explain why origin/main^2 is unsafe once main moves past the relevant merge commit.

Comment thread CLAUDE.md Outdated
thecodedrift and others added 2 commits July 11, 2026 01:01
The base-branch restore step used `git rev-parse origin/main^2`, which only
yields the child's merge-commit second parent while that merge is still main's
tip. Once any later PR merges (or the tip is a squash/rebase commit), origin/main^2
points at the wrong SHA and restores the wrong branch head.

Resolve the merge commit from the closed PR itself via `gh pr view --json
mergeCommit`, then take its second parent — correct regardless of what has
landed on main since. Surfaced by Copilot on the taskless/public port of this
runbook (public#9); fixing it upstream here so it flows to public and
taskless/taskless.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The restore step resolved the merge commit from <n>, the same placeholder
used for the child PR in steps 2-3. But the child is the PR that gets *closed*
by the base-branch deletion — it is unmerged, so its mergeCommit is null and
git rev-parse "$MERGE_SHA^2" would fail. The merge commit belongs to the
parent PR (merged with --delete-branch); its second parent is the deleted base
branch's pre-merge tip.

Split the placeholders into <parent> (merged) and <child> (closed), and add a
lead-in naming the two PRs so the step reads unambiguously. Caught by Copilot
review on this PR.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thecodedrift
thecodedrift force-pushed the jakob/harden-stack-recovery-doc branch from 1115a8d to 89c15d5 Compare July 11, 2026 08:01
@thecodedrift
thecodedrift merged commit 60bd8f1 into main Jul 11, 2026
4 checks passed
@thecodedrift
thecodedrift deleted the jakob/harden-stack-recovery-doc branch July 11, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changeset PR intentionally ships no release note (bypasses the changeset requirement)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants