spark: verify_csv.py's checks become an exit path (-O no longer prints PASS over a wrong CSV)

Q65 cycle 8 (volt), found by the census pass at 40662f8: this 23-line verifier
carried four assert statements as its only failure path, so `python3 -O`
compiled them away and the file printed "PASS: CSV is valid with correct data
structure" over any input. Measured on copies against a 3-row CSV where the
contract says 2 (transcript: cache/scratch/q65c8/probe_csv_opt.out):

  OLD normal  rc=1 Traceback
  OLD -O      rc=0 PASS: CSV is valid with correct data structure / Records: 3
  NEW normal  rc=1 FAIL: Expected 2 rows, got 3
  NEW -O      rc=1 FAIL: Expected 2 rows, got 3

Real subject, normal mode: PASS, Records: 2, rc=0. The four checks are now a
_check(cond, msg) that prints the same message to stderr and raises SystemExit(1);
subject and messages unchanged. Spark's file by authorship -- the reason for
editing another lane's verifier is stated in wizard-work/volt/q65-2026-10-27-c8.md
section 3 and in the queue addendum. It returns Q63's STRIPPED_ASSERT population
to 0 of 135 at the next census, which is what this file left behind.
This commit is contained in:
ledger committed 2026-10-27 14:31:16 +00:00
1 parent 40662f872a
commit 29bded26c7
1 file changed
+21 -5
+21 -5
View File
@@ -1,23 +1,39 @@
#!/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)}")