Part of #1367 (Phase 2 — AI Review Parity).
Goal
CodeRabbit's merge-workflow integration (pre-merge checks, post-merge actions):
Pre-merge checks
Configurable checks reported as a commit status / check run (buddy-bot/gate) so branch protection can require it. Each check has a mode: off | warning | error (error fails the check run → blocks merge under branch protection):
- Title/description validation — conventional-commit title format, description completeness (template sections filled)
- Docstring coverage — changed public APIs have doc comments; threshold percent
- Linked-issue assessment (AI) — does the diff actually address the linked issue's requirements? Post gaps found
- Custom checks (AI) — config-defined natural-language assertions evaluated against the diff (e.g. "DB migrations must be backwards compatible", "no new dependencies without a justification in the description")
- Dependency gate (our twist, non-AI) — fail when the PR introduces a dependency with: known vulnerabilities (existing OSV integration
src/services/security-advisories.ts), deprecation flag (existingdeprecated-dependencies-checker.ts), or a license outside an allowlist (new: fetchlicensefrom packuments — small addition tosrc/registry/registry-client.ts)
Post-merge actions
Config-defined actions on merge of matching PRs (on: { branches, labels, paths }):
- Built-ins: append to
CHANGELOG.mdsection, comment on linked issues, dashboard refresh (buddy.ts:createOrUpdateDashboard) - Custom AI prompts (agent read-only tier + specific write target) — CodeRabbit's "post-merge actions" (changelog updates, ticket filing)
- Notification hook events (emits through #1387 once it lands)
Design
src/gates/—checks.ts(registry + evaluation),status.ts(check-run creation/update viaPOST /repos/{o}/{r}/check-runs; requires GitHub App token or Actionschecks: write— document both),post-merge.ts- Triggers: pre-merge checks run on
pull_request: [opened, synchronize, edited]; post-merge onpull_request: [closed]withmerged == true— both via the unified workflow (src/setup.ts) - Non-AI checks must run without any API key; AI checks skip with
neutralconclusion + explanatory summary when no key - Config:
gates?: {
preMerge?: {
titleFormat?: 'off' | 'warning' | 'error'
description?: { mode: ..., requireSections?: string[] }
docstringCoverage?: { mode: ..., threshold?: number }
issueAssessment?: 'off' | 'warning' | 'error'
dependencyGate?: { mode: ..., licenseAllowlist?: string[], blockVulnerable?: boolean, blockDeprecated?: boolean }
custom?: { name: string, instructions: string, mode: ... }[]
}
postMerge?: { name: string, on?: {...}, action: 'changelog' | 'comment-issues' | 'dashboard-refresh' | { prompt: string } }[]
}Tasks
- Check-run plumbing in
src/git/github-provider.ts(create/update, annotations for failures) - Non-AI checks: title/description/docstring-coverage/dependency-gate (+ license fetch in registry client)
- AI checks: issue assessment + custom assertions via #1374 read-only mode with structured verdict output (#1373 json mode)
- Post-merge dispatcher + built-ins + custom prompts
- Config + validation +
docs/gates.md(incl. branch-protection setup guide) - Tests: mode matrix (off/warning/error), neutral-on-no-key, check-run payloads, post-merge filters
Acceptance criteria
- Branch protection can require
buddy-bot/gate; anerror-mode failure blocks merge and annotates why - Dependency gate fails a fixture PR adding a known-vulnerable package — with zero AI configured
- Post-merge changelog action appends a correct entry on merge