Skip to content

fix(bin): retry transient GitHub mergeability unknown - #6115

Closed
mehulbhagwani wants to merge 2 commits into
kunchenguid:mainfrom
mehulbhagwani:fm/fm-6020-unknown-retry
Closed

mehulbhagwani wants to merge 2 commits into
kunchenguid:mainfrom
mehulbhagwani:fm/fm-6020-unknown-retry

Conversation

@mehulbhagwani

Copy link
Copy Markdown
Contributor

Intent

do it

This is the fix PR for upstream issue #6020, "fm-pr-merge treats transient GitHub mergeable UNKNOWN as a terminal refusal". On 2026-09-28 the maintainer marked it ready-for-pr. Evidence on main: github_verify_mergeable in bin/fm-pr-merge.sh accepts only literal MERGEABLE; its caller runs it just before gh pr merge and exits on failure; there is no bounded backoff for UNKNOWN, so transient forge recalculation reads as a terminal unmergeable refusal. The fix is bounded backoff on UNKNOWN only; re-check all live conditions on each attempt, including head, draft, conflicts, checks, away-authority, and queue protections; after the bound, report pending, not unmergeable; do not weaken any other refusal. The PR must say "Fixes #6020". The implementation is committed on the feature branch and must be validated from that committed head. Open a new upstream PR with a MATCH attestation and include "Fixes #6020" in the PR body.

What Changed

  • github_verify_mergeable in bin/fm-pr-merge.sh now applies bounded backoff when GitHub reports mergeable state UNKNOWN instead of treating it as a terminal refusal, re-checking all live conditions (head, draft, conflicts, checks, away-authority, and queue protections) on each retry attempt.
  • After the retry bound is exhausted, the caller reports the PR as pending rather than unmergeable, while every other refusal path is left unchanged.
  • docs/configuration.md documents the new UNKNOWN-retry environment variables, and tests/fm-pr-merge.test.sh adds coverage for the retry and pending-report behavior.

Fixes #6020

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is a narrowly-scoped bounded retry added only on the UNKNOWN mergeable status (return code 10), re-verifying every live pre-merge condition on each attempt exactly as intent requires, without weakening any other refusal path, and is covered by four new behavioral tests exercising the real script.

Testing

Code review confirms the fix adds github_verify_mergeable_with_retry() which retries only on live UNKNOWN status (returns 10), re-verifies all live conditions each attempt (draft/conflicts/checks/away-authority/queue), refuses immediately on any other refusal or a head-commit change mid-retry, and reports exit code 3 ("still pending") after exhausting FM_PR_MERGE_UNKNOWN_RETRIES rather than treating exhaustion as a terminal unmergeable refusal. Four new tests exercise these paths end-to-end against a mocked gh CLI with sequenced JSON fixtures, asserting real exit codes and gh call logs — this is genuine product-level behavior verification, not string matching. I could not get the full test file to finish executing within this turn's time budget, so I have no live pass/fail confirmation to report — reporting all scenarios as untested rather than guessing.

  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
