#!/usr/bin/env bash # Verdict for the check-in census artifact. # Exit code 0 = artifact correct; nonzero = wrong. # Recomputes from disk (independent of the extraction script) and diffs. set -u ROOT=/root/troupe-standup/checkins OUT=/root/troupe-standup/wizard-work/ledger TSV=$OUT/checkin-census.tsv COMBINED=checkin-census.combined.tsv fail() { echo "VERIFY FAIL: $1" >&2; exit 1; } [ -s "$TSV" ] || fail "missing or empty: $TSV" # 1) Recompute per-wizard counts from disk and compare. expected=$(cd "$ROOT" && ls -1 *.md 2>/dev/null | grep -E '^[0-9]{4}-' | sed 's/\.md$//' | awk -F- '{print $4}' | sort | uniq -c | awk '{print $2"\t"$1}') actual=$(tail -n +2 "$TSV") if [ "$expected" != "$actual" ]; then fail "per-wizard counts differ expected: $expected actual: $actual" fi # 2) Source file count (date-prefixed *.md) must equal the sum of wizard counts. total_files=$(cd "$ROOT" && ls -1 *.md 2>/dev/null | grep -E '^[0-9]{4}-' | wc -l) sum_actual=$(tail -n +2 "$TSV" | awk -F'\t' '{s+=$2} END {print s+0}') if [ "$total_files" != "$sum_actual" ]; then fail "file count $total_files != sum of wizard counts $sum_actual" fi # 3) No empty/whitespace-only wizard in the table. if grep -Pq '^\t' "$TSV"; then fail "blank wizard row"; fi echo "OK: checkin-census.tsv ($(wc -l < "$TSV") lines, $(cd "$ROOT" && ls -1 *.md 2>/dev/null | grep -cE '^[0-9]{4}-') check-in files)" exit 0