#!/usr/bin/env python3 """NAS Hermes: four synthetic telemetry checks and one short speech check.""" import concurrent.futures,importlib.util,io,json,threading,time,urllib.request,wave from pathlib import Path s=importlib.util.spec_from_file_location('managed_transport',Path(__file__).resolve().parent.parent/'basalt-candidate-2026-11-01/paired_transport.py');assert s and s.loader m=importlib.util.module_from_spec(s);s.loader.exec_module(m);KEY=m.key() BASE='http://192.168.1.212:8120';OUT=Path('/opt/data/profiles/athena-deck/cache/scratch/telemetry-live-acceptance.json') START=time.monotonic();samples=[];stop=threading.Event() def call(path,data=None,binary=False): assert time.monotonic()-START<900,'Short test budget exceeded' req=urllib.request.Request(BASE+path,data=json.dumps(data).encode() if data is not None else None,headers={'Authorization':'Bearer '+KEY,'Content-Type':'application/json'}) with urllib.request.urlopen(req,timeout=180 if data is not None else 10) as r:return r.read() if binary else json.load(r) def poll(): while not stop.is_set(): try:samples.append(call('/v1/telemetry/speed')) except Exception as e:samples.append({'error':type(e).__name__}) stop.wait(.15) def chat(messages): out=call('/v1/chat/completions',dict(model='flash-next-basalt',messages=messages,max_tokens=128,temperature=0,chat_template_kwargs={'enable_thinking':False})) assert out['choices'][0]['message'].get('content') return {'usage':out.get('usage'),'timings':out.get('timings')} def main(): worker=threading.Thread(target=poll,daemon=True);worker.start() base='\n'.join(f'Datenzeile {i:04d}: alpha beta gamma delta epsilon, unveraenderte Testdaten.' for i in range(600)) first=[{'role':'user','content':base+'\nSchreibe jetzt die Zahlen von 1 bis 300, mit Komma getrennt.'}] second=[{'role':'user','content':base+'\nSchreibe jetzt die Zahlen von 301 bis 600, mit Komma getrennt.'}] third=[{'role':'user','content':'Schreibe die Zahlen von 601 bis 900, mit Komma getrennt.'}] try: with concurrent.futures.ThreadPoolExecutor(max_workers=3) as pool: jobs=[pool.submit(chat,msg) for msg in (first,second,third)];results=[j.result() for j in jobs] follow=chat(first) finally:stop.set();worker.join(timeout=12) valid=[x for x in samples if x.get('available',True) and 'error' not in x] checks=dict(two_slots_observed=any(x.get('active_slots')==2 for x in valid),generation_observed=any((x.get('generation_tok_s') or 0)>0 for x in valid),prefill_observed=any((x.get('prefill_tok_s') or 0)>0 for x in valid),cache_reused=(follow.get('usage',{}).get('prompt_tokens_details',{}).get('cached_tokens') or 0)>0) result=dict(checks=checks,requests=results,cached_followup=follow,samples=samples,seconds=time.monotonic()-START) OUT.write_text(json.dumps(result,indent=2));print(json.dumps({'stage':'LLM acceptance','checks':checks,'seconds':result['seconds'],'evidence':str(OUT)}),flush=True) assert all(checks.values()),'One or more actual LLM telemetry checks failed' audio=call('/v1/audio/speech',dict(model='qwen-anna-gpu-3060',input='Anna ist bereit. Die Anzeige wurde aktualisiert.',voice='default',response_format='wav'),binary=True) with wave.open(io.BytesIO(audio),'rb') as w:voice=dict(rate=w.getframerate(),channels=w.getnchannels(),frames=w.getnframes(),seconds=w.getnframes()/w.getframerate()) assert voice['rate']==24000 and voice['channels']==1 and voice['frames']>0 result.update(tts=voice,seconds=time.monotonic()-START);OUT.write_text(json.dumps(result,indent=2));assert json.loads(OUT.read_text())['tts']==voice print(json.dumps({'stage':'Anna API passed','voice':voice,'total_seconds':result['seconds']}),flush=True) if __name__=='__main__':main()