Files
rag-technical-docs-assistant/docs/plans/archive/local-s2s-eight-phase/prompts/phase-04.md
T

60 lines
5.4 KiB
Markdown

# Phase 4 - Verified interruption and history synchronization
Paste the following into a fresh implementation session in this repository.
```text
Implement Phase 4 only: Verified interruption and history synchronization.
Prerequisite:
Phase 3 works in isolation. Upstream history/turn ownership and required patch are understood.
Required visible outcome:
The user interrupts a long answer and continues coherently; inspect the next model request to prove unheard sentinel text is absent.
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. 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.
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.
Relevant paths (verify actual locations before editing):
Internal interruption contract, local adapter, pinned engine extension/patch, runtime barrier integration, diagnostics and regression tests.
Validation:
Controlled clocks, ordering, races, receipt replay, mid-segment interruption, teardown/reuse, terminal-completed/unplayed audio, plus actual bounded live interruption.
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.
Explicit stop/narrow condition:
This is the highest-risk gate. Stopped playback or upstream SDK compatibility does not prove the required semantics.
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.
```