Files
Investidor-V2/outputs/investmoz-staff-preparation-20261012/finalize-opening-records.py
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

40 lines
3.8 KiB
Python

from pathlib import Path
from datetime import datetime,timezone
import csv,hashlib,json,subprocess
ROOT=Path(__file__).resolve().parents[2];OUT=ROOT/'outputs/investmoz-workflow-opening-20261012'
csv.field_size_limit(10000000)
def read(p):return json.loads(Path(p).read_text(encoding='utf-8-sig'))
def sha(p):return hashlib.sha256(Path(p).read_bytes()).hexdigest()
def save(p,v):Path(p).write_text(json.dumps(v,indent=2,ensure_ascii=False)+'\n',encoding='utf-8')
baseline=read(OUT/'matrix-deployment-baseline.json');proof=read(OUT/'matrix-deployment-proof.json')
matrix=ROOT/'docs/investmoz/v2/auditoria-portal/matriz-requisitos.csv'
with matrix.open(encoding='utf-8-sig',newline='') as file:rows=list(csv.reader(file))
assert len(rows)==len(baseline['rows'])==3402 and sha(matrix)==proof['sha256']
differences=[]
for previous,current in zip(baseline['rows'],rows):
assert len(previous)==len(current)
for i,(a,b) in enumerate(zip(previous,current)):
if a!=b:
assert previous[0] in baseline['notes'] and rows[0][i]=='Consolidação'
assert b==a+'\n\n[Entrega ativa 2e2f16c83483 — 12/10/2026] '+baseline['notes'][previous[0]]
differences.append(previous[0])
assert len(differences)==3
r=subprocess.run(['C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe',str(ROOT/'outputs/investmoz-staff-preparation-20261012/deployment-state-readonly.php')],cwd=ROOT,capture_output=True,text=True,encoding='utf-8',timeout=30)
assert r.returncode==0;final=json.loads(r.stdout);save(OUT/'destino-final-leitura.json',final)
assert final['flags']==read(OUT/'destino-aberto.json')['flags']
assert final['protected_tables']==read(OUT/'destino-antes.json')['protected_tables']
assert final['scanner']['available'] and not final['queue'] and final['failed_jobs']==0
candidate=ROOT/'outputs/investmoz-staff-preparation-20261012/abertura-workflow-2e2f16c83483'
m=read(candidate/'manifesto-final.json')
for item in m['source_files']+m['compiled_resources']:assert sha(ROOT/item['path'])==item.get('after_sha256',item.get('sha256'))
assert sha(candidate/'investmoz-abertura-2e2f16c83483.zip')=='13ddf150f0f7ab03de83437064bf32f34a382727880e9c7470faf87a9d035819'
assert sha(candidate/'manifesto-final.json')=='1da64a6def3d1ffe814e0fea8ac7b0f654320715032bfe7d89dabf750988cd64'
assert not list((ROOT/'public').glob('.workflow-opening-check-*.php')) and not (ROOT/'.env.opening-2e2f16c83483-new').exists()
receipt=read(OUT/'manifesto-execucao.json')
assert receipt['state']=='enabled_verified'
receipt.update(completed_at=datetime.now(timezone.utc).isoformat(),result='delivery_completed_workflow_enabled',final_protected_data_unchanged=True,final_queue_empty=True,failed_jobs=0,first_legitimate_process_in_target='pending_observation_not_an_enablement_blocker',new_human_UI_login_claimed=False,matrix={'requirements':3401,'source_occurrences':7739,'changed_cells':3,'new_ids':0,'states_unchanged':True,'sha256':proof['sha256']},artifacts={name:sha(OUT/name) for name in ['resultado.md','web-staged.json','web-enabled.json','navegacao-perfis-leitura.json','destino-antes.json','destino-aberto.json','destino-final-leitura.json','matrix-deployment-proof.json']})
save(OUT/'manifesto-execucao.json',receipt)
save(ROOT/'storage/app/private/investmoz-v2/portal-audit/workflow-opening-2e2f16c83483-execution.json',receipt)
save(OUT/'registo-documental.json',{'at':receipt['completed_at'],'result':'complete','delivery':'2e2f16c83483','same_matrix_updated':True,'changed_cells':3,'all_other_cells_preserved':True,'manifest_sha256':sha(OUT/'manifesto-execucao.json')})
print(json.dumps({'result':receipt['result'],'delivery':receipt['delivery'],'COUNTRY02_preserved':True,'workflow_enabled':True,'source_files':9,'resources_served':159,'matrix_cells_updated':3,'active_business_data_unchanged':True,'new_migrations':0,'new_services':0}))