Repository navigation
refactor(gateway): deslop worker environments - #165341
Conversation
Consolidate workspace archive state, teardown completion, manifest admission, inference query ownership, and repeated provider and transport plumbing. Preserve existing worker surfaces, persisted shapes, live-authority fences, and recovery ordering.
Keep every recovery preflight while checking already-absent paths synchronously inside the existing Git worker. The unchanged 25,001-record recovery test timed out on the clean base and passes 21 candidate executions under its existing timeout. Restore the turn-claim authority helper to its original scope after integration.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 1:22 AM ET / 05:22 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR consolidates Gateway worker workspace, placement, inference, and transport plumbing and speeds recovery of already-deleted workspace files. Merge readiness✅ Ready for maintainer review Keep open: the work remains distinct from current main, and no actionable introduced defect was found. The verified repository-admin author also excludes automatic closure. Priority: P2 Review scores
Verification
How this fits togetherGateway worker environments place session work on remote machines and reconcile completed workspace changes back to OpenClaw. Their lifecycle owners coordinate preparation, execution, recovery, and cleanup. flowchart TD
A[Session turn] --> B[Placement admission]
B --> C[Worker environment]
C --> D[Workspace results]
D --> E[Reconciliation and recovery]
E --> F[Accepted workspace]
E --> G[Teardown and cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -508, Tests 0, Other +3. Total -505 across 43 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the consolidated lifecycle owners while preserving exact workspace custody, serialized placement output, and live-authority checks. Do we have a high-confidence way to reproduce the issue? Not applicable to the refactor itself. The reported recovery timeout was not independently reproduced in this read-only review. Is this the best way to solve the issue? Yes: consolidating existing owners removes forwarding plumbing while preserving the inspected contracts, and the metadata optimization remains inside the existing worker boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 49fc679f9f68. LabelsLabel changes: No label changes. Label 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)
|
Simplify distributed worker workspace, teardown, inference, placement, provider, and transport internals while preserving public surfaces, persisted formats, and live authority. Remove 508 net worker-environment production lines (505 net across the PR including the exact worker-inventory update); retain all existing assertions. Use worker-local synchronous metadata checks for already-converged deletions, preserving all recovery passes. Validate with core typechecking, zero import cycles, independent review, 1,294 focused Linux tests, and 21 unchanged large-inventory regression executions on each of macOS and Linux.
What Problem This Solves
Distributed worker hosting carries avoidable callback plumbing, mirrored types, and repeated preparation and cleanup logic across its existing owners.
User Impact
No feature, configuration, persisted schema, wire shape, or tool surface changes. Large converged-deletion recovery avoids per-path threadpool overhead in its existing Git worker. Live placement, epoch, generation, turn-claim, and precommit authority checks remain in place.
Why This Change Was Made
Production changes: 66,484 → 65,976 lines, net −508 (0.764%). The exact worker-only inventory correction adds three tooling lines, so the complete PR removes 505 net lines. Tests/support remain 117,330 lines, with only six added/six removed helper-reference lines. Replacement files are included in those totals.
This is the final below-threshold batch after reading the complete subtree, including every production file over 200 lines. The proposed larger SSH/node workspace consolidation is already implemented: both transports share the manifest program, local reconciliation, and staged apply owners. Remaining branches preserve distinct local/remote capture policy, transport settlement, and crash recovery. The 1,000-line and 20% targets are not claimed achieved.
Evidence
tbx_01m454wg3a6ncrkts9y8hz0g72: verified source treeb91fa3751efcc51659b91c533b818625a4fc37d8from candidate05085ef0ea8daf3b67674b148ee133d085708d65, then ran 88 focused files: 1,294 passed, one existing skip, across two Vitest shards (503.76 seconds). Testbox run.pnpm install --frozen-lockfile;node --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts;node --import ./scripts/tsx.mjs scripts/check-import-cycles.ts;node scripts/run-vitest.mjswith the focused selection; and the unchanged large-inventory case with--repeats 20.The prewarmed Testbox attempts finished before the slow local source freeze completed; the repository caps idle lifetime at 15 minutes. The supported one-shot route prepared source before allocation and completed successfully. AWS fallback was unavailable because of a coordinator failure and the shared fleet lease limit. Initial hosted CI passed all jobs except the database-worker inventory classification and the session-row golden serialization case. Both were attributable to this batch: the extracted transition helper needed its exact worker-only classification, and placement field construction needed the original JSON property order. Independent review passed both corrections. After a replacement Testbox remained queued for more than ten minutes, authorized reduced-priority local proof passed the SQLite ratchet, both zero-cycle checks, and three focused files (18 tests): the inventory ratchet, placement projector, and unchanged golden-row serialization test. Replacement hosted CI is pending on
1a6b4b71cb2d940cdff25ed19ee03dbeb007baba.Fixes found along the way
The large-inventory regression exposed 75,003 serialized missing-path probes over three recovery preflights. Worker-local synchronous metadata checks preserve every pass and error distinction while removing threadpool round trips. The original test and timeout are unchanged.
Complete size-sorted READ coverage (123 production files over 200 lines)
placement-turn-authority.tsprovider-lifecycle.tsnode-worker-tunnel.tsbootstrap.tsworker-turn-rpc.tsworker-turn-launcher.tsprepared-pool.tsinference.tslocal-workspace-projection.tsservice.tsplacement-dispatch-pending-results.tsworker-turn-execution.tsplacement-dispatch-startup.tsnode-launch-adapter.tscomputer-transport.tsworkspace-quiescence-scripts.tsworker-session-tool-executor.tsnode-workspace-transfer-service.tsworkspace-sync.tsenvironment-access.tssession-attachment-service.tsplacement-turn-claims-store.tsnode-worker-workspace-actions.tsplacement-turn-claim-events.tsnode-bootstrap-artifact-build.tslive-events.tsprovider-intent.tsworkspace-result-finalize.tsbundle.tsplacement-move-intent.tsplacement-dispatch-coordinator.tsworkspace-reconcile-recovery.tsinference-runtime.tsstore-projection.tsworker-turn-payload.tsplacement-turn-claims.tsplacement-dispatch.tsplacement-record.tsstore.tsworkspace-sync-scripts.tsworkspace-accepted-remote-script.tsworkspace-result-staging.tsnode-workspace-retain-coordinator.tsprovider-owner-lifecycle.tsplacement-dispatch-failure.tsprepared-environment-store.tsworkspace-sync-helpers.tsworkspace-actual-manifest.tssession-repository-checkpoints.tsnode-enrollment.tsrepository-project-admission.tsworker-turn-admission.tsplacement-reclaim.tsplacement-turn-claims.worker.tsplacement-dispatch-recovery.tsplacement-store.tscredential-broker.tsproject-preparation.tsplacement-row-codec.tsnode-desktop-carrier.tsplacement-workspace-result.tsinference-control-internal.tsdesktop-tunnel.tsprovider-node-provisioning.tsnode-worker-repository-preparation.tsplacement-move-service.tsworkspace-manifest.tsstore-transitions.tsworkspace-manifest-worker.tsinference-store.kernel.tssession-placement-lifecycle.tstranscript-commit.kernel.tsssh.tsworkspace-inventory-computation.runtime.tstranscript-commit-store.worker.tstranscript-commit.runtime.tsnode-workspace-upload-reader.tsplacement-workspace-journal.tsnode-worker-bundle-installer.tsplacement-projector.tsworkspace-accepted-sync.tsworkspace-mutation-lock-remote-script.tsstore.kernel.tsworkspace-sync-inventory.tsworker-turn-media.tsworkspace-reconcile-apply.tsplacement-session-tool-operations.kernel.tsservice-contract.tsskill-resource-transfer.tsprepared-pool-presence.tsplacement-worker-gate.tsworkspace-result-inventory.runtime.tslocal-workspace-template.tstunnel-contract.tsstore-row-codec.tsworker-gateway-tool-runtime.tsworker-turn-prompt.tsproject-setup-script.tsartifact-transfer-http.tsnode-workspace-transfer-http.tsportal-node-carrier.tsworker-turn-run-owner.tsplacement-session-tool-operations.tsworker-turn-attachments.tsworkspace-hash-memo.tssession-attachment-store.tsrepository-workspace-mutation.tsworkspace-reconcile-fs.tsservice-validation.tsartifact-transfer-service.tscomputer-service.tsplacement-transitions.worker.tsworkspace-reconcile-preflight.tsadmission.tsworker-session-tool-source.tsnode-worker-workspace-fallback.tsplacement-disk-space.tsstore-validation.tslocal-workspace-archive.tsstore.worker.tsworkspace-reconcile-core.tsworkspace-git-base.tsstore-mutations.tsAdditional changes in smaller production modules
placement-pending-failure.tsandplacement-teardown.tsshare terminal completion/compare-and-swap construction;provider-runtime-refresh.tsderives its callback type;terminal-environment-retention.tsaccepts the existing transaction database directly;tunnel-ssh-runner.tscarries one terminal fact; andworker-turn-failure.tsshares ordered cleanup while retaining authority checks before every operation. These modules are included in the production totals even though they are below the mandatory coverage-table size.The
node-worker-abort.tssubstitution was reverted because the generic abort race changed synchronous abort precedence. RPC type-sidecar inlining was reverted to satisfy the existing line-cap gate. The finalplacement-turn-authority.tsdiff contains only the listener-notification import/call; its recovery and validation guards match the pinned baseline.Focused performance repair evidence
The unchanged 25,001-deletion test timed out at 30 seconds on the clean PR baseline. The repair replaces 75,003 serialized asynchronous missing-path probes across three passes with synchronous nonthrowing lstat calls inside the existing Git worker; it does not cache filesystem facts across passes. The candidate passed 21 executions (
--repeats 20), totaling 311,503 ms (about 14.83 seconds per execution). Assertions and the timeout were unchanged. The final candidate also passed 21 executions on Linux in 11,720 ms total; the full focused selection, core typecheck, review, and both import-cycle checks passed as recorded above. The replacement hosted CI state is recorded in Evidence above.