Skip to content

feat: implement issue #407 — Compliance: ruleset-drift-pr-quality-require_code_owner_review - #415

Closed
don-petry wants to merge 1 commit into
mainfrom
dev-lead/issue-407-20260717-1354
Closed

don-petry wants to merge 1 commit into
mainfrom
dev-lead/issue-407-20260717-1354

Conversation

@don-petry

Copy link
Copy Markdown
Contributor

Closes #407

Implemented by dev-lead agent. Please review.

Copilot AI review requested due to automatic review settings July 17, 2026 14:00
@don-petry
don-petry requested a review from a team as a code owner July 17, 2026 14:00
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 12739fe4-d9cf-4e00-95c4-7056f1e83f51

📥 Commits

Reviewing files that changed from the base of the PR and between 825bece and 5d85a54.

📒 Files selected for processing (2)
  • scripts/apply-rulesets.sh
  • tests/scripts/apply-rulesets.test.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-407-20260717-1354

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request enhances scripts/apply-rulesets.sh to allow offline previewing of codified payloads during dry runs by gracefully falling back when the GitHub API fetch fails. It also adds a comprehensive test suite in tests/scripts/apply-rulesets.test.sh to assert that standard PR quality ruleset parameters are correctly codified. The review feedback suggests improving error handling in the ruleset script to distinguish between a missing gh CLI and an invalid token scope, which prevents misleading error messages.

Comment thread scripts/apply-rulesets.sh
Comment on lines +180 to 191
if ! existing=$(gh api "repos/$ORG/$REPO/rulesets" 2>/dev/null); then
# In dry-run mode the fetch is best-effort: fall back to treating the repo as
# having no existing rulesets so the codified payloads can be previewed
# offline (without an admin token). Real runs must fail hard on a failed fetch.
if [[ "$DRY_RUN" = true ]]; then
skip "Could not fetch existing rulesets — previewing payloads as new (create)"
existing='[]'
else
err "Failed to fetch existing rulesets for $ORG/$REPO — check GH_TOKEN has administration:read scope"
exit 1
fi
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If the gh CLI is not installed or not available in the system's PATH, the command substitution gh api ... will fail with exit code 127. In non-dry-run mode, the script currently outputs a misleading error message suggesting that the GH_TOKEN lacks the administration:read scope, which can lead to confusing troubleshooting.

We can capture the exit status of the command substitution and provide a more accurate error message if gh is missing.

Suggested change
if ! existing=$(gh api "repos/$ORG/$REPO/rulesets" 2>/dev/null); then
# In dry-run mode the fetch is best-effort: fall back to treating the repo as
# having no existing rulesets so the codified payloads can be previewed
# offline (without an admin token). Real runs must fail hard on a failed fetch.
if [[ "$DRY_RUN" = true ]]; then
skip "Could not fetch existing rulesets — previewing payloads as new (create)"
existing='[]'
else
err "Failed to fetch existing rulesets for $ORG/$REPO — check GH_TOKEN has administration:read scope"
exit 1
fi
fi
if ! existing=$(gh api "repos/$ORG/$REPO/rulesets" 2>/dev/null); then
gh_err=$?
# In dry-run mode the fetch is best-effort: fall back to treating the repo as
# having no existing rulesets so the codified payloads can be previewed
# offline (without an admin token). Real runs must fail hard on a failed fetch.
if [[ "$DRY_RUN" = true ]]; then
skip "Could not fetch existing rulesets — previewing payloads as new (create)"
existing='[]'
else
if [[ $gh_err -eq 127 ]]; then
err "Failed to fetch existing rulesets: 'gh' CLI is not installed or not in PATH"
else
err "Failed to fetch existing rulesets for $ORG/$REPO — check GH_TOKEN has administration:read scope"
fi
exit 1
fi
fi

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the repository’s GitHub ruleset application tooling in response to compliance issue #407 by improving offline/dry-run behavior and adding a regression test to validate the codified pr-quality ruleset payload.

Changes:

  • Add a shell test that asserts scripts/apply-rulesets.sh --dry-run --force outputs the required pr-quality review parameters.
  • Adjust scripts/apply-rulesets.sh so --dry-run can proceed even if fetching existing rulesets fails (e.g., without an admin-capable token).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/scripts/apply-rulesets.test.sh Adds a manual regression test for the pr-quality payload emitted by scripts/apply-rulesets.sh.
scripts/apply-rulesets.sh Makes existing-ruleset fetch best-effort in --dry-run to enable offline payload previews.

Comment thread scripts/apply-rulesets.sh
Comment on lines 179 to +185
info "Fetching existing rulesets for $ORG/$REPO ..."
if ! existing=$(gh api "repos/$ORG/$REPO/rulesets"); then
err "Failed to fetch existing rulesets for $ORG/$REPO — check GH_TOKEN has administration:read scope"
exit 1
if ! existing=$(gh api "repos/$ORG/$REPO/rulesets" 2>/dev/null); then
# In dry-run mode the fetch is best-effort: fall back to treating the repo as
# having no existing rulesets so the codified payloads can be previewed
# offline (without an admin token). Real runs must fail hard on a failed fetch.
if [[ "$DRY_RUN" = true ]]; then
skip "Could not fetch existing rulesets — previewing payloads as new (create)"
Comment on lines +5 to +12
# The compliance standard requires the pr-quality ruleset to enforce
# require_code_owner_review=true (among other review requirements). This guards
# the codified payload against silent drift in the repo. Live GitHub-state
# convergence is a separate operation that requires an admin token.
#
# Runs the script in --dry-run --force mode so no real GitHub API calls are
# made and the repo-identity safety check is skipped. Asserts the dry-run
# output codifies each required pr-quality review parameter.
Comment on lines +45 to +48
if [[ ! -x "$SCRIPT" && ! -f "$SCRIPT" ]]; then
echo "not ok - script not found at ${SCRIPT}"
exit 1
fi
@don-petry

Copy link
Copy Markdown
Contributor Author

Closing as part of the 50-PR cap drain. The dev-lead fix-loop repairs #1340 (self-cancellation), #1290 (comment-inertness) and #806 (thread-resolution) have all landed, so this deadlocked PR can be regenerated cleanly through the repaired loop. The driving issue stays open and its dev-lead label is re-fired — no work is lost.

@don-petry don-petry closed this Jul 21, 2026
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.

Compliance: ruleset-drift-pr-quality-require_code_owner_review

3 participants