Skip to content

fix(discord): retain voice input until transcription completes - #139484

Merged
steipete merged 1 commit into
mainfrom
codex/130860-wav-lifetime-20260905
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/130860-wav-lifetime-20260905

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Related: #130860

What Problem This Solves

Fixes an issue where Discord voice transcription could lose its temporary audio when it stayed queued or in progress for more than 30 minutes. Failed and discarded recordings also retained temporary workspace resources after they were no longer needed.

Why This Change Was Made

WAV creation now returns the existing workspace's cleanup handle. The receiver retains ownership until it either discards the input or transfers it to the processing queue; queue completion releases the workspace on both success and failure.

This extracts the independent WAV lifetime repair from #130860. The shared transcription mock now uses the runtime method's real type so its file-consuming regressions are checked accurately.

User Impact

Long-running and queued transcriptions keep valid audio until they finish. Short, stale, failed, and replaced captures release their temporary files promptly, along with the workspace's retained cleanup resources.

Evidence

  • Eight retention and cleanup regressions demonstrated failure on the original code and success with the fix, using real WAV files and filesystem cleanup.
  • 71 focused tests passed for the final change across audio codec/WAV, receive, segment, and lifetime suites.
  • Extension production/test typechecks, type-aware lint, and all changed-check guards passed, including dead exports, media download helpers, runtime sidecar loaders, and import cycles.
  • Fresh independent P0–P2 review found no actionable findings.

The focused tests exercise the Discord service boundaries with synthetic data; the broader live Discord work remains with #130860.

Keep temporary WAV input alive through queued and in-flight transcription, then release the owning workspace on every completion or discard path. Failed writes release their partial workspace immediately. Extracted from #130860.
@steipete steipete self-assigned this Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 6:59 PM ET / 22:59 UTC.

ClawSweeper review

What this changes

The Discord plugin keeps temporary voice recordings until processing finishes and releases discarded or failed recordings promptly.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: pinned main and v2026.9.2 still delete WAV input after 30 minutes. No actionable introduced defect was found, and the broader related PR does not supersede this extraction.

Priority: P2
Reviewed head: fe4572385c5139e7dee608b888e8c2d52f557e2e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported filesystem regressions exercise WAV creation and queue cleanup with mocked transcription; they do not establish live Discord behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported filesystem regressions exercise WAV creation and queue cleanup with mocked transcription; they do not establish live Discord behavior.
Evidence reviewed 8 items Introduced scope and merge identity: Raw commit records confirm the original head's parent and the test merge's ordered base/head parents. The verified merge changes only the five voice implementation and test paths supplied in the introduction evidence.
Problem remains on main: The pinned main implementation schedules unconditional directory removal 30 minutes after WAV creation, independently of queued or running transcription.
Latest-release check: The supplied v2026.9.2 release commit contains the same timer-owned WAV cleanup, so that release does not include this repair.
Findings None None.
Security None None.

How this fits together

Discord voice capture writes decoded speech to a temporary WAV file and queues it for transcription. The resulting text feeds meeting transcripts or an agent response; the receiver and processing queue now share explicit responsibility for releasing the input file.

flowchart TD
  A[Discord speech] --> B[Decode and write WAV]
  B --> C{Capture still usable?}
  C -->|No| F[Release workspace]
  C -->|Yes| D[Wait in processing queue]
  D --> E[Transcribe and process text]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +129. Total +133 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 28 24 +4
Tests 3 159 30 +129
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 187 54 +133

Review metrics

None.

Technical review

Best possible solution:

Keep WAV lifetime tied to its actual processing owner, with cleanup on completion, failure, and discard.

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

Yes, from source: hold queued or in-progress WAV consumption beyond 30 minutes and the existing main timer removes its input. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. Transferring the existing workspace cleanup handle follows the file's consumer lifetime and avoids another timeout or parallel cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 36612a28e005.

Labels

Label changes:

  • add P2: This fixes a bounded Discord voice failure affecting recordings queued or processed longer than 30 minutes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported filesystem regressions exercise WAV creation and queue cleanup with mocked transcription; they do not establish live Discord behavior.

Label justifications:

  • P2: This fixes a bounded Discord voice failure affecting recordings queued or processed longer than 30 minutes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported filesystem regressions exercise WAV creation and queue cleanup with mocked transcription; they do not establish live Discord behavior.

Evidence

What I checked:

  • Introduced scope and merge identity: Raw commit records confirm the original head's parent and the test merge's ordered base/head parents. The verified merge changes only the five voice implementation and test paths supplied in the introduction evidence. (7aacba5d3a0e)
  • Problem remains on main: The pinned main implementation schedules unconditional directory removal 30 minutes after WAV creation, independently of queued or running transcription. (extensions/discord/src/voice/audio.ts:334, 36612a28e005)
  • Latest-release check: The supplied v2026.9.2 release commit contains the same timer-owned WAV cleanup, so that release does not include this repair. (extensions/discord/src/voice/audio.ts, 3928bad9badf)
  • Cleanup ownership and downstream consumption: The receiver retains cleanup through early returns, transfers it to the queue, and disposes in the queue's finally block. Segment processing awaits transcription; later playback consumes separately synthesized audio rather than the input WAV. Existing session and transcript-binding checks remain intact. (extensions/discord/src/voice/voice-receive.ts:242, fe4572385c51)
  • Focused regression coverage: The new suite uses real WAV files with mocked decoding/transcription to cover queued and in-progress retention beyond 30 minutes, transcription failure, leaving, replacement, short audio, and leaving during a write. The audio suite also checks partial-write cleanup. The PR reports eight before/after regressions and 71 focused passing tests; these were inspected, not executed during review. (extensions/discord/src/voice/voice-wav-lifetime.test.ts:57, fe4572385c51)
  • Existing workspace boundary: The SDK reexports temporary workspaces from @openclaw/fs-safe. This PR changes their ownership inside Discord without changing the dependency or public SDK. The dependency implementation was unavailable locally, so exceptional disposer behavior was not independently inspected; no Codex runtime dependency is established by this change. (src/infra/private-temp-workspace.ts:6, fe4572385c51)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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 91bcdd4 into main Sep 5, 2026
98 checks passed
@steipete
steipete deleted the codex/130860-wav-lifetime-20260905 branch September 5, 2026 23:11
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
steipete added a commit that referenced this pull request Sep 6, 2026
Keep explicit recording owned by its source across connection and manager
replacement. Receive each speaker once, retain packet-time capture authority,
and share completed batch transcription with authorized conversation.

Separate recording progress from conversation admission and replies, fence
incomplete or retired conversation input, and bound receive, conversation,
and queued WAV work. Retain WAV ownership through delayed processing and
cleanup, including when a retired recording hands off to conversation.

Preserve short authorized recording chunks and distinguish completed empty
transcription from omitted media input. Document lifecycle and limit behavior.

Split from #130860. Follows #139484 and #139572. Related: #127426.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…law#139484)

Keep temporary WAV input alive through queued and in-flight transcription, then release the owning workspace on every completion or discard path. Failed writes release their partial workspace immediately. Extracted from openclaw#130860.
steipete added a commit that referenced this pull request Sep 6, 2026
)

* fix(discord): keep recording independent of voice conversations

Keep explicit recording owned by its source across connection and manager
replacement. Receive each speaker once, retain packet-time capture authority,
and share completed batch transcription with authorized conversation.

Separate recording progress from conversation admission and replies, fence
incomplete or retired conversation input, and bound receive, conversation,
and queued WAV work. Retain WAV ownership through delayed processing and
cleanup, including when a retired recording hands off to conversation.

Preserve short authorized recording chunks and distinguish completed empty
transcription from omitted media input. Document lifecycle and limit behavior.

Split from #130860. Follows #139484 and #139572. Related: #127426.

* fix(discord): keep package-boundary types portable

Spell the existing channel-resolution union within the plugin and type the
transcript fixture callback with its public SDK contract. This removes a
forbidden normalization-core import and prevents Vitest's private Procedure
type from leaking into generated declarations.

Validation: normalization import guard, all 123 plugin package boundaries,
extension and root integration types, 53 voice cases and two core provider
integrations, and scoped P0-P2 review.

* fix(discord): retain safely bound realtime-only recordings

Preserve existing per-speaker realtime finals when batch audio is disabled
or the actual media runtime confirms no backend is available. Carry packet
capture receipts through delayed admission and wait for every batch result;
successful, silent, failed, mixed, or incomplete input cannot duplicate or
authorize fallback notes. A provider continuity reset permanently retires
the recording owner until a fresh speaker connection establishes receipts.

Bound pending final text and surface limited coverage through /vc status.
Document the independent batch path and the narrower realtime-only contract.

Related to #130860 and #139658.

* test(discord): declare capture-only fixture capability

Keep fake transcript managers aligned with the required realtime capability
query. These integration fixtures have no realtime conversation and return
false without weakening the production interface.

Validation: canonical root test types, provider integration, scoped lint,
and independent P0-P2 review passed.

* refactor(discord): make recording contracts a type-only leaf

Move capture, packet-receipt, and segment-result contracts out of their
runtime owners, breaking the full import graph cycle. Narrow realtime
recording metadata to the three strings it consumes.

All six existing modules emit identical JavaScript; the new leaf emits
none. Validation: both import-cycle guards, three canonical type lanes,
18 focused tests, lint, full build, and scoped P0-P2 review passed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…claw#139658)

* fix(discord): keep recording independent of voice conversations

Keep explicit recording owned by its source across connection and manager
replacement. Receive each speaker once, retain packet-time capture authority,
and share completed batch transcription with authorized conversation.

Separate recording progress from conversation admission and replies, fence
incomplete or retired conversation input, and bound receive, conversation,
and queued WAV work. Retain WAV ownership through delayed processing and
cleanup, including when a retired recording hands off to conversation.

Preserve short authorized recording chunks and distinguish completed empty
transcription from omitted media input. Document lifecycle and limit behavior.

Split from openclaw#130860. Follows openclaw#139484 and openclaw#139572. Related: openclaw#127426.

* fix(discord): keep package-boundary types portable

Spell the existing channel-resolution union within the plugin and type the
transcript fixture callback with its public SDK contract. This removes a
forbidden normalization-core import and prevents Vitest's private Procedure
type from leaking into generated declarations.

Validation: normalization import guard, all 123 plugin package boundaries,
extension and root integration types, 53 voice cases and two core provider
integrations, and scoped P0-P2 review.

* fix(discord): retain safely bound realtime-only recordings

Preserve existing per-speaker realtime finals when batch audio is disabled
or the actual media runtime confirms no backend is available. Carry packet
capture receipts through delayed admission and wait for every batch result;
successful, silent, failed, mixed, or incomplete input cannot duplicate or
authorize fallback notes. A provider continuity reset permanently retires
the recording owner until a fresh speaker connection establishes receipts.

Bound pending final text and surface limited coverage through /vc status.
Document the independent batch path and the narrower realtime-only contract.

Related to openclaw#130860 and openclaw#139658.

* test(discord): declare capture-only fixture capability

Keep fake transcript managers aligned with the required realtime capability
query. These integration fixtures have no realtime conversation and return
false without weakening the production interface.

Validation: canonical root test types, provider integration, scoped lint,
and independent P0-P2 review passed.

* refactor(discord): make recording contracts a type-only leaf

Move capture, packet-receipt, and segment-result contracts out of their
runtime owners, breaking the full import graph cycle. Narrow realtime
recording metadata to the three strings it consumes.

All six existing modules emit identical JavaScript; the new leaf emits
none. Validation: both import-cycle guards, three canonical type lanes,
18 focused tests, lint, full build, and scoped P0-P2 review passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant