Repository navigation
fix(bin): allow attended merges for cleaned-up GitHub PRs - #70
Merged
Merged
Conversation
… gone fm-pr-merge.sh refused any merge without task metadata, so a PR that outlived its cleaned-up task had no guarded merge path. --closed-task is that attended path: it requires --expected-head, keeps every live green, head, hold, and queue guard, refuses while away or with auto-merge or branch-update flags, and records nothing against the gone task.
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.
Intent
Q2244 ALL (2026-11-18, main chat): "q2244 all. feel free to do whatever you think is the good idea amd is safe" - use the Claude allowance before its reset on three Claude-only jobs.
This job is part of option C: build this held Firstmate fix now, with Claude writing the code.
bin/fm-pr-merge.sh cannot merge a PR whose job was already closed and cleaned up: on 2026-10-31 the captain approved merging docs-only PR https://github.com/peterOC26/PurpleVoice_GSD_Claude/pull/239, but the merge script refused with "task metadata is unavailable" because job pv-sydney-trial-run-r2 had been cleaned up first. There is no guarded path for a PR that outlived its job.
What Changed
--closed-taskfor attended GitHub PR merges after task cleanup, requiring an expected head and preserving the merge, captain-hold, away-posture, and queue safeguards.Risk Assessment
✅ Low: The new --closed-task path is narrow and only adds checks: it works only for attended GitHub merges and needs a pinned approved head. It refuses when the task record still exists, when a merge queue may be in play, when the away-posture record exists, and with --attended-override, --update-branch or --auto (that last one through reject_protected_forge_args). It skips only the code that reads and writes the task record, and it still applies the live green, mergeable and captain-hold guards.
Testing
The focused closed-task regression selectors passed. The final live run used the real merge script and
ghwith synthetic PR data on localhost: the stale head was refused, and the approved head merged with a supervision outcome and no recreated task metadata or poll. The emulator response was adjusted to match the CLI’s GraphQL contract before the final run;git diff --checkwas clean.--closed-taskafter task cleanup; the CLI verifies the merge and records its supervision outcome without recreating task metadata or a poll.--closed-task; the script refuses and sends no merge mutation.Evidence: Live merge through real GitHub CLI and localhost API emulator
Source: Live merge through real GitHub CLI and localhost API emulator
Evidence: Focused closed-task regression tests
Source: Focused closed-task regression tests
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-pr-merge.sh:1993- In --closed-task mode, a pull request whose base branch has moved on (mergeStateStatus=BEHIND, so FM_PR_GITHUB_BEHIND=true at line 1233) gets this error: "updating its source branch requires explicit --update-branch consent on this authorized merge request". But --closed-task refuses --update-branch at lines 409-411, so following that advice only produces a second refusal with exit 2. This is a likely case for a PR that outlived its task by weeks, like the 2026-10-31 PR in the intent, when branch protection requires branches to be up to date. Concrete sequence: runfm-pr-merge.sh pv-x <url> --closed-task --expected-head Hon a green PR that reads BEHIND. It exits 1 and tells the operator to add --update-branch. They rerun with --update-branch and get exit 2 with "--closed-task refuses --attended-override and --update-branch". Fix: when CLOSED_TASK=true, print a closed-task message instead. It should say the branch must be updated outside this script, and the merge rerun with --expected-head set to the new head once the captain approves it. No behavior change is needed.✅ **Test** - passed
✅ No issues found.
--closed-taskafter task cleanup; the CLI verifies the merge and records its supervision outcome without recreating task metadata or a poll.--closed-task; the script refuses and sends no merge mutation.git diff --check 9706deb4410ccc693f644f8d750b95eb0d83e8af..d02b66af805bf45b2dc995758dbc1d4570cb418dFocused selectors fromtests/fm-pr-merge.test.sh:test_closed_task_merges_a_pr_that_outlived_its_taskandtest_closed_task_keeps_every_guardRan the realbin/fm-pr-merge.shand/usr/bin/ghagainst a localhost-only synthetic GitHub API emulator for approved-head merge and stale-head refusal.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.