Repository navigation
fix(process): preserve arguments through Windows batch wrappers - #133185
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 4:53 AM ET / 08:53 UTC. ClawSweeper reviewWhat this changesThe PR changes Windows batch-wrapper serialization so permitted arguments such as empty strings, tabs, carets, quotes, and trailing backslashes reach child programs unchanged in command runners and terminal PTYs. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer handling: this active maintainer PR repairs a reproduced Windows argument-corruption bug, has exact-head native after-proof, and no concrete patch defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s process layer launches local tools from argument arrays. On Windows, batch wrappers go through cmd.exe before reaching the child program, including interactive terminal PTYs. flowchart LR
A[Tool arguments] --> B[Process launcher]
B --> C[Batch wrapper detection]
C --> D[Windows command serialization]
D --> E[cmd.exe or terminal PTY]
E --> F[Batch wrapper]
F --> G[Child program arguments]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +107. Total +107 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the centralized guarded serializer and the string-tail PTY handoff, then land after exact-head CI is green; keep the acknowledged unchanged direct node-pty tab-only behavior as a separate dependency-owner follow-up. Do we have a high-confidence way to reproduce the issue? Yes. The linked native Windows before run recorded seven failures in the real .cmd-to-Node path, and the exact-head after run reports those batch and PTY matrices passing. Is this the best way to solve the issue? Yes. The repair belongs in the shared batch serialization owner used by command runners and known batch-wrapper callers, rather than adding caller-specific escaping or fallbacks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 039187abe405. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
|
Native Windows reproduction confirmed at d210305 in Windows test-2. The real Ordinary arguments, spaces, embedded quotes, and all seven prohibited-character rejection controls passed. The process test shard reported 7 failed, 71 passed, and 1 skipped; the reproduction cases themselves were 7 failed and 10 passed. The shared serializer repair is in progress. This is before-proof only: no native passing repair or merge readiness is claimed yet. Production's existing prohibited-character policy will stay unchanged. |
|
Native Windows after proof passed on The latest ClawSweeper rank-up request is addressed by the shared serializer repair and this exact-head result. Production remains +23/-23, net 0. Final required CI is still pending, so no landing is claimed yet. The earlier expanded direct-executable matrix also revealed an existing pinned node-pty defect: a single tab argument disappears in its unchanged array serializer. That exact failing evidence remains in the earlier job and is preserved for the separately owned node-pty single-character whitespace argument loss dependency repair proposal. This PR does not patch that dependency, add an xfail/skip, or claim the full direct matrix passes. Its ordinary direct control verifies literal arguments, including shell metacharacters that must stay allowed; the full batch matrix is unchanged. |
|
Land-ready evidence for The shared guarded batch serializer now quotes every token and handles backslash runs once under the cmd/CRT contract. Its PTY caller uses node-pty's documented preescaped string seam; native executable and extracted npm entrypoint arrays remain unchanged. The old one-use escape helper, conditional outer quoting, and redundant COMSPEC forwarding are removed. Production +23/-23, net 0; tests +119/-12. Native before showed seven argument-corruption failures. Final-head native Windows proof passed all 53 added cases, including three real batch PTY matrices and the ordinary direct-executable control. The runner used PR merge ref The complete local eight-file changed gate passed. Scoped P0 autoreview and independent source/dependency/native-evidence review found no remaining actionable issue in this repair. The latest ClawSweeper rank-up request—owner repair plus passing exact-head native proof—is addressed. The unchanged direct node-pty single-whitespace defect remains a separately owned dependency proposal, with its failing native evidence preserved. This PR neither patches that dependency nor claims the full direct matrix passes; no xfail/skip was added. Final-head CI is green. Native review artifacts are validated; proceeding through the repository prepare/merge flow. |
|
Merged via squash.
|
…claw#133185) * test(process): reproduce Windows batch argument loss * test(process): route batch argv probe through Windows CI * fix(process): preserve arguments through Windows batch wrappers * test(process): avoid spread when expanding Windows argv cases * test(process): align caller coverage with batch quoting contract
What Problem This Solves
Windows batch wrappers silently lose empty arguments, split tabs, remove carets, and merge an argument ending in a quoted backslash with the next argument. The child can exit successfully while receiving different input. A native Windows reproduction confirmed seven failures before this repair; ordinary arguments, spaces, quotes, and all seven unsafe-character rejection controls passed.
Why This Change Was Made
buildWindowsCmdExeCommandLineowns the guarded batch serialization shared by process runners, supervisor fallback, Gmail watcher, TUI local authentication, and terminal PTYs. It previously quoted only spaces and double quotes, escaped carets outside the protected quote context, and omitted the CRT backslash rules.The serializer now quotes every token and consumes each backslash run once before doubling embedded quotes. This preserves empty strings, tabs, carets, and trailing backslashes without a quadratic regex scan. The existing rejection of
&,|,<,>,%, CR, and LF is unchanged. The single-use escape helper and conditional outer-quote path are removed.Terminal PTYs pass the finished cmd argument tail through node-pty's documented preescaped string API, preventing a second layer of quote escaping. Direct executable and extracted npm Node entrypoint paths retain argument arrays. Redundant COMSPEC parameter forwarding is removed; its lookup and fallback semantics are unchanged.
User Impact
Allowed arguments retain their exact values through Windows batch wrappers. No dependencies, configuration, environment options, permissions, or shell fallback policy change.
Evidence
d2103056a350d438233c094fc2ca0888f9ea3430: seven intended argument failures and ten passed controls. Recorded outcomes.af04f67c8821fc93b4c71853ea928cd678bcbd3e: all 42 batch cases, three batch PTY cases, and seven rejection controls passed. The direct executable matrix exposed the separate dependency limitation described below; the overall job failed.Final-head native Windows verification passed: Windows test-2, exact
93f45c768decd3a3946edc3c6e9e591872667a86, passed all 53 added cases: 42 batch invocations, three batch PTY matrices, one ordinary direct-executable PTY control, and seven rejection controls. The process shard passed 114 tests with one unrelated skip; all 14 Windows job shards passed. The complete local eight-filecheck-changedgate also passed. Final-head CI is green. The native landing workflow merged this repair as 1f017332a6528; canonical main ancestry and the two production files were verified after landing.The latest ClawSweeper rank-up move requested the owner repair plus passing exact-head native evidence; both are now supplied.
Named follow-up: node-pty single-character whitespace argument loss. The unchanged direct-executable array path drops a tab-only argument because pinned node-pty quotes whitespace only when the argument has more than one character. The failed direct matrix and exact native log above are preserved as before evidence for a separate dependency-owner repair proposal; no xfail/skip or dependency patch is included here. The direct control now states its actual ordinary-argument scope and verifies that shell metacharacters remain allowed. This PR does not claim that the full direct-executable matrix passes.
Production: +23/-23, net 0. Tests: +119/-12, net +107. The regression existed in the inspected stable release; introduction provenance is unknown. The earlier test-only integration-path CI selection omission is tracked separately and is not changed here.