Files
Investidor-V2/outputs/investmoz-audit-current-20261012/verify-B7-final-menu.py
T
nala ba1c0340ea
tests / ci (push) Canceled after 0s
oportunidades 8
2026-10-14 08:25:30 +02:00

50 lines
5.0 KiB
Python

from pathlib import Path
from hashlib import sha256
from collections import Counter
from datetime import datetime,timezone
import csv,json,copy
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';QA=PRIVATE/'portal-stability-source-20261011_083742'
sha=lambda p:sha256(p.read_bytes()).hexdigest();dest=OUT/'option-B7-final-review-verification.json';assert not dest.exists()
groups=json.loads((OUT/'proof-groups.json').read_text(encoding='utf-8'));saldo=json.loads((OUT/'option-B7-four-lots-plan.json').read_text(encoding='utf-8'))
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']
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'])==43
code=json.loads((OUT/'option-B7-code-preservation.json').read_text(encoding='utf-8'))
for name,expected in code['checked_active_sha256'].items():assert sha(ROOT/name)==expected
delta=json.loads((OUT/'option-B7-business-delta.json').read_text(encoding='utf-8'))
for f in delta['files']:assert sha(QA/f['relative'])==f['after_sha256'] and sha(ROOT/f['relative'])==f['active_sha256']
assert sha(QA/'public/build/manifest.json')==code['QA_manifest_sha256']
table=json.loads((OUT/'option-B7-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
assert saldo['technical_closed']==10 and saldo['technical_remaining']==8
assert sum(x['hours'][0]for x in saldo['lots'])==18 and sum(x['hours'][1]for x in saldo['lots'])==31
assert sum(x[0]for x in saldo['work_types'].values())==18 and sum(x[1]for x in saldo['work_types'].values())==31
summary=json.loads((OUT/'reconciliation-summary.json').read_text(encoding='utf-8'))
summary.update(at=datetime.now(timezone.utc).isoformat(),states=states,proof_groups=43,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='B7',finite_lots_plan='option-B7-four-lots-plan.json',finite_technical_positions=18,finite_visual_scenarios=8,
technical_positions_closed=10,technical_positions_remaining=8,legacy_company_sale_workflow_HTTP_demonstrated=True,legacy_company_sale_profile_dependency_resolved=True,
latest_QA_product_delta=code['QA_product_delta_files'],final_candidate_fixed=False,new_visual_closures=0,active_changes=0,remaining_effort_hours=[18,31],C135_new_calls_or_resets=0)
summary.update(C132_corrective_actions_pending=[],C132_pending_access_confirmation_ids=[],C132_closure_status='final_decision_record_presented_not_yet_decided')
(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='B7 legacy company_sale profile bridge and exact active-path read; ten technical positions, not final candidate',proof_groups=43,new_visual_closures=0,active_changes=0,remaining_estimate_hours=[18,31])
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':9,'proof_groups':43,'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':False,'recompile_required':True,'technical_positions_closed':10,'technical_positions_remaining':8,'remaining_hours':[18,31],
'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))