Skip to content

fix(mxc): bound termination and output drain cleanup - #1387

Merged
shanselman merged 2 commits into
mainfrom
pr/1166
Sep 11, 2026
Merged

shanselman merged 2 commits into
mainfrom
pr/1166

Conversation

@shanselman

@shanselman shanselman commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #1166 (fix(mxc): bound termination and output drain cleanup) with a current-main replacement based on 4064eb9c. Current head: fc54e2ee.

This keeps MXC cleanup bounded without reusing SetupEngine ownership blindly. It caps blocked process-tree termination workers, preserves the original handle-backed Process until a kill worker releases it, bounds post-exit pipe drain, and captures raw redirected bytes so newline-free, exact-buffer, configured-encoding, and fragmented-BOM final output is retained. Dedicated reader threads use bounded repeated CancelSynchronousIo cancellation for the synchronous anonymous pipes created by System.Diagnostics.Process, closing the inherited-handle race without allowing the invocation to hang.

The exact-buffer regression uses a silent inherited-handle child, so the expected 4,096-byte parent output cannot be polluted by scheduler-dependent descendant writes.

Required proof pools

  • windows-wsl-mxc

Validation

Current head fc54e2ee:

  • ./build.ps1: passed
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 3,998 passed, 32 skipped, 0 failed
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 2,865 passed, 0 skipped, 0 failed
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~Mxc': 225 passed, 7 environment-gated skips, 0 failed
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~MxcExecutorTests': 10 passed, 0 failed
  • Focused exact-buffer output regression: passed individually and in the complete executor suite after the silent-child fixture fix
  • Codex autoreview of the production change: clean, no accepted/actionable findings
  • Rubber-duck review of the production change: clean, no actionable in-scope defects
  • Codex autoreview of fc54e2ee: clean, no accepted/actionable findings
  • Rubber-duck review of fc54e2ee: clean, no actionable findings

Real behavior proof

Not verified / blocked. Do not merge.

./scripts/validate-mxc-e2e.ps1 was run without -AllowSkip. Repository build succeeds, but fresh Ubuntu 24.04 WSL setup fails before any Gateway-to-Windows-node MXC behavior executes:

Failed to attach disk '%LOCALAPPDATA%\Temp\<id>\swap.vhdx' to WSL2: Access is denied.
Error code: Wsl/InstallDistro/Service/RegisterDistro/CreateVm/MountDisk/E_ACCESSDENIED

No Crabbox validation was used. This PR must remain draft and blocked until the non-skipping windows-wsl-mxc proof passes on a capable host.

Preserve final redirected output fragments while bounding cancellation and inherited-pipe cleanup. Cap blocked process-tree kill workers and coordinate process ownership until cleanup completes.

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

Copilot-Session: 1c0274bb-f65e-4900-be1b-1303a10fdec5
@clawsweeper

clawsweeper Bot commented Sep 10, 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.

@shanselman shanselman added the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

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

ClawSweeper review

What this changes

Bounds Windows sandbox process termination and output draining while preserving final output fragments, with regression tests for blocked termination and inherited pipe handles.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR remains useful because current main still has both unbounded paths. No definite introduced defect was found, but the required integrated MXC proof remains blocked and the recorded human-review hold still applies.

Priority: P2
Reviewed head: fc54e2ee07b21d40cd431eb42d396b2ad3618ca4

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and process coverage are useful, but the required integrated behavior remains unverified.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/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 8 items Applicable repository policy: Read the complete root AGENTS.md and proof-validation skill. No applicable nested AGENTS.md or maintainer-notes directory was found. MXC changes require the non-skipping Gateway-to-Windows-node validation path.
Introduced cleanup ownership: The executor adds bounded kill-worker admission, deferred disposal of the original Process, bounded normal-exit draining, and native cancellation of dedicated pipe readers. Inspection found no definite blocking correctness defect.
Current main still needs the change: Current main still calls the process-tree killer synchronously and uses parameterless WaitForExit for normal output draining. The merged cancellation fix at #1151 (fix(mxc): tasklist no longer hangs past sandbox timeout) does not cover these remaining paths.
Findings None None.
Security None None.

How this fits together

The Windows node passes sandboxed command requests and cancellation signals to the MXC executor, which launches wxc-exec. Its process cleanup and output capture determine when command results return to the caller.

flowchart TD
 A[Sandboxed command request] --> B[Windows sandbox executor]
 B --> C[MXC launcher]
 C --> D{Exit or cancellation}
 D --> E[Bounded termination and pipe drain]
 E --> F[Captured output and command result]
 F --> G[Windows node caller]
Loading

Before merge

  • Resolve merge risk (P1) - The replacement native pipe readers and deferred Process disposal have not completed the required integrated MXC run, leaving invocation availability and cleanup under that environment unverified.
  • Complete next step (P2) - After the owner resumes work, provide passing current-head ./scripts/validate-mxc-e2e.ps1 results without -AllowSkip before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +486 net lines; tests and fixtures +542 net lines The growth supports native pipe cancellation, decoding, bounded termination, and process-level regression coverage.

Root-cause cluster

Relationship: canonical
Canonical: #1387
Summary: This is the explicitly designated replacement for the closed, unmerged earlier cleanup branch; the older merged timeout repair covers only part of the behavior.

Members:

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

Merge-risk options

Maintainer options:

  1. Retain the proof hold (recommended)
    Keep landing paused until the owner supplies the required non-skipping MXC result from a capable Windows host.

Technical review

Best possible solution:

Retain bounded cleanup and final-output preservation, backed by passing current-head Windows Gateway-to-node MXC proof before landing.

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

Yes, source establishes the blocking paths: a synchronous tree kill can stall cancellation, and inherited pipe handles can prevent the normal drain from completing. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes, the patch addresses the remaining waits within the existing executor and protects output handling with focused process fixtures; integrated validation is still required.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 734763131c8d.

Labels

Label justifications:

  • P2: This is a focused sandbox command reliability improvement without evidence of a widespread urgent outage.
  • merge-risk: 🚨 availability: New native reader cancellation and deferred disposal affect command completion and remain unverified through the required integrated MXC path.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Applicable repository policy: Read the complete root AGENTS.md and proof-validation skill. No applicable nested AGENTS.md or maintainer-notes directory was found. MXC changes require the non-skipping Gateway-to-Windows-node validation path. (AGENTS.md:55, fc54e2ee07b2)
  • Introduced cleanup ownership: The executor adds bounded kill-worker admission, deferred disposal of the original Process, bounded normal-exit draining, and native cancellation of dedicated pipe readers. Inspection found no definite blocking correctness defect. (src/OpenClaw.Shared/Mxc/MxcExecutor.cs:171, fc54e2ee07b2)
  • Current main still needs the change: Current main still calls the process-tree killer synchronously and uses parameterless WaitForExit for normal output draining. The merged cancellation fix at fix(mxc): tasklist no longer hangs past sandbox timeout #1151 (fix(mxc): tasklist no longer hangs past sandbox timeout) does not cover these remaining paths. (src/OpenClaw.Shared/Mxc/MxcExecutor.cs:191, 734763131c8d)
  • Latest release check: The supplied latest release, v2026.7.1-4, also retains synchronous termination and unbounded normal-exit draining. (src/OpenClaw.Shared/Mxc/MxcExecutor.cs:191, c7c6fb06be03)
  • Current-head validation and proof limitation: The captured body, sourceRevision a950e155666baf9eb747a0d779562e26a6c874ecf6173e080910fbf403a26c02, reports build success, 3,998 Shared tests, 2,865 Tray tests, and 10 executor tests passing. Its non-skipping MXC attempt failed with WSL E_ACCESSDENIED before Gateway-to-node execution. These are contributor-reported results; this read-only review ran no builds or tests. (fc54e2ee07b2)
  • Required proof is independently specified: The validation script requires reported passing real Gateway execution and containment proofs and rejects skips by default; ordinary CI or process fixtures cannot substitute for this declared pool. (scripts/validate-mxc-e2e.ps1:105, fc54e2ee07b2)

Likely related people:

  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Barbara Kudiess: 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.

  • After the owner resumes work, attach passing current-head windows-wsl-mxc output without -AllowSkip, redact private information, and update the PR body for automatic re-review; if needed, ask a maintainer to comment @clawsweeper re-review.

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 (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-10T23:14:21.594Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-10T23:23:14.999Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-10T23:32:36.631Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-10T23:38:32.986Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-11T00:02:59.129Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-11T00:08:38.538Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-11T00:19:38.707Z sha fc54e2e :: blocked before merge. :: none
  • reviewed 2026-09-11T00:27:48.094Z sha fc54e2e :: blocked before merge. :: none

Use a silent inherited-handle child so exact pipe-buffer output assertions cannot be polluted by scheduler-dependent descendant writes.

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

Copilot-Session: 1c0274bb-f65e-4900-be1b-1303a10fdec5
@shanselman

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-reviewnnThe current head fc54e2ee replaces the exact-output fixture child with a silent inherited-handle holder. Current-head build, Shared, Tray, focused MXC, executor, and exact-output validation are recorded in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper assist is taking a look at your question.

I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes.

Request: re-reviewnnThe current head fc54e2ee replaces the exact-output fixture child with a silent inherited-handle holder. Current-head build, Shared, Tray, focused MXC, executor, and exact-output validation are recorded in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026

Copy link
Copy Markdown

ClawSweeper assist: fc54e2ee appears to address the previous fixture finding, but confirming correctness requires a full re-review. Required MXC integration proof remains blocked.

Evidence:

  • The previous review covered 1c764ac8 and requested a silent retained-handle child. The supplied patch adds hold-silent.
  • The current PR body reports passing build, Shared, Tray, focused MXC, executor, and exact-output validation for fc54e2ee.
  • That body also records non-skipping integration validation failing during WSL setup with MountDisk/E_ACCESSDENIED, before Gateway-to-Windows-node MXC behavior executes.

Suggested next action: Request @clawsweeper review for the current head; passing windows-wsl-mxc proof on a capable host is still required.


Source: #1387 (comment)
Assist reasoning: medium.

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 10, 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.

Re-review progress:

@shanselman shanselman added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@shanselman shanselman added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@shanselman shanselman added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@shanselman shanselman removed the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Sep 10, 2026
@shanselman shanselman added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 10, 2026
@clawsweeper clawsweeper Bot added 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

Automation disclosure: This comment was generated and posted by GitHub Copilot using Scott Hanselman's authenticated GitHub account, acting on his behalf.

@clawsweeper stop

This PR is intentionally frozen until a capable windows-wsl-mxc host can run ./scripts/validate-mxc-e2e.ps1 without -AllowSkip. Please stop automated review/status churn until new proof is posted.

@shanselman shanselman added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🦞✅
Got it. ClawSweeper will leave this item for human review.

I added clawsweeper:human-review and paused the automation trail until a maintainer asks again.

@clawsweeper clawsweeper Bot added clawsweeper:human-review ClawSweeper automerge is paused for maintainer review rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@shanselman shanselman added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@shanselman shanselman added the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 10, 2026
@clawsweeper clawsweeper Bot removed the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@shanselman shanselman added the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@clawsweeper clawsweeper Bot removed the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@shanselman shanselman added the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@clawsweeper clawsweeper Bot removed the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@shanselman shanselman added the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@clawsweeper clawsweeper Bot removed the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Sep 11, 2026
@shanselman
shanselman marked this pull request as ready for review September 11, 2026 19:11
@shanselman
shanselman merged commit 0e34e20 into main Sep 11, 2026
73 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:human-review ClawSweeper automerge is paused for maintainer review merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant