Repository navigation
refactor(discord): split voice lifecycle ownership - #122479
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 2:14 AM ET / 06:14 UTC. ClawSweeper reviewWhat this changesThe PR splits Discord voice lifecycle behavior into focused session, receive, following, realtime, playback, turn, and consult modules, using a per-guild generation to reject stale async work. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. This active maintainer PR replaces current main’s monolithic Discord voice owner with generation-fenced lifecycle owners; no introduced correctness defect was found, but exact-head CI is still running. Priority: P1 Review scores
Verification
How this fits togetherDiscord voice turns gateway voice state and audio into a guild-scoped session, then dispatches agent work and playback. The changed lifecycle layer controls whether delayed joins, receives, follows, transcripts, and realtime callbacks may still publish after a session changes. flowchart LR
A[Discord gateway and audio] --> B[Voice runtime]
B --> C[Guild voice session]
C --> D[Generation authority]
D --> E[Receive and realtime work]
E --> F[Agent dispatch]
F --> G[Voice playback]
H[Leave and follow events] --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1791, Tests -375, Other -3. Total +1413 across 37 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain one per-guild generation as the authoritative lifecycle fact, and merge after exact-head checks validate the owner-level regressions without reintroducing downstream stale-work guards. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main awaits authorization before receiver subscription, and the PR supplies ordered regressions for leave-vs-join, authorization, decode, follow, and realtime connect. The read-only checkout lacks dependencies, so these scenarios were not rerun here. Is this the best way to solve the issue? Yes. Recording authority at the per-guild lifecycle owner is more maintainable than adding separate stale-work guards to receive, following, realtime, and playback consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 77d89b2fa843. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Move the exact-speech protocol (typed consult-call outcome instead of string scraping), agent-proxy session instructions, and consult/wake-name/ barge-in policy defaults from the Discord plugin into src/talk, exported additively via openclaw/plugin-sdk/realtime-voice. Wake-name enablement now keys on a supportsActivationNameGating provider capability instead of a hardcoded provider id. Follow-up to the voice split (#122479).
Move the exact-speech protocol (typed consult-call outcome instead of string scraping), agent-proxy session instructions, and consult/wake-name/ barge-in policy defaults from the Discord plugin into src/talk, exported additively via openclaw/plugin-sdk/realtime-voice. Wake-name enablement now keys on a supportsActivationNameGating provider capability instead of a hardcoded provider id. Follow-up to the voice split (#122479).
* refactor(voice): promote realtime voice policy to talk owner Move the exact-speech protocol (typed consult-call outcome instead of string scraping), agent-proxy session instructions, and consult/wake-name/ barge-in policy defaults from the Discord plugin into src/talk, exported additively via openclaw/plugin-sdk/realtime-voice. Wake-name enablement now keys on a supportsActivationNameGating provider capability instead of a hardcoded provider id. Follow-up to the voice split (#122479). * fix(talk): bind exact-speech bypass to retained session state Per ClawSweeper review on #122668: the protocol marker is untrusted model tool-call text; only a parsed answer matching a currently retained exact-speech text may select the privileged replay path. Unretained marker calls route to a normal consult.
* refactor(discord): split voice subsystem by lifecycle owner * fix(discord): make one generation the voice lifecycle authority * refactor(discord): delete superseded voice plumbing * test(discord): split voice coverage by lifecycle owner * chore(lint): ratchet max-lines baseline after voice split * fix(discord): re-read voice lifecycle after realtime connect * test(discord): move wake follow-up coverage to turns owner * refactor(discord): keep realtime lifecycle state private * refactor(discord): keep voice test harness type private * refactor(discord): remove split voice test accessors * test(discord): type split voice fixtures at owners * test(discord): trim split voice test imports
…w#122668) * refactor(voice): promote realtime voice policy to talk owner Move the exact-speech protocol (typed consult-call outcome instead of string scraping), agent-proxy session instructions, and consult/wake-name/ barge-in policy defaults from the Discord plugin into src/talk, exported additively via openclaw/plugin-sdk/realtime-voice. Wake-name enablement now keys on a supportsActivationNameGating provider capability instead of a hardcoded provider id. Follow-up to the voice split (openclaw#122479). * fix(talk): bind exact-speech bypass to retained session state Per ClawSweeper review on openclaw#122668: the protocol marker is untrusted model tool-call text; only a parsed answer matching a currently retained exact-speech text may select the privileged replay path. Unretained marker calls route to a normal consult.
What Problem This Solves
Fixes Discord voice races where leaving during a pending join could reconnect later, a stopped session could subscribe after authorization, decoded STT work could outlive leave, followed-user state could resurrect an older move, realtime connect could report ready after close, and provider-reset completions could leak into a newer voice generation.
The previous voice implementation also concentrated connection, follow, receive, realtime, playback, turn, and consult ownership in two files over 4,000 lines, making these lifecycle invariants difficult to express and verify.
Why This Change Was Made
The voice subsystem is split by lifecycle owner into runtime, guild session, following, receive, realtime session, playback, turns, and consult modules. One per-guild generation now authorizes connection publication, capture, realtime state, transcripts, and playback; provider continuity retains its own epoch. Playback and exact-speech state are closed unions rather than parallel booleans.
Discord startup keeps its existing outer lazy boundary, while STT/TTS no longer loads realtime provider and consult machinery:
voice-session.tsdynamically importsrealtime-session.runtime.tsonly for agent-proxy and bidi modes. Generic policy text and the exact-speech scraper remain byte-identical and are explicitly marked for a separate owner-reviewed realtime-voice follow-up.User Impact
Discord voice leave, follow, capture, and realtime operations are last-event-wins. Stale async work can no longer reconnect, subscribe, transcribe, play, publish readiness, or deliver provider completions after its voice generation has closed.
There is no configuration or Plugin SDK change. Existing voice instructions, consult/control tool schemas, transcript-source behavior, and STT/TTS behavior are preserved.
Evidence
Regression provenance and before/after proof:
realtime.tsconfirms the assembled instruction builder and consult/control tool assembly are byte-identical.Validation on head
4119d4a90a416efa0ed2e2d70d62fc4849f88875:node scripts/check-changed.mjs --base <frozen-merge-base>: green, including dead-code scans, production/test typechecks, extension lint, database-first guard, and zero runtime import cycles.pnpm build: green; no[INEFFECTIVE_DYNAMIC_IMPORT]warning.pnpm lint:tmp:export-name-collisions: green.pnpm check:wrapper-shadowing: green.pnpm plugin-sdk:surface:check: green.pnpm lint:plugins:no-extension-test-core-imports: green.pnpm check:max-lines-ratchet: green against the rebased branch base; the three superseded Discord voice entries were removed.Remote-proof note: Blacksmith Testbox was unavailable because the host lacks the
blacksmithexecutable, and direct AWS Crabbox had no configured broker login. Repository policy therefore routed trusted-source proof to the local fallback above. Hosted exact-head PR CI remains the authoritative merge-tree proof.LOC classification from
git diff --numstat(moves are not discounted):The positive production delta is the concrete ownership boundary: eight bounded concept modules, their closed lifecycle states, and narrow injected ports replace the two monoliths. No compatibility alias, fallback stack, new config, or new public API remains.