Skip to content

Auto-merge Sortie-created PRs on approval and green CI #417

@sergeyklay

Description

@sergeyklay

When a Sortie-created PR is approved by reviewers and all CI checks pass, the orchestrator should optionally merge it automatically. This closes the issue-to-PR-to-merge cycle without requiring human intervention for the final step.

Depends on #414 (generalized reaction primitives). This is a reaction with kind auto-merge that fires on the approved + CI green compound condition.

Detection: during the reconcile cycle, check if a Sortie-managed PR satisfies all merge preconditions: review approved (or no reviewers required), CI passing, no merge conflicts, and the PR is not a draft. Use existing SCM adapter methods (GetReviewDecision, GetCIStatus, GetMergeability).

Action: call a new MergePR(ctx, pr, strategy) error method on the SCM adapter interface. The merge strategy (merge commit, squash, or rebase) is configurable in WORKFLOW.md with a sensible default (squash). The orchestrator performs the merge directly rather than dispatching an agent continuation, since no code changes are needed.

Config: reactions.auto_merge with fields:

  • enabled: bool (default false, opt-in)
  • strategy: string (default squash, options: merge, squash, rebase)
  • require_ci: bool (default true)
  • delete_branch: bool (default true)

Auto-merge is disabled by default. Teams must explicitly opt in via WORKFLOW.md config. This is intentional: merging is an irreversible action and should require conscious configuration.

Guard rails: only merge PRs with the Sortie-managed label/branch convention. Never merge draft PRs. Log the merge action prominently. Post a tracker comment on the linked issue confirming the auto-merge.

Verify: configure reactions.auto_merge.enabled: true in WORKFLOW.md. A Sortie-created PR receives approval and CI passes. The orchestrator merges the PR using the configured strategy and deletes the source branch. When auto-merge is disabled (default), approved PRs are not merged automatically. Draft PRs are never auto-merged regardless of config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:orchestratorDispatch, retry, reconciliation, state machine, poll looparea:tracker-adapterTracker interface, Jira adapter, GitHub adapter, file adapter

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions