Skip to content

refactor(voice): simplify audio worker plumbing - #154498

Open
roboclaw-bot wants to merge 2 commits into
mainfrom
openclaw/audio-worker-deslop
Open

roboclaw-bot wants to merge 2 commits into
mainfrom
openclaw/audio-worker-deslop

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #154119

What Problem This Solves

The audio-worker cutover duplicated buffer and lifecycle plumbing that can share existing owners.

User Impact

No intended user-visible change. Worker isolation, bounded queues, cancellation, capture finalization, and playback accounting are preserved. No configuration or stored-data migration is needed.

Why This Change Was Made

  • Replace the separate raw-byte ring buffer with the existing pending-audio owner, retaining explicit PCM versus raw-byte alignment.
  • Reuse the SDK deferred helper instead of hand-maintained promise-resolver fields.
  • Use one Discord file-settlement path and one OpenAI callback-credit acknowledgement path.
  • Remove the constructor-only Discord transport factory and migrate its callers.

Production code across the nine touched production files falls from 3,050 to 2,975 lines: net −75. Discord contributes −14 and OpenAI −61. Tests/support add 59 lines; the whole patch is net −16. No files, core/SDK exports, or generic framework were added. No tests were deleted or reclassified.

Evidence

  • 129 focused Discord tests passed; 77 focused OpenAI tests passed, with one existing Bun-only case skipped locally.
  • 15 additional Testbox worker-boundary test executions and the full build passed. During a 500 ms Gateway stall, actual workers emitted 25 RTP packets and delivered 25 direct PCM messages. Testbox run
  • Extension production/test types, dead-code scans, final changed-file lint/format, line caps, plugin boundaries, runtime loaders, and import-cycle checks passed across the recorded phases. The initially failed batch is retained as failed; its identified type and lint findings were corrected and the affected gates passed.
  • Fresh independent P0–P2 autoreview was scoped-clean; the parent reviewed the production and test diff.
  • Exact-head CI passed for d09bfca1ac8c5c2a5c07e1faf2737e2c3e4c6ca9; the CI gate completed successfully at 06:29 UTC on September 21.
Measured test costs
Test file Solo wrapper wall, one worker (s) CI sum of printed test durations (s) CI passed cases
Discord audio-transport.test.ts 7.07 0.020 10
OpenAI realtime-quicksilver-audio-buffer.test.ts 2.02 0.374 9
OpenAI realtime-quicksilver-socket.runtime.test.ts 1.83 0.045 7

The CI figures sum the verbose reporter’s rounded per-test durations. They are not isolated CPU time, full-file wall time, or job duration. Full-file CI wall times were not reported and are unavailable, not zero. Transport evidence comes from successful job 106233580289; both OpenAI files come from successful job 106233580307.

- No authenticated Discord/OpenAI call or deployment was performed. Testbox proof used real workers/codecs with loopback transports. Its source snapshot precedes only final mechanical typing/import/test-sequencing corrections. Reuse is based on recorded edit history and source review, not an object-to-object comparison or an exact-final-commit build claim.

Worked on by

Work sessions


View the OpenClaw team session

@clawsweeper

clawsweeper Bot commented Sep 21, 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 extensions: openai size: M maintainer Maintainer-authored PR labels Sep 21, 2026
OpenClaw-Publication: cde7abc6-9cd0-4c03-bca4-a4e277227808
Co-authored-by: steipete <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/audio-worker-deslop branch from ca0dbd6 to d09bfca Compare September 21, 2026 06:18
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 21, 2026 06:18
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 6, 2026, 7:42 PM ET / 23:42 UTC (Revision 3).

ClawSweeper review

What this changes

Consolidates Discord and OpenAI voice-worker buffering, startup promises, playback cleanup, and callback acknowledgements without intended user-visible changes.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: protected maintainer work still contains useful cleanup beyond current main. No introduced correctness defect was found.

Priority: P3
Reviewed head: d09bfca1ac8c5c2a5c07e1faf2737e2c3e4c6ca9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused, maintainable cleanup with useful regression coverage and no blocking correctness finding; merge conflicts are a separate workflow blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor-proof gate is exempt for this bot-authored internal cleanup. The captured body records real worker/codec loopback observations through the changed audio paths under a Gateway stall; linked raw logs could not be independently downloaded. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor-proof gate is exempt for this bot-authored internal cleanup. The captured body records real worker/codec loopback observations through the changed audio paths under a Gateway stall; linked raw logs could not be independently downloaded. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduced patch: Reviewed the merge-base-to-head delta rather than endpoint drift. The introduced changes preserve raw-byte mode, PCM alignment, stale-generation credit returns, and playback settlement; no dependency, public SDK, configuration, or stored-data contract changes were introduced.
Meaningful remaining behavior: The branch rounds take() output to complete samples and consolidates file completion and worker-failure settlement. Inspected current main retains an unaligned allocation in take() and separate Discord settlement paths, so complete redundancy is not established.
Current-main overlap and routing: Current-main history shows Peter Steinberger's subsequent provider and Discord refactors. Source comparison confirms main already shares the raw-byte buffer, uses deferred startup promises, consolidates acknowledgements, and removes the constructor-only transport factory.
Findings None None.
Security None None.

How this fits together

Discord and OpenAI voice workers handle timing-sensitive audio outside the Gateway's main event loop. Their control adapters exchange bounded audio batches, completion events, and cancellation signals with voice sessions.

flowchart LR
  A[Voice session] --> B[Control adapters]
  B --> C[Bounded audio buffers]
  C --> D[Audio workers]
  D --> E[Discord and OpenAI transports]
  D --> F[Credits and completion events]
  F --> B
Loading

Before merge

  • Resolve merge risk (P1) - The pinned head conflicts with current main; the reconciled result needs review before merge.
  • Complete next step (P2) - Resolve the current-main conflicts, retain only the remaining useful changes, and obtain review of the reconciled result.
Agent review details

Security

None.

PR surface

Source -75, Tests +59. Total -16 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 9 90 165 -75
Tests 4 66 7 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 156 172 -16

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain current main's shared worker owners and integrate only the remaining sample-alignment and playback-settlement improvements.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain current main's shared worker owners and integrate only the remaining sample-alignment and playback-settlement improvements.

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

Not applicable: this PR proposes behavior-preserving cleanup, and source review found no concrete introduced failure to reproduce.

Is this the best way to solve the issue?

Yes: reusing existing buffer and deferred owners is a focused simplification, while current-main overlap makes a smaller refreshed patch appropriate.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 45228e1aeed6.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal plumbing cleanup with no intended user-visible behavior or configuration change.
  • 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 ordinary contributor-proof gate is exempt for this bot-authored internal cleanup. The captured body records real worker/codec loopback observations through the changed audio paths under a Gateway stall; linked raw logs could not be independently downloaded. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced patch: Reviewed the merge-base-to-head delta rather than endpoint drift. The introduced changes preserve raw-byte mode, PCM alignment, stale-generation credit returns, and playback settlement; no dependency, public SDK, configuration, or stored-data contract changes were introduced. (d09bfca1ac8c)
  • Meaningful remaining behavior: The branch rounds take() output to complete samples and consolidates file completion and worker-failure settlement. Inspected current main retains an unaligned allocation in take() and separate Discord settlement paths, so complete redundancy is not established. (extensions/openai/realtime-quicksilver-audio-buffer.ts:162, d09bfca1ac8c)
  • Current-main overlap and routing: Current-main history shows Peter Steinberger's subsequent provider and Discord refactors. Source comparison confirms main already shares the raw-byte buffer, uses deferred startup promises, consolidates acknowledgements, and removes the constructor-only transport factory. (extensions/openai/realtime-quicksilver-audio-buffer.ts, 45228e1aeed6)
  • Live merge blocker: GitHub REST confirms the PR remains open at the pinned head with mergeable=false and mergeable_state=dirty. No pinned test merge is available; this establishes a conflict blocker, not removal of current-main behavior. (d09bfca1ac8c)
  • Merged worker foundation: fix(voice): keep audio flowing while the Gateway is busy #154119 is verified merged at 41ee7fb. It establishes the worker architecture this cleanup follows; it does not establish that this cleanup is fully implemented. (41ee7fb2422b)
  • Recorded boundary proof and inspection limits: The supplied PR body records real workers/codecs using loopback transports during a 500 ms Gateway stall, observing 25 RTP packets and 25 direct PCM messages, plus focused tests and final-head CI. It explicitly distinguishes its earlier source snapshot from final mechanical corrections. REST reports the linked Testbox workflow wrapper as cancelled; its log download was blocked by the host's storage-domain allowlist, so independent trace verification remains unavailable. The recorded observations are retained without claiming the wrapper succeeded or requesting contributor proof solely because of this reviewer limitation.

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Reconcile the branch with current main, preserving newer worker lifecycle code and retaining only the useful remaining delta.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-21T06:25:38.109Z sha d09bfca :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T06:37:55.668Z sha d09bfca :: needs maintainer review before merge. :: none

This branch has not been deployed

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

Labels

channel: discord Channel integration: discord extensions: openai maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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