feat(review): opt-in, comment-driven merge-conflict resolution

Merged
KH
5mo ago
+301-13

What

Adds opt-in, comment-driven merge-conflict resolution to the review agent (pr-reviewer). Comment @relay fix conflicts on a PR and the agent resolves its merge conflicts.

The flow: cloud merges the base branch into the working tree → the harness resolves the conflict markers (preserving both sides' intent, never weakening tests or flipping safety defaults) → verifies the merged tree against the repo's CI command → cloud finalizes and pushes the merge commit. A conflict that needs human judgment is left in place and reported under ## Unresolved conflicts so a risky half-merge is never pushed.

This is distinct from cloud's existing deterministic conflictAutofix (clean rebase only; aborts on real textual conflicts).

Why

Requested: ability to comment at the review agent and have it fix merge conflicts, opt-in.

Changes (this repo)

  • review/persona.ts — declares capabilities.conflictResolve.
  • review/agent.ts — issue_comment.created trigger; strict directive parser (matchesConflictDirective); commander authorization (isAuthorizedConflictCommander — never a bot; gated on PR author / APPROVERS / REVIEW_AUTHORS); readPr extended to read a PR from an issue_comment payload; resolveConflicts; conflictResolveHarnessPrompt.
  • review/README.md — documents the feature.
  • tests/review-agent.test.mjs — coverage for the matcher, commander auth, issue_comment readPr, and prompt invariants.

Dormant until cloud ships

This is inert until the cloud-side merge-in-tree + finalize-push flow lands. With no base-merge, the harness finds no markers and changes nothing.

Tracked in AgentWorkforce/cloud#2149.

Testing

npm test — typecheck clean, all 91 tests pass.

🤖 Generated with Claude Code


Summary by cubic

Add opt-in, comment-driven merge-conflict resolution to the review agent. Comment @relay fix conflicts on a PR to resolve merge markers, verify with CI, and have cloud finalize the merge; conflicts needing judgment are left for humans.

  • New Features - New features added
    • Triggered by issue_comment.created only on a strict @relay fix/resolve conflicts directive; casual mentions are ignored.
    • Authorization: only the PR author or users in APPROVERS/REVIEW_AUTHORS; never bots.
    • Hardened PR parsing for issue_comment: only treat comments on PRs (issue.pull_request present), prefer the PR opener for author gating, ignore plain issues.
    • Runs a conflict-resolution harness that preserves both sides’ intent, removes markers, verifies the merged tree CI-deep, and comments results; unresolved files are listed under “Unresolved conflicts”.
    • Declares conflictResolve in the persona; updates review/README.md; adds tests for directive matching, commander auth, PR parsing, and prompt invariants.
    • Inert until the cloud merge-in-tree + finalize-push flow ships; without it, no changes are made.