from pathlib import Path
import argparse
import copy
import csv
import hashlib
import io
import json
import re

parser = argparse.ArgumentParser()
parser.add_argument("--actual")
parser.add_argument("--local-http", action="store_true")
args = parser.parse_args()
checks = []
def check(condition, label):
    if not condition:
        raise ValueError(label)
    checks.append(label)
def load(name): return json.loads(Path(name).read_text())
def rows(name): return list(csv.DictReader(io.StringIO(Path(name).read_text(encoding="utf-8-sig"))))
def negative(fn, value, label):
    try: fn(value)
    except (ValueError, AssertionError, KeyError, TypeError, IndexError): checks.append(label)
    else: raise AssertionError("Negative input accepted: " + label)
result=load("result.json")
check(result["model_called"] is False,"framework execution explicitly has no model")
check(result["checks"]>=5,"actual framework assertions ran")
check(result["processes"]==2,"two child processes executed")
check(len(result["first"]["processed"])==1 and len(result["resumed"]["processed"])==3,"one-to-three resume verified")
def validate(v):
    if v.get("model_called") is not False or v.get("checks",0)<5: raise ValueError("invalid framework proof")
bad=copy.deepcopy(result);bad["checks"]=0;negative(validate,bad,"missing actual assertions rejected")
report={"layer":"offline/material checks, not proof of unrun product or model", "checks":checks, "count":len(checks)}
Path("verification.json").write_text(json.dumps(report,ensure_ascii=False,indent=2))
print(json.dumps(report,ensure_ascii=False))
