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 / 21-final-sha.sh

66 lines · 4309 bytes Raw Blame History
1#!/usr/bin/env bash
2# 21: since the crumb retirement (2026-11-07, DRA-97) the final SHA is the last source commit; no crumb commit is
3# needed. A source-only branch is rebased by the real scripts/rebase-crumb.sh onto a moved main (local bare origin,
4# url.insteadOf for the aien-dev URL), then judged by the real scripts/pr-gate.sh --worktree --dry-run (fake `gh`
5# answering from a fixture). Expected: the rebased head is one commit, the source commit itself (same subject and
6# change, no "crumb compile" commit), the gate admits it with "GATE crumb: SKIP retired", and HEAD is unchanged by
7# the gate. CRUMB and a `crumb` on PATH are stubs that record any call and exit 99; they must never be called.
8here="$(cd "$(dirname "$0")" && pwd)"; . "$here/lib.sh"
9proof_begin 21 "final SHA = the source commit, no crumb commit needed (retired, DRA-97)" "${1:-}"
10RB=${REBASE_CRUMB:-$here/../rebase-crumb.sh}; [ -x "$RB" ] || { echo "rebase-crumb.sh not found at $RB" >&2; exit 2; }
11GATE=${PR_GATE:-$here/../pr-gate.sh}; [ -x "$GATE" ] || { echo "pr-gate.sh not found at $GATE" >&2; exit 2; }
12export SLEEP_SECS=0
13FAKEURL="https://github.com/aien-dev/proof-repo"
14clone_repo "$TMP/seed"; git -C "$TMP/seed" checkout -q -B main
15git clone -q --bare "$TMP/seed" "$TMP/origin.git"
16git clone -q "$TMP/origin.git" "$TMP/a"; A=$TMP/a
17git clone -q "$TMP/origin.git" "$TMP/other"; O=$TMP/other
18for r in "$A" "$O"; do git -C "$r" config user.name proof; git -C "$r" config user.email proof@example.invalid; done
19mkdir -p "$TMP/bin" "$TMP/fx"
20printf '#!/usr/bin/env bash\necho "$*" >> "%s/crumb-called"\nexit 99\n' "$TMP" > "$TMP/bin/crumb"
21cat > "$TMP/bin/gh" <<'S'
22#!/usr/bin/env bash
23case "$1 $2" in
24 "pr view") cat "$FXFILE" ;;
25 "pr list") echo '[]' ;;
26 api\ repos/*) echo '[]' ;;
27 *) echo "fake gh: unhandled: $*" >&2; exit 2 ;;
28esac
29S
30chmod +x "$TMP/bin/crumb" "$TMP/bin/gh"; export PATH="$TMP/bin:$PATH" CRUMB="$TMP/bin/crumb" FXFILE="$TMP/fx/pr.json"
31
32L=$(leaf_crumb_dir "$A") || { echo "no leaf crumb dir" >&2; exit 1; }
33F=$(tracked_file_in "$A" "$L")
34S0=$(git -C "$A" rev-parse HEAD)
35git -C "$A" checkout -q -b feat
36printf '\n# proof 21 source change\n' >> "$A/$F"; git -C "$A" commit -qam "source change in $L"
37S1=$(git -C "$A" rev-parse HEAD); num "source_sha=${S1:0:12}"
38check "source commit differs from the base" [ "$S1" != "$S0" ]
39git -C "$A" push -q origin feat
40git -C "$A" remote set-url origin "$FAKEURL"; git -C "$A" config "url.$TMP/origin.git.insteadOf" "$FAKEURL"
41git -C "$A" checkout -q main
42
43# main moves (a commit outside the changed file), so the rebase rewrites the source commit
44printf '\n# proof 21 main moves\n' >> "$O/README.md"; git -C "$O" commit -qam "main moves"; git -C "$O" push -q origin main
45
46measure rebase_crumb "$RB" "$A" feat
47check_eq "rebase-crumb.sh exits 0" "$RC" 0
48S2=$(git -C "$A" rev-parse HEAD); num "final_sha=${S2:0:12}"
49check "final SHA differs from the pre-rebase source SHA (rebased)" [ "$S2" != "$S1" ]
50check_eq "final head is one commit on main" "$(git -C "$A" rev-list --count origin/main..HEAD)" 1
51check_eq "final commit is the source commit" "$(git -C "$A" log -1 --format=%s)" "source change in $L"
52check_eq "final commit carries the same change as the source commit" \
53 "$(git -C "$A" diff HEAD~1 HEAD | git -C "$A" patch-id --stable | cut -d' ' -f1)" \
54 "$(git -C "$A" diff "$S1~1" "$S1" | git -C "$A" patch-id --stable | cut -d' ' -f1)"
55check_eq "no crumb compile commit" "$(git -C "$A" log --format=%s origin/main..HEAD | grep -c '^crumb compile' || true)" 0
56
57printf '{"number":1,"state":"OPEN","isDraft":false,"baseRefName":"main","headRefName":"feat","headRefOid":"%s","mergeable":"MERGEABLE","mergeStateStatus":"CLEAN","reviewDecision":"","statusCheckRollup":[]}\n' "$S2" > "$FXFILE"
58git -C "$A" checkout -q feat
59measure gate_final "$GATE" proof-repo 1 --worktree "$A" --dry-run
60check_eq "pr-gate admits the final SHA (exit 0, dry run)" "$RC" 0
61check "GATE crumb: SKIP retired" grep -qF 'GATE crumb: SKIP retired 2026-11-07 (DRA-97); .crumb files are history' <<<"$OUT"
62note "$(grep '^GATE crumb' <<<"$OUT" | cut -c1-110)"
63check_eq "the gate added no commit" "$(git -C "$A" rev-parse HEAD)" "$S2"
64check_eq "working tree clean" "$(git -C "$A" status --porcelain | wc -l)" 0
65check "the crumb tool was never called" test ! -e "$TMP/crumb-called"
66proof_end