Skip to content

Preserve normal setup command output drains - #1361

Merged
shanselman merged 3 commits into
mainfrom
pr/1343
Sep 8, 2026
Merged

shanselman merged 3 commits into
mainfrom
pr/1343

Conversation

@shanselman

@shanselman shanselman commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Supersedes #1343 (fix(setup): preserve normal command output drains), fixes #1194 (Preserve trailing command output while bounding inherited-pipe waits), and preserves @karkarl's focused design on current main.

  • wait for both redirected streams to reach EOF after normal successful command exits so trailing JSON and success markers are not truncated
  • preserve caller cancellation while waiting for normal stream closure
  • keep bounded output draining for timeout cleanup
  • add a source-compatible default-interface escape method for known inherited-pipe inspections without changing the existing public RunAsync signature
  • opt current wsl.exe --list, --version, and --status inspection calls into the bounded three-second escape
  • include the newer Windows-node bootstrap uninstall inspection that did not exist on the contributor branch
  • retain full EOF draining for RunInWslAsync, installation, pairing, gateway commands, and destructive WSL operations
  • preserve the current deterministic WSL UTF-8 output handling
  • use the shared process test host for deterministic inherited-pipe regression coverage instead of relying on cmd.exe start /b timing

Required proof pools

  • windows-wsl-gateway-e2e: selected because setup WSL inspection and command-output behavior changed. Current-head workflow run 34180664096 passed Setup and connect E2E, network recovery E2E, and revocation recovery E2E.

Validation

Current head: 29686d14.

  • .\build.ps1: passed
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,943 passed, 32 skipped
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,861 passed
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: 1,099 passed
  • deterministic inherited-pipe regression: 10 consecutive focused runs passed locally
  • current-head CI run 34180664096: Core and CLI, Tray/setup/integration, UI/functional/accessibility, Setup and connect E2E, network recovery E2E, revocation recovery E2E, x64 publish, release metadata, proof contracts, and CI Gate passed
  • final structured autoreview: clean, no accepted/actionable findings
  • final rubber-duck review: no blockers after replacing the shell-timing fixture and widening the integration threshold while retaining exact unit coverage for the three-second cap

Real behavior proof

  • 8,000 stdout lines and 8,000 stderr lines plus final STDOUT_MARKER and STDERR_MARKER are captured completely
  • normal output draining continues past the old command deadline until EOF
  • caller cancellation interrupts normal post-exit draining
  • the deterministic shared test host launches a descendant that holds inherited stdout/stderr handles for 30 seconds; the opted-in runner returns while that descendant is still alive and cleanup terminates it afterward
  • exact three-second bounded-drain behavior is covered by deterministic unit tests, while the process integration test proves return well before the 30-second descendant exits
  • ten real current-head CommandRunner.RunInWslAsync executions against Ubuntu via wsl.exe -d Ubuntu -- bash -s each captured 2,000 stdout lines plus trailing stdout/stderr markers and completed without a pipe hang; warmed runs completed in roughly 0.2 to 0.35 seconds
  • current-head hosted Setup and connect E2E passed in run 34180664096

Not verified / blocked: none for the changed behavior.

Ownership notes

  • old owner: CommandRunner.RunAsync universally capped every successful output drain
  • new owner: normal RunAsync waits for EOF; RunAsyncAllowingInheritedPipeHandleEscape explicitly identifies known WSL inspection callers
  • preserved invariant: the original public ICommandRunner.RunAsync and CommandRunner.RunAsync signatures remain unchanged for source and binary compatibility

Security impact

No credential, permission, or command-policy changes. The change only controls post-exit output draining and cancellation.

Co-authored-by: Karen Lai <[email protected]>

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

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
@clawsweeper

clawsweeper Bot commented Sep 7, 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: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 7, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

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

@clawsweeper clawsweeper Bot added 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. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed September 7, 2026, 10:40 PM ET / September 8, 2026, 02:40 UTC.

ClawSweeper review

What this changes

Preserves trailing setup-command output by waiting for stream closure, while retaining bounded waits for explicit WSL inspections and timeout cleanup.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful fix absent from current main, with no actionable patch findings. The previously identified setup/connect proof requirement remains unresolved in the available snapshot, and the collaborator-authored PR remains draft.

Priority: P2
Reviewed head: 29686d144164d67603cc548d56a6d99fb5845dc1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, compatible repair with meaningful runtime evidence and no actionable findings; the declared product-path validation still needs a recorded result.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Recorded real Ubuntu executions exercised RunInWslAsync and captured trailing markers without hangs; the production runner is byte-identical at the recorded proof revision and current head. Preserve that focused proof, while keeping the separately declared setup/connect pool unresolved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded real Ubuntu executions exercised RunInWslAsync and captured trailing markers without hangs; the production runner is byte-identical at the recorded proof revision and current head. Preserve that focused proof, while keeping the separately declared setup/connect pool unresolved.
Evidence reviewed 9 items Repository policy: Read the complete root AGENTS.md and the required proof-validation skill. No applicable nested AGENTS.md or maintainer-notes directory was found. Applied setup proof requirements without executing builds, tests, or additional reviewers.
Current main still has the reported mechanism: Current main universally races stream closure against a capped delay. The PR instead waits for EOF on ordinary exits and preserves the cap for explicitly selected inspections and timeout cleanup.
Production behavior and compatibility: The original RunAsync signatures remain intact; the new interface method has a default implementation. RunInWslAsync continues through ordinary RunAsync. Timeout killing, UTF-8 handling, output limits, command arguments, and credentials are unchanged.
Findings None None.
Security None None.

How this fits together

