25 lines
932 B
Python
25 lines
932 B
Python
from mltrail_verifiable_provenance_ledger_for.reprobundle import ReproBundle
|
|
|
|
|
|
def test_reprobundle_deterministic_root():
|
|
components = {
|
|
"code_commit": {"repo": "example", "commit": "abc123"},
|
|
"environment": {"python": "3.9", "deps": {"numpy": "1.26.0"}},
|
|
"run_manifest": {"cmd": "python train.py", "seed": 42},
|
|
}
|
|
b1 = ReproBundle(components)
|
|
b2 = ReproBundle({k: components[k] for k in reversed(list(components.keys()))})
|
|
|
|
# Merkle root must be stable regardless of insertion order
|
|
assert b1.merkle_root() == b2.merkle_root()
|
|
|
|
|
|
def test_reprobundle_detects_change():
|
|
base = {
|
|
"code_commit": {"repo": "example", "commit": "abc123"},
|
|
"environment": {"python": "3.9", "deps": {"numpy": "1.26.0"}},
|
|
}
|
|
b = ReproBundle(base)
|
|
b_changed = ReproBundle({**base, "run_manifest": {"cmd": "python train.py"}})
|
|
assert b.merkle_root() != b_changed.merkle_root()
|