24 lines
1.5 KiB
Python
24 lines
1.5 KiB
Python
"""Compare actual container source bytes to the repository and fault-study image."""
|
|
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
ids = subprocess.check_output(["docker", "compose", "ps", "-q", "api"], text=True).split()
|
|
assert ids
|
|
probe = "import hashlib,json,pathlib; p=pathlib.Path('/app/src/messenger'); print(json.dumps({x.name:hashlib.sha256(x.read_bytes()).hexdigest() for x in sorted(p.glob('*.py'))}))"
|
|
actual = json.loads(subprocess.check_output(["docker", "exec", ids[0], "python", "-c", probe], text=True))
|
|
expected = {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(Path("src/messenger").glob("*.py"))}
|
|
assert actual == expected, "Runtime source differs from repository"
|
|
old = json.loads(Path("evidence/fault-runtime-source.json").read_text())
|
|
changed = sorted(name for name, digest in actual.items() if digest != old["source_sha256"].get(name))
|
|
assert set(changed) <= {"domain.py"}, changed
|
|
result = {"runtime_container_id": ids[0], "runtime_source_sha256": actual,
|
|
"fault_image_id": old["image_id"], "changed_after_fault_image": changed,
|
|
"pipeline_modules_identical": True,
|
|
"explanation": "Only shared cursor parsing was tightened after fault tests; complete final HTTP suite checks it. All pipeline/outbox/storage modules are byte-identical.",
|
|
"passed": True}
|
|
Path("evidence/runtime-source.json").write_text(json.dumps(result, indent=2))
|
|
print("PASS: runtime matches repository; fault-tested pipeline modules are identical")
|