feat(voice): add authenticated Phase 2 live lifecycle

Add cookie authentication, owned conversations, durable Live reservations,
tool completion/replay fencing, revocation, and startup reconciliation.
Introduce forward lifecycle/owner-chain migrations and the temporary Gemini
adapter while preserving the existing OpenAI Realtime adapter.

Include the executable audio client, regression coverage, configuration,
API/database documentation, and recorded acceptance evidence.

Validation: focused review suite 82 passed; Python/TOML parsing, JavaScript
syntax, and whitespace checks passed. Full PostgreSQL/provider-free results
are recorded in the repair report; real-provider/browser acceptance is unrun.

Follow-up work remains for configurable OpenAI/Gemini selection, transport
admission, authority diagnostics, playback message bounds, and client replay
identity after ambiguous creation responses.
This commit is contained in:
11linear11
2026-10-09 07:59:02 -04:00
parent 07245cd5ca
commit 996435d2ae
42 changed files with 4551 additions and 88 deletions
+53
View File
@@ -1,5 +1,16 @@
# Phase 1 agent reference map
Current voice decision (2026-10-09): **Gemini Live is temporarily the sole voice
provider because an OpenAI Realtime voice key is unavailable.** The validated
backend Gemini model/voice configuration is shared by reservation, stream and
operator smoke. No OpenAI voice key is required. Extraction/embedding providers,
frozen profiles, measured calibration and canonical search are unchanged.
The provider-independent browser audio/events, direct document/chunk identities
and durable owner/replay/revocation rules remain authoritative. Historical
OpenAI checkpoints below remain historical. Gemini interruption closes safely
where native sample-level context truncation cannot be verified; seamless
barge-in is not certified. See [Phase 2 repair report](guides/realtime-agent-phase2-repair.md).
Use this index to select the governing contract and inspect the real implementation before changing, testing, or reviewing behavior. Paths are relative to this file. Current voice contract amended 2026-10-08 by Realtime Phase 0; English revision 1.3 remains the broader scope baseline. Historical component evidence below is preserved; the English revision 1.3 documentation checkpoint reran no application/provider/database tests; current repair acceptance is recorded at the end. Use the latest applicable recorded acceptance, not earlier unavailable-database reports. Dated component records below describe their historical checkpoint; absence-of-worker statements there are superseded by the current Phase 5/6 inventory and repair evidence.
## Authority and document resolution
@@ -1818,3 +1829,45 @@ and fixture-correction reruns are recorded separately in the guide.
Real provider, browser playback/Persian speech and isolated PostgreSQL acceptance
remain unrun. Existing authorization, actor/corpus/profile/calibration gates and
fail-closed cancellation classification still apply; no Phase 2 work was added.
## Current Phase 2 repair inventory (2026-10-09)
- Deployment configuration: `app/modules/voice/configuration.py`; finite limits
remain in `app/modules/voice/settings.py`.
- Cookie auth and C01/V01-V04/WSS: `app/api/v1/auth.py`, `dependencies.py`,
`conversations.py`, `live.py`; bounded blocking work in
`app/infrastructure/blocking.py`; application lifecycle in `app/main.py`.
- Durable admission/completion: `app/modules/voice/lifecycle.py`,
`durable_tools.py`; post-commit loop notifications in `registry.py`.
- Forward owner-chain repair: `migrations/versions/0005_live_owner_chain.py`.
Revisions 0001-0004 are preserved.
- Gemini adapter: `app/infrastructure/gemini_live.py`; shared canonical search,
StructuredTool and SearchToolRunner are retained.
- Exercised developer audio example: `examples/voice-client.js`,
`examples/voice-audio-worklet.js`; guide linked in the repair report.
- This Linux environment uses `.venv/bin/python`, not the historical Windows
`.venv/Scripts/python`. Existing timeout validation creates a local socket;
sandbox denial must be distinguished from an application validation defect.
Exact executed checks, remaining provider limitations and preservation evidence
are recorded in the [Phase 2 repair report](guides/realtime-agent-phase2-repair.md).
## Remaining Phase 2 defects checkpoint (2026-10-09)
The [current repair record](guides/realtime-agent-phase2-repair.md#remaining-defect-repair-2026-10-09)
supersedes affected initial Phase 2 behavior. Native pending generations retain
their input identity; ambiguous overlapping speech closes safely. Gemini PCM
admission uses packed bounded slabs separately from controls and shares the
runtime aggregate backlog. Durable canonical technical errors coalesce/replay
with fresh eligibility checks. Legacy creation hashes are verified against
persisted payload/configuration before atomic normalization; migrations 0001-0005
remain immutable. The delivered VoiceClient now owns resources by connection
generation, coordinates V04 before transport teardown, and attempts logout
independently of close failure. Partial application startup always cleans up.
Regression sources add `tests/unit/test_phase2_remaining.py` and executable
`tests/support/voice_client_harness.mjs`. Actual client/ASGI/PostgreSQL close
acceptance uses a local transport bridge; Node executes the delivered client and
worklet. Exact results and unrun real-provider/browser prerequisites are in the
repair record. No selected-model multi-turn or frontend readiness claim is made.