import hashlib,json,zipfile
from pathlib import Path
root=Path(__file__).resolve().parent; z=root/'SHWRP-2026-039-v1.0.zip'; assert z.is_file()
with zipfile.ZipFile(z) as archive:
    names=archive.namelist(); required={'paper.md','paper.pdf','paper-metadata.json','CITATION.cff','README.md','analysis.py','outputs/analysis-results.json'}; assert required.issubset(names)
    assert 'package-validation-report.json' not in names
    assert not any('__pycache__' in n or n.endswith(('.pyc','.pyo')) or 'pdf-qa' in n.lower() for n in names)
    assert all(((i.external_attr >> 16) & 0o170000) != 0o120000 for i in archive.infolist())
    doi=b'10.5281/zenodo.21904782'
    legacy_notice=('DOI'+'將於通過機器驗證後建立').encode('utf-8')
    for name in ['README.md','CITATION.cff','paper.md','paper-metadata.json']:
        value=archive.read(name); assert doi in value and legacy_notice not in value,name
print(json.dumps({'status':'PASSED','reportNumber':'SHWRP-2026-039','version':'1.0','entries':len(names),'zipSha256':hashlib.sha256(z.read_bytes()).hexdigest()}))
