"""Shared runtime with local adapter and explicitly simulated native setup I/O.""" from uuid import uuid4 from app.infrastructure.local_s2s import LocalS2SAdapter from app.modules.voice.runtime import VoiceRuntime from app.modules.voice.settings import RuntimeSettings from tests.unit.test_local_s2s_phase2 import local_config, confirmed from tests.unit.test_realtime_phase1 import Transport, commands, until async def make_local(service, runner, persisted): wire, output = Transport(), [] adapter = LocalS2SAdapter(wire, config=local_config(local_s2s_retain_interrupted_answers=True), settings=RuntimeSettings(_env_file=None)) async def emit(event):output.append(event) async def authority(execution): return persisted['enabled'] and execution.capture( dict(id=execution.user_id,organization_id='fixture',role='user'),persisted['epoch']) runtime = VoiceRuntime(adapter,service,runner,uuid4(),emit,authority_check=authority) await runtime.start() await until(lambda:commands(wire,'session.update')) session=confirmed(adapter);session['id']='fixture-native-session' await runtime.handle(dict(type='session.updated',session=session)) await until(lambda:runtime.ready) return runtime,wire,output