Files
rag-technical-docs-assistant/docs/evaluation/local-s2s/check-native-runner.py
T
11linear11 a94b8cd3ea feat(voice): implement local S2S retained history and provider selection
Add pinned CPU engine dependencies, retained interrupted-response history, provider admission, offline evaluation and isolated browser tooling.

Record Phase 2 acceptance and Phase 3/4 preparation, bounded paid-test accounting and interruption incident findings. Human interruption acceptance, paired OpenAI evaluation and rollback remain pending.
2026-10-16 17:09:27 -04:00

54 lines
2.1 KiB
Python

"""Provider-free checks: headroom refusal, owned stop and child exit propagation."""
import contextlib
from io import StringIO
from pathlib import Path
import runpy
from tempfile import TemporaryDirectory
from unittest.mock import patch
script = Path(__file__).with_name('run-image-session-smoke.py').resolve()
original_read = Path.read_text
def check(kind):
calls = []
memory = iter(([4*1024**2] if kind == 'headroom' else [6*1024**2, 2*1024**2]) + [6*1024**2]*4)
class Process:
returncode = None
def poll(self):
return self.returncode
def wait(self, timeout):
return self.returncode
process = Process()
def start(*args, **kwargs):
calls.append('start')
if kind == 'child_failure':
process.returncode = 7
return process
def stop(command, **kwargs):
if '--time' not in command:
raise AssertionError('Unexpected command')
calls.append('stop_owned')
process.returncode = 143
def read(path, *args, **kwargs):
if str(path) == '/proc/meminfo':
return 'MemAvailable: '+str(next(memory))+' kB\n'
return original_read(path, *args, **kwargs)
with TemporaryDirectory() as directory:
root = Path(directory)
(root/'.local-s2s-build').mkdir()
with patch('pathlib.Path.cwd', return_value=root), patch('pathlib.Path.read_text', read), \
patch('sys.argv', [str(script), 'normal']), patch('subprocess.Popen', start), \
patch('subprocess.run', stop), contextlib.redirect_stdout(StringIO()):
try:
runpy.run_path(str(script), run_name='__main__')
except SystemExit as exc:
assert exc.code == 1
else:
raise AssertionError('Failure returned success')
assert calls == ([] if kind == 'headroom' else ['start'] if kind == 'child_failure' else ['start','stop_owned'])
for case in ('headroom', 'low_memory', 'child_failure'):
check(case)
print('PASS: pre-start memory guard, owned-container stop, nonzero child propagation')