Skip to content

orchestrator supervision: auto-resolve PR merge conflicts (rebase, re-gate, re-park) #57

Description

@polymath-orchestrator

Goal

Add a standing duty to the orchestrator supervision loop: whenever the orchestrator notices a fleet-owned PR is CONFLICTING (GitHub mergeStateStatus DIRTY / mergeable=CONFLICTING), it must automatically fix the conflict — not just report the PR as parked-but-conflicted.

Requested by Nick on 2026-07-06 after PR #38 (AgentWrapper#2357 backport) sat conflicted twice: once from an unrelated merge, once after he merged #37 into overlapping sensitive files. Each time it needed a manual "please rebase" nudge. He wants the orchestrator to self-heal these.

Behavior to encode

On each supervision loop, for every PR the fleet owns:

  1. Detect conflict state (gh pr view <n> --json mergeable,mergeStateStatus → CONFLICTING / DIRTY).
  2. Dispatch (or perform) a rebase onto current origin/main and hand-resolve the conflicts, preserving all intended changesets (never drop one side to make it apply).
  3. Re-verify — mandatory, because a resolved conflict is new code: full local gates (cd backend && go build ./... && go vet ./... && go test ./...) + frontend typecheck where relevant; push --force-with-lease; confirm CI returns green and mergeStateStatus is CLEAN/UNSTABLE.
  4. Re-request the cross-family review on the re-resolved diff (the prior review verdict is stale once the merge is redone).
  5. Re-park merge-ready for the human. Conflict auto-resolution NEVER implies auto-merge — especially on sensitive paths (daemon/**, session_manager/**, lifecycle/**), which always park for a human regardless.

Guardrails (must be in the policy text, not just the happy path)

  • Scope to fleet-owned PRs only; skip anything the orchestrator can't cleanly attribute to a session/worktree it manages.
  • A "preserve both sides" resolution is a judgment call — it must go back through gates + review, never be declared ready on the rebase alone.
  • If the conflict can't be resolved confidently (semantic conflict, not just textual), park it for the human with a written note rather than force a dubious resolution — a parked item with a reason is a success state (per the two hard lines).
  • Rate-limit: a PR that re-conflicts repeatedly behind a churning file (like fix(send): submit multiline prompts + never nudge a session paused on a permission dialog AgentWrapper/agent-orchestrator#2357 behind every lifecycle merge) should be flagged to the human as "merge this next to stop the treadmill," not rebased indefinitely.

Acceptance criteria

  • Orchestrator supervision-loop policy (in agent-instructions/ sources) gains a "conflict auto-resolution" duty with the behavior + guardrails above
  • npm run agents regenerated so the duty appears in CLAUDE.md; npm run agents:check clean
  • The duty explicitly preserves the park-not-merge rule and the sensitive-path park list
  • Verified: point the orchestrator at a deliberately-conflicted fleet PR and confirm it rebases, re-gates, re-reviews, and re-parks without merging

Context / pointers

Metadata

Metadata

Labels

taskNon-feature work item

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions