Files
Investidor-V2/tools/portal-service-followup-manifests.py
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

32 lines
3.8 KiB
Python

from pathlib import Path
import json,hashlib,zipfile
from datetime import datetime,timezone
R=Path(__file__).resolve().parent.parent;P=R/'storage/app/private/investmoz-v2/portal-audit'
plan=json.loads((P/'service-followup-latest.json').read_text());S=Path(plan['source'])
assert S.name.startswith('workflow-service-followup-source-') and plan['target']['port']==55441
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
prior=json.loads((P/'workflow-upgrade-code-20261011.json').read_text())
delta=['app/Services/PortalSuperusers.php','app/Services/PortalProfileInstallation.php','app/Http/Controllers/PortalProfileInstallationController.php','routes/web.php','resources/js/pages/profiles/installation.tsx','resources/js/pages/profiles/bootstrap-confirmation.tsx']
files={key:sha(S/key) for key in sorted(set(prior['code_files'])|set(delta))}
assets={p.relative_to(S/'public/build').as_posix():sha(p) for p in sorted((S/'public/build').rglob('*')) if p.is_file()}
build={'result':'passed','mode':'production','assets':assets,'manifest_sha256':assets['manifest.json'],'active_assets_preserved':True,'active_writes':0}
(P/'service-followup-production-build.json').write_text(json.dumps(build,indent=2),encoding='utf-8')
revision=hashlib.sha256(json.dumps(files,separators=(',',':')).encode()).hexdigest()
code={'code_files':files,'code_revision':revision,'production_manifest_sha256':assets['manifest.json'],'previous_candidate':'98a8e0b70892',
'delta_files':{key:files[key] for key in delta},'schema_changes':0,'active_writes':0,'activation_ready':False,'integration_status':'Separate QA delta; fixed candidate not replaced'}
(P/'service-followup-code.json').write_text(json.dumps(code,indent=2),encoding='utf-8')
# Prepare a physical-restoration tool scoped exclusively to the new bootstrap clone.
t=(R/'tools/portal-workflow-upgrade-backup-qa.php').read_text(encoding='utf-8')
for a,b in [('portal-workflow-upgrade-runtime.php','portal-service-followup-runtime.php'),('workflow-upgrade-latest.json','service-followup-latest.json'),('workflow-upgrade-code-20261011.json','service-followup-code.json'),('workflow-upgrade-preflight-20261011.json','service-followup-preflight-20261011.json'),('workflow-upgrade-production-build-20261011.json','service-followup-production-build.json'),('workflow-upgrade-backup-restoration-qa-20261011.json','service-followup-backup-restoration-qa.json'),('workflow-upgrade-backups/','service-followup-backups/')]:
t=t.replace(a,b)
t=t.replace("'workflow_upgrade_restore_'","'workflow_service_restore_'")
needle='throw_unless($source->query("SELECT count(*) FROM audit_events'
start=t.index(needle);end=t.index('\n',start)
t=t[:start]+"""throw_unless($source->query("SELECT count(*) FROM portal_superuser_pair")->fetchColumn()==1
&& $source->query("SELECT count(*) FROM audit_events WHERE source_system='portal-profile-installation' AND action='bootstrap-request'")->fetchColumn()==1
&& $source->query("SELECT count(*) FROM audit_events WHERE source_system='portal-profile-installation' AND action='bootstrap-confirm'")->fetchColumn()==1,RuntimeException::class,'Cross-confirmation/audit duplicated');"""+t[end:]
t=t.replace("'exact_single_installation_audits'=>true","'exact_cross_confirmation_audits'=>true,'fixture_schema_setup'=>true,'authenticated_installer_proof_reused_from_fixed_candidate'=>true")
t=t.replace('Post-use upgrade clone proof; not a destination installation or real-holder designation.','Post-use crossed bootstrap clone proof; not a destination installation, authenticated installer repeat or real-holder designation.')
(R/'tools/portal-service-followup-backup-qa.php').write_text(t,encoding='utf-8')
print(json.dumps({'result':'separate_delta_manifest_prepared','code_revision':revision,'delta_files':len(delta),'code_files':len(files),'assets':len(assets),'fixed_candidate_preserved':'98a8e0b70892','active_writes':0}))