Repository navigation
refactor(setup): route SetupSteps WSL quoting through WslShellQuoting - #1001
Conversation
Migrate SetupSteps.cs off three divergent private ShellEscape helpers onto
the shared WslShellQuoting contract (added in PR 2), then delete the
duplicates. Behavior-preserving: generated scripts are byte-identical.
- InstallCliStep (escape-only, caller supplies its own outer quotes) ->
WslShellQuoting.EscapePosixSingleQuoteInner.
- ConfigureGatewayStep + WindowsNodeBootstrapContextStep (standalone
fully-wrapped tokens) -> WslShellQuoting.QuotePosixSingleQuote.
- Delete all three private ShellEscape methods.
WslShellQuoting stays internal, reachable via the existing
InternalsVisibleTo("OpenClaw.SetupEngine").
Add characterization tests pinning generated command/script output for
embedded-quote inputs, and a source-shape ledger guard
(setup-shellescape-closed) that fails CI if a local ShellEscape reappears
in SetupSteps.cs.
Co-authored-by: Copilot App <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed July 16, 2026, 3:48 PM ET / 19:48 UTC. Summary Reproducibility: not applicable. This PR is presented as a behavior-preserving refactor rather than a report of failing current-main behavior. Review metrics: 3 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep the centralized quoting implementation and architecture guard, then attach redacted current-head terminal proof from representative real WSL setup paths using values containing embedded single quotes. Do we have a high-confidence way to reproduce the issue? Not applicable; this PR is presented as a behavior-preserving refactor rather than a report of failing current-main behavior. Is this the best way to solve the issue? Yes, using the shared contract with separate inner-escape and fully wrapped operations is the narrowest maintainable solution; only the required real setup proof remains outstanding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e0afbc425fb7. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
Preserve the finalized WSL quoting ownership rows from openclaw#1001 and append the WSL distro install-path policy row. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f19f98b7-f377-4da5-a7ce-0f1ae34153cf
Summary
Migrates
SetupSteps.csoff three divergent privateShellEscapehelpers onto the sharedWslShellQuotingcontract (added in PR 2, #994), then deletes the duplicates. This is a net-negative dedup and is behavior-preserving — the generated WSL scripts are byte-identical.The three deleted helpers had two different wrap semantics; each call site was audited individually and mapped by the semantics of the helper it used:
ShellEscapesemanticsInstallCliStep'...')BuildInstallCommand: installUrl, trimmedVersionWslShellQuoting.EscapePosixSingleQuoteInnerConfigureGatewayStepWslShellQuoting.QuotePosixSingleQuoteWindowsNodeBootstrapContextStepRunOpenclawSetupAsyncworkspaceArg;BuildApplyScript/BuildRollbackScriptbash-assignment linesWslShellQuoting.QuotePosixSingleQuoteThe dangerous inversion — a wrapped variant where the caller already supplies
'...'(yielding''x''), or an escape-only variant on a standalone token (yielding an unquoted/splittable arg) — does not occur: only the two escape-only sites have caller-supplied outer quotes.WslShellQuotingstaysinternal; it is reachable fromOpenClaw.SetupEnginevia the existingInternalsVisibleTo("OpenClaw.SetupEngine")inOpenClaw.Shared.csproj. Making itpublicwould needlessly widen the Shared surface, so it was left internal per existing repo convention.Validation
./build.ps1— all projects succeeded.dotnet test tests/OpenClaw.Shared.Tests— 2864 passed / 31 skipped (WSL/device integration skips).dotnet test tests/OpenClaw.Tray.Tests— 1717 passed.dotnet test tests/OpenClaw.SetupEngine.Tests— 426 passed.system.run/MXC; no migrated site feedssystem.run/exec, andRunOpenclawSetupAsync/ apply / rollback still deliver scripts viainputViaStdin: true, so no MXC/exec-approval surface is touched.Real behavior proof
Characterization tests pin the generated command/script strings byte-for-byte for representative inputs containing an embedded single quote, proving the migration is output-identical:
curl … '…install'\''s.sh' … --version '2026.5.22'\''a'—InstallCli_BuildInstallCommand_EscapesSingleQuotesInUrlAndVersion(pre-existing, escape-only variant).openclaw config set gateway.custom.note 'a'\''b'—ConfigureGateway_QuotesExtraConfigValueWithEmbeddedSingleQuote(new).workspace='/home/o'\''brien/.openclaw/workspace'—WindowsNodeContext_BuildApplyScript_QuotesWorkspacePathWithEmbeddedSingleQuoteand…RollbackScript…(new).Architecture ledger
wsl-posix-quoting: residue cleared, invariant/retirement updated to reflect the migration is complete.setup-shellescape-closedrow (closed,source-shape) guarded bySetupStepsShellEscapeClosureTests.SetupSteps_DoesNotReintroduce_PrivateShellEscape— fails CI if a localShellEscapereappears inSetupSteps.cs(the behavioralWslShellQuotingTestscan't catch a re-added local helper).SetupSteps.cs" extraction guidance.ArchitectureLedgerConsistencyTestsremains green.Reviews (adversarial, multi-model) — GO
$$"""..."""raw-string interpolation, and a correct/false-positive-free ledger guard regex. Gemini additionally injected a fake helper to prove the guard fires.tests/OpenClaw.Shared.Tests/Architecture/SetupStepsShellEscapeClosureTests.csmust ship with the PR so the ledger doesn't reference an absent guard — it is included in this PR.Co-authored-by: Copilot App [email protected]