feat(voice): support evidence reuse, 120s output capacity, and input ASR coalescing
- Add internal reuse_last_evidence tool for continuing existing topic without repeated retrieval - Expand OpenAI output capacity to 120s / 5,760,000 bytes and add delivery fairness - Coalesce adjacent user ASR transcript deltas to prevent client control queue overflow - Add server-side OPENAI_REALTIME_SPEED configuration and update style to v4 - Add extensive unit and integration regressions for evidence reuse, capacity, and fairness
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Controlled-clock synchronization races and private branch attribution."""
|
||||
import asyncio
|
||||
import logging
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
@@ -10,6 +11,66 @@ from tests.unit.test_realtime_phase1 import (
|
||||
from tests.unit.test_realtime_repairs import Clock, without_ticker
|
||||
|
||||
|
||||
def test_numeric_timeline_is_disabled_by_default(runner, persisted, caplog):
|
||||
caplog.set_level(logging.INFO, logger="app.modules.voice.diagnostics")
|
||||
async def scenario():
|
||||
runtime, transport, _ = await make(SimpleNamespace(engine=None), runner, persisted)
|
||||
try:
|
||||
await input_turn(runtime)
|
||||
await response(runtime, transport)
|
||||
await runtime.handle(delta(48000))
|
||||
await until(lambda: next(iter(runtime.audio.values())).sent == 48000)
|
||||
assert "Voice trace" not in caplog.text
|
||||
finally:
|
||||
await runtime.close()
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_cancellation_timeline_distinguishes_receipt_from_locked_processing(runner, persisted, caplog):
|
||||
caplog.set_level(logging.INFO, logger="app.modules.voice.diagnostics")
|
||||
async def scenario():
|
||||
clock = Clock()
|
||||
runtime, transport, _ = await make(SimpleNamespace(engine=None), runner, persisted, clock=clock)
|
||||
runtime.settings = runtime.settings.model_copy(update={"diagnostic_trace_enabled": 1})
|
||||
await without_ticker(runtime)
|
||||
try:
|
||||
await input_turn(runtime)
|
||||
await response(runtime, transport)
|
||||
await runtime.handle(delta(48000))
|
||||
await until(lambda: next(iter(runtime.audio.values())).sent == 48000)
|
||||
await input_turn(runtime, "u2", 10)
|
||||
await until(lambda: "stage=cancel_sent" in caplog.text)
|
||||
deadline = runtime.responses["r1"].cancel_deadline
|
||||
clock.now = deadline - .1
|
||||
async with runtime.lock:
|
||||
terminal_task = asyncio.create_task(done(runtime, status="cancelled"))
|
||||
await until(lambda: "stage=terminal_received" in caplog.text)
|
||||
assert "stage=terminal_processed" not in caplog.text
|
||||
clock.advance(.05)
|
||||
await terminal_task
|
||||
assert runtime.usable and runtime.responses["r1"].terminal
|
||||
assert runtime.responses["r1"].cancel_deadline == deadline
|
||||
stages = [r.message.split("stage=")[1].split()[0] for r in caplog.records if "Voice trace" in r.message]
|
||||
expected = ["cancel_enqueued", "cancel_dispatched", "cancel_sent", "terminal_received", "terminal_processed"]
|
||||
assert [s for s in stages if s in expected] == expected
|
||||
assert "lock_wait_ms=" in caplog.text
|
||||
assert "turn=live-turn-1" in caplog.text
|
||||
assert "generated_bytes=48000" in caplog.text and "sent_bytes=48000" in caplog.text
|
||||
finally:
|
||||
await runtime.close()
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_trace_rejects_content_and_untrusted_references(caplog):
|
||||
from app.modules.voice.diagnostics import trace
|
||||
caplog.set_level(logging.INFO, logger="app.modules.voice.diagnostics")
|
||||
trace("SECRET_SESSION", "audio_received", turn_ref="SECRET_TURN", audio_ref="SECRET_AUDIO",
|
||||
chunk_bytes=9600, text="SECRET_DOCUMENT", generated_bytes=2**63, played_ms=True)
|
||||
assert "SECRET" not in caplog.text
|
||||
assert "generated_bytes=2147483647" in caplog.text and "chunk_bytes=9600" in caplog.text
|
||||
assert "played_ms=" not in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("terminal_first", [False, True])
|
||||
@pytest.mark.parametrize("verified", [False, True])
|
||||
def test_cancel_error_requires_verified_classification_and_terminal(
|
||||
@@ -298,4 +359,4 @@ def test_no_active_classifier_is_profile_and_signature_bounded(model, voice, acc
|
||||
adapter = RealtimeAdapter(object(), model=model, voice=voice)
|
||||
assert adapter.is_no_active(CAPTURED_NO_ACTIVE) is accepted
|
||||
assert not adapter.is_no_active(dict(CAPTURED_NO_ACTIVE, code="other"))
|
||||
assert not adapter.is_no_active(dict(CAPTURED_NO_ACTIVE, param="response_id"))
|
||||
assert not adapter.is_no_active(dict(CAPTURED_NO_ACTIVE, param="response_id"))
|
||||
|
||||
Reference in New Issue
Block a user