M6 + M0: hardening, deploy docs, PoC scripts

- Pipeline-down fallback: dialplan plays gogo-fallback after a failed
  AudioSocket (§15) + script to synthesize the Bosnian prompt via TTS
- Voice heartbeat file → /health/voice endpoint + live status in admin panel
- Retention job also purges stale call registrations; chat sessions metered;
  100%-usage super-admin alert email (GOGO_ADMIN_ALERT_EMAIL)
- .env.example, docs/DEPLOY.md (compose stack, GPU node, backups pg_dump,
  update procedure, security notes)
- §16 Definition of Done as an automated test: softphone-style call → fake
  partner availability → request pushed → webhook confirm → console SMS
- M0 PoC scripts: STT accuracy harness (CER/WER + spoken-digit check; dry-run
  verified with espeak-ng samples + faster-whisper small on CPU — phone number
  extracted exactly), TTS bake-off (Azure vs ElevenLabs, latency+cost), and
  end-to-end latency smoke test speaking real AudioSocket to the live pipeline

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 11:27:05 +02:00
parent de5a2abdeb
commit fd45ff84dc
16 changed files with 733 additions and 5 deletions

View File

@@ -61,6 +61,7 @@ async def record_agent_call(
tenant.slug, used // 60, tenant.included_minutes,
)
await _send_warning(session, tenant, used // 60, 100)
await _alert_admin(tenant, used // 60)
elif used >= included_s * 0.8 and not counter.warned_80:
counter.warned_80 = True
await _send_warning(session, tenant, used // 60, 80)
@@ -75,6 +76,28 @@ async def _send_warning(session: AsyncSession, tenant: Tenant, used_minutes: int
log.exception("usage warning email failed (tenant %s)", tenant.slug)
async def _alert_admin(tenant: Tenant, used_minutes: int) -> None:
"""100% soft-limit hit → alert the super-admin for an upsell conversation (§12)."""
from gogo.config import get_settings
from gogo.email import EmailMessage, send_email
to = get_settings().admin_alert_email
if not to:
return
try:
await send_email(
EmailMessage(
[to],
f"[Gogo] {tenant.name} prešao 100% minuta ({used_minutes} min)",
f"Salon {tenant.name} ({tenant.slug}) je prešao uključene minute "
f"({used_minutes}/{tenant.included_minutes}). Asistent i dalje odgovara "
"(hard cutoff je isključen) — vrijeme za razgovor o većem paketu.",
)
)
except Exception: # noqa: BLE001
log.exception("admin alert email failed")
async def record_sms(session: AsyncSession, tenant_id: uuid.UUID) -> None:
counter = await get_counter(session, tenant_id)
counter.sms_sent += 1