Files

61 lines
5.4 KiB
Markdown

# Phase 1 - Preserve OpenAI and introduce the provider boundary
Copy this prompt into a fresh implementation session in the repository.
```text
Implement Phase 1 of the active FOUR-phase local S2S plan only: Preserve OpenAI and introduce the provider boundary.
Do not execute the archived eight-stage prompts.
Prerequisite:
No adapter implementation has started. Inspect the current repository and deployment first.
Required visible outcome:
An existing OpenAI session still works; an offline before/after interruption replay proves the same cleanup and next-turn behavior.
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:
- Capture current/preserved container and image identities, effective provider/profile and focused regression results. Keep the operational deployment unchanged.
- Pin an upstream commit/build inputs and audit actual setup, input consumption, manual turn control, metadata/identities, tool events, audio rates, terminal states and history repair.
- Record a compatibility matrix and unresolved decisions, especially the no-op truncate and completed-but-unplayed history case.
- Extract only the small internal provider boundary needed by runtime. Runtime owns authorization, turn identity, playback credits, deadlines, evidence lifetime and next-turn release; adapters own native wire/confirmation details.
- Keep native OpenAI cancel/terminal/truncate/ack semantics, raw replay fingerprints and correlation intact. Preserve Gemini's conservative failures.
- Define correlated interruption progress with separate generation-stop and actual history-repair proof. Capability flags never waive safety gates.
- Add controlled-clock replay/conformance coverage and document the internal responsibility split without changing public browser behavior.
Acceptance criteria:
- Existing OpenAI regressions retain their assertions and pass; pre-existing failures are reported honestly.
- The same fixture before/after refactoring releases exactly one new response after matching cleanup, with wrong/missing/late/conflicting acknowledgements failing safely.
- Upstream SHA/build provenance, compatibility gaps and original rollback identities are recorded.
- No runtime switch, production data change, wholesale rewrite or model/voice branch in shared turn control.
Relevant areas; verify actual paths first:
configuration/settings, runtime.py, realtime.py, provider factory, minimal shared contract, Gemini compatibility, focused tests and voice contract docs.
Validation:
Existing context-sync, provider-selection, retained-search, source-report, output-limit and style tests; controlled-clock replay. Isolated PostgreSQL acceptance if persisted profile/lifecycle behavior is touched.
Visible demo:
Run an existing OpenAI interaction if already authorized, and show a deterministic interruption trace through the new boundary. No new provider is enabled.
Stop/narrow condition:
Unknown upstream behavior stays unverified. Do not weaken OpenAI or start a deployment switch to make the new boundary easier.
Deliver scoped implementation/configuration/tests/contracts as necessary,
docs/evaluation/local-s2s/phase-01.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.
```