Repository navigation
fix(openshell): preserve file writes during concurrent mirror commands - #130447
Conversation
Lease complete mirror file operations through the workspace owner instead of locking only remote transport. Preserve successful writes across exec publication and share serialization across backend handles. Proven with a real Docker red/green reproduction, 128-workflow mirror/remote stress matrix, exact inventories, failure recovery, 170 focused tests, and updated operator docs. Related: #127441; follow-up to #130031.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 6:36 PM ET / 22:36 UTC. ClawSweeper reviewWhat this changesThe PR serializes complete OpenShell mirror file-bridge operations with command workspace publication so concurrent commands cannot erase successful file writes. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: current main still permits the reported lost-write interleaving, while this branch moves the lease to the lifecycle owner that spans local mutation and remote synchronization. No blocking patch defect found; this active maintainer-labeled PR needs normal exact-head landing gates. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherOpenShell mirror mode keeps a local workspace synchronized with a remote sandbox. Commands upload and later publish that workspace, while file tools mutate and synchronize individual paths; both flows must share one workspace lifecycle. flowchart LR
A[Agent command or file tool] --> B[OpenShell mirror backend]
B --> C[Shared workspace lease]
C --> D[Local file operation]
C --> E[Remote sandbox synchronization]
E --> F[Published mirror workspace]
D --> G[Consistent local and remote files]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +265, Tests +34, Docs +6. Total +305 across 9 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one lease at the mirror lifecycle owner across local validation or mutation and remote synchronization; no net-neutral alternative can preserve that atomic operation boundary without reintroducing transport-only locking. Do we have a high-confidence way to reproduce the issue? Yes: current main writes the host path before acquiring the transport-only synchronization lease, and the branch’s E2E test recreates that prepared-exec/file-write order. This review did not execute the Docker lane because the checkout is read-only. Is this the best way to solve the issue? Yes: the lease must begin before the host operation, not only for remote transport; private callbacks avoid nested locks while preserving the existing shared workspace queue. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d27b0e96204a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Pre-land proof for
CI recovery note: the initial PR CI attachment was delayed. The native manual fallback run33018360581 exercised the broad matrix but encountered repeated runner shutdowns during core lint and an Android dependency-resolution failure. It was stopped as redundant only after the successful normal PR run on the same SHA was verified; those fallback attempts are not being represented as passing runs. Maintainer-tooling follow-up, separate from this repair: the PR-event watcher currently selects only The repair keeps one process-local workspace ownership path; no SDK/config/protocol/storage change. Docs describe the lock boundary and external-editor limitation. Disposable Docker resources and test credentials were removed. No packaged-release, full model-agent conversation, or soak-test claim is made. |
|
Merged via squash.
|
* origin/main: (26 commits) fix(plugins): preserve registry epoch on activation rollback (#129232) refactor(plugins): make discovery invocation-owned (#130486) feat(ui): save appearance preferences per user profile (#130340) fix: Buzz bots recover relay stalls and reject revoked senders (#130467) fix(code-mode): serialize catalog handles nested in final values (#130276) fix(webchat): CLI skill and harness-injected turns render as operator-sent messages (#130427) fix(agents): read the published model catalog owner from session_status (#130277) fix(channels): preserve long presentation text (#130368) fix(agents): route CLI bootstrap truncation notice into the system prompt (#130325) refactor(plugins): unify setup registration and artifact selection (#130474) fix(memory): prevent forgotten session content from returning (#130451) refactor(outbound): consolidate transport completion (#130460) fix(workers): protect in-flight workspace manifests from concurrent retention (#130449) fix(portals): keep worker previews reachable and owned by the active environment (#130434) fix(config): keep core channels keys in the generated config schema (#120736) chore(deps): refresh dependencies after seven-day cooldown (#130296) fix(agents): remind exec models to quote shell metacharacters (#125485) fix(auth): honor shared-store ownership in temp-state exec and agent deletion (#130437) fix(openshell): preserve file writes during concurrent mirror commands (#130447) fix(workers): report full nodes as at capacity, not offline (#130445) ...
openclaw#130447) Lease complete mirror file operations through the workspace owner instead of locking only remote transport. Preserve successful writes across exec publication and share serialization across backend handles. Proven with a real Docker red/green reproduction, 128-workflow mirror/remote stress matrix, exact inventories, failure recovery, 170 focused tests, and updated operator docs. Related: openclaw#127441; follow-up to openclaw#130031.
Related: #127441 (parallel OpenShell mirror races), follow-up to #130031 (OpenShell execution and workspace integrity).
What Problem This Solves
Fixes an issue where users writing a file through an OpenShell mirror sandbox could receive success but lose the file when a concurrent command published its downloaded workspace. This was reproduced against the earlier integration repair using a real Docker-hosted OpenShell gateway.
Why This Change Was Made
The backend now holds the existing workspace lease across the complete mirror file operation: validation, host read/mutation, and remote synchronization. Previously only the remote transport step acquired it, allowing command publication to overwrite an already-successful host write. Seven file-bridge operations now share the exec lifecycle owner; four transport-only wrappers are removed, with narrow private callbacks avoiding nested locks.
Remote-canonical mode keeps its existing remote-shell bridge. No public SDK, config, protocol, dependency, or persistence contract changes. This is the owner-boundary repair; retrying uploads or guarding missing files downstream would conceal the lost write rather than prevent it.
User Impact
Concurrent commands and file tools sharing a mirror workspace no longer erase successful file writes through this race. Independent backend handles share the same process-local workspace lock, while unrelated workspaces remain independent. Documentation clarifies that external editors and separate Gateway processes are outside this lock.
Release-note context: fix silent file loss during overlapping OpenShell mirror command/file-tool operations.
Evidence
AI-assisted with Codex; source, caller/sibling boundaries, and observed behavior reviewed.
ENOENTdespite a successful write. After: correct file contents locally and in the sandbox. The regression is retained in the live E2E lane.scripts/pr ci-dispatchduring the initial PR CI attachment delay.Commands:
The live command used the existing CLI/config override variables for the disposable gateway and GNU coreutils on macOS. A full baseline build passed before source-backed repetitions. This is real gateway/SSH/container/filesystem proof, not a packaged-release, full-model-agent, remote-VM, or long-duration soak claim.
Earlier exploratory runs hit a no-output watchdog or the combined-case time budget; those are not counted as passes. The final matrix separates the modes under the unchanged 12-minute per-case timeout, drains concurrent work, and reports progress without weakening assertions. The earlier combined changed-file gate found typing/lint issues in the test harness; final targeted reruns passed after correction. Exact-head hosted CI is the landing gate.
Production LOC: +53/-40 (net +13); tests/test support: +431/-145 (net +286); docs: +16/-10. Production growth represents whole-operation ownership for seven methods replacing four insufficient remote-step wrappers. Existing helpers were extracted from the E2E file; no test-only production seam was added.
Provenance: the host-before-upload ordering predates the available shallow history boundary. The transport-only lease in #130031, authored and merged by @steipete on 2026-08-26 (
c69abc232755c9a4f6e78f279cb05b51392df281), carried the gap forward. This follow-up was found by the requested live stress testing; it is not attributed to an unrelated contributor.Maintainer review disposition
ClawSweeper's refreshed exact-head review reports no actionable findings and identifies this as the best owner-boundary repair. Its production-growth item is accepted as justified: the net 13 lines move seven complete file operations under the existing lifecycle owner while removing four insufficient transport-only wrappers. The exact-head CI item is satisfied by the newest green normal PR run above.
The bot's earlier partial live-verification failure was an output matcher looking for an individual test name under the default summarized reporter; its captured logs showed the signal-exit regression passing twice. Its refreshed review now reports PASS with the verbose reporter. The actual Docker integration proof remains the two-mode live matrix documented above, not that small process-helper test.
An explicit reporter rerun also passed, with the exact expected name visible: