Skip to content

feat: implement issue #324 — Compliance: ruleset-drift-pr-quality-dismiss_stale_reviews_on_push - #353

Merged
don-petry merged 6 commits into
mainfrom
dev-lead/issue-324-20260721-1926
Aug 2, 2026
Merged

feat: implement issue #324 — Compliance: ruleset-drift-pr-quality-dismiss_stale_reviews_on_push#353
don-petry merged 6 commits into
mainfrom
dev-lead/issue-324-20260721-1926

Conversation

@don-petry

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

Copy link
Copy Markdown
Contributor

User description

Closes #324

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

  • New Features

    • Added automated enforcement of pull request quality requirements on the default branch.
    • Pull requests now require configured approvals, code-owner review, resolved conversations, and approval after the latest push.
    • Restricted merging to squash merges.
    • Repository settings now automatically reapply these quality requirements when configuration changes.
  • Tests

    • Added automated checks to verify the quality ruleset and repository-settings integration.

CodeAnt-AI Description

Enforce current pull request review and merge requirements for the default branch

What Changed

  • Pull requests now require one approval, code-owner review, resolved conversations, and approval of the latest pushed changes
  • New pushes dismiss previous approvals so reviewers must approve the updated code
  • Merging is limited to squash merges
  • Repository settings updates now apply these pull request rules automatically
  • Added checks to verify the rules and their automatic application

Impact

✅ Fewer stale approvals on changed pull requests
✅ Stronger review compliance before merging
✅ Consistent squash-only merges

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

Copilot AI review requested due to automatic review settings July 21, 2026 19:29
@don-petry
don-petry requested a review from a team as a code owner July 21, 2026 19:29
@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 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an executable Bash script that idempotently creates or updates the pr-quality GitHub ruleset, integrates it into repository settings automation, and adds static Bats coverage.

Changes

PR quality ruleset

Layer / File(s) Summary
Ruleset definition and API upsert
.github/scripts/apply-pr-quality-ruleset.sh
Validates GH_TOKEN, builds the pull request ruleset payload, and creates or updates the pr-quality ruleset. Concurrent creation failures trigger a re-fetch and update.
Repository settings integration
.github/scripts/apply-repo-settings.sh, .github/workflows/apply-repo-settings.yml
Applies the PR-quality ruleset after the code-quality ruleset and triggers the workflow when the new script changes.
Static ruleset validation
.github/scripts/tests/apply-pr-quality-ruleset.bats, .github/scripts/tests/apply-repo-settings.bats
Checks script properties, ruleset requirements, and invocation from the repository settings script.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow
  participant apply-repo-settings.sh
  participant apply-pr-quality-ruleset.sh
  participant GitHubAPI
  Workflow->>apply-repo-settings.sh: Run after relevant script changes
  apply-repo-settings.sh->>apply-pr-quality-ruleset.sh: Apply pr-quality ruleset
  apply-pr-quality-ruleset.sh->>GitHubAPI: Discover and upsert ruleset
  GitHubAPI-->>apply-pr-quality-ruleset.sh: Return API result
Loading

Possibly related issues

  • petry-projects/broodly#408 — Configures dismiss_stale_reviews_on_push: true for the same pr-quality ruleset requirement.
  • petry-projects/ContentTwin#388 — Configures the same stale-review dismissal setting.

Possibly related PRs

Suggested reviewers: donpetry-bot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes configure the pr-quality ruleset to dismiss stale reviews on push and wire validation and application support for issue #324.
Out of Scope Changes check ✅ Passed The script, tests, repository-settings wiring, and workflow trigger support the linked ruleset-compliance objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the feature, issue number, and stale-review dismissal requirement implemented by the 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 dev-lead/issue-324-20260721-1926

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 introduces a shell script to idempotently manage the pr-quality repository ruleset for the petry-projects/markets repository, along with a suite of BATS tests to verify the script's configuration. The review feedback suggests removing error-masking redirections (2>/dev/null || true) from the GitHub API call to allow the script to fail fast on errors. Additionally, the feedback recommends replacing fragile exact string matches and non-portable \s regular expressions in the BATS tests with more resilient and portable [[:space:]]* patterns to ensure compatibility across macOS and Linux environments.

Comment thread .github/scripts/apply-pr-quality-ruleset.sh Outdated
Comment thread .github/scripts/tests/apply-pr-quality-ruleset.bats
Comment thread .github/scripts/tests/apply-pr-quality-ruleset.bats
Comment thread .github/scripts/tests/apply-pr-quality-ruleset.bats

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

