Skip to content

fix(audio): unify Piper extraction deadline - #1294

Merged
shanselman merged 3 commits into
mainfrom
fix/f003-piper-tar-timeout
Sep 4, 2026
Merged

shanselman merged 3 commits into
mainfrom
fix/f003-piper-tar-timeout

Conversation

@shanselman

@shanselman shanselman commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

What problem this solves

Piper voice extraction could outlive cancellation or its 120-second timeout because process exit and redirected output drains used separate waits. A descendant inheriting stdout or stderr could keep a drain open after tar exited.

This supersedes #1268 because that PR's head branch is in a contributor fork and is not writable by maintainers.

What changed

  • Process exit plus complete stdout and stderr drain share one linked caller/timeout deadline.
  • Timeout, cancellation, and unexpected drain failures trigger bounded process-tree cleanup and close inherited pipe readers.
  • Partial extraction is guarded by a sibling .installing marker, so interrupted or late cleanup cannot make corrupt model files appear installed.
  • Existing valid files are preserved during a failed recovery attempt, and voice deletion removes both the model directory and marker.
  • Deterministic fixtures cover success, timeout, delayed output, cancellation, pre-cancellation, inherited handles, marker semantics, and process cleanup.

Required proof pools

  • none: this is a local Windows tar.exe process-lifecycle fix. It does not change installer, gateway, MCP, node capability, or interactive UI contracts.

Validation

Current head: e46cf147e201b36080c7b0b3e551109a962b7564

  • .\build.ps1: all projects passed.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,915 passed, 32 environment-gated skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,840 passed, 0 failed.
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: 1,045 passed, 0 failed.
  • Focused Piper, process-wait, asset-hash, and single-flight tests: 19 passed.
  • Timeout extraction regression: 30/30 isolated repetitions passed.
  • Cancellation extraction regression: 25/25 isolated repetitions passed.
  • Hanselman dual-model adversarial review: no remaining MEDIUM, HIGH, or CRITICAL findings.

Real behavior proof

Environment: native Windows 11, .NET SDK 10.0.303, Windows SDK 10.0.26100.0.

  • Real Windows extraction creates a .tar.bz2 with Windows tar.exe, extracts through PiperVoiceManager.ExtractTarBz2Async, and verifies expected model files and content.
  • Timeout proof runs the exact Piper extraction boundary against a deterministic tar-shaped fixture, surfaces the wrapped timeout within the bounded cleanup budget, and confirms the extractor exits.
  • Cancellation proof waits for fixture readiness, cancels against the production 120-second budget, returns promptly, and confirms the extractor exits.
  • Inherited-handle proof confirms cancellation does not wait for descendant-held stdout/stderr pipes.
  • Partial-install proof confirms a sibling marker blocks incomplete layouts from being treated as installed and is removed by voice deletion.
  • The prior remote-head test failure was stale camera/screen capture timeout evidence. Those consent-timeout fixes are present through merged Fix camera/screen capture consent hang for unattended MCP callers #1300 on base SHA 91837de0cc182f2fe6ead8f85e0e6393a8ef064d.

Security impact

No new permissions, network calls, command surface, secrets handling, or data scope. Extraction still executes OS tar -xjf only after the archive passes its pinned SHA-256 check. Diagnostics do not add prompt, credential, or arbitrary file-content logging.

Compatibility

Backward compatible. Existing complete voice installs without a marker remain recognized.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 2, 2026
@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement 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 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 4:24 AM ET / 08:24 UTC.

ClawSweeper review

What this changes

Bounds Piper offline-voice extraction and output draining with one deadline, tracks incomplete installations, and adds process-lifecycle and extraction tests.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and the latest release retain the unbounded extraction wait. No blocking correctness or security findings were identified.

Priority: P2
Reviewed head: e46cf147e201b36080c7b0b3e551109a962b7564

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant lifecycle coverage, reported passing Windows validation, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This collaborator-authored internal repair is exempt from the external contributor proof gate; the supplied native-Windows report covers the production extractor, process faults, and marker compatibility.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This collaborator-authored internal repair is exempt from the external contributor proof gate; the supplied native-Windows report covers the production extractor, process faults, and marker compatibility.
Evidence reviewed 11 items Repository policy: Read the complete root AGENTS.md and proof-validation skill. No additional AGENTS.md files apply under the changed source/test paths, and no maintainer-notes directory exists. Reviewed the supplied validation against this policy without executing builds or tests.
Verified change ownership: Read all five introduced files. The original head records parent 6a68457; the test merge separately records the pinned main followed by the exact PR head. Its tree matches the reviewed head, with no base-only changes attributed to this PR.
Still necessary on main: The current-main extractor redirects stderr, calls unbounded WaitForExit, and reads stderr afterward. A stuck extractor or filled stderr pipe can therefore prevent completion.
Findings None None.
Security None None.

