from pathlib import Path from hashlib import sha256 import json import zipfile ROOT = Path(__file__).resolve().parents[2] OUT = Path(__file__).resolve().parent DOC = ROOT / 'docs/investmoz/v2/auditoria-portal' old_zip = OUT / 'investmoz-sintese-modulos-PDF-C137-revisao-20261012.zip' old_hash = 'a49823898d7c9f92df6b934337f08d94c14c4111b36f5b7d257413d7da0ee86e' assert sha256(old_zip.read_bytes()).hexdigest() == old_hash with zipfile.ZipFile(old_zip) as old: assert old.testzip() is None files = {name: old.read(name) for name in old.namelist()} # Preserve previous manifest/inventory as history; regenerate the current ones. for name in ['manifesto-revisao-QA.json', 'inventario-pacote.json', 'LEIA-ME.md']: files['historico/20261012-' + name] = files.pop(name) for name in ['relatorio-executivo.md', 'backlog.md', 'visao-consolidada-modulos.md', 'decisao-produto-tres-entregas.md', 'C135-pedido-suporte.md', 'matriz-requisitos.csv', 'backlog-priorizado.csv']: files[name] = (DOC / name).read_bytes() files['sintese-fecho-por-modulo.md'] = (OUT / 'sintese-fecho-por-modulo.md').read_bytes() for name in ['three-deliveries-budget.json', 'three-deliveries-reconciliation.json']: files[name] = (OUT / name).read_bytes() readme = '''# InvesteMoz: decisão sobre o produto a concluir Revisão documental de 13/10/2026, da mesma auditoria. Abrir primeiro `decisao-produto-tres-entregas.md` e escolher o âmbito da próxima candidata: - A: núcleo operacional das seis categorias base, 36–64 h. - B: núcleo + percurso integrado existente, 40–72 h. - C: todos os consumidores existentes, 60–110 h. Os três conjuntos são produto já utilizável, essencial e evolução posterior. 60–110 h = correções 17–32 + implementação restante 17–36 + verificação 26–42. 76–152 h são incrementos distintos, não repetem estas parcelas. São estimativas de planeamento, não prazos prometidos. Dependências/exclusões constam no detalhe. Matriz/backlog CSV com bytes, IDs, fontes e estados intactos. Nenhum novo teste, desenvolvimento ou alteração ativa nesta reorganização. A/B e C37 preservados; C132 separado. C135: texto sanitizado pronto para suporte, não submetido, sem canal ligado; nenhuma reinicialização adicional, critérios visuais novos abertos. Os ficheiros `delta-QA/`, provas e grupos provêm do lote anterior e conservam bytes/hashes: código preparado não significa ativação ou fecho visual. O manifesto anterior está em `historico/`; o atual é documental, não um instalador. O ZIP anterior a49823898d7c... permanece imutável. Não contém credenciais, ficheiros MFA, bases, .env ou originais privados. Este ZIP não autoriza ativação. ''' files['LEIA-ME.md'] = readme.encode('utf-8') for name, payload in files.items(): assert not name.startswith('/') and '..' not in Path(name).parts assert not name.lower().endswith(('.env', '.sql', '.2fas', '.p12', '.pfx', '.key')) assert b'otpauth://' not in payload, name assert b'QA-6cc8c780' not in payload and b'QA-4d2ad9e2' not in payload, name review_hash = sha256(files['decisao-produto-tres-entregas.md'] + files['three-deliveries-budget.json']).hexdigest() revision = review_hash[:12] manifest = { 'review_revision': revision, 'date': '2026-10-13', 'kind': 'Product-scope decision, document-only', 'previous_QA_review': 'eed791c1cdd2', 'previous_ZIP_SHA256': old_hash, 'current_QA_code_changed': False, 'active_changes': False, 'activation_package': False, 'existing_matrix_sha256': sha256(files['matriz-requisitos.csv']).hexdigest(), 'existing_backlog_sha256': sha256(files['backlog-priorizado.csv']).hexdigest(), 'functional_state_changes': 0, 'new_requirement_ids': 0, 'support_C135_submitted': False, 'files': [{'file': name, 'bytes': len(payload), 'sha256': sha256(payload).hexdigest()} for name, payload in sorted(files.items())] } manifest_bytes = (json.dumps(manifest, ensure_ascii=False, indent=2) + '\n').encode('utf-8') files['manifesto-revisao-QA.json'] = manifest_bytes inventory = {'review_revision': revision, 'self_excluded': 'inventario-pacote.json', 'files': [{'file': name, 'bytes': len(payload), 'sha256': sha256(payload).hexdigest()} for name, payload in sorted(files.items())]} files['inventario-pacote.json'] = (json.dumps(inventory, ensure_ascii=False, indent=2) + '\n').encode('utf-8') target = OUT / 'investmoz-tres-entregas-decisao-20261013.zip' assert not target.exists(), 'Do not overwrite an existing review package' with zipfile.ZipFile(target, 'w', compression=zipfile.ZIP_DEFLATED, compresslevel=9) as archive: for name, payload in sorted(files.items()): archive.writestr(name, payload) with zipfile.ZipFile(target) as archive: assert archive.testzip() is None assert len(set(archive.namelist())) == len(files) for name, payload in files.items(): assert archive.read(name) == payload assert target.stat().st_size < 10 * 1024 * 1024 receipt = {'file': str(target), 'sha256': sha256(target.read_bytes()).hexdigest(), 'bytes': target.stat().st_size, 'entries': len(files), 'review_revision': revision, 'CRC_and_file_hashes_verified': True, 'code_changes': 0, 'active_changes': 0, 'matrix_and_backlog_CSV_unchanged': True, 'C135_submitted': False} (OUT / 'three-deliveries-package.json').write_text(json.dumps(receipt, indent=2) + '\n', encoding='utf-8') print(json.dumps(receipt))