Skip to content

feat: implement issue #861 — [#850 Phase 1b] Make compliance audit + deploy compliance v<M>-stable-aware (flag bare tags) - #863

Merged
don-petry merged 1 commit into
mainfrom
dev-lead/issue-861-20260722-0219
Jul 22, 2026
Merged

don-petry merged 1 commit into
mainfrom
dev-lead/issue-861-20260722-0219

Conversation

@don-petry

@don-petry don-petry commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

User description

Closes #861

Implemented by dev-lead agent. Please review.


CodeAnt-AI Description

Require major-scoped workflow pins for ring and dev-lead stubs

What Changed

  • Ring workflow stubs now must use the major-scoped v<M>-<tier> pin; bare tier pins like @.../stable are treated as drift once a release exists.
  • If a ring agent has no release yet, a bare tier pin still passes; tier-correct v<M>-<tier> pins continue to pass, and wrong-tier pins are still flagged.
  • Dev-lead stubs now must use dev-lead/v<M>-<tier> for both the workflow pin and agent_ref, so the two references stay on the same major and tier.
  • Tests were updated to cover the new drift cases and the major-scoped accepted forms.

Impact

✅ Fewer false-compliant workflow stubs
✅ Earlier detection of outdated bare tier pins
✅ Fewer split-channel dev-lead checkouts

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

…deploy compliance v<M>-stable-aware (flag bare tags)
@don-petry
don-petry requested a review from a team as a code owner July 22, 2026 02:39
Copilot AI review requested due to automatic review settings July 22, 2026 02:39
@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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@codeant-ai

codeant-ai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 884db6b Jul 22, 2026 · 02:39 02:46

Updated in place by CodeAnt AI · last 5 reviews

@coderabbitai

coderabbitai Bot commented Jul 22, 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: 35 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9063a9af-eb26-405a-abe2-47629a210891

📥 Commits

Reviewing files that changed from the base of the PR and between 632c46d and 884db6b.

📒 Files selected for processing (5)
  • scripts/compliance-audit.sh
  • scripts/deploy-standard-workflows.sh
  • test/scripts/compliance-audit/centralized-stub-pins.bats
  • test/scripts/compliance-audit/dev-lead-stub-channel-sync.bats
  • test/scripts/deploy-standard-workflows/emit-vform.bats
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-861-20260722-0219

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 Jul 22, 2026
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry enabled auto-merge (squash) July 22, 2026 02:40
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Enforce major-scoped v- pins for RING + dev-lead stubs

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Require RING workflow stubs to pin major-scoped v- channels; flag bare tier tags.
• Make deploy drift-check major-aware: bare tier is only acceptable before first release.
• Expand Bats coverage for new drift rules and dev-lead channel/agent_ref synchronization.
Diagram

graph TD
  A["Repo workflow stubs"] --> B["scripts/compliance-audit.sh"] --> C["Audit findings"]
  D["scripts/deploy-standard-workflows.sh"] --> E["Proposed stub repin (v<M>-tier)"]
  B --> F{{"GitHub Contents/Refs API"}}
  D --> F
  G["Bats tests"] --> B
  G --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Always require v- (even pre-release)
  • ➕ Simplifies deploy/audit logic by removing the "no current major" exception
  • ➕ Eliminates an ambiguous grace period for bare tier tags
  • ➖ Requires defining a major line before any release exists (e.g., forced v0), which may not match current release semantics
  • ➖ Higher migration friction for brand-new agents
2. Derive expected major from repo templates/config (not Git refs)
  • ➕ Avoids reliance on GitHub release/tag discovery and its edge cases
  • ➕ Keeps policy decision in a single configuration source
  • ➖ Introduces/extends configuration surface area and risks divergence from actual published tags
  • ➖ Still needs validation that tags exist remotely

Recommendation: Current approach is reasonable: it enforces the new v-form requirement for RING/dev-lead while keeping a pragmatic exception for agents with no releases. Review focus should be on the correctness of "has current major" detection and ensuring messaging clearly distinguishes bare-tier drift vs wrong-tier v-form drift.

Files changed (5) +187 / -84

Enhancement (2) +50 / -29
compliance-audit.shRequire v<M>-<tier> pins for RING and dev-lead stubs +29/-19

Require v<M>-<tier> pins for RING and dev-lead stubs

