Files

24 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Validate retained art inputs, fit, review dimensions and v03 preservation only."""
from pathlib import Path
from PIL import Image
import hashlib,json,subprocess,sys
p=Path(__file__).resolve().parent.parent
sha=lambda f:hashlib.sha256(f.read_bytes()).hexdigest()
prior=json.loads((p/'source/prior-revision-hashes.json').read_text())
assert all(sha(p.parent/'v03'/f)==h for f,h in prior.items()), 'v03 changed'
fit=json.loads((p/'source/art-fit.json').read_text())
assert sha(p/'source/art-native.png')==fit['sourceSHA256']
assert sha(p/'source/art-master.png')==fit['outputSHA256']
expected={'source/art-master.png':[2000,2800],'review/art-review.png':[1000,1400],'review/art-card-size.png':[500,700],'review/art-thumbnail.png':[250,350]}
before={f:sha(p/f) for f in expected}
for f,size in expected.items():
with Image.open(p/f) as im:
assert list(im.size)==size
assert im.mode=='RGB'
subprocess.run([sys.executable,str(p/'source/fit-art.py')],check=True)
assert before=={f:sha(p/f) for f in expected}, 'fit not byte-repeatable'
result={'status':'pass','scope':'Art source/fit/review only; no card assembly or material validation','priorRevision':'v03','priorFilesUnchanged':len(prior),'nativeSourceHashVerified':True,'masterHashVerified':True,'reviewDimensions':expected,'repeatableFitAndReviews':True,'nonCloudPixelIdentity':'Not claimed; visually reviewed generative edit'}
(p/'review/source-validation.json').write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps(result,indent=2))