Skip to content

fix(mxc): tasklist no longer hangs past sandbox timeout - #1151

Merged
shanselman merged 3 commits into
mainfrom
shanselman-fix-issue-1149
Aug 14, 2026
Merged

shanselman merged 3 commits into
mainfrom
shanselman-fix-issue-1149

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Closes #1149

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where users running tasklist or another non-terminating command in the Windows node MXC sandbox could see the node invocation remain pending after the configured timeout.

Why This Change Was Made

MXC cancellation now retains process-tree termination but replaces unbounded launcher and redirected-pipe cleanup with process-exit and pipe-completion signals capped at 500 ms. A deterministic test seam covers the case where the launcher survives the kill attempt without changing sandbox capabilities or process-enumeration policy.

User Impact

Sandboxed Windows node commands now return a timed-out result promptly instead of remaining stuck indefinitely after their timeout expires.

Evidence

  • An always-on regression test simulates a launcher that remains alive after process-tree termination is attempted and proves MxcExecutor.RunAsync returns a timed-out result within one second.
  • A normal-exit test proves stdout and stderr are still captured through the new bounded drain path.
  • The real WSL gateway to Windows node MXC validation completed successfully with all 17 tests passing.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

  • ./build.ps1: passed, all five projects built successfully.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: passed, 3,641 passed and 32 skipped.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: passed, 2,249 passed.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --filter "FullyQualifiedName~MxcExecutorTests": passed, 3 passed.
  • ./scripts/validate-mxc-e2e.ps1: passed, 17 passed, including all three required gateway MXC proofs.

Real Behavior Proof

  • Environment tested: Windows ARM64, .NET SDK 10.0.302, temporary WSL gateway and isolated E2E data.
  • PR head or commit tested: c31f320a
  • Exact steps or command run: focused MxcExecutorTests, full required build and test suites, then ./scripts/validate-mxc-e2e.ps1.
  • Evidence after fix: the focused test leaves the launcher alive after cancellation and asserts the timed-out result returns within one second; the MXC E2E script reports all gateway proofs passed.
  • Observed result: cancellation cleanup remained bounded, normal stdout/stderr capture remained intact, and real gateway-mediated MXC execution succeeded.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A
  • Not verified or blocked: direct tasklist host-process enumeration was not asserted because visibility remains governed by AppContainer policy. If tasklist cannot complete, the invocation now returns after the configured timeout instead of hanging indefinitely.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): Yes
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: Only host-side cancellation cleanup changes. Existing MXC policy, process-tree termination, capability checks, and timeout reporting remain in place; the cleanup wait is now bounded.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 4:08 PM ET / 20:08 UTC.

ClawSweeper review

What this changes

The PR bounds MXC cancellation cleanup after a sandboxed Windows command times out, while preserving complete redirected output for normally exited commands.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The repaired head addresses both prior findings, and the collaborator-authored PR has current-head validation claims plus an active linked bug; it needs normal maintainer merge review rather than automated cleanup.

Priority: P1
Reviewed head: 54f23d267db285d8838497b3b23f847c183c7c48

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair resolves both earlier findings and has credible current-head gateway validation, with the intended cancellation tradeoff left visible for merger review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The repaired-head follow-up reports focused stress runs and the repository-required real gateway-to-Windows-node MXC proof, including the denied-write case.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The repaired-head follow-up reports focused stress runs and the repository-required real gateway-to-Windows-node MXC proof, including the denied-write case.
Evidence reviewed 5 items Current main still has the unbounded cancellation path: Current main waits synchronously for redirected-pipe draining after cancellation, the behavior this PR replaces with bounded cleanup.
Repaired head preserves normal output draining: The final head retains synchronous lossless draining on normal completion and limits the new timeout cap to the cancellation branch, resolving the prior output-loss finding.
Final repair provenance: The latest commit explicitly synchronizes cancellation after launcher startup and changes the regression assertion to a scheduler-tolerant semantic contract.
Findings None None.
Security None None.