• Updates centralized workflow stub auditing so RING reusables must use the major-scoped 'v<M>-<tier>' ref and bare tier pins are treated as drift. Tightens dev-lead stub validation to require 'dev-lead/v<M>-<channel>' in both 'uses:' and 'agent_ref', catching major mismatches as split-brain.

scripts/compliance-audit.sh

deploy-standard-workflows.shMake drift detection major-aware for bare tier pins +21/-10

Make drift detection major-aware for bare tier pins

• Extends ring-managed compliance detection to accept templates pinned either to bare tier or v-form. Treats bare tier pins as compliant only when the agent has no current major (no releases); otherwise the stub is drift and should be repinned to 'v<M>-<tier>'.

scripts/deploy-standard-workflows.sh

Tests (3) +137 / -55
centralized-stub-pins.batsAdd integration coverage: bare tier RING pins are now flagged +54/-8

Add integration coverage: bare tier RING pins are now flagged

• Introduces an integration-style test that mocks 'gh_api' and asserts findings are emitted when a stable-tier repo pins a bare tier ref. Adds positive coverage for tier-correct v-form pins and ensures wrong-tier v-form pins remain flagged.

test/scripts/compliance-audit/centralized-stub-pins.bats

dev-lead-stub-channel-sync.batsUpdate dev-lead channel extraction/matching to v-form +60/-47

Update dev-lead channel extraction/matching to v-form

• Updates helper mirroring logic to extract and match full 'v<M>-<channel>' strings instead of bare channels. Adds explicit tests that bare pins yield empty extraction (drift) and that major mismatches are detected as split-brain.

test/scripts/compliance-audit/dev-lead-stub-channel-sync.bats

emit-vform.batsTest deploy behavior for bare tier pins with/without releases +23/-0

Test deploy behavior for bare tier pins with/without releases

• Adds drift-check tests verifying that a bare tier stub is repinned to 'v<M>-<tier>' once a release exists, but remains compliant when no release/current major is present. Preserves existing coverage for wrong-tier v-form drift behavior.

test/scripts/deploy-standard-workflows/emit-vform.bats

@don-petry
don-petry disabled auto-merge July 22, 2026 02:41
@don-petry

Copy link
Copy Markdown
Contributor Author

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

