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 3 - Local provider and normal browser session
# Phase 3 - Complete interruption, shared RAG and used sources
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 3 only: Local provider and normal browser session.
Implement Phase 3 of the active FOUR-phase local S2S plan only: Complete interruption, shared RAG and used sources.
Do not execute the archived eight-stage prompts.
Prerequisite:
Phases 1 and 2 have accepted prerequisite evidence. Candidate app has disposable DB/storage.
Phase 2 accepted. Local engine history ownership and compatibility gaps are understood; shared SearchService remains authoritative.
Required visible outcome:
The existing browser opens a local_s2s session, greets in Persian, displays transcript and closes cleanly in isolation.
The user interrupts and continues safely, receives correct document answers and sees only valid used sources; repeated interrupted searches are not duplicated.
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,39 @@ 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 local_s2s to validated selection/factory/settings/readiness without removing openai/gemini or adding a UI selector.
2. Freeze engine/patch/contract revisions, effective component models, voice, speech policy, rates and instruction/config digest. Do not store secrets or secret hashes.
3. Compare reservation expectations with authoritative effective engine setup; do not rely on connection reachability or echoing desired values.
4. Map real input acceptance, response intent/identity, tool frames, terminal states and audio/transcript. Do not synthesize native commit acknowledgements from timing.
5. Keep browser PCM16LE mono24k and public events. Bound resampling and convert playback coordinates correctly.
6. Preserve owner/Origin/cookie/CSRF/replay/epoch checks and old profiles. Audit DB/DTO constraints; new migration only if necessary.
7. Use isolated DB/storage and separate test browser credentials/origin. Unsupported interruption fails closed until Phase 4.
- First implement/prove local interruption and history synchronization. Patch/version the pinned engine narrowly if it cannot apply the required real mutation.
- Cover active generation AND already-completed generation with queued unplayed audio. Track operation/response/item/segment/session identities and actual played coordinates.
- Inspect the next real controlled LLM request: unheard assistant sentinel text must be absent while valid previous user/tool/assistant context remains. Do not infer text alignment from duration/character ratios.
- Accept only receipts emitted after the actual mutation with applied history revision/provenance. Missing, wrong, stale or conflicting receipts fail within bounded deadlines; runtime retains release authority.
- If exact heard-prefix repair is unproven, keep the gate open. Whole-turn rollback or fully-played-segment retention is a weaker policy requiring explicit acceptance and contract documentation.
- Suppress obsolete STT/LLM/TTS outputs even if remote inference keeps computing. Keep backend retained retrieval separate from speech cancellation and preserve original deadlines.
- Then expose search_knowledge, reuse_last_evidence and report_used_sources through the existing backend dispatcher/ToolContext/DurableTools/SearchService; never add engine DB authority or a parallel RAG implementation.
- Preserve successful-terminal tool validation, call/item/response dedup, backend scope, calibrated eligible retrieval, source identities and handoff/delivery revalidation.
- Test current-turn source reports, private invalid-report correction, no_evidence versus technical error, knowledge revocation, topic switch and interrupted pending-search reuse.
- Evaluate known hours/fees, deputy name/organization and incentive percentage/date/exclusion failures. Correct citations alone do not prove correct answer content.
Acceptance criteria:
- Ready/audio/transcript/close work end to end in the isolated app.
- Incorrect profile, configuration, ownership or epoch is rejected; no snapshot rewrites.
- Malformed terminals/disconnects cannot cause false success.
- This remains development-only, not operational parity or a default switch.
- No next response before generation-stop, real context repair and playback gates. Active and completed-unplayed history tests pass without fabricated acknowledgement events.
- Missing/wrong receipts fail safely; late output cannot contaminate a new turn or reused session; OpenAI interruption regressions remain intact.
- All three tools execute through existing authority; no stale/revoked/inactive/deleted evidence reaches reuse/delivery.
- Repeating an interrupted same-topic question uses one original retrieval plus revalidation, with valid used-source subset. Known critical document fixtures are answered correctly.
Relevant paths (verify actual locations before editing):
configuration.py, settings.py, voice_provider.py, new local adapter, live admission/lifecycle only where required, .env.example and isolated deployment config.
Relevant areas; verify actual paths first:
Local adapter and minimal pinned-engine repair extension, shared interruption contract/barriers, tool event mapping, existing dispatch/DurableTools and focused conformance/evaluation tests.
Validation:
Provider-free adapter contract tests, isolated PostgreSQL admission/replay/profile/revocation, then bounded browser live smoke.
Controlled-clock/history-inspection/late-event tests; all affected OpenAI tests; existing retained-search/source suites extended to local; isolated DB evidence/revocation acceptance; bounded real barge-in and RAG checks.
Visible demonstration:
Use the existing browser to greet and close. Show the local pinned profile and separate OpenAI conformance results.
Visible demo:
Interrupt before an unheard sentinel and inspect the subsequent LLM context; then ask hours, deputy and incentive questions, including a pending-search interruption/repeat.
Explicit stop/narrow condition:
Never use a second port with the operational DB. No promotion before interruption/RAG acceptance.
Stop/narrow condition:
This phase has two required checkpoints: history safety before dependent continuation tests, then shared RAG. They are not extra phases, and neither can be skipped or accepted from stopped playback alone.
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-03.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-03.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.
```