Skip to content

fix(setup): enforce one Tailscale probe deadline - #1296

Merged
shanselman merged 7 commits into
mainfrom
shanselman-repair-tailscale-probe-deadline
Sep 4, 2026
Merged

shanselman merged 7 commits into
mainfrom
shanselman-repair-tailscale-probe-deadline

Conversation

@shanselman

@shanselman shanselman commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Replaces #1267 because the contributor fork rejected the required current-origin/main merge through the maintainer OAuth token's missing workflow scope. This branch preserves the original fix, merges current main at 1d32722cada43a5515a90599c25ec1b235100566, and completes the deadline repair.

What Problem This Solves

The setup Capabilities page could hang while probing tailscale.exe status --json when the process did not exit or a descendant retained a redirected output handle.

Why This Change Was Made

BoundedProcessOutput applies one monotonic five-second deadline to immediate process exit and redirected stdout drain. Immediate-child completion uses Process.Exited, independent of pipe EOF, with an already-exited race check. Incremental stdout capture preserves valid status that arrived before a descendant-held pipe exceeded the remaining drain budget.

The landing repair also:

  • keeps process start and cleanup off the WinUI dispatcher;
  • cancels superseded probes and generation-gates UI/config writes;
  • kills the process tree on exit-phase timeout or cancellation and explicitly handles partial tree-kill failures;
  • caps both redirected streams at 1 MiB while continuing to drain excess data;
  • invokes status --json --peers=false so valid large-tailnet responses cannot be truncated by peer data;
  • uses ArgumentList rather than a raw command-line string;
  • records only exception types in cleanup diagnostics; and
  • removes load-sensitive timing assumptions from the regression tests.

Required proof pools

  • none: no custom host class is required. The changed production helper is directly exercised on Windows against a hung child process, an inherited redirected handle, and oversized output. No UI text, layout, permissions, gateway, or installer behavior changed.

Validation

Current reviewed head: aaa891a11c9ee40ad642976fbda7b58015b18923.

  • .\build.ps1: passed in 47.0s. Shared, CLI, WinNode CLI, SetupEngine, and WinUI built successfully.
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: 1,055 passed, 0 failed in 57.5s.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,915 passed, 32 skipped, 0 failed in 28.6s. Skips are the existing environment-gated integration tests.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,840 passed, 0 failed in 37.1s with isolated OPENCLAW_TRAY_DATA_DIR.
  • Focused SetupEngine/Tailscale selection: 34 passed, 0 failed in 28.0s.
  • Focused production-entry proof: 3 tests passed in each of three consecutive runs, 9/9 total, in 34.5s.
  • Hanselman adversarial review: Claude Opus 5 and GPT-5.3-Codex findings fixed; second pass found no remaining runtime correctness or security defect.
  • python .agents\skills\autoreview\scripts\autoreview --mode local --stream-engine-output: clean, no accepted/actionable findings, overall confidence 0.90.

Real behavior proof

The exact production BoundedProcessOutput.ReadAsync entry point used by CapabilitiesPage was exercised on Windows 10.0.26340, win-x64, .NET SDK 10.0.303/runtime 10.0.11:

$ dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-build --no-restore --filter "FullyQualifiedName~ReadAsync_HungWindowsTailscaleProbeHonorsFiveSecondDeadline|FullyQualifiedName~ReadAsync_PreservesValidStatusWhenDescendantRetainsOutputHandle|FullyQualifiedName~ReadAsync_CapsCapturedStdout"
Passed ReadAsync_HungWindowsTailscaleProbeHonorsFiveSecondDeadline [5 s]
Passed ReadAsync_CapsCapturedStdout [61-65 ms]
Passed ReadAsync_PreservesValidStatusWhenDescendantRetainsOutputHandle [5 s]
Total tests: 3. Passed: 3.

The command passed three consecutive times. The retained-handle regression launches an immediate process that emits valid Tailscale status JSON and exits while a descendant keeps stdout open beyond the remaining drain budget. ReadAsync returns exit code 0, retains the JSON, and TailscaleSetupPolicy.TryParseStatus reports a running backend. The hung-process regression returns at the single deadline and terminates the process tree. The oversized-output regression verifies capture remains bounded.

Capabilities page visible proof: Not verified / blocked. This Windows host has no installed Tailscale CLI. No visible copy or layout changed, and direct current-head production-entry proof covers the process-lifecycle behavior without mutating user or machine environment state.

Security Impact

  • New permissions or capabilities: No
  • Secrets or tokens handling changed: No
  • New or changed network calls: No
  • Command execution surface changed: No. The existing Tailscale status probe now uses structured argv and bounded lifecycle/output handling.
  • Diagnostic privacy: cleanup traces contain operation and exception type only, not output or exception messages.

Compatibility and Migration

Backward compatible. No configuration or migration is required.

SebTardif and others added 4 commits August 29, 2026 11:18
Setup Capabilities called ReadToEnd() before WaitForExit(5000), so a
hung or pipe-blocked tailscale.exe never reached the timeout.

Wait for the child first, drain leftover stdout, and kill the process
tree when either step times out.

Signed-off-by: Sebastien Tardif <[email protected]>
Use one monotonic deadline for process exit and redirected output drain, with bounded kill cleanup and cancellation-safe task observation.

