#!/usr/bin/env bash
# Verdict for the ledger commit census artifact (as of pinned HEAD 2d8254dd...).
# Exit code 0 = artifact correct; nonzero = wrong.
set -u
cd /root/troupe-standup/wizard-work/ledger || exit 1
SHA=2d8254dd1335675905ee82fa39ae6cb56edefd82
tsv_sum=$(tail -n +2 2026-10-26-commit-census-as-of-HEAD.tsv | awk -F'\t' 'NF{s+=$2} END{print s+0}')
git_count=$(git -C /root/troupe-standup rev-list --count "$SHA")
if [ "$tsv_sum" = "$git_count" ]; then
  echo "OK $git_count"
  exit 0
fi
echo "MISMATCH tsv=$tsv_sum git=$git_count" >&2
exit 1
