from pathlib import Path import hashlib,json,shutil,sys out=Path(__file__).resolve().parent;private=Path('C:/Users/macbook/.config/investmoz/parques-L1-QA-20261016');qa=private/'source';compat=private/'compatibility-build-source';root=out.parents[1] sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest();m=json.loads((out/'MANIFESTO-CANDIDATA.json').read_text('utf-8'));mode=sys.argv[1];assert mode in ['candidate','compatible'] for x in m['sources']: n=x['path'];src=(private/'candidate-sources'if mode=='candidate'else compat)/n if mode=='compatible' and n in ['app/Services/InvestmentZoneOperationalDetailsInstallation.php','resources/js/components/investment-zone-operational-details.tsx']: if(qa/n).exists():(qa/n).unlink() else:shutil.copy2(src,qa/n) build=private/('candidate-build'if mode=='candidate'else 'compatibility-build');target=(qa/'public/build').resolve();assert target.is_relative_to(qa.resolve()) shutil.rmtree(target);shutil.copytree(build,target) for p in(qa/'storage/framework/views').glob('*.php'):p.unlink() if mode=='compatible':assert sha(qa/'resources/js/pages/investment/zone.tsx')==m['old_editor_sha256'] (out/('REVERSAO-APLICADA-QA.json'if mode=='compatible'else 'CANDIDATA-REPOSTA-QA.json')).write_text(json.dumps({'mode':mode,'QA_only':True,'old_editor_exact':mode=='compatible','schema_and_data_preserved':True,'retained_functional_sources':8}), 'utf-8') print('Private QA switched to '+mode+'; schema and business data untouched')