fr36-probe.py
import pathlib, shutil, subprocess, sys, tempfile
root=pathlib.Path(sys.argv[1])
probe=r'''
import importlib.util,json,pathlib,socket,sys
attempts=[]
def deny(*a,**k):
attempts.append('network');raise AssertionError('offline probe')
socket.socket.connect=deny;socket.getaddrinfo=deny
spec=importlib.util.spec_from_file_location('Cell29',pathlib.Path.cwd()/'Cell29.py');m=importlib.util.module_from_spec(spec);sys.modules['Cell29']=m;spec.loader.exec_module(m)
from fastapi.testclient import TestClient
with TestClient(m.app) as c:
payload={'event_name':'Purchase','event_id':'fr36-synthetic-optout','opt_out':True,'user_data':{'email':'fixture@example.invalid','external_id':'fixture-person'},'custom_data':{'value':1}}
posted=c.post('/api/v1/events/collect',json=payload,headers={'X-Tenant-ID':'fixture-a'})
assert posted.status_code==200,posted.text
event_id=posted.json()['event_id']
fetched=c.get(f'/api/v1/events/{event_id}',headers={'X-Tenant-ID':'fixture-b'})
assert fetched.status_code==200,fetched.text
stored=fetched.json()['properties']['user_data_hash']
assert stored['external_id']=='fixture-person' and 'email_hash' in stored
print(json.dumps({'opt_out_true_collect_status':posted.status_code,'success':posted.json()['success'],'different_untrusted_tenant_header_read_status':fetched.status_code,'stored_user_fields':sorted(stored),'network_attempts':len(attempts),'scope':'actual source fixture only; headers are untrusted test inputs, no established tenant identity or production exposure asserted'}))
assert attempts==[]
'''
with tempfile.TemporaryDirectory(prefix='mizoki-fr36-') as d:
shutil.copy2(root/'src/cells/cell29/Cell29.py',pathlib.Path(d)/'Cell29.py')
r=subprocess.run([sys.executable,'-I','-c',probe],cwd=d,env={'PYTHONDONTWRITEBYTECODE':'1'},capture_output=True,text=True,timeout=20)
print(r.stdout,end='');print(r.stderr,end='',file=sys.stderr);sys.exit(r.returncode)