feat(workflow): auto-flag PRs exceeding commit threshold#484
Conversation
Implement commit count monitoring in pr-validation workflow to prevent scope creep and encourage smaller, shippable PRs. Thresholds (per issue #362): - 10 commits: Add 'needs-split' label, show notice - 15 commits: Add 'needs-split' label, show warning - 20 commits: Block PR (require 'commit-limit-bypass' label to override) Features: - Automatic 'needs-split' label application - Label removal when commit count drops below threshold - Human override via 'commit-limit-bypass' label - Clear messaging at each threshold level Labels created: - 'needs-split' (yellow): PR should be split into smaller PRs - 'commit-limit-bypass' (red): Override for 20+ commit limit Evidence from issue #362: - PR #255: 48 commits (expected 3-5) - PR #235: 23 commits (expected 5-10) Fixes #362 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Review findings: - APPROVED_WITH_COMMENTS (95% confidence) - Thresholds (10/15/20) are evidence-based and appropriate - Label management logic is correct and idempotent - Bypass mechanism is secure (requires human override) Important issues identified: - Missing LASTEXITCODE checks after gh commands (5 locations) - API pagination limit at 100 commits needs documentation Recommendations: - High priority: Add LASTEXITCODE checks before merge - Medium priority: Improve observability (add commit count to report) - Low priority: Extract to module for testing (follow-up) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses critic feedback by adding error handling after: - gh pr view commands for label fetching - gh pr edit commands for label modifications Safety comments added explaining why 2>$null suppression is safe (PR exists when workflow runs, so errors indicate actual failures).
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
PR Validation ReportNote ✅ Status: PASS Description Validation
QA Validation
⚡ Warnings
Powered by PR Validation - View Workflow |
Session Protocol Compliance ReportCaution ❌ Overall Verdict: CRITICAL_FAIL 6 MUST requirement(s) not met. These must be addressed before merge. What is Session Protocol?Session logs document agent work sessions and must comply with RFC 2119 requirements:
See .agents/SESSION-PROTOCOL.md for full specification. Compliance Summary
Detailed Results2025-12-29-session-01-issue-362-reviewBased on the context, this is reviewing a partial session log for Issue #362 Review. Let me check if there's a complete session log or if this is the full content: Now I can provide the compliance assessment: Run Details
Powered by AI Session Protocol Validator - View Workflow |
AI Quality Gate ReviewWarning WalkthroughThis PR was reviewed by six AI agents in parallel, analyzing different aspects of the changes:
Review Summary
💡 Quick Access: Click on individual agent jobs (e.g., "🔒 security Review", "🧪 qa Review") in the workflow run to see detailed findings and step summaries. Analyst Review DetailsLet me check the local repository for the workflow file changes: Now let me check the existing patterns in the repository for CI workflows and review any related scripts: Based on my analysis of the PR workflow file and related patterns, I can now provide the analyst review. Analysis: PR #364 - Auto-flag PRs Exceeding Commit ThresholdCode Quality Score
Overall: 4.25/5 Impact Assessment
Findings
Positive Observations
Recommendations
VerdictRoadmap Review DetailsStrategic Alignment Assessment
Feature Completeness
Impact Analysis
Concerns
Recommendations
VerdictQA Review DetailsBased on my analysis: PR Validation ReportTest Coverage Assessment
Quality Concerns
Regression Risk Assessment
Workflow Logic VerificationThe implementation follows secure patterns:
Why No Unit Tests RequiredPer PR Type Detection rules for WORKFLOW category:
DevOps Review DetailsI now have the full workflow file. Let me check the base branch version to see what changed. I have the full workflow file. I can now perform the DevOps review. DevOps Review: PR #364 - Auto-flag PRs exceeding commit thresholdPR Scope Detection
Pipeline Impact Assessment
CI/CD Quality Checks
Findings
Detailed AnalysisCommit Count Check (Lines 263-303):
Label Management (Lines 305-338):
Blocking Enforcement (Lines 340-367):
Security Review:
Template Assessment
Automation Opportunities
Recommendations
VerdictArchitect Review DetailsI'll analyze this PR for architectural concerns. Let me first examine the existing codebase structure and the PR changes. Let me also check ADR-026 for concurrency/safety patterns and review the scripts directory for related modules. Now I have sufficient context to provide the architectural review. Architecture Review: PR #362 - Auto-Flag PRs Exceeding Commit ThresholdDesign Quality Assessment
Overall Design Score: 3.6/5 Architectural Concerns
ADR-006 Compliance AnalysisADR-006 specifies:
The commit-check implementation adds 103 lines to
Per ADR-006, this logic should move to a testable PowerShell module. Breaking Change Assessment
Technical Debt Analysis
ADR Assessment
Positive Observations
Recommendations
VerdictSecurity Review DetailsI'll analyze the PR for security vulnerabilities. Let me first examine the workflow file changes and understand the implementation. Security Analysis: PR Validation WorkflowPR Type ClassificationCategory: WORKFLOW ( Findings
Analysis Summary1. Command Injection (CWE-78) - [PASS]
2. Secret Handling - [PASS]
3. Permissions - [PASS]
4. Action Pinning - [PASS]
5. LASTEXITCODE Checking - [PASS]
6. Error Disclosure - [PASS]
7. Label Operations - [PASS]
RecommendationsNone required. VerdictRun Details
Powered by AI Quality Gate workflow |
|
Caution Review failedFailed to post review comments Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdded a plan critique document and augmented the PR validation workflow to count commits, set a COMMIT_STATUS (OK/WARNING/ALERT/BLOCKED) at thresholds 10/15/20, apply/remove Changes
Sequence Diagram(s)sequenceDiagram
actor PR as PR Event
participant GHA as GitHub Actions
participant PS as PowerShell step
participant API as GitHub API
participant Check as Enforce Blocking Issues
PR->>GHA: opened/updated
GHA->>PS: run commit-count check
PS->>API: list PR commits (<=100)
API-->>PS: commit list -> commit_count
PS->>PS: set COMMIT_STATUS (OK/WARNING/ALERT/BLOCKED)
alt status in (WARNING, ALERT, BLOCKED)
PS->>API: apply `needs-split` label
API-->>PS: label applied
else status = OK
PS->>API: remove `needs-split` label (if present)
API-->>PS: label removed
end
PS-->>GHA: export COMMIT_STATUS & COMMIT_COUNT
rect rgba(200,220,255,0.6)
Note over Check: Blocking enforcement reads COMMIT_STATUS
GHA->>Check: evaluate COMMIT_STATUS
alt COMMIT_STATUS = BLOCKED
Check->>API: check for `commit-limit-bypass` label
alt bypass exists
API-->>Check: bypass found → allow merge
else no bypass
Check-->>GHA: block merge
end
else COMMIT_STATUS != BLOCKED
Check-->>GHA: allow merge
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Review Triage RequiredNote Priority: NORMAL - Human approval required before bot responds Review Summary
Next Steps
Powered by PR Maintenance workflow - Add triage:approved label |
There was a problem hiding this comment.
Pull request overview
This PR implements automatic PR size monitoring based on commit count to prevent scope explosion. It introduces a three-tier progressive threshold system (warning at 10 commits, alert at 15, blocking at 20) with automatic label management and a human-override mechanism.
Key Changes
- Added commit count monitoring to the PR validation workflow with evidence-based thresholds (10/15/20 commits)
- Implemented progressive enforcement with automatic
needs-splitlabel application for threshold violations - Added
commit-limit-bypasslabel mechanism for human override of the 20-commit blocking threshold
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/pr-validation.yml |
Implements commit count checking, three-tier threshold enforcement, automatic label management, and blocking gate for oversized PRs |
.serena/memories/issue-362-critique-findings.md |
Documents critique findings and recommendations from the agent review process |
.agents/sessions/2025-12-29-session-01-issue-362-review.md |
Records the review session context, findings, and verdict for issue #362 implementation |
.agents/critique/362-commit-threshold-monitoring-critique.md |
Provides detailed critique analysis including strengths, issues, and approval conditions for the implementation |
Addresses Copilot review comments: - Add PR_NUMBER env var to Enforce Blocking Issues step (prevents gh pr view failure) - Add LASTEXITCODE check after gh api call at line 269 (prevents silent API failures) - Add null check for commits response (prevents silent data errors) - Document 100-commit pagination limit assumption (edge case) - Update critique doc checkbox to reflect LASTEXITCODE fixes implemented Comment-IDs: 2651058502, 2651058538, 2651058560, 2651058583 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolved 2 review threads on PR #481: - gemini-code-assist[bot]: Import-Module robustness (PRRT_kwDOQoWRls5nfbwS) - Copilot: Module import location (PRRT_kwDOQoWRls5nh8zH) All fixes were already implemented in commit 7d213db. This session verified the fixes and resolved the threads via GraphQL API. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
@rjmurillo-bot Useful insights, but not likely to be reused given the current format. Why would you seek issue 362 critique findings in the future? Consider alternatives: breaking lessons out into different, more descriptive items, and/or folding into existing items
rjmurillo
left a comment
There was a problem hiding this comment.
gh exit code check and movving issue 362 memories into something more discoverable in the future
Add missing Protocol Compliance section with Session Start/End checklists to comply with SESSION-PROTOCOL.md MUST requirements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Session file was missing required Protocol Compliance section with Session Start/End checklists per SESSION-PROTOCOL.md. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request
Summary
Implements automatic PR size monitoring based on commit count per issue #362. PRs exceeding thresholds trigger progressive warnings and blocking enforcement.
Specification References
Changes
needs-splitlabel application for threshold violationscommit-limit-bypasslabel override mechanismghCLI commandsType of Change
Testing
Agent Review
Security Review
Other Agent Reviews
Checklist
Related Issues
Closes #362