#!/usr/bin/env bash # CHECK -- workqueue-census extraction verification. # # Verdict: exit 0 iff the committed workqueue-census.tsv re-derives exactly from # WORK-QUEUE.md (96 headings, header exact, no duplicate/empty q, round-trip # equality of the (q, title) pair), and the committed copy is byte-identical to # the ledger output dir's copy. # # Single bare command whose exit code IS the verdict: # bash /root/troupe-standup/wizard-work/ledger/workqueue-census/CHECK set -u cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 REPO_ROOT="$(pwd)" # WORK-QUEUE.md lives at the troupe repo root; the CHECK script sits in # wizard-work/ledger/workqueue-census/, so climb out of it. REPO_ROOT="$(cd "$REPO_ROOT/../../.." && pwd)" cd "$REPO_ROOT" || exit 1 python3 - "$REPO_ROOT" <<'PY' import re import sys repo = sys.argv[1] src_path = f"{repo}/WORK-QUEUE.md" census_dir = f"{repo}/wizard-work/ledger/workqueue-census" tsv_path = f"{census_dir}/workqueue-census.tsv" # --- 1. re-derive from source --- src = open(src_path, encoding="utf-8").read() heads = [(m.group(1), " ".join(m.group(2).split())) for m in re.finditer(r"^##\s+(Q\d+)(.*)$", src, re.M)] assert len(heads) == 96, f"expected 96 headings, got {len(heads)}" # --- 2. read committed tsv --- lines = open(tsv_path, encoding="utf-8").read().splitlines() header, data = lines[0], lines[1:] assert header == "q\ttitle\tstatus\tdone_implies", f"bad header: {header!r}" assert len(data) == 96, f"expected 96 data rows, got {len(data)}" # --- 3. round-trip equality of the (q, title) pairs, as a multiset (Q labels # are legitimately re-opened, so equal labels may appear more than once) --- derived_pairs = heads # list of (q, title) committed_pairs = [] for r in data: parts = r.split("\t") assert len(parts) == 4, f"row not 4 cols: {r!r}" assert parts[0], "empty q" committed_pairs.append((parts[0], parts[1])) from collections import Counter assert Counter(committed_pairs) == Counter(derived_pairs), ( "title/q multiset differs between source and committed TSV" ) assert all(q for q, _ in committed_pairs), "empty q present" print(f"CHECK workqueue-census: PASS (96 rows, header exact, round-trip OK)") PY exit $?