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 / 18-crumb-only-no-rebuild.sh
| 1 | #!/usr/bin/env bash |
| 2 | # 18: a .crumb-only commit does not trigger recompilation. On a clone of a cargo workspace, build once |
| 3 | # (warm-up into TARGET_DIR), build again with no change (noise floor), then commit a change that touches only |
| 4 | # a .crumb file (`crumb propose` writes extensions.proposed) and build a third time with -v: the third build |
| 5 | # must report 0 "Compiling" and 0 "Dirty" lines. TARGET_DIR is reused, never deleted. |
| 6 | # Env: TARGET_DIR (default ${XDG_CACHE_HOME:-$HOME/.cache}/aien/pipeline/target-cold), |
| 7 | # CARGO_ARGS (default --locked --offline). The cache stays outside the temporary clone. |
| 8 | here="$(cd "$(dirname "$0")" && pwd)"; . "$here/lib.sh" |
| 9 | proof_begin 18 "crumb-only commit avoids unrelated recompilation" "${1:-}" |
| 10 | [ -f "$SRC/Cargo.toml" ] || proof_na "no Cargo.toml at the repository root" |
| 11 | command -v cargo >/dev/null 2>&1 || proof_na "cargo not on PATH" |
| 12 | TD=${TARGET_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/aien/pipeline/target-cold} |
| 13 | export CARGO_TARGET_DIR=$TD |
| 14 | ARGS=${CARGO_ARGS:---locked --offline} |
| 15 | clone_repo "$TMP/a"; cd "$TMP/a" || exit 1 |
| 16 | note "target dir: $TD ($(du -sh "$TD" 2>/dev/null | cut -f1) before)" |
| 17 | counts() { echo "compiling=$(grep -c '^ *Compiling' <<<"$1") dirty=$(grep -c '^ *Dirty' <<<"$1") fresh=$(grep -c '^ *Fresh' <<<"$1")"; } |
| 18 | |
| 19 | # shellcheck disable=SC2086 |
| 20 | measure build_1_warmup cargo build $ARGS; check "build 1 succeeds" [ "$RC" -eq 0 ] |
| 21 | [ "$RC" -eq 0 ] || { echo "$OUT" | tail -5; proof_end; } |
| 22 | # shellcheck disable=SC2086 |
| 23 | measure build_2_no_change cargo build -v $ARGS; C2=$(counts "$OUT"); num "build2_$C2" |
| 24 | check "build 2 (no change) compiles nothing" grep -q 'compiling=0 dirty=0' <<<"$C2" |
| 25 | |
| 26 | L=$(leaf_crumb_dir .) || L=. |
| 27 | $CRUMB propose "$L" "proof 18: proposed purpose, crumb-only change" >/dev/null || { echo "propose failed" >&2; exit 1; } |
| 28 | CH=$(git status --porcelain | awk '{print $2}' | tr '\n' ' ' | sed 's/ $//'); num "changed_paths=$CH" |
| 29 | check_eq "the change touches exactly one .crumb file" "$(git status --porcelain | wc -l)/$(git status --porcelain | grep -c '\.crumb$')" "1/1" |
| 30 | git add -A && git commit -q -m "crumb-only change (proof 18)" |
| 31 | # shellcheck disable=SC2086 |
| 32 | measure build_3_after_crumb_commit cargo build -v $ARGS; C3=$(counts "$OUT"); num "build3_$C3" |
| 33 | check "build 3 after the crumb-only commit compiles nothing" grep -q 'compiling=0 dirty=0' <<<"$C3" |
| 34 | check "build 3 still reports fresh crates" grep -qv 'fresh=0' <<<"$C3" |
| 35 | note "target dir after: $(du -sh "$TD" 2>/dev/null | cut -f1)" |
| 36 | proof_end |