Skip to content

feat(api): add speech profile and language-pair routing - #245

Open
jinyu918 wants to merge 6 commits into
1024XEngineer:devfrom
jinyu918:feat/language-speech-routing-phase-1
Open

feat(api): add speech profile and language-pair routing#245
jinyu918 wants to merge 6 commits into
1024XEngineer:devfrom
jinyu918:feat/language-speech-routing-phase-1

Conversation

@jinyu918

@jinyu918 jinyu918 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements Phase 1 of language-pair-based ASR/TTS provider routing.

  • Adds versioned contract types for ASR profiles, TTS profiles, and exact language-pair routes.
  • Adds PostgreSQL schema for speech_asr_profiles, speech_tts_profiles, and speech_language_pair_routes.
  • Normalizes unordered language pairs so zh-CN <-> en-US and en-US <-> zh-CN resolve to the same route.
  • Enforces one active route per language pair through a partial unique index.
  • Validates that active routes reference enabled, non-retired, capability-compatible ASR and TTS profiles.
  • Preserves active language-catalog configuration creation during Phase 1. Strict validation against a complete active speech route is opt-in through NewServiceWithSpeechRouteValidator and will be enabled in production after constructable provider profiles and routes are provisioned.
  • Seeds the existing legacy-default profile pair and the en-US / zh-CN route for compatibility.
  • Documents profile immutability and the retirement-based replacement flow. No client-writable profile or route CRUD API is introduced.

Validation

  • Added contract, route-domain, migration-schema, and PostgreSQL store tests.
  • Verified both directions of zh-CN <-> en-US resolve to the same active route.
  • Verified duplicate active routes are rejected.
  • Verified disabled, retired, or capability-incompatible profiles cannot be used by an active route.
  • Verified language configurations without a complete active route are rejected.

Scope

This PR establishes the API data model and validation boundary only. It does not build the realtime provider registry, prepare session bindings, consume language configuration events, or change media/provider protocol handling.

Related issue

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

Go coverage

Scope Current Baseline Delta
packages/contracts 87.2% 87.2% +0.0%
services/api 61.1% 60.8% +0.3%
services/realtime-audio 78.6% 78.6% +0.0%
Total 69.3% 69.2% +0.1%

Base branch: dev · Commit: f6525f5 · Test workflow run

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one production regression in the new strict speech-route wiring. Targeted tests pass: go test ./packages/contracts/languages/v1 ./services/api/languages.

Comment thread services/api/main.go Outdated
@jinyu918

This comment was marked as outdated.

@fennoai

This comment was marked as resolved.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

整体结构清晰:契约、领域校验、PostgreSQL 存储和迁移职责分离合理;语言对查询使用规范化键和部分唯一索引,查询形态没有明显性能问题;错误包装与单元测试覆盖也较完整。

发现 1 个需要修正的能力完整性问题,已添加行内意见。

Comment thread services/api/languages/store_speech_postgres.go Outdated
@jinyu918 jinyu918 self-assigned this Aug 13, 2026
@jinyu918 jinyu918 added the enhancement New feature or request label Aug 13, 2026

@Jerry-Yu-TeslaCoil Jerry-Yu-TeslaCoil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先前两条评审意见(生产默认严格校验会打掉非 en-US/zh-CN 目录对;ResolveSpeechRoute 未要求 TTS 双侧覆盖)在最新提交里都已处理:生产仍走 NewService(严格校验 opt-in),Resolve 路径已要求双侧 TTS。CI 全绿。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants