feat(pr): draft PRs by default, auto-undraft in pr-patrol#1794
Conversation
Previous run (2026-03-05T07:59:11Z) failed with error_max_turns after 31 turns — Claude ran out with max-turns=30 on a weekly sweep. Also increase timeout-minutes from 30 to 60 to give sufficient wall-clock headroom for weekly/monthly cadences. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* origin/main: feat(pr-patrol): add auto-merge for PRs labeled ready-to-merge (#1788) feat(ci): test Drizzle migrations against throwaway Postgres in CI (#1771) feat(ci): integrate Reviewdog for inline PR annotations (#1787) fix(ci): add CodeRabbit security gate to block merges on critical findings (#1780) feat(statements): CRUD CLI commands + markdown ontology draft workflow (#1784) feat(pr-patrol): add main branch CI monitoring and PR overlap detection (#1786) feat(ci): add PR size warning (non-test additions) and Drizzle schema drift detection (#1781) fix(ci): increase scheduled-maintenance max-turns and timeout (#1783) fix: derive test mock column types from Drizzle schema to prevent drift (#1782)
- `crux pr create` now creates draft PRs by default (use --no-draft to override) - New `crux pr ready` command validates eligibility (CI green, no conflicts, no unresolved threads, no unchecked items) before converting draft to ready - PR Patrol auto-undrafts draft PRs labeled `ready-to-merge` when all other eligibility checks pass, then merges in the same cycle - PR Patrol skips draft PRs from the fix queue (no point fixing drafts) - Added `isDraft` to GraphQL PR query and `GqlPrNode` interface - `is-draft` added as a new `MergeBlockReason` - 4 new tests covering draft eligibility checks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…iled undraft tracking - Filter out 'is-draft' from block reasons in `crux pr ready` (it's the whole point of the command, not a blocker) - Replace REST-then-GraphQL fallback with direct GraphQL for undrafting (REST API doesn't support undrafting, so the REST call always fails) - Track which PRs were successfully undrafted before attempting merge (prevents merge attempts on PRs where undraft API call failed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🛑 Protected Paths ModifiedThis PR modifies 1 protected file(s) that control agent behavior, CI pipelines, or validation logic. These changes require human review before merging. CLI commands (crux/commands/)
Action required: Add the
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA new ready command for PRs marks draft pull requests as ready for review with eligibility checks (CI status, conflicts, unresolved threads, unchecked checkboxes), while the PR patrol system gains draft-aware logic to handle drafts through a new undraft phase that auto-undrafts eligible PRs and re-evaluates for merging. Changes
Sequence DiagramssequenceDiagram
participant User
participant CLI as ready command
participant GQL as GraphQL API
participant PR as GitHub PR
User->>CLI: Execute ready command
CLI->>GQL: Fetch PR details (isDraft, CI status, etc.)
GQL-->>CLI: Return PR data
alt PR is eligible
CLI->>CLI: Validate: isDraft=true, CI passing, no conflicts
CLI->>GQL: Execute undraft mutation
GQL->>PR: Mark PR as ready
GQL-->>CLI: Success response
CLI-->>User: PR ready for review
else PR not eligible
CLI->>CLI: Check eligibility (CI, conflicts, threads, etc.)
CLI-->>User: Detailed block reasons
end
sequenceDiagram
participant Cycle as PR Patrol Cycle
participant GQL as GraphQL API
participant Store as PR Cache
participant MergeSys as Merge System
Cycle->>GQL: Fetch all open PRs with isDraft field
GQL-->>Cycle: PR list with draft status
Cycle->>Cycle: Detect issues & block reasons (including is-draft)
alt Undraft phase
Cycle->>Cycle: Filter: eligible except for is-draft
Cycle->>GQL: undraftPr for eligible drafts
GQL-->>Cycle: Undraft results
Cycle->>Store: Update PR cache (isDraft=false)
Cycle->>Cycle: Re-compute merge candidates
end
Cycle->>MergeSys: Proceed with merge phase
MergeSys-->>Cycle: Merge outcomes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crux/commands/pr.ts`:
- Around line 650-656: The current filter in the crux pr ready path removes
'ci-pending' from eligibility.blockReasons, allowing PRs to be marked ready
while CI is still running; restore CI as a blocker by removing 'ci-pending' from
the exclusion list in the blockReasons filtering logic (leave only 'is-draft'
excluded) so that checkMergeEligibility(prNode).blockReasons still contains
'ci-pending' unless checks are green; update the code around the force check and
the blockReasons assignment that references eligibility.blockReasons to match
the PR Patrol auto-undraft behavior.
- Around line 622-635: The code currently treats a malformed --pr as falsy and
silently falls back to branch autodetection; change the logic around
options.pr/parseInt so that when options.pr is provided but parseInt yields NaN
you return a user-facing error instead of falling back. Specifically, validate
the parsed value (prNum) using Number.isInteger or !Number.isNaN after parseInt
on options.pr and, if invalid, return an error output/exitCode rather than
running currentBranch()/githubApi; keep the existing branch-autodetect behavior
only when options.pr is undefined or empty.
In `@crux/pr-patrol/index.ts`:
- Around line 1388-1406: The dry-run path only logs "Would undraft" but doesn't
simulate removal of the 'is-draft' block, so findMergeCandidates(...) still sees
the PR as blocked; update the dry-run branch in the loop over draftCandidates to
mirror the real undraft outcome by either adding candidate.number to
undraftedNumbers when config.dryRun is true or by creating the same updated
object used later (removing 'is-draft') so that the subsequent
findMergeCandidates/mergeCandidates logic treats the PR as eligible; touch the
loop that calls undraftPr and the undraftedNumbers set (and keep the existing
undraftPr call in non-dry runs) so dry-run merges are reported exactly like a
real run.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cd65095a-ef91-4c4a-9eea-e9b6ab0383f9
📒 Files selected for processing (3)
crux/commands/pr.tscrux/pr-patrol/index.test.tscrux/pr-patrol/index.ts
- Validate --pr option: return error on malformed values instead of silently falling back to branch autodetection - Keep ci-pending as a blocker for `crux pr ready` to match PR Patrol auto-undraft behavior (only is-draft is filtered out) - Simulate undraft in dry-run mode so merge phase also reports what would happen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ CodeRabbit Security GateNo unresolved Critical or Major CodeRabbit findings. Check passes.
|
Summary
crux pr createnow creates draft PRs by default (use--no-draftto override)crux pr readycommand validates eligibility before converting draft → readyready-to-mergewhen all eligibility checks passisDraftto GraphQL PR queries andGqlPrNodeinterfaceWhy
Previously, agent PRs were immediately mergeable on creation, with no clear signal about whether they'd passed all quality gates. Draft PRs provide a visual "not ready yet" signal in the GitHub PR list, preventing premature merges while the PR awaits CI, review, and comment resolution.
Key changes
crux/commands/pr.ts: Default--draft, newreadysubcommand with eligibility validationcrux/pr-patrol/index.ts:isDraftin GraphQL,is-draftmerge block reason,undraftPr()function, auto-undraft phase in patrol cycle, draft PRs filtered from fix queuecrux/pr-patrol/index.test.ts: 4 new tests for draft eligibilityWorkflow
ready-to-mergewhen satisfiedcrux pr readylets agents/humans manually undraft with eligibility validationTest plan
/review-prcompleted — found and fixed 3 issues:crux pr readyself-blocked onis-draft(HIGH)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
readycommand to manually mark draft pull requests as ready for review with comprehensive eligibility checksTests