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 / 18-crumb-only-no-rebuild.sh

36 lines · 2460 bytes Raw Blame History
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.
8here="$(cd "$(dirname "$0")" && pwd)"; . "$here/lib.sh"
9proof_begin 18 "crumb-only commit avoids unrelated recompilation" "${1:-}"
10[ -f "$SRC/Cargo.toml" ] || proof_na "no Cargo.toml at the repository root"
11command -v cargo >/dev/null 2>&1 || proof_na "cargo not on PATH"
12TD=${TARGET_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/aien/pipeline/target-cold}
13export CARGO_TARGET_DIR=$TD
14ARGS=${CARGO_ARGS:---locked --offline}
15clone_repo "$TMP/a"; cd "$TMP/a" || exit 1
16note "target dir: $TD ($(du -sh "$TD" 2>/dev/null | cut -f1) before)"
17counts() { echo "compiling=$(grep -c '^ *Compiling' <<<"$1") dirty=$(grep -c '^ *Dirty' <<<"$1") fresh=$(grep -c '^ *Fresh' <<<"$1")"; }
18
19# shellcheck disable=SC2086
20measure 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
23measure build_2_no_change cargo build -v $ARGS; C2=$(counts "$OUT"); num "build2_$C2"
24check "build 2 (no change) compiles nothing" grep -q 'compiling=0 dirty=0' <<<"$C2"
25
26L=$(leaf_crumb_dir .) || L=.
27$CRUMB propose "$L" "proof 18: proposed purpose, crumb-only change" >/dev/null || { echo "propose failed" >&2; exit 1; }
28CH=$(git status --porcelain | awk '{print $2}' | tr '\n' ' ' | sed 's/ $//'); num "changed_paths=$CH"
29check_eq "the change touches exactly one .crumb file" "$(git status --porcelain | wc -l)/$(git status --porcelain | grep -c '\.crumb$')" "1/1"
30git add -A && git commit -q -m "crumb-only change (proof 18)"
31# shellcheck disable=SC2086
32measure build_3_after_crumb_commit cargo build -v $ARGS; C3=$(counts "$OUT"); num "build3_$C3"
33check "build 3 after the crumb-only commit compiles nothing" grep -q 'compiling=0 dirty=0' <<<"$C3"
34check "build 3 still reports fresh crates" grep -qv 'fresh=0' <<<"$C3"
35note "target dir after: $(du -sh "$TD" 2>/dev/null | cut -f1)"
36proof_end