Add ordered Gemini credential failover
Fixes #78.
Summary
A rejected or exhausted Gemini key can end an interview even when another credential is available. Add an ordered key list so the interview can switch credentials while staying in its original LiveKit room and project.
Changes
- Use provider keys, then global
GOOGLE_API_KEYS, then globalGOOGLE_API_KEY, resolved into one list at load time. Keys from a provider or the config file replace what they would inherit, and a blank value counts as unset. Reject empty entries and duplicate keys. - Share cooldowns across interviews and keep a working key selected for each interview. A rejected key sits out for 60 seconds; a 403 with no reason only for the kind of request that saw it. Failures that aren't about the key keep the existing retry budget on the same credential.
- When every Live key is out on quota, wait for the first one back within the restart budget, as a sole key would retry. An interview's first open still ends within 30 seconds.
- Switching Live keys uses cold recovery from retained interview state. Report key changes do not restart Live. Cross-key resumption remains unverified, and keys from the same Google Cloud project still share quota.
check-geminiselects keys the same way: it skips rejected keys, tries no more keys than an interview's first open could reach, and reports any other failure at once.- Make the integration tests portable so they also pass on Windows.
Testing
Add coverage for selection order, shared and per-surface cooldowns and their expiry, the wait on an all-quota rotation, reason codes in responses and close frames, blank key lists, redaction, bounded retries, a first-open 503 retried on the selected key with and without a backup, and check-gemini failover and its attempt limit.
cargo test passes on Windows: lib 272, cli 45, config 44 and web 126. scripts/test.sh passes on Ubuntu 24.04 (WSL), and cargo-mutants over the changes since the last review leaves no missed mutants. Formatting and Clippy pass.
Summary by cubic
Adds ordered Gemini credential failover so a rejected or quota-exhausted key no longer ends an interview. The interview switches to the next key while staying in its original LiveKit room and project.
GOOGLE_API_KEYStakes precedence over legacyGOOGLE_API_KEY; a provider list replaces the global list. Precedence, cooldowns, and session recovery are documented indocs/providers.md.- Quota and rejected-key failures move on to the next key; transport errors and 5xx responses keep the existing retry budget on the same key.
- Quota failures put a key on a shared 60-second cooldown per surface; a sole key is never marked, and invalid keys stay disabled until restart.
- Live key switches start a cold Gemini session from retained interview state; report key changes do not restart Live.
check-geminiselects keys the same way and tries no more than an interview's first open could reach.- Keys from the same Google Cloud project still share quota; cross-key resumption is not verified.
The integration tests also pass on Windows: test servers are drained before cleanup, shell scripts run through sh, and the tests use occupied ports and portable fixtures.