Files
aigc-home/docs/hel-892/batch179-target-snapshots/verify.py
T

55 lines
2.0 KiB
Python

"""Static consistency/freeze verification; no target reads or collector execution."""
import ast
import csv
import json
from audit import HERE, ROOT, load, matrix, receive, references, sha, validate_snapshot, write
def validate_reference_records(records):
# Rebuild only bounded, frozen own-member records; never accept caller-supplied time/identity.
assert records == references()
def main():
baseline = load(HERE / "baseline.json")
assert all(sha((ROOT / r["path"]).read_bytes()) == r["sha256"] for r in baseline["files"])
snapshot, receipt = receive()
validate_snapshot(snapshot)
refs = load(HERE / "reference-catalog.json")
validate_reference_records(refs)
rows = matrix(snapshot, refs)
assert rows == load(HERE / "installation-matrix.json") and len(rows) == 34
with (HERE / "installation-matrix.csv").open(newline="") as stream:
csv_rows = [{k: json.loads(v) for k, v in row.items()} for row in csv.DictReader(stream)]
assert rows == csv_rows
assert all(r["protocol_178_reusable"] is False for r in rows)
assert sum(c["status"] == "no_exact_reference" for r in rows for c in r["candidates"]) == 6
for path in HERE.glob("*.py"):
ast.parse(path.read_text())
write(
"verification.json",
dict(
frozen_files=len(baseline["files"]),
changed_old_files=[],
exceptions=[],
snapshot_entries=len(rows),
csv_json_equal=True,
canonical_references=len(refs),
missing_version_path_references=6,
receipt_archive_sha256=receipt["archive_sha256"],
receipt_crc_sha=True,
target_texts_received=0,
target_requests_this_run=0,
collector_executions_this_run=0,
engine_tests=0,
tools_ast=True,
),
)
print(len(baseline["files"]), "old files frozen; 34 receipt entries and references consistent")
if __name__ == "__main__":
main()