Skip to content

feat: implement issue #453 — Compliance: ruleset-drift-pr-quality-dismiss_stale_reviews_on_push - #455

Open
don-petry wants to merge 2 commits into
mainfrom
dev-lead/issue-453-20260821-1308
Open

feat: implement issue #453 — Compliance: ruleset-drift-pr-quality-dismiss_stale_reviews_on_push#455
don-petry wants to merge 2 commits into
mainfrom
dev-lead/issue-453-20260821-1308

Conversation

@don-petry

@don-petry don-petry commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

User description

Closes #453

Implemented by dev-lead agent. Please review.


CodeAnt-AI Description

Require fresh approvals after code changes and preserve repository rules during reconciliation

What Changed

  • New commits pushed to a pull request invalidate existing approvals, ensuring merged code has been reviewed in its final form
  • Repository settings now reconcile stale-review dismissal together with squash-only merges and last-push approval requirements
  • Existing ruleset metadata and unrelated rules remain unchanged during updates
  • Added coverage for drifted settings, missing values, and preserved repository configuration

Impact

✅ Fresh approvals after every code update
✅ Fewer merges of unreviewed changes
✅ Preserved repository rules during settings updates

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Documentation

    • Clarified that new pushes invalidate existing pull request approvals when stale review dismissal is enabled.
  • Improvements

    • Improved repository ruleset updates to preserve existing metadata and unrelated rules.
    • Added consistent defaults for review dismissal and bypass settings.
  • Tests

    • Expanded validation to cover pull request settings, metadata preservation, and default behavior.

@don-petry
don-petry requested a review from a team as a code owner August 21, 2026 13:12
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@codeant-ai

codeant-ai Bot commented Aug 21, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 86ecd38 Aug 21, 2026 · 13:12 13:14

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

@codeant-ai

codeant-ai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 54 minutes

Limit details: You’ve used the included review currently available.

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?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a963b0d-1552-4730-94fd-4c275caec85c

📥 Commits

Reviewing files that changed from the base of the PR and between 86ecd38 and 97fef1b.

📒 Files selected for processing (2)
  • scripts/apply-repo-settings.sh
  • scripts/apply-repo-settings.test.sh

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f77600e-10c4-4d3f-b0ff-47f2d6869460

📥 Commits

Reviewing files that changed from the base of the PR and between eb98ae6 and 86ecd38.

📒 Files selected for processing (3)
  • .github/settings.yml
  • scripts/apply-repo-settings.sh
  • scripts/apply-repo-settings.test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR documents dismiss_stale_reviews_on_push: true, adds a pure helper for complete ruleset payload reconciliation, updates the application path to use it, and adds tests for reconciliation and default handling.

Changes

Ruleset reconciliation

Layer / File(s) Summary
Ruleset payload reconciliation
.github/settings.yml, scripts/apply-repo-settings.sh
The documented standard requires stale-review dismissal. The script preserves ruleset metadata and non-pull-request rules while enforcing the required pull-request settings.
Reconciliation test coverage
scripts/apply-repo-settings.test.sh
Tests cover setting reconciliation, metadata and rule preservation, bypass_actors defaults, and missing dismissal configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 86ecd

This change requires fresh approvals after updates while preserving existing repository settings; no actionable merge-blocking risk remains at the current head.

Suggested reviewers: donpetry-bot

🚥 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 identifies the implementation of issue #453 and the specific ruleset compliance change.
Linked Issues check ✅ Passed The changes address issue #453 by reconciling dismissal settings, preserving ruleset data, and documenting the required configuration.
Out of Scope Changes check ✅ Passed All changes support issue #453 through ruleset reconciliation, documentation, and focused tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)
✨ 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 dev-lead/issue-453-20260821-1308

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.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Aug 21, 2026

@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 refactors the repository settings reconciliation script by extracting the payload generation logic into a standalone, testable function pr_quality_reconcile_payload and adding corresponding unit tests. The review feedback highlights two main improvements: first, avoiding hardcoded values in the new function by utilizing the script's existing constants to prevent potential infinite reconciliation loops; second, defensively wrapping command substitutions in the test script within conditional blocks to ensure robust error handling under strict shell execution modes.

