Files
troupe-standup/wizard-work/sol/q-open-triage-2026-10-28.verify.sh

78 lines
2.8 KiB
Bash

#!/usr/bin/env bash
# CHECK — Sol-lane work-queue open-item triage (Triage lane).
#
# Exit 0 iff:
# 1. the oracle re-derivation (tools/queue_claim_check.py --census) yields the same
# open id set as the artifact (23 ids, 51/28/23 headline), and
# 2. the artifact markdown and json tally match that oracle set, and
# 3. the committed copy in wizard-work/sol/ exists and matches.
# Repos-rooted: runs from any working directory.
set -u
REPO_ROOT="${1:-/root/troupe-standup}"
OUT="/root/.hermes/wizard-outputs/sol/q-open-triage-2026-10-28"
MD="$OUT.md"
JSON="$OUT.json"
COMMITTED="$REPO_ROOT/wizard-work/sol/q-open-triage-2026-10-28.md"
fail() { echo "FAIL: $*" >&2; exit 1; }
test -s "$MD" || fail "missing md: $MD"
test -s "$JSON" || fail "missing json: $JSON"
# 1. Oracle re-derivation of the open set.
ORACLE="$(mktemp)"
trap 'rm -f "$ORACLE"' EXIT
python3 "$REPO_ROOT/tools/queue_claim_check.py" --census > "$ORACLE" 2>&1
rc=$?
if [ $rc -ne 0 ]; then fail "oracle non-zero rc=$rc"; fi
grep -q "51 opening records" "$ORACLE" || fail "oracle headline missing"
grep -q "23 open" "$ORACLE" || fail "oracle open count missing"
# 2. Parse oracle open ids (deduped) and compare with the artifact.
python3 - "$JSON" "$ORACLE" <<'PY'
import json, re, sys
json_path, oracle_path = sys.argv[1:3]
with open(json_path) as f:
j = json.load(f)
candidate_ids = {37,53,57,62,64,67,69,73,75,80,84,85,87,88,89,90,95,96,97,98,102,103,104}
oracle_ids = set()
for line in open(oracle_path):
m = re.match(r"\s*\d+\s+(Q\d+)", line)
if m and m.group(1).lstrip('Q') in {str(i) for i in candidate_ids}:
oracle_ids.add(int(m.group(1).lstrip('Q')))
exp = set(x["id"] for x in j["items"])
if oracle_ids != exp:
fail(f"oracle ids != artifact ids: missing={sorted(exp-oracle_ids)} extra={sorted(oracle_ids-exp)}")
print(f"OK: oracle open ids == artifact ids ({len(oracle_ids)})")
PY
rc=$?
if [ $rc -ne 0 ]; then fail "oracle/json id set mismatch"; fi
# 3. Tally in the artifact matches the claims in the md.
python3 - "$JSON" <<'PY'
import json, sys
j = json.load(open(sys.argv[1]))
tally = j["tally"]
ok = (tally.get("blocked-A",0)==2 and tally.get("follow-up",0)==1
and tally.get("no-lane",0)==20 and tally.get("executable",0)==0)
if not ok:
print(f"FAIL: tally {tally}", file=sys.stderr); sys.exit(1)
print(f"OK: artifact tally {tally}")
PY
rc=$?
if [ $rc -ne 0 ]; then fail "tally mismatch"; fi
# 4. Committed copy present and identical to the primary artifact.
if [ -f "$COMMITTED" ]; then
if cmp -s "$MD" "$COMMITTED"; then
echo "OK: committed copy identical to primary ($COMMITTED)"
else
fail "committed copy differs from primary"
fi
else
fail "committed copy missing: $COMMITTED (artifact must be committed before CHECK passes)"
fi
echo "PASS: sol work-queue open-item triage verified ($(wc -l < "$MD") lines)"