interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / scripts / pipeline-proofs / 19-pr-gate-refuses-stale.sh

88 lines · 5112 bytes Raw Blame History
1#!/usr/bin/env bash
2# 19: since the crumb retirement (2026-11-07, DRA-97) stale, missing or mixed crumbs no longer block admission.
3# The real scripts/pr-gate.sh (with a fake `gh` that answers from fixtures: open PR, CLEAN, no required contexts)
4# is run with --worktree on a clone whose PR branch (a) changed source without recompiling (formerly STALE),
5# (b) deleted a .crumb (formerly MISSING), (c) changed source only, with no crumb commit, (d) changed source and
6# a .crumb in one last commit (formerly refused by rule 2). Every case must exit 0 with
7# "GATE crumb: SKIP retired". The crumb tool is never needed: CRUMB and a `crumb` on PATH are stubs that record
8# any call and exit 99, and the proof checks they were never called. No network.
9here="$(cd "$(dirname "$0")" && pwd)"; . "$here/lib.sh"
10proof_begin 19 "pr-gate.sh no longer refuses stale, missing or mixed crumbs (retired, DRA-97)" "${1:-}"
11GATE=${PR_GATE:-$here/../pr-gate.sh}; [ -x "$GATE" ] || { echo "pr-gate.sh not found at $GATE" >&2; exit 2; }
12export SLEEP_SECS=0
13clone_repo "$TMP/seed"; git -C "$TMP/seed" checkout -q -B main
14git clone -q --bare "$TMP/seed" "$TMP/origin.git"
15git clone -q "$TMP/origin.git" "$TMP/w"; W=$TMP/w
16git -C "$W" config user.name proof; git -C "$W" config user.email proof@example.invalid
17FX="$TMP/fx"; mkdir -p "$FX" "$TMP/bin"; export FX
18cat > "$TMP/bin/gh" <<'S'
19#!/usr/bin/env bash
20d="$FX/$CASE"
21case "$1 $2" in
22 "pr view") cat "$d/pr.json" ;;
23 "pr list") echo '[]' ;;
24 api\ repos/*) echo '[]' ;;
25 *) echo "fake gh: unhandled: $*" >&2; exit 2 ;;
26esac
27S
28printf '#!/usr/bin/env bash\necho "$*" >> "%s/crumb-called"\nexit 99\n' "$TMP" > "$TMP/bin/crumb"
29chmod +x "$TMP/bin/gh" "$TMP/bin/crumb"; export PATH="$TMP/bin:$PATH" CRUMB="$TMP/bin/crumb"
30fx() { # fx <case> <branch> <sha>
31 mkdir -p "$FX/$1"
32 printf '{"number":1,"state":"OPEN","isDraft":false,"baseRefName":"main","headRefName":"%s","headRefOid":"%s","mergeable":"MERGEABLE","mergeStateStatus":"CLEAN","reviewDecision":"","statusCheckRollup":[]}\n' "$2" "$3" > "$FX/$1/pr.json"
33}
34L=$(leaf_crumb_dir "$W") || { echo "no leaf crumb dir" >&2; exit 1; }
35F=$(tracked_file_in "$W" "$L")
36MAIN=main
37branch() { git -C "$W" checkout -q -b "$1" "origin/$MAIN"; }
38push() { git -C "$W" push -q origin "$1"; git -C "$W" rev-parse HEAD; }
39admitted() { # admitted <label> : last gate run exited 0 with the retired SKIP and no crumb FAIL
40 check_eq "$1: pr-gate exits 0 (dry run)" "$RC" 0
41 check "$1: GATE crumb: SKIP retired" grep -qF 'GATE crumb: SKIP retired 2026-11-07 (DRA-97); .crumb files are history' <<<"$OUT"
42 check "$1: no GATE crumb: FAIL" bash -c '! grep -q "^GATE crumb: FAIL" <<<"$1"' _ "$OUT"
43}
44
45# (a) formerly stale: source change committed without recompiling
46branch stale; printf '\n# proof 19 stale\n' >> "$W/$F"; git -C "$W" commit -qam "source change, no crumb compile"
47SHA=$(push stale); fx stale stale "$SHA"
48export CASE=stale; measure gate_stale "$GATE" proof-repo 1 --worktree "$W" --dry-run
49admitted "stale tree"
50note "$(grep '^GATE crumb' <<<"$OUT" | cut -c1-110)"
51
52# (b) formerly missing: a .crumb deleted (immediate child of a crumbed parent, and a deep one if present)
53IMM=""; DEEP=""
54for d in $(crumb_dirs "$W" | grep -v '^\.$'); do
55 p=${d%/*}; [ "$p" = "$d" ] && p=.
56 if [ -f "$W/$p/.crumb" ]; then [ -n "$IMM" ] || IMM=$d; else [ -n "$DEEP" ] || DEEP=$d; fi
57done
58num "immediate_child_crumb=$IMM"; num "deep_crumb_without_crumbed_parent=${DEEP:-none}"
59branch missing-immediate; git -C "$W" rm -q "$IMM/.crumb"; git -C "$W" commit -qm "delete $IMM/.crumb"
60SHA=$(push missing-immediate); fx missing missing-immediate "$SHA"
61export CASE=missing; measure gate_missing_immediate "$GATE" proof-repo 1 --worktree "$W" --dry-run
62admitted "missing immediate-child crumb"
63if [ -n "$DEEP" ]; then
64 branch missing-deep; git -C "$W" rm -q "$DEEP/.crumb"; git -C "$W" commit -qm "delete $DEEP/.crumb"
65 SHA=$(push missing-deep); fx deep missing-deep "$SHA"
66 export CASE=deep; measure gate_missing_deep "$GATE" proof-repo 1 --worktree "$W" --dry-run
67 admitted "missing deep crumb"
68else
69 note "no deep crumb without a crumbed parent in this repository; (b2) not applicable"
70fi
71
72# (c) source change only, no crumb commit: the final SHA is the source commit
73branch ok; printf '\n# proof 19 ok\n' >> "$W/$F"; git -C "$W" commit -qam "source change"
74SHA=$(push ok); fx ok ok "$SHA"
75export CASE=ok; measure gate_ok "$GATE" proof-repo 1 --worktree "$W" --dry-run
76admitted "source-only head"
77note "$(grep '^GATE crumb' <<<"$OUT" | cut -c1-110)"
78
79# (d) formerly refused: source and a .crumb changed in the same last commit
80branch mixed; printf '\n# proof 19 mixed\n' >> "$W/$F"; printf '\n' >> "$W/$L/.crumb"
81git -C "$W" add -A; git -C "$W" commit -qm "source + crumb together"
82SHA=$(push mixed); fx mixed mixed "$SHA"
83export CASE=mixed; measure gate_mixed "$GATE" proof-repo 1 --worktree "$W" --dry-run
84admitted "mixed last commit"
85check "mixed last commit: not refused by rule 2" bash -c '! grep -q "crumb commit must be separate and last" <<<"$1"' _ "$OUT"
86
87check "the crumb tool was never called" test ! -e "$TMP/crumb-called"
88proof_end