Comment on lines +204 to +222
pr_quality_reconcile_payload() {
local json="${1:-}"
printf '%s' "$json" | jq \
--arg method "$PR_QUALITY_MERGE_METHOD" '
{
name: .name,
target: .target,
enforcement: .enforcement,
bypass_actors: (.bypass_actors // []),
conditions: .conditions,
rules: [
(.rules // [])[]
| if .type == "pull_request"
then .parameters.allowed_merge_methods = [$method]
| .parameters = ((.parameters // {}) + {require_last_push_approval: true, dismiss_stale_reviews_on_push: true})
else . end
]
}'
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The pr_quality_reconcile_payload function currently hardcodes require_last_push_approval: true and dismiss_stale_reviews_on_push: true inside the jq filter. This bypasses the PR_QUALITY_REQUIRE_LAST_PUSH_APPROVAL and PR_QUALITY_DISMISS_STALE_REVIEWS constants defined at the top of the script. If those constants are ever modified, the drift detection will trigger an update, but the generated payload will still apply the hardcoded true values, causing an infinite reconciliation loop.

Additionally, we should add a defensive check to ensure the function returns an error if the input JSON is empty, and use defensive defaults in jq to handle potentially null or missing fields.

pr_quality_reconcile_payload() {
  local json="${1:-}"
  if [[ -z "$json" ]]; then
    return 1
  fi
  printf '%s' "$json" | jq \
    --arg method "$PR_QUALITY_MERGE_METHOD" \
    --argjson rlpa "$PR_QUALITY_REQUIRE_LAST_PUSH_APPROVAL" \
    --argjson ds "$PR_QUALITY_DISMISS_STALE_REVIEWS" '
    {
      name: .name,
      target: .target,
      enforcement: .enforcement,
      bypass_actors: (.bypass_actors // []),
      conditions: .conditions,
      rules: [
        (.rules // [])[]
        | if .type == "pull_request"
          then .parameters.allowed_merge_methods = [$method]
            | .parameters = ((.parameters // {}) + {require_last_push_approval: $rlpa, dismiss_stale_reviews_on_push: $ds})
          else . end
      ]
    }'
}
References
  1. When using jq to modify or iterate over JSON fields that might be null or missing, use defensive defaults (e.g., // [] or // {}) to prevent jq from throwing errors like 'Cannot use null as object'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in scripts/apply-repo-settings.sh: replaced the two hardcoded true literals in pr_quality_reconcile_payload's jq filter with --argjson rlpa "$PR_QUALITY_REQUIRE_LAST_PUSH_APPROVAL" and --argjson ds "$PR_QUALITY_DISMISS_STALE_REVIEWS", so the payload always reflects the constants and cannot drift from them. Also added an empty-input guard ([[ -z "$json" ]] && return 1) and a corresponding test in the test script.

Comment thread scripts/apply-repo-settings.test.sh Outdated
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) August 21, 2026 13:17
@don-petry
don-petry disabled auto-merge August 21, 2026 13:20
@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry enabled auto-merge (squash) August 21, 2026 13:22
@don-petry
don-petry disabled auto-merge August 21, 2026 13:23
@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-08-21T14:24:36Z.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
**Files changed:** None
### Findings
The SonarCloud bot comment reports:
- ✅ **Quality Gate: PASSED**
- ✅ **0 New issues** 
- ✅ **0 Accepted issues**
- ✅ **0 Security Hotspots**
- ✅ **0.0% Duplication on New Code**
All CI checks show `conclusion: "success"` (SonarCloud Code Analysis passed). No reviews have state `CHANGES_REQUESTED`. 
**Conclusion:** No actionable issues. The quality gate passed with zero new issues and zero security hotspots. The PR is ready to merge from a code quality perspective.

@don-petry
don-petry enabled auto-merge (squash) August 21, 2026 13:24

@donpetry-bot donpetry-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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 97fef1b979bb4f6a12cd8edb1bfce296cdeac185
Cascade: triage → deep (triage: haiku 4.5 → deep: opus 4.8 + duck: o4-mini → audit: fable 5)

Summary

Clean refactor of scripts/apply-repo-settings.sh extracting the pr-quality ruleset PUT-payload builder into a pure, unit-tested pr_quality_reconcile_payload function, plus adding dismiss_stale_reviews_on_push to the reconciled settings (a branch-protection hardening). The triage-escalating Gemini high-priority flag ('hardcodes require_last_push_approval/dismiss_stale_reviews_on_push, risking an infinite reconciliation loop') is a resolved false positive: at the current head 97fef1b the payload is parameterized via --argjson from the same PR_QUALITY_* constants the drift detector reads, so there is no value divergence and no loop; Gemini reviewed an earlier state. Downstream impact: (none).

Findings

  • INFO: Gemini's high-priority 'infinite reconciliation loop' concern is not present at head 97fef1b. pr_quality_reconcile_payload (apply-repo-settings.sh:205-212) applies require_last_push_approval and dismiss_stale_reviews_on_push via --argjson rlpa/$ds bound to PR_QUALITY_REQUIRE_LAST_PUSH_APPROVAL and PR_QUALITY_DISMISS_STALE_REVIEWS ('true'), the exact constants the drift-status functions compare against (lines 283-293). Detector and writer share one source of truth, so no drift/apply divergence.
  • INFO: 10 new unit tests cover drift on every reconciled parameter, preservation of name/target/enforcement/conditions/bypass_actors and non-pull_request rules, absent-bypass_actors default, and non-zero exit on empty input. shellcheck clean; suite passes in a clean env and the CI 'review' check is green. (A local resolve_repo test 'failure' was env contamination from the reviewer runner's GITHUB_REPOSITORY, unrelated to this PR.)
  • INFO: Change is security-adjacent (reconciles pr-quality branch-protection ruleset) but strengthens posture: dismiss_stale_reviews_on_push=true drops approvals on new pushes. jq is fed GitHub-API ruleset JSON via stdin with typed --argjson bindings; no shell/jq injection, no secrets. run_secret_scanning MCP tool not available in this environment; gitleaks CI passed and diff contains no secret material.

Reviewed by the PR-review cascade (triage: haiku 4.5 → deep: opus 4.8 + duck: o4-mini → audit: fable 5). Reply if you need a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compliance: ruleset-drift-pr-quality-dismiss_stale_reviews_on_push

2 participants