fr19-readonly-probe.py
import ast,asyncio,json,socket
from datetime import datetime,timezone
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch
from fastapi import FastAPI,Depends
from fastapi.responses import StreamingResponse
from fastapi.testclient import TestClient
from pydantic import BaseModel
source=Path('src/cells/cell01/Cell1.py').read_text()
names={'ReasonInput','reason_endpoint','trace_endpoint','user_metrics_endpoint'}
module=ast.Module(body=[n for n in ast.parse(source).body if isinstance(n,(ast.ClassDef,ast.AsyncFunctionDef)) and n.name in names],type_ignores=[])
async def auth():return {'sub':'fixture-user','email':'fixture@example.invalid','role':'authenticated'}
async def no_delay(*a):pass
app=FastAPI();ns={'app':app,'Depends':Depends,'get_current_user':auth,'BaseModel':BaseModel,'StreamingResponse':StreamingResponse,'asyncio':SimpleNamespace(sleep=no_delay),'datetime':datetime,'json':json,'logger':SimpleNamespace(info=lambda *a:None)}
exec(compile(module,'Cell1.py:selected-current-routes','exec'),ns)
attempts=[]
def deny(*a,**k):attempts.append('network');raise AssertionError('offline')
with patch.object(socket.socket,'connect',deny),patch.object(socket,'getaddrinfo',deny),TestClient(app) as client:
reason=client.post('/v1/reason',json={'prompt':'fixture-only'});trace=client.get('/v1/trace');metrics=client.get('/v1/cell01/me')
result={'observed_at':datetime.now(timezone.utc).isoformat(),'scope':'exact AST-extracted current routes, fixture auth, inert logger, sleeps removed; not full app or production','reason':{'http':reason.status_code,'body':reason.json()},'trace':{'http':trace.status_code,'events':[json.loads(x[6:]) for x in trace.text.splitlines() if x.startswith('data: ')]},'metrics':{'http':metrics.status_code,'body':metrics.json()},'network_attempts':attempts}
assert not attempts
print(json.dumps(result,indent=2))