Skip to content

Update a behind branch and wait for fresh CI before auto-merging #3447

Closed

Description

@integry

Problem

ProPR's auto-merge requires GitHub to report the PR as clean. A PR that is merely behind its base is skipped until something else changes it, so with several agents merging into one repository PRs stall. Where branch protection does not require up-to-date branches, two PRs that each pass alone can merge and break the base together.

Goal

Merge-queue-like behaviour for ProPR-managed auto-merge.

Acceptance criteria

  • A new auto_merge.require_up_to_date option in .propr/workflow.yml (default false), following the optional-key pattern (validator, schema parity, scaffold, docs).
  • When enabled and an auto-merge candidate passes every other gate but its head does not contain the latest base commit, ProPR updates the branch through GitHub's update-branch API (with the expected head SHA) instead of merging, and does not merge that head.
  • The merge is attempted again only when CI has passed on the updated head; the existing check-run and sweep paths provide the re-evaluation.
  • If the update fails because of conflicts, the existing opt-in conflict-resolution flow is used when enabled; otherwise the PR is left with a comment explaining why auto-merge is waiting.
  • Updates are rate-limited per PR (no more than a configured number per hour) so a busy base branch cannot cause an update loop; per-repository updates are serialised so only the oldest eligible PR is updated at a time.
  • Every decision is recorded with the existing auto-merge decision event (new reasons for "updated branch" and "waiting for CI on updated head").
  • With the option off, behaviour is unchanged.
  • Tests cover behind, up-to-date, conflict, rate limit, serialisation and option off.

Implementation

Key files: packages/core/src/webhook/checkRunHandler.ts (processPRAutoMerge, between the mergeable-state gate and mergePR), packages/core/src/webhook/checkRunHelpers.ts (getCiMergeReadiness, mergePR, hasActiveTasksForPR), packages/core/src/workflow/autoMergePolicy.ts (config, reasons), packages/core/src/services/autoMergeGate.ts (recordAutoMergeDecisionEvent), src/daemon/autoMergeSweep.ts, packages/core/src/webhook/mergeConflictAutoResolve.ts, packages/api/mcp/toolsPullRequests.ts (update_pull_request_branch uses the same GitHub call), docs/docs/features/repository-workflow.md. Tests: test/checkRunHandler.test.ts, test/autoMergeSweep.test.ts, packages/core/test/autoMergePolicy.test.ts. Verify with npm run test:prepare, npm run typecheck, the changed test files via node scripts/run-test-suite.mjs, and eslint --max-warnings 0 per touched package.

Activity

  1. propr-dev commented on Nov 11, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3447/claude-opus-5-5-update-a-behind-branch-an-20261111-2200-q3e
    • Base Branch: main
    • Worktree: issue-3447-20261111-2200-claude-opus-5-5-q3e

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions