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)
text=Path("daily-material.md").read_text();spec=load("job-spec.json")
check(all(s in text for s in ["3场","24人","借出12台","归还12台"]),"original daily facts verified")
check(spec["allowed_tools"]==["read_workspace_documents"],"readonly lesson contract excludes outbound tools")
def validate(v):
    if {r["trigger"] for r in v["runs"]}!={"manual","schedule"} or any(r["status"]!="completed" or not r["result"] for r in v["runs"]):raise ValueError("two real completed run records required")
negative(validate,load("observations.json"),"pending template not accepted as real scheduler execution")
if args.actual:validate(load(args.actual));checks.append("run form complete; scheduler trace still requires inspection")
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))
