#!/usr/bin/env bash # CHECK — 2026-10-27 commit census (Extract lane). # Exits 0 iff the committed TSV re-derives field-for-field from `git log HEAD`. # The re-derivation is a separate git pass inside this script, so it cannot use # or rely on the extraction script's own Counter logic. set -u cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 repo=/root/troupe-standup tsv=2026-10-27-commit-census.tsv # Snapshot head at capture time (before this artifact's own commits landed). PINNED=ca3e13d328dfac3f06a98ef2423c37c36c7c4a5e test -d "$repo" || { echo "FAIL: repo $repo missing"; exit 1; } git -C "$repo" rev-parse --verify "$PINNED" >/dev/null 2>&1 \ || { echo "FAIL: pinned $PINNED not found"; exit 1; } [ -f "$tsv" ] || { echo "FAIL: $tsv missing"; exit 1; } # Independent re-derivation straight from the pinned HEAD, not from HEAD itself. expected=$(git -C "$repo" log --date=short --pretty=format:%ad "$PINNED" | awk 'NF' \ | sort | uniq -c | sort -k2) fail=0 # Per-row comparison: date (field 2 of expected) vs count (field 2 of TSV). while IFS=$'\t' read -r d c; do [ -z "${d:-}" ] && continue case "$d" in date|TOTAL) continue;; esac exp=$(printf '%s\n' "$expected" | awk -v d="$d" '$2==d {print $1}') if [ "${exp:-}" != "$c" ]; then echo "FAIL: $d expected $exp, got $c" fail=1 fi done < "$tsv" # Total comparison. exp_total=$(printf '%s\n' "$expected" | awk '{s+=$1} END {print s+0}') act_total=$(awk -F'\t' 'NR>1 && $1!="TOTAL" {s+=$2} END {print s+0}' "$tsv") if [ "$exp_total" != "$act_total" ]; then echo "FAIL: total expected $exp_total, got $act_total" fail=1 fi # No missing rows. missing=$(comm -23 \ <(printf '%s\n' "$expected" | awk '{print $2}' | sort) \ <(awk -F'\t' 'NR>1 && $1!="TOTAL" {print $1}' "$tsv" | sort) | tr '\n' ' ') if [ -n "${missing:-}" ]; then echo "FAIL: rows missing from table: $missing" fail=1 fi if [ "$fail" -eq 0 ]; then n=$(awk -F'\t' 'NR>1 && $1!="TOTAL" {n++} END {print n+0}' "$tsv") echo "PASS: 2026-10-27 commit census verified ($act_total commits, $n rows)" exit 0 fi echo "CHECK FAIL" >&2 exit 1