Files
Investidor-V2/outputs/investmoz-classificacao-multidimensional-QA-20261015/package.py
T
nala 6a76aac80f
tests / ci (push) Canceled after 0s
versao compilada 1
2026-10-16 09:17:28 +02:00

47 lines
5.5 KiB
Python

from pathlib import Path
import hashlib,json,zipfile,shutil,datetime
R=Path('C:/laragon/www/portal-investidor');O=Path(__file__).parent;Q=Path('C:/Users/macbook/.config/investmoz/classificacao-QA-20261015/source')
def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest()
assert json.loads((O/'VERIFICACAO-LOCAL.json').read_text(encoding='utf8'))['result']=='passed'
ui=json.loads((O/'INTERFACE-QA.json').read_text(encoding='utf8'));assert ui['result']=='passed' and ui['invalid_reference_preserved'] and ui['error_focus']['index']=='0'
changes=[]
for folder in ['app','config','routes','database','resources']:
for p in (Q/folder).rglob('*'):
if p.is_file():
rel=p.relative_to(Q).as_posix();a=R/rel
if not a.exists() or a.read_bytes()!=p.read_bytes():changes.append({'path':rel,'previous_sha256':sha(a)if a.exists()else None,'candidate_sha256':sha(p),'operation':'replace'if a.exists()else'new'})
changes.sort(key=lambda x:x['path']);assert len(changes)==17 and sum(c['operation']=='new'for c in changes)==3
ident=hashlib.sha256(json.dumps(changes,sort_keys=True).encode()).hexdigest()[:12];candidate='classificacao-multidimensional-QA-'+ident
for file in ['RELATORIO-QA.md','PROPOSTA-UNICA-TEMPO.md','PROCEDIMENTO-E-REVERSAO.md']:
p=O/file;s=p.read_text(encoding='utf8');lines=s.splitlines(keepends=True);p.write_text(lines[0]+'\nCandidata: `'+candidate+'`.\n'+''.join(lines[1:]),encoding='utf8')
(O/'LEIA-ME.md').write_text('# Pacote exclusivamente para revisão\n\nCandidata `'+candidate+'`. Preparação QA autorizada; disponibilização ativa não autorizada.\n\n`fontes/`: as 17 fontes propostas. `build/`: compilação correspondente. `reversao-anterior/`: 14 fontes anteriores para comparação; o build anterior deve vir do backup fresco da janela. `reversao-compat/`: contrato anterior com aceitação do campo opcional já utilizado. `documentos/`: âmbito, limites e proposta única. `provas/`: resultados e roteiros guardados de QA, que não são componentes de instalação.\n\nNão instalar documentação/roteiros/fixtures nem transportar base, .env, sessões ou credenciais. Não executar as provas contra o ativo. Conferir todos os hashes com o manifesto e a autorização nominal antes de qualquer troca. A disponibilidade da biblioteca, a confirmação de associação, o workflow editorial e atos externos permanecem independentes.\n',encoding='utf8')
files={}
for c in changes:
files['fontes/'+c['path']]=Q/c['path']
if c['previous_sha256']:files['reversao-anterior/'+c['path']]=R/c['path']
for p in (Q/'public/build').rglob('*'):
if p.is_file():files['build/'+p.relative_to(Q/'public/build').as_posix()]=p
files['reversao-compat/app/Services/OpportunityCanonicalContract.php']=O/'reversao-compat/app/Services/OpportunityCanonicalContract.php'
for f in ['RELATORIO-QA.md','PROPOSTA-UNICA-TEMPO.md','PROCEDIMENTO-E-REVERSAO.md','RECONCILIACAO-E-INCREMENTOS.md','OPENAPI-QA.json','SCHEMA-CANONICO-QA.json']:
files['documentos/'+f]=O/f
for f in ['HTTP-DELTA-QA.json','HTTP-FASE1-QA.json','SERVICOS-DELTA-QA.json','REVERSAO-COMPAT-QA.json','VERIFICACAO-LOCAL.json','ATUALIZACAO-MATRIZ.json','INTERFACE-QA.json','FIXTURE-QA.json','PUBLIC-FIXTURE-QA.json','QA-MOVEL.png','QA-ERRO-E-FOCO.png','QA-FICHA-PUBLICA.png','lint.log','typescript.log']:
files['provas/'+f]=O/f
for f in ['prove-HTTP-QA.py','resume-HTTP-QA.py','prove-services-QA.php','public-fixture-QA.php','prove-rollback-QA.php','verify-local.py']:
files['provas/roteiros/'+f]=O/f
files['LEIA-ME.md']=O/'LEIA-ME.md'
payload=[{'path':name,'sha256':sha(p),'bytes':p.stat().st_size}for name,p in sorted(files.items())]
manifest={'candidate':candidate,'prepared_at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'authorization':'QA preparation only; active deployment pending Tempo decision','source_count':17,'replacements':14,'new_sources':3,'migrations':0,'flags_changed':0,'real_data_or_publications_changed':0,'sources':changes,'previous_build_manifest_sha256':sha(R/'public/build/manifest.json'),'candidate_build_manifest_sha256':sha(Q/'public/build/manifest.json'),'rollback_compatibility_sha256':sha(O/'reversao-compat/app/Services/OpportunityCanonicalContract.php'),'payload':payload}
mp=O/'MANIFESTO-ENTREGA.json';mp.write_text(json.dumps(manifest,ensure_ascii=False,indent=2),encoding='utf8')
zp=R/'outputs'/(candidate+'.zip')
with zipfile.ZipFile(zp,'w',zipfile.ZIP_DEFLATED,compresslevel=9)as z:
for name,p in sorted(files.items()):z.write(p,name)
z.write(mp,'MANIFESTO-ENTREGA.json')
assert zp.stat().st_size<10*1024*1024
with zipfile.ZipFile(zp)as z:
assert z.testzip()is None
assert len(z.namelist())==len(set(z.namelist()))==len(payload)+1
for item in payload:assert hashlib.sha256(z.read(item['path'])).hexdigest()==item['sha256'],item['path']
receipt={'candidate':candidate,'status':'complete QA review package; active deployment not authorized','zip':{'name':zp.name,'bytes':zp.stat().st_size,'sha256':sha(zp),'entries':len(payload)+1,'all_entry_hashes_verified':True},'manifest_sha256':sha(mp),'documents':{f:sha(O/f)for f in ['RELATORIO-QA.md','PROPOSTA-UNICA-TEMPO.md','PROCEDIMENTO-E-REVERSAO.md','RECONCILIACAO-E-INCREMENTOS.md']},'checks':{'HTTP':44,'services':22,'rollback':6,'interface':'passed','syntax_lint_types_assets':'passed'},'protected_active_files_unchanged':1899,'source_count':17,'replacements':14,'new_sources':3,'migrations':0,'same_matrix_rows':3402,'other_raw_rows_preserved':3394,'active_changes':0,'editorial_accepted_tests_repeated':False}
(O/'RECIBO-INTEGRIDADE.json').write_text(json.dumps(receipt,ensure_ascii=False,indent=2),encoding='utf8')
print(json.dumps(receipt,ensure_ascii=True))