Repository navigation
refactor(sandbox): canonicalize backend ownership - #126828
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 4:26 PM ET / 20:26 UTC. ClawSweeper reviewWhat this changesThe PR makes OpenShell return one memoized sandbox backend handle for both filesystem bridge modes and replaces duplicate OpenShell/Codex argv quoting with the existing Plugin SDK command builder. Merge readinessKeep this maintainer-owned PR open: current main still has the split backend wrappers and duplicated quoting helper, while the proposed canonical-handle refactor preserves the existing shared SDK contract with no actionable defect found. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherSandbox factories supply a backend to the agent runtime, which then creates an execution specification and a filesystem bridge from that backend. OpenShell uses SSH-backed remote or mirror workspaces, while the Codex extension routes app-server process requests through the same sandbox backend contract. flowchart LR
A[Sandbox configuration] --> B[OpenShell backend factory]
B --> C[Canonical backend handle]
C --> D[Process execution]
C --> E[Remote or mirror filesystem bridge]
D --> F[SSH-backed sandbox]
E --> F
G[Codex process request] --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource -54, Tests +58, Other 0. Total +4 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the canonical-handle refactor after exact-head CI completes, preserving the single shared Plugin SDK quoting path and the factory-to-bridge identity regression coverage. Do we have a high-confidence way to reproduce the issue? Not applicable; this is a refactor PR, and the stated former split-owner behavior is directly established by current-main source plus focused regression coverage. Is this the best way to solve the issue? Yes; reusing the existing public sandbox command builder and making the factory-returned handle canonical removes duplicate paths without expanding the Plugin SDK. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ddf73d4ca2ef. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
… advance 80) Resolution (13 raw conflicts; 12 ui resolved by fork-ownership policy): - pnpm-lock.yaml: regenerated via pnpm install (derived file). - extensions/openshell/src/openshell-core.test.ts (merge=ours drift): ADOPT-UPSTREAM openclaw#129258 fixture dedup + openclaw#120996 tempWorkspace migration + openclaw#126828 canonical-owner test (fork's makeTempDir shape + missing test were stale freezes of older upstream code, not fork intent). Grafted fork's one genuine delta: required SandboxConfig.osSandbox block into createOpenShellBackendSandboxConfig. - src/agents/cli-runner.reliability.test.ts (merge=ours drift): clean 3-way merge-file. Kept fork tests + upstream openclaw#125085 (codex->agent-cli literals, watchdog resume tuning test; math verified against merged reliability.ts). - src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts: ADOPT-UPSTREAM (preflight tsgo-core=1 catch: upstream consumer openclaw#128970 imports resolveSettledToolBatchEvidence which merge churn had dropped from the fork provider; export surface differs by exactly this extraction; fork toolMetas type carries toolCallId?/terminate?/isError?). - ui/src/ui/markdown.ts: explicit param types on the linkify www plugin callbacks (validate/normalize). @types/markdown-it 14.1.2->14.2.0 (upstream dep bump) dropped contextual typing for them; the fork-owned ui copy now types them inline per linkify-it's Validate/Match signatures (upstream adapted its own ui tree the same way). Only ui file needed it; tsgo:test:ui 3->0 locally. Note: ui tree-hash invariant vs main intentionally broken by this one adaptation — main's ui does not compile against the new lockfile (baseline 0 was measured with @types 14.1.2). No product-collision: no codex/** residuals.
What Problem This Solves
Maintainer-requested sandbox adapter cleanup: OpenShell constructed duplicate backend handle objects, so remote and mirror filesystem bridges could retain a different object from the backend returned by the factory. OpenShell and Codex also duplicated the same existing shell-argument quoting contract.
Why This Change Was Made
The OpenShell implementation now memoizes one canonical backend handle, returns that handle from the factory, and gives the same lifecycle owner to both filesystem bridge modes. OpenShell and the Codex sandbox exec-server reuse the existing
openclaw/plugin-sdk/sandboxcommand builder; remote execution, mirror synchronization, SSH behavior, working-directory validation, and finalization contracts are unchanged. The assertion-safety baseline is ratcheted down solely for the removed assertion.User Impact
No user-visible behavior changes. Existing OpenShell remote/mirror, SSH sandbox, and Codex process/HTTP/lifecycle behavior and public Plugin SDK contracts are preserved. The internal implementation removes duplicate ownership and quoting paths: production +14/-68 (net -54), regression tests +58/-0, and shrink-only baseline maintenance +1/-1.
Evidence
node scripts/run-vitest.mjs extensions/openshell/src/openshell-core.test.ts extensions/openshell/src/backend.exec-workdir.test.ts extensions/openshell/src/backend.e2e.test.ts— 52 passed; 1 live integration intentionally skipped.node scripts/run-vitest.mjs extensions/codex/src/app-server/sandbox-exec-server.test.ts extensions/codex/src/app-server/sandbox-exec-server.lifecycle.test.ts extensions/codex/src/app-server/sandbox-exec-server.http.test.ts— 48 passed.node scripts/run-vitest.mjs src/agents/sandbox/ssh-backend.test.ts src/agents/sandbox/remote-fs-bridge.test.ts src/agents/sandbox/ssh.test.ts— 71 passed.node scripts/check-changed.mjs -- extensions/openshell/src/backend.ts extensions/openshell/src/cli.ts extensions/openshell/src/openshell-core.test.ts extensions/codex/src/app-server/sandbox-exec-server/processes.ts config/assertion-safety-baseline.txt— passed, including 5 plugin-contract tests, assertion-safety ratchets, extension production/test typechecks, lint, boundaries, dead exports, dependency/patch guards, and zero runtime import cycles.git diff --check origin/main...HEAD— passed..agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output— clean; no actionable findings.[email protected]without changing any tracked dependency, manifest, patch, or lockfile. Live proof was intentionally not run because this is an internal, behavior-preserving refactor.