Skip to content

feat: add require-no-conflicts-before-stop workflow policy#176

Merged
NiveditJain merged 2 commits into
mainfrom
luv-176
Apr 24, 2026
Merged

feat: add require-no-conflicts-before-stop workflow policy#176
NiveditJain merged 2 commits into
mainfrom
luv-176

Conversation

@NiveditJain

Copy link
Copy Markdown
Member

Summary

  • Adds a new builtin Stop-event workflow policy require-no-conflicts-before-stop that denies the agent from stopping until the current branch merges cleanly with the base branch.
  • Runs two independent probes:
    • Localgit merge-tree --write-tree --name-only origin/<base> HEAD. Exit 1 denies with the specific conflicted file list.
    • GitHubgh pr view --json mergeable. Catches conflicts that a stale local origin/<base> would miss (e.g. someone landed a conflicting PR on main since the last fetch). CONFLICTING denies; UNKNOWN also denies and instructs the agent to wait ~10s and re-check before retrying Stop — preventing a false negative while GitHub recomputes mergeability.
  • Fails open on missing cwd, detached HEAD, on base branch, missing origin/<base>, no commits ahead, no gh CLI, or no PR — consistent with the sibling require-*-before-stop policies.
  • Opt-in (defaultEnabled: false); baseBranch param defaults to "main".

Test plan

  • Unit tests: 14 new cases covering both layers, fall-through paths, custom baseBranch, and fail-open scenarios — all 980 tests pass
  • bun run lint — clean (no new warnings)
  • bun --bun tsc --noEmit — clean
  • Local smoke test against a real conflict on a scratch repo
  • Docker clean-install test (oven/bun:latest with npm install -g /pkg.tgz)
  • bun run test:e2e

🤖 Generated with Claude Code

New Stop-event policy that denies the agent from stopping until the
current branch merges cleanly with the base branch.

Two-layer detection:
1. Local `git merge-tree --write-tree --name-only origin/<base> HEAD` —
   deny with the conflicted file list on exit 1.
2. GitHub `gh pr view --json mergeable` — deny on CONFLICTING (catches
   stale-origin cases). On UNKNOWN, deny and instruct the agent to wait
   ~10s and re-check before retrying Stop, preventing a false negative
   while GitHub recomputes mergeability.

Fail-open on missing cwd, detached HEAD, on base branch, missing
origin/<base>, no commits ahead, no gh CLI, or no PR for the branch —
matching the pattern of the sibling require-*-before-stop policies.

Opt-in (defaultEnabled: false), baseBranch param defaults to "main".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@NiveditJain has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 12 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 59 minutes and 12 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e96bd770-0162-4f3b-b772-7727d6acbbc1

📥 Commits

Reviewing files that changed from the base of the PR and between 97aee5c and dc16cd6.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • __tests__/hooks/builtin-policies.test.ts
  • docs/built-in-policies.mdx
  • src/hooks/builtin-policies.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch luv-176

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Replaces the #TBD placeholder with the actual PR number (#176).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@NiveditJain NiveditJain merged commit 9ba5280 into main Apr 24, 2026
9 checks passed
@NiveditJain NiveditJain deleted the luv-176 branch April 27, 2026 17:57
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