ЛР5: закрыть review края broker, staging replay и полной валидации изображений
This commit is contained in:
+12
-13
@@ -1,4 +1,4 @@
|
||||
"""Compare actual container source bytes to the repository and fault-study image."""
|
||||
"""Verify final container source bytes without attributing old experiments to a new image."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
@@ -8,16 +8,15 @@ 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")
|
||||
instances = []
|
||||
for cid in ids:
|
||||
actual = json.loads(subprocess.check_output(["docker", "exec", cid, "python", "-c", probe], text=True))
|
||||
assert actual == expected, "Runtime source differs from repository"
|
||||
identity = json.loads(subprocess.check_output(["docker", "inspect", cid], text=True))[0]
|
||||
instances.append({"container_id": cid, "image_id": identity["Image"], "source_matches_repository": True})
|
||||
result = {"instances": instances, "runtime_source_sha256": expected,
|
||||
"passed": True,
|
||||
"fault_scope": "The repeated 11 fault scenarios and 9 extra invariants ran after worker/jobs/UTF-8/image-validation fixes. Only the shared validate_image wrapper's killpg/output failure guards were tightened afterward. The complete final 179-case suite and 40M image runs used this final image; no full-image identity with the preceding fault run is claimed."}
|
||||
Path("evidence/review-runtime-source.json").write_text(json.dumps(result, indent=2))
|
||||
print("PASS: both final API containers match repository source")
|
||||
|
||||
Reference in New Issue
Block a user