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

38 lines
5.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
import json,hashlib,csv,datetime,zipfile
root=Path(__file__).resolve().parents[2];out=Path(__file__).resolve().parent
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
encode=lambda d:(json.dumps(d,ensure_ascii=False,indent=2)+'\n').encode('utf-8')
assert not (out/'RECIBO-MAPA.json').exists()
new=['app/Services/ExistingBusinessClassification.php','app/Http/Controllers/ExistingBusinessClassificationController.php','resources/js/pages/investment/business-classification.tsx']
replace=['app/Policies/ExistingBusinessPolicy.php','routes/existing-business.php','app/Http/Controllers/PublicBusinessOpportunityController.php','app/Http/Resources/PublicBusinessOpportunityResource.php','resources/js/pages/investment/business.tsx','resources/js/pages/investment/business-wizard.tsx','resources/js/pages/investment/business-marketplace.tsx','resources/js/pages/investment/business-opportunity.tsx']
reused=['app/Services/OpportunityClassification.php','app/Services/OpportunityCanonicalValue.php','app/Services/ExistingBusinessDrafts.php','app/Services/ExistingBusinessVerification.php','app/Services/ExistingBusinessIntake.php','app/Services/BusinessFormSchema.php','app/Services/Mne/BusinessRepository.php','app/Services/Mne/CompatibleBusinessRepository.php','app/Services/Mne/LegacyBusinessRepository.php','resources/js/components/opportunity-classification.tsx','app/Models/ExistingBusiness.php','app/Models/DomainRecord.php','app/Http/Controllers/ExistingBusinessController.php']
assert all(not (root/n).exists() for n in new)
sources={n:sha(root/n) for n in replace+reused}
proof={'date':'2026-10-16','scope':'planning only; no functional source edits, tests or active changes','planned_source_count':11,'planned_replacements':[{'path':n,'observed_sha256':sources[n]} for n in replace],'planned_new_sources':[{'path':n,'observed_absent':True} for n in new],'reused_unchanged':[{'path':n,'sha256':sources[n]} for n in reused],'migrations_planned':0,'new_business_records_planned':0,'new_grants_planned':0}
(out/'FONTES-E-DELTA-PREVISTO.json').write_bytes(encode(proof))
matrix=root/'docs/investmoz/v2/auditoria-portal/matriz-requisitos.csv';matrixHash=sha(matrix);csv.field_size_limit(10000000)
ids=['M2-d0c06a75-0158','M2-d0c06a75-0029','RF-CLU-002','RF-CLU-003','RF-COR-003','MASTER-e1169a77-0043','MASTER-e1169a77-0062']
with matrix.open(encoding='utf-8-sig',newline='') as f:rows={r['ID']:r for r in csv.DictReader(f) if r['ID'] in ids}
assert len(rows)==len(ids)
statuses={k:{'Estado':r['Estado']} for k,r in rows.items()}
backlog=root/'docs/investmoz/v2/auditoria-portal/backlog.md';before=backlog.read_bytes();marker='## 16/10/2026 — mapa prévio de classificação de /negocios'
assert marker not in before.decode('utf-8')
note='\n\n'+marker+'\n\nIncremento limitado pela Tempo a QA, antes de codificar: campos e relações atuais, suplemento no contexto cifrado das revisões do mesmo UUID, decisão e divulgação distintas, sem reabrir o workflow do anúncio. Inspeção de leitura confirmou 172aa874-98fc-4bf6-b78f-d2e9a386d345 publicado/v12, 12 revisões/11 transições e zero documentos associados. A base QA de referência permanece intacta; ensaio previsto num clone novo. Dependências antecipadas: ações exclusivas do suplemento para publicado, adaptação da evidência documental e da pesquisa cifrada, responsabilidades/permissões atuais e reversão após uso.\n\nMapa completo, 11 fontes previstas (8 alterações/3 novas), critérios a demonstrar, reversão e estimativa restante 10–16 h: outputs/investmoz-negocios-classificacao-mapa-20261016/MAPA-ALTERACOES.md. Inspeção SQL não é aceitação funcional. Sem alterações de código de aplicação/ativo, nova atribuição, anúncio paralelo ou repetição de provas aceites. Mesmos sete requisitos referenciados, estados da matriz preservados; classificação canónica e acesso concluídos, restantes quatro lacunas abertas. Planeamento não autoriza disponibilização ativa.\n'
backlog.write_bytes(before+note.encode('utf-8'))
assert backlog.read_bytes().startswith(before) and sha(matrix)==matrixHash
for n,h in sources.items():assert sha(root/n)==h
preservation={'matrix_sha256_unchanged':matrixHash,'same_requirement_ids':ids,'statuses_unchanged':statuses,'backlog_before_sha256':hashlib.sha256(before).hexdigest(),'backlog_after_sha256':sha(backlog),'previous_backlog_bytes_preserved':True,'application_sources_unchanged':len(sources),'functional_code_implemented':False,'active_changes':0,'QA_data_writes':0,'accepted_tests_repeated':False}
(out/'PRESERVACAO-PLANEAMENTO.json').write_bytes(encode(preservation))
payload=['MAPA-ALTERACOES.md','ESTADO-QA-READONLY.json','FONTES-E-DELTA-PREVISTO.json','PRESERVACAO-PLANEAMENTO.json']
receipt={'date':'2026-10-16','status':'map before implementation; QA scope only','files':{n:{'sha256':sha(out/n),'bytes':(out/n).stat().st_size} for n in payload},'estimated_remaining_hours':[10,16],'accepted_deliveries_and_matrix_statuses_preserved':True,'active_changes':0,'QA_data_writes':0,'functional_tests_run':0}
(out/'RECIBO-MAPA.json').write_bytes(encode(receipt))
archive=root/'outputs/negocios-classificacao-mapa-20261016.zip';assert not archive.exists()
with zipfile.ZipFile(archive,'w',zipfile.ZIP_DEFLATED,compresslevel=9) as z:
for n in payload+['RECIBO-MAPA.json']:z.write(out/n,n)
with zipfile.ZipFile(archive) as z:
assert z.testzip() is None
for n in payload:assert hashlib.sha256(z.read(n)).hexdigest()==receipt['files'][n]['sha256']
integrity={'archive':archive.name,'sha256':sha(archive),'bytes':archive.stat().st_size,'entries':len(payload)+1,'CRC_and_payload_hashes_verified':True,'receipt_sha256':sha(out/'RECIBO-MAPA.json')}
(out/'INTEGRIDADE-PACOTE.json').write_bytes(encode(integrity));print(json.dumps(integrity))