"Offline batch evidence tooling; no upstream execution." import hashlib import json from build_definition import OUT, REF, REPO, build, canonical from inventory import inventory def main(): b = build() seen = set() for e in b["sources"]: p = (OUT / e["local_file"]).resolve() raw = p.read_bytes() assert hashlib.sha256(raw).hexdigest() == e["sha256"] assert 1 <= e["lines"][0] <= e["lines"][1] <= len(raw.decode().splitlines()) seen.add(str(p)) if "git_blob_sha1" in e: assert ( hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == e["git_blob_sha1"] ) parent = OUT.parent / "moge3-reference" if e["id"] == "frontend" else p.parent t = json.loads((parent / (e["id"] + "-tree.json")).read_bytes()) assert t["sha"] == e["commit"] and not t["truncated"] assert next(x["sha"] for x in t["tree"] if x["path"] == e["file"]) == e["git_blob_sha1"] ids = json.loads((REF / "identities.json").read_bytes()) ids += [ i for i in json.loads((OUT.parent / ("moge3-reference/identities.jso" + "n")).read_bytes()) if i["id"] in ["frontend", "core"] ] for i in ids: root = REF if i["id"] in ["llama", "showtext"] else OUT.parent / "moge3-reference" raw = (root / (i["id"] + "-commit.txt")).read_bytes() assert ( hashlib.sha1(b"commit " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == i["commit"] ) assert raw.decode().splitlines()[0] == "tree " + i["tree"] if i.get("tag"): assert i["commit"] in (root / (i["id"] + "-tag.txt")).read_text() assert "LICENSE" not in [ e["path"] for e in json.loads((REF / "llama-tree.json").read_bytes())["tree"] ] inv = inventory() assert len(inv["fields"]) == 33 and not inv["notes"] for a, f in zip(inv["fields"], b["fields"], strict=True): assert (a["pointer"], a["scope"], a["json_type"], canonical(a["value"])) == ( f["pointer"], f["scope"], f["json_type"], canonical(f["value"]), ) g = json.loads((REPO / b["source_path"]).read_bytes()) assert "frontendVersion" not in g.get("extra", {}) and not g.get("definitions") ns = {n["id"]: n for n in g["nodes"]} for n in g["nodes"]: assert n["mode"] == 0 and "widgets_values_named" not in n assert not {"cnr_id", "aux_id", "ver"} & n["properties"].keys() for eid, src, slot, dst, inp, _ in g["links"]: assert eid in ns[src]["outputs"][slot]["links"] assert ns[dst]["inputs"][inp]["link"] == eid (OUT / "source-check.json").write_text( json.dumps( dict( all_pass=True, cited_texts=len(seen), citations=len(b["sources"]), counts=b["counts"], local_file_base=str(OUT.relative_to(REPO)), upstream_executed=False, source_identity="undeclared", all_reference_versions_are_hypotheses=True, missing_llama_license=True, ), ensure_ascii=False, indent=2, ) + "\n" ) print( ( "PASS bytes/Git provenance, all 33 positions a" "nd four physical edges; no source identity in" "vented" ) ) if __name__ == "__main__": main()