from pathlib import Path from hashlib import sha256 from collections import Counter from datetime import datetime,timezone import csv,json csv.field_size_limit(10000000) OUT=Path(__file__).resolve().parent;ROOT=OUT.parents[1];DOC=ROOT/'docs/investmoz/v2/auditoria-portal';PRIVATE=ROOT/'storage/app/private/investmoz-v2/portal-audit' sha=lambda p:sha256(p.read_bytes()).hexdigest() dest=OUT/'option-B5-review-verification.json';assert not dest.exists() proof=json.loads((OUT/'csv-authoring-proof.json').read_text(encoding='utf-8'));plan=json.loads((OUT/'authoring-plan.json').read_text(encoding='utf-8')) for f in proof['files']:assert sha(DOC/f['name'])==f['after_sha256'] with(DOC/'matriz-requisitos.csv').open(encoding='utf-8-sig',newline='')as f:rows=list(csv.DictReader(f)) assert len(rows)==3401 and len({r['ID']for r in rows})==3401 states=dict(Counter(r['Estado']for r in rows));assert states==proof['states'] groups=json.loads((OUT/'proof-groups.json').read_text(encoding='utf-8'));versions={};names=set() for g in groups['groups']: for s in g['sources']: name=s['file'];assert Path(name).name==name candidates=[OUT/name,PRIVATE/name,OUT/'C132-para-revisao/evidencias'/name,OUT/'para-revisao/evidencias'/name] p=next((p for p in candidates if p.is_file()and sha(p)==s['sha256']),None);assert p,'Proof source no longer matches '+name versions[(name,s['sha256'])]={'file':name,'sha256':s['sha256'],'path':str(p.relative_to(ROOT))};names.add(name) assert len(groups['groups'])==35 code=json.loads((OUT/'option-B5-code-preservation.json').read_text(encoding='utf-8')) for name,expected in code['checked_active_sha256'].items():assert sha(ROOT/name)==expected table=json.loads((OUT/'option-B5-exit-criteria.json').read_text(encoding='utf-8'));assert len(table['rows'])==22 and sum(bool(r['closed_in_scoped_acceptance'])for r in table['rows'])==2 summary=json.loads((OUT/'reconciliation-summary.json').read_text(encoding='utf-8')) summary.update(at=datetime.now(timezone.utc).isoformat(),states=states,proof_groups=35,requirements_with_explicit_proof_groups=len({r for g in groups['groups']for r in g['requirements']} & {r['ID']for r in rows})) summary['option_B'].update(current_increment='B5',finite_lots_plan='option-B5-four-lots-plan.json',finite_technical_positions=18,finite_visual_scenarios=8, coeditor_revocation_HTTP_demonstrated=True,revocation_not_demonstrated=False,new_entity_support_HTTP_demonstrated=True, no_new_product_source_change_since_B2=False,latest_QA_product_delta=['app/Http/Controllers/LandAssistanceController.php'], final_candidate_fixed=False,new_visual_closures=0,active_changes=0,remaining_effort_hours=[25,43]) summary.update(C132_corrective_actions_pending=[],C132_pending_access_confirmation_ids=[],C132_closure_status='proposed_with_documented_limits') (OUT/'reconciliation-summary.json').write_text(json.dumps(summary,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') docs=json.loads((OUT/'option-B-documents-reconciliation.json').read_text(encoding='utf-8')) docs.update(scope='B5 four finite QA lots; two technical criteria, not final candidate',pending_incident_confirmations=[],C132_account16_confirmation_only=False, proof_groups=35,new_visual_closures=0,active_changes=0,remaining_estimate_hours=[25,43]) for e in docs['files']:e['sha256']=sha(DOC/e['file']) (OUT/'option-B-documents-reconciliation.json').write_text(json.dumps(docs,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') for name in ['matriz-requisitos.csv','backlog-priorizado.csv']:(OUT/'para-revisao'/name).write_bytes((DOC/name).read_bytes()) result={'at':summary['at'],'result':'passed','requirements':3401,'source_occurrences':7739,'new_requirement_ids':0,'source_ids_versions_and_states_preserved':True, 'changed_existing_requirements':16,'proof_groups':35,'unique_source_files_verified':len(names),'source_file_versions_verified':len(versions), 'source_resolution':list(versions.values()),'visual_closures':0,'active_writes':0,'QA_product_delta_files':code['QA_product_delta_files'], 'QA_bundle_unchanged':True,'recompile_required':False,'matrix_sha256':sha(DOC/'matriz-requisitos.csv'),'backlog_sha256':sha(DOC/'backlog-priorizado.csv')} dest.write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') print(json.dumps({k:v for k,v in result.items()if k!='source_resolution'},ensure_ascii=False))