Skip to content

refactor(speech-core): share TTS request pre-resolution across discord and voice-call - #109640

Merged
steipete merged 1 commit into
mainfrom
refactor/speech-core-tts-glue
Jul 17, 2026
Merged

steipete merged 1 commit into
mainfrom
refactor/speech-core-tts-glue

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord voice and the voice-call plugin each re-implemented TTS request pre-resolution before calling the shared speech-core synthesis entry points: Discord carried a local mergeTtsConfig/resolveVoiceTtsConfig pair plus inline directive parsing, and voice-call rebuilt override merging, provider collection, and directive policy in telephony-tts.ts. The two copies had drifted (shallow vs deep provider merge; parse-time provider attribution disagreeing with what synthesis actually selects).

Why This Change Was Made

Phase 4 of the voice-stack consolidation (follows #109413, #109466, #109497). speech-core gains one prepareTtsRequest({ cfg, override?, text }) that deep-merges the surface override into messages.tts, resolves the effective config, and parses inline directives once with the provider attribution synthesis will actually use. It is exposed only through the existing api.runtime.tts facade — no new named plugin-SDK export; surface counts are unchanged.

Both consumers migrated; their local merge/resolution/directive code is deleted. Stream-vs-file selection (Discord) and telephony/μ-law specifics (voice-call) stay consumer-side.

Two deliberate drift resolutions, both toward the canonical semantics synthesis already applies internally:

  1. Provider-config merging is uniformly deep (Discord's hand-rolled per-provider spread was equivalent for its shapes; voice-call's was already deep).
  2. Directive parse-time preferredProviderId now comes from getTtsProvider (preference/persona-aware) at both sites, so parse-time attribution can no longer disagree with synthesis-time provider selection (previously possible in voice-call).

User Impact

None intended: same effective config and directive handling for the same inputs; the drift fixes align edge-case directive attribution with actual synthesis behavior.

Evidence

  • Testbox broad run: 67 files, 644 tests passed across packages/speech-core, extensions/voice-call, extensions/discord/src/voice; focused local run 197 tests; suites rerun green after rebase onto current main.
  • New unit tests: deep merging, prototype-pollution hardening, directive handling, timeout behavior, effective-config propagation.
  • pnpm plugin-sdk:surface:check: counts unchanged; node scripts/check-deadcode-exports.mjs: zero findings; typecheck lanes green; targeted lint green.
  • Autoreview (Codex gpt-5.6-sol, xhigh): clean (0.91).
  • Non-test LOC net −152.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: voice-call Channel integration: voice-call scripts Repository scripts plugin: google-meet size: XL maintainer Maintainer-authored PR labels Jul 17, 2026
@steipete
steipete force-pushed the refactor/speech-core-tts-glue branch from d0a1bf5 to 17e7930 Compare July 17, 2026 04:32
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed docs Improvements or additions to documentation scripts Repository scripts plugin: google-meet size: XL labels Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 12:37 AM ET / 04:37 UTC.

Summary
The PR adds shared TTS request preparation to speech-core, exposes it through the plugin runtime facade, and migrates Discord voice and voice-call telephony TTS to use it.

PR surface: Source -151, Tests +89. Total -62 across 13 files.

Reproducibility: not applicable. This PR is presented as a behavior-neutral refactor rather than a fix for a reproducible current-main bug. Its deliberate drift resolutions still require real consumer-path validation.

Review metrics: 1 noteworthy metric.

  • Plugin runtime API: 1 callable added. prepareTtsRequest becomes part of PluginRuntime.tts, so its durable compatibility intent should be decided before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted after-fix Discord voice and voice-call runtime proof showing directive handling and successful synthesis.
  • Obtain explicit maintainer direction on whether prepareTtsRequest belongs in the supported plugin runtime API.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR supplies extensive automated tests and static checks but no after-fix run showing real Discord voice playback and voice-call synthesis; add redacted live output, logs, or recordings, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The new api.runtime.tts.prepareTtsRequest callable may become a durable plugin compatibility contract without explicit maintainer confirmation of that API direction.
  • [P1] Voice-call directive provider attribution changes to preference/persona-aware selection; automated tests do not establish that real Discord and telephony behavior remains unchanged.
  • [P1] The exact PR head still has incomplete CI, although pending checks alone do not increase the item priority.

Maintainer options:

  1. Approve and prove the API (recommended)
    Confirm the new runtime callable as supported, add any necessary compatibility coverage, and provide real Discord and voice-call evidence before merge.
  2. Narrow the boundary
    Move preparation behind a bundled internal seam if this behavior should not become part of the plugin runtime contract.
  3. Pause this phase
    Keep the PR pending if maintainers are not ready to own either permanent boundary.

Next step before merge

  • [P1] A maintainer must decide the durable plugin-runtime API boundary, and the contributor must supply real consumer-path proof; neither is a safe automated repair task.

Maintainer decision needed

  • Question: Should TTS request pre-resolution become a supported callable on the plugin runtime API?
  • Rationale: The patch adds a new PluginRuntime.tts callable, and repository policy requires explicit maintainer direction for a permanent plugin API addition even when it is additive and well tested.
  • Likely owner: steipete — The available merged history identifies this person as the recent contributor driving the voice-stack consolidation and the best routing candidate for this boundary decision.
  • Options:
    • Approve runtime API (recommended): Keep the callable on api.runtime.tts, establish its compatibility intent, and validate both migrated consumers with real behavior proof.
    • Keep it internal: Use a bundled internal speech-core bridge instead if maintainers do not want external plugins to depend on request pre-resolution.
    • Pause consolidation: Hold this phase until the durable TTS preparation ownership boundary is decided.

Security
Cleared: The supplied diff adds no dependency, workflow, secret, permission, artifact-download, package-resolution, or code-execution change presenting a concrete security or supply-chain concern.

Review details

Best possible solution:

Confirm prepareTtsRequest as the intended plugin runtime boundary, document or test its compatibility contract as appropriate, and demonstrate unchanged Discord voice and voice-call synthesis behavior with redacted real-runtime evidence before merge.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR is presented as a behavior-neutral refactor rather than a fix for a reproducible current-main bug. Its deliberate drift resolutions still require real consumer-path validation.

Is this the best way to solve the issue?

Unclear. Centralizing duplicated preparation logic is directionally maintainable, but explicit maintainer confirmation is needed to establish whether the plugin runtime facade is the intended permanent owner boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 863297cce515.

Label changes

Label changes:

  • add P3: This is a behavior-neutral consolidation refactor with no reported urgent user regression.
  • add merge-risk: 🚨 compatibility: The PR adds a plugin-facing TTS runtime callable whose long-term API and upgrade contract requires explicit maintainer confirmation.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies extensive automated tests and static checks but no after-fix run showing real Discord voice playback and voice-call synthesis; add redacted live output, logs, or recordings, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P3: This is a behavior-neutral consolidation refactor with no reported urgent user regression.
  • merge-risk: 🚨 compatibility: The PR adds a plugin-facing TTS runtime callable whose long-term API and upgrade contract requires explicit maintainer confirmation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies extensive automated tests and static checks but no after-fix run showing real Discord voice playback and voice-call synthesis; add redacted live output, logs, or recordings, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source -151, Tests +89. Total -62 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 10 97 248 -151
Tests 3 237 148 +89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 334 396 -62

What I checked:

  • Proposed shared contract: The patch adds prepareTtsRequest, which deep-merges a surface TTS override, resolves the effective configuration, and parses directives using the selected provider. (packages/speech-core/src/tts.ts:471, 17e7930be5cf)
  • Plugin runtime API addition: The patch adds prepareTtsRequest to the plugin-facing TTS runtime type and gateway, making the callable a compatibility-sensitive API surface even without a new named SDK barrel export. (src/plugin-sdk/tts-runtime.types.ts:102, 17e7930be5cf)
  • Consumer migration: Discord voice removes its local merge, config-resolution, and directive-parsing implementation in favor of the new runtime method. (extensions/discord/src/voice/tts.ts:1, 17e7930be5cf)
  • Consumer migration: Voice-call replaces its local merging and directive policy with the shared preparation call while retaining telephony conversion and timeout behavior. (extensions/voice-call/src/telephony-tts.ts:1, 17e7930be5cf)
  • Automated evidence only: The PR body reports broad and focused tests, type checks, lint, SDK surface checks, and autoreview, but no observed after-fix Discord voice playback or voice-call synthesis run. (17e7930be5cf)
  • Protected routing: The current PR labels include maintainer, which requires explicit maintainer handling and prevents conservative auto-close cleanup.

Likely related people:

  • steipete: The supplied history shows this person authored the three immediately preceding merged voice-stack consolidation phases and has prior merged history across the affected voice surfaces. (role: recent voice-stack contributor; confidence: medium; commits: edd052989b5d, 92146f9f803b, e3618454f245; files: packages/speech-core/src/tts.ts, extensions/voice-call/src/telephony-tts.ts, extensions/discord/src/voice/tts.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit a77c077 into main Jul 17, 2026
161 of 169 checks passed
@steipete
steipete deleted the refactor/speech-core-tts-glue branch July 17, 2026 04:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

channel: discord Channel integration: discord channel: voice-call Channel integration: voice-call maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant