docs(voice): consolidate local S2S roadmap into four phases

This commit is contained in:
amirhosein mazaheri
2026-10-15 09:26:39 +03:30
parent 22f29b8d58
commit 872e5f25cb
20 changed files with 1005 additions and 357 deletions
@@ -1,15 +1,16 @@
# Phase 4 - Verified interruption and history synchronization
# Phase 4 - Validate quality/cost and prove controlled switch/rollback
Paste the following into a fresh implementation session in this repository.
Copy this prompt into a fresh implementation session in the repository.
```text
Implement Phase 4 only: Verified interruption and history synchronization.
Implement Phase 4 of the active FOUR-phase local S2S plan only: Validate quality/cost and prove controlled switch/rollback.
Do not execute the archived eight-stage prompts.
Prerequisite:
Phase 3 works in isolation. Upstream history/turn ownership and required patch are understood.
Phase 3 accepted. Frozen corpus/model profiles, bounded live evaluation authorization and reviewable deployment/rollback configuration are available.
Required visible outcome:
The user interrupts a long answer and continues coherently; inspect the next model request to prove unheard sentinel text is absent.
A paired OpenAI/local scorecard supports the deployment decision, and the preserved OpenAI container is demonstrably restorable without rebuild.
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.
@@ -24,36 +25,38 @@ Execution rules:
- 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. Add an actual correlated engine repair operation/extension if needed. Pin the patch and test it independently; do not monkey-patch installed packages as the deployment strategy.
2. Handle both active generation and completed generation with audio still queued at the browser. Closing TTS HTTP or getting response.done does not prove history repair.
3. Track response/item/segment/session identities, final consumed position and reliable text/audio mapping; no proportional text slicing.
4. Preserve valid earlier user/assistant/tool state and remove unheard assistant continuation from subsequent LLM input. Verify applied history revision/digest.
5. If exact heard-prefix repair cannot be proven, keep this gate open. Whole-turn rollback or fully-played-segment-only retention needs explicit policy acceptance and contract changes.
6. Validate real applied receipts against operation identity; reject stale/missing/conflicting receipts with bounded safe failure. Runtime owns final release.
7. Suppress late STT/LLM/TTS work and preserve same-topic backend search independently. Re-run all affected OpenAI interruption tests.
- Run paired Persian fixtures with the same authorized corpus and expected facts: names/roles, numbers/dates/conditions, noise/pauses/corrections, ambiguity, no evidence, follow-up and topic switch.
- Measure first audible response after speech end, tool time, interruption stop, underruns, duplicates, disconnects and successful tasks. Count actual model usage, STT duration, TTS units, startup/failure/abandoned work; unknown cost stays unknown.
- Fault-test quota, slow/down endpoints, partial stream loss, restart, saturation and teardown; no unbounded queues, retry storms or stale output. Use human listening separately from deterministic checks.
- Set/accept thresholds before evaluation. Provisional targets: zero critical factual fixture errors, p95 first-audible latency <= baseline + 1 second, no persistent underruns and cost per successful task <= 70% baseline for cost-saving promotion.
- Change one component at a time and report failures honestly. If quality/cost targets fail, keep OpenAI rather than silently changing thresholds or padding buffers.
- Finalize opt-in Compose, .env.example and operator runbook. Keep original container/image/config intact and separately tag candidate. Check any schema change against the old image; incompatible schema blocks simple rollback.
- Complete all reviewable preparation before operational switching. With explicit authorization, drain/close sessions, stop current API, then start candidate on operational DB. Never run both APIs against it simultaneously.
- Verify fresh-session greeting, RAG, sources, interruption and close; actually stop candidate/start preserved OpenAI without rebuild and verify a fresh baseline session.
- Leave final provider as explicitly requested. Record IDs/digests/commands/checks and limitations; container rollback is not DB/filesystem rollback or seamless media resume.
Acceptance criteria:
- Generation stop, real context repair and application playback gates all precede next response.
- Active and completed-unplayed cases pass controlled history inspection and actual microphone testing.
- Wrong/missing receipts fail safely; late output cannot contaminate another turn/session.
- No fabricated conversation.item.truncated or weakened OpenAI checks; unapproved weaker policies block promotion.
- Required paired factual, human-quality, failure and resource checks have actual evidence and sample counts; missing live checks block promotion.
- Cost-saving claims include failed/abandoned/startup usage; model pricing alone is not measured service savings.
- Original OpenAI restoration has actually succeeded and users/ingestion data are preserved. One API owns the operational lifecycle at a time.
- Final provider is explicitly recorded. Without switch authorization, prepare the result and remain operationally unchanged rather than claiming deployment completion.
Relevant paths (verify actual locations before editing):
Internal interruption contract, local adapter, pinned engine extension/patch, runtime barrier integration, diagnostics and regression tests.
Relevant areas; verify actual paths first:
Evaluation harness/fixtures/usage diagnostics, opt-in Compose configuration, .env.example, operator runbook and phase evidence; code changes only for demonstrated defects.
Validation:
Controlled clocks, ordering, races, receipt replay, mid-segment interruption, teardown/reuse, terminal-completed/unplayed audio, plus actual bounded live interruption.
Focused/provider-free tests, isolated PostgreSQL acceptance, controlled faults, authorized paired real-provider checks and human listening; config/image inspection and controlled fresh-session switch/rollback.
Visible demonstration:
Generate an answer with a late sentinel, interrupt before hearing it, inspect the following LLM context, then demonstrate real barge-in and continuation.
Visible demo:
Play paired Persian name/date clips and show the scorecard. If authorized and accepted, demonstrate local RAG then OpenAI rollback without rebuilding the preserved container.
Explicit stop/narrow condition:
This is the highest-risk gate. Stopped playback or upstream SDK compatibility does not prove the required semantics.
Stop/narrow condition:
Quality/cost evidence and explicit operational switch authorization are separate gates within this phase. Prepare independent work but do not bypass either.
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-04.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.
Deliver scoped implementation/configuration/tests/contracts as necessary,
docs/evaluation/local-s2s/phase-04.md with exact commands and actual/simulated/
unverified outcomes, and an updated docs/plans/local-s2s-adapter-progress.md.
Provide demo steps, acceptance verdict, risks, not-run checks and rollback relevance.
Do not declare completion while mandatory real-provider/human checks are missing.
Do not implement the next phase or switch the operational provider implicitly.
```