Skip to content

fix: canary C6 政策调和——@vN 与 zizmor SHA 钉扎的双合法形态(ADR-0022) - #33

Merged
randypanding merged 1 commit into
mainfrom
canary-c6-harmonize
Aug 19, 2026
Merged

fix: canary C6 政策调和——@vN 与 zizmor SHA 钉扎的双合法形态(ADR-0022)#33
randypanding merged 1 commit into
mainfrom
canary-c6-harmonize

Conversation

@randypanding

Copy link
Copy Markdown
Contributor

问题

ADR-0021 批次内两项政策互撞,canary 周期运行实证(run 32234849030):

  • .github gate.yml 为过 zizmor unpinned-uses(blanket 钉扎政策)把 hygiene 引用从 @v1 改钉 40-hex SHA;
  • canary C6 原逻辑只认 @vN → 政策合法的修复被自己周期回路判红。

修复(调和为双合法形态)

组织 reusable workflow(CI-Workflows/*)引用接受:

  1. @vN 大版本指针(版本策略既有形态);
  2. 40-hex SHA 且命中某个 vN tag 实际指向的 commit(版本化钉扎)——满足 zizmor blanket 政策的同时保留版本语义,且比 @vn 更强(不可变+可审计)。SHA 未命中任何 vN tag 仍判红(防止钉到任意中间 commit 绕过发布流程)。

tag 解析含 annotated tag 解引用(git/ref → type=tag 时跟到 commit)。

验证

  • 本地实跑 canary:政策冲突项转绿;唯一残留为 template-service 39 位截断 SHA(PR template-service#13 修复中,canary 抓到的真 bug)。

ADR-0021 ADR-0022

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 16 minutes

Limit details: You’ve used all 3 included reviews currently available.

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 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: CHILL

Plan: Pro Plus

Run ID: 478df9e0-9ed0-400a-8a2a-7c6d20269cae

📥 Commits

Reviewing files that changed from the base of the PR and between f5d88e8 and 6adab10.

📒 Files selected for processing (1)
  • scripts/canary.py

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Harmonize C6 reusable workflow version pinning

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Accepts reusable workflows pinned by major tags or release-associated commit SHAs.
• Dereferences annotated tags before validating pinned commits against published versions.
• Rejects arbitrary or malformed SHAs while preserving fail-closed canary behavior.
Diagram

graph TD
  A["C6 Scanner"] --> B{"Org Workflow?"} -- Yes --> D{"Version Form?"} -- "40-hex" --> F["GitHub Tags API"] --> G{"Tag Commit?"} -- Yes --> E["Accept"]
  B -- No --> C{"40-hex SHA?"} -- No --> H["Policy Failure"]
  C -- Yes --> E
  D -- "@vN" --> E
  D -- Other --> H
  G -- No --> H
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Allow any full SHA
  • ➕ Avoids tag API lookups
  • ➕ Fully satisfies immutable pinning requirements
  • ➖ Permits unreleased intermediate commits
  • ➖ Removes the CI-Workflows version-policy guarantee
2. Require major tags only
  • ➕ Keeps version semantics simple
  • ➕ Avoids runtime tag-to-commit validation
  • ➖ Conflicts with zizmor blanket SHA-pinning policy
  • ➖ Major tags remain mutable
3. Maintain an approved SHA manifest
  • ➕ Avoids live GitHub tag resolution
  • ➕ Makes approved releases explicit and reviewable
  • ➖ Introduces duplicated release metadata
  • ➖ Requires updates whenever major tags move or releases change

Recommendation: Keep the PR’s dual-form validation. It reconciles existing major-version compatibility with immutable zizmor-compliant pins while preventing arbitrary commits from bypassing the release process; live tag resolution also avoids maintaining a duplicated approval manifest.

Files changed (1) +48 / -3

Bug fix (1) +48 / -3
canary.pyAccept release-associated SHA pins in C6 +48/-3

Accept release-associated SHA pins in C6

• Extends C6 to accept organization reusable workflows referenced by either @vN or a full SHA matching a vN tag commit. Adds GitHub tag discovery, annotated-tag dereferencing, lazy loading, and explicit failures for arbitrary or malformed references.

scripts/canary.py

@randypanding
randypanding merged commit 4916e86 into main Aug 19, 2026
10 checks passed
@randypanding
randypanding deleted the canary-c6-harmonize branch August 19, 2026 09:10
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. C4 rejects allowed SHA 🐞 Bug ≡ Correctness
Description
check_c6() now accepts version-tagged SHAs, but check_c4() still requires template-service
reusable workflows to contain @v. Pinning those workflows to a valid vN tag commit therefore
satisfies C6 but always fails C4, leaving the policy conflict unresolved for template-service.
Code

scripts/canary.py[R221-223]

+                    if re.fullmatch(r"v[0-9]+", ver):
+                        continue
+                    if re.fullmatch(r"[0-9a-f]{40}", ver):
Relevance

●●● Strong

C4 contradicts PR #33's explicitly intended dual SHA/@vN policy.

PR-#30
PR-#33

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
C4 searches each required template-service workflow reference for the literal @v, while the
changed C6 branch explicitly admits 40-hex SHA references. Since all checks run in sequence, a SHA
accepted by C6 remains rejected by C4.

scripts/canary.py[123-126]
scripts/canary.py[221-235]

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

## Issue description
C6 accepts either an `@vN` reference or a 40-hex SHA matching a vN tag, while C4 still accepts only textual `@vN` references for template-service. A policy-compliant SHA pin consequently fails the overall canary.

## Issue Context
Apply the same reusable-workflow reference policy consistently across C4 and C6. Avoid duplicating the validation logic if possible.

## Fix Focus Areas
- scripts/canary.py[123-126]
- scripts/canary.py[221-235]

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



Remediation recommended

2. Tag pagination omits releases 🐞 Bug ☼ Reliability
Description
ciw_version_tag_shas() fetches only the first 100 repository tags, so valid vN tags on later pages
are absent from the allowlist. Once CI-Workflows exceeds that limit, workflows pinned to an omitted
release SHA are incorrectly rejected.
Code

scripts/canary.py[170]

+    tags = fetch_json(f"{API}/repos/{ORG}/CI-Workflows/tags?per_page=100")
Relevance

●●● Strong

Recent PR #10 accepted the identical GitHub-list pagination omission fix.

PR-#10

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper makes one per_page=100 request and then treats its result as the complete legal SHA
set. GitHub documents that the list-tags endpoint returns at most 100 entries per page and exposes a
page parameter; the repository's own C3 logic also recognizes that a 100-item response may be
truncated.

scripts/canary.py[167-188]
scripts/canary.py[106-110]
🌐 GitHub documents that List repository tags is paginated, with per_page capped at 100 and page selecting subsequent result pages.
PR-#10

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

## Issue description
The GitHub tags endpoint is paginated with a maximum of 100 results per page, but `ciw_version_tag_shas()` reads only page one. This makes the purported complete vN SHA set incomplete.

## Issue Context
Fetch successive pages until exhaustion, preserving fail-closed behavior if any page cannot be retrieved. A guarded failure when the page limit is reached would be safer than silently accepting an incomplete set.

## Fix Focus Areas
- scripts/canary.py[167-188]

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


Grey Divider

Context sources
✅ Compliance rules (platform): 11 rules
✅ Web pages:
  +2 more
Review mode: ⚖️ Balanced: This modifies governance enforcement with GitHub API/tag-resolution behavior and fail-closed semantics, so it warrants a complete review.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread scripts/canary.py
Comment on lines +221 to +223
if re.fullmatch(r"v[0-9]+", ver):
continue
if re.fullmatch(r"[0-9a-f]{40}", ver):

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. C4 rejects allowed sha 🐞 Bug ≡ Correctness

check_c6() now accepts version-tagged SHAs, but check_c4() still requires template-service
reusable workflows to contain @v. Pinning those workflows to a valid vN tag commit therefore
satisfies C6 but always fails C4, leaving the policy conflict unresolved for template-service.
Agent Prompt
## Issue description
C6 accepts either an `@vN` reference or a 40-hex SHA matching a vN tag, while C4 still accepts only textual `@vN` references for template-service. A policy-compliant SHA pin consequently fails the overall canary.

## Issue Context
Apply the same reusable-workflow reference policy consistently across C4 and C6. Avoid duplicating the validation logic if possible.

## Fix Focus Areas
- scripts/canary.py[123-126]
- scripts/canary.py[221-235]

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

Comment thread scripts/canary.py
def ciw_version_tag_shas() -> set[str]:
"""CI-Workflows 全部 vN 大版本 tag 指向的 commit SHA 集(含 annotated tag 解引用)。"""
shas: set[str] = set()
tags = fetch_json(f"{API}/repos/{ORG}/CI-Workflows/tags?per_page=100")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Tag pagination omits releases 🐞 Bug ☼ Reliability

ciw_version_tag_shas() fetches only the first 100 repository tags, so valid vN tags on later pages
are absent from the allowlist. Once CI-Workflows exceeds that limit, workflows pinned to an omitted
release SHA are incorrectly rejected.
Agent Prompt
## Issue description
The GitHub tags endpoint is paginated with a maximum of 100 results per page, but `ciw_version_tag_shas()` reads only page one. This makes the purported complete vN SHA set incomplete.

## Issue Context
Fetch successive pages until exhaustion, preserving fail-closed behavior if any page cannot be retrieved. A guarded failure when the page limit is reached would be safer than silently accepting an incomplete set.

## Fix Focus Areas
- scripts/canary.py[167-188]

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant