Add architecture longread and remove dead code found during review #1

Merged
didar merged 2 commits from worktree-call-center-review into main 2026-08-20 09:42:16 +00:00
Owner
  • docs: longread.md — deep architecture/flow review of the whole
    platform (services, event bus reality vs docs, AI/ML stack honesty
    check, tech debt inventory)
  • ai_orchestrator_service/voice.py: drop _voice_decision_legacy
    (unreferenced) and the shadowed first _voice_decision definition
    (silently overwritten by the real one, dead code)
  • ui/analyst/app.js: drop duplicate dead definitions of
    loadSavedAnalyticsViews/saveAnalyticsView/deleteAnalyticsView and
    the first loadAnalyticsTrend implementation, all shadowed by later
    declarations in the same file; kept the intentional AI-mode
    drilldown wrapper layer (openAnalyticsDrilldown/exportAnalyticsDrilldownCsv/etc.)
    since that duplication is deliberate delegation, not dead code
  • ui/operator/vendor/sip-0.21.2.min.js: remove byte-identical orphaned
    duplicate of ui/operator/sip-0.21.2.min.js (unreferenced anywhere)
- docs: longread.md — deep architecture/flow review of the whole platform (services, event bus reality vs docs, AI/ML stack honesty check, tech debt inventory) - ai_orchestrator_service/voice.py: drop _voice_decision_legacy (unreferenced) and the shadowed first _voice_decision definition (silently overwritten by the real one, dead code) - ui/analyst/app.js: drop duplicate dead definitions of loadSavedAnalyticsViews/saveAnalyticsView/deleteAnalyticsView and the first loadAnalyticsTrend implementation, all shadowed by later declarations in the same file; kept the intentional AI-mode drilldown wrapper layer (openAnalyticsDrilldown/exportAnalyticsDrilldownCsv/etc.) since that duplication is deliberate delegation, not dead code - ui/operator/vendor/sip-0.21.2.min.js: remove byte-identical orphaned duplicate of ui/operator/sip-0.21.2.min.js (unreferenced anywhere)
didar added 1 commit 2026-08-19 14:39:09 +00:00
- docs: longread.md — deep architecture/flow review of the whole
  platform (services, event bus reality vs docs, AI/ML stack honesty
  check, tech debt inventory)
- ai_orchestrator_service/voice.py: drop _voice_decision_legacy
  (unreferenced) and the shadowed first _voice_decision definition
  (silently overwritten by the real one, dead code)
- ui/analyst/app.js: drop duplicate dead definitions of
  loadSavedAnalyticsViews/saveAnalyticsView/deleteAnalyticsView and
  the first loadAnalyticsTrend implementation, all shadowed by later
  declarations in the same file; kept the intentional AI-mode
  drilldown wrapper layer (openAnalyticsDrilldown/exportAnalyticsDrilldownCsv/etc.)
  since that duplication is deliberate delegation, not dead code
- ui/operator/vendor/sip-0.21.2.min.js: remove byte-identical orphaned
  duplicate of ui/operator/sip-0.21.2.min.js (unreferenced anywhere)

Verified via full pytest run: identical set of 97 pre-existing
failures before and after (sales_* test-isolation ordering issue and
one known persona-prompt test), no new regressions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
didar requested review from arystanbek 2026-08-19 14:39:09 +00:00
didar added 1 commit 2026-08-19 16:40:42 +00:00
The AudioSocket/media_runtime playback pipeline already supports chunked
TTS streaming (voice_v2_streaming_tts), but every provider inherited the
base TTSProvider.synthesize_chunks(), which just called the blocking
synthesize() and yielded the entire finished audio as a single "chunk" -
so the caller waited for full-utterance synthesis before any playback
could start regardless of the flag.

ElevenLabs is the production default (AI_VOICE_TTS_PROVIDER=elevenlabs in
deployment/docker-compose.server.yml), so give it a real implementation
that POSTs to the /stream endpoint and yields audio as network chunks
arrive, instead of waiting for the whole response body. Chunk boundaries
are re-aligned to whole 16-bit PCM samples so a split sample at a network
read boundary can't corrupt playback. The full synthesized audio is still
written to the on-disk cache afterwards so repeat phrases stay fast and
skip the vendor call entirely, matching the existing synthesize() cache
behavior.

Added test_elevenlabs_tts_provider_streams_chunks_and_caches_full_audio to
cover: chunk splitting mid-sample gets re-aligned, all yielded chunks are
sample-aligned, the full audio round-trips through the cache, and a
cached synthesis is replayed without invoking the streaming endpoint
again.

Verified via tests/test_ai_voice_tts_provider.py (9/9 pass) and a wider
voice/tts-filtered run across the suite: the only failures present are
the same pre-existing, already-documented ones (sales_service test
cross-file isolation ordering, one known persona-prompt assertion) -
identical set to before this change, no new failures.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner

Ревью (Arystanbek):

Просмотрел diff целиком. По удалению dead code — всё корректно, поведение не меняется:

  • voice.py (-206): _voice_decision_legacy и перекрытое первое _voice_decision удаляются, второе определение и так выигрывало в Python. OK
  • app.js (-90), ui/operator/vendor/sip-0.21.2.min.js (удалён): дубль-определения / orphaned-дубликат. OK
  • longread.md: доки. OK

Но в diff есть кое-что, чего нет в описании:

  • tts.py (+61): добавлен метод synthesize_chunks (стриминговый ElevenLabs TTS с 2-byte PCM выравниванием на границах чанков + кэш) и тест (+73). Это новая фича, а не "remove dead code". На main метод пока нигде не вызывается -> висячий код до будущего PR.
    Варианты: дописать в описание, вынести в отдельный PR, либо подтвердить, что это groundwork под следующий PR со стримингом ответа.

CI/CD: konturai-deploy.sh (case call-center) после мержа делает git pull + build :latest, но перезапускает ТОЛЬКО api-gateway. voice.py -> ai_orchestrator, tts.py -> ai-voice-runtime — эти сервисы автоматически не рестартнутся, изменения не вступят в силу без ручного рестарта. Учти при деплое.

Ревью (Arystanbek): Просмотрел diff целиком. По удалению dead code — всё корректно, поведение не меняется: - voice.py (-206): `_voice_decision_legacy` и перекрытое первое `_voice_decision` удаляются, второе определение и так выигрывало в Python. OK - app.js (-90), `ui/operator/vendor/sip-0.21.2.min.js` (удалён): дубль-определения / orphaned-дубликат. OK - longread.md: доки. OK Но в diff есть кое-что, чего нет в описании: - `tts.py` (+61): добавлен метод `synthesize_chunks` (стриминговый ElevenLabs TTS с 2-byte PCM выравниванием на границах чанков + кэш) и тест (+73). Это новая фича, а не "remove dead code". На `main` метод пока нигде не вызывается -> висячий код до будущего PR. Варианты: дописать в описание, вынести в отдельный PR, либо подтвердить, что это groundwork под следующий PR со стримингом ответа. CI/CD: `konturai-deploy.sh` (case `call-center`) после мержа делает `git pull` + `build :latest`, но перезапускает ТОЛЬКО `api-gateway`. `voice.py` -> `ai_orchestrator`, `tts.py` -> `ai-voice-runtime` — эти сервисы автоматически не рестартнутся, изменения не вступят в силу без ручного рестарта. Учти при деплое.
didar merged commit 9cc5d802d6 into main 2026-08-20 09:42:16 +00:00
didar deleted branch worktree-call-center-review 2026-08-20 09:42:16 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: digiops/call-center#1