Repository navigation
fix(bin): accept a green merge-result pipeline built for the current head in fm-pr-merge - #61
Merged
Merged
Conversation
added 2 commits
October 14, 2026 12:48
…head in fm-pr-merge Projects that run only merge-result pipelines (platform-infra, devops/observability) never have a pipeline whose sha is the merge request head, so every guarded merge there was refused. The guard now also accepts a successful merge_request_event pipeline on refs/merge-requests/<iid>/merge whose synthetic merge commit has the live head as its second parent, provided no branch pipeline at that head is anything but success. Runs built for an older head, failed or running runs, and unconfirmable builds stay refused, with every failing condition reported. The merge-result ref classification moves into fm-pr-lib.sh so fm-pr-status and fm-pr-merge share one predicate.
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
Fix bin/fm-pr-merge.sh so a GitLab merge request whose project runs only merge-result pipelines can be merged when that merge-result pipeline is green and current.
Problem: the GitLab guard refused unless the head pipeline ran at the exact current head commit ("the head pipeline ran at ..., not at the current head ..."). platform-infra and devops/observability run only merge-result pipelines, so the pipeline SHA is always a synthetic merge commit and every guarded merge there was refused. Receipt: platform-infra !1884 on 2026-10-14, approved twice, mergeable, merge-result pipeline success on 0536d43d, head 4995446e.
Acceptance (from the task):
Decisions made:
What Changed
bin/fm-pr-merge.sh: the GitLab guard now accepts a green merge-result pipeline (sourcemerge_request_event, refrefs/merge-requests/<iid>/merge) only if its commit has exactly two parents and the second parent is the live head. It also requires the newest non-external branch pipeline at the head, if there is one, to be green. It still refuses merge-result runs that failed, are still running, were built for an older head or for another MR, and it reports every failing condition. The branch-pipeline-at-head path is unchanged, and the script header now documents the newly accepted shape.bin/fm-pr-lib.sh: new shared predicatefm_pr_gitlab_ref_is_merge_result. Bothfm-pr-merge.shandbin/fm-pr-status.shnow use it to classify the badge kind instead of each having its own copy.tests/fm-pr-merge.test.shadds tests for these cases: merge-result green and current (accepted), stale head (refused), failed (refused), and branch pipeline at head (accepted).docs/architecture.mdnow mentions that merge-result pipelines are accepted.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The merge guard is relaxed only for a green merge-result run on this merge request's own merge ref, and only after the forge confirms it was built for the live head and no branch run at that head is red; every other shape is still refused, the header documents the new case, and colocated behavioural tests cover the required cases.
Testing
I ran the colocated behavioural suite for fm-pr-merge, which uses a stubbed glab, and it passes. A green merge-result run built for the current head (parent_ids[1] equals the live head) merges and reports the accepted shape. A merge-result run built for a stale head, a failed or running one, a green badge over a failed branch run at the head, and one whose build cannot be proven are all refused. The branch-pipeline-at-head path is unchanged. The fm-pr-status suite also passes after the shared-predicate refactor. Running the new tests against the pre-fix script fails the merge-result acceptance case, which reproduces the !1884 bug. There is no UI surface; the evidence is the CLI test transcripts.
Evidence: fm-pr-merge behavioural test transcript (post-fix)
Source: fm-pr-merge behavioural test transcript (post-fix)
Evidence: fm-pr-status test transcript
Source: fm-pr-status test transcript
Evidence: New tests against the pre-fix script (reproduces the refusal)
Source: New tests against the pre-fix script (reproduces the refusal)
not ok - gitlab-merge-result-current: a green merge-result pipeline built for the head should merge: expected exit 0, got 1Pipeline
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(exit 0; covers (v) current-head merge-result accepted, (w) stale head refused, (x) failed/running refused, (y) green MR badge over failed branch run refused, (z) unprovable build refused, plus unchanged branch-at-head and all earlier GitLab/GitHub cases)bash tests/fm-pr-status.test.sh(exit 0; the shared predicate refactor did not break the fm-pr-status badge classification)Regression repro: ran the new tests/fm-pr-merge.test.sh plus bin/fm-pr-lib.sh against the base commit ac50aa5's fm-pr-merge.sh in a temporary worktree (since removed).gitlab-merge-result-currentfails there with exit 1, so the test reproduces the original refusal✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.