diff --git a/wizard-work/spark/verify_csv.py b/wizard-work/spark/verify_csv.py index 277c099..0d69954 100644 --- a/wizard-work/spark/verify_csv.py +++ b/wizard-work/spark/verify_csv.py @@ -1,24 +1,40 @@ #!/usr/bin/env python3 -"""Verify CSV output is valid.""" +"""Verify CSV output is valid. + +Exit-safe since 2026-10-27 (Q63's STRIPPED_ASSERT class, found by +volt's Q65 census pass at `c64e39d`): every check below was an `assert`, so +`python3 -O` -- which compiles asserts away -- printed PASS and exited 0 +against a wrong CSV. `assert` is not a failure path; `_check` raises. +The subject and the messages are unchanged; the only difference is that a +failing check now survives -O. +""" import csv import json +import sys + + +def _check(cond, message): + if not cond: + print("FAIL: " + message, file=sys.stderr) + raise SystemExit(1) + # Verify CSV is valid with open('/root/.hermes/wizard-outputs/spark/output.csv', 'r') as f: reader = csv.DictReader(f) rows = list(reader) -assert len(rows) == 2, f"Expected 2 rows, got {len(rows)}" -assert 'name' in rows[0], "Missing 'name' column" -assert rows[0]['name'] == 'Alice Smith', f"Wrong name: {rows[0]['name']}" +_check(len(rows) == 2, f"Expected 2 rows, got {len(rows)}") +_check('name' in rows[0], "Missing 'name' column") +_check(rows[0]['name'] == 'Alice Smith', f"Wrong name: {rows[0]['name']}") # Verify the JSON source was correctly processed with open('/root/.hermes/wizard-outputs/spark/sample_data.json', 'r') as f: source = json.load(f) -assert len(source) == 2, "Source JSON should have 2 records" +_check(len(source) == 2, "Source JSON should have 2 records") print("PASS: CSV is valid with correct data structure") print(f"Records: {len(rows)}") -print(f"Columns: {sorted(rows[0].keys())}") \ No newline at end of file +print(f"Columns: {sorted(rows[0].keys())}")