Skip to content

fix(bin): recover a landed GitHub PR merge from a non-zero merge command - #48

Merged
adibirzu merged 3 commits into
mainfrom
fm/fm-pr-merge-outcome-false-error
Sep 13, 2026
Merged

adibirzu merged 3 commits into
mainfrom
fm/fm-pr-merge-outcome-false-error

Conversation

@adibirzu

@adibirzu adibirzu commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

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's merged state before invoking gh-axi pr merge; if that command exits non-zero, a follow-up authoritative read that shows a merged=false → merged=true transition is now reported as a landed success via a new github_report_recovered_landed_output notice, 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-read merged=false + post-read merged=true recovers 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 merge as 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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Proven live merged=false→merged=true recovers a failed post-merge report as success ✅ pass live 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…
Already-merged pre-state on a failed merge command stays fail-closed with the correct (non-contradictory) actionable message ✅ pass live 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…
Adversarial: unreadable/unknown pre-merge state plus a failed merge command that later reads back merged=true must NOT be recovered as success (guards against over-eager recovery) ✅ pass live Manually drove the real bin/fm-pr-merge.sh (not part of the committed suite) with a fake gh-axi whose first 'pr view' call (pre-merge) fails outright (simulating an unreadable pre-state), 'pr merge' f…
A genuine (non-recovered) merge failure still fails closed and quotes the forge's own error ✅ pass live 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)
ok - fm-pr-merge reports an already-merged pre-state as actionable, not as a contradictory unsuccessful outcome
ok - fm-pr-merge falls back to the gh-axi view when gh's read fails
ok - fm-pr-merge preserves success when only the forge's post-merge report fails
... (62 lines total, all 'ok', exit code 0)
Evidence: Manual adversarial run: unreadable pre-merge state + failed merge command + post-merge merged=true
EXIT CODE: 2
--- stdout ---
armed: state/task-x1.check.sh
--- stderr ---
error: invalid PR merge request
actionable: the merge command for https://github.com/example/repo/pull/91 failed, but the pull request reads back as state=MERGED, merged=true, isInMergeQueue=false
--- gh-axi.log ---
pr view 91 --repo example/repo
pr merge 91 --repo example/repo --squash
pr view 91 --repo example/repo

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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Proven live merged=false→merged=true recovers a failed post-merge report as success ✅ pass live 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…
Already-merged pre-state on a failed merge command stays fail-closed with the correct (non-contradictory) actionable message ✅ pass live 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…
Adversarial: unreadable/unknown pre-merge state plus a failed merge command that later reads back merged=true must NOT be recovered as success (guards against over-eager recovery) ✅ pass live Manually drove the real bin/fm-pr-merge.sh (not part of the committed suite) with a fake gh-axi whose first 'pr view' call (pre-merge) fails outright (simulating an unreadable pre-state), 'pr merge' f…
A genuine (non-recovered) merge failure still fails closed and quotes the forge's own error ✅ pass live 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.

@adibirzu adibirzu changed the title fix(fm-pr-merge): recover landed GitHub merges when the post-merge report fails fix(fm-pr-merge): recover landed GitHub merges when the merge command exits non-zero Sep 12, 2026
@adibirzu
adibirzu force-pushed the fm/fm-pr-merge-outcome-false-error branch from 3674a8f to cfb2cfc Compare September 13, 2026 00:21
@adibirzu adibirzu changed the title fix(fm-pr-merge): recover landed GitHub merges when the merge command exits non-zero fix(fm-pr-merge): stop landed GitHub merges from reporting a false invalid-request error Sep 13, 2026
@adibirzu
adibirzu force-pushed the fm/fm-pr-merge-outcome-false-error branch from cfb2cfc to 2ae1c25 Compare September 13, 2026 07:40
@adibirzu adibirzu changed the title fix(fm-pr-merge): stop landed GitHub merges from reporting a false invalid-request error fix(fm-pr-merge): recover landed GitHub merges from a non-zero merge command Sep 13, 2026
@adibirzu adibirzu closed this Sep 13, 2026
@adibirzu adibirzu reopened this Sep 13, 2026
@adibirzu
adibirzu force-pushed the fm/fm-pr-merge-outcome-false-error branch 2 times, most recently from 177101f to 704f8d2 Compare September 13, 2026 22:29
@adibirzu adibirzu changed the title fix(fm-pr-merge): recover landed GitHub merges from a non-zero merge command fix(merge): recover landed GitHub merges after a non-zero merge command Sep 13, 2026
@adibirzu
adibirzu force-pushed the fm/fm-pr-merge-outcome-false-error branch from 704f8d2 to f9391f4 Compare September 13, 2026 23:05
@adibirzu adibirzu changed the title fix(merge): recover landed GitHub merges after a non-zero merge command fix(bin): recover a landed GitHub PR merge from a non-zero merge command Sep 13, 2026
@adibirzu
adibirzu merged commit 2fdd46f into main Sep 13, 2026
16 checks passed
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