Implements repo-local compliance remediation for issue #324 by adding an idempotent script to create/update the pr-quality GitHub ruleset for petry-projects/markets, and a Bats test suite to statically assert the codified parameters (including dismiss_stale_reviews_on_push: true).

Changes:

  • Added .github/scripts/apply-pr-quality-ruleset.sh to apply the pr-quality ruleset via gh api with a jq-constructed payload matching the org standard.
  • Added .github/scripts/tests/apply-pr-quality-ruleset.bats to validate key ruleset parameters without live API calls.

Reviewed changes

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

File Description
.github/scripts/apply-pr-quality-ruleset.sh Adds an idempotent repo-local script to create/update the pr-quality ruleset (including dismiss_stale_reviews_on_push: true).
.github/scripts/tests/apply-pr-quality-ruleset.bats Adds Bats tests that assert the script contains the expected ruleset settings.

Comment thread .github/scripts/tests/apply-pr-quality-ruleset.bats
Comment thread .github/scripts/tests/apply-pr-quality-ruleset.bats
Comment thread .github/scripts/apply-pr-quality-ruleset.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) July 21, 2026 19:44

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

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 @.github/scripts/tests/apply-pr-quality-ruleset.bats:
- Around line 19-49: Update the tests targeting the repository and ruleset
settings to match executable configuration lines rather than comments: anchor
the repository assertion to the REPO assignment and each payload assertion to
its property line, including the existing checks for
dismiss_stale_reviews_on_push, required approvals, code-owner review, thread
resolution, last-push approval, and allowed merge methods. Keep the current
expected values unchanged.
🪄 Autofix (Beta)

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

Review profile: CHILL

Plan: Pro

Run ID: 1c102832-22b9-487e-83dd-368aa20244d8

📥 Commits

Reviewing files that changed from the base of the PR and between 78b40c7 and 2e7c71e.

📒 Files selected for processing (2)
  • .github/scripts/apply-pr-quality-ruleset.sh
  • .github/scripts/tests/apply-pr-quality-ruleset.bats

Comment thread .github/scripts/tests/apply-pr-quality-ruleset.bats
@don-petry
don-petry disabled auto-merge July 21, 2026 19:54
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@codeant-ai

codeant-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed 06f463c Aug 02, 2026 · 17:21 17:21
✅ Reviewed your PR 012881e Aug 02, 2026 · 15:19 15:20

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Aug 2, 2026
@don-petry
don-petry disabled auto-merge August 2, 2026 15:20
Comment thread .github/scripts/apply-pr-quality-ruleset.sh
Comment thread .github/scripts/apply-pr-quality-ruleset.sh
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #353
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-08-02T15:52:37Z

@don-petry

Copy link
Copy Markdown
Contributor Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-08-02T15:52:37Z

@don-petry
don-petry enabled auto-merge (squash) August 2, 2026 15:22
@don-petry
don-petry disabled auto-merge August 2, 2026 15:24
@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 2, 2026 15:28
@don-petry
don-petry disabled auto-merge August 2, 2026 15:28
@don-petry
don-petry enabled auto-merge (squash) August 2, 2026 15:30
@don-petry
don-petry disabled auto-merge August 2, 2026 15:31
@don-petry

Copy link
Copy Markdown
Contributor Author

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

Agent reasoning
Issues addressed: 0
- Quality Gate passed with 0 new issues, 0 security hotspots
Files changed: N/A (no fixes required)
Skipped (informational): 0
```

@don-petry
don-petry enabled auto-merge (squash) August 2, 2026 15:31
@don-petry
don-petry disabled auto-merge August 2, 2026 16:42
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (no-changes)

Agent reasoning
Addressed 5 threads:
- Thread PRRT_kwDORntvTc6Ss48J: Verified line 24 of apply-pr-quality-ruleset.bats already uses grep -qE with [[:space:]]* (POSIX ERE) [replied + resolved]
- Thread PRRT_kwDORntvTc6Ss48O: Verified lines 28–44 all use [[:space:]]* patterns throughout [replied + resolved]
- Thread PRRT_kwDORntvTc6Ss48S: Verified line 48 uses [[:space:]]* inside JSON array brackets [replied + resolved]
- Thread PRRT_kwDORntvTc6VyOrG: Verified apply-repo-settings.sh calls apply-pr-quality-ruleset.sh (line 66), workflow paths-trigger includes it (line 20), and apply-repo-settings.bats has a static wiring test [replied + resolved]
- Thread PRRT_kwDORntvTc6VyOrM: Verified race condition is handled (lines 87–101): POST failure re-fetches ruleset ID and PUTs instead of creating a duplicate [replied + resolved]
Test verification: pass — 18/18 BATS tests pass (apply-pr-quality-ruleset.bats + apply-repo-settings.bats)
Files changed: none — all fixes were already present in prior commits; threads were unresolved pending confirmation
```

