Files
Investidor-V2/outputs/investmoz-parques-QA-20261016/seal-package.py
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

41 lines
5.8 KiB
Python

from pathlib import Path,PurePosixPath
import json,hashlib,shutil,zipfile,datetime
out=Path(__file__).resolve().parent;root=out.parents[1];private=Path('C:/Users/macbook/.config/investmoz/parques-QA-20261016');qa=private/'source';dest=out/'para-revisao';sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest();load=lambda p:json.loads(p.read_text('utf-8'))
candidate=load(out/'CANDIDATA.json');m=load(dest/'MANIFESTO-CANDIDATA.json');compat=load(dest/'MANIFESTO-COMPATIBILIDADE.json');assert m['candidate']==candidate['candidate']
for n,v in load(root/'outputs/investmoz-parques-mapa-20261016/DOC01/RECIBO-INTEGRIDADE.json')['documents'].items():assert sha(root/'outputs/investmoz-parques-mapa-20261016/DOC01'/n)==v['sha256']
baseline=load(out/'ATIVO-ANTES.json');actual={p.relative_to(root).as_posix():sha(p)for folder in ['app','config','routes','database','resources','public/build']for p in(root/folder).rglob('*')if p.is_file()};assert actual==baseline['files'];assert all(sha(root/n)==h for n,h in baseline['protected'].items())
installer=load(out/'INSTALADOR-CANDIDATA-FINAL.json');installer['scope']='Final candidate includes the directed pending-location fix; the seven final retained variants were exercised by the old-editor v13 save, without active changes.';(out/'INSTALADOR-CANDIDATA-FINAL.json').write_text(json.dumps(installer,ensure_ascii=False,indent=2)+'\n','utf-8');shutil.copy2(out/'INSTALADOR-CANDIDATA-FINAL.json',dest/'INSTALADOR-CANDIDATA-FINAL.json')
shutil.copy2(out/'HISTORICO-PRESERVADO-QA.json',dest/'HISTORICO-PRESERVADO-QA.json')
files={}
for row in m['sources']:
n=row['path'];p=qa/n;assert sha(p)==row['candidate_sha256'];assert (sha(root/n)if(root/n).exists()else None)==row['before_sha256'];files['candidate/sources/'+n]=p
for n,h in m['build'].items():assert sha(qa/'public/build'/n)==h;files['candidate/build/'+n]=qa/'public/build'/n
for n,h in compat['application_files'].items():
p=(private/'compatibility-build-source'/n) if n in compat['retained_functional_sources'] else root/n if(root/n).exists()else qa/n
assert sha(p)==h,(n,h,sha(p));files['compatibility/sources/'+n]=p
for n,h in compat['build'].items():assert sha(private/'compatibility-build'/n)==h;files['compatibility/build/'+n]=private/'compatibility-build'/n
for p in dest.iterdir():
if p.is_file()and p.suffix!='.zip'and p.name!='RECIBO-INTEGRIDADE.json':files['documents/'+p.name]=p
for name in ['VISUAL-CANDIDATA.png','VISUAL-EDITOR-FINAL.png','VISUAL-DOSSIER-FINAL.png','VISUAL-MOVEL.png','VISUAL-EDITOR-FINAL-NOVA-SESSAO.txt','VISUAL-CARTOES.txt','VISUAL-DESCONHECIDOS.txt','VISUAL-MOVEL.json','BUILD-CANDIDATE-FINAL.log','BUILD-COMPATIBILITY.log','TYPES-CHECK-FINAL.log','LINT.log','LINT-CARTOES.log']:
files['evidence/'+name]=out/name
index={'candidate':candidate['candidate'],'entries':{n:{'sha256':sha(p),'bytes':p.stat().st_size}for n,p in files.items()},'exclusions':['QA .env/keys','credentials and MFA','cookies and sessions','dumps','raw private payloads','synthetic data to import']}
indexfile=dest/'MANIFESTO-INTEGRIDADE-PACOTE.json';indexfile.write_text(json.dumps(index,indent=2)+'\n','utf-8')
bundle=dest/(candidate['candidate']+'.zip');assert not bundle.exists()
with zipfile.ZipFile(bundle,'w',zipfile.ZIP_DEFLATED,compresslevel=9)as z:
for n,p in files.items():assert '..'not in PurePosixPath(n).parts and not PurePosixPath(n).is_absolute();z.write(p,n)
z.write(indexfile,'MANIFESTO-INTEGRIDADE-PACOTE.json')
with zipfile.ZipFile(bundle)as z:
assert z.testzip()is None and len(z.namelist())==len(files)+1
for n,p in files.items():assert hashlib.sha256(z.read(n)).hexdigest()==sha(p)
assert z.read('MANIFESTO-INTEGRIDADE-PACOTE.json')==indexfile.read_bytes()
assert bundle.stat().st_size<10*1024*1024
receipt={'candidate':candidate['candidate'],'at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'code_hash':candidate['code_hash'],'scope':'QA candidate only; active activation requires a separate explicit decision',
'documents':{p.name:{'sha256':sha(p),'bytes':p.stat().st_size}for p in dest.iterdir()if p.is_file()and p.suffix!='.zip'and p.name!='RECIBO-INTEGRIDADE.json'},
'package':{'name':bundle.name,'sha256':sha(bundle),'bytes':bundle.stat().st_size,'entries':len(files)+1,'all_entries_SHA256':'passed','CRC':'passed'},
'counts':{'candidate_application_artifacts':16,'candidate_build_files':162,'compatibility_application_artifacts':14,'compatibility_build_files':162,'retained_functional_sources':7},
'proof':{'HTTP_checks':73,'HTTP_requests':183,'old_editor_save_versions':[12,13],'public_version_preserved_during_final_save':11,'dossier_consulted_version':5,'original_immutable_revisions_preserved':36,'restored_QA_tables':171,'restored_QA_sequences':31,'restored_private_files':2,'final_sources_build_verified_in_restored_clone':178,'active_source_build_files_unchanged':989,'active_config_locks_unchanged':3,'active_connections':0,'global_accepted_tests_repeated':False},
'matrix':load(out/'MATRIZ-ATUALIZACAO.json'),'backlog_sha256':sha(root/'docs/investmoz/v2/auditoria-portal/backlog.md'),'limits':['QA clone is not current complete active database','No volumetric test','Optional CAE linkage has no substantive park positive case claimed','Partial compatible rollback retains seven sources and migration; old UI has no new reconciliation control','No real park data classified or published','Full parks sheet and other gaps remain open'],
'estimate':{'QA_historical_hours':[24,37],'QA_remaining_hours':0,'future_operational_hours':[2,4],'hours_consumed_claimed':False}}
(dest/'RECIBO-INTEGRIDADE.json').write_text(json.dumps(receipt,ensure_ascii=False,indent=2)+'\n','utf-8')
print(json.dumps({'candidate':candidate['candidate'],'package':receipt['package'],'receipt_sha256':sha(dest/'RECIBO-INTEGRIDADE.json'),'documents':{n:v['sha256']for n,v in receipt['documents'].items()if n.endswith('.md')or n.startswith('MANIFESTO-CANDIDATA')or n.startswith('MANIFESTO-COMPATIBILIDADE')}}))