Files
rag-technical-docs-assistant/docs/evaluation/local-s2s/phase-02-accepted-20261016.md
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

112 lines
7.9 KiB
Markdown

# Phase 2 accepted — 2026-10-16
**Accepted for isolated development-only normal Persian browser voice.** The
required Phase 2 implementation, real component/audio evidence, human browser
round trip and applicable PostgreSQL acceptance are complete. This does not
promote local_s2s or accept interruption continuation. Phase 3/4 have not started.
[Machine-readable results](phase-02-accepted-20261016.json) record hashes, billing
lookups and exact scoped outcomes. Earlier checkpoints remain historical.
## Acceptance evidence
| Required gate | Actual evidence |
| --- | --- |
| Phase 1 / OpenAI preservation | Prior accepted [real OpenAI interaction](phase-01-linux-preparation.md); 258 focused preservation tests now pass |
| Pinned source, dependencies, image and assets | [Reviewed lock](phase-02-dependency-lock.md), [source acquisition](phase-02-source-checkout.json), [Linux image](phase-02-image-build-20261016.md), [assets](phase-02-linux-assets-20261016.md) |
| Actual native engine / setup / shutdown | [Native fixture conformance and cleanup](phase-02-native-session-20261016.md); actual engine image and first-turn repair below |
| Actual STT, LLM and TTS | [Component evidence](phase-02-real-components-20261016.md), [native round trip](phase-02-real-native-20261016.md); user previously accepted pronunciation |
| Existing browser, transcripts, full audio and normal close | [Repaired real browser exchange](phase-02-browser-first-turn-repair-20261016.md): all 350208 PCM bytes / 7.296s played, completed terminal without limitation/cancellation; isolated DB confirms closed/user_requested and no error |
| Setup mismatch, HTTP, adapter and frozen profile behavior | 125 focused local tests pass, including existing pinned-source/fixture coverage; actual native setup mismatch evidence retained |
| Isolated DB profile/replay/admission/owner/revocation and ASGI behavior | 63 PostgreSQL tests pass with --require-postgres, zero skips |
| Budget authorization | No new inference during completion; all unresolved attempts retain reservations; conservative exposure remains below $1 |
The repaired engine is immutable image
`sha256:a51167d1952a8947efe1c9048311b549a1998ab8cfaf41371228b6c326781ff9`.
Upstream remains `619e3fe4f71d1c6f35c15870d588a3638de34722`, extension
`rag-local-s2s-phase2-v3`, private shape v1. The same language detector now warms
before listener readiness. No model, buffer, speed, public event, PCM or timeout
change was needed to finish acceptance.
## Final checks and test repairs
| Check | Result |
| --- | --- |
| Local boundary/engine/Phase2/repair unit tests | 125 passed in 13.80s |
| OpenAI/provider/context/audio/style/source preservation | 258 passed in 61.48s |
| Local + expanded PostgreSQL acceptance | 63 passed in 116.02s, zero skips |
| Six corrected citation scenarios alone | 6 passed in 17.00s; included in the 63 |
| Final RAM-database runner smoke | 2 passed in 3.36s; repeats local cases |
| Browser/native budget guards and native runner | All three scripts passed |
| Recorded running-source fingerprints, Python syntax and secret scan | Passed |
The **446 primary tests** are 383 unit plus 63 integration tests. Subset reruns
are not counted again. The broader ordinary suite was not rerun; historical
unrelated cancellation-diagnostic failures remain disclosed in the Phase 1 report.
Two existing fixtures needed correction, without changing production runtime:
- The six ASGI cases waited for public sources immediately after retrieval, then
timed out on the next response acknowledgement. The API's existing
[declared-source amendment](../../specifications/RAG-Phase1-API-Catalog.md)
requires report_used_sources. Tests now complete that real tool round trip,
acknowledge each OpenAI response and verify exact public references and
document/chunk identities. No-evidence/errors publish no citations; reporting
creates no extra durable retrieval. Existing persistence assertions are retained.
- The transcript test assumed two adjacent unsent deltas would produce separate
frames, although existing control delivery may concatenate them. It now waits
for first-frame delivery before testing identity replay and a legitimate repeated
word. All original text/order/release assertions and deadlines remain intact.
The old fixtures were actually rerun before correction: PostgreSQL produced
57 passed / 6 failed in 212.44s, and preservation produced 257 passed / 1 failed
in 61.18s. These results are retained, superseded by the complete green reruns.
An initial disk-backed DB run was deliberately interrupted after 11 passes in
113.09s because of slow disk synchronization. Its test-owned database was removed.
Reproduction from the repository root, with the existing cached image/network:
```sh
TRUSTED_HOSTS='["localhost:8000","127.0.0.1:8000"]' .venv/bin/python -m pytest tests/unit/test_local_s2s_boundary.py tests/unit/test_local_s2s_engine.py tests/unit/test_local_s2s_phase2.py tests/unit/test_local_s2s_repairs.py -q --tb=short
TRUSTED_HOSTS='["localhost:8000","127.0.0.1:8000"]' .venv/bin/python -m pytest tests/unit/test_realtime_phase1.py tests/unit/test_live_context_sync.py tests/unit/test_phase2_provider_selection.py tests/unit/test_voice_retained_search.py tests/unit/test_voice_reported_sources.py tests/unit/test_voice_output_capacity.py tests/unit/test_openai_output_limit.py tests/unit/test_openai_persian_style.py tests/unit/test_openai_speech_configuration.py -q --tb=short
.venv/bin/python docs/evaluation/local-s2s/phase-02-final-postgres.py
.venv/bin/python docs/evaluation/local-s2s/check-browser-budget.py
.venv/bin/python docs/evaluation/local-s2s/check-native-budget.py
.venv/bin/python docs/evaluation/local-s2s/check-native-runner.py
```
The [DB runner](phase-02-final-postgres.py) creates a fresh 512MiB/no-swap,
two-CPU PostgreSQL/pgvector container from the verified cached image. Data is tmpfs;
PostgreSQL durability settings are not disabled. No published port, operational
volume, .env or provider credential is attached. The existing harness migrates and
drops random schemas; the owned container stops and auto-removes on completion.
No operational container/image/database was modified.
## Cost accounting and handoff
Read-only OpenRouter GET lookups confirmed **$0.003504399** across known billed
requests. All still-unresolved calls, the initial failed WAV and the cancelled TTS
retain their full reserves: **$0.417**. Combined conservative exposure is therefore
**$0.420504399**, below the original $1 authorization. The provider key's unrelated
$5 limit was not changed. A 404 is not treated as free.
Final per-request billing, including the successful browser greeting, remains
unavailable from some generation lookups. Thus no exact browser-turn cost or final
invoice total is claimed. Phase 2's bounded-cost compliance is verified; delayed
invoice reconciliation remains a disclosed accounting follow-up, not an unrun
functional acceptance test. Phase 4 cost/quality evaluation remains separate.
Original exclusive ledgers were neither reset nor rewritten. The live repair
ledger still records $0.925118333 and its $0.995118333 ceiling; the reconciliation
above is a separate accounting snapshot and grants no additional inference.
The paid engine watchdog was stopped normally after acceptance, releasing RAM.
Final inspect confirms engine exit0, OOMKilled=false, no retained task-owned
disposable acceptance container and no leftover disk-test database.
Its image, candidate DB/account, API, frontend and private login file are retained.
Do not restart its existing exclusive ledger or repeat paid browser tests.
Remaining work belongs to Phase 3 (interruption and real history repair, shared
RAG, used sources) and Phase 4 (quality/latency/cost evaluation, controlled switch
and proven rollback). Native fixture source/tool tests are not real-provider RAG
acceptance. Operational OpenAI remains preserved; this phase performs no promotion
or rollback rehearsal and claims no production parity.