From 812c7923bafbc674f0384734ec042a369f051d3c Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 20:17:04 -0600 Subject: [PATCH 1/2] ci: add ci-policy agreement checker (#7090) Adds the Phase 1 agreement contract: the tier-to-trigger mapping and the production-line-guard row in .github/ci-policy.md, a pure-bash checker with contract tests, explicit Phase 2-3 waivers for #6929/#6953/#6959/#6981, and workflow-lint wiring. No workflow is re-armed or retired. --- .github/ci-policy-waivers.txt | 38 +++ .github/ci-policy.md | 53 +++ .github/scripts/check-ci-policy-agreement.sh | 306 ++++++++++++++++++ .../scripts/check-ci-policy-agreement.test.sh | 272 ++++++++++++++++ .github/workflows/workflow-lint.yml | 15 + 5 files changed, 684 insertions(+) create mode 100644 .github/ci-policy-waivers.txt create mode 100755 .github/scripts/check-ci-policy-agreement.sh create mode 100755 .github/scripts/check-ci-policy-agreement.test.sh diff --git a/.github/ci-policy-waivers.txt b/.github/ci-policy-waivers.txt new file mode 100644 index 0000000000..42d7628fcf --- /dev/null +++ b/.github/ci-policy-waivers.txt @@ -0,0 +1,38 @@ +# CI policy agreement waivers (Phase 2–3 of design #7089). +# +# Format: +# leg is basic | main | nightly +# +# Each waiver names the live phase issue that owns the disagreement. +# The checker requires every issue here to be one of the four Phase 2–3 +# issues below and to be open: closing an issue retires its waiver in +# the same change. A waiver for a workflow no longer in disagreement +# fails as stale. +# +# Phase 2: +# #6929 mcpx-fix-test-guard — dispatch-only; basic + main triggers gone +# #6953 opencode-config-guard — PR-only; main trigger gone +# Phase 3: +# #6959 production-line-guard — dispatch-only; basic + main triggers gone +# #6981 go-modules-build, identity-build, map-build, mcpx-nixbuild — +# dispatch-only; basic + main triggers gone + +.github/workflows/mcpx-fix-test-guard.yml basic #6929 +.github/workflows/mcpx-fix-test-guard.yml main #6929 + +.github/workflows/opencode-config-guard.yml main #6953 + +.github/workflows/production-line-guard.yml basic #6959 +.github/workflows/production-line-guard.yml main #6959 + +.github/workflows/go-modules-build.yml basic #6981 +.github/workflows/go-modules-build.yml main #6981 + +.github/workflows/identity-build.yml basic #6981 +.github/workflows/identity-build.yml main #6981 + +.github/workflows/map-build.yml basic #6981 +.github/workflows/map-build.yml main #6981 + +.github/workflows/mcpx-nixbuild.yml basic #6981 +.github/workflows/mcpx-nixbuild.yml main #6981 diff --git a/.github/ci-policy.md b/.github/ci-policy.md index b61f18797b..9342107852 100644 --- a/.github/ci-policy.md +++ b/.github/ci-policy.md @@ -97,6 +97,36 @@ service rehomed as `fleet serve search`) to the same rule, with its own pinned headers. Intentional changes land in both copies in the same PR; intentional header changes update the guard script in the same PR. +## Policy-to-trigger agreement contract (#7090) + +A tier assignment in the table below is a promise about triggers, not +just a label. The agreement checker +(`.github/scripts/check-ci-policy-agreement.sh`, mounted in +`workflow-lint.yml`) enforces this mapping for every workflow named in +the `workflow` column of the guard/build rows below: + +- **basic (PR) tier** — satisfied by `pull_request`, with the same + path filter the check needs (`paths:` in the `pull_request` block). + A path-filtered `pull_request` trigger is the active PR venue in this + repo. `merge_group` is not active: the no-merge-queue ruling above + removed it, and this phase must not re-add it. +- **main tier** — satisfied by `push:` with `branches:` containing + `main`, or by a named main-tier venue that runs the same check. +- **nightly** — satisfied by a `schedule:` trigger. +- `workflow_dispatch:` alone satisfies no tier. It may be present + alongside a tier trigger, but it never substitutes for one. +- A workflow named in the table must exist. A row naming a workflow + that is not on disk is a policy defect, regardless of any waiver. + +Known Phase 2–3 disagreements are recorded as explicit waivers in +`.github/ci-policy-waivers.txt`, each naming its live phase issue and +the missing leg it covers. A waiver whose issue is no longer open fails +the checker; a missing or unknown waiver fails it too. The four live +phases are #6929 (`mcpx-fix-test-guard`), #6953 +(`opencode-config-guard`), #6959 (`production-line-guard`), and #6981 +(the four build workflows). This phase adds the checker only; it does +not re-arm, retire, or re-enable any workflow. + ## Workflow and composite-action validation (#5743) `.github/workflows/workflow-lint.yml` is a **basic-tier** check @@ -176,6 +206,29 @@ main-breakage rate (issues labelled `main-broken`) proves out. | mcpx test (#1998) | init + unit + lint + 6 static e2e shards + ci-ok (PR tier, non-draft PRs) | same full sharded suite on push to main | — (main covers it) | | mcpx fix-test guard (#1969) | fix PRs touching `pkgs/mcpx/**` must carry a test or a `No test: ` attestation (basic tier) | contract tests for the guard script only | — | +### Agreement-tracked guard/build rows (#7090) + +This table is the normative, machine-checked form for the seven +guard/build workflows in Phase 1 of design #7089. Where the summary +table above and this table differ for those workflows, this table +wins. The `workflow` cell is the file ci-policy promises; the checker +reads only this table. `basic`, `main`, and `nightly` are the promised +tiers; `PR gate` names one representative glob that must remain in the +workflow's `pull_request.paths` (a declared path under that glob +satisfies it; `-` means no path gate); `waiver` names the live Phase 2–3 +issue that currently covers the disagreement. `workflow_dispatch` is +never a tier. + +| workflow | basic | main | nightly | PR gate | waiver | +| --- | --- | --- | --- | --- | --- | +| `.github/workflows/mcpx-fix-test-guard.yml` | yes | yes | no | `pkgs/mcpx/**` | #6929 | +| `.github/workflows/opencode-config-guard.yml` | yes | yes | no | - | #6953 | +| `.github/workflows/production-line-guard.yml` | yes | yes | no | `pkgs/**` | #6959 | +| `.github/workflows/go-modules-build.yml` | yes | yes | no | `pkgs/chat/**` | #6981 | +| `.github/workflows/identity-build.yml` | yes | yes | no | `pkgs/identity/**` | #6981 | +| `.github/workflows/map-build.yml` | yes | yes | no | `pkgs/map/**` | #6981 | +| `.github/workflows/mcpx-nixbuild.yml` | yes | yes | no | `pkgs/mcpx/**` | #6981 | + ## Coverage rule Nothing removed from PRs may vanish: the union of main-tier + diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh new file mode 100755 index 0000000000..27a8511e84 --- /dev/null +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -0,0 +1,306 @@ +#!/usr/bin/env bash +# check-ci-policy-agreement.sh — fail when ci-policy's tier promises and +# a workflow's triggers disagree (#7090, Phase 1 of design #7089). +# +# Scope is exactly the "Agreement-tracked guard/build rows" table in +# .github/ci-policy.md: the seven guard/build workflows of Phase 1. +# Workflows ci-policy does not name are not inspected, and test-suite +# registry rows (#6185) are out of scope. +# +# Mapping (stated in ci-policy.md): +# basic — pull_request, path-gated where the row names a PR gate +# main — push: branches: [main] +# nightly — schedule +# workflow_dispatch alone satisfies no tier +# +# Known Phase 2–3 disagreements live in .github/ci-policy-waivers.txt, +# one line per missing leg. A waiver must name one of the four live +# phase issues (#6929, #6953, #6959, #6981); a waiver on a compliant +# leg is stale and fails. +# +# Usage: +# check-ci-policy-agreement.sh check the repository tree +# +# Environment: +# CI_POLICY_ROOT repository root (default: this repo) +# CI_POLICY_REPO owner/repo for issue state (default: +# $GITHUB_REPOSITORY or the code repo) +# CI_POLICY_ISSUE_STATE_FIXTURE file of " " lines, used +# by the contract tests instead of gh +# +# Oracle: the mapping above plus GitHub's own workflow-trigger syntax. +# The contract tests beside this script exercise every failure mode. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="${CI_POLICY_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}" +POLICY="$ROOT/.github/ci-policy.md" +WAIVERS="$ROOT/.github/ci-policy-waivers.txt" +REPO="${CI_POLICY_REPO:-${GITHUB_REPOSITORY:-developing-today/code}}" + +EXPECTED_ISSUES=(6929 6953 6959 6981) + +fail=0 +note_fail() { + echo "ci-policy-agreement: FAIL: $*" >&2 + fail=1 +} + +trim() { + local s="$1" + s="${s#"${s%%[![:space:]]*}"}" + s="${s%"${s##*[![:space:]]}"}" + printf '%s' "$s" +} + +strip_code() { + local s="$1" + s="${s//\`/}" + trim "$s" +} + +# parse_on FILE — emit TSV rows for the top-level on: block. +# EVENT +# PATH +# BRANCH +# INLINE +parse_on() { + awk ' + function trim(s) { sub(/^[[:space:]]+/, "", s); sub(/[[:space:]]+$/, "", s); return s } + /^on:[[:space:]]*\[/ { print "INLINE\t" $0; next } + /^on:[[:space:]]*$/ { in_on = 1; next } + in_on && /^[^[:space:]#]/ { exit } + !in_on { next } + /^[[:space:]]*#/ { next } + /^ [A-Za-z_][A-Za-z0-9_-]*:[[:space:]]*$/ { + ev = $0; sub(/^ /, "", ev); sub(/:.*/, "", ev) + print "EVENT\t" ev + sub_key = "" + next + } + /^ [A-Za-z_][A-Za-z0-9_-]*:[[:space:]]+.+/ { + print "INLINE\t" trim($0) + next + } + /^ branches:[[:space:]]*\[/ { + v = $0; sub(/^ branches:[[:space:]]*\[/, "", v); sub(/\].*$/, "", v) + n = split(v, parts, ",") + for (i = 1; i <= n; i++) { + b = trim(parts[i]); gsub(/^"|"$/, "", b); gsub(/^'\''|'\''$/, "", b) + if (b != "") print "BRANCH\t" ev "\t" b + } + sub_key = "" + next + } + /^ branches:/ { sub_key = "branches"; next } + /^ paths:/ { sub_key = "paths"; next } + /^ paths-ignore:/ { sub_key = "paths-ignore"; next } + /^ [A-Za-z_-]+:/ { sub_key = ""; next } + /^ - / { + if (ev == "") next + v = $0; sub(/^ - /, "", v); gsub(/^"|"$/, "", v); v = trim(v) + if (sub_key == "branches") print "BRANCH\t" ev "\t" v + else if (sub_key == "paths") print "PATH\t" ev "\t" v + } + ' "$1" +} + +declare -A WAIVER=() +declare -A WAIVER_SEEN=() + +if [ ! -f "$POLICY" ]; then + echo "ci-policy-agreement: FAIL: policy not found: $POLICY" >&2 + exit 1 +fi + +# --- waivers (read first: the row pass consults them) ------------------ +if [ -f "$WAIVERS" ]; then + while IFS= read -r line; do + line="$(trim "$line")" + case "$line" in ''|'#'*) continue ;; esac + read -r wf leg issue _ <<<"$line" + case "$leg" in + basic|main|nightly) ;; + *) note_fail "waiver line has unknown leg '$leg': $line"; continue ;; + esac + case "$issue" in + '#'[0-9]*) issue="${issue#\#}" ;; + [0-9]*) ;; + *) note_fail "waiver line has no issue number: $line"; continue ;; + esac + key="$wf|$leg" + if [ -n "${WAIVER[$key]:-}" ] && [ "${WAIVER[$key]}" != "$issue" ]; then + note_fail "conflicting waivers for $wf $leg (#${WAIVER[$key]} and #$issue)" + fi + WAIVER["$key"]="$issue" + done <"$WAIVERS" +else + note_fail "waiver file not found: $WAIVERS" +fi + +# --- policy rows ------------------------------------------------------- +rows=0 +while IFS= read -r line; do + case "$line" in + '| `.github/workflows/'*) ;; + *) continue ;; + esac + IFS='|' read -r _ c_wf c_basic c_main c_nightly c_gate _ <<<"$line" + wf="$(strip_code "$c_wf")" + basic="$(trim "$c_basic")" + main="$(trim "$c_main")" + nightly="$(trim "$c_nightly")" + gate="$(strip_code "$c_gate")" + rows=$((rows + 1)) + + case "$wf" in + .github/workflows/*.yml|.github/workflows/*.yaml) ;; + *) note_fail "policy row names '$wf', which is not a .github/workflows/*.yml file"; continue ;; + esac + + if [ ! -f "$ROOT/$wf" ]; then + note_fail "ci-policy names $wf but the file does not exist" + continue + fi + + declare -A EVENTS=() PATHS=() BRANCHES=() + while IFS=$'\t' read -r kind a b; do + case "$kind" in + EVENT) EVENTS["$a"]=1 ;; + PATH) PATHS["$a|$b"]=1 ;; + BRANCH) BRANCHES["$a|$b"]=1 ;; + INLINE) note_fail "$wf: cannot parse inline on: entry: $a" ;; + esac + done < <(parse_on "$ROOT/$wf") + + check_leg() { # check_leg LEG PRESENT MISSING-DESCRIPTION + local leg="$1" present="$2" missing="$3" + local key="$wf|$1" + if [ "$present" = "1" ]; then + if [ -n "${WAIVER[$key]:-}" ]; then + WAIVER_SEEN["$key"]=1 + note_fail "$wf: stale waiver for $leg (#${WAIVER[$key]}) — the leg is present" + fi + return + fi + if [ -n "${WAIVER[$key]:-}" ]; then + echo "ci-policy-agreement: WAIVED $wf $leg (#${WAIVER[$key]}): $missing" + WAIVER_SEEN["$key"]=1 + return + fi + note_fail "$wf missing $leg tier: $missing" + } + + if [ "$basic" = "yes" ]; then + present=0 + describe="${gate:+ with a path under $gate}" + [ "$gate" = "-" ] && describe="" + if [ -n "${EVENTS[pull_request]:-}" ]; then + present=1 + if [ "$gate" != "-" ] && [ -n "$gate" ]; then + gate_ok=0 + for k in "${!PATHS[@]}"; do + ev="${k%%|*}" + p="${k#*|}" + [ "$ev" = "pull_request" ] || continue + # shellcheck disable=SC2053 # glob match is intended + if [[ "$p" == $gate ]]; then gate_ok=1; break; fi + done + [ "$gate_ok" = "1" ] || present=0 + fi + fi + check_leg basic "$present" "no pull_request trigger$describe" + elif [ -n "${WAIVER[$wf|basic]:-}" ]; then + WAIVER_SEEN["$wf|basic"]=1 + note_fail "$wf: stale waiver for basic (#${WAIVER[$wf|basic]}) — policy does not assign basic" + fi + + if [ "$main" = "yes" ]; then + present=0 + if [ -n "${EVENTS[push]:-}" ] && [ -n "${BRANCHES[push|main]:-}" ]; then + present=1 + fi + check_leg main "$present" "no push: branches: [main] trigger" + elif [ -n "${WAIVER[$wf|main]:-}" ]; then + WAIVER_SEEN["$wf|main"]=1 + note_fail "$wf: stale waiver for main (#${WAIVER[$wf|main]}) — policy does not assign main" + fi + + if [ "$nightly" = "yes" ]; then + present=0 + [ -n "${EVENTS[schedule]:-}" ] && present=1 + check_leg nightly "$present" "no schedule trigger" + elif [ -n "${WAIVER[$wf|nightly]:-}" ]; then + WAIVER_SEEN["$wf|nightly"]=1 + note_fail "$wf: stale waiver for nightly (#${WAIVER[$wf|nightly]}) — policy does not assign nightly" + fi + + unset EVENTS PATHS BRANCHES +done <"$POLICY" + +if [ "$rows" -eq 0 ]; then + note_fail "no agreement-tracked workflow rows found in $POLICY" +fi + +# Every waiver in the file must correspond to an actual disagreement. +for k in "${!WAIVER[@]}"; do + if [ -z "${WAIVER_SEEN[$k]:-}" ]; then + wf="${k%%|*}" + leg="${k#*|}" + note_fail "stale waiver: $wf $leg (#${WAIVER[$k]}) — no disagreement on that leg" + fi +done + +# --- waiver issue liveness -------------------------------------------- +declare -A ISSUES_USED=() +for k in "${!WAIVER[@]}"; do + ISSUES_USED["${WAIVER[$k]}"]=1 +done + +for issue in "${!ISSUES_USED[@]}"; do + known=0 + for expected in "${EXPECTED_ISSUES[@]}"; do + [ "$issue" = "$expected" ] && known=1 + done + if [ "$known" != "1" ]; then + note_fail "waiver names #$issue, which is not one of the live Phase 2–3 issues (#6929, #6953, #6959, #6981)" + fi +done + +# Every issue the checker verifies must be open. Unused phase issues are +# fine: closing one retires its waivers, and the next real drift must be +# waived in the same change. + +state_of() { # state_of ISSUE + local issue="$1" state="" + if [ -n "${CI_POLICY_ISSUE_STATE_FIXTURE:-}" ]; then + state="$(awk -v n="$issue" '$1 == n { print $2; exit }' "$CI_POLICY_ISSUE_STATE_FIXTURE")" + elif command -v gh >/dev/null 2>&1; then + state="$(gh issue view "$issue" --repo "$REPO" --json state --jq .state 2>/dev/null || true)" + fi + printf '%s' "$state" +} + +for issue in "${!ISSUES_USED[@]}"; do + state="$(state_of "$issue")" + case "$state" in + OPEN|open|Open) ISSUE_STATE="open" ;; + CLOSED|closed|Closed) ISSUE_STATE="closed" ;; + *) ISSUE_STATE="unknown" ;; + esac + case "$ISSUE_STATE" in + open) ;; + closed) note_fail "waiver issue #$issue is closed — remove its waivers in this change" ;; + *) note_fail "cannot verify waiver issue #$issue is open (set CI_POLICY_ISSUE_STATE_FIXTURE in tests, or check gh/GITHUB_REPOSITORY in CI)" ;; + esac +done + +if [ "$fail" -ne 0 ]; then + echo "ci-policy-agreement: FAILED" >&2 + exit 1 +fi + +waived=0 +for k in "${!WAIVER_SEEN[@]}"; do waived=$((waived + 1)); done +echo "ci-policy-agreement: checked $rows workflow(s); $waived waived leg(s) across live issues #6929, #6953, #6959, #6981" +echo "ci-policy-agreement: OK" diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh new file mode 100755 index 0000000000..fff35d628a --- /dev/null +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -0,0 +1,272 @@ +#!/usr/bin/env bash +# Contract tests for check-ci-policy-agreement.sh (#7090, design #7089). +# +# Every case builds a throwaway policy, workflow set, waiver file and +# issue-state fixture, then asserts the checker's verdict. Oracle: the +# tier→trigger mapping stated in .github/ci-policy.md plus GitHub's +# workflow-trigger syntax. No network, no gh. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CHECK="$SCRIPT_DIR/check-ci-policy-agreement.sh" +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +RC=0 +OUT="" + +# new_root NAME — create an isolated repo root and set ROOT. +new_root() { + ROOT="$TMP/$1" + mkdir -p "$ROOT/.github/workflows" + : >"$ROOT/.github/ci-policy-waivers.txt" + printf '6929 OPEN\n6953 OPEN\n6959 OPEN\n6981 OPEN\n' >"$ROOT/issue-states.txt" +} + +# policy ROW... — write a minimal agreement table. +policy() { + { + echo '| workflow | basic | main | nightly | PR gate | waiver |' + echo '| --- | --- | --- | --- | --- | --- |' + for row in "$@"; do echo "$row"; done + } >"$ROOT/.github/ci-policy.md" +} + +# workflow NAME BODY — write .github/workflows/NAME.yml. +workflow() { + local name="$1" body="$2" + printf 'name: %s\n%s\n' "$name" "$body" >"$ROOT/.github/workflows/$name.yml" +} + +# compliant NAME — a workflow satisfying basic (path-gated), main, nightly. +compliant() { + local name="$1" + workflow "$name" "on: + pull_request: + paths: + - \"pkgs/$name/**\" + push: + branches: [main] + schedule: + - cron: \"0 0 * * *\" +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true" + policy "| \`.github/workflows/$name.yml\` | yes | yes | yes | \`pkgs/$name/**\` | - |" +} + +run_check() { + RC=0 + OUT="$(CI_POLICY_ROOT="$ROOT" CI_POLICY_ISSUE_STATE_FIXTURE="$ROOT/issue-states.txt" \ + bash "$CHECK" 2>&1)" || RC=$? +} + +expect_pass() { # expect_pass NAME + if [ "$RC" -ne 0 ]; then + echo "FAIL: $1 should have passed" >&2 + printf '%s\n' "$OUT" >&2 + exit 1 + fi + echo "pass: $1" +} + +expect_fail() { # expect_fail NAME PATTERN + if [ "$RC" -eq 0 ]; then + echo "FAIL: $1 should have failed" >&2 + printf '%s\n' "$OUT" >&2 + exit 1 + fi + if ! grep -qF -- "$2" <<<"$OUT"; then + echo "FAIL: $1 failed without naming '$2'" >&2 + printf '%s\n' "$OUT" >&2 + exit 1 + fi + echo "pass: $1" +} + +# 1. Compliant tree, no waivers. +new_root ok +compliant alpha +run_check +expect_pass "compliant workflow passes" + +# 2. workflow_dispatch alone satisfies no tier. +new_root dispatch +workflow alpha 'on: + workflow_dispatch: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | yes | no | `pkgs/alpha/**` | - |' +run_check +expect_fail "dispatch-only workflow fails" "alpha.yml missing basic tier" + +# 3. Basic present but main trigger missing. +new_root no-main +workflow alpha 'on: + pull_request: + paths: + - "pkgs/alpha/**" +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | yes | no | `pkgs/alpha/**` | - |' +run_check +expect_fail "missing push-to-main fails" "alpha.yml missing main tier" + +# 4. push on a non-main branch does not satisfy main. +new_root wrong-branch +workflow alpha 'on: + push: + branches: [dev] +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | no | yes | no | - | - |' +run_check +expect_fail "push to dev fails main" "alpha.yml missing main tier" + +# 5. PR trigger without the promised path gate fails basic. +new_root no-gate +workflow alpha 'on: + pull_request: + paths: + - "docs/**" +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | no | no | `pkgs/alpha/**` | - |' +run_check +expect_fail "wrong PR path gate fails basic" "alpha.yml missing basic tier" + +# 6. Nightly promise with no schedule fails. +new_root no-nightly +workflow alpha 'on: + pull_request: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | no | yes | - | - |' +run_check +expect_fail "missing schedule fails nightly" "alpha.yml missing nightly tier" + +# 7. A policy row naming a nonexistent workflow fails. +new_root ghost +policy '| `.github/workflows/ghost.yml` | yes | yes | no | - | - |' +run_check +expect_fail "policy row for a nonexistent workflow fails" "names .github/workflows/ghost.yml but the file does not exist" + +# 8. A waiver covers a real disagreement and is reported, not silent. +new_root waived +workflow alpha 'on: + workflow_dispatch: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | no | no | - | #6929 |' +printf '.github/workflows/alpha.yml basic #6929\n' >"$ROOT/.github/ci-policy-waivers.txt" +run_check +expect_pass "waiver covers a real disagreement" +grep -q "WAIVED .github/workflows/alpha.yml basic (#6929)" <<<"$OUT" || { + echo "FAIL: waiver was not reported" >&2 + printf '%s\n' "$OUT" >&2 + exit 1 +} + +# 9. A stale waiver on a compliant leg fails. +new_root stale +compliant alpha +printf '.github/workflows/alpha.yml basic #6929\n' >"$ROOT/.github/ci-policy-waivers.txt" +run_check +expect_fail "waiver on a compliant leg is stale" "stale waiver" + +# 10. A waiver issue outside the Phase 2–3 set fails. +new_root unknown-issue +workflow alpha 'on: + workflow_dispatch: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | no | no | - | #1234 |' +printf '.github/workflows/alpha.yml basic #1234\n' >"$ROOT/.github/ci-policy-waivers.txt" +run_check +expect_fail "waiver naming an unrelated issue fails" "not one of the live Phase 2–3 issues" + +# 11. A closed waiver issue fails. +new_root closed-issue +workflow alpha 'on: + workflow_dispatch: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | no | no | - | #6929 |' +printf '.github/workflows/alpha.yml basic #6929\n' >"$ROOT/.github/ci-policy-waivers.txt" +printf '6929 CLOSED\n' >"$ROOT/issue-states.txt" +run_check +expect_fail "closed waiver issue fails" "waiver issue #6929 is closed" + +# 12. A missing issue number fails. +new_root no-issue +workflow alpha 'on: + workflow_dispatch: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | yes | no | no | - | - |' +printf '.github/workflows/alpha.yml basic\n' >"$ROOT/.github/ci-policy-waivers.txt" +run_check +expect_fail "waiver without an issue fails" "waiver line has no issue number" + +# 13. An unknown leg fails. +new_root bad-leg +compliant alpha +printf '.github/workflows/alpha.yml monthly #6929\n' >"$ROOT/.github/ci-policy-waivers.txt" +run_check +expect_fail "waiver with an unknown leg fails" "waiver line has unknown leg" + +# 14. A flow-style on: block is rejected rather than guessed. +new_root inline +workflow alpha 'on: [push] +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +policy '| `.github/workflows/alpha.yml` | no | yes | no | - | - |' +run_check +expect_fail "inline on: block fails loudly" "cannot parse inline on: entry" + +# 15. Workflows ci-policy does not name are ignored. +new_root out-of-scope +compliant alpha +workflow beta 'on: + workflow_dispatch: +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: true' +run_check +expect_pass "unnamed workflow is out of scope" + +echo "check-ci-policy-agreement.test.sh: OK" diff --git a/.github/workflows/workflow-lint.yml b/.github/workflows/workflow-lint.yml index 26a1427539..8fd36b4b1f 100644 --- a/.github/workflows/workflow-lint.yml +++ b/.github/workflows/workflow-lint.yml @@ -10,18 +10,27 @@ name: workflow-lint # workflow set plus shape validation of .github/actions/*/action.yml # — whenever a change touches those paths. Pure bash + one pinned # static binary, so this stays a seconds-long basic check. +# +# It also runs the ci-policy agreement checker (#7090): a trigger +# sweep or a policy edit that breaks the tier→trigger mapping fails +# here, in the same change. on: pull_request: paths: - ".github/workflows/**" - ".github/actions/**" + - ".github/ci-policy.md" + - ".github/ci-policy-waivers.txt" - ".github/scripts/check-workflows.sh" - ".github/scripts/check-workflows.test.sh" + - ".github/scripts/check-ci-policy-agreement.sh" + - ".github/scripts/check-ci-policy-agreement.test.sh" workflow_dispatch: permissions: contents: read + issues: read concurrency: group: workflow-lint-${{ github.ref }} @@ -56,3 +65,9 @@ jobs: run: bash .github/scripts/check-workflows.test.sh - name: Validate workflows and composite actions run: bash .github/scripts/check-workflows.sh + - name: Contract tests for the ci-policy agreement checker (#7090) + run: bash .github/scripts/check-ci-policy-agreement.test.sh + - name: Check ci-policy tiers against workflow triggers (#7090) + env: + GH_TOKEN: ${{ github.token }} + run: bash .github/scripts/check-ci-policy-agreement.sh From 87dbee1f13b325f9ba52bc2e30b50acfeaf77a56 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 20:20:04 -0600 Subject: [PATCH 2/2] ci: drop stale merge_group wording from ci-policy (#7090) --- .github/ci-policy.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/ci-policy.md b/.github/ci-policy.md index 9342107852..16e377ae5b 100644 --- a/.github/ci-policy.md +++ b/.github/ci-policy.md @@ -131,8 +131,8 @@ not re-arm, retire, or re-enable any workflow. `.github/workflows/workflow-lint.yml` is a **basic-tier** check (job `basic: workflow lint`): on pull requests touching -`.github/workflows/**` or `.github/actions/**`, and on merge -groups, it runs `.github/scripts/check-workflows.sh`, which lints +`.github/workflows/**` or `.github/actions/**` it runs +`.github/scripts/check-workflows.sh`, which lints the complete workflow set with actionlint (shellcheck over `run:` blocks at `-S warning` when shellcheck is available, matching the mcpx leg) and shape-validates every `.github/actions/*/action.yml` @@ -148,7 +148,8 @@ workflow before use. ## OpenCode metered-provider config guard `.github/workflows/opencode-config-guard.yml` runs the static guard and -its fixtures on pull requests, merge groups, and pushes to `main`. The +its fixtures on pull requests and pushes to `main` (the merge-group leg +is not active under the no-merge-queue ruling). The guard checks known metered selections (`cloudflare-*` and the direct PAYG `deepseek` provider) in model-route targets/fallbacks, provider-route selections, top-level defaults, and agent model/fallback fields. Disabled