Agent reasoning
Issues addressed: 0
- Quality Gate passed (informational): no actionable issues
Files changed: none
Skipped (informational): 0
```
The PR is clean. The SonarCloud bot comment is reporting a successful quality gate pass with no code issues to address. All CI checks are passing, and there are no blocking reviews.

@don-petry
don-petry enabled auto-merge (squash) July 22, 2026 02:41
@don-petry
don-petry merged commit 1eca5df into main Jul 22, 2026
28 checks passed
@don-petry
don-petry deleted the dev-lead/issue-861-20260722-0219 branch July 22, 2026 02:43

Copilot AI 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.

Pull request overview

Updates the org compliance audit and the standard-workflow deployment drift logic to enforce major-scoped v-form pins (v<M>-<tier>) for ring-managed stubs and dev-lead stubs, and adds/updates bats coverage to lock in the new policy for issue #861.

Changes:

  • Compliance audit: require v-form pins for RING centralized stubs and dev-lead stubs, and tighten dev-lead agent_ref sync to match the full v<M>-<tier> channel.
  • Deploy drift check: recognize v-form refs in templates, and treat bare-tier stubs as compliant only when the agent has no releases.
  • Tests: expand bats coverage for the new drift / acceptance cases across deploy + compliance audit checks.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
scripts/compliance-audit.sh Enforces v-form pins for RING stubs and dev-lead stubs; updates drift messaging accordingly.
scripts/deploy-standard-workflows.sh Extends drift detection to allow v-form refs and makes bare-tier acceptance release-aware.
test/scripts/compliance-audit/centralized-stub-pins.bats Adds integration-style coverage to ensure bare tier pins are flagged and v-form pins are accepted for RING stubs.
test/scripts/compliance-audit/dev-lead-stub-channel-sync.bats Updates mirror helpers + tests to extract/match full v<M>-<tier> channels and reject bare pins.
test/scripts/deploy-standard-workflows/emit-vform.bats Adds deploy drift-check coverage for “released agent => bare is drift” and “no release => bare is compliant”.
Comments suppressed due to low confidence (1)

scripts/deploy-standard-workflows.sh:332

  • is_already_compliant always calls ring_host_current_major (a gh api request) before checking whether the existing stub is already pinned to a tier-correct v<M>-<tier> ref. This adds an avoidable network call for every already-compliant v-form stub, which can slow large sweeps and increase risk of GitHub API rate limiting.

Consider short-circuiting by first extracting existing_ref and returning early when ring_vform_tier_aligned passes; only call ring_host_current_major when you still need to decide whether a bare tier stub is allowed (no-release case).

      local host major
      host="$(cut -d/ -f1-2 <<< "$prefix")"
      major="$(ring_host_current_major "$host" "$base")"
      if [[ -z "$major" ]]; then
        local ref
        while IFS= read -r ref; do
          [[ -n "$ref" ]] && grep -qF "${prefix}@${ref}" <<< "$existing_content" && return 0
        done < <(ring_accepted_refs "$base" "$repo")
      fi
      # A stub already pinned to the repo's tier-correct `v<M>-<tier>` form (any
      # major) is compliant regardless of release state. A WRONG-tier v-form — or a
      # bare stub once the agent has a release — is not accepted here and stays drift.
      local existing_ref
      existing_ref=$(grep -oE "@${base}/[^[:space:]\"']+" <<< "$existing_content" | head -1)
      existing_ref="${existing_ref#@}"
      if [[ -n "$existing_ref" ]] && ring_vform_tier_aligned "$existing_ref" "$base" "$repo"; then
        return 0
      fi
      return 1

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 87 rules

Grey Divider


Action required

1. Audit/deploy pin mismatch 🐞 Bug ≡ Correctness
Description
check_centralized_workflow_stubs() now accepts only major-scoped v<M>-<tier> pins for RING stubs,
so a bare <agent>/<tier> pin is always flagged as drift. deploy-standard-workflows.sh still treats
bare-tier pins as compliant when ring_host_current_major() finds no releases, so the deploy sweep
may never remediate the audit finding for pre-release agents.
Code

scripts/compliance-audit.sh[R1566-1576]

+    # Compliance rule (major-scoped-channels epic #657 F5, #861):
+    #   RING reusables MUST pin the major-scoped `<name>/v<M>-<tier>` form — any
+    #     major M whose tier matches the repo (ring_major_form_acceptable). A bare
+    #     `<name>/<tier>` pin is now drift: the fleet has migrated onto the v-form,
+    #     so the bare grace (stub_pin_acceptable) no longer applies to the rings.
+    #   Non-RING reusables (fixed-pin entries) keep the exact/legacy match via
+    #     stub_pin_acceptable.
+    # Both helpers anchor to start-of-line so a `# uses: …` comment never counts;
+    # a v-form pinned to the WRONG tier stays drift.
+    if { [ "$is_ring" = 1 ] && ring_major_form_acceptable "$decoded" "$reusable" "$chan" "$repo"; } \
+      || { [ "$is_ring" != 1 ] && stub_pin_acceptable "$decoded" "$reusable" "$canonical" "$legacy"; }; then
Relevance

⭐⭐⭐ High

Team previously fixed audit/deploy rule divergence; #531 explicitly unified drift logic to avoid
mismatches.

PR-#531
PR-#695
PR-#699

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The audit’s new branching makes RING compliance depend solely on ring_major_form_acceptable, which
rejects bare-tier pins (no v<M>- major). Deploy, and its tests, explicitly keep bare-tier pins
compliant when no release/major exists, proving the two paths can now disagree for pre-release
agents.

scripts/compliance-audit.sh[1566-1577]
scripts/deploy-standard-workflows.sh[301-332]
scripts/lib/ring-pins.sh[143-159]
test/scripts/deploy-standard-workflows/emit-vform.bats[86-93]
test/scripts/deploy-standard-workflows/emit-vform.bats[118-126]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`scripts/compliance-audit.sh` now *unconditionally* flags bare `<agent>/<tier>` pins for RING reusables by removing the `stub_pin_acceptable` path for RING entries and requiring `ring_major_form_acceptable`. However, `scripts/deploy-standard-workflows.sh` explicitly keeps bare-tier stubs compliant when the reusable has **no release** (no current major), meaning the deploy sweep will not converge the fleet with the audit.

### Issue Context
- The shared ring model (`scripts/lib/ring-pins.sh`) defines `ring_host_current_major()` which returns empty when there are no release tags, and callers should fall back to bare-tier pins.
- Deploy logic already implements and tests this no-release grace.

