#!/usr/bin/env bash
# Per-member Linux gate: clippy -D warnings + FULL CI unit set + treqs, bound to the object sha. Usage: <sha> <label> [base]
set -u
SHA="${1:?sha}"; LABEL="${2:?label}"; BASE="${3:-de5a44bc338d679f3c63f6d0f68826eb9e575d73}"
export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$PATH"
OUT="$HOME/gate-294-doyle/$LABEL-$SHA"; mkdir -p "$OUT"
cd "$HOME/spt-core-gate-w2" || exit 90
[ -z "$(git status --short | grep -v '^?? .adapter-notify/')" ] || { echo TREE_DIRTY; git status --short; exit 91; }
git cat-file -e "$SHA^{commit}" || { echo SHA_ABSENT; exit 92; }
git merge-base --is-ancestor "$BASE" "$SHA"; echo "ancestor_rc=$?" | tee "$OUT/ancestor.txt"
git checkout -q --detach "$SHA" || exit 93
echo "HEAD=$(git rev-parse HEAD) tree=$(git rev-parse HEAD^{tree}) base=$BASE" | tee "$OUT/head.txt"
cargo run -q -p xtask -- pool-claim --pool target --label "$LABEL" > "$OUT/claim.raw" 2>&1; echo $? > "$OUT/claim.exit"; echo "claim exit $(cat "$OUT/claim.exit")"; tail -2 "$OUT/claim.raw"
run() { n="$1"; shift; echo "=== $n start $(date -u +%T): $*"; "$@" > "$OUT/$n.raw" 2>&1; echo $? > "$OUT/$n.exit"; echo "=== $n exit $(cat "$OUT/$n.exit") end $(date -u +%T)"; }
run clippy cargo clippy --workspace --all-targets -- -D warnings
run fixture cargo build -p spt --bin translate_proof_fixture
run unitset cargo nextest run --no-fail-fast --workspace -E 'kind(lib) + kind(bin)'
run treqs traceable-reqs check
echo "=== SUMMARY $LABEL $SHA"; for f in "$OUT"/*.exit; do printf '%s=%s\n' "$(basename "$f" .exit)" "$(cat "$f")"; done
echo "summary_lines=$(grep -c 'Summary \[' "$OUT/unitset.raw")"; grep 'Summary \[' "$OUT/unitset.raw"
echo "clippy_warning_lines=$(grep -c '^warning' "$OUT/clippy.raw")"
