docs(voice): plan phased local S2S adapter with execution prompts

This commit is contained in:
amirhosein mazaheri
2026-10-15 09:21:54 +03:30
parent 5a4786d0fe
commit 22f29b8d58
12 changed files with 981 additions and 0 deletions
@@ -0,0 +1,58 @@
# Phase 6 - Persian quality, latency, cost and resilience
Paste the following into a fresh implementation session in this repository.
```text
Implement Phase 6 only: Persian quality, latency, cost and resilience.
Prerequisite:
Phases 3-5 accepted; exact model/profile choices and frozen evaluation corpus recorded.
Required visible outcome:
A paired OpenAI/local scorecard and audio samples demonstrate measured accuracy, latency, failure behavior and cost per successful task.
Execution rules:
- Read docs/plans/local-s2s-adapter-plan.md and docs/plans/local-s2s-adapter-progress.md first. Read applicable AGENTS.md, repository skills and governing API/database/workflow sections. Inspect current code; historical defaults are not current evidence.
- Implement only this phase. Check actual prerequisite artifacts, not just the existence of code. State observed, simulated, unverified and blocked outcomes separately.
- Preserve OpenAI/Gemini behavior, original operational/rollback containers/images, frozen old profiles and unrelated working-tree changes. No database reset, compose down, pruning or implicit provider switch.
- Keep existing browser PCM24k/application events, backend-derived identity, one canonical search implementation, document/chunk references and authorization/revision checks.
- Make the smallest scoped change. No plugin framework, full runtime rewrite, new broker or unrelated refactor. Update intentional contracts and affected consumers coherently; never edit applied migrations.
- Ordinary tests are provider-free. DB acceptance requires a verified disposable TEST_DATABASE_URL and --require-postgres; never production. Do not run a parallel application API against the operational database.
- Reuse explicit authorization already present. Paid requests, downloads and operational switching need the applicable bounded authorization. Without it, finish independent offline preparation, identify the exact missing prerequisite and keep dependent live acceptance open.
- Do not print keys/full environments/raw provider payloads or real user speech. Consent-controlled fixture artifacts are separate from default logs.
- Never fake provider events, terminal success or history acknowledgements. Unsupported capabilities fail safely. Do not introduce automatic cross-provider fallback.
- Before finishing: inspect diff, run meaningful checks, record exact commands/results and demo steps, update the progress ledger and list all not-run checks. Do not accept a phase with required live/human checks unrun. Do not begin the next phase.
Required work:
1. Use identical authorized corpus/questions/audio fixtures for baseline and candidate; record exact profiles/sample counts.
2. Cover names/roles, numbers/dates, pauses/noise, correction/ambiguity, follow-up/topic switch, no evidence and conflicts.
3. Measure first audible response after speech end, first text/audio, tool time, interruption stop, underruns, duplicates, disconnects and completion rate.
4. Count actual returned input/output/cache usage, STT duration, TTS billed units, failed/abandoned work and startup probes; unknown costs stay unknown.
5. Fault-test slow/down providers, quota, partial stream loss, engine restart, saturation and teardown; no late contamination, unbounded queues or retry storms.
6. Change one component at a time. Predeclare thresholds and keep human Persian listening separate from transport checks. Do not tune thresholds after observing failures.
Acceptance criteria:
- Zero incorrect critical names/numbers/dates/conditions in the agreed fixture set; no fabricated unsupported answers.
- Interruption scenarios complete or fail safely as specified; no persistent underruns.
- Assess predeclared targets with counts and failures. Provisional p95 first-audible latency <= baseline + 1 second; cost/task <= 70% baseline for cost-saving promotion.
- If quality/cost targets fail, classify honestly and keep OpenAI. Missing live/human checks leave the gate open.
Relevant paths (verify actual locations before editing):
Evaluation harness, consented fixtures/annotations, content-free usage/timing diagnostics and only demonstrated bounded resource/error fixes.
Validation:
Focused regressions, isolated DB acceptance, controlled transport faults, authorized bounded paired provider evaluation and human listening.
Visible demonstration:
Play paired name/number/date clips; open the scorecard and demonstrate a controlled provider failure without cross-session output.
Explicit stop/narrow condition:
No blanket prompt/buffer expansion, selected anecdotes or mocked quality claims. Targets are provisional goals, not achieved measurements.
Deliver:
1. Scoped code/configuration and necessary tests/contracts where this phase requires implementation; Phase 0 remains an audit.
2. docs/evaluation/local-s2s/phase-06.md with exact commands, results, actual/simulated/unverified evidence, fingerprints, not-run checks and risks.
3. Updated docs/plans/local-s2s-adapter-progress.md with a candid acceptance verdict.
4. Exact demo instructions and rollback relevance. Preserve the operational provider unless this phase explicitly authorizes switching and session authorization exists.
Do not implement the next phase. Do not mark acceptance complete with mandatory live or human checks unrun.
```