### Fix Focus Areas
- scripts/compliance-audit.sh[1566-1576]

### Implementation guidance
Update `check_centralized_workflow_stubs()` so RING pin compliance is **release-aware**, matching deploy behavior:
1. Determine the current major for the reusable (via `ring_host_current_major` or an equivalent gh_api-based helper, ideally cached per agent for performance).
2. If there is **no current major** (empty), allow bare-tier pins (e.g., via `stub_pin_acceptable` using the computed bare canonical + legacy) the same way deploy considers them compliant.
3. If there **is** a current major, require the `v<M>-<tier>` form (current behavior).

Add/adjust integration tests to cover the no-release audit behavior (mirroring `emit-vform.bats`’s `unset GH_RELEASE_REFS` scenario) so audit+deploy cannot regress into disagreement again.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

# bare-tier pins the fleet still carries; the wrong tier stays drift.
if stub_pin_acceptable "$decoded" "$reusable" "$canonical" "$legacy" \
|| { [ "$is_ring" = 1 ] && ring_major_form_acceptable "$decoded" "$reusable" "$chan" "$repo"; }; then
# Compliance rule (major-scoped-channels epic #657 F5, #861):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Audit/deploy pin mismatch 🐞 Bug ≡ Correctness

check_centralized_workflow_stubs() now accepts only major-scoped v<M>-<tier> pins for RING stubs,
so a bare <agent>/<tier> pin is always flagged as drift. deploy-standard-workflows.sh still treats
bare-tier pins as compliant when ring_host_current_major() finds no releases, so the deploy sweep
may never remediate the audit finding for pre-release agents.
Agent Prompt
### Issue description
`scripts/compliance-audit.sh` now *unconditionally* flags bare `<agent>/<tier>` pins for RING reusables by removing the `stub_pin_acceptable` path for RING entries and requiring `ring_major_form_acceptable`. However, `scripts/deploy-standard-workflows.sh` explicitly keeps bare-tier stubs compliant when the reusable has **no release** (no current major), meaning the deploy sweep will not converge the fleet with the audit.

### Issue Context
- The shared ring model (`scripts/lib/ring-pins.sh`) defines `ring_host_current_major()` which returns empty when there are no release tags, and callers should fall back to bare-tier pins.
- Deploy logic already implements and tests this no-release grace.

### Fix Focus Areas
- scripts/compliance-audit.sh[1566-1576]

### Implementation guidance
Update `check_centralized_workflow_stubs()` so RING pin compliance is **release-aware**, matching deploy behavior:
1. Determine the current major for the reusable (via `ring_host_current_major` or an equivalent gh_api-based helper, ideally cached per agent for performance).
2. If there is **no current major** (empty), allow bare-tier pins (e.g., via `stub_pin_acceptable` using the computed bare canonical + legacy) the same way deploy considers them compliant.
3. If there **is** a current major, require the `v<M>-<tier>` form (current behavior).

Add/adjust integration tests to cover the no-release audit behavior (mirroring `emit-vform.bats`’s `unset GH_RELEASE_REFS` scenario) so audit+deploy cannot regress into disagreement again.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Summary