@don-petry
don-petry enabled auto-merge (squash) August 2, 2026 16:44

@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: 618baaf41f2a17236ccf604ff39c5ff818763f05
Review mode: triage-approved (single reviewer)

Summary

Adds an idempotent script codifying the pr-quality ruleset for petry-projects/markets (fixing the dismiss_stale_reviews_on_push drift from issue #324), wires it into apply-repo-settings.sh and the workflow path triggers, and adds bats tests. The payload matches the org standard standards/rulesets/pr-quality.json exactly.

Linked issue analysis

Issue #324 (compliance audit) flagged that the pr-quality ruleset parameter dismiss_stale_reviews_on_push drifted to false. This PR substantively addresses it: apply-pr-quality-ruleset.sh sets dismiss_stale_reviews_on_push: true and reproduces the codified standard byte-for-byte (parameters, conditions, bypass_actors incl. OrganizationAdmin + Integration 3167543), so the repo-local fallback cannot re-introduce drift.

Findings

  • Ruleset payload verified identical to the source-of-truth standard (petry-projects/.github/standards/rulesets/pr-quality.json), including bypass actors.
  • Script handles the create/update race: on POST 422 conflict it re-fetches the existing ruleset ID and falls back to PUT.
  • All 10 review threads (gemini, copilot, coderabbit, codeant) are resolved; prior feedback on test fragility and concurrency was addressed in later commits.
  • Workflow change is a path-trigger addition only; permissions: {} unchanged. No GitHub Actions security smells.
  • Secret scanning MCP tool not available in this run; the gitleaks CI check passed. No secrets in the diff (GH_TOKEN is read from the environment, never printed).
  • Minor (non-blocking): bats tests assert on script text via grep rather than executing the payload; acceptable for static guardrail tests and consistent with the existing apply-repo-settings.bats pattern.

CI status

Green on head commit 618baaf: CodeQL, Secret scan (gitleaks), SonarCloud, agent-shield, CodeRabbit, Graphite AI Reviews all SUCCESS. Backend/Frontend CI and dependency audits SKIPPED (no matching paths/ecosystems). CANCELLED entries are superseded dev-lead orchestration reruns; the latest run of each is SUCCESS/SKIPPED. Branch is BEHIND main but MERGEABLE.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@codeant-ai codeant-ai Bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Aug 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@don-petry
don-petry merged commit 9c3a877 into main Aug 2, 2026
21 of 23 checks passed
@don-petry
don-petry deleted the dev-lead/issue-324-20260721-1926 branch August 2, 2026 17:22

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/apply-repo-settings.yml (1)

32-32: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Disable default checkout credential persistence.

actions/checkout persists the provided token by default. This workflow only runs authenticated GitHub API calls via GH_TOKEN_ADMIN, not authenticated Git commands, so set persist-credentials: false to reduce credential exposure in later workspace or artifact handling.

Proposed fix
       - uses: Vercel/move-files-action@a32a8bca44959cdbeec29df7fa93adfa6a95a7 # [version]
+        with:
+          persist-credentials: false
🤖 Prompt for 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.

In @.github/workflows/apply-repo-settings.yml at line 32, Update the
actions/checkout step in the workflow to set persist-credentials to false, while
leaving the existing checkout version and GH_TOKEN_ADMIN-based API
authentication unchanged.

Source: Linters/SAST tools

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

Outside diff comments:
In @.github/workflows/apply-repo-settings.yml:
- Line 32: Update the actions/checkout step in the workflow to set
persist-credentials to false, while leaving the existing checkout version and
GH_TOKEN_ADMIN-based API authentication unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e991312a-7b43-4782-a5ea-9cd748628a9d

📥 Commits

Reviewing files that changed from the base of the PR and between 2e7c71e and 06f463c.

📒 Files selected for processing (5)
  • .github/scripts/apply-pr-quality-ruleset.sh
  • .github/scripts/apply-repo-settings.sh
  • .github/scripts/tests/apply-pr-quality-ruleset.bats
  • .github/scripts/tests/apply-repo-settings.bats
  • .github/workflows/apply-repo-settings.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/scripts/tests/apply-pr-quality-ruleset.bats

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

Labels

size:L This PR changes 100-499 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

3 participants