The setup engine runs Windows processes and WSL commands during installation, configuration, and pairing. Their captured output feeds JSON parsing, success-marker checks, and setup decisions.

flowchart TD
  A[Setup steps] --> B[Windows or WSL command]
  B --> C[Capture stdout and stderr]
  C --> D{Drain policy}
  D -->|Normal exit| E[Wait for stream closure or cancellation]
  D -->|Inspection or timeout| F[Bounded drain]
  E --> G[Command result and setup decisions]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The available snapshot does not establish completion of the declared current-head setup/connect pool; focused Ubuntu output runs do not establish the full installation and pairing outcome.
  • Complete next step (P2) - Record the completed current-head setup/connect proof-pool result, refresh the stale validation section, and have the owner mark the draft ready before landing.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +138/-33; tests and test configuration +145/-9 Production growth preserves existing signatures and makes the exceptional drain policy explicit at WSL inspection callers.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1194
Summary: This PR is the active candidate for the reported output-drain defect.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep complete output draining as the normal policy, retain explicit bounded inspections, and establish the declared setup/connect result before landing.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep complete output draining as the normal policy, retain explicit bounded inspections, and establish the declared setup/connect result before landing.

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

Yes, at source level: current main can return when its drain delay wins before stdout/stderr callbacks finish. This review did not execute a failing reproduction.

Is this the best way to solve the issue?

Yes. An explicit inspection escape preserves complete ordinary command output without changing existing call signatures or broadening command policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6d1056270082.

Labels

Label justifications:

  • P2: This is a focused setup reliability repair; the snapshot establishes no urgent user-facing regression caused by the patch.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded real Ubuntu executions exercised RunInWslAsync and captured trailing markers without hangs; the production runner is byte-identical at the recorded proof revision and current head. Preserve that focused proof, while keeping the separately declared setup/connect pool unresolved.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded real Ubuntu executions exercised RunInWslAsync and captured trailing markers without hangs; the production runner is byte-identical at the recorded proof revision and current head. Preserve that focused proof, while keeping the separately declared setup/connect pool unresolved.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md and the required proof-validation skill. No applicable nested AGENTS.md or maintainer-notes directory was found. Applied setup proof requirements without executing builds, tests, or additional reviewers. (AGENTS.md:75, 29686d144164)
  • Current main still has the reported mechanism: Current main universally races stream closure against a capped delay. The PR instead waits for EOF on ordinary exits and preserves the cap for explicitly selected inspections and timeout cleanup. (src/OpenClaw.SetupEngine/CommandRunner.cs:213, 6d1056270082)
  • Production behavior and compatibility: The original RunAsync signatures remain intact; the new interface method has a default implementation. RunInWslAsync continues through ordinary RunAsync. Timeout killing, UTF-8 handling, output limits, command arguments, and credentials are unchanged. (src/OpenClaw.SetupEngine/CommandRunner.cs:308, 29686d144164)
  • Proof continuity: The captured body identifies b4db08d and reports ten real Ubuntu RunInWslAsync executions, each capturing 2,000 stdout lines and trailing markers without hanging. CommandRunner has identical blob 08950e28af686a41f056ec27b7e334041ee07bb4 at that revision, the previous reviewed head, and the current head. This preserves the focused behavioral evidence without relabeling it as a new current-head execution. (src/OpenClaw.SetupEngine/CommandRunner.cs, 29686d144164)
  • Required proof pool remains distinct: The declared windows-wsl-gateway-e2e pool requires setup, bootstrap, pairing, and invocation evidence with nonzero test counts and redacted results. Captured current-head checks show Setup and connect E2E in progress. The previous review requested its completed result. The merged installer repair at fix(setup): securely bound CLI installer retries #1297 removes the previously cited dependency blocker, but its run does not establish this PR's pool result. (.github/proof-pools.json:342, 29686d144164)
  • Focused regression coverage: Inspected high-volume stdout/stderr marker coverage, cancellation during post-exit draining, waiting beyond the old deadline, and the shared process fixture that leaves a live descendant holding inherited handles. The added project reference uses an existing repository test host and introduces no external dependency. (tests/OpenClaw.SetupEngine.Tests/CommandRunnerTests.cs:140, 29686d144164)

Likely related people:

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

  • Record the completed current-head setup/connect pool result with nonzero test counts and redacted evidence.

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-09-07T22:27:30.767Z sha b4db08d :: blocked before merge. :: none
  • reviewed 2026-09-07T22:31:36.966Z sha b4db08d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T22:44:00.719Z sha b4db08d :: blocked before merge. :: none
  • reviewed 2026-09-08T01:11:27.941Z sha 756ed24 :: blocked before merge. :: none

@shanselman

Copy link
Copy Markdown
Collaborator Author

Current head b4db08d is review-clean. ClawSweeper reports no actionable findings and accepts the current-head live WSL output proof. Local build and all required suites pass. Hosted setup/connect E2E is blocked only by the recurring external OpenClaw CLI installer failure, so this draft is paused pending #1297 (fix(setup): securely bound CLI installer retries).

@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 7, 2026
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 8, 2026
Use the shared process test host instead of cmd.exe start so the inherited-output-handle regression measures the bounded drain rather than shell startup behavior.

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

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
@shanselman
shanselman marked this pull request as ready for review September 8, 2026 02:58
@shanselman
shanselman merged commit f9bfc87 into main Sep 8, 2026
20 of 21 checks passed
@shanselman
shanselman deleted the pr/1343 branch September 8, 2026 02:58
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 8, 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.

Preserve trailing command output while bounding inherited-pipe waits

1 participant