Makes the compliance audit and deploy drift-check major-scoped-channel aware (#657 F5): RING workflow stubs and the dev-lead stub must now pin v<M>-<tier> channels; a bare <agent>/<tier> pin is drift. The deploy-side bare-tier grace is now major-aware — bare pins stay compliant only while the agent has no release. 187+/84- across 2 scripts and 3 bats files.

Linked issue analysis

Closes #861 ([#850 Phase 1b]). All three scope items are substantively addressed: (1) check_centralized_workflow_stubs now requires ring_major_form_acceptable for RING reusables and flags bare tier pins, with the finding message naming the expected v<M>-<tier> form; (2) check_dev_lead_stub pin regex + uses_channel extraction require dev-lead/v[0-9]+-(stable|next|ring[0-9]+) and agent_ref must match the full v-form (major split-brain caught); (3) is_already_compliant in deploy-standard-workflows.sh accepts v-form template refs into the ring branch and grants bare-tier grace only when ring_host_current_major is empty. Audit stays major-agnostic on tier as required. Guardrails respected: no standards/workflows/*.yml edits, no scripts/lib/ring-pins.sh changes, no consumer-repo edits. All helpers the new code calls (ring_tier_for_repo, ring_host_current_major, ring_accepted_refs, ring_vform_tier_aligned) verified present at head. Dependency ordering satisfied — #860 (Part 1 template re-pins) is closed, so a live audit sees v-form templates.

Findings

No blocking findings.

  • Logic verified against head: bare pin on a released agent falls through is_already_compliant to the ring_vform_tier_aligned check (fails → drift), matching the new emit-vform.bats cases; the no-release path preserves the existing ring_accepted_refs grace (dry-run.bats no-release case preserved as required).
  • Tests were strengthened, not weakened: new F5 integration tests exercise the whole check via mocked gh_api, replacing the now-obsolete bare-tier transition test; dev-lead mirror helpers updated to the v-form policy including a bare-pin-yields-empty case and a major split-brain case.
  • Secret scanning MCP tool was not available in this run — gitleaks CI check is green; no secrets in the diff (shell logic + tests only).
  • Minor (non-blocking): the stale NOTE at the top of check_centralized_workflow_stubs still says dev-lead is 'pinned to the dev-lead/stable channel' — could be updated to v-form wording in a follow-up.

CI status

All checks green: ShellCheck ✓, Lint ✓, Lint and bats ✓ (×2), CodeQL ✓, SonarCloud Quality Gate ✓, Secret scan (gitleaks) ✓, agent-shield ✓, Agent Security Scan ✓, npm audit ✓, CodeRabbit ✓. Remaining entries are expected SKIPPED (ecosystem-specific audits, dependabot). Bot review comments are quota/no-op noise only; dev-lead fix-reviews pass reported no-changes. No unresolved human review threads.


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

Comment on lines +1575 to 1578
if { [ "$is_ring" = 1 ] && ring_major_form_acceptable "$decoded" "$reusable" "$chan" "$repo"; } \
|| { [ "$is_ring" != 1 ] && stub_pin_acceptable "$decoded" "$reusable" "$canonical" "$legacy"; }; then
continue
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.

Suggestion: The new ring-only acceptance path unconditionally rejects bare <base>/<tier> pins, but deploy logic still treats bare pins as compliant when an agent has no release major yet. This creates an audit/deploy contract split where audit reports unavoidable drift that deploy will not fix. Align this check with deploy by allowing bare-tier ring pins when no current major exists for that reusable host. [api mismatch]

Severity Level: Major ⚠️
- ⚠️ Compliance audit flags unfixable drift for pre-release ring stubs.
- ⚠️ Deploy sweep leaves some pre-release stubs unrepinned.
- ⚠️ Engineers see recurring non-actionable ci-workflows findings.
Steps of Reproduction ✅
1. Run the org-wide audit script `scripts/compliance-audit.sh` (entrypoint at lines 1–40)
so that it iterates repositories and invokes `check_centralized_workflow_stubs "$repo"`
from the main loop at `scripts/compliance-audit.sh:2854-2860`.

2. In some repo `R`, ensure a centralized ring-managed stub (e.g.
`.github/workflows/auto-rebase.yml`) is pinned to a bare-tier channel such as `uses:
petry-projects/.github/.github/workflows/auto-rebase-reusable.yml@auto-rebase/stable`,
which matches the channel model wired through `centralized[]` and `ring_canonical_ref` in
`check_centralized_workflow_stubs` at `scripts/compliance-audit.sh:1490-1521`.

3. When `check_centralized_workflow_stubs` runs for `R`, it sets `is_ring=1` and
`chan="${reusable%-reusable}"`, then loads the stub into `decoded` (lines 59–65) and
evaluates the new condition at `scripts/compliance-audit.sh:1567-1577`: the RING path
calls `ring_major_form_acceptable "$decoded" "$reusable" "$chan" "$repo"`, which only
accepts `uses:` refs in major-scoped `<base>/v<M>-<tier>` form (implementation at
`scripts/compliance-audit.sh:1470-1483`), so a bare `auto-rebase/stable` pin is rejected
and the `if` falls through, producing a `non-stub-*.yml` drift finding even though the
stub matches the bare-tier ring channel.

4. Deploy the same stub via `scripts/deploy-standard-workflows.sh`: `is_already_compliant`
at `scripts/deploy-standard-workflows.sh:287-323` computes
`major="$(ring_host_current_major "$host" "$base")"` and, when the agent has no current
major (`major` empty), executes the `if [[ -z "$major" ]]` block at lines 55–62 to treat
any bare-tier ref from `ring_accepted_refs "$base" "$repo"` (defined in
`scripts/lib/ring-pins.sh:46-63`) as compliant, so the deploy sweep leaves the bare-tier
stub unchanged while the audit continues to flag it as non-compliant.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

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

**Path:** scripts/compliance-audit.sh
**Line:** 1575:1578
**Comment:**
	*Api Mismatch: The new ring-only acceptance path unconditionally rejects bare `<base>/<tier>` pins, but deploy logic still treats bare pins as compliant when an agent has no release major yet. This creates an audit/deploy contract split where audit reports unavoidable drift that deploy will not fix. Align this check with deploy by allowing bare-tier ring pins when no current major exists for that reusable host.

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
👍 | 👎

Comment on lines +1638 to 1641
if ! printf '%s\n' "$decoded" | grep -qE "^[[:space:]]*uses:[[:space:]]*petry-projects/\\.github-private/\\.github/workflows/dev-lead-reusable\\.yml@dev-lead/v[0-9]+-(stable|next|ring[0-9]+)([[:space:]]|$)"; then
add_finding "$repo" "ci-workflows" "dev-lead-stub-pin" "error" \
"The \`dev-lead.yml\` caller stub must pin a \`dev-lead\` channel tag — \`petry-projects/.github-private/.github/workflows/dev-lead-reusable.yml@dev-lead/<channel>\` where <channel> is \`stable\` (default), \`next\`, or \`ring<N>\`. Re-sync from \`standards/workflows/dev-lead.yml\`." \
"The \`dev-lead.yml\` caller stub must pin a major-scoped \`dev-lead\` channel tag — \`petry-projects/.github-private/.github/workflows/dev-lead-reusable.yml@dev-lead/v<M>-<channel>\` where <channel> is \`stable\` (default), \`next\`, or \`ring<N>\` (a bare \`dev-lead/<channel>\` tier pin is drift). Re-sync from \`standards/workflows/dev-lead.yml\`." \
"standards/ci-standards.md#dev-lead-agent"

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 check now requires dev-lead/v<M>-<channel> unconditionally, but deployment still emits/accepts bare dev-lead/<channel> when no release major exists. That makes dev-lead.yml impossible to satisfy in no-release states and creates recurring compliance failures. Gate the strict v-form requirement on detected current major (or mirror deploy’s no-major fallback). [api mismatch]

Severity Level: Major ⚠️
- ⚠️ Dev-lead stubs can fail compliance before first release.
- ⚠️ Deploy and audit disagree on dev-lead pin format.
- ⚠️ Teams face persistent dev-lead ci-workflows findings pre-release.
Steps of Reproduction ✅
1. Run `scripts/compliance-audit.sh` so that the main audit loop at
`scripts/compliance-audit.sh:2835-2860` evaluates each repository and calls
`check_dev_lead_stub "$repo"` for non-meta repos (definition at
`scripts/compliance-audit.sh:1615-1780`).

2. In a non-meta repo that has adopted dev-lead, ensure `.github/workflows/dev-lead.yml`
is pinned to the legacy bare-tier channel that deployment emits when no release major
exists, e.g. `uses:
petry-projects/.github-private/.github/workflows/dev-lead-reusable.yml@dev-lead/stable`;
this is what `emit_ref_for` in `scripts/deploy-standard-workflows.sh:103-115` produces
when `ring_host_current_major` returns an empty major for dev-lead.

3. `check_dev_lead_stub` fetches and decodes the stub (lines 124–128) and then evaluates
the new pin rule at `scripts/compliance-audit.sh:136-142`: the `grep -qE` condition only
accepts `uses:` lines of the form `@dev-lead/v[0-9]+-(stable|next|ring[0-9]+)`, so any
bare `dev-lead/<channel>` pin is rejected and `add_finding` is invoked, yielding a
`ci-workflows/dev-lead-stub-pin` error that cannot be resolved while deployment continues
to emit bare-tier pins in no-major states.

4. If a maintainer attempts to satisfy the audit by pinning `@dev-lead/vM-stable` before
any `dev-lead/vM.*` tags exist on the host (`petry-projects/.github-private`), the next
run of `scripts/deploy-standard-workflows.sh` treats that v-form as drift:
`is_already_compliant` (lines 287–323) calls `ring_host_current_major`, sees `major`
empty, and only accepts bare-tier refs from `ring_accepted_refs`, so the deploy sweep
rewrites the stub back to `dev-lead/<channel>`, causing an oscillation where dev-lead.yml
cannot simultaneously pass both deploy and audit in a no-release-major state.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

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

**Path:** scripts/compliance-audit.sh
**Line:** 1638:1641
**Comment:**
	*Api Mismatch: This check now requires `dev-lead/v<M>-<channel>` unconditionally, but deployment still emits/accepts bare `dev-lead/<channel>` when no release major exists. That makes `dev-lead.yml` impossible to satisfy in no-release states and creates recurring compliance failures. Gate the strict v-form requirement on detected current major (or mirror deploy’s no-major fallback).

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
👍 | 👎

Comment on lines +315 to +321
host="$(cut -d/ -f1-2 <<< "$prefix")"
major="$(ring_host_current_major "$host" "$base")"
if [[ -z "$major" ]]; then
local ref
while IFS= read -r ref; do
[[ -n "$ref" ]] && grep -qF "${prefix}@${ref}" <<< "$existing_content" && return 0
done < <(ring_accepted_refs "$base" "$repo")

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 bare-tier grace is keyed only on major being empty, but major is also empty when ring_host_current_major fails to query tags (it returns empty on API failure). That means transient GH/API errors can incorrectly mark bare stubs as compliant and skip required re-pins. Differentiate “no releases found” from “lookup failed” (e.g., by status code/explicit sentinel) before allowing this grace path. [incorrect condition logic]

Severity Level: Major ⚠️
- ⚠️ Major-scoped migration can silently skip some stubs.
- ⚠️ Bare-tier pins may persist after releases due to API errors.
- ⚠️ Drift detection during deploy becomes sensitive to transient failures.
Steps of Reproduction ✅
1. Run `scripts/deploy-standard-workflows.sh` to perform a standards deployment sweep; for
each centralized workflow, the deploy logic calls `is_already_compliant
"$existing_content" "$template" "$repo"` defined at
`scripts/deploy-standard-workflows.sh:287-323` to decide whether the stub in a target repo
needs re-pinning.

2. For a ring-managed reusable whose template `uses:` line points at a channel ref
(matched by the `[[ "$ref_after" =~ ^${base}/(v[0-9]+-)?(stable|next|ring[0-9]+)$ ]]`
condition at `scripts/deploy-standard-workflows.sh:42-50`), control enters the ring
branch, and `host="$(cut -d/ -f1-2 <<< "$prefix")"` and `major="$(ring_host_current_major
"$host" "$base")"` are computed at lines 55–57.

3. `ring_host_current_major` is implemented in `scripts/lib/ring-pins.sh:14-29` and calls
`gh api "repos/${host}/git/matching-refs/tags/${base}/v" --jq '.[]?.ref'`; on any
GitHub/API failure (network, auth, or rate limiting) the `gh api` command exits non-zero,
the `|| { ...; return 0; }` handler runs, it prints a warning and returns success with no
output, so `major` is set to the empty string exactly as in the legitimate “no tags exist
yet” case.

4. When `major` is empty due to this lookup failure, the `if [[ -z "$major" ]]` block at
`scripts/deploy-standard-workflows.sh:58-62` executes the bare-tier grace path: it
iterates over `ring_accepted_refs "$base" "$repo"` (defined in
`scripts/lib/ring-pins.sh:46-63`) and returns 0 as soon as it finds a matching bare-tier
ref in `existing_content`, marking the stub “already compliant” and skipping the intended
re-pin to a `v<M>-<tier>` channel even though the agent actually has published releases
and should be migrated.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

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

**Path:** scripts/deploy-standard-workflows.sh
**Line:** 315:321
**Comment:**
	*Incorrect Condition Logic: The bare-tier grace is keyed only on `major` being empty, but `major` is also empty when `ring_host_current_major` fails to query tags (it returns empty on API failure). That means transient GH/API errors can incorrectly mark bare stubs as compliant and skip required re-pins. Differentiate “no releases found” from “lookup failed” (e.g., by status code/explicit sentinel) before allowing this grace path.

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
👍 | 👎

don-petry added a commit that referenced this pull request Aug 7, 2026
…deploy compliance v<M>-stable-aware (flag bare tags) (#863)

Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
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.

[#850 Phase 1b] Make compliance audit + deploy compliance v<M>-stable-aware (flag bare tags)

3 participants