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 / 16-siblings-current.sh

39 lines · 2235 bytes Raw Blame History
1#!/usr/bin/env bash
2# 16: unchanged siblings stay CURRENT. After one leaf change, every crumb outside the changed directory's
3# ancestor chain reports CURRENT in `crumb status`, and a second change in a different subtree stales only
4# its own chain (the two chains share only the root).
5here="$(cd "$(dirname "$0")" && pwd)"; . "$here/lib.sh"
6proof_begin 16 "unchanged siblings stay CURRENT" "${1:-}"
7clone_repo "$TMP/a"; cd "$TMP/a" || exit 1
8L=$(leaf_crumb_dir .) || { echo "no leaf crumb directory with a tracked file" >&2; exit 1; }
9F=$(tracked_file_in . "$L")
10TOTAL=$(crumb_dirs . | wc -l)
11printf '\n# proof 16 touch\n' >> "$F"; git add -- "$F"
12CHAIN=$(ancestors_with_crumbs . "$L")
13measure status $CRUMB status .
14CUR=$(echo "$OUT" | awk '$1=="CURRENT"{print $2}' | sort)
15STALE=$(echo "$OUT" | awk '$1=="STALE"{print $2}' | sort)
16num "current=$(echo "$CUR" | grep -c .)"; num "stale=$(echo "$STALE" | grep -c .)"; num "total=$TOTAL"
17check_eq "CURRENT + STALE = every crumb" "$(( $(echo "$CUR" | grep -c .) + $(echo "$STALE" | grep -c .) ))" "$TOTAL"
18outside=0; for d in $CUR; do case " $CHAIN " in *" $d "*) ;; *) outside=$((outside+1)) ;; esac; done
19num "siblings_current=$outside"
20check_eq "every crumb outside the chain is CURRENT" "$outside" "$((TOTAL - $(echo "$CHAIN" | wc -w)))"
21for d in $STALE; do case " $CHAIN " in *" $d "*) ;; *) echo " FAIL $d is STALE but not in the chain"; FAILS=$((FAILS+1)) ;; esac; done
22
23# second change in a different subtree: pick a crumb dir sharing only the root with the first chain
24L2=""
25for d in $(crumb_dirs . | grep -v '^\.$' | awk -F/ '{print NF" "$0}' | sort -rn | cut -d' ' -f2); do
26 case " $CHAIN " in *" $d "*) continue ;; esac
27 case "$L/" in "$d"/*) continue ;; esac
28 F2=$(tracked_file_in . "$d"); [ -n "$F2" ] || continue
29 L2=$d; break
30done
31if [ -n "$L2" ]; then
32 printf '\n# proof 16 second touch\n' >> "$F2"; git add -- "$F2"
33 WANT=$( (echo "$CHAIN" | tr ' ' '\n'; ancestors_with_crumbs . "$L2" | tr ' ' '\n') | sort -u | tr '\n' ' ' | sed 's/ $//')
34 check_eq "two changes stale exactly the union of the two chains" "$(stale_set .)" "$WANT"
35 num "second_dir=$L2"
36else
37 note "no second independent subtree with a tracked file; second-change check skipped"
38fi
39proof_end