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:
11linear11
2026-10-16 17:09:27 -04:00
parent 8d348f0ba1
commit a94b8cd3ea
111 changed files with 14764 additions and 58 deletions
+76
View File
@@ -0,0 +1,76 @@
# Phase 4 implementation preparation — 2026-10-16
Status: **offline_prepared; live evaluation and promotion not accepted**. The user
explicitly authorized preparation alongside unfinished real Phase 3 checks and
requested an OpenAI/local_s2s frontend selector. Neither phase is accepted from
these offline tests. No operational service/profile, audio buffering/speed,
provider key, paid ledger or document data was changed.
## Delivered
- Angular provider dropdown beside the composer. Standard choices are OpenAI and
«سیستم جدید»; legacy Gemini remains visible when current/enabled. Unavailable
choices are disabled. Changing provider closes the old call, checks terminal
status, and takes effect on the next microphone click with fresh request/session
ids. Unconfirmed closure keeps the old selection and ids.
- Authenticated metadata `/api/v1/voice/sessions/providers` reports configured
eligibility, not remote health. No paid probe is made. The server retains keys,
models, voices and tuned profiles. Frontend configuration eligibility for the
selected provider uses F01's optional provider query.
- V01 optionally selects an allowlisted provider. Omission preserves old clients;
replay keeps its frozen row. Conflicting explicit selection returns409 even
under concurrent creation. Stream setup uses the persisted provider and the
same authorization, profile, search and playback gates. No fallback is added.
- `VOICE_SELECTABLE_PROVIDERS=[]` defaults to the configured provider only.
Additional local choices still require isolated test DB/storage. No migration
or profile rewrite was introduced.
- Offline [paired scorecard](../../../services/local_s2s/evaluation.py),
[empty input template](phase-04-evaluation-template.json),
[fault matrix](phase-04-fault-matrix.json), and
[selection/rollback runbook](phase-04-switch-runbook.md). It reports nearest-rank
p95 and actual billed cost per successful task from all supplied charges;
unknown billing stays unknown. Missing paired samples, accepted thresholds,
real/human evidence or actual restoration blocks acceptance. No savings are
claimed from this implementation.
- Separate COPY-only API candidate
`sha256:51d4b79825bc3b29abba692093ee879360def9530676755acfb27d63884424ad`;
native engine remains pinned to the Phase 3 image. The
[prepared override](phase-04-candidate.override.yml) requires the preserved
private OpenAI profile and does not enable paid engine initialization. It was
syntax-validated with a fake profile fixture, not launched.
## Validation
The [machine-readable report](phase-04.json) records exact commands, hashes and
results. Results are provider-free unless explicitly marked otherwise.
- Backend selection/auth/lifecycle/local/history/scorecard: **207 passed in 34.66s**;
final targeted fault/scorecard checks **13 passed in 1.15s** (overlapping rerun).
- **14 PostgreSQL tests passed in 34.62s**, zero skips. They cover pinned provider, replay, competing choices,
close/new-session change, selected-provider WebSocket setup and existing
local/OpenAI/Gemini tool paths. Provider transport is controlled fixtures.
- **46 Angular voice service tests passed**. They cover switching, unconfirmed close, request-id
pinning and old-backend compatibility, alongside existing audio/teardown cases.
- Angular development build passed in **11.789s**. Tests require the installed Node22 runtime;
the frontend shell's Node20 failed to initialize the existing jsdom/undici
dependency before any tests ran. No dependencies or Node settings were changed.
- Actual candidate image passed OpenAPI/selection/empty-scorecard smoke with
network disabled. Compose config validation passed with a fake private profile.
- No real microphone/paired provider calls, browser visual acceptance, measured
cost saving, complete live fault campaign or operational restoration occurred.
## Use and remaining work
The UI/backend source and reviewable image are prepared. They are **not deployed**
to the user's running browser/API. Set the additional allowlist only in the
reviewed isolated environment and preserve the full existing OpenAI profile;
example defaults are not a substitute for its model/voice/input/tuning settings.
Both old and new clients are supported; pending identities are never rewritten
to make a provider switch succeed.
Before acceptance: complete real Phase 3 interruption/repeated-question/RAG and
critical factual cases; accept sample thresholds before paired measurements;
reconcile all startup/failure/abandoned costs; run resource/fault and human quality
checks; then, with separate operational authorization, actually demonstrate
restoration of preserved OpenAI without a rebuild. Keep one API per operational
DB and leave the final provider explicitly requested. Preparation is not promotion.