aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / scripts / pipeline-proofs / 16-siblings-current.sh
| 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). |
| 5 | here="$(cd "$(dirname "$0")" && pwd)"; . "$here/lib.sh" |
| 6 | proof_begin 16 "unchanged siblings stay CURRENT" "${1:-}" |
| 7 | clone_repo "$TMP/a"; cd "$TMP/a" || exit 1 |
| 8 | L=$(leaf_crumb_dir .) || { echo "no leaf crumb directory with a tracked file" >&2; exit 1; } |
| 9 | F=$(tracked_file_in . "$L") |
| 10 | TOTAL=$(crumb_dirs . | wc -l) |
| 11 | printf '\n# proof 16 touch\n' >> "$F"; git add -- "$F" |
| 12 | CHAIN=$(ancestors_with_crumbs . "$L") |
| 13 | measure status $CRUMB status . |
| 14 | CUR=$(echo "$OUT" | awk '$1=="CURRENT"{print $2}' | sort) |
| 15 | STALE=$(echo "$OUT" | awk '$1=="STALE"{print $2}' | sort) |
| 16 | num "current=$(echo "$CUR" | grep -c .)"; num "stale=$(echo "$STALE" | grep -c .)"; num "total=$TOTAL" |
| 17 | check_eq "CURRENT + STALE = every crumb" "$(( $(echo "$CUR" | grep -c .) + $(echo "$STALE" | grep -c .) ))" "$TOTAL" |
| 18 | outside=0; for d in $CUR; do case " $CHAIN " in *" $d "*) ;; *) outside=$((outside+1)) ;; esac; done |
| 19 | num "siblings_current=$outside" |
| 20 | check_eq "every crumb outside the chain is CURRENT" "$outside" "$((TOTAL - $(echo "$CHAIN" | wc -w)))" |
| 21 | for 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 |
| 24 | L2="" |
| 25 | for 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 |
| 30 | done |
| 31 | if [ -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" |
| 36 | else |
| 37 | note "no second independent subtree with a tracked file; second-change check skipped" |
| 38 | fi |
| 39 | proof_end |