Co-authored-by: Copilot App <[email protected]>
@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 removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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, 5:26 AM ET / 09:26 UTC.

ClawSweeper review

What this changes

The PR replaces the setup wizard's unbounded Windows Tailscale status read with a deadline-bound, cancellable process probe and regression coverage.

Merge readiness

✅ Ready for maintainer review

This collaborator PR remains necessary: current main is the unpatched base, while the introduced helper bounds the probe lifecycle and preserves useful status output. The current-head Windows production-entry proof is strong, and no correctness or security finding remains.

Priority: P2
Reviewed head: aaa891a11c9ee40ad642976fbda7b58015b18923

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation and strong Windows production-entry proof support normal merge-ready quality.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed production owner, BoundedProcessOutput.ReadAsync, is called by the Capabilities page and was exercised on Windows with a hung child, a valid status followed by a descendant-held output handle, and oversized output. The PR records repeated after-fix terminal results; no UI copy or layout changed, and the unavailable installed Tailscale CLI is explicitly documented as a visible-proof blocker.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owner, BoundedProcessOutput.ReadAsync, is called by the Capabilities page and was exercised on Windows with a hung child, a valid status followed by a descendant-held output handle, and oversized output. The PR records repeated after-fix terminal results; no UI copy or layout changed, and the unavailable installed Tailscale CLI is explicitly documented as a visible-proof blocker.
Evidence reviewed 5 items Introduced bounded process lifecycle: The introduced helper applies a monotonic timeout to immediate-child exit and redirected stdout drain, returning captured output only when the immediate process exited.
Capabilities-page integration: The page invokes the bounded helper off the WinUI dispatcher, cancels superseded probes, and generation-gates subsequent UI and configuration writes.
Regression coverage and supplied real proof: The current-head tests exercise a hung process, a descendant-held redirected handle that follows valid status JSON, and bounded stdout capture. The PR body records three consecutive Windows runs of the exact ReadAsync entry point with all three scenarios passing.
Findings None None.
Security None None.

How this fits together

The setup Capabilities page runs the local Tailscale CLI to determine readiness, then uses its status to update the setup configuration and wizard review. This change controls the CLI process and redirected-output lifecycle before status parsing reaches the UI.

flowchart LR
A[Capabilities page] --> B[Tailscale CLI status probe]
B --> C[Deadline and output capture]
C --> D[Status JSON parsing]
D --> E[Setup configuration]
E --> F[Wizard status and review]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +366, tests +306 The substantial helper is paired with focused coverage for its timeout, cancellation, inherited-handle, and output-cap behavior.

Root-cause cluster

Relationship: canonical
Canonical: #1296
Summary: This PR explicitly replaces the earlier Tailscale probe repair with the completed deadline and cleanup approach.

Members:

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

Technical review

Best possible solution:

Land the bounded process helper with its current regression coverage, retaining the page's cancellation and stale-result guard.

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

Yes, at source level. The base implementation reads stdout before reaching its exit wait, and the supplied current-head Windows proof exercises both a hung child and a descendant-held output handle.

Is this the best way to solve the issue?

Yes. A focused process-lifecycle helper lets the page keep valid early status, bound both wait phases to one deadline, and prevent stale probe results from changing setup state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1d32722cada4.

Labels

Label justifications:

  • P2: This is a localized setup-wizard hang fix with a bounded user-impact surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed production owner, BoundedProcessOutput.ReadAsync, is called by the Capabilities page and was exercised on Windows with a hung child, a valid status followed by a descendant-held output handle, and oversized output. The PR records repeated after-fix terminal results; no UI copy or layout changed, and the unavailable installed Tailscale CLI is explicitly documented as a visible-proof blocker.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner, BoundedProcessOutput.ReadAsync, is called by the Capabilities page and was exercised on Windows with a hung child, a valid status followed by a descendant-held output handle, and oversized output. The PR records repeated after-fix terminal results; no UI copy or layout changed, and the unavailable installed Tailscale CLI is explicitly documented as a visible-proof blocker.

Evidence

What I checked:

Likely related people:

  • Andy Eskridge: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Joel: 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-02T18:11:57.836Z sha 19edb7d :: needs changes before merge. :: [P2] Detect child exit independently of pipe EOF | [P2] Provide Capabilities-page proof or state the blocker
  • reviewed 2026-09-02T18:46:38.672Z sha 70c433d :: needs maintainer review before merge. :: none

@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
Use Process.Exited for immediate-child completion and retain incrementally captured Tailscale status when a descendant keeps the redirected pipe open.

Co-authored-by: Copilot App <[email protected]>
@shanselman

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Addressed the two P2 findings at 70c433d: immediate exit now uses Process.Exited with the already-exited race covered; ReadAsync preserves parseable status while a descendant retains stdout; and the PR body now includes current-head Windows proof plus the explicit Capabilities-page UI injection blocker.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 2, 2026
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]>
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: e1ae849f-65fd-4424-a93f-461dea53cfde
@shanselman
shanselman merged commit 585c177 into main Sep 4, 2026
34 of 37 checks passed
@shanselman
shanselman deleted the shanselman-repair-tailscale-probe-deadline branch September 4, 2026 10:01
@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. proof: sufficient Contributor real behavior proof is sufficient. 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