diff --git a/.github/workflows/gate.yml b/.github/workflows/gate.yml index d47a71c..2daa540 100644 --- a/.github/workflows/gate.yml +++ b/.github/workflows/gate.yml @@ -37,8 +37,11 @@ jobs: NEEDS: ${{ toJSON(needs) }} run: | echo "$NEEDS" - if echo "$NEEDS" | jq -e '[to_entries[] | select(.value.result != "success" and .value.result != "skipped")] | length > 0' >/dev/null; then - echo "::error::hygiene 未通过"; exit 1 + # P1-3(ADR-0032):skipped ≠ success——官方行为下 skipped job 上报 Success, + # 即使 required 也不拦合并;gate 是唯一 required check,必须显式断言每个 + # needs 的 result == "success",skipped/cancelled/failure/startup_failure 全红 + if echo "$NEEDS" | jq -e '[to_entries[] | select(.value.result != "success")] | length > 0' >/dev/null; then + echo "::error::hygiene 未通过(skipped 不算绿——ADR-0032 严格断言)"; exit 1 fi - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -166,4 +169,4 @@ jobs: if [[ $MISSING -eq 0 ]]; then echo "OK adr-required: $( { echo "$PR_TITLE"; echo "$PR_BODY"; } | grep -oE "$ADR_RE" | sort -u | tr '\n' ' ')(存在性已验;实体性后验:drift-check §10)" fi - exit $MISSING + exit $MISSING \ No newline at end of file diff --git a/.github/workflows/governance-drift.yml b/.github/workflows/governance-drift.yml index 221ea04..08bc530 100644 --- a/.github/workflows/governance-drift.yml +++ b/.github/workflows/governance-drift.yml @@ -28,6 +28,11 @@ jobs: env: GH_TOKEN: ${{ secrets.GOVERNANCE_TOKEN }} run: | + # pipefail(ADR-0032,P1-3):Actions 默认 shell(bash -e 无 pipefail)下 + # `drift-check | tee` 的退出码被 tee 吞掉——漂移检出时本步骤仍 success, + # 下方 if: failure() 的开 issue 分支从不触发(run 32331351942 实证)。 + # GM-1 报警机制依赖本步骤真实变红。 + set -o pipefail if [[ -z "$GH_TOKEN" ]]; then echo "::error::缺 org secret GOVERNANCE_TOKEN(需 org admin token)。设置: 组织 Settings → Secrets and variables → Actions → New organization secret" >&2 exit 2 @@ -101,4 +106,4 @@ jobs: gh issue comment "$NUM" --repo "$REPO" --body "漂移已消除(运行 #${{ github.run_id }} 全绿)。自动关闭;如复现将重新开启新报告。" gh issue close "$NUM" --repo "$REPO" --reason completed echo "closed #$NUM" - done + done \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md index 9712e86..22b127e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,5 +26,5 @@ AI agent 进入本仓的工作契约(索引型,CG-1;细节按需读引用 | 语言/依赖政策 | governance/policy/languages.yaml | | 测试政策 | governance/policy/testing.yaml | | agent 标准 schema | standards/agent/*.schema.yaml | -| bot/agent 反馈通道规范(禁 review thread) | standards/automation/bot-channels.md | -| 原型 profiles / 注册条目 | Cloudbird-Software/agent-registry | +| 自动化规范(CI 链路 / bot 反馈通道,ADR-0031/0032) | standards/automation/ | +| 原型 profiles / 注册条目 | Cloudbird-Software/agent-registry | \ No newline at end of file diff --git a/standards/automation/required-check-chains.md b/standards/automation/required-check-chains.md new file mode 100644 index 0000000..d8f5099 --- /dev/null +++ b/standards/automation/required-check-chains.md @@ -0,0 +1,37 @@ +# Required check 链路规范(路径过滤与结构性跳过) + +ADR-0032(自动合并计划 P1-3,#81 §3.1/§3.2)。适用对象:组织内全部仓库的 +GitHub Actions workflow。 + +## 规则 1:required 链路上的 workflow 禁用 workflow 级 `paths:` / `paths-ignore:` + +被 ruleset 声明为 required check 的 workflow(当前唯一 required = `gate`, +BP-2)**不得**在 `on:` 层使用 `paths:` / `paths-ignore:` 过滤——路径不匹配时 +check 完全不产生,PR 永久 pending,或 ruleset 静默匹配为空导致裸奔合并。 + +路径过滤只能用于非 required 的建议性 workflow,并须在本文件豁免清单登记理由。 + +## 规则 2:aggregator 严格断言,结构性跳过须显式登记 + +gate aggregator 断言为严格 `result == "success"`——skipped、cancelled、 +failure、timed_out、startup_failure 一律红。事件互补设计(如 `deps` 仅 PR +事件、`deps-audit` 仅 push 事件)产生的**结构性预期跳过**,须在 aggregator +步骤内以 `EXPECTED_SKIP[事件]` 白名单显式登记;未登记的 skipped 一律红 +(fail-closed 方向)。merge queue(P2-7)接入 `merge_group` 事件时同步扩充。 + +## 规则 3:安全 job 永远不许无条件 skip + +hygiene(gitleaks 全历史凭据扫描、zizmor 工作流安全审计)等安全类 job 不 +存在合法的永久跳过路径(`if: false` 禁止);事件互补必须保证两个事件面都 +有安全覆盖。任何"跳过安全检查"的诉求都须先以 ADR 修订本规范。 + +## 豁免清单(非 required workflow 的 workflow 级路径过滤) + +| 仓库 / workflow | 用途 | 理由 | +|---|---|---| +| AI_Web_School `contract.yml`(contract-watch) | 冻结契约变更检测(P5 建议性检测) | 非 required check(该仓唯一 required = gate);paths 过滤省 runner,契约无关 PR 本就无检测意义 | + +## 执法 + +- 静态扫描基线(T4,2026-08-20 全 11 仓):required 链路零 workflow 级路径 + 过滤,唯一豁免如上。P1-4(#85)落地后将此扫描纳入 drift-check 例行对账。 \ No newline at end of file