How this fits together

The Windows node runs approved commands through the MXC AppContainer launcher and returns their output to the gateway. This change affects timeout recovery before the node reports the invocation result.

flowchart LR
  A[Gateway command request] --> B[Windows node]
  B --> C[MXC sandbox launcher]
  C --> D[Command process]
  D --> E{Completes or times out}
  E -->|Completes| F[Drain output and return result]
  E -->|Times out| G[Terminate process tree]
  G --> H[Bounded cleanup and timed-out result]
Loading

Before merge

  • Resolve merge risk (P1) - On cancellation, a launcher that ignores process-tree termination can remain alive and late redirected output can be discarded after the 500 ms cap; this is the stated availability-over-perfect-cleanup tradeoff.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and regression coverage production +78 / -13, tests +172 The focused production change is paired with dedicated normal-output and cancellation-bound coverage.

Merge-risk options

Maintainer options:

  1. Accept bounded timeout recovery (recommended)
    Accept the documented tradeoff that an unkillable launcher may outlive the invocation so the Windows node can return a timed-out result instead of hanging indefinitely.
  2. Require stronger cleanup semantics
    Pause this PR if maintainers require confirmed launcher termination and complete late output before a timed-out result is returned.

Technical review

Best possible solution:

Keep bounded cleanup only on cancellation, retain lossless normal-exit draining, and land after maintainers accept the bounded-recovery tradeoff and required checks pass.

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

Yes. The linked report gives a concrete sandboxed tasklist path, and current main's cancellation branch still synchronously waits for process and pipe completion after cancellation.

Is this the best way to solve the issue?

Yes. Restricting the cleanup cap to cancellation directly fixes the hang while preserving the established lossless drain on normal exits and leaving MXC policy unchanged.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 17a8b0363a82.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The repaired-head follow-up reports focused stress runs and the repository-required real gateway-to-Windows-node MXC proof, including the denied-write case.
  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 availability.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The linked report shows sandboxed Windows commands can leave a node invocation pending indefinitely after timeout.
  • merge-risk: 🚨 availability: The changed cancellation path determines whether a timed-out Windows-node command returns or remains stuck.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The repaired-head follow-up reports focused stress runs and the repository-required real gateway-to-Windows-node MXC proof, including the denied-write case.
  • proof: sufficient: Contributor real behavior proof is sufficient. The repaired-head follow-up reports focused stress runs and the repository-required real gateway-to-Windows-node MXC proof, including the denied-write case.

Evidence

What I checked:

Likely related people:

  • shanselman: Introduced the released MXC executor path and authored both commits on the repaired PR head. (role: feature owner and recent area contributor; confidence: high; commits: 4206611f2b2e, c31f320a8d5d, 54f23d267db2; files: src/OpenClaw.Shared/Mxc/MxcExecutor.cs, tests/OpenClaw.Shared.Tests/Mxc/MxcExecutorTests.cs)
  • Barbara Kudiess: Git history identifies the direct wxc-exec MXC implementation as the origin of this executor surface. (role: original MXC implementation contributor; confidence: medium; commits: cf611d4ab59f; files: src/OpenClaw.Shared/Mxc/MxcExecutor.cs)

Rank-up moves

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

  • Let the in-progress required checks finish on the repaired head.

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 (4 earlier review cycles)
  • reviewed 2026-08-12T04:04:54.733Z sha c31f320 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T13:16:56.140Z sha c31f320 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T17:09:35.569Z sha c31f320 :: needs changes before merge. :: [P2] Preserve complete output after a normal process exit
  • reviewed 2026-08-14T17:27:17.298Z sha c31f320 :: needs changes before merge. :: [P2] Preserve complete output after a normal process exit | [P2] Make the cleanup-bound regression test reliable

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

Retried the failed Build and Test job twice today.

  • Attempt 2: the original SystemRun_Where_ReturnsExpectedOutput integration failure passed, but an unrelated ChatTimelineVirtualizationProofTests.ModerateScrollUpDuringSettleTimer_IsNotRepinned UI timing precondition failed.
  • Attempt 3: Shared tests failed in this PR's new MxcExecutorTests.RunAsync_CancellationCleanupIsBounded_WhenProcessTreeKillDoesNotStopLauncher; cleanup took 1,562 ms at MxcExecutorTests.cs:78.

All MXC E2E shards and the other test stages passed when reached, but the PR's own cleanup-bound regression test is not stable under CI load. I did not merge while the required test check remains red.

@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 14, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient Contributor real behavior proof is sufficient. label Aug 14, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

Follow-up diagnosis: this is primarily a timing-test issue, not evidence that the cleanup architecture is broken.

Why:

  • Production uses Task.WhenAll(...).WaitAsync(cleanupTimeout). That is a bounded asynchronous wait, but .NET timer continuations are scheduler-dependent; it is not a hard real-time wall-clock guarantee under a loaded, coverage-instrumented runner.
  • The failing test configures 100 ms cancellation + 100 ms cleanup, but asserts total wall time < 1 second, measured from before process startup. Attempt 3 observed 1,562 ms under full-suite coverage load. That can happen from process startup, timer, and thread-pool scheduling latency even though the cleanup wait itself is bounded.
  • On the exact PR head, the focused test passed 25/25 normally and 10/10 under dotnet-coverage locally.
  • The PR's other focused tests pass. All three gateway/MXC E2E shards pass.
  • The original SystemRun_Where_ReturnsExpectedOutput failure passed on rerun. The attempt-2 chat timeline failure is unrelated baseline UI timing.

Architectural tradeoff that still needs maintainer acceptance: after the 500 ms production cleanup cap, a launcher that ignored process-tree termination may survive, and late output may be discarded. That is intentional availability-over-perfect-cleanup behavior and matches the existing bounded-drain pattern.

Recommended branch fix:

  1. Keep the production implementation.
  2. Make the regression test assert the semantic contract (TimedOut, ExitCode == -1, cancellation result) and a coarse non-hang ceiling, not < 1 second as a hard scheduler guarantee.
  3. Start cancellation timing only after confirming the test launcher started, so process startup is not charged to cleanup.
  4. Update/rebase onto current main, then rerun CI.

Keep lossless output draining on normal completion while bounding only the cancellation path. Synchronize cancellation after launcher startup and assert the semantic cleanup contract with a scheduler-tolerant ceiling.

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

Copilot-Session: 27dc9d2f-ee94-48f1-bf06-8f3d10414fc9
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 14, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

Pushed a deterministic repair at 54f23d26 and merged current main into the branch.

Changes:

  • Bound cleanup only on cancellation; normal successful completion retains lossless output draining.
  • Include the launcher PID in cancellation-cleanup timeout diagnostics.
  • Start cancellation after the launcher is confirmed started.
  • Assert process-tree kill was attempted and use a scheduler-tolerant post-cancel ceiling.

Validation:

  • Focused MxcExecutorTests: 3/3 passed.
  • Stress: 20/20 normal and 10/10 under dotnet-coverage.
  • Full build passed.
  • Shared: 3,689 total, 3,657 passed, 32 skipped.
  • Tray: 2,468/2,468 passed.
  • validate-mxc-e2e.ps1 passed, including real gateway system.run execution and denied-write proof.

@shanselman shanselman removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Aug 14, 2026
@clawsweeper clawsweeper Bot added 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 merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 14, 2026
@shanselman
shanselman merged commit 3692878 into main Aug 14, 2026
32 of 33 checks passed
@shanselman
shanselman deleted the shanselman-fix-issue-1149 branch August 14, 2026 20:34
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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.

[Bug]: tasklist hangs forever in Windows node sandbox even with "Allow Windows UI APIs" enabled (2026.7.1)

1 participant