fix(guard-size): scope pull-request CI to the PR diff (sc-1539) - #378
Conversation
## Summary - make pull-request size checks evaluate only files changed from the exact GitHub base commit - keep push-main, manual, and legacy-baseline audits whole-tree - resolve pull-request scope only for the gate command - share Git prefix resolution across PR diff selection and size preflight - add regressions for inherited line debt, changed growth, inherited/legacy disable debt, stale bases, and freeze isolation ## Root cause A pull-request checkout has a clean index, so guard-size fell into its whole-tree audit path. Pre-existing oversized files inherited from main were therefore blamed on unrelated PRs. ## Impact Required PR checks now fail only when the PR adds or worsens per-file size debt. Main-branch pushes still report inherited repository drift, legacy disable baselines still require migration, and non-gate commands are isolated from PR-only environment state. ## Validation - focused ratchet suites: 58 passed - Biome lint: passed - structure lint: passed - TypeScript typecheck: passed - build: passed - exact PR #376 base/head reproduction: whole-tree audit failed as before; PR-base scope passed - GitNexus staged audit: LOW risk, zero affected flows - duplication matcher and commit-guard: passed - full suite reached a pre-existing childless Vitest-parent hang; recurrence report 4c791856-dea7-4883-b460-caba479c90b3 Story: sc-1539 Autonomous report: 6f6fb84b-8fc5-484f-9d7e-50038de4b6e1
|
Warning Review limit reached
Next review available in: 52 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ratchet workflow now supplies the pull-request base SHA. Git helpers derive changed-file scope, and size-disable gates use that scope without mutating baselines. Tests cover inherited debt, ceiling failures, unavailable bases, freeze behavior, and legacy baseline migration. ChangesPull-request ratchet scoping
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PullRequestWorkflow
participant SizeDisableGate
participant GitScope
participant RatchetBaseline
PullRequestWorkflow->>SizeDisableGate: run with GUARD_RATCHET_BASE
SizeDisableGate->>GitScope: resolve changed files from base to HEAD
GitScope-->>SizeDisableGate: return pull-request file scope
SizeDisableGate->>RatchetBaseline: evaluate scoped files
SizeDisableGate-->>PullRequestWorkflow: pass or fail without baseline mutation
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@gate-engine/ratchets/git-index.mts`:
- Around line 85-90: Update gitPrefix to use trimEnd() instead of trim() when
processing the output of execFileSync, preserving valid leading whitespace while
removing trailing command line endings so changedSetSince matches paths
correctly.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: deacb1a3-b40b-4158-b5d3-3fd0b522570a
📒 Files selected for processing (5)
.github/workflows/gate.ymlgate-engine/ratchets/__tests__/size-disable.test.mtsgate-engine/ratchets/git-index.mtsgate-engine/ratchets/size-disable.mtsgate-engine/ratchets/size-preflight.mts
Summary
Root cause
A pull-request checkout has a clean index, so guard-size fell into its whole-tree audit path. Pre-existing oversized files inherited from main were therefore blamed on unrelated PRs.
Impact
Required PR checks now fail only when the PR adds or worsens per-file size debt. Main-branch pushes still report inherited repository drift, legacy disable baselines still require migration, and non-gate commands are isolated from PR-only environment state.
Validation
Story: sc-1539
Autonomous report: 6f6fb84b-8fc5-484f-9d7e-50038de4b6e1
Summary by CodeRabbit
New Features
Bug Fixes
Tests