From 3cf36fb3777218344f60b60a37e4b4dc1a47a133 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 07:43:24 +0000 Subject: [PATCH] feat(ci): guard against new root *COMPLETE* / *SUMMARY* status files (#12136) --- .github/ci-policy.md | 1 + .github/scripts/check-ci-policy-agreement.sh | 1 + .github/scripts/check-root-status-files.sh | 61 +++++++++++ .../scripts/check-root-status-files.test.sh | 102 ++++++++++++++++++ .github/test-suite-registry.json | 13 +++ .github/workflows/root-status-guard.yml | 32 ++++++ 6 files changed, 210 insertions(+) create mode 100755 .github/scripts/check-root-status-files.sh create mode 100755 .github/scripts/check-root-status-files.test.sh create mode 100644 .github/workflows/root-status-guard.yml diff --git a/.github/ci-policy.md b/.github/ci-policy.md index 4a363e9832..b970eccb02 100644 --- a/.github/ci-policy.md +++ b/.github/ci-policy.md @@ -108,6 +108,7 @@ never a state that persists by default. | opencode-config-guard | nightly schedule | yes | | mcpx fix-test guard | nightly schedule | yes | | production-line guard | nightly schedule | yes | +| root-status guard | nightly schedule | yes | | go modules build | nightly schedule | yes | | identity build | nightly schedule | yes | | map build | nightly schedule | yes | diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 3e0c7726df..cef60e5f1f 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -27,6 +27,7 @@ REGISTRY=( "opencode-config-guard.yml|opencode-config-guard|nightly" "mcpx-fix-test-guard.yml|mcpx fix-test guard|nightly" "production-line-guard.yml|production-line guard|nightly" + "root-status-guard.yml|root-status guard|nightly" "go-modules-build.yml|go modules build|nightly" "identity-build.yml|identity build|nightly" "map-build.yml|map build|nightly" diff --git a/.github/scripts/check-root-status-files.sh b/.github/scripts/check-root-status-files.sh new file mode 100755 index 0000000000..f7f54438f2 --- /dev/null +++ b/.github/scripts/check-root-status-files.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# Repo-root status-file guard (#12136). +# +# Fails when a file at the repository root has a name containing +# COMPLETE or SUMMARY (case-insensitive). Those names mark one-shot +# status documents ("implementation complete", slice summaries, +# completion reports) that go stale the moment they land; #12136 +# removed 26 of them, plus two helper scripts and a committed chat +# transcript, in PR #13047. Status belongs in the issue tracker or +# under doc/, never as a new root file. +# +# Only the root is guarded: the same names inside a directory (for +# example the pm-stack/opencode-claimant/ copies the issue's evidence +# names) are that directory's own business. +# +# No grandfather list: the removal landed first (this guard is +# stacked on PR #13047), so the invariant holds on the whole tree +# from the day the guard lands. The repo's grandfather-list ratchet +# (check-production-line-limit.sh) exists for violations that take +# many PRs to burn down; here a single already-open PR removes them +# all, so a list would be dead entries the moment #13047 merges. +# +# Argument contract (#3352): the whole command line is the single +# optional positional argument below; anything else is a usage +# error (exit 2) before any work happens. +# +# Usage: check-root-status-files.sh [ROOT] (default: repo root) +set -euo pipefail + +[[ $# -le 1 ]] || { + echo "Usage: check-root-status-files.sh [ROOT]" >&2 + exit 2 +} + +ROOT="${1:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" + +if [ ! -d "$ROOT" ]; then + echo "::error::root status guard: root not found: $ROOT" + exit 1 +fi + +fail=0 +checked=0 +while IFS= read -r -d '' file; do + base="$(basename "$file")" + lower="${base,,}" + checked=$((checked + 1)) + case "$lower" in + *complete* | *summary*) + echo "::error::ROOT STATUS FILE $base: root files named *COMPLETE* / *SUMMARY* are one-shot status documents that go stale on landing (#12136). Record the status in the issue tracker or under doc/ instead." + fail=1 + ;; + esac +done < <(find "$ROOT" -maxdepth 1 \( -type f -o -type l \) -print0 | sort -z) + +echo "root-status-guard: checked $checked root files" +if [ "$fail" -ne 0 ]; then + echo "root-status-guard: FAILED - root status file(s) listed above" + exit 1 +fi +echo "root-status-guard: OK" diff --git a/.github/scripts/check-root-status-files.test.sh b/.github/scripts/check-root-status-files.test.sh new file mode 100755 index 0000000000..c944df67c0 --- /dev/null +++ b/.github/scripts/check-root-status-files.test.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +# Contract tests for check-root-status-files.sh (#12136). +# Builds fixture roots in a temp dir: a clean root passes (including +# a *COMPLETE* file nested in a subdirectory - only the root is +# guarded), and a root *COMPLETE* / *SUMMARY* file fails, named. +# Path-only, so it runs offline. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CHECK="$SCRIPT_DIR/check-root-status-files.sh" +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +failures=0 +note_fail() { + echo "FAIL: $1" + failures=$((failures + 1)) +} + +# A clean root passes: ordinary root files, plus a *COMPLETE* file +# nested in a subdirectory (out of scope - the guard is root-only). +CLEAN="$TMP/clean" +mkdir -p "$CLEAN/doc" +: >"$CLEAN/README.md" +: >"$CLEAN/Cargo.toml" +: >"$CLEAN/doc/TASK_COMPLETE.md" +if bash "$CHECK" "$CLEAN" >/dev/null 2>&1; then + echo "ok: a clean root passes (nested *COMPLETE* is out of scope)" +else + note_fail "a clean root should pass" +fi + +# A root *COMPLETE* file fails, and the failure names it. +BAD="$TMP/complete" +mkdir -p "$BAD" +: >"$BAD/README.md" +: >"$BAD/TASK_COMPLETE.md" +if out=$(bash "$CHECK" "$BAD" 2>&1); then + note_fail "a root TASK_COMPLETE.md should fail" +elif ! printf '%s' "$out" | grep -qF 'TASK_COMPLETE.md'; then + note_fail "the failure should name the offending file" + printf '%s\n' "$out" | sed 's/^/ /' +else + echo "ok: a root TASK_COMPLETE.md fails, naming the file" +fi + +# Matching is case-insensitive, like the lowercase slice-1 names +# #12136 removed (slice1_final_verification.md and friends). +LOWER="$TMP/lower" +mkdir -p "$LOWER" +: >"$LOWER/implementation_summary.txt" +if bash "$CHECK" "$LOWER" >/dev/null 2>&1; then + note_fail "a lowercase root implementation_summary.txt should fail" +else + echo "ok: a lowercase root *summary* file fails" +fi + +# The exact shape #12136 cleaned up fails too. +SLICE="$TMP/slice" +mkdir -p "$SLICE" +: >"$SLICE/SLICE1_COMPLETION_SUMMARY.txt" +if bash "$CHECK" "$SLICE" >/dev/null 2>&1; then + note_fail "a root SLICE1_COMPLETION_SUMMARY.txt should fail" +else + echo "ok: a root SLICE1_COMPLETION_SUMMARY.txt fails" +fi + +# Scope boundary: the issue's guard bullet names *COMPLETE* and +# *SUMMARY* only, so a *STATUS* name alone still passes. +STATUS="$TMP/status" +mkdir -p "$STATUS" +: >"$STATUS/IMPLEMENTATION_STATUS.md" +if bash "$CHECK" "$STATUS" >/dev/null 2>&1; then + echo "ok: a root *STATUS*-only name passes (guard covers *COMPLETE* / *SUMMARY*)" +else + note_fail "a *STATUS*-only name should pass" +fi + +if bash "$CHECK" "$TMP/missing" >/dev/null 2>&1; then + note_fail "a missing root should fail" +else + echo "ok: a missing root fails" +fi + +# Argument contract (#3352): anything beyond the one optional ROOT +# positional is a usage error, exit 2, with the usage message. +rc=0 +out=$(bash "$CHECK" "$CLEAN" extra 2>&1) || rc=$? +if [ "$rc" -ne 2 ]; then + note_fail "an extra argument should exit 2 (usage error), got $rc" +elif ! printf '%s' "$out" | grep -qF 'Usage:'; then + note_fail "the extra-argument failure should print the usage message" + printf '%s\n' "$out" | sed 's/^/ /' +else + echo "ok: an extra argument is a usage error (exit 2, usage printed)" +fi + +if [ "$failures" -ne 0 ]; then + echo "check-root-status-files.test: $failures failure(s)" + exit 1 +fi +echo "check-root-status-files.test: OK" diff --git a/.github/test-suite-registry.json b/.github/test-suite-registry.json index 64362da9ed..ff19e55523 100644 --- a/.github/test-suite-registry.json +++ b/.github/test-suite-registry.json @@ -1070,6 +1070,19 @@ "status": "mapped", "related_issues": [1411] }, + { + "id": "ci.root-status-files", + "paths": [".github/scripts/check-root-status-files.test.sh"], + "invocation": "bash .github/scripts/check-root-status-files.test.sh", + "venue": { + "workflow": ".github/workflows/root-status-guard.yml", + "job_step": "Guard contract tests (#12136)", + "state": "active", + "dispatchable": true + }, + "status": "mapped", + "related_issues": [12136] + }, { "id": "bin.node-tests", "paths": ["bin/*.test.mjs"], diff --git a/.github/workflows/root-status-guard.yml b/.github/workflows/root-status-guard.yml new file mode 100644 index 0000000000..2b26aa171e --- /dev/null +++ b/.github/workflows/root-status-guard.yml @@ -0,0 +1,32 @@ +name: root-status-guard + +# Repo-root status-file guard (#12136): no file at the repository +# root may be named *COMPLETE* / *SUMMARY* - those are one-shot +# status documents that go stale on landing. Pure bash - no nix, no +# toolchain - so this stays a seconds-long basic check. + +on: + schedule: + # Nightly instead of on every push to main (Drew, 2026-11-16; see + # .github/ci-policy.md "Nightly main CI"). + - cron: "17 7 * * *" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: root-status-guard-${{ github.event_name == 'push' && github.run_id || github.ref }} + cancel-in-progress: true + +jobs: + root-status-guard: + name: "basic: root status files" + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v7 + - name: Guard passes on this tree (#12136) + run: bash .github/scripts/check-root-status-files.sh + - name: Guard contract tests (#12136) + run: bash .github/scripts/check-root-status-files.test.sh