-
Notifications
You must be signed in to change notification settings - Fork 0
governance: org-required-workflows 钉点落盘 + 双轨 required + §15 对账(P3-1,ADR-0046,#95) #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
33c6e37
a90ef51
c55961b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -577,6 +577,48 @@ for r in $REPOS; do | |
| done | ||
| [[ $STUCK_TOTAL -eq 0 ]] && ok "pr-liveness(全部受管仓 open PR 无卡死,阈值 ${LIVENESS_H}h)" | ||
|
|
||
| # ---------- 15. org-required-workflows 钉点完整性(P3-1 #95 / ADR-0046)---------- | ||
| # §1 已对账 ruleset JSON 文本(path/ref/repository_id 任何改动即漂移)。本节补盲区: | ||
| # ref 为 tag 时,tag 指针被移动(ruleset 文本不变、内容换了)——钉点的 commit 绑定 | ||
| # 必须与 expected-state.org_required_workflows.ref_commit 一致;钉点 tag 还必须是 | ||
| # CI-Workflows 当前发布不变式(§11:vN==最高 vN.x.y)认可的物。fail-closed。 | ||
| ORW_CFG=$(jq -c '.org_required_workflows // empty' "$EXPECTED") | ||
| if [[ -n "$ORW_CFG" ]]; then | ||
| WANT_RULESET=$(jq -r '.ruleset' <<<"$ORW_CFG") | ||
| WANT_REPO_ID=$(jq -r '.repository_id' <<<"$ORW_CFG") | ||
| WANT_PATH=$(jq -r '.path' <<<"$ORW_CFG") | ||
| WANT_REF=$(jq -r '.ref' <<<"$ORW_CFG") | ||
| WANT_COMMIT=$(jq -r '.ref_commit' <<<"$ORW_CFG") | ||
| ORW_LIST=$(api "https://api.github.com/orgs/$ORG/rulesets?per_page=100") | ||
| ORW_ROW=$(jq -c --arg n "$WANT_RULESET" '.[] | select(.name == $n)' <<<"$ORW_LIST" 2>/dev/null) | ||
| if [[ -z "$ORW_ROW" || "$ORW_ROW" == "null" ]]; then | ||
| drift "org-required-workflows ruleset '$WANT_RULESET' 线上不存在——中心审判失效,全部受管仓回落本地 gate(P3-1 枢轴脱离,ADR-0046)" | ||
| else | ||
| GOT_WF=$(jq -c '.rules[] | select(.type == "workflows") | .parameters.workflows[0] // empty' <<<"$ORW_ROW") | ||
| GOT_PATH=$(jq -r '.path // empty' <<<"$GOT_WF") | ||
| GOT_REF=$(jq -r '.ref // empty' <<<"$GOT_WF") | ||
| GOT_REPO_ID=$(jq -r '.repository_id // empty' <<<"$GOT_WF") | ||
| BAD="" | ||
| [[ "$GOT_PATH" == "$WANT_PATH" ]] || BAD="$BAD path=$GOT_PATH" | ||
| [[ "$GOT_REF" == "$WANT_REF" ]] || BAD="$BAD ref=$GOT_REF" | ||
| [[ "$GOT_REPO_ID" == "$WANT_REPO_ID" ]] || BAD="$BAD repository_id=$GOT_REPO_ID" | ||
| if [[ -n "$BAD" ]]; then | ||
| drift "org-required-workflows 钉点漂移:$BAD(期望 path=$WANT_PATH ref=$WANT_REF repo_id=$WANT_REPO_ID)——审判源被改指(ADR-0046 §15)" | ||
| fi | ||
| # tag 解引用 → commit 绑定(tag 移动而 ruleset 文本不变的情形) | ||
| SHORTREF="${WANT_REF#refs/tags/}" | ||
| TAGROW=$(api "https://api.github.com/repos/$ORG/CI-Workflows/git/ref/tags/$SHORTREF") | ||
| TAGCOMMIT=$(jq -r '.object.sha // empty' <<<"$TAGROW") | ||
| if [[ -z "$TAGCOMMIT" ]]; then | ||
| drift "org-required-workflows 钉点 tag $WANT_REF 解引用失败(fail-closed,ADR-0046 §15)" | ||
| elif [[ "$TAGCOMMIT" != "$WANT_COMMIT" ]]; then | ||
| drift "org-required-workflows 钉点 tag $WANT_REF 已移动:${TAGCOMMIT:0:8} ≠ 声明 ${WANT_COMMIT:0:8}——审判内容被换(ADR-0046 §15;还原或走发布流程+expected-state 更新)" | ||
|
Comment on lines
+610
to
+615
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
ORG="${ORG:-Cloudbird-Software}"
CFG="governance/expected-state.json"
REPO="$(jq -r '.org_required_workflows.repository' "$CFG")"
REF="$(jq -r '.org_required_workflows.ref' "$CFG")"
WANT="$(jq -r '.org_required_workflows.ref_commit' "$CFG")"
TAG="${REF#refs/tags/}"
ROW="$(curl -fsS \
-H "Authorization: Bearer ${GH_TOKEN:?需要 GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$ORG/$REPO/git/ref/tags/$TAG")"
TYPE="$(jq -r '.object.type' <<<"$ROW")"
SHA="$(jq -r '.object.sha' <<<"$ROW")"
if [[ "$TYPE" == "tag" ]]; then
ACTUAL="$(curl -fsS \
-H "Authorization: Bearer "$GH_TOKEN \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$ORG/$REPO/git/tags/$SHA" | jq -r '.object.sha')"
else
ACTUAL="$SHA"
fi
printf 'type=%s actual=%s expected=%s\n' "$TYPE" "$ACTUAL" "$WANT"
test "$ACTUAL" = "$WANT"Repository: Cloudbird-Software/.github Length of output: 274 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- relevant function and call sites ---'
rg -n -A35 -B8 'cw_commit_sha|TAGROW|TAGCOMMIT|SHORTREF' governance/drift-check.sh
printf '%s\n' '--- declared reference ---'
jq -r '.org_required_workflows | {repository, ref, ref_commit}' governance/expected-state.jsonRepository: Cloudbird-Software/.github Length of output: 4988 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
cat -n governance/drift-check.sh | sed -n '350,430p;560,620p'
printf '%s\n' '--- relevant API and expected-state references ---'
rg -n -A8 -B8 'CW_REFS|org_required_workflows|git/ref/tags|git/tags' governance/drift-check.sh governance/expected-state.jsonRepository: Cloudbird-Software/.github Length of output: 16376 修复注释 tag 的 commit 解引用。 当 🤖 Prompt for AI Agents
Comment on lines
+610
to
+615
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Annotated tags compare incorrectly §15 compares the first-level ref object SHA directly with ref_commit; for an annotated tag this is the tag-object SHA, not the commit SHA, so a valid pin is reported as drift. Existing §11 already implements the required type check and tag-object dereference. Agent Prompt
|
||
| else | ||
| ok "org-required-workflows 钉点完整($WANT_REF == ${TAGCOMMIT:0:8},path/repository_id 一致)" | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| echo "----------------------------------------" | ||
| if [[ $DRIFTS -gt 0 ]]; then | ||
| echo "结果: $DRIFTS 项漂移。修复: bash governance/apply.sh 或手动改回" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,9 +54,12 @@ | |
| "required_status_checks": [ | ||
| { | ||
| "context": "gate" | ||
| }, | ||
| { | ||
| "context": "org-gate" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "name": "org-required-workflows", | ||
| "target": "branch", | ||
| "enforcement": "active", | ||
| "conditions": { | ||
| "ref_name": { | ||
| "include": [ | ||
| "~DEFAULT_BRANCH" | ||
| ], | ||
| "exclude": [] | ||
| }, | ||
| "repository_name": { | ||
| "include": [ | ||
| "~ALL" | ||
| ], | ||
| "exclude": [] | ||
| } | ||
| }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Empty bypass list mismatches The new ruleset omits bypass_actors, so desired-state normalization produces null while the authenticated GitHub detail response produces an empty array when no actors exist. Exact comparison therefore continually reports this newly applied ruleset as drift. Agent Prompt
|
||
| "rules": [ | ||
| { | ||
| "type": "workflows", | ||
| "parameters": { | ||
| "workflows": [ | ||
| { | ||
| "path": ".github/workflows/org-gate.yml", | ||
| "ref": "refs/tags/v1.4.1", | ||
| "repository_id": 1337911551 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4. Declared repository is ignored
🐞 Bug⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools