Repository navigation
fix(discord): retire voice sessions after realtime provider closure - #131548
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 1:49 AM ET / 05:49 UTC. ClawSweeper reviewWhat this changesThe PR makes Discord realtime voice sessions disconnect and release their resources after a terminal provider closure, while keeping temporary provider recovery connected and resuming queued speech. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain Keep open for normal maintainer review: current main still has the log-only terminal-close handler, while this patch routes the terminal callback to the existing exact-entry teardown path and adds the missing reconnect-ready transition. No actionable correctness or security finding was identified; exact-head CI is still pending. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherThe Discord voice plugin connects a realtime provider bridge to a managed Discord voice entry. Provider callbacks feed session lifecycle state, playback, transcript capture, and the manager’s connected-status output. flowchart LR
Provider[Realtime provider] --> Bridge[Shared voice bridge]
Bridge --> Session[Discord realtime session]
Session --> Decision{Terminal close or reconnect ready?}
Decision -->|Reconnect ready| Playback[Resume queued speech]
Decision -->|Terminal close| Teardown[Voice-entry teardown]
Teardown --> Status[Release resources and clear status]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +27, Tests +263, Docs +1. Total +291 across 9 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the direct lifecycle-owner repair and merge only after the exact-head required checks complete successfully. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main’s terminal callback only logs, while the existing terminal-error callback invokes the exact voice-entry stop owner; the PR supplies focused manager-boundary regressions for that path. Is this the best way to solve the issue? Yes. Routing the terminal callback through the existing voice-entry teardown owner preserves replacement fencing and resource cleanup; putting teardown in the shared bridge or treating reconnect as terminal would cross ownership boundaries or break recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a33c8a5c0ec6. 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
HistoryReview history (1 earlier review cycle)
|
Route terminal provider closure through the existing voice entry teardown owner and resume queued speech after reconnect readiness. Closes #131397.
b721e25 to
85c5a2e
Compare
|
Exact-head land-ready evidence for CI run 33145495041 is green: 101 successful jobs, 17 skipped. Artifact build, typed extension lint, and openclaw/ci-gate all passed. Metadata generation completed in 13.4s. Accepted focused proof: 51 tests / 3 files, with the five relocated cases unchanged; the subsequent mechanical rebase preserved all task bytes and the full repair diff. Fresh independent review found no P0 defect. node scripts/run-vitest.mjs extensions/discord/src/voice/voice-session.lifecycle.test.ts extensions/discord/src/voice/voice-session.terminal.test.ts test/transcripts-tool.discord-lifecycle.integration.test.tsnode scripts/watch-pr-ci.mjs 131548 85c5a2ed60c1b522ef51f3181178b5ffa6600f19scripts/pr review-validate-artifacts 131548The watcher returned The maintainer's explicit bounded-proof waiver remains: no live Discord/provider conversation or mock-Gateway verdict is claimed. Hosted build/lint success is not a claim that the documented full local commands passed. ClawSweeper's exact-head review, updated 2026-08-28 at 06:00 UTC, found no actionable correctness/security defect. Its terminal-test probe timed out after 30 seconds waiting for filename output, showing only Vitest startup and no failed assertion; no eventual pass of that bot command is claimed. Separately completed proof is 253 combined tests before relocation and the final 51 tests above. Its pending-CI statement is superseded by the green run linked above. The net +17 production lines supply terminal-owner notification, factory disposal, and recovered readiness while sharing existing teardown/ready paths; no simpler net-neutral alternative was identified. The optional Rank-up request for a real-setup after-fix capture is explicitly skipped under the existing user-approved bounded-live-proof waiver; fixtures are not live Discord. Exact-head docs CI also passed. This comment records the independently verified pre-merge gate decision. Native prepare reused the exact-head green evidence, and native merge completed as 533319b6753f4367581a59dc26b9c6d2fd19d66d, without a bypass. |
|
Merged via squash.
|
…penclaw#131548) * fix(discord): retire voice sessions after realtime provider closure Route terminal provider closure through the existing voice entry teardown owner and resume queued speech after reconnect readiness. Closes openclaw#131397. * test(discord): prove terminal closure retires transcript captures * test(discord): split terminal lifecycle coverage
Closes #131397 (Discord realtime lifecycle remains stale after provider closure or recovery).
Additional instructions
Maintainers can push to this same-repository branch.
What Problem This Solves
Fixes an issue where users in Discord realtime voice would retain an apparently connected but nonfunctional session after the realtime provider terminally closed. Closure during startup could also report a successful join, and pending consult delivery could outlive the voice session. Successful OpenAI provider reconnection could leave queued speech paused because Discord waited for a readiness callback that fires only once.
Why This Change Was Made
The realtime session now records terminal closure before notifying the existing exact voice-entry teardown owner. That single path releases receive streams, timers, playback and consult delivery, updates manager status, and cannot let an old provider callback remove a replacement. A bridge returned after a synchronous creation-time close is disposed before connection or playback attachment.
Recovered readiness uses the existing generation-fenced ready callback for both
onReadyand the provider's actualsession.reconnect.readyevent. Temporary reconnect diagnostics and continuity resets remain nonterminal. The former log-only close handler is removed; no status guard, retry loop, fallback, or second teardown path is introduced.Transcript retirement uses the authoritative owner from the landed transcript lifecycle repair: the existing voice-entry stop clears the binding before its
onStopcallback, and the existing core finalizer retires the capture and persists its stop time. This PR adds no core notification or persistence policy. It does not import the independent capture-ownership repair, which remains separate; no integration with that open patch is claimed.User Impact
Terminal realtime closure now disconnects the unusable Discord voice session and clears connected status. Operators get the existing terminal diagnostic and can retry
/vc join. Temporary provider recovery preserves the session and resumes queued speech. Intentional local leave does not become a second terminal error.No configuration, schema, dependency, permission, or protocol change. The Discord voice guide documents recovery. AI-assisted.
Evidence
request.onClosethrough the real shared bridge/harness rather than bypassing it.session.reconnect.readyarrived without a secondonReady.stoppedAt; historical stop does not call provider stop again, and old provider callbacks cannot retire or write to a replacement. The boundary regression also proves detachment before exactly oneonStopnotification under reentrant stop, while retaining stream/timer/player teardown coverage. Prior old-base proof was 248 tests, not the current combined count. A final test-only typing correction removed an unsupported argument from the reentrantentry.stop()call; the affected lifecycle and composed integration files were rerun afterward: 51 passed across 2 files. After moving the five terminal-close cases unchanged into their own suite, the final affected run passed 51 tests across 3 files, including the real transcript integration. Production remained unchanged.d2f13bc2702b2c9468b0e870fa40eac459440532, temporarily using its unchanged log-only realtime runtime: 2 failed / 1 passed. Both providercompletedanderrorcallbacks left the second capture in the real transcript tool's active list; the original STT destruction case passed. The repaired runtime was restored byte-for-byte.stopargument described above; the corrected typecheck and affected tests passed.pnpm lint:extensionsattempts stopped before lint withplugin-sdk boundary dts timed out after 300000ms. Actual local extension lint remains incomplete. A laterpnpm lint:scriptspassed; the redundant local database scan was cancelled after the corresponding hosted guard passed. The later local media/runtime-sidecar/import-cycle commands were not reached. Hosted checks are separate evidence, not local passes. No timeout, heap budget, runtime, preparation, or lint check was bypassed or weakened.nodes --help, including one focused retry on the same Node runtime. The full local command was not green; exact-head CI artifact-build proof is required before merge.Full focused command for the current file layout; the 253-test run preceded the file-only split, while the final affected command below was rerun afterward:
Proof limitation
No live Discord/provider conversation or mock-Gateway verdict is claimed. The maintained Crabline server omits voice and interaction dispatch and ignores voice-state opcode 4; the live voice QA route requires Discord credentials. The maintainer explicitly approved this bounded repair using failing/passing real-owner callback regressions, direct provider/session contracts, fresh independent review, and, before merge, green exact-head CI instead of additional live Discord proof. No operator Gateway, production configuration, or live credentials were used.
Scope and provenance
Production: +24/-7 (net +17). Tests/support: +457/-184 (net +273); the parameterized integration fixture includes indentation movement (ignoring whitespace, its delta is +71/-8). Moving the five terminal cases into a dedicated test file adds 22 net test wrapper/import lines without changing their bodies. Docs: +1. Production growth supplies the missing terminal-owner notification, creation-time disposal fence, and recovered-readiness transition while sharing the existing ready and teardown paths.
The log-only close handler dates to the realtime voice introduction, authored by @steipete on 2026-05-08 and reachable in stable
v2026.5.12. The capture-ownership refactor did not introduce it. The patch was rebased onto maind2f13bc2702b2c9468b0e870fa40eac459440532to compose with the new transcript retirement owner. The realtime production repair remains byte-identical to the pre-integration reviewed implementation. A later mechanical rebase ontob70945a58e69d5c48d27835239cc4cb02f1db2d7brings in the trusted native wrapper update from #131535; no task file changed during that rebase.Review and hosted CI follow-up
The latest ClawSweeper review, reviewed at 05:49 UTC on 2026-08-28 against
85c5a2ed60c1b522ef51f3181178b5ffa6600f19, found no actionable correctness or security defect and affirmed the owner-level fix. Its probe ofnode scripts/run-vitest.mjs extensions/discord/src/voice/voice-session.terminal.test.tstimed out after 30 seconds waiting for filename output; captured output showed Vitest startup, with no failed assertion. No eventual pass of that bot command is claimed. The separately completed local proof remains 253 combined tests before relocation and 51 affected tests across 3 files afterward, including all five unchanged moved cases; fresh independent review was clean.The review's pending-CI statement is now superseded by the green exact-head run below. Its +17 production-growth note is accepted with the owner-boundary justification above: terminal notification, synchronous-factory disposal, and recovered readiness reuse existing teardown and ready paths; no simpler net-neutral alternative was identified. A status-only guard, consumer-only retirement, or retry loop would leave the owning lifecycle defect unresolved. The docs check passed on the exact current head, alongside local
pnpm docs:list.The optional Rank-up request for a real-setup after-fix capture is explicitly skipped under the maintainer's already approved bounded-live-proof waiver. Vitest fixtures are not live Discord/provider evidence. The maintainer independently verified the exact-head gates and review, accepted this disposition, and authorized native prepare/merge; no new code change or rule bypass is involved.
On published head
b721e250983dd521da3fde12fb7e0c9568c14ccb, hosted artifact build passed, includingwrite-cli-startup-metadatain 20 seconds. The CI run finished with 99 successful jobs, 17 skipped, and two failures: extension lint found 1,044 counted lines in the lifecycle test, and the aggregate gate correctly failed. The reviewed test-only split is committed: the files now have 919 and 147 nonblank lines, below the unchanged 1,000-line limit; all five cases retain their original bodies. No lint limit or assertion changed. Exact-head CI run 33145495041 for85c5a2ed60c1b522ef51f3181178b5ffa6600f19is now green: 101 successful jobs and 17 skipped. Artifact build passed in 1m52.5s, including metadata generation in 13.4s; typed extension lint and the aggregate gate passed. These hosted results do not turn the documented local timeouts into local passes. Native review artifacts validate asREADY FOR /prepare-pr; final independent gate verification and native prepare/merge authorization are complete. This evidence update does not claim that the PR has merged.