How this fits together

The Piper voice manager installs local speech models requested through Voice Settings. It verifies downloaded archives, runs Windows tar, and exposes installed voices to speech playback.

flowchart TD
A[Voice download request] --> B[Create incomplete marker]
B --> C[Download and verify archive]
C --> D[Extract and drain output]
D --> E{Completed within deadline?}
E -->|Yes| F[Verify files and clear marker]
F --> G[Offline voice ready]
E -->|Timeout or cancellation| H[Bounded cleanup and retryable error]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test growth Production +238/-19 (net +219); tests and fixtures +584/-0 Production growth supports a distinct complete-output deadline and incomplete-install tracking, with process and extraction coverage.

Root-cause cluster

Relationship: canonical
Canonical: #1294
Summary: The supplied discussion identifies this collaborator-owned branch as the adopted landing path for the Piper extraction hang.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep extraction and complete output draining under one deadline while preserving shared-download cancellation isolation and existing marker-free installations.

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

Yes, from source: a stuck tar child or filled stderr pipe reaches main's unbounded WaitForExit. No current-main runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. The focused extraction helper provides complete-output deadline semantics that the existing local command runner does not, while retaining hash verification and download ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 91837de0cc18.

Labels

Label justifications:

  • P2: This repairs a bounded audio-download workflow whose extractor can currently hang; it does not establish a broader runtime outage.
  • 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: This collaborator-authored internal repair is exempt from the external contributor proof gate; the supplied native-Windows report covers the production extractor, process faults, and marker compatibility.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md and proof-validation skill. No additional AGENTS.md files apply under the changed source/test paths, and no maintainer-notes directory exists. Reviewed the supplied validation against this policy without executing builds or tests. (AGENTS.md:77, e46cf147e201)
  • Verified change ownership: Read all five introduced files. The original head records parent 6a68457; the test merge separately records the pinned main followed by the exact PR head. Its tree matches the reviewed head, with no base-only changes attributed to this PR. (e46cf147e201)
  • Still necessary on main: The current-main extractor redirects stderr, calls unbounded WaitForExit, and reads stderr afterward. A stuck extractor or filled stderr pipe can therefore prevent completion. (src/OpenClaw.Shared/Audio/PiperVoiceManager.cs:365, 91837de0cc18)
  • Latest-release check: The supplied latest release, v2026.7.1-4, points to c7c6fb0 and contains the same unbounded extraction wait. (src/OpenClaw.Shared/Audio/PiperVoiceManager.cs:365, c7c6fb06be03)
  • Deadline and cleanup: Process exit and both output drains share one linked deadline. Timeout and cancellation invoke best-effort tree termination, close readers, and bound the subsequent cleanup wait. (src/OpenClaw.Shared/Audio/BoundedProcessWait.cs:30, e46cf147e201)
  • Install compatibility and integrity: Existing complete installations without a marker retain their readiness behavior. New downloads retain the pinned SHA-256 verification before extraction; the marker clears only after successful extraction and layout verification. The added marker test checks readiness with and without the marker and deletion cleanup. (src/OpenClaw.Shared/Audio/PiperVoiceManager.cs:212, e46cf147e201)

Likely related people:

  • Régis Brid: Raw commit b0ba9af adds src/OpenClaw.Shared/Audio/SingleFlightDownload.cs:21 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b0ba9affa25d; files: src/OpenClaw.Shared/Audio/SingleFlightDownload.cs)
  • shanselman: 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 (1 earlier review cycle)
  • reviewed 2026-09-02T18:06:55.197Z sha 36e6994 :: needs maintainer review before merge. :: none

shanselman added a commit that referenced this pull request Sep 2, 2026
)

Root cause: after 31a8c65/16cb6897 gated screen.snapshot/camera.snap/
location.get behind interactive consent, NodeService.EnsureCaptureConsentAsync
awaited the RecordingConsentDialog's Task<bool> with no timeout anywhere. An
unattended caller (local MCP HTTP client, automated agent, hosted CI) hung
forever waiting for a human who would never appear, only "recovering" when
the caller's own HttpClient.Timeout (30s in the failing integration tests)
fired. This broke McpHttpServerIntegrationTests.CameraSnap_ReturnsImageOr-
WellFormedError and ScreenSnapshot_ReturnsImageOrWellFormedError, blocking
PRs #1282, #1294, #1295, #1296.

Fix: add a fail-closed, configurable consent-prompt timeout
(SettingsData.CaptureConsentTimeoutMs, default 120s) enforced by a new pure
ConsentPromptTimeoutGate helper. On timeout the prompt is denied (never
granted) and the dangling dialog window is force-closed. The bounded task is
independent of any single caller's CancellationToken so the shared in-flight
prompt (_screen/_camera/_locationConsentInFlight) still resolves for any
other concurrent waiter even if the owning caller cancels first. A late
Allow click that races the timeout no longer persists a stale grant after
the request has already been denied. Interactive UI consent (Allow/Deny,
persistence) is unchanged.

- Never bypasses or auto-grants consent: timeout always resolves to denied.
- TrayAppFixture sets CaptureConsentTimeoutMs=3000 for deterministic CI,
  not a test/client timeout change - this is a real product settings knob.
- New unit tests cover fail-closed timeout, pass-through grant/deny, and the
  shared-prompt-survives-caller-cancellation case a rubber-duck review found.

Co-authored-by: Copilot App <[email protected]>
larroy pushed a commit to larroy/openclaw-windows-node that referenced this pull request Sep 3, 2026
…enclaw#1300)

Root cause: after 31a8c65/16cb6897 gated screen.snapshot/camera.snap/
location.get behind interactive consent, NodeService.EnsureCaptureConsentAsync
awaited the RecordingConsentDialog's Task<bool> with no timeout anywhere. An
unattended caller (local MCP HTTP client, automated agent, hosted CI) hung
forever waiting for a human who would never appear, only "recovering" when
the caller's own HttpClient.Timeout (30s in the failing integration tests)
fired. This broke McpHttpServerIntegrationTests.CameraSnap_ReturnsImageOr-
WellFormedError and ScreenSnapshot_ReturnsImageOrWellFormedError, blocking
PRs openclaw#1282, openclaw#1294, openclaw#1295, openclaw#1296.

Fix: add a fail-closed, configurable consent-prompt timeout
(SettingsData.CaptureConsentTimeoutMs, default 120s) enforced by a new pure
ConsentPromptTimeoutGate helper. On timeout the prompt is denied (never
granted) and the dangling dialog window is force-closed. The bounded task is
independent of any single caller's CancellationToken so the shared in-flight
prompt (_screen/_camera/_locationConsentInFlight) still resolves for any
other concurrent waiter even if the owning caller cancels first. A late
Allow click that races the timeout no longer persists a stale grant after
the request has already been denied. Interactive UI consent (Allow/Deny,
persistence) is unchanged.

- Never bypasses or auto-grants consent: timeout always resolves to denied.
- TrayAppFixture sets CaptureConsentTimeoutMs=3000 for deterministic CI,
  not a test/client timeout change - this is a real product settings knob.
- New unit tests cover fail-closed timeout, pass-through grant/deny, and the
  shared-prompt-survives-caller-cancellation case a rubber-duck review found.

Co-authored-by: Copilot App <[email protected]>
SebTardif and others added 3 commits September 4, 2026 00:40
Voice Settings Piper download extract called WaitForExit() with
stderr redirected and no timeout. A hung tar child or a full
stderr pipe blocked the UI until the process exited.

Wait with a 120s budget, drain stderr asynchronously, and kill
the process tree on timeout or cancel.

Signed-off-by: Sebastien Tardif <[email protected]>
Use one timeout and cancellation budget for process exit and both output drains, with bounded process-tree cleanup and observed abandoned tasks. Add deterministic lifecycle fixtures and real Windows tar extraction coverage.

Co-authored-by: Copilot App <[email protected]>
@shanselman
shanselman force-pushed the fix/f003-piper-tar-timeout branch from 36e6994 to e46cf14 Compare September 4, 2026 08:14
@shanselman
shanselman merged commit 1d32722 into main Sep 4, 2026
22 checks passed
@shanselman
shanselman deleted the fix/f003-piper-tar-timeout branch September 4, 2026 08:41
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants