Hello. We gate merges into main on Origin with a ruleset (require_status_checks) and a script that merges with origin pr merge --squash --expect-head. We want to know exactly what Origin guarantees at the moment of a merge and of a push, so that our script does not assume more than the server enforces. We could not find these points in the documentation.
require_branch_up_to_date (merge ruleset). At merge time, what is compared: whether the pull request head contains the live tip of the base branch, or the base recorded on the pull request version (version.baseSha, which the API docs say “can lag the branch’s current tip”)?
Atomicity of merge rules. Are the ruleset conditions (require_branch_up_to_date, require_status_checks) and --expect-head / expectedHeadSha checked inside the same transaction that writes the merge commit to the base branch? If the base tip moves between the check and the write, can the merge still land? Is there a per-branch lock?
Required checks and the base. The API reference says required checks count base-agnostic attempts and attempts matching the PR’s latest recorded version base. When the recorded version base is older than the live base tip, can a check posted for that older base still satisfy require_status_checks at merge time?
Squash parent. For a squash merge, is the new commit’s parent the recorded version.baseSha or the live base tip at the moment of the write? If the live tip moved after evaluation, does the merge refuse, or land on the new tip?
The behind_base blocker. What does the mergeability blocker behind_base mean, when is it raised, and how does it appear in origin pr view --json?
Stack-member pins. The CLI help says an Origin server without stack-member pins checks only the named change’s pin. Does the current Origin service have stack-member pins?
Push old-value check. On a git push, does the Origin git server check the client’s old object id for the ref atomically with the ref update, so that a push based on a stale old value is always refused (with or without --force-with-lease), even when the new commit is a descendant of the ref’s current value?
Hi @Bryon_McCoy, short version: the merge write is conditional on both the base tip and the PR head that were evaluated, but required checks on their own are not tied to the live base tip. In your order:
The recorded base, compared with the live tip. The rule passes only when the tip of the base branch, read at merge time, equals the base_sha of the PR’s latest version. It is an equality test on that recorded base, not an ancestry test on the head, so once the base branch moves the rule fails until a head push or retarget records a new version.
Not one transaction, but the write is a compare-and-swap. The rules are evaluated right before the write, against a base tip and a head read at that moment, and --expect-head is compared with that same head. The merge commit is built from exactly that head and is written only if the base branch is still at that tip. If the base moved, nothing lands on the old evaluation: Origin evaluates again against the new tip and retries a limited number of times, then fails the merge. Don’t count on a per-branch lock, and anything else a rule reads (a check result, a review) is as of that evaluation.
Yes. Required checks are matched on the PR head plus the recorded version base (or no base), never on the live tip. With require_status_checks alone, a check reported for the older recorded base still counts after the base branch moves. Add require_branch_up_to_date if the tested base has to be the tip you land on.
The live tip. The squash commit’s parent is the base tip the merge evaluation read, not version.baseSha. If that tip moves first, see 2: the write is refused, and after a fresh evaluation the squash lands on the new tip if the rules still pass. With only require_status_checks they usually will, so don’t assume the parent is the commit your checks ran against.
behind_base is the mergeability blocker for a failing require_branch_up_to_date, so it only appears when a ruleset on the base branch has that rule and the base tip no longer equals the PR’s recorded base. In origin pr view <number> --json mergeability it shows as mergeable: false with a failed require_branch_up_to_date rule (“Branch is out of date with the target branch.”). The behind_base kind itself is what the mergeability API returns in its blockers list.
Yes. The current service checks every --expect-head <number>=<sha> pin, for the PR you name and for each stack member the merge lands.
Yes. Each ref update in a push is applied as a compare-and-swap on the old value your client sent. If the ref is not at that value when the update is applied, that ref is rejected with “incorrect old value provided”, even when your new commit descends from the ref’s current value, and forcing doesn’t change that. Keep in mind the old value is the one the server advertised at the start of that push; the --force-with-lease comparison with your tracking ref happens in your git client.