Bound semantic worker storage and add verified evidence closeout
This commit is contained in:
@@ -62,3 +62,37 @@ def test_corrupted_predecessor_refuses_before_staging(tmp_path):
|
||||
def test_escape_rejected(tmp_path, path):
|
||||
with pytest.raises(ValueError):
|
||||
module.confined(tmp_path, path)
|
||||
|
||||
|
||||
def test_learning_patch_keeps_image_and_unrelated_payload(tmp_path):
|
||||
before = {
|
||||
"dataset_store.py": hashlib.sha256(b"old").hexdigest(),
|
||||
"templates.json": hashlib.sha256(b"templates").hexdigest(),
|
||||
}
|
||||
identity = hashlib.sha256(json.dumps(before, sort_keys=True).encode()).hexdigest()
|
||||
base = tmp_path / "releases" / ("semantic-learning-" + identity[:16])
|
||||
base.mkdir(parents=True)
|
||||
(base / "dataset_store.py").write_bytes(b"old")
|
||||
(base / "templates.json").write_bytes(b"templates")
|
||||
manifest = {"id": identity, "files": before, "image": "pinned-image", "schema_version": "v1"}
|
||||
encoded = json.dumps(manifest).encode()
|
||||
(base / "release.json").write_bytes(encoded)
|
||||
recipe = dict(
|
||||
kind="semantic-learning",
|
||||
base_release=identity[:16],
|
||||
base_manifest_sha256=hashlib.sha256(encoded).hexdigest(),
|
||||
overlays={
|
||||
"dataset_store.py": dict(
|
||||
base64=base64.b64encode(b"new").decode(), sha256=hashlib.sha256(b"new").hexdigest()
|
||||
)
|
||||
},
|
||||
)
|
||||
result = module.stage(tmp_path, recipe)
|
||||
target = tmp_path / "releases" / ("semantic-learning-" + result["release"])
|
||||
after = json.loads((target / "release.json").read_text())
|
||||
assert (
|
||||
after["image"] == "pinned-image"
|
||||
and after["files"]["templates.json"] == before["templates.json"]
|
||||
)
|
||||
assert (base / "dataset_store.py").read_bytes() == b"old"
|
||||
assert (target / "dataset_store.py").read_bytes() == b"new"
|
||||
|
||||
Reference in New Issue
Block a user