#!/usr/bin/env python3 """Finite model-free WS route replay of canonical deployed source in isolated localhost. No live phone/session/history, no inference, no fake pack approvals or live configuration. """ import json,subprocess from pathlib import Path ROOT=Path(__file__).resolve().parents[1] REMOTE=r''' import asyncio,contextlib,inspect,json,secrets,socket,tempfile,hashlib,sys from pathlib import Path root=Path('/home/gorios-spark-2/lan-voice') for name,digest in expected.items():assert hashlib.sha256((root/name).read_bytes()).hexdigest()==digest import shutil stage_dir=tempfile.TemporaryDirectory(prefix='startup-canonical-source-') stage=Path(stage_dir.name) for path in root.glob('*.py'):shutil.copy2(path,stage/path.name) shutil.copy2(root/'reviewed_action_packs.json',stage/'reviewed_action_packs.json') (stage/'web').mkdir();sys.path.insert(0,str(stage)) import gateway as g import uvicorn,websockets,httpx from history import History from guest_sessions import GuestSessions from tests_fake import FakeModel from action_protocol import configured_packs pin='987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887' assert configured_packs()[pin]=={'asset_01':10042,'asset_02':10042} async def main(): with tempfile.TemporaryDirectory(prefix='startup-capabilities-probe-') as directory: history=History(Path(directory)/'public-empty.sqlite3');await history.initialize() token=secrets.token_urlsafe(32) async with httpx.AsyncClient(transport=httpx.MockTransport(lambda req: (_ for _ in ()).throw(AssertionError('no_inference_allowed')))) as client: state=g.app.state state.busy=False;state.model=FakeModel();state.client=client;state.history=history state.token=token;state.guest_enabled=False;state.lan_open=False;state.guests=GuestSessions();state.debug=None state.voices=[{'id':g.DEFAULT_VOICE_ID,'source':'registered_reference','default':True}] server=uvicorn.Server(uvicorn.Config(g.app,host='127.0.0.1',port=0,lifespan='off',log_level='critical',access_log=False)) sock=socket.socket();sock.bind(('127.0.0.1',0));sock.listen();sock.setblocking(False);port=sock.getsockname()[1] task=asyncio.create_task(server.serve(sockets=[sock]));rows=[] try: async with asyncio.timeout(5): while not server.started:await asyncio.sleep(.01) kwargs={'origin':'https://192.168.31.61:5011','open_timeout':3,'close_timeout':1} if 'proxy' in inspect.signature(websockets.connect).parameters:kwargs['proxy']=None for kind,offer in [('pending',{'action_protocol':1,'action_kinds':[],'action_pending_pack_sha256':pin}),('legacy',{}),('unknown',{'action_protocol':1,'action_kinds':[],'action_pending_pack_sha256':'b'*64})]: async with websockets.connect(f'ws://127.0.0.1:{port}/ws/dialogue',**kwargs) as ws: await ws.send(json.dumps({'type':'auth','token':token}));assert json.loads(await ws.recv())['type']=='auth' await ws.send(json.dumps({'type':'hello','codec':'pcm16','sample_rate':16000,'frame_duration':20,'persona':'default','tts_debug':False,**offer})) hello=json.loads(await ws.recv());assert hello['type']=='hello' and not hello['action_available'] assert hello['action_pending']==(kind=='pending') async def update(value): await ws.send(json.dumps({'type':'client.capabilities.ready','action_protocol':1,'action_kinds':['dance'],'action_pack_sha256':value})) async with asyncio.timeout(3): while True: event=json.loads(await ws.recv()) if event['type']=='client.capabilities':return event['action_available'],event['turn_id'] assert event['type']=='history' # Isolated empty history; never saved or printed. denied=await update('b'*64);accepted=await update(pin);duplicate=await update(pin) assert not denied[0] and accepted[0]==(kind=='pending') and duplicate==accepted rows.append({'offer':kind,'hello_available':False,'pending':hello['action_pending'],'ready_available':accepted[0],'duplicate_turn_unchanged':duplicate[1]==hello['turn_id']}) async with asyncio.timeout(3): while state.busy:await asyncio.sleep(.01) finally: server.should_exit=True;await task return {'status':'passed','scope':'canonical source isolated actual WS routes; no live session','rows':rows,'connections':3,'model_calls':0,'asr_calls':0,'tts_calls':0,'device':'not_run'} print(json.dumps(asyncio.run(main()))) stage_dir.cleanup() ''' def main(): expected=json.loads((ROOT/'gateway/SOURCE_MANIFEST.json').read_text())['deployment_baseline']['files'] payload='expected='+repr(expected)+'\n'+REMOTE result=subprocess.run(['ssh','-o','BatchMode=yes','-o','ConnectTimeout=5','gorios-spark-2@192.168.31.61','cd /home/gorios-spark-2/lan-voice && exec .venv/bin/python -'],input=payload.encode(),capture_output=True,timeout=25) if result.returncode: print('FAIL: isolated capability probe; remote exception suppressed, no live changes');raise SystemExit(1) report=json.loads(result.stdout);output=ROOT/'logs/action-emotion/startup-074/capability-ws.json' output.parent.mkdir(parents=True,exist_ok=True);output.write_text(json.dumps(report,indent=2)+'\n');print(json.dumps(report,indent=2)) if __name__=='__main__':main()