from pathlib import Path import json,zipfile,hashlib,re R=Path(__file__).resolve().parent; ROOT=R.parents[1] Q=ROOT/'storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742' sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() base=R/'investmoz-B-posicoes-tecnicas-QA-revisao-20261013.zip' assert sha(base)=='5b3676a25555e140b783350eb9379a6911dcf1ef62bf0d67271ded5244d288dc' with zipfile.ZipFile(base) as z: names={n[len('delta-QA/'):] for n in z.namelist() if n.startswith('delta-QA/')} expected={n:hashlib.sha256(z.read('delta-QA/'+n)).hexdigest() for n in names} for n in ['case32-reauth-delta-manifest-20261014.json','case32-C147-delta-manifest-20261014.json','case32-C148-delta-manifest-20261014.json']: expected.update(json.loads((R/n).read_text(encoding='utf-8'))['effective_product_source_files']) for rel,copy in [('resources/js/pages/investment/business-wizard.tsx','line07-submit-feedback-QA-business-wizard-20261015.tsx'),('resources/js/pages/investment/business.tsx','line07-triage-feedback-QA-business-20261015.tsx'),('resources/js/pages/land-assistance/form.tsx','line11-recovery-QA-form-20261015.tsx')]: expected[rel]=sha(R/copy) for n,h in expected.items():assert sha(Q/n)==h, f'Unreconciled QA source: {n}' build=json.loads((Q/'public/build/manifest.json').read_text(encoding='utf-8')) assets={'manifest.json'} for item in build.values(): if item.get('file'):assets.add(item['file']) assets.update(item.get('css',[]));assets.update(item.get('assets',[])) if (Q/'public/build/fonts-manifest.json').exists():assets.add('fonts-manifest.json') for n in list(assets): if n.endswith(('.css','.json')): text=(Q/'public/build'/n).read_text(encoding='utf-8') for url in re.findall(r'(?:/build/)?(assets/[A-Za-z0-9_./-]+\.(?:woff2?|ttf|otf|svg|png|jpg))',text):assets.add(url) for n in assets:assert (Q/'public/build'/n).is_file(),n protected={n:sha(ROOT/n) if (ROOT/n).exists() else None for n in expected} protected['public/build/manifest.json']=sha(ROOT/'public/build/manifest.json') d={'base_revision':'396c691930bc','source_files':expected,'build_files':{n:sha(Q/'public/build'/n) for n in sorted(assets)},'active_protected_hashes':protected,'activation_authorized':False} (R/'B-final-inputs-20261015.json').write_text(json.dumps(d,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') print(json.dumps({'sources':len(expected),'build_files':len(assets),'inputs_verified':True}))