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 2 - Isolated S2S engine with OpenRouter stages
# Phase 2 - Add an isolated local stack and browser voice session
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 2 only: Isolated S2S engine with OpenRouter stages.
Implement Phase 2 of the active FOUR-phase local S2S plan only: Add an isolated local stack and browser voice session.
Do not execute the archived eight-stage prompts.
Prerequisite:
Pinned engine/build design from Phase 0; independent of Phase 1 where no application integration is used.
Phase 1 accepted. Isolated engine and candidate API use disposable DB/storage, not the operational database.
Required visible outcome:
A Persian recording independently becomes a transcript, LLM response and playable WAV with stage timings and actual usage.
The existing browser talks in Persian through local_s2s using OpenRouter STT/LLM/TTS, displays transcripts and closes normally in a disposable environment.
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,34 +25,37 @@ 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. Build a separate pinned engine image/environment. Use local VAD and independently configured remote STT, Chat Completions LLM and TTS.
2. Discover/pin supported model IDs/voices/parameters and test Persian language behavior. Choose a tool-capable text LLM, not an assumed universal audio endpoint.
3. Verify explicit credential forwarding, multipart/JSON STT, TTS stream fields, raw PCM rate/endianness and startup probes. Add a narrow shim only for an observed mismatch.
4. Use final-utterance STT initially. Bound retries, requests, response sizes, concurrency and cleanup; include startup probes in cost.
5. Provide deterministic stub mode and opt-in live smoke with bounded requests/time/cost. Save only consented evaluation outputs; do not connect to production DB/API.
- Build a separate engine from the pinned SHA with local VAD and independently configured OpenRouter HTTP STT, tool-capable Chat Completions LLM and TTS. Avoid unnecessary local-model/GPU downloads.
- Discover/pin actual model IDs, voices, Persian hints, supported fields and PCM rates. Verify multipart/JSON STT, TTS streaming/format compatibility and explicit server-side credential forwarding.
- Begin with final-utterance STT. Bound requests/concurrency/bytes/retries/cleanup and meter startup probes. Provide stub mode plus an explicitly opt-in bounded live smoke and playable test audio.
- Add local_s2s settings/factory/readiness alongside openai/gemini. Preserve the browser PCM16LE mono24k and existing JSON events; use bounded stateful resampling if required.
- Freeze engine/patch/contract revision, component identities, voice/input policy and effective instruction/config digest. Compare to authoritative engine state, not request echoes or socket reachability.
- Map actual input acceptance, manual response creation/intent, tool framing, terminal/error and transcript/audio semantics without invented native commit events.
- Preserve owner/Origin/cookie/CSRF/replay/epoch checks and old snapshots. Audit provider DTO/DB constraints; use a forward migration only if actually needed and compatible with rollback.
- Use a separate test hostname/browser identity and disposable DB/storage. Until Phase 3, interruptions must fail safely and be labelled development-only; do not enable unsafe continuation.
Acceptance criteria:
- With authorized live prerequisites, all three stages succeed and output audio is valid; otherwise mark live-pending.
- Invalid key/model/voice/rate cannot produce false readiness.
- Models remain independently replaceable and keys remain server-side.
- Existing app, worker, database and rollback container are untouched.
- A normal browser greeting/answer/transcript/close works against the isolated candidate, and independent stage probes produce valid audio.
- Model/voice/rate/credential/effective-config mismatches fail setup accurately; keys and secret-derived hashes never enter profiles or logs.
- Existing OpenAI remains usable; new configuration does not rewrite old reservations or change the operational provider.
- Actual provider checks are distinguished from stubs. Missing credentials or real speech evidence leaves live acceptance pending.
Relevant paths (verify actual locations before editing):
An opt-in engine build/service directory, isolated Compose configuration, smoke command and evaluation fixtures. Do not vendor all upstream code into app/.
Relevant areas; verify actual paths first:
Pinned engine service/build config, isolated Compose profile, local adapter, validated settings/profile/factory/readiness, .env.example, smoke harness and tests.
Validation:
Pinned upstream relevant tests and HTTP fixtures; optional bounded actual-provider requests. Ordinary tests require no keys or weights.
HTTP boundary fixtures, pinned-engine relevant tests, local adapter contract tests, isolated PostgreSQL profile/admission/replay/revocation cases and bounded actual browser/provider smoke.
Visible demonstration:
Run the isolated Persian smoke, inspect its requested test transcript, hear the WAV and view per-stage timing/usage.
Visible demo:
Show a recorded Persian utterance becoming a WAV response, then perform a normal greeting in the existing browser against the isolated candidate.
Explicit stop/narrow condition:
Missing keys/availability blocks live proof only. Do not install unrelated local-model/GPU extras.
Stop/narrow condition:
A different port is not DB isolation. Do not claim safe barge-in or production parity before Phase 3; do not promote this provider.
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-02.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-02.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.
```