Skip to content

Merge the Base branch again when it moves while CI runs - #57

Merged
JacobStephens2 merged 2 commits into
mainfrom
base-moves-during-ci
Sep 25, 2026
Merged

JacobStephens2 merged 2 commits into
mainfrom
base-moves-during-ci

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

Summary

A Base branch that moves while CI runs now gets merged again instead of failing the Run. vacation#28 ended as a Failed run, with PR vacation#40 sent back to draft and all 3 Repairs unused: PR vacation#38 merged into main at 20:29:44, inside the 60s CI wait on 6e1234c, and the final mergeable check found the conflict in ConsideredGames.java.

 repair_loop
   loop
     merge origin/<base>
       conflicted -> conflict Repair, go round
     push
     watch CI
       red -> CI-fix Repair, go round
-      green or absent -> done
+      green or absent
+        fetch origin/<base>
+        not moved -> done
+        moved 3 times already -> Failed run
+        else -> go round
 ensure_pr_ready_and_mergeable

A merge after a move may need a conflict Repair, which draws on the usual MAX_REPAIRS budget. MAX_BASE_MOVES = 3 caps the moves themselves, since a clean merge uses no Repair and a busy Base branch could otherwise keep a Run going forever.

The fake gh gains gh fake on-ci-read <times> '<script>', which runs a script the first time thirdshift reads CI on each new head, so tests can move main mid-watch.

Evidence

  • Before: the three new tests in tests/mergeable.rs fail on main:
    merges_a_base_branch_that_moved_while_ci_passed
      main moves during CI -> origin issue-7 has no merge of main       FAILED
    hands_a_conflict_from_a_base_branch_that_moved_during_the_ci_wait_to_a_repair
      main moves on feature.txt during CI -> 1 claude call, not 2        FAILED
    fails_when_the_base_branch_keeps_moving_during_the_ci_wait
      main moves on every CI wait -> exit 0                              FAILED
    
    After: all pass. The conflict case, which is the vacation#28 shape, ends in exit 0 with a conflict Repair and a ready PR. The keeps-moving case ends as a Failed run after exactly 3 merges, with origin/main kept moving while CI ran: merged it again 3 times. Full suite: 107 passed, and cargo clippy --all-targets -D warnings is clean.

Merge Danger

Door: two-way

A revert restores the old behaviour. No state or format changes.

Blast Radius: Runs

A Run whose Base branch moves while CI runs now takes up to 3 more merge-and-CI rounds, each with its own CI grace period, before it ends. On a busy Base branch that adds wall-clock time where it used to fail fast.

vacation#28 ended as a Failed run with PR 40 sent back to draft, with all
3 Repairs unused. PR #38 merged into main at 20:29:44, inside the 60s CI
wait on 6e1234c. repair_loop only re-merged the Base branch after a
Repair, so green or absent CI returned straight to the final mergeable
check, which found the conflict in ConsideredGames.java and failed.

After green or absent CI, repair_loop now fetches the Base branch and, if
it moved, goes round again: a clean merge is pushed and CI watched on the
new head, and a conflict gets a conflict Repair from the usual budget.
Rounds without a Repair are capped at 3 (MAX_CATCH_UPS), so a busy Base
branch cannot keep a Run going forever; past the cap it is a Failed run.

The fake gh gains `gh fake on-ci-read <times> '<script>'` so tests can
move main while thirdshift waits for CI.
The cap is now MAX_BASE_MOVES and counts every move of the Base branch
while CI ran, whether or not the merge after it needs a Repair, in plain
words rather than a new "catch-up" term. The upstream check shared by
ensure_base_branch_merged and base_branch_moved lives in one helper. The
tests now pin the cap at exactly 3 merges and cover the base moving
while CI passes, not only while it is absent.
@JacobStephens2
JacobStephens2 merged commit cd34e42 into main Sep 25, 2026
13 checks passed
@JacobStephens2
JacobStephens2 deleted the base-moves-during-ci branch September 25, 2026 22:03
@JacobStephens2 JacobStephens2 mentioned this pull request Sep 26, 2026
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