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.
This commit is contained in:
@@ -14,6 +14,10 @@ LIMITS = {'/v1/audio/transcriptions': (1100000, 65536),
|
||||
'/v1/audio/speech': (16384, 1440000)}
|
||||
|
||||
|
||||
class EvaluationBudgetExhausted(ValueError):
|
||||
"""Evaluation admission refused before any provider request."""
|
||||
|
||||
|
||||
class ComponentServer:
|
||||
def __init__(self, key, *, port=8766, transport=None, timeout=30, inactivity=None):
|
||||
if not key or not key.isascii() or any(c.isspace() for c in key):
|
||||
@@ -48,11 +52,13 @@ class ComponentServer:
|
||||
await self.stopping.wait()
|
||||
finally:
|
||||
server.close()
|
||||
await server.wait_closed()
|
||||
tasks = list(self.requests)
|
||||
for task, writer in list(self.requests.items()):
|
||||
writer.close()
|
||||
task.cancel()
|
||||
# Newer Python also waits for accepted clients here. Close/cancel
|
||||
# those owners first so waiting cannot defer provider cancellation.
|
||||
await server.wait_closed()
|
||||
if tasks:
|
||||
await asyncio.wait(tasks, timeout=1)
|
||||
self.counts['shutdown_pending'] = sum(not t.done() for t in tasks)
|
||||
@@ -194,6 +200,9 @@ class ComponentServer:
|
||||
forwarding.result()
|
||||
else:
|
||||
self.counts['disconnected'] += 1
|
||||
except EvaluationBudgetExhausted:
|
||||
self.counts['budget_rejected'] += 1
|
||||
await self._error(writer, 429)
|
||||
except TimeoutError:
|
||||
self.counts['expired'] += 1
|
||||
except asyncio.CancelledError:
|
||||
|
||||
Reference in New Issue
Block a user