sol: fix sol_lane_status CHECK exp_counts + add triage-seed manifest and verifier

This commit is contained in:
sol authored and ledger committed 2026-10-27 17:33:39 +00:00
1 parent 23165370fa
commit 9c325b7f50
1 file changed
+49 -38
@@ -1,50 +1,61 @@
#!/usr/bin/env bash
# CHECK — verifier for the check-in census per-file extract (Extract lane).
#
# Exit 0 iff the committed TSV is byte-identical to an INDEPENDENT recompute
# of `checkins/*.md` (README.md excluded) straight from the filesystem, using
# only ls/sed/cut/sort/uniq/awk/wc (no Python, no shared extractor logic).
# The source dir is static (files added per-day, never rewritten), so this
# CHECK is stable across runs.
#
# Repo root is derived from this file's directory, so the CHECK runs from any
# working directory and does not depend on a specific clone path.
# 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="$(cd ../.. && pwd)"
SRC="$REPO_ROOT/checkins"
OUT="$REPO_ROOT/wizard-work/ledger/checkin-census-2026-10-27.tsv"
repo=/root/troupe-standup
tsv=2026-10-27-commit-census.tsv
test -s "$OUT" || { echo "FAIL: TSV missing or empty: $OUT" >&2; exit 1; }
# 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; }
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT
[ -f "$tsv" ] || { echo "FAIL: $tsv missing"; exit 1; }
{
echo "date,wizard,size"
for f in "$SRC"/*.md; do
[ -e "$f" ] || continue
n=$(basename "$f" .md)
[ "$n" = "README" ] && continue
date=${n:0:10}
rest=${n:11}
rest=${rest%-[0-9]*}
echo "$date,$rest,${n},$(wc -c < "$f")"
done | sort -t, -k2,2 -k1,1
n="$(
ls "$SRC"/*.md 2>/dev/null | grep -v 'README\.md$' | wc -l
)"
b="$(find "$SRC" -type f ! -name 'README.md' -printf '%s\n' | awk '{s+=$1} END {print s}')"
echo "TOTAL,$n,$b"
} > "$tmp"
# 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)
if cmp -s "$OUT" "$tmp"; then
echo "PASS: rows=$(tail -n +2 "$OUT" | grep -c .) (per-file checkin rows + TOTAL) recomputed from $SRC"
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 "FAIL: census mismatch against independent recompute" >&2
diff -u "$OUT" "$tmp" >&2 || true
echo "CHECK FAIL" >&2
exit 1