Repository navigation
fix(openshell): remote workspace is never seeded when the gateway restarts before first exec - #129809
Conversation
…tarts between sandbox create and first exec The remote-mode seed obligation lived only in process memory (remoteSeedPending), so a gateway restart between sandbox create and the first exec adopted the sandbox via 'sandbox get' and silently skipped the one-time seed, leaving an empty remote-canonical workspace with no visible failure. Adopted remote sandboxes now probe the managed roots once per process at the ensure boundary and arm the seed only when every root is missing or empty, so recovery can never wipe operator content in an already-seeded workspace (the seed guard shipped in v2026.7.1, so legacy seeded sandboxes without any marker exist). The probe also heals a create that timed out client-side after the sandbox actually came up. Regression test simulates create -> restart -> first exec and fails pre-fix; a sibling test locks the never-reseed-non-empty-roots invariant.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:18 PM ET / August 26, 2026, 03:18 UTC. ClawSweeper reviewWhat this changesThe PR makes OpenShell remote-mode adoption probe its managed workspace roots so an empty sandbox is seeded after a Gateway restart before first use. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. Current main still returns immediately after adopting an existing OpenShell sandbox, while this focused lifecycle-owner patch restores the missing seed path and preserves non-empty remote workspaces; the protected maintainer PR needs normal exact-head validation. Priority: P1 Review scores
Verification
How this fits togetherOpenShell is a bundled sandbox plugin used by the Gateway for remote agent workspaces. The backend adopts or creates a sandbox, prepares its workspace, then hands execution and filesystem operations to the agent runtime. flowchart LR
A[Gateway restart] --> B[OpenShell backend]
B --> C[Adopt remote sandbox]
C --> D[Probe managed workspace roots]
D --> E{All roots empty?}
E -->|Yes| F[Seed remote workspace]
E -->|No| G[Preserve remote workspace]
F --> H[Agent exec and file tools]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +152, Docs +2. Total +180 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the adoption-boundary probe and its non-destructive regression coverage, then confirm the restart path on the exact head with the existing OpenShell E2E environment. Do we have a high-confidence way to reproduce the issue? Yes, by source: a successful adopted-sandbox lookup leaves the old in-memory seed flag false, so first use skips the canonical seed flow. The added regression models that path, though it was not executed in this read-only review. Is this the best way to solve the issue? Yes. The repair records the missing lifecycle fact where adoption occurs and delegates to the existing canonical seed operation; a downstream exec-only workaround would leave other remote operations inconsistent. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6b02b00e23fa. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Addressing the ClawSweeper "Before merge" items:
|
|
Merged via squash.
|
…tarts between sandbox create and first exec (openclaw#129809) The remote-mode seed obligation lived only in process memory (remoteSeedPending), so a gateway restart between sandbox create and the first exec adopted the sandbox via 'sandbox get' and silently skipped the one-time seed, leaving an empty remote-canonical workspace with no visible failure. Adopted remote sandboxes now probe the managed roots once per process at the ensure boundary and arm the seed only when every root is missing or empty, so recovery can never wipe operator content in an already-seeded workspace (the seed guard shipped in v2026.7.1, so legacy seeded sandboxes without any marker exist). The probe also heals a create that timed out client-side after the sandbox actually came up. Regression test simulates create -> restart -> first exec and fails pre-fix; a sibling test locks the never-reseed-non-empty-roots invariant.
What Problem This Solves
Fixes an issue where operators using the OpenShell sandbox backend in
mode: "remote"would end up with a silently empty remote-canonical workspace when the Gateway restarted (crash, deploy, host reboot) betweensandbox createand the first exec. The one-time seed obligation lived only in process memory (remoteSeedPending): the next process'ssandbox getsucceeded, the flag was false, and the seed never ran — the agent then operated in an unseeded workspace with no visible failure.Why This Change Was Made
The seed obligation must survive restarts, so adopted remote sandboxes now probe the managed roots (
remoteWorkspaceDir,remoteAgentWorkspaceDir) once per process at the ensure boundary — the same self-healing pattern the generic SSH backend uses. The probe arms the seed only when every managed root is missing or empty, so the wipe step of seeding is provably a no-op and recovery can never destroy operator content: the seed guard shipped in stable v2026.7.1, so legacy seeded sandboxes with no marker exist in production, and/sandbox//agentare OpenShell-managed roots that may pre-exist — a plain existence probe or marker-absence check would risk wiping remote-canonical data. Ambiguous probe output fails toward "seeded". The probe also heals a sibling hole: asandbox createthat times out client-side after the sandbox actually came up was previously adopted unseeded with no restart involved.Accepted tradeoffs (noted in code comments): an operator who deliberately empties both managed roots gets re-seeded from local after a restart (nothing is destroyed), and a mid-seed crash that left partial content is treated as seeded — the same weakness the SSH backend has. Mirror mode is untouched (it syncs every exec).
User Impact
Remote-mode OpenShell sandboxes now reliably get their one-time workspace seed even when the Gateway restarts before the first exec, eliminating a silent-failure class. Already-seeded workspaces are never re-seeded or wiped. Docs updated to state the recovery behavior.
Evidence
extensions/openshell/src/backend.remote-seed.test.tssimulates create → process restart → first exec (fresh backend,sandbox getsucceeds, probe reports empty roots) and asserts the seed upload runs. Verified it fails on pre-fix code for exactly that reason (no seed upload) by running it against the HEAD version ofbackend.ts.rm -rf) commands.check-changed,tsgo:extensions, andtsgo:extensions:testall pass.gpt-5.6-sol, high reasoning) on the exact diff: clean, no accepted/actionable findings.OPENCLAW_E2E_OPENSHELL=1e2e lane covers the real CLI path where one exists.Production LOC: +26/-0 in
backend.ts(~16 non-comment) | Tests: +155 | Docs: +6/-4. Growth is the new restart-surviving probe at the lifecycle owner; no existing structure could absorb it.