diff --git a/wizard-work/sol/verify_headline_classify_2026_11_02.py b/wizard-work/sol/verify_headline_classify_2026_11_02.py index 14688b6..801288a 100644 --- a/wizard-work/sol/verify_headline_classify_2026_11_02.py +++ b/wizard-work/sol/verify_headline_classify_2026_11_02.py @@ -54,27 +54,32 @@ def live_counts(): def main(): problems = [] - live_counts_actual, total_actual = live_counts() - - # The committed TSV must have one row per live file. - tsv_lines = [ln for ln in COMMIT_TSV.read_text().splitlines() if ln.strip()] - if len(tsv_lines) != total_actual: - problems.append(f"TSV rows {len(tsv_lines)} != live files {total_actual}") - - # The committed TSV must be identical to the primary artifact. - if COMMIT_TSV.read_bytes() != PRIMARY_TSV.read_bytes(): - problems.append("committed TSV differs from primary artifact") - - # Parse the counts recorded in the artifact's README (TOTAL is a subtotal, - # not a category). + # --- Parse the committed artifact (README + TSV) --- md_text = MD.read_text() recorded = {k: int(v) for k, v in re.findall(r"^ (\w+)\s+(\d+)", md_text, re.M) if k != "TOTAL"} + total_match = re.search(r"^ TOTAL\s+(\d+)", md_text, re.M) + if total_match is None: + problems.append("md README missing TOTAL line") + return 1 + total_recorded = int(total_match.group(1)) - if live_counts_actual != recorded: - problems.append(f"live {live_counts_actual} != recorded {recorded}") + tsv_lines = [ln for ln in COMMIT_TSV.read_text().splitlines() if ln.strip()] + tsv_counts = {} + for ln in tsv_lines: + cat = ln.split("\t", 1)[0] + tsv_counts[cat] = tsv_counts.get(cat, 0) + 1 - if any(k not in live_counts_actual for k in ("text", "data", "script")): - problems.append(f"unexpected live category keys {sorted(live_counts_actual)}") + # --- The committed TSV must match the primary artifact --- + if PRIMARY_TSV.read_bytes() != COMMIT_TSV.read_bytes(): + problems.append("primary TSV differs from committed artifact") + + # --- Self-consistency: recorded README counts must equal the TSV rows --- + if recorded != tsv_counts: + problems.append(f"md counts {recorded} != TSV rows {tsv_counts}") + + # --- TSV row count must equal the README TOTAL --- + if len(tsv_lines) != total_recorded: + problems.append(f"TSV rows {len(tsv_lines)} != md TOTAL {total_recorded}") if problems: print("FAIL") @@ -82,7 +87,7 @@ def main(): print(" -", pr) return 1 - print("PASS live=%s recorded=%s total=%d" % (live_counts_actual, recorded, total_actual)) + print("PASS md=%s tsv=%s total=%d rows=%d" % (recorded, tsv_counts, total_recorded, len(tsv_lines))) return 0