Repository navigation
fix(discord): release voice recordings when speaking-end events are lost - #192932
Merged
steipete merged 2 commits intoNov 4, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
steipete
marked this pull request as ready for review
November 4, 2026 18:04
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Expire packet-inactive captures even without speaking-end, and close failed input. Preserve the SDK silence window, configured grace, physical finalization ownership and existing recording/backlog bounds. Regressions cover missing end, leave, error, short grace and four concurrent partial recordings retaining 75 MB.
Raise the test-line scalar by the exact 188-line deficit: 187 audited regression lines plus one remaining inherited line after main deleted six of the seven uncovered lines from #192478. Maintainer approved the budget exception.
steipete
force-pushed
the
steipete/perf-micro-discord-voice-capture-retention-20260919
branch
from
November 4, 2026 18:29
21a497b to
f34b090
Compare
steipete
enabled auto-merge (squash)
November 4, 2026 18:44
steipete
deleted the
steipete/perf-micro-discord-voice-capture-retention-20260919
branch
November 4, 2026 18:45
Contributor
Author
|
Merged via squash auto-merge.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 5, 2026
…ost (openclaw#192932) * fix(discord): release stalled voice capture buffers Expire packet-inactive captures even without speaking-end, and close failed input. Preserve the SDK silence window, configured grace, physical finalization ownership and existing recording/backlog bounds. Regressions cover missing end, leave, error, short grace and four concurrent partial recordings retaining 75 MB. * test(discord): allocate audited voice retention coverage Raise the test-line scalar by the exact 188-line deficit: 187 audited regression lines plus one remaining inherited line after main deleted six of the seven uncovered lines from openclaw#192478. Maintainer approved the budget exception.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes Discord voice captures retaining partial recordings indefinitely when a speaker stops or leaves without a speaking-end event, or a receive stream emits an error without closing.
User Impact
Idle speaker subscriptions now close and release their recording buffers. Valid buffered speech still reaches transcription; failed input discards its incomplete segment. Continuous capture remains registered. Existing upload/backlog limits, configured silence grace, and the SDK's 100 ms silence window are preserved, including very short grace settings. No new configuration or migration is required.
Why This Change Was Made
Speaking-start previously canceled the only finalization timer, while packet activity never armed a replacement. The Discord audio worker now refreshes an owned inactivity deadline on packets, restores it on speaking-start, and closes failed input. Physical subscription close remains the owner of reservation removal, independently of delayed decoding or recording work. This removes five production TypeScript lines and keeps runtime changes in the Discord plugin. The only external edit is the explicitly approved test-budget bookkeeping.
Evidence
The missing-end, user-leave, and error-without-close regressions fail on the parent and pass with the fix. A committed synthetic workload exercises four concurrent speakers, real Opus decoding, recording, WAV writes, and cleanup. It also fails on the parent. Existing long-utterance upload limits, receive backlog, and recording backlog tests remain enforced; the backlog fixture now sends ongoing packets instead of simulating speech with a stale speaking flag.
Five interleaved fresh-capture samples per version, plus A/A controls; 4,900 20 ms frames per speaker (98 seconds each). Compiler/import setup excluded; SDK transport and transcription are synthetic. This is owner-boundary proof, not live Discord E2E or whole-Gateway database/workspace scaling.
A/A controls: feed wall 336.629→339.504 ms; CPU 634.834→620.894 ms; identical byte counts. Feed overhead is 4.23% wall / 4.51% CPU, below the predeclared 20% investigation threshold. The fixed path settles four WAVs in a median 104.012 ms after the deadline; the parent performs no settlement. Allocation counts decoded PCM, not total V8 allocation or RSS. A separate CPU/heap-profiled run verifies the actual retained chunk arrays reach zero.
Reproduce:
OPENCLAW_VOICE_CAPTURE_MEASURE=1 node scripts/run-vitest.mjs extensions/discord/src/voice/voice-capture-retention.perf.test.ts --maxWorkers=1.Focused receive, lifecycle, capture-state, transport and retention suites: 70 tests passed (40.12 s runner including compilation; owner tests under one second per file). The final profiled finalization/retention/backlog run passed 10 tests in 19.31 s including instrumented imports. Regression growth covers missing lifecycle events, preservation of short configured grace, and a rerunnable full-size buffer-retention workload.
Test audit and budget
The test-audit and simplification passes retain 187 net test lines. Missing speaking-end, member leave, and error without close exercise distinct lifecycle inputs through the manager/worker/receive/recording boundary. The short-grace case protects the existing configuration contract. The four-speaker real-codec workload supplies the requested reproducible retention measurement; existing backlog and upload-limit tests retain long-utterance and reconnect coverage. No duplicate test or test-only production seam was found.
Maintainer approval covers an exact scalar test-budget raise, including inherited debt. After rebasing on
f9a25d7c2caccd7fbcd14ab899543d453b54ebb5, the required increase is 188, not 194: this PR adds 187 lines; #192478 (8e1cc8c4) added seven unallocated lines, and #192777 (f9a25d7c2cac) subsequently deleted six. The final count and effective ceiling are both 6,470,174, with zero spare allowance. The scalar changes from 6,326,285 to 6,326,473; existing per-change allocations are untouched. This is the approved maintainer exception, not a waiver of a failing gate.Resource acceptance
The perf lead explicitly accepts 4.5% CPU overhead against 75.3 MB → 0 of unbounded voice-recording retention observed in production (heap pair on r276). The synthetic owner fixture reproduces the retention and proves cleanup; it does not claim a post-deployment production measurement. No production host was accessed or changed.
Final validation
Rebased onto
f9a25d7c2caccd7fbcd14ab899543d453b54ebb5; 13 focused tests pass across finalization, retention, recording backlog, and upload limits. Codex autoreview of the complete rebased candidate is scoped-clean through P2. The exact test-line ratchet passes with zero slack.pnpm check:changed --base f9a25d7c2caccd7fbcd14ab899543d453b54ebb5completed: every guard, format, extension/test typecheck, extension/script lint, and architecture check passed except the dead-export scan. Its four findings exactly match the independent parent reproduction below. Exact-head CI 41887692472 passed forf34b090c0980716088fe34a6b4c32112fffbff40. Normal auto-merge landed this reviewed head as58293c5bbec258e97d7a3d461a1209466c4eeda1; no admin bypass or CI rerun was used.The earlier unused PostgreSQL export was fixed upstream by #192929 (
cfb85a1d15e8). The untouched Skill Workshop export,SKILL_WORKSHOP_PLUGIN_ID, originated in #192766 (3e114e23c33c); production and full-tree scans reproduce it on the exact parentf9a25d7c2cac. The full-tree scan additionally findsSETUP_PROOF_ACCOUNT_ID,SETUP_PROOF_LOGIN, andSETUP_PROOF_REPOSITORYin the worker-setup fixture, introduced by #192538 (0b9f3ab3aec3). These are newly observed main regressions, not noise, and remain follow-ups outside this plugin fix's scope. The script export scan passes.