Skip to content

feat: implement issue #984 — Standardize branch-policy compliance self-heal: vendor apply-repo-settings as a canary-ringed reusable - #985

Open
don-petry wants to merge 9 commits into
mainfrom
dev-lead/issue-984-20260818-1655
Open

feat: implement issue #984 — Standardize branch-policy compliance self-heal: vendor apply-repo-settings as a canary-ringed reusable#985
don-petry wants to merge 9 commits into
mainfrom
dev-lead/issue-984-20260818-1655

Conversation

@don-petry

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

Copy link
Copy Markdown
Contributor

User description

Closes #984

Implemented by dev-lead agent. Please review.


CodeAnt-AI Description

Standardize weekly repository settings and branch-policy self-healing

What Changed

  • Added an Apply repo settings workflow that weekly applies standard repository settings plus the pr-quality and code-quality branch-policy rulesets.
  • Added manual preview runs, scheduled runs, and push-triggered runs for the central repository and adopting repositories.
  • Added clear failure details when the required classic admin credential is missing or unavailable.
  • Added staged canary-ring rollout registration from next through stable.
  • Documented workflow adoption, required credentials, on-demand remediation, and break-glass manual execution.
  • Added contract tests covering workflow inputs, credential checks, settings and ruleset application, caller wiring, and canary registration.

Impact

✅ Weekly branch-policy drift correction
✅ Fewer repositories with outdated rulesets
✅ Clearer credential failure messages

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

…f-heal: vendor apply-repo-settings as a canary-ringed reusable
@don-petry
don-petry requested a review from a team as a code owner August 18, 2026 17:10
@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 18, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed 5ad1d5c Aug 21, 2026 · 07:54 07:55
✅ Incremental review completed 2c4c424 Aug 20, 2026 · 02:58 02:58
✅ Reviewed your PR a9de6be Aug 18, 2026 · 17:11 17:14

@codeant-ai

codeant-ai Bot commented Aug 18, 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

@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

@coderabbitai

coderabbitai Bot commented Aug 18, 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: 39 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 895ba4de-6572-4694-8c11-fa8df28a4521

📥 Commits

Reviewing files that changed from the base of the PR and between bc87cc6 and 5ad1d5c.

📒 Files selected for processing (9)
  • .github/workflows/apply-repo-settings-reusable.yml
  • .github/workflows/apply-repo-settings-tests.yml
  • .github/workflows/apply-repo-settings.yml
  • standards/canary-rings.json
  • standards/ci-standards.md
  • standards/github-settings.md
  • standards/ruleset-remediation-runbook.md
  • standards/workflows/apply-repo-settings.yml
  • test/scripts/apply-repo-settings/reusable-contract.bats

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:L This PR changes 100-499 lines, ignoring generated files label Aug 18, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces the apply-repo-settings workflow as a weekly self-heal mechanism for branch-policy compliance, updating the canary rings registry, CI standards, and ruleset remediation documentation, and adding contract tests in BATS. The reviewer provided valuable feedback to improve robustness: evaluating the dry_run boolean input with an explicit == true check to prevent truthy-string coercion, using the optional/try operator ? in yq commands to avoid fatal parsing errors, and refining the Bash line-reading loop in the test script to handle missing trailing newlines and carriage returns.

Comment thread standards/workflows/apply-repo-settings.yml Outdated
Comment thread test/scripts/apply-repo-settings/reusable-contract.bats Outdated
Comment thread test/scripts/apply-repo-settings/reusable-contract.bats 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 18, 2026 17:13
@don-petry
don-petry disabled auto-merge August 18, 2026 17:14
# ── the reusable is a well-formed pure reusable ───────────────────────────────
@test "reusable exists and declares workflow_call" {
[ -f "$REUSABLE" ]
run yq '.on | has("workflow_call")' "$REUSABLE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The CI workflow installs bats, shellcheck, and jq, but not yq; on a clean ubuntu-latest runner this first yq invocation fails with command-not-found and causes the wholesale Bats suite to fail. Install yq in the workflow or replace these queries with an available dependency. [import error]

Severity Level: Major ⚠️
- ❌ Apply-repo-settings CI suite fails before assertions.
- ❌ Contract regressions cannot pass the required workflow.

Use CodeAnt Skill

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** test/scripts/apply-repo-settings/reusable-contract.bats
**Line:** 28:28
**Comment:**
	*Import Error: The CI workflow installs `bats`, `shellcheck`, and `jq`, but not `yq`; on a clean `ubuntu-latest` runner this first `yq` invocation fails with command-not-found and causes the wholesale Bats suite to fail. Install `yq` in the workflow or replace these queries with an available dependency.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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 .github/workflows/apply-repo-settings-tests.yml: renamed the install step to "Install bats, shellcheck, jq, and yq" and added a pinned mikefarah/yq v4.44.3 install with SHA-256 verification, matching the pattern already used in pr-review-mention-tests.yml. The bats suite can now resolve yq on a clean ubuntu-latest runner.

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.

Verified: the fix is correctly in place. .github/workflows/apply-repo-settings-tests.yml line 46 installs yq as a pinned mikefarah/yq v4.44.3 binary with SHA-256 checksum verification — matching the pattern from pr-review-mention-tests.yml. The Lint and bats CI check passes, confirming the bats suite can now resolve yq on a clean ubuntu-latest runner.

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.

Dev-lead verification: confirmed. .github/workflows/apply-repo-settings-tests.yml line 46 installs yq v4.44.3 as a pinned mikefarah/yq binary with HTTPS enforcement and SHA-256 checksum verification — the bats suite can resolve yq on a clean ubuntu-latest runner. The Lint and bats CI check passes. No further changes needed.

Comment thread test/scripts/apply-repo-settings/reusable-contract.bats Outdated
Comment on lines +132 to +133
run yq -oy '[.agents["apply-repo-settings"].rings[].channel] | sort | join(",")' "$REGISTRY"
[ "$output" = "next,ring0,ring1,stable" ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This assertion checks only that four channel names exist, so it passes if the registry assigns incorrect order values, members, or a mismatched reusable path. Those fields drive canary-rollout.sh's promotion and target resolution, making such corruption operationally significant. Validate the expected path and each channel's order and membership, not just the sorted channel-name set. [incomplete implementation]

Severity Level: Major ⚠️
- ⚠️ Canary promotion can target incorrect repositories.
- ❌ Rollout may use the wrong reusable workflow path.
- ⚠️ Ring ordering can bypass intended soak stages.

Use CodeAnt Skill

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** test/scripts/apply-repo-settings/reusable-contract.bats
**Line:** 132:133
**Comment:**
	*Incomplete Implementation: This assertion checks only that four channel names exist, so it passes if the registry assigns incorrect `order` values, members, or a mismatched reusable path. Those fields drive `canary-rollout.sh`'s promotion and target resolution, making such corruption operationally significant. Validate the expected path and each channel's order and membership, not just the sorted channel-name set.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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 test/scripts/apply-repo-settings/reusable-contract.bats: added a new test "registry entry has correct reusable path, ring order, and membership" immediately after the existing channel-name test. It asserts the reusable path (.github/workflows/apply-repo-settings-reusable.yml), the monotone order value for each ring (next=0, ring0=1, ring1=2, stable=3), and the membership anchors for next (petry-projects/.github-private), ring0 (petry-projects/.github), and stable (*). Corruption of any of these fields now causes a test failure before the canary promotion runs.

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.

Verified: the fix is correctly in place. test/scripts/apply-repo-settings/reusable-contract.bats lines 137–156 contain the new test registry entry has correct reusable path, ring order, and membership, which asserts: the reusable path (.github/workflows/apply-repo-settings-reusable.yml), monotone ring orders (next=0, ring0=1, ring1=2, stable=3), and membership anchors for next (petry-projects/.github-private), ring0 (petry-projects/.github), and stable (*). All assertions match standards/canary-rings.json and the Lint and bats CI check passes.

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.

Dev-lead verification: confirmed. test/scripts/apply-repo-settings/reusable-contract.bats lines 137–156 contain the new test registry entry has correct reusable path, ring order, and membership, which asserts the reusable path (.github/workflows/apply-repo-settings-reusable.yml), monotone ring orders (next=0, ring0=1, ring1=2, stable=3), and membership anchors for next, ring0, and stable rings. Corruption of any of these fields now causes a test failure. The Lint and bats CI check passes. No further changes needed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Reviewed against the plan in #984 — the shape is right and matches the org conventions (same-commit registry entry, stub source-of-truth under standards/workflows/, host local-ref dogfood, secret-name reconciliation in the docs). Steering notes, in priority order:

Must fix before merge

  1. yq in the bats environment — codeant-ai is right: reusable-contract.bats calls yq but the bats CI job doesn't install it, so the suite will die command-not-found on a clean runner. Either install yq in the test workflow or rewrite those assertions with the tooling the job already has.
  2. Strengthen the both-scripts assertion — the current grep is satisfied by the reusable's comments (which mention both script names). Assert the actual invocations inside the run: block (e.g. match ^\s*bash scripts/apply-rulesets\.sh within the step script), otherwise the invariant this test exists for can silently regress.

Worth doing
3. Deepen the registry assertion to check order, members, and the reusable path for the apply-repo-settings entry — those fields drive canary-rollout.sh promotion/target resolution.
4. Gemini's inputs.dry_run == true nit is harmless to adopt for future-proofing, though with a type: boolean input the current expression evaluates correctly.

Post-merge ordering constraint (do not skip)
The canonical stub pins @apply-repo-settings/v1-stable, which does not exist until the release cut. Sequence must be: merge → cut apply-repo-settings/v1.0.0 + seed v1-next|v1-ring0|v1-ring1|v1-stable → vendor stubs to ring members (each pinned to its ring's channel) → promote per the #548 gate. Vendoring a stub before its tag exists = fleet-wide startup_failure. Keeping RING_REUSABLES enforcement off until stable (as already noted) is correct.

Follow-ups to file now (so fleet delivery doesn't stall after this merges): the cross-repo work lives outside this repo — (a) .github-private: Fleet Monitor stub-registry wiring + drift-allowlist audit; (b) per-repo: vendor the stub and delete the diverged forks in markets / TalkTerm / bmad-bgreat-suite / google-app-scripts incl. all GH_TOKEN_ADMIN references; (c) close .github-private#1209 with evidence once stable is reached. Please file these as linked issues.

@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 18, 2026 17:18
@don-petry
don-petry disabled auto-merge August 18, 2026 17:19
@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.

Comment thread test/scripts/apply-repo-settings/reusable-contract.bats Outdated
@don-petry

Copy link
Copy Markdown
Contributor Author

@donpetry-bot CI is green (bats ×2, ShellCheck, Sonar quality gate) — please run the fresh review.

Also, the branch is BEHIND main — auto-rebase should pick it up, or rebase on next dev-lead touch.

Reminder from the earlier review (not yet done): please file the cross-repo follow-up issues so fleet delivery continues after this merges — (a) .github-private: Fleet Monitor stub-registry wiring + drift-allowlist audit; (b) per-repo stub vendoring + diverged-fork deletion (markets, TalkTerm, bmad-bgreat-suite, google-app-scripts) incl. GH_TOKEN_ADMIN removal; (c) release cut apply-repo-settings/v1.0.0 + seed v1-* channel tags before any consumer stub lands; (d) close .github-private#1209 once stable.

@donpetry-bot

Copy link
Copy Markdown
Contributor

@don-petry I'm on it — starting a fresh review now. Results will appear in a few minutes.

@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 18, 2026 17:26
@don-petry
don-petry disabled auto-merge August 18, 2026 17:27
@don-petry
don-petry enabled auto-merge (squash) August 18, 2026 17:28
@don-petry
don-petry disabled auto-merge August 18, 2026 17:28
@don-petry
don-petry enabled auto-merge (squash) August 18, 2026 17:28
@don-petry
don-petry disabled auto-merge August 20, 2026 02:58
@don-petry
don-petry enabled auto-merge (squash) August 20, 2026 03:03
@don-petry
don-petry disabled auto-merge August 20, 2026 03:03
@don-petry

Copy link
Copy Markdown
Contributor Author

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

Agent reasoning
   - 0 Security Hotspots
   - 0.0% Coverage on New Code
   - 0.0% Duplication on New Code
2. **All CI checks are passing** — no failures, timeouts, or cancellations (all statuses are either "success" or "skipped")
3. **No review blockers** — all reviews are COMMENTED or APPROVED; zero CHANGES_REQUESTED
4. **The donpetry-bot automated review** provided an APPROVED decision with detailed security findings, all marked as INFO (confirmations that controls are in place), not issues requiring fixes.
5. **The gemini-code-assist[bot] review** offered code suggestions (using `== true` for dry_run checks, optional operator `?` in yq, refining bash loops), but these are refinements to existing code, not blocking issues, and appear to be feedback on the implementation approach rather than mandatory fixes.
## Summary
**No actionable issues to address.** The PR passes all quality gates and CI checks. The SonarCloud bot comment reports 0 new issues and 0 security hotspots — this is a clean bill of health, not a list of findings to fix.
The PR is ready for merge once the required human review from org-leads is obtained (which is already gated in the merge requirements as noted in the donpetry-bot review).

@don-petry
don-petry enabled auto-merge (squash) August 20, 2026 03:04
@don-petry
don-petry disabled auto-merge August 20, 2026 17:44
@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-20T18:16:23Z

@don-petry
don-petry enabled auto-merge (squash) August 20, 2026 17:46
@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge August 20, 2026 18:58
@don-petry
don-petry enabled auto-merge (squash) August 20, 2026 19:01
@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge August 20, 2026 20:45
@don-petry
don-petry enabled auto-merge (squash) August 20, 2026 20:47
@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge August 20, 2026 22:45
@don-petry

Copy link
Copy Markdown
Contributor Author

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

PR: #985
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-20T23:17:24Z

@don-petry
don-petry enabled auto-merge (squash) August 20, 2026 22:47
@donpetry-bot
donpetry-bot requested a review from a team August 21, 2026 01:49
@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

@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 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry disabled auto-merge August 21, 2026 07:55
@don-petry
don-petry enabled auto-merge (squash) August 21, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human-review size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize branch-policy compliance self-heal: vendor apply-repo-settings as a canary-ringed reusable

2 participants