45 lines
4.8 KiB
Python
45 lines
4.8 KiB
Python
import hashlib
|
|
import json
|
|
import shutil
|
|
import zipfile
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
OUT = ROOT / 'outputs/investmoz-staff-preparation-20261012'
|
|
QA = ROOT / 'storage/app/private/investmoz-v2/portal-audit/onboarding-qa-internal-20261011_191450'
|
|
PATHS = ['app/Services/OpportunityContacts.php', 'app/Services/OpportunityCanonicalContract.php', 'app/Services/PortalProfileAccess.php', 'app/Providers/AppServiceProvider.php', 'app/Http/Controllers/PortalProfileController.php', 'routes/web.php', 'resources/js/components/opportunity-contact-form.tsx', 'resources/js/components/opportunity-canonical-fields.tsx', 'resources/js/pages/management/opportunity-draft.tsx']
|
|
sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest()
|
|
FILES = [{'path': p, 'before_sha256': sha(ROOT / p) if (ROOT / p).exists() else None, 'after_sha256': sha(QA / p)} for p in PATHS]
|
|
ASSETS = [{'path': str(path.relative_to(QA)).replace('\\', '/'), 'sha256': sha(path)} for path in sorted((QA / 'public/build').rglob('*')) if path.is_file()]
|
|
assert all(item['before_sha256'] != item['after_sha256'] for item in FILES)
|
|
for name in ['contact-http-qa.json', 'contact-policy-qa.json', 'session-gate-after.json']:
|
|
assert json.loads((OUT / name).read_text())['result'] == 'passed'
|
|
worker = json.loads((OUT / 'worker-readonly.json').read_text())
|
|
assert worker['result'] == 'inspected' and worker['configuration_matches'] and worker['task']['enabled'] and worker['task']['last_result'] == 0
|
|
identity = {'base_revision': '2876cdfa900a', 'files': FILES, 'build': ASSETS, 'flags_proposed': ['PORTAL_PROFILE_ACCESS_ENABLED', 'PORTAL_OPPORTUNITY_DASHBOARD_ACCESS_ENABLED', 'PORTAL_OPPORTUNITY_SPECIALIZED_DRAFTS_ENABLED']}
|
|
revision = hashlib.sha256(json.dumps(identity, sort_keys=True, separators=(',', ':')).encode()).hexdigest()
|
|
folder = OUT / ('delta-contacto-' + revision[:12])
|
|
assert not folder.exists(), 'Preserve fixed revision'
|
|
folder.mkdir()
|
|
for p in PATHS + [item['path'] for item in ASSETS]:
|
|
destination = folder / 'payload' / p
|
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copyfile(QA / p, destination)
|
|
backup = json.loads((ROOT / 'storage/app/private/investmoz-v2/portal-audit/internal-designation-target-backup.json').read_text())
|
|
manifest = {**identity, 'revision': revision, 'at': datetime.now(timezone.utc).isoformat(), 'target': 'https://portal-investidor.test; investemoz:5432', 'source': 'guarded QA 55441 *_test', 'schema_changes': 0, 'migrations': 0, 'service_changes': 0, 'new_active_accounts_or_grants': 0, 'active_writes': 0,
|
|
'included': ['C129 contact creation/reuse through existing CRM master from editable draft', 'C130 access revision bound with governance enabled', 'existing isolated workflow of six base categories'],
|
|
'pending': ['visual demonstration of the new contact form and affected authentication state', 'final correspondence of the fixed delta with backup and pre-deployment target', 'explicit authorization of new delta and three operational gates'],
|
|
'ready_for_activation': False, 'backup_pre_change': {'verified_at': backup['verified_at'], 'valid_until': backup['valid_until'], 'restored_target': backup['restored_target'], 'restoration_verified': backup['restore_verified'], 'code_revision_backed_up': backup['candidate_revision'], 'dump_sha256': backup['dump_sha256'], 'files_sha256': backup['files_sha256']},
|
|
'limitations': ['Contact job title from the normative specification is not a column of the current master; full normative contract remains partial', 'Existing variant exclusions, individual sharing and opportunity restoration remain disabled', 'Four modular categories, integrated journey 190000, legacy, offers and SLA are separate']}
|
|
(folder / 'manifesto.json').write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding='utf-8')
|
|
archive = folder / ('delta-' + revision[:12] + '.zip')
|
|
with zipfile.ZipFile(archive, 'w', zipfile.ZIP_DEFLATED) as stream:
|
|
for path in sorted((folder / 'payload').rglob('*')):
|
|
if path.is_file(): stream.write(path, str(path.relative_to(folder / 'payload')))
|
|
receipt = {'revision': revision[:12], 'full_revision': revision, 'source_files': len(FILES), 'compiled_resources': len(ASSETS), 'zip_sha256': sha(archive), 'manifest_sha256': sha(folder / 'manifesto.json'), 'ready_for_activation': False, 'active_unchanged': all((ROOT / item['path']).exists() == (item['before_sha256'] is not None) and (item['before_sha256'] is None or sha(ROOT / item['path']) == item['before_sha256']) for item in FILES)}
|
|
assert receipt['active_unchanged']
|
|
(folder / 'pacote.json').write_text(json.dumps(receipt, indent=2), encoding='utf-8')
|
|
(OUT / 'delta-contacto-link.json').write_text(json.dumps({'folder': str(folder), **receipt}, indent=2), encoding='utf-8')
|
|
print(json.dumps(receipt))
|