Repository navigation
fix(bin): recover a landed GitHub PR merge from a non-zero merge command - #48
Merged
Merged
Conversation
adibirzu
force-pushed
the
fm/fm-pr-merge-outcome-false-error
branch
from
September 13, 2026 00:21
3674a8f to
cfb2cfc
Compare
adibirzu
force-pushed
the
fm/fm-pr-merge-outcome-false-error
branch
from
September 13, 2026 07:40
cfb2cfc to
2ae1c25
Compare
adibirzu
force-pushed
the
fm/fm-pr-merge-outcome-false-error
branch
2 times, most recently
from
September 13, 2026 22:29
177101f to
704f8d2
Compare
adibirzu
force-pushed
the
fm/fm-pr-merge-outcome-false-error
branch
from
September 13, 2026 23:05
704f8d2 to
f9391f4
Compare
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
2026-09-12, "go. finish all the needed fixes. use all the available llms" - finish the firstmate defect where a successful GitHub merge is then reported as an invalid PR merge request, so a merge that actually succeeded is reported as success; ship the queued firstmate defects across available harnesses and merge under that standing word once green on the fork.
What Changed
bin/fm-pr-merge.sh: takes a best-effort live read of the PR'smergedstate before invokinggh-axi pr merge; if that command exits non-zero, a follow-up authoritative read that shows amerged=false→merged=truetransition is now reported as a landed success via a newgithub_report_recovered_landed_outputnotice, instead of being refused as a failed merge — an unknown pre-state or a pre-state that was already merged still falls back to the existing fail-closed refusal/actionable-output paths.bin/fm-pr-merge.sh: reworks the post-merge-command branching so the already-read outcome is reused instead of re-reading, and the exit path skips exiting on the recovered case while still preserving the command's diagnostic output.docs/architecture.md: documents the new recovery condition (pre-readmerged=false+ post-readmerged=truerecovers a non-zero exit as landed; unreadable or already-merged pre-state stays fail-closed) and points to the script header as owner of the exact condition.tests/fm-pr-merge.test.sh: adds/extends coverage for the recovered-landed-success path alongside the existing fail-closed cases.Risk Assessment
✅ Low: The change is narrowly scoped to bin/fm-pr-merge.sh's GitHub merge path: it adds a best-effort premerge read, records it, and only treats a failed
gh-axi pr mergeas a recovered success when that premerge read proved merged=false and the post-command read proves merged=true — every other pre-state (unknown or already-merged) still fails closed with the original non-zero exit, matching the previously-decided fix for the mislabeled already-merged case (confirmed present in this diff at bin/fm-pr-merge.sh's elif condition). Tests exercise real script behavior (exit codes, stdout/stderr, state files) rather than source-text matching, and I traced the control flow for all pre/post-state combinations (false→true, true→true, unknown→true, queued cases) without finding a path that silently returns a wrong result.Testing
Ran the full targeted behavior suite for the changed file (tests/fm-pr-merge.test.sh) against the real bin/fm-pr-merge.sh — all 62 cases passed, including the two cases added/rewritten by this branch for the reported defect and the round-1 mislabeling fix — then drove one additional adversarial scenario by hand (unproven pre-merge state) to confirm the fail-closed boundary the intent calls out is not accidentally widened; that scenario also passed. No code changes were needed and the working tree remains clean.
bash tests/fm-pr-merge.test.sh→ok - fm-pr-merge preserves success when only the forge's post-merge report fails(test_github_post_merge_report_failure_preserves_landed_success): drives the real…bash tests/fm-pr-merge.test.sh→ok - fm-pr-merge reports an already-merged pre-state as actionable, not as a contradictory unsuccessful outcome(test_github_failed_merge_on_already_merged_pr_repo…bash tests/fm-pr-merge.test.sh→ passing tests 'fm-pr-merge propagates a real merge failure without silently succeeding', 'fm-pr-merge refuses a GitHub merge call that leaves the PR open and unqueue…Evidence: fm-pr-merge.test.sh full run (62/62 ok, exit 0)
Evidence: Manual adversarial run: unreadable pre-merge state + failed merge command + post-merge merged=true
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-pr-merge.test.sh→ok - fm-pr-merge preserves success when only the forge's post-merge report fails(test_github_post_merge_report_failure_preserves_landed_success): drives the real…bash tests/fm-pr-merge.test.sh→ok - fm-pr-merge reports an already-merged pre-state as actionable, not as a contradictory unsuccessful outcome(test_github_failed_merge_on_already_merged_pr_repo…bash tests/fm-pr-merge.test.sh→ passing tests 'fm-pr-merge propagates a real merge failure without silently succeeding', 'fm-pr-merge refuses a GitHub merge call that leaves the PR open and unqueue…bash tests/fm-pr-merge.test.sh (full file, 62 assertions, all ok, exit 0)Manual live run of bin/fm-pr-merge.sh with a custom fake gh-axi simulating an unreadable pre-merge read + failed merge command + merged=true post-merge read (adversarial fail-closed guard check)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.