from http_common import * manager=session('manager');anon=session();source=private/'source';manifest=source/'database/data/economic-references-lot-01.json';m=json.loads(manifest.read_text('utf-8')) old=manifest.read_bytes() try: manifest.write_bytes(old+b' ');call(manager,base,expected=422);check('tampered_manifest_bytes_refused',True) finally:manifest.write_bytes(old) first=source/'storage/app/private/investmoz-v2/economic-references/lot-01'/m['sources'][0]['relative_path'];old=first.read_bytes() try: first.write_bytes(old+b'QA');p=plan(manager);check('source_byte_mismatch_visible_and_publish_disabled',not p['sources'][0]['ready'] and not p['operations']['publish']['ready'] and bool(p['operations']['publish']['reasons'])) operation(manager,'publish',expected=422);check('source_byte_mismatch_publication_refused',True) finally:first.write_bytes(old) r,_=operation(manager,'schema',expected=403);check('schema_after_use_still_requires_existing_pair',True) r,_=operation(manager,'import');check('final_revision_import_reuses_15_after_withdrawal',not r['changed'] and len(r['reused'])==15) r,_=operation(manager,'publish');check('explicit_republication_restores_only_nine_chain_visibilities',len(r['changed'])==9 and len(r['reused'])==6) check('canonical_frozen_relations_recover_after_reference_republication',len(call(anon,'/api/v1/investment/opportunities/inv-mz-gen-5673010729603343')['context']['classification'])==3) check('business_frozen_relations_recover_after_reference_republication',len(call(anon,'/negocios/'+f['business_slug'])['data']['multidimensional'])==3) unauthed=session('no-mfa');unauthed[0].clear();call(unauthed,'/login');a=f['actors']['manager'];call(unauthed,'/login',{'email':a['email'],'password':a['password']},expected=(200,204,302));call(unauthed,base+'/import',{'hash':'0'*64,'idempotency_key':str(uuid.uuid4()),'confirm':True,'reason':'Tentativa sem concluir o MFA nesta sessão sintética QA.'},expected=(302,401));check('password_without_MFA_cannot_reach_operational_write',True) print(json.dumps({'checks':len(proof['checks']),'phase':'operational refusals and explicit recovery complete'}))