Skip to content

fix(capture): tolerate bounded audio backpressure - #26

Merged
omarshahine merged 3 commits into
mainfrom
fix/capture-queue-contention
Sep 20, 2026
Merged

omarshahine merged 3 commits into
mainfrom
fix/capture-queue-contention

Conversation

@omarshahine

Copy link
Copy Markdown
Collaborator

Change

Keep the FaceTime capture process alive when its bounded writer queue fills during a short scheduler or pipe stall. The queue still uses fixed preallocated storage, never overwrites the slot owned by the drain worker, and replaces the oldest pending frame with fresher audio under sustained backpressure. Invalid audio preparation remains fatal.

This fixes the native failure exposed while validating openclaw/openclaw#119291.

Compatibility and security

No plugin/native protocol, privilege, signing, or macOS compatibility contract changes. This is a source-only repair. Native publishing and tap updates remain a separate owner-controlled release step.

Validation

  • bash scripts/test-native.sh

  • pnpm build:capture

  • pnpm test (5 files, 21 tests)

  • git diff --check

  • Independent Codex autoreview: no actionable P0/P1 findings

  • Isolated live proof reproduced the original queue-overflow teardown after about 102 seconds while routing and output suppression remained healthy. A second live call has not been made with this repaired source.

  • Relevant automated checks passed

  • Live proof included when the FaceTime user path changes

  • Shared native contracts coordinated with openclaw/openclaw, if changed

  • Changelog updated for user-visible, compatibility, security, or release changes

  • No credentials, call details, private paths, or generated artifacts included

@omarshahine
omarshahine requested review from a team as code owners September 16, 2026 16:17
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed September 19, 2026, 11:59 PM ET / September 20, 2026, 03:59 UTC (Revision 3).

ClawSweeper review

What this changes

The native FaceTime capture writer replaces stale queued audio during backpressure, protects the buffer being converted, and adds focused queue checks.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful repair: current main and the latest release retain the saturation failure path. No actionable patch defect was found, but repository-required after-fix macOS proof remains outstanding.

Likely related people: Takhoffman and omarshahine, based on prior merged capture work.

Priority: P1
Reviewed head: dfbe0b1772f5f7124a4b64c4a8b9d00225aa364c

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 9 items Current-main failure remains: Main still returns false when the semaphore is exhausted or the queue lock is contended; the tap callback converts false into the capture-overflow failure signal.
Latest release retains the same behavior: GitHub identifies v0.1.1 as the latest release; inspection of its supplied commit shows the same semaphore-exhaustion and contention failure returns.
Queue ownership and integration: The introduced queue separates available, pending, and active slots. Only pending slots can be replaced; the serial drain returns its active slot after conversion. PCMWriter treats contention and saturation as nonfatal while preserving preparation rejection.
Findings None None.
Security None None.

How this fits together

The native capture process receives call audio from a macOS Core Audio tap and converts it into PCM streamed to OpenClaw. Its bounded writer queue separates the realtime audio callback from conversion and stdout writes.

flowchart LR
  A[FaceTime call audio] --> B[Core Audio tap]
  B --> C[Bounded audio queue]
  C --> D{Free buffer available?}
  D -->|Yes| E[Queue fresh audio]
  D -->|No| F[Replace oldest pending audio]
  E --> G[Convert and write PCM]
  F --> G
  G --> H[OpenClaw voice bridge]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied evidence does not establish audio recovery after queue replacement under real macOS backpressure.
  • Complete next step (P2) - Provide after-fix macOS evidence of capture surviving temporary backpressure and resuming audio, with explicit operator and participant consent. Redacted terminal output or logs count; screenshots or recordings are useful when they show the result. Remove credentials, phone numbers, private endpoints, and call details. Updating the PR body should trigger review automatically; otherwise ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC Production +93/-56 (net +37); native checks +69; test runner +8 The production growth supplies explicit buffer ownership needed to replace pending audio safely.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain bounded preallocated buffering and active-slot protection, with demonstrated audio recovery after temporary backpressure and fatal handling reserved for invalid preparation or conversion failures.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain bounded preallocated buffering and active-slot protection, with demonstrated audio recovery after temporary backpressure and fatal handling reserved for invalid preparation or conversion failures.

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

Yes, at source level: exhausting main's writer slots or contending its lock returns false and signals capture failure. The author reports a live pre-fix failure; this review did not execute macOS capture.

Is this the best way to solve the issue?

Yes. Tracking free, pending, and active buffers directly is a focused repair that avoids overwriting audio in conversion and preserves the existing output contract; runtime recovery still needs verification.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4b406fb885c3.

Labels

Label justifications:

  • P1: The PR addresses a reported live-call teardown from ordinary bounded capture backpressure that remains possible on main.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Current-main failure remains: Main still returns false when the semaphore is exhausted or the queue lock is contended; the tap callback converts false into the capture-overflow failure signal. (native/Sources/FaceTimeAudioCapture/FaceTimeAudioCapture.swift:485, 4b406fb885c3)
  • Latest release retains the same behavior: GitHub identifies v0.1.1 as the latest release; inspection of its supplied commit shows the same semaphore-exhaustion and contention failure returns. (native/Sources/FaceTimeAudioCapture/FaceTimeAudioCapture.swift:485, 3afde42c83db)
  • Queue ownership and integration: The introduced queue separates available, pending, and active slots. Only pending slots can be replaced; the serial drain returns its active slot after conversion. PCMWriter treats contention and saturation as nonfatal while preserving preparation rejection. (native/Sources/FaceTimeAudioCapture/FixedSlotQueue.swift:27, dfbe0b1772f5)
  • Focused checks and CI coverage: Queue checks cover oldest-pending replacement, active-buffer protection, lock contention, rejected preparation, and slot reuse. The supplied current-head native check succeeded; its workflow runs native checks, capture build, archive creation, and archive verification. No builds or artifact-producing tests were executed during this read-only review. (native/Checks/FixedSlotQueueChecks.swift:5, dfbe0b1772f5)
  • Applicable live-proof policy and dependency signal: CONTRIBUTING.md explicitly requires live proof for changes affecting the end-to-end FaceTime product and identifies the canonical OpenClaw FaceTime documentation as that proof contract. This establishes the dependency-specific policy signal for this capture behavior. (CONTRIBUTING.md:49, dfbe0b1772f5)
  • Canonical proof contract: The FaceTime guide distinguishes internal readiness flags from observed audio delivery and requires consent for live verification. Relevant evidence must demonstrate actual audio behavior; successful checks alone do not establish it. (docs/plugins/facetime.md:249, a545a850420c)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • omarshahine: 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-16T16:19:38.148Z sha 846acd5 :: blocked before merge. :: none
  • reviewed 2026-09-20T03:53:17.299Z sha 4891c44 :: blocked before merge. :: none

@omarshahine
omarshahine merged commit cff304b into main Sep 20, 2026
12 checks passed
@omarshahine
omarshahine deleted the fix/capture-queue-contention branch September 20, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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