46 lines
5.2 KiB
Python
46 lines
5.2 KiB
Python
from pathlib import Path
|
|
import json,hashlib,zipfile
|
|
out=Path(__file__).resolve().parent;prior=out.parent;root=out.parents[2]
|
|
read=lambda p:json.loads(p.read_text('utf-8'))
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
write=lambda n,d:(out/n).write_text(json.dumps(d,ensure_ascii=False,indent=2)+'\n','utf-8')
|
|
assert not (out/'RECIBO-INTEGRIDADE.json').exists()
|
|
lot=read(out/'LOTE-PROPOSTO.json')
|
|
lot['rollback_components']=[r['path'] for r in lot['prospective_files'][:8] if r['path'].startswith(('app/','resources/'))]
|
|
assert len(lot['rollback_components'])==6
|
|
lot['rollback_after_use']='PARTIAL AND COMPATIBLE: retain additive migration/data, six functional source files, reference manifest and coherent compatibility build; operational layer can be removed without losing UUID resolution or historical data'
|
|
lot['compatibility_build_required']=True
|
|
lot['documentary_reconciliation']['status']='OPEN; factual reconciliation still required. Five-node QA sample does not certify a normative edition.'
|
|
write('LOTE-PROPOSTO.json',lot)
|
|
base=read(prior/'BASELINE-FICHEIROS.json')
|
|
changed=[x['path'] for x in base['files'] if not (root/x['path']).is_file() or sha(root/x['path'])!=x['sha256']]
|
|
assert not changed
|
|
for r in lot['prospective_files']:
|
|
p=root/r['path']
|
|
assert (p.is_file() and sha(p)==r['before_sha256']) if r['exists'] else not p.exists()
|
|
assert lot['authorization_granted'] is False and lot['app_code_changed'] is False
|
|
assert len(lot['prospective_files'])==12 and lot['runtime_sources']==10
|
|
assert sum(x['exists'] for x in lot['prospective_files'])==6
|
|
assert len(lot['activities'])+len(lot['chain_stages'])+len(lot['chain_links'])+1==15
|
|
assert lot['estimate_hours']['revised_QA_total']==[a+b for a,b in zip(lot['estimate_hours']['original_functional_QA_total'],lot['estimate_hours']['new_operational_QA'])]
|
|
original=read(out/'ENQUADRAMENTO-RECOMENDACOES.json')['original_documents_preserved']
|
|
assert sha(prior/'MAPA-LOTE-MINIMO.md')==original['map_sha256']
|
|
assert sha(prior/'RECIBO-INTEGRIDADE.json')==original['receipt_sha256']
|
|
assert sha(root/'outputs/investmoz-referencias-economicas-mapa-20261016.zip')==original['ZIP_sha256']
|
|
for n in ['MAPA-LOTE-MINIMO.md','DESENHO-OPERACIONAL.md']:
|
|
t=(out/n).read_text('utf-8');assert '\ufffd' not in t and 'Ã' not in t and 'â‚' not in t
|
|
assert 'A Tempo decide se usa este exemplar' not in (out/'MAPA-LOTE-MINIMO.md').read_text('utf-8')
|
|
write('VERIFICACAO-DOCUMENTAL.json',{'revision':'DOC01','protected_active_files_compared':len(base['files']),'active_files_changed':changed,'active_DB_connections_this_revision':0,'functional_tests_repeated':0,'implementation_started':False,'all_prospective_files_match_baseline':True,'original_map_receipt_ZIP_unchanged':True,'QA_prior_evidence_reused':{'state_sha256':sha(prior/'ESTADO-QA-READONLY.json'),'reference_preservation_sha256':sha(prior/'PRESERVACAO-REFERENCIAS-QA.json')},'counts_and_estimates_reconciled':True,'type':'Static document/integrity check; not functional QA or permission approval'})
|
|
names=['MAPA-LOTE-MINIMO.md','DESENHO-OPERACIONAL.md','LOTE-PROPOSTO.json','FONTES-E-DELTA-PREVISTO.json','ENQUADRAMENTO-RECOMENDACOES.json','INSPECAO-MECANISMO-EXISTENTE.json','ATUALIZACAO-MESMA-MATRIZ.json','VERIFICACAO-DOCUMENTAL.json']
|
|
items=[{'path':n,'sha256':sha(out/n),'bytes':(out/n).stat().st_size} for n in names]
|
|
write('INTEGRIDADE-CONTEUDO.json',{'revision':'DOC01','scope':'Documentary design only; no deployable sources or active authorization','files':items,'prior_documents':original})
|
|
archive=root/'outputs/investmoz-referencias-economicas-mapa-DOC01-20261016.zip';assert not archive.exists()
|
|
with zipfile.ZipFile(archive,'w',compression=zipfile.ZIP_DEFLATED) as z:
|
|
for n in names+['INTEGRIDADE-CONTEUDO.json']:z.write(out/n,n)
|
|
with zipfile.ZipFile(archive) as z:
|
|
assert z.testzip() is None and sorted(z.namelist())==sorted(names+['INTEGRIDADE-CONTEUDO.json'])
|
|
for i in items:assert hashlib.sha256(z.read(i['path'])).hexdigest()==i['sha256']
|
|
receipt={'revision':'DOC01','date':'2026-10-16','scope':'Revised design for Tempo decision; no implementation or active authorization','files':items,'zip':{'path':archive.relative_to(root).as_posix(),'bytes':archive.stat().st_size,'sha256':sha(archive),'entries':len(names)+1,'entry_hashes_and_CRC_verified':True},'previous_immutable_documents':original,'preservation':{'protected_active_files':len(base['files']),'changed':0,'active_DB_connections_this_revision':0,'functional_tests_repeated':0,'matrix_rows':3402,'matrix_updated':7,'unrelated_raw_records_preserved':3395,'all_states_preserved':True},'estimates_hours':{'prior_functional_QA':[12,18],'operational_path_QA_delta':[2,4],'revised_QA_total':[14,22],'future_active_execution_separate':[2,4]},'authorization_granted':False,'implementation_started':False,'rollback':'partial and compatible, with additive schema/data plus six functional sources, reference manifest and coherent compatibility build retained','verification':'Local ZIP opened and every file compared to SHA256 inventory. No Tempo ZIP inspection or functional test inferred.'}
|
|
write('RECIBO-INTEGRIDADE.json',receipt)
|
|
print(json.dumps({'zip':receipt['zip'],'map_sha256':sha(out/'MAPA-LOTE-MINIMO.md'),'operational_design_sha256':sha(out/'DESENHO-OPERACIONAL.md'),'receipt_sha256':sha(out/'RECIBO-INTEGRIDADE.json'),'active_files_unchanged':len(base['files'])}))
|