fix(voice): correct input accounting and session termination

Separate detected speech limits from continuous microphone silence while preserving transport bounds and absolute commit fencing.

Handle verified OpenAI cancellation races and terminal items, preserve causal close outcomes, and share bounded cleanup ownership with safe diagnostics.

Add regression coverage and align the API contract and frontend handoff. Validation: 61 focused unit tests passed; staged diff whitespace checks passed. Live browser acceptance remains outstanding.
This commit is contained in:
amirhosein mazaheri
2026-10-10 17:41:11 +03:30
parent b06eaf59f4
commit a769196bfa
23 changed files with 1809 additions and 92 deletions
@@ -176,19 +176,21 @@ failures persist `failed` with matching close reason/error code; committed termi
logout/V04/expiry outcomes remain intact. Persistence retries bounded admission
saturation, but a database outage can still prevent a durable write and is logged.
## Continuous idle input limitation
## Continuous microphone input
The example continuously sends microphone PCM after readiness, including silence.
The frozen input-since-commit budget is 480000 bytes (10 seconds at 24 kHz PCM16LE).
Without verified native commitment, exactly 480000 bytes are accepted; the next
sample fails LIVE_BUFFER_OVERFLOW and closes. Native input consumption/transport
send is not commitment. This behavior is deterministic for an idle Gemini fake
with no activity boundary and applies to uncommitted admission for either adapter.
The example continuously sends 24 kHz mono PCM16LE after readiness, including
silence. The 2026-10-10 [input-accounting repair](voice-input-accounting-repair.md)
supersedes the earlier deterministic 10-second idle overflow.
The 480000-byte limit now bounds trusted detected uncommitted speech intervals,
including VAD padding. Local queued/in-flight input remains bounded to 96000 bytes
and 100 messages, with existing send deadlines. Silence outside detected speech
does not consume the speech allowance. A completed send releases local transport
storage only; it is neither provider consumption nor commitment.
Longer continuous idle operation remains a product/provider-contract decision.
This example does not gate silence, fabricate commitment or add browser activity
controls. Use explicit stop/close and a fresh eligible session after overflow;
do not assume uninterrupted idle capture or seamless Gemini barge-in is supported.
Keep sending the original timeline; no RMS gate, new VAD, buffer clear or invented
silence acknowledgment is required. Genuine long speech, missing stop/commit,
transport saturation and expiry still fail safely. Browser/provider acceptance
remains necessary; seamless Gemini context truncation remains unsupported.
Automated fake-provider/loopback/worklet results prove technical boundaries only.
Real provider access, measured retrieval quality, Persian speech, microphone,