UNKNOWN mergeability resolves to MERGEABLE within retry bound and merges ⏸️ untested no The full test file run was still executing (long-running, many real subprocess/gh-mock invocations) when this turn's time budget was reached; could not capture its exit status.
UNKNOWN mergeability exhausts retry bound and reports pending (exit 3) rather than unmergeable ⏸️ untested no Same as above — full suite run did not finish before the turn ended.
Non-UNKNOWN refusal (e.g. CONFLICTING) still refuses immediately without retrying ⏸️ untested no Same as above — full suite run did not finish before the turn ended.
Head commit changes mid-retry causes a refusal instead of merging a different commit ⏸️ untested no Same as above — full suite run did not finish before the turn ended.
  • Outcome: ⚠️ 2 warnings across 1 run (6m15s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ Could not obtain a completed live test run for the new UNKNOWN-mergeability retry tests within the turn's time budget; the suite is long-running and subprocess-heavy. No failure was observed, but no pass was confirmed either — the run should be finished and checked before merge.
  • ⚠️ live validation verdict: inconclusive (0 of 4 scenarios were driven live against the product); untested: UNKNOWN mergeability resolves to MERGEABLE within retry bound and merges, UNKNOWN mergeability exhausts retry bound and reports pending (exit 3) rather than unmergeable, Non-UNKNOWN refusal (e.g. CONFLICTING) still refuses immediately without retrying, Head commit changes mid-retry causes a refusal instead of merging a different commit
  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
UNKNOWN mergeability resolves to MERGEABLE within retry bound and merges ⏸️ untested no The full test file run was still executing (long-running, many real subprocess/gh-mock invocations) when this turn's time budget was reached; could not capture its exit status.
UNKNOWN mergeability exhausts retry bound and reports pending (exit 3) rather than unmergeable ⏸️ untested no Same as above — full suite run did not finish before the turn ended.
Non-UNKNOWN refusal (e.g. CONFLICTING) still refuses immediately without retrying ⏸️ untested no Same as above — full suite run did not finish before the turn ended.
Head commit changes mid-retry causes a refusal instead of merging a different commit ⏸️ untested no Same as above — full suite run did not finish before the turn ended.
  • Read git diff d5c2507a..62a8d9b8 for bin/fm-pr-merge.sh and tests/fm-pr-merge.test.sh
  • Started bash tests/fm-pr-merge.test.sh (full suite) in background — still running at end of turn, no result captured
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Adds retry logic for GitHub mergeable status checks.

The PR appears safe to merge, with non-blocking follow-up warranted for override bounds and changing-blocker test coverage.

Reviews (1) · Last reviewed commit: "no-mistakes(document): Document new UNKN..."

Comment thread bin/fm-pr-merge.sh
Comment on lines +145 to +149
case "$UNKNOWN_RETRY_LIMIT" in
''|*[!0-9]*) echo "error: FM_PR_MERGE_UNKNOWN_RETRIES must be a non-negative whole number" >&2; exit 2 ;;
esac
case "$UNKNOWN_RETRY_BACKOFF_SECS" in
''|*[!0-9]*) echo "error: FM_PR_MERGE_UNKNOWN_BACKOFF_SECS must be a non-negative whole number" >&2; exit 2 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Retry overrides have no ceiling A mistyped retry count or backoff value can keep the merge waiting for an effectively unbounded time. The process holds the task control lock throughout that wait, blocking the task’s watcher and teardown. Cap both values so an override cannot defeat the bounded-retry safeguard.

Comment thread tests/fm-pr-merge.test.sh
Comment on lines +2512 to +2515
expect_code 0 "$rc" "github-unknown-then-mergeable: UNKNOWN should retry and merge"
[ "$(cat "$case_dir/github-view-sequence-pos")" -eq 2 ] \
|| fail "github-unknown-then-mergeable: full verification did not rerun"
assert_logged_gh_merge "$case_dir" 81 example/repo --squash

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Changing blockers remain untested This test confirms that verification runs again, but its draft state, checks, and away authority never change. It therefore cannot catch a regression that merges after one of those conditions becomes blocking during backoff. Add a case that changes a blocker between views and asserts that no merge occurs.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @mehulbhagwani — really appreciate you taking the time on this. Closing as overlap: the same fix for #6020 already landed in #6110 (karotkriss), which was further along (CLEAN CI, live validation go, capped retry delay, re-check coverage for a check turning red mid-retry).

Your tip also restores the UNKNOWN-retry path (and documents FM_PR_MERGE_UNKNOWN_RETRIES / FM_PR_MERGE_UNKNOWN_BACKOFF_SECS). Greptile P2 notes (uncapped overrides; changing-blocker test) and inconclusive live validation meant this sibling was not the one we merged. No further action needed here.

Contract-class: restore (same concrete fm-pr-merge UNKNOWN path). Firstmate flag no.

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.

fm-pr-merge treats transient GitHub mergeable UNKNOWN as a terminal refusal

2 participants