Files
Investidor-V2/outputs/investmoz-editorial-QA-20261018/freeze-release.py
T
nala cf003c8623
tests / ci (push) Canceled after 0s
versao nrgocios 4
2026-10-18 15:57:06 +02:00

25 lines
4.0 KiB
Python

from pathlib import Path
import json,shutil,hashlib,zipfile
r=Path.cwd();o=Path(__file__).resolve().parent;q=Path('C:/Users/macbook/.config/investmoz/editorial-QA-20261018/source');c=q.parent/'compatible-reversal';hist=o/'historico-d5e7fda5e0d4';hist.mkdir(exist_ok=False)
for n in ['MANIFESTO-QA.json','DELTA.patch','RECIBO-QA.json','RELATORIO-QA.md','manual-atual.md']:shutil.copy2(o/n,hist/n)
exec(compile((o/'finalize.py').read_text('utf8'),str(o/'finalize.py'),'exec'))
m=json.loads((o/'MANIFESTO-QA.json').read_text('utf8'));sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest();rel=o/'para-revisao';rel.mkdir(exist_ok=True)
public={**m,'sources':[{**d,'before_sha256':d['before'],'after_sha256':d['after']} for d in m['sources']],'build':[{'path':n,'sha256':v} for n,v in m['build'].items()]}
(rel/'MANIFESTO-QA.json').write_text(json.dumps(public,ensure_ascii=False,indent=2),'utf8')
rollback={'candidate':m['candidate'],'scope':'Compatible partial UI reversal after use, not data rollback','retains_schema_and_history':True,'retained_runtime_readers':['app/Http/Controllers/EditorialArticleController.php','app/Services/LegacyContent.php','app/Http/Controllers/PortalServicesController.php','routes/web.php','resources/js/pages/portal/article.tsx','resources/js/pages/portal/document.tsx'],'restored_previous_sources':['resources/js/pages/portal/manage.tsx','resources/js/pages/management/editor.tsx','app/Http/Controllers/PortalManagementController.php'],'sources':[{'path':d['path'],'sha256':sha(c/d['path'])} for d in m['sources']],'build':[{'path':p.relative_to(c).as_posix(),'sha256':sha(p)} for p in sorted((c/'public/build').rglob('*')) if p.is_file()]}
(rel/'MANIFESTO-REVERSAO.json').write_text(json.dumps(rollback,ensure_ascii=False,indent=2),'utf8')
with zipfile.ZipFile(rel/'REVERSAO-COMPATIVEL.zip','w',zipfile.ZIP_DEFLATED) as z:
for x in rollback['sources']+rollback['build']:z.write(c/x['path'],x['path'])
shutil.copy2(o/(m['candidate']+'.zip'),rel/(m['candidate']+'.zip'))
auth={'at':'2026-10-18','owner':'Tempo, Lda.','decision':'a Tempo autoriza a disponibilização','scope':'Gestão editorial autónoma, delta nominal160000, respetivo código/build e acessos; sem publicar conteúdos de negócio ou repetir instalações aceites','candidate':m['candidate'],'revision_sha256':m['revision_sha256'],'source':'mensagem expressa do utilizador nesta conversa; autorização mantém-se'}
(rel/'AUTORIZACAO-TEMPO.json').write_text(json.dumps(auth,ensure_ascii=False,indent=2),'utf8')
a=r/'outputs/investmoz-editorial-ativacao-20261018';a.mkdir(exist_ok=False);shutil.copy2(rel/'AUTORIZACAO-TEMPO.json',a/'AUTORIZACAO-TEMPO.json')
base=json.loads((o/'ATIVO-ANTES.json').read_text('utf8'));(a/'ATIVO-ANTES.json').write_text(json.dumps({'files':base,'protected':{n:sha(r/n) for n in ['.env','composer.lock','package-lock.json']}},indent=2),'utf8')
# Reuse the proven fresh-backup/read-only restore procedure with this fixed manifest and nominal target.
s=(r/'outputs/investmoz-documentos-publicos-ativacao-20261018/fresh-backup.php').read_text('utf8').replace('investmoz-documentos-publicos-QA-20261018','investmoz-editorial-QA-20261018').replace('documentos-publicos-QA-629d8347f147',m['candidate']).replace('public-documents-before-','editorial-before-').replace('public_documents_before_','editorial_before_')
(a/'fresh-backup.php').write_text(s,'utf8')
for n in ['verify-restored-files.py','cache-snapshot.php','verify-data.php']:
s=(r/'outputs/investmoz-documentos-publicos-ativacao-20261018'/n).read_text('utf8').replace('documentos-publicos-QA-629d8347f147',m['candidate']);(a/n).write_text(s,'utf8')
boot=(r/'outputs/investmoz-documentos-publicos-ativacao-20261018/boot-restored-clone.php').read_text('utf8').replace('documentos-publicos-QA-629d8347f147',m['candidate']).replace('public_documents_before_','editorial_before_');(a/'boot-restored-clone.php').write_text(boot,'utf8')
print(json.dumps({'fixed_candidate':m['candidate'],'revision':m['revision_sha256'],'sources':len(m['sources']),'build':len(m['build']),'reversal_build':len(rollback['build']),'authorization_recorded':True},indent=2))