Skip to content

fix(guard-size): scope pull-request CI to the PR diff (sc-1539) - #378

Merged
norvalbv merged 2 commits into
mainfrom
codex/sc-1539-size-gate-pr-diff
Aug 10, 2026
Merged

fix(guard-size): scope pull-request CI to the PR diff (sc-1539)#378
norvalbv merged 2 commits into
mainfrom
codex/sc-1539-size-gate-pr-diff

Conversation

@norvalbv

@norvalbv norvalbv commented Aug 10, 2026

Copy link
Copy Markdown
Owner

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 fix(review): resolve checklist assets across providers (sc-1397) #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

Summary by CodeRabbit

  • New Features

    • Pull-request checks now evaluate size and disable limits only for files changed in the request.
    • Checks report a clear error when the pull request’s base revision is unavailable.
    • Existing baselines are protected from updates during pull-request validation.
  • Bug Fixes

    • Prevented unrelated inherited debt from blocking pull-request checks.
    • Preserved migration checks for legacy disable baselines.
  • Tests

    • Added coverage for pull-request scoping, baseline handling, stale revisions, and failure scenarios.

## 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
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@norvalbv, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df278847-3429-4f42-9401-cd46b54b1e2e

📥 Commits

Reviewing files that changed from the base of the PR and between 004f619 and 64ecfff.

📒 Files selected for processing (2)
  • gate-engine/ratchets/__tests__/size-disable.test.mts
  • gate-engine/ratchets/git-index.mts
📝 Walkthrough

Walkthrough

The 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.

Changes

Pull-request ratchet scoping

Layer / File(s) Summary
Git scope resolution
gate-engine/ratchets/git-index.mts, gate-engine/ratchets/size-preflight.mts
Added helpers for repository prefixes, validated base comparisons, normalized changed paths, and pull-request scope resolution. Reused the prefix helper in preflight.
Scoped gate execution
.github/workflows/gate.yml, gate-engine/ratchets/size-disable.mts
Passed the pull-request base to the gate. The gate prioritizes pull-request scope, then staged files, then the whole tree. Pull-request runs do not tighten or mutate baselines.
Scope and baseline validation
gate-engine/ratchets/__tests__/size-disable.test.mts
Added coverage for inherited debt filtering, changed-file ceiling failures, unavailable bases, freeze behavior, and legacy aggregate baselines.

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
Loading

Possibly related PRs

  • norvalbv/devkit#25: Changes per-file raw-line ceiling ratcheting in the same gate area.
  • norvalbv/devkit#73: Provides related per-file disable-baseline logic used by this gate.
  • norvalbv/devkit#98: Uses an explicitly supplied base commit to scope gate behavior through environment variables.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: scoping pull-request size checks to the pull-request diff.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/sc-1539-size-gate-pr-diff

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8c64c1 and 004f619.

📒 Files selected for processing (5)
  • .github/workflows/gate.yml
  • gate-engine/ratchets/__tests__/size-disable.test.mts
  • gate-engine/ratchets/git-index.mts
  • gate-engine/ratchets/size-disable.mts
  • gate-engine/ratchets/size-preflight.mts

Comment thread gate-engine/ratchets/git-index.mts Outdated
@norvalbv
norvalbv merged commit 7ed8ed7 into main Aug 10, 2026
2 checks passed
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