from hashlib import sha256
from itertools import product


def review(format, custom, pinned, matches):
    if not matches:
        return "Stop: digest mismatch"
    if format == "pickle" or custom:
        return "Code-execution review"
    if not pinned:
        return "Provenance review"
    return "Candidate for controlled review"


# Hash literal bytes only. No loading, unpickling or remote execution.
payload = b"synthetic tensor bytes for notebook only"
expected = sha256(payload).hexdigest()
assert sha256(payload).hexdigest() == expected
assert sha256(payload + b"changed").hexdigest() != expected


# Verification: digest failure dominates, executable paths stay in review.
assert review("safetensors", False, True, False).startswith("Stop")
assert review("safetensors", True, True, True) == "Code-execution review"
fixtures = []
for format, custom, pinned, matches in product(
        ("safetensors", "pickle"), (True, False), (True, False), (True, False)):
    fixtures.append({"inputs": {"format": format,
                                "custom": "yes" if custom else "no",
                                "pinned": "yes" if pinned else "no",
                                "hash": "yes" if matches else "no"},
                     "expected": {"outcome": review(format, custom, pinned, matches)}})

import json
print(json.dumps({"fixtures": fixtures, "checks_passed": True}))
