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.
100 lines
5.9 KiB
Markdown
100 lines
5.9 KiB
Markdown
# Phase 4 provider selection and rollback preparation
|
|
|
|
Preparation only. Phase 3 real barge-in/RAG acceptance, paired evaluation and
|
|
restoration evidence are still required. Do not promote local_s2s from fixture
|
|
results or start paid engine initialization without a fresh bounded ledger under
|
|
the original $1 authorization. Operational services and user .env are unchanged.
|
|
|
|
## Selection inside one API
|
|
|
|
`VOICE_PROVIDER` keeps its existing default meaning. Additional session choices
|
|
are enabled explicitly with server-only `VOICE_SELECTABLE_PROVIDERS`, for example
|
|
`["openai","local_s2s"]`. Empty preserves default-only behavior. Both providers
|
|
use the same backend identity, authorization, canonical search and database.
|
|
There is no automatic fallback. Local selection retains the isolated
|
|
`*_local_s2s_test` database/dedicated storage requirement.
|
|
|
|
The UI reads authenticated `GET /api/v1/voice/sessions/providers`, displays
|
|
configuration eligibility and lets the user choose a provider. This request does
|
|
not connect to a provider; `connection_checked=false` explicitly records that
|
|
remote readiness has not been tested. Keys, component models, speed and buffers
|
|
remain server-owned. An unconfigured or disabled provider cannot be selected.
|
|
|
|
Changing the dropdown closes the current call and checks its terminal server
|
|
status. If closure is unknown, selection and request ids remain pinned and a
|
|
message explains that the change was not applied. A successful change takes
|
|
effect on the next microphone click, which creates new request/session ids.
|
|
No media is resumed across providers. An ambiguous creation attempt cannot be
|
|
reused with a different explicit provider. A request-id/provider conflict returns
|
|
409; an unenabled provider is unavailable, never silently replaced.
|
|
|
|
`GET /api/v1/configuration?provider=openai|local_s2s|gemini` evaluates the selected
|
|
provider through the same capability checks. Old clients may omit provider and
|
|
retain default behavior. A new frontend against an older backend hides the
|
|
unsupported selector; it does not rewrite a pending request's provider intent.
|
|
|
|
## Configuration review before a disposable test
|
|
|
|
1. Preserve the complete existing OpenAI effective profile/environment privately,
|
|
including model, voice, speed, token limits, ASR, VAD and delivery settings.
|
|
Do not recreate it from example defaults. Record its profile digest.
|
|
2. Use the standalone disposable candidate stack. Add the reviewed candidate API
|
|
image and the additional provider allowlist. Keep one API per database.
|
|
3. Keep the local engine fixed to its own model/voice and retained-draft revision.
|
|
Require authenticated engine setup proof. Never change global engine models
|
|
from frontend fields.
|
|
4. Supply a newly prepared, exclusive, carried-forward test ledger before paid
|
|
startup. Previous ledgers are exhausted/exclusive and must not be reset.
|
|
5. Confirm provider metadata, cookie/Origin/CSRF admission, frozen replay,
|
|
unavailable-provider rejection and normal session closure before human tests.
|
|
|
|
No operational compose up/down, container stop/start, volume cleanup or provider
|
|
switch is performed by this runbook or scorecard command.
|
|
|
|
## Controlled deployment and rollback (not executed)
|
|
|
|
After Phase 3 acceptance and explicit operational authorization:
|
|
|
|
- Record the actual current API/container/image identities, server profile digest,
|
|
mounts and database compatibility. Preserve the original container and image.
|
|
- Close/drain active sessions; stop the current API before a candidate is allowed
|
|
to reconcile that same operational database. Never run two APIs against it.
|
|
- Verify fresh-session Persian greeting, selected provider, real RAG, used sources,
|
|
interruption and normal close. A health response alone is insufficient.
|
|
- Actually stop the candidate and restore the preserved OpenAI API/image/profile
|
|
without rebuilding. Verify a fresh baseline voice session and preserved users,
|
|
documents and ingestion. Then leave the provider explicitly requested by user.
|
|
- If validation fails, preserve evidence and restore the known baseline. Container
|
|
rollback does not roll back the database/filesystem or resume a media session.
|
|
|
|
No database migration was added for provider selection. Applied migrations are
|
|
unchanged. Actual backward image compatibility/restoration remains unproved;
|
|
this document is not rollback acceptance and deliberately contains no guessed
|
|
operational container IDs or commands that could stop the wrong service.
|
|
|
|
## Paired evaluation input
|
|
|
|
Copy `phase-04-evaluation-template.json` to a new consent-controlled artifact.
|
|
Record stable OpenAI/local profile SHA-256 values and approve the provisional
|
|
thresholds and minimum sample counts before collecting live observations.
|
|
Each sample contains `provider`, `case_id`, booleans `success`, `critical_error`,
|
|
`persistent_underrun`, `duplicate`, `disconnected`, and observed
|
|
`first_audible_ms`; optionally `tool_ms` and `interruption_stop_ms`.
|
|
Record all billed charges with unique `id`, `provider`, `kind` and `cost_usd`.
|
|
Kinds are request/startup/failed/abandoned/session; avoid counting the same invoice
|
|
in both per-request and session totals. Unknown cost is null, never zero.
|
|
|
|
```sh
|
|
.venv/bin/python -m services.local_s2s.evaluation --input <observations.json> --output <new-scorecard.json>
|
|
```
|
|
|
|
The command is offline, refuses to overwrite an output and performs no provider
|
|
calls or deployment actions. It reports nearest-rank p95, paired case counts and
|
|
cost per successful task including all supplied overhead. It blocks acceptance
|
|
for missing samples, unknown costs, unpaired cases, failures, unaccepted thresholds,
|
|
missing profile identity, missing real/human evidence or missing rollback proof.
|
|
Targets remain provisional: zero critical/task failures, no persistent underruns
|
|
or duplicate/disconnected tasks, local p95 <= baseline + 1000ms and cost <= 70%
|
|
of baseline. Sample count is deliberately unset until accepted. A scorecard is
|
|
not